new PauseState to differentiate game and editor pausing
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -203,8 +203,9 @@ namespace OpenRA
|
||||
public event Action<Actor> ActorAdded = _ => { };
|
||||
public event Action<Actor> 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++;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user