Fixing ui bugs, added cutscenes

This commit is contained in:
Vladislav Khorev committed 2026-06-27 22:05:19 +03:00
1 parent 9aeb0b1194
commit 5516d02e2c
18 files changed
+2100 -222

No files matched your search

+1 -2
View File
@@ -168,10 +168,9 @@ namespace ZL
dialogueSystem.init(renderer, CONST_ZIP_FILE);
dialogueSystem.loadDatabase(params.dialoguesJsonPath);
dialogueSystem.loadCutsceneDatabase("resources/dialogue/cutscenes006.json");
dialogueSystem.loadCutsceneDatabase("resources/dialogue/cutscenes008.json");
dialogueSystem.setQuestJournal(journal);
npcNameText = std::make_unique<TextRenderer>();
if (!npcNameText->init(renderer, "resources/fonts/DroidSans.ttf", 24, CONST_ZIP_FILE)) {
std::cerr << "Failed to init NPC name TextRenderer" << std::endl;
+16 -1
View File
@@ -480,6 +480,7 @@ namespace ZL {
}
void MenuManager::selectInventoryItem(int index) {
std::cout << "MenuManager::selectInventoryItem: " << index << std::endl;
const auto& items = inventory->getItems();
if (index < 0 || index >= static_cast<int>(items.size())) return;
@@ -1336,7 +1337,8 @@ namespace ZL {
uiManager.setText("quest_title", def.title);
static const char* kCheckboxes[3] = { "objective1checkbox", "objective2checkbox", "objective3checkbox" };
static const char* kObjNames[3] = { "objective1name", "objective2name", "objective3name" };
static const char* kObjNames[3] = { "objective1name", "objective2name", "objective3name" };
static const char* kObjNameLayouts[3] = { "objective1nameLayout", "objective2nameLayout", "objective3nameLayout" };
std::vector<const Quest::QuestObjective*> visibleObjs;
for (const auto& obj : def.objectives)
@@ -1347,6 +1349,7 @@ namespace ZL {
const auto& obj = *visibleObjs[i];
const bool isActive = (&obj - def.objectives.data() == quest->activeObjectiveIndex);
auto img = uiManager.findStaticImage(kCheckboxes[i]);
auto textView = uiManager.findTextView(kObjNames[i]);
if (img) img->texture = obj.completed ? texObjectiveCompleted_ : texObjectiveBlank_;
std::array<float, 4> color;
if (obj.completed) {
@@ -1356,6 +1359,18 @@ namespace ZL {
} else {
color = { 0.996f, 0.977f, 0.761f, 0.9f };
}
const int numLines = countWrappedLines(obj.text, *textView->textRenderer, 540);
if (numLines == 1)
{
uiManager.findNode(kObjNameLayouts[i])->height = 80.0f;
}
else
{
uiManager.findNode(kObjNameLayouts[i])->height = 60.0f;
}
uiManager.setText(kObjNames[i], obj.text);
uiManager.setTextColor(kObjNames[i], color);
uiManager.setNodeVisible(kCheckboxes[i], true);
+1 -23
View File
@@ -111,7 +111,7 @@ void CutsceneOverlay::draw(Renderer& renderer, const ZL::Dialogue::PresentationM
const float W = Environment::projectionWidth;
const float H = Environment::projectionHeight;
const UiRect subtitleRect{ W * 0.12f, 22.0f, W * 0.76f, 110.0f };
const UiRect subtitleRect{ W * 0.12f, 22.0f, W * 0.76f, 142.0f };
lastCutsceneAdvanceRect = subtitleRect;
@@ -175,28 +175,6 @@ void CutsceneOverlay::draw(Renderer& renderer, const ZL::Dialogue::PresentationM
renderer.DrawVertexRenderStruct(subtitleQuad.mesh);
}
if (model.cutsceneSkippable && cutsceneSkipHintVisible) {
/*const UiRect hintBg{W - 250.0f, H - 62.0f, 226.0f, 42.0f};
skipHintBgQuad.rebuild(hintBg);
glBindTexture(GL_TEXTURE_2D, choiceOptionalTexture->getTexID());
renderer.DrawVertexRenderStruct(skipHintBgQuad.mesh);
const UiRect progressBg{ W - 232.0f, H - 34.0f, 190.0f, 7.0f };
skipProgressBgQuad.rebuild(progressBg);
renderer.DrawVertexRenderStruct(skipProgressBgQuad.mesh);
if (cutsceneSkipHolding) {
const float progress = std::clamp(
static_cast<float>(cutsceneSkipHoldElapsedMs) / static_cast<float>(CutsceneSkipHoldDurationMs),
0.0f, 1.0f
);
const UiRect progressFill{ progressBg.x, progressBg.y, progressBg.w * progress, progressBg.h };
skipProgressFillQuad.rebuild(progressFill);
glBindTexture(GL_TEXTURE_2D, choiceMainTexture->getTexID());
renderer.DrawVertexRenderStruct(skipProgressFillQuad.mesh);
}*/
}
renderer.PopMatrix();
renderer.PopProjectionMatrix();
renderer.shaderManager.PopShader();
+5 -5
View File
@@ -293,12 +293,12 @@ void DialogueOverlay::drawPortrait(Renderer& renderer, const PresentationModel&
if (model.mode == PresentationMode::Choice) {
const float choiceTexAspect = static_cast<float>(choiceMainTexture->getWidth())
/ static_cast<float>(choiceMainTexture->getHeight());
const float choiceW = W - leftPad - rightPad;
const float choiceW = W - leftPad - rightPad + 32;
const float choiceH = choiceW / choiceTexAspect;
const float choiceSpacing = 8.f;
const float choiceSpacing = -18.f;
const float totalChoicesH = (choiceH + choiceSpacing) * static_cast<float>(model.choices.size()) - choiceSpacing;
const float choiceStartY = panelTopY - 34.f - totalChoicesH; // below name row
const float choiceStartY = panelTopY - 80.f - totalChoicesH; // below name row
if (choiceQuads.size() < model.choices.size()) {
choiceQuads.resize(model.choices.size());
@@ -313,7 +313,7 @@ void DialogueOverlay::drawPortrait(Renderer& renderer, const PresentationModel&
for (size_t i = 0; i < model.choices.size(); ++i) {
const float cy = choiceStartY + (choiceH + choiceSpacing) * static_cast<float>(model.choices.size() - 1 - i);
UiRect rect{ leftPad, cy, choiceW, choiceH };
UiRect rect{ leftPad-16.f, cy, choiceW, choiceH };
lastChoiceRects.push_back(rect);
choiceQuads[i].rebuild(rect);
@@ -338,7 +338,7 @@ void DialogueOverlay::drawPortrait(Renderer& renderer, const PresentationModel&
const std::string wrappedChoice = wrapTextToWidth(model.choices[i].text, *choiceRenderer, rect.w - 20.0f, 1.0f);
choiceRenderer->drawText(
wrappedChoice, rect.x + 20.f, rect.y + choiceH * 0.35f, 1.5f, false,
wrappedChoice, rect.x + 20.f, rect.y + choiceH * 0.35f+5.f, 1.4f, false,
isHighlighted ? std::array<float, 4>{1.0f, 1.0f, 1.0f, 1.0f} : color
);
}