Add map folder types. Fixes #4635.
This commit is contained in:
@@ -21,12 +21,13 @@ namespace OpenRA
|
||||
{
|
||||
public readonly ModMetadata Mod;
|
||||
public readonly string[]
|
||||
Folders, MapFolders, Rules, ServerTraits,
|
||||
Folders, Rules, ServerTraits,
|
||||
Sequences, VoxelSequences, Cursors, Chrome, Assemblies, ChromeLayout,
|
||||
Weapons, Voices, Notifications, Music, Movies, Translations, TileSets,
|
||||
ChromeMetrics, PackageContents, LuaScripts, MapCompatibility, Missions;
|
||||
|
||||
public readonly IReadOnlyDictionary<string, string> Packages;
|
||||
public readonly IReadOnlyDictionary<string, string> MapFolders;
|
||||
public readonly MiniYaml LoadScreen;
|
||||
public readonly MiniYaml LobbyDefaults;
|
||||
public readonly Dictionary<string, Pair<string, int>> Fonts;
|
||||
@@ -43,7 +44,7 @@ namespace OpenRA
|
||||
|
||||
// TODO: Use fieldloader
|
||||
Folders = YamlList(yaml, "Folders");
|
||||
MapFolders = YamlList(yaml, "MapFolders");
|
||||
MapFolders = YamlDictionary(yaml, "MapFolders");
|
||||
Packages = YamlDictionary(yaml, "Packages");
|
||||
Rules = YamlList(yaml, "Rules");
|
||||
ServerTraits = YamlList(yaml, "ServerTraits");
|
||||
|
||||
@@ -42,16 +42,19 @@ namespace OpenRA
|
||||
|
||||
public void LoadMaps()
|
||||
{
|
||||
var paths = modData.Manifest.MapFolders.SelectMany(f => FindMapsIn(f));
|
||||
foreach (var path in paths)
|
||||
// Expand the dictionary (dir path, dir type) to a dictionary of (map path, dir type)
|
||||
var mapPaths = modData.Manifest.MapFolders.SelectMany(kv =>
|
||||
FindMapsIn(kv.Key).ToDictionary(p => p, p => string.IsNullOrEmpty(kv.Value) ? MapClassification.Unknown : Enum<MapClassification>.Parse(kv.Value)));
|
||||
|
||||
foreach (var path in mapPaths)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (new Support.PerfTimer(path))
|
||||
using (new Support.PerfTimer(path.Key))
|
||||
{
|
||||
var map = new Map(path, modData.Manifest.Mod.Id);
|
||||
var map = new Map(path.Key, modData.Manifest.Mod.Id);
|
||||
if (modData.Manifest.MapCompatibility.Contains(map.RequiresMod))
|
||||
previews[map.Uid].UpdateFromMap(map);
|
||||
previews[map.Uid].UpdateFromMap(map, path.Value);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@@ -24,6 +24,9 @@ namespace OpenRA
|
||||
{
|
||||
public enum MapStatus { Available, Unavailable, Searching, DownloadAvailable, Downloading, DownloadError }
|
||||
|
||||
// Used for grouping maps in the UI
|
||||
public enum MapClassification { Unknown, System, User, Remote }
|
||||
|
||||
// Fields names must match the with the remote API
|
||||
public class RemoteMapData
|
||||
{
|
||||
@@ -53,6 +56,7 @@ namespace OpenRA
|
||||
public Bitmap CustomPreview { get; private set; }
|
||||
public Map Map { get; private set; }
|
||||
public MapStatus Status { get; private set; }
|
||||
public MapClassification Class { get; private set; }
|
||||
|
||||
Download download;
|
||||
public long DownloadBytes { get; private set; }
|
||||
@@ -94,9 +98,10 @@ namespace OpenRA
|
||||
Bounds = Rectangle.Empty;
|
||||
SpawnPoints = NoSpawns;
|
||||
Status = MapStatus.Unavailable;
|
||||
Class = MapClassification.Unknown;
|
||||
}
|
||||
|
||||
public void UpdateFromMap(Map m)
|
||||
public void UpdateFromMap(Map m, MapClassification classification)
|
||||
{
|
||||
Map = m;
|
||||
Title = m.Title;
|
||||
@@ -108,6 +113,7 @@ namespace OpenRA
|
||||
SpawnPoints = m.GetSpawnPoints().ToList();
|
||||
CustomPreview = m.CustomPreview;
|
||||
Status = MapStatus.Available;
|
||||
Class = classification;
|
||||
}
|
||||
|
||||
public void UpdateRemoteSearch(MapStatus status, MiniYaml yaml)
|
||||
@@ -146,8 +152,9 @@ namespace OpenRA
|
||||
if (CustomPreview != null)
|
||||
cache.CacheMinimap(this);
|
||||
}
|
||||
Status = status;
|
||||
|
||||
Status = status;
|
||||
Class = MapClassification.Remote;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -199,7 +206,7 @@ namespace OpenRA
|
||||
}
|
||||
|
||||
Log.Write("debug", "Downloaded map to '{0}'", mapPath);
|
||||
Game.RunAfterTick(() => UpdateFromMap(new Map(mapPath)));
|
||||
Game.RunAfterTick(() => UpdateFromMap(new Map(mapPath), MapClassification.User));
|
||||
};
|
||||
|
||||
download = new Download(mapUrl, mapPath, onDownloadProgress, onDownloadComplete);
|
||||
|
||||
@@ -13,8 +13,8 @@ Folders:
|
||||
~^Content/cnc
|
||||
|
||||
MapFolders:
|
||||
./mods/cnc/maps
|
||||
~^maps/cnc
|
||||
./mods/cnc/maps: System
|
||||
~^maps/cnc: User
|
||||
|
||||
Packages:
|
||||
bluetib.mix
|
||||
|
||||
@@ -17,8 +17,8 @@ Folders:
|
||||
~^Content/d2k/Music
|
||||
|
||||
MapFolders:
|
||||
./mods/d2k/maps
|
||||
~^maps/d2k
|
||||
./mods/d2k/maps: System
|
||||
~^maps/d2k: User
|
||||
|
||||
Packages:
|
||||
SOUND.RS
|
||||
|
||||
@@ -13,8 +13,8 @@ Folders:
|
||||
~^Content/ra
|
||||
|
||||
MapFolders:
|
||||
./mods/ra/maps
|
||||
~^maps/ra
|
||||
./mods/ra/maps: System
|
||||
~^maps/ra: User
|
||||
|
||||
Packages:
|
||||
~main.mix
|
||||
|
||||
@@ -15,8 +15,8 @@ Folders:
|
||||
./mods/ra/uibits
|
||||
|
||||
MapFolders:
|
||||
./mods/ts/maps
|
||||
~^maps/ts
|
||||
./mods/ts/maps: System
|
||||
~^maps/ts: User
|
||||
|
||||
Packages:
|
||||
# Tiberian Sun
|
||||
|
||||
Reference in New Issue
Block a user