Do not use the map's rules when rendering the minimap in the map chooser

Using the mod's rules is *a lot* faster because we don't have to load
each map's rules.
This commit is contained in:
Pavlos Touboulidis
2014-05-14 23:56:00 +03:00
parent ca44be7b2e
commit df6159f12b
4 changed files with 12 additions and 7 deletions

View File

@@ -70,7 +70,7 @@ namespace OpenRA.Editor
{
MakeDirty();
var tileSet = Program.Rules.TileSets[surface1.Map.Tileset];
miniMapBox.Image = Minimap.AddStaticResources(tileSet, surface1.Map, Minimap.TerrainBitmap(tileSet, surface1.Map, true));
miniMapBox.Image = Minimap.RenderMapPreview(tileSet, surface1.Map, true);
cashToolStripStatusLabel.Text = CalculateTotalResource().ToString();
}
@@ -288,7 +288,7 @@ namespace OpenRA.Editor
p.ResumeLayout();
}
miniMapBox.Image = Minimap.AddStaticResources(tileset, surface1.Map, Minimap.TerrainBitmap(tileset, surface1.Map, true));
miniMapBox.Image = Minimap.RenderMapPreview(tileset, surface1.Map, true);
propertiesToolStripMenuItem.Enabled = true;
toolStripMenuItemProperties.Enabled = true;

View File

@@ -76,7 +76,7 @@ namespace OpenRA.Editor
try
{
var tileset = Program.Rules.TileSets[map.Tileset];
MiniMapBox.Image = Minimap.AddStaticResources(tileset, map, Minimap.TerrainBitmap(tileset, map, true));
MiniMapBox.Image = Minimap.RenderMapPreview(tileset, map, true);
}
catch (Exception ed)
{

View File

@@ -55,7 +55,7 @@ namespace OpenRA.Graphics
// Add the static resources defined in the map; if the map lives
// in a world use AddCustomTerrain instead
public static Bitmap AddStaticResources(TileSet tileset, Map map, Bitmap terrainBitmap)
static Bitmap AddStaticResources(TileSet tileset, Map map, Ruleset resourceRules, Bitmap terrainBitmap)
{
Bitmap terrain = new Bitmap(terrainBitmap);
@@ -74,7 +74,7 @@ namespace OpenRA.Graphics
if (map.MapResources.Value[mapX, mapY].Type == 0)
continue;
var res = map.Rules.Actors["world"].Traits.WithInterface<ResourceTypeInfo>()
var res = resourceRules.Actors["world"].Traits.WithInterface<ResourceTypeInfo>()
.Where(t => t.ResourceType == map.MapResources.Value[mapX, mapY].Type)
.Select(t => t.TerrainType).FirstOrDefault();
if (res == null)
@@ -179,9 +179,14 @@ namespace OpenRA.Graphics
}
public static Bitmap RenderMapPreview(TileSet tileset, Map map, bool actualSize)
{
return RenderMapPreview(tileset, map, map.Rules, actualSize);
}
public static Bitmap RenderMapPreview(TileSet tileset, Map map, Ruleset resourceRules, bool actualSize)
{
Bitmap terrain = TerrainBitmap(tileset, map, actualSize);
return AddStaticResources(tileset, map, terrain);
return AddStaticResources(tileset, map, resourceRules, terrain);
}
}
}

View File

@@ -149,7 +149,7 @@ namespace OpenRA
// the next render cycle.
// (d) Any partially written bytes from the next minimap is in an
// unallocated area, and will be committed in the next cycle.
var bitmap = p.CustomPreview ?? Minimap.RenderMapPreview(modData.DefaultRules.TileSets[p.Map.Tileset], p.Map, true);
var bitmap = p.CustomPreview ?? Minimap.RenderMapPreview(modData.DefaultRules.TileSets[p.Map.Tileset], p.Map, modData.DefaultRules, true);
p.Minimap = sheetBuilder.Add(bitmap);
lock (syncRoot)