From 49d8874433fff884168832cb0f50a5cdc21d602d Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Sun, 6 Apr 2025 17:58:24 -0500 Subject: [PATCH] Remove unneeded fields from src/ui/filter-text.ts --- src/ui/filter-text.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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