diff --git a/resources/dialogue/sample_dialogues.json b/resources/dialogue/sample_dialogues.json index e8a56e7..527b7eb 100644 --- a/resources/dialogue/sample_dialogues.json +++ b/resources/dialogue/sample_dialogues.json @@ -1,130 +1,168 @@ { "dialogues": [ { - "id": "npc_viola_intro", - "displayName": "Ghost introduction", - "start": "start", + "id": "test_line_dialogue", + "start": "line_1", "nodes": [ { - "id": "start", + "id": "line_1", "type": "Line", "speaker": "Ghost", - "portrait": "resources/w/ghost_skin001.png", - "text": "So, you finally reached this room.", - "next": "intro_choice" + "portrait": "resources/ghost_avatar.png", + "text": "You finally came here.", + "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", - "speaker": "Ghost", - "portrait": "resources/w/ghost_skin001.png", - "text": "Choose what Geralt says next.", + "speaker": "Hero", + "portrait": "", + "text": "Choose your answer.", "choices": [ { - "id": "main_job", + "id": "main_1", "kind": "Main", - "text": "I am looking for answers.", - "next": "job_line" + "text": "Show me your goods.", + "next": "line_goods" }, { - "id": "optional_who", + "id": "optional_1", "kind": "Optional", "text": "Who are you?", - "next": "who_line", - "consumeOnce": true - }, - { - "id": "exit_now", - "kind": "Exit", - "text": "Enough. Goodbye.", - "next": "end" + "next": "line_who" } ] }, { - "id": "who_line", + "id": "line_goods", "type": "Line", - "speaker": "Ghost", - "portrait": "resources/w/ghost_skin001.png", - "text": "Only a memory. But memories can still be dangerous.", - "next": "intro_choice" + "speaker": "Merchant", + "portrait": "resources/ghost_avatar.png", + "text": "Take a look.", + "next": "end_1" }, { - "id": "job_line", + "id": "line_who", "type": "Line", - "speaker": "Ghost", - "portrait": "resources/w/ghost_skin001.png", - "text": "Then watch carefully. What follows is not a story, but a wound.", - "next": "start_cutscene" + "speaker": "Merchant", + "portrait": "resources/ghost_avatar.png", + "text": "Just a trader passing through.", + "next": "end_1" }, { - "id": "start_cutscene", - "type": "CutsceneStart", - "cutsceneId": "ghost_memory_01", - "next": "set_memory_seen" - }, + "id": "end_1", + "type": "End" + } + ] + }, + + { + "id": "test_condition_dialogue", + "start": "set_flag_1", + "nodes": [ { - "id": "set_memory_seen", + "id": "set_flag_1", "type": "SetFlag", "effects": [ - { - "flag": "memory_seen", - "value": 1 - } + { "flag": "met_ghost", "value": 1 } ], - "next": "after_cutscene_condition" + "next": "condition_1" }, { - "id": "after_cutscene_condition", + "id": "condition_1", "type": "Condition", "conditions": [ - { - "flag": "memory_seen", - "op": ">=", - "value": 1 - } + { "flag": "met_ghost", "op": "Equals", "value": 1 } ], - "trueNext": "after_cutscene_line", - "falseNext": "end" + "trueNext": "line_true", + "falseNext": "line_false" }, { - "id": "after_cutscene_line", + "id": "line_true", "type": "Line", "speaker": "Ghost", - "portrait": "resources/w/ghost_skin001.png", - "text": "Now you know enough for the first quest hook.", - "next": "end" + "portrait": "resources/ghost_avatar.png", + "text": "Now you know who I am.", + "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" } ] } ], + "cutscenes": [ { - "id": "ghost_memory_01", - "background": "resources/w/room005.png", - "skippable": true, + "id": "test_cutscene_01", + "background": "resources/first_cutscene.png", "lines": [ { "speaker": "Narrator", - "text": "The room went silent, as if the walls remembered everything.", - "durationMs": 2800 + "portrait": "", + "text": "The air in the room turned cold.", + "durationMs": 2200 }, { "speaker": "Ghost", - "portrait": "resources/w/ghost_skin001.png", - "text": "There were voices here once. Oaths. Smoke. Firelight.", + "portrait": "resources/ghost_avatar.png", + "text": "Some memories never fade.", "durationMs": 2600 - }, - { - "speaker": "Narrator", - "text": "Now there was only ash and a story that refused to die.", - "durationMs": 2700 } ] } ] -} +} \ No newline at end of file diff --git a/resources/first_cutscene.png b/resources/first_cutscene.png new file mode 100644 index 0000000..7e9a378 --- /dev/null +++ b/resources/first_cutscene.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c11579d1e2930947f39c31d9ed5d798b32f72e483032d8b519bca1a0477107b8 +size 1024447 diff --git a/resources/ghost_avatar.png b/resources/ghost_avatar.png new file mode 100644 index 0000000..b8f3200 --- /dev/null +++ b/resources/ghost_avatar.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1839586121d9d513ed0aea18f5b8899d5f79ee7ada455ec3e47aa6c1a4d9986b +size 736341 diff --git a/src/Game.cpp b/src/Game.cpp index d4c3690..e87e282 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -231,7 +231,7 @@ namespace ZL dialogueSystem.loadDatabase("resources/dialogue/sample_dialogues.json"); dialogueSystem.addTriggerZone({ "ghost_room_trigger", - "npc_viola_intro", + "test_line_dialogue", Eigen::Vector3f(0.0f, 0.0f, -8.5f), 2.0f, true, @@ -248,13 +248,22 @@ namespace ZL { glClear(GL_DEPTH_BUFFER_BIT); + glDisable(GL_DEPTH_TEST); + glDepthMask(GL_FALSE); + renderer.shaderManager.PushShader(defaultShaderName); renderer.RenderUniform1i(textureUniformName, 0); glEnable(GL_BLEND); + menuManager.uiManager.draw(renderer); dialogueSystem.draw(renderer); + glDisable(GL_BLEND); renderer.shaderManager.PopShader(); + + glDepthMask(GL_TRUE); + glEnable(GL_DEPTH_TEST); + CheckGlError(); } @@ -545,6 +554,23 @@ namespace ZL 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.key.keysym.sym == SDLK_BACKSPACE) {