2026-10-28 18:54:20 +00:00
|
|
|
|
<script setup lang="ts">
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
import type { BuildingType, Resources, VillageState } from '~/types/game'
|
2026-10-29 10:15:26 +00:00
|
|
|
|
import { buildScene, type SceneBuilding, type SceneInset, type ScenePlot } from '~/diorama/scene'
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
import type { BuildingTag } from '~/utils/buildingTags'
|
2026-10-28 18:54:20 +00:00
|
|
|
|
|
2026-10-28 20:03:51 +00:00
|
|
|
|
const props = defineProps<{
|
|
|
|
|
|
village: VillageState
|
|
|
|
|
|
/** Whole seconds until a server timestamp, on the server's clock. */
|
|
|
|
|
|
secondsUntil: (iso: string) => number
|
2026-10-29 09:56:52 +00:00
|
|
|
|
/** Fill the whole stage at any shape, without the sideways scroll of narrow frames. */
|
|
|
|
|
|
fill?: boolean
|
2026-10-30 10:27:18 +00:00
|
|
|
|
/** A picture only (the landing page): no pan, zoom or land beyond the view. */
|
2026-10-30 10:17:34 +00:00
|
|
|
|
still?: boolean
|
2026-10-29 10:15:26 +00:00
|
|
|
|
/** With `fill`: pixels at the edges that windows cover; the whole village fits into the rest. */
|
|
|
|
|
|
inset?: SceneInset
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
/** Projected stock, for the storage's tag. */
|
|
|
|
|
|
resources?: Resources | null
|
|
|
|
|
|
/** A window or card is open: a click in the village closes it instead of opening another. */
|
|
|
|
|
|
dismiss?: boolean
|
2026-10-28 20:03:51 +00:00
|
|
|
|
}>()
|
2026-10-28 18:54:20 +00:00
|
|
|
|
/** Id of the building whose details are open. */
|
|
|
|
|
|
const selected = defineModel<number | null>('selected', { default: null })
|
2026-10-28 21:14:56 +00:00
|
|
|
|
/** Type whose empty plot was picked, to build it. */
|
|
|
|
|
|
const plot = defineModel<BuildingType | null>('plot', { default: null })
|
2026-10-28 18:54:20 +00:00
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
|
2026-10-28 19:33:14 +00:00
|
|
|
|
// The scene is cut to the stage's shape, so the land always fills it edge to edge.
|
|
|
|
|
|
// On narrow screens the stage keeps a minimum width and scrolls sideways instead.
|
|
|
|
|
|
const scroller = ref<HTMLElement | null>(null)
|
|
|
|
|
|
const stage = ref<HTMLElement | null>(null)
|
|
|
|
|
|
const size = ref({ w: 1200, h: 520 })
|
|
|
|
|
|
const aspect = computed(() => Math.round((size.value.w / Math.max(1, size.value.h)) * 10) / 10)
|
2026-10-29 10:15:26 +00:00
|
|
|
|
const scene = computed(() =>
|
2026-10-30 10:27:18 +00:00
|
|
|
|
props.fill ? buildScene(props.village, { width: size.value.w, height: size.value.h, inset: props.inset, surroundings: !props.still }) : buildScene(props.village, aspect.value),
|
2026-10-29 10:15:26 +00:00
|
|
|
|
)
|
2026-10-28 18:54:20 +00:00
|
|
|
|
|
|
|
|
|
|
function measure() {
|
2026-10-28 19:33:14 +00:00
|
|
|
|
const el = stage.value
|
|
|
|
|
|
if (el && el.clientWidth && el.clientHeight) size.value = { w: el.clientWidth, h: el.clientHeight }
|
2026-10-28 18:54:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
let observer: ResizeObserver | undefined
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
measure()
|
|
|
|
|
|
observer = new ResizeObserver(measure)
|
2026-10-28 19:33:14 +00:00
|
|
|
|
if (stage.value) observer.observe(stage.value)
|
|
|
|
|
|
// Start a scrolled phone view on the village centre.
|
|
|
|
|
|
const sc = scroller.value
|
|
|
|
|
|
if (sc) sc.scrollLeft = (sc.scrollWidth - sc.clientWidth) / 2
|
2026-10-28 18:54:20 +00:00
|
|
|
|
})
|
|
|
|
|
|
onBeforeUnmount(() => observer?.disconnect())
|
|
|
|
|
|
|
2026-10-30 10:17:34 +00:00
|
|
|
|
// On a stage the player pans and zooms over the land round the village.
|
|
|
|
|
|
const { view, viewBox, panning, zoomIn, zoomOut, reset, canZoomIn, canZoomOut, atHome } = useDioramaCamera({
|
|
|
|
|
|
id: () => props.village.id,
|
|
|
|
|
|
stage,
|
|
|
|
|
|
home: () => scene.value.home,
|
|
|
|
|
|
bounds: () => scene.value.bounds,
|
|
|
|
|
|
inset: () => props.inset ?? { top: 0, right: 0, bottom: 0, left: 0 },
|
2026-10-30 10:27:18 +00:00
|
|
|
|
enabled: () => !!props.fill && !props.still,
|
2026-10-30 10:17:34 +00:00
|
|
|
|
})
|
|
|
|
|
|
/** The zoom buttons sit in the bottom right corner of the part no window covers. */
|
|
|
|
|
|
const controlsAt = computed(() => ({ right: `${(props.inset?.right ?? 0) + 8}px`, bottom: `${(props.inset?.bottom ?? 0) + 8}px` }))
|
|
|
|
|
|
|
feat: building portraits, screen headers and a livelier village: shadows, smoke, walkers, a pond
Each building screen opens with the building drawn as it stands, its level and what it
does; the HQ list and the building cards show the same portraits. In the village,
buildings and trees cast flat shadows, chimneys, forges and kilns smoke, villagers walk
the roads to the zones they work in (more where more work), and a pond lies in the
meadow. Motion stops for players who prefer reduced motion.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:46:15 +00:00
|
|
|
|
// Walkers and smoke only move for players who don't ask for reduced motion.
|
|
|
|
|
|
const motion = ref(false)
|
|
|
|
|
|
onMounted(() => (motion.value = !window.matchMedia('(prefers-reduced-motion: reduce)').matches))
|
|
|
|
|
|
|
2026-10-30 10:52:55 +00:00
|
|
|
|
// The picture is WebGL (useDioramaGl); the SVG over it only takes clicks and focus and
|
|
|
|
|
|
// carries the tags. The ground rings under the open building and the one keyboard focus
|
|
|
|
|
|
// is on are drawn in the picture, under the buildings.
|
|
|
|
|
|
const canvas = ref<HTMLCanvasElement | null>(null)
|
|
|
|
|
|
const focused = ref<{ id: number; dashed: boolean } | null>(null)
|
|
|
|
|
|
const onFocus = (id: number, e: FocusEvent) => (focused.value = { id, dashed: (e.target as Element).matches(':focus-visible') })
|
|
|
|
|
|
const marks = computed(() => [
|
|
|
|
|
|
...(selected.value !== null ? [{ id: selected.value, dashed: false }] : []),
|
|
|
|
|
|
...(focused.value?.dashed ? [focused.value] : []),
|
|
|
|
|
|
])
|
|
|
|
|
|
useDioramaGl({ canvas, scene: () => scene.value, view: () => view.value, size: () => size.value, motion: () => motion.value, marks: () => marks.value, background: '#6a7049' })
|
|
|
|
|
|
const targets = computed(() => scene.value.objects.flatMap((o) => (o.building ? [{ key: o.key, b: o.building }] : [])))
|
|
|
|
|
|
|
2026-10-28 19:33:14 +00:00
|
|
|
|
const name = (b: SceneBuilding) => t(`buildings.${b.type}`)
|
|
|
|
|
|
const label = (b: SceneBuilding) => t('village.diorama.label', { name: name(b), level: b.level })
|
2026-10-28 21:14:56 +00:00
|
|
|
|
const plotLabel = (p: ScenePlot) => t(p.another ? 'village.diorama.plot_another' : 'village.diorama.plot', { name: t(`buildings.${p.type}`) })
|
2026-10-28 18:54:20 +00:00
|
|
|
|
|
2026-10-28 21:14:56 +00:00
|
|
|
|
// Buildings stand still: hovering changes nothing but the cursor and the tooltip.
|
|
|
|
|
|
// A click opens the details and marks the ground under it.
|
2026-10-28 19:33:14 +00:00
|
|
|
|
function toggle(id: number) {
|
2026-10-28 21:14:56 +00:00
|
|
|
|
plot.value = null
|
2026-10-28 19:33:14 +00:00
|
|
|
|
selected.value = selected.value === id ? null : id
|
|
|
|
|
|
}
|
2026-10-28 21:14:56 +00:00
|
|
|
|
function pick(type: BuildingType) {
|
|
|
|
|
|
selected.value = null
|
|
|
|
|
|
plot.value = plot.value === type ? null : type
|
|
|
|
|
|
}
|
|
|
|
|
|
function clear() {
|
|
|
|
|
|
selected.value = null
|
|
|
|
|
|
plot.value = null
|
|
|
|
|
|
}
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
// A pointer click while something is open only closes it, so a stray click never swaps
|
|
|
|
|
|
// the window for another; keys still open what has focus.
|
|
|
|
|
|
const press = (id: number) => (props.dismiss ? clear() : toggle(id))
|
|
|
|
|
|
const pressPlot = (type: BuildingType) => (props.dismiss ? clear() : pick(type))
|
2026-10-28 18:54:20 +00:00
|
|
|
|
|
2026-10-30 10:17:34 +00:00
|
|
|
|
/** viewBox units per screen pixel: badges keep the same size however the scene is scaled or zoomed. */
|
|
|
|
|
|
const k = computed(() => (view.value.w / Math.max(1, size.value.w)) * (size.value.w < 900 ? 0.85 : 1))
|
2026-10-28 18:54:20 +00:00
|
|
|
|
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
// Every building wears a tag like the old village views: its level and the one number
|
|
|
|
|
|
// that says what it does now (app/utils/buildingTags.ts). Sizes are screen pixels, scaled
|
|
|
|
|
|
// by k into the scene, so tags read the same however the village is scaled.
|
|
|
|
|
|
const TAG = { h: 20, chip: 20, icon: 14, gap: 4, pad: 6, font: 12 }
|
|
|
|
|
|
const FONT = 'ui-sans-serif, system-ui, sans-serif'
|
|
|
|
|
|
let measurer: CanvasRenderingContext2D | null = null
|
|
|
|
|
|
const widths = new Map<string, number>()
|
|
|
|
|
|
function textWidth(text: string) {
|
|
|
|
|
|
if (!widths.has(text)) {
|
|
|
|
|
|
measurer ??= import.meta.client ? document.createElement('canvas').getContext('2d') : null
|
|
|
|
|
|
if (measurer) measurer.font = `700 ${TAG.font}px ${FONT}`
|
|
|
|
|
|
widths.set(text, measurer ? Math.ceil(measurer.measureText(text).width) : text.length * 7.5)
|
|
|
|
|
|
}
|
|
|
|
|
|
return widths.get(text)!
|
|
|
|
|
|
}
|
|
|
|
|
|
const TONES = {
|
|
|
|
|
|
plain: { fill: '#f3e7c9', stroke: '#57391f', text: '#2f2013', icon: '#57391f' },
|
|
|
|
|
|
warn: { fill: '#e8cd7c', stroke: '#8a6a1c', text: '#2f2013', icon: '#57391f' },
|
|
|
|
|
|
alarm: { fill: '#7b1e16', stroke: '#4a120d', text: '#f3e7c9', icon: '#f3e7c9' },
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Tags that would overlap move up above the one in front, nearest buildings first.
|
2026-10-28 19:33:14 +00:00
|
|
|
|
const badges = computed(() => {
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
const K = k.value
|
2026-10-28 19:33:14 +00:00
|
|
|
|
const list = scene.value.objects.flatMap((o) => (o.building?.focusable ? [o.building] : []))
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
const placed: { b: SceneBuilding; info: BuildingTag | null; x: number; y: number; w: number; h: number }[] = []
|
|
|
|
|
|
const overlaps = (x: number, y: number, w: number, h: number) =>
|
|
|
|
|
|
placed.some((p) => Math.abs(p.x - x) < (p.w + w) / 2 + 2 * K && Math.abs(p.y - y) < (p.h + h) / 2 + 2 * K)
|
2026-10-28 19:33:14 +00:00
|
|
|
|
for (const b of [...list].sort((p, q) => q.label[1] - p.label[1])) {
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
const building = props.village.buildings.find((x) => x.id === b.id)
|
|
|
|
|
|
const info = building && props.resources ? buildingTag(props.village, building, props.resources, props.secondsUntil, t) : null
|
|
|
|
|
|
const inner = info ? TAG.pad + (info.icon ? TAG.icon + TAG.gap : 0) + textWidth(info.text) + TAG.pad : 0
|
|
|
|
|
|
const w = (TAG.chip + inner) * K
|
|
|
|
|
|
const h = TAG.h * K
|
2026-10-28 19:33:14 +00:00
|
|
|
|
const [x] = b.label
|
|
|
|
|
|
let y = b.label[1]
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
for (let n = 0; n < 8 && overlaps(x, y, w, h); n++) y -= h * 1.2
|
|
|
|
|
|
placed.push({ b, info, x, y, w, h })
|
2026-10-28 19:33:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
return placed
|
|
|
|
|
|
})
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
const tagTitle = (b: SceneBuilding, info: BuildingTag | null) => [label(b), info?.title].filter(Boolean).join(' · ')
|
2026-10-28 20:03:51 +00:00
|
|
|
|
|
2026-10-28 21:14:56 +00:00
|
|
|
|
// Countdowns sit right above what is being built: over the level badge, or over the
|
|
|
|
|
|
// scaffold of a new building.
|
2026-10-28 20:03:51 +00:00
|
|
|
|
// A timer that would cover another timer or a level badge moves up until it is clear.
|
|
|
|
|
|
const timers = computed(() => {
|
|
|
|
|
|
const K = k.value
|
2026-10-29 13:09:03 +00:00
|
|
|
|
const half = { w: 41 * K, h: 12.5 * K }
|
2026-10-28 20:03:51 +00:00
|
|
|
|
const placed: { x: number; y: number }[] = []
|
|
|
|
|
|
const hits = (x: number, y: number) =>
|
|
|
|
|
|
placed.some((p) => Math.abs(p.x - x) < half.w * 2 && Math.abs(p.y - y) < half.h * 2) ||
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
badges.value.some((p) => Math.abs(p.x - x) < half.w + p.w / 2 && Math.abs(p.y - y) < half.h + p.h / 2)
|
2026-10-28 20:03:51 +00:00
|
|
|
|
return scene.value.timers
|
|
|
|
|
|
.map((tm) => {
|
|
|
|
|
|
const badge = tm.buildingId !== null ? badges.value.find((p) => p.b.id === tm.buildingId) : undefined
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
const lift = badge ? 24 : 2
|
2026-10-28 20:03:51 +00:00
|
|
|
|
return { ...tm, x: badge?.x ?? tm.at[0], y: (badge?.y ?? tm.at[1]) - lift * K }
|
|
|
|
|
|
})
|
|
|
|
|
|
.sort((a, b) => b.y - a.y)
|
|
|
|
|
|
.map((tm) => {
|
|
|
|
|
|
let y = tm.y
|
|
|
|
|
|
for (let n = 0; n < 8 && hits(tm.x, y); n++) y -= half.h * 2.1
|
|
|
|
|
|
placed.push({ x: tm.x, y })
|
|
|
|
|
|
return { ...tm, y }
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
2026-10-28 19:33:14 +00:00
|
|
|
|
</script>
|
2026-10-28 18:54:20 +00:00
|
|
|
|
|
2026-10-28 19:33:14 +00:00
|
|
|
|
<template>
|
2026-10-30 10:17:34 +00:00
|
|
|
|
<div ref="scroller" class="relative h-full w-full overflow-y-hidden bg-[#6a7049]" :class="fill ? 'overflow-x-hidden' : 'overflow-x-auto'">
|
2026-10-30 10:52:55 +00:00
|
|
|
|
<div ref="stage" class="relative h-full" :class="[fill ? (still ? '' : 'pan touch-none') : 'min-w-[640px]', { panning }]">
|
|
|
|
|
|
<canvas ref="canvas" class="absolute inset-0 block h-full w-full" aria-hidden="true" />
|
2026-10-28 19:33:14 +00:00
|
|
|
|
<svg
|
2026-10-30 10:52:55 +00:00
|
|
|
|
class="absolute inset-0 block h-full w-full select-none"
|
2026-10-30 10:17:34 +00:00
|
|
|
|
:viewBox="viewBox"
|
2026-10-28 19:33:14 +00:00
|
|
|
|
preserveAspectRatio="xMidYMid slice"
|
|
|
|
|
|
role="group"
|
|
|
|
|
|
:aria-label="$t('village.diorama.title')"
|
2026-10-28 21:14:56 +00:00
|
|
|
|
@click="clear"
|
2026-10-28 19:33:14 +00:00
|
|
|
|
>
|
2026-10-28 21:14:56 +00:00
|
|
|
|
<!-- Empty plots: nothing to see, but each opens its building type's build card. -->
|
|
|
|
|
|
<ellipse
|
|
|
|
|
|
v-for="p in scene.plots"
|
|
|
|
|
|
:key="p.key"
|
|
|
|
|
|
class="plot"
|
|
|
|
|
|
:class="{ 'is-selected': plot === p.type }"
|
|
|
|
|
|
v-bind="p.ring"
|
|
|
|
|
|
role="button"
|
|
|
|
|
|
tabindex="0"
|
|
|
|
|
|
:aria-label="plotLabel(p)"
|
|
|
|
|
|
:aria-pressed="plot === p.type"
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
@click.stop="pressPlot(p.type)"
|
2026-10-28 21:14:56 +00:00
|
|
|
|
@keydown.enter.prevent="pick(p.type)"
|
|
|
|
|
|
@keydown.space.prevent="pick(p.type)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<title>{{ plotLabel(p) }}</title>
|
|
|
|
|
|
</ellipse>
|
|
|
|
|
|
|
2026-10-29 13:09:03 +00:00
|
|
|
|
<!-- The wall is thin: a wide band along its ring opens it too. -->
|
|
|
|
|
|
<ellipse
|
|
|
|
|
|
v-if="scene.wallBand"
|
|
|
|
|
|
class="band"
|
|
|
|
|
|
v-bind="scene.wallBand.ring"
|
|
|
|
|
|
:stroke-width="scene.wallBand.width"
|
|
|
|
|
|
aria-hidden="true"
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
@click.stop="press(scene.wallBand.id)"
|
2026-10-29 13:09:03 +00:00
|
|
|
|
/>
|
|
|
|
|
|
|
2026-10-30 10:52:55 +00:00
|
|
|
|
<!-- Each building's outline, back to front, so the one in front takes the click. -->
|
|
|
|
|
|
<g
|
|
|
|
|
|
v-for="{ key, b } in targets"
|
|
|
|
|
|
:key="key"
|
|
|
|
|
|
class="bld"
|
|
|
|
|
|
:role="b.focusable ? 'button' : undefined"
|
|
|
|
|
|
:tabindex="b.focusable ? 0 : -1"
|
|
|
|
|
|
:aria-hidden="b.focusable ? undefined : 'true'"
|
|
|
|
|
|
:aria-label="b.focusable ? label(b) : undefined"
|
|
|
|
|
|
:aria-pressed="b.focusable ? selected === b.id : undefined"
|
|
|
|
|
|
@click.stop="press(b.id)"
|
|
|
|
|
|
@keydown.enter.prevent="toggle(b.id)"
|
|
|
|
|
|
@keydown.space.prevent="toggle(b.id)"
|
|
|
|
|
|
@focus="onFocus(b.id, $event)"
|
|
|
|
|
|
@blur="focused = null"
|
|
|
|
|
|
>
|
|
|
|
|
|
<polygon v-if="b.hit" class="hit" :points="b.hit" />
|
|
|
|
|
|
<title>{{ label(b) }}</title>
|
2026-10-29 14:50:07 +00:00
|
|
|
|
</g>
|
|
|
|
|
|
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
<!-- Building tags (level and what it does now) and countdowns. Flat colours only. -->
|
|
|
|
|
|
<g class="pointer-events-none" :font-family="FONT" text-anchor="middle">
|
2026-10-29 13:09:03 +00:00
|
|
|
|
<g
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
v-for="{ b, info, x, y, w } in badges"
|
2026-10-29 13:09:03 +00:00
|
|
|
|
:key="`badge-${b.id}`"
|
|
|
|
|
|
class="pointer-events-auto cursor-pointer"
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
:transform="`translate(${x - w / 2} ${y}) scale(${k})`"
|
|
|
|
|
|
@click.stop="press(b.id)"
|
2026-10-29 13:09:03 +00:00
|
|
|
|
>
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
<title>{{ tagTitle(b, info) }}</title>
|
|
|
|
|
|
<rect
|
|
|
|
|
|
:width="w / k"
|
|
|
|
|
|
:height="TAG.h"
|
|
|
|
|
|
:y="-TAG.h / 2"
|
|
|
|
|
|
:fill="TONES[info?.tone ?? 'plain'].fill"
|
|
|
|
|
|
:stroke="selected === b.id ? '#7b1e16' : TONES[info?.tone ?? 'plain'].stroke"
|
|
|
|
|
|
:stroke-width="selected === b.id ? 2.4 : 1.4"
|
2026-10-28 18:54:20 +00:00
|
|
|
|
/>
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
<rect :width="TAG.chip" :height="TAG.h" :y="-TAG.h / 2" :fill="b.upgrading ? '#c49a2c' : '#57391f'" />
|
|
|
|
|
|
<text :x="TAG.chip / 2" :y="4.3" :font-size="TAG.font" font-weight="700" :fill="b.upgrading ? '#1f150c' : '#f3e7c9'">{{ b.level }}</text>
|
|
|
|
|
|
<template v-if="info">
|
|
|
|
|
|
<g v-if="info.icon" :transform="`translate(${TAG.chip + TAG.pad} ${-TAG.icon / 2})`" :style="{ color: TONES[info.tone].icon }">
|
|
|
|
|
|
<IconResource v-if="info.icon.kind === 'resource'" :resource="info.icon.name" :width="TAG.icon" :height="TAG.icon" />
|
|
|
|
|
|
<IconUnit v-else-if="info.icon.kind === 'unit'" :unit="info.icon.name" :width="TAG.icon" :height="TAG.icon" />
|
|
|
|
|
|
<IconUi v-else :name="info.icon.name" :width="TAG.icon" :height="TAG.icon" />
|
|
|
|
|
|
</g>
|
|
|
|
|
|
<text
|
|
|
|
|
|
:x="TAG.chip + TAG.pad + (info.icon ? TAG.icon + TAG.gap : 0)"
|
|
|
|
|
|
:y="4.3"
|
|
|
|
|
|
text-anchor="start"
|
|
|
|
|
|
:font-size="TAG.font"
|
|
|
|
|
|
font-weight="700"
|
|
|
|
|
|
:fill="TONES[info.tone].text"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ info.text }}
|
|
|
|
|
|
</text>
|
|
|
|
|
|
</template>
|
2026-10-28 18:54:20 +00:00
|
|
|
|
</g>
|
2026-10-28 20:03:51 +00:00
|
|
|
|
|
2026-10-29 13:09:03 +00:00
|
|
|
|
<g
|
|
|
|
|
|
v-for="tm in timers"
|
|
|
|
|
|
:key="`timer-${tm.orderId}`"
|
|
|
|
|
|
:class="tm.buildingId ? 'pointer-events-auto cursor-pointer' : ''"
|
|
|
|
|
|
:transform="`translate(${tm.x} ${tm.y})`"
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
@click.stop="tm.buildingId && press(tm.buildingId)"
|
2026-10-29 13:09:03 +00:00
|
|
|
|
>
|
|
|
|
|
|
<rect :x="-39 * k" :y="-11.5 * k" :width="78 * k" :height="22 * k" :rx="2 * k" fill="#2f2013" stroke="#c49a2c" :stroke-width="1.2 * k" />
|
|
|
|
|
|
<g :transform="`translate(${-27.5 * k} ${-0.5 * k}) scale(${1.15 * k})`" fill="none" stroke="#d9b44a" stroke-width="1.4" stroke-linecap="round">
|
2026-10-28 20:03:51 +00:00
|
|
|
|
<circle r="5" />
|
|
|
|
|
|
<path d="M0 -3v3l2 1.5" />
|
|
|
|
|
|
</g>
|
2026-10-29 13:09:03 +00:00
|
|
|
|
<text :x="7 * k" :y="4.6 * k" :font-size="13 * k" font-weight="700" fill="#f3e7c9" class="tabular-nums">
|
2026-10-28 20:03:51 +00:00
|
|
|
|
{{ formatDuration(secondsUntil(tm.finishesAt)) }}
|
|
|
|
|
|
</text>
|
|
|
|
|
|
</g>
|
2026-10-28 18:54:20 +00:00
|
|
|
|
</g>
|
2026-10-28 19:33:14 +00:00
|
|
|
|
</svg>
|
|
|
|
|
|
</div>
|
2026-10-30 10:17:34 +00:00
|
|
|
|
|
|
|
|
|
|
<!-- Zoom: the wheel, a pinch, + − 0 or these; drag the land to look round. -->
|
|
|
|
|
|
<div v-if="fill && !still" class="float absolute z-[1] flex border border-wood-900 bg-parchment-200" :style="controlsAt">
|
|
|
|
|
|
<button type="button" class="btn btn-ghost" :disabled="atHome" :title="$t('village.diorama.whole_key')" @click="reset">
|
|
|
|
|
|
{{ $t('village.diorama.whole') }}
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<button type="button" class="btn btn-ghost px-2.5" :disabled="!canZoomOut" :aria-label="$t('village.diorama.zoom_out')" :title="$t('village.diorama.zoom_out_key')" @click="zoomOut">
|
|
|
|
|
|
−
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<button type="button" class="btn btn-ghost px-2.5" :disabled="!canZoomIn" :aria-label="$t('village.diorama.zoom_in')" :title="$t('village.diorama.zoom_in_key')" @click="zoomIn">
|
|
|
|
|
|
+
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
2026-10-28 18:54:20 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2026-10-30 10:17:34 +00:00
|
|
|
|
/* The land drags; while it does, nothing under the pointer looks clickable. */
|
|
|
|
|
|
.pan {
|
|
|
|
|
|
cursor: grab;
|
|
|
|
|
|
}
|
|
|
|
|
|
.panning,
|
|
|
|
|
|
.panning .bld,
|
|
|
|
|
|
.panning .plot,
|
|
|
|
|
|
.panning .band,
|
|
|
|
|
|
.panning .cursor-pointer {
|
|
|
|
|
|
cursor: grabbing;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-28 21:14:56 +00:00
|
|
|
|
/* Buildings are massive and stay put: no lift, no glow, nothing on hover. Only a click
|
2026-10-30 10:52:55 +00:00
|
|
|
|
(or keyboard focus) outlines the ground they stand on, drawn in the picture. */
|
2026-10-28 21:14:56 +00:00
|
|
|
|
.bld,
|
|
|
|
|
|
.plot {
|
2026-10-28 18:54:20 +00:00
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
outline: none;
|
|
|
|
|
|
}
|
2026-10-29 13:09:03 +00:00
|
|
|
|
.plot,
|
|
|
|
|
|
.hit {
|
2026-10-28 18:54:20 +00:00
|
|
|
|
fill: transparent;
|
|
|
|
|
|
stroke: transparent;
|
|
|
|
|
|
}
|
2026-10-29 13:09:03 +00:00
|
|
|
|
.band {
|
|
|
|
|
|
fill: none;
|
|
|
|
|
|
stroke: transparent;
|
|
|
|
|
|
pointer-events: stroke;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
2026-10-28 21:14:56 +00:00
|
|
|
|
.plot.is-selected {
|
2026-10-28 19:33:14 +00:00
|
|
|
|
stroke: #7b1e16;
|
2026-10-28 18:54:20 +00:00
|
|
|
|
stroke-width: 2;
|
|
|
|
|
|
}
|
2026-10-28 21:14:56 +00:00
|
|
|
|
.plot:focus-visible {
|
2026-10-28 19:33:14 +00:00
|
|
|
|
stroke: #7b1e16;
|
2026-10-28 18:54:20 +00:00
|
|
|
|
stroke-width: 2;
|
|
|
|
|
|
stroke-dasharray: 4 3;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|