Merge pull request #3238 from pchote/local-pause-state

Remove local pause order lag delay
This commit is contained in:
Matthias Mailänder
2013-05-10 03:07:08 -07:00
6 changed files with 19 additions and 11 deletions

View File

@@ -109,6 +109,7 @@ namespace OpenRA.Network
} }
orderManager.world.Paused = pause; orderManager.world.Paused = pause;
orderManager.world.PredictedPaused = pause;
} }
break; break;
} }

View File

@@ -175,7 +175,7 @@ namespace OpenRA.Widgets
return true; return true;
} }
else if (e.KeyName == Game.Settings.Keys.PauseKey) else if (e.KeyName == Game.Settings.Keys.PauseKey)
world.IssueOrder(Order.PauseGame(!world.Paused)); world.SetPauseState(!world.Paused);
} }
return false; return false;
} }

View File

@@ -177,9 +177,16 @@ namespace OpenRA
public event Action<Actor> ActorAdded = _ => { }; public event Action<Actor> ActorAdded = _ => { };
public event Action<Actor> ActorRemoved = _ => { }; public event Action<Actor> ActorRemoved = _ => { };
public bool Paused = false; public bool Paused { get; internal set; }
public bool PredictedPaused { get; internal set; }
public bool IsShellmap = false; public bool IsShellmap = false;
public void SetPauseState(bool paused)
{
IssueOrder(Order.PauseGame(paused));
PredictedPaused = paused;
}
public void Tick() public void Tick()
{ {
if (!Paused && (!IsShellmap || Game.Settings.Game.ShowShellmap)) if (!Paused && (!IsShellmap || Game.Settings.Game.ShowShellmap))

View File

@@ -55,11 +55,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
public void OptionsClicked() public void OptionsClicked()
{ {
var cachedPause = world.Paused; var cachedPause = world.PredictedPaused;
ingameRoot.IsVisible = () => false; ingameRoot.IsVisible = () => false;
if (world.LobbyInfo.IsSinglePlayer) if (world.LobbyInfo.IsSinglePlayer)
world.IssueOrder(Order.PauseGame(true)); world.SetPauseState(true);
Game.LoadWidget(world, "INGAME_MENU", Ui.Root, new WidgetArgs() Game.LoadWidget(world, "INGAME_MENU", Ui.Root, new WidgetArgs()
{ {
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{ {
ingameRoot.IsVisible = () => true; ingameRoot.IsVisible = () => true;
if (world.LobbyInfo.IsSinglePlayer) if (world.LobbyInfo.IsSinglePlayer)
world.IssueOrder(Order.PauseGame(cachedPause)); world.SetPauseState(cachedPause);
} }
} }
}); });

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Scripting
return; return;
} }
w.Paused = true; w.SetPauseState(true);
// Mute world sounds // Mute world sounds
var oldModifier = Sound.SoundVolumeModifier; var oldModifier = Sound.SoundVolumeModifier;
@@ -51,7 +51,7 @@ namespace OpenRA.Scripting
Ui.CloseWindow(); Ui.CloseWindow();
Sound.SoundVolumeModifier = oldModifier; Sound.SoundVolumeModifier = oldModifier;
w.Paused = false; w.SetPauseState(false);
onComplete(); onComplete();
}); });
} }

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
optionsBG.Visible = false; optionsBG.Visible = false;
if (world.LobbyInfo.IsSinglePlayer) if (world.LobbyInfo.IsSinglePlayer)
world.IssueOrder(Order.PauseGame(cachedPause)); world.SetPauseState(cachedPause);
} }
} }
}); });
@@ -57,13 +57,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
optionsBG.Visible ^= true; optionsBG.Visible ^= true;
if (optionsBG.Visible) if (optionsBG.Visible)
{ {
cachedPause = world.Paused; cachedPause = world.PredictedPaused;
if (world.LobbyInfo.IsSinglePlayer) if (world.LobbyInfo.IsSinglePlayer)
world.IssueOrder(Order.PauseGame(true)); world.SetPauseState(true);
} }
else else
world.IssueOrder(Order.PauseGame(cachedPause)); world.SetPauseState(cachedPause);
}; };
Game.LoadWidget(world, "CHAT_PANEL", gameRoot, new WidgetArgs()); Game.LoadWidget(world, "CHAT_PANEL", gameRoot, new WidgetArgs());