This commit is contained in:
Vlad committed 2026-04-13 15:08:38 +06:00
commit 422ff1fbe3
25 files changed
+1697 -6

No files matched your search

+71 -3
View File
@@ -217,6 +217,17 @@ namespace ZL
loadingCompleted = true;
dialogueSystem.init(renderer, CONST_ZIP_FILE);
dialogueSystem.loadDatabase("resources/dialogue/sample_dialogues.json");
dialogueSystem.addTriggerZone({
"ghost_room_trigger",
"test_line_dialogue",
Eigen::Vector3f(0.0f, 0.0f, -8.5f),
2.0f,
true,
false
});
scriptEngine.init(this);
std::cout << "Load resurces step 13" << std::endl;
@@ -332,12 +343,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();
}
@@ -472,12 +493,12 @@ namespace ZL
// Check if player reached target interactive object
if (targetInteractiveObject && player) {
float distToObject = (player->position - targetInteractiveObject->position).norm();
// If player is close enough to pick up the item
if (distToObject <= targetInteractiveObject->interactionRadius + 1.0f) {
std::cout << "[PICKUP] Player reached object! Distance: " << distToObject << std::endl;
std::cout << "[PICKUP] Calling Lua callback for: " << targetInteractiveObject->id << std::endl;
// Call custom activate function if specified, otherwise use fallback
try {
if (!targetInteractiveObject->activateFunctionName.empty()) {
@@ -492,9 +513,14 @@ namespace ZL
catch (const std::exception& e) {
std::cerr << "[PICKUP] Error calling function: " << e.what() << std::endl;
}
targetInteractiveObject = nullptr;
}
//for (auto& npc : npcs) npc->update(delta);
if (player) {
dialogueSystem.update(static_cast<int>(delta), player->position);
}
}
}
}
@@ -584,6 +610,12 @@ namespace ZL
handleDown(ZL::UiManager::MOUSE_FINGER_ID, mx, my);
// Calculate ray for picking
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;
float aspect = (float)Environment::width / (float)Environment::height;
@@ -693,6 +725,27 @@ namespace ZL
}
}
if (event.type == SDL_KEYDOWN && dialogueSystem.handleKeyDown(event.key.keysym.sym)) {
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) {
@@ -773,5 +826,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