Fixing ui bugs
This commit is contained in:
parent
3e8dba36a4
commit
a8ded217df
@ -8,7 +8,7 @@
|
||||
body, html {
|
||||
margin: 0; padding: 0; width: 100%; height: 100%;
|
||||
overflow: hidden; background-color: #000;
|
||||
position: fixed; /* Предотвращает pull-to-refresh на Android */
|
||||
position: fixed;
|
||||
}
|
||||
#canvas {
|
||||
display: block;
|
||||
@ -17,10 +17,23 @@
|
||||
width: 100vw; height: 100vh;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#fs-button {
|
||||
position: absolute;
|
||||
top: 10px; right: 10px;
|
||||
padding: 10px;
|
||||
z-index: 10;
|
||||
background: rgba(255,255,255,0.3);
|
||||
color: white; border: 1px solid white;
|
||||
cursor: pointer;
|
||||
font-family: sans-serif;
|
||||
border-radius: 5px;
|
||||
}
|
||||
#status { color: white; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<button id="fs-button">Fullscreen</button>
|
||||
<div id="status">Downloading...</div>
|
||||
<canvas id="canvas" oncontextmenu="event.preventDefault()" tabindex="-1"></canvas>
|
||||
|
||||
@ -36,12 +49,18 @@
|
||||
}
|
||||
};
|
||||
|
||||
// Обработка ориентации
|
||||
document.getElementById('fs-button').addEventListener('click', function() {
|
||||
if (!document.fullscreenElement) {
|
||||
document.documentElement.requestFullscreen().catch(e => {
|
||||
console.error(`Error attempting to enable full-screen mode: ${e.message}`);
|
||||
});
|
||||
} else {
|
||||
document.exitFullscreen();
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener("orientationchange", function() {
|
||||
// Chrome на Android обновляет innerWidth/Height не мгновенно.
|
||||
// Ждем завершения анимации поворота.
|
||||
setTimeout(() => {
|
||||
// В Emscripten это вызовет ваш onWindowResized в C++
|
||||
window.dispatchEvent(new Event('resize'));
|
||||
}, 200);
|
||||
});
|
||||
|
||||
@ -8,16 +8,21 @@
|
||||
"children": [
|
||||
{
|
||||
"type": "TextView",
|
||||
"name": "velocityText",
|
||||
"x": 10,
|
||||
"y": 10,
|
||||
"width": 200,
|
||||
"name": "gameScoreText",
|
||||
"x": 0,
|
||||
"y": 30,
|
||||
"width": 80,
|
||||
"height": 40,
|
||||
"horizontal_gravity": "left",
|
||||
"vertical_gravity": "top",
|
||||
"text": "Velocity: 0",
|
||||
"fontSize": 24,
|
||||
"color": [1.0, 1.0, 1.0, 1.0],
|
||||
"text": "Score: 0",
|
||||
"fontSize": 36,
|
||||
"color": [
|
||||
0,
|
||||
217,
|
||||
255,
|
||||
1
|
||||
],
|
||||
"centered": false
|
||||
},
|
||||
{
|
||||
|
||||
@ -139,11 +139,12 @@ namespace ZL {
|
||||
if (auto btn = uiManager.findButton("takeButton")) btn->state = ButtonState::Disabled;
|
||||
|
||||
|
||||
/*
|
||||
auto velocityTv = uiManager.findTextView("velocityText");
|
||||
if (velocityTv) {
|
||||
velocityTv->rect.x = 10.0f;
|
||||
velocityTv->rect.y = static_cast<float>(Environment::height) - velocityTv->rect.h - 10.0f;
|
||||
}
|
||||
}*/
|
||||
|
||||
uiManager.setButtonPressCallback("shootButton", [this](const std::string&) {
|
||||
if (onFirePressed) onFirePressed();
|
||||
|
||||
@ -349,6 +349,7 @@ namespace ZL
|
||||
}
|
||||
if (bestIdx >= 0) {
|
||||
networkClient->Send("BOX_PICKUP:" + std::to_string(bestIdx));
|
||||
this->playerScore += 1;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1837,6 +1838,11 @@ namespace ZL
|
||||
}
|
||||
}
|
||||
|
||||
if (playerScore != prevPlayerScore)
|
||||
{
|
||||
prevPlayerScore = playerScore;
|
||||
menuManager.uiManager.setText("gameScoreText", "Score: " + std::to_string(playerScore));
|
||||
}
|
||||
}
|
||||
|
||||
void Space::fireProjectiles() {
|
||||
@ -1845,6 +1851,7 @@ namespace ZL
|
||||
Vector3f{ 1.5f, 0.9f - 6.f, 5.0f }
|
||||
};
|
||||
|
||||
|
||||
const float projectileSpeed = PROJECTILE_VELOCITY;
|
||||
const float lifeMs = PROJECTILE_LIFE;
|
||||
const float size = 0.5f;
|
||||
|
||||
@ -126,6 +126,7 @@ namespace ZL {
|
||||
|
||||
std::unordered_set<int> deadRemotePlayers;
|
||||
int playerScore = 0;
|
||||
int prevPlayerScore = 0;
|
||||
bool wasConnectedToServer = false;
|
||||
|
||||
static constexpr float TARGET_MAX_DIST = 50000.0f;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user