diff --git a/OpenRA.TilesetBuilder/Surface.cs b/OpenRA.TilesetBuilder/Surface.cs index 06bf191777..d4259ba1b2 100644 --- a/OpenRA.TilesetBuilder/Surface.cs +++ b/OpenRA.TilesetBuilder/Surface.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Windows.Forms; @@ -15,8 +16,12 @@ namespace OpenRA.TilesetBuilder public string InputMode; public Bitmap[] icon; public int TileSize; + public int TilesPerRow; //private System.ComponentModel.IContainer components; + + public event Action UpdateMouseTilePosition = (x, y, t) => { }; + Template CurrentTemplate; public bool ShowTerrainTypes @@ -67,19 +72,21 @@ namespace OpenRA.TilesetBuilder /* draw template outlines */ foreach (var t in Templates) { + System.Drawing.Pen pen = Pens.White; + foreach (var c in t.Cells.Keys) { if (CurrentTemplate == t) e.Graphics.FillRectangle(currentBrush, TileSize * c.X, TileSize * c.Y, TileSize, TileSize); if (!t.Cells.ContainsKey(c + new int2(-1, 0))) - e.Graphics.DrawLine(Pens.Red, (TileSize * c).ToPoint(), (TileSize * (c + new int2(0, 1))).ToPoint()); + e.Graphics.DrawLine(pen, (TileSize * c).ToPoint(), (TileSize * (c + new int2(0, 1))).ToPoint()); if (!t.Cells.ContainsKey(c + new int2(+1, 0))) - e.Graphics.DrawLine(Pens.Red, (TileSize * (c + new int2(1, 0))).ToPoint(), (TileSize * (c + new int2(1, 1))).ToPoint()); + e.Graphics.DrawLine(pen, (TileSize * (c + new int2(1, 0))).ToPoint(), (TileSize * (c + new int2(1, 1))).ToPoint()); if (!t.Cells.ContainsKey(c + new int2(0, +1))) - e.Graphics.DrawLine(Pens.Red, (TileSize * (c + new int2(0, 1))).ToPoint(), (TileSize * (c + new int2(1, 1))).ToPoint()); + e.Graphics.DrawLine(pen, (TileSize * (c + new int2(0, 1))).ToPoint(), (TileSize * (c + new int2(1, 1))).ToPoint()); if (!t.Cells.ContainsKey(c + new int2(0, -1))) - e.Graphics.DrawLine(Pens.Red, (TileSize * c).ToPoint(), (TileSize * (c + new int2(1, 0))).ToPoint()); + e.Graphics.DrawLine(pen, (TileSize * c).ToPoint(), (TileSize * (c + new int2(1, 0))).ToPoint()); } } } @@ -128,6 +135,8 @@ namespace OpenRA.TilesetBuilder } } } + + UpdateMouseTilePosition(pos.X, pos.Y, (pos.Y * TilesPerRow) + pos.X); } private void InitializeComponent() diff --git a/OpenRA.TilesetBuilder/frmBuilder.Designer.cs b/OpenRA.TilesetBuilder/frmBuilder.Designer.cs index f1ec285a8c..e25c52e08e 100644 --- a/OpenRA.TilesetBuilder/frmBuilder.Designer.cs +++ b/OpenRA.TilesetBuilder/frmBuilder.Designer.cs @@ -52,6 +52,7 @@ this.toolStripButton15 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton14 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton16 = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripButton3 = new System.Windows.Forms.ToolStripButton(); this.surface1 = new OpenRA.TilesetBuilder.Surface(); @@ -227,6 +228,7 @@ this.toolStripButton1.Name = "toolStripButton1"; this.toolStripButton1.Size = new System.Drawing.Size(118, 20); this.toolStripButton1.Text = "Template Tool"; + this.toolStripButton1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.toolStripButton1.Click += new System.EventHandler(this.TerrainTypeSelectorClicked); // // toolStrip1 @@ -236,6 +238,7 @@ this.toolStripButton15, this.toolStripButton2, this.toolStripButton14, + this.toolStripButton16, this.toolStripSeparator1, this.toolStripButton3}); this.toolStrip1.Location = new System.Drawing.Point(3, 0); @@ -250,6 +253,7 @@ this.toolStripButton15.Name = "toolStripButton15"; this.toolStripButton15.Size = new System.Drawing.Size(48, 22); this.toolStripButton15.Text = "New"; + this.toolStripButton15.ToolTipText = "Create new tileset"; this.toolStripButton15.Click += new System.EventHandler(this.toolStripButton15_Click); // // toolStripButton2 @@ -259,6 +263,7 @@ this.toolStripButton2.Name = "toolStripButton2"; this.toolStripButton2.Size = new System.Drawing.Size(51, 22); this.toolStripButton2.Text = "Save"; + this.toolStripButton2.ToolTipText = "Save Template definitions to file (*.tsx)"; this.toolStripButton2.Click += new System.EventHandler(this.SaveClicked); // // toolStripButton14 @@ -268,8 +273,19 @@ this.toolStripButton14.Name = "toolStripButton14"; this.toolStripButton14.Size = new System.Drawing.Size(59, 22); this.toolStripButton14.Text = "Export"; + this.toolStripButton14.ToolTipText = "Export defined Templates to files"; this.toolStripButton14.Click += new System.EventHandler(this.ExportClicked); // + // toolStripButton16 + // + this.toolStripButton16.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton14.Image"))); + this.toolStripButton16.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton16.Name = "toolStripButton16"; + this.toolStripButton16.Size = new System.Drawing.Size(65, 22); + this.toolStripButton16.Text = "Dump"; + this.toolStripButton16.ToolTipText = "Dump Template ID to tile number mapping to console"; + this.toolStripButton16.Click += new System.EventHandler(this.Export2Clicked); + // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; @@ -282,6 +298,8 @@ this.toolStripButton3.Name = "toolStripButton3"; this.toolStripButton3.Size = new System.Drawing.Size(70, 22); this.toolStripButton3.Text = "Overlays"; + this.toolStripButton3.ToolTipText = "Show/hide terrain type overlays"; + this.toolStripButton3.CheckOnClick = true; this.toolStripButton3.Click += new System.EventHandler(this.ShowOverlaysClicked); // // surface1 @@ -290,7 +308,7 @@ this.surface1.ImagesList = this.imageList; this.surface1.Location = new System.Drawing.Point(0, 0); this.surface1.Name = "surface1"; - this.surface1.ShowTerrainTypes = true; + this.surface1.ShowTerrainTypes = this.toolStripButton3.Checked; this.surface1.Size = new System.Drawing.Size(653, 454); this.surface1.TabIndex = 2; this.surface1.Text = "surface1"; @@ -325,13 +343,14 @@ private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripButton toolStripButton3; private System.Windows.Forms.ToolStripButton toolStripButton14; + private System.Windows.Forms.ToolStripButton toolStripButton15; + private System.Windows.Forms.ToolStripButton toolStripButton16; public System.Windows.Forms.ImageList imageList; private System.Windows.Forms.ToolStrip tsTerrainTypes; private System.Windows.Forms.Panel panel1; private Surface surface1; private System.Windows.Forms.ToolStripLabel toolStripLabel2; private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; - private System.Windows.Forms.ToolStripButton toolStripButton15; private System.Windows.Forms.ToolStripButton toolStripButton1; private System.Windows.Forms.ToolStripLabel toolStripLabel3; private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; diff --git a/OpenRA.TilesetBuilder/frmBuilder.cs b/OpenRA.TilesetBuilder/frmBuilder.cs index bf85e2825d..b7db7e0dad 100644 --- a/OpenRA.TilesetBuilder/frmBuilder.cs +++ b/OpenRA.TilesetBuilder/frmBuilder.cs @@ -65,6 +65,7 @@ namespace OpenRA.TilesetBuilder } surface1.Image = (Bitmap)rbitmap; + surface1.TilesPerRow = surface1.Image.Size.Width / surface1.TileSize; surface1.Image.SetResolution(96, 96); // people keep being noobs about DPI, and GDI+ cares. surface1.TerrainTypes = new int[surface1.Image.Width / size, surface1.Image.Height / size]; /* all passable by default */ surface1.Templates = new List