diff --git a/OpenRA.Editor/Form1.Designer.cs b/OpenRA.Editor/Form1.Designer.cs index 9cf21c942b..23c9a5faea 100644 --- a/OpenRA.Editor/Form1.Designer.cs +++ b/OpenRA.Editor/Form1.Designer.cs @@ -95,13 +95,10 @@ this.surface1.BackColor = System.Drawing.Color.Black; this.surface1.Dock = System.Windows.Forms.DockStyle.Fill; this.surface1.Location = new System.Drawing.Point(0, 0); - this.surface1.Map = null; this.surface1.Name = "surface1"; - this.surface1.Palette = null; this.surface1.Size = new System.Drawing.Size(783, 680); this.surface1.TabIndex = 2; this.surface1.Text = "surface1"; - this.surface1.TileSet = null; // // tt // diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index f8ac9c94e8..ae653f04ee 100644 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -15,7 +15,14 @@ namespace OpenRA.Editor InitializeComponent(); LocateGameRoot(); - var mods = new[] { "ra" }; + LoadMap("ra", "mjolnir"); + } + + void LoadMap(string mod, string mapname) + { + tilePalette.Controls.Clear(); + + var mods = new[] { mod }; var manifest = new Manifest(mods); @@ -23,7 +30,7 @@ namespace OpenRA.Editor foreach (var pkg in manifest.Packages) FileSystem.Mount(pkg); // load the map - var map = new Map(new Folder("mods/ra/maps/scm01ea")); + var map = new Map(new Folder("mods/{0}/maps/{1}".F(mod, mapname))); // we're also going to need a tileset... var tsinfo = fileMapping[Pair.New(mods[0], map.Theater)]; @@ -31,9 +38,7 @@ namespace OpenRA.Editor var palette = new Palette(FileSystem.Open(map.Theater.ToLowerInvariant() + ".pal"), true); - surface1.TileSet = tileset; - surface1.Map = map; - surface1.Palette = palette; + surface1.Bind(map, tileset, palette); // construct the palette of tiles diff --git a/OpenRA.Editor/Surface.cs b/OpenRA.Editor/Surface.cs index 5624c50001..4daebeae8d 100644 --- a/OpenRA.Editor/Surface.cs +++ b/OpenRA.Editor/Surface.cs @@ -1,19 +1,27 @@ using System.Collections.Generic; using System.Drawing; +using System.Drawing.Imaging; using System.Windows.Forms; using OpenRA.FileFormats; -using System; -using System.Drawing.Imaging; namespace OpenRA.Editor { class Surface : Control { - public Map Map { get; set; } - public TileSet TileSet { get; set; } - public Palette Palette { get; set; } - public int2 Offset { get; set; } - public Pair Brush { get; set; } + Map Map; + TileSet TileSet; + Palette Palette; + int2 Offset; + public Pair Brush; + + public void Bind(Map m, TileSet ts, Palette p) + { + Map = m; + TileSet = ts; + Palette = p; + Brush = Pair.New((ushort)0, null as Bitmap); + Chunks.Clear(); + } Dictionary Chunks = new Dictionary(); @@ -127,8 +135,8 @@ namespace OpenRA.Editor if (Map == null) return; if (TileSet == null) return; - for( var u = Map.TopLeft.X - Map.TopLeft.X % ChunkSize; u <= Map.BottomRight.X; u += ChunkSize ) - for (var v = Map.TopLeft.Y - Map.TopLeft.Y % ChunkSize; v <= Map.BottomRight.Y; v += ChunkSize) + for( var u = 0; u <= Map.BottomRight.X; u += ChunkSize ) + for (var v = 0; v <= Map.BottomRight.Y; v += ChunkSize) { var x = new int2(u/ChunkSize,v/ChunkSize); if (!Chunks.ContainsKey(x)) Chunks[x] = RenderChunk(u / ChunkSize, v / ChunkSize);