Overhaul ingame timer displays. Fixes #3062.
This commit is contained in:
@@ -73,7 +73,8 @@ namespace OpenRA
|
||||
public static int RenderFrame = 0;
|
||||
public static int NetFrameNumber { get { return orderManager.NetFrameNumber; } }
|
||||
public static int LocalTick { get { return orderManager.LocalFrameNumber; } }
|
||||
public const int NetTickScale = 3; // 120ms net tick for 40ms local tick
|
||||
public const int NetTickScale = 3; // 120ms net tick for 40ms local tick
|
||||
public const int Timestep = 40;
|
||||
|
||||
public static event Action<OrderManager> ConnectionStateChanged = _ => { };
|
||||
static ConnectionState lastConnectionState = ConnectionState.PreConnecting;
|
||||
@@ -224,6 +225,7 @@ namespace OpenRA
|
||||
|
||||
var map = modData.PrepareMap(mapUID);
|
||||
orderManager.world = new World(modData.Manifest, map, orderManager, isShellmap);
|
||||
orderManager.world.Timestep = Timestep;
|
||||
worldRenderer = new WorldRenderer(orderManager.world);
|
||||
orderManager.world.LoadComplete(worldRenderer);
|
||||
|
||||
|
||||
@@ -200,7 +200,6 @@
|
||||
<Compile Include="Widgets\ShpImageWidget.cs" />
|
||||
<Compile Include="Widgets\SliderWidget.cs" />
|
||||
<Compile Include="Widgets\TextFieldWidget.cs" />
|
||||
<Compile Include="Widgets\TimerWidget.cs" />
|
||||
<Compile Include="Widgets\VqaPlayerWidget.cs" />
|
||||
<Compile Include="Widgets\Widget.cs" />
|
||||
<Compile Include="Widgets\WidgetLoader.cs" />
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2013 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 System.Drawing;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Graphics;
|
||||
|
||||
namespace OpenRA.Widgets
|
||||
{
|
||||
public class TimerWidget : LabelWidget
|
||||
{
|
||||
public override void Draw()
|
||||
{
|
||||
var font = Game.Renderer.Fonts[Font];
|
||||
var rb = RenderBounds;
|
||||
var color = GetColor();
|
||||
var contrast = GetContrastColor();
|
||||
|
||||
var s = WidgetUtils.FormatTime(Game.LocalTick) + (Game.orderManager.world.Paused?" (paused)":"");
|
||||
var pos = new float2(rb.Left - font.Measure(s).X / 2, rb.Top);
|
||||
if (Contrast)
|
||||
font.DrawTextWithContrast(s, pos, color, contrast, 1);
|
||||
else
|
||||
font.DrawText(s, pos, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace OpenRA
|
||||
Queue<Action<World>> frameEndActions = new Queue<Action<World>>();
|
||||
|
||||
public int FrameNumber { get { return orderManager.LocalFrameNumber; } }
|
||||
public int Timestep;
|
||||
|
||||
internal readonly OrderManager orderManager;
|
||||
public Session LobbyInfo { get { return orderManager.LobbyInfo; } }
|
||||
@@ -190,6 +191,7 @@ namespace OpenRA
|
||||
public bool PredictedPaused { get; internal set; }
|
||||
public bool PauseStateLocked { get; set; }
|
||||
public bool IsShellmap = false;
|
||||
public int WorldTick { get; private set; }
|
||||
|
||||
public void SetPauseState(bool paused)
|
||||
{
|
||||
@@ -209,6 +211,8 @@ namespace OpenRA
|
||||
{
|
||||
if (!Paused && (!IsShellmap || Game.Settings.Game.ShowShellmap))
|
||||
{
|
||||
WorldTick++;
|
||||
|
||||
using (new PerfSample("tick_idle"))
|
||||
foreach (var ni in ActorsWithTrait<INotifyIdle>())
|
||||
if (ni.Actor.IsIdle)
|
||||
|
||||
@@ -479,6 +479,8 @@
|
||||
<Compile Include="Widgets\Logic\DisconnectWatcherLogic.cs" />
|
||||
<Compile Include="Activities\FlyFollow.cs" />
|
||||
<Compile Include="Modifiers\DisabledOverlay.cs" />
|
||||
<Compile Include="Widgets\Logic\ReplayControlBarLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\GameTimerLogic.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
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);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,25 @@ Container@INGAME_ROOT:
|
||||
Children:
|
||||
LogicTicker@DISCONNECT_WATCHER:
|
||||
Logic:DisconnectWatcherLogic
|
||||
Timer@GAME_TIMER:
|
||||
X: WINDOW_RIGHT/2
|
||||
Y: 0
|
||||
Font: Title
|
||||
Contrast: true
|
||||
Container@GAME_TIMER_BLOCK:
|
||||
Logic:GameTimerLogic
|
||||
X:WINDOW_RIGHT/2 - WIDTH
|
||||
Width:100
|
||||
Height:55
|
||||
Children:
|
||||
Label@GAME_TIMER:
|
||||
Width:PARENT_RIGHT
|
||||
Height:30
|
||||
Align:Center
|
||||
Font:Title
|
||||
Contrast:true
|
||||
Label@GAME_TIMER_STATUS:
|
||||
Y:35
|
||||
Width:PARENT_RIGHT
|
||||
Height:15
|
||||
Align:Center
|
||||
Font:Bold
|
||||
Contrast:true
|
||||
StrategicProgress@STRATEGIC_PROGRESS:
|
||||
X: WINDOW_RIGHT/2
|
||||
Y: 40
|
||||
|
||||
@@ -19,11 +19,25 @@ Container@INGAME_ROOT:
|
||||
Y:0
|
||||
Width:WINDOW_RIGHT
|
||||
Height:WINDOW_BOTTOM
|
||||
Timer@GAME_TIMER:
|
||||
X: WINDOW_RIGHT/2
|
||||
Y: 0
|
||||
Font: Title
|
||||
Contrast: true
|
||||
Container@GAME_TIMER_BLOCK:
|
||||
Logic:GameTimerLogic
|
||||
X:WINDOW_RIGHT/2 - WIDTH
|
||||
Width:100
|
||||
Height:55
|
||||
Children:
|
||||
Label@GAME_TIMER:
|
||||
Width:PARENT_RIGHT
|
||||
Height:30
|
||||
Align:Center
|
||||
Font:Title
|
||||
Contrast:true
|
||||
Label@GAME_TIMER_STATUS:
|
||||
Y:32
|
||||
Width:PARENT_RIGHT
|
||||
Height:15
|
||||
Align:Center
|
||||
Font:Bold
|
||||
Contrast:true
|
||||
StrategicProgress@STRATEGIC_PROGRESS:
|
||||
X: WINDOW_RIGHT/2
|
||||
Y: 40
|
||||
|
||||
@@ -19,11 +19,25 @@ Container@INGAME_ROOT:
|
||||
Y:0
|
||||
Width:WINDOW_RIGHT
|
||||
Height:WINDOW_BOTTOM
|
||||
Timer@GAME_TIMER:
|
||||
X: WINDOW_RIGHT/2
|
||||
Y: 0-10
|
||||
Font: Title
|
||||
Contrast: true
|
||||
Container@GAME_TIMER_BLOCK:
|
||||
Logic:GameTimerLogic
|
||||
X:WINDOW_RIGHT/2 - WIDTH
|
||||
Width:100
|
||||
Height:55
|
||||
Children:
|
||||
Label@GAME_TIMER:
|
||||
Width:PARENT_RIGHT
|
||||
Height:15
|
||||
Align:Center
|
||||
Font:Title
|
||||
Contrast:true
|
||||
Label@GAME_TIMER_STATUS:
|
||||
Y:35
|
||||
Width:PARENT_RIGHT
|
||||
Height:15
|
||||
Align:Center
|
||||
Font:Bold
|
||||
Contrast:true
|
||||
StrategicProgress@STRATEGIC_PROGRESS:
|
||||
X: WINDOW_RIGHT/2
|
||||
Y: 40
|
||||
|
||||
Reference in New Issue
Block a user