rename Ui.RootWidget to just Ui.Root

This commit is contained in:
Chris Forbes
2011-12-13 23:46:58 +13:00
parent 58f6816d84
commit bf5be88c75
30 changed files with 47 additions and 46 deletions

View File

@@ -127,7 +127,7 @@ namespace OpenRA.Graphics
using( new PerfSample("render_widgets") )
{
Ui.Draw();
var cursorName = Ui.RootWidget.GetCursorOuter(Viewport.LastMousePos) ?? "default";
var cursorName = Ui.Root.GetCursorOuter(Viewport.LastMousePos) ?? "default";
var cursorSequence = CursorProvider.GetCursorSequence(cursorName);
var cursorSprite = cursorSequence.GetSprite((int)cursorFrame);

View File

@@ -57,8 +57,8 @@ namespace OpenRA.Widgets
if (panel == null)
return;
Ui.RootWidget.RemoveChild(fullscreenMask);
Ui.RootWidget.RemoveChild(panel);
Ui.Root.RemoveChild(fullscreenMask);
Ui.Root.RemoveChild(panel);
panel = fullscreenMask = null;
}
@@ -72,11 +72,11 @@ namespace OpenRA.Widgets
fullscreenMask = new MaskWidget();
fullscreenMask.Bounds = new Rectangle(0, 0, Game.viewport.Width, Game.viewport.Height);
fullscreenMask.OnMouseDown = mi => RemovePanel();
Ui.RootWidget.AddChild(fullscreenMask);
Ui.Root.AddChild(fullscreenMask);
var oldBounds = panel.Bounds;
panel.Bounds = new Rectangle(RenderOrigin.X, RenderOrigin.Y + Bounds.Height, oldBounds.Width, oldBounds.Height);
Ui.RootWidget.AddChild(panel);
Ui.Root.AddChild(panel);
}
public void ShowDropDown<T>(string panelTemplate, int height, IEnumerable<T> options, Func<T, ScrollItemWidget, ScrollItemWidget> setupItem)

View File

@@ -19,18 +19,19 @@ namespace OpenRA.Widgets
{
public static class Ui
{
public static Widget RootWidget = new ContainerWidget();
public static Widget Root = new ContainerWidget();
static Stack<Widget> WindowList = new Stack<Widget>();
public static Widget SelectedWidget;
public static Widget MouseOverWidget;
public static void CloseWindow()
{
if (WindowList.Count > 0)
RootWidget.RemoveChild(WindowList.Pop());
Root.RemoveChild(WindowList.Pop());
if (WindowList.Count > 0)
RootWidget.AddChild(WindowList.Peek());
Root.AddChild(WindowList.Peek());
}
public static Widget OpenWindow(string id)
@@ -40,9 +41,9 @@ namespace OpenRA.Widgets
public static Widget OpenWindow(string id, WidgetArgs args)
{
var window = Game.modData.WidgetLoader.LoadWidget(args, RootWidget, id);
var window = Game.modData.WidgetLoader.LoadWidget(args, Root, id);
if (WindowList.Count > 0)
RootWidget.RemoveChild(WindowList.Peek());
Root.RemoveChild(WindowList.Peek());
WindowList.Push(window);
return window;
}
@@ -52,9 +53,9 @@ namespace OpenRA.Widgets
return Game.modData.WidgetLoader.LoadWidget(args, parent, id);
}
public static void Tick() { RootWidget.TickOuter(); }
public static void Tick() { Root.TickOuter(); }
public static void Draw() { RootWidget.DrawOuter(); }
public static void Draw() { Root.DrawOuter(); }
public static bool HandleInput(MouseInput mi)
{
@@ -67,7 +68,7 @@ namespace OpenRA.Widgets
if (SelectedWidget != null && SelectedWidget.HandleMouseInputOuter(mi))
handled = true;
if (!handled && RootWidget.HandleMouseInputOuter(mi))
if (!handled && Root.HandleMouseInputOuter(mi))
handled = true;
if (mi.Event == MouseInputEvent.Move)
@@ -93,14 +94,14 @@ namespace OpenRA.Widgets
if (SelectedWidget != null)
return SelectedWidget.HandleKeyPressOuter(e);
if (RootWidget.HandleKeyPressOuter(e))
if (Root.HandleKeyPressOuter(e))
return true;
return false;
}
public static void ResetAll()
{
RootWidget.RemoveChildren();
Root.RemoveChildren();
while (WindowList.Count > 0)
CloseWindow();

View File

@@ -131,7 +131,7 @@ namespace OpenRA.Mods.Cnc
{ "continueLoading", () => TestAndContinue() },
{ "installData", Info }
};
Ui.LoadWidget(Info["InstallerBackgroundWidget"], Ui.RootWidget, args);
Ui.LoadWidget(Info["InstallerBackgroundWidget"], Ui.Root, args);
Ui.OpenWindow(Info["InstallerMenuWidget"], args);
}
else

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Cnc.Widgets
this.world = world;
tabsWidget = Lazy.New(() =>
Ui.RootWidget.GetWidget<ProductionTabsWidget>(info.ProductionTabsWidget));
Ui.Root.GetWidget<ProductionTabsWidget>(info.ProductionTabsWidget));
}
public void SelectionChanged()

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Cnc.Widgets
: base(world, worldRenderer)
{
tooltipContainer = Lazy.New(() =>
Ui.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
Ui.Root.GetWidget<TooltipContainerWidget>(TooltipContainer));
}
public override void MouseEntered()

