fix: dialogue text now displays correctly

This commit is contained in:
vottozi 2026-04-13 02:16:25 +06:00
parent 7125674308
commit 6465549c3b
4 changed files with 141 additions and 71 deletions

View File

@ -1,128 +1,166 @@
{ {
"dialogues": [ "dialogues": [
{ {
"id": "npc_viola_intro", "id": "test_line_dialogue",
"displayName": "Ghost introduction", "start": "line_1",
"start": "start",
"nodes": [ "nodes": [
{ {
"id": "start", "id": "line_1",
"type": "Line", "type": "Line",
"speaker": "Ghost", "speaker": "Ghost",
"portrait": "resources/w/ghost_skin001.png", "portrait": "resources/ghost_avatar.png",
"text": "So, you finally reached this room.", "text": "You finally came here.",
"next": "intro_choice" "next": "line_2"
}, },
{ {
"id": "intro_choice", "id": "line_2",
"type": "Line",
"speaker": "Hero",
"portrait": "",
"text": "I need answers.",
"next": "end_1"
},
{
"id": "end_1",
"type": "End"
}
]
},
{
"id": "test_choice_dialogue",
"start": "line_1",
"nodes": [
{
"id": "line_1",
"type": "Line",
"speaker": "Merchant",
"portrait": "resources/ghost_avatar.png",
"text": "What do you want?",
"next": "choice_1"
},
{
"id": "choice_1",
"type": "Choice", "type": "Choice",
"speaker": "Ghost", "speaker": "Hero",
"portrait": "resources/w/ghost_skin001.png", "portrait": "",
"text": "Choose what Geralt says next.", "text": "Choose your answer.",
"choices": [ "choices": [
{ {
"id": "main_job", "id": "main_1",
"kind": "Main", "kind": "Main",
"text": "I am looking for answers.", "text": "Show me your goods.",
"next": "job_line" "next": "line_goods"
}, },
{ {
"id": "optional_who", "id": "optional_1",
"kind": "Optional", "kind": "Optional",
"text": "Who are you?", "text": "Who are you?",
"next": "who_line", "next": "line_who"
"consumeOnce": true
},
{
"id": "exit_now",
"kind": "Exit",
"text": "Enough. Goodbye.",
"next": "end"
} }
] ]
}, },
{ {
"id": "who_line", "id": "line_goods",
"type": "Line", "type": "Line",
"speaker": "Ghost", "speaker": "Merchant",
"portrait": "resources/w/ghost_skin001.png", "portrait": "resources/ghost_avatar.png",
"text": "Only a memory. But memories can still be dangerous.", "text": "Take a look.",
"next": "intro_choice" "next": "end_1"
}, },
{ {
"id": "job_line", "id": "line_who",
"type": "Line", "type": "Line",
"speaker": "Ghost", "speaker": "Merchant",
"portrait": "resources/w/ghost_skin001.png", "portrait": "resources/ghost_avatar.png",
"text": "Then watch carefully. What follows is not a story, but a wound.", "text": "Just a trader passing through.",
"next": "start_cutscene" "next": "end_1"
}, },
{ {
"id": "start_cutscene", "id": "end_1",
"type": "CutsceneStart", "type": "End"
"cutsceneId": "ghost_memory_01", }
"next": "set_memory_seen" ]
}, },
{ {
"id": "set_memory_seen", "id": "test_condition_dialogue",
"start": "set_flag_1",
"nodes": [
{
"id": "set_flag_1",
"type": "SetFlag", "type": "SetFlag",
"effects": [ "effects": [
{ { "flag": "met_ghost", "value": 1 }
"flag": "memory_seen",
"value": 1
}
], ],
"next": "after_cutscene_condition" "next": "condition_1"
}, },
{ {
"id": "after_cutscene_condition", "id": "condition_1",
"type": "Condition", "type": "Condition",
"conditions": [ "conditions": [
{ { "flag": "met_ghost", "op": "Equals", "value": 1 }
"flag": "memory_seen",
"op": ">=",
"value": 1
}
], ],
"trueNext": "after_cutscene_line", "trueNext": "line_true",
"falseNext": "end" "falseNext": "line_false"
}, },
{ {
"id": "after_cutscene_line", "id": "line_true",
"type": "Line", "type": "Line",
"speaker": "Ghost", "speaker": "Ghost",
"portrait": "resources/w/ghost_skin001.png", "portrait": "resources/ghost_avatar.png",
"text": "Now you know enough for the first quest hook.", "text": "Now you know who I am.",
"next": "end" "next": "end_1"
}, },
{ {
"id": "end", "id": "line_false",
"type": "Line",
"speaker": "Ghost",
"portrait": "resources/ghost_avatar.png",
"text": "You should not hear this line.",
"next": "end_1"
},
{
"id": "end_1",
"type": "End"
}
]
},
{
"id": "test_cutscene_dialogue",
"start": "cutscene_start",
"nodes": [
{
"id": "cutscene_start",
"type": "CutsceneStart",
"cutsceneId": "test_cutscene_01",
"next": "end_1"
},
{
"id": "end_1",
"type": "End" "type": "End"
} }
] ]
} }
], ],
"cutscenes": [ "cutscenes": [
{ {
"id": "ghost_memory_01", "id": "test_cutscene_01",
"background": "resources/w/room005.png", "background": "resources/first_cutscene.png",
"skippable": true,
"lines": [ "lines": [
{ {
"speaker": "Narrator", "speaker": "Narrator",
"text": "The room went silent, as if the walls remembered everything.", "portrait": "",
"durationMs": 2800 "text": "The air in the room turned cold.",
"durationMs": 2200
}, },
{ {
"speaker": "Ghost", "speaker": "Ghost",
"portrait": "resources/w/ghost_skin001.png", "portrait": "resources/ghost_avatar.png",
"text": "There were voices here once. Oaths. Smoke. Firelight.", "text": "Some memories never fade.",
"durationMs": 2600 "durationMs": 2600
},
{
"speaker": "Narrator",
"text": "Now there was only ash and a story that refused to die.",
"durationMs": 2700
} }
] ]
} }

BIN
resources/first_cutscene.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
resources/ghost_avatar.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -231,7 +231,7 @@ namespace ZL
dialogueSystem.loadDatabase("resources/dialogue/sample_dialogues.json"); dialogueSystem.loadDatabase("resources/dialogue/sample_dialogues.json");
dialogueSystem.addTriggerZone({ dialogueSystem.addTriggerZone({
"ghost_room_trigger", "ghost_room_trigger",
"npc_viola_intro", "test_line_dialogue",
Eigen::Vector3f(0.0f, 0.0f, -8.5f), Eigen::Vector3f(0.0f, 0.0f, -8.5f),
2.0f, 2.0f,
true, true,
@ -248,13 +248,22 @@ namespace ZL
{ {
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
renderer.shaderManager.PushShader(defaultShaderName); renderer.shaderManager.PushShader(defaultShaderName);
renderer.RenderUniform1i(textureUniformName, 0); renderer.RenderUniform1i(textureUniformName, 0);
glEnable(GL_BLEND); glEnable(GL_BLEND);
menuManager.uiManager.draw(renderer); menuManager.uiManager.draw(renderer);
dialogueSystem.draw(renderer); dialogueSystem.draw(renderer);
glDisable(GL_BLEND); glDisable(GL_BLEND);
renderer.shaderManager.PopShader(); renderer.shaderManager.PopShader();
glDepthMask(GL_TRUE);
glEnable(GL_DEPTH_TEST);
CheckGlError(); CheckGlError();
} }
@ -545,6 +554,23 @@ namespace ZL
continue; continue;
} }
if (event.type == SDL_KEYDOWN && event.key.repeat == 0) {
switch (event.key.keysym.sym) {
case SDLK_f:
dialogueSystem.startDialogue("test_line_dialogue");
break;
case SDLK_e:
dialogueSystem.startDialogue("test_cutscene_dialogue");
break;
case SDLK_RETURN:
default:
break;
}
}
// Обработка ввода текста // Обработка ввода текста
if (event.type == SDL_KEYDOWN) { if (event.type == SDL_KEYDOWN) {
if (event.key.keysym.sym == SDLK_BACKSPACE) { if (event.key.keysym.sym == SDLK_BACKSPACE) {