diff --git a/TM_RoyalRounds_Online.Script.txt b/TM_RoyalRounds_Online.Script.txt
index 8d89347..ea49c2c 100644
--- a/TM_RoyalRounds_Online.Script.txt
+++ b/TM_RoyalRounds_Online.Script.txt
@@ -282,6 +282,7 @@ UIModules_Chrono::SetTimeOffset(Player, SpecificOffset);
***Match_InitRound***
***
+declare netwrite Integer Net_RoyalRounds_CheckpointUI_TotalNbSegments for Teams[0];
declare Integer[Text] CustomTimes for This = [];
declare Integer[Text][Integer] CurrentRanking for This = []; // CurrentRanking[Segment][AccountId][Time]
CurrentRanking[0] = Integer[Text]; // Init white section
@@ -338,13 +339,12 @@ foreach (Event in RacePendingEvents) {
Event.Player.Dossard_Number = TL::FormatInteger(ML::Clamp(Rank, 0, 99), 2);
// Send Rank to Checkpoint UI
- declare UI <=> UIManager.GetUI(Event.Player);
- if (UI != Null) {
- declare netwrite Integer Net_RoyalRounds_CheckpointUI_Rank for UI;
- Net_RoyalRounds_CheckpointUI_Rank = Rank;
- declare netwrite Integer Net_RoyalRounds_CheckpointUI_Update for UI;
- Net_RoyalRounds_CheckpointUI_Update += 1;
- }
+ declare netwrite Integer Net_RoyalRounds_CheckpointUI_Rank for Event.Player;
+ Net_RoyalRounds_CheckpointUI_Rank = Rank;
+ declare netwrite Integer Net_RoyalRounds_CheckpointUI_Update for Event.Player;
+ Net_RoyalRounds_CheckpointUI_Update += 1;
+ declare netwrite Integer Net_RoyalRounds_CheckpointUI_CurrentNbSegments for Event.Player;
+ Net_RoyalRounds_CheckpointUI_CurrentNbSegments = CurrentSegment;
if (CurrentSegment < S_SegmentsPerRound) { // TODO Try to keep CP diff a the bottom of the screen
declare ModeRounds_CanSpawn for Event.Player.Score = Rounds_Settings_CanSpawnDefault;
@@ -426,6 +426,10 @@ if (
UpdateScoresTableFooter(S_PointsLimit, S_RoundsPerMap, S_MapsPerMatch, Map_ValidRoundsNb, S_SegmentsPerRound);
}
+
+if (Net_RoyalRounds_CheckpointUI_TotalNbSegments != S_SegmentsPerRound) {
+ Net_RoyalRounds_CheckpointUI_TotalNbSegments = S_SegmentsPerRound;
+}
***
***Rounds_CheckStopRound***
@@ -733,28 +737,43 @@ Boolean MapIsOver(Boolean _UseTieBreak, Integer _PointsLimit, Integer _ValidRoun
#Include "TextLib" as TL
main() {
- declare netread Integer Net_RoyalRounds_CheckpointUI_Rank for UI;
- declare netread Integer Net_RoyalRounds_CheckpointUI_Update for UI;
-
declare Integer TimeToDisplay = 0;
declare Integer LastUpdate = 0;
declare Quad_UI <=> (Page.GetFirstChild("quad-ui") as CMlQuad);
declare Label_Rank <=> (Page.GetFirstChild("label-rank") as CMlLabel);
declare Label_Time <=> (Page.GetFirstChild("label-time") as CMlLabel);
+ declare Label_Segments <=> (Page.GetFirstChild("label-segments") as CMlLabel);
+
+ declare netread Integer Net_RoyalRounds_CheckpointUI_TotalNbSegments for Teams[0];
while(True) {
yield;
- if (LastUpdate != Net_RoyalRounds_CheckpointUI_Update) {
- LastUpdate = Net_RoyalRounds_CheckpointUI_Update;
- Label_Rank.Value = TL::FormatRank(Net_RoyalRounds_CheckpointUI_Rank, False);
- Label_Time.Value = TL::TimeToText(GUIPlayer.RaceWaypointTimes[0], True, True);// PrevRace
- Quad_UI.Visible = True;
- TimeToDisplay = Now + 3000;
- }
-
- if (TimeToDisplay != 0 && TimeToDisplay < Now) {
+ if (GUIPlayer != Null) {
+ declare netread Integer Net_RoyalRounds_CheckpointUI_Rank for GUIPlayer;
+ declare netread Integer Net_RoyalRounds_CheckpointUI_CurrentNbSegments for GUIPlayer;
+ declare netread Integer Net_RoyalRounds_CheckpointUI_Update for GUIPlayer;
+
+ if (LastUpdate != Net_RoyalRounds_CheckpointUI_Update) {
+ if (GUIPlayer.RaceWaypointTimes.count <= 0) continue; // skip if there is any latency (useful for spectators)
+ LastUpdate = Net_RoyalRounds_CheckpointUI_Update;
+ if (Net_RoyalRounds_CheckpointUI_Rank > 0) {
+ Label_Time.Value = TL::TimeToText(GUIPlayer.RaceWaypointTimes[0], True, True);
+ Label_Rank.Value = TL::FormatRank(Net_RoyalRounds_CheckpointUI_Rank, False);
+ Label_Segments.Value = TL::Compose("Segment %1/%2", TL::ToText(Net_RoyalRounds_CheckpointUI_CurrentNbSegments), TL::ToText(Net_RoyalRounds_CheckpointUI_TotalNbSegments));
+ Quad_UI.Visible = True;
+ TimeToDisplay = Now + 3000;
+ } else {
+ TimeToDisplay = -1; // Force hide UI
+ }
+ }
+
+ if (TimeToDisplay != 0 && TimeToDisplay < Now) {
+ Quad_UI.Visible = False;
+ TimeToDisplay = 0;
+ }
+ } else if (Quad_UI.Visible) {
Quad_UI.Visible = False;
TimeToDisplay = 0;
}
@@ -776,6 +795,10 @@ Boolean MapIsOver(Boolean _UseTieBreak, Integer _PointsLimit, Integer _ValidRoun
+
+
+
+
@@ -784,4 +807,4 @@ Boolean MapIsOver(Boolean _UseTieBreak, Integer _PointsLimit, Integer _ValidRoun
Layers::Create("ML_RoyalRounds_CheckpointUI", MLText);
Layers::SetType("ML_RoyalRounds_CheckpointUI", CUILayer::EUILayerType::Normal);
Layers::Attach("ML_RoyalRounds_CheckpointUI");
-}
\ No newline at end of file
+}