split Widget static bits into Ui static class

This commit is contained in:
Chris Forbes
2011-12-13 23:38:59 +13:00
parent 83055f0a17
commit ed429a3b30
60 changed files with 173 additions and 168 deletions

View File

@@ -95,14 +95,14 @@ namespace OpenRA
// Hacky workaround for orderManager visibility // Hacky workaround for orderManager visibility
public static Widget OpenWindow(World world, string widget) public static Widget OpenWindow(World world, string widget)
{ {
return Widget.OpenWindow(widget, new WidgetArgs() {{ "world", world }, { "orderManager", orderManager }, { "worldRenderer", worldRenderer }}); return Ui.OpenWindow(widget, new WidgetArgs() {{ "world", world }, { "orderManager", orderManager }, { "worldRenderer", worldRenderer }});
} }
// Who came up with the great idea of making these things // Who came up with the great idea of making these things
// impossible for the things that want them to access them directly? // impossible for the things that want them to access them directly?
public static Widget OpenWindow(string widget, WidgetArgs args) public static Widget OpenWindow(string widget, WidgetArgs args)
{ {
return Widget.OpenWindow(widget, new WidgetArgs(args) return Ui.OpenWindow(widget, new WidgetArgs(args)
{ {
{ "world", worldRenderer.world }, { "world", worldRenderer.world },
{ "orderManager", orderManager }, { "orderManager", orderManager },
@@ -160,7 +160,7 @@ namespace OpenRA
using( new PerfSample( "tick_time" ) ) using( new PerfSample( "tick_time" ) )
{ {
orderManager.LastTickTime += Settings.Game.Timestep; orderManager.LastTickTime += Settings.Game.Timestep;
Widget.DoTick(); Ui.DoTick();
var world = orderManager.world; var world = orderManager.world;
if (orderManager.GameStarted) if (orderManager.GameStarted)
++Viewport.TicksSinceLastMove; ++Viewport.TicksSinceLastMove;
@@ -215,7 +215,7 @@ namespace OpenRA
worldRenderer = new WorldRenderer(orderManager.world); worldRenderer = new WorldRenderer(orderManager.world);
if (orderManager.GameStarted) return; if (orderManager.GameStarted) return;
Widget.SelectedWidget = null; Ui.SelectedWidget = null;
orderManager.LocalFrameNumber = 0; orderManager.LocalFrameNumber = 0;
orderManager.LastTickTime = Environment.TickCount; orderManager.LastTickTime = Environment.TickCount;
@@ -270,7 +270,7 @@ namespace OpenRA
AddChatLine = (a,b,c) => {}; AddChatLine = (a,b,c) => {};
ConnectionStateChanged = om => {}; ConnectionStateChanged = om => {};
BeforeGameStart = () => {}; BeforeGameStart = () => {};
Widget.ResetAll(); Ui.ResetAll();
worldRenderer = null; worldRenderer = null;
if (server != null) if (server != null)

View File

@@ -126,15 +126,15 @@ namespace OpenRA.Graphics
using( new PerfSample("render_widgets") ) using( new PerfSample("render_widgets") )
{ {
Widget.DoDraw(); Ui.DoDraw();
var cursorName = Widget.RootWidget.GetCursorOuter(Viewport.LastMousePos) ?? "default"; var cursorName = Ui.RootWidget.GetCursorOuter(Viewport.LastMousePos) ?? "default";
var cursorSequence = CursorProvider.GetCursorSequence(cursorName); var cursorSequence = CursorProvider.GetCursorSequence(cursorName);
var cursorSprite = cursorSequence.GetSprite((int)cursorFrame); var cursorSprite = cursorSequence.GetSprite((int)cursorFrame);
renderer.SpriteRenderer.DrawSprite(cursorSprite, renderer.SpriteRenderer.DrawSprite(cursorSprite,
Viewport.LastMousePos - cursorSequence.Hotspot, Viewport.LastMousePos - cursorSequence.Hotspot,
Game.modData.Palette.GetPaletteIndex(cursorSequence.Palette), Game.modData.Palette.GetPaletteIndex(cursorSequence.Palette),
cursorSprite.size); cursorSprite.size);
} }
using( new PerfSample("render_flip") ) using( new PerfSample("render_flip") )
@@ -194,7 +194,7 @@ namespace OpenRA.Graphics
{ {
if (cachedScroll != scrollPosition) if (cachedScroll != scrollPosition)
{ {
int2 boundary = new int2(1,1); // Add a curtain of cells around the viewport to account for rounding errors var boundary = new int2(1,1); // Add a curtain of cells around the viewport to account for rounding errors
var tl = ViewToWorld(int2.Zero).ToInt2() - boundary; var tl = ViewToWorld(int2.Zero).ToInt2() - boundary;
var br = ViewToWorld(new int2(Width, Height)).ToInt2() + boundary; var br = ViewToWorld(new int2(Width, Height)).ToInt2() + boundary;

View File

@@ -35,18 +35,12 @@ namespace OpenRA
public void OnKeyInput( KeyInput input ) public void OnKeyInput( KeyInput input )
{ {
Sync.CheckSyncUnchanged( world, () => Sync.CheckSyncUnchanged(world, () => Ui.DoHandleKeyPress(input));
{
Widget.DoHandleKeyPress( input );
} );
} }
public void OnMouseInput( MouseInput input ) public void OnMouseInput( MouseInput input )
{ {
Sync.CheckSyncUnchanged( world, () => Sync.CheckSyncUnchanged(world, () => Ui.DoHandleInput(input));
{
Widget.DoHandleInput( input );
} );
} }
} }
} }

View File

@@ -128,7 +128,7 @@ namespace OpenRA.Widgets
var s = font.Measure(text); var s = font.Measure(text);
var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0); var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0);
DrawBackground(rb, disabled, Depressed, Widget.MouseOverWidget == this); DrawBackground(rb, disabled, Depressed, Ui.MouseOverWidget == this);
font.DrawText(text, new int2(rb.X + (UsableWidth - s.X)/ 2, rb.Y + (Bounds.Height - s.Y) / 2) + stateOffset, font.DrawText(text, new int2(rb.X + (UsableWidth - s.X)/ 2, rb.Y + (Bounds.Height - s.Y) / 2) + stateOffset,
disabled ? Color.Gray : Color.White); disabled ? Color.Gray : Color.White);
} }

View File

@@ -49,7 +49,7 @@ namespace OpenRA.Widgets
var check = new Rectangle(rect.Location, new Size(Bounds.Height, Bounds.Height)); var check = new Rectangle(rect.Location, new Size(Bounds.Height, Bounds.Height));
var state = disabled ? "checkbox-disabled" : var state = disabled ? "checkbox-disabled" :
Depressed && HasPressedState ? "checkbox-pressed" : Depressed && HasPressedState ? "checkbox-pressed" :
Widget.MouseOverWidget == this ? "checkbox-hover" : Ui.MouseOverWidget == this ? "checkbox-hover" :
"checkbox"; "checkbox";
WidgetUtils.DrawPanel(state, check); WidgetUtils.DrawPanel(state, check);

View File

@@ -57,8 +57,8 @@ namespace OpenRA.Widgets
if (panel == null) if (panel == null)
return; return;
Widget.RootWidget.RemoveChild(fullscreenMask); Ui.RootWidget.RemoveChild(fullscreenMask);
Widget.RootWidget.RemoveChild(panel); Ui.RootWidget.RemoveChild(panel);
panel = fullscreenMask = null; panel = fullscreenMask = null;
} }
@@ -72,17 +72,17 @@ namespace OpenRA.Widgets
fullscreenMask = new MaskWidget(); fullscreenMask = new MaskWidget();
fullscreenMask.Bounds = new Rectangle(0, 0, Game.viewport.Width, Game.viewport.Height); fullscreenMask.Bounds = new Rectangle(0, 0, Game.viewport.Width, Game.viewport.Height);
fullscreenMask.OnMouseDown = mi => RemovePanel(); fullscreenMask.OnMouseDown = mi => RemovePanel();
Widget.RootWidget.AddChild(fullscreenMask); Ui.RootWidget.AddChild(fullscreenMask);
var oldBounds = panel.Bounds; var oldBounds = panel.Bounds;
panel.Bounds = new Rectangle(RenderOrigin.X, RenderOrigin.Y + Bounds.Height, oldBounds.Width, oldBounds.Height); panel.Bounds = new Rectangle(RenderOrigin.X, RenderOrigin.Y + Bounds.Height, oldBounds.Width, oldBounds.Height);
Widget.RootWidget.AddChild(panel); Ui.RootWidget.AddChild(panel);
} }
public void ShowDropDown<T>(string panelTemplate, int height, IEnumerable<T> options, Func<T, ScrollItemWidget, ScrollItemWidget> setupItem) public void ShowDropDown<T>(string panelTemplate, int height, IEnumerable<T> options, Func<T, ScrollItemWidget, ScrollItemWidget> setupItem)
{ {
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", Bounds.Width }}; var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", Bounds.Width }};
var panel = (ScrollPanelWidget)Widget.LoadWidget(panelTemplate, null, new WidgetArgs() var panel = (ScrollPanelWidget)Ui.LoadWidget(panelTemplate, null, new WidgetArgs()
{{ "substitutions", substitutions }}); {{ "substitutions", substitutions }});
var itemTemplate = panel.GetWidget<ScrollItemWidget>("TEMPLATE"); var itemTemplate = panel.GetWidget<ScrollItemWidget>("TEMPLATE");
@@ -91,7 +91,7 @@ namespace OpenRA.Widgets
{ {
var o = option; var o = option;
ScrollItemWidget item = setupItem(o, itemTemplate); var item = setupItem(o, itemTemplate);
var onClick = item.OnClick; var onClick = item.OnClick;
item.OnClick = () => { onClick(); RemovePanel(); }; item.OnClick = () => { onClick(); RemovePanel(); };

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Widgets
public override void Draw() public override void Draw()
{ {
var state = IsSelected() ? "scrollitem-selected" : var state = IsSelected() ? "scrollitem-selected" :
Widget.MouseOverWidget == this ? "scrollitem-hover" : Ui.MouseOverWidget == this ? "scrollitem-hover" :
null; null;
if (state != null) if (state != null)

View File

@@ -70,13 +70,13 @@ namespace OpenRA.Widgets
scrollbarRect = new Rectangle(rb.Right - ScrollbarWidth, rb.Y + ScrollbarWidth - 1, ScrollbarWidth, ScrollbarHeight + 2); scrollbarRect = new Rectangle(rb.Right - ScrollbarWidth, rb.Y + ScrollbarWidth - 1, ScrollbarWidth, ScrollbarHeight + 2);
thumbRect = new Rectangle(rb.Right - ScrollbarWidth, thumbOrigin, ScrollbarWidth, thumbHeight); thumbRect = new Rectangle(rb.Right - ScrollbarWidth, thumbOrigin, ScrollbarWidth, thumbHeight);
var upHover = Widget.MouseOverWidget == this && upButtonRect.Contains(Viewport.LastMousePos); var upHover = Ui.MouseOverWidget == this && upButtonRect.Contains(Viewport.LastMousePos);
var upDisabled = thumbHeight == 0 || ListOffset >= 0; var upDisabled = thumbHeight == 0 || ListOffset >= 0;
var downHover = Widget.MouseOverWidget == this && downButtonRect.Contains(Viewport.LastMousePos); var downHover = Ui.MouseOverWidget == this && downButtonRect.Contains(Viewport.LastMousePos);
var downDisabled = thumbHeight == 0 || ListOffset <= Bounds.Height - ContentHeight; var downDisabled = thumbHeight == 0 || ListOffset <= Bounds.Height - ContentHeight;
var thumbHover = Widget.MouseOverWidget == this && thumbRect.Contains(Viewport.LastMousePos); var thumbHover = Ui.MouseOverWidget == this && thumbRect.Contains(Viewport.LastMousePos);
WidgetUtils.DrawPanel(Background, backgroundRect); WidgetUtils.DrawPanel(Background, backgroundRect);
WidgetUtils.DrawPanel("scrollpanel-bg", scrollbarRect); WidgetUtils.DrawPanel("scrollpanel-bg", scrollbarRect);
ButtonWidget.DrawBackground("button", upButtonRect, upDisabled, UpPressed, upHover); ButtonWidget.DrawBackground("button", upButtonRect, upDisabled, UpPressed, upHover);

View File

@@ -117,7 +117,7 @@ namespace OpenRA.Widgets
WidgetUtils.DrawPanel("slider-track", trackRect); WidgetUtils.DrawPanel("slider-track", trackRect);
// Thumb // Thumb
var thumbHover = Widget.MouseOverWidget == this && tr.Contains(Viewport.LastMousePos); var thumbHover = Ui.MouseOverWidget == this && tr.Contains(Viewport.LastMousePos);
ButtonWidget.DrawBackground("scrollthumb", tr, IsDisabled(), isMoving, thumbHover); ButtonWidget.DrawBackground("scrollthumb", tr, IsDisabled(), isMoving, thumbHover);
} }
} }

