diff --git a/app/components/village/BuildForm.vue b/app/components/village/BuildForm.vue index 4a2f4cd..f3e8374 100644 --- a/app/components/village/BuildForm.vue +++ b/app/components/village/BuildForm.vue @@ -8,6 +8,8 @@ const props = defineProps<{ resources: Resources canAfford: (cost: Cost) => boolean busy: boolean + /** A building type a quest points at: its rows are marked and scrolled into view. */ + hint?: string | null }>() const emit = defineEmits<{ build: [type: BuildingType] @@ -61,6 +63,19 @@ const rows = computed(() => { return out }) +// A quest's "show me" lands here: bring the first marked row into view. +const root = ref(null) +watch( + () => props.hint, + async (hint) => { + if (!hint) return + tab.value = 'construct' + await nextTick() + root.value?.querySelector('[data-hint]')?.scrollIntoView({ block: 'center' }) + }, + { immediate: true }, +) + const locked = computed(() => props.options.filter((o) => o.blocked === 'requires')) /** Why a row can't be built now, or '' when its button shows. */ @@ -82,7 +97,7 @@ const demolishable = computed(() => + + diff --git a/app/pages/village/[id]/build.vue b/app/pages/village/[id]/build.vue index 19d25c7..3e9a24f 100644 --- a/app/pages/village/[id]/build.vue +++ b/app/pages/village/[id]/build.vue @@ -22,6 +22,7 @@ const showInVillage = (id: number) => navigateTo({ path: `/village/${route.param :resources="resources" :can-afford="v.canAfford" :busy="v.busy.value" + :hint="typeof route.query.hint === 'string' ? route.query.hint : null" @build="v.build" @upgrade="v.upgrade" @demolish="v.demolish"