feat: the map fills the screen too, with its panels in the dock, and the reports open over the village: one stage for the whole world, nothing jumps
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bcd98dba5a
commit
2c8865bbd4
|
|
@ -11,7 +11,7 @@ This is the Nuxt client for a browser strategy game in the style of Tribal Wars.
|
||||||
- **The village is a ground-level land view** (`app/components/village/Diorama.vue`, geometry in `app/diorama/`): isometric low-poly, drawn as inline SVG, no WebGL. The land fills the frame edge to edge (no island, no sky), cut to the container's shape; narrow screens scroll sideways. There are no tiles or positions: the server only sends each building's `space` and the village's `space.used/max`, and the client lays everything out deterministically in id order. The village core sits in the middle (headquarters on the plaza, storage, hiding places and rally point around it, inside the wall ring when there is one, a dirt edge without). Resource sites stand outside in their zones: iron mines at the rocky hill (upper left), clay pits on clay ground (lower left), timber camps at the forest edge (lower right), farms with fields (right); dirt roads lead from the gates to each zone and forest fills the rest. Levels start at 1. Each type has a model per level tier (1–4, 5–14, 15+); the wall goes stakes → timber → stone with towers. Buildings are focusable buttons that enter the building (`buildingRoute`): the headquarters opens construction, the rally point its commands, a military building its recruiting, every other building its own screen (`/village/<id>/building/<bid>`); each of these screens starts with `VillageBuildingHeader`: a close-up (`VillageCloseup`, `app/diorama/closeup.ts`: the building large on its ground, its props and forest, its assigned workers walking to where they work and back carrying what they make), what it does now and one level up (`effects`/`next_effects` from the server), workers, priority, upgrade and demolish. The open building stays outlined in the village, and clicking it again returns to the overview. Buildings are clickable anywhere on their outline (`hit`, a convex hull round their polygons and ground ring), the thin wall also along a wide band on its ring, and their level badges and countdowns as well; a type that doesn't stand yet keeps an invisible empty plot that opens its build card. Buildings never move or light up on hover: only a click outlines the ground under them. The village feels alive, and life stays out of the way: flat ground shadows, smoke from chimneys, forges and kilns; workers go out to their zone with their tool (`VillageWorker`, timing in `app/diorama/life.ts`: one SMIL clock per figure for the walk, stepping legs, the tool swing at work, the load on the way home and turning round), two villagers talk on the plaza, a builder hammers at every order in the works, a guard paces inside the gate, sheep graze past the farms and chickens peck round the plaza (`VillageAnimal`), birds cross now and then (`VillageBird`); the close-up does the same for its building. All motion stops under `prefers-reduced-motion`; people who stay put then stand still. The same models draw the building portraits on screen headers, the HQ list and the building cards (`VillageBuildingPortrait`). The world map groups forests, lakes and rocky hills by smooth noise of the coordinates, and village markers grow in five sizes with points. Map coordinates run around 0|0, negative included (−500 to 499 on a 1000-field map, lowest value from `map.view`'s `min`); continents are named from the top-left like Die Stämme, so 0|0 is the corner of K44, K45, K54 and K55. Use `app/utils/map.ts` for bounds and continents, never `0` or `500` literals.
|
- **The village is a ground-level land view** (`app/components/village/Diorama.vue`, geometry in `app/diorama/`): isometric low-poly, drawn as inline SVG, no WebGL. The land fills the frame edge to edge (no island, no sky), cut to the container's shape; narrow screens scroll sideways. There are no tiles or positions: the server only sends each building's `space` and the village's `space.used/max`, and the client lays everything out deterministically in id order. The village core sits in the middle (headquarters on the plaza, storage, hiding places and rally point around it, inside the wall ring when there is one, a dirt edge without). Resource sites stand outside in their zones: iron mines at the rocky hill (upper left), clay pits on clay ground (lower left), timber camps at the forest edge (lower right), farms with fields (right); dirt roads lead from the gates to each zone and forest fills the rest. Levels start at 1. Each type has a model per level tier (1–4, 5–14, 15+); the wall goes stakes → timber → stone with towers. Buildings are focusable buttons that enter the building (`buildingRoute`): the headquarters opens construction, the rally point its commands, a military building its recruiting, every other building its own screen (`/village/<id>/building/<bid>`); each of these screens starts with `VillageBuildingHeader`: a close-up (`VillageCloseup`, `app/diorama/closeup.ts`: the building large on its ground, its props and forest, its assigned workers walking to where they work and back carrying what they make), what it does now and one level up (`effects`/`next_effects` from the server), workers, priority, upgrade and demolish. The open building stays outlined in the village, and clicking it again returns to the overview. Buildings are clickable anywhere on their outline (`hit`, a convex hull round their polygons and ground ring), the thin wall also along a wide band on its ring, and their level badges and countdowns as well; a type that doesn't stand yet keeps an invisible empty plot that opens its build card. Buildings never move or light up on hover: only a click outlines the ground under them. The village feels alive, and life stays out of the way: flat ground shadows, smoke from chimneys, forges and kilns; workers go out to their zone with their tool (`VillageWorker`, timing in `app/diorama/life.ts`: one SMIL clock per figure for the walk, stepping legs, the tool swing at work, the load on the way home and turning round), two villagers talk on the plaza, a builder hammers at every order in the works, a guard paces inside the gate, sheep graze past the farms and chickens peck round the plaza (`VillageAnimal`), birds cross now and then (`VillageBird`); the close-up does the same for its building. All motion stops under `prefers-reduced-motion`; people who stay put then stand still. The same models draw the building portraits on screen headers, the HQ list and the building cards (`VillageBuildingPortrait`). The world map groups forests, lakes and rocky hills by smooth noise of the coordinates, and village markers grow in five sizes with points. Map coordinates run around 0|0, negative included (−500 to 499 on a 1000-field map, lowest value from `map.view`'s `min`); continents are named from the top-left like Die Stämme, so 0|0 is the corner of K44, K45, K54 and K55. Use `app/utils/map.ts` for bounds and continents, never `0` or `500` literals.
|
||||||
- **Flat medieval colours only**, in the diorama and everywhere else: no gradients (CSS or SVG), no blur or backdrop-blur, no SVG filters or glows, no translucent overlays. Depth comes from the three flat shades per face in `app/diorama/iso.ts`, solid borders and hard shadows. In the diorama there are no outlines: a polygon strokes in its own fill only to close seams, detail comes from a few large shaded panels (a stone plinth, a door and windows from `house()`/`openings()`, two-tier firs, people as shaded shapes in `VillageWalker`), not from many small nodes. A face that must draw over its wall (doors, windows) sets `depth`; offsets and `shift()` carry it along. In the close-up, workers are sorted in among the objects by depth. Surfaces carry small repeating patterns generated in code at startup (`app/utils/patterns.ts` → `--pat-*` custom properties, set by `plugins/patterns.client.ts`, painted per `bg-parchment-*`/`bg-wood-*` class and on `.panel`, `.frame`, `.btn-primary` in `main.css`): parchment flecks, woven header bands with a stitched hem, wood grain; flat opaque shades a step off the surface, never images or opacity. Keep them minimal. One look for every part: each header band is `.panel-head` with a `.panel-title`, everything that floats over the village has the `.float` hard shadow and sits in a bordered frame, and every vertical scroll area is `.scroll-y`, whose bar always shows so content never shifts sideways; the one scrollbar style (wood handle with notches in a parchment track) lives in `main.css`. Every page keeps the page scrollbar, the fullscreen village included (an empty track there), so the usable width never changes when hopping between the village, the map and the reports. Keep components small and typed, with state in composables (`useVillage`, `useWorld`).
|
- **Flat medieval colours only**, in the diorama and everywhere else: no gradients (CSS or SVG), no blur or backdrop-blur, no SVG filters or glows, no translucent overlays. Depth comes from the three flat shades per face in `app/diorama/iso.ts`, solid borders and hard shadows. In the diorama there are no outlines: a polygon strokes in its own fill only to close seams, detail comes from a few large shaded panels (a stone plinth, a door and windows from `house()`/`openings()`, two-tier firs, people as shaded shapes in `VillageWalker`), not from many small nodes. A face that must draw over its wall (doors, windows) sets `depth`; offsets and `shift()` carry it along. In the close-up, workers are sorted in among the objects by depth. Surfaces carry small repeating patterns generated in code at startup (`app/utils/patterns.ts` → `--pat-*` custom properties, set by `plugins/patterns.client.ts`, painted per `bg-parchment-*`/`bg-wood-*` class and on `.panel`, `.frame`, `.btn-primary` in `main.css`): parchment flecks, woven header bands with a stitched hem, wood grain; flat opaque shades a step off the surface, never images or opacity. Keep them minimal. One look for every part: each header band is `.panel-head` with a `.panel-title`, everything that floats over the village has the `.float` hard shadow and sits in a bordered frame, and every vertical scroll area is `.scroll-y`, whose bar always shows so content never shifts sideways; the one scrollbar style (wood handle with notches in a parchment track) lives in `main.css`. Every page keeps the page scrollbar, the fullscreen village included (an empty track there), so the usable width never changes when hopping between the village, the map and the reports. Keep components small and typed, with state in composables (`useVillage`, `useWorld`).
|
||||||
- **The village fills the screen.** On the village's own screens (`/village/<id>/…`) `GameVillageFrame` draws the diorama fixed across the whole browser window and docks everything over it, solid and opaque: the menu and the village bar along the top, the overview boxes in a right column (on phones a bottom sheet on the overview), and the open screen (headquarters, recruit, rally point, workforce) in a `UiWindow` on the left that folds and closes back to the overview; on the overview the left slot holds the build card of an empty plot picked in the village (`useVillageSelection`). Screen grids inside a window use container queries (`@4xl:`), not viewport breakpoints. The village scales to fit, no pan: the frame measures what the bars, the right column, the phone tab bar and the bottom sheet cover (`inset`), `buildScene` fits the whole village into the rest, and ground and forest are generated for the whole stage, so nothing of the village is ever cut off. Windows are docked now and meant to become draggable later, so `UiWindow` holds no position logic. This is where the game deliberately leaves Die Stämme's look behind.
|
- **The village fills the screen.** On the village's own screens (`/village/<id>/…`) `GameVillageFrame` draws the diorama fixed across the whole browser window and docks everything over it, solid and opaque: the menu and the village bar along the top, the overview boxes in a right column (on phones a bottom sheet on the overview), and the open screen (headquarters, recruit, rally point, workforce) in a `UiWindow` on the left that folds and closes back to the overview; on the overview the left slot holds the build card of an empty plot picked in the village (`useVillageSelection`). Screen grids inside a window use container queries (`@4xl:`), not viewport breakpoints. The village scales to fit, no pan: the frame measures what the bars, the right column, the phone tab bar and the bottom sheet cover (`inset`), `buildScene` fits the whole village into the rest, and ground and forest are generated for the whole stage, so nothing of the village is ever cut off. Windows are docked now and meant to become draggable later, so `UiWindow` holds no position logic. This is where the game deliberately leaves Die Stämme's look behind.
|
||||||
- **One game shell for the rest.** The map and reports sit in one centred column (1100 px). All world pages use `layouts/game.vue` (on village screens `GameVillageFrame` draws the same parts over the village): the dark main menu (`GameMenuBar`: village, map, reports with its count inline, each with a hover dropdown of its sub-pages; server clock; account dropdown), then the village header (`GameVillageBar`, in two pieces with the village showing between them: on the left the quick bar with the village's screens over the village row, on the right the stock in thin cells and incoming troops; the space between lets clicks through), thin notices, and the content in a `.frame`. On phones the screens move to a bottom tab bar (`GameTabBar`). The header's village is the URL's on village screens and the last opened one elsewhere; `GameVillageFrame` holds its one `useVillage()` and shares it through `useVillageContext()`. Pages outside a world use `layouts/default.vue` (menu only). A page has one of two shapes: a title with box tabs (`UiSubTabs`: buildings like the rally point) or a title with a sub-menu on the left (`UiSideMenu`: lists like reports). One key per screen (`useShortcuts`): V overview, H headquarters, T recruit, P rally point, W workforce, M map, R reports. The overview stays clean: the village and a narrow column of boxes (incoming attacks, production, units, population, construction); tables live on the building screens. The map shows a popup over a hovered village and actions under a clicked one. The village row starts with the quest book (`QuestBook`, a native `<dialog>` without a veil): it opens by itself when `quests.claimable` goes up, and a goal's "show me" opens its screen, a building goal the headquarters with `?hint=<type>` marking that row.
|
- **One stage for the whole world.** Every page of a world shares that frame, so nothing moves when hopping between them: the reports open in the window over the village, and the map fills the screen under the menu bar itself (it reads `useStage()` for where the menu ends) and teleports its panels (centre and zoom, minimap with the jump form, field info, legend) into the right dock (`#stage-dock`); on phones a small strip with home and zoom floats over it. Only pages outside a world, or a world whose village isn't known yet, sit in the centred column (1100 px). All world pages use `layouts/game.vue` (on village screens `GameVillageFrame` draws the same parts over the village): the dark main menu (`GameMenuBar`: village, map, reports with its count inline, each with a hover dropdown of its sub-pages; server clock; account dropdown), then the village header (`GameVillageBar`, in two pieces with the village showing between them: on the left the quick bar with the village's screens over the village row, on the right the stock in thin cells and incoming troops; the space between lets clicks through), thin notices, and the content in a `.frame`. On phones the screens move to a bottom tab bar (`GameTabBar`). The header's village is the URL's on village screens and the last opened one elsewhere; `GameVillageFrame` holds its one `useVillage()` and shares it through `useVillageContext()`. Pages outside a world use `layouts/default.vue` (menu only). A page has one of two shapes: a title with box tabs (`UiSubTabs`: buildings like the rally point) or a title with a sub-menu on the left (`UiSideMenu`: lists like reports). One key per screen (`useShortcuts`): V overview, H headquarters, T recruit, P rally point, W workforce, M map, R reports. The overview stays clean: the village and a narrow column of boxes (incoming attacks, production, units, population, construction); tables live on the building screens. The map shows a popup over a hovered village and actions under a clicked one. The village row starts with the quest book (`QuestBook`, a native `<dialog>` without a veil): it opens by itself when `quests.claimable` goes up, and a goal's "show me" opens its screen, a building goal the headquarters with `?hint=<type>` marking that row.
|
||||||
- All user-facing text goes through i18n keys, with `en` as the first locale. Sources are `i18n/locales/` and `i18n/pages/` (`@blax-software/i18n` layout); register a new page file in `i18n/messageloader.ts`. vue-i18n reads a bare `|` as a plural separator and drops what follows, so coordinates in messages are written `"{x}{'|'}{y}"` inside a double-quoted string.
|
- All user-facing text goes through i18n keys, with `en` as the first locale. Sources are `i18n/locales/` and `i18n/pages/` (`@blax-software/i18n` layout); register a new page file in `i18n/messageloader.ts`. vue-i18n reads a bare `|` as a plural separator and drops what follows, so coordinates in messages are written `"{x}{'|'}{y}"` inside a double-quoted string.
|
||||||
|
|
||||||
## Mock server
|
## Mock server
|
||||||
|
|
|
||||||
|
|
@ -32,17 +32,18 @@ watch(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
// On the village's own screens the village fills the screen and everything else docks
|
// Every page of the world fills the screen with the same bars and docks over it, so
|
||||||
// over it; on the map and the reports the header sits above a framed page as before.
|
// nothing moves when hopping between them: the village behind its own screens and the
|
||||||
|
// reports, the map behind itself.
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const base = computed(() => `/village/${props.villageId}`)
|
const base = computed(() => `/village/${props.villageId}`)
|
||||||
const stage = computed(() => route.path.startsWith(base.value))
|
const onMap = computed(() => route.path.startsWith('/map/'))
|
||||||
const overview = computed(() => route.path === base.value || route.path === `${base.value}/`)
|
const overview = computed(() => route.path === base.value || route.path === `${base.value}/`)
|
||||||
const { plot, clear } = useVillageSelection()
|
const { plot, clear } = useVillageSelection()
|
||||||
clear()
|
clear()
|
||||||
// An empty plot's build card lives on the overview.
|
// An empty plot's build card lives on the overview.
|
||||||
watch(plot, (p) => {
|
watch(plot, (p) => {
|
||||||
if (p && stage.value && !overview.value) navigateTo(base.value)
|
if (p && !overview.value) navigateTo(base.value)
|
||||||
})
|
})
|
||||||
// Clicking a building enters it: its screen opens in the window, and the building stays
|
// Clicking a building enters it: its screen opens in the window, and the building stays
|
||||||
// outlined in the village while it is open. Clicking it again goes back to the overview.
|
// outlined in the village while it is open. Clicking it again goes back to the overview.
|
||||||
|
|
@ -60,13 +61,16 @@ const screenTitle = computed(() => {
|
||||||
if (route.path.startsWith(`${base.value}/building/`) && openBuilding.value && v.village.value) {
|
if (route.path.startsWith(`${base.value}/building/`) && openBuilding.value && v.village.value) {
|
||||||
return buildingName(v.village.value, openBuilding.value, t)
|
return buildingName(v.village.value, openBuilding.value, t)
|
||||||
}
|
}
|
||||||
|
if (route.path.startsWith('/reports/')) return t('reports.title')
|
||||||
const s = VILLAGE_SCREENS.find((s) => s.path && route.path.startsWith(`${base.value}${s.path}`))
|
const s = VILLAGE_SCREENS.find((s) => s.path && route.path.startsWith(`${base.value}${s.path}`))
|
||||||
return s ? t(`village.screens.${s.name}`) : ''
|
return s ? t(`village.screens.${s.name}`) : ''
|
||||||
})
|
})
|
||||||
const picked = computed(() => !!plot.value)
|
const picked = computed(() => !!plot.value)
|
||||||
|
|
||||||
|
// The map draws itself under the menu bar; it needs to know where that ends.
|
||||||
|
const menuBar = ref<HTMLElement | null>(null)
|
||||||
|
const menuBottom = ref(0)
|
||||||
|
provideStage({ menuBottom })
|
||||||
// What the bars, the right column and the phone tab bar cover, so the whole village fits
|
// What the bars, the right column and the phone tab bar cover, so the whole village fits
|
||||||
// into the rest of the screen while land and forest run on beneath them.
|
// into the rest of the screen while land and forest run on beneath them.
|
||||||
const topBars = ref<HTMLElement | null>(null)
|
const topBars = ref<HTMLElement | null>(null)
|
||||||
|
|
@ -78,6 +82,7 @@ function measureInset() {
|
||||||
const W = document.documentElement.clientWidth
|
const W = document.documentElement.clientWidth
|
||||||
const H = document.documentElement.clientHeight
|
const H = document.documentElement.clientHeight
|
||||||
const top = topBars.value?.getBoundingClientRect().bottom ?? 0
|
const top = topBars.value?.getBoundingClientRect().bottom ?? 0
|
||||||
|
menuBottom.value = Math.round(menuBar.value?.getBoundingClientRect().bottom ?? 0)
|
||||||
const side = sideColumn.value?.getBoundingClientRect()
|
const side = sideColumn.value?.getBoundingClientRect()
|
||||||
const shown = side && side.width > 0 && side.height > 0
|
const shown = side && side.width > 0 && side.height > 0
|
||||||
// A column on the right takes its width; on phones the boxes sit at the bottom instead.
|
// A column on the right takes its width; on phones the boxes sit at the bottom instead.
|
||||||
|
|
@ -92,7 +97,7 @@ onMounted(() => {
|
||||||
insetObserver = new ResizeObserver(measureInset)
|
insetObserver = new ResizeObserver(measureInset)
|
||||||
window.addEventListener('resize', measureInset)
|
window.addEventListener('resize', measureInset)
|
||||||
})
|
})
|
||||||
watch([topBars, sideColumn, picked, overview], async () => {
|
watch([topBars, sideColumn, picked, overview, onMap], async () => {
|
||||||
await nextTick()
|
await nextTick()
|
||||||
insetObserver?.disconnect()
|
insetObserver?.disconnect()
|
||||||
for (const el of [topBars.value, sideColumn.value]) if (el) insetObserver?.observe(el)
|
for (const el of [topBars.value, sideColumn.value]) if (el) insetObserver?.observe(el)
|
||||||
|
|
@ -114,11 +119,14 @@ useShortcuts(() => {
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- The centred column: village header, thin notices, then the framed content. -->
|
<!--
|
||||||
|
Every page of the world on one stage: the village (or the map) fills the screen, the
|
||||||
|
menu and the village bar run along the top, the open screen sits in a window on the
|
||||||
|
left and the boxes in a dock on the right.
|
||||||
|
-->
|
||||||
<template>
|
<template>
|
||||||
<!-- The village's own screens: the village fills the screen, bars and windows dock over it. -->
|
<div>
|
||||||
<div v-if="stage">
|
<div v-if="!onMap" class="fixed inset-0 z-0">
|
||||||
<div class="fixed inset-0 z-0">
|
|
||||||
<VillageDiorama
|
<VillageDiorama
|
||||||
v-if="v.village.value"
|
v-if="v.village.value"
|
||||||
v-model:selected="selected"
|
v-model:selected="selected"
|
||||||
|
|
@ -129,9 +137,12 @@ useShortcuts(() => {
|
||||||
:seconds-until="v.secondsUntil"
|
:seconds-until="v.secondsUntil"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- The map draws itself across the screen and puts its panels into the dock. -->
|
||||||
|
<slot v-else />
|
||||||
|
|
||||||
<div class="pointer-events-none fixed inset-0 z-10 flex flex-col">
|
<div class="pointer-events-none fixed inset-0 z-10 flex flex-col">
|
||||||
<div ref="topBars" class="shrink-0">
|
<div ref="topBars" class="shrink-0">
|
||||||
<GameMenuBar class="pointer-events-auto" in-world wide />
|
<div ref="menuBar"><GameMenuBar class="pointer-events-auto" in-world wide /></div>
|
||||||
<div class="space-y-1 px-1 pt-1 sm:px-2">
|
<div class="space-y-1 px-1 pt-1 sm:px-2">
|
||||||
<GameVillageBar v-if="v.village.value && v.resources.value" :village="v.village.value" :resources="v.resources.value" />
|
<GameVillageBar v-if="v.village.value && v.resources.value" :village="v.village.value" :resources="v.resources.value" />
|
||||||
<GameProtectionBar
|
<GameProtectionBar
|
||||||
|
|
@ -150,52 +161,29 @@ useShortcuts(() => {
|
||||||
|
|
||||||
<div class="flex min-h-0 flex-1 items-start gap-2 p-1 pb-14 sm:p-2 md:pb-2">
|
<div class="flex min-h-0 flex-1 items-start gap-2 p-1 pb-14 sm:p-2 md:pb-2">
|
||||||
<!-- Left: the open screen in a window, or on the overview the card of what is picked. -->
|
<!-- Left: the open screen in a window, or on the overview the card of what is picked. -->
|
||||||
<div v-if="overview" v-show="picked" class="scroll-y float pointer-events-auto max-h-full w-full border border-wood-900 bg-parchment-200 p-1.5 sm:w-80">
|
<template v-if="!onMap">
|
||||||
<slot />
|
<div v-if="overview" v-show="picked" class="scroll-y float pointer-events-auto max-h-full w-full border border-wood-900 bg-parchment-200 p-1.5 sm:w-80">
|
||||||
</div>
|
<slot />
|
||||||
<UiWindow v-else class="w-full max-w-[66rem]" :title="screenTitle" :close-to="base">
|
</div>
|
||||||
<slot />
|
<UiWindow v-else class="w-full max-w-[66rem]" :title="screenTitle" :close-to="base">
|
||||||
</UiWindow>
|
<slot />
|
||||||
|
</UiWindow>
|
||||||
|
</template>
|
||||||
|
|
||||||
<!-- Right: the boxes with the numbers that matter at a glance. -->
|
<!-- Right: the village's boxes, or on the map its own panels. -->
|
||||||
|
<!-- On the map it is there from the start: the map's panels teleport into it. -->
|
||||||
<div
|
<div
|
||||||
v-if="v.village.value"
|
v-if="v.village.value || onMap"
|
||||||
ref="sideColumn"
|
ref="sideColumn"
|
||||||
class="scroll-y float pointer-events-auto ml-auto max-h-full w-[17.5rem] shrink-0 border border-wood-900 bg-parchment-200"
|
class="scroll-y float pointer-events-auto ml-auto max-h-full w-[17.5rem] shrink-0 border border-wood-900 bg-parchment-200"
|
||||||
:class="overview && !picked ? 'max-lg:w-full max-lg:self-end max-lg:max-h-[45dvh]' : 'hidden lg:block'"
|
:class="overview && !picked ? 'max-lg:w-full max-lg:self-end max-lg:max-h-[45dvh]' : 'hidden lg:block'"
|
||||||
>
|
>
|
||||||
<VillageOverviewSidebar :village="v.village.value" :base="base" :seconds-until="v.secondsUntil" />
|
<div v-if="onMap" id="stage-dock" class="space-y-2 p-2" />
|
||||||
|
<VillageOverviewSidebar v-else-if="v.village.value" :village="v.village.value" :base="base" :seconds-until="v.secondsUntil" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<GameTabBar :village-id="villageId" />
|
<GameTabBar :village-id="villageId" />
|
||||||
<QuestBook v-if="v.village.value" />
|
<QuestBook v-if="v.village.value" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Map and reports: the village header above a framed page. -->
|
|
||||||
<div v-else>
|
|
||||||
<div class="mx-auto max-w-[1100px] space-y-1 px-1 pt-1.5 sm:px-2">
|
|
||||||
<GameVillageBar v-if="v.village.value && v.resources.value" :village="v.village.value" :resources="v.resources.value" />
|
|
||||||
<GameProtectionBar
|
|
||||||
v-if="v.village.value?.rally.protected_until"
|
|
||||||
:until="v.village.value.rally.protected_until"
|
|
||||||
:village-id="villageId"
|
|
||||||
:seconds-until="v.secondsUntil"
|
|
||||||
/>
|
|
||||||
<VillageFoodWarning
|
|
||||||
v-if="v.village.value"
|
|
||||||
:starvation="v.village.value.starvation"
|
|
||||||
:levy="v.village.value.levy"
|
|
||||||
:seconds-until="v.secondsUntil"
|
|
||||||
/>
|
|
||||||
<p v-if="v.error.value" class="alert" role="alert">{{ v.error.value }}</p>
|
|
||||||
</div>
|
|
||||||
<main class="mx-auto max-w-[1100px] px-1 pt-1 pb-4 sm:px-2">
|
|
||||||
<div class="frame">
|
|
||||||
<slot />
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
<GameTabBar :village-id="villageId" />
|
|
||||||
<QuestBook v-if="v.village.value" />
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import type { InjectionKey, Ref } from 'vue'
|
||||||
|
|
||||||
|
/** What the fullscreen frame tells the page drawn on it: where the menu bar ends. */
|
||||||
|
export interface Stage {
|
||||||
|
/** px from the top of the window to the bottom of the menu bar. */
|
||||||
|
menuBottom: Ref<number>
|
||||||
|
}
|
||||||
|
|
||||||
|
const STAGE: InjectionKey<Stage> = Symbol('stage')
|
||||||
|
|
||||||
|
export const provideStage = (stage: Stage) => provide(STAGE, stage)
|
||||||
|
|
||||||
|
/** The fullscreen frame around the page, or null where a page stands without one. */
|
||||||
|
export const useStage = () => inject(STAGE, null)
|
||||||
|
|
@ -6,9 +6,6 @@ const { current } = useCurrentWorld()
|
||||||
* The village whose header stays on top of every screen in the world: the one in the
|
* The village whose header stays on top of every screen in the world: the one in the
|
||||||
* URL on village screens, else the one last opened in this world (map, reports).
|
* URL on village screens, else the one last opened in this world (map, reports).
|
||||||
*/
|
*/
|
||||||
/** The village's own screens draw their menu over the fullscreen village themselves. */
|
|
||||||
const onVillage = computed(() => route.path.startsWith('/village/'))
|
|
||||||
|
|
||||||
const villageId = computed(() => {
|
const villageId = computed(() => {
|
||||||
if (route.path.startsWith('/village/')) return Number(route.params.id)
|
if (route.path.startsWith('/village/')) return Number(route.params.id)
|
||||||
const worldId = Number(route.params.worldId)
|
const worldId = Number(route.params.worldId)
|
||||||
|
|
@ -19,7 +16,8 @@ const villageId = computed(() => {
|
||||||
<!-- Inside a world: the main menu, then the village header and its screens, like Die Stämme. -->
|
<!-- Inside a world: the main menu, then the village header and its screens, like Die Stämme. -->
|
||||||
<template>
|
<template>
|
||||||
<div class="min-h-dvh pb-14 md:pb-0">
|
<div class="min-h-dvh pb-14 md:pb-0">
|
||||||
<GameMenuBar v-if="!onVillage" in-world />
|
<!-- With a village, GameVillageFrame draws the menu over its fullscreen stage. -->
|
||||||
|
<GameMenuBar v-if="!villageId" in-world />
|
||||||
<GameVillageFrame v-if="villageId" :key="villageId" :village-id="villageId">
|
<GameVillageFrame v-if="villageId" :key="villageId" :village-id="villageId">
|
||||||
<slot />
|
<slot />
|
||||||
</GameVillageFrame>
|
</GameVillageFrame>
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,20 @@ const field = computed(() => ZOOM[zoom.value]!)
|
||||||
const RULER = 26
|
const RULER = 26
|
||||||
const clamp = (n: number, lo: number, hi: number) => Math.max(lo, Math.min(hi, n))
|
const clamp = (n: number, lo: number, hi: number) => Math.max(lo, Math.min(hi, n))
|
||||||
|
|
||||||
// The map fills its box exactly: full width, and the height left on screen.
|
// On the fullscreen stage the map fills the screen under the menu bar, with the village
|
||||||
|
// bar and the dock floating over it; without one it fills its box on the page.
|
||||||
|
const stage = useStage()
|
||||||
|
const staged = !!stage
|
||||||
|
/** The frame's border around the map, in px; none on the stage. */
|
||||||
|
const edge = staged ? 0 : 2
|
||||||
const box = ref<HTMLElement | null>(null)
|
const box = ref<HTMLElement | null>(null)
|
||||||
const area = ref({ w: 800, h: 520 })
|
const area = ref({ w: 800, h: 520 })
|
||||||
function measure() {
|
function measure() {
|
||||||
if (!box.value) return
|
if (!box.value) return
|
||||||
const rect = box.value.getBoundingClientRect()
|
const rect = box.value.getBoundingClientRect()
|
||||||
area.value = { w: Math.floor(rect.width) - 8, h: Math.max(360, Math.floor(window.innerHeight - rect.top - 32)) }
|
area.value = staged
|
||||||
|
? { w: Math.floor(rect.width), h: Math.floor(rect.height) }
|
||||||
|
: { w: Math.floor(rect.width) - 8, h: Math.max(360, Math.floor(window.innerHeight - rect.top - 32)) }
|
||||||
}
|
}
|
||||||
let observer: ResizeObserver | undefined
|
let observer: ResizeObserver | undefined
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|
@ -143,10 +150,10 @@ const from = computed(() => {
|
||||||
const v = bar?.village.value
|
const v = bar?.village.value
|
||||||
return v && v.world_id === worldId ? { id: v.id, x: v.x, y: v.y } : null
|
return v && v.world_id === worldId ? { id: v.id, x: v.x, y: v.y } : null
|
||||||
})
|
})
|
||||||
/** Where a field sits inside the map frame, in px (the frame's border is 2 px). */
|
/** Where a field sits inside the map frame, in px. */
|
||||||
function fieldAt(x: number, y: number) {
|
function fieldAt(x: number, y: number) {
|
||||||
const v = visible.value!
|
const v = visible.value!
|
||||||
return { left: 2 + RULER + (x - v.left + 0.5) * field.value, top: 2 + RULER + (y - v.top) * field.value }
|
return { left: edge + RULER + (x - v.left + 0.5) * field.value, top: edge + RULER + (y - v.top) * field.value }
|
||||||
}
|
}
|
||||||
const popupAt = (x: number, y: number, below: boolean) => {
|
const popupAt = (x: number, y: number, below: boolean) => {
|
||||||
const p = fieldAt(x, y)
|
const p = fieldAt(x, y)
|
||||||
|
|
@ -186,82 +193,82 @@ const continent = computed(() => (rounded.value ? continentOf(rounded.value.x, r
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="p-2.5">
|
<div>
|
||||||
<header class="mb-2 flex flex-wrap items-center justify-between gap-2">
|
<div
|
||||||
<div>
|
ref="box"
|
||||||
<p class="text-xs font-semibold tracking-wide text-ink-500 uppercase">{{ $t('map.title') }}</p>
|
:class="staged ? 'fixed inset-x-0 bottom-0 z-0' : 'relative min-w-0 p-2.5'"
|
||||||
<h1 class="font-display text-lg font-bold text-wood-950">
|
:style="staged ? { top: `${stage!.menuBottom.value}px` } : undefined"
|
||||||
{{ $t('map.continent', { k: continent }) }}
|
>
|
||||||
<span v-if="rounded" class="ml-2 text-lg font-normal text-ink-500 tabular-nums">{{ rounded.x }}|{{ rounded.y }}</span>
|
<!-- A dark wooden frame around the map on a page; edge to edge on the stage. -->
|
||||||
</h1>
|
<div class="h-full overflow-hidden bg-[#4f6129]" :class="staged ? '' : 'border-2 border-wood-900'">
|
||||||
</div>
|
<MapWorldMap
|
||||||
|
v-if="visible"
|
||||||
<div class="flex flex-wrap items-center gap-2">
|
:view="view"
|
||||||
<button type="button" class="btn btn-outline" @click="router.replace({ query: {} })">{{ $t('map.home') }}</button>
|
:left="visible.left"
|
||||||
<div class="flex items-center rounded-sm border border-wood-600 bg-parchment-50">
|
:top="visible.top"
|
||||||
<button type="button" class="btn btn-ghost px-2.5" :disabled="zoom === 0" :aria-label="$t('map.zoom_out')" @click="zoom--">−</button>
|
:cols="visible.cols"
|
||||||
<button type="button" class="btn btn-ghost px-2.5" :disabled="zoom === ZOOM.length - 1" :aria-label="$t('map.zoom_in')" @click="zoom++">+</button>
|
:rows="visible.rows"
|
||||||
</div>
|
:width="area.w"
|
||||||
</div>
|
:height="area.h"
|
||||||
</header>
|
:field="field"
|
||||||
|
:selected="selected"
|
||||||
<p v-if="error" class="alert mb-4" role="alert">{{ error }}</p>
|
@select="selected = $event"
|
||||||
|
@hover="hovered = $event"
|
||||||
<div class="grid gap-3 lg:grid-cols-[1fr_16rem]">
|
@drag="onDragMove"
|
||||||
<div ref="box" class="relative min-w-0">
|
@dragend="onDragEnd"
|
||||||
<!-- A dark wooden frame around the map, like a board on the table. -->
|
@pan="pan"
|
||||||
<div class="overflow-hidden border-2 border-wood-900 bg-[#4f6129]">
|
|
||||||
<MapWorldMap
|
|
||||||
v-if="visible"
|
|
||||||
:view="view"
|
|
||||||
:left="visible.left"
|
|
||||||
:top="visible.top"
|
|
||||||
:cols="visible.cols"
|
|
||||||
:rows="visible.rows"
|
|
||||||
:width="area.w"
|
|
||||||
:height="area.h"
|
|
||||||
:field="field"
|
|
||||||
:selected="selected"
|
|
||||||
@select="selected = $event"
|
|
||||||
@hover="hovered = $event"
|
|
||||||
@drag="onDragMove"
|
|
||||||
@dragend="onDragEnd"
|
|
||||||
@pan="pan"
|
|
||||||
/>
|
|
||||||
<p v-else class="py-24 text-center text-sm text-parchment-100">{{ $t('common.loading') }}</p>
|
|
||||||
</div>
|
|
||||||
<MapFieldPopup
|
|
||||||
v-if="tip"
|
|
||||||
:village="tip"
|
|
||||||
:from="from"
|
|
||||||
class="pointer-events-none absolute z-20 -translate-x-1/2 -translate-y-full"
|
|
||||||
:style="popupAt(tip.x, tip.y, false)"
|
|
||||||
/>
|
/>
|
||||||
<MapFieldPopup
|
<p v-else class="py-24 text-center text-sm text-parchment-100">{{ $t('common.loading') }}</p>
|
||||||
v-if="menu"
|
|
||||||
:village="menu"
|
|
||||||
:from="from"
|
|
||||||
actions
|
|
||||||
class="absolute z-20 -translate-x-1/2"
|
|
||||||
:style="popupAt(menu.x, menu.y, true)"
|
|
||||||
@center="goTo(menu)"
|
|
||||||
@close="selected = null"
|
|
||||||
/>
|
|
||||||
<div class="mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-ink-500">
|
|
||||||
<span>{{ $t('map.controls') }}</span>
|
|
||||||
<span v-if="busy">{{ $t('common.loading') }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<MapFieldPopup
|
||||||
|
v-if="tip"
|
||||||
|
:village="tip"
|
||||||
|
:from="from"
|
||||||
|
class="pointer-events-none absolute z-20 -translate-x-1/2 -translate-y-full"
|
||||||
|
:style="popupAt(tip.x, tip.y, false)"
|
||||||
|
/>
|
||||||
|
<MapFieldPopup
|
||||||
|
v-if="menu"
|
||||||
|
:village="menu"
|
||||||
|
:from="from"
|
||||||
|
actions
|
||||||
|
class="absolute z-20 -translate-x-1/2"
|
||||||
|
:style="popupAt(menu.x, menu.y, true)"
|
||||||
|
@center="goTo(menu)"
|
||||||
|
@close="selected = null"
|
||||||
|
/>
|
||||||
|
<!-- Phones have no dock: home and zoom float over the map instead. -->
|
||||||
|
<div v-if="staged" class="float absolute bottom-16 left-2 z-20 flex border border-wood-900 bg-parchment-200 lg:hidden">
|
||||||
|
<button type="button" class="btn btn-ghost" @click="router.replace({ query: {} })">{{ $t('map.home') }}</button>
|
||||||
|
<button type="button" class="btn btn-ghost px-2.5" :disabled="zoom === 0" :aria-label="$t('map.zoom_out')" @click="zoom--">−</button>
|
||||||
|
<button type="button" class="btn btn-ghost px-2.5" :disabled="zoom === ZOOM.length - 1" :aria-label="$t('map.zoom_in')" @click="zoom++">+</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- The map's panels go into the stage's dock on the right. -->
|
||||||
|
<Teleport defer to="#stage-dock" :disabled="!staged">
|
||||||
|
<div class="space-y-2" :class="staged ? '' : 'p-2.5 pt-0'">
|
||||||
|
<section class="panel">
|
||||||
|
<div class="panel-head">
|
||||||
|
<h1 class="panel-title">{{ $t('map.continent', { k: continent }) }}</h1>
|
||||||
|
<span v-if="rounded" class="text-sm text-ink-500 tabular-nums">{{ rounded.x }}|{{ rounded.y }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-1.5 p-2">
|
||||||
|
<button type="button" class="btn btn-outline" @click="router.replace({ query: {} })">{{ $t('map.home') }}</button>
|
||||||
|
<div class="ml-auto flex items-center border border-wood-600 bg-parchment-50">
|
||||||
|
<button type="button" class="btn btn-ghost px-2.5" :disabled="zoom === 0" :aria-label="$t('map.zoom_out')" @click="zoom--">−</button>
|
||||||
|
<button type="button" class="btn btn-ghost px-2.5" :disabled="zoom === ZOOM.length - 1" :aria-label="$t('map.zoom_in')" @click="zoom++">+</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p v-if="error" class="alert m-2 mt-0" role="alert">{{ error }}</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
<aside class="space-y-5">
|
|
||||||
<section class="panel overflow-hidden">
|
<section class="panel overflow-hidden">
|
||||||
<div class="panel-head">
|
<div class="panel-head">
|
||||||
<h2 class="panel-title">{{ $t('map.minimap') }}</h2>
|
<h2 class="panel-title">{{ $t('map.minimap') }}</h2>
|
||||||
<span v-if="overview.view.value" class="text-xs text-ink-500 tabular-nums">
|
<span v-if="overview.view.value" class="text-xs text-ink-500 tabular-nums">{{ overview.view.value.w }}×{{ overview.view.value.h }}</span>
|
||||||
{{ overview.view.value.w }}×{{ overview.view.value.h }}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="border-b-2 border-wood-700">
|
<div class="border-b border-wood-700">
|
||||||
<MapMiniMap
|
<MapMiniMap
|
||||||
v-if="overview.view.value"
|
v-if="overview.view.value"
|
||||||
:overview="overview.view.value"
|
:overview="overview.view.value"
|
||||||
|
|
@ -270,8 +277,7 @@ const continent = computed(() => (rounded.value ? continentOf(rounded.value.x, r
|
||||||
/>
|
/>
|
||||||
<p v-else class="py-16 text-center text-sm text-ink-500">{{ $t('common.loading') }}</p>
|
<p v-else class="py-16 text-center text-sm text-ink-500">{{ $t('common.loading') }}</p>
|
||||||
</div>
|
</div>
|
||||||
<form class="flex items-center gap-1.5 p-3" @submit.prevent="jump">
|
<form class="flex items-center gap-1 p-2" @submit.prevent="jump">
|
||||||
<span class="mr-1 text-sm font-semibold text-ink-700">{{ $t('map.center_map') }}</span>
|
|
||||||
<label class="sr-only" for="jump-x">x</label>
|
<label class="sr-only" for="jump-x">x</label>
|
||||||
<input id="jump-x" v-model.number="jumpX" class="input w-16 px-1.5 py-1 text-center tabular-nums" type="number" :min="lo" :max="hi" />
|
<input id="jump-x" v-model.number="jumpX" class="input w-16 px-1.5 py-1 text-center tabular-nums" type="number" :min="lo" :max="hi" />
|
||||||
<span class="font-semibold text-ink-500">|</span>
|
<span class="font-semibold text-ink-500">|</span>
|
||||||
|
|
@ -280,19 +286,22 @@ const continent = computed(() => (rounded.value ? continentOf(rounded.value.x, r
|
||||||
<button type="submit" class="btn btn-primary ml-auto py-1">{{ $t('map.jump') }}</button>
|
<button type="submit" class="btn btn-primary ml-auto py-1">{{ $t('map.jump') }}</button>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<MapInfoCard :village="shown" :at="selected" @center="goTo" />
|
<MapInfoCard :village="shown" :at="selected" @center="goTo" />
|
||||||
|
|
||||||
<section class="panel">
|
<section class="panel">
|
||||||
<div class="panel-head">
|
<div class="panel-head">
|
||||||
<h2 class="panel-title">{{ $t('map.legend.title') }}</h2>
|
<h2 class="panel-title">{{ $t('map.legend.title') }}</h2>
|
||||||
</div>
|
</div>
|
||||||
<ul class="panel-body space-y-2 text-sm">
|
<ul class="panel-body space-y-1.5 text-sm">
|
||||||
<li class="flex items-center gap-2"><span class="size-3 border border-wood-900 bg-[#d9b44a]" /> {{ $t('map.legend.own') }} <span class="ml-auto tabular-nums text-ink-500">{{ counts.own }}</span></li>
|
<li class="flex items-center gap-2"><span class="size-3 border border-wood-900 bg-[#d9b44a]" /> {{ $t('map.legend.own') }} <span class="ml-auto tabular-nums text-ink-500">{{ counts.own }}</span></li>
|
||||||
<li class="flex items-center gap-2"><span class="size-3 border border-wood-900 bg-[#962a1f]" /> {{ $t('map.legend.players') }} <span class="ml-auto tabular-nums text-ink-500">{{ counts.players }}</span></li>
|
<li class="flex items-center gap-2"><span class="size-3 border border-wood-900 bg-[#962a1f]" /> {{ $t('map.legend.players') }} <span class="ml-auto tabular-nums text-ink-500">{{ counts.players }}</span></li>
|
||||||
<li class="flex items-center gap-2"><span class="size-3 border border-wood-900 bg-[#8b9094]" /> {{ $t('map.legend.barbarians') }} <span class="ml-auto tabular-nums text-ink-500">{{ counts.barbarians }}</span></li>
|
<li class="flex items-center gap-2"><span class="size-3 border border-wood-900 bg-[#8b9094]" /> {{ $t('map.legend.barbarians') }} <span class="ml-auto tabular-nums text-ink-500">{{ counts.barbarians }}</span></li>
|
||||||
<li class="pt-1 text-xs text-ink-500">{{ $t('map.legend.lines') }}</li>
|
<li class="pt-1 text-xs text-ink-500">{{ $t('map.legend.lines') }}</li>
|
||||||
|
<li class="text-xs text-ink-500">{{ $t('map.controls') }}<template v-if="busy"> · {{ $t('common.loading') }}</template></li>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
</aside>
|
</div>
|
||||||
</div>
|
</Teleport>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,7 @@ const DOT = { won: 'bg-moss-600', losses: 'bg-gold-500', lost: 'bg-blood-700', i
|
||||||
<!-- The report list, like Die Stämme's: kinds on the left; a dot for the outcome, unread in bold, newest first; act on checked rows. -->
|
<!-- The report list, like Die Stämme's: kinds on the left; a dot for the outcome, unread in bold, newest first; act on checked rows. -->
|
||||||
<template>
|
<template>
|
||||||
<div class="space-y-2 p-2.5">
|
<div class="space-y-2 p-2.5">
|
||||||
<h1 class="font-display text-lg font-bold text-wood-950">{{ $t('reports.title') }}</h1>
|
<div class="grid gap-2 @2xl:grid-cols-[10rem_minmax(0,1fr)]">
|
||||||
<div class="grid gap-2 md:grid-cols-[10rem_minmax(0,1fr)]">
|
|
||||||
<UiSideMenu :items="kinds" class="self-start" />
|
<UiSideMenu :items="kinds" class="self-start" />
|
||||||
|
|
||||||
<section class="panel min-w-0">
|
<section class="panel min-w-0">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue