Fixing android bugs and more

This commit is contained in:
Vladislav Khorev committed 2026-07-19 19:49:50 +03:00
1 parent 5b21ba615e
commit fc93eb6680
55 files changed
+1192 -141

No files matched your search

+24 -12
View File
@@ -30,10 +30,18 @@ bool DialogueOverlay::init(Renderer& renderer, const std::string& zipFile) {
bodyRenderer = std::make_unique<TextRenderer>();
choiceRenderer = std::make_unique<TextRenderer>();
portraitNameRenderer = std::make_unique<TextRenderer>();
portraitBodyRenderer = std::make_unique<TextRenderer>();
portraitChoiceRenderer = std::make_unique<TextRenderer>();
return
nameRenderer->init(renderer, "resources/fonts/DroidSans.ttf", 28, zipFile) &&
bodyRenderer->init(renderer, "resources/fonts/DroidSans.ttf", 24, zipFile) &&
choiceRenderer->init(renderer, "resources/fonts/DroidSans.ttf", 22, zipFile);
choiceRenderer->init(renderer, "resources/fonts/DroidSans.ttf", 22, zipFile)&&
portraitNameRenderer->init(renderer, "resources/fonts/DroidSans.ttf", 40, zipFile) &&
portraitBodyRenderer->init(renderer, "resources/fonts/DroidSans.ttf", 36, zipFile) &&
portraitChoiceRenderer->init(renderer, "resources/fonts/DroidSans.ttf", 36, zipFile);
}
void DialogueOverlay::update(const PresentationModel& model, int deltaMs) {
@@ -215,8 +223,10 @@ void DialogueOverlay::drawPortrait(Renderer& renderer, const PresentationModel&
const float H = Environment::projectionHeight;
// Panel: DialogChoice001.png scaled to full screen width, aspect ratio preserved.
const float texAspect = static_cast<float>(textboxChoicePortraitTexture->getWidth())
/ static_cast<float>(textboxChoicePortraitTexture->getHeight());
/*const float texAspect = static_cast<float>(textboxChoicePortraitTexture->getWidth())
/ static_cast<float>(textboxChoicePortraitTexture->getHeight());*/
const float texAspect = 4800.0f / 3568.0f;
const float panelW = W;
const float panelH = panelW / texAspect;
const float clipAtBottom = 18.f;
@@ -228,11 +238,11 @@ void DialogueOverlay::drawPortrait(Renderer& renderer, const PresentationModel&
const float portraitY = panelTopY + 6.f - 40.f;
// Text sits inside the panel near the top.
const float leftPad = 60.f;
const float leftPad = 68.f;
const float rightPad = 60.f;
const float textMaxWidth = W - leftPad - rightPad;
const float nameY = panelTopY - 32.f - 50.f;
const float bodyY = nameY - 38.f;
const float bodyY = nameY - 48.f;
// --- Rebuild quads only when geometry changes ---
{
@@ -282,25 +292,27 @@ void DialogueOverlay::drawPortrait(Renderer& renderer, const PresentationModel&
lastChoiceRects.clear();
if (!model.speaker.empty()) {
nameRenderer->drawText(model.speaker, leftPad, nameY, 1.0f, false, { 1.0f, 0.88f, 0.45f, 1.0f });
portraitNameRenderer->drawText(model.speaker, leftPad, nameY, 1.0f, false, { 1.0f, 0.88f, 0.45f, 1.0f });
}
const std::string wrappedBody = wrapTextToWidth(model.visibleText, *bodyRenderer, textMaxWidth, 1.0f);
bodyRenderer->drawText(wrappedBody, leftPad, bodyY, 1.0f, false, { 1.0f, 1.0f, 1.0f, 1.0f });
const std::string wrappedBody = wrapTextToWidth(model.visibleText, *portraitBodyRenderer, textMaxWidth, 1.0f);
portraitBodyRenderer->drawText(wrappedBody, leftPad, bodyY, 1.0f, false, { 1.0f, 1.0f, 1.0f, 1.0f });
// Hit rect for tap-to-advance.
lastDialogueAdvanceRect = { 0.f, 0.f, W, panelTopY };
// --- Choice mode: stack choices inside the panel ---
if (model.mode == PresentationMode::Choice) {
/*
const float choiceTexAspect = static_cast<float>(choiceMainTexture->getWidth())
/ static_cast<float>(choiceMainTexture->getHeight());
/ static_cast<float>(choiceMainTexture->getHeight());*/
const float choiceTexAspect = 3652.f / 484.f;
const float choiceW = W - leftPad - rightPad + 32;
const float choiceH = choiceW / choiceTexAspect;
const float choiceSpacing = -18.f;
const float totalChoicesH = (choiceH + choiceSpacing) * static_cast<float>(model.choices.size()) - choiceSpacing;
const float choiceStartY = panelTopY - 80.f - totalChoicesH; // below name row
const float choiceStartY = panelTopY - 90.f - totalChoicesH; // below name row
if (choiceQuads.size() < model.choices.size()) {
choiceQuads.resize(model.choices.size());
@@ -339,8 +351,8 @@ void DialogueOverlay::drawPortrait(Renderer& renderer, const PresentationModel&
: std::array<float, 4>{ 1.0f, 0.93f, 0.65f, 1.0f };
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+5.f, 1.4f, false,
portraitChoiceRenderer->drawText(
wrappedChoice, rect.x + 28.f, rect.y + choiceH * 0.35f+5.f, 1.0f, false,
isHighlighted ? std::array<float, 4>{1.0f, 1.0f, 1.0f, 1.0f} : color
);
}
+4
View File
@@ -43,6 +43,10 @@ private:
std::unique_ptr<TextRenderer> bodyRenderer;
std::unique_ptr<TextRenderer> choiceRenderer;
std::unique_ptr<TextRenderer> portraitNameRenderer;
std::unique_ptr<TextRenderer> portraitBodyRenderer;
std::unique_ptr<TextRenderer> portraitChoiceRenderer;
UiQuad portraitQuad;
UiQuad textboxQuad;
UiQuad textboxChoiceQuad;