Add a WidgetArgs type to work around gmcs not understanding lambda -> Action -> object.

This commit is contained in:
Paul Chote
2011-05-13 09:41:21 +12:00
parent 603379aa96
commit f4ea4c5daa
17 changed files with 85 additions and 79 deletions

View File

@@ -98,14 +98,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 Dictionary<string,object>{{ "world", world }, { "orderManager", orderManager }, { "worldRenderer", worldRenderer }}); return Widget.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, Dictionary<string, object> args) public static Widget OpenWindow(string widget, WidgetArgs args)
{ {
return Widget.OpenWindow(widget, new Dictionary<string,object>(args) return Widget.OpenWindow(widget, new WidgetArgs(args)
{ {
{ "world", worldRenderer.world }, { "world", worldRenderer.world },
{ "orderManager", orderManager }, { "orderManager", orderManager },
@@ -113,9 +113,9 @@ namespace OpenRA
}); });
} }
public static Widget LoadWidget(World world, string widget, Dictionary<string, object> args) public static Widget LoadWidget(World world, string widget, WidgetArgs args)
{ {
return Widget.LoadWidget(widget, new Dictionary<string,object>(args) return Widget.LoadWidget(widget, new WidgetArgs(args)
{ {
{ "world", world }, { "world", world },
{ "orderManager", orderManager }, { "orderManager", orderManager },

View File

@@ -121,7 +121,7 @@ namespace OpenRA.Widgets
height); height);
} }
public void PostInit(Dictionary<string, object> args) public void PostInit(WidgetArgs args)
{ {
if (Delegate == null) if (Delegate == null)
return; return;
@@ -322,10 +322,10 @@ namespace OpenRA.Widgets
public static Widget OpenWindow(string id) public static Widget OpenWindow(string id)
{ {
return OpenWindow(id, new Dictionary<string, object>()); return OpenWindow(id, new WidgetArgs());
} }
public static Widget OpenWindow(string id, Dictionary<string, object> args) public static Widget OpenWindow(string id, WidgetArgs args)
{ {
var window = Game.modData.WidgetLoader.LoadWidget(args, rootWidget, id); var window = Game.modData.WidgetLoader.LoadWidget(args, rootWidget, id);
if (WindowList.Count > 0) if (WindowList.Count > 0)
@@ -334,7 +334,7 @@ namespace OpenRA.Widgets
return window; return window;
} }
public static Widget LoadWidget(string id, Dictionary<string, object> args) public static Widget LoadWidget(string id, WidgetArgs args)
{ {
return Game.modData.WidgetLoader.LoadWidget(args, rootWidget, id); return Game.modData.WidgetLoader.LoadWidget(args, rootWidget, id);
} }
@@ -378,7 +378,14 @@ namespace OpenRA.Widgets
public override string GetCursor(int2 pos) { return null; } public override string GetCursor(int2 pos) { return null; }
public override Widget Clone() { return new ContainerWidget(this); } public override Widget Clone() { return new ContainerWidget(this); }
} }
public class WidgetArgs : Dictionary<string, object>
{
public WidgetArgs() : base() { }
public WidgetArgs(Dictionary<string, object> args) : base(args) { }
public void Add(string key, Action val) { base.Add(key, val); }
}
public interface IWidgetDelegate { } public interface IWidgetDelegate { }
// TODO: This can die once ra init is sane // TODO: This can die once ra init is sane

View File

@@ -32,7 +32,7 @@ namespace OpenRA
} }
} }
public Widget LoadWidget( Dictionary<string, object> args, Widget parent, string w ) public Widget LoadWidget( WidgetArgs args, Widget parent, string w )
{ {
MiniYamlNode ret; MiniYamlNode ret;
if (!widgets.TryGetValue(w, out ret)) if (!widgets.TryGetValue(w, out ret))
@@ -41,7 +41,7 @@ namespace OpenRA
return LoadWidget( args, parent, ret ); return LoadWidget( args, parent, ret );
} }
public Widget LoadWidget( Dictionary<string, object> args, Widget parent, MiniYamlNode node) public Widget LoadWidget( WidgetArgs args, Widget parent, MiniYamlNode node)
{ {
var widget = NewWidget(node.Key, args); var widget = NewWidget(node.Key, args);
@@ -63,7 +63,7 @@ namespace OpenRA
return widget; return widget;
} }
Widget NewWidget(string widgetType, Dictionary<string, object> args) Widget NewWidget(string widgetType, WidgetArgs args)
{ {
widgetType = widgetType.Split('@')[0]; widgetType = widgetType.Split('@')[0];
return Game.modData.ObjectCreator.CreateObject<Widget>(widgetType + "Widget", args); return Game.modData.ObjectCreator.CreateObject<Widget>(widgetType + "Widget", args);

View File

@@ -85,9 +85,9 @@ namespace OpenRA.Mods.Cnc
Widget.RootWidget.RemoveChildren(); Widget.RootWidget.RemoveChildren();
if (!FileSystem.Exists(Info["TestFile"])) if (!FileSystem.Exists(Info["TestFile"]))
{ {
var args = new Dictionary<string, object>() var args = new WidgetArgs()
{ {
{ "continueLoading", (Action)(() => TestAndContinue()) }, { "continueLoading", () => TestAndContinue() },
{ "installData", Info } { "installData", Info }
}; };
Widget.LoadWidget(Info["InstallerBackgroundWidget"], args); Widget.LoadWidget(Info["InstallerBackgroundWidget"], args);

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Cnc.Widgets
{ {
// Show connection failed dialog // Show connection failed dialog
Widget.CloseWindow(); Widget.CloseWindow();
Widget.OpenWindow("CONNECTIONFAILED_PANEL", new Dictionary<string, object>() Widget.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs()
{ {
{ "onAbort", onAbort }, { "onAbort", onAbort },
{ "onRetry", onRetry }, { "onRetry", onRetry },
@@ -85,13 +85,13 @@ namespace OpenRA.Mods.Cnc.Widgets
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 Dictionary<string, object>() Widget.OpenWindow("CONNECTING_PANEL", new WidgetArgs()
{ {
{ "host", host }, { "host", host },
{ "port", port }, { "port", port },
{ "onConnect", onConnect }, { "onConnect", onConnect },
{ "onAbort", onAbort }, { "onAbort", onAbort },
{ "onRetry", new Action(() => Connect(host, port, onConnect, onAbort)) } { "onRetry", () => Connect(host, port, onConnect, onAbort) }
}); });
} }
} }

View File

@@ -59,8 +59,7 @@ namespace OpenRA.Mods.Cnc.Widgets
ingameRoot.GetWidget<CncMenuButtonWidget>("OPTIONS_BUTTON").OnClick = () => ingameRoot.GetWidget<CncMenuButtonWidget>("OPTIONS_BUTTON").OnClick = () =>
{ {
ingameRoot.IsVisible = () => false; ingameRoot.IsVisible = () => false;
var onExit = new Action(() => {ingameRoot.IsVisible = () => true;}); Widget.LoadWidget("INGAME_MENU", new WidgetArgs() {{ "world", world }, { "onExit", () => ingameRoot.IsVisible = () => true }});
Widget.LoadWidget("INGAME_MENU", new Dictionary<string, object>() {{ "world", world }, { "onExit", onExit }});
}; };
var postgameBG = ingameRoot.GetWidget("POSTGAME_BG"); var postgameBG = ingameRoot.GetWidget("POSTGAME_BG");
@@ -93,19 +92,19 @@ namespace OpenRA.Mods.Cnc.Widgets
bool hideButtons = false; bool hideButtons = false;
menu.GetWidget("MENU_BUTTONS").IsVisible = () => !hideButtons; menu.GetWidget("MENU_BUTTONS").IsVisible = () => !hideButtons;
var onQuit = (Action)(() => Action onQuit = () =>
{ {
Game.DisconnectOnly(); Game.DisconnectOnly();
Widget.RootWidget.RemoveChildren(); Widget.RootWidget.RemoveChildren();
Game.LoadShellMap(); Game.LoadShellMap();
}); };
var doNothing = (Action)(() => {}); Action doNothing = () => {};
menu.GetWidget<CncMenuButtonWidget>("QUIT_BUTTON").OnClick = () => menu.GetWidget<CncMenuButtonWidget>("QUIT_BUTTON").OnClick = () =>
PromptConfirmAction("Quit", "Are you sure you want to quit?", onQuit, doNothing); PromptConfirmAction("Quit", "Are you sure you want to quit?", onQuit, doNothing);
var onSurrender = (Action)(() => world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false))); Action onSurrender = () => world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
var surrenderButton = menu.GetWidget<CncMenuButtonWidget>("SURRENDER_BUTTON"); var surrenderButton = menu.GetWidget<CncMenuButtonWidget>("SURRENDER_BUTTON");
surrenderButton.IsDisabled = () => (world.LocalPlayer == null || world.LocalPlayer.WinState != WinState.Undefined); surrenderButton.IsDisabled = () => (world.LocalPlayer == null || world.LocalPlayer.WinState != WinState.Undefined);
surrenderButton.OnClick = () => surrenderButton.OnClick = () =>
@@ -114,18 +113,18 @@ namespace OpenRA.Mods.Cnc.Widgets
menu.GetWidget<CncMenuButtonWidget>("MUSIC_BUTTON").OnClick = () => menu.GetWidget<CncMenuButtonWidget>("MUSIC_BUTTON").OnClick = () =>
{ {
hideButtons = true; hideButtons = true;
Widget.OpenWindow("MUSIC_PANEL", new Dictionary<string, object>() Widget.OpenWindow("MUSIC_PANEL", new WidgetArgs()
{ {
{ "onExit", new Action(() => hideButtons = false) }, { "onExit", () => hideButtons = false },
}); });
}; };
menu.GetWidget<CncMenuButtonWidget>("PREFERENCES_BUTTON").OnClick = () => menu.GetWidget<CncMenuButtonWidget>("PREFERENCES_BUTTON").OnClick = () =>
{ {
hideButtons = true; hideButtons = true;
Widget.OpenWindow("SETTINGS_PANEL", new Dictionary<string, object>() Widget.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
{ {
{ "onExit", new Action(() => hideButtons = false) }, { "onExit", () => hideButtons = false },
}); });
}; };

View File

@@ -29,9 +29,9 @@ namespace OpenRA.Mods.Cnc.Widgets
[ObjectCreator.Param] Action continueLoading) [ObjectCreator.Param] Action continueLoading)
{ {
var panel = widget.GetWidget("INSTALL_PANEL"); var panel = widget.GetWidget("INSTALL_PANEL");
var args = new Dictionary<string, object>() var args = new WidgetArgs()
{ {
{ "continueLoading", new Action(() => { Widget.CloseWindow(); continueLoading(); }) }, { "continueLoading", () => { Widget.CloseWindow(); continueLoading(); } },
{ "installData", installData } { "installData", installData }
}; };
@@ -46,11 +46,11 @@ namespace OpenRA.Mods.Cnc.Widgets
// TODO: // TODO:
panel.GetWidget<CncMenuButtonWidget>("MODS_BUTTON").OnClick = () => panel.GetWidget<CncMenuButtonWidget>("MODS_BUTTON").OnClick = () =>
{ {
Widget.OpenWindow("MODS_PANEL", new Dictionary<string, object>() Widget.OpenWindow("MODS_PANEL", new WidgetArgs()
{ {
{ "onExit", new Action(() => {}) }, { "onExit", () => {} },
// Close this panel // Close this panel
{ "onSwitch", new Action(Widget.CloseWindow) }, { "onSwitch", Widget.CloseWindow },
}); });
}; };
} }

