From 5c7a54585516a88f02cefbe0515a7fa8c2115ba3 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 10 May 2010 20:23:11 +1200 Subject: [PATCH] new map dialog; not quite wired yet --- OpenRA.Editor/Form1.Designer.cs | 22 +- OpenRA.Editor/Form1.cs | 34 ++- OpenRA.Editor/Form1.resx | 15 ++ OpenRA.Editor/NewMapDialog.Designer.cs | 280 +++++++++++++++++++++++++ OpenRA.Editor/NewMapDialog.cs | 19 ++ OpenRA.Editor/NewMapDialog.resx | 120 +++++++++++ OpenRA.Editor/OpenRA.Editor.csproj | 9 + OpenRA.Game/Traits/World/Theater.cs | 5 +- 8 files changed, 497 insertions(+), 7 deletions(-) create mode 100644 OpenRA.Editor/NewMapDialog.Designer.cs create mode 100644 OpenRA.Editor/NewMapDialog.cs create mode 100644 OpenRA.Editor/NewMapDialog.resx diff --git a/OpenRA.Editor/Form1.Designer.cs b/OpenRA.Editor/Form1.Designer.cs index f731cc2a72..003fbe6b13 100644 --- a/OpenRA.Editor/Form1.Designer.cs +++ b/OpenRA.Editor/Form1.Designer.cs @@ -45,6 +45,7 @@ this.toolStripButton5 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton4 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton6 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); this.tt = new System.Windows.Forms.ToolTip(this.components); this.folderBrowser = new System.Windows.Forms.FolderBrowserDialog(); @@ -187,10 +188,11 @@ this.toolStripButton5, this.toolStripButton4, this.toolStripButton1, + this.toolStripButton6, this.toolStripButton2}); this.toolStrip1.Location = new System.Drawing.Point(3, 0); this.toolStrip1.Name = "toolStrip1"; - this.toolStrip1.Size = new System.Drawing.Size(305, 25); + this.toolStrip1.Size = new System.Drawing.Size(416, 25); this.toolStrip1.TabIndex = 0; // // toolStripButton3 @@ -200,6 +202,7 @@ this.toolStripButton3.Name = "toolStripButton3"; this.toolStripButton3.Size = new System.Drawing.Size(51, 22); this.toolStripButton3.Text = "New"; + this.toolStripButton3.Click += new System.EventHandler(this.NewClicked); // // toolStripButton5 // @@ -208,6 +211,7 @@ this.toolStripButton5.Name = "toolStripButton5"; this.toolStripButton5.Size = new System.Drawing.Size(56, 22); this.toolStripButton5.Text = "Open"; + this.toolStripButton5.Click += new System.EventHandler(this.OpenClicked); // // toolStripButton4 // @@ -227,14 +231,23 @@ this.toolStripButton1.Text = "Save As..."; this.toolStripButton1.Click += new System.EventHandler(this.SaveAsClicked); // + // toolStripButton6 + // + 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(59, 22); + this.toolStripButton6.Text = "Resize"; + this.toolStripButton6.Click += new System.EventHandler(this.ResizeClicked); + // // 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); + this.toolStripButton2.Size = new System.Drawing.Size(80, 22); + this.toolStripButton2.Text = "Properties"; + this.toolStripButton2.Click += new System.EventHandler(this.PropertiesClicked); // // tt // @@ -286,6 +299,7 @@ private System.Windows.Forms.ToolStripButton toolStripButton5; private System.Windows.Forms.ToolStripButton toolStripButton4; private System.Windows.Forms.FolderBrowserDialog folderBrowser; + private System.Windows.Forms.ToolStripButton toolStripButton6; } } diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index 7c87778fa0..212445449e 100644 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -4,6 +4,7 @@ using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Windows.Forms; +using System.Linq; using OpenRA.FileFormats; using OpenRA.GameRules; using OpenRA.Traits; @@ -18,11 +19,12 @@ namespace OpenRA.Editor AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly; LocateGameRoot(); - LoadMap("ra", "mjolnir"); + LoadMap(currentMod, "mjolnir"); } string loadedMapName; string colors; + string currentMod = "ra"; TileSet tileset; void LoadMap(string mod, string mapname) @@ -31,6 +33,8 @@ namespace OpenRA.Editor actorPalette.Controls.Clear(); resourcePalette.Controls.Clear(); + currentMod = mod; + var mods = new[] { mod }; var manifest = new Manifest(mods); @@ -326,11 +330,39 @@ namespace OpenRA.Editor void SaveAsClicked(object sender, EventArgs e) { + folderBrowser.ShowNewFolderButton = true; if (DialogResult.OK == folderBrowser.ShowDialog()) { + loadedMapName = folderBrowser.SelectedPath; SaveClicked(sender, e); } } + + void OpenClicked(object sender, EventArgs e) + { + folderBrowser.ShowNewFolderButton = true; + if (DialogResult.OK == folderBrowser.ShowDialog()) + LoadMap(currentMod, Path.GetFileName(folderBrowser.SelectedPath)); + } + + void NewClicked(object sender, EventArgs e) + { + using (var nmd = new NewMapDialog()) + { + nmd.theater.Items.Clear(); + nmd.theater.Items.AddRange(Rules.Info["world"].Traits.WithInterface() + .Select(a => a.Theater).ToArray()); + + if (DialogResult.OK != nmd.ShowDialog()) + { + } + } + } + + void PropertiesClicked(object sender, EventArgs e) + { + // + } } } \ No newline at end of file diff --git a/OpenRA.Editor/Form1.resx b/OpenRA.Editor/Form1.resx index ed37871b95..1f4349add1 100644 --- a/OpenRA.Editor/Form1.resx +++ b/OpenRA.Editor/Form1.resx @@ -179,6 +179,21 @@ xGIF4KjoGBLzY1OrF9k6OOFxnwDC4wxIMX1G0pMhgVyMNyoA13PAtS7OrJk1PrC69LUdQWxuF6IybHrX LRI7JrtZdoDAo1XmbjMyD+tjSXxGcXRmnYg5ttD9QuxDhN0uUgDOmbvNTpPOJaGAo2K36cyaGZvOFIfd 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 diff --git a/OpenRA.Editor/NewMapDialog.Designer.cs b/OpenRA.Editor/NewMapDialog.Designer.cs new file mode 100644 index 0000000000..ec363900cf --- /dev/null +++ b/OpenRA.Editor/NewMapDialog.Designer.cs @@ -0,0 +1,280 @@ +namespace OpenRA.Editor +{ + partial class NewMapDialog + { + /// + /// 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.button2 = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.cordonBottom = new System.Windows.Forms.NumericUpDown(); + this.cordonTop = new System.Windows.Forms.NumericUpDown(); + this.cordonRight = new System.Windows.Forms.NumericUpDown(); + this.cordonLeft = new System.Windows.Forms.NumericUpDown(); + this.height = new System.Windows.Forms.NumericUpDown(); + this.width = new System.Windows.Forms.NumericUpDown(); + this.label4 = new System.Windows.Forms.Label(); + this.theater = new System.Windows.Forms.ComboBox(); + ((System.ComponentModel.ISupportInitialize)(this.cordonBottom)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.cordonTop)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.cordonRight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.cordonLeft)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.height)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.width)).BeginInit(); + this.SuspendLayout(); + // + // button2 + // + this.button2.DialogResult = System.Windows.Forms.DialogResult.OK; + this.button2.Location = new System.Drawing.Point(229, 160); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 23); + this.button2.TabIndex = 12; + this.button2.Text = "OK"; + this.button2.UseVisualStyleBackColor = true; + // + // button1 + // + this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.button1.Location = new System.Drawing.Point(310, 160); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 13; + this.button1.Text = "Cancel"; + this.button1.UseVisualStyleBackColor = true; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(31, 77); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(107, 13); + this.label3.TabIndex = 9; + this.label3.Text = "Cordon Right/Bottom"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(31, 51); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(86, 13); + this.label2.TabIndex = 11; + this.label2.Text = "Cordon Left/Top"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(31, 25); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(27, 13); + this.label1.TabIndex = 10; + this.label1.Text = "Size"; + // + // cordonBottom + // + this.cordonBottom.Location = new System.Drawing.Point(280, 75); + 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 = 8; + this.cordonBottom.Value = new decimal(new int[] { + 112, + 0, + 0, + 0}); + // + // cordonTop + // + this.cordonTop.Location = new System.Drawing.Point(280, 49); + 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 = 3; + this.cordonTop.Value = new decimal(new int[] { + 16, + 0, + 0, + 0}); + // + // cordonRight + // + this.cordonRight.Location = new System.Drawing.Point(169, 75); + 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 = 5; + this.cordonRight.Value = new decimal(new int[] { + 112, + 0, + 0, + 0}); + // + // cordonLeft + // + this.cordonLeft.Location = new System.Drawing.Point(169, 49); + 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 = 7; + this.cordonLeft.Value = new decimal(new int[] { + 16, + 0, + 0, + 0}); + // + // height + // + this.height.Increment = new decimal(new int[] { + 8, + 0, + 0, + 0}); + this.height.Location = new System.Drawing.Point(280, 23); + 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 = 6; + this.height.Value = new decimal(new int[] { + 128, + 0, + 0, + 0}); + // + // width + // + this.width.Increment = new decimal(new int[] { + 8, + 0, + 0, + 0}); + this.width.Location = new System.Drawing.Point(169, 23); + 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 = 4; + this.width.Value = new decimal(new int[] { + 128, + 0, + 0, + 0}); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(31, 124); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(44, 13); + this.label4.TabIndex = 14; + this.label4.Text = "Theater"; + // + // theater + // + this.theater.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.theater.FormattingEnabled = true; + this.theater.Location = new System.Drawing.Point(169, 121); + this.theater.Name = "theater"; + this.theater.Size = new System.Drawing.Size(216, 21); + this.theater.TabIndex = 15; + // + // NewMapDialog + // + 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(418, 210); + this.Controls.Add(this.theater); + this.Controls.Add(this.label4); + 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 = "NewMapDialog"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "New Map"; + ((System.ComponentModel.ISupportInitialize)(this.cordonBottom)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.cordonTop)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.cordonRight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.cordonLeft)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.height)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.width)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; + public System.Windows.Forms.NumericUpDown cordonBottom; + public System.Windows.Forms.NumericUpDown cordonTop; + public System.Windows.Forms.NumericUpDown cordonRight; + public System.Windows.Forms.NumericUpDown cordonLeft; + public System.Windows.Forms.NumericUpDown height; + public System.Windows.Forms.NumericUpDown width; + private System.Windows.Forms.Label label4; + public System.Windows.Forms.ComboBox theater; + } +} \ No newline at end of file diff --git a/OpenRA.Editor/NewMapDialog.cs b/OpenRA.Editor/NewMapDialog.cs new file mode 100644 index 0000000000..3bc078a5b6 --- /dev/null +++ b/OpenRA.Editor/NewMapDialog.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 NewMapDialog : Form + { + public NewMapDialog() + { + InitializeComponent(); + } + } +} diff --git a/OpenRA.Editor/NewMapDialog.resx b/OpenRA.Editor/NewMapDialog.resx new file mode 100644 index 0000000000..ff31a6db56 --- /dev/null +++ b/OpenRA.Editor/NewMapDialog.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/OpenRA.Editor.csproj b/OpenRA.Editor/OpenRA.Editor.csproj index 259f019c9a..bad0919313 100644 --- a/OpenRA.Editor/OpenRA.Editor.csproj +++ b/OpenRA.Editor/OpenRA.Editor.csproj @@ -57,11 +57,20 @@ Form1.cs + + Form + + + NewMapDialog.cs + Form1.cs + + NewMapDialog.cs + ResXFileCodeGenerator Resources.Designer.cs diff --git a/OpenRA.Game/Traits/World/Theater.cs b/OpenRA.Game/Traits/World/Theater.cs index 6984b1f0cb..7785d56f6d 100644 --- a/OpenRA.Game/Traits/World/Theater.cs +++ b/OpenRA.Game/Traits/World/Theater.cs @@ -20,7 +20,7 @@ namespace OpenRA.Traits { - class TheaterInfo : TraitInfo + public class TheaterInfo : TraitInfo { public readonly string Name = null; public readonly string Theater = null; @@ -29,5 +29,6 @@ namespace OpenRA.Traits public readonly string Templates = null; public readonly string MapColors = null; } - class Theater {} + + public class Theater {} }