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 36 additions and 5 deletions
Showing only changes of commit c152132c74 - Show all commits

View file

@ -9,6 +9,9 @@ use vulkan_rs::prelude::*;
pub enum BehindLeader {
Time(f64),
Laps(i32),
DNF,
DSQ,
PITS,
}
pub struct LeaderBoardEntry {
@ -164,6 +167,15 @@ impl LeaderBoardEntry {
BehindLeader::Laps(laps_behind) => {
self.time_label.set_text(format!("+{}", laps_behind))?;
}
BehindLeader::DNF => {
self.time_label.set_text("DNF")?;
}
BehindLeader::DSQ => {
self.time_label.set_text("DSQ")?;
}
BehindLeader::PITS => {
self.time_label.set_text("PIT")?;
}
}
Ok(())

View file

@ -327,12 +327,31 @@ impl LeaderBoard {
}
fn query_behind_leader(scoring: &VehicleScoringInfoV01) -> BehindLeader {
let laps_behind = scoring.mLapsBehindLeader;
match scoring.mFinishStatus {
0 | 1 => {
if scoring.mInPits != 0 {
BehindLeader::PITS
} else {
let laps_behind = scoring.mLapsBehindLeader;
if laps_behind != 0 {
BehindLeader::Laps(laps_behind)
} else {
BehindLeader::Time(scoring.mTimeBehindLeader)
if laps_behind != 0 {
BehindLeader::Laps(laps_behind)
} else {
BehindLeader::Time(scoring.mTimeBehindLeader)
}
}
}
2 => BehindLeader::DNF,
3 => BehindLeader::DSQ,
_ => {
write_log!(format!(
"not allowed finish state: {}",
scoring.mFinishStatus
));
BehindLeader::Time(scoring.mTimeBehindLeader)
}
}
}