Fix time formatting

This commit is contained in:
Sofia 2026-07-28 23:14:50 +03:00
parent 0685b83555
commit 227dea72c6

View File

@ -46,7 +46,7 @@ impl ReplayHud {
fn on_change(&mut self, new_value: f64) { fn on_change(&mut self, new_value: f64) {
if self.dragging { if self.dragging {
if let Some(current_time_label) = &mut self.current_time { if let Some(current_time_label) = &mut self.current_time {
current_time_label.set_text(&format!("{:.2}", new_value)); current_time_label.set_text(&format_time(new_value));
} }
self.signals().on_time_changed().emit(new_value); self.signals().on_time_changed().emit(new_value);
} }
@ -54,10 +54,10 @@ impl ReplayHud {
pub fn update_times(&mut self, current_time: f64, end_time: f64, set_value: bool) { pub fn update_times(&mut self, current_time: f64, end_time: f64, set_value: bool) {
if let Some(current_time_label) = &mut self.current_time { if let Some(current_time_label) = &mut self.current_time {
current_time_label.set_text(&format!("{:.2}", current_time)); current_time_label.set_text(&format_time(current_time));
} }
if let Some(end_time_label) = &mut self.end_time { if let Some(end_time_label) = &mut self.end_time {
end_time_label.set_text(&format!("{:.2}", end_time)); end_time_label.set_text(&format_time(end_time));
} }
if let Some(slider) = &mut self.slider { if let Some(slider) = &mut self.slider {
slider.set_min(0.); slider.set_min(0.);
@ -68,3 +68,9 @@ impl ReplayHud {
} }
} }
} }
fn format_time(time: f64) -> String {
let minutes = (time / 60.).floor();
let seconds = time % 60.;
format!("{:02}:{:02}", minutes as u32, seconds as u32)
}