blob: f0aca7aae2fa9f1918d02bd3187e3482627ecb38 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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}
|