Introduce map Visibility field.
This replaces the Selectable, UseAsShellmap, and special-cased Type = "Mission" fields.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user