From 1182bcfbec58234979e107de88453c93f9b09523 Mon Sep 17 00:00:00 2001 From: FlightlessMango Date: Wed, 19 Jul 2023 20:24:05 +0200 Subject: [PATCH] hud_elements/battery: make sure time isn't illogical --- src/hud_elements.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hud_elements.cpp b/src/hud_elements.cpp index f080538..ba19361 100644 --- a/src/hud_elements.cpp +++ b/src/hud_elements.cpp @@ -847,6 +847,9 @@ void HudElements::battery(){ float minutes; minutes = std::modf(Battery_Stats.remaining_time, &hours); minutes *= 60; + char time_buffer[32]; + snprintf(time_buffer, sizeof(time_buffer), "%02d:%02d", static_cast(hours), static_cast(minutes)); + if (!HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_horizontal] && !HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_hud_compact]){ ImGui::TableNextRow(); ImGui::NextColumn(); @@ -861,7 +864,10 @@ void HudElements::battery(){ ImguiNextColumnOrNewRow(); } - right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%02.0f:%02.0f", hours, minutes); + if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_hud_compact]) + ImGuiTableSetColumnIndex(0); + + right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%s", time_buffer); } } else { ImguiNextColumnOrNewRow();