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();