feat: players interpolation & add hud.set_allow_pause(...)
This commit is contained in:
+21
-9
@@ -223,7 +223,8 @@ void Hud::cleanup() {
|
||||
}
|
||||
|
||||
void Hud::processInput(bool visible) {
|
||||
if (!Window::isFocused() && !pause && !isInventoryOpen()) {
|
||||
auto menu = gui.getMenu();
|
||||
if (!Window::isFocused() && !menu->hasOpenPage() && !isInventoryOpen()) {
|
||||
setPause(true);
|
||||
}
|
||||
if (!pause && visible && Events::jactive(BIND_HUD_INVENTORY)) {
|
||||
@@ -318,14 +319,13 @@ void Hud::update(bool visible) {
|
||||
if (!visible && inventoryOpen) {
|
||||
closeInventory();
|
||||
}
|
||||
if (pause && menu->getCurrent().panel == nullptr) {
|
||||
if (pause && !menu->hasOpenPage()) {
|
||||
setPause(false);
|
||||
}
|
||||
|
||||
if (!gui.isFocusCaught()) {
|
||||
processInput(visible);
|
||||
}
|
||||
if ((pause || inventoryOpen) == Events::_cursor_locked) {
|
||||
if ((menu->hasOpenPage() || inventoryOpen) == Events::isCursorLocked()) {
|
||||
Events::toggleCursor();
|
||||
}
|
||||
|
||||
@@ -590,7 +590,9 @@ void Hud::draw(const DrawContext& ctx){
|
||||
const Viewport& viewport = ctx.getViewport();
|
||||
const uint width = viewport.getWidth();
|
||||
const uint height = viewport.getHeight();
|
||||
auto menu = gui.getMenu();
|
||||
|
||||
darkOverlay->setVisible(menu->hasOpenPage());
|
||||
updateElementsPosition(viewport);
|
||||
|
||||
uicamera->setFov(height);
|
||||
@@ -676,19 +678,20 @@ void Hud::setPause(bool pause) {
|
||||
if (this->pause == pause) {
|
||||
return;
|
||||
}
|
||||
this->pause = pause;
|
||||
if (allowPause) {
|
||||
this->pause = pause;
|
||||
}
|
||||
|
||||
if (inventoryOpen) {
|
||||
closeInventory();
|
||||
}
|
||||
|
||||
const auto& menu = gui.getMenu();
|
||||
if (pause) {
|
||||
menu->setPage("pause");
|
||||
} else {
|
||||
if (menu->hasOpenPage()) {
|
||||
menu->reset();
|
||||
} else {
|
||||
menu->setPage("pause");
|
||||
}
|
||||
darkOverlay->setVisible(pause);
|
||||
menu->setVisible(pause);
|
||||
}
|
||||
|
||||
@@ -721,3 +724,12 @@ void Hud::setDebugCheats(bool flag) {
|
||||
debugPanel->setZIndex(2);
|
||||
gui.add(debugPanel);
|
||||
}
|
||||
|
||||
void Hud::setAllowPause(bool flag) {
|
||||
if (pause) {
|
||||
auto menu = gui.getMenu();
|
||||
setPause(false);
|
||||
menu->setPage("pause", true);
|
||||
}
|
||||
allowPause = flag;
|
||||
}
|
||||
|
||||
@@ -113,6 +113,8 @@ class Hud : public util::ObjectsKeeper {
|
||||
bool showContentPanel = true;
|
||||
/// @brief Provide cheat controllers to the debug panel
|
||||
bool allowDebugCheats = true;
|
||||
/// @brief Allow actual pause
|
||||
bool allowPause = true;
|
||||
bool debug = false;
|
||||
/// @brief UI element will be dynamicly positioned near to inventory or in screen center
|
||||
std::shared_ptr<gui::UINode> secondUI;
|
||||
@@ -206,6 +208,8 @@ public:
|
||||
|
||||
void setDebugCheats(bool flag);
|
||||
|
||||
void setAllowPause(bool flag);
|
||||
|
||||
static bool showGeneratorMinimap;
|
||||
|
||||
/// @brief Runtime updating debug visualization texture
|
||||
|
||||
@@ -168,8 +168,9 @@ void LevelScreen::updateHotkeys() {
|
||||
|
||||
void LevelScreen::update(float delta) {
|
||||
gui::GUI* gui = engine.getGUI();
|
||||
auto menu = gui->getMenu();
|
||||
|
||||
bool inputLocked = hud->isPause() ||
|
||||
bool inputLocked = menu->hasOpenPage() ||
|
||||
hud->isInventoryOpen() ||
|
||||
gui->isFocusCaught();
|
||||
if (!gui->isFocusCaught()) {
|
||||
|
||||
Reference in New Issue
Block a user