Skip to content

Add HUD status-bar tooltips for Coins, Reputation, and Score in Main Street#466

Open
SorraTheOrc wants to merge 2 commits into
mainfrom
feature/CG-0MP2A0X0K007JRU4-hud-tooltips
Open

Add HUD status-bar tooltips for Coins, Reputation, and Score in Main Street#466
SorraTheOrc wants to merge 2 commits into
mainfrom
feature/CG-0MP2A0X0K007JRU4-hud-tooltips

Conversation

@SorraTheOrc
Copy link
Copy Markdown
Member

Summary

Add contextual tooltips to the top status bar (Coins, Reputation, Score) in Main Street to show expected income this turn, reputation influence on income, and next tier threshold.

Work item: CG-0MP2A0X0K007JRU4

Changes

  • New: example-games/main-street/scenes/MainStreetHudTooltips.ts — Tooltip content builder module with i18n key registry (HUD_TOOLTIP_I18N_KEYS, HUD_ARIA_I18N_KEYS), default localizable strings (HUD_TOOLTIP_STRINGS), and ARIA labels (HUD_ARIA_LABELS). Builder functions:

    • buildCoinsTooltip() — expected income (pre/post reputation multiplier) + calculation note
    • buildReputationTooltip() — current rep, active coin multiplier, effect explanation
    • buildScoreTooltip() — final-score estimate + next tier threshold or "All tiers unlocked"
    • findNextLockedTier() — utility to find next locked tier from campaign progress
  • Modified: example-games/main-street/scenes/MainStreetRenderer.ts — Added interactive tooltip zones to coinText, repText, and scoreText HUD elements via new attachHudTooltipZone() method. Desktop: hover shows/dismisses tooltip. Mobile: tap toggles tooltip. Respects TooltipManager / SettingsPanel.showTooltips toggle.

  • New: tests/main-street/hud-tooltips.test.ts — 18 unit tests covering tooltip content builders, findNextLockedTier, and i18n key consistency

  • Modified: tests/main-street/MainStreetScene.browser.test.ts — 1 browser integration test verifying tooltip zones are attached and tooltipManager.show() is called with correct content

How to test manually

  1. Start the game (npm run dev)
  2. Hover over the Coins value in the HUD → tooltip should show "Income This Turn", base income, multiplied income with multiplier, and a calculation note
  3. Hover over the Rep value → tooltip should show reputation value and coin multiplier
  4. Hover over the Score value → tooltip should show estimated score and next tier threshold
  5. On mobile/small viewport, tap the HUD values to toggle tooltips
  6. Toggle off tooltips in Settings panel → tooltips should not appear

Review focus

  • Tooltip content accuracy (computed income, reputation multiplier, score estimate, tier thresholds)
  • ARIA label accessibility attributes on interactive zones
  • i18n key registry completeness for future localization
  • Consistency with existing tooltip patterns (TooltipManager usage)

Map added 2 commits May 18, 2026 00:11
…n, and Score

- Add MainStreetHudTooltips.ts module with tooltip content builder functions
  for Coins (income breakdown), Reputation (multiplier details), and
  Score (estimate + next tier threshold).
- Include i18n key registry (HUD_TOOLTIP_I18N_KEYS, HUD_ARIA_I18N_KEYS)
  and default localizable strings (HUD_TOOLTIP_STRINGS).
- Add ARIA labels for each interactive HUD zone (HUD_ARIA_LABELS).
- Modify MainStreetRenderer.refreshHud() to attach interactive tooltip
  zones to coinText, repText, and scoreText via new
  attachHudTooltipZone() method.
- Desktop: pointerover shows tooltip; pointerout hides it.
- Mobile: tap toggles tooltip on/off.
- Tooltips respect TooltipManager / SettingsPanel.showTooltips toggle.
- Add unit tests (18 tests) for tooltip builders and i18n key consistency.
- Add browser integration test verifying tooltip zones are attached and
  tooltipManager.show() is called with correct content.
…tem instead of hardcoded English defaults

- Add src/core-engine/I18n.ts: minimal i18n module providing t(), registerLocale(),
  setLocale(), getLocale(), and resetI18n() for locale-aware string lookup
- Register HUD_TOOLTIP_STRINGS and HUD_ARIA_STRINGS as the 'en' locale bundle
  at module load time in MainStreetHudTooltips.ts
- Refactor all tooltip builder functions (buildCoinsTooltip, buildReputationTooltip,
  buildScoreTooltip) to use t(HUD_TOOLTIP_I18N_KEYS.xxx) instead of direct
  HUD_TOOLTIP_STRINGS.xxx lookups
- Refactor HUD_ARIA_LABELS to use getter properties that resolve through t(),
  making ARIA labels locale-aware
- Export I18n module from core-engine/index.ts barrel file
- Add comprehensive I18n tests (14 unit + integration tests)
- Add 4 new tests to hud-tooltips.test.ts verifying i18n resolution for tooltip
  strings, ARIA labels, and locale overrides

This addresses the audit gap: HUD_TOOLTIP_I18N_KEYS were defined but not consumed
by any lookup mechanism. The builders now use the i18n t() function which resolves
the active locale bundle with en fallback, satisfying the constraint to not ship
hardcoded English-only strings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant