From 7031a219221a75f18e436e9239620d6aad3b2683 Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Fri, 12 Jun 2026 20:18:43 +0300 Subject: [PATCH] Fixing UI bugs, updating web UI --- proj-web/CMakeLists.txt | 2 + resources/dialogue/cutscene_subtitle_bg.png | 4 +- resources/loading.png | 2 +- resources/loadingProgressBar.png | 3 + resources/loadingProgressBarFrame.png | 3 + resources/rotateYourDevice.png | 3 + resources/start_uni_exterior.lua | 1 + resources/w/ui/img/Hint1.png | 4 +- resources/w/ui/img/Hint2.png | 4 +- resources/w/ui/img/Hint3.png | 4 +- resources/w/ui/img/Hint4.png | 4 +- resources/w/ui/img/Hint5.png | 4 +- resources/w/ui/img/Hint6a.png | 4 +- resources/w/ui/img/Hint6b.png | 4 +- resources/w/ui/img/Hint_darklands001.png | 4 +- .../w/ui/img/Journal001_State=Default.png | 4 +- .../w/ui/img/Journal001_State=Selected.png | 4 +- resources/w/ui/img/Journal001_State=Tap.png | 4 +- .../w/ui/img/Phone001_State=Selected.png | 4 +- resources/w/ui/img/Phone001_State=Tap.png | 4 +- resources/w/ui/img/hint_arrow_down.png | 4 +- resources/w/ui/img/hint_arrow_left.png | 4 +- resources/w/ui/img/hint_arrow_right.png | 4 +- resources/w/ui/img/hint_arrow_up.png | 4 +- resources/w/ui/screen_journal.json | 13 +- src/Game.cpp | 135 +++++++++++++++++- src/Game.h | 22 ++- src/MenuManager.cpp | 8 ++ 28 files changed, 216 insertions(+), 48 deletions(-) create mode 100644 resources/loadingProgressBar.png create mode 100644 resources/loadingProgressBarFrame.png create mode 100644 resources/rotateYourDevice.png diff --git a/proj-web/CMakeLists.txt b/proj-web/CMakeLists.txt index fa20b5f..dcb8772 100644 --- a/proj-web/CMakeLists.txt +++ b/proj-web/CMakeLists.txt @@ -185,6 +185,8 @@ set(EMSCRIPTEN_LINK_FLAGS "-sALLOW_MEMORY_GROWTH=1" "-sFULL_ES3=1" "--preload-file ${CMAKE_CURRENT_SOURCE_DIR}/../resources/loading.png@resources/loading.png" + "--preload-file ${CMAKE_CURRENT_SOURCE_DIR}/../resources/loadingProgressBar.png@resources/loadingProgressBar.png" + "--preload-file ${CMAKE_CURRENT_SOURCE_DIR}/../resources/loadingProgressBarFrame.png@resources/loadingProgressBarFrame.png" "--preload-file ${CMAKE_CURRENT_SOURCE_DIR}/../resources/shaders@resources/shaders" "--preload-file ${CMAKE_CURRENT_SOURCE_DIR}/../resources/start_uni_interior.lua@resources/start_uni_interior.lua" "--preload-file ${CMAKE_CURRENT_SOURCE_DIR}/../resources/start_uni_exterior.lua@resources/start_uni_exterior.lua" diff --git a/resources/dialogue/cutscene_subtitle_bg.png b/resources/dialogue/cutscene_subtitle_bg.png index 9984263..677e860 100644 --- a/resources/dialogue/cutscene_subtitle_bg.png +++ b/resources/dialogue/cutscene_subtitle_bg.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b5aff657e1efd81b8a4806cee19928c4649506ce2906aa2cd03c9569139c6f5c -size 1128 +oid sha256:3f77716075ec73a29c3255a61680352b8e38e58907b4241b1e3e7e182089754f +size 394 diff --git a/resources/loading.png b/resources/loading.png index a31d7fa..d2afc3a 100644 --- a/resources/loading.png +++ b/resources/loading.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f5c05b59ffb6170102aef205bafaf95fa88abb76ec549722d408600154c2b4f0 +oid sha256:0b91a4d03c9f07f703075fb4fc19ec4b9277f5a5d2b7f95d3a720be8c4360ec8 size 13592 diff --git a/resources/loadingProgressBar.png b/resources/loadingProgressBar.png new file mode 100644 index 0000000..f512be6 --- /dev/null +++ b/resources/loadingProgressBar.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cb61801af17154e10ce5667b0be124b50d9ec67c6007f97852366a056e701887 +size 371 diff --git a/resources/loadingProgressBarFrame.png b/resources/loadingProgressBarFrame.png new file mode 100644 index 0000000..d1001c9 --- /dev/null +++ b/resources/loadingProgressBarFrame.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:437d00f9e5230fc8f7756795937f8c3e69479f1c87ce4b1333e6fb14adc8082c +size 371 diff --git a/resources/rotateYourDevice.png b/resources/rotateYourDevice.png new file mode 100644 index 0000000..9d578b9 --- /dev/null +++ b/resources/rotateYourDevice.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9d676836531093a5b9b160f2be918e87d253eab389e59d730b6e231ea05807bb +size 25523 diff --git a/resources/start_uni_exterior.lua b/resources/start_uni_exterior.lua index e9d42c6..f1cf768 100644 --- a/resources/start_uni_exterior.lua +++ b/resources/start_uni_exterior.lua @@ -26,6 +26,7 @@ function on_container_clicked() game_api.start_dialogue("dialog_contaier003") elseif player_container_aware == 1 then game_api.start_dialogue("dialog_contaier002") + game_api.setIntValue("player_has_coursework", 1) else game_api.start_dialogue("dialog_contaier001") end diff --git a/resources/w/ui/img/Hint1.png b/resources/w/ui/img/Hint1.png index 5eff0ad..63a8608 100644 --- a/resources/w/ui/img/Hint1.png +++ b/resources/w/ui/img/Hint1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:58b0cbfdee7f1a9833c2373138fb57b294cd74241eee76d8d6d486bbc1900bba -size 92577 +oid sha256:89d163a143b89ca2f643a1b6b540681eb0c5c348170c51cdec99f61ebe0d47d2 +size 328438 diff --git a/resources/w/ui/img/Hint2.png b/resources/w/ui/img/Hint2.png index 54e7624..2d56d5a 100644 --- a/resources/w/ui/img/Hint2.png +++ b/resources/w/ui/img/Hint2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9df93a2d9772131198ba870d21ec58f2cdad6c8cfddd8d7651d1eb060dc86de2 -size 94084 +oid sha256:47ff20d4445c18d20fae842f61fab6ae53af8a850be564065e9bf9fccff6e8ec +size 335321 diff --git a/resources/w/ui/img/Hint3.png b/resources/w/ui/img/Hint3.png index 4ccfe79..512c383 100644 --- a/resources/w/ui/img/Hint3.png +++ b/resources/w/ui/img/Hint3.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1f538a05f82eddef759a5965eb8ce695f3435377337be4f11c14272a3330f6cf -size 101283 +oid sha256:faa8cfdd4d2df5916a06c6497686c71e516faf3639541dbf0cc5001ac36c0250 +size 335362 diff --git a/resources/w/ui/img/Hint4.png b/resources/w/ui/img/Hint4.png index 32a2e9f..a35fdf4 100644 --- a/resources/w/ui/img/Hint4.png +++ b/resources/w/ui/img/Hint4.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f8ec3eed0d8d53878b9509b7208365fd3733d2937736e49954317ed171548382 -size 107965 +oid sha256:c5f2f556d6d32581e800279bf90cdcda59c619c2bedb9e9a6edc78a9d4270c5f +size 372666 diff --git a/resources/w/ui/img/Hint5.png b/resources/w/ui/img/Hint5.png index 2fad43f..4ff5aef 100644 --- a/resources/w/ui/img/Hint5.png +++ b/resources/w/ui/img/Hint5.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a1289f15723d5149051c89f4537d8fe9b2048f22c678b4d7e7385ed63eaf73df -size 90367 +oid sha256:cdeec7178f9f5fca71563aef52842e60376cf32b82e0f988f9a7ef94485a0353 +size 313774 diff --git a/resources/w/ui/img/Hint6a.png b/resources/w/ui/img/Hint6a.png index 4a54875..66b3788 100644 --- a/resources/w/ui/img/Hint6a.png +++ b/resources/w/ui/img/Hint6a.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:00d7779ba5b5188757b79b7a7e96a5ad148ff4a881b4fe0067d288963311985c -size 103833 +oid sha256:4d7f7ff0ef71ec8d04cb3f2694fae91cf26245eda81b407ffeae4079c58c5f43 +size 352111 diff --git a/resources/w/ui/img/Hint6b.png b/resources/w/ui/img/Hint6b.png index a22a9ef..b229fe2 100644 --- a/resources/w/ui/img/Hint6b.png +++ b/resources/w/ui/img/Hint6b.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2e9eefa66da9fd5fd82be7a156d4a34cf3a8cbd2bec67283d056edb34d79a063 -size 141603 +oid sha256:9cc6a1c6c587fa1edd05c4080f1b16ed3b8e0e450bee559956ebb591787b97af +size 349923 diff --git a/resources/w/ui/img/Hint_darklands001.png b/resources/w/ui/img/Hint_darklands001.png index 40e20d2..8bda30d 100644 --- a/resources/w/ui/img/Hint_darklands001.png +++ b/resources/w/ui/img/Hint_darklands001.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:87c030916193e9cb63814e3ebcb393e8bbaafc4e7766dfdf19c87ca77ac7b284 -size 312915 +oid sha256:33c96364a5fbae7f3788c40b004f62211995b5f156b470c3c8679aed6ac863e2 +size 373943 diff --git a/resources/w/ui/img/Journal001_State=Default.png b/resources/w/ui/img/Journal001_State=Default.png index a6eb3ef..f9e5b54 100644 --- a/resources/w/ui/img/Journal001_State=Default.png +++ b/resources/w/ui/img/Journal001_State=Default.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5548bc89d49799fdd4c5acb60f90ad15e09976707458323a42c5e21beedc080f -size 147743 +oid sha256:d3eb043a5989c478c7b7e21f1e101a1dc5751faa89923d149742150315d639e8 +size 631607 diff --git a/resources/w/ui/img/Journal001_State=Selected.png b/resources/w/ui/img/Journal001_State=Selected.png index cd9c2c9..977db78 100644 --- a/resources/w/ui/img/Journal001_State=Selected.png +++ b/resources/w/ui/img/Journal001_State=Selected.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b3420f309c3eef72369229d9316a50e48ecb2a4f34b9999ae907cbcdc3f87465 -size 160455 +oid sha256:3fae467310687b45bc8afb6c36e11622f0d46f0ec394a1a1157905df448cff8d +size 578484 diff --git a/resources/w/ui/img/Journal001_State=Tap.png b/resources/w/ui/img/Journal001_State=Tap.png index 9dde54e..664ad81 100644 --- a/resources/w/ui/img/Journal001_State=Tap.png +++ b/resources/w/ui/img/Journal001_State=Tap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:afd82669661fb611bebec0296a9166dfa391b124fc21424f8a821395f1c6dc2a -size 134106 +oid sha256:33e5cbf6bdc14734cd4ec026ac5d34961806a54ee8ac0e9546fd55d0d9d2be2a +size 479569 diff --git a/resources/w/ui/img/Phone001_State=Selected.png b/resources/w/ui/img/Phone001_State=Selected.png index f7ee960..88d926e 100644 --- a/resources/w/ui/img/Phone001_State=Selected.png +++ b/resources/w/ui/img/Phone001_State=Selected.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:76736f641751a94d09795087d4bdbf1a3463e0cbdc979b649e9d2291f7986b4b -size 238080 +oid sha256:1edcbb671a74e573aa0e0c6f569e5ebe2033b5739c3540655936b37acc08955c +size 873116 diff --git a/resources/w/ui/img/Phone001_State=Tap.png b/resources/w/ui/img/Phone001_State=Tap.png index 949c0d8..8922467 100644 --- a/resources/w/ui/img/Phone001_State=Tap.png +++ b/resources/w/ui/img/Phone001_State=Tap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:864f06a227a8e679d6dfd3c044b2aed28c0c9c11458230fb91ae1e435db9a406 -size 165128 +oid sha256:fbfb3c6b4b1da439df0bba68e8dc5614fb03f3625ce43a5858cde45dbc086c3f +size 600718 diff --git a/resources/w/ui/img/hint_arrow_down.png b/resources/w/ui/img/hint_arrow_down.png index eb8c9c4..1ca4e0c 100644 --- a/resources/w/ui/img/hint_arrow_down.png +++ b/resources/w/ui/img/hint_arrow_down.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5f1346a192fb72f69ba8778c56cf5db7c269b45abb7f3db2aa57eac3166a9c30 -size 2019 +oid sha256:120be26f48544519472913dc3fd8744e5222ece14be1dd452d0e9791538abe04 +size 4387 diff --git a/resources/w/ui/img/hint_arrow_left.png b/resources/w/ui/img/hint_arrow_left.png index 44c37cc..ece8fdf 100644 --- a/resources/w/ui/img/hint_arrow_left.png +++ b/resources/w/ui/img/hint_arrow_left.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f557553413c44562745ca1d3f024304de63ef0e91346cfa8728930aa7eaac838 -size 1545 +oid sha256:865151e74ce3617ada289fb657248a9bad7e8eed56f346b43ce3ec2043ca7b1f +size 2666 diff --git a/resources/w/ui/img/hint_arrow_right.png b/resources/w/ui/img/hint_arrow_right.png index 06d0c7c..d422f09 100644 --- a/resources/w/ui/img/hint_arrow_right.png +++ b/resources/w/ui/img/hint_arrow_right.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e36468ad8ac9f86fce40c754a3e65b0f3e69ce377f8266658cfb2066d2ca2afa -size 1567 +oid sha256:d8c35b978fab5f3db55788382f98cec49be79bb0be3d495c9ca370ca6723f47f +size 2653 diff --git a/resources/w/ui/img/hint_arrow_up.png b/resources/w/ui/img/hint_arrow_up.png index 3d38c95..b2cf9c3 100644 --- a/resources/w/ui/img/hint_arrow_up.png +++ b/resources/w/ui/img/hint_arrow_up.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2bb859189e7ed73e340b4d16f19937451f14577f714859ab263eca865665c6cc -size 1785 +oid sha256:6a5fceaed91293e738389ff2bdeeaa62ef41811043d9faa1f3ef49d7494a66f5 +size 3186 diff --git a/resources/w/ui/screen_journal.json b/resources/w/ui/screen_journal.json index 4749e2f..87ca600 100644 --- a/resources/w/ui/screen_journal.json +++ b/resources/w/ui/screen_journal.json @@ -4,7 +4,7 @@ "name": "hud_root", "width": "match_parent", "height": "match_parent", - "vertical_align": "center", + "vertical_align": "top", "horizontal_align": "center", "children": [ { @@ -12,19 +12,20 @@ "name": "background", "width": 1266, "height": 585, + "y": 68, "horizontal_gravity": "center", - "vertical_gravity": "center", + "vertical_gravity": "top", "texture": "resources/w/ui/img/journal/QuestJournal003.png" }, { "type": "Button", "name": "journalExitButton", - "horizontal_gravity": "top", - "vertical_gravity": "center", + "horizontal_gravity": "center", + "vertical_gravity": "top", "width": 90, "height": 90, - "x": 1170, - "y": 240, + "x": 580, + "y": 70, "textures": { "normal": "resources/w/ui/img/Close001_State=Default.png", "hover": "resources/w/ui/img/Close001_State=Selected.png", diff --git a/src/Game.cpp b/src/Game.cpp index 9eeef8c..8f6cc5f 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -48,18 +48,24 @@ namespace ZL #ifdef EMSCRIPTEN Game* Game::s_instance = nullptr; - void Game::onResourcesZipLoaded(const char* /*filename*/) { + void Game::onResourcesZipLoaded(unsigned /*handle*/, void* /*userData*/, const char* /*filename*/) { std::cout << "Resources.zip loaded successfully" << std::endl; if (s_instance) { + s_instance->resourcesDownloadProgress = 1.0f; s_instance->mainThreadHandler.EnqueueMainThreadTask([&]() { s_instance->setupPart2(); }); } } - void Game::onResourcesZipError(const char* /*filename*/) { + void Game::onResourcesZipError(unsigned /*handle*/, void* /*userData*/, int /*httpStatus*/) { std::cout << "Failed to download resources.zip" << std::endl; } + + void Game::onResourcesZipProgress(unsigned /*handle*/, void* /*userData*/, int percentComplete) { + if (s_instance) + s_instance->resourcesDownloadProgress = percentComplete / 100.0f; + } #endif Game::Game() @@ -98,6 +104,12 @@ namespace ZL #endif loadingTexture = renderer.textureManager.LoadFromPng("resources/loading.png", ""); +#ifdef EMSCRIPTEN + loadingProgressBarFrameTexture = renderer.textureManager.LoadFromPng( + "resources/loadingProgressBarFrame.png", "", true); + loadingProgressBarTexture = renderer.textureManager.LoadFromPng( + "resources/loadingProgressBar.png", "", true); +#endif float minDimension; float width = Environment::projectionWidth; float height = Environment::projectionHeight; @@ -119,7 +131,8 @@ namespace ZL // The loading screen stays visible until the download finishes. s_instance = this; std::cout << "Load resurces step 1" << std::endl; - emscripten_async_wget("resources.zip", "resources.zip", onResourcesZipLoaded, onResourcesZipError); + emscripten_async_wget2("resources.zip", "resources.zip", "GET", nullptr, nullptr, + onResourcesZipLoaded, onResourcesZipError, onResourcesZipProgress); #else mainThreadHandler.EnqueueMainThreadTask([this]() { std::cout << "Load resurces step 2" << std::endl; @@ -451,6 +464,9 @@ namespace ZL renderer.textureManager.LoadFromPng("resources/w/ui/img/toast/item_received001.png", CONST_ZIP_FILE, true); renderer.textureManager.LoadFromPng("resources/w/ui/img/toast/item_removed001.png", CONST_ZIP_FILE, true); + mobileRotateTexture = renderer.textureManager.LoadFromPng( + "resources/rotateYourDevice.png", CONST_ZIP_FILE, true); + // Wire inventory callbacks: tutorial tracking + toast notifications. @@ -608,6 +624,9 @@ namespace ZL if (!loadingCompleted) { drawLoading(); } + else if (Environment::width < Environment::height) { + drawMobilePortraitOverlay(); + } else { if (currentLocation) @@ -643,6 +662,37 @@ namespace ZL CheckGlError(__FILE__, __LINE__); } + void Game::drawMobilePortraitOverlay() + { + if (!mobileRotateTexture) return; + + const float W = Environment::projectionWidth; + const float H = Environment::projectionHeight; + + if (W != mobileRotateMeshLastW || H != mobileRotateMeshLastH) { + mobileRotateMeshLastW = W; + mobileRotateMeshLastH = H; + const float minDim = min(W, H); + mobileRotateMesh.data = CreateRect2D({ 0.f, 0.f }, { minDim * 0.5f, minDim * 0.5f }, 3.f); + mobileRotateMesh.RefreshVBO(); + } + + renderer.shaderManager.PushShader(defaultShaderName); + renderer.RenderUniform1i(textureUniformName, 0); + renderer.RenderUniform1f("uAlpha", 1.0f); + renderer.PushProjectionMatrix(-W * 0.5f, W * 0.5f, -H * 0.5f, H * 0.5f, -10, 10); + renderer.PushMatrix(); + renderer.LoadIdentity(); + + glBindTexture(GL_TEXTURE_2D, mobileRotateTexture->getTexID()); + renderer.DrawVertexRenderStruct(mobileRotateMesh); + + renderer.PopMatrix(); + renderer.PopProjectionMatrix(); + renderer.shaderManager.PopShader(); + CheckGlError(__FILE__, __LINE__); + } + void Game::drawLoading() { glClear(GL_DEPTH_BUFFER_BIT); @@ -669,6 +719,81 @@ namespace ZL renderer.PopMatrix(); renderer.PopProjectionMatrix(); renderer.shaderManager.PopShader(); + +#ifdef EMSCRIPTEN + if (loadingProgressBarFrameTexture && loadingProgressBarTexture) { + const float W = Environment::projectionWidth; + const float H = Environment::projectionHeight; + static constexpr float kBarW = 400.0f; + static constexpr float kBarH = 40.0f; + const float barCenterY = -(H * 0.4f - 60.0f); + const float barLeft = -kBarW * 0.5f; + const float barBottom = barCenterY - kBarH * 0.5f; + const float barTop = barCenterY + kBarH * 0.5f; + + + // Rebuild frame mesh when projection dimensions change + if (W != loadingBarLastW || H != loadingBarLastH) { + loadingBarLastW = W; + loadingBarLastH = H; + VertexDataStruct frameData; + frameData.PositionData = { + {barLeft, barBottom, 4.f}, {barLeft, barTop, 4.f}, {barLeft+kBarW, barTop, 4.f}, + {barLeft+kBarW, barTop, 4.f}, {barLeft+kBarW, barBottom, 4.f}, {barLeft, barBottom, 4.f} + }; + frameData.TexCoordData = { + {0.f,0.f},{0.f,1.f},{1.f,1.f}, + {1.f,1.f},{1.f,0.f},{0.f,0.f} + }; + loadingProgressBarFrameMesh.data = std::move(frameData); + loadingProgressBarFrameMesh.RefreshVBO(); + loadingBarLastRenderedProgress = -1.0f; // force fill rebuild too + } + + // Rebuild fill mesh when progress changes + const float p = std::min(resourcesDownloadProgress, 1.0f); + if (p != loadingBarLastRenderedProgress) { + loadingBarLastRenderedProgress = p; + if (p > 0.001f) { + const float fillRight = barLeft + kBarW * p; + VertexDataStruct fillData; + fillData.PositionData = { + {barLeft, barBottom, 4.f}, {barLeft, barTop, 4.f}, {fillRight, barTop, 4.f}, + {fillRight, barTop, 4.f}, {fillRight, barBottom, 4.f}, {barLeft, barBottom, 4.f} + }; + fillData.TexCoordData = { + {0.f,0.f},{0.f,1.f},{p,1.f}, + {p,1.f},{p,0.f},{0.f,0.f} + }; + loadingProgressBarFillMesh.data = std::move(fillData); + loadingProgressBarFillMesh.RefreshVBO(); + } + } + + renderer.shaderManager.PushShader(defaultShaderName); + renderer.RenderUniform1i(textureUniformName, 0); + renderer.RenderUniform1f("uAlpha", 1.0f); + renderer.PushProjectionMatrix(-W*0.5f, W*0.5f, -H*0.5f, H*0.5f, -10, 10); + renderer.PushMatrix(); + renderer.LoadIdentity(); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glBindTexture(GL_TEXTURE_2D, loadingProgressBarFrameTexture->getTexID()); + renderer.DrawVertexRenderStruct(loadingProgressBarFrameMesh); + + if (p > 0.001f) { + glBindTexture(GL_TEXTURE_2D, loadingProgressBarTexture->getTexID()); + renderer.DrawVertexRenderStruct(loadingProgressBarFillMesh); + } + + renderer.PopMatrix(); + renderer.PopProjectionMatrix(); + renderer.shaderManager.PopShader(); + } +#endif + CheckGlError(__FILE__, __LINE__); } @@ -729,6 +854,7 @@ namespace ZL void Game::update() { SDL_Event event; + const bool mobileIsPortrait = loadingCompleted && (Environment::width < Environment::height); while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) { Environment::exitGameLoop = true; @@ -746,6 +872,9 @@ namespace ZL //space.clearTextRendererCache(); } + // Suppress all input while portrait overlay is shown + if (mobileIsPortrait) continue; + #ifdef __ANDROID__ if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_AC_BACK) { Environment::exitGameLoop = true; diff --git a/src/Game.h b/src/Game.h index ca30589..f478215 100644 --- a/src/Game.h +++ b/src/Game.h @@ -115,8 +115,18 @@ namespace ZL { #ifdef EMSCRIPTEN static Game* s_instance; - static void onResourcesZipLoaded(const char* filename); - static void onResourcesZipError(const char* filename); + static void onResourcesZipLoaded(unsigned handle, void* userData, const char* filename); + static void onResourcesZipError(unsigned handle, void* userData, int httpStatus); + static void onResourcesZipProgress(unsigned handle, void* userData, int percentComplete); + + float resourcesDownloadProgress = 0.0f; + std::shared_ptr loadingProgressBarTexture; + std::shared_ptr loadingProgressBarFrameTexture; + VertexRenderStruct loadingProgressBarFrameMesh; + VertexRenderStruct loadingProgressBarFillMesh; + float loadingBarLastRenderedProgress = -1.0f; + float loadingBarLastW = -1.0f; + float loadingBarLastH = -1.0f; #endif // Screen-flash transition state (shared by darklands and night transitions) @@ -131,6 +141,14 @@ namespace ZL { void updateDarklandsFlash(int64_t deltaMs); void drawDarklandsFlash(); + // Portrait-mode overlay (mobile / portrait browsers) + std::shared_ptr mobileRotateTexture; + VertexRenderStruct mobileRotateMesh; + float mobileRotateMeshLastW = -1.0f; + float mobileRotateMeshLastH = -1.0f; + + void drawMobilePortraitOverlay(); + int64_t newTickCount; int64_t lastTickCount; diff --git a/src/MenuManager.cpp b/src/MenuManager.cpp index 6106801..0e6e110 100644 --- a/src/MenuManager.cpp +++ b/src/MenuManager.cpp @@ -218,6 +218,7 @@ namespace ZL { uiManager.pushMenuFromSavedRoot(aboutScreenRoot); uiManager.setTextButtonCallback("aboutBackButton", [this](const std::string&) { uiManager.popMenu(); + uiManager.updateAllLayouts(); }); } @@ -308,6 +309,7 @@ namespace ZL { void MenuManager::closeInventory() { state = GameState::Gameplay; uiManager.popMenu(); + uiManager.updateAllLayouts(); } void MenuManager::openQuestJournal() { @@ -344,6 +346,7 @@ namespace ZL { selectedQuestIndex = -1; visibleQuestIds.clear(); uiManager.popMenu(); + uiManager.updateAllLayouts(); } void MenuManager::toggleQuestJournal() { @@ -480,6 +483,7 @@ namespace ZL { }); uiManager.setButtonCallback("buttonBack", [this](const std::string&) { uiManager.popMenu(); + uiManager.updateAllLayouts(); }); } @@ -491,6 +495,7 @@ namespace ZL { }); uiManager.setButtonCallback("buttonBack", [this](const std::string&) { uiManager.popMenu(); + uiManager.updateAllLayouts(); }); uiManager.setButtonCallback("videoSkip", [this](const std::string&) { closePhoneEntirely(); @@ -533,6 +538,7 @@ namespace ZL { }); uiManager.setButtonCallback("buttonBack", [this](const std::string&) { uiManager.popMenu(); + uiManager.updateAllLayouts(); }); uiManager.setButtonCallback("mapGo", [this](const std::string&) { tutorialNeedOpenTaxiScreen = false; @@ -572,6 +578,7 @@ namespace ZL { activeChatIndex_ = -1; phoneChatVisibleBubbles_.clear(); uiManager.popMenu(); + uiManager.updateAllLayouts(); if (tutorialPhoneChatScreenOpened) { uiManager.setNodeVisible("hint_m002", false); @@ -590,6 +597,7 @@ namespace ZL { phoneChatVisibleBubbles_.clear(); const int depth = uiManager.menuStackSize(); for (int i = 0; i < depth; ++i) uiManager.popMenu(); + uiManager.updateAllLayouts(); if (tutorialNeedOpenTaxiScreen) {