-
Notifications
You must be signed in to change notification settings - Fork 1k
Fixed playerPanel doesnt show flag | Added flag name on hover #3851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
3bd3487
450607f
037cc23
79a3dad
cc1b2b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -491,12 +491,17 @@ export class PlayerPanel extends LitElement implements Layer { | |
| `; | ||
| } | ||
|
|
||
| private renderIdentityRow(other: PlayerView, my: PlayerView) { | ||
| const flagCode = other.cosmetics.flag; | ||
| const country = | ||
| typeof flagCode === "string" | ||
| ? Countries.find((c) => c.code === flagCode) | ||
| : undefined; | ||
| private renderIdentityRow( | ||
| other: PlayerView, | ||
| my: PlayerView, | ||
| ) { | ||
| const activeFlagPath = other.cosmetics.flag | ||
| const flagCode = activeFlagPath?.match(/\/([^.]+)\./)?.[1]; | ||
|
|
||
| // Find the country based on that code | ||
| const country = flagCode | ||
| ? Countries.find((c) => c.code === flagCode.split("/")[1]) | ||
|
Comment on lines
+499
to
+503
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Find where cosmetics.flag is assigned or read to understand the path format
rg -n "cosmetics[.\[]" --type ts -A 2 -B 2 | grep -i flag | head -40
# Also check cosmetics.json for flag entry shapes
fd "cosmetics.json" --exec cat {}Repository: openfrontio/OpenFrontIO Length of output: 2640 🏁 Script executed: # Check how the flag is used after extraction in PlayerPanel.ts
rg -n "flagCode" src/client/graphics/layers/PlayerPanel.ts -A 5 -B 2
# Check if there's validation for custom URLs elsewhere
rg -n "cosmetics.flag" src/client/graphics/layers/ -A 3 -B 1 | head -50Repository: openfrontio/OpenFrontIO Length of output: 2042 🏁 Script executed: # Find Countries definition and what codes it contains
rg -n "Countries\s*=" src/client --type ts -A 5 | head -30
# See how 'country' variable is used after line 506 in PlayerPanel.ts
rg -n "const country = " src/client/graphics/layers/PlayerPanel.ts -A 10Repository: openfrontio/OpenFrontIO Length of output: 418 🏁 Script executed: # Find the Countries import in PlayerPanel.ts
rg -n "^import|^from|Countries" src/client/graphics/layers/PlayerPanel.ts | head -20
# Find Countries definition in the entire codebase
rg -n "const Countries|export.*Countries" src/client --type ts -B 2 -A 3Repository: openfrontio/OpenFrontIO Length of output: 939 🏁 Script executed: # Read the countries.json file to see code structure
cat resources/countries.json | head -50Repository: openfrontio/OpenFrontIO Length of output: 913 🏁 Script executed: # Check GameView.ts flagAssignment and asset generation
rg -n "flag:" src/core/game/GameView.ts -B 3 -A 3
# Check if assetUrl or asset hashing changes the path before reaching PlayerPanel
rg -n "assetUrl|flagAssignments" src/client/graphics/layers/PlayerPanel.ts -B 2 -A 2
# Check core/AssetUrls to see how flag paths are transformed
cat src/core/AssetUrls.ts | head -40Repository: openfrontio/OpenFrontIO Length of output: 2500 Flag code extraction breaks for hashed asset paths—improve regex to handle hash suffixes. The current regex The proposed regex Suggested refactor- const flagCode = activeFlagPath?.match(/\/([^.]+)\./)?.[1];
-
- // Find the country based on that code
- const country = flagCode
- ? Countries.find((c) => c.code === flagCode.split("/")[1])
- : flagCode;
+ // Extract the 2-letter code from paths like "/flags/us.svg" or "/_assets/flags/us-hash.svg"
+ const flagCode = activeFlagPath?.match(/([a-z]{2})(?:-[a-f0-9]+)?\.svg$/)?.[1];
+ const country = flagCode
+ ? Countries.find((c) => c.code === flagCode)
+ : undefined;🤖 Prompt for AI Agents
Comment on lines
+502
to
+503
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need to do this lookup? Can we do what NameLayer.ts does? |
||
| : flagCode; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| const chip = | ||
| other.type() === PlayerType.Human | ||
|
|
@@ -505,10 +510,11 @@ export class PlayerPanel extends LitElement implements Layer { | |
|
|
||
| return html` | ||
| <div class="flex items-center gap-2.5 flex-wrap"> | ||
| ${country && typeof flagCode === "string" | ||
| ${activeFlagPath | ||
| ? html`<img | ||
| src=${assetUrl(`flags/${encodeURIComponent(flagCode)}.svg`)} | ||
| alt=${country?.name ?? "Flag"} | ||
| src=${activeFlagPath} | ||
| title=${typeof country !== "string" ? country?.name : country} | ||
| alt=${typeof country !== "string" ? country?.name : country} | ||
| class="h-10 w-10 rounded-full object-cover" | ||
| @error=${(e: Event) => { | ||
| (e.target as HTMLImageElement).style.display = "none"; | ||
|
|
@@ -946,7 +952,9 @@ export class PlayerPanel extends LitElement implements Layer { | |
| class="p-6 flex flex-col gap-2 font-sans antialiased text-[14.5px] leading-relaxed" | ||
| > | ||
| <!-- Identity (flag, name, type, traitor, relation) --> | ||
| <div class="mb-1">${this.renderIdentityRow(other, my)}</div> | ||
| <div class="mb-1"> | ||
| ${this.renderIdentityRow(other, my)} | ||
| </div> | ||
|
|
||
| ${this.sendTarget | ||
| ? html` | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon on
activeFlagPathdeclaration is still breaking Prettier CI.Line 498 has no semicolon:
Run
npx prettier --write src/client/graphics/layers/PlayerPanel.tsto confirm all remaining formatting issues are cleared before merging.📝 Committable suggestion
🤖 Prompt for AI Agents