DirectConnectLogic in its own file
This commit is contained in:
@@ -344,6 +344,7 @@
|
|||||||
<Compile Include="Widgets\Logic\PerfDebugLogic.cs" />
|
<Compile Include="Widgets\Logic\PerfDebugLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\RADownloadPackagesLogic.cs" />
|
<Compile Include="Widgets\Logic\RADownloadPackagesLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\RAInstallFromCDLogic.cs" />
|
<Compile Include="Widgets\Logic\RAInstallFromCDLogic.cs" />
|
||||||
|
<Compile Include="Widgets\Logic\DirectConnectLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\RAInstallLogic.cs" />
|
<Compile Include="Widgets\Logic\RAInstallLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\ReplayBrowserLogic.cs" />
|
<Compile Include="Widgets\Logic\ReplayBrowserLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\ServerBrowserLogic.cs" />
|
<Compile Include="Widgets\Logic\ServerBrowserLogic.cs" />
|
||||||
|
|||||||
51
OpenRA.Mods.RA/Widgets/Logic/DirectConnectLogic.cs
Normal file
51
OpenRA.Mods.RA/Widgets/Logic/DirectConnectLogic.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#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.Linq;
|
||||||
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.RA.Widgets.Logic
|
||||||
|
{
|
||||||
|
public class DirectConnectLogic
|
||||||
|
{
|
||||||
|
[ObjectCreator.UseCtor]
|
||||||
|
public DirectConnectLogic( [ObjectCreator.Param] Widget widget )
|
||||||
|
{
|
||||||
|
var dc = widget.GetWidget("DIRECTCONNECT_BG");
|
||||||
|
|
||||||
|
dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text = Game.Settings.Player.LastServer;
|
||||||
|
|
||||||
|
dc.GetWidget<ButtonWidget>("JOIN_BUTTON").OnClick = () =>
|
||||||
|
{
|
||||||
|
var address = dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text;
|
||||||
|
var cpts = address.Split(':').ToArray();
|
||||||
|
if (cpts.Length < 1 || cpts.Length > 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int port;
|
||||||
|
if (cpts.Length != 2 || !int.TryParse(cpts[1], out port))
|
||||||
|
port = 1234;
|
||||||
|
|
||||||
|
Game.Settings.Player.LastServer = address;
|
||||||
|
Game.Settings.Save();
|
||||||
|
|
||||||
|
Widget.CloseWindow();
|
||||||
|
Game.JoinServer(cpts[0], port);
|
||||||
|
};
|
||||||
|
|
||||||
|
dc.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () =>
|
||||||
|
{
|
||||||
|
Widget.CloseWindow();
|
||||||
|
Widget.OpenWindow("MAINMENU_BG");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var sl = bg.GetWidget<ScrollPanelWidget>("SERVER_LIST");
|
var sl = bg.GetWidget<ScrollPanelWidget>("SERVER_LIST");
|
||||||
ServerTemplate = sl.GetWidget<ScrollItemWidget>("SERVER_TEMPLATE");
|
ServerTemplate = sl.GetWidget<ScrollItemWidget>("SERVER_TEMPLATE");
|
||||||
|
|
||||||
@@ -160,41 +159,5 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
return game.Mods.All( m => m.Contains('@')) && game.Mods.Select( m => Pair.New(m.Split('@')[0], m.Split('@')[1]))
|
return game.Mods.All( m => m.Contains('@')) && game.Mods.Select( m => Pair.New(m.Split('@')[0], m.Split('@')[1]))
|
||||||
.All(kv => Game.CurrentMods.ContainsKey(kv.First) && AreVersionsCompatible(kv.Second, Game.CurrentMods[kv.First].Version));
|
.All(kv => Game.CurrentMods.ContainsKey(kv.First) && AreVersionsCompatible(kv.Second, Game.CurrentMods[kv.First].Version));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public class DirectConnectLogic
|
|
||||||
{
|
|
||||||
[ObjectCreator.UseCtor]
|
|
||||||
public DirectConnectLogic( [ObjectCreator.Param] Widget widget )
|
|
||||||
{
|
|
||||||
var dc = widget.GetWidget("DIRECTCONNECT_BG");
|
|
||||||
|
|
||||||
dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text = Game.Settings.Player.LastServer;
|
|
||||||
|
|
||||||
dc.GetWidget<ButtonWidget>("JOIN_BUTTON").OnClick = () =>
|
|
||||||
{
|
|
||||||
var address = dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text;
|
|
||||||
var cpts = address.Split(':').ToArray();
|
|
||||||
if (cpts.Length < 1 || cpts.Length > 2)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int port;
|
|
||||||
if (cpts.Length != 2 || !int.TryParse(cpts[1], out port))
|
|
||||||
port = 1234;
|
|
||||||
|
|
||||||
Game.Settings.Player.LastServer = address;
|
|
||||||
Game.Settings.Save();
|
|
||||||
|
|
||||||
Widget.CloseWindow();
|
|
||||||
Game.JoinServer(cpts[0], port);
|
|
||||||
};
|
|
||||||
|
|
||||||
dc.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () =>
|
|
||||||
{
|
|
||||||
Widget.CloseWindow();
|
|
||||||
Widget.OpenWindow("MAINMENU_BG");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user