Add support for single-line time display.
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
@@ -19,27 +20,39 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
public GameTimerLogic(Widget widget, OrderManager orderManager, World world)
|
public GameTimerLogic(Widget widget, OrderManager orderManager, World world)
|
||||||
{
|
{
|
||||||
var timer = widget.GetOrNull<LabelWidget>("GAME_TIMER");
|
var timer = widget.GetOrNull<LabelWidget>("GAME_TIMER");
|
||||||
if (timer != null)
|
|
||||||
timer.GetText = () => WidgetUtils.FormatTime(world.WorldTick);
|
|
||||||
|
|
||||||
var status = widget.GetOrNull<LabelWidget>("GAME_TIMER_STATUS");
|
var status = widget.GetOrNull<LabelWidget>("GAME_TIMER_STATUS");
|
||||||
|
var startTick = Ui.LastTickTime;
|
||||||
|
|
||||||
|
Func<bool> shouldShowStatus = () => (world.Paused || world.Timestep != Game.Timestep)
|
||||||
|
&& (Ui.LastTickTime - startTick) / 1000 % 2 == 0;
|
||||||
|
|
||||||
|
Func<string> statusText = () =>
|
||||||
|
{
|
||||||
|
if (world.Paused || world.Timestep == 0)
|
||||||
|
return "Paused";
|
||||||
|
|
||||||
|
if (world.Timestep == 1)
|
||||||
|
return "Max Speed";
|
||||||
|
|
||||||
|
return "{0:F1}x Speed".F(Game.Timestep * 1f / world.Timestep);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (timer != null)
|
||||||
|
{
|
||||||
|
timer.GetText = () =>
|
||||||
|
{
|
||||||
|
if (status == null && shouldShowStatus())
|
||||||
|
return statusText();
|
||||||
|
|
||||||
|
return WidgetUtils.FormatTime(world.WorldTick);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (status != null)
|
if (status != null)
|
||||||
{
|
{
|
||||||
var startTick = Ui.LastTickTime;
|
|
||||||
// Blink the status line
|
// Blink the status line
|
||||||
status.IsVisible = () => (world.Paused || world.Timestep != Game.Timestep)
|
status.IsVisible = shouldShowStatus;
|
||||||
&& (Ui.LastTickTime - startTick) / 1000 % 2 == 0;
|
status.GetText = statusText;
|
||||||
|
|
||||||
status.GetText = () =>
|
|
||||||
{
|
|
||||||
if (world.Paused || world.Timestep == 0)
|
|
||||||
return "Paused";
|
|
||||||
|
|
||||||
if (world.Timestep == 1)
|
|
||||||
return "Max Speed";
|
|
||||||
|
|
||||||
return "{0:F1}x Speed".F(Game.Timestep * 1f / world.Timestep);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user