Overhaul ingame timer displays. Fixes #3062.
This commit is contained in:
46
OpenRA.Mods.RA/Widgets/Logic/GameTimerLogic.cs
Normal file
46
OpenRA.Mods.RA/Widgets/Logic/GameTimerLogic.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
{
|
||||
public class GameTimerLogic
|
||||
{
|
||||
[ObjectCreator.UseCtor]
|
||||
public GameTimerLogic(Widget widget, OrderManager orderManager, World world)
|
||||
{
|
||||
var timer = widget.GetOrNull<LabelWidget>("GAME_TIMER");
|
||||
if (timer != null)
|
||||
timer.GetText = () => WidgetUtils.FormatTime(world.WorldTick);
|
||||
|
||||
var status = widget.GetOrNull<LabelWidget>("GAME_TIMER_STATUS");
|
||||
if (status != null)
|
||||
{
|
||||
// Blink the status line
|
||||
status.IsVisible = () => (world.Paused || world.Timestep != Game.Timestep)
|
||||
&& orderManager.LocalFrameNumber / 25 % 2 == 0;
|
||||
|
||||
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