feat: inline bilingual choice text (textEn), lang-aware choice rendering
This commit is contained in:
@@ -24,6 +24,7 @@ export interface SceneNode {
|
|||||||
export interface Choice {
|
export interface Choice {
|
||||||
text: string
|
text: string
|
||||||
textKey?: string
|
textKey?: string
|
||||||
|
textEn?: string
|
||||||
targetScene: string
|
targetScene: string
|
||||||
conditions?: Condition[]
|
conditions?: Condition[]
|
||||||
effects?: Effect[]
|
effects?: Effect[]
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
"choices": [
|
"choices": [
|
||||||
{
|
{
|
||||||
"text": "走向左边那扇发光的门",
|
"text": "走向左边那扇发光的门",
|
||||||
|
"textEn": "Walk towards the glowing door on the left",
|
||||||
"textKey": "scene.intro.choice.left_door",
|
"textKey": "scene.intro.choice.left_door",
|
||||||
"targetScene": "left_door",
|
"targetScene": "left_door",
|
||||||
"effects": [
|
"effects": [
|
||||||
@@ -52,6 +53,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "走向右边那扇普通的门",
|
"text": "走向右边那扇普通的门",
|
||||||
|
"textEn": "Walk towards the plain door on the right",
|
||||||
"textKey": "scene.intro.choice.right_door",
|
"textKey": "scene.intro.choice.right_door",
|
||||||
"targetScene": "right_door",
|
"targetScene": "right_door",
|
||||||
"effects": [
|
"effects": [
|
||||||
@@ -60,11 +62,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "仔细搜索房间",
|
"text": "仔细搜索房间",
|
||||||
|
"textEn": "Search the room carefully",
|
||||||
"textKey": "scene.intro.choice.search",
|
"textKey": "scene.intro.choice.search",
|
||||||
"targetScene": "investigation_site"
|
"targetScene": "investigation_site"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "留在原地,什么也不做",
|
"text": "留在原地,什么也不做",
|
||||||
|
"textEn": "Stay where you are, do nothing",
|
||||||
"textKey": "scene.intro.choice.stay",
|
"textKey": "scene.intro.choice.stay",
|
||||||
"targetScene": "stay"
|
"targetScene": "stay"
|
||||||
}
|
}
|
||||||
@@ -107,7 +111,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"choices": [
|
"choices": [
|
||||||
{ "text": "离开房间", "targetScene": "corridor" }
|
{ "text": "离开房间", "textEn": "Leave the room", "targetScene": "corridor" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"corridor": {
|
"corridor": {
|
||||||
@@ -147,6 +151,7 @@
|
|||||||
"choices": [
|
"choices": [
|
||||||
{
|
{
|
||||||
"text": "与陌生人握手",
|
"text": "与陌生人握手",
|
||||||
|
"textEn": "Shake hands with the stranger",
|
||||||
"targetScene": "trust_ending",
|
"targetScene": "trust_ending",
|
||||||
"effects": [
|
"effects": [
|
||||||
{ "type": "add", "target": "trust", "value": 30 }
|
{ "type": "add", "target": "trust", "value": 30 }
|
||||||
@@ -154,6 +159,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "拒绝握手,保持警惕",
|
"text": "拒绝握手,保持警惕",
|
||||||
|
"textEn": "Refuse to shake hands, stay alert",
|
||||||
"targetScene": "alone_ending"
|
"targetScene": "alone_ending"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -185,10 +191,12 @@
|
|||||||
"choices": [
|
"choices": [
|
||||||
{
|
{
|
||||||
"text": "继续前进",
|
"text": "继续前进",
|
||||||
|
"textEn": "Continue forward",
|
||||||
"targetScene": "continue_ending"
|
"targetScene": "continue_ending"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "回头",
|
"text": "回头",
|
||||||
|
"textEn": "Turn back",
|
||||||
"targetScene": "intro"
|
"targetScene": "intro"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -199,10 +207,12 @@
|
|||||||
"choices": [
|
"choices": [
|
||||||
{
|
{
|
||||||
"text": "继续前进",
|
"text": "继续前进",
|
||||||
|
"textEn": "Continue forward",
|
||||||
"targetScene": "continue_ending"
|
"targetScene": "continue_ending"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "回头",
|
"text": "回头",
|
||||||
|
"textEn": "Turn back",
|
||||||
"targetScene": "intro"
|
"targetScene": "intro"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -213,10 +223,12 @@
|
|||||||
"choices": [
|
"choices": [
|
||||||
{
|
{
|
||||||
"text": "返回调查现场",
|
"text": "返回调查现场",
|
||||||
|
"textEn": "Return to the investigation scene",
|
||||||
"targetScene": "investigation_site"
|
"targetScene": "investigation_site"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "离开",
|
"text": "离开",
|
||||||
|
"textEn": "Leave",
|
||||||
"targetScene": "corridor"
|
"targetScene": "corridor"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -231,7 +243,7 @@
|
|||||||
"loopStart": 3.0,
|
"loopStart": 3.0,
|
||||||
"loopEnd": 6.0,
|
"loopEnd": 6.0,
|
||||||
"choices": [
|
"choices": [
|
||||||
{ "text": "站起来离开", "targetScene": "alone_ending" }
|
{ "text": "站起来离开", "textEn": "Stand up and leave", "targetScene": "alone_ending" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"trust_ending": {
|
"trust_ending": {
|
||||||
@@ -240,6 +252,7 @@
|
|||||||
"choices": [
|
"choices": [
|
||||||
{
|
{
|
||||||
"text": "开启信任的旅程(需要 trust >= 80)",
|
"text": "开启信任的旅程(需要 trust >= 80)",
|
||||||
|
"textEn": "Embark on a journey of trust (requires trust >= 80)",
|
||||||
"targetScene": "secret_ending",
|
"targetScene": "secret_ending",
|
||||||
"conditions": [
|
"conditions": [
|
||||||
{ "variable": "trust", "op": ">=", "value": 80 }
|
{ "variable": "trust", "op": ">=", "value": 80 }
|
||||||
@@ -247,6 +260,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "离开这里",
|
"text": "离开这里",
|
||||||
|
"textEn": "Leave this place",
|
||||||
"targetScene": "alone_ending"
|
"targetScene": "alone_ending"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -13,7 +13,12 @@ const emit = defineEmits<{
|
|||||||
choose: [index: number]
|
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 focusIndex = ref(0)
|
||||||
const btnRefs = ref<(HTMLButtonElement | null)[]>([])
|
const btnRefs = ref<(HTMLButtonElement | null)[]>([])
|
||||||
|
|
||||||
@@ -75,7 +80,7 @@ function onKeydown(e: KeyboardEvent, index: number) {
|
|||||||
@click="emit('choose', index)"
|
@click="emit('choose', index)"
|
||||||
@keydown="onKeydown($event, index)"
|
@keydown="onKeydown($event, index)"
|
||||||
>
|
>
|
||||||
{{ choice.text }}
|
{{ choiceLabel(choice) }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user