m_crosshair is not needed and the config should be checked every frame because otherwise Alt-I command was broken (the number of crosshairs to render is mapped to a UI key) [Bart]

This commit is contained in:
CapitaineSheridan 2023-03-13 08:55:58 +01:00 committed by trzy
parent a319bbee0c
commit abc2900770
2 changed files with 11 additions and 12 deletions

View file

@ -45,8 +45,6 @@ bool CCrosshair::Init()
m_isBitmapCrosshair = false; m_isBitmapCrosshair = false;
} }
m_crosshairs = m_config["Crosshairs"].ValueAs<unsigned>();
m_xRes = m_config["XResolution"].ValueAs<unsigned>(); m_xRes = m_config["XResolution"].ValueAs<unsigned>();
m_yRes = m_config["YResolution"].ValueAs<unsigned>(); m_yRes = m_config["YResolution"].ValueAs<unsigned>();
m_a = (float)m_xRes / (float)m_yRes; m_a = (float)m_xRes / (float)m_yRes;
@ -255,8 +253,10 @@ void CCrosshair::Update(uint32_t currentInputs, CInputs* Inputs, unsigned int xO
bool offscreenTrigger[2]{false}; bool offscreenTrigger[2]{false};
float x[2]{ 0.0f }, y[2]{ 0.0f }; float x[2]{ 0.0f }, y[2]{ 0.0f };
m_crosshairs &= 3; // Crosshairs can be enabled/disabled at run-tim
if (!m_crosshairs) unsigned crosshairs = m_config["Crosshairs"].ValueAs<unsigned>();
crosshairs &= 3;
if (!crosshairs)
return; return;
// Set up the viewport and orthogonal projection // Set up the viewport and orthogonal projection
@ -308,11 +308,11 @@ void CCrosshair::Update(uint32_t currentInputs, CInputs* Inputs, unsigned int xO
// Draw visible crosshairs // Draw visible crosshairs
if ((m_crosshairs & 1) && !offscreenTrigger[0]) // Player 1 if ((crosshairs & 1) && !offscreenTrigger[0]) // Player 1
{ {
DrawCrosshair(m, x[0], y[0], 0); DrawCrosshair(m, x[0], y[0], 0);
} }
if ((m_crosshairs & 2) && !offscreenTrigger[1]) // Player 2 if ((crosshairs & 2) && !offscreenTrigger[1]) // Player 2
{ {
DrawCrosshair(m, x[1], y[1], 1); DrawCrosshair(m, x[1], y[1], 1);
} }

View file

@ -33,7 +33,6 @@ private:
bool m_isBitmapCrosshair = false; bool m_isBitmapCrosshair = false;
std::string m_crosshairStyle = ""; std::string m_crosshairStyle = "";
GLuint m_crosshairTexId[2] = { 0 }; GLuint m_crosshairTexId[2] = { 0 };
unsigned int m_crosshairs = 0;
int m_p1CrosshairW = 0, m_p1CrosshairH = 0, m_p2CrosshairW = 0, m_p2CrosshairH = 0; int m_p1CrosshairW = 0, m_p1CrosshairH = 0, m_p2CrosshairW = 0, m_p2CrosshairH = 0;
float m_diagDpi = 0.0f, m_hDpi = 0.0f, m_vDpi = 0.0f; float m_diagDpi = 0.0f, m_hDpi = 0.0f, m_vDpi = 0.0f;
unsigned int m_xRes=0; unsigned int m_xRes=0;