This commit is contained in:
ntr committed 2023-08-04 16:00:10 +10:00
1 parent d97efd0e88
commit c61fd84f90
4 files changed
+57 -50

No files matched your search

+6 -23
View File
@@ -19,8 +19,8 @@ public class TimingUI : MonoBehaviour {
VisualElement notice;
VisualElement noticeSectors;
VisualElement noticeDiff;
Label noticeTime;
Label noticeDiff;
void OnEnable() {
Init();
@@ -37,7 +37,7 @@ public class TimingUI : MonoBehaviour {
timerSectors = uiDocument.rootVisualElement.Q<VisualElement>("timerSectors");
noticeTime = uiDocument.rootVisualElement.Q<Label>("noticeTime");
noticeDiff = uiDocument.rootVisualElement.Q<Label>("noticeDiff");
noticeDiff = uiDocument.rootVisualElement.Q<VisualElement>("noticeDiff");
timerTime = uiDocument.rootVisualElement.Q<Label>("timerTime");
timerPb = uiDocument.rootVisualElement.Q<Label>("timerPb");
@@ -73,7 +73,7 @@ public class TimingUI : MonoBehaviour {
foreach (Sector sector in timing.sectors) {
Label l = timing.sectorTimes
.Where(s => s.Sector == sector.sector)
.Select(s => SectorLabel(s))
.Select(s => timing.PBSectorDiff(s).ToLabel())
.DefaultIfEmpty(new Label("-"))
.Single();
@@ -90,11 +90,12 @@ public class TimingUI : MonoBehaviour {
// should show the diff to the PB
// or - if there is only 1 lap
noticeDiff.text = lap.ToString();
noticeDiff.Clear();
noticeDiff.Add(timing.PBLapDiff(lap).ToLabel());
noticeSectors.Clear();
foreach (SectorTime sector in lap.Sectors) {
Label l = SectorLabel(sector);
Label l = timing.PBSectorDiff(sector).ToLabel();
noticeSectors.Add(l);
}
}
@@ -103,22 +104,4 @@ public class TimingUI : MonoBehaviour {
timer.RemoveFromClassList("hidden");
notice.AddToClassList("hidden");
}
Label SectorLabel(SectorTime s) {
double diff = timing.PBSectorDiff(s);
string sign = diff switch {
< 0 => "",
_ => "+",
};
DiffColour colour = diff switch {
< 0 => DiffColour.Green,
_ => DiffColour.Yellow,
};
Label l = new Label($"{sign}{diff:0.000}");
string colourClass = colour.ToString().ToLowerInvariant();
l.AddToClassList(colourClass);
return l;
}
}