Skip to content

Commit

Permalink
Optional GL animation usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neloreck committed Jan 12, 2025
1 parent f5bbb31 commit dbc6921
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
19 changes: 15 additions & 4 deletions src/xrGame/HudItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,13 @@ bool CHudItem::TryPlayAnimIdle()
return false;
}

//AVO: check if animation exists
bool CHudItem::isHUDAnimationExist(pcstr anim_name) const
{
return isHUDAnimationExist(anim_name, false);
}

//AVO: check if animation exists
bool CHudItem::isHUDAnimationExist(pcstr anim_name, bool is_silent) const
{
if (const auto* data = HudItemData()) // First person
{
Expand All @@ -399,16 +404,22 @@ bool CHudItem::isHUDAnimationExist(pcstr anim_name) const
else
return false; // No hud section, no warning
#ifdef DEBUG
Msg("~ [WARNING] ------ Animation [%s] does not exist in [%s]", anim_name, HudSection().c_str());
if (!is_silent)
Msg("~ [WARNING] ------ Animation [%s] does not exist in [%s]", anim_name, HudSection().c_str());
#endif
return false;
}

pcstr CHudItem::WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2) const
{
if (isHUDAnimationExist(anim_name))
return WhichHUDAnimationExist(anim_name, anim_name2, false);
}

pcstr CHudItem::WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2, bool is_silent) const
{
if (isHUDAnimationExist(anim_name, is_silent))
return anim_name;
if (isHUDAnimationExist(anim_name2))
if (isHUDAnimationExist(anim_name2, is_silent))
return anim_name2;
return nullptr;
}
Expand Down
2 changes: 2 additions & 0 deletions src/xrGame/HudItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,7 @@ class CHudItem : public CHUDState
virtual CHudItem* cast_hud_item() { return this; }
void PlayAnimIdleMovingCrouch(); //AVO: new crouch idle animation
bool isHUDAnimationExist(pcstr anim_name) const;
bool isHUDAnimationExist(pcstr anim_name, bool is_silent) const;
pcstr WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2) const;
pcstr WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2, bool is_silent) const;
};
10 changes: 7 additions & 3 deletions src/xrGame/WeaponMagazinedWGrenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,10 +736,14 @@ void CWeaponMagazinedWGrenade::PlayAnimShoot()

void CWeaponMagazinedWGrenade::PlayAnimModeSwitch()
{
if (m_bGrenadeMode)
PlayHUDMotion("anm_switch_g", "anim_switch_grenade_on", /*FALSE*/ TRUE, this, eSwitch); //AVO: fix fast anim switch
// Respect SOC/CS/COP animations naming with two possible animation assignments and do not spam in logs on checks.
// Possible place to inject anm_switch_g_empty / anm_switch_empty logics later with CoC/anomaly-like implementation.
cpcstr animation = m_bGrenadeMode ? WhichHUDAnimationExist("anm_switch_g", "anim_switch_grenade_on", true) : WhichHUDAnimationExist("anm_switch", "anim_switch_grenade_off", true);

if (animation)
PlayHUDMotion(animation, TRUE, this, eSwitch);
else
PlayHUDMotion("anm_switch", "anim_switch_grenade_off", /*FALSE*/ TRUE, this, eSwitch); //AVO: fix fast anim switch
SwitchState(eSwitch);
}

void CWeaponMagazinedWGrenade::PlayAnimBore()
Expand Down

0 comments on commit dbc6921

Please sign in to comment.