Fixes observer widgets being loaded multiple times at game end.
This commit is contained in:
@@ -16,6 +16,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{
|
{
|
||||||
public class LoadIngamePlayerOrObserverUILogic
|
public class LoadIngamePlayerOrObserverUILogic
|
||||||
{
|
{
|
||||||
|
bool loadingObserverWidgets = false;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public LoadIngamePlayerOrObserverUILogic(Widget widget, World world)
|
public LoadIngamePlayerOrObserverUILogic(Widget widget, World world)
|
||||||
{
|
{
|
||||||
@@ -35,12 +37,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
sidebarTicker.OnTick = () =>
|
sidebarTicker.OnTick = () =>
|
||||||
{
|
{
|
||||||
// Switch to observer mode after win/loss
|
// 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, () =>
|
Game.RunAfterDelay(objectives != null ? objectives.Info.GameOverDelay : 0, () =>
|
||||||
{
|
{
|
||||||
playerRoot.RemoveChildren();
|
playerRoot.RemoveChildren();
|
||||||
Game.LoadWidget(world, "OBSERVER_WIDGETS", playerRoot, new WidgetArgs());
|
Game.LoadWidget(world, "OBSERVER_WIDGETS", playerRoot, new WidgetArgs());
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user