Fix time formatting
This commit is contained in:
parent
0685b83555
commit
227dea72c6
@ -46,7 +46,7 @@ impl ReplayHud {
|
||||
fn on_change(&mut self, new_value: f64) {
|
||||
if self.dragging {
|
||||
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);
|
||||
}
|
||||
@ -54,10 +54,10 @@ impl ReplayHud {
|
||||
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user