2026-10-28 23:38:54 +00:00
|
|
|
<script setup lang="ts">
|
2026-10-29 00:26:08 +00:00
|
|
|
import type { UiIconName } from '~/components/icon/Ui.vue'
|
|
|
|
|
|
2026-10-28 23:38:54 +00:00
|
|
|
const props = defineProps<{
|
2026-10-29 00:26:08 +00:00
|
|
|
/** Inside a world: the world's menu (village, map, reports) and its clock. */
|
2026-10-28 23:38:54 +00:00
|
|
|
inWorld?: boolean
|
2026-10-29 09:56:52 +00:00
|
|
|
/** Across the whole screen, over the fullscreen village, instead of the centred column. */
|
|
|
|
|
wide?: boolean
|
2026-10-28 23:38:54 +00:00
|
|
|
}>()
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
const { user, logout } = useAuth()
|
|
|
|
|
const { current } = useCurrentWorld()
|
|
|
|
|
const { worlds, refresh } = useWorld()
|
|
|
|
|
const unread = useUnreadReports()
|
|
|
|
|
const { now } = useServerClock()
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
|
|
|
|
|
const world = computed(() => (props.inWorld && current.value ? (worlds.value?.find((w) => w.id === current.value!.worldId) ?? null) : null))
|
|
|
|
|
if (props.inWorld && !worlds.value) refresh()
|
|
|
|
|
|
2026-10-29 00:26:08 +00:00
|
|
|
interface Entry {
|
|
|
|
|
key: 'village' | 'map' | 'reports'
|
|
|
|
|
to: string
|
|
|
|
|
icon: UiIconName
|
|
|
|
|
active: boolean
|
|
|
|
|
count?: number
|
|
|
|
|
/** The dropdown under the entry, like the menu of Die Stämme. */
|
|
|
|
|
sub: { label: string; to: string | { path: string; query: Record<string, string> } }[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// One bar with every section of the world; each entry opens its own page, and on
|
|
|
|
|
// hover or focus a dropdown with its sub-pages.
|
|
|
|
|
const entries = computed<Entry[]>(() => {
|
2026-10-28 23:38:54 +00:00
|
|
|
const c = current.value
|
|
|
|
|
if (!props.inWorld || !c) return []
|
2026-10-29 00:26:08 +00:00
|
|
|
const out: Entry[] = []
|
|
|
|
|
if (c.villageId) {
|
|
|
|
|
const base = `/village/${c.villageId}`
|
|
|
|
|
out.push({
|
|
|
|
|
key: 'village',
|
|
|
|
|
to: base,
|
|
|
|
|
icon: 'home',
|
|
|
|
|
active: route.path.startsWith('/village/'),
|
|
|
|
|
sub: VILLAGE_SCREENS.map((s) => ({ label: t(`village.screens.${s.name}`), to: `${base}${s.path}` })),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
out.push({ key: 'map', to: `/map/${c.worldId}`, icon: 'pin', active: route.path.startsWith('/map/'), sub: [] })
|
|
|
|
|
out.push({
|
|
|
|
|
key: 'reports',
|
|
|
|
|
to: `/reports/${c.worldId}`,
|
|
|
|
|
icon: 'report',
|
|
|
|
|
active: route.path.startsWith('/reports/'),
|
|
|
|
|
count: unread.value,
|
|
|
|
|
sub: (['all', 'attack', 'defense', 'support'] as const).map((kind) => ({
|
|
|
|
|
label: t(`reports.kinds.${kind}`),
|
|
|
|
|
to: kind === 'all' ? `/reports/${c.worldId}` : { path: `/reports/${c.worldId}`, query: { type: kind } },
|
|
|
|
|
})),
|
|
|
|
|
})
|
|
|
|
|
return out
|
2026-10-28 23:38:54 +00:00
|
|
|
})
|
|
|
|
|
|
2026-10-29 00:26:08 +00:00
|
|
|
/** The key that opens a menu entry (the village entry opens its overview). */
|
feat: rally point tabs, map village popups, report filters, beginner protection bar, keyboard shortcuts
Ideas taken from how Die Stämme works, in our own look: the rally point splits into
commands, troops and simulator; hovering a village on the map shows its owner, points
and distance, a click offers send troops and centre; reports filter by attacks,
defence and support; a dismissible bar counts down beginner protection; one key per
screen (V, H, T, P, W, M, R); resources in the village bar lead to the workforce.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 00:00:13 +00:00
|
|
|
const shortcutOf = (key: string) => SHORTCUTS[(key === 'village' ? 'overview' : key) as keyof typeof SHORTCUTS].toUpperCase()
|
2026-10-29 00:26:08 +00:00
|
|
|
const home = computed(() => (props.inWorld && current.value?.villageId ? `/village/${current.value.villageId}` : '/worlds'))
|
feat: rally point tabs, map village popups, report filters, beginner protection bar, keyboard shortcuts
Ideas taken from how Die Stämme works, in our own look: the rally point splits into
commands, troops and simulator; hovering a village on the map shows its owner, points
and distance, a click offers send troops and centre; reports filter by attacks,
defence and support; a dismissible bar counts down beginner protection; one key per
screen (V, H, T, P, W, M, R); resources in the village bar lead to the workforce.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 00:00:13 +00:00
|
|
|
|
2026-10-28 23:38:54 +00:00
|
|
|
const connection = computed(() =>
|
|
|
|
|
isMockServer
|
|
|
|
|
? { text: t('app.mock'), tone: 'bg-gold-400' }
|
|
|
|
|
: ws.is_opened.value
|
|
|
|
|
? { text: t('app.connected'), tone: 'bg-moss-500' }
|
|
|
|
|
: { text: t('app.offline'), tone: 'bg-blood-600' },
|
|
|
|
|
)
|
|
|
|
|
const clock = computed(() => new Date(now.value).toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false }))
|
|
|
|
|
|
2026-10-29 00:26:08 +00:00
|
|
|
// A dropdown closes once one of its links is followed.
|
|
|
|
|
const menuKey = ref(0)
|
|
|
|
|
watch(() => route.fullPath, () => menuKey.value++)
|
2026-10-28 23:38:54 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-10-29 00:26:08 +00:00
|
|
|
<!-- The main menu on every page: one dark bar, every section with its dropdown, the server clock and the account. -->
|
2026-10-28 23:38:54 +00:00
|
|
|
<template>
|
2026-10-29 13:09:03 +00:00
|
|
|
<header class="border-b-2 border-wood-950 bg-wood-900 text-sm text-parchment-100">
|
2026-10-29 09:56:52 +00:00
|
|
|
<div :key="menuKey" class="mx-auto flex h-9 items-stretch px-1 sm:px-2" :class="wide ? '' : 'max-w-[1100px]'">
|
2026-10-29 00:26:08 +00:00
|
|
|
<NuxtLink :to="home" class="mr-1 shrink-0 items-center gap-1.5 px-1.5" :class="entries.length ? 'hidden sm:flex' : 'flex'" :title="t('app.title')">
|
|
|
|
|
<span class="grid size-6 place-items-center border border-gold-600 bg-blood-700 text-gold-400">
|
|
|
|
|
<IconBuilding type="headquarters" class="size-4" />
|
2026-10-28 23:38:54 +00:00
|
|
|
</span>
|
2026-10-29 13:09:03 +00:00
|
|
|
<span class="hidden font-display text-base font-semibold text-gold-400 lg:inline" style="font-variant: small-caps">{{ t('app.title') }}</span>
|
2026-10-28 23:38:54 +00:00
|
|
|
</NuxtLink>
|
|
|
|
|
|
2026-10-29 00:26:08 +00:00
|
|
|
<nav v-if="entries.length" class="flex items-stretch" :aria-label="t('app.menu')">
|
|
|
|
|
<div v-for="e in entries" :key="e.key" class="group relative flex">
|
|
|
|
|
<NuxtLink
|
|
|
|
|
:to="e.to"
|
|
|
|
|
class="menu-item"
|
|
|
|
|
:class="{ 'menu-item-active': e.active }"
|
|
|
|
|
:aria-current="e.active ? 'page' : undefined"
|
|
|
|
|
:title="t('app.shortcut', { key: shortcutOf(e.key) })"
|
|
|
|
|
>
|
|
|
|
|
<IconUi :name="e.icon" class="size-4" />
|
|
|
|
|
<span class="hidden sm:inline">{{ t(`app.${e.key}`) }}</span>
|
|
|
|
|
<span v-if="e.count" class="font-bold text-gold-400 tabular-nums">({{ e.count }})</span>
|
|
|
|
|
</NuxtLink>
|
|
|
|
|
<div v-if="e.sub.length" class="menu-drop">
|
|
|
|
|
<NuxtLink v-for="s in e.sub" :key="s.label" :to="s.to" class="menu-drop-item">{{ s.label }}</NuxtLink>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-10-28 23:38:54 +00:00
|
|
|
</nav>
|
|
|
|
|
|
2026-10-29 00:26:08 +00:00
|
|
|
<div class="ml-auto flex items-stretch">
|
|
|
|
|
<span v-if="world" class="hidden items-center border-l border-wood-700 px-2.5 text-parchment-300 md:flex">{{ world.name }}</span>
|
|
|
|
|
<span v-if="user" class="flex items-center gap-1.5 border-l border-wood-700 px-2.5 tabular-nums text-parchment-200" :title="`${t('app.server_time')} · ${connection.text}`">
|
|
|
|
|
<span class="size-1.5 rounded-full" :class="connection.tone" />
|
2026-10-28 23:38:54 +00:00
|
|
|
{{ clock }}
|
|
|
|
|
</span>
|
2026-10-29 00:26:08 +00:00
|
|
|
<div v-if="user" class="group relative flex">
|
|
|
|
|
<button type="button" class="menu-item border-r-0 border-l" :title="t('app.account')">
|
2026-10-28 23:38:54 +00:00
|
|
|
<IconUi name="users" class="size-4" />
|
2026-10-29 00:26:08 +00:00
|
|
|
<span class="hidden max-w-28 truncate md:inline">{{ user.name }}</span>
|
|
|
|
|
</button>
|
|
|
|
|
<div class="menu-drop right-0 left-auto">
|
|
|
|
|
<NuxtLink to="/worlds" class="menu-drop-item">{{ t('app.change_world') }}</NuxtLink>
|
|
|
|
|
<button type="button" class="menu-drop-item w-full text-left" @click="logout()">{{ t('app.logout') }}</button>
|
2026-10-28 23:38:54 +00:00
|
|
|
</div>
|
2026-10-29 00:26:08 +00:00
|
|
|
</div>
|
2026-10-28 23:38:54 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
@reference "~/assets/css/main.css";
|
|
|
|
|
|
2026-10-29 00:26:08 +00:00
|
|
|
.menu-item {
|
|
|
|
|
@apply flex items-center gap-1.5 border-r border-wood-700 px-2.5 font-semibold text-parchment-100 hover:bg-wood-800 focus-visible:outline-2 focus-visible:outline-gold-500;
|
|
|
|
|
}
|
|
|
|
|
.menu-item-active {
|
|
|
|
|
@apply bg-wood-800 text-gold-400;
|
2026-10-28 23:38:54 +00:00
|
|
|
}
|
2026-10-29 00:26:08 +00:00
|
|
|
/* Shown on hover or keyboard focus; touch devices just follow the entry's own link. */
|
|
|
|
|
.menu-drop {
|
|
|
|
|
@apply absolute top-full left-0 z-50 hidden min-w-44 border border-wood-950 bg-parchment-50 py-0.5 text-ink-900 shadow-[2px_2px_0_0_rgb(31_21_12/0.4)] group-focus-within:block group-hover:block;
|
2026-10-28 23:38:54 +00:00
|
|
|
}
|
2026-10-29 00:26:08 +00:00
|
|
|
.menu-drop-item {
|
|
|
|
|
@apply block px-2.5 py-1 font-semibold whitespace-nowrap text-wood-900 hover:bg-parchment-200 hover:text-blood-700;
|
2026-10-28 23:38:54 +00:00
|
|
|
}
|
|
|
|
|
</style>
|