Let sidebar timer count backwards if a time limit is set

This commit is contained in:
Oliver Brakmann
2018-12-22 03:28:16 +01:00
committed by abcdefg30
parent 4a35d85884
commit 47d88983fb

View File

@@ -23,6 +23,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
var timer = widget.GetOrNull<LabelWidget>("GAME_TIMER");
var status = widget.GetOrNull<LabelWidget>("GAME_TIMER_STATUS");
var tlm = world.WorldActor.TraitOrDefault<TimeLimitManager>();
var startTick = Ui.LastTickTime;
Func<bool> shouldShowStatus = () => (world.Paused || world.Timestep != world.LobbyInfo.GlobalSettings.Timestep)
@@ -51,7 +52,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (status == null && shouldShowStatus())
return statusText();
return WidgetUtils.FormatTime(world.WorldTick, timestep);
var timeLimit = tlm != null ? tlm.TimeLimit : 0;
var displayTick = timeLimit > 0 ? timeLimit - world.WorldTick : world.WorldTick;
return WidgetUtils.FormatTime(displayTick, timestep);
};
}