View File

@@ -92,22 +92,22 @@ namespace OpenRA.Mods.Cnc.Widgets
// Show connection failed dialog // Show connection failed dialog
Widget.CloseWindow(); Widget.CloseWindow();
Action onConnect = new Action(() => Action onConnect = () =>
{ {
Game.OpenWindow("SERVER_LOBBY", new Dictionary<string, object>() Game.OpenWindow("SERVER_LOBBY", new WidgetArgs()
{ {
{ "onExit", onExit }, { "onExit", onExit },
{ "onStart", OnGameStart } { "onStart", OnGameStart }
}); });
}); };
Action onRetry = new Action(() => Action onRetry = () =>
{ {
Widget.CloseWindow(); Widget.CloseWindow();
CncConnectingLogic.Connect(om.Host, om.Port, onConnect, onExit); CncConnectingLogic.Connect(om.Host, om.Port, onConnect, onExit);
}); };
Widget.OpenWindow("CONNECTIONFAILED_PANEL", new Dictionary<string, object>() Widget.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs()
{ {
{ "onAbort", onExit }, { "onAbort", onExit },
{ "onRetry", onRetry }, { "onRetry", onRetry },
@@ -197,10 +197,10 @@ namespace OpenRA.Mods.Cnc.Widgets
Game.Settings.Save(); Game.Settings.Save();
}); });
Widget.OpenWindow( "MAPCHOOSER_PANEL", new Dictionary<string, object> Widget.OpenWindow( "MAPCHOOSER_PANEL", new WidgetArgs()
{ {
{ "initialMap", Map.Uid }, { "initialMap", Map.Uid },
{ "onExit", new Action(() => {}) }, { "onExit", () => {} },
{ "onSelect", onSelect } { "onSelect", onSelect }
}); });
}; };
@@ -406,7 +406,7 @@ namespace OpenRA.Mods.Cnc.Widgets
if (Map.Players[s.MapPlayer].LockColor) if (Map.Players[s.MapPlayer].LockColor)
return false; return false;
var colorChooser = Game.modData.WidgetLoader.LoadWidget( new Dictionary<string,object>() { {"worldRenderer", worldRenderer} }, null, "COLOR_CHOOSER" ); var colorChooser = Game.modData.WidgetLoader.LoadWidget( new WidgetArgs() { {"worldRenderer", worldRenderer} }, null, "COLOR_CHOOSER" );
var hueSlider = colorChooser.GetWidget<SliderWidget>("HUE_SLIDER"); var hueSlider = colorChooser.GetWidget<SliderWidget>("HUE_SLIDER");
hueSlider.SetOffset(orderManager.LocalClient.ColorRamp.H / 255f); hueSlider.SetOffset(orderManager.LocalClient.ColorRamp.H / 255f);

View File

@@ -50,10 +50,10 @@ namespace OpenRA.Mods.Cnc.Widgets
mainMenu.GetWidget<CncMenuButtonWidget>("REPLAYS_BUTTON").OnClick = () => mainMenu.GetWidget<CncMenuButtonWidget>("REPLAYS_BUTTON").OnClick = () =>
{ {
Menu = MenuType.None; Menu = MenuType.None;
Widget.OpenWindow("REPLAYBROWSER_PANEL", new Dictionary<string, object>() Widget.OpenWindow("REPLAYBROWSER_PANEL", new WidgetArgs()
{ {
{ "onExit", new Action(() => Menu = MenuType.Main) }, { "onExit", () => Menu = MenuType.Main },
{ "onStart", new Action(RemoveShellmapUI) } { "onStart", RemoveShellmapUI }
}); });
}; };
@@ -68,30 +68,30 @@ namespace OpenRA.Mods.Cnc.Widgets
multiplayerMenu.GetWidget<CncMenuButtonWidget>("JOIN_BUTTON").OnClick = () => multiplayerMenu.GetWidget<CncMenuButtonWidget>("JOIN_BUTTON").OnClick = () =>
{ {
Menu = MenuType.None; Menu = MenuType.None;
Widget.OpenWindow("SERVERBROWSER_PANEL", new Dictionary<string, object>() Widget.OpenWindow("SERVERBROWSER_PANEL", new WidgetArgs()
{ {
{ "onExit", new Action(() => Menu = MenuType.Multiplayer) }, { "onExit", () => Menu = MenuType.Multiplayer },
{ "openLobby", new Action(() => OpenLobbyPanel(MenuType.Multiplayer)) } { "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer) }
}); });
}; };
multiplayerMenu.GetWidget<CncMenuButtonWidget>("CREATE_BUTTON").OnClick = () => multiplayerMenu.GetWidget<CncMenuButtonWidget>("CREATE_BUTTON").OnClick = () =>
{ {
Menu = MenuType.None; Menu = MenuType.None;
Widget.OpenWindow("CREATESERVER_PANEL", new Dictionary<string, object>() Widget.OpenWindow("CREATESERVER_PANEL", new WidgetArgs()
{ {
{ "onExit", new Action(() => Menu = MenuType.Multiplayer) }, { "onExit", () => Menu = MenuType.Multiplayer },
{ "openLobby", new Action(() => OpenLobbyPanel(MenuType.Multiplayer)) } { "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer) }
}); });
}; };
multiplayerMenu.GetWidget<CncMenuButtonWidget>("DIRECTCONNECT_BUTTON").OnClick = () => multiplayerMenu.GetWidget<CncMenuButtonWidget>("DIRECTCONNECT_BUTTON").OnClick = () =>
{ {
Menu = MenuType.None; Menu = MenuType.None;
Widget.OpenWindow("DIRECTCONNECT_PANEL", new Dictionary<string, object>() Widget.OpenWindow("DIRECTCONNECT_PANEL", new WidgetArgs()
{ {
{ "onExit", new Action(() => Menu = MenuType.Multiplayer) }, { "onExit", () => Menu = MenuType.Multiplayer },
{ "openLobby", new Action(() => OpenLobbyPanel(MenuType.Multiplayer)) } { "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer) }
}); });
}; };
@@ -102,28 +102,28 @@ namespace OpenRA.Mods.Cnc.Widgets
settingsMenu.GetWidget<CncMenuButtonWidget>("MODS_BUTTON").OnClick = () => settingsMenu.GetWidget<CncMenuButtonWidget>("MODS_BUTTON").OnClick = () =>
{ {
Menu = MenuType.None; Menu = MenuType.None;
Widget.OpenWindow("MODS_PANEL", new Dictionary<string, object>() Widget.OpenWindow("MODS_PANEL", new WidgetArgs()
{ {
{ "onExit", new Action(() => Menu = MenuType.Settings) }, { "onExit", () => Menu = MenuType.Settings },
{ "onSwitch", new Action(RemoveShellmapUI) } { "onSwitch", RemoveShellmapUI }
}); });
}; };
settingsMenu.GetWidget<CncMenuButtonWidget>("MUSIC_BUTTON").OnClick = () => settingsMenu.GetWidget<CncMenuButtonWidget>("MUSIC_BUTTON").OnClick = () =>
{ {
Menu = MenuType.None; Menu = MenuType.None;
Widget.OpenWindow("MUSIC_PANEL", new Dictionary<string, object>() Widget.OpenWindow("MUSIC_PANEL", new WidgetArgs()
{ {
{ "onExit", new Action(() => Menu = MenuType.Settings) }, { "onExit", () => Menu = MenuType.Settings },
}); });
}; };
settingsMenu.GetWidget<CncMenuButtonWidget>("PREFERENCES_BUTTON").OnClick = () => settingsMenu.GetWidget<CncMenuButtonWidget>("PREFERENCES_BUTTON").OnClick = () =>
{ {
Menu = MenuType.None; Menu = MenuType.None;
Widget.OpenWindow("SETTINGS_PANEL", new Dictionary<string, object>() Widget.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
{ {
{ "onExit", new Action(() => Menu = MenuType.Settings) }, { "onExit", () => Menu = MenuType.Settings },
}); });
}; };
settingsMenu.GetWidget<CncMenuButtonWidget>("BACK_BUTTON").OnClick = () => Menu = MenuType.Main; settingsMenu.GetWidget<CncMenuButtonWidget>("BACK_BUTTON").OnClick = () => Menu = MenuType.Main;
@@ -138,10 +138,10 @@ namespace OpenRA.Mods.Cnc.Widgets
void OpenLobbyPanel(MenuType menu) void OpenLobbyPanel(MenuType menu)
{ {
Menu = MenuType.None; Menu = MenuType.None;
Game.OpenWindow("SERVER_LOBBY", new Dictionary<string, object>() Game.OpenWindow("SERVER_LOBBY", new WidgetArgs()
{ {
{ "onExit", new Action(() => { Game.DisconnectOnly(); Menu = menu; }) }, { "onExit", () => { Game.DisconnectOnly(); Menu = menu; } },
{ "onStart", new Action(RemoveShellmapUI) } { "onStart", RemoveShellmapUI }
}); });
} }
@@ -152,8 +152,8 @@ namespace OpenRA.Mods.Cnc.Widgets
Game.CreateLocalServer(map); Game.CreateLocalServer(map);
CncConnectingLogic.Connect(IPAddress.Loopback.ToString(), CncConnectingLogic.Connect(IPAddress.Loopback.ToString(),
Game.Settings.Server.LoopbackPort, Game.Settings.Server.LoopbackPort,
new Action(() => OpenLobbyPanel(MenuType.Main)), () => OpenLobbyPanel(MenuType.Main),
new Action(() => { Game.CloseServer(); Menu = MenuType.Main; })); () => { Game.CloseServer(); Menu = MenuType.Main; });
} }
} }
} }

View File

@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Cnc.Widgets
var installButton = panel.GetWidget<CncMenuButtonWidget>("INSTALL_BUTTON"); var installButton = panel.GetWidget<CncMenuButtonWidget>("INSTALL_BUTTON");
installButton.OnClick = () => installButton.OnClick = () =>
Widget.OpenWindow("INSTALL_MUSIC_PANEL", new Dictionary<string, object>() {{ "afterInstall", afterInstall }}); Widget.OpenWindow("INSTALL_MUSIC_PANEL", new WidgetArgs() {{ "afterInstall", afterInstall }});
installButton.IsVisible = () => music.Length < 2; // Hack around ra shipping (only) hellmarch by default installButton.IsVisible = () => music.Length < 2; // Hack around ra shipping (only) hellmarch by default
panel.GetWidget("NO_MUSIC_LABEL").IsVisible = noMusic; panel.GetWidget("NO_MUSIC_LABEL").IsVisible = noMusic;

View File

@@ -38,10 +38,10 @@ namespace OpenRA.Mods.Cnc.Widgets
panel.GetWidget<CncMenuButtonWidget>("MAP_BUTTON").OnClick = () => panel.GetWidget<CncMenuButtonWidget>("MAP_BUTTON").OnClick = () =>
{ {
Widget.OpenWindow( "MAPCHOOSER_PANEL", new Dictionary<string, object> Widget.OpenWindow( "MAPCHOOSER_PANEL", new WidgetArgs()
{ {
{ "initialMap", map.Uid }, { "initialMap", map.Uid },
{ "onExit", new Action(() => {}) }, { "onExit", () => {} },
{ "onSelect", new Action<Map>(m => map = m) } { "onSelect", new Action<Map>(m => map = m) }
}); });
}; };

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
public void StartGame() public void StartGame()
{ {
Widget.RootWidget.RemoveChildren(); Widget.RootWidget.RemoveChildren();
Game.modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "INIT_SETUP" ); Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "INIT_SETUP" );
} }
} }
} }

View File

@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA
public void WorldLoaded(World world) public void WorldLoaded(World world)
{ {
Game.LoadWidget(world, Info.Widget, new Dictionary<string, object>()); Game.LoadWidget(world, Info.Widget, new WidgetArgs());
} }
} }
} }

View File

@@ -70,7 +70,7 @@ namespace OpenRA.Mods.RA
public void StartGame() public void StartGame()
{ {
Widget.RootWidget.RemoveChildren(); Widget.RootWidget.RemoveChildren();
Game.modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "INIT_SETUP" ); Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "INIT_SETUP" );
} }
} }
} }

View File

@@ -42,15 +42,15 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
switch (orderManager.Connection.ConnectionState) switch (orderManager.Connection.ConnectionState)
{ {
case ConnectionState.PreConnecting: case ConnectionState.PreConnecting:
Widget.LoadWidget("MAINMENU_BG", new Dictionary<string, object>()); Widget.LoadWidget("MAINMENU_BG", new WidgetArgs());
break; break;
case ConnectionState.Connecting: case ConnectionState.Connecting:
Widget.OpenWindow("CONNECTING_BG", Widget.OpenWindow("CONNECTING_BG",
new Dictionary<string, object> { { "host", orderManager.Host }, { "port", orderManager.Port } }); new WidgetArgs() { { "host", orderManager.Host }, { "port", orderManager.Port } });
break; break;
case ConnectionState.NotConnected: case ConnectionState.NotConnected:
Widget.OpenWindow("CONNECTION_FAILED_BG", Widget.OpenWindow("CONNECTION_FAILED_BG",
new Dictionary<string, object> { { "orderManager", orderManager } }); new WidgetArgs() { { "orderManager", orderManager } });
break; break;
case ConnectionState.Connected: case ConnectionState.Connected:
var lobby = Game.OpenWindow(orderManager.world, "SERVER_LOBBY"); var lobby = Game.OpenWindow(orderManager.world, "SERVER_LOBBY");

View File

@@ -92,7 +92,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
var mapButton = lobby.GetWidget("CHANGEMAP_BUTTON"); var mapButton = lobby.GetWidget("CHANGEMAP_BUTTON");
mapButton.OnMouseUp = mi => mapButton.OnMouseUp = mi =>
{ {
Widget.OpenWindow( "MAP_CHOOSER", new Dictionary<string, object> { { "orderManager", orderManager }, { "mapName", MapUid } } ); Widget.OpenWindow( "MAP_CHOOSER", new WidgetArgs() { { "orderManager", orderManager }, { "mapName", MapUid } } );
return true; return true;
}; };
@@ -281,7 +281,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
if (Map.Players[s.MapPlayer].LockColor) if (Map.Players[s.MapPlayer].LockColor)
return false; return false;
var colorChooser = Game.modData.WidgetLoader.LoadWidget( new Dictionary<string,object>() { {"worldRenderer", worldRenderer} }, null, "COLOR_CHOOSER" ); var colorChooser = Game.modData.WidgetLoader.LoadWidget( new WidgetArgs() { {"worldRenderer", worldRenderer} }, null, "COLOR_CHOOSER" );
var hueSlider = colorChooser.GetWidget<SliderWidget>("HUE_SLIDER"); var hueSlider = colorChooser.GetWidget<SliderWidget>("HUE_SLIDER");
hueSlider.SetOffset(orderManager.LocalClient.ColorRamp.H / 255f); hueSlider.SetOffset(orderManager.LocalClient.ColorRamp.H / 255f);

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public MainMenuButtonsDelegate([ObjectCreator.Param] Widget widget) public MainMenuButtonsDelegate([ObjectCreator.Param] Widget widget)
{ {
Game.modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "PERF_BG" ); Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "PERF_BG" );
widget.GetWidget("MAINMENU_BUTTON_JOIN").OnMouseUp = mi => { Widget.OpenWindow("JOINSERVER_BG"); return true; }; widget.GetWidget("MAINMENU_BUTTON_JOIN").OnMouseUp = mi => { Widget.OpenWindow("JOINSERVER_BG"); return true; };
widget.GetWidget("MAINMENU_BUTTON_CREATE").OnMouseUp = mi => { Widget.OpenWindow("CREATESERVER_BG"); return true; }; widget.GetWidget("MAINMENU_BUTTON_CREATE").OnMouseUp = mi => { Widget.OpenWindow("CREATESERVER_BG"); return true; };
widget.GetWidget("MAINMENU_BUTTON_SETTINGS").OnMouseUp = mi => { Widget.OpenWindow("SETTINGS_MENU"); return true; }; widget.GetWidget("MAINMENU_BUTTON_SETTINGS").OnMouseUp = mi => { Widget.OpenWindow("SETTINGS_MENU"); return true; };
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
public static void DisplayModSelector() public static void DisplayModSelector()
{ {
var selector = Game.modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "QUICKMODSWITCHER" ); var selector = Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "QUICKMODSWITCHER" );
var switcher = selector.GetWidget<ButtonWidget>("SWITCHER"); var switcher = selector.GetWidget<ButtonWidget>("SWITCHER");
switcher.OnMouseDown = _ => ShowModsDropDown(switcher); switcher.OnMouseDown = _ => ShowModsDropDown(switcher);
switcher.GetText = ActiveModTitle; switcher.GetText = ActiveModTitle;