Predict local pause state to avoid order lag. Fixes #3223.
This commit is contained in:
@@ -109,6 +109,7 @@ namespace OpenRA.Network
|
||||
}
|
||||
|
||||
orderManager.world.Paused = pause;
|
||||
orderManager.world.PredictedPaused = pause;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace OpenRA.Widgets
|
||||
return true;
|
||||
}
|
||||
else if (e.KeyName == Game.Settings.Keys.PauseKey)
|
||||
world.IssueOrder(Order.PauseGame(!world.Paused));
|
||||
world.SetPauseState(!world.Paused);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -177,9 +177,16 @@ namespace OpenRA
|
||||
public event Action<Actor> ActorAdded = _ => { };
|
||||
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 void SetPauseState(bool paused)
|
||||
{
|
||||
IssueOrder(Order.PauseGame(paused));
|
||||
PredictedPaused = paused;
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
if (!Paused && (!IsShellmap || Game.Settings.Game.ShowShellmap))
|
||||
|
||||
@@ -55,11 +55,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
|
||||
public void OptionsClicked()
|
||||
{
|
||||
var cachedPause = world.Paused;
|
||||
var cachedPause = world.PredictedPaused;
|
||||
|
||||
ingameRoot.IsVisible = () => false;
|
||||
if (world.LobbyInfo.IsSinglePlayer)
|
||||
world.IssueOrder(Order.PauseGame(true));
|
||||
world.SetPauseState(true);
|
||||
|
||||
Game.LoadWidget(world, "INGAME_MENU", Ui.Root, new WidgetArgs()
|
||||
{
|
||||
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
{
|
||||
ingameRoot.IsVisible = () => true;
|
||||
if (world.LobbyInfo.IsSinglePlayer)
|
||||
world.IssueOrder(Order.PauseGame(cachedPause));
|
||||
world.SetPauseState(cachedPause);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Scripting
|
||||
return;
|
||||
}
|
||||
|
||||
w.Paused = true;
|
||||
w.SetPauseState(true);
|
||||
|
||||
// Mute world sounds
|
||||
var oldModifier = Sound.SoundVolumeModifier;
|
||||
@@ -51,7 +51,7 @@ namespace OpenRA.Scripting
|
||||
|
||||
Ui.CloseWindow();
|
||||
Sound.SoundVolumeModifier = oldModifier;
|
||||
w.Paused = false;
|
||||
w.SetPauseState(false);
|
||||
onComplete();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
optionsBG.Visible = false;
|
||||
|
||||
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;
|
||||
if (optionsBG.Visible)
|
||||
{
|
||||
cachedPause = world.Paused;
|
||||
cachedPause = world.PredictedPaused;
|
||||
|
||||
if (world.LobbyInfo.IsSinglePlayer)
|
||||
world.IssueOrder(Order.PauseGame(true));
|
||||
world.SetPauseState(true);
|
||||
}
|
||||
else
|
||||
world.IssueOrder(Order.PauseGame(cachedPause));
|
||||
world.SetPauseState(cachedPause);
|
||||
};
|
||||
|
||||
Game.LoadWidget(world, "CHAT_PANEL", gameRoot, new WidgetArgs());
|
||||
|
||||
Reference in New Issue
Block a user