diff --git a/src/ui/filter-text.ts b/src/ui/filter-text.ts index 8b13b76db31..a0c871f9fbc 100644 --- a/src/ui/filter-text.ts +++ b/src/ui/filter-text.ts @@ -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