View File

@@ -91,7 +91,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
}
ingameRoot.IsVisible = () => false;
Game.LoadWidget(world, "INGAME_MENU", Ui.RootWidget, new WidgetArgs()
Game.LoadWidget(world, "INGAME_MENU", Ui.Root, new WidgetArgs()
{
{ "onExit", () => ingameRoot.IsVisible = () => true }
});

View File

@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
resumeButton.OnClick = () =>
{
Ui.CloseWindow();
Ui.RootWidget.RemoveChild(menu);
Ui.Root.RemoveChild(menu);
world.WorldActor.Trait<CncMenuPaletteEffect>().Fade(CncMenuPaletteEffect.EffectType.None);
onExit();
};

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Cnc.Widgets
{
pm = world.LocalPlayer.PlayerActor.Trait<PowerManager>();
tooltipContainer = Lazy.New(() =>
Ui.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
Ui.Root.GetWidget<TooltipContainerWidget>(TooltipContainer));
}
public override void MouseEntered()

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Cnc.Widgets
this.world = world;
this.worldRenderer = worldRenderer;
tooltipContainer = Lazy.New(() =>
Ui.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
Ui.Root.GetWidget<TooltipContainerWidget>(TooltipContainer));
cantBuild = new Animation("clock");
cantBuild.PlayFetchIndex("idle", () => 0);

View File

@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Cnc.Widgets
// Only visible if the production palette has icons to display
IsVisible = () => queueGroup != null && Groups[queueGroup].Tabs.Count > 0;
paletteWidget = Lazy.New(() => Ui.RootWidget.GetWidget<ProductionPaletteWidget>(PaletteWidget));
paletteWidget = Lazy.New(() => Ui.Root.GetWidget<ProductionPaletteWidget>(PaletteWidget));
}
public void SelectNextTab(bool reverse)

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Cnc.Widgets
{
pr = world.LocalPlayer.PlayerActor.Trait<PlayerResources>();
tooltipContainer = Lazy.New(() =>
Ui.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
Ui.Root.GetWidget<TooltipContainerWidget>(TooltipContainer));
}
public override void MouseEntered()

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Cnc.Widgets
this.worldRenderer = worldRenderer;
spm = world.LocalPlayer.PlayerActor.Trait<SupportPowerManager>();
tooltipContainer = Lazy.New(() =>
Ui.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
Ui.Root.GetWidget<TooltipContainerWidget>(TooltipContainer));
iconSprites = Rules.Info.Values.SelectMany( u => u.Traits.WithInterface<SupportPowerInfo>() )
.Select(u => u.Image).Distinct()

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Cnc.Widgets
: base()
{
tooltipContainer = Lazy.New(() =>
Ui.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
Ui.Root.GetWidget<TooltipContainerWidget>(TooltipContainer));
}
protected ToggleButtonWidget(ToggleButtonWidget other)
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Cnc.Widgets
TooltipText = other.TooltipText;
TooltipContainer = other.TooltipContainer;
tooltipContainer = Lazy.New(() =>
Ui.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
Ui.Root.GetWidget<TooltipContainerWidget>(TooltipContainer));
}
public override void MouseEntered()

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA
public void StartGame()
{
Ui.ResetAll();
Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Ui.RootWidget, "INIT_SETUP" );
Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Ui.Root, "INIT_SETUP" );
}
}
}

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA
public class LoadWidgetAtGameStartInfo : ITraitInfo
{
public readonly string Widget = null;
public readonly bool ClearRootWidget = true;
public readonly bool ClearRoot = true;
public object Create(ActorInitializer init) { return new LoadWidgetAtGameStart(this); }
}
@@ -62,10 +62,10 @@ namespace OpenRA.Mods.RA
public void WorldLoaded(World world)
{
// Clear any existing widget state
if (Info.ClearRootWidget)
if (Info.ClearRoot)
Ui.ResetAll();
Game.LoadWidget(world, Info.Widget, Ui.RootWidget, new WidgetArgs());
Game.LoadWidget(world, Info.Widget, Ui.Root, new WidgetArgs());
}
}
}

View File

