Introduce map Visibility field.
This replaces the Selectable, UseAsShellmap, and special-cased Type = "Mission" fields.
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
51
OpenRA.Editor/PropertiesDialog.Designer.cs
generated
51
OpenRA.Editor/PropertiesDialog.Designer.cs
generated
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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<MiniYamlNode>();
|
||||
var fields = new[]
|
||||
{
|
||||
"Selectable",
|
||||
"MapFormat",
|
||||
"RequiresMod",
|
||||
"Title",
|
||||
@@ -383,7 +399,7 @@ namespace OpenRA
|
||||
"Tileset",
|
||||
"MapSize",
|
||||
"Bounds",
|
||||
"UseAsShellmap",
|
||||
"Visibility",
|
||||
"Type",
|
||||
};
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
Func<MapPreview, bool> 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<SmudgeReference>());
|
||||
map.Actors = Exts.Lazy(() => new Dictionary<string, ActorReference>());
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
var gameModeDropdown = widget.GetOrNull<DropDownButtonWidget>("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<string> 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)
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user