diff --git a/OpenRA.Game/GameRules/UserSettings.cs b/OpenRA.Game/GameRules/UserSettings.cs
index cbfe68f372..f7b1254ca6 100644
--- a/OpenRA.Game/GameRules/UserSettings.cs
+++ b/OpenRA.Game/GameRules/UserSettings.cs
@@ -35,6 +35,7 @@ namespace OpenRA.GameRules
public bool PerfDebug = false;
public bool IndexDebug = false;
public bool RecordSyncReports = true;
+ public bool ShowGameTimer = true;
// Window settings
public WindowMode WindowMode = WindowMode.PseudoFullscreen;
diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj
index b3d423fac7..6fe2f3ec10 100755
--- a/OpenRA.Game/OpenRA.Game.csproj
+++ b/OpenRA.Game/OpenRA.Game.csproj
@@ -230,6 +230,7 @@
+
diff --git a/OpenRA.Game/Widgets/Delegates/IngameChromeDelegate.cs b/OpenRA.Game/Widgets/Delegates/IngameChromeDelegate.cs
index d004fddb76..5fcda2af1f 100644
--- a/OpenRA.Game/Widgets/Delegates/IngameChromeDelegate.cs
+++ b/OpenRA.Game/Widgets/Delegates/IngameChromeDelegate.cs
@@ -29,6 +29,7 @@ namespace OpenRA.Widgets.Delegates
var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG");
Game.OnGameStart += () => r.OpenWindow("INGAME_ROOT");
+ Game.OnGameStart += () => gameRoot.GetWidget("GAME_TIMER").Stopwatch.Reset();
r.GetWidget("INGAME_OPTIONS_BUTTON").OnMouseUp = mi => {
optionsBG.Visible = !optionsBG.Visible;
diff --git a/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs b/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs
index d3485c798b..2d618f2838 100644
--- a/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs
+++ b/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs
@@ -149,6 +149,14 @@ namespace OpenRA.Widgets.Delegates
return true;
};
+ var timedebug = debug.GetWidget("GAMETIME_CHECKBOX");
+ timedebug.Checked = () => {return Game.Settings.ShowGameTimer;};
+ timedebug.OnMouseDown = mi =>
+ {
+ Game.Settings.ShowGameTimer ^= true;
+ return true;
+ };
+
bg.GetWidget("BUTTON_CLOSE").OnMouseUp = mi => {
Game.Settings.Save();
Chrome.rootWidget.CloseWindow();
diff --git a/OpenRA.Game/Widgets/TimerWidget.cs b/OpenRA.Game/Widgets/TimerWidget.cs
new file mode 100644
index 0000000000..be0e9849f7
--- /dev/null
+++ b/OpenRA.Game/Widgets/TimerWidget.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Drawing;
+using OpenRA.Support;
+
+namespace OpenRA.Widgets
+{
+ public class TimerWidget : Widget
+ {
+ public Stopwatch Stopwatch;
+
+ public TimerWidget ()
+ {
+ Stopwatch = new Stopwatch();
+ IsVisible = () => Game.Settings.ShowGameTimer;
+ }
+
+ public override void DrawInner (World world)
+ {
+ var s = WorldUtils.FormatTime((int) Stopwatch.ElapsedTime() * 25);
+ var size = Game.chrome.renderer.RegularFont.Measure(s);
+ var padding = 5;
+ WidgetUtils.DrawPanel("dialog4",new Rectangle(RenderBounds.Top - padding, RenderBounds.Left - padding, size.X + 2*padding, size.Y + 2*padding));
+ Game.chrome.renderer.RegularFont.DrawText(s, new float2(RenderBounds.Top, RenderBounds.Left), Color.White);
+ }
+ }
+}
+
diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml
index 54b4c265ab..81e91fb7ee 100644
--- a/mods/cnc/chrome/ingame.yaml
+++ b/mods/cnc/chrome/ingame.yaml
@@ -5,6 +5,10 @@ Container@ROOT:
Delegate:IngameChromeDelegate
Visible:false
Children:
+ Timer@GAME_TIMER:
+ Id:GAME_TIMER
+ X: WINDOW_BOTTOM - 30
+ Y: 10
PostGame@POSTGAME_TEXT:
Id:POSTGAME_TEXT
X:0
diff --git a/mods/cnc/chrome/settings.yaml b/mods/cnc/chrome/settings.yaml
index fd3088507a..68bf61615d 100644
--- a/mods/cnc/chrome/settings.yaml
+++ b/mods/cnc/chrome/settings.yaml
@@ -213,4 +213,11 @@ Container@ROOT:
Y:120
Width:300
Height:20
- Text:Show Spatial Index Debug
\ No newline at end of file
+ Text:Show Spatial Index Debug
+ Checkbox@GAMETIME_CHECKBOX:
+ Id:GAMETIME_CHECKBOX
+ X:0
+ Y:150
+ Width:300
+ Height:20
+ Text:Show Game Time Counter
\ No newline at end of file
diff --git a/mods/ra/chrome/ingame.yaml b/mods/ra/chrome/ingame.yaml
index 7541ac2c1e..9ee0cc1c9b 100644
--- a/mods/ra/chrome/ingame.yaml
+++ b/mods/ra/chrome/ingame.yaml
@@ -5,6 +5,10 @@ Container@ROOT:
Delegate:IngameChromeDelegate
Visible:false
Children:
+ Timer@GAME_TIMER:
+ Id:GAME_TIMER
+ X: WINDOW_BOTTOM - 30
+ Y: 10
PostGame@POSTGAME_TEXT:
Id:POSTGAME_TEXT
X:0
diff --git a/mods/ra/chrome/settings.yaml b/mods/ra/chrome/settings.yaml
index fd3088507a..68bf61615d 100644
--- a/mods/ra/chrome/settings.yaml
+++ b/mods/ra/chrome/settings.yaml
@@ -213,4 +213,11 @@ Container@ROOT:
Y:120
Width:300
Height:20
- Text:Show Spatial Index Debug
\ No newline at end of file
+ Text:Show Spatial Index Debug
+ Checkbox@GAMETIME_CHECKBOX:
+ Id:GAMETIME_CHECKBOX
+ X:0
+ Y:150
+ Width:300
+ Height:20
+ Text:Show Game Time Counter
\ No newline at end of file