recent lap
This commit is contained in:
1 parent
96038013db
commit
daa84c8a9d
4 files changed
+40
-6
No files matched your search
@@ -15,9 +15,11 @@ public class Timing: MonoBehaviour {
|
|||||||
public string mapName;
|
public string mapName;
|
||||||
public double sectorTime;
|
public double sectorTime;
|
||||||
public double lapTime;
|
public double lapTime;
|
||||||
|
public Sector[] sectors;
|
||||||
|
public LapJSON recentLap;
|
||||||
|
|
||||||
double sectorStart;
|
double sectorStart;
|
||||||
double lapStart;
|
double lapStart;
|
||||||
public Sector[] sectors;
|
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
sectorTimes = new List<SectorTime>();
|
sectorTimes = new List<SectorTime>();
|
||||||
|
|||||||
@@ -4,10 +4,14 @@
|
|||||||
<ui:VisualElement name="Top" style="flex-grow: 1;" />
|
<ui:VisualElement name="Top" style="flex-grow: 1;" />
|
||||||
<ui:VisualElement name="Middle" style="flex-grow: 1; align-items: center;" />
|
<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="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="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:Label tabindex="-1" text="1:28.248" display-tooltip-when-elided="true" name="pb" />
|
||||||
</ui:VisualElement>
|
</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: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="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('project://database/Assets/UI%20Toolkit/Fonts/Jura-Medium.otf?fileID=12800000&guid=65648a14640996362a6b0929c723b6e4&type=3#Jura-Medium');" />
|
<ui:Label tabindex="-1" text="64.0" display-tooltip-when-elided="true" class="green" style="-unity-font-style: normal; -unity-font: url('project://database/Assets/UI%20Toolkit/Fonts/Jura-Medium.otf?fileID=12800000&guid=65648a14640996362a6b0929c723b6e4&type=3#Jura-Medium');" />
|
||||||
|
|||||||
@@ -16,8 +16,12 @@ public class TimingUI : MonoBehaviour {
|
|||||||
|
|
||||||
Label timer;
|
Label timer;
|
||||||
Label pb;
|
Label pb;
|
||||||
|
Label recentTime;
|
||||||
|
Label recentDiff;
|
||||||
|
|
||||||
|
VisualElement pbCompare;
|
||||||
|
VisualElement currentLap;
|
||||||
VisualElement sectors;
|
VisualElement sectors;
|
||||||
VisualElement timeSheet;
|
|
||||||
|
|
||||||
void OnEnable() {
|
void OnEnable() {
|
||||||
Init();
|
Init();
|
||||||
@@ -25,16 +29,24 @@ public class TimingUI : MonoBehaviour {
|
|||||||
|
|
||||||
void Init() {
|
void Init() {
|
||||||
uiDocument = GetComponent<UIDocument>();
|
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");
|
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 = "-";
|
pb.text = "-";
|
||||||
|
|
||||||
|
|
||||||
|
pbCompare.AddToClassList("hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedUpdate() {
|
void FixedUpdate() {
|
||||||
if (timer == null) {
|
if (timer == null) {
|
||||||
Debug.LogWarning("no speed or timer");
|
Debug.LogWarning("no timer");
|
||||||
Init();
|
Init();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -64,6 +76,17 @@ public class TimingUI : MonoBehaviour {
|
|||||||
|
|
||||||
sectors.Add(l);
|
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) {
|
Label SectorLabel(SectorTime s) {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#character-name {
|
#character-name {
|
||||||
|
|
||||||
-unity-font-style: bold;
|
-unity-font-style: bold;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
color: rgb(49, 26, 17);
|
color: rgb(49, 26, 17);
|
||||||
@@ -42,3 +43,7 @@
|
|||||||
.yellow {
|
.yellow {
|
||||||
color: var(--yellow);
|
color: var(--yellow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user