feat(hud): Add force show HUD component and replaced some hard-coded values. (#628)

This commit is contained in:
SpaghettDev
2022-11-26 20:42:58 +01:00
committed by GitHub
parent 89ad2755ac
commit 2db1ce1c48
5 changed files with 44 additions and 17 deletions

View File

@ -1,16 +1,18 @@
#include "backend/looped/looped.hpp"
#include "natives.hpp"
#include "core/data/hud_component_names.hpp"
#include <algorithm>
namespace big
{
static bool bLastHideRadar = false;
static bool bHasHUDBeenHidden = false;
void looped::self_hud()
{
const bool bHideRadar = g->self.hide_radar;
const bool bHideAmmo = g->self.hide_ammo;
const bool bForceShowElement = g->self.force_show_hud_element;
const bool bForceShowHUD = g->self.force_show_hud;
auto& bHudComponents = g->self.hud_components_states;
if (bHideRadar)
@ -28,6 +30,11 @@ namespace big
HUD::DISPLAY_AMMO_THIS_FRAME(false);
}
if (bForceShowHUD) {
HUD::DISPLAY_HUD_WHEN_NOT_IN_STATE_OF_PLAY_THIS_FRAME();
HUD::DISPLAY_HUD_WHEN_PAUSED_THIS_FRAME();
}
if (
std::all_of(
std::begin(bHudComponents),
@ -36,14 +43,22 @@ namespace big
)
) {
HUD::DISPLAY_HUD(false);
bHasHUDBeenHidden = true;
}
else
{
HUD::DISPLAY_HUD(true);
for (int i = 0; i < (int)HudComponents::HUD_WEAPONS; i++)
bHasHUDBeenHidden = false;
}
if (!bHasHUDBeenHidden)
{
for (int i = 0; i < static_cast<int>(HudComponents::HUD_WEAPONS); i++)
{
if (bHudComponents[i])
HUD::HIDE_HUD_COMPONENT_THIS_FRAME(i + 1);
else if (!bHudComponents[i] && bForceShowElement)
HUD::SHOW_HUD_COMPONENT_THIS_FRAME(i + 1);
}
}
}

View File

@ -1,12 +1,13 @@
#include "backend/looped/looped.hpp"
#include "natives.hpp"
#include "core/enums.hpp"
namespace big
{
void looped::weapons_force_crosshairs()
{
if (g->weapons.force_crosshairs) {
HUD::SHOW_HUD_COMPONENT_THIS_FRAME(14 /*RETICLE*/);
HUD::SHOW_HUD_COMPONENT_THIS_FRAME(static_cast<int>(HudComponents::RETICLE));
}
}
}