beginning of an editor

This commit is contained in:
Chris Forbes
2010-05-08 19:05:05 +12:00
parent 29d670dd79
commit f08247afd0
12 changed files with 780 additions and 0 deletions

48
OpenRA.Editor/Surface.cs Normal file
View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OpenRA.FileFormats;
using System.Drawing;
namespace OpenRA.Editor
{
class Surface : Control
{
public Map Map { get; set; }
public TileSet TileSet { get; set; }
public int2 Offset { get; set; }
public Surface()
: base()
{
BackColor = Color.Black;
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.ResizeRedraw, true);
UpdateStyles();
}
public const int CellSize = 24;
static readonly Pen RedPen = new Pen(Color.Red);
protected override void OnPaint(PaintEventArgs e)
{
if (Map == null) return;
if (TileSet == null) return;
var n = (ushort)14;
var template = TileSet.walk[n];
var tile = TileSet.tiles[n];
for( var u = 0; u < template.Size.X; u++ )
for( var v = 0; v < template.Size.Y; v++ )
if (template.TerrainType.ContainsKey(u + v * template.Size.X))
{
e.Graphics.DrawRectangle(RedPen, new Rectangle(CellSize * u, CellSize * v, CellSize, CellSize));
}
}
}
}