Fix the legacy map editor.
This commit is contained in:
2
Makefile
2
Makefile
@@ -166,7 +166,7 @@ mod_ts: $(mod_ts_TARGET)
|
||||
editor_SRCS := $(shell find OpenRA.Editor/ -iname '*.cs')
|
||||
editor_TARGET = OpenRA.Editor.exe
|
||||
editor_KIND = winexe
|
||||
editor_DEPS = $(game_TARGET)
|
||||
editor_DEPS = $(game_TARGET) $(mod_common_TARGET)
|
||||
editor_LIBS = System.Windows.Forms.dll System.Data.dll System.Drawing.dll $(editor_DEPS) thirdparty/Eluant.dll
|
||||
editor_EXTRA = -resource:OpenRA.Editor.Form1.resources -resource:OpenRA.Editor.MapSelect.resources
|
||||
editor_FLAGS = -win32icon:OpenRA.Editor/OpenRA.Editor.Icon.ico
|
||||
|
||||
@@ -160,6 +160,10 @@
|
||||
<Project>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</Project>
|
||||
<Name>OpenRA.Game</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\OpenRA.Mods.Common\OpenRA.Mods.Common.csproj">
|
||||
<Project>{FE6C8CC0-2F07-442A-B29F-17617B3B7FC6}</Project>
|
||||
<Name>OpenRA.Mods.Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="OpenRA.Editor.Icon.ico" />
|
||||
|
||||
@@ -14,13 +14,14 @@ using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.FileSystem;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.SpriteLoaders;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Editor
|
||||
{
|
||||
static class RenderUtils
|
||||
{
|
||||
static Bitmap RenderShp(ISpriteSource shp, IPalette p)
|
||||
static Bitmap RenderShp(ShpTDSprite shp, IPalette p)
|
||||
{
|
||||
var frame = shp.Frames.First();
|
||||
|
||||
@@ -50,14 +51,14 @@ namespace OpenRA.Editor
|
||||
var image = info.Traits.Get<ILegacyEditorRenderInfo>().EditorImage(info);
|
||||
using (var s = GlobalFileSystem.OpenWithExts(image, tileset.Extensions))
|
||||
{
|
||||
var shp = new ShpReader(s);
|
||||
var shp = new ShpTDSprite(s);
|
||||
var bitmap = RenderShp(shp, p);
|
||||
|
||||
try
|
||||
{
|
||||
using (var s2 = GlobalFileSystem.OpenWithExts(image + "2", tileset.Extensions))
|
||||
{
|
||||
var shp2 = new ShpReader(s2);
|
||||
var shp2 = new ShpTDSprite(s2);
|
||||
var roofBitmap = RenderShp(shp2, p);
|
||||
|
||||
using (var g = System.Drawing.Graphics.FromImage(bitmap))
|
||||
@@ -81,7 +82,7 @@ namespace OpenRA.Editor
|
||||
using (var s = GlobalFileSystem.OpenWithExts(image, exts))
|
||||
{
|
||||
// TODO: Do this properly
|
||||
var shp = new ShpReader(s) as ISpriteSource;
|
||||
var shp = new ShpTDSprite(s);
|
||||
var frame = shp.Frames.Last();
|
||||
|
||||
var bitmap = new Bitmap(frame.Size.Width, frame.Size.Height, PixelFormat.Format8bppIndexed);
|
||||
|
||||
@@ -274,7 +274,7 @@ namespace OpenRA.Editor
|
||||
var cell = new CPos(u * ChunkSize + i, v * ChunkSize + j);
|
||||
var tr = Map.MapTiles.Value[cell];
|
||||
var tile = TileSetRenderer.Data(tr.Type);
|
||||
var index = (tr.Index < tile.Count) ? tr.Index : (byte)0;
|
||||
var index = (tr.Index < tile.Length) ? tr.Index : (byte)0;
|
||||
var rawImage = tile[index];
|
||||
for (var x = 0; x < TileSetRenderer.TileSize; x++)
|
||||
for (var y = 0; y < TileSetRenderer.TileSize; y++)
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace OpenRA.Editor
|
||||
this.TileSize = Math.Min(tileSize.Width, tileSize.Height);
|
||||
|
||||
templates = new Dictionary<ushort, byte[][]>();
|
||||
var spriteLoader = new SpriteLoader(tileset.Extensions, null);
|
||||
var spriteLoader = new SpriteLoader(Game.modData.SpriteLoaders, tileset.Extensions, null);
|
||||
foreach (var t in tileset.Templates)
|
||||
{
|
||||
var allFrames = spriteLoader.LoadAllFrames(t.Value.Image);
|
||||
@@ -102,7 +102,7 @@ namespace OpenRA.Editor
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public List<byte[]> Data(ushort id)
|
||||
public byte[][] Data(ushort id)
|
||||
{
|
||||
return templates[id];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user