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.Paused = pause;
|
||||||
|
orderManager.world.PredictedPaused = pause;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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))
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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());
|
||||||
|
|||||||
Reference in New Issue
Block a user