From 86a9f38c3bf2cf6fd9a44f0f01ef60a5821d317e Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Mon, 9 Mar 2026 13:50:59 +0300 Subject: [PATCH] Some UI changes --- resources/button_minus_disabled.png | 3 ++ resources/button_plus_disabled.png | 3 ++ resources/config/main_menu.json | 10 ++---- resources/config/ship_selection_menu.json | 7 ++++ resources/config/ui.json | 6 ++-- resources/connection_failed.png | 4 +-- resources/loading.png | 4 +-- resources/main_menu/about.png | 3 ++ resources/main_menu/about_hover.png | 3 ++ resources/main_menu/about_pressed.png | 3 ++ resources/main_menu/title.png | 4 +-- resources/select_your_ship.png | 3 ++ src/Game.cpp | 43 ++++++++++------------- src/MenuManager.cpp | 23 +++++++++++- src/Space.cpp | 7 ++++ 15 files changed, 86 insertions(+), 40 deletions(-) create mode 100644 resources/button_minus_disabled.png create mode 100644 resources/button_plus_disabled.png create mode 100644 resources/main_menu/about.png create mode 100644 resources/main_menu/about_hover.png create mode 100644 resources/main_menu/about_pressed.png create mode 100644 resources/select_your_ship.png diff --git a/resources/button_minus_disabled.png b/resources/button_minus_disabled.png new file mode 100644 index 0000000..6a990e9 --- /dev/null +++ b/resources/button_minus_disabled.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a9667686ef6f83297b38a9b06d893fce5f1128ed8610283c32989a6bd37e9327 +size 11294 diff --git a/resources/button_plus_disabled.png b/resources/button_plus_disabled.png new file mode 100644 index 0000000..e7cf3c7 --- /dev/null +++ b/resources/button_plus_disabled.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:08e52cc78b6e2fbade9edd79ab7f394118fdcd6ca38ea7f2d68b25852e327acd +size 9563 diff --git a/resources/config/main_menu.json b/resources/config/main_menu.json index e97adb4..c103fb2 100644 --- a/resources/config/main_menu.json +++ b/resources/config/main_menu.json @@ -13,7 +13,7 @@ { "type": "StaticImage", "name": "titleBtn", - "width": 254, + "width": 434, "height": 35, "texture": "resources/main_menu/title.png" }, @@ -25,15 +25,11 @@ "texture": "resources/main_menu/line.png" }, { - "type": "Button", + "type": "StaticImage", "name": "subtitleBtn", "width": 144, "height": 11, - "textures": { - "normal": "resources/main_menu/subtitle.png", - "hover": "resources/main_menu/subtitle.png", - "pressed": "resources/main_menu/subtitle.png" - } + "texture": "resources/main_menu/subtitle.png" }, { "type": "Button", diff --git a/resources/config/ship_selection_menu.json b/resources/config/ship_selection_menu.json index 1a305de..bba2052 100644 --- a/resources/config/ship_selection_menu.json +++ b/resources/config/ship_selection_menu.json @@ -10,6 +10,13 @@ "width": "match_parent", "height": "match_parent", "children": [ + { + "type": "StaticImage", + "name": "titleBtn", + "width": 266, + "height": 66, + "texture": "resources/select_your_ship.png" + }, { "type": "LinearLayout", "orientation": "horizontal", diff --git a/resources/config/ui.json b/resources/config/ui.json index b7971a7..65d8225 100644 --- a/resources/config/ui.json +++ b/resources/config/ui.json @@ -65,7 +65,8 @@ "textures": { "normal": "resources/button_minus.png", "hover": "resources/button_minus_pressed.png", - "pressed": "resources/button_minus_pressed.png" + "pressed": "resources/button_minus_pressed.png", + "disabled" : "resources/button_minus_disabled.png" } }, { @@ -81,7 +82,8 @@ "textures": { "normal": "resources/button_plus.png", "hover": "resources/button_plus_pressed.png", - "pressed": "resources/button_plus_pressed.png" + "pressed": "resources/button_plus_pressed.png", + "disabled" : "resources/button_plus_disabled.png" } } ] diff --git a/resources/connection_failed.png b/resources/connection_failed.png index 52515b1..c1d108c 100644 --- a/resources/connection_failed.png +++ b/resources/connection_failed.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:801e00e096b469e1081cd805e83e682b858ded21ab0d3963bf7633fb22a76a4e -size 124627 +oid sha256:529240c1211bd455015a6dbc581d4b624711183b60f736b45a7729cdb4c6277f +size 125781 diff --git a/resources/loading.png b/resources/loading.png index 76fa26a..a31d7fa 100644 --- a/resources/loading.png +++ b/resources/loading.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cb69fc16814ff0db507965e95df225f1316917b802998e8517242b8ef534e3ea -size 5861 +oid sha256:f5c05b59ffb6170102aef205bafaf95fa88abb76ec549722d408600154c2b4f0 +size 13592 diff --git a/resources/main_menu/about.png b/resources/main_menu/about.png new file mode 100644 index 0000000..da06378 --- /dev/null +++ b/resources/main_menu/about.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:97ce17108ceabc0c0c8f8853f910322d98ee21a3d85dff44409ccc00c370ebf2 +size 1027 diff --git a/resources/main_menu/about_hover.png b/resources/main_menu/about_hover.png new file mode 100644 index 0000000..dac27c9 --- /dev/null +++ b/resources/main_menu/about_hover.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0675bd5e392e2635cb896215e023a9785e765507449b716273c826e17edeff73 +size 17670 diff --git a/resources/main_menu/about_pressed.png b/resources/main_menu/about_pressed.png new file mode 100644 index 0000000..714d290 --- /dev/null +++ b/resources/main_menu/about_pressed.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2a395d9bada999ce26f7379543c708e0bbe7b56c3fc7989deac8675c669d1b28 +size 1003 diff --git a/resources/main_menu/title.png b/resources/main_menu/title.png index 70058a0..c20c4d7 100644 --- a/resources/main_menu/title.png +++ b/resources/main_menu/title.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3cfd73ee7e067e0298f461ea0a01f1e2fc4b093cf2d22c665654f030867463b7 -size 7191 +oid sha256:32a5288d6024ea21d8b9e53608ec182516e30845de638457a23498649cda9832 +size 12534 diff --git a/resources/select_your_ship.png b/resources/select_your_ship.png new file mode 100644 index 0000000..14f21d6 --- /dev/null +++ b/resources/select_your_ship.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c962f6f711cb6b4b243c3c62334282b7565ca643bca99f0efd7049ef6e012217 +size 17024 diff --git a/src/Game.cpp b/src/Game.cpp index 6936e59..b58236e 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -110,7 +110,20 @@ namespace ZL loadingTexture = std::make_unique(CreateTextureDataFromPng("resources/loading.png", CONST_ZIP_FILE)); #endif - loadingMesh.data = CreateRect2D({ 0.5f, 0.5f }, { 0.5f, 0.5f }, 3); + float minDimension; + float width = Environment::projectionWidth; + float height = Environment::projectionHeight; + + if (width >= height) + { + minDimension = height; + } + else + { + minDimension = width; + } + + loadingMesh.data = CreateRect2D({ 0.0f, 0.0f }, { minDimension*0.5f, minDimension*0.5f }, 3); loadingMesh.RefreshVBO(); #ifdef EMSCRIPTEN @@ -268,12 +281,12 @@ namespace ZL renderer.shaderManager.PushShader(defaultShaderName); renderer.RenderUniform1i(textureUniformName, 0); - //float width = Environment::projectionWidth; - //float height = Environment::projectionHeight; + float width = Environment::projectionWidth; + float height = Environment::projectionHeight; renderer.PushProjectionMatrix( - 0, 1, - 0, 1, + -width * 0.5f, width*0.5f, + -height * 0.5f, height * 0.5f, -10, 10); renderer.PushMatrix(); @@ -335,7 +348,7 @@ namespace ZL //SDL_GL_MakeCurrent(ZL::Environment::window, glContext); ZL::CheckGlError(); - glClearColor(0.0f, 0.0f, 1.0f, 1.0f); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //processTickCount(); @@ -452,24 +465,6 @@ namespace ZL } if (event.type == SDL_KEYUP) { - if (event.key.keysym.sym == SDLK_a) { - x = x + 0.2f; - } - if (event.key.keysym.sym == SDLK_q) { - x = x - 0.2f; - } - if (event.key.keysym.sym == SDLK_s) { - y = y + 0.2f; - } - if (event.key.keysym.sym == SDLK_w) { - y = y - 0.2f; - } - if (event.key.keysym.sym == SDLK_d) { - z = z + 0.2f; - } - if (event.key.keysym.sym == SDLK_e) { - z = z - 0.2f; - } if (event.key.keysym.sym == SDLK_r) { std::cout << "Camera position: x=" << x << " y=" << y << " z=" << z << std::endl; } diff --git a/src/MenuManager.cpp b/src/MenuManager.cpp index e862e49..6b8c2f4 100644 --- a/src/MenuManager.cpp +++ b/src/MenuManager.cpp @@ -135,13 +135,16 @@ namespace ZL { state = GameState::Gameplay; uiManager.replaceRoot(gameplayRoot); + uiManager.findButton("minusButton")->state = ButtonState::Disabled; + + auto velocityTv = uiManager.findTextView("velocityText"); if (velocityTv) { velocityTv->rect.x = 10.0f; velocityTv->rect.y = static_cast(Environment::height) - velocityTv->rect.h - 10.0f; } - uiManager.startAnimationOnNode("backgroundNode", "bgScroll"); + //uiManager.startAnimationOnNode("backgroundNode", "bgScroll"); uiManager.setButtonPressCallback("shootButton", [this](const std::string&) { if (onFirePressed) onFirePressed(); @@ -152,11 +155,29 @@ namespace ZL { uiManager.setButtonPressCallback("plusButton", [this](const std::string&) { int newVel = Environment::shipState.selectedVelocity + 1; if (newVel > 4) newVel = 4; + uiManager.findButton("minusButton")->state = ButtonState::Normal; + if (newVel == 4) + { + uiManager.findButton("plusButton")->state = ButtonState::Disabled; + } + else + { + uiManager.findButton("plusButton")->state = ButtonState::Normal; + } if (onVelocityChanged) onVelocityChanged(newVel); }); uiManager.setButtonPressCallback("minusButton", [this](const std::string&) { int newVel = Environment::shipState.selectedVelocity - 1; if (newVel < 0) newVel = 0; + uiManager.findButton("plusButton")->state = ButtonState::Normal; + if (newVel == 0) + { + uiManager.findButton("minusButton")->state = ButtonState::Disabled; + } + else + { + uiManager.findButton("minusButton")->state = ButtonState::Normal; + } if (onVelocityChanged) onVelocityChanged(newVel); }); uiManager.setSliderCallback("velocitySlider", [this](const std::string&, float value) { diff --git a/src/Space.cpp b/src/Space.cpp index c7cfc3d..3869c84 100644 --- a/src/Space.cpp +++ b/src/Space.cpp @@ -264,11 +264,17 @@ namespace ZL explosionEmitter.setEmissionPoints(std::vector()); Environment::shipState.position = Vector3f{ 0, 0, 45000.f }; Environment::shipState.velocity = 0.0f; + Environment::shipState.selectedVelocity = 0; Environment::shipState.rotation = Eigen::Matrix3f::Identity(); Environment::inverseShipMatrix = Eigen::Matrix3f::Identity(); Environment::zoom = DEFAULT_ZOOM; Environment::tapDownHold = false; playerScore = 0; + if (menuManager.uiManager.findButton("minusButton")) + { + menuManager.uiManager.findButton("minusButton")->state = ButtonState::Disabled; + } + } void Space::setup() { @@ -1669,6 +1675,7 @@ namespace ZL shipAlive = false; gameOver = true; + Environment::shipState.selectedVelocity = 0; Environment::shipState.velocity = 0.0f; showExplosion = true;