Store map packages in MapPreview.

This commit is contained in:
Paul Chote
2016-02-20 17:50:04 +00:00
parent 226081d379
commit d492c23a6d
12 changed files with 102 additions and 103 deletions

View File

@@ -60,11 +60,9 @@ namespace OpenRA
{
using (new Support.PerfTimer(path.Key))
{
using (var package = modData.ModFiles.OpenPackage(path.Key))
{
var uid = Map.ComputeUID(package);
previews[uid].UpdateFromMap(package, path.Value, modData.Manifest.MapCompatibility, mapGrid.Type);
}
var package = modData.ModFiles.OpenPackage(path.Key);
var uid = Map.ComputeUID(package);
previews[uid].UpdateFromMap(package, path.Value, modData.Manifest.MapCompatibility, mapGrid.Type);
}
}
catch (Exception e)
@@ -189,7 +187,7 @@ namespace OpenRA
if (bitmap == null)
{
createdPreview = true;
var map = new Map(p.Path);
var map = new Map(modData, p.Package);
bitmap = Minimap.RenderMapPreview(modData.DefaultRules.TileSets[map.Tileset], map, modData.DefaultRules, true);
}

View File

@@ -58,7 +58,7 @@ namespace OpenRA
MapCache cache;
public readonly string Uid;
public string Path { get; private set; }
public IReadOnlyPackage Package { get; private set; }
public string Title { get; private set; }
public string Type { get; private set; }
@@ -126,7 +126,7 @@ namespace OpenRA
yaml = new MiniYaml(null, MiniYaml.FromStream(yamlStream, "map.yaml")).ToDictionary();
}
Path = p.Name;
Package = p;
GridType = gridType;
Class = classification;

View File

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