diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index e68aac57e9..10920b9019 100644 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -426,8 +426,7 @@ namespace OpenRA.Editor pd.TitleBox.Text = surface1.Map.Title; pd.DescBox.Text = surface1.Map.Description; pd.AuthorBox.Text = surface1.Map.Author; - pd.SelectableCheckBox.Checked = surface1.Map.Selectable; - pd.ShellmapCheckBox.Checked = surface1.Map.UseAsShellmap; + pd.mapVisibilityComboBox.SelectedIndex = pd.mapVisibilityComboBox.FindStringExact(Enum.GetName(typeof(MapVisibility), surface1.Map.Visibility)); if (DialogResult.OK != pd.ShowDialog()) return; @@ -435,8 +434,7 @@ namespace OpenRA.Editor surface1.Map.Title = pd.TitleBox.Text; surface1.Map.Description = pd.DescBox.Text; surface1.Map.Author = pd.AuthorBox.Text; - surface1.Map.Selectable = pd.SelectableCheckBox.Checked; - surface1.Map.UseAsShellmap = pd.ShellmapCheckBox.Checked; + surface1.Map.Visibility = (MapVisibility)Enum.Parse(typeof(MapVisibility), pd.mapVisibilityComboBox.SelectedItem.ToString()); } } diff --git a/OpenRA.Editor/PropertiesDialog.Designer.cs b/OpenRA.Editor/PropertiesDialog.Designer.cs index 1a9ef94881..465294649f 100644 --- a/OpenRA.Editor/PropertiesDialog.Designer.cs +++ b/OpenRA.Editor/PropertiesDialog.Designer.cs @@ -43,10 +43,10 @@ namespace OpenRA.Editor this.TitleBox = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.DescBox = new System.Windows.Forms.TextBox(); - this.SelectableCheckBox = new System.Windows.Forms.CheckBox(); this.label3 = new System.Windows.Forms.Label(); this.AuthorBox = new System.Windows.Forms.TextBox(); - this.ShellmapCheckBox = new System.Windows.Forms.CheckBox(); + this.mapVisibilityComboBox = new System.Windows.Forms.ComboBox(); + this.label4 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // button2 @@ -103,16 +103,6 @@ namespace OpenRA.Editor this.DescBox.Size = new System.Drawing.Size(286, 20); this.DescBox.TabIndex = 17; // - // selectable - // - this.SelectableCheckBox.AutoSize = true; - this.SelectableCheckBox.Location = new System.Drawing.Point(118, 138); - this.SelectableCheckBox.Name = "selectable"; - this.SelectableCheckBox.Size = new System.Drawing.Size(130, 17); - this.SelectableCheckBox.TabIndex = 18; - this.SelectableCheckBox.Text = "Show in Map Chooser"; - this.SelectableCheckBox.UseVisualStyleBackColor = true; - // // label3 // this.label3.AutoSize = true; @@ -129,16 +119,27 @@ namespace OpenRA.Editor this.AuthorBox.Size = new System.Drawing.Size(286, 20); this.AuthorBox.TabIndex = 17; // - // checkBox1 - // - this.ShellmapCheckBox.AutoSize = true; - this.ShellmapCheckBox.Location = new System.Drawing.Point(118, 161); - this.ShellmapCheckBox.Name = "checkBox1"; - this.ShellmapCheckBox.Size = new System.Drawing.Size(105, 17); - this.ShellmapCheckBox.TabIndex = 18; - this.ShellmapCheckBox.Text = "Use as Shellmap"; - this.ShellmapCheckBox.UseVisualStyleBackColor = true; // + // mapVisibilityComboBox + // + this.mapVisibilityComboBox.FormattingEnabled = true; + this.mapVisibilityComboBox.Items.AddRange(new object[] { + "Lobby", + "Shellmap", + "MissionSelector"}); + this.mapVisibilityComboBox.Location = new System.Drawing.Point(150, 137); + this.mapVisibilityComboBox.Name = "mapVisibilityComboBox"; + this.mapVisibilityComboBox.Size = new System.Drawing.Size(121, 21); + this.mapVisibilityComboBox.TabIndex = 19; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(90, 140); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(58, 13); + this.label4.TabIndex = 20; + this.label4.Text = "Map class:"; // PropertiesDialog // this.AcceptButton = this.button2; @@ -146,8 +147,8 @@ namespace OpenRA.Editor this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.button1; this.ClientSize = new System.Drawing.Size(370, 228); - this.Controls.Add(this.ShellmapCheckBox); - this.Controls.Add(this.SelectableCheckBox); + this.Controls.Add(this.label4); + this.Controls.Add(this.mapVisibilityComboBox); this.Controls.Add(this.AuthorBox); this.Controls.Add(this.label3); this.Controls.Add(this.DescBox); @@ -173,9 +174,9 @@ namespace OpenRA.Editor public System.Windows.Forms.TextBox TitleBox; private System.Windows.Forms.Label label2; public System.Windows.Forms.TextBox DescBox; - public System.Windows.Forms.CheckBox SelectableCheckBox; private System.Windows.Forms.Label label3; public System.Windows.Forms.TextBox AuthorBox; - public System.Windows.Forms.CheckBox ShellmapCheckBox; + public System.Windows.Forms.ComboBox mapVisibilityComboBox; + private System.Windows.Forms.Label label4; } } diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 1fbb6d8683..e0f52eb772 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -383,7 +383,7 @@ namespace OpenRA static string ChooseShellmap() { var shellmaps = modData.MapCache - .Where(m => m.Status == MapStatus.Available && m.Map.UseAsShellmap) + .Where(m => m.Status == MapStatus.Available && m.Map.Visibility.HasFlag(MapVisibility.Shellmap)) .Select(m => m.Uid); if (!shellmaps.Any()) diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index 913a93e966..52a3e346db 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -100,6 +100,14 @@ namespace OpenRA public string GameLost; } + [Flags] + public enum MapVisibility + { + Lobby = 1, + Shellmap = 2, + MissionSelector = 4 + } + public class Map { [FieldLoader.Ignore] public IFolder Container; @@ -108,8 +116,7 @@ namespace OpenRA // Yaml map data public string Uid { get; private set; } public int MapFormat; - public bool Selectable = true; - public bool UseAsShellmap; + public MapVisibility Visibility = MapVisibility.Lobby; public string RequiresMod; public string Title; @@ -262,6 +269,16 @@ namespace OpenRA var nd = yaml.ToDictionary(); + // Format 6 -> 7 combined the Selectable and UseAsShellmap flags into the Class enum + if (MapFormat < 7) + { + MiniYaml useAsShellmap; + if (nd.TryGetValue("UseAsShellmap", out useAsShellmap) && bool.Parse(useAsShellmap.Value)) + Visibility = MapVisibility.Shellmap; + else if (Type == "Mission" || Type == "Campaign") + Visibility = MapVisibility.MissionSelector; + } + // Load players foreach (var my in nd["Players"].ToDictionary().Values) { @@ -320,7 +337,7 @@ namespace OpenRA // The Uid is calculated from the data on-disk, so // format changes must be flushed to disk. // TODO: this isn't very nice - if (MapFormat < 6) + if (MapFormat < 7) Save(path); Uid = ComputeHash(); @@ -369,12 +386,11 @@ namespace OpenRA public void Save(string toPath) { - MapFormat = 6; + MapFormat = 7; var root = new List(); var fields = new[] { - "Selectable", "MapFormat", "RequiresMod", "Title", @@ -383,7 +399,7 @@ namespace OpenRA "Tileset", "MapSize", "Bounds", - "UseAsShellmap", + "Visibility", "Type", }; diff --git a/OpenRA.Game/Widgets/WidgetUtils.cs b/OpenRA.Game/Widgets/WidgetUtils.cs index 422688bb48..ed58dc6c8b 100644 --- a/OpenRA.Game/Widgets/WidgetUtils.cs +++ b/OpenRA.Game/Widgets/WidgetUtils.cs @@ -217,7 +217,7 @@ namespace OpenRA.Widgets { Func isIdealMap = m => { - if (m.Status != MapStatus.Available || !m.Map.Selectable) + if (m.Status != MapStatus.Available || !m.Map.Visibility.HasFlag(MapVisibility.Lobby)) return false; // Other map types may have confusing settings or gameplay @@ -236,7 +236,7 @@ namespace OpenRA.Widgets }; var selected = Game.modData.MapCache.Where(m => isIdealMap(m)).RandomOrDefault(Game.CosmeticRandom) ?? - Game.modData.MapCache.First(m => m.Status == MapStatus.Available && m.Map.Selectable); + Game.modData.MapCache.First(m => m.Status == MapStatus.Available && m.Map.Visibility.HasFlag(MapVisibility.Lobby)); return selected.Uid; } diff --git a/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs b/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs index 9339342826..4c6314c159 100644 --- a/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs +++ b/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs @@ -150,7 +150,6 @@ namespace OpenRA.Mods.Common.UtilityCommands map.MapSize.X = mapSize; map.MapSize.Y = mapSize; map.Bounds = Rectangle.FromLTRB(offsetX, offsetY, offsetX + width, offsetY + height); - map.Selectable = true; map.Smudges = Exts.Lazy(() => new List()); map.Actors = Exts.Lazy(() => new Dictionary()); diff --git a/OpenRA.Mods.RA/Widgets/Logic/MainMenuLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/MainMenuLogic.cs index 43d78833cf..6624f049b8 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/MainMenuLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/MainMenuLogic.cs @@ -88,7 +88,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var hasCampaign = Game.modData.Manifest.Missions.Any(); var hasMissions = Game.modData.MapCache - .Any(p => p.Status == MapStatus.Available && p.Map.Type == "Mission" && !p.Map.Selectable); + .Any(p => p.Status == MapStatus.Available && p.Map.Visibility.HasFlag(MapVisibility.MissionSelector)); missionsButton.Disabled = !hasCampaign && !hasMissions; diff --git a/OpenRA.Mods.RA/Widgets/Logic/MapChooserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/MapChooserLogic.cs index a09942c448..a61f02b963 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/MapChooserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/MapChooserLogic.cs @@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var gameModeDropdown = widget.GetOrNull("GAMEMODE_FILTER"); if (gameModeDropdown != null) { - var selectableMaps = Game.modData.MapCache.Where(m => m.Status == MapStatus.Available && m.Map.Selectable); + var selectableMaps = Game.modData.MapCache.Where(m => m.Status == MapStatus.Available && m.Map.Visibility.HasFlag(MapVisibility.Lobby)); var gameModes = selectableMaps .GroupBy(m => m.Type) .Select(g => Pair.New(g.Key, g.Count())).ToList(); @@ -111,7 +111,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic void EnumerateMaps(Action onSelect) { var maps = Game.modData.MapCache - .Where(m => m.Status == MapStatus.Available && m.Map.Selectable) + .Where(m => m.Status == MapStatus.Available && m.Map.Visibility.HasFlag(MapVisibility.Lobby)) .Where(m => gameMode == null || m.Type == gameMode) .Where(m => mapFilter == null || m.Title.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0 || m.Author.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0) .OrderBy(m => m.PlayerCount) diff --git a/OpenRA.Mods.RA/Widgets/Logic/MissionBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/MissionBrowserLogic.cs index 2d4cf0edc7..4033dfdc25 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/MissionBrowserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/MissionBrowserLogic.cs @@ -110,9 +110,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic } // Add an additional group for loose missions - // Loose missions must define Type: Mission and Selectable: false. var looseMissions = Game.modData.MapCache - .Where(p => p.Status == MapStatus.Available && p.Map.Type == "Mission" && !p.Map.Selectable && !allMaps.Contains(p.Map)) + .Where(p => p.Status == MapStatus.Available && p.Map.Visibility.HasFlag(MapVisibility.MissionSelector) && !allMaps.Contains(p.Map)) .Select(p => p.Map); if (looseMissions.Any())