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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
<!--
Settings (the reference `SettingsMenu`): the visual style theme and the
UI language (client-only preferences), plus the special-unlock controls
(the reference `settingsClearUnlocked` / `settingsUnlockSpecials`
entries, which are game commands).
-->
<script lang="ts">
import type { GameSession } from '$lib/state/session';
import { availableLocales, locale, type Locale } from '$lib/i18n';
import { styleTheme, type StyleTheme } from '$lib/settings';
import { t } from '$lib/i18n';
import Menu from '../Menu.svelte';
import SpecialUnlocksMenu from './SpecialUnlocksMenu.svelte';
let {
session,
open = $bindable(true)
}: {
session: GameSession;
open?: boolean;
} = $props();
const player = session.player;
const gameState = session.state;
const THEMES: { id: StyleTheme; label: string }[] = [
{ id: 'frosthaven', label: 'Frosthaven' },
{ id: 'gloomhaven', label: 'Gloomhaven' },
{ id: 'original', label: 'Original' }
];
let unlocksOpen = $state(false);
</script>
<Menu open={open} title={t('menuSettings')}>
<div class="settingsrow">
<label for="theme">{t('menuSettings')}</label>
<select
id="theme"
class="search"
style="margin: 0; width: auto"
value={$styleTheme}
onchange={(e) => styleTheme.set(e.currentTarget.value as StyleTheme)}
>
{#each THEMES as th (th.id)}
<option value={th.id}>{th.label}</option>
{/each}
</select>
</div>
<div class="settingsrow">
<label for="locale">Language</label>
<select
id="locale"
class="search"
style="margin: 0; width: auto"
value={$locale}
onchange={(e) => locale.set(e.currentTarget.value as Locale)}
>
{#each availableLocales as l (l)}
<option value={l}>{l}</option>
{/each}
</select>
</div>
<div class="settingsrow settingsrow--btn">
<button
class="pill"
disabled={!$player || !($gameState?.unlockedClasses.length ?? 0)}
onclick={() => session.command('clearUnlockedClasses')}
>
{t('settingsClearUnlocked')}
</button>
</div>
<div class="settingsrow settingsrow--btn">
<button class="pill" onclick={() => (unlocksOpen = true)}>
{t('settingsUnlockSpecials')}
</button>
</div>
</Menu>
{#if unlocksOpen}
<SpecialUnlocksMenu {session} bind:open={unlocksOpen} />
{/if}
<style>
.settingsrow--btn {
justify-content: flex-start;
}
.pill {
padding: 6px 12px;
font-size: 13px;
border: none;
border-radius: 4px;
background: rgba(255, 255, 255, 0.12);
color: inherit;
cursor: pointer;
text-align: left;
}
.pill:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.25);
}
.pill:disabled {
opacity: 0.3;
cursor: default;
}
</style>
|