Skip to content

Commit a293867

Browse files
committed
fix: improve visual handling in ehm hud
1 parent 385e602 commit a293867

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

src/Features/Hud/EHMDebugHud.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "Command.hpp"
77
#include "Event.hpp"
88
#include "Hud.hpp"
9+
#include <Features/Session.hpp>
910

1011
Variable sar_ehm_hud("sar_ehm_hud", "0", "Enables EHM debug HUD.\n");
1112

@@ -24,6 +25,7 @@ Variable sar_ehm_hud_autofill("sar_ehm_hud_autofill", "1", 0, 2,
2425
struct SlotInfoRecord {
2526
int slot;
2627
float lifetime;
28+
float timeSinceSlotChanged;
2729
const char *lastClassname;
2830
bool isActive;
2931
};
@@ -113,6 +115,9 @@ static void handleSlotRecords() {
113115
? server->GetEntityClassName(info->m_pEntity)
114116
: g_slotStates[i].lastClassname;
115117

118+
if (slotChanged) {
119+
record->timeSinceSlotChanged = 0.0f;
120+
}
116121

117122
if (!fresh) {
118123
attemptAutofill(i);
@@ -121,7 +126,10 @@ static void handleSlotRecords() {
121126
continue;
122127
}
123128

124-
g_slotStates[i].lifetime += 1.0f / 60.0f;
129+
if (session->isRunning) {
130+
record->lifetime += 1.0f / 60.0f;
131+
record->timeSinceSlotChanged += 1.0f / 60.0f;
132+
}
125133
}
126134
}
127135

@@ -231,15 +239,14 @@ class EHMDebugHud : public Hud {
231239

232240
int recordPosY = hudY + paddingBorder + paddingY + lineHeight * (i + 1);
233241

234-
float factor = std::fminf(1.0f, slotRecord.lifetime);
242+
float slotTimeFactor = std::fminf(1.0f, slotRecord.timeSinceSlotChanged);
243+
float lifetimeFactor = std::fminf(1.0f, slotRecord.lifetime);
235244

236-
Color serialColor = slotRecord.isActive
237-
? Color(255, 255, 255, 128)
238-
: Color(255, 255, 255 * factor, 255 - 127 * factor);
245+
Color serialColor = Color(255, 255, 255 * slotTimeFactor, 255 - 127 * slotTimeFactor);
239246

240247
Color classnameColor = slotRecord.isActive
241-
? Color(128 + 127 * factor, 255, 255 * factor, 128)
242-
: Color(255, 128 + 127 * factor, 255 * factor, 32);
248+
? Color(128 + 127 * lifetimeFactor, 255, 255 * lifetimeFactor, 128)
249+
: Color(255, 128 + 127 * lifetimeFactor, 255 * lifetimeFactor, 32);
243250

244251
surface->DrawTxt(font, hudX + slotHeaderX, recordPosY, Color(255, 255, 255, 128), "%d", slot);
245252
surface->DrawTxt(font, hudX + serialHeaderX, recordPosY, serialColor, "%d", info->m_SerialNumber);

0 commit comments

Comments
 (0)