feat: inline bilingual choice text (textEn), lang-aware choice rendering

This commit is contained in:
2026-06-09 15:51:37 +08:00
parent daec24d69b
commit 8e7f77bc38
3 changed files with 24 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ export interface SceneNode {
export interface Choice {
text: string
textKey?: string
textEn?: string
targetScene: string
conditions?: Condition[]
effects?: Effect[]

View File

@@ -44,6 +44,7 @@
"choices": [
{
"text": "走向左边那扇发光的门",
"textEn": "Walk towards the glowing door on the left",
"textKey": "scene.intro.choice.left_door",
"targetScene": "left_door",
"effects": [
@@ -52,6 +53,7 @@
},
{
"text": "走向右边那扇普通的门",
"textEn": "Walk towards the plain door on the right",
"textKey": "scene.intro.choice.right_door",
"targetScene": "right_door",
"effects": [
@@ -60,11 +62,13 @@
},
{
"text": "仔细搜索房间",
"textEn": "Search the room carefully",
"textKey": "scene.intro.choice.search",
"targetScene": "investigation_site"
},
{
"text": "留在原地,什么也不做",
"textEn": "Stay where you are, do nothing",
"textKey": "scene.intro.choice.stay",
"targetScene": "stay"
}
@@ -107,7 +111,7 @@
}
],
"choices": [
{ "text": "离开房间", "targetScene": "corridor" }
{ "text": "离开房间", "textEn": "Leave the room", "targetScene": "corridor" }
]
},
"corridor": {
@@ -147,6 +151,7 @@
"choices": [
{
"text": "与陌生人握手",
"textEn": "Shake hands with the stranger",
"targetScene": "trust_ending",
"effects": [
{ "type": "add", "target": "trust", "value": 30 }
@@ -154,6 +159,7 @@
},
{
"text": "拒绝握手,保持警惕",
"textEn": "Refuse to shake hands, stay alert",
"targetScene": "alone_ending"
}
]
@@ -185,10 +191,12 @@
"choices": [
{
"text": "继续前进",
"textEn": "Continue forward",
"targetScene": "continue_ending"
},
{
"text": "回头",
"textEn": "Turn back",
"targetScene": "intro"
}
]
@@ -199,10 +207,12 @@
"choices": [
{
"text": "继续前进",
"textEn": "Continue forward",
"targetScene": "continue_ending"
},
{
"text": "回头",
"textEn": "Turn back",
"targetScene": "intro"
}
]
@@ -213,10 +223,12 @@
"choices": [
{
"text": "返回调查现场",
"textEn": "Return to the investigation scene",
"targetScene": "investigation_site"
},
{
"text": "离开",
"textEn": "Leave",
"targetScene": "corridor"
}
]
@@ -231,7 +243,7 @@
"loopStart": 3.0,
"loopEnd": 6.0,
"choices": [
{ "text": "站起来离开", "targetScene": "alone_ending" }
{ "text": "站起来离开", "textEn": "Stand up and leave", "targetScene": "alone_ending" }
]
},
"trust_ending": {
@@ -240,6 +252,7 @@
"choices": [
{
"text": "开启信任的旅程(需要 trust >= 80",
"textEn": "Embark on a journey of trust (requires trust >= 80)",
"targetScene": "secret_ending",
"conditions": [
{ "variable": "trust", "op": ">=", "value": 80 }
@@ -247,6 +260,7 @@
},
{
"text": "离开这里",
"textEn": "Leave this place",
"targetScene": "alone_ending"
}
]

View File

@@ -13,7 +13,12 @@ const emit = defineEmits<{
choose: [index: number]
}>()
const { t } = useI18n()
const { t, currentLang } = useI18n()
function choiceLabel(c: Choice): string {
if (currentLang.value === 'en' && (c as any).textEn) return (c as any).textEn
return c.text
}
const focusIndex = ref(0)
const btnRefs = ref<(HTMLButtonElement | null)[]>([])
@@ -75,7 +80,7 @@ function onKeydown(e: KeyboardEvent, index: number) {
@click="emit('choose', index)"
@keydown="onKeydown($event, index)"
>
{{ choice.text }}
{{ choiceLabel(choice) }}
</button>
</div>
</div>