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:
@@ -70,7 +70,7 @@ namespace OpenRA.Editor
|
|||||||
{
|
{
|
||||||
MakeDirty();
|
MakeDirty();
|
||||||
var tileSet = Program.Rules.TileSets[surface1.Map.Tileset];
|
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();
|
cashToolStripStatusLabel.Text = CalculateTotalResource().ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +288,7 @@ namespace OpenRA.Editor
|
|||||||
p.ResumeLayout();
|
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;
|
propertiesToolStripMenuItem.Enabled = true;
|
||||||
toolStripMenuItemProperties.Enabled = true;
|
toolStripMenuItemProperties.Enabled = true;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ namespace OpenRA.Editor
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var tileset = Program.Rules.TileSets[map.Tileset];
|
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)
|
catch (Exception ed)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
// Add the static resources defined in the map; if the map lives
|
// Add the static resources defined in the map; if the map lives
|
||||||
// in a world use AddCustomTerrain instead
|
// 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);
|
Bitmap terrain = new Bitmap(terrainBitmap);
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ namespace OpenRA.Graphics
|
|||||||
if (map.MapResources.Value[mapX, mapY].Type == 0)
|
if (map.MapResources.Value[mapX, mapY].Type == 0)
|
||||||
continue;
|
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)
|
.Where(t => t.ResourceType == map.MapResources.Value[mapX, mapY].Type)
|
||||||
.Select(t => t.TerrainType).FirstOrDefault();
|
.Select(t => t.TerrainType).FirstOrDefault();
|
||||||
if (res == null)
|
if (res == null)
|
||||||
@@ -179,9 +179,14 @@ namespace OpenRA.Graphics
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Bitmap RenderMapPreview(TileSet tileset, Map map, bool actualSize)
|
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);
|
Bitmap terrain = TerrainBitmap(tileset, map, actualSize);
|
||||||
return AddStaticResources(tileset, map, terrain);
|
return AddStaticResources(tileset, map, resourceRules, terrain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ namespace OpenRA
|
|||||||
// the next render cycle.
|
// the next render cycle.
|
||||||
// (d) Any partially written bytes from the next minimap is in an
|
// (d) Any partially written bytes from the next minimap is in an
|
||||||
// unallocated area, and will be committed in the next cycle.
|
// 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);
|
p.Minimap = sheetBuilder.Add(bitmap);
|
||||||
|
|
||||||
lock (syncRoot)
|
lock (syncRoot)
|
||||||
|
|||||||
Reference in New Issue
Block a user