add dialogue and cutscene system

This commit is contained in:
vottozi committed 2026-04-12 01:46:33 +06:00
1 parent 178f69967b
commit 7125674308
23 files changed
+1619 -2

No files matched your search

+40 -1
View File
@@ -227,6 +227,17 @@ namespace ZL
loadingCompleted = true;
dialogueSystem.init(renderer, CONST_ZIP_FILE);
dialogueSystem.loadDatabase("resources/dialogue/sample_dialogues.json");
dialogueSystem.addTriggerZone({
"ghost_room_trigger",
"npc_viola_intro",
Eigen::Vector3f(0.0f, 0.0f, -8.5f),
2.0f,
true,
false
});
scriptEngine.init(this);
std::cout << "Load resurces step 13" << std::endl;
@@ -241,6 +252,7 @@ namespace ZL
renderer.RenderUniform1i(textureUniformName, 0);
glEnable(GL_BLEND);
menuManager.uiManager.draw(renderer);
dialogueSystem.draw(renderer);
glDisable(GL_BLEND);
renderer.shaderManager.PopShader();
CheckGlError();
@@ -361,7 +373,10 @@ namespace ZL
lastTickCount = newTickCount;
if (player) player->update(delta);
for (auto& npc : npcs) npc->update(delta);
//for (auto& npc : npcs) npc->update(delta);
if (player) {
dialogueSystem.update(static_cast<int>(delta), player->position);
}
}
@@ -450,6 +465,11 @@ namespace ZL
if (event.type == SDL_MOUSEBUTTONDOWN) {
handleDown(ZL::UiManager::MOUSE_FINGER_ID, mx, my);
if (dialogueSystem.blocksGameplayInput()) {
dialogueSystem.handlePointerReleased(static_cast<float>(mx), Environment::projectionHeight - static_cast<float>(my));
continue;
}
// Unproject click to ground plane (y=0) for Viola's walk target
float ndcX = 2.0f * event.button.x / Environment::width - 1.0f;
float ndcY = 1.0f - 2.0f * event.button.y / Environment::height;
@@ -521,6 +541,10 @@ namespace ZL
}
}
if (event.type == SDL_KEYDOWN && dialogueSystem.handleKeyDown(event.key.keysym.sym)) {
continue;
}
// Обработка ввода текста
if (event.type == SDL_KEYDOWN) {
if (event.key.keysym.sym == SDLK_BACKSPACE) {
@@ -601,5 +625,20 @@ namespace ZL
}
bool Game::requestDialogueStart(const std::string& dialogueId)
{
return dialogueSystem.startDialogue(dialogueId);
}
void Game::setDialogueFlag(const std::string& flag, int value)
{
dialogueSystem.setFlag(flag, value);
}
int Game::getDialogueFlag(const std::string& flag) const
{
return dialogueSystem.getFlag(flag);
}
} // namespace ZL