From 54922a74b1a7fb6a585a578bc3d963495b77bb36 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 25 Sep 2011 15:02:38 +1300 Subject: [PATCH] spliit CncDirectConnectLogic into its own file --- OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj | 1 + .../Widgets/Logic/CncDirectConnectLogic.cs | 48 +++++++++++++++++++ .../Widgets/Logic/CncServerBrowserLogic.cs | 32 ------------- 3 files changed, 49 insertions(+), 32 deletions(-) create mode 100644 OpenRA.Mods.Cnc/Widgets/Logic/CncDirectConnectLogic.cs diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj index 543a58a997..b171b7ac55 100644 --- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj +++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj @@ -107,6 +107,7 @@ + diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncDirectConnectLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncDirectConnectLogic.cs new file mode 100644 index 0000000000..d4f5a3859a --- /dev/null +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncDirectConnectLogic.cs @@ -0,0 +1,48 @@ +#region Copyright & License Information +/* + * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using System; +using System.Linq; +using OpenRA.Widgets; + +namespace OpenRA.Mods.Cnc.Widgets.Logic +{ + public class CncDirectConnectLogic + { + [ObjectCreator.UseCtor] + public CncDirectConnectLogic([ObjectCreator.Param] Widget widget, + [ObjectCreator.Param] Action onExit, + [ObjectCreator.Param] Action openLobby) + { + var panel = widget.GetWidget("DIRECTCONNECT_PANEL"); + var ipField = panel.GetWidget("IP"); + var portField = panel.GetWidget("PORT"); + + var last = Game.Settings.Player.LastServer.Split(':').ToArray(); + ipField.Text = last.Length > 1 ? last[0] : "localhost"; + portField.Text = last.Length > 2 ? last[1] : "1234"; + + panel.GetWidget("JOIN_BUTTON").OnClick = () => + { + int port; + if (!int.TryParse(portField.Text, out port)) + port = 1234; + + Game.Settings.Player.LastServer = "{0}:{1}".F(ipField.Text, port); + Game.Settings.Save(); + + Widget.CloseWindow(); + CncConnectingLogic.Connect(ipField.Text, port, openLobby, onExit); + }; + + panel.GetWidget("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); }; + } + } +} diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncServerBrowserLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncServerBrowserLogic.cs index eb3c019077..d2b4cb8ae7 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncServerBrowserLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncServerBrowserLogic.cs @@ -159,36 +159,4 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic } } } - - public class CncDirectConnectLogic - { - [ObjectCreator.UseCtor] - public CncDirectConnectLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] Action onExit, - [ObjectCreator.Param] Action openLobby) - { - var panel = widget.GetWidget("DIRECTCONNECT_PANEL"); - var ipField = panel.GetWidget("IP"); - var portField = panel.GetWidget("PORT"); - - var last = Game.Settings.Player.LastServer.Split(':').ToArray(); - ipField.Text = last.Length > 1 ? last[0] : "localhost"; - portField.Text = last.Length > 2 ? last[1] : "1234"; - - panel.GetWidget("JOIN_BUTTON").OnClick = () => - { - int port; - if (!int.TryParse(portField.Text, out port)) - port = 1234; - - Game.Settings.Player.LastServer = "{0}:{1}".F(ipField.Text, port); - Game.Settings.Save(); - - Widget.CloseWindow(); - CncConnectingLogic.Connect(ipField.Text, port, openLobby, onExit); - }; - - panel.GetWidget("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); }; - } - } }