Fix end game window conflicting with ingame menu

Fixes #6311
This commit is contained in:
Oliver Brakmann
2014-08-23 14:49:28 +02:00
parent f0fc63b15d
commit 2f4c81b7c9
5 changed files with 13 additions and 7 deletions

View File

@@ -417,8 +417,11 @@ namespace OpenRA.Widgets
public virtual void RemoveChild(Widget child)
{
Children.Remove(child);
child.Removed();
if (child != null)
{
Children.Remove(child);
child.Removed();
}
}
public virtual void RemoveChildren()

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.D2k.Widgets.Logic
Action ShowLeaveRestartDialog = () =>
{
gameRoot.IsVisible = () => false;
gameRoot.RemoveChildren();
Game.LoadWidget(world, "LEAVE_RESTART_WIDGET", Ui.Root, new WidgetArgs());
};
world.GameOver += ShowLeaveRestartDialog;

View File

@@ -32,9 +32,8 @@ namespace OpenRA.Mods.RA.Widgets
panelName = "LEAVE_RESTART_FULL";
var dialog = widget.Get<ContainerWidget>(panelName);
var fmvPlayer = Ui.Root.GetOrNull<BackgroundWidget>("FMVPLAYER");
dialog.IsVisible = () => true;
widget.IsVisible = () => fmvPlayer == null || fmvPlayer != Ui.CurrentWindow();
widget.IsVisible = () => Ui.CurrentWindow() == null;
var leaveButton = dialog.Get<ButtonWidget>("LEAVE_BUTTON");
leaveButton.OnClick = () =>

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Action ShowLeaveRestartDialog = () =>
{
ingameRoot.IsVisible = () => false;
ingameRoot.RemoveChildren();
Game.LoadWidget(world, "LEAVE_RESTART_WIDGET", Ui.Root, new WidgetArgs());
};
world.GameOver += ShowLeaveRestartDialog;

View File

@@ -21,6 +21,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
readonly World world;
readonly Widget ingameRoot;
bool disableSystemButtons;
Widget currentWidget;
[ObjectCreator.UseCtor]
public OrderButtonsChromeLogic(Widget widget, World world)
@@ -28,6 +29,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
this.world = world;
ingameRoot = Ui.Root.Get("INGAME_ROOT");
Action removeCurrentWidget = () => Ui.Root.RemoveChild(currentWidget);
world.GameOver += removeCurrentWidget;
// Order Buttons
var sell = widget.GetOrNull<ButtonWidget>("SELL_BUTTON");
if (sell != null)
@@ -139,7 +143,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
disableSystemButtons = false;
});
Game.LoadWidget(world, button.MenuContainer, Ui.Root, widgetArgs);
currentWidget = Game.LoadWidget(world, button.MenuContainer, Ui.Root, widgetArgs);
}
static void BindOrderButton<T>(World world, ButtonWidget w, string icon)