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.TitleBox.Text = surface1.Map.Title;
|
||||||
pd.DescBox.Text = surface1.Map.Description;
|
pd.DescBox.Text = surface1.Map.Description;
|
||||||
pd.AuthorBox.Text = surface1.Map.Author;
|
pd.AuthorBox.Text = surface1.Map.Author;
|
||||||
pd.SelectableCheckBox.Checked = surface1.Map.Selectable;
|
pd.mapVisibilityComboBox.SelectedIndex = pd.mapVisibilityComboBox.FindStringExact(Enum.GetName(typeof(MapVisibility), surface1.Map.Visibility));
|
||||||
pd.ShellmapCheckBox.Checked = surface1.Map.UseAsShellmap;
|
|
||||||
|
|
||||||
if (DialogResult.OK != pd.ShowDialog())
|
if (DialogResult.OK != pd.ShowDialog())
|
||||||
return;
|
return;
|
||||||
@@ -435,8 +434,7 @@ namespace OpenRA.Editor
|
|||||||
surface1.Map.Title = pd.TitleBox.Text;
|
surface1.Map.Title = pd.TitleBox.Text;
|
||||||
surface1.Map.Description = pd.DescBox.Text;
|
surface1.Map.Description = pd.DescBox.Text;
|
||||||
surface1.Map.Author = pd.AuthorBox.Text;
|
surface1.Map.Author = pd.AuthorBox.Text;
|
||||||
surface1.Map.Selectable = pd.SelectableCheckBox.Checked;
|
surface1.Map.Visibility = (MapVisibility)Enum.Parse(typeof(MapVisibility), pd.mapVisibilityComboBox.SelectedItem.ToString());
|
||||||
surface1.Map.UseAsShellmap = pd.ShellmapCheckBox.Checked;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
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.TitleBox = new System.Windows.Forms.TextBox();
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
this.DescBox = new System.Windows.Forms.TextBox();
|
this.DescBox = new System.Windows.Forms.TextBox();
|
||||||
this.SelectableCheckBox = new System.Windows.Forms.CheckBox();
|
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
this.AuthorBox = new System.Windows.Forms.TextBox();
|
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();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// button2
|
// button2
|
||||||
@@ -103,16 +103,6 @@ namespace OpenRA.Editor
|
|||||||
this.DescBox.Size = new System.Drawing.Size(286, 20);
|
this.DescBox.Size = new System.Drawing.Size(286, 20);
|
||||||
this.DescBox.TabIndex = 17;
|
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
|
// label3
|
||||||
//
|
//
|
||||||
this.label3.AutoSize = true;
|
this.label3.AutoSize = true;
|
||||||
@@ -129,16 +119,27 @@ namespace OpenRA.Editor
|
|||||||
this.AuthorBox.Size = new System.Drawing.Size(286, 20);
|
this.AuthorBox.Size = new System.Drawing.Size(286, 20);
|
||||||
this.AuthorBox.TabIndex = 17;
|
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
|
// PropertiesDialog
|
||||||
//
|
//
|
||||||
this.AcceptButton = this.button2;
|
this.AcceptButton = this.button2;
|
||||||
@@ -146,8 +147,8 @@ namespace OpenRA.Editor
|
|||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.CancelButton = this.button1;
|
this.CancelButton = this.button1;
|
||||||
this.ClientSize = new System.Drawing.Size(370, 228);
|
this.ClientSize = new System.Drawing.Size(370, 228);
|
||||||
this.Controls.Add(this.ShellmapCheckBox);
|
this.Controls.Add(this.label4);
|
||||||
this.Controls.Add(this.SelectableCheckBox);
|
this.Controls.Add(this.mapVisibilityComboBox);
|
||||||
this.Controls.Add(this.AuthorBox);
|
this.Controls.Add(this.AuthorBox);
|
||||||
this.Controls.Add(this.label3);
|
this.Controls.Add(this.label3);
|
||||||
this.Controls.Add(this.DescBox);
|
this.Controls.Add(this.DescBox);
|
||||||
@@ -173,9 +174,9 @@ namespace OpenRA.Editor
|
|||||||
public System.Windows.Forms.TextBox TitleBox;
|
public System.Windows.Forms.TextBox TitleBox;
|
||||||
private System.Windows.Forms.Label label2;
|
private System.Windows.Forms.Label label2;
|
||||||
public System.Windows.Forms.TextBox DescBox;
|
public System.Windows.Forms.TextBox DescBox;
|
||||||
public System.Windows.Forms.CheckBox SelectableCheckBox;
|
|
||||||
private System.Windows.Forms.Label label3;
|
private System.Windows.Forms.Label label3;
|
||||||
public System.Windows.Forms.TextBox AuthorBox;
|
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()
|
static string ChooseShellmap()
|
||||||
{
|
{
|
||||||
var shellmaps = modData.MapCache
|
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);
|
.Select(m => m.Uid);
|
||||||
|
|
||||||
if (!shellmaps.Any())
|
if (!shellmaps.Any())
|
||||||
|
|||||||
@@ -100,6 +100,14 @@ namespace OpenRA
|
|||||||
public string GameLost;
|
public string GameLost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum MapVisibility
|
||||||
|
{
|
||||||
|
Lobby = 1,
|
||||||
|
Shellmap = 2,
|
||||||
|
MissionSelector = 4
|
||||||
|
}
|
||||||
|
|
||||||
public class Map
|
public class Map
|
||||||
{
|
{
|
||||||
[FieldLoader.Ignore] public IFolder Container;
|
[FieldLoader.Ignore] public IFolder Container;
|
||||||
@@ -108,8 +116,7 @@ namespace OpenRA
|
|||||||
// Yaml map data
|
// Yaml map data
|
||||||
public string Uid { get; private set; }
|
public string Uid { get; private set; }
|
||||||
public int MapFormat;
|
public int MapFormat;
|
||||||
public bool Selectable = true;
|
public MapVisibility Visibility = MapVisibility.Lobby;
|
||||||
public bool UseAsShellmap;
|
|
||||||
public string RequiresMod;
|
public string RequiresMod;
|
||||||
|
|
||||||
public string Title;
|
public string Title;
|
||||||
@@ -262,6 +269,16 @@ namespace OpenRA
|
|||||||
|
|
||||||
var nd = yaml.ToDictionary();
|
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
|
// Load players
|
||||||
foreach (var my in nd["Players"].ToDictionary().Values)
|
foreach (var my in nd["Players"].ToDictionary().Values)
|
||||||
{
|
{
|
||||||
@@ -320,7 +337,7 @@ namespace OpenRA
|
|||||||
// The Uid is calculated from the data on-disk, so
|
// The Uid is calculated from the data on-disk, so
|
||||||
// format changes must be flushed to disk.
|
// format changes must be flushed to disk.
|
||||||
// TODO: this isn't very nice
|
// TODO: this isn't very nice
|
||||||
if (MapFormat < 6)
|
if (MapFormat < 7)
|
||||||
Save(path);
|
Save(path);
|
||||||
|
|
||||||
Uid = ComputeHash();
|
Uid = ComputeHash();
|
||||||
@@ -369,12 +386,11 @@ namespace OpenRA
|
|||||||
|
|
||||||
public void Save(string toPath)
|
public void Save(string toPath)
|
||||||
{
|
{
|
||||||
MapFormat = 6;
|
MapFormat = 7;
|
||||||
|
|
||||||
var root = new List<MiniYamlNode>();
|
var root = new List<MiniYamlNode>();
|
||||||
var fields = new[]
|
var fields = new[]
|
||||||
{
|
{
|
||||||
"Selectable",
|
|
||||||
"MapFormat",
|
"MapFormat",
|
||||||
"RequiresMod",
|
"RequiresMod",
|
||||||
"Title",
|
"Title",
|
||||||
@@ -383,7 +399,7 @@ namespace OpenRA
|
|||||||
"Tileset",
|
"Tileset",
|
||||||
"MapSize",
|
"MapSize",
|
||||||
"Bounds",
|
"Bounds",
|
||||||
"UseAsShellmap",
|
"Visibility",
|
||||||
"Type",
|
"Type",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
Func<MapPreview, bool> isIdealMap = m =>
|
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;
|
return false;
|
||||||
|
|
||||||
// Other map types may have confusing settings or gameplay
|
// 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) ??
|
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;
|
return selected.Uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -150,7 +150,6 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
map.MapSize.X = mapSize;
|
map.MapSize.X = mapSize;
|
||||||
map.MapSize.Y = mapSize;
|
map.MapSize.Y = mapSize;
|
||||||
map.Bounds = Rectangle.FromLTRB(offsetX, offsetY, offsetX + width, offsetY + height);
|
map.Bounds = Rectangle.FromLTRB(offsetX, offsetY, offsetX + width, offsetY + height);
|
||||||
map.Selectable = true;
|
|
||||||
|
|
||||||
map.Smudges = Exts.Lazy(() => new List<SmudgeReference>());
|
map.Smudges = Exts.Lazy(() => new List<SmudgeReference>());
|
||||||
map.Actors = Exts.Lazy(() => new Dictionary<string, ActorReference>());
|
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 hasCampaign = Game.modData.Manifest.Missions.Any();
|
||||||
var hasMissions = Game.modData.MapCache
|
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;
|
missionsButton.Disabled = !hasCampaign && !hasMissions;
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var gameModeDropdown = widget.GetOrNull<DropDownButtonWidget>("GAMEMODE_FILTER");
|
var gameModeDropdown = widget.GetOrNull<DropDownButtonWidget>("GAMEMODE_FILTER");
|
||||||
if (gameModeDropdown != null)
|
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
|
var gameModes = selectableMaps
|
||||||
.GroupBy(m => m.Type)
|
.GroupBy(m => m.Type)
|
||||||
.Select(g => Pair.New(g.Key, g.Count())).ToList();
|
.Select(g => Pair.New(g.Key, g.Count())).ToList();
|
||||||
@@ -111,7 +111,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
void EnumerateMaps(Action<string> onSelect)
|
void EnumerateMaps(Action<string> onSelect)
|
||||||
{
|
{
|
||||||
var maps = Game.modData.MapCache
|
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 => gameMode == null || m.Type == gameMode)
|
||||||
.Where(m => mapFilter == null || m.Title.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0 || m.Author.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0)
|
.Where(m => mapFilter == null || m.Title.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0 || m.Author.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0)
|
||||||
.OrderBy(m => m.PlayerCount)
|
.OrderBy(m => m.PlayerCount)
|
||||||
|
|||||||
@@ -110,9 +110,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add an additional group for loose missions
|
// Add an additional group for loose missions
|
||||||
// Loose missions must define Type: Mission and Selectable: false.
|
|
||||||
var looseMissions = Game.modData.MapCache
|
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);
|
.Select(p => p.Map);
|
||||||
|
|
||||||
if (looseMissions.Any())
|
if (looseMissions.Any())
|
||||||
|
|||||||
Reference in New Issue
Block a user