Major refactoring for game menu

This commit is contained in:
Vladislav Khorev committed 2026-02-22 19:50:13 +03:00
1 parent 5b57696acf
commit b59a10b7e6
8 files changed
+142 -103

No files matched your search

+9 -41
View File
@@ -30,10 +30,6 @@ namespace ZL
extern const char* CONST_ZIP_FILE;
extern bool g_exitBgAnimating;
extern bool firePressed;
extern float x;
Eigen::Quaternionf generateRandomQuaternion(std::mt19937& gen)
@@ -145,7 +141,7 @@ namespace ZL
return P;
}
bool Space::worldToScreen(const Vector3f& world, float& outX, float& outY, float& outDepth) const
bool worldToScreen(const Vector3f& world, float& outX, float& outY, float& outDepth)
{
// Матрицы должны совпасть с drawBoxes/drawShip по смыслу
float aspect = static_cast<float>(Environment::width) / static_cast<float>(Environment::height);
@@ -176,7 +172,7 @@ namespace ZL
return true;
}
bool Space::projectToNDC(const Vector3f& world, float& ndcX, float& ndcY, float& ndcZ, float& clipW) const
bool projectToNDC(const Vector3f& world, float& ndcX, float& ndcY, float& ndcZ, float& clipW)
{
float aspect = static_cast<float>(Environment::width) / static_cast<float>(Environment::height);
Eigen::Matrix4f V = makeViewMatrix_FromYourCamera();
@@ -278,6 +274,10 @@ namespace ZL
newShipVelocity = newVelocity;
};
menuManager.onFirePressed = [this]() {
firePressed = true;
};
bool cfgLoaded = sparkEmitter.loadFromJsonFile("resources/config/spark_config.json", renderer, CONST_ZIP_FILE);
bool projCfgLoaded = projectileEmitter.loadFromJsonFile("resources/config/spark_projectile_config.json", renderer, CONST_ZIP_FILE);
bool explosionCfgLoaded = explosionEmitter.loadFromJsonFile("resources/config/explosion_config.json", renderer, CONST_ZIP_FILE);
@@ -566,7 +566,6 @@ namespace ZL
drawBoxesLabels();
drawShip();
//drawUI();
drawTargetHud();
CheckGlError();
}
@@ -1394,25 +1393,6 @@ namespace ZL
void Space::handleDown(int mx, int my)
{
int uiX = mx;
int uiY = Environment::height - my;
menuManager.uiManager.onMouseDown(uiX, uiY);
bool uiHandled = false;
for (const auto& button : menuManager.uiManager.findButton("") ? std::vector<std::shared_ptr<UiButton>>{} : std::vector<std::shared_ptr<UiButton>>{}) {
(void)button;
}
auto pressedSlider = [&]() -> std::shared_ptr<UiSlider> {
for (const auto& slider : menuManager.uiManager.findSlider("") ? std::vector<std::shared_ptr<UiSlider>>{} : std::vector<std::shared_ptr<UiSlider>>{}) {
(void)slider;
}
return nullptr;
}();
if (!menuManager.uiManager.isUiInteraction()) {
Environment::tapDownHold = true;
Environment::tapDownStartPos(0) = mx;
@@ -1420,29 +1400,17 @@ namespace ZL
Environment::tapDownCurrentPos(0) = mx;
Environment::tapDownCurrentPos(1) = my;
}
}
void Space::handleUp(int mx, int my)
{
int uiX = mx;
int uiY = Environment::height - my;
menuManager.uiManager.onMouseUp(uiX, uiY);
if (!menuManager.uiManager.isUiInteraction()) {
Environment::tapDownHold = false;
}
Environment::tapDownHold = false;
}
void Space::handleMotion(int mx, int my)
{
int uiX = mx;
int uiY = Environment::height - my;
menuManager.uiManager.onMouseMove(uiX, uiY);
if (Environment::tapDownHold && !menuManager.uiManager.isUiInteraction()) {
if (Environment::tapDownHold) {
Environment::tapDownCurrentPos(0) = mx;
Environment::tapDownCurrentPos(1) = my;
}