View File

@@ -203,7 +203,7 @@ namespace OpenRA.Widgets
var disabled = IsDisabled(); var disabled = IsDisabled();
var state = disabled ? "textfield-disabled" : var state = disabled ? "textfield-disabled" :
Focused ? "textfield-focused" : Focused ? "textfield-focused" :
Widget.MouseOverWidget == this ? "textfield-hover" : Ui.MouseOverWidget == this ? "textfield-hover" :
"textfield"; "textfield";
WidgetUtils.DrawPanel(state, WidgetUtils.DrawPanel(state,

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Widgets
public static string GetScrollCursor(Widget w, ScrollDirection edge, int2 pos) public static string GetScrollCursor(Widget w, ScrollDirection edge, int2 pos)
{ {
if (!Game.Settings.Game.ViewportEdgeScroll || Widget.MouseOverWidget != w) if (!Game.Settings.Game.ViewportEdgeScroll || Ui.MouseOverWidget != w)
return null; return null;
var blockedDirections = Game.viewport.GetBlockedDirections(); var blockedDirections = Game.viewport.GetBlockedDirections();
@@ -81,10 +81,10 @@ namespace OpenRA.Widgets
{ {
switch (e.KeyName) switch (e.KeyName)
{ {
case "up": Keyboard = Keyboard.Set(ScrollDirection.Up, (e.Event == KeyInputEvent.Down)); return true; case "up": Keyboard = Keyboard.Set(ScrollDirection.Up, e.Event == KeyInputEvent.Down); return true;
case "down": Keyboard = Keyboard.Set(ScrollDirection.Down, (e.Event == KeyInputEvent.Down)); return true; case "down": Keyboard = Keyboard.Set(ScrollDirection.Down, e.Event == KeyInputEvent.Down); return true;
case "left": Keyboard = Keyboard.Set(ScrollDirection.Left, (e.Event == KeyInputEvent.Down)); return true; case "left": Keyboard = Keyboard.Set(ScrollDirection.Left, e.Event == KeyInputEvent.Down); return true;
case "right": Keyboard = Keyboard.Set(ScrollDirection.Right, (e.Event == KeyInputEvent.Down)); return true; case "right": Keyboard = Keyboard.Set(ScrollDirection.Right, e.Event == KeyInputEvent.Down); return true;
} }
return false; return false;
} }
@@ -109,7 +109,6 @@ namespace OpenRA.Widgets
{ {
var scroll = new float2(0, 0); var scroll = new float2(0, 0);
// Modified to use the ViewportEdgeScrollStep setting - Gecko
if (Keyboard.Includes(ScrollDirection.Up) || Edge.Includes(ScrollDirection.Up)) if (Keyboard.Includes(ScrollDirection.Up) || Edge.Includes(ScrollDirection.Up))
scroll += new float2(0, -1); scroll += new float2(0, -1);
if (Keyboard.Includes(ScrollDirection.Right) || Edge.Includes(ScrollDirection.Right)) if (Keyboard.Includes(ScrollDirection.Right) || Edge.Includes(ScrollDirection.Right))

View File

@@ -17,7 +17,7 @@ using OpenRA.Graphics;
namespace OpenRA.Widgets namespace OpenRA.Widgets
{ {
public abstract class Widget public static class Ui
{ {
public static Widget RootWidget = new ContainerWidget(); public static Widget RootWidget = new ContainerWidget();
@@ -108,10 +108,13 @@ namespace OpenRA.Widgets
{ {
RootWidget.RemoveChildren(); RootWidget.RemoveChildren();
while (Widget.WindowList.Count > 0) while (WindowList.Count > 0)
Widget.CloseWindow(); CloseWindow();
} }
}
public abstract class Widget
{
// Info defined in YAML // Info defined in YAML
public string Id = null; public string Id = null;
public string X = "0"; public string X = "0";
@@ -221,6 +224,7 @@ namespace OpenRA.Widgets
} }
public virtual Rectangle EventBounds { get { return RenderBounds; } } public virtual Rectangle EventBounds { get { return RenderBounds; } }
public virtual Rectangle GetEventBounds() public virtual Rectangle GetEventBounds()
{ {
return Children return Children
@@ -229,16 +233,17 @@ namespace OpenRA.Widgets
.Aggregate(EventBounds, Rectangle.Union); .Aggregate(EventBounds, Rectangle.Union);
} }
public bool Focused { get { return SelectedWidget == this; } } public bool Focused { get { return Ui.SelectedWidget == this; } }
public virtual bool TakeFocus(MouseInput mi) public virtual bool TakeFocus(MouseInput mi)
{ {
if (Focused) if (Focused)
return true; return true;
if (SelectedWidget != null && !SelectedWidget.LoseFocus(mi)) if (Ui.SelectedWidget != null && !Ui.SelectedWidget.LoseFocus(mi))
return false; return false;
SelectedWidget = this; Ui.SelectedWidget = this;
return true; return true;
} }
@@ -251,8 +256,8 @@ namespace OpenRA.Widgets
public virtual bool LoseFocus() public virtual bool LoseFocus()
{ {
if (SelectedWidget == this) if (Ui.SelectedWidget == this)
SelectedWidget = null; Ui.SelectedWidget = null;
return true; return true;
} }
@@ -285,17 +290,17 @@ namespace OpenRA.Widgets
if (!(Focused || (IsVisible() && GetEventBounds().Contains(mi.Location)))) if (!(Focused || (IsVisible() && GetEventBounds().Contains(mi.Location))))
return false; return false;
var oldMouseOver = MouseOverWidget; var oldMouseOver = Ui.MouseOverWidget;
// Send the event to the deepest children first and bubble up if unhandled // Send the event to the deepest children first and bubble up if unhandled
foreach (var child in Children.OfType<Widget>().Reverse()) foreach (var child in Children.OfType<Widget>().Reverse())
if (child.HandleMouseInputOuter(mi)) if (child.HandleMouseInputOuter(mi))
return true; return true;
if (IgnoreChildMouseOver) if (IgnoreChildMouseOver)
MouseOverWidget = oldMouseOver; Ui.MouseOverWidget = oldMouseOver;
if (mi.Event == MouseInputEvent.Move && MouseOverWidget == null && !IgnoreMouseOver) if (mi.Event == MouseInputEvent.Move && Ui.MouseOverWidget == null && !IgnoreMouseOver)
MouseOverWidget = this; Ui.MouseOverWidget = this;
return HandleMouseInput(mi); return HandleMouseInput(mi);
} }

View File

@@ -123,7 +123,7 @@ namespace OpenRA.Mods.Cnc
void TestAndContinue() void TestAndContinue()
{ {
Widget.ResetAll(); Ui.ResetAll();
if (!FileSystem.Exists(Info["TestFile"])) if (!FileSystem.Exists(Info["TestFile"]))
{ {
var args = new WidgetArgs() var args = new WidgetArgs()
@@ -131,8 +131,8 @@ namespace OpenRA.Mods.Cnc
{ "continueLoading", () => TestAndContinue() }, { "continueLoading", () => TestAndContinue() },
{ "installData", Info } { "installData", Info }
}; };
Widget.LoadWidget(Info["InstallerBackgroundWidget"], Widget.RootWidget, args); Ui.LoadWidget(Info["InstallerBackgroundWidget"], Ui.RootWidget, args);
Widget.OpenWindow(Info["InstallerMenuWidget"], args); Ui.OpenWindow(Info["InstallerMenuWidget"], args);
} }
else else
Game.LoadShellMap(); Game.LoadShellMap();

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Cnc
{ {
Sound.StopMusic(); Sound.StopMusic();
Game.Disconnect(); Game.Disconnect();
Widget.ResetAll(); Ui.ResetAll();
Game.LoadShellMap(); Game.LoadShellMap();
}; };
Game.RunAfterDelay(5000, () => Scripting.Media.PlayFMVFullscreen(w, "consyard.vqa", afterFMV)); Game.RunAfterDelay(5000, () => Scripting.Media.PlayFMVFullscreen(w, "consyard.vqa", afterFMV));
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Cnc
{ {
Sound.StopMusic(); Sound.StopMusic();
Game.Disconnect(); Game.Disconnect();
Widget.ResetAll(); Ui.ResetAll();
Game.LoadShellMap(); Game.LoadShellMap();
}; };
Game.RunAfterDelay(5000, () => Scripting.Media.PlayFMVFullscreen(w, "gameover.vqa", afterFMV)); Game.RunAfterDelay(5000, () => Scripting.Media.PlayFMVFullscreen(w, "gameover.vqa", afterFMV));

View File

@@ -33,15 +33,16 @@ namespace OpenRA.Mods.Cnc.Widgets
this.world = world; this.world = world;
tabsWidget = Lazy.New(() => tabsWidget = Lazy.New(() =>
Widget.RootWidget.GetWidget<ProductionTabsWidget>(info.ProductionTabsWidget)); Ui.RootWidget.GetWidget<ProductionTabsWidget>(info.ProductionTabsWidget));
} }
public void SelectionChanged() public void SelectionChanged()
{ {
// Find an actor with a queue // Find an actor with a queue
var producer = world.Selection.Actors.FirstOrDefault(a => a.IsInWorld var producer = world.Selection.Actors.FirstOrDefault(a => a.IsInWorld
&& a.World.LocalPlayer == a.Owner && a.World.LocalPlayer == a.Owner
&& a.HasTrait<ProductionQueue>()); && a.HasTrait<ProductionQueue>());
if (producer != null) if (producer != null)
tabsWidget.Value.CurrentQueue = producer.TraitsImplementing<ProductionQueue>().First(); tabsWidget.Value.CurrentQueue = producer.TraitsImplementing<ProductionQueue>().First();
} }

View File

@@ -19,19 +19,19 @@ namespace OpenRA.Mods.Cnc.Widgets
{ {
public static void PromptConfirmAction(string title, string text, Action onConfirm, Action onCancel) public static void PromptConfirmAction(string title, string text, Action onConfirm, Action onCancel)
{ {
var prompt = Widget.OpenWindow("CONFIRM_PROMPT"); var prompt = Ui.OpenWindow("CONFIRM_PROMPT");
prompt.GetWidget<LabelWidget>("PROMPT_TITLE").GetText = () => title; prompt.GetWidget<LabelWidget>("PROMPT_TITLE").GetText = () => title;
prompt.GetWidget<LabelWidget>("PROMPT_TEXT").GetText = () => text; prompt.GetWidget<LabelWidget>("PROMPT_TEXT").GetText = () => text;
prompt.GetWidget<ButtonWidget>("CONFIRM_BUTTON").OnClick = () => prompt.GetWidget<ButtonWidget>("CONFIRM_BUTTON").OnClick = () =>
{ {
Widget.CloseWindow(); Ui.CloseWindow();
onConfirm(); onConfirm();
}; };
prompt.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () => prompt.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () =>
{ {
Widget.CloseWindow(); Ui.CloseWindow();
onCancel(); onCancel();
}; };
} }

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Cnc.Widgets
: base(world, worldRenderer) : base(world, worldRenderer)
{ {
tooltipContainer = Lazy.New(() => tooltipContainer = Lazy.New(() =>
Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer)); Ui.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
} }
public override void MouseEntered() public override void MouseEntered()
@@ -121,7 +121,7 @@ namespace OpenRA.Mods.Cnc.Widgets
public override void Tick() public override void Tick()
{ {
Edge = ScrollDirection.None; Edge = ScrollDirection.None;
if (Game.Settings.Game.ViewportEdgeScroll && Game.HasInputFocus && Widget.MouseOverWidget == this) if (Game.Settings.Game.ViewportEdgeScroll && Game.HasInputFocus && Ui.MouseOverWidget == this)
{ {
// Check for edge-scroll // Check for edge-scroll
if (Viewport.LastMousePos.X < EdgeScrollThreshold) if (Viewport.LastMousePos.X < EdgeScrollThreshold)

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
panel.GetWidget<ButtonWidget>("GIVE_EXPLORATION_BUTTON").OnClick = () => panel.GetWidget<ButtonWidget>("GIVE_EXPLORATION_BUTTON").OnClick = () =>
world.IssueOrder(new Order("DevGiveExploration", world.LocalPlayer.PlayerActor, false)); world.IssueOrder(new Order("DevGiveExploration", world.LocalPlayer.PlayerActor, false));
panel.GetWidget<ButtonWidget>("CLOSE_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); }; panel.GetWidget<ButtonWidget>("CLOSE_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };
} }
public void Order(World world, string order) public void Order(World world, string order)

View File

@@ -86,12 +86,12 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{ {
if (menu != MenuType.None) if (menu != MenuType.None)
{ {
Widget.CloseWindow(); Ui.CloseWindow();
menu = MenuType.None; menu = MenuType.None;
} }
ingameRoot.IsVisible = () => false; ingameRoot.IsVisible = () => false;
Game.LoadWidget(world, "INGAME_MENU", Widget.RootWidget, new WidgetArgs() Game.LoadWidget(world, "INGAME_MENU", Ui.RootWidget, new WidgetArgs()
{ {
{ "onExit", () => ingameRoot.IsVisible = () => true } { "onExit", () => ingameRoot.IsVisible = () => true }
}); });
@@ -135,7 +135,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
cheatsButton.OnClick = () => cheatsButton.OnClick = () =>
{ {
if (menu != MenuType.None) if (menu != MenuType.None)
Widget.CloseWindow(); Ui.CloseWindow();
menu = MenuType.Cheats; menu = MenuType.Cheats;
Game.OpenWindow("CHEATS_PANEL", new WidgetArgs() {{"onExit", () => menu = MenuType.None }}); Game.OpenWindow("CHEATS_PANEL", new WidgetArgs() {{"onExit", () => menu = MenuType.None }});

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Game.RunAfterDelay(1200 + 40 * mpe.Info.FadeLength, () => Game.RunAfterDelay(1200 + 40 * mpe.Info.FadeLength, () =>
{ {
Game.Disconnect(); Game.Disconnect();
Widget.ResetAll(); Ui.ResetAll();
Game.LoadShellMap(); Game.LoadShellMap();
}); });
}; };
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
menu.GetWidget<ButtonWidget>("MUSIC_BUTTON").OnClick = () => menu.GetWidget<ButtonWidget>("MUSIC_BUTTON").OnClick = () =>
{ {
hideButtons = true; hideButtons = true;
Widget.OpenWindow("MUSIC_PANEL", new WidgetArgs() Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs()
{ {
{ "onExit", () => hideButtons = false }, { "onExit", () => hideButtons = false },
}); });
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
menu.GetWidget<ButtonWidget>("SETTINGS_BUTTON").OnClick = () => menu.GetWidget<ButtonWidget>("SETTINGS_BUTTON").OnClick = () =>
{ {
hideButtons = true; hideButtons = true;
Widget.OpenWindow("SETTINGS_PANEL", new WidgetArgs() Ui.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
{ {
{ "world", world }, { "world", world },
{ "onExit", () => hideButtons = false }, { "onExit", () => hideButtons = false },
@@ -80,8 +80,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
resumeButton.IsDisabled = () => resumeDisabled; resumeButton.IsDisabled = () => resumeDisabled;
resumeButton.OnClick = () => resumeButton.OnClick = () =>
{ {
Widget.CloseWindow(); Ui.CloseWindow();
Widget.RootWidget.RemoveChild(menu); Ui.RootWidget.RemoveChild(menu);
world.WorldActor.Trait<CncMenuPaletteEffect>().Fade(CncMenuPaletteEffect.EffectType.None); world.WorldActor.Trait<CncMenuPaletteEffect>().Fade(CncMenuPaletteEffect.EffectType.None);
onExit(); onExit();
}; };

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
statusLabel = panel.GetWidget<LabelWidget>("STATUS_LABEL"); statusLabel = panel.GetWidget<LabelWidget>("STATUS_LABEL");
backButton = panel.GetWidget<ButtonWidget>("BACK_BUTTON"); backButton = panel.GetWidget<ButtonWidget>("BACK_BUTTON");
backButton.OnClick = Widget.CloseWindow; backButton.OnClick = Ui.CloseWindow;
retryButton = panel.GetWidget<ButtonWidget>("RETRY_BUTTON"); retryButton = panel.GetWidget<ButtonWidget>("RETRY_BUTTON");
retryButton.OnClick = CheckForDisk; retryButton.OnClick = CheckForDisk;
@@ -114,7 +114,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Game.RunAfterTick(() => Game.RunAfterTick(() =>
{ {
Widget.CloseWindow(); Ui.CloseWindow();
afterInstall(); afterInstall();
}); });
} }

View File

@@ -22,15 +22,15 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var panel = widget.GetWidget("INSTALL_PANEL"); var panel = widget.GetWidget("INSTALL_PANEL");
var args = new WidgetArgs() var args = new WidgetArgs()
{ {
{ "afterInstall", () => { Widget.CloseWindow(); continueLoading(); } }, { "afterInstall", () => { Ui.CloseWindow(); continueLoading(); } },
{ "installData", installData } { "installData", installData }
}; };
panel.GetWidget<ButtonWidget>("DOWNLOAD_BUTTON").OnClick = () => panel.GetWidget<ButtonWidget>("DOWNLOAD_BUTTON").OnClick = () =>
Widget.OpenWindow("INSTALL_DOWNLOAD_PANEL", args); Ui.OpenWindow("INSTALL_DOWNLOAD_PANEL", args);
panel.GetWidget<ButtonWidget>("INSTALL_BUTTON").OnClick = () => panel.GetWidget<ButtonWidget>("INSTALL_BUTTON").OnClick = () =>
Widget.OpenWindow("INSTALL_FROMCD_PANEL", new WidgetArgs(args) Ui.OpenWindow("INSTALL_FROMCD_PANEL", new WidgetArgs(args)
{ {
{ "filesToCopy", new[] { "CONQUER.MIX", "DESERT.MIX", "SCORES.MIX", { "filesToCopy", new[] { "CONQUER.MIX", "DESERT.MIX", "SCORES.MIX",
"SOUNDS.MIX", "TEMPERAT.MIX", "WINTER.MIX" } }, "SOUNDS.MIX", "TEMPERAT.MIX", "WINTER.MIX" } },
@@ -41,11 +41,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
panel.GetWidget<ButtonWidget>("MODS_BUTTON").OnClick = () => panel.GetWidget<ButtonWidget>("MODS_BUTTON").OnClick = () =>
{ {
Widget.OpenWindow("MODS_PANEL", new WidgetArgs() Ui.OpenWindow("MODS_PANEL", new WidgetArgs()
{ {
{ "onExit", () => {} }, { "onExit", () => {} },
// Close this panel // Close this panel
{ "onSwitch", Widget.CloseWindow }, { "onSwitch", Ui.CloseWindow },
}); });
}; };
} }

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
mainMenu.GetWidget<ButtonWidget>("MODS_BUTTON").OnClick = () => mainMenu.GetWidget<ButtonWidget>("MODS_BUTTON").OnClick = () =>
{ {
Menu = MenuType.None; Menu = MenuType.None;
Widget.OpenWindow("MODS_PANEL", new WidgetArgs() Ui.OpenWindow("MODS_PANEL", new WidgetArgs()
{ {
{ "onExit", () => Menu = MenuType.Main }, { "onExit", () => Menu = MenuType.Main },
{ "onSwitch", RemoveShellmapUI } { "onSwitch", RemoveShellmapUI }
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
settingsMenu.GetWidget<ButtonWidget>("REPLAYS_BUTTON").OnClick = () => settingsMenu.GetWidget<ButtonWidget>("REPLAYS_BUTTON").OnClick = () =>
{ {
Menu = MenuType.None; Menu = MenuType.None;
Widget.OpenWindow("REPLAYBROWSER_PANEL", new WidgetArgs() Ui.OpenWindow("REPLAYBROWSER_PANEL", new WidgetArgs()
{ {
{ "onExit", () => Menu = MenuType.Settings }, { "onExit", () => Menu = MenuType.Settings },
{ "onStart", RemoveShellmapUI } { "onStart", RemoveShellmapUI }
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
settingsMenu.GetWidget<ButtonWidget>("MUSIC_BUTTON").OnClick = () => settingsMenu.GetWidget<ButtonWidget>("MUSIC_BUTTON").OnClick = () =>
{ {
Menu = MenuType.None; Menu = MenuType.None;
Widget.OpenWindow("MUSIC_PANEL", new WidgetArgs() Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs()
{ {
{ "onExit", () => Menu = MenuType.Settings }, { "onExit", () => Menu = MenuType.Settings },
}); });
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
settingsMenu.GetWidget<ButtonWidget>("SETTINGS_BUTTON").OnClick = () => settingsMenu.GetWidget<ButtonWidget>("SETTINGS_BUTTON").OnClick = () =>
{ {
Menu = MenuType.None; Menu = MenuType.None;
Widget.OpenWindow("SETTINGS_PANEL", new WidgetArgs() Ui.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
{ {
{ "world", world }, { "world", world },
{ "onExit", () => Menu = MenuType.Settings }, { "onExit", () => Menu = MenuType.Settings },
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
void OpenGamePanel(string id) void OpenGamePanel(string id)
{ {
Menu = MenuType.None; Menu = MenuType.None;
Widget.OpenWindow(id, new WidgetArgs() Ui.OpenWindow(id, new WidgetArgs()
{ {
{ "onExit", () => Menu = MenuType.Multiplayer }, { "onExit", () => Menu = MenuType.Multiplayer },
{ "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) } { "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) }

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
installed = Rules.Music.Where(m => m.Value.Exists).Any(); installed = Rules.Music.Where(m => m.Value.Exists).Any();
Func<bool> noMusic = () => !installed; Func<bool> noMusic = () => !installed;
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); }; panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };
Action afterInstall = () => Action afterInstall = () =>
{ {
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var installButton = panel.GetWidget<ButtonWidget>("INSTALL_BUTTON"); var installButton = panel.GetWidget<ButtonWidget>("INSTALL_BUTTON");
installButton.OnClick = () => installButton.OnClick = () =>
Widget.OpenWindow("INSTALL_MUSIC_PANEL", new WidgetArgs() { Ui.OpenWindow("INSTALL_MUSIC_PANEL", new WidgetArgs() {
{ "afterInstall", afterInstall }, { "afterInstall", afterInstall },
{ "filesToCopy", new [] { "SCORES.MIX" } }, { "filesToCopy", new [] { "SCORES.MIX" } },
{ "filesToExtract", new [] { "transit.mix" } }, { "filesToExtract", new [] { "transit.mix" } },

View File

@@ -140,7 +140,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
int.TryParse(windowHeight.Text, out y); int.TryParse(windowHeight.Text, out y);
graphicsSettings.WindowedSize = new int2(x,y); graphicsSettings.WindowedSize = new int2(x,y);
Game.Settings.Save(); Game.Settings.Save();
Widget.CloseWindow(); Ui.CloseWindow();
onExit(); onExit();
}; };
} }

View File

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

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Cnc.Widgets
this.world = world; this.world = world;
this.worldRenderer = worldRenderer; this.worldRenderer = worldRenderer;
tooltipContainer = Lazy.New(() => tooltipContainer = Lazy.New(() =>
Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer)); Ui.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
cantBuild = new Animation("clock"); cantBuild = new Animation("clock");
cantBuild.PlayFetchIndex("idle", () => 0); 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 // Only visible if the production palette has icons to display
IsVisible = () => queueGroup != null && Groups[queueGroup].Tabs.Count > 0; IsVisible = () => queueGroup != null && Groups[queueGroup].Tabs.Count > 0;
paletteWidget = Lazy.New(() => Widget.RootWidget.GetWidget<ProductionPaletteWidget>(PaletteWidget)); paletteWidget = Lazy.New(() => Ui.RootWidget.GetWidget<ProductionPaletteWidget>(PaletteWidget));
} }
public void SelectNextTab(bool reverse) public void SelectNextTab(bool reverse)
@@ -135,9 +135,9 @@ namespace OpenRA.Mods.Cnc.Widgets
rightButtonRect = new Rectangle(rb.Right - ArrowWidth, rb.Y, ArrowWidth, rb.Height); rightButtonRect = new Rectangle(rb.Right - ArrowWidth, rb.Y, ArrowWidth, rb.Height);
var leftDisabled = ListOffset >= 0; var leftDisabled = ListOffset >= 0;
var leftHover = Widget.MouseOverWidget == this && leftButtonRect.Contains(Viewport.LastMousePos); var leftHover = Ui.MouseOverWidget == this && leftButtonRect.Contains(Viewport.LastMousePos);
var rightDisabled = ListOffset <= Bounds.Width - rightButtonRect.Width - leftButtonRect.Width - ContentWidth; var rightDisabled = ListOffset <= Bounds.Width - rightButtonRect.Width - leftButtonRect.Width - ContentWidth;
var rightHover = Widget.MouseOverWidget == this && rightButtonRect.Contains(Viewport.LastMousePos); var rightHover = Ui.MouseOverWidget == this && rightButtonRect.Contains(Viewport.LastMousePos);
WidgetUtils.DrawPanel("panel-black", rb); WidgetUtils.DrawPanel("panel-black", rb);
ButtonWidget.DrawBackground("button", leftButtonRect, leftDisabled, leftPressed, leftHover); ButtonWidget.DrawBackground("button", leftButtonRect, leftDisabled, leftPressed, leftHover);
@@ -157,7 +157,7 @@ namespace OpenRA.Mods.Cnc.Widgets
foreach (var tab in Groups[queueGroup].Tabs) foreach (var tab in Groups[queueGroup].Tabs)
{ {
var rect = new Rectangle(origin.X + ContentWidth, origin.Y, TabWidth, rb.Height); var rect = new Rectangle(origin.X + ContentWidth, origin.Y, TabWidth, rb.Height);
var hover = !leftHover && !rightHover && Widget.MouseOverWidget == this && rect.Contains(Viewport.LastMousePos); var hover = !leftHover && !rightHover && Ui.MouseOverWidget == this && rect.Contains(Viewport.LastMousePos);
var baseName = tab.Queue == CurrentQueue ? "button-toggled" : "button"; var baseName = tab.Queue == CurrentQueue ? "button-toggled" : "button";
ButtonWidget.DrawBackground(baseName, rect, false, false, hover); ButtonWidget.DrawBackground(baseName, rect, false, false, hover);
ContentWidth += TabWidth - 1; ContentWidth += TabWidth - 1;

View File

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

View File

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

View File

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

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Cnc.Widgets
public void SetTooltip(string id, WidgetArgs args) public void SetTooltip(string id, WidgetArgs args)
{ {
RemoveTooltip(); RemoveTooltip();
tooltip = Widget.LoadWidget(id, this, new WidgetArgs(args) {{ "tooltipContainer", this }}); tooltip = Ui.LoadWidget(id, this, new WidgetArgs(args) {{ "tooltipContainer", this }});
} }
public void RemoveTooltip() public void RemoveTooltip()
@@ -45,7 +45,9 @@ namespace OpenRA.Mods.Cnc.Widgets
} }
public override void Draw() { BeforeRender(); } public override void Draw() { BeforeRender(); }
public override Rectangle GetEventBounds() { return Rectangle.Empty; } public override Rectangle GetEventBounds() { return Rectangle.Empty; }
public override int2 ChildOrigin public override int2 ChildOrigin
{ {
get get
@@ -62,6 +64,7 @@ namespace OpenRA.Mods.Cnc.Widgets
} }
public override string GetCursor(int2 pos) { return null; } public override string GetCursor(int2 pos) { return null; }
public override Widget Clone() { throw new NotImplementedException(); } public override Widget Clone() { throw new NotImplementedException(); }
} }
} }

View File

@@ -16,6 +16,7 @@ namespace OpenRA.Mods.RA
public class NullLoadScreen : ILoadScreen public class NullLoadScreen : ILoadScreen
{ {
public void Init(Dictionary<string, string> info) {} public void Init(Dictionary<string, string> info) {}
public void Display() public void Display()
{ {
if (Game.Renderer == null) if (Game.Renderer == null)
@@ -28,8 +29,8 @@ namespace OpenRA.Mods.RA
public void StartGame() public void StartGame()
{ {
Widget.ResetAll(); Ui.ResetAll();
Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "INIT_SETUP" ); Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Ui.RootWidget, "INIT_SETUP" );
} }
} }
} }

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA
public void WorldLoaded(World world) public void WorldLoaded(World world)
{ {
// Remove all open widgets // Remove all open widgets
Widget.ResetAll(); Ui.ResetAll();
if (world.LocalPlayer != null) if (world.LocalPlayer != null)
Game.OpenWindow(world, Info.Widget); Game.OpenWindow(world, Info.Widget);
@@ -63,9 +63,9 @@ namespace OpenRA.Mods.RA
{ {
// Clear any existing widget state // Clear any existing widget state
if (Info.ClearRootWidget) if (Info.ClearRootWidget)
Widget.ResetAll(); Ui.ResetAll();
Game.LoadWidget(world, Info.Widget, Widget.RootWidget, new WidgetArgs()); Game.LoadWidget(world, Info.Widget, Ui.RootWidget, new WidgetArgs());
} }
} }
} }

View File

@@ -76,7 +76,7 @@ namespace OpenRA.Mods.RA
void TestAndContinue() void TestAndContinue()
{ {
Widget.ResetAll(); Ui.ResetAll();
if (!FileSystem.Exists(Info["TestFile"])) if (!FileSystem.Exists(Info["TestFile"]))
{ {
var args = new WidgetArgs() var args = new WidgetArgs()
@@ -84,13 +84,13 @@ namespace OpenRA.Mods.RA
{ "continueLoading", () => TestAndContinue() }, { "continueLoading", () => TestAndContinue() },
{ "installData", Info } { "installData", Info }
}; };
Widget.OpenWindow(Info["InstallerMenuWidget"], args); Ui.OpenWindow(Info["InstallerMenuWidget"], args);
} }
else else
{ {
Game.LoadShellMap(); Game.LoadShellMap();
Widget.ResetAll(); Ui.ResetAll();
Widget.OpenWindow("MAINMENU_BG"); Ui.OpenWindow("MAINMENU_BG");
} }
} }
} }

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Scripting
if (music) if (music)
Sound.PlayMusic(); Sound.PlayMusic();
Widget.CloseWindow(); Ui.CloseWindow();
Sound.SoundVolumeModifier = oldModifier; Sound.SoundVolumeModifier = oldModifier;
w.EnableTick = true; w.EnableTick = true;
onComplete(); onComplete();

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{ {
// Show connection failed dialog // Show connection failed dialog
CloseWindow(); CloseWindow();
Widget.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs() Ui.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs()
{ {
{ "onAbort", onAbort }, { "onAbort", onAbort },
{ "onRetry", onRetry }, { "onRetry", onRetry },
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
void CloseWindow() void CloseWindow()
{ {
Game.ConnectionStateChanged -= ConnectionStateChanged; Game.ConnectionStateChanged -= ConnectionStateChanged;
Widget.CloseWindow(); Ui.CloseWindow();
} }
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public static void Connect(string host, int port, Action onConnect, Action onAbort) public static void Connect(string host, int port, Action onConnect, Action onAbort)
{ {
Game.JoinServer(host, port); Game.JoinServer(host, port);
Widget.OpenWindow("CONNECTING_PANEL", new WidgetArgs() Ui.OpenWindow("CONNECTING_PANEL", new WidgetArgs()
{ {
{ "host", host }, { "host", host },
{ "port", port }, { "port", port },
@@ -85,8 +85,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public ConnectionFailedLogic(Widget widget, string host, int port, Action onRetry, Action onAbort) public ConnectionFailedLogic(Widget widget, string host, int port, Action onRetry, Action onAbort)
{ {
var panel = widget; var panel = widget;
panel.GetWidget<ButtonWidget>("ABORT_BUTTON").OnClick = () => { Widget.CloseWindow(); onAbort(); }; panel.GetWidget<ButtonWidget>("ABORT_BUTTON").OnClick = () => { Ui.CloseWindow(); onAbort(); };
panel.GetWidget<ButtonWidget>("RETRY_BUTTON").OnClick = () => { Widget.CloseWindow(); onRetry(); }; panel.GetWidget<ButtonWidget>("RETRY_BUTTON").OnClick = () => { Ui.CloseWindow(); onRetry(); };
widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () => widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
"Could not connect to {0}:{1}".F(host, port); "Could not connect to {0}:{1}".F(host, port);

View File

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

View File

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

View File

@@ -33,11 +33,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.Settings.Player.LastServer = "{0}:{1}".F(ipField.Text, port); Game.Settings.Player.LastServer = "{0}:{1}".F(ipField.Text, port);
Game.Settings.Save(); Game.Settings.Save();
Widget.CloseWindow(); Ui.CloseWindow();
ConnectionLogic.Connect(ipField.Text, port, openLobby, onExit); ConnectionLogic.Connect(ipField.Text, port, openLobby, onExit);
}; };
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); }; panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };
} }
} }
} }

View File

@@ -96,7 +96,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{ {
Game.RunAfterTick(() => Game.RunAfterTick(() =>
{ {
Widget.CloseWindow(); Ui.CloseWindow();
afterInstall(); afterInstall();
}); });
} }
@@ -104,7 +104,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var dl = new Download(installData["PackageURL"], file, onDownloadProgress, onDownloadComplete); var dl = new Download(installData["PackageURL"], file, onDownloadProgress, onDownloadComplete);
cancelButton.OnClick = () => { dl.Cancel(); Widget.CloseWindow(); }; cancelButton.OnClick = () => { dl.Cancel(); Ui.CloseWindow(); };
retryButton.OnClick = () => { dl.Cancel(); ShowDownloadDialog(); }; retryButton.OnClick = () => { dl.Cancel(); ShowDownloadDialog(); };
} }
} }

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.AddChatLine += AddChatLine; Game.AddChatLine += AddChatLine;
Game.BeforeGameStart += UnregisterEvents; Game.BeforeGameStart += UnregisterEvents;
var r = Widget.RootWidget; var r = Ui.RootWidget;
gameRoot = r.GetWidget("INGAME_ROOT"); gameRoot = r.GetWidget("INGAME_ROOT");
var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG"); var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG");
@@ -33,8 +33,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
optionsBG.GetWidget<ButtonWidget>("DISCONNECT").OnClick = () => LeaveGame(optionsBG); optionsBG.GetWidget<ButtonWidget>("DISCONNECT").OnClick = () => LeaveGame(optionsBG);
optionsBG.GetWidget<ButtonWidget>("SETTINGS").OnClick = () => Widget.OpenWindow("SETTINGS_MENU"); optionsBG.GetWidget<ButtonWidget>("SETTINGS").OnClick = () => Ui.OpenWindow("SETTINGS_MENU");
optionsBG.GetWidget<ButtonWidget>("MUSIC").OnClick = () => Widget.OpenWindow("MUSIC_MENU"); optionsBG.GetWidget<ButtonWidget>("MUSIC").OnClick = () => Ui.OpenWindow("MUSIC_MENU");
optionsBG.GetWidget<ButtonWidget>("RESUME").OnClick = () => optionsBG.Visible = false; optionsBG.GetWidget<ButtonWidget>("RESUME").OnClick = () => optionsBG.Visible = false;
optionsBG.GetWidget<ButtonWidget>("SURRENDER").OnClick = () => optionsBG.GetWidget<ButtonWidget>("SURRENDER").OnClick = () =>
@@ -74,8 +74,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
pane.Visible = false; pane.Visible = false;
Game.Disconnect(); Game.Disconnect();
Game.LoadShellMap(); Game.LoadShellMap();
Widget.CloseWindow(); Ui.CloseWindow();
Widget.OpenWindow("MAINMENU_BG"); Ui.OpenWindow("MAINMENU_BG");
} }
void UnregisterEvents() void UnregisterEvents()

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.AddChatLine += AddChatLine; Game.AddChatLine += AddChatLine;
Game.BeforeGameStart += UnregisterEvents; Game.BeforeGameStart += UnregisterEvents;
var r = Widget.RootWidget; var r = Ui.RootWidget;
gameRoot = r.GetWidget("OBSERVER_ROOT"); gameRoot = r.GetWidget("OBSERVER_ROOT");
var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG"); var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG");
@@ -37,12 +37,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
optionsBG.Visible = false; optionsBG.Visible = false;
Game.Disconnect(); Game.Disconnect();
Game.LoadShellMap(); Game.LoadShellMap();
Widget.CloseWindow(); Ui.CloseWindow();
Widget.OpenWindow("MAINMENU_BG"); Ui.OpenWindow("MAINMENU_BG");
}; };
optionsBG.GetWidget<ButtonWidget>("SETTINGS").OnClick = () => Widget.OpenWindow("SETTINGS_MENU"); optionsBG.GetWidget<ButtonWidget>("SETTINGS").OnClick = () => Ui.OpenWindow("SETTINGS_MENU");
optionsBG.GetWidget<ButtonWidget>("MUSIC").OnClick = () => Widget.OpenWindow("MUSIC_MENU"); optionsBG.GetWidget<ButtonWidget>("MUSIC").OnClick = () => Ui.OpenWindow("MUSIC_MENU");
optionsBG.GetWidget<ButtonWidget>("RESUME").OnClick = () => optionsBG.Visible = false; optionsBG.GetWidget<ButtonWidget>("RESUME").OnClick = () => optionsBG.Visible = false;
optionsBG.GetWidget<ButtonWidget>("SURRENDER").IsVisible = () => false; optionsBG.GetWidget<ButtonWidget>("SURRENDER").IsVisible = () => false;
} }

View File

@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
ConnectionLogic.Connect(om.Host, om.Port, onConnect, onExit); ConnectionLogic.Connect(om.Host, om.Port, onConnect, onExit);
}; };
Widget.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs() Ui.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs()
{ {
{ "onAbort", onExit }, { "onAbort", onExit },
{ "onRetry", onRetry }, { "onRetry", onRetry },
@@ -78,7 +78,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.AddChatLine -= AddChatLine; Game.AddChatLine -= AddChatLine;
Game.ConnectionStateChanged -= ConnectionStateChanged; Game.ConnectionStateChanged -= ConnectionStateChanged;
Widget.CloseWindow(); Ui.CloseWindow();
} }
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
@@ -135,7 +135,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.Settings.Save(); Game.Settings.Save();
}); });
Widget.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs() Ui.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs()
{ {
{ "initialMap", Map.Uid }, { "initialMap", Map.Uid },
{ "onExit", () => {} }, { "onExit", () => {} },
@@ -192,7 +192,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var musicButton = lobby.GetWidget<ButtonWidget>("MUSIC_BUTTON"); var musicButton = lobby.GetWidget<ButtonWidget>("MUSIC_BUTTON");
if (musicButton != null) if (musicButton != null)
musicButton.OnClick = () => Widget.OpenWindow("MUSIC_PANEL", new WidgetArgs musicButton.OnClick = () => Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs
{ { "onExit", () => {} } }); { { "onExit", () => {} } });
// Add a bot on the first lobbyinfo update // Add a bot on the first lobbyinfo update
@@ -247,7 +247,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
MapUid = orderManager.LobbyInfo.GlobalSettings.Map; MapUid = orderManager.LobbyInfo.GlobalSettings.Map;
Map = new Map(Game.modData.AvailableMaps[MapUid].Path); Map = new Map(Game.modData.AvailableMaps[MapUid].Path);
var title = Widget.RootWidget.GetWidget<LabelWidget>("TITLE"); var title = Ui.RootWidget.GetWidget<LabelWidget>("TITLE");
title.Text = orderManager.LobbyInfo.GlobalSettings.ServerName; title.Text = orderManager.LobbyInfo.GlobalSettings.ServerName;
} }

View File

@@ -21,20 +21,22 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{ {
rootMenu = widget; rootMenu = widget;
Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "PERF_BG" ); Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Ui.RootWidget, "PERF_BG" );
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_JOIN").OnClick = () => OpenGamePanel("JOINSERVER_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_CREATE").OnClick = () => OpenGamePanel("CREATESERVER_BG");
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_DIRECTCONNECT").OnClick = () => OpenGamePanel("DIRECTCONNECT_BG"); widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_DIRECTCONNECT").OnClick = () => OpenGamePanel("DIRECTCONNECT_BG");
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_SETTINGS").OnClick = () => Widget.OpenWindow("SETTINGS_MENU"); widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_SETTINGS").OnClick = () => Ui.OpenWindow("SETTINGS_MENU");
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_MUSIC").OnClick = () => Widget.OpenWindow("MUSIC_MENU"); widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_MUSIC").OnClick = () => Ui.OpenWindow("MUSIC_MENU");
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_MODS").OnClick = () => widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_MODS").OnClick = () =>
Widget.OpenWindow("MODS_PANEL", new WidgetArgs() Ui.OpenWindow("MODS_PANEL", new WidgetArgs()
{ {
{ "onExit", () => {} }, { "onExit", () => {} },
{ "onSwitch", RemoveShellmapUI } { "onSwitch", RemoveShellmapUI }
}); });
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_REPLAY_VIEWER").OnClick = () => widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_REPLAY_VIEWER").OnClick = () =>
Widget.OpenWindow("REPLAYBROWSER_BG", new WidgetArgs() Ui.OpenWindow("REPLAYBROWSER_BG", new WidgetArgs()
{ {
{ "onExit", () => {} }, { "onExit", () => {} },
{ "onStart", RemoveShellmapUI } { "onStart", RemoveShellmapUI }
@@ -49,7 +51,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
void OpenGamePanel(string id) void OpenGamePanel(string id)
{ {
Widget.OpenWindow(id, new WidgetArgs() Ui.OpenWindow(id, new WidgetArgs()
{ {
{ "onExit", () => {} }, { "onExit", () => {} },
{ "openLobby", () => OpenLobbyPanel() } { "openLobby", () => OpenLobbyPanel() }

View File

@@ -27,8 +27,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{ {
map = Game.modData.AvailableMaps[WidgetUtils.ChooseInitialMap(initialMap)]; map = Game.modData.AvailableMaps[WidgetUtils.ChooseInitialMap(initialMap)];
widget.GetWidget<ButtonWidget>("BUTTON_OK").OnClick = () => { Widget.CloseWindow(); onSelect(map); }; widget.GetWidget<ButtonWidget>("BUTTON_OK").OnClick = () => { Ui.CloseWindow(); onSelect(map); };
widget.GetWidget<ButtonWidget>("BUTTON_CANCEL").OnClick = () => { Widget.CloseWindow(); onExit(); }; widget.GetWidget<ButtonWidget>("BUTTON_CANCEL").OnClick = () => { Ui.CloseWindow(); onExit(); };
scrollpanel = widget.GetWidget<ScrollPanelWidget>("MAP_LIST"); scrollpanel = widget.GetWidget<ScrollPanelWidget>("MAP_LIST");
itemTemplate = scrollpanel.GetWidget<ScrollItemWidget>("MAP_TEMPLATE"); itemTemplate = scrollpanel.GetWidget<ScrollItemWidget>("MAP_TEMPLATE");

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
loadButton.OnClick = () => LoadMod(currentMod.Id, onSwitch); loadButton.OnClick = () => LoadMod(currentMod.Id, onSwitch);
loadButton.IsDisabled = () => currentMod.Id == Game.CurrentMods.Keys.First(); loadButton.IsDisabled = () => currentMod.Id == Game.CurrentMods.Keys.First();
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); }; panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };
currentMod = Mod.AllMods[Game.modData.Manifest.Mods[0]]; currentMod = Mod.AllMods[Game.modData.Manifest.Mods[0]];
// Mod list // Mod list
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.RunAfterTick(() => Game.RunAfterTick(() =>
{ {
Widget.CloseWindow(); Ui.CloseWindow();
onSwitch(); onSwitch();
Game.InitializeWithMods(mods); Game.InitializeWithMods(mods);
}); });

View File

@@ -34,14 +34,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public MusicPlayerLogic() public MusicPlayerLogic()
{ {
bg = Widget.RootWidget.GetWidget("MUSIC_MENU"); bg = Ui.RootWidget.GetWidget("MUSIC_MENU");
CurrentSong = GetNextSong(); CurrentSong = GetNextSong();
bg.GetWidget( "BUTTON_PAUSE" ).IsVisible = () => Sound.MusicPlaying; bg.GetWidget( "BUTTON_PAUSE" ).IsVisible = () => Sound.MusicPlaying;
bg.GetWidget( "BUTTON_PLAY" ).IsVisible = () => !Sound.MusicPlaying; bg.GetWidget( "BUTTON_PLAY" ).IsVisible = () => !Sound.MusicPlaying;
bg.GetWidget<ButtonWidget>("BUTTON_CLOSE").OnClick = bg.GetWidget<ButtonWidget>("BUTTON_CLOSE").OnClick =
() => { Game.Settings.Save(); Widget.CloseWindow(); }; () => { Game.Settings.Save(); Ui.CloseWindow(); };
bg.GetWidget("BUTTON_INSTALL").IsVisible = () => false; bg.GetWidget("BUTTON_INSTALL").IsVisible = () => false;

View File

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

View File

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

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
statusLabel = panel.GetWidget<LabelWidget>("STATUS_LABEL"); statusLabel = panel.GetWidget<LabelWidget>("STATUS_LABEL");
backButton = panel.GetWidget<ButtonWidget>("BACK_BUTTON"); backButton = panel.GetWidget<ButtonWidget>("BACK_BUTTON");
backButton.OnClick = Widget.CloseWindow; backButton.OnClick = Ui.CloseWindow;
retryButton = panel.GetWidget<ButtonWidget>("RETRY_BUTTON"); retryButton = panel.GetWidget<ButtonWidget>("RETRY_BUTTON");
retryButton.OnClick = CheckForDisk; retryButton.OnClick = CheckForDisk;
@@ -105,7 +105,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.RunAfterTick(() => Game.RunAfterTick(() =>
{ {
Widget.CloseWindow(); Ui.CloseWindow();
continueLoading(); continueLoading();
}); });
} }

View File

@@ -22,15 +22,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var panel = widget.GetWidget("INSTALL_PANEL"); var panel = widget.GetWidget("INSTALL_PANEL");
var args = new WidgetArgs() var args = new WidgetArgs()
{ {
{ "afterInstall", () => { Widget.CloseWindow(); continueLoading(); } }, { "afterInstall", () => { Ui.CloseWindow(); continueLoading(); } },
{ "installData", installData } { "installData", installData }
}; };
panel.GetWidget<ButtonWidget>("DOWNLOAD_BUTTON").OnClick = () => panel.GetWidget<ButtonWidget>("DOWNLOAD_BUTTON").OnClick = () =>
Widget.OpenWindow("INSTALL_DOWNLOAD_PANEL", args); Ui.OpenWindow("INSTALL_DOWNLOAD_PANEL", args);
panel.GetWidget<ButtonWidget>("INSTALL_BUTTON").OnClick = () => panel.GetWidget<ButtonWidget>("INSTALL_BUTTON").OnClick = () =>
Widget.OpenWindow("INSTALL_FROMCD_PANEL", args); Ui.OpenWindow("INSTALL_FROMCD_PANEL", args);
panel.GetWidget<ButtonWidget>("QUIT_BUTTON").OnClick = Game.Exit; panel.GetWidget<ButtonWidget>("QUIT_BUTTON").OnClick = Game.Exit;
} }

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{ {
panel = widget; panel = widget;
panel.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); }; panel.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };
var rl = panel.GetWidget<ScrollPanelWidget>("REPLAY_LIST"); var rl = panel.GetWidget<ScrollPanelWidget>("REPLAY_LIST");
var replayDir = Path.Combine(Platform.SupportDir, "Replays"); var replayDir = Path.Combine(Platform.SupportDir, "Replays");
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (currentReplay != null) if (currentReplay != null)
{ {
Game.JoinReplay(currentReplay.Filename); Game.JoinReplay(currentReplay.Filename);
Widget.CloseWindow(); Ui.CloseWindow();
onStart(); onStart();
} }
}; };

View File

@@ -64,11 +64,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var host = currentServer.Address.Split(':')[0]; var host = currentServer.Address.Split(':')[0];
var port = int.Parse(currentServer.Address.Split(':')[1]); var port = int.Parse(currentServer.Address.Split(':')[1]);
Widget.CloseWindow(); Ui.CloseWindow();
ConnectionLogic.Connect(host, port, openLobby, onExit); ConnectionLogic.Connect(host, port, openLobby, onExit);
}; };
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); }; panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };
// Server list // Server list
serverTemplate = sl.GetWidget<ScrollItemWidget>("SERVER_TEMPLATE"); serverTemplate = sl.GetWidget<ScrollItemWidget>("SERVER_TEMPLATE");

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
this.onExit = onExit; this.onExit = onExit;
var settings = Game.Settings; var settings = Game.Settings;
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); }; panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };
panel.GetWidget<ButtonWidget>("CREATE_BUTTON").OnClick = CreateAndJoin; panel.GetWidget<ButtonWidget>("CREATE_BUTTON").OnClick = CreateAndJoin;
map = Game.modData.AvailableMaps[ WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map) ]; map = Game.modData.AvailableMaps[ WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map) ];
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{ {
panel.GetWidget<ButtonWidget>("MAP_BUTTON").OnClick = () => panel.GetWidget<ButtonWidget>("MAP_BUTTON").OnClick = () =>
{ {
Widget.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs() Ui.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs()
{ {
{ "initialMap", map.Uid }, { "initialMap", map.Uid },
{ "onExit", () => {} }, { "onExit", () => {} },
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
// Create and join the server // Create and join the server
Game.CreateServer(settings); Game.CreateServer(settings);
Widget.CloseWindow(); Ui.CloseWindow();
ConnectionLogic.Connect(IPAddress.Loopback.ToString(), Game.Settings.Server.ListenPort, onCreate, onExit); ConnectionLogic.Connect(IPAddress.Loopback.ToString(), Game.Settings.Server.ListenPort, onCreate, onExit);
} }
} }

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public SettingsMenuLogic() public SettingsMenuLogic()
{ {
bg = Widget.RootWidget.GetWidget<BackgroundWidget>("SETTINGS_MENU"); bg = Ui.RootWidget.GetWidget<BackgroundWidget>("SETTINGS_MENU");
var tabs = bg.GetWidget<ContainerWidget>("TAB_CONTAINER"); var tabs = bg.GetWidget<ContainerWidget>("TAB_CONTAINER");
//Tabs //Tabs
@@ -122,7 +122,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
int.TryParse(windowHeight.Text, out y); int.TryParse(windowHeight.Text, out y);
gs.WindowedSize = new int2(x,y); gs.WindowedSize = new int2(x,y);
Game.Settings.Save(); Game.Settings.Save();
Widget.CloseWindow(); Ui.CloseWindow();
}; };
} }

View File

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

View File

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

View File

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

View File

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