Added some dialogs for transitions

This commit is contained in:
Vladislav Khorev 2026-06-04 19:12:18 +03:00
parent 59e0b2d77a
commit 1d3bea452c
11 changed files with 224 additions and 24 deletions

View File

@ -611,6 +611,60 @@
"type": "End" "type": "End"
} }
] ]
},
{
"id": "dialog_video001",
"start": "line_1",
"nodes": [
{
"id": "line_1",
"type": "Line",
"speaker": "Бекзат",
"portrait": "resources/dialogue/portrait_hero_neutral.png",
"text": "Ого, пока я залипал в телефоне, уже наступила ночь!",
"next": "end_1"
},
{
"id": "end_1",
"type": "End"
}
]
},
{
"id": "dialog_video002",
"start": "line_1",
"nodes": [
{
"id": "line_1",
"type": "Line",
"speaker": "Бекзат",
"portrait": "resources/dialogue/portrait_hero_neutral.png",
"text": "Я не буду сейчас смотреть видеоролики, давай лучше пойдем спать.",
"next": "end_1"
},
{
"id": "end_1",
"type": "End"
}
]
},
{
"id": "dialog_video003",
"start": "line_1",
"nodes": [
{
"id": "line_1",
"type": "Line",
"speaker": "Бекзат",
"portrait": "resources/dialogue/portrait_hero_neutral.png",
"text": "Мне некогда деградировать, мне нужно сегодня 100% быть на лекции!",
"next": "end_1"
},
{
"id": "end_1",
"type": "End"
}
]
} }
], ],
"cutscenes": [{ "cutscenes": [{

View File

@ -141,6 +141,60 @@
"type": "End" "type": "End"
} }
] ]
},
{
"id": "dialog_video001",
"start": "line_1",
"nodes": [
{
"id": "line_1",
"type": "Line",
"speaker": "Бекзат",
"portrait": "resources/dialogue/portrait_hero_neutral.png",
"text": "Ого, пока я залипал в приложении, уже наступила ночь!",
"next": "end_1"
},
{
"id": "end_1",
"type": "End"
}
]
},
{
"id": "dialog_video002",
"start": "line_1",
"nodes": [
{
"id": "line_1",
"type": "Line",
"speaker": "Бекзат",
"portrait": "resources/dialogue/portrait_hero_neutral.png",
"text": "Я не буду сейчас смотреть видеоролики, давай лучше вернемся в общагу и пойдем спать.",
"next": "end_1"
},
{
"id": "end_1",
"type": "End"
}
]
},
{
"id": "dialog_video003",
"start": "line_1",
"nodes": [
{
"id": "line_1",
"type": "Line",
"speaker": "Бекзат",
"portrait": "resources/dialogue/portrait_hero_neutral.png",
"text": "Мне некогда деградировать, мне нужно сегодня 100% быть на лекции!",
"next": "end_1"
},
{
"id": "end_1",
"type": "End"
}
]
} }
], ],
"cutscenes": [ "cutscenes": [

View File

@ -1101,6 +1101,60 @@
"type": "End" "type": "End"
} }
] ]
},
{
"id": "dialog_video001",
"start": "line_1",
"nodes": [
{
"id": "line_1",
"type": "Line",
"speaker": "Бекзат",
"portrait": "resources/dialogue/portrait_hero_neutral.png",
"text": "Ого, пока я залипал в приложении, уже наступила ночь!",
"next": "end_1"
},
{
"id": "end_1",
"type": "End"
}
]
},
{
"id": "dialog_video002",
"start": "line_1",
"nodes": [
{
"id": "line_1",
"type": "Line",
"speaker": "Бекзат",
"portrait": "resources/dialogue/portrait_hero_neutral.png",
"text": "Я не буду сейчас смотреть видеоролики, давай лучше вернемся в общагу и пойдем спать.",
"next": "end_1"
},
{
"id": "end_1",
"type": "End"
}
]
},
{
"id": "dialog_video003",
"start": "line_1",
"nodes": [
{
"id": "line_1",
"type": "Line",
"speaker": "Бекзат",
"portrait": "resources/dialogue/portrait_hero_neutral.png",
"text": "Мне некогда деградировать сейчас!",
"next": "end_1"
},
{
"id": "end_1",
"type": "End"
}
]
} }
], ],
"cutscenes": [ "cutscenes": [

View File

@ -1,6 +1,7 @@
uniform float uAlpha; uniform float uAlpha;
uniform vec3 uFlashColor;
void main() void main()
{ {
gl_FragColor = vec4(1.0, 1.0, 1.0, uAlpha); gl_FragColor = vec4(uFlashColor, uAlpha);
} }

View File

@ -1,7 +1,8 @@
precision mediump float; precision mediump float;
uniform float uAlpha; uniform float uAlpha;
uniform vec3 uFlashColor;
void main() void main()
{ {
gl_FragColor = vec4(1.0, 1.0, 1.0, uAlpha); gl_FragColor = vec4(uFlashColor, uAlpha);
} }

View File

@ -90,10 +90,7 @@ game_api.set_trigger_zone_callbacks("ladder_zone001",
) )
function on_bed_sleep() function on_bed_sleep()
local need_sleep = game_api.getIntValue("need_sleep") if (not game_api.is_night()) then
print("Lua script need sleep =")
print(need_sleep)
if (need_sleep==0) then
game_api.start_dialogue("dialog_no_sleep001") game_api.start_dialogue("dialog_no_sleep001")
else else
game_api.start_cutscene("sleep_cutscene001") game_api.start_cutscene("sleep_cutscene001")

View File

@ -312,7 +312,7 @@ namespace ZL
params_dorm.npcsJsonPath = "resources/config2/npcs_dorm.json"; params_dorm.npcsJsonPath = "resources/config2/npcs_dorm.json";
params_dorm.dialoguesJsonPath = "resources/dialogue/dorm_dialogues.json"; params_dorm.dialoguesJsonPath = "resources/dialogue/dorm_dialogues.json";
/*
params_dorm.navigationJsonPaths = { params_dorm.navigationJsonPaths = {
"resources/navigation/dorm3_bca.json", "resources/navigation/dorm3_bca.json",
"resources/navigation/dorm3_ca.json", "resources/navigation/dorm3_ca.json",
@ -320,7 +320,7 @@ namespace ZL
"resources/navigation/dorm3_a.json", "resources/navigation/dorm3_a.json",
"resources/navigation/dorm3_b.json", "resources/navigation/dorm3_b.json",
"resources/navigation/dorm3_all_open.json", "resources/navigation/dorm3_all_open.json",
};*/ };
/* /*
params_dorm.navigationJsonPaths = { params_dorm.navigationJsonPaths = {
"resources/navigation/dorm2_bca2.json", "resources/navigation/dorm2_bca2.json",
@ -341,16 +341,14 @@ namespace ZL
"resources/navigation/dorm2_b.txt", "resources/navigation/dorm2_b.txt",
"resources/navigation/dorm2_all_open.txt", "resources/navigation/dorm2_all_open.txt",
};*/ };*/
/* params_dorm.navigationJsonPaths = {
params_dorm.navigationJsonPaths = {
"resources/navigation/dorm0_large.json", "resources/navigation/dorm0_large.json",
"resources/navigation/dorm0_large.json", "resources/navigation/dorm0_large.json",
"resources/navigation/dorm0_large.json", "resources/navigation/dorm0_large.json",
"resources/navigation/dorm0_large.json", "resources/navigation/dorm0_large.json",
"resources/navigation/dorm0_large.json", "resources/navigation/dorm0_large.json",
"resources/navigation/dorm0_large.json", "resources/navigation/dorm0_large.json",
}; };*/
params_dorm.teleportsJsonPath = "resources/config2/teleports_dorm.json"; params_dorm.teleportsJsonPath = "resources/config2/teleports_dorm.json";
params_dorm.triggerZonesJsonPath = "resources/config2/trigger_zones_dorm.json"; params_dorm.triggerZonesJsonPath = "resources/config2/trigger_zones_dorm.json";
@ -422,6 +420,10 @@ namespace ZL
startDarklandsTransition(); startDarklandsTransition();
}; };
menuManager.startNightTransitionFunc = [this]() {
startNightTransition();
};
// Wire bubble-slot callback so chat bubbles appear as dialogue lines are shown. // Wire bubble-slot callback so chat bubbles appear as dialogue lines are shown.
for (auto& [name, loc] : locations) { for (auto& [name, loc] : locations) {
loc->dialogueSystem.setOnBubbleSlotReady([this](const std::string& bubbleSlot) { loc->dialogueSystem.setOnBubbleSlotReady([this](const std::string& bubbleSlot) {
@ -760,11 +762,12 @@ namespace ZL
if (editorMode == EditorMode::InteractiveObjects && currentLocation) { if (editorMode == EditorMode::InteractiveObjects && currentLocation) {
currentLocation->editor.selectInteractiveObject(9); currentLocation->editor.selectInteractiveObject(9);
} else { } else {
if (menuManager.isDawn) { startNightTransition();
/*if (menuManager.isDawn) {
menuManager.isDawn = false; // step back: dawn → plain night menuManager.isDawn = false; // step back: dawn → plain night
} else { } else {
menuManager.isNight = !menuManager.isNight; menuManager.isNight = !menuManager.isNight;
} }*/
} }
break; break;
case SDLK_0: case SDLK_0:
@ -1163,6 +1166,17 @@ namespace ZL
darklandsFlashActive = true; darklandsFlashActive = true;
darklandsFlashFadingIn = true; darklandsFlashFadingIn = true;
darklandsFlashAlpha = 0.0f; darklandsFlashAlpha = 0.0f;
isNightTransition = false;
return true;
}
bool Game::startNightTransition()
{
if (darklandsFlashActive) return false;
darklandsFlashActive = true;
darklandsFlashFadingIn = true;
darklandsFlashAlpha = 0.0f;
isNightTransition = true;
return true; return true;
} }
@ -1175,6 +1189,10 @@ namespace ZL
if (darklandsFlashFadingIn) { if (darklandsFlashFadingIn) {
darklandsFlashAlpha = min(darklandsFlashAlpha + step, 1.0f); darklandsFlashAlpha = min(darklandsFlashAlpha + step, 1.0f);
if (darklandsFlashAlpha >= 1.0f) { if (darklandsFlashAlpha >= 1.0f) {
if (isNightTransition) {
menuManager.isNight = !menuManager.isNight;
if (currentLocation) currentLocation->dialogueSystem.startDialogue("dialog_video001");
} else {
isDarklands = !isDarklands; isDarklands = !isDarklands;
// Change HUD // Change HUD
@ -1186,6 +1204,7 @@ namespace ZL
else else
currentLocation->scriptEngine.callDarklandsExitCallback(); currentLocation->scriptEngine.callDarklandsExitCallback();
} }
}
darklandsFlashFadingIn = false; darklandsFlashFadingIn = false;
} }
} else { } else {
@ -1193,6 +1212,7 @@ namespace ZL
if (darklandsFlashAlpha <= 0.0f) { if (darklandsFlashAlpha <= 0.0f) {
darklandsFlashAlpha = 0.0f; darklandsFlashAlpha = 0.0f;
darklandsFlashActive = false; darklandsFlashActive = false;
isNightTransition = false;
} }
} }
} }
@ -1229,6 +1249,9 @@ namespace ZL
renderer.LoadIdentity(); renderer.LoadIdentity();
renderer.RenderUniform1f("uAlpha", darklandsFlashAlpha); renderer.RenderUniform1f("uAlpha", darklandsFlashAlpha);
static const float kWhite[3] = { 1.f, 1.f, 1.f };
static const float kBlack[3] = { 0.f, 0.f, 0.f };
renderer.RenderUniform3fv("uFlashColor", isNightTransition ? kBlack : kWhite);
renderer.DrawVertexRenderStruct(darklandsFlashQuad); renderer.DrawVertexRenderStruct(darklandsFlashQuad);
renderer.PopMatrix(); renderer.PopMatrix();

View File

@ -51,6 +51,7 @@ namespace ZL {
bool isDarklands = false; bool isDarklands = false;
// Returns false if a transition is already in progress. // Returns false if a transition is already in progress.
bool startDarklandsTransition(); bool startDarklandsTransition();
bool startNightTransition();
Inventory inventory; Inventory inventory;
InteractiveObject* pickedUpObject = nullptr; InteractiveObject* pickedUpObject = nullptr;
@ -118,10 +119,11 @@ namespace ZL {
static void onResourcesZipError(const char* filename); static void onResourcesZipError(const char* filename);
#endif #endif
// White-flash transition state // Screen-flash transition state (shared by darklands and night transitions)
float darklandsFlashAlpha = 0.0f; float darklandsFlashAlpha = 0.0f;
bool darklandsFlashActive = false; bool darklandsFlashActive = false;
bool darklandsFlashFadingIn = true; bool darklandsFlashFadingIn = true;
bool isNightTransition = false; // true → black flash toggling isNight; false → white flash toggling isDarklands
VertexRenderStruct darklandsFlashQuad; VertexRenderStruct darklandsFlashQuad;
float darklandsFlashQuadW = -1.0f; float darklandsFlashQuadW = -1.0f;
float darklandsFlashQuadH = -1.0f; float darklandsFlashQuadH = -1.0f;

View File

@ -384,8 +384,15 @@ namespace ZL {
uiManager.popMenu(); uiManager.popMenu();
}); });
uiManager.setButtonCallback("videoSkip", [this](const std::string&) { uiManager.setButtonCallback("videoSkip", [this](const std::string&) {
// TODO: trigger time-skip game feature
closePhoneEntirely(); closePhoneEntirely();
if (isNight)
{
startDialogueFunc("dialog_video002");
}
else
{
startNightTransitionFunc();
}
}); });
} }

View File

@ -69,6 +69,7 @@ namespace ZL {
std::function<void(const std::string&)> startDialogueFunc; std::function<void(const std::string&)> startDialogueFunc;
std::function<void()> startDarklandsTransitionFunc; std::function<void()> startDarklandsTransitionFunc;
std::function<void()> startNightTransitionFunc;
void setDarklandsMode(bool enabled); void setDarklandsMode(bool enabled);
void advanceTutorialStep(); void advanceTutorialStep();

View File

@ -222,6 +222,12 @@ namespace ZL {
std::cout << "Set dawn called" << std::endl; std::cout << "Set dawn called" << std::endl;
}); });
api.set_function("is_night",
[game]() {
return game->isNight;
});
// advance_darklands_hud() // advance_darklands_hud()
// Advances the uni_interior darklands HUD from step12 to step13. // Advances the uni_interior darklands HUD from step12 to step13.
// Call when the player enters the ghost trigger zone in darklands. // Call when the player enters the ghost trigger zone in darklands.