From ac75259efdad98393f267cc5006401fe01f1135e Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 11 May 2010 11:09:26 +1200 Subject: [PATCH] make it actually work, except for half the export --- OpenRA.TilesetBuilder/Form1.Designer.cs | 263 +++++++++++++++++++++++- OpenRA.TilesetBuilder/Form1.cs | 148 +++++++++++-- OpenRA.TilesetBuilder/Form1.resx | 214 +++++++++++++++++++ 3 files changed, 606 insertions(+), 19 deletions(-) diff --git a/OpenRA.TilesetBuilder/Form1.Designer.cs b/OpenRA.TilesetBuilder/Form1.Designer.cs index 0b199f7703..66c1fc556d 100644 --- a/OpenRA.TilesetBuilder/Form1.Designer.cs +++ b/OpenRA.TilesetBuilder/Form1.Designer.cs @@ -28,34 +28,289 @@ /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); + this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); + this.panel1 = new System.Windows.Forms.Panel(); this.surface1 = new OpenRA.TilesetBuilder.Surface(); + this.toolStrip1 = new System.Windows.Forms.ToolStrip(); + this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton14 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton3 = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripButton4 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton12 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton11 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton10 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton9 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton8 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton7 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton6 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton5 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton13 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); + this.toolStripContainer1.ContentPanel.SuspendLayout(); + this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); + this.toolStripContainer1.SuspendLayout(); + this.panel1.SuspendLayout(); + this.toolStrip1.SuspendLayout(); this.SuspendLayout(); // + // toolStripContainer1 + // + // + // toolStripContainer1.ContentPanel + // + this.toolStripContainer1.ContentPanel.Controls.Add(this.panel1); + this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(745, 571); + this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.toolStripContainer1.Location = new System.Drawing.Point(0, 0); + this.toolStripContainer1.Name = "toolStripContainer1"; + this.toolStripContainer1.Size = new System.Drawing.Size(745, 596); + this.toolStripContainer1.TabIndex = 0; + this.toolStripContainer1.Text = "toolStripContainer1"; + // + // toolStripContainer1.TopToolStripPanel + // + this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.toolStrip1); + // + // panel1 + // + this.panel1.AutoScroll = true; + this.panel1.Controls.Add(this.surface1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(745, 571); + this.panel1.TabIndex = 0; + // // surface1 // 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.Name = "surface1"; - this.surface1.Size = new System.Drawing.Size(745, 596); - this.surface1.TabIndex = 0; + this.surface1.Size = new System.Drawing.Size(598, 372); + this.surface1.TabIndex = 2; this.surface1.Text = "surface1"; // + // toolStrip1 + // + this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None; + this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripButton2, + this.toolStripButton14, + this.toolStripButton3, + this.toolStripSeparator1, + this.toolStripButton4, + this.toolStripButton12, + this.toolStripButton11, + this.toolStripButton10, + this.toolStripButton9, + this.toolStripButton8, + this.toolStripButton7, + this.toolStripButton6, + this.toolStripButton5, + this.toolStripButton13, + this.toolStripButton1}); + this.toolStrip1.Location = new System.Drawing.Point(3, 0); + this.toolStrip1.Name = "toolStrip1"; + this.toolStrip1.Size = new System.Drawing.Size(602, 25); + this.toolStrip1.TabIndex = 0; + // + // toolStripButton2 + // + this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image"))); + this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton2.Name = "toolStripButton2"; + this.toolStripButton2.Size = new System.Drawing.Size(51, 22); + this.toolStripButton2.Text = "Save"; + this.toolStripButton2.Click += new System.EventHandler(this.SaveClicked); + // + // toolStripButton14 + // + this.toolStripButton14.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton14.Image"))); + this.toolStripButton14.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton14.Name = "toolStripButton14"; + this.toolStripButton14.Size = new System.Drawing.Size(60, 22); + this.toolStripButton14.Text = "Export"; + this.toolStripButton14.Click += new System.EventHandler(this.ExportClicked); + // + // toolStripButton3 + // + this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image"))); + this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton3.Name = "toolStripButton3"; + this.toolStripButton3.Size = new System.Drawing.Size(104, 22); + this.toolStripButton3.Text = "Show Overlays"; + this.toolStripButton3.Click += new System.EventHandler(this.ShowOverlaysClicked); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25); + // + // toolStripButton4 + // + this.toolStripButton4.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton4.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton4.Image"))); + this.toolStripButton4.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton4.Name = "toolStripButton4"; + this.toolStripButton4.Size = new System.Drawing.Size(25, 22); + this.toolStripButton4.Tag = "0"; + this.toolStripButton4.Text = "tt0"; + this.toolStripButton4.Click += new System.EventHandler(this.TerrainTypeSelectorClicked); + // + // toolStripButton12 + // + this.toolStripButton12.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton12.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton12.Image"))); + this.toolStripButton12.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton12.Name = "toolStripButton12"; + this.toolStripButton12.Size = new System.Drawing.Size(25, 22); + this.toolStripButton12.Tag = "1"; + this.toolStripButton12.Text = "tt1"; + this.toolStripButton12.Click += new System.EventHandler(this.TerrainTypeSelectorClicked); + // + // toolStripButton11 + // + this.toolStripButton11.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton11.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton11.Image"))); + this.toolStripButton11.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton11.Name = "toolStripButton11"; + this.toolStripButton11.Size = new System.Drawing.Size(25, 22); + this.toolStripButton11.Tag = "2"; + this.toolStripButton11.Text = "tt2"; + this.toolStripButton11.Click += new System.EventHandler(this.TerrainTypeSelectorClicked); + // + // toolStripButton10 + // + this.toolStripButton10.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton10.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton10.Image"))); + this.toolStripButton10.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton10.Name = "toolStripButton10"; + this.toolStripButton10.Size = new System.Drawing.Size(25, 22); + this.toolStripButton10.Tag = "3"; + this.toolStripButton10.Text = "tt3"; + this.toolStripButton10.Click += new System.EventHandler(this.TerrainTypeSelectorClicked); + // + // toolStripButton9 + // + this.toolStripButton9.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton9.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton9.Image"))); + this.toolStripButton9.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton9.Name = "toolStripButton9"; + this.toolStripButton9.Size = new System.Drawing.Size(25, 22); + this.toolStripButton9.Tag = "4"; + this.toolStripButton9.Text = "tt4"; + this.toolStripButton9.Click += new System.EventHandler(this.TerrainTypeSelectorClicked); + // + // toolStripButton8 + // + this.toolStripButton8.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton8.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton8.Image"))); + this.toolStripButton8.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton8.Name = "toolStripButton8"; + this.toolStripButton8.Size = new System.Drawing.Size(25, 22); + this.toolStripButton8.Tag = "5"; + this.toolStripButton8.Text = "tt5"; + this.toolStripButton8.Click += new System.EventHandler(this.TerrainTypeSelectorClicked); + // + // toolStripButton7 + // + this.toolStripButton7.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton7.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton7.Image"))); + this.toolStripButton7.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton7.Name = "toolStripButton7"; + this.toolStripButton7.Size = new System.Drawing.Size(25, 22); + this.toolStripButton7.Tag = "6"; + this.toolStripButton7.Text = "tt6"; + this.toolStripButton7.Click += new System.EventHandler(this.TerrainTypeSelectorClicked); + // + // toolStripButton6 + // + this.toolStripButton6.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton6.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton6.Image"))); + this.toolStripButton6.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton6.Name = "toolStripButton6"; + this.toolStripButton6.Size = new System.Drawing.Size(25, 22); + this.toolStripButton6.Tag = "7"; + this.toolStripButton6.Text = "tt7"; + this.toolStripButton6.Click += new System.EventHandler(this.TerrainTypeSelectorClicked); + // + // toolStripButton5 + // + this.toolStripButton5.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton5.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton5.Image"))); + this.toolStripButton5.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton5.Name = "toolStripButton5"; + this.toolStripButton5.Size = new System.Drawing.Size(25, 22); + this.toolStripButton5.Tag = "8"; + this.toolStripButton5.Text = "tt8"; + this.toolStripButton5.Click += new System.EventHandler(this.TerrainTypeSelectorClicked); + // + // toolStripButton13 + // + this.toolStripButton13.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton13.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton13.Image"))); + this.toolStripButton13.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton13.Name = "toolStripButton13"; + this.toolStripButton13.Size = new System.Drawing.Size(25, 22); + this.toolStripButton13.Tag = "9"; + this.toolStripButton13.Text = "tt9"; + // + // toolStripButton1 + // + this.toolStripButton1.Checked = true; + this.toolStripButton1.CheckState = System.Windows.Forms.CheckState.Checked; + this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image"))); + this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton1.Name = "toolStripButton1"; + this.toolStripButton1.Size = new System.Drawing.Size(88, 22); + this.toolStripButton1.Text = "Template Tool"; + this.toolStripButton1.Click += new System.EventHandler(this.TerrainTypeSelectorClicked); + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(745, 596); - this.Controls.Add(this.surface1); + this.Controls.Add(this.toolStripContainer1); this.Name = "Form1"; this.Text = "Tileset Builder"; + this.toolStripContainer1.ContentPanel.ResumeLayout(false); + this.toolStripContainer1.TopToolStripPanel.ResumeLayout(false); + this.toolStripContainer1.TopToolStripPanel.PerformLayout(); + this.toolStripContainer1.ResumeLayout(false); + this.toolStripContainer1.PerformLayout(); + this.panel1.ResumeLayout(false); + this.toolStrip1.ResumeLayout(false); + this.toolStrip1.PerformLayout(); this.ResumeLayout(false); } #endregion + private System.Windows.Forms.ToolStripContainer toolStripContainer1; + private System.Windows.Forms.Panel panel1; private Surface surface1; + private System.Windows.Forms.ToolStrip toolStrip1; + private System.Windows.Forms.ToolStripButton toolStripButton1; + private System.Windows.Forms.ToolStripButton toolStripButton2; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripButton toolStripButton3; + private System.Windows.Forms.ToolStripButton toolStripButton4; + private System.Windows.Forms.ToolStripButton toolStripButton12; + private System.Windows.Forms.ToolStripButton toolStripButton11; + private System.Windows.Forms.ToolStripButton toolStripButton10; + private System.Windows.Forms.ToolStripButton toolStripButton9; + private System.Windows.Forms.ToolStripButton toolStripButton8; + private System.Windows.Forms.ToolStripButton toolStripButton7; + private System.Windows.Forms.ToolStripButton toolStripButton6; + private System.Windows.Forms.ToolStripButton toolStripButton5; + private System.Windows.Forms.ToolStripButton toolStripButton13; + private System.Windows.Forms.ToolStripButton toolStripButton14; + } } diff --git a/OpenRA.TilesetBuilder/Form1.cs b/OpenRA.TilesetBuilder/Form1.cs index bd9e5d0f2b..84b5b35e00 100644 --- a/OpenRA.TilesetBuilder/Form1.cs +++ b/OpenRA.TilesetBuilder/Form1.cs @@ -1,21 +1,117 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Drawing; -using System.Windows.Forms; +using System.IO; using System.Linq; +using System.Windows.Forms; +using System.Xml; namespace OpenRA.TilesetBuilder { public partial class Form1 : Form { + string srcfile; public Form1( string src ) { + srcfile = src; + InitializeComponent(); surface1.Image = (Bitmap)Image.FromFile(src); surface1.TerrainTypes = new int[surface1.Image.Width / 24, surface1.Image.Height / 24]; /* all passable by default */ surface1.Templates = new List