pog
This commit is contained in:
1 parent
d97efd0e88
commit
c61fd84f90
4 files changed
+57
-50
No files matched your search
@@ -7,7 +7,9 @@
|
||||
<ui:VisualElement name="notice" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0);">
|
||||
<ui:VisualElement name="noticeLap" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); flex-direction: row; justify-content: space-between; align-items: auto; width: auto; align-self: stretch; flex-shrink: 0;">
|
||||
<ui:Label tabindex="-1" text="1:24.248" display-tooltip-when-elided="true" name="noticeTime" style="align-self: flex-end; align-items: auto;" />
|
||||
<ui:Label tabindex="-1" text="-0.999" display-tooltip-when-elided="true" name="noticeDiff" />
|
||||
<ui:VisualElement name="noticeDiff" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); -unity-text-align: upper-right;">
|
||||
<ui:Label tabindex="-1" text="-0.999" display-tooltip-when-elided="true" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="noticeSectors" class="sectors" style="flex-grow: 0; background-color: rgba(0, 0, 0, 0); flex-direction: row; -unity-text-align: upper-left;">
|
||||
<ui:Label tabindex="-1" text="+2.1" display-tooltip-when-elided="true" class="yellow" />
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user