diff --git a/src/xrEngine/editor_base.h b/src/xrEngine/editor_base.h index 71197b13920..b8e440b29a3 100644 --- a/src/xrEngine/editor_base.h +++ b/src/xrEngine/editor_base.h @@ -20,6 +20,9 @@ class XR_NOVTABLE ENGINE_API ide_tool : public pureFrame virtual pcstr tool_name() = 0; bool& get_open_state() { return is_opened; } + bool is_open() const { return is_opened; } + virtual bool is_active() const { return is_opened; } + ImGuiWindowFlags get_default_window_flags() const; }; diff --git a/src/xrGame/ActorInput.cpp b/src/xrGame/ActorInput.cpp index 430c7193f0f..00d145fb955 100644 --- a/src/xrGame/ActorInput.cpp +++ b/src/xrGame/ActorInput.cpp @@ -36,7 +36,7 @@ bool g_bAutoClearCrouch = true; void CActor::IR_OnKeyboardPress(int cmd) { - if (GamePersistent().GetHudTuner().get_open_state() && Device.editor().IsActiveState()) + if (GamePersistent().GetHudTuner().is_active()) return; if (Remote()) @@ -212,7 +212,7 @@ void CActor::IR_OnKeyboardPress(int cmd) void CActor::IR_OnMouseWheel(float x, float y) { - if (GamePersistent().GetHudTuner().get_open_state() && Device.editor().IsActiveState()) + if (GamePersistent().GetHudTuner().is_active()) return; if (inventory().Action((y > 0) ? (u16)kWPN_ZOOM_INC : (u16)kWPN_ZOOM_DEC, CMD_START)) @@ -226,7 +226,7 @@ void CActor::IR_OnMouseWheel(float x, float y) void CActor::IR_OnKeyboardRelease(int cmd) { - if (GamePersistent().GetHudTuner().get_open_state() && Device.editor().IsActiveState()) + if (GamePersistent().GetHudTuner().is_active()) return; if (Remote()) @@ -268,7 +268,7 @@ void CActor::IR_OnKeyboardRelease(int cmd) void CActor::IR_OnKeyboardHold(int cmd) { - if (GamePersistent().GetHudTuner().get_open_state() && Device.editor().IsActiveState()) + if (GamePersistent().GetHudTuner().is_active()) return; if (Remote() || !g_Alive()) @@ -348,7 +348,7 @@ void CActor::OnAxisMove(float x, float y, float scale, bool invert) void CActor::IR_OnMouseMove(int dx, int dy) { - if (GamePersistent().GetHudTuner().get_open_state() && Device.editor().IsActiveState()) + if (GamePersistent().GetHudTuner().is_active()) return; PIItem iitem = inventory().ActiveItem(); diff --git a/src/xrGame/Missile.cpp b/src/xrGame/Missile.cpp index 4dc7c6e1b64..a86f382bd1c 100644 --- a/src/xrGame/Missile.cpp +++ b/src/xrGame/Missile.cpp @@ -198,7 +198,7 @@ void CMissile::UpdateCL() CActor* pActor = smart_cast(H_Parent()); if (pActor && !pActor->AnyMove() && this == pActor->inventory().ActiveItem()) { - if (!((GamePersistent().GetHudTuner().get_open_state() && Device.editor().IsActiveState())) && GetState() == eIdle && (Device.dwTimeGlobal - m_dw_curr_substate_time > 20000)) + if (!GamePersistent().GetHudTuner().is_active() && GetState() == eIdle && (Device.dwTimeGlobal - m_dw_curr_substate_time > 20000)) { SwitchState(eBore); ResetSubStateTime(); diff --git a/src/xrGame/Weapon.cpp b/src/xrGame/Weapon.cpp index 2ab8785b9bf..c556cb13eba 100644 --- a/src/xrGame/Weapon.cpp +++ b/src/xrGame/Weapon.cpp @@ -878,7 +878,7 @@ void CWeapon::UpdateCL() CActor* pActor = smart_cast(H_Parent()); if (pActor && !pActor->AnyMove() && this == pActor->inventory().ActiveItem()) { - if (!((GamePersistent().GetHudTuner().get_open_state() && Device.editor().IsActiveState())) && GetState() == eIdle && (Device.dwTimeGlobal - m_dw_curr_substate_time > 20000) && + if (!GamePersistent().GetHudTuner().is_active() && GetState() == eIdle && (Device.dwTimeGlobal - m_dw_curr_substate_time > 20000) && !IsZoomed() && g_player_hud->attached_item(1) == nullptr) { if (AllowBore()) @@ -1297,7 +1297,7 @@ bool CWeapon::SilencerAttachable() { return (ALife::eAddonAttachable == m_eSilen void CWeapon::UpdateHUDAddonsVisibility() { - if (GamePersistent().GetHudTuner().get_open_state() && Device.editor().IsActiveState()) + if (GamePersistent().GetHudTuner().is_active()) return; static shared_str wpn_scope = WPN_SCOPE; static shared_str wpn_silencer = WPN_SILENCER; @@ -1346,7 +1346,7 @@ void CWeapon::UpdateHUDAddonsVisibility() void CWeapon::UpdateAddonsVisibility() { - if (GamePersistent().GetHudTuner().get_open_state() && Device.editor().IsActiveState()) + if (GamePersistent().GetHudTuner().is_active()) return; static shared_str wpn_scope = WPN_SCOPE; diff --git a/src/xrGame/player_hud.cpp b/src/xrGame/player_hud.cpp index 3be6a945d67..9489b2cdec1 100644 --- a/src/xrGame/player_hud.cpp +++ b/src/xrGame/player_hud.cpp @@ -131,7 +131,7 @@ void attachable_hud_item::update(bool bForce) reload_measures(); } - if (GamePersistent().GetHudTuner().get_open_state() && Device.editor().IsActiveState()) + if (GamePersistent().GetHudTuner().is_active()) m_measures.update(m_attach_offset); m_parent->calc_transform(m_attach_place_idx, m_attach_offset, m_item_transform); diff --git a/src/xrGame/player_hud_tune.cpp b/src/xrGame/player_hud_tune.cpp index c687183020d..528b568df9c 100644 --- a/src/xrGame/player_hud_tune.cpp +++ b/src/xrGame/player_hud_tune.cpp @@ -21,6 +21,11 @@ CHudTuner::CHudTuner() paused = fsimilar(Device.time_factor(), EPS); } +bool CHudTuner::is_active() const +{ + return is_open() && Device.editor().IsActiveState(); +} + void CHudTuner::ResetToDefaultValues() { if (current_hud_item) diff --git a/src/xrGame/player_hud_tune.h b/src/xrGame/player_hud_tune.h index 3e35e80b5b5..dd92087dc5c 100644 --- a/src/xrGame/player_hud_tune.h +++ b/src/xrGame/player_hud_tune.h @@ -7,8 +7,7 @@ class CHudTuner final : public xray::editor::ide_tool public: CHudTuner(); void OnFrame() override; - - void OnAppDeactivate(); + bool is_active() const override; private: pcstr tool_name() override { return "Hud Tuner"; }