Remove unneeded fields from src/ui/filter-text.ts

This commit is contained in:
Sirz Benjie 2025-04-06 17:58:24 -05:00
parent 18c4dddcf0
commit 9660c3e463
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E
1 changed files with 11 additions and 4 deletions

View File

@ -20,7 +20,6 @@ export class FilterText extends Phaser.GameObjects.Container {
private window: Phaser.GameObjects.NineSlice;
private labels: Phaser.GameObjects.Text[] = [];
private selections: Phaser.GameObjects.Text[] = [];
private selectionStrings: string[] = [];
private rows: FilterTextRow[] = [];
public cursorObj: Phaser.GameObjects.Image;
public numFilters = 0;
@ -112,8 +111,6 @@ export class FilterText extends Phaser.GameObjects.Container {
this.selections.push(filterTypesSelection);
this.add(filterTypesSelection);
this.selectionStrings.push("");
this.calcFilterPositions();
this.numFilters++;
@ -122,7 +119,6 @@ export class FilterText extends Phaser.GameObjects.Container {
resetSelection(index: number): void {
this.selections[index].setText(this.defaultText);
this.selectionStrings[index] = "";
this.onChange();
}
@ -204,6 +200,17 @@ export class FilterText extends Phaser.GameObjects.Container {
return this.selections[row].getWrappedText()[0];
}
/**
* Forcibly set the selection text for a specific filter row and then call the `onChange` function
*
* @param row the filter row to set the text for
* @param value the text to set for the filter row
*/
setValue(row: FilterTextRow, value: string) {
this.selections[row].setText(value);
this.onChange();
}
/**
* Find the nearest filter to the provided container on the y-axis
* @param container the StarterContainer to compare position against