working toward something sane

This commit is contained in:
Chris Forbes
2010-05-08 21:49:27 +12:00
parent edc73f2df8
commit 5bcebade32
3 changed files with 27 additions and 17 deletions

View File

@@ -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
//

View File

@@ -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

View File

@@ -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<ushort, Bitmap> Brush { get; set; }
Map Map;
TileSet TileSet;
Palette Palette;
int2 Offset;
public Pair<ushort, Bitmap> 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<int2, Bitmap> Chunks = new Dictionary<int2, Bitmap>();
@@ -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);