feat: the headquarters marks and scrolls to the rows a hint points at
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a93a1104ef
commit
9950f5423c
|
|
@ -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<Row[]>(() => {
|
|||
return out
|
||||
})
|
||||
|
||||
// A quest's "show me" lands here: bring the first marked row into view.
|
||||
const root = ref<HTMLElement | null>(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(() =>
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<section class="panel overflow-hidden">
|
||||
<section ref="root" class="panel overflow-hidden">
|
||||
<div class="panel-head">
|
||||
<div class="flex items-center gap-1" role="tablist">
|
||||
<button
|
||||
|
|
@ -115,7 +130,13 @@ const demolishable = computed(() =>
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="row in rows" :key="row.key" class="border-b border-parchment-300 last:border-b-0 even:bg-parchment-100">
|
||||
<tr
|
||||
v-for="row in rows"
|
||||
:key="row.key"
|
||||
class="border-b border-parchment-300 last:border-b-0"
|
||||
:class="row.type === hint ? 'quest-hint' : 'even:bg-parchment-100'"
|
||||
:data-hint="row.type === hint ? '' : undefined"
|
||||
>
|
||||
<td class="px-3 py-1">
|
||||
<div class="flex items-center gap-2">
|
||||
<VillagePortraitTile :type="row.type" :level="row.kind === 'upgrade' ? row.building.level : 1" class="size-8" />
|
||||
|
|
@ -247,3 +268,15 @@ const demolishable = computed(() =>
|
|||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@reference "~/assets/css/main.css";
|
||||
|
||||
/* The row a quest points at: a gold band and a marker before the name. */
|
||||
.quest-hint {
|
||||
@apply bg-gold-400;
|
||||
}
|
||||
.quest-hint td:first-child {
|
||||
@apply border-l-4 border-l-blood-700;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in New Issue