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

+39 -3
View File
@@ -160,9 +160,18 @@ namespace FRG {
void MenuManager::loadUiRoots(const std::string& zipFile) {
hudRoot = loadLocalizedUi("resources/w/ui/hud_step0.json", zipFile);
#ifdef __ANDROID__
hudStep1Root = loadLocalizedUi("resources/w/ui/hud_step1android.json", zipFile);
#else
hudStep1Root = loadLocalizedUi("resources/w/ui/hud_step1.json", zipFile);
#endif
hudStep2Root = loadLocalizedUi("resources/w/ui/hud_step2.json", zipFile);
#ifdef __ANDROID__
hudStep3Root = loadLocalizedUi("resources/w/ui/hud_step3android.json", zipFile);
#else
hudStep3Root = loadLocalizedUi("resources/w/ui/hud_step3.json", zipFile);
#endif
hudStep4Root = loadLocalizedUi("resources/w/ui/hud_step4.json", zipFile);
hudStep5aRoot = loadLocalizedUi("resources/w/ui/hud_step5a.json", zipFile);
hudStep5bRoot = loadLocalizedUi("resources/w/ui/hud_step5b.json", zipFile);
@@ -216,9 +225,17 @@ namespace FRG {
questJournalRoot = loadLocalizedUi("resources/w/ui/screen_journal.json", zipFile);
portraitQuestJournalListRoot = loadLocalizedUi("resources/w/ui/portrait_screen_journal.json", zipFile);
portraitQuestJournalItemRoot = loadLocalizedUi("resources/w/ui/portrait_screen_journal_item.json", zipFile);
mainMenuRoot = loadLocalizedUi("resources/w/ui/screen_main_menu.json", zipFile);
#ifdef __ANDROID__
mainMenuRoot = loadLocalizedUi("resources/w/ui/screen_main_menu_android.json", zipFile);
aboutScreenRoot = loadLocalizedUi("resources/w/ui/screen_about_android.json", zipFile);
#else
mainMenuRoot = loadLocalizedUi("resources/w/ui/screen_main_menu.json", zipFile);
aboutScreenRoot = loadLocalizedUi("resources/w/ui/screen_about.json", zipFile);
creditsScreenRoot = loadLocalizedUi("resources/w/ui/screen_credits.json", zipFile);
#endif
creditsScreenRoot = loadLocalizedUi("resources/w/ui/screen_credits.json", zipFile);
portraitCreditsScreenRoot = loadLocalizedUi("resources/w/ui/screen_credits_portrait.json", zipFile);
settingsScreenRoot = loadLocalizedUi("resources/w/ui/screen_settings.json", zipFile);
settingsGraphicsScreenRoot = loadLocalizedUi("resources/w/ui/screen_settings_graphics.json", zipFile);
languageScreenRoot = loadLocalizedUi("resources/w/ui/screen_language.json", zipFile);
@@ -488,8 +505,17 @@ namespace FRG {
}
void MenuManager::showCreditsScreen() {
uiManager.pushMenuFromSavedRoot(creditsScreenRoot);
isPlayerInCreditsMenu = true;
if (isPortraitMode())
{
uiManager.pushMenuFromSavedRoot(portraitCreditsScreenRoot);
}
else
{
uiManager.pushMenuFromSavedRoot(creditsScreenRoot);
}
uiManager.setButtonCallback("creditsBackButton", [this](const std::string&) {
isPlayerInCreditsMenu = false;
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
@@ -642,6 +668,9 @@ namespace FRG {
refreshFullscreenToggle();
refreshShadowToggle();
#ifdef __ANDROID__
uiManager.setNodeVisible("fullScreenToggleButton", false);
#else
uiManager.setTextButtonCallback("fullScreenToggleButton", [this, refreshFullscreenToggle](const std::string&) {
Environment::setFullscreen(!Environment::isFullscreen);
refreshFullscreenToggle();
@@ -649,6 +678,7 @@ namespace FRG {
uiManager.updateAllLayouts();
topUiManager.updateAllLayouts();
});
#endif
uiManager.setTextButtonCallback("shadowToggleButton", [this, refreshShadowToggle](const std::string&) {
bool newValue = !this->shadowsEnabled;
@@ -2327,6 +2357,12 @@ namespace FRG {
}
void MenuManager::onOrientationChanged() {
if (isPlayerInCreditsMenu) {
uiManager.popMenu();
showCreditsScreen();
uiManager.updateAllLayouts();
return;
}
if (uiState_ == GameUiState::Inventory) {
const int savedIndex = inventorySelectedIndex_;
const bool wasOnItemDetail = (inventoryMenuStackDepth_ == 2);
+5 -2
View File
@@ -202,6 +202,7 @@ namespace FRG {
GameUiState uiState_ = GameUiState::Gameplay;
Inventory* inventory = nullptr;
bool isPlayerInCreditsMenu = false;
int inventorySelectedIndex_ = -1;
int inventoryMenuStackDepth_ = 0;
@@ -265,6 +266,8 @@ namespace FRG {
std::shared_ptr<UiNode> mainMenuRoot;
std::shared_ptr<UiNode> aboutScreenRoot;
std::shared_ptr<UiNode> creditsScreenRoot;
std::shared_ptr<UiNode> portraitCreditsScreenRoot;
std::shared_ptr<UiNode> settingsScreenRoot;
std::shared_ptr<UiNode> settingsGraphicsScreenRoot;
std::shared_ptr<UiNode> languageScreenRoot;
@@ -317,11 +320,11 @@ namespace FRG {
// OFFSET_UP / OFFSET_DOWN = how far the FBO extends above / below screen center.
// Height = UP + DOWN. Quad: y0 = projH/2 - DOWN, y1 = projH/2 + UP.
static constexpr float CHAT_FBO_WIDTH_L = 469.0f;
static constexpr float CHAT_FBO_OFFSET_UP_L = 260.0f;
static constexpr float CHAT_FBO_OFFSET_UP_L = 240.0f;
static constexpr float CHAT_FBO_OFFSET_DOWN_L = 70.0f;
static constexpr float CHAT_FBO_WIDTH_P = 670.0f;
static constexpr float CHAT_FBO_OFFSET_UP_P = 360.0f;
static constexpr float CHAT_FBO_OFFSET_UP_P = 356.0f;
static constexpr float CHAT_FBO_OFFSET_DOWN_P = 70.0f;
std::unique_ptr<FrameBuffer> chatFrameBuffer_;
+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;