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