@@ -20,8 +20,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
[ObjectCreator.UseCtor]
public DeveloperModeLogic(World world)
{
var devmodeBG = Ui.RootWidget.GetWidget("INGAME_ROOT").GetWidget("DEVELOPERMODE_BG");
var devModeButton = Ui.RootWidget.GetWidget<ButtonWidget>("INGAME_DEVELOPERMODE_BUTTON");
var devmodeBG = Ui.Root.GetWidget("INGAME_ROOT").GetWidget("DEVELOPERMODE_BG");
var devModeButton = Ui.Root.GetWidget<ButtonWidget>("INGAME_DEVELOPERMODE_BUTTON");
devModeButton.OnClick = () => devmodeBG.Visible ^= true;
var devTrait = world.LocalPlayer.PlayerActor.Trait<DeveloperMode>();

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public DiplomacyLogic(World world)
{
this.world = world;
var root = Ui.RootWidget.GetWidget("INGAME_ROOT");
var root = Ui.Root.GetWidget("INGAME_ROOT");
var diplomacyBG = root.GetWidget("DIPLOMACY_BG");
var diplomacy = root.GetWidget<ButtonWidget>("INGAME_DIPLOMACY_BUTTON");

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.AddChatLine += AddChatLine;
Game.BeforeGameStart += UnregisterEvents;
var r = Ui.RootWidget;
var r = Ui.Root;
gameRoot = r.GetWidget("INGAME_ROOT");
var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG");

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.AddChatLine += AddChatLine;
Game.BeforeGameStart += UnregisterEvents;
var r = Ui.RootWidget;
var r = Ui.Root;
gameRoot = r.GetWidget("OBSERVER_ROOT");
var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG");

View File

@@ -247,7 +247,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
MapUid = orderManager.LobbyInfo.GlobalSettings.Map;
Map = new Map(Game.modData.AvailableMaps[MapUid].Path);
var title = Ui.RootWidget.GetWidget<LabelWidget>("TITLE");
var title = Ui.Root.GetWidget<LabelWidget>("TITLE");
title.Text = orderManager.LobbyInfo.GlobalSettings.ServerName;
}

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
rootMenu = widget;
Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Ui.RootWidget, "PERF_BG" );
Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Ui.Root, "PERF_BG" );
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_JOIN").OnClick = () => OpenGamePanel("JOINSERVER_BG");
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_CREATE").OnClick = () => OpenGamePanel("CREATESERVER_BG");
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_DIRECTCONNECT").OnClick = () => OpenGamePanel("DIRECTCONNECT_BG");

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public MusicPlayerLogic()
{
bg = Ui.RootWidget.GetWidget("MUSIC_MENU");
bg = Ui.Root.GetWidget("MUSIC_MENU");
CurrentSong = GetNextSong();
bg.GetWidget( "BUTTON_PAUSE" ).IsVisible = () => Sound.MusicPlaying;

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public OrderButtonsChromeLogic(World world)
{
/* todo: attach this to the correct widget, to remove the lookups below */
var r = Ui.RootWidget;
var r = Ui.Root;
var gameRoot = r.GetWidget("INGAME_ROOT");
var moneybin = gameRoot.GetWidget("INGAME_MONEY_BIN");

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
public PerfDebugLogic()
{
var r = Ui.RootWidget;
var r = Ui.Root;
var perfRoot = r.GetWidget("PERF_BG");
perfRoot.IsVisible = () => perfRoot.Visible && Game.Settings.Debug.PerfGraph;

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public SettingsMenuLogic()
{
bg = Ui.RootWidget.GetWidget<BackgroundWidget>("SETTINGS_MENU");
bg = Ui.Root.GetWidget<BackgroundWidget>("SETTINGS_MENU");
var tabs = bg.GetWidget<ContainerWidget>("TAB_CONTAINER");
//Tabs

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.RA.Widgets
if( world.LocalPlayer == null ) return;
if( world.LocalPlayer.WinState != WinState.Undefined ) return;
var radarBin = Ui.RootWidget.GetWidget<RadarBinWidget>(RadarBin);
var radarBin = Ui.Root.GetWidget<RadarBinWidget>(RadarBin);
powerCollection = "power-" + world.LocalPlayer.Country.Race;

View File

@@ -113,7 +113,7 @@ namespace OpenRA.Mods.RA.Widgets
if (WorldInteractionController != null)
{
var controller = Ui.RootWidget.GetWidget<WorldInteractionControllerWidget>(WorldInteractionController);
var controller = Ui.Root.GetWidget<WorldInteractionControllerWidget>(WorldInteractionController);
controller.HandleMouseInput(fakemi);
fakemi.Event = MouseInputEvent.Up;
controller.HandleMouseInput(fakemi);

View File

@@ -110,7 +110,7 @@ namespace OpenRA.Mods.RA.Widgets
if (WorldInteractionController != null)
{
var controller = Ui.RootWidget.GetWidget<WorldInteractionControllerWidget>(WorldInteractionController);
var controller = Ui.Root.GetWidget<WorldInteractionControllerWidget>(WorldInteractionController);
controller.HandleMouseInput(fakemi);
fakemi.Event = MouseInputEvent.Up;
controller.HandleMouseInput(fakemi);

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA
public void SelectionChanged()
{
var palette = Ui.RootWidget.GetWidget<BuildPaletteWidget>("INGAME_BUILD_PALETTE");
var palette = Ui.Root.GetWidget<BuildPaletteWidget>("INGAME_BUILD_PALETTE");
if (palette == null)
return;