fix: remove scene. prefix from textKey, add fallback to choice.text when locale key missing
This commit is contained in:
@@ -81,7 +81,7 @@
|
|||||||
"choices": [
|
"choices": [
|
||||||
{
|
{
|
||||||
"text": "走向左边那扇发光的门",
|
"text": "走向左边那扇发光的门",
|
||||||
"textKey": "scene.intro.choice.left_door",
|
"textKey": "intro.choice.left_door",
|
||||||
"targetScene": "left_door",
|
"targetScene": "left_door",
|
||||||
"effects": [
|
"effects": [
|
||||||
{ "type": "add", "target": "courage", "value": 10 }
|
{ "type": "add", "target": "courage", "value": 10 }
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "走向右边那扇普通的门",
|
"text": "走向右边那扇普通的门",
|
||||||
"textKey": "scene.intro.choice.right_door",
|
"textKey": "intro.choice.right_door",
|
||||||
"targetScene": "right_door",
|
"targetScene": "right_door",
|
||||||
"effects": [
|
"effects": [
|
||||||
{ "type": "add", "target": "courage", "value": -5 }
|
{ "type": "add", "target": "courage", "value": -5 }
|
||||||
@@ -97,12 +97,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "仔细搜索房间",
|
"text": "仔细搜索房间",
|
||||||
"textKey": "scene.intro.choice.search",
|
"textKey": "intro.choice.search",
|
||||||
"targetScene": "investigation_site"
|
"targetScene": "investigation_site"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "留在原地,什么也不做",
|
"text": "留在原地,什么也不做",
|
||||||
"textKey": "scene.intro.choice.stay",
|
"textKey": "intro.choice.stay",
|
||||||
"targetScene": "stay"
|
"targetScene": "stay"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -193,7 +193,7 @@
|
|||||||
"choices": [
|
"choices": [
|
||||||
{
|
{
|
||||||
"text": "与陌生人握手",
|
"text": "与陌生人握手",
|
||||||
"textKey": "scene.left_door.choice.handshake",
|
"textKey": "left_door.choice.handshake",
|
||||||
"prompt": "陌生人会记住你的善意",
|
"prompt": "陌生人会记住你的善意",
|
||||||
"targetScene": "trust_ending",
|
"targetScene": "trust_ending",
|
||||||
"effects": [
|
"effects": [
|
||||||
@@ -296,7 +296,7 @@
|
|||||||
"choices": [
|
"choices": [
|
||||||
{
|
{
|
||||||
"text": "开启信任的旅程(需要 trust >= 80)",
|
"text": "开启信任的旅程(需要 trust >= 80)",
|
||||||
"textKey": "scene.trust_ending.choice.journey",
|
"textKey": "trust_ending.choice.journey",
|
||||||
"prompt": "你们的羁绊将改变一切",
|
"prompt": "你们的羁绊将改变一切",
|
||||||
"targetScene": "secret_ending",
|
"targetScene": "secret_ending",
|
||||||
"conditions": [
|
"conditions": [
|
||||||
|
|||||||
@@ -17,6 +17,14 @@ const emit = defineEmits<{
|
|||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const store = useGameStore()
|
const store = useGameStore()
|
||||||
|
|
||||||
|
function choiceText(choice: Choice): string {
|
||||||
|
if (choice.textKey) {
|
||||||
|
const translated = t(choice.textKey)
|
||||||
|
if (translated !== choice.textKey) return translated
|
||||||
|
}
|
||||||
|
return choice.text.trim() || choice.textKey || ''
|
||||||
|
}
|
||||||
const focusIndex = ref(0)
|
const focusIndex = ref(0)
|
||||||
const btnRefs = ref<(HTMLButtonElement | null)[]>([])
|
const btnRefs = ref<(HTMLButtonElement | null)[]>([])
|
||||||
const choiceEnabled = ref(!store.antiMistap)
|
const choiceEnabled = ref(!store.antiMistap)
|
||||||
@@ -96,7 +104,7 @@ function handleChoose(index: number) {
|
|||||||
@click="handleChoose(index)"
|
@click="handleChoose(index)"
|
||||||
@keydown="onKeydown($event, index)"
|
@keydown="onKeydown($event, index)"
|
||||||
>
|
>
|
||||||
{{ t(choice.textKey || choice.text) }}
|
{{ choiceText(choice) }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user