use the convenient printf fomat as ImGui::Text supports it (#2486)

This commit is contained in:
AltoXorg 2023-02-17 00:37:27 +08:00 committed by GitHub
parent 1e6ec1bdda
commit 877fc2dcca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,22 +49,7 @@ void DisplayTimeHHMMSS(uint32_t timeInTenthsOfSeconds, const char* text, ImVec4
ImGui::Text(text);
ImGui::SameLine();
// Hack to keep the timers aligned and prevent them from shifting around
// Put a leading zero in front of the seconds or minutes if they're less than 10
if (mm < 10 && ss < 10) {
ImGui::Text("%u:0%u:0%u.%u", hh, mm, ss, ds);
}
if (mm < 10 && ss >= 10) {
ImGui::Text("%u:0%u:%u.%u", hh, mm, ss, ds);
}
if (mm >= 10 && ss < 10) {
ImGui::Text("%u:%u:0%u.%u", hh, mm, ss, ds);
}
if (mm >= 10 && ss >= 10) {
ImGui::Text("%u:%u:%u.%u", hh, mm, ss, ds);
}
ImGui::Text("%2u:%02u:%02u.%u", hh, mm, ss, ds);
ImGui::PopStyleColor();
}
@ -85,20 +70,7 @@ void DisplayStat(const char* text, uint32_t value) {
ImGui::Text(text);
ImGui::SameLine();
// Hack to keep the digits properly aligned in the column
if (value < 10) {
ImGui::Text(" %u", value);
} else if (value < 100) {
ImGui::Text(" %u", value);
} else if (value < 1000) {
ImGui::Text(" %u", value);
} else if (value < 10000) {
ImGui::Text(" %u", value);
} else if (value < 100000) {
ImGui::Text(" %u", value);
} else {
ImGui::Text("%u", value);
}
ImGui::Text("%7u", value);
}
void DisplayStatIfNonZero(const char* text, uint32_t value) {