From b7e6dc90c339845871ea2cd77a562316047eb3f0 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 9 May 2010 13:24:07 +1200 Subject: [PATCH] resize dialog --- OpenRA.Editor/Form1.Designer.cs | 116 +++++++++---- OpenRA.Editor/Form1.cs | 18 ++ OpenRA.Editor/Form1.resx | 21 ++- OpenRA.Editor/OpenRA.Editor.csproj | 9 + OpenRA.Editor/ResizeDialog.Designer.cs | 225 +++++++++++++++++++++++++ OpenRA.Editor/ResizeDialog.cs | 19 +++ OpenRA.Editor/ResizeDialog.resx | 120 +++++++++++++ OpenRA.Editor/Surface.cs | 6 +- 8 files changed, 498 insertions(+), 36 deletions(-) create mode 100644 OpenRA.Editor/ResizeDialog.Designer.cs create mode 100644 OpenRA.Editor/ResizeDialog.cs create mode 100644 OpenRA.Editor/ResizeDialog.resx diff --git a/OpenRA.Editor/Form1.Designer.cs b/OpenRA.Editor/Form1.Designer.cs index 23c9a5faea..7b0c807ce7 100644 --- a/OpenRA.Editor/Form1.Designer.cs +++ b/OpenRA.Editor/Form1.Designer.cs @@ -32,11 +32,15 @@ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.tilePalette = new System.Windows.Forms.FlowLayoutPanel(); - this.surface1 = new OpenRA.Editor.Surface(); - this.tt = new System.Windows.Forms.ToolTip(this.components); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); + this.tt = new System.Windows.Forms.ToolTip(this.components); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.tabPage2 = new System.Windows.Forms.TabPage(); + this.tilePalette = new System.Windows.Forms.FlowLayoutPanel(); + this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); + this.surface1 = new OpenRA.Editor.Surface(); this.toolStripContainer1.ContentPanel.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); this.toolStripContainer1.SuspendLayout(); @@ -44,6 +48,8 @@ this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); this.toolStrip1.SuspendLayout(); + this.tabControl1.SuspendLayout(); + this.tabPage1.SuspendLayout(); this.SuspendLayout(); // // toolStripContainer1 @@ -72,7 +78,7 @@ // // splitContainer1.Panel1 // - this.splitContainer1.Panel1.Controls.Add(this.tilePalette); + this.splitContainer1.Panel1.Controls.Add(this.tabControl1); // // splitContainer1.Panel2 // @@ -81,14 +87,80 @@ this.splitContainer1.SplitterDistance = 198; this.splitContainer1.TabIndex = 0; // + // toolStrip1 + // + this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None; + this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripButton1, + this.toolStripButton2}); + this.toolStrip1.Location = new System.Drawing.Point(3, 0); + this.toolStrip1.Name = "toolStrip1"; + this.toolStrip1.Size = new System.Drawing.Size(122, 25); + this.toolStrip1.TabIndex = 0; + // + // toolStripButton1 + // + 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(51, 22); + this.toolStripButton1.Text = "Save"; + // + // tt + // + this.tt.ShowAlways = true; + // + // tabControl1 + // + this.tabControl1.Alignment = System.Windows.Forms.TabAlignment.Left; + this.tabControl1.Controls.Add(this.tabPage1); + this.tabControl1.Controls.Add(this.tabPage2); + this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabControl1.Location = new System.Drawing.Point(0, 0); + this.tabControl1.Multiline = true; + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(198, 680); + this.tabControl1.TabIndex = 0; + // + // tabPage1 + // + this.tabPage1.Controls.Add(this.tilePalette); + this.tabPage1.Location = new System.Drawing.Point(23, 4); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(3); + this.tabPage1.Size = new System.Drawing.Size(171, 672); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "Templates"; + this.tabPage1.UseVisualStyleBackColor = true; + // + // tabPage2 + // + this.tabPage2.Location = new System.Drawing.Point(23, 4); + this.tabPage2.Name = "tabPage2"; + this.tabPage2.Padding = new System.Windows.Forms.Padding(3); + this.tabPage2.Size = new System.Drawing.Size(171, 672); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "Actors"; + this.tabPage2.UseVisualStyleBackColor = true; + // // tilePalette // this.tilePalette.AutoScroll = true; this.tilePalette.Dock = System.Windows.Forms.DockStyle.Fill; - this.tilePalette.Location = new System.Drawing.Point(0, 0); + this.tilePalette.Location = new System.Drawing.Point(3, 3); this.tilePalette.Name = "tilePalette"; - this.tilePalette.Size = new System.Drawing.Size(198, 680); - this.tilePalette.TabIndex = 0; + this.tilePalette.Size = new System.Drawing.Size(165, 666); + this.tilePalette.TabIndex = 1; + // + // 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(59, 22); + this.toolStripButton2.Text = "Resize"; + this.toolStripButton2.Click += new System.EventHandler(this.ResizeClicked); // // surface1 // @@ -100,28 +172,6 @@ this.surface1.TabIndex = 2; this.surface1.Text = "surface1"; // - // tt - // - this.tt.ShowAlways = true; - // - // toolStrip1 - // - this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None; - this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripButton1}); - this.toolStrip1.Location = new System.Drawing.Point(3, 0); - this.toolStrip1.Name = "toolStrip1"; - this.toolStrip1.Size = new System.Drawing.Size(94, 25); - this.toolStrip1.TabIndex = 0; - // - // toolStripButton1 - // - 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(51, 22); - this.toolStripButton1.Text = "Save"; - // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -140,6 +190,8 @@ this.splitContainer1.ResumeLayout(false); this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); + this.tabControl1.ResumeLayout(false); + this.tabPage1.ResumeLayout(false); this.ResumeLayout(false); } @@ -149,10 +201,14 @@ private System.Windows.Forms.ToolStripContainer toolStripContainer1; private System.Windows.Forms.SplitContainer splitContainer1; private Surface surface1; - private System.Windows.Forms.FlowLayoutPanel tilePalette; private System.Windows.Forms.ToolTip tt; private System.Windows.Forms.ToolStrip toolStrip1; private System.Windows.Forms.ToolStripButton toolStripButton1; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.FlowLayoutPanel tilePalette; + private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.ToolStripButton toolStripButton2; } } diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index 89eacfbd78..78df763411 100644 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -125,5 +125,23 @@ namespace OpenRA.Editor bitmap.UnlockBits(data); return bitmap; } + + void ResizeClicked(object sender, EventArgs e) + { + using (var rd = new ResizeDialog()) + { + rd.width.Value = surface1.Map.MapSize.X; + rd.height.Value = surface1.Map.MapSize.Y; + rd.cordonLeft.Value = surface1.Map.TopLeft.X; + rd.cordonTop.Value = surface1.Map.TopLeft.Y; + rd.cordonRight.Value = surface1.Map.BottomRight.X; + rd.cordonBottom.Value = surface1.Map.BottomRight.Y; + + if (DialogResult.OK != rd.ShowDialog()) + return; + + surface1.Bind(surface1.Map, surface1.TileSet, surface1.Palette); // rebind it to invalidate all caches + } + } } } \ No newline at end of file diff --git a/OpenRA.Editor/Form1.resx b/OpenRA.Editor/Form1.resx index 0235fec697..ef0582873f 100644 --- a/OpenRA.Editor/Form1.resx +++ b/OpenRA.Editor/Form1.resx @@ -120,9 +120,6 @@ 77, 17 - - 17, 17 - @@ -139,4 +136,22 @@ KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI + ymqkDYYXcCjDZOANURSjCNGFQUTsl4GXVMxKk62YU4fXQpaIlygHQxBRH8/zwvyaIAYe+HLgnPN8nue9 + HA3nvDTq63oW/jm13XOwvPTB3DYFY5MH+bXfcN8ygfTSMSSXfESicQDxBqdYHwH29g9w2tnZ3UcguIvN + rR3417exuBJE5N1n/wfwLgXEOc38Bc6xNRHb+/y4nm49G0Bnit2zf9H6bkliE/jKuYxrd6oVgDWfjB+K + TWeKMyrGEVfowITvD9re/9ABVQrAhh0HHK+ZselMMaN/mvwtDb+aVqkA7HYIwIj3ysfluPTorJnP6Ezx + oHsD1s5ZXEktUwCOioB5f1CEPR9+wTG6iuiserTo8dkwng7HT/R+XUPF8xlcTjErAOdMcW6NW8STiwG8 + 7vej8oUPN/PsEv3t8Ao0TZP3T1u8uJRkUgAuSYHtO97oLxmXd5t9Ho8aPTK+GzntqNfrLm2fFoihwYOI + xGIF4KjoGBLzY1OrF9k6OOFxnwDC4wxIMX1G0pMhgVyMNyoA13PAtS7OrJk1PrC69LUdQWxuF6IybHrX + LRI7JrtZdoDAo1XmbjMyD+tjSXxGcXRmnYg5ttD9QuxDhN0uUgDOmbvNTpPOJaGAo2K36cyaGZvOFIfd + KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC + + + + 17, 17 + \ No newline at end of file diff --git a/OpenRA.Editor/OpenRA.Editor.csproj b/OpenRA.Editor/OpenRA.Editor.csproj index 46218f5c08..d6203883ee 100644 --- a/OpenRA.Editor/OpenRA.Editor.csproj +++ b/OpenRA.Editor/OpenRA.Editor.csproj @@ -66,6 +66,9 @@ Resources.Designer.cs Designer + + ResizeDialog.cs + True Resources.resx @@ -79,6 +82,12 @@ Settings.settings True + + Form + + + ResizeDialog.cs + Component diff --git a/OpenRA.Editor/ResizeDialog.Designer.cs b/OpenRA.Editor/ResizeDialog.Designer.cs new file mode 100644 index 0000000000..d712881805 --- /dev/null +++ b/OpenRA.Editor/ResizeDialog.Designer.cs @@ -0,0 +1,225 @@ +namespace OpenRA.Editor +{ + partial class ResizeDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.width = new System.Windows.Forms.NumericUpDown(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.cordonLeft = new System.Windows.Forms.NumericUpDown(); + this.cordonTop = new System.Windows.Forms.NumericUpDown(); + this.cordonRight = new System.Windows.Forms.NumericUpDown(); + this.cordonBottom = new System.Windows.Forms.NumericUpDown(); + this.label3 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.height = new System.Windows.Forms.NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)(this.width)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.cordonLeft)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.cordonTop)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.cordonRight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.cordonBottom)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.height)).BeginInit(); + this.SuspendLayout(); + // + // width + // + this.width.Increment = new decimal(new int[] { + 8, + 0, + 0, + 0}); + this.width.Location = new System.Drawing.Point(161, 18); + this.width.Maximum = new decimal(new int[] { + 2048, + 0, + 0, + 0}); + this.width.Name = "width"; + this.width.Size = new System.Drawing.Size(105, 20); + this.width.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(23, 20); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(27, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Size"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(23, 46); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(86, 13); + this.label2.TabIndex = 1; + this.label2.Text = "Cordon Left/Top"; + // + // cordonLeft + // + this.cordonLeft.Location = new System.Drawing.Point(161, 44); + this.cordonLeft.Maximum = new decimal(new int[] { + 2048, + 0, + 0, + 0}); + this.cordonLeft.Name = "cordonLeft"; + this.cordonLeft.Size = new System.Drawing.Size(105, 20); + this.cordonLeft.TabIndex = 0; + // + // cordonTop + // + this.cordonTop.Location = new System.Drawing.Point(272, 44); + this.cordonTop.Maximum = new decimal(new int[] { + 2048, + 0, + 0, + 0}); + this.cordonTop.Name = "cordonTop"; + this.cordonTop.Size = new System.Drawing.Size(105, 20); + this.cordonTop.TabIndex = 0; + // + // cordonRight + // + this.cordonRight.Location = new System.Drawing.Point(161, 70); + this.cordonRight.Maximum = new decimal(new int[] { + 2048, + 0, + 0, + 0}); + this.cordonRight.Name = "cordonRight"; + this.cordonRight.Size = new System.Drawing.Size(105, 20); + this.cordonRight.TabIndex = 0; + // + // cordonBottom + // + this.cordonBottom.Location = new System.Drawing.Point(272, 70); + this.cordonBottom.Maximum = new decimal(new int[] { + 2048, + 0, + 0, + 0}); + this.cordonBottom.Name = "cordonBottom"; + this.cordonBottom.Size = new System.Drawing.Size(105, 20); + this.cordonBottom.TabIndex = 0; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(23, 72); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(107, 13); + this.label3.TabIndex = 1; + this.label3.Text = "Cordon Right/Bottom"; + // + // button1 + // + this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.button1.Location = new System.Drawing.Point(302, 111); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 2; + this.button1.Text = "Cancel"; + this.button1.UseVisualStyleBackColor = true; + // + // button2 + // + this.button2.DialogResult = System.Windows.Forms.DialogResult.OK; + this.button2.Location = new System.Drawing.Point(221, 111); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 23); + this.button2.TabIndex = 2; + this.button2.Text = "OK"; + this.button2.UseVisualStyleBackColor = true; + // + // height + // + this.height.Increment = new decimal(new int[] { + 8, + 0, + 0, + 0}); + this.height.Location = new System.Drawing.Point(272, 18); + this.height.Maximum = new decimal(new int[] { + 2048, + 0, + 0, + 0}); + this.height.Name = "height"; + this.height.Size = new System.Drawing.Size(105, 20); + this.height.TabIndex = 0; + // + // ResizeDialog + // + this.AcceptButton = this.button2; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.button1; + this.ClientSize = new System.Drawing.Size(409, 146); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.cordonBottom); + this.Controls.Add(this.cordonTop); + this.Controls.Add(this.cordonRight); + this.Controls.Add(this.cordonLeft); + this.Controls.Add(this.height); + this.Controls.Add(this.width); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Name = "ResizeDialog"; + this.Text = "Resize Map"; + ((System.ComponentModel.ISupportInitialize)(this.width)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.cordonLeft)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.cordonTop)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.cordonRight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.cordonBottom)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.height)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + public System.Windows.Forms.NumericUpDown width; + public System.Windows.Forms.NumericUpDown cordonLeft; + public System.Windows.Forms.NumericUpDown cordonTop; + public System.Windows.Forms.NumericUpDown cordonRight; + public System.Windows.Forms.NumericUpDown cordonBottom; + public System.Windows.Forms.NumericUpDown height; + } +} \ No newline at end of file diff --git a/OpenRA.Editor/ResizeDialog.cs b/OpenRA.Editor/ResizeDialog.cs new file mode 100644 index 0000000000..f4587a8f11 --- /dev/null +++ b/OpenRA.Editor/ResizeDialog.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace OpenRA.Editor +{ + public partial class ResizeDialog : Form + { + public ResizeDialog() + { + InitializeComponent(); + } + } +} diff --git a/OpenRA.Editor/ResizeDialog.resx b/OpenRA.Editor/ResizeDialog.resx new file mode 100644 index 0000000000..ff31a6db56 --- /dev/null +++ b/OpenRA.Editor/ResizeDialog.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/OpenRA.Editor/Surface.cs b/OpenRA.Editor/Surface.cs index 9bed52bf17..4ddbc13aa1 100644 --- a/OpenRA.Editor/Surface.cs +++ b/OpenRA.Editor/Surface.cs @@ -8,9 +8,9 @@ namespace OpenRA.Editor { class Surface : Control { - Map Map; - TileSet TileSet; - Palette Palette; + public Map Map { get; private set; } + public TileSet TileSet { get; private set; } + public Palette Palette { get; private set; } int2 Offset; public Pair Brush;