diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index c32870654a..b8aa4b690d 100644 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * 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, @@ -102,15 +102,15 @@ namespace OpenRA.Network var client = orderManager.LobbyInfo.ClientWithIndex(clientId); if (client != null) { - var pause = order.TargetString == "Pause"; - if (orderManager.world.Paused != pause && !world.LobbyInfo.IsSinglePlayer) + var pauseState = order.TargetString == "Pause" ? World.PauseState.Paused : World.PauseState.Active; + if (orderManager.world.Paused != pauseState && !world.LobbyInfo.IsSinglePlayer) { - var pausetext = "The game is {0} by {1}".F(pause ? "paused" : "un-paused", client.Name); + var pausetext = "The game is {0} by {1}.".F(pauseState == World.PauseState.Paused ? "paused" : "un-paused", client.Name); Game.AddChatLine(Color.White, "", pausetext); } - orderManager.world.Paused = pause; - orderManager.world.PredictedPaused = pause; + orderManager.world.Paused = pauseState; + orderManager.world.PredictedPaused = pauseState; } break; } diff --git a/OpenRA.Game/Traits/DebugPauseState.cs b/OpenRA.Game/Traits/DebugPauseState.cs index d7ec732273..bbaff35512 100644 --- a/OpenRA.Game/Traits/DebugPauseState.cs +++ b/OpenRA.Game/Traits/DebugPauseState.cs @@ -18,7 +18,7 @@ namespace OpenRA.Traits public class DebugPauseState : ISync { World world; - [Sync] public bool Paused { get { return world.Paused; } } + [Sync] public bool Paused { get { return world.Paused == World.PauseState.Paused; } } public DebugPauseState(World world) { this.world = world; } } } diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index f798ea70da..7dc0ac36ae 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -199,7 +199,7 @@ namespace OpenRA.Widgets var key = Hotkey.FromKeyInput(e); if (key == Game.Settings.Keys.PauseKey && World.LocalPlayer != null) // Disable pausing for spectators - World.SetPauseState(!World.Paused); + World.SetPauseState(World.Paused != World.PauseState.Paused); else if (key == Game.Settings.Keys.SelectAllUnitsKey) { var ownUnitsOnScreen = SelectActorsInBox(World, worldRenderer.Viewport.TopLeft, worldRenderer.Viewport.BottomRight, diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 6d1aa45475..0d91c947b9 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -203,8 +203,9 @@ namespace OpenRA public event Action ActorAdded = _ => { }; public event Action ActorRemoved = _ => { }; - public bool Paused { get; internal set; } - public bool PredictedPaused { get; internal set; } + public enum PauseState { Active, Paused, Editor } + public PauseState Paused { get; internal set; } + public PauseState PredictedPaused { get; internal set; } public bool PauseStateLocked { get; set; } public bool IsShellmap = false; public int WorldTick { get; private set; } @@ -215,17 +216,17 @@ namespace OpenRA return; IssueOrder(Order.PauseGame(paused)); - PredictedPaused = paused; + PredictedPaused = paused ? PauseState.Paused : PauseState.Active;; } - public void SetLocalPauseState(bool paused) + public void SetLocalPauseState(PauseState paused) { Paused = PredictedPaused = paused; } public void Tick() { - if (!Paused && (!IsShellmap || Game.Settings.Game.ShowShellmap)) + if (Paused != PauseState.Paused && (!IsShellmap || Game.Settings.Game.ShowShellmap)) { WorldTick++; diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs index d4c03a05d1..77dbdb11d3 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs @@ -41,7 +41,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic public void OptionsClicked() { - var cachedPause = world.PredictedPaused; + var cachedPause = world.PredictedPaused == World.PauseState.Paused; ingameRoot.IsVisible = () => false; if (world.LobbyInfo.IsSinglePlayer) diff --git a/OpenRA.Mods.RA/Console/PlayerCommands.cs b/OpenRA.Mods.RA/Console/PlayerCommands.cs index fd88f94912..4e19552236 100644 --- a/OpenRA.Mods.RA/Console/PlayerCommands.cs +++ b/OpenRA.Mods.RA/Console/PlayerCommands.cs @@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA { case "pause": world.IssueOrder(new Order("PauseGame", null, false) - { TargetString = world.Paused ? "UnPause" : "Pause" }); + { TargetString = world.Paused == World.PauseState.Paused ? "UnPause" : "Pause" }); break; case "surrender": world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false)); diff --git a/OpenRA.Mods.RA/Widgets/Logic/GameTimerLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/GameTimerLogic.cs index 8233b9eda7..c637d3e588 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/GameTimerLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/GameTimerLogic.cs @@ -27,12 +27,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic { var startTick = Ui.LastTickTime; // Blink the status line - status.IsVisible = () => (world.Paused || world.Timestep != Game.Timestep) + status.IsVisible = () => (world.Paused == World.PauseState.Paused || world.Timestep != Game.Timestep) && (Ui.LastTickTime - startTick) / 1000 % 2 == 0; status.GetText = () => { - if (world.Paused || world.Timestep == 0) + if (world.Paused == World.PauseState.Paused || world.Timestep == 0) return "Paused"; if (world.Timestep == 1) diff --git a/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs index 5bae5362b1..d356cb5e17 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs @@ -57,7 +57,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic optionsBG.Visible ^= true; if (optionsBG.Visible) { - cachedPause = world.PredictedPaused; + cachedPause = world.PredictedPaused == World.PauseState.Paused; if (world.LobbyInfo.IsSinglePlayer) world.SetPauseState(true);