Skip to content

Commit

Permalink
* UPD: [xrGame] add is_open, is_active functions to ide_tool + refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
yohjimane committed Jun 2, 2024
1 parent c125a5f commit 108817b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/xrEngine/editor_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
10 changes: 5 additions & 5 deletions src/xrGame/ActorInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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))
Expand All @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Missile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void CMissile::UpdateCL()
CActor* pActor = smart_cast<CActor*>(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();
Expand Down
6 changes: 3 additions & 3 deletions src/xrGame/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ void CWeapon::UpdateCL()
CActor* pActor = smart_cast<CActor*>(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())
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/player_hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/xrGame/player_hud_tune.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions src/xrGame/player_hud_tune.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"; }
Expand Down Expand Up @@ -71,6 +70,4 @@ class CHudTuner final : public xray::editor::ide_tool

hud_item_measures curr_measures{};
hud_item_measures new_measures{};

xr_map<u32, bool> bone_map;
};

0 comments on commit 108817b

Please sign in to comment.