Fix the in-game widget hierarchy.

This commit is contained in:
Paul Chote
2014-10-14 16:57:38 +13:00
parent a946fac06b
commit 311a909f18
14 changed files with 309 additions and 275 deletions

View File

@@ -56,7 +56,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Action closeMenu = () =>
{
Ui.CloseWindow();
Ui.Root.RemoveChild(menu);
if (mpe != null)
mpe.Fade(MenuPaletteEffect.EffectType.None);
onExit();
@@ -110,12 +109,16 @@ namespace OpenRA.Mods.RA.Widgets.Logic
resumeButton.IsDisabled = () => resumeDisabled;
resumeButton.OnClick = closeMenu;
// Game info panel
var gameInfoPanel = Game.LoadWidget(world, "GAME_INFO_PANEL", menu, new WidgetArgs()
var panelRoot = widget.GetOrNull("PANEL_ROOT");
if (panelRoot != null)
{
{ "activePanel", activePanel }
});
gameInfoPanel.IsVisible = () => !hideMenu;
var gameInfoPanel = Game.LoadWidget(world, "GAME_INFO_PANEL", panelRoot, new WidgetArgs()
{
{ "activePanel", activePanel }
});
gameInfoPanel.IsVisible = () => !hideMenu;
}
}
}
}

View File

@@ -20,7 +20,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public class OrderButtonsChromeLogic
{
readonly World world;
readonly Widget ingameRoot;
readonly Widget worldRoot;
readonly Widget menuRoot;
bool disableSystemButtons;
Widget currentWidget;
@@ -28,9 +29,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public OrderButtonsChromeLogic(Widget widget, World world)
{
this.world = world;
ingameRoot = Ui.Root.Get("INGAME_ROOT");
var ingameRoot = Ui.Root.Get("INGAME_ROOT");
worldRoot = ingameRoot.Get("WORLD_ROOT");
menuRoot = ingameRoot.Get("MENU_ROOT");
Action removeCurrentWidget = () => Ui.Root.RemoveChild(currentWidget);
Action removeCurrentWidget = () => menuRoot.RemoveChild(currentWidget);
world.GameOver += removeCurrentWidget;
// Order Buttons
@@ -127,7 +130,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var cachedPause = world.PredictedPaused;
if (button.HideIngameUI)
ingameRoot.IsVisible = () => false;
worldRoot.IsVisible = () => false;
if (button.Pause && world.LobbyInfo.IsSinglePlayer)
world.SetPauseState(true);
@@ -136,15 +139,16 @@ namespace OpenRA.Mods.RA.Widgets.Logic
widgetArgs.Add("onExit", () =>
{
if (button.HideIngameUI)
ingameRoot.IsVisible = () => true;
worldRoot.IsVisible = () => true;
if (button.Pause && world.LobbyInfo.IsSinglePlayer)
world.SetPauseState(cachedPause);
menuRoot.RemoveChild(currentWidget);
disableSystemButtons = false;
});
currentWidget = Game.LoadWidget(world, button.MenuContainer, Ui.Root, widgetArgs);
currentWidget = Game.LoadWidget(world, button.MenuContainer, menuRoot, widgetArgs);
}
static void BindOrderButton<T>(World world, ButtonWidget w, string icon)