spliit CncDirectConnectLogic into its own file

This commit is contained in:
Chris Forbes
2011-09-25 15:02:38 +13:00
parent 07175277f1
commit 54922a74b1
3 changed files with 49 additions and 32 deletions

View File

@@ -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<TextFieldWidget>("IP");
var portField = panel.GetWidget<TextFieldWidget>("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<ButtonWidget>("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<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); };
}
}
}