Some UI changes

This commit is contained in:
Vladislav Khorev 2026-03-09 13:50:59 +03:00
parent 24aa7007bb
commit 86a9f38c3b
15 changed files with 86 additions and 40 deletions

BIN
resources/button_minus_disabled.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
resources/button_plus_disabled.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -13,7 +13,7 @@
{ {
"type": "StaticImage", "type": "StaticImage",
"name": "titleBtn", "name": "titleBtn",
"width": 254, "width": 434,
"height": 35, "height": 35,
"texture": "resources/main_menu/title.png" "texture": "resources/main_menu/title.png"
}, },
@ -25,15 +25,11 @@
"texture": "resources/main_menu/line.png" "texture": "resources/main_menu/line.png"
}, },
{ {
"type": "Button", "type": "StaticImage",
"name": "subtitleBtn", "name": "subtitleBtn",
"width": 144, "width": 144,
"height": 11, "height": 11,
"textures": { "texture": "resources/main_menu/subtitle.png"
"normal": "resources/main_menu/subtitle.png",
"hover": "resources/main_menu/subtitle.png",
"pressed": "resources/main_menu/subtitle.png"
}
}, },
{ {
"type": "Button", "type": "Button",

View File

@ -10,6 +10,13 @@
"width": "match_parent", "width": "match_parent",
"height": "match_parent", "height": "match_parent",
"children": [ "children": [
{
"type": "StaticImage",
"name": "titleBtn",
"width": 266,
"height": 66,
"texture": "resources/select_your_ship.png"
},
{ {
"type": "LinearLayout", "type": "LinearLayout",
"orientation": "horizontal", "orientation": "horizontal",

View File

@ -65,7 +65,8 @@
"textures": { "textures": {
"normal": "resources/button_minus.png", "normal": "resources/button_minus.png",
"hover": "resources/button_minus_pressed.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": { "textures": {
"normal": "resources/button_plus.png", "normal": "resources/button_plus.png",
"hover": "resources/button_plus_pressed.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"
} }
} }
] ]

BIN
resources/connection_failed.png (Stored with Git LFS)

Binary file not shown.

BIN
resources/loading.png (Stored with Git LFS)

Binary file not shown.

BIN
resources/main_menu/about.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
resources/main_menu/about_hover.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
resources/main_menu/about_pressed.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
resources/main_menu/title.png (Stored with Git LFS)

Binary file not shown.

BIN
resources/select_your_ship.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -110,7 +110,20 @@ namespace ZL
loadingTexture = std::make_unique<Texture>(CreateTextureDataFromPng("resources/loading.png", CONST_ZIP_FILE)); loadingTexture = std::make_unique<Texture>(CreateTextureDataFromPng("resources/loading.png", CONST_ZIP_FILE));
#endif #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(); loadingMesh.RefreshVBO();
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
@ -268,12 +281,12 @@ namespace ZL
renderer.shaderManager.PushShader(defaultShaderName); renderer.shaderManager.PushShader(defaultShaderName);
renderer.RenderUniform1i(textureUniformName, 0); renderer.RenderUniform1i(textureUniformName, 0);
//float width = Environment::projectionWidth; float width = Environment::projectionWidth;
//float height = Environment::projectionHeight; float height = Environment::projectionHeight;
renderer.PushProjectionMatrix( renderer.PushProjectionMatrix(
0, 1, -width * 0.5f, width*0.5f,
0, 1, -height * 0.5f, height * 0.5f,
-10, 10); -10, 10);
renderer.PushMatrix(); renderer.PushMatrix();
@ -335,7 +348,7 @@ namespace ZL
//SDL_GL_MakeCurrent(ZL::Environment::window, glContext); //SDL_GL_MakeCurrent(ZL::Environment::window, glContext);
ZL::CheckGlError(); 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); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//processTickCount(); //processTickCount();
@ -452,24 +465,6 @@ namespace ZL
} }
if (event.type == SDL_KEYUP) { 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) { if (event.key.keysym.sym == SDLK_r) {
std::cout << "Camera position: x=" << x << " y=" << y << " z=" << z << std::endl; std::cout << "Camera position: x=" << x << " y=" << y << " z=" << z << std::endl;
} }

View File

@ -135,13 +135,16 @@ namespace ZL {
state = GameState::Gameplay; state = GameState::Gameplay;
uiManager.replaceRoot(gameplayRoot); uiManager.replaceRoot(gameplayRoot);
uiManager.findButton("minusButton")->state = ButtonState::Disabled;
auto velocityTv = uiManager.findTextView("velocityText"); auto velocityTv = uiManager.findTextView("velocityText");
if (velocityTv) { if (velocityTv) {
velocityTv->rect.x = 10.0f; velocityTv->rect.x = 10.0f;
velocityTv->rect.y = static_cast<float>(Environment::height) - velocityTv->rect.h - 10.0f; velocityTv->rect.y = static_cast<float>(Environment::height) - velocityTv->rect.h - 10.0f;
} }
uiManager.startAnimationOnNode("backgroundNode", "bgScroll"); //uiManager.startAnimationOnNode("backgroundNode", "bgScroll");
uiManager.setButtonPressCallback("shootButton", [this](const std::string&) { uiManager.setButtonPressCallback("shootButton", [this](const std::string&) {
if (onFirePressed) onFirePressed(); if (onFirePressed) onFirePressed();
@ -152,11 +155,29 @@ namespace ZL {
uiManager.setButtonPressCallback("plusButton", [this](const std::string&) { uiManager.setButtonPressCallback("plusButton", [this](const std::string&) {
int newVel = Environment::shipState.selectedVelocity + 1; int newVel = Environment::shipState.selectedVelocity + 1;
if (newVel > 4) newVel = 4; 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); if (onVelocityChanged) onVelocityChanged(newVel);
}); });
uiManager.setButtonPressCallback("minusButton", [this](const std::string&) { uiManager.setButtonPressCallback("minusButton", [this](const std::string&) {
int newVel = Environment::shipState.selectedVelocity - 1; int newVel = Environment::shipState.selectedVelocity - 1;
if (newVel < 0) newVel = 0; 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); if (onVelocityChanged) onVelocityChanged(newVel);
}); });
uiManager.setSliderCallback("velocitySlider", [this](const std::string&, float value) { uiManager.setSliderCallback("velocitySlider", [this](const std::string&, float value) {

View File

@ -264,11 +264,17 @@ namespace ZL
explosionEmitter.setEmissionPoints(std::vector<Vector3f>()); explosionEmitter.setEmissionPoints(std::vector<Vector3f>());
Environment::shipState.position = Vector3f{ 0, 0, 45000.f }; Environment::shipState.position = Vector3f{ 0, 0, 45000.f };
Environment::shipState.velocity = 0.0f; Environment::shipState.velocity = 0.0f;
Environment::shipState.selectedVelocity = 0;
Environment::shipState.rotation = Eigen::Matrix3f::Identity(); Environment::shipState.rotation = Eigen::Matrix3f::Identity();
Environment::inverseShipMatrix = Eigen::Matrix3f::Identity(); Environment::inverseShipMatrix = Eigen::Matrix3f::Identity();
Environment::zoom = DEFAULT_ZOOM; Environment::zoom = DEFAULT_ZOOM;
Environment::tapDownHold = false; Environment::tapDownHold = false;
playerScore = 0; playerScore = 0;
if (menuManager.uiManager.findButton("minusButton"))
{
menuManager.uiManager.findButton("minusButton")->state = ButtonState::Disabled;
}
} }
void Space::setup() { void Space::setup() {
@ -1669,6 +1675,7 @@ namespace ZL
shipAlive = false; shipAlive = false;
gameOver = true; gameOver = true;
Environment::shipState.selectedVelocity = 0;
Environment::shipState.velocity = 0.0f; Environment::shipState.velocity = 0.0f;
showExplosion = true; showExplosion = true;