Fixing ui bugs
This commit is contained in:
parent
3e8dba36a4
commit
a8ded217df
@ -8,7 +8,7 @@
|
|||||||
body, html {
|
body, html {
|
||||||
margin: 0; padding: 0; width: 100%; height: 100%;
|
margin: 0; padding: 0; width: 100%; height: 100%;
|
||||||
overflow: hidden; background-color: #000;
|
overflow: hidden; background-color: #000;
|
||||||
position: fixed; /* Предотвращает pull-to-refresh на Android */
|
position: fixed;
|
||||||
}
|
}
|
||||||
#canvas {
|
#canvas {
|
||||||
display: block;
|
display: block;
|
||||||
@ -17,10 +17,23 @@
|
|||||||
width: 100vw; height: 100vh;
|
width: 100vw; height: 100vh;
|
||||||
border: none;
|
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%); }
|
#status { color: white; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<button id="fs-button">Fullscreen</button>
|
||||||
<div id="status">Downloading...</div>
|
<div id="status">Downloading...</div>
|
||||||
<canvas id="canvas" oncontextmenu="event.preventDefault()" tabindex="-1"></canvas>
|
<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() {
|
window.addEventListener("orientationchange", function() {
|
||||||
// Chrome на Android обновляет innerWidth/Height не мгновенно.
|
|
||||||
// Ждем завершения анимации поворота.
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// В Emscripten это вызовет ваш onWindowResized в C++
|
|
||||||
window.dispatchEvent(new Event('resize'));
|
window.dispatchEvent(new Event('resize'));
|
||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -8,16 +8,21 @@
|
|||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"type": "TextView",
|
"type": "TextView",
|
||||||
"name": "velocityText",
|
"name": "gameScoreText",
|
||||||
"x": 10,
|
"x": 0,
|
||||||
"y": 10,
|
"y": 30,
|
||||||
"width": 200,
|
"width": 80,
|
||||||
"height": 40,
|
"height": 40,
|
||||||
"horizontal_gravity": "left",
|
"horizontal_gravity": "left",
|
||||||
"vertical_gravity": "top",
|
"vertical_gravity": "top",
|
||||||
"text": "Velocity: 0",
|
"text": "Score: 0",
|
||||||
"fontSize": 24,
|
"fontSize": 36,
|
||||||
"color": [1.0, 1.0, 1.0, 1.0],
|
"color": [
|
||||||
|
0,
|
||||||
|
217,
|
||||||
|
255,
|
||||||
|
1
|
||||||
|
],
|
||||||
"centered": false
|
"centered": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -139,11 +139,12 @@ namespace ZL {
|
|||||||
if (auto btn = uiManager.findButton("takeButton")) btn->state = ButtonState::Disabled;
|
if (auto btn = uiManager.findButton("takeButton")) btn->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.setButtonPressCallback("shootButton", [this](const std::string&) {
|
uiManager.setButtonPressCallback("shootButton", [this](const std::string&) {
|
||||||
if (onFirePressed) onFirePressed();
|
if (onFirePressed) onFirePressed();
|
||||||
|
|||||||
@ -349,6 +349,7 @@ namespace ZL
|
|||||||
}
|
}
|
||||||
if (bestIdx >= 0) {
|
if (bestIdx >= 0) {
|
||||||
networkClient->Send("BOX_PICKUP:" + std::to_string(bestIdx));
|
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() {
|
void Space::fireProjectiles() {
|
||||||
@ -1845,6 +1851,7 @@ namespace ZL
|
|||||||
Vector3f{ 1.5f, 0.9f - 6.f, 5.0f }
|
Vector3f{ 1.5f, 0.9f - 6.f, 5.0f }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const float projectileSpeed = PROJECTILE_VELOCITY;
|
const float projectileSpeed = PROJECTILE_VELOCITY;
|
||||||
const float lifeMs = PROJECTILE_LIFE;
|
const float lifeMs = PROJECTILE_LIFE;
|
||||||
const float size = 0.5f;
|
const float size = 0.5f;
|
||||||
|
|||||||
@ -126,6 +126,7 @@ namespace ZL {
|
|||||||
|
|
||||||
std::unordered_set<int> deadRemotePlayers;
|
std::unordered_set<int> deadRemotePlayers;
|
||||||
int playerScore = 0;
|
int playerScore = 0;
|
||||||
|
int prevPlayerScore = 0;
|
||||||
bool wasConnectedToServer = false;
|
bool wasConnectedToServer = false;
|
||||||
|
|
||||||
static constexpr float TARGET_MAX_DIST = 50000.0f;
|
static constexpr float TARGET_MAX_DIST = 50000.0f;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user