Working on UI fixing

This commit is contained in:
Vladislav Khorev 2026-06-12 14:40:41 +03:00
parent a4032d769e
commit dee9615483
5 changed files with 24 additions and 21 deletions

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
<title>Bishkek Witcher</title> <title>Shadow Over Bishkek</title>
<style> <style>
body, html { body, html {
margin: 0; padding: 0; width: 100%; height: 100%; margin: 0; padding: 0; width: 100%; height: 100%;

View File

@ -223,7 +223,8 @@ namespace ZL
"resources/navigation/uni_interior4_locked.txt" //16 "resources/navigation/uni_interior4_locked.txt" //16
}; };
/* /*
uniInteriorParams.navigationJsonPaths = { uniInteriorParams.navigationJsonPaths = {
"resources/navigation/uni_interior4_unlocked_n2.json", //0 "resources/navigation/uni_interior4_unlocked_n2.json", //0
@ -872,7 +873,7 @@ namespace ZL
break; break;
case SDLK_e: case SDLK_e:
currentLocation->dialogueSystem.startCutscene("lection_cutscene001"); //.startDialogue("test_cutscene_pan_dialogue"); //currentLocation->dialogueSystem.startCutscene("lection_cutscene001"); //.startDialogue("test_cutscene_pan_dialogue");
break; break;

View File

@ -89,8 +89,6 @@ namespace ZL {
hudRoot = loadUiFromFile("resources/w/ui/hud_step0.json", renderer, zipFile); hudRoot = loadUiFromFile("resources/w/ui/hud_step0.json", renderer, zipFile);
hudStep1Root = loadUiFromFile("resources/w/ui/hud_step1.json", renderer, zipFile); hudStep1Root = loadUiFromFile("resources/w/ui/hud_step1.json", renderer, zipFile);
hudStep2Root = loadUiFromFile("resources/w/ui/hud_step2.json", renderer, zipFile); hudStep2Root = loadUiFromFile("resources/w/ui/hud_step2.json", renderer, zipFile);
hudStep1Root = loadUiFromFile("resources/w/ui/hud_uni_int_step11.json", renderer, zipFile);
hudStep2Root = loadUiFromFile("resources/w/ui/hud_uni_int_step11.json", renderer, zipFile);
hudStep3Root = loadUiFromFile("resources/w/ui/hud_step3.json", renderer, zipFile); hudStep3Root = loadUiFromFile("resources/w/ui/hud_step3.json", renderer, zipFile);
hudStep4Root = loadUiFromFile("resources/w/ui/hud_step4.json", renderer, zipFile); hudStep4Root = loadUiFromFile("resources/w/ui/hud_step4.json", renderer, zipFile);
hudStep5aRoot = loadUiFromFile("resources/w/ui/hud_step5a.json", renderer, zipFile); hudStep5aRoot = loadUiFromFile("resources/w/ui/hud_step5a.json", renderer, zipFile);

View File

@ -56,12 +56,21 @@ void DialogueOverlay::draw(Renderer& renderer, const PresentationModel& model) {
return; return;
} }
//const float W = Environment::projectionWidth; const float W = Environment::projectionWidth;
const float W = 1280.0;
UiRect portraitRect{ 24.0f + 90, 24.0f + 16, 176.0f, 176.0f }; const float nameX = 312 + 8;
UiRect textboxRect{ 30.f, -48.f, 1222.f, 340.0f }; const float nameY = 232 - 38.0f;
UiRect textboxChoiceRect{ 30.f, -90.f, 1200.f, 619.5f }; const float bodyX = 312 + 8;
const float bodyY = 232 - 78.0f;
const float bodyMaxWidthPx = 1280.0 - nameX - 48.f - 60.f;
float centeredShiftX = ((W - nameX - 48.f - 60.f) - bodyMaxWidthPx)*0.5;
UiRect portraitRect{ 24.0f + 90 + centeredShiftX, 24.0f + 16, 176.0f, 176.0f };
UiRect textboxRect{ 30.f + centeredShiftX, -48.f, 1222.f, 340.0f };
UiRect textboxChoiceRect{ 30.f + centeredShiftX, -90.f, 1200.f, 619.5f };
lastDialogueAdvanceRect = { portraitRect.x, portraitRect.y, textboxRect.x + textboxRect.w - portraitRect.x, textboxRect.h }; lastDialogueAdvanceRect = { portraitRect.x, portraitRect.y, textboxRect.x + textboxRect.w - portraitRect.x, textboxRect.h };
@ -119,10 +128,6 @@ void DialogueOverlay::draw(Renderer& renderer, const PresentationModel& model) {
renderer.shaderManager.PopShader(); renderer.shaderManager.PopShader();
const float nameX = 312+8;
const float nameY = 232 - 38.0f;
const float bodyX = 312+8;
const float bodyY = 232 - 78.0f;
lastChoiceRects.clear(); lastChoiceRects.clear();
@ -130,18 +135,17 @@ void DialogueOverlay::draw(Renderer& renderer, const PresentationModel& model) {
if (model.mode == PresentationMode::Choice) if (model.mode == PresentationMode::Choice)
{ {
nameRenderer->drawText(model.speaker, nameX+20, nameY+230, 1.0f, false, { 1.0f, 0.88f, 0.45f, 1.0f }); nameRenderer->drawText(model.speaker, nameX+20 + centeredShiftX, nameY+230, 1.0f, false, { 1.0f, 0.88f, 0.45f, 1.0f });
} }
else else
{ {
nameRenderer->drawText(model.speaker, nameX, nameY, 1.0f, false, { 1.0f, 0.88f, 0.45f, 1.0f }); nameRenderer->drawText(model.speaker, nameX + centeredShiftX, nameY, 1.0f, false, { 1.0f, 0.88f, 0.45f, 1.0f });
} }
} }
const float bodyMaxWidthPx = W - nameX - 48.f - 60.f;
const std::string wrappedBody = wrapTextToWidth(model.visibleText, *bodyRenderer, bodyMaxWidthPx, 1.0f); const std::string wrappedBody = wrapTextToWidth(model.visibleText, *bodyRenderer, bodyMaxWidthPx, 1.0f);
bodyRenderer->drawText(wrappedBody, bodyX, bodyY, 1.0f, false, { 1.0f, 1.0f, 1.0f, 1.0f }); bodyRenderer->drawText(wrappedBody, bodyX + centeredShiftX, bodyY, 1.0f, false, { 1.0f, 1.0f, 1.0f, 1.0f });
if (model.mode == PresentationMode::Choice) { if (model.mode == PresentationMode::Choice) {
@ -166,7 +170,7 @@ void DialogueOverlay::draw(Renderer& renderer, const PresentationModel& model) {
for (size_t i = 0; i < model.choices.size(); ++i) { for (size_t i = 0; i < model.choices.size(); ++i) {
const float cy = choiceStartY + (choiceHeight + choiceSpacing) * static_cast<float>(model.choices.size() - 1 - i); const float cy = choiceStartY + (choiceHeight + choiceSpacing) * static_cast<float>(model.choices.size() - 1 - i);
UiRect rect{ 320.f, cy, choiceWidth, choiceHeight }; UiRect rect{ 320.f + centeredShiftX , cy, choiceWidth, choiceHeight };
lastChoiceRects.push_back(rect); lastChoiceRects.push_back(rect);
choiceQuads[i].rebuild(rect); choiceQuads[i].rebuild(rect);

View File

@ -175,7 +175,7 @@ extern "C" int SDL_main(int argc, char* argv[]) {
ZL::Environment::window = SDL_CreateWindow( ZL::Environment::window = SDL_CreateWindow(
"Bishkek Witcher Game", "Shadow Over Bishkek",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
ZL::Environment::width, ZL::Environment::height, ZL::Environment::width, ZL::Environment::height,
SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN
@ -263,7 +263,7 @@ int main(int argc, char *argv[]) {
#endif #endif
ZL::Environment::window = SDL_CreateWindow( ZL::Environment::window = SDL_CreateWindow(
"Bishkek Witcher Game", "Shadow Over Bishkek",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
ZL::Environment::width, ZL::Environment::height, ZL::Environment::width, ZL::Environment::height,
windowFlags windowFlags