feat(hud): Add force show HUD component and replaced some hard-coded values. (#628)
This commit is contained in:
parent
2364bc5688
commit
cab25b12f7
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
@ -184,6 +184,8 @@ namespace big
|
||||
bool hide_ammo = false;
|
||||
int selected_hud_component = 1;
|
||||
bool hud_components_states[(int)HudComponents::HUD_WEAPONS] = { false };
|
||||
bool force_show_hud_element = false;
|
||||
bool force_show_hud = false;
|
||||
bool mobile_radio = false;
|
||||
};
|
||||
|
||||
@ -640,6 +642,8 @@ namespace big
|
||||
this->self.selected_hud_component = j["self"]["selected_hud_component"];
|
||||
for (int i = 0; i < (int)HudComponents::HUD_WEAPONS; i++)
|
||||
this->self.hud_components_states[i] = j["self"]["hud_components_states"].at(i);
|
||||
this->self.force_show_hud_element = j["self"]["force_show_hud_element"];
|
||||
this->self.force_show_hud = j["self"]["force_show_hud"];
|
||||
this->self.unlimited_oxygen = j["self"]["unlimited_oxygen"];
|
||||
this->self.no_water_collision = j["self"]["no_water_collision"];
|
||||
this->self.mobile_radio = j["self"]["mobile_radio"];
|
||||
@ -979,6 +983,8 @@ namespace big
|
||||
this->self.hud_components_states[20],
|
||||
this->self.hud_components_states[21] })
|
||||
},
|
||||
{ "force_show_hud_element", this->self.force_show_hud_element },
|
||||
{ "force_show_hud", this->self.force_show_hud },
|
||||
{ "unlimited_oxygen", this->self.unlimited_oxygen },
|
||||
{ "no_water_collision", this->self.no_water_collision },
|
||||
{ "mobile_radio", this->self.mobile_radio },
|
||||
|
@ -313,7 +313,7 @@ namespace big
|
||||
|
||||
if (g_context_menu_service->enabled)
|
||||
{
|
||||
HUD::SHOW_HUD_COMPONENT_THIS_FRAME(14 /*RETICLE*/);
|
||||
HUD::SHOW_HUD_COMPONENT_THIS_FRAME(static_cast<int>(HudComponents::RETICLE));
|
||||
|
||||
g_context_menu_service->get_entity_closest_to_screen_center();
|
||||
|
||||
|
@ -75,11 +75,8 @@ namespace big
|
||||
if (g->self.invisibility) {
|
||||
ImGui::Checkbox("Locally Visible", &g->self.local_visibility);
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Keep Player Clean", &g->self.clean_player);
|
||||
|
||||
ImGui::Checkbox("No Collision", &g->self.no_collision);
|
||||
|
||||
ImGui::Checkbox("Mobile Radio", &g->self.mobile_radio);
|
||||
|
||||
ImGui::EndGroup();
|
||||
@ -173,6 +170,10 @@ namespace big
|
||||
|
||||
ImGui::Checkbox("Hide Ammo", &g->self.hide_ammo);
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::Checkbox("Force show HUD", &g->self.force_show_hud);
|
||||
|
||||
ImGui::Combo("##hud_comp_combo", &g->self.selected_hud_component, hud_component_names, (int)HudComponents::HUD_WEAPONS);
|
||||
ImGui::SameLine();
|
||||
components::button("Hide", [] {
|
||||
@ -200,6 +201,10 @@ namespace big
|
||||
g->self.hud_components_states[i] = false;
|
||||
}
|
||||
});
|
||||
ImGui::SameLine();
|
||||
ImGui::Checkbox("Force show HUD element", &g->self.force_show_hud_element);
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("To force show a HUD specific element, click Hide all then click Show on the desired element.");
|
||||
|
||||
ImGui::EndGroup();
|
||||
|
||||
|
Reference in New Issue
Block a user