Fix the legacy map editor.

This commit is contained in:
Paul Chote
2014-10-05 18:11:36 +13:00
parent fff8c7680b
commit 9312d1915f
5 changed files with 13 additions and 8 deletions

View File

@@ -166,7 +166,7 @@ mod_ts: $(mod_ts_TARGET)
editor_SRCS := $(shell find OpenRA.Editor/ -iname '*.cs') editor_SRCS := $(shell find OpenRA.Editor/ -iname '*.cs')
editor_TARGET = OpenRA.Editor.exe editor_TARGET = OpenRA.Editor.exe
editor_KIND = winexe 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_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_EXTRA = -resource:OpenRA.Editor.Form1.resources -resource:OpenRA.Editor.MapSelect.resources
editor_FLAGS = -win32icon:OpenRA.Editor/OpenRA.Editor.Icon.ico editor_FLAGS = -win32icon:OpenRA.Editor/OpenRA.Editor.Icon.ico

View File

@@ -160,6 +160,10 @@
<Project>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</Project> <Project>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</Project>
<Name>OpenRA.Game</Name> <Name>OpenRA.Game</Name>
</ProjectReference> </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>
<ItemGroup> <ItemGroup>
<Content Include="OpenRA.Editor.Icon.ico" /> <Content Include="OpenRA.Editor.Icon.ico" />

View File

@@ -14,13 +14,14 @@ using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.FileSystem; using OpenRA.FileSystem;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Mods.Common.SpriteLoaders;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Editor namespace OpenRA.Editor
{ {
static class RenderUtils static class RenderUtils
{ {
static Bitmap RenderShp(ISpriteSource shp, IPalette p) static Bitmap RenderShp(ShpTDSprite shp, IPalette p)
{ {
var frame = shp.Frames.First(); var frame = shp.Frames.First();
@@ -50,14 +51,14 @@ namespace OpenRA.Editor
var image = info.Traits.Get<ILegacyEditorRenderInfo>().EditorImage(info); var image = info.Traits.Get<ILegacyEditorRenderInfo>().EditorImage(info);
using (var s = GlobalFileSystem.OpenWithExts(image, tileset.Extensions)) using (var s = GlobalFileSystem.OpenWithExts(image, tileset.Extensions))
{ {
var shp = new ShpReader(s); var shp = new ShpTDSprite(s);
var bitmap = RenderShp(shp, p); var bitmap = RenderShp(shp, p);
try try
{ {
using (var s2 = GlobalFileSystem.OpenWithExts(image + "2", tileset.Extensions)) using (var s2 = GlobalFileSystem.OpenWithExts(image + "2", tileset.Extensions))
{ {
var shp2 = new ShpReader(s2); var shp2 = new ShpTDSprite(s2);
var roofBitmap = RenderShp(shp2, p); var roofBitmap = RenderShp(shp2, p);
using (var g = System.Drawing.Graphics.FromImage(bitmap)) using (var g = System.Drawing.Graphics.FromImage(bitmap))
@@ -81,7 +82,7 @@ namespace OpenRA.Editor
using (var s = GlobalFileSystem.OpenWithExts(image, exts)) using (var s = GlobalFileSystem.OpenWithExts(image, exts))
{ {
// TODO: Do this properly // TODO: Do this properly
var shp = new ShpReader(s) as ISpriteSource; var shp = new ShpTDSprite(s);
var frame = shp.Frames.Last(); var frame = shp.Frames.Last();
var bitmap = new Bitmap(frame.Size.Width, frame.Size.Height, PixelFormat.Format8bppIndexed); var bitmap = new Bitmap(frame.Size.Width, frame.Size.Height, PixelFormat.Format8bppIndexed);

View File

@@ -274,7 +274,7 @@ namespace OpenRA.Editor
var cell = new CPos(u * ChunkSize + i, v * ChunkSize + j); var cell = new CPos(u * ChunkSize + i, v * ChunkSize + j);
var tr = Map.MapTiles.Value[cell]; var tr = Map.MapTiles.Value[cell];
var tile = TileSetRenderer.Data(tr.Type); 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]; var rawImage = tile[index];
for (var x = 0; x < TileSetRenderer.TileSize; x++) for (var x = 0; x < TileSetRenderer.TileSize; x++)
for (var y = 0; y < TileSetRenderer.TileSize; y++) for (var y = 0; y < TileSetRenderer.TileSize; y++)

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Editor
this.TileSize = Math.Min(tileSize.Width, tileSize.Height); this.TileSize = Math.Min(tileSize.Width, tileSize.Height);
templates = new Dictionary<ushort, byte[][]>(); 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) foreach (var t in tileset.Templates)
{ {
var allFrames = spriteLoader.LoadAllFrames(t.Value.Image); var allFrames = spriteLoader.LoadAllFrames(t.Value.Image);
@@ -102,7 +102,7 @@ namespace OpenRA.Editor
return bitmap; return bitmap;
} }
public List<byte[]> Data(ushort id) public byte[][] Data(ushort id)
{ {
return templates[id]; return templates[id];
} }