Handle more states of drivers
This commit is contained in:
parent
544f6d765d
commit
65878f8120
2 changed files with 36 additions and 5 deletions
|
@ -9,6 +9,9 @@ use vulkan_rs::prelude::*;
|
||||||
pub enum BehindLeader {
|
pub enum BehindLeader {
|
||||||
Time(f64),
|
Time(f64),
|
||||||
Laps(i32),
|
Laps(i32),
|
||||||
|
DNF,
|
||||||
|
DSQ,
|
||||||
|
PITS,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct LeaderBoardEntry {
|
pub struct LeaderBoardEntry {
|
||||||
|
@ -164,6 +167,15 @@ impl LeaderBoardEntry {
|
||||||
BehindLeader::Laps(laps_behind) => {
|
BehindLeader::Laps(laps_behind) => {
|
||||||
self.time_label.set_text(format!("+{}", 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(())
|
Ok(())
|
||||||
|
|
|
@ -327,12 +327,31 @@ impl LeaderBoard {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn query_behind_leader(scoring: &VehicleScoringInfoV01) -> BehindLeader {
|
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 {
|
if laps_behind != 0 {
|
||||||
BehindLeader::Laps(laps_behind)
|
BehindLeader::Laps(laps_behind)
|
||||||
} else {
|
} else {
|
||||||
BehindLeader::Time(scoring.mTimeBehindLeader)
|
BehindLeader::Time(scoring.mTimeBehindLeader)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
2 => BehindLeader::DNF,
|
||||||
|
3 => BehindLeader::DSQ,
|
||||||
|
|
||||||
|
_ => {
|
||||||
|
write_log!(format!(
|
||||||
|
"not allowed finish state: {}",
|
||||||
|
scoring.mFinishStatus
|
||||||
|
));
|
||||||
|
|
||||||
|
BehindLeader::Time(scoring.mTimeBehindLeader)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue