From 33b35f768e1e7f749d0efd3bd230ff60f7d6e276 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 8 May 2011 18:45:52 +1200 Subject: [PATCH] Nits --- OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs | 24 +++++++------------ OpenRA.Mods.Cnc/Widgets/CncMapChooserLogic.cs | 2 +- .../Widgets/CncReplayBrowserLogic.cs | 22 ++++++++--------- .../Widgets/CncServerBrowserLogic.cs | 4 ++-- 4 files changed, 23 insertions(+), 29 deletions(-) diff --git a/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs b/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs index 678beda33c..c18b2e3a73 100755 --- a/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs @@ -30,17 +30,17 @@ namespace OpenRA.Mods.Cnc.Widgets Dictionary CountryNames; string MapUid; Map Map; - - public static ColorRamp CurrentColorPreview; - // Must be set only once on game start - // TODO: This is stupid + readonly Action OnGameStart; + readonly Action onExit; + readonly OrderManager orderManager; + readonly WorldRenderer worldRenderer; + + public static ColorRamp CurrentColorPreview; static bool staticSetup; - public static CncLobbyLogic GetHandler() { var panel = Widget.RootWidget.GetWidget("SERVER_LOBBY"); - // The panel may not be open anymore if (panel == null) return null; @@ -63,7 +63,7 @@ namespace OpenRA.Mods.Cnc.Widgets if (handler == null) return; - handler.onGameStart(); + handler.OnGameStart(); } static void AddChatLineStub(Color c, string from, string text) @@ -84,7 +84,6 @@ namespace OpenRA.Mods.Cnc.Widgets handler.ConnectionStateChanged(om); } - // Listen for connection failures void ConnectionStateChanged(OrderManager om) { @@ -98,7 +97,7 @@ namespace OpenRA.Mods.Cnc.Widgets Game.OpenWindow("SERVER_LOBBY", new Dictionary() { { "onExit", onExit }, - { "onStart", onGameStart } + { "onStart", OnGameStart } }); }); @@ -118,11 +117,6 @@ namespace OpenRA.Mods.Cnc.Widgets } } - readonly Action onGameStart; - readonly Action onExit; - readonly OrderManager orderManager; - readonly WorldRenderer worldRenderer; - [ObjectCreator.UseCtor] internal CncLobbyLogic([ObjectCreator.Param( "widget" )] Widget lobby, [ObjectCreator.Param] OrderManager orderManager, @@ -132,7 +126,7 @@ namespace OpenRA.Mods.Cnc.Widgets { this.orderManager = orderManager; this.worldRenderer = worldRenderer; - this.onGameStart = onStart; + this.OnGameStart = onStart; this.onExit = onExit; if (!staticSetup) diff --git a/OpenRA.Mods.Cnc/Widgets/CncMapChooserLogic.cs b/OpenRA.Mods.Cnc/Widgets/CncMapChooserLogic.cs index 1cc7d8f96e..083fabb678 100644 --- a/OpenRA.Mods.Cnc/Widgets/CncMapChooserLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncMapChooserLogic.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.Cnc.Widgets { public class CncMapChooserLogic : IWidgetDelegate { - Map map = null; + Map map; Widget scrollpanel; Widget itemTemplate; diff --git a/OpenRA.Mods.Cnc/Widgets/CncReplayBrowserLogic.cs b/OpenRA.Mods.Cnc/Widgets/CncReplayBrowserLogic.cs index cb8f300598..638e972607 100644 --- a/OpenRA.Mods.Cnc/Widgets/CncReplayBrowserLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncReplayBrowserLogic.cs @@ -22,21 +22,21 @@ namespace OpenRA.Mods.Cnc.Widgets { public class CncReplayBrowserLogic : IWidgetDelegate { - Widget widget; + Widget panel; [ObjectCreator.UseCtor] public CncReplayBrowserLogic([ObjectCreator.Param] Widget widget, [ObjectCreator.Param] Action onExit, [ObjectCreator.Param] Action onStart) { - this.widget = widget; + panel = widget.GetWidget("REPLAYBROWSER_PANEL"); - widget.GetWidget("CANCEL_BUTTON").OnClick = onExit; + panel.GetWidget("CANCEL_BUTTON").OnClick = onExit; - var rl = widget.GetWidget("REPLAY_LIST"); + var rl = panel.GetWidget("REPLAY_LIST"); var replayDir = Path.Combine(Platform.SupportDir, "Replays"); - var template = widget.GetWidget("REPLAY_TEMPLATE"); + var template = panel.GetWidget("REPLAY_TEMPLATE"); CurrentReplay = null; rl.RemoveChildren(); @@ -49,7 +49,7 @@ namespace OpenRA.Mods.Cnc.Widgets CurrentReplay = files.FirstOrDefault(); } - var watch = widget.GetWidget("WATCH_BUTTON"); + var watch = panel.GetWidget("WATCH_BUTTON"); watch.IsDisabled = () => currentReplay == null || currentMap == null; watch.OnClick = () => { @@ -60,7 +60,7 @@ namespace OpenRA.Mods.Cnc.Widgets } }; - widget.GetWidget("REPLAY_INFO").IsVisible = () => currentReplay != null; + panel.GetWidget("REPLAY_INFO").IsVisible = () => currentReplay != null; } string currentReplay = null; @@ -78,14 +78,14 @@ namespace OpenRA.Mods.Cnc.Widgets var summary = new ReplaySummary(currentReplay); currentMap = summary.Map(); - widget.GetWidget("DURATION").GetText = + panel.GetWidget("DURATION").GetText = () => WidgetUtils.FormatTime(summary.Duration * 3 /* todo: 3:1 ratio isnt always true. */); - widget.GetWidget("MAP_PREVIEW").Map = () => currentMap; - widget.GetWidget("MAP_TITLE").GetText = + panel.GetWidget("MAP_PREVIEW").Map = () => currentMap; + panel.GetWidget("MAP_TITLE").GetText = () => currentMap != null ? currentMap.Title : "(Unknown Map)"; var players = summary.LobbyInfo.Slots.Count(s => summary.LobbyInfo.ClientInSlot(s) != null || s.Bot != null); - widget.GetWidget("PLAYERS").GetText = () => players.ToString(); + panel.GetWidget("PLAYERS").GetText = () => players.ToString(); } catch(Exception e) { diff --git a/OpenRA.Mods.Cnc/Widgets/CncServerBrowserLogic.cs b/OpenRA.Mods.Cnc/Widgets/CncServerBrowserLogic.cs index 8ccc44c185..883239ac8a 100644 --- a/OpenRA.Mods.Cnc/Widgets/CncServerBrowserLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncServerBrowserLogic.cs @@ -23,8 +23,8 @@ namespace OpenRA.Mods.Cnc.Widgets { // Prevent repeated additions of RefreshServerList to the master server static bool masterServerSetup; - - GameServer currentServer = null; + + GameServer currentServer; Widget serverTemplate; enum SearchStatus