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
|
|
|
|
|
}>()
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
const { user, logout } = useAuth()
|
|
|
|
|
const { current } = useCurrentWorld()
|
|
|
|
|
const { worlds, refresh } = useWorld()
|
|
|
|
|
const unread = useUnreadReports()
|
2026-10-30 09:59:07 +00:00
|
|
|
const chat = useChat()
|
2026-10-30 09:54:16 +00:00
|
|
|
const villageContext = useVillageContextOrNull()
|
|
|
|
|
const villageState = computed(() => villageContext?.village.value ?? null)
|
2026-10-28 23:38:54 +00:00
|
|
|
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 {
|
2026-10-30 09:54:16 +00:00
|
|
|
key: 'village' | 'map' | 'reports' | 'ranking' | 'tribe'
|
2026-10-29 00:26:08 +00:00
|
|
|
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,
|
2026-10-31 10:07:33 +00:00
|
|
|
sub: (['all', 'attack', 'defense', 'support', 'trade'] as const).map((kind) => ({
|
2026-10-29 00:26:08 +00:00
|
|
|
label: t(`reports.kinds.${kind}`),
|
|
|
|
|
to: kind === 'all' ? `/reports/${c.worldId}` : { path: `/reports/${c.worldId}`, query: { type: kind } },
|
|
|
|
|
})),
|
|
|
|
|
})
|
2026-10-30 09:54:16 +00:00
|
|
|
out.push({
|
|
|
|
|
key: 'tribe',
|
|
|
|
|
to: `/tribe/${c.worldId}`,
|
|
|
|
|
icon: 'users',
|
|
|
|
|
active: route.path.startsWith('/tribe/'),
|
|
|
|
|
// Invites waiting while the player has no tribe.
|
|
|
|
|
count: villageState.value?.tribe.tribe ? undefined : villageState.value?.tribe.invites,
|
|
|
|
|
sub: [],
|
|
|
|
|
})
|
2026-10-29 15:27:21 +00:00
|
|
|
out.push({
|
|
|
|
|
key: 'ranking',
|
|
|
|
|
to: `/ranking/${c.worldId}`,
|
|
|
|
|
icon: 'rank',
|
|
|
|
|
active: route.path.startsWith('/ranking/'),
|
2026-10-30 09:54:16 +00:00
|
|
|
sub: (['players', 'tribes', 'villages', 'attack', 'defense'] as const).map((kind) => ({
|
2026-10-29 15:27:21 +00:00
|
|
|
label: t(`ranking.kinds.${kind}`),
|
|
|
|
|
to: kind === 'players' ? `/ranking/${c.worldId}` : { path: `/ranking/${c.worldId}`, query: { kind } },
|
|
|
|
|
})),
|
|
|
|
|
})
|
2026-10-29 00:26:08 +00:00
|
|
|
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-30 10:53:13 +00:00
|
|
|
<div :key="menuKey" class="flex h-9 items-stretch px-1 sm:px-2">
|
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" />
|
fix: responsive building pages: the send form and simulator size by their column, the build queue sits with the headquarters on the right, action buttons never wrap or clip, the menu shows icons only below 1024 px
Checked every world page at 1920, 1465, 1280, 1024, 900, 768, 600 and 390 px for clipped, spilling and page-wide overflow.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 12:52:30 +00:00
|
|
|
<span class="hidden lg:inline">{{ t(`app.${e.key}`) }}</span>
|
2026-10-29 00:26:08 +00:00
|
|
|
<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">
|
fix: responsive building pages: the send form and simulator size by their column, the build queue sits with the headquarters on the right, action buttons never wrap or clip, the menu shows icons only below 1024 px
Checked every world page at 1920, 1465, 1280, 1024, 900, 768, 600 and 390 px for clipped, spilling and page-wide overflow.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 12:52:30 +00:00
|
|
|
<span v-if="world" class="hidden items-center border-l border-wood-700 px-2.5 text-parchment-300 xl:flex">{{ world.name }}</span>
|
2026-10-30 09:59:07 +00:00
|
|
|
<button
|
|
|
|
|
v-if="entries.length"
|
|
|
|
|
type="button"
|
|
|
|
|
class="menu-item border-l"
|
|
|
|
|
:class="{ 'menu-item-active': chat.state.value.open }"
|
|
|
|
|
:title="t('app.chat')"
|
|
|
|
|
@click="chat.toggle()"
|
|
|
|
|
>
|
|
|
|
|
<IconUi name="chat" class="size-4" />
|
fix: responsive building pages: the send form and simulator size by their column, the build queue sits with the headquarters on the right, action buttons never wrap or clip, the menu shows icons only below 1024 px
Checked every world page at 1920, 1465, 1280, 1024, 900, 768, 600 and 390 px for clipped, spilling and page-wide overflow.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 12:52:30 +00:00
|
|
|
<span class="hidden lg:inline">{{ t('app.chat') }}</span>
|
2026-10-30 09:59:07 +00:00
|
|
|
<span v-if="chat.unread.value" class="font-bold text-gold-400 tabular-nums">({{ chat.unread.value }})</span>
|
|
|
|
|
</button>
|
2026-10-29 00:26:08 +00:00
|
|
|
<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" />
|
fix: responsive building pages: the send form and simulator size by their column, the build queue sits with the headquarters on the right, action buttons never wrap or clip, the menu shows icons only below 1024 px
Checked every world page at 1920, 1465, 1280, 1024, 900, 768, 600 and 390 px for clipped, spilling and page-wide overflow.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 12:52:30 +00:00
|
|
|
<span class="hidden max-w-28 truncate lg:inline">{{ user.name }}</span>
|
2026-10-29 00:26:08 +00:00
|
|
|
</button>
|
|
|
|
|
<div class="menu-drop right-0 left-auto">
|
|
|
|
|
<NuxtLink to="/worlds" class="menu-drop-item">{{ t('app.change_world') }}</NuxtLink>
|
2026-10-30 10:30:34 +00:00
|
|
|
<NuxtLink to="/account" class="menu-drop-item">{{ t('app.account') }}</NuxtLink>
|
2026-10-29 00:26:08 +00:00
|
|
|
<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>
|