summaryrefslogtreecommitdiff
path: root/web/src/lib/ui/MainMenu.svelte
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2026-11-15 13:45:21 +0100
committerJoel Klinghed <the_jk@spawned.biz>2026-11-15 13:45:21 +0100
commit4f50f2008f4d7c2a635f7f26861fcfc7f7504423 (patch)
tree94e6286e7e22e0467a61b99c18b9ab582fbbe656 /web/src/lib/ui/MainMenu.svelte
parent3ebbdf6ffa16f751c82e3bd2e74294f4fe843155 (diff)
Phase 3: web UI core loop (M3)
Browser game UI on top of the Phase 2 protocol: server-driven, input-only clients with per-connection secret visibility. Web (Svelte 5): - Layout: TopBar (element buttons with use/imbue long-press, title, menu), MainList (character/monster/note rows), BottomBar (draw/next-round + level widget with T/H/X/C values). - CharacterRow with the secret initiative input: own value editable, server-masked values render as ??, revealed on draw. - Per-figure StatusMenu: health/max/xp/bless/curse/empower/enfeeble steppers, condition grid, turn-done — all server commands, player-gated. - Menu dialogs: select scenario, add section, add/remove character, set level/difficulty/solo/auto-level, add/remove monster, note row, action log with rollback, settings (style theme + language). - Player vs spectator UI gated on the live seat table; reconnecting banner, error toasts, connection status plumbing. - i18n: English ported, locale store with localStorage persistence. - Design tokens + the three style themes (frosthaven/gloomhaven/original). - Unit tests: level values, game logic (elements/conditions/art/stats), i18n, the reactive player store, the data client (sections keyed by scenario number), plus the existing connection/protocol/state tests. Server: - Serve the engine's data JSON at /data/ and artwork at /images/ so the client menus and rows read the same assets the engine loads.
Diffstat (limited to 'web/src/lib/ui/MainMenu.svelte')
-rw-r--r--web/src/lib/ui/MainMenu.svelte89
1 files changed, 89 insertions, 0 deletions
diff --git a/web/src/lib/ui/MainMenu.svelte b/web/src/lib/ui/MainMenu.svelte
new file mode 100644
index 0000000..f0aca7a
--- /dev/null
+++ b/web/src/lib/ui/MainMenu.svelte
@@ -0,0 +1,89 @@
+<!--
+ The slide-out main menu (the reference app's menu drawer): undo/redo,
+ action log, scenario setup, character/monster management, and settings.
+ Every entry either acts directly (undo/redo) or opens one of the menu
+ dialogs owned by the App.
+-->
+<script lang="ts">
+ import type { GameSession } from '$lib/state/session';
+ import { t } from '$lib/i18n';
+
+ export type MenuName =
+ | 'scenario'
+ | 'section'
+ | 'addChar'
+ | 'removeChar'
+ | 'setLevel'
+ | 'addMon'
+ | 'removeMon'
+ | 'noteRow'
+ | 'actionLog'
+ | 'settings';
+
+ let {
+ session,
+ open = $bindable(false),
+ onOpenMenu
+ }: {
+ session: GameSession;
+ open?: boolean;
+ onOpenMenu: (menu: MenuName) => void;
+ } = $props();
+
+ const gameState = session.state;
+ const index = session.index;
+
+ function pick(menu: MenuName) {
+ open = false;
+ onOpenMenu(menu);
+ }
+</script>
+
+{#if open}
+ <!-- Click-to-close scrim (Escape also closes; not a real control). -->
+ <div
+ class="scrim"
+ aria-hidden="true"
+ style="position: fixed; inset: 0; z-index: 39; background: #00000066"
+ onclick={() => (open = false)}
+ ></div>
+ <nav class="drawer drawer--open" aria-label="Main menu">
+ <div class="drawer__header"></div>
+ <div style="padding: 8px 0">
+ <div class="statrow" style="padding: 4px 16px">
+ <span class="statrow__label" style="opacity: 0.8; font-size: 13px">
+ {t('currentCampaign', { campaign: $gameState?.currentCampaign ?? '—' })}
+ </span>
+ </div>
+ </div>
+
+ <button class="drawer__item" disabled={$index <= 0} onclick={() => { open = false; session.undo(); }}>
+ {t('undo')}
+ </button>
+ <button class="drawer__item" onclick={() => { open = false; session.redo(); }}>
+ {t('redo')}
+ </button>
+ <button class="drawer__item" onclick={() => pick('actionLog')}>{t('menuActionLog')}</button>
+
+ <hr class="drawer__divider" />
+
+ <button class="drawer__item" onclick={() => pick('scenario')}>{t('menuSetScenario')}</button>
+ <button class="drawer__item" onclick={() => pick('section')}>{t('menuAddSection')}</button>
+
+ <hr class="drawer__divider" />
+
+ <button class="drawer__item" onclick={() => pick('addChar')}>{t('menuAddCharacter')}</button>
+ <button class="drawer__item" onclick={() => pick('removeChar')}>{t('menuRemoveCharacters')}</button>
+ <button class="drawer__item" onclick={() => pick('setLevel')}>{t('menuSetLevel')}</button>
+
+ <hr class="drawer__divider" />
+
+ <button class="drawer__item" onclick={() => pick('addMon')}>{t('menuAddMonsters')}</button>
+ <button class="drawer__item" onclick={() => pick('removeMon')}>{t('menuRemoveMonsters')}</button>
+ <button class="drawer__item" onclick={() => pick('noteRow')}>{t('menuAddNoteRow')}</button>
+
+ <hr class="drawer__divider" />
+
+ <button class="drawer__item" onclick={() => pick('settings')}>{t('menuSettings')}</button>
+ </nav>
+{/if}