hud elements: custom_text guard for out of range

mangoconfig
FlightlessMango 8 months ago
parent 2bf27939e0
commit b32e6b299c

@ -875,13 +875,24 @@ void HudElements::show_fps_limit(){
} }
void HudElements::custom_text_center(){ void HudElements::custom_text_center(){
ImguiNextColumnFirstItem(); if (HUDElements.place >= 0 &&
ImGui::PushFont(HUDElements.sw_stats->font1); static_cast<size_t>(HUDElements.place) < HUDElements.ordered_functions.size()) {
const std::string& value = HUDElements.ordered_functions[HUDElements.place].second;
center_text(value); if (!HUDElements.sw_stats || !HUDElements.sw_stats->font1) {
HUDElements.TextColored(HUDElements.colors.text, "%s",value.c_str()); return;
ImGui::NewLine(); }
ImGui::PopFont();
ImguiNextColumnFirstItem();
ImGui::PushFont(HUDElements.sw_stats->font1);
const std::string& value = HUDElements.ordered_functions[HUDElements.place].second;
center_text(value);
HUDElements.TextColored(HUDElements.colors.text, "%s", value.c_str());
ImGui::NewLine();
ImGui::PopFont();
}
} }
void HudElements::custom_text(){ void HudElements::custom_text(){

Loading…
Cancel
Save