From 9b4812f8b832df1fa000722307ff95c4a76a02fa Mon Sep 17 00:00:00 2001 From: Ryan <7389646+ryanbarlow97@users.noreply.github.com> Date: Tue, 31 Mar 2026 21:18:06 +0100 Subject: [PATCH] UI: Search Skin (#3552) ## Description: Sorta fixes a visual bug: image By adding parity with the flag modal: image (Parity image ) (code pretty much copy paste from flagmodal) ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: w.o.n --- resources/lang/en.json | 3 ++- src/client/TerritoryPatternsModal.ts | 33 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/resources/lang/en.json b/resources/lang/en.json index 58af1c01b..2c61a00be 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -949,7 +949,8 @@ "default": "Default" }, "select_skin": "Select Skin", - "selected": "selected" + "selected": "selected", + "search": "Search..." }, "cosmetics": { "artist_label": "Artist:" diff --git a/src/client/TerritoryPatternsModal.ts b/src/client/TerritoryPatternsModal.ts index 9d9c995ed..6702d05ef 100644 --- a/src/client/TerritoryPatternsModal.ts +++ b/src/client/TerritoryPatternsModal.ts @@ -22,6 +22,7 @@ export class TerritoryPatternsModal extends BaseModal { @state() private selectedPattern: PlayerPattern | null; @state() private selectedColor: string | null = null; + @state() private search = ""; private cosmetics: Cosmetics | null = null; private userSettings: UserSettings = new UserSettings(); @@ -67,6 +68,15 @@ export class TerritoryPatternsModal extends BaseModal { this.refresh(); } + private includedInSearch(name: string): boolean { + const displayName = name.replace(/_/g, " "); + return displayName.toLowerCase().includes(this.search.toLowerCase()); + } + + private handleSearch(event: Event) { + this.search = (event.target as HTMLInputElement).value; + } + private renderPatternGrid(): TemplateResult { const buttons: TemplateResult[] = []; const patterns: (Pattern | null)[] = [ @@ -74,6 +84,12 @@ export class TerritoryPatternsModal extends BaseModal { ...Object.values(this.cosmetics?.patterns ?? {}), ]; for (const pattern of patterns) { + if (pattern === null && this.search) { + continue; + } + if (pattern !== null && !this.includedInSearch(pattern.name)) { + continue; + } const colorPalettes = pattern ? [...(pattern.colorPalettes ?? []), null] : [null]; @@ -135,6 +151,19 @@ export class TerritoryPatternsModal extends BaseModal { ariaLabel: translateText("common.back"), rightContent: html``, })} + +
+ +