Direct Connect dialog & saves last server
This commit is contained in:
@@ -44,20 +44,20 @@ namespace OpenRA.GameRules
|
||||
public bool MusicPlayer = true;
|
||||
|
||||
// Internal game settings
|
||||
public readonly int Timestep = 40;
|
||||
public readonly int SheetSize = 2048;
|
||||
public int Timestep = 40;
|
||||
public int SheetSize = 2048;
|
||||
|
||||
// External game settings
|
||||
public readonly string NetworkHost = null;
|
||||
public readonly int NetworkPort = 0;
|
||||
public readonly string Replay = null;
|
||||
public string LastServer = "localhost:1234";
|
||||
public string Replay = null;
|
||||
public string PlayerName = null;
|
||||
public readonly string[] InitialMods = { "ra" };
|
||||
public string[] InitialMods = { "ra" };
|
||||
|
||||
public readonly int ListenPort = 1234;
|
||||
public readonly int ExternalPort = 1234;
|
||||
public readonly bool InternetServer = true;
|
||||
public readonly string MasterServer = "http://open-ra.org/master/";
|
||||
// Server settings
|
||||
public int ListenPort = 1234;
|
||||
public int ExternalPort = 1234;
|
||||
public bool InternetServer = true;
|
||||
public string MasterServer = "http://open-ra.org/master/";
|
||||
|
||||
string SettingsFile;
|
||||
UserSettings defaults;
|
||||
|
||||
@@ -33,12 +33,12 @@ namespace OpenRA.Widgets.Delegates
|
||||
|
||||
public ServerBrowserDelegate()
|
||||
{
|
||||
var r = Chrome.rootWidget;
|
||||
|
||||
var r = Chrome.rootWidget;
|
||||
var bg = r.GetWidget("JOINSERVER_BG");
|
||||
var dc = r.GetWidget("DIRECTCONNECT_BG");
|
||||
|
||||
MasterServerQuery.OnComplete += games =>
|
||||
{
|
||||
var bg = r.GetWidget("JOINSERVER_BG");
|
||||
|
||||
if (games == null)
|
||||
{
|
||||
r.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = true;
|
||||
@@ -76,6 +76,10 @@ namespace OpenRA.Widgets.Delegates
|
||||
OnMouseUp = nmi =>
|
||||
{
|
||||
r.GetWidget("JOINSERVER_BG").Visible = false;
|
||||
|
||||
Game.Settings.LastServer = g.Address;
|
||||
Game.Settings.Save();
|
||||
|
||||
Game.JoinServer(g.Address.Split(':')[0], int.Parse(g.Address.Split(':')[1]));
|
||||
Game.SetGameId(g.Id);
|
||||
return true;
|
||||
@@ -92,7 +96,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
|
||||
r.GetWidget("MAINMENU_BUTTON_JOIN").OnMouseUp = mi =>
|
||||
{
|
||||
var bg = r.OpenWindow("JOINSERVER_BG");
|
||||
r.OpenWindow("JOINSERVER_BG");
|
||||
|
||||
r.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = true;
|
||||
r.GetWidget<LabelWidget>("JOINSERVER_PROGRESS_TITLE").Text = "Fetching game list...";
|
||||
@@ -105,10 +109,8 @@ namespace OpenRA.Widgets.Delegates
|
||||
return true;
|
||||
};
|
||||
|
||||
r.GetWidget("JOINSERVER_BUTTON_REFRESH").OnMouseUp = mi =>
|
||||
bg.GetWidget("JOINSERVER_BUTTON_REFRESH").OnMouseUp = mi =>
|
||||
{
|
||||
var bg = r.GetWidget("JOINSERVER_BG");
|
||||
|
||||
r.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = true;
|
||||
r.GetWidget<LabelWidget>("JOINSERVER_PROGRESS_TITLE").Text = "Fetching game list...";
|
||||
|
||||
@@ -120,20 +122,39 @@ namespace OpenRA.Widgets.Delegates
|
||||
return true;
|
||||
};
|
||||
|
||||
r.GetWidget("JOINSERVER_BUTTON_CANCEL").OnMouseUp = mi =>
|
||||
bg.GetWidget("JOINSERVER_BUTTON_CANCEL").OnMouseUp = mi =>
|
||||
{
|
||||
r.CloseWindow();
|
||||
return true;
|
||||
};
|
||||
|
||||
r.GetWidget("JOINSERVER_BUTTON_DIRECTCONNECT").OnMouseUp = mi =>
|
||||
{ /* rude hack. Should prompt the user once we have textfield widgets */
|
||||
bg.GetWidget("JOINSERVER_BUTTON_DIRECTCONNECT").OnMouseUp = mi => {
|
||||
r.CloseWindow();
|
||||
if (Game.Settings.NetworkHost != null)
|
||||
Game.JoinServer(Game.Settings.NetworkHost, Game.Settings.NetworkPort);
|
||||
|
||||
dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text = Game.Settings.LastServer;
|
||||
r.OpenWindow("DIRECTCONNECT_BG");
|
||||
return true;
|
||||
};
|
||||
|
||||
dc.GetWidget("BUTTON_START").OnMouseUp = mi => {
|
||||
|
||||
var address = dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text;
|
||||
var cpts = address.Split(':').ToArray();
|
||||
if (cpts.Length != 2)
|
||||
return true;
|
||||
|
||||
Game.Settings.LastServer = address;
|
||||
Game.Settings.Save();
|
||||
|
||||
r.CloseWindow();
|
||||
Game.JoinServer(cpts[0], int.Parse(cpts[1]));
|
||||
return true;
|
||||
};
|
||||
|
||||
r.GetWidget("BUTTON_CANCEL").OnMouseUp = mi => {
|
||||
r.CloseWindow();
|
||||
return r.GetWidget("MAINMENU_BUTTON_JOIN").OnMouseUp(mi);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,6 @@ namespace OpenRA.Widgets
|
||||
}
|
||||
else if (!char.IsControl(c))
|
||||
{
|
||||
Console.WriteLine("{0} {1}",MaxLength, Text.Length);
|
||||
if (MaxLength > 0 && Text.Length >= MaxLength)
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user