diff options
Diffstat (limited to 'web/src/lib/ui/menus/SpecialUnlocksMenu.svelte')
| -rw-r--r-- | web/src/lib/ui/menus/SpecialUnlocksMenu.svelte | 83 |
1 files changed, 83 insertions, 0 deletions
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> |
