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
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
// impossible for the things that want them to access them directly?
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 },
{ "orderManager", orderManager },
@@ -160,7 +160,7 @@ namespace OpenRA
using( new PerfSample( "tick_time" ) )
{
orderManager.LastTickTime += Settings.Game.Timestep;
Widget.DoTick();
Ui.DoTick();
var world = orderManager.world;
if (orderManager.GameStarted)
++Viewport.TicksSinceLastMove;
@@ -215,7 +215,7 @@ namespace OpenRA
worldRenderer = new WorldRenderer(orderManager.world);
if (orderManager.GameStarted) return;
Widget.SelectedWidget = null;
Ui.SelectedWidget = null;
orderManager.LocalFrameNumber = 0;
orderManager.LastTickTime = Environment.TickCount;
@@ -270,7 +270,7 @@ namespace OpenRA
AddChatLine = (a,b,c) => {};
ConnectionStateChanged = om => {};
BeforeGameStart = () => {};
Widget.ResetAll();
Ui.ResetAll();
worldRenderer = null;
if (server != null)

View File

@@ -126,15 +126,15 @@ namespace OpenRA.Graphics
using( new PerfSample("render_widgets") )
{
Widget.DoDraw();
var cursorName = Widget.RootWidget.GetCursorOuter(Viewport.LastMousePos) ?? "default";
Ui.DoDraw();
var cursorName = Ui.RootWidget.GetCursorOuter(Viewport.LastMousePos) ?? "default";
var cursorSequence = CursorProvider.GetCursorSequence(cursorName);
var cursorSprite = cursorSequence.GetSprite((int)cursorFrame);
renderer.SpriteRenderer.DrawSprite(cursorSprite,
Viewport.LastMousePos - cursorSequence.Hotspot,
Game.modData.Palette.GetPaletteIndex(cursorSequence.Palette),
cursorSprite.size);
Viewport.LastMousePos - cursorSequence.Hotspot,
Game.modData.Palette.GetPaletteIndex(cursorSequence.Palette),
cursorSprite.size);
}
using( new PerfSample("render_flip") )
@@ -194,7 +194,7 @@ namespace OpenRA.Graphics
{
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 br = ViewToWorld(new int2(Width, Height)).ToInt2() + boundary;

View File

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

View File

@@ -128,7 +128,7 @@ namespace OpenRA.Widgets
var s = font.Measure(text);
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,
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 state = disabled ? "checkbox-disabled" :
Depressed && HasPressedState ? "checkbox-pressed" :
Widget.MouseOverWidget == this ? "checkbox-hover" :
Ui.MouseOverWidget == this ? "checkbox-hover" :
"checkbox";
WidgetUtils.DrawPanel(state, check);

View File

@@ -57,8 +57,8 @@ namespace OpenRA.Widgets
if (panel == null)
return;
Widget.RootWidget.RemoveChild(fullscreenMask);
Widget.RootWidget.RemoveChild(panel);
Ui.RootWidget.RemoveChild(fullscreenMask);
Ui.RootWidget.RemoveChild(panel);
panel = fullscreenMask = null;
}
@@ -72,17 +72,17 @@ namespace OpenRA.Widgets
fullscreenMask = new MaskWidget();
fullscreenMask.Bounds = new Rectangle(0, 0, Game.viewport.Width, Game.viewport.Height);
fullscreenMask.OnMouseDown = mi => RemovePanel();
Widget.RootWidget.AddChild(fullscreenMask);
Ui.RootWidget.AddChild(fullscreenMask);
var oldBounds = panel.Bounds;
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)
{
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 }});
var itemTemplate = panel.GetWidget<ScrollItemWidget>("TEMPLATE");
@@ -91,7 +91,7 @@ namespace OpenRA.Widgets
{
var o = option;
ScrollItemWidget item = setupItem(o, itemTemplate);
var item = setupItem(o, itemTemplate);
var onClick = item.OnClick;
item.OnClick = () => { onClick(); RemovePanel(); };

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Widgets
public override void Draw()
{
var state = IsSelected() ? "scrollitem-selected" :
Widget.MouseOverWidget == this ? "scrollitem-hover" :
Ui.MouseOverWidget == this ? "scrollitem-hover" :
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);
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 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 thumbHover = Widget.MouseOverWidget == this && thumbRect.Contains(Viewport.LastMousePos);
var thumbHover = Ui.MouseOverWidget == this && thumbRect.Contains(Viewport.LastMousePos);
WidgetUtils.DrawPanel(Background, backgroundRect);
WidgetUtils.DrawPanel("scrollpanel-bg", scrollbarRect);
ButtonWidget.DrawBackground("button", upButtonRect, upDisabled, UpPressed, upHover);

View File

@@ -117,7 +117,7 @@ namespace OpenRA.Widgets
WidgetUtils.DrawPanel("slider-track", trackRect);
// 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);
}
}

