Use rFactor typical angled ui elements #6

Merged
hodasemi merged 12 commits from dev into master 2023-01-20 22:15:16 +00:00
2 changed files with 16 additions and 10 deletions
Showing only changes of commit bd31f4fbb5 - Show all commits

View file

@ -126,6 +126,14 @@ impl LeaderBoardEntry {
self.place_label.set_text(self.place)
}
pub fn reset_time(&mut self) -> Result<()> {
self.behind = BehindLeader::Time(f64::MIN);
self.best_lap = f64::MIN;
self.time_behind_next = f64::MIN;
self.time_label.set_text("---")
}
pub fn update_time_behind_leader(&mut self, behind: BehindLeader) -> Result<()> {
if self.behind != behind {
self.behind = behind;
@ -149,13 +157,7 @@ impl LeaderBoardEntry {
}
}
BehindLeader::Laps(laps_behind) => {
let text = if laps_behind == 1 {
format!("+{} Lap", laps_behind)
} else {
format!("+{} Laps", laps_behind)
};
self.time_label.set_text(text)?;
self.time_label.set_text(format!("+{}", laps_behind))?;
}
}
}
@ -167,7 +169,7 @@ impl LeaderBoardEntry {
if self.best_lap != time {
self.best_lap = time;
if self.best_lap < 0.0 {
if self.best_lap <= 0.0 {
self.time_label.set_text("---")?;
} else {
let text = if self.best_lap > 60.0 {

View file

@ -276,7 +276,7 @@ impl DataReceiver for LeaderBoard {
match phase {
GamePhase::Practice | GamePhase::Qualifying | GamePhase::TestDay => {
for entry in self.leaderboard_entries.iter_mut() {
entry.update_best_lap(-1.0)?;
entry.reset_time()?;
}
self.leaderboard.enable()?;
@ -284,7 +284,11 @@ impl DataReceiver for LeaderBoard {
GamePhase::Race => {
for entry in self.leaderboard_entries.iter_mut() {
entry.update_time_behind_leader(BehindLeader::Time(0.0))?;
entry.reset_time()?;
}
for entry in self.deltaboard_entries.iter_mut() {
entry.reset_time()?;
}
self.leaderboard.enable()?;