summaryrefslogtreecommitdiff
path: root/web/src/lib/ui/menus
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/lib/ui/menus')
-rw-r--r--web/src/lib/ui/menus/AddNoteRowMenu.svelte113
-rw-r--r--web/src/lib/ui/menus/AddSectionMenu.svelte103
-rw-r--r--web/src/lib/ui/menus/AddSummonMenu.svelte261
-rw-r--r--web/src/lib/ui/menus/FigureNoteMenu.svelte83
-rw-r--r--web/src/lib/ui/menus/NoteRowMenu.svelte270
-rw-r--r--web/src/lib/ui/menus/SettingsMenu.svelte63
-rw-r--r--web/src/lib/ui/menus/SpecialUnlocksMenu.svelte83
7 files changed, 841 insertions, 135 deletions
diff --git a/web/src/lib/ui/menus/AddNoteRowMenu.svelte b/web/src/lib/ui/menus/AddNoteRowMenu.svelte
deleted file mode 100644
index 5bb14a0..0000000
--- a/web/src/lib/ui/menus/AddNoteRowMenu.svelte
+++ /dev/null
@@ -1,113 +0,0 @@
-<!--
- Add Note Row (the reference `NoteRowAddMenu`, Phase 3 form): a colour
- picker, free text, and an optional link to a figure. Sending
- `addNoteRow` appends the row (beneath its linked figure, if any).
--->
-<script lang="ts">
- import type { GameSession } from '$lib/state/session';
- import { isCharacter, isMonster } from '$lib/protocol/types';
- import { t } from '$lib/i18n';
- import Menu from '../Menu.svelte';
-
- let {
- session,
- open = $bindable(true)
- }: {
- session: GameSession;
- open?: boolean;
- } = $props();
-
- const gameState = session.state;
- const player = session.player;
-
- const COLORS = [
- 0xffb58900,
- 0xff1565c0,
- 0xff2e7d32,
- 0xffc2185b,
- 0xffffb300,
- 0xff5e35b1
- ];
-
- let color = $state(COLORS[0]);
- let text = $state('');
- let linkedId = $state('');
-
- $effect(() => {
- if (!open) return;
- color = COLORS[0];
- text = '';
- linkedId = '';
- });
-
- const figures = $derived.by(() =>
- ($gameState?.currentList ?? [])
- .filter((i) => isCharacter(i) || isMonster(i))
- .map((i) => ({
- id: i.id,
- name: isCharacter(i) ? i.characterState.display : i.id
- }))
- );
-
- function colorCss(c: number): string {
- return `#${c.toString(16).padStart(8, '0').slice(2)}`;
- }
-
- function add() {
- if (!$player) return;
- const id =
- typeof crypto !== 'undefined' && 'randomUUID' in crypto
- ? crypto.randomUUID()
- : `note-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
- session.command('addNoteRow', {
- noteRow: {
- id,
- text: text.trim(),
- color,
- linkedId,
- standeeNr: 0
- }
- });
- open = false;
- }
-</script>
-
-<Menu open={open} title={t('menuAddNoteRow')}>
- <div style="display: flex; gap: 6px; padding: 8px 4px">
- {#each COLORS as c (c)}
- <button
- aria-label="note colour"
- style="width: 32px; height: 32px; border-radius: 6px; background: {colorCss(c)}; outline: {c === color ? '3px solid #fff' : 'none'}"
- onclick={() => (color = c)}
- ></button>
- {/each}
- </div>
-
- <input class="search" placeholder={t('noteRowHint')} bind:value={text} />
-
- <div class="statrow" style="align-items: center">
- <span class="statrow__label" style="font-size: 13px">{t('noteRowWholeGroup')}</span>
- <select
- class="search"
- style="margin: 0; width: auto"
- value={linkedId}
- onchange={(e) => (linkedId = e.currentTarget.value)}
- >
- <option value="">{t('noteRowAll')}</option>
- {#each figures as f (f.id)}
- <option value={f.id}>{f.name}</option>
- {/each}
- </select>
- </div>
-
- <div style="display: flex; justify-content: flex-end; padding: 8px 4px">
- <button
- class="stepbtn"
- style="border-radius: 6px"
- disabled={!$player || text.trim() === ''}
- onclick={add}
- >
- {t('noteRowAddFromMenu')}
- </button>
- </div>
-</Menu>
diff --git a/web/src/lib/ui/menus/AddSectionMenu.svelte b/web/src/lib/ui/menus/AddSectionMenu.svelte
index 991b6a5..8fdef55 100644
--- a/web/src/lib/ui/menus/AddSectionMenu.svelte
+++ b/web/src/lib/ui/menus/AddSectionMenu.svelte
@@ -2,6 +2,15 @@
Add Section (the reference `AddSectionMenu`): lists the addable sections
of the current scenario (its rooms after the start room, minus spawns)
and adds one via `setScenario { scenario, section: true }`.
+
+ Reference behaviors ported here:
+ - case-insensitive search filter over the section names;
+ - ordering by the section number (`findNrFromScenarioName`) with a
+ string-compare fallback;
+ - sections already in the scenario are greyed out and tapping them is a
+ no-op;
+ - the search label is "Add Random Dungeon Card" when the scenario is
+ "#Random Dungeon".
-->
<script lang="ts">
import type { GameSession } from '$lib/state/session';
@@ -21,11 +30,25 @@
const player = session.player;
let sections = $state<string[] | null>(null);
+ let search = $state('');
+
+ /** Port of the reference `GameMethods.findNrFromScenarioName`: drop the
+ * first character, read until a space or `.`, and parse an int. Null when
+ * the remainder is not a number. */
+ function sectionNr(name: string): number | null {
+ const rest = name.slice(1);
+ const end = rest.search(/[ .]/);
+ const nr = end === -1 ? rest : rest.slice(0, end);
+ if (nr === '') return null;
+ const n = Number(nr);
+ return Number.isInteger(n) ? n : null;
+ }
$effect(() => {
if (!open) return;
const s = $gameState?.scenario ?? '';
const c = $gameState?.currentCampaign ?? '';
+ search = '';
if (!s || !c) {
sections = [];
return;
@@ -45,35 +68,77 @@
};
});
+ const shown = $derived.by(() => {
+ const all = sections ?? [];
+ const q = search.trim().toLowerCase();
+ const filtered = q
+ ? all.filter((n) => n.toLowerCase().includes(q))
+ : all;
+ return [...filtered].sort((a, b) => {
+ const aNr = sectionNr(a);
+ const bNr = sectionNr(b);
+ if (aNr != null && bNr != null) return aNr - bNr;
+ return a < b ? -1 : a > b ? 1 : 0;
+ });
+ });
+
+ const added = $derived($gameState?.scenarioSectionsAdded ?? []);
+
+ function isAdded(section: string): boolean {
+ return added.includes(section);
+ }
+
function pick(section: string) {
- if (!$player) return;
+ if (!$player || isAdded(section)) return;
// For sections the wire `scenario` field carries the *section name*;
// the server matches it against the current scenario's sections.
session.command('setScenario', { scenario: section, section: true });
open = false;
}
+
+ /** The reference relabels the search field on the random dungeon. */
+ const searchLabel = $derived(
+ $gameState?.scenario === '#Random Dungeon'
+ ? t('menuAddRandomDungeonCard')
+ : t('menuAddSection')
+ );
</script>
<Menu open={open} title={t('menuAddSection')}>
{#if !$gameState?.scenario}
- <p style="padding: 12px; opacity: 0.7">{t('web:noScenario')}</p>
- {:else if sections === null}
- <p style="padding: 12px; opacity: 0.7">{t('connecting')}</p>
- {:else if sections.length === 0}
- <p style="padding: 12px; opacity: 0.7">{t('noResultsFound')}</p>
+ <p class="empty">{t('web:noScenario')}</p>
{:else}
- <ul class="menulist">
- {#each sections as section (section)}
- <li>
- <button
- class="menulist__item"
- disabled={!$player}
- onclick={() => pick(section)}
- >
- {section}
- </button>
- </li>
- {/each}
- </ul>
+ <input class="search" placeholder={searchLabel} bind:value={search} />
+ {#if sections === null}
+ <p class="empty">{t('connecting')}</p>
+ {:else if shown.length === 0}
+ <p class="empty">{t('noResultsFound')}</p>
+ {:else}
+ <ul class="menulist">
+ {#each shown as section (section)}
+ <li>
+ <button
+ class="menulist__item"
+ class:menulist__item--added={isAdded(section)}
+ disabled={!$player || isAdded(section)}
+ onclick={() => pick(section)}
+ >
+ {section}
+ </button>
+ </li>
+ {/each}
+ </ul>
+ {/if}
{/if}
</Menu>
+
+<style>
+ .empty {
+ padding: 12px;
+ opacity: 0.7;
+ }
+ /* The reference greys added sections (Colors.blueGrey on a light theme). */
+ .menulist__item--added {
+ color: #90a4ae;
+ }
+</style>
diff --git a/web/src/lib/ui/menus/AddSummonMenu.svelte b/web/src/lib/ui/menus/AddSummonMenu.svelte
new file mode 100644
index 0000000..a60cb42
--- /dev/null
+++ b/web/src/lib/ui/menus/AddSummonMenu.svelte
@@ -0,0 +1,261 @@
+<!--
+ Add Summon (the reference `AddSummonMenu`): choose a standee colour and
+ number, then pick from the character's class summons (filtered by level
+ and standee cap) or the generic item summons. Adding sends `addStandee`
+ with `type: 3` (summon) and `addAsSummon: true`.
+-->
+<script lang="ts">
+ import type { GameSession } from '$lib/state/session';
+ import type { CharacterItem } from '$lib/protocol/types';
+ import { gameData, type SummonModel } from '$lib/data/gameData';
+ import { summonImage } from '$lib/game/art';
+ import Menu from '../Menu.svelte';
+
+ const COLORS = ['blue', 'green', 'yellow', 'orange', 'white', 'purple', 'pink', 'red'];
+ const MIN_STANDEES_FOR_NR = 2;
+ const NUMBERS = [1, 2, 3, 4, 5, 6, 7, 8];
+
+ let {
+ session,
+ character,
+ open = $bindable(true)
+ }: {
+ session: GameSession;
+ character: CharacterItem;
+ open?: boolean;
+ } = $props();
+
+ const player = session.player;
+ const gameState = session.state;
+
+ let chosenGfx = $state('blue');
+ let chosenNr = $state(1);
+
+ // The class's summonable figures (the reference filters by level and the
+ // number of standees already out; item summons are always listed).
+ let classSummons = $state<SummonModel[] | null>(null);
+ let itemSummons = $state<SummonModel[] | null>(null);
+
+ $effect(() => {
+ if (!open) return;
+ let alive = true;
+ classSummons = null;
+ itemSummons = null;
+ gameData
+ .loadCampaign(character.edition)
+ .then((c) => {
+ const cls = c.classes.find(
+ (x) => x.name === character.characterClass || x.id === character.characterClass
+ );
+ if (!alive || !cls) return;
+ const level = character.characterState.level;
+ classSummons = cls.summons
+ .filter((s) => s.level <= level)
+ .filter((s) => {
+ const out = character.characterState.summonList.filter(
+ (x) => x.name === s.name
+ ).length;
+ return out < s.standees;
+ });
+ })
+ .catch(() => {});
+ gameData
+ .summons()
+ .then((list) => {
+ if (alive) itemSummons = list;
+ })
+ .catch(() => {});
+ return () => {
+ alive = false;
+ };
+ });
+
+ /** The entries to list (class summons first, then item summons). */
+ const entries = $derived.by(() => {
+ const out: SummonModel[] = [];
+ if (classSummons) out.push(...classSummons);
+ if (itemSummons) out.push(...itemSummons);
+ return out;
+ });
+
+ function entryGfx(model: SummonModel): string {
+ return model.gfx || chosenGfx;
+ }
+
+ /** The standee number shown for a model (hidden for fixed-art, single-standee). */
+ function entryNr(model: SummonModel): number {
+ if (model.gfx && model.standees < MIN_STANDEES_FOR_NR) return 0;
+ return chosenNr;
+ }
+
+ function add(model: SummonModel) {
+ if (!$player) return;
+ const gfx = entryGfx(model);
+ const nr = entryNr(model);
+ session.command('addStandee', {
+ nr,
+ summon: {
+ standeeNr: nr,
+ name: model.name,
+ health: model.health,
+ move: model.move,
+ attack: model.attack,
+ range: model.range,
+ gfx
+ },
+ ownerId: character.id,
+ type: 3,
+ addAsSummon: true
+ });
+ open = false;
+ }
+</script>
+
+<Menu {open} title="Add Summon">
+ <div class="swatches" role="radiogroup" aria-label="standee colour">
+ {#each COLORS as c (c)}
+ <button
+ class="swatch"
+ class:swatch--selected={c === chosenGfx}
+ disabled={!$player}
+ aria-label={c}
+ onclick={() => (chosenGfx = c)}
+ >
+ <img src={summonImage(c)} alt="" />
+ </button>
+ {/each}
+ </div>
+
+ <div class="numbers" role="radiogroup" aria-label="standee number">
+ {#each NUMBERS as n (n)}
+ <button
+ class="numbtn"
+ class:numbtn--selected={n === chosenNr}
+ disabled={!$player}
+ onclick={() => (chosenNr = n)}
+ >
+ {n}
+ </button>
+ {/each}
+ </div>
+
+ {#if $gameState}
+ <ul class="summonlist">
+ {#each entries as model (model.name + model.gfx)}
+ <li>
+ <button
+ class="summonlist__item"
+ disabled={!$player}
+ onclick={() => add(model)}
+ >
+ <span class="summonlist__art">
+ <img src={summonImage(entryGfx(model))} alt="" />
+ {#if entryNr(model) > 0}
+ <span class="summonlist__nr">{entryNr(model)}</span>
+ {/if}
+ </span>
+ <span class="summonlist__name">{model.name}</span>
+ </button>
+ </li>
+ {/each}
+ </ul>
+ {/if}
+</Menu>
+
+<style>
+ .swatches {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 6px;
+ margin-bottom: 10px;
+ justify-content: center;
+ }
+ .swatch {
+ width: 40px;
+ height: 40px;
+ padding: 3px;
+ border-radius: 4px;
+ border: 1px solid rgba(255, 255, 255, 0.25);
+ background: rgba(0, 0, 0, 0.3);
+ cursor: pointer;
+ }
+ .swatch--selected {
+ border: 2px solid #7ec8ff;
+ }
+ .swatch img {
+ width: 100%;
+ height: 100%;
+ object-fit: contain;
+ }
+ .numbers {
+ display: grid;
+ grid-template-columns: repeat(4, 1fr);
+ gap: 6px;
+ margin-bottom: 12px;
+ }
+ .numbtn {
+ height: 32px;
+ font-size: 13px;
+ border: 1px solid rgba(255, 255, 255, 0.25);
+ border-radius: 4px;
+ background: rgba(0, 0, 0, 0.3);
+ color: inherit;
+ cursor: pointer;
+ }
+ .numbtn--selected {
+ border: 2px solid #7ec8ff;
+ font-weight: 700;
+ }
+ .summonlist {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ max-height: 40vh;
+ overflow-y: auto;
+ }
+ .summonlist__item {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ width: 100%;
+ padding: 6px 8px;
+ border: none;
+ border-radius: 4px;
+ background: none;
+ color: inherit;
+ font-size: 13px;
+ text-align: left;
+ cursor: pointer;
+ }
+ .summonlist__item:hover {
+ background: rgba(255, 255, 255, 0.1);
+ }
+ .summonlist__art {
+ position: relative;
+ width: 32px;
+ height: 32px;
+ flex: 0 0 auto;
+ }
+ .summonlist__art img {
+ width: 100%;
+ height: 100%;
+ object-fit: contain;
+ }
+ .summonlist__nr {
+ position: absolute;
+ inset: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 14px;
+ font-weight: 700;
+ color: #fff;
+ text-shadow: 0 0 3px #000, 0 1px 2px #000;
+ }
+ .summonlist__name {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+</style>
diff --git a/web/src/lib/ui/menus/FigureNoteMenu.svelte b/web/src/lib/ui/menus/FigureNoteMenu.svelte
new file mode 100644
index 0000000..0f79578
--- /dev/null
+++ b/web/src/lib/ui/menus/FigureNoteMenu.svelte
@@ -0,0 +1,83 @@
+<!--
+ A figure's quick note (the reference `SetFigureNoteMenu`): the free-form
+ note shown inline on a figure's row (character or monster). The note is
+ committed (via `setFigureNote`) when the field loses focus or the dialog
+ is dismissed, and only when the text actually changed, so an unedited
+ open/close doesn't pollute the undo history.
+-->
+<script lang="ts">
+ import type { GameSession } from '$lib/state/session';
+ import Menu from '../Menu.svelte';
+
+ let {
+ session,
+ figureId,
+ initial,
+ open = $bindable(true)
+ }: {
+ session: GameSession;
+ figureId: string;
+ initial: string;
+ open?: boolean;
+ } = $props();
+
+ const player = session.player;
+
+ let text = $state(initial);
+ let lastCommitted = $state(initial);
+
+ function commit() {
+ const trimmed = text.trim();
+ if (trimmed !== lastCommitted) {
+ lastCommitted = trimmed;
+ if ($player)
+ session.command('setFigureNote', { note: trimmed, figureId });
+ }
+ }
+
+ function close() {
+ commit();
+ open = false;
+ }
+</script>
+
+<Menu {open}>
+ <textarea
+ class="search search--area"
+ rows={3}
+ maxlength={140}
+ placeholder="…"
+ bind:value={text}
+ readonly={!$player}
+ onblur={commit}
+ ></textarea>
+ {#if $player}
+ <div class="actions">
+ <button class="pill" onclick={close}>Save</button>
+ </div>
+ {/if}
+</Menu>
+
+<style>
+ textarea.search--area {
+ resize: vertical;
+ min-height: 64px;
+ }
+ .actions {
+ display: flex;
+ justify-content: flex-end;
+ margin-top: 10px;
+ }
+ .pill {
+ padding: 6px 14px;
+ font-size: 13px;
+ border: none;
+ border-radius: 4px;
+ background: rgba(255, 255, 255, 0.12);
+ color: inherit;
+ cursor: pointer;
+ }
+ .pill:hover {
+ background: rgba(255, 255, 255, 0.25);
+ }
+</style>
diff --git a/web/src/lib/ui/menus/NoteRowMenu.svelte b/web/src/lib/ui/menus/NoteRowMenu.svelte
new file mode 100644
index 0000000..78f25f9
--- /dev/null
+++ b/web/src/lib/ui/menus/NoteRowMenu.svelte
@@ -0,0 +1,270 @@
+<!--
+ The note-row editor (the reference `NoteRowMenu`): used both to create a
+ new note (note == null) and to edit an existing one. In create mode all
+ edits accumulate locally and are committed by the Add button; in edit
+ mode colour/link changes commit immediately and the text commits on close
+ (only when it actually changed, so an unedited open/close doesn't pollute
+ the undo history).
+-->
+<script lang="ts">
+ import type { GameSession } from '$lib/state/session';
+ import {
+ isCharacter,
+ isMonster,
+ type CharacterItem,
+ type MonsterItem,
+ type NoteRowItem
+ } from '$lib/protocol/types';
+ import { t } from '$lib/i18n';
+ import Menu from '../Menu.svelte';
+
+ /** The reference `_kPalette` (12 swatches, ARGB). */
+ const PALETTE = [
+ 0xff4e5d6c,
+ 0xff6d4c41,
+ 0xff37474f,
+ 0xff5d4037,
+ 0xff455a64,
+ 0xff6a1b9a,
+ 0xffad1457,
+ 0xffc62828,
+ 0xffe65100,
+ 0xff2e7d32,
+ 0xff1565c0,
+ 0xff00838f
+ ];
+
+ let {
+ session,
+ note = null,
+ presetLinkId = '',
+ presetStandeeNr = 0,
+ open = $bindable(true)
+ }: {
+ session: GameSession;
+ /** The existing note to edit; null to create a new one. */
+ note?: NoteRowItem | null;
+ /** Create mode only: pre-select a link target (status-menu entry). */
+ presetLinkId?: string;
+ presetStandeeNr?: number;
+ open?: boolean;
+ } = $props();
+
+ const player = session.player;
+ const gameState = session.state;
+
+ const isEdit = $derived(note != null);
+ const canAct = $derived(!!$player && $gameState != null);
+
+ let text = $state(note?.text ?? '');
+ let color = $state(note?.color ?? 0xff4e5d6c);
+ let linkedId = $state(note?.linkedId ?? presetLinkId);
+ let standeeNr = $state(note?.standeeNr ?? presetStandeeNr);
+ let lastCommitted = $state(text);
+
+ function colorCss(c: number): string {
+ return `#${c.toString(16).padStart(8, '0').slice(2)}`;
+ }
+
+ function cmd(name: string, args: Record<string, unknown>) {
+ if ($player) session.command(name, args);
+ }
+
+ /** Every link target (characters and monsters) in list order. */
+ const figures = $derived.by(() => {
+ const out: { id: string; kind: 'player' | 'monster'; display: string }[] = [];
+ for (const item of $gameState?.currentList ?? []) {
+ if (isCharacter(item)) {
+ const c = item as CharacterItem;
+ out.push({ id: c.id, kind: 'player', display: c.characterState.display || c.id });
+ } else if (isMonster(item)) {
+ out.push({ id: item.id, kind: 'monster', display: item.id });
+ }
+ }
+ return out;
+ });
+
+ /** The linked monster (for the standee selector), if any. */
+ const linkedMonster = $derived.by((): MonsterItem | null => {
+ const gs = $gameState;
+ if (linkedId === '' || gs == null) return null;
+ return (
+ gs.currentList.find((i): i is MonsterItem => isMonster(i) && i.id === linkedId) ??
+ null
+ );
+ });
+
+ function pickColor(c: number) {
+ color = c;
+ if (note) cmd('setNoteRowColor', { color: c, noteId: note.id });
+ }
+
+ function setLink(id: string, nr: number) {
+ linkedId = id;
+ standeeNr = id === '' ? 0 : nr;
+ if (note)
+ cmd('setNoteRowLink', {
+ noteId: note.id,
+ linkedId,
+ standeeNr
+ });
+ }
+
+ function commitText() {
+ if (!note) return;
+ const trimmed = text.trim();
+ if (trimmed !== lastCommitted) {
+ lastCommitted = trimmed;
+ cmd('setNoteRowText', { text: trimmed, noteId: note.id });
+ }
+ }
+
+ function add() {
+ cmd('addNoteRow', {
+ noteRow: {
+ id: 'note_' + crypto.randomUUID(),
+ text: text.trim(),
+ color,
+ linkedId,
+ standeeNr
+ }
+ });
+ open = false;
+ }
+
+ function remove() {
+ if (note) cmd('removeNoteRow', { noteId: note.id });
+ open = false;
+ }
+
+ function close() {
+ commitText();
+ open = false;
+ }
+</script>
+
+<Menu {open} title={t('noteRowTitle')}>
+ <textarea
+ class="search search--area"
+ rows={3}
+ maxlength={300}
+ placeholder={t('noteRowHint')}
+ bind:value={text}
+ readonly={!canAct}
+ onblur={commitText}
+ ></textarea>
+
+ {#if canAct}
+ <div class="fieldlabel">{t('noteRowColourLabel')}</div>
+ <div class="palette" role="radiogroup" aria-label={t('noteRowColourLabel')}>
+ {#each PALETTE as c (c)}
+ <button
+ class="swatch"
+ class:swatch--selected={c === color}
+ style:background={colorCss(c)}
+ aria-label={colorCss(c)}
+ onclick={() => pickColor(c)}
+ ></button>
+ {/each}
+ </div>
+
+ <div class="fieldlabel">{t('noteRowConnectLabel')}</div>
+ <select
+ class="search"
+ style="margin: 0"
+ value={linkedId}
+ onchange={(e) => setLink(e.currentTarget.value, 0)}
+ >
+ <option value="">{t('noteRowConnectNone')}</option>
+ {#each figures as f (f.id)}
+ <option value={f.id}>
+ {f.kind === 'player' ? t('noteRowConnectPlayer') : t('noteRowConnectMonster')}:
+ {f.display}
+ </option>
+ {/each}
+ </select>
+
+ {#if linkedMonster}
+ <select
+ class="search"
+ style="margin: 0"
+ value={linkedMonster.monsterInstances.some((s) => s.standeeNr === standeeNr)
+ ? standeeNr
+ : 0}
+ onchange={(e) => setLink(linkedId, Number(e.currentTarget.value))}
+ >
+ <option value={0}>{t('noteRowWholeGroup')}</option>
+ {#each linkedMonster.monsterInstances as s (s.standeeNr)}
+ <option value={s.standeeNr}>{t('noteRowStandeeNr', { nr: s.standeeNr })}</option>
+ {/each}
+ </select>
+ {/if}
+
+ <div class="actions">
+ {#if isEdit && note}
+ <button class="pill pill--danger" onclick={remove}>{t('noteRowDelete')}</button>
+ {:else}
+ <span></span>
+ {/if}
+ {#if isEdit}
+ <button class="pill" onclick={close}>{t('close')}</button>
+ {:else}
+ <button class="pill pill--primary" onclick={add}>{t('noteRowAddFromMenu')}</button>
+ {/if}
+ </div>
+ {/if}
+</Menu>
+
+<style>
+ textarea.search--area {
+ resize: vertical;
+ min-height: 64px;
+ margin-bottom: 10px;
+ }
+ .fieldlabel {
+ font-size: 13px;
+ margin: 10px 0 4px;
+ opacity: 0.85;
+ }
+ .palette {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 6px;
+ }
+ .swatch {
+ width: 26px;
+ height: 26px;
+ border-radius: 50%;
+ border: 1px solid rgba(0, 0, 0, 0.4);
+ cursor: pointer;
+ padding: 0;
+ }
+ .swatch--selected {
+ border: 3px solid #fff;
+ }
+ .actions {
+ display: flex;
+ justify-content: space-between;
+ gap: 8px;
+ margin-top: 14px;
+ }
+ .pill {
+ padding: 6px 14px;
+ font-size: 13px;
+ border: none;
+ border-radius: 4px;
+ background: rgba(255, 255, 255, 0.12);
+ color: inherit;
+ cursor: pointer;
+ }
+ .pill:hover {
+ background: rgba(255, 255, 255, 0.25);
+ }
+ .pill--primary {
+ background: rgba(255, 255, 255, 0.3);
+ font-weight: 600;
+ }
+ .pill--danger {
+ color: #ff5252;
+ }
+</style>
diff --git a/web/src/lib/ui/menus/SettingsMenu.svelte b/web/src/lib/ui/menus/SettingsMenu.svelte
index ef5a91a..4a6699a 100644
--- a/web/src/lib/ui/menus/SettingsMenu.svelte
+++ b/web/src/lib/ui/menus/SettingsMenu.svelte
@@ -1,20 +1,35 @@
<!--
- Settings (Phase 3 subset of the reference `SettingsMenu`): the visual
- style theme and the UI language. Both are client-only preferences.
+ 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 { open = $bindable(true) }: { open?: boolean } = $props();
+ 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')}>
@@ -47,4 +62,46 @@
{/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>
diff --git a/web/src/lib/ui/menus/SpecialUnlocksMenu.svelte b/web/src/lib/ui/menus/SpecialUnlocksMenu.svelte
new file mode 100644
index 0000000..e565c33
--- /dev/null
+++ b/web/src/lib/ui/menus/SpecialUnlocksMenu.svelte
@@ -0,0 +1,83 @@
+<!--
+ Special Unlocks (the reference `SpecialUnlocksMenu`): toggles the special
+ characters available in the add-character menu (`unlockSpecial`). Locked
+ entries show as "???"; the icon is always visible.
+-->
+<script lang="ts">
+ import type { GameSession } from '$lib/state/session';
+ import { t } from '$lib/i18n';
+ import Menu from '../Menu.svelte';
+
+ /** The unlockable specials (the reference hard-codes this list). */
+ const UNLOCKS: { id: string; icon: string }[] = [
+ { id: 'Demons', icon: '/images/demons.png' },
+ { id: 'Merchant-Guild', icon: '/images/merchant-guild.png' },
+ { id: 'Military', icon: '/images/military.png' },
+ { id: 'Bladeswarm', icon: '/images/class-icons/Bladeswarm.png' }
+ ];
+
+ let {
+ session,
+ open = $bindable(true)
+ }: {
+ session: GameSession;
+ open?: boolean;
+ } = $props();
+
+ const gameState = session.state;
+ const player = session.player;
+
+ const unlocked = $derived($gameState?.unlockedClasses ?? []);
+
+ function isEnabled(id: string): boolean {
+ return unlocked.includes(id);
+ }
+
+ function toggle(id: string) {
+ if (!$player) return;
+ session.command('unlockSpecial', { id });
+ }
+</script>
+
+<Menu {open} title={t('specialUnlocks')}>
+ <ul class="unlocklist">
+ {#each UNLOCKS as u (u.id)}
+ <li>
+ <label class="unlocklist__item" class:unlocklist__item--disabled={!$player}>
+ <input
+ type="checkbox"
+ checked={isEnabled(u.id)}
+ disabled={!$player}
+ onchange={() => toggle(u.id)}
+ />
+ <img class="unlocklist__icon" src={u.icon} alt="" />
+ <span>{isEnabled(u.id) ? u.id : '???'}</span>
+ </label>
+ </li>
+ {/each}
+ </ul>
+</Menu>
+
+<style>
+ .unlocklist {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ }
+ .unlocklist__item {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ padding: 8px 4px;
+ font-size: 14px;
+ cursor: pointer;
+ }
+ .unlocklist__item--disabled {
+ cursor: default;
+ }
+ .unlocklist__icon {
+ width: 40px;
+ height: 40px;
+ object-fit: contain;
+ }
+</style>