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;
|
||||
|
||||
@@ -34,11 +34,11 @@ namespace OpenRA.Widgets.Delegates
|
||||
public ServerBrowserDelegate()
|
||||
{
|
||||
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;
|
||||
|
||||
|
||||
@@ -249,6 +249,55 @@ Container:
|
||||
Height:25
|
||||
Text:Cancel
|
||||
Bold:True
|
||||
Background@DIRECTCONNECT_BG:
|
||||
Id:DIRECTCONNECT_BG
|
||||
Delegate:ServerBrowserDelegate
|
||||
X:(WINDOW_RIGHT - WIDTH)/2
|
||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||
Width:400
|
||||
Height:155
|
||||
Visible:false
|
||||
Children:
|
||||
Label@DIRECTCONNECT_LABEL_TITLE:
|
||||
Id:DIRECTCONNECT_LABEL_TITLE
|
||||
X:0
|
||||
Y:20
|
||||
Width:400
|
||||
Height:25
|
||||
Text:Direct Connect
|
||||
Align:Center
|
||||
Bold:True
|
||||
Label@ADDRESS_LABEL:
|
||||
Id:ADDRESS_LABEL
|
||||
X:50
|
||||
Y:59
|
||||
Width:95
|
||||
Height:25
|
||||
Align:Right
|
||||
Text:Server Address:
|
||||
TextField@SERVER_ADDRESS:
|
||||
Id:SERVER_ADDRESS
|
||||
X:150
|
||||
Y:60
|
||||
Width:200
|
||||
MaxLength:50
|
||||
Height:25
|
||||
Button@BUTTON_START:
|
||||
Id:BUTTON_START
|
||||
X:130
|
||||
Y:PARENT_BOTTOM - 45
|
||||
Width:120
|
||||
Height:25
|
||||
Text:Join
|
||||
Bold:True
|
||||
Button@BUTTON_CANCEL:
|
||||
Id:BUTTON_CANCEL
|
||||
X:260
|
||||
Y:PARENT_BOTTOM - 45
|
||||
Width:120
|
||||
Height:25
|
||||
Text:Cancel
|
||||
Bold:True
|
||||
Background@CONNECTION_FAILED_BG:
|
||||
Id:CONNECTION_FAILED_BG
|
||||
Delegate:ConnectionDialogsDelegate
|
||||
|
||||
Reference in New Issue
Block a user