Remember the last map. Disable the server desc and password fields. Draw the chat entry box on top of the display box.

This commit is contained in:
Paul Chote
2011-05-08 17:01:12 +12:00
parent 805f61cc4b
commit fdf9927854
5 changed files with 29 additions and 19 deletions

View File

@@ -27,6 +27,7 @@ namespace OpenRA.GameRules
public bool AdvertiseOnline = true;
public string MasterServer = "http://master.open-ra.org/";
public bool AllowCheats = false;
public string LastMap = null;
}
public class DebugSettings

View File

@@ -199,6 +199,8 @@ namespace OpenRA.Mods.Cnc.Widgets
var onSelect = new Action<Map>(m =>
{
orderManager.IssueOrder(Order.Command("map " + m.Uid));
Game.Settings.Server.LastMap = m.Uid;
Game.Settings.Save();
Widget.CloseWindow();
});

View File

@@ -46,12 +46,15 @@ namespace OpenRA.Mods.Cnc.Widgets
});
};
if (string.IsNullOrEmpty(Game.Settings.Server.LastMap) || !Game.modData.AvailableMaps.TryGetValue(Game.Settings.Server.LastMap, out map))
map = Game.modData.AvailableMaps.FirstOrDefault(m => m.Value.Selectable).Value;
panel.GetWidget<MapPreviewWidget>("MAP_PREVIEW").Map = () => map;
panel.GetWidget<LabelWidget>("MAP_NAME").GetText = () => map.Title;
panel.GetWidget<TextFieldWidget>("SERVER_NAME").Text = settings.Server.Name ?? "";
panel.GetWidget<TextFieldWidget>("LISTEN_PORT").Text = settings.Server.ListenPort.ToString();
advertiseOnline = Game.Settings.Server.AdvertiseOnline;
var externalPort = panel.GetWidget<CncTextFieldWidget>("EXTERNAL_PORT");
externalPort.Text = settings.Server.ExternalPort.ToString();
@@ -60,6 +63,10 @@ namespace OpenRA.Mods.Cnc.Widgets
var advertiseCheckbox = panel.GetWidget<CncCheckboxWidget>("ADVERTISE_CHECKBOX");
advertiseCheckbox.IsChecked = () => advertiseOnline;
advertiseCheckbox.OnClick = () => advertiseOnline ^= true;
// Disable these until we have some logic behind them
panel.GetWidget<CncTextFieldWidget>("SERVER_DESC").IsDisabled = () => true;
panel.GetWidget<CncTextFieldWidget>("SERVER_PASSWORD").IsDisabled = () => true;
}
void CreateAndJoin()
@@ -68,6 +75,7 @@ namespace OpenRA.Mods.Cnc.Widgets
Game.Settings.Server.ListenPort = int.Parse(panel.GetWidget<TextFieldWidget>("LISTEN_PORT").Text);
Game.Settings.Server.ExternalPort = int.Parse(panel.GetWidget<TextFieldWidget>("EXTERNAL_PORT").Text);
Game.Settings.Server.AdvertiseOnline = advertiseOnline;
Game.Settings.Server.LastMap = map.Uid;
Game.Settings.Save();
Game.CreateServer(Game.Settings, map.Uid);

View File

@@ -71,7 +71,6 @@ Container@CREATESERVER_PANEL:
Width:275
MaxLength:50
Height:25
Text:Describe your server here
Label@SERVER_PASSWORD_LABEL:
X:15
Y:84

View File

@@ -309,22 +309,6 @@ Container@SERVER_LOBBY:
Text:Ready
Align:Left
Bold:True
CncTextField@CHAT_TEXTFIELD:
Id:CHAT_TEXTFIELD
X:15
Y:PARENT_BOTTOM - HEIGHT - 15
Width:PARENT_RIGHT - 30
Height:25
LeftMargin:50
Background: panel-darkred
Children:
Label@LABEL_CHATTYPE:
Id:LABEL_CHATTYPE
Y:0-1
Width:45
Height:25
Align:Right
Text:Chat:
CncScrollPanel@CHAT_DISPLAY:
Id:CHAT_DISPLAY
X:15
@@ -357,6 +341,22 @@ Container@SERVER_LOBBY:
Height:14
Width:PARENT_RIGHT - 100 - 10
WordWrap:true
CncTextField@CHAT_TEXTFIELD:
Id:CHAT_TEXTFIELD
X:15
Y:PARENT_BOTTOM - HEIGHT - 15
Width:PARENT_RIGHT - 30
Height:25
LeftMargin:50
Background: panel-darkred
Children:
Label@LABEL_CHATTYPE:
Id:LABEL_CHATTYPE
Y:0-1
Width:45
Height:25
Align:Right
Text:Chat:
CncMenuButton@DISCONNECT_BUTTON:
Id:DISCONNECT_BUTTON
X:0