diff --git a/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs b/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs index 90b5333388..678beda33c 100755 --- a/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs @@ -206,7 +206,7 @@ namespace OpenRA.Mods.Cnc.Widgets Widget.OpenWindow( "MAPCHOOSER_PANEL", new Dictionary { - { "initialMap", Map }, + { "initialMap", Map.Uid }, { "onExit", new Action(() => Widget.CloseWindow()) }, { "onSelect", onSelect } }); diff --git a/OpenRA.Mods.Cnc/Widgets/CncMapChooserLogic.cs b/OpenRA.Mods.Cnc/Widgets/CncMapChooserLogic.cs index 73bcc0e927..1cc7d8f96e 100644 --- a/OpenRA.Mods.Cnc/Widgets/CncMapChooserLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncMapChooserLogic.cs @@ -21,33 +21,31 @@ namespace OpenRA.Mods.Cnc.Widgets { public class CncMapChooserLogic : IWidgetDelegate { - Map Map = null; + Map map = null; Widget scrollpanel; Widget itemTemplate; [ObjectCreator.UseCtor] internal CncMapChooserLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] Map initialMap, + [ObjectCreator.Param] string initialMap, [ObjectCreator.Param] Action onExit, [ObjectCreator.Param] Action onSelect) { - if (initialMap != null) - Map = initialMap; - else - Map = Game.modData.AvailableMaps.FirstOrDefault(m => m.Value.Selectable).Value; + if (string.IsNullOrEmpty(initialMap) || ! Game.modData.AvailableMaps.TryGetValue(initialMap, out map)) + map = Game.modData.AvailableMaps.FirstOrDefault(m => m.Value.Selectable).Value; var panel = widget.GetWidget("MAPCHOOSER_PANEL"); - panel.GetWidget("MAP_PREVIEW").Map = () => Map; - panel.GetWidget("CURMAP_TITLE").GetText = () => Map.Title; - panel.GetWidget("CURMAP_AUTHOR").GetText = () => Map.Author; - panel.GetWidget("CURMAP_DESC").GetText = () => Map.Description; - panel.GetWidget("CURMAP_DESC_LABEL").IsVisible = () => Map.Description != null; - panel.GetWidget("CURMAP_SIZE").GetText = () => "{0}x{1}".F(Map.Bounds.Width, Map.Bounds.Height); - panel.GetWidget("CURMAP_THEATER").GetText = () => Rules.TileSets[Map.Tileset].Name; - panel.GetWidget("CURMAP_PLAYERS").GetText = () => Map.PlayerCount.ToString(); + panel.GetWidget("MAP_PREVIEW").Map = () => map; + panel.GetWidget("CURMAP_TITLE").GetText = () => map.Title; + panel.GetWidget("CURMAP_AUTHOR").GetText = () => map.Author; + panel.GetWidget("CURMAP_DESC").GetText = () => map.Description; + panel.GetWidget("CURMAP_DESC_LABEL").IsVisible = () => map.Description != null; + panel.GetWidget("CURMAP_SIZE").GetText = () => "{0}x{1}".F(map.Bounds.Width, map.Bounds.Height); + panel.GetWidget("CURMAP_THEATER").GetText = () => Rules.TileSets[map.Tileset].Name; + panel.GetWidget("CURMAP_PLAYERS").GetText = () => map.PlayerCount.ToString(); - panel.GetWidget("BUTTON_OK").OnClick = () => onSelect(Map); + panel.GetWidget("BUTTON_OK").OnClick = () => onSelect(map); panel.GetWidget("BUTTON_CANCEL").OnClick = onExit; panel.GetWidget("BUTTON_INSTALL").IsDisabled = () => true; @@ -63,17 +61,17 @@ namespace OpenRA.Mods.Cnc.Widgets scrollpanel.RemoveChildren(); foreach (var kv in Game.modData.AvailableMaps.OrderBy(kv => kv.Value.Title).OrderBy(kv => kv.Value.PlayerCount)) { - var map = kv.Value; - if (!map.Selectable) + var m = kv.Value; + if (!m.Selectable) continue; var template = itemTemplate.Clone() as ContainerWidget; - template.GetBackground = () => (template.RenderBounds.Contains(Viewport.LastMousePos) ? "button-hover" : (Map == map) ? "button-pressed" : null); - template.OnMouseDown = mi => { if (mi.Button != MouseButton.Left) return false; Map = map; return true; }; + template.GetBackground = () => (template.RenderBounds.Contains(Viewport.LastMousePos) ? "button-hover" : (m == map) ? "button-pressed" : null); + template.OnMouseDown = mi => { if (mi.Button != MouseButton.Left) return false; map = m; return true; }; template.IsVisible = () => true; - template.GetWidget("TITLE").GetText = () => map.Title; - template.GetWidget("PLAYERS").GetText = () => "{0}".F(map.PlayerCount); - template.GetWidget("TYPE").GetText = () => map.Type; + template.GetWidget("TITLE").GetText = () => m.Title; + template.GetWidget("PLAYERS").GetText = () => "{0}".F(m.PlayerCount); + template.GetWidget("TYPE").GetText = () => m.Type; scrollpanel.AddChild(template); } } diff --git a/OpenRA.Mods.Cnc/Widgets/CncServerCreationLogic.cs b/OpenRA.Mods.Cnc/Widgets/CncServerCreationLogic.cs index f53dcc8582..72a702f32e 100644 --- a/OpenRA.Mods.Cnc/Widgets/CncServerCreationLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncServerCreationLogic.cs @@ -40,7 +40,7 @@ namespace OpenRA.Mods.Cnc.Widgets { Widget.OpenWindow( "MAPCHOOSER_PANEL", new Dictionary { - { "initialMap", map }, + { "initialMap", map.Uid }, { "onExit", new Action(() => Widget.CloseWindow()) }, { "onSelect", new Action(m => { map = m; Widget.CloseWindow(); }) } }); diff --git a/mods/cnc/chrome/createserver.yaml b/mods/cnc/chrome/createserver.yaml index 8e3133243a..5f352f8185 100644 --- a/mods/cnc/chrome/createserver.yaml +++ b/mods/cnc/chrome/createserver.yaml @@ -142,7 +142,7 @@ Container@CREATESERVER_PANEL: Y:259 Width:140 Height:35 - Text:Change Map + Text:Choose Map CncMenuButton@CREATE_BUTTON: Id:CREATE_BUTTON X:464