View File

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

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Widgets
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;
var blockedDirections = Game.viewport.GetBlockedDirections();
@@ -81,10 +81,10 @@ namespace OpenRA.Widgets
{
switch (e.KeyName)
{
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 "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 "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 "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;
}
return false;
}
@@ -109,7 +109,6 @@ namespace OpenRA.Widgets
{
var scroll = new float2(0, 0);
// Modified to use the ViewportEdgeScrollStep setting - Gecko
if (Keyboard.Includes(ScrollDirection.Up) || Edge.Includes(ScrollDirection.Up))
scroll += new float2(0, -1);
if (Keyboard.Includes(ScrollDirection.Right) || Edge.Includes(ScrollDirection.Right))

View File

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

View File

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

View File

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

View File

@@ -33,15 +33,16 @@ namespace OpenRA.Mods.Cnc.Widgets
this.world = world;
tabsWidget = Lazy.New(() =>
Widget.RootWidget.GetWidget<ProductionTabsWidget>(info.ProductionTabsWidget));
Ui.RootWidget.GetWidget<ProductionTabsWidget>(info.ProductionTabsWidget));
}
public void SelectionChanged()
{
// Find an actor with a queue
var producer = world.Selection.Actors.FirstOrDefault(a => a.IsInWorld
&& a.World.LocalPlayer == a.Owner
&& a.HasTrait<ProductionQueue>());
&& a.World.LocalPlayer == a.Owner
&& a.HasTrait<ProductionQueue>());
if (producer != null)
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)
{
var prompt = Widget.OpenWindow("CONFIRM_PROMPT");
var prompt = Ui.OpenWindow("CONFIRM_PROMPT");
prompt.GetWidget<LabelWidget>("PROMPT_TITLE").GetText = () => title;
prompt.GetWidget<LabelWidget>("PROMPT_TEXT").GetText = () => text;
prompt.GetWidget<ButtonWidget>("CONFIRM_BUTTON").OnClick = () =>
{
Widget.CloseWindow();
Ui.CloseWindow();
onConfirm();
};
prompt.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () =>
{
Widget.CloseWindow();
Ui.CloseWindow();
onCancel();
};
}

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Cnc.Widgets
: base(world, worldRenderer)
{
tooltipContainer = Lazy.New(() =>
Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
Ui.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
}
public override void MouseEntered()
@@ -121,7 +121,7 @@ namespace OpenRA.Mods.Cnc.Widgets
public override void Tick()
{
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
if (Viewport.LastMousePos.X < EdgeScrollThreshold)

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
panel.GetWidget<ButtonWidget>("GIVE_EXPLORATION_BUTTON").OnClick = () =>
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)

View File

@@ -86,12 +86,12 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{
if (menu != MenuType.None)
{
Widget.CloseWindow();
Ui.CloseWindow();
menu = MenuType.None;
}
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 }
});
@@ -135,7 +135,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
cheatsButton.OnClick = () =>
{
if (menu != MenuType.None)
Widget.CloseWindow();
Ui.CloseWindow();
menu = MenuType.Cheats;
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.Disconnect();
Widget.ResetAll();
Ui.ResetAll();
Game.LoadShellMap();
});
};
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
menu.GetWidget<ButtonWidget>("MUSIC_BUTTON").OnClick = () =>
{
hideButtons = true;
Widget.OpenWindow("MUSIC_PANEL", new WidgetArgs()
Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs()
{
{ "onExit", () => hideButtons = false },
});
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
menu.GetWidget<ButtonWidget>("SETTINGS_BUTTON").OnClick = () =>
{
hideButtons = true;
Widget.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
Ui.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
{
{ "world", world },
{ "onExit", () => hideButtons = false },
@@ -80,8 +80,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
resumeButton.IsDisabled = () => resumeDisabled;
resumeButton.OnClick = () =>
{
Widget.CloseWindow();
Widget.RootWidget.RemoveChild(menu);
Ui.CloseWindow();
Ui.RootWidget.RemoveChild(menu);
world.WorldActor.Trait<CncMenuPaletteEffect>().Fade(CncMenuPaletteEffect.EffectType.None);
onExit();
};

View File

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

View File

@@ -22,15 +22,15 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var panel = widget.GetWidget("INSTALL_PANEL");
var args = new WidgetArgs()
{
{ "afterInstall", () => { Widget.CloseWindow(); continueLoading(); } },
{ "afterInstall", () => { Ui.CloseWindow(); continueLoading(); } },
{ "installData", installData }
};
panel.GetWidget<ButtonWidget>("DOWNLOAD_BUTTON").OnClick = () =>
Widget.OpenWindow("INSTALL_DOWNLOAD_PANEL", args);
Ui.OpenWindow("INSTALL_DOWNLOAD_PANEL", args);
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",
"SOUNDS.MIX", "TEMPERAT.MIX", "WINTER.MIX" } },
@@ -41,11 +41,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
panel.GetWidget<ButtonWidget>("MODS_BUTTON").OnClick = () =>
{
Widget.OpenWindow("MODS_PANEL", new WidgetArgs()
Ui.OpenWindow("MODS_PANEL", new WidgetArgs()
{
{ "onExit", () => {} },
// 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 = () =>
{
Menu = MenuType.None;
Widget.OpenWindow("MODS_PANEL", new WidgetArgs()
Ui.OpenWindow("MODS_PANEL", new WidgetArgs()
{
{ "onExit", () => Menu = MenuType.Main },
{ "onSwitch", RemoveShellmapUI }
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
settingsMenu.GetWidget<ButtonWidget>("REPLAYS_BUTTON").OnClick = () =>
{
Menu = MenuType.None;
Widget.OpenWindow("REPLAYBROWSER_PANEL", new WidgetArgs()
Ui.OpenWindow("REPLAYBROWSER_PANEL", new WidgetArgs()
{
{ "onExit", () => Menu = MenuType.Settings },
{ "onStart", RemoveShellmapUI }
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
settingsMenu.GetWidget<ButtonWidget>("MUSIC_BUTTON").OnClick = () =>
{
Menu = MenuType.None;
Widget.OpenWindow("MUSIC_PANEL", new WidgetArgs()
Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs()
{
{ "onExit", () => Menu = MenuType.Settings },
});
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
settingsMenu.GetWidget<ButtonWidget>("SETTINGS_BUTTON").OnClick = () =>
{
Menu = MenuType.None;
Widget.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
Ui.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
{
{ "world", world },
{ "onExit", () => Menu = MenuType.Settings },
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
void OpenGamePanel(string id)
{
Menu = MenuType.None;
Widget.OpenWindow(id, new WidgetArgs()
Ui.OpenWindow(id, new WidgetArgs()
{
{ "onExit", () => Menu = MenuType.Multiplayer },
{ "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();
Func<bool> noMusic = () => !installed;
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); };
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };
Action afterInstall = () =>
{
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var installButton = panel.GetWidget<ButtonWidget>("INSTALL_BUTTON");
installButton.OnClick = () =>
Widget.OpenWindow("INSTALL_MUSIC_PANEL", new WidgetArgs() {
Ui.OpenWindow("INSTALL_MUSIC_PANEL", new WidgetArgs() {
{ "afterInstall", afterInstall },
{ "filesToCopy", new [] { "SCORES.MIX" } },
{ "filesToExtract", new [] { "transit.mix" } },

View File

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

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Cnc.Widgets
{
pm = world.LocalPlayer.PlayerActor.Trait<PowerManager>();
tooltipContainer = Lazy.New(() =>
Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
Ui.RootWidget.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(() =>
Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
Ui.RootWidget.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(() => Widget.RootWidget.GetWidget<ProductionPaletteWidget>(PaletteWidget));
paletteWidget = Lazy.New(() => Ui.RootWidget.GetWidget<ProductionPaletteWidget>(PaletteWidget));
}
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);
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 rightHover = Widget.MouseOverWidget == this && rightButtonRect.Contains(Viewport.LastMousePos);
var rightHover = Ui.MouseOverWidget == this && rightButtonRect.Contains(Viewport.LastMousePos);
WidgetUtils.DrawPanel("panel-black", rb);
ButtonWidget.DrawBackground("button", leftButtonRect, leftDisabled, leftPressed, leftHover);
@@ -157,7 +157,7 @@ namespace OpenRA.Mods.Cnc.Widgets
foreach (var tab in Groups[queueGroup].Tabs)
{
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";
ButtonWidget.DrawBackground(baseName, rect, false, false, hover);
ContentWidth += TabWidth - 1;

View File

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

View File

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

View File

@@ -16,6 +16,7 @@ namespace OpenRA.Mods.RA
public class NullLoadScreen : ILoadScreen
{
public void Init(Dictionary<string, string> info) {}
public void Display()
{
if (Game.Renderer == null)
@@ -28,8 +29,8 @@ namespace OpenRA.Mods.RA
public void StartGame()
{
Widget.ResetAll();
Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "INIT_SETUP" );
Ui.ResetAll();
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)
{
// Remove all open widgets
Widget.ResetAll();
Ui.ResetAll();
if (world.LocalPlayer != null)
Game.OpenWindow(world, Info.Widget);
@@ -63,9 +63,9 @@ namespace OpenRA.Mods.RA
{
// Clear any existing widget state
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()
{
Widget.ResetAll();
Ui.ResetAll();
if (!FileSystem.Exists(Info["TestFile"]))
{
var args = new WidgetArgs()
@@ -84,13 +84,13 @@ namespace OpenRA.Mods.RA
{ "continueLoading", () => TestAndContinue() },
{ "installData", Info }
};
Widget.OpenWindow(Info["InstallerMenuWidget"], args);
Ui.OpenWindow(Info["InstallerMenuWidget"], args);
}
else
{
Game.LoadShellMap();
Widget.ResetAll();
Widget.OpenWindow("MAINMENU_BG");
Ui.ResetAll();
Ui.OpenWindow("MAINMENU_BG");
}
}
}

View File

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

View File

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

View File

@@ -20,8 +20,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
[ObjectCreator.UseCtor]
public DeveloperModeLogic(World world)
{
var devmodeBG = Widget.RootWidget.GetWidget("INGAME_ROOT").GetWidget("DEVELOPERMODE_BG");
var devModeButton = Widget.RootWidget.GetWidget<ButtonWidget>("INGAME_DEVELOPERMODE_BUTTON");
var devmodeBG = Ui.RootWidget.GetWidget("INGAME_ROOT").GetWidget("DEVELOPERMODE_BG");
var devModeButton = Ui.RootWidget.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 = Widget.RootWidget.GetWidget("INGAME_ROOT");
var root = Ui.RootWidget.GetWidget("INGAME_ROOT");
var diplomacyBG = root.GetWidget("DIPLOMACY_BG");
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.Save();
Widget.CloseWindow();
Ui.CloseWindow();
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(() =>
{
Widget.CloseWindow();
Ui.CloseWindow();
afterInstall();
});
}
@@ -104,7 +104,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
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(); };
}
}

View File

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

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.AddChatLine += AddChatLine;
Game.BeforeGameStart += UnregisterEvents;
var r = Widget.RootWidget;
var r = Ui.RootWidget;
gameRoot = r.GetWidget("OBSERVER_ROOT");
var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG");
@@ -37,12 +37,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
optionsBG.Visible = false;
Game.Disconnect();
Game.LoadShellMap();
Widget.CloseWindow();
Widget.OpenWindow("MAINMENU_BG");
Ui.CloseWindow();
Ui.OpenWindow("MAINMENU_BG");
};
optionsBG.GetWidget<ButtonWidget>("SETTINGS").OnClick = () => Widget.OpenWindow("SETTINGS_MENU");
optionsBG.GetWidget<ButtonWidget>("MUSIC").OnClick = () => Widget.OpenWindow("MUSIC_MENU");
optionsBG.GetWidget<ButtonWidget>("SETTINGS").OnClick = () => Ui.OpenWindow("SETTINGS_MENU");
optionsBG.GetWidget<ButtonWidget>("MUSIC").OnClick = () => Ui.OpenWindow("MUSIC_MENU");
optionsBG.GetWidget<ButtonWidget>("RESUME").OnClick = () => optionsBG.Visible = 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);
};
Widget.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs()
Ui.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs()
{
{ "onAbort", onExit },
{ "onRetry", onRetry },
@@ -78,7 +78,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.AddChatLine -= AddChatLine;
Game.ConnectionStateChanged -= ConnectionStateChanged;
Widget.CloseWindow();
Ui.CloseWindow();
}
[ObjectCreator.UseCtor]
@@ -135,7 +135,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.Settings.Save();
});
Widget.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs()
Ui.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs()
{
{ "initialMap", Map.Uid },
{ "onExit", () => {} },
@@ -192,7 +192,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var musicButton = lobby.GetWidget<ButtonWidget>("MUSIC_BUTTON");
if (musicButton != null)
musicButton.OnClick = () => Widget.OpenWindow("MUSIC_PANEL", new WidgetArgs
musicButton.OnClick = () => Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs
{ { "onExit", () => {} } });
// Add a bot on the first lobbyinfo update
@@ -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 = Widget.RootWidget.GetWidget<LabelWidget>("TITLE");
var title = Ui.RootWidget.GetWidget<LabelWidget>("TITLE");
title.Text = orderManager.LobbyInfo.GlobalSettings.ServerName;
}

View File

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

View File

@@ -27,8 +27,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
map = Game.modData.AvailableMaps[WidgetUtils.ChooseInitialMap(initialMap)];
widget.GetWidget<ButtonWidget>("BUTTON_OK").OnClick = () => { Widget.CloseWindow(); onSelect(map); };
widget.GetWidget<ButtonWidget>("BUTTON_CANCEL").OnClick = () => { Widget.CloseWindow(); onExit(); };
widget.GetWidget<ButtonWidget>("BUTTON_OK").OnClick = () => { Ui.CloseWindow(); onSelect(map); };
widget.GetWidget<ButtonWidget>("BUTTON_CANCEL").OnClick = () => { Ui.CloseWindow(); onExit(); };
scrollpanel = widget.GetWidget<ScrollPanelWidget>("MAP_LIST");
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.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]];
// Mod list
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.RunAfterTick(() =>
{
Widget.CloseWindow();
Ui.CloseWindow();
onSwitch();
Game.InitializeWithMods(mods);
});

View File

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

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 = Widget.RootWidget;
var r = Ui.RootWidget;
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 = Widget.RootWidget;
var r = Ui.RootWidget;
var perfRoot = r.GetWidget("PERF_BG");
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");
backButton = panel.GetWidget<ButtonWidget>("BACK_BUTTON");
backButton.OnClick = Widget.CloseWindow;
backButton.OnClick = Ui.CloseWindow;
retryButton = panel.GetWidget<ButtonWidget>("RETRY_BUTTON");
retryButton.OnClick = CheckForDisk;
@@ -105,7 +105,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.RunAfterTick(() =>
{
Widget.CloseWindow();
Ui.CloseWindow();
continueLoading();
});
}

View File

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

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
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 replayDir = Path.Combine(Platform.SupportDir, "Replays");
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (currentReplay != null)
{
Game.JoinReplay(currentReplay.Filename);
Widget.CloseWindow();
Ui.CloseWindow();
onStart();
}
};

View File

@@ -64,11 +64,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var host = currentServer.Address.Split(':')[0];
var port = int.Parse(currentServer.Address.Split(':')[1]);
Widget.CloseWindow();
Ui.CloseWindow();
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
serverTemplate = sl.GetWidget<ScrollItemWidget>("SERVER_TEMPLATE");

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
this.onExit = onExit;
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;
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 = () =>
{
Widget.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs()
Ui.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs()
{
{ "initialMap", map.Uid },
{ "onExit", () => {} },
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
// Create and join the server
Game.CreateServer(settings);
Widget.CloseWindow();
Ui.CloseWindow();
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()
{
bg = Widget.RootWidget.GetWidget<BackgroundWidget>("SETTINGS_MENU");
bg = Ui.RootWidget.GetWidget<BackgroundWidget>("SETTINGS_MENU");
var tabs = bg.GetWidget<ContainerWidget>("TAB_CONTAINER");
//Tabs
@@ -122,7 +122,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
int.TryParse(windowHeight.Text, out y);
gs.WindowedSize = new int2(x,y);
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.WinState != WinState.Undefined ) return;
var radarBin = Widget.RootWidget.GetWidget<RadarBinWidget>(RadarBin);
var radarBin = Ui.RootWidget.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 = Widget.RootWidget.GetWidget<WorldInteractionControllerWidget>(WorldInteractionController);
var controller = Ui.RootWidget.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 = Widget.RootWidget.GetWidget<WorldInteractionControllerWidget>(WorldInteractionController);
var controller = Ui.RootWidget.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 = Widget.RootWidget.GetWidget<BuildPaletteWidget>("INGAME_BUILD_PALETTE");
var palette = Ui.RootWidget.GetWidget<BuildPaletteWidget>("INGAME_BUILD_PALETTE");
if (palette == null)
return;