-
Notifications
You must be signed in to change notification settings - Fork 714
Update game timer UI #2577
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?
Update game timer UI #2577
Conversation
WalkthroughThis PR refactors the top-right in-game UI: it changes the sidebar and replay controls layout to stack vertically, replaces replay icon variants with a single fast-forward icon, adds a padded HH:MM:SS/MM:SS timer formatter with conditional red coloring when <60s, and adds a fastest speed button plus styling changes to the replay panel. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (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. Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/client/graphics/layers/GameRightSidebar.ts (2)
75-87: Consider extracting thepadhelper to avoid recreation.The timer formatting logic correctly produces HH:MM:SS or MM:SS based on duration, matching the PR objectives. However, the
padfunction is redefined on every call.Extract it to a class-level private method or a module-level constant:
+ private pad = (n: number) => (n < 10 ? `0${n}` : n); + private secondsToHms = (d: number): string => { - const pad = (n: number) => (n < 10 ? `0${n}` : n); - const h = Math.floor(d / 3600); const m = Math.floor((d % 3600) / 60); const s = Math.floor((d % 3600) % 60); if (h !== 0) { - return `${pad(h)}:${pad(m)}:${pad(s)}`; + return `${this.pad(h)}:${this.pad(m)}:${this.pad(s)}`; } else { - return `${pad(m)}:${pad(s)}`; + return `${this.pad(m)}:${this.pad(s)}`; } };
122-126: Consider adding a non-color indicator for timer urgency.The timer turns red when below 60 seconds, which is helpful for most users. However, colorblind users may not perceive this change. Consider adding an icon (e.g., warning symbol) or text prefix when the timer is critical.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
resources/images/FastForwardIconSolidWhite.svgis excluded by!**/*.svg
📒 Files selected for processing (3)
src/client/graphics/layers/GameRightSidebar.ts(3 hunks)src/client/graphics/layers/ReplayPanel.ts(2 hunks)src/client/index.html(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-06-09T02:20:43.637Z
Learnt from: VariableVince
Repo: openfrontio/OpenFrontIO PR: 1110
File: src/client/Main.ts:293-295
Timestamp: 2025-06-09T02:20:43.637Z
Learning: In src/client/Main.ts, during game start in the handleJoinLobby callback, UI elements are hidden using direct DOM manipulation with classList.add("hidden") for consistency. This includes modals, buttons, and error divs. The codebase follows this pattern rather than using component APIs for hiding elements during game transitions.
Applied to files:
src/client/graphics/layers/ReplayPanel.tssrc/client/graphics/layers/GameRightSidebar.tssrc/client/index.html
📚 Learning: 2025-10-18T11:00:57.142Z
Learnt from: NewYearNewPhil
Repo: openfrontio/OpenFrontIO PR: 2230
File: src/client/graphics/GameRenderer.ts:269-277
Timestamp: 2025-10-18T11:00:57.142Z
Learning: In src/client/graphics/GameRenderer.ts, the GameRecapCapture implementation does not use setCaptureRenderEnabled on layers. Instead, it uses RecapCaptureSurface.capture() to render capture layers (TerrainLayer, TerritoryLayer, RailroadLayer, StructureIconsLayer, UnitLayer) directly to an off-screen canvas without requiring layer-level capture mode methods.
Applied to files:
src/client/graphics/layers/ReplayPanel.tssrc/client/graphics/layers/GameRightSidebar.ts
📚 Learning: 2025-08-12T00:31:50.144Z
Learnt from: scottanderson
Repo: openfrontio/OpenFrontIO PR: 1752
File: src/core/game/Game.ts:750-752
Timestamp: 2025-08-12T00:31:50.144Z
Learning: In the OpenFrontIO codebase, changes to the PlayerInteraction interface (like adding canDonateGold and canDonateTroops flags) do not require corresponding updates to src/core/Schemas.ts or server serialization code.
Applied to files:
src/client/graphics/layers/GameRightSidebar.ts
🧬 Code graph analysis (1)
src/client/graphics/layers/ReplayPanel.ts (2)
src/client/LangSelector.ts (1)
translateText(258-278)src/core/configuration/PastelTheme.ts (1)
backgroundColor(180-182)
🔇 Additional comments (7)
src/client/graphics/layers/ReplayPanel.ts (3)
69-76: LGTM on styling updates.The container and label styling changes improve visual consistency and spacing.
77-85: Clean grid expansion to support 4 speed options.The layout change from 2 to 4 columns accommodates the new fastest speed button effectively.
91-101: Good refactor for active state styling.Extracting the
backgroundColorvariable improves readability. The approach is clean and works well for the current use case.src/client/index.html (1)
401-406: Nice layout consolidation for the top-right UI.The vertical stacking of
game-right-sidebarandreplay-panelwithin a single fixed container achieves the PR objective of making the UI more compact and providing more game space.src/client/graphics/layers/GameRightSidebar.ts (3)
4-4: LGTM on the new icon import.The
FastForwardIconSolidimport aligns with the PR objective to update the fast-forward icon representation.
128-149: Clean layout reorganization with clear separation.The refactored layout with separate sections for time, controls, settings, and exit is easy to understand and maintain. The inline comments are helpful.
152-173: LGTM on replay controls update.The replay button now uses the new
FastForwardIconSolidicon, and the button wrappers are consistent with proper cursor styling and event handling.
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.
Do you know where this icon came from or what license it's under? we may need to add attribution in the CREDITS.md
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.
I made it from my own hand. How do I give open front ownership of this asset?
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.
Great! the asset will be licensed as CC-SA
evanpelle
left a comment
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.
Thanks!
|
can you run |
Description:
Before:
After:
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
rovi.