recent lap

This commit is contained in:
ntr committed 2023-08-01 18:28:20 +10:00
1 parent 96038013db
commit daa84c8a9d
4 files changed
+40 -6

No files matched your search

+3 -1
View File
@@ -15,9 +15,11 @@ public class Timing: MonoBehaviour {
public string mapName;
public double sectorTime;
public double lapTime;
public Sector[] sectors;
public LapJSON recentLap;
double sectorStart;
double lapStart;
public Sector[] sectors;
void Awake() {
sectorTimes = new List<SectorTime>();
+5 -1
View File
@@ -4,10 +4,14 @@
<ui:VisualElement name="Top" style="flex-grow: 1;" />
<ui:VisualElement name="Middle" style="flex-grow: 1; align-items: center;" />
<ui:VisualElement name="Bottom" style="flex-grow: 0; background-color: rgba(0, 0, 0, 0.26); flex-direction: column; align-items: stretch; justify-content: flex-end; color: rgb(255, 255, 255); width: 33%; align-self: center;">
<ui:VisualElement name="upper" 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:VisualElement name="currentLap" 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; visibility: visible; display: flex;">
<ui:Label tabindex="-1" text="Time" display-tooltip-when-elided="true" name="timer" style="align-self: flex-end; align-items: auto;" />
<ui:Label tabindex="-1" text="1:28.248" display-tooltip-when-elided="true" name="pb" />
</ui:VisualElement>
<ui:VisualElement name="pbCompare" 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="recentTime" style="align-self: flex-end; align-items: auto;" />
<ui:Label tabindex="-1" text="-0.999" display-tooltip-when-elided="true" name="recentDiff" class="green" />
</ui:VisualElement>
<ui:VisualElement name="sectors" style="flex-grow: 0; background-color: rgba(0, 0, 0, 0); flex-direction: row; align-self: stretch; align-items: stretch; justify-content: space-between;">
<ui:Label tabindex="-1" text="32.0" display-tooltip-when-elided="true" class="yellow" />
<ui:Label tabindex="-1" text="64.0" display-tooltip-when-elided="true" class="green" style="-unity-font-style: normal; -unity-font: url(&apos;project://database/Assets/UI%20Toolkit/Fonts/Jura-Medium.otf?fileID=12800000&amp;guid=65648a14640996362a6b0929c723b6e4&amp;type=3#Jura-Medium&apos;);" />
+27 -4
View File
@@ -16,8 +16,12 @@ public class TimingUI : MonoBehaviour {
Label timer;
Label pb;
Label recentTime;
Label recentDiff;
VisualElement pbCompare;
VisualElement currentLap;
VisualElement sectors;
VisualElement timeSheet;
void OnEnable() {
Init();
@@ -25,16 +29,24 @@ public class TimingUI : MonoBehaviour {
void Init() {
uiDocument = GetComponent<UIDocument>();
timer = uiDocument.rootVisualElement.Q<Label>("timer");
pb = uiDocument.rootVisualElement.Q<Label>("pb");
pbCompare = uiDocument.rootVisualElement.Q<VisualElement>("pbCompare");
currentLap = uiDocument.rootVisualElement.Q<VisualElement>("currentLap");
sectors = uiDocument.rootVisualElement.Q<VisualElement>("sectors");
recentTime = uiDocument.rootVisualElement.Q<Label>("recentTime");
recentDiff = uiDocument.rootVisualElement.Q<Label>("recentDiff");
timer = uiDocument.rootVisualElement.Q<Label>("timer");
pb = uiDocument.rootVisualElement.Q<Label>("pb");
pb.text = "-";
pbCompare.AddToClassList("hidden");
}
void FixedUpdate() {
if (timer == null) {
Debug.LogWarning("no speed or timer");
Debug.LogWarning("no timer");
Init();
return;
}
@@ -64,6 +76,17 @@ public class TimingUI : MonoBehaviour {
sectors.Add(l);
}
// if (timing.recentLap != null) ShowRecentLap()
}
// yadad yadad
void ShowRecentLap() {
currentLap.AddToClassList("hidden");
pbCompare.RemoveFromClassList("hidden");
recentTime.text = timing.recentLap.ToString();
// recentDiff = yadad
}
Label SectorLabel(SectorTime s) {
+5
View File
@@ -22,6 +22,7 @@
}
#character-name {
-unity-font-style: bold;
font-size: 18px;
color: rgb(49, 26, 17);
@@ -42,3 +43,7 @@
.yellow {
color: var(--yellow);
}
.hidden {
display: none;
}