From de59ce1091db0039402e4cf9747a5838ec9fe913 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 10 May 2010 20:57:22 +1200 Subject: [PATCH] add map metadata dialog, and make it work --- OpenRA.Editor/Form1.cs | 23 ++- OpenRA.Editor/OpenRA.Editor.csproj | 9 ++ OpenRA.Editor/PropertiesDialog.Designer.cs | 159 +++++++++++++++++++++ OpenRA.Editor/PropertiesDialog.cs | 12 ++ OpenRA.Editor/PropertiesDialog.resx | 120 ++++++++++++++++ OpenRA.FileFormats/Map/Map.cs | 2 +- 6 files changed, 322 insertions(+), 3 deletions(-) create mode 100644 OpenRA.Editor/PropertiesDialog.Designer.cs create mode 100644 OpenRA.Editor/PropertiesDialog.cs create mode 100644 OpenRA.Editor/PropertiesDialog.resx diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index bc97276330..56f0d46628 100644 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using System.IO; -using System.Windows.Forms; using System.Linq; +using System.Windows.Forms; using OpenRA.FileFormats; using OpenRA.GameRules; using OpenRA.Traits; @@ -376,6 +376,7 @@ namespace OpenRA.Editor nmd.theater.Items.Clear(); nmd.theater.Items.AddRange(Rules.Info["world"].Traits.WithInterface() .Select(a => a.Theater).ToArray()); + nmd.theater.SelectedIndex = 0; if (DialogResult.OK == nmd.ShowDialog()) { @@ -398,6 +399,10 @@ namespace OpenRA.Editor map.Tileset = nmd.theater.SelectedItem as string; + map.Title = "Name your map here"; + map.Description = "Describe your map here"; + map.Author = "Your name here"; + NewMap(map); } } @@ -405,7 +410,21 @@ namespace OpenRA.Editor void PropertiesClicked(object sender, EventArgs e) { - // + using (var pd = new PropertiesDialog()) + { + pd.title.Text = surface1.Map.Title; + pd.desc.Text = surface1.Map.Description; + pd.author.Text = surface1.Map.Author; + pd.selectable.Checked = surface1.Map.Selectable; + + if (DialogResult.OK != pd.ShowDialog()) + return; + + surface1.Map.Title = pd.title.Text; + surface1.Map.Description = pd.desc.Text; + surface1.Map.Author = pd.author.Text; + surface1.Map.Selectable = pd.selectable.Checked; + } } } } \ No newline at end of file diff --git a/OpenRA.Editor/OpenRA.Editor.csproj b/OpenRA.Editor/OpenRA.Editor.csproj index bad0919313..d73e720712 100644 --- a/OpenRA.Editor/OpenRA.Editor.csproj +++ b/OpenRA.Editor/OpenRA.Editor.csproj @@ -64,6 +64,12 @@ NewMapDialog.cs + + Form + + + PropertiesDialog.cs + Form1.cs @@ -71,6 +77,9 @@ NewMapDialog.cs + + PropertiesDialog.cs + ResXFileCodeGenerator Resources.Designer.cs diff --git a/OpenRA.Editor/PropertiesDialog.Designer.cs b/OpenRA.Editor/PropertiesDialog.Designer.cs new file mode 100644 index 0000000000..b4a7758396 --- /dev/null +++ b/OpenRA.Editor/PropertiesDialog.Designer.cs @@ -0,0 +1,159 @@ +namespace OpenRA.Editor +{ + partial class PropertiesDialog + { + /// + /// 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.label1 = new System.Windows.Forms.Label(); + this.title = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.desc = new System.Windows.Forms.TextBox(); + this.selectable = new System.Windows.Forms.CheckBox(); + this.label3 = new System.Windows.Forms.Label(); + this.author = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // button2 + // + this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button2.DialogResult = System.Windows.Forms.DialogResult.OK; + this.button2.Location = new System.Drawing.Point(196, 193); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 23); + this.button2.TabIndex = 14; + this.button2.Text = "OK"; + this.button2.UseVisualStyleBackColor = true; + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.button1.Location = new System.Drawing.Point(277, 193); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 15; + this.button1.Text = "Cancel"; + this.button1.UseVisualStyleBackColor = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 50); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(27, 13); + this.label1.TabIndex = 16; + this.label1.Text = "Title"; + // + // title + // + this.title.Location = new System.Drawing.Point(66, 47); + this.title.Name = "title"; + this.title.Size = new System.Drawing.Size(286, 20); + this.title.TabIndex = 17; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 76); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(32, 13); + this.label2.TabIndex = 16; + this.label2.Text = "Desc"; + // + // desc + // + this.desc.Location = new System.Drawing.Point(66, 73); + this.desc.Name = "desc"; + this.desc.Size = new System.Drawing.Size(286, 20); + this.desc.TabIndex = 17; + // + // selectable + // + this.selectable.AutoSize = true; + this.selectable.Location = new System.Drawing.Point(118, 138); + this.selectable.Name = "selectable"; + this.selectable.Size = new System.Drawing.Size(130, 17); + this.selectable.TabIndex = 18; + this.selectable.Text = "Show in Map Chooser"; + this.selectable.UseVisualStyleBackColor = true; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(12, 102); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(38, 13); + this.label3.TabIndex = 16; + this.label3.Text = "Author"; + // + // author + // + this.author.Location = new System.Drawing.Point(66, 99); + this.author.Name = "author"; + this.author.Size = new System.Drawing.Size(286, 20); + this.author.TabIndex = 17; + // + // PropertiesDialog + // + 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(370, 228); + this.Controls.Add(this.selectable); + this.Controls.Add(this.author); + this.Controls.Add(this.label3); + this.Controls.Add(this.desc); + this.Controls.Add(this.label2); + this.Controls.Add(this.title); + this.Controls.Add(this.label1); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Name = "PropertiesDialog"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "PropertiesDialog"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Label label1; + public System.Windows.Forms.TextBox title; + private System.Windows.Forms.Label label2; + public System.Windows.Forms.TextBox desc; + public System.Windows.Forms.CheckBox selectable; + private System.Windows.Forms.Label label3; + public System.Windows.Forms.TextBox author; + } +} \ No newline at end of file diff --git a/OpenRA.Editor/PropertiesDialog.cs b/OpenRA.Editor/PropertiesDialog.cs new file mode 100644 index 0000000000..2d3faf0a6e --- /dev/null +++ b/OpenRA.Editor/PropertiesDialog.cs @@ -0,0 +1,12 @@ +using System.Windows.Forms; + +namespace OpenRA.Editor +{ + public partial class PropertiesDialog : Form + { + public PropertiesDialog() + { + InitializeComponent(); + } + } +} diff --git a/OpenRA.Editor/PropertiesDialog.resx b/OpenRA.Editor/PropertiesDialog.resx new file mode 100644 index 0000000000..ff31a6db56 --- /dev/null +++ b/OpenRA.Editor/PropertiesDialog.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.FileFormats/Map/Map.cs b/OpenRA.FileFormats/Map/Map.cs index 50a99810da..2c6c1c3778 100644 --- a/OpenRA.FileFormats/Map/Map.cs +++ b/OpenRA.FileFormats/Map/Map.cs @@ -34,7 +34,7 @@ namespace OpenRA.FileFormats public string Uid; // Yaml map data - public bool Selectable; + public bool Selectable = true; public int MapFormat = 1; public string Title; public string Description;