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

@@ -25,7 +25,9 @@ namespace OpenRA.Mods.D2k.Widgets.Logic
{
public class IngameChromeLogic
{
readonly Widget gameRoot;
readonly Widget ingameRoot;
readonly Widget worldRoot;
readonly Widget menuRoot;
readonly Widget playerRoot;
readonly World world;
@@ -33,8 +35,10 @@ namespace OpenRA.Mods.D2k.Widgets.Logic
public IngameChromeLogic(World world)
{
this.world = world;
gameRoot = Ui.Root.Get("INGAME_ROOT");
playerRoot = gameRoot.Get("PLAYER_ROOT");
ingameRoot = Ui.Root.Get("INGAME_ROOT");
worldRoot = ingameRoot.Get("WORLD_ROOT");
menuRoot = ingameRoot.Get("MENU_ROOT");
playerRoot = worldRoot.Get("PLAYER_ROOT");
InitRootWidgets();
if (world.LocalPlayer == null)
@@ -45,14 +49,14 @@ namespace OpenRA.Mods.D2k.Widgets.Logic
void InitRootWidgets()
{
Game.LoadWidget(world, "CHAT_PANEL", gameRoot, new WidgetArgs());
Game.LoadWidget(world, "CHAT_PANEL", worldRoot, new WidgetArgs());
Action ShowLeaveMapWidget = () =>
world.GameOver += () =>
{
gameRoot.RemoveChildren();
Game.LoadWidget(world, "LEAVE_MAP_WIDGET", Ui.Root, new WidgetArgs());
worldRoot.RemoveChildren();
menuRoot.RemoveChildren();
Game.LoadWidget(world, "LEAVE_MAP_WIDGET", menuRoot, new WidgetArgs());
};
world.GameOver += ShowLeaveMapWidget;
}
void InitObserverWidgets()