Store map path in MapPreview.

This commit is contained in:
Paul Chote
2016-02-05 21:29:23 +00:00
parent 6628bc046f
commit d5e3fbf452
4 changed files with 7 additions and 4 deletions

View File

@@ -57,6 +57,8 @@ namespace OpenRA
MapCache cache; MapCache cache;
public readonly string Uid; public readonly string Uid;
public string Path { get; private set; }
public string Title { get; private set; } public string Title { get; private set; }
public string Type { get; private set; } public string Type { get; private set; }
public string Author { get; private set; } public string Author { get; private set; }
@@ -118,6 +120,7 @@ namespace OpenRA
public void UpdateFromMap(Map m, MapClassification classification) public void UpdateFromMap(Map m, MapClassification classification)
{ {
Map = m; Map = m;
Path = m.Path;
Title = m.Title; Title = m.Title;
Type = m.Type; Type = m.Type;
Type = m.Type; Type = m.Type;
@@ -231,7 +234,7 @@ namespace OpenRA
return; return;
} }
mapPath = Path.Combine(baseMapPath, res.Headers["Content-Disposition"].Replace("attachment; filename = ", "")); mapPath = System.IO.Path.Combine(baseMapPath, res.Headers["Content-Disposition"].Replace("attachment; filename = ", ""));
} }
Action<DownloadProgressChangedEventArgs> onDownloadProgress = i => { DownloadBytes = i.BytesReceived; DownloadPercentage = i.ProgressPercentage; }; Action<DownloadProgressChangedEventArgs> onDownloadProgress = i => { DownloadBytes = i.BytesReceived; DownloadPercentage = i.ProgressPercentage; };

View File

@@ -166,7 +166,7 @@ namespace OpenRA
throw new InvalidDataException("Invalid map uid: {0}".F(uid)); throw new InvalidDataException("Invalid map uid: {0}".F(uid));
// Operate on a copy of the map to avoid gameplay state leaking into the cache // Operate on a copy of the map to avoid gameplay state leaking into the cache
var map = new Map(MapCache[uid].Map.Path); var map = new Map(MapCache[uid].Path);
LoadTranslations(map); LoadTranslations(map);

View File

@@ -284,7 +284,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
string DeleteMap(string map) string DeleteMap(string map)
{ {
var path = Game.ModData.MapCache[map].Map.Path; var path = Game.ModData.MapCache[map].Path;
try try
{ {
if (File.Exists(path)) if (File.Exists(path))

View File

@@ -103,7 +103,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var missionMapPaths = kv.Value.Nodes.Select(n => Path.GetFullPath(n.Key)).ToList(); var missionMapPaths = kv.Value.Nodes.Select(n => Path.GetFullPath(n.Key)).ToList();
var maps = modData.MapCache var maps = modData.MapCache
.Where(p => p.Status == MapStatus.Available && missionMapPaths.Contains(Path.GetFullPath(p.Map.Path))) .Where(p => p.Status == MapStatus.Available && missionMapPaths.Contains(Path.GetFullPath(p.Path)))
.Select(p => p.Map) .Select(p => p.Map)
.OrderBy(m => missionMapPaths.IndexOf(Path.GetFullPath(m.Path))); .OrderBy(m => missionMapPaths.IndexOf(Path.GetFullPath(m.Path)));