+
diff --git a/app/components/map/WorldMap.vue b/app/components/map/WorldMap.vue
index 51b50af..d2331ca 100644
--- a/app/components/map/WorldMap.vue
+++ b/app/components/map/WorldMap.vue
@@ -20,6 +20,8 @@ const props = defineProps<{
current?: number | null
/** The clock, for where groups on the march are. */
now: number
+ /** Id of the group on the march that was clicked. */
+ march?: number | null
}>()
const emit = defineEmits<{
select: [at: { x: number; y: number }]
@@ -29,6 +31,8 @@ const emit = defineEmits<{
dragend: []
/** Whole fields, from the arrow keys. */
pan: [dx: number, dy: number]
+ /** A group on the march or its line was clicked. */
+ march: [id: number]
}>()
const { t } = useI18n()
@@ -126,12 +130,13 @@ const tier = (points: number): 1 | 2 | 3 | 4 | 5 => (points < 150 ? 1 : points <
const relation = (v: MapVillage): MarkerRelation => (v.id === props.current ? 'current' : (v.relation ?? (v.own ? 'own' : v.player ? 'none' : 'barbarian')))
// Groups on the march: a line from village to village and the group where it is now,
-// moving straight at constant speed (raiders wait at their camp until they march).
+// moving straight at constant speed (raiders wait at their camp until they march). A group
+// leaves the map when it arrives; the page reloads then and shows what comes of it.
const motion = ref(false)
onMounted(() => (motion.value = !window.matchMedia('(prefers-reduced-motion: reduce)').matches))
const centre = (p: { x: number; y: number }) => [(p.x + 0.5) * props.field, (p.y + 0.5) * props.field] as const
const marches = computed(() =>
- (props.view?.movements ?? []).map((m: MapMovement) => {
+ (props.view?.movements ?? []).filter((m) => Date.parse(m.arrives_at) > props.now).map((m: MapMovement) => {
const [ax, ay] = centre(m.from)
const [bx, by] = centre(m.to)
const start = Date.parse(m.sent_at)
@@ -331,11 +336,35 @@ function onKey(e: KeyboardEvent) {
-
+
-
+
+
-
+
+ {{ marchTitle(g.m) }}
+
+ {{ marchTitle(g.m) }}
diff --git a/app/components/village/Diorama.vue b/app/components/village/Diorama.vue
index f1e11ad..489ca69 100644
--- a/app/components/village/Diorama.vue
+++ b/app/components/village/Diorama.vue
@@ -11,6 +11,8 @@ const props = defineProps<{
secondsUntil: (iso: string) => number
/** Fill the whole stage at any shape, without the sideways scroll of narrow frames. */
fill?: boolean
+ /** A picture only (the landing page): no zoom controls. */
+ still?: boolean
/** With `fill`: pixels at the edges that windows cover; the whole village fits into the rest. */
inset?: SceneInset
/** Projected stock, for the storage's tag. */
@@ -49,6 +51,18 @@ onMounted(() => {
})
onBeforeUnmount(() => observer?.disconnect())
+// 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 },
+ enabled: () => !!props.fill,
+})
+/** 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` }))
+
// 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))
@@ -76,8 +90,8 @@ function clear() {
const press = (id: number) => (props.dismiss ? clear() : toggle(id))
const pressPlot = (type: BuildingType) => (props.dismiss ? clear() : pick(type))
-/** viewBox units per screen pixel: badges keep the same size however the scene is scaled. */
-const k = computed(() => (scene.value.width / Math.max(1, size.value.w)) * (size.value.w < 900 ? 0.85 : 1))
+/** 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))
// 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
@@ -149,11 +163,11 @@ const timers = computed(() => {
-