give raw time remaining estimate based on rate

This commit is contained in:
Green Sky 2024-09-24 12:05:29 +02:00
parent c9f34e4656
commit 3bdf262068
No known key found for this signature in database

View File

@ -1042,11 +1042,16 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) {
float fraction = float(total) / total_size; float fraction = float(total) / total_size;
char overlay_buf[32]; char overlay_buf[64];
if (rate > 0.000001f) { if (rate > 0.000001f) {
const char* byte_suffix = "???"; const char* byte_suffix = "???";
int64_t byte_divider = sizeToHumanReadable(rate, byte_suffix); int64_t byte_divider = sizeToHumanReadable(rate, byte_suffix);
int64_t seconds_remaining = (total_size - total) / rate;
if (seconds_remaining > 0) {
std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%% @ %.1f%s/s %lds ", fraction * 100 + 0.01f, rate/byte_divider, byte_suffix, seconds_remaining);
} else {
std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%% @ %.1f%s/s", fraction * 100 + 0.01f, rate/byte_divider, byte_suffix); std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%% @ %.1f%s/s", fraction * 100 + 0.01f, rate/byte_divider, byte_suffix);
}
} else { } else {
std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%%", fraction * 100 + 0.01f); std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%%", fraction * 100 + 0.01f);
} }