Fixes observer widgets being loaded multiple times at game end.

This commit is contained in:
deniz1a
2015-08-11 12:31:23 +03:00
parent a6dae8e854
commit e59cd78322

View File

@@ -16,6 +16,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
public class LoadIngamePlayerOrObserverUILogic
{
bool loadingObserverWidgets = false;
[ObjectCreator.UseCtor]
public LoadIngamePlayerOrObserverUILogic(Widget widget, World world)
{
@@ -35,12 +37,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
sidebarTicker.OnTick = () =>
{
// Switch to observer mode after win/loss
if (world.LocalPlayer.WinState != WinState.Undefined)
if (world.LocalPlayer.WinState != WinState.Undefined && !loadingObserverWidgets)
{
loadingObserverWidgets = true;
Game.RunAfterDelay(objectives != null ? objectives.Info.GameOverDelay : 0, () =>
{
playerRoot.RemoveChildren();
Game.LoadWidget(world, "OBSERVER_WIDGETS", playerRoot, new WidgetArgs());
});
}
};
}