fixed #536 -- add grid to editor
This commit is contained in:
10
OpenRA.Editor/Form1.Designer.cs
generated
10
OpenRA.Editor/Form1.Designer.cs
generated
@@ -73,6 +73,7 @@ namespace OpenRA.Editor
|
||||
this.propertiesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.resizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.showActorNamesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.showGridToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripComboBox1 = new System.Windows.Forms.ToolStripComboBox();
|
||||
this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
|
||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
||||
@@ -395,6 +396,7 @@ namespace OpenRA.Editor
|
||||
this.propertiesToolStripMenuItem,
|
||||
this.resizeToolStripMenuItem,
|
||||
this.showActorNamesToolStripMenuItem,
|
||||
this.showGridToolStripMenuItem,
|
||||
this.fixOpenAreasToolStripMenuItem});
|
||||
this.mapToolStripMenuItem.Name = "mapToolStripMenuItem";
|
||||
this.mapToolStripMenuItem.Size = new System.Drawing.Size(43, 23);
|
||||
@@ -425,6 +427,13 @@ namespace OpenRA.Editor
|
||||
this.showActorNamesToolStripMenuItem.Text = "Show Actor &Names";
|
||||
this.showActorNamesToolStripMenuItem.Click += new System.EventHandler(this.ShowActorNamesClicked);
|
||||
//
|
||||
// showGridToolStripMenuItem
|
||||
//
|
||||
this.showGridToolStripMenuItem.Name = "showGridToolStripMenuItem";
|
||||
this.showGridToolStripMenuItem.Size = new System.Drawing.Size(175, 22);
|
||||
this.showGridToolStripMenuItem.Text = "Show &Grid";
|
||||
this.showGridToolStripMenuItem.Click += new System.EventHandler(this.ShowGridClicked);
|
||||
//
|
||||
// toolStripComboBox1
|
||||
//
|
||||
this.toolStripComboBox1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
|
||||
@@ -550,6 +559,7 @@ namespace OpenRA.Editor
|
||||
private System.Windows.Forms.ToolStripLabel toolStripLabel1;
|
||||
private System.Windows.Forms.ToolStripComboBox toolStripComboBox1;
|
||||
private System.Windows.Forms.ToolStripMenuItem showActorNamesToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem showGridToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem fixOpenAreasToolStripMenuItem;
|
||||
|
||||
}
|
||||
|
||||
@@ -423,6 +423,13 @@ namespace OpenRA.Editor
|
||||
surface1.ShowActorNames = showActorNamesToolStripMenuItem.Checked;
|
||||
}
|
||||
|
||||
void ShowGridClicked(object sender, EventArgs e)
|
||||
{
|
||||
showGridToolStripMenuItem.Checked ^= true;
|
||||
surface1.ShowGrid = showGridToolStripMenuItem.Checked;
|
||||
surface1.Chunks.Clear();
|
||||
}
|
||||
|
||||
void FixOpenAreas(object sender, EventArgs e)
|
||||
{
|
||||
dirty = true;
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace OpenRA.Editor
|
||||
|
||||
public bool IsPanning;
|
||||
public bool ShowActorNames;
|
||||
public bool ShowGrid;
|
||||
|
||||
public event Action AfterChange = () => { };
|
||||
public event Action<string> MousePositionChanged = _ => { };
|
||||
@@ -198,7 +199,6 @@ namespace OpenRA.Editor
|
||||
{
|
||||
|
||||
var bitmap = new Bitmap(ChunkSize * TileSet.TileSize, ChunkSize * TileSet.TileSize);
|
||||
bitmap.SetPixel(0, 0, Color.Green);
|
||||
|
||||
var data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height),
|
||||
ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
@@ -242,6 +242,16 @@ namespace OpenRA.Editor
|
||||
}
|
||||
|
||||
bitmap.UnlockBits(data);
|
||||
|
||||
if (ShowGrid)
|
||||
using( var g = SGraphics.FromImage(bitmap) )
|
||||
{
|
||||
var rect = new Rectangle(0,0,bitmap.Width, bitmap.Height);
|
||||
ControlPaint.DrawGrid( g, rect, new Size(2, Game.CellSize), Color.DarkRed );
|
||||
ControlPaint.DrawGrid( g, rect, new Size(Game.CellSize, 2), Color.DarkRed );
|
||||
ControlPaint.DrawGrid( g, rect, new Size(Game.CellSize, Game.CellSize), Color.Red );
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user