Repository navigation
Show structure levels - #1305
Conversation
WalkthroughThe StructureIconsLayer was refactored to use PIXI containers instead of sprites, enabling support for displaying unit levels as bitmap text overlays. Helper methods were added to modularize update logic. A new bitmap font XML was introduced, TypeScript was updated to recognize XML imports, and the webpack config was changed to treat XML as a font asset. Changes
Sequence Diagram(s)sequenceDiagram
participant GameLoop
participant StructureIconsLayer
participant PIXI
participant BitmapFont
GameLoop->>StructureIconsLayer: tick()
StructureIconsLayer->>StructureIconsLayer: handleActiveUnit(unit)
StructureIconsLayer->>StructureIconsLayer: checkForOwnershipChange(render, unit)
StructureIconsLayer->>StructureIconsLayer: checkForLevelChange(render, unit)
alt New structure needed
StructureIconsLayer->>StructureIconsLayer: addNewStructure(unit)
StructureIconsLayer->>StructureIconsLayer: createPixiSprite(unit)
StructureIconsLayer->>PIXI: Create Container & Sprite
StructureIconsLayer->>BitmapFont: Add bitmap text if level > 1
end
StructureIconsLayer->>PIXI: Update container position/scale
StructureIconsLayer->>StructureIconsLayer: handleInactiveUnit(unit)
StructureIconsLayer->>PIXI: Remove container if needed
Possibly related PRs
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm error Exit handler never called! 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
resources/fonts/round_6x6.xml (1)
16-16: Minor: Standardize attribute spacingSome lines have extra space before the
widthattribute.- <char id="67" x="32" y="0" width="16" height="16" page="0" xadvance="14" xoffset="0" yoffset="0"/> + <char id="67" x="32" y="0" width="16" height="16" page="0" xadvance="14" xoffset="0" yoffset="0"/>Also applies to: 19-19, 22-22, 25-25, 28-28, 31-31, 34-34, 37-37, 40-40, 43-43, 46-46
src/client/graphics/layers/StructureIconsLayer.ts (1)
252-263: Consider showing all unit levels for consistencyCurrently only shows level for units > 1. Consider showing all levels for clarity.
- if (unit.level() > 1) { + if (unit.level() > 0) {Also consider making font size proportional to icon size:
- fontSize: 8, + fontSize: Math.max(8, Math.floor(ICON_SIZE / 3)),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
resources/fonts/round_6x6.pngis excluded by!**/*.png
📒 Files selected for processing (2)
resources/fonts/round_6x6.xml(1 hunks)src/client/graphics/layers/StructureIconsLayer.ts(6 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: andrewNiziolek
PR: openfrontio/OpenFrontIO#1007
File: resources/lang/de.json:115-115
Timestamp: 2025-06-02T14:27:37.609Z
Learning: For OpenFrontIO project: When localization keys are renamed in language JSON files, the maintainers separate technical changes from translation content updates. They wait for community translators to update the actual translation values rather than attempting to translate in the same PR. This allows technical changes to proceed while ensuring accurate translations from native speakers.
src/client/graphics/layers/StructureIconsLayer.ts (1)
Learnt from: devalnor
PR: openfrontio/OpenFrontIO#1248
File: src/client/graphics/layers/TerritoryInfoLayer.ts:20-20
Timestamp: 2025-06-22T21:51:14.990Z
Learning: In TerritoryInfoLayer.ts, the highlightedTerritory field uses both null and undefined intentionally: undefined represents initial state or inactive layer (Ctrl released), while null represents active layer with no territory being highlighted at cursor position. This distinction is important for proper state change detection.
🧬 Code Graph Analysis (1)
src/client/graphics/layers/StructureIconsLayer.ts (1)
src/core/game/GameView.ts (2)
UnitView(45-142)unit(531-533)
🔇 Additional comments (3)
src/client/graphics/layers/StructureIconsLayer.ts (3)
131-173: Clean refactoring with helper methodsGood separation of concerns. The helper methods improve readability and follow single responsibility principle.
264-270: Proper Container positioning and scalingGood implementation maintaining existing offset logic and preventing oversized icons at high zoom.
320-331: Well-structured helper methodClean encapsulation of structure addition logic. Properly initializes all properties.
|
Fixes #1300 |
## Description: REQUIRES THE LEVEL PR TO BE MERGED FIRST (as it is using the same layer) #1305 #### Icons only zoom level  #### Icons and sprite zoom level  ## 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 - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: Vivacious Box --------- Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
Description:
Show structure levels on the structureIconsLayer

Add new bitmap font (modified from this font: https://frostyfreeze.itch.io/pixel-bitmap-fonts-png-xml CC0 license)
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
Vivacious Box