From ee3a8c2b60fc6dfc0692c9627bd83e3f23c24714 Mon Sep 17 00:00:00 2001 From: Scionwest_cp Date: Sun, 3 Jan 2010 20:48:25 -0800 Subject: [PATCH] Mud Designer: - Added a new designer that I will begin working on and testing UITypeEditors with. Future plan is to migrate all editors into a single editor relying heavily on UITypeEditors to flesh it out. - Selecting the Script property within the Designer.cs form executes the UIScriptEditor class and installs the UIScriptControl into the Designers control collection. - Clicking close on the Designer.cs GUI showcases clearing the controls of custom UITypeEditors and how the results of the editing is saved into the object that the PropertyGrid is editing. Mud Engine: - Added a UIScriptControl User Control that the UIScriptEditor TypeEditor uses to install directly into the new Test Designer. --- Mud Designer/Designer.Designer.cs | 95 ++++++++++++++ Mud Designer/Designer.cs | 29 +++++ Mud Designer/Designer.resx | 120 ++++++++++++++++++ Mud Designer/Editors/ToolkitLauncher.cs | 15 +++ .../Editors/ToolkitLauncher.designer.cs | 88 ++++++++----- Mud Designer/Mud Designer.csproj | 20 +++ .../UITypeEditors/UIScriptControl.Designer.cs | 58 +++++++++ .../UITypeEditors/UIScriptControl.cs | 30 +++++ .../UITypeEditors/UIScriptControl.resx | 120 ++++++++++++++++++ .../MudEngine/UITypeEditors/UIScriptEditor.cs | 30 +++-- 10 files changed, 562 insertions(+), 43 deletions(-) create mode 100644 Mud Designer/Designer.Designer.cs create mode 100644 Mud Designer/Designer.cs create mode 100644 Mud Designer/Designer.resx create mode 100644 Mud Designer/MudEngine/UITypeEditors/UIScriptControl.Designer.cs create mode 100644 Mud Designer/MudEngine/UITypeEditors/UIScriptControl.cs create mode 100644 Mud Designer/MudEngine/UITypeEditors/UIScriptControl.resx diff --git a/Mud Designer/Designer.Designer.cs b/Mud Designer/Designer.Designer.cs new file mode 100644 index 0000000..5a3e4f7 --- /dev/null +++ b/Mud Designer/Designer.Designer.cs @@ -0,0 +1,95 @@ +namespace MudDesigner +{ + partial class Designer + { + /// + /// 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.ControlContainer = new System.Windows.Forms.SplitContainer(); + this.button1 = new System.Windows.Forms.Button(); + this.propertyGrid1 = new System.Windows.Forms.PropertyGrid(); + this.ControlContainer.Panel2.SuspendLayout(); + this.ControlContainer.SuspendLayout(); + this.SuspendLayout(); + // + // ControlContainer + // + this.ControlContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.ControlContainer.Location = new System.Drawing.Point(0, 0); + this.ControlContainer.Name = "ControlContainer"; + // + // ControlContainer.Panel2 + // + this.ControlContainer.Panel2.Controls.Add(this.propertyGrid1); + this.ControlContainer.Panel2.Controls.Add(this.button1); + this.ControlContainer.Size = new System.Drawing.Size(797, 625); + this.ControlContainer.SplitterDistance = 538; + this.ControlContainer.TabIndex = 0; + // + // button1 + // + this.button1.Dock = System.Windows.Forms.DockStyle.Top; + this.button1.Location = new System.Drawing.Point(0, 0); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(255, 23); + this.button1.TabIndex = 1; + this.button1.Text = "Close"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // propertyGrid1 + // + this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill; + this.propertyGrid1.Location = new System.Drawing.Point(0, 23); + this.propertyGrid1.Name = "propertyGrid1"; + this.propertyGrid1.Size = new System.Drawing.Size(255, 602); + this.propertyGrid1.TabIndex = 2; + // + // Designer + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.ClientSize = new System.Drawing.Size(797, 625); + this.Controls.Add(this.ControlContainer); + this.Name = "Designer"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Mud Designer Replacement Test"; + this.ControlContainer.Panel2.ResumeLayout(false); + this.ControlContainer.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + internal System.Windows.Forms.SplitContainer ControlContainer; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.PropertyGrid propertyGrid1; + + + } +} \ No newline at end of file diff --git a/Mud Designer/Designer.cs b/Mud Designer/Designer.cs new file mode 100644 index 0000000..5510d54 --- /dev/null +++ b/Mud Designer/Designer.cs @@ -0,0 +1,29 @@ +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; + +using MudDesigner.MudEngine.GameObjects.Environment; +using MudDesigner.MudEngine.GameObjects; +namespace MudDesigner +{ + public partial class Designer : Form + { + Room r = new Room(); + + public Designer() + { + InitializeComponent(); + propertyGrid1.SelectedObject = r; + } + + private void button1_Click(object sender, EventArgs e) + { + ControlContainer.Panel1.Controls.Clear(); + } + } +} diff --git a/Mud Designer/Designer.resx b/Mud Designer/Designer.resx new file mode 100644 index 0000000..ff31a6d --- /dev/null +++ b/Mud Designer/Designer.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/Mud Designer/Editors/ToolkitLauncher.cs b/Mud Designer/Editors/ToolkitLauncher.cs index 25051ad..fa5f2bc 100644 --- a/Mud Designer/Editors/ToolkitLauncher.cs +++ b/Mud Designer/Editors/ToolkitLauncher.cs @@ -160,5 +160,20 @@ namespace MudDesigner.Editors { System.Diagnostics.Process.Start("http://muddesigner.dailyforum.net"); } + + private void btnTest_Click(object sender, EventArgs e) + { + Designer form = new Designer(); + Program.CurrentEditor = form; + + form.Show(); + this.Hide(); + while (form.Created) + Application.DoEvents(); + + form = null; + + this.Show(); + } } } diff --git a/Mud Designer/Editors/ToolkitLauncher.designer.cs b/Mud Designer/Editors/ToolkitLauncher.designer.cs index 785cd05..0a18c37 100644 --- a/Mud Designer/Editors/ToolkitLauncher.designer.cs +++ b/Mud Designer/Editors/ToolkitLauncher.designer.cs @@ -30,6 +30,9 @@ { this.components = new System.ComponentModel.Container(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.label2 = new System.Windows.Forms.Label(); + this.linkLabel1 = new System.Windows.Forms.LinkLabel(); + this.label1 = new System.Windows.Forms.Label(); this.btnLogo = new System.Windows.Forms.Button(); this.tabEditors = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); @@ -57,9 +60,7 @@ this.txtScript = new System.Windows.Forms.RichTextBox(); this.tabVariables = new System.Windows.Forms.TabPage(); this.Help = new System.Windows.Forms.ToolTip(this.components); - this.label1 = new System.Windows.Forms.Label(); - this.linkLabel1 = new System.Windows.Forms.LinkLabel(); - this.label2 = new System.Windows.Forms.Label(); + this.btnTest = new System.Windows.Forms.Button(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); @@ -99,6 +100,40 @@ this.splitContainer1.SplitterDistance = 154; this.splitContainer1.TabIndex = 0; // + // label2 + // + this.label2.AutoSize = true; + this.label2.BackColor = System.Drawing.Color.Black; + this.label2.ForeColor = System.Drawing.Color.White; + this.label2.Location = new System.Drawing.Point(267, 131); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(227, 13); + this.label2.TabIndex = 3; + this.label2.Text = "to leave feedback and help build a community!"; + // + // linkLabel1 + // + this.linkLabel1.AutoSize = true; + this.linkLabel1.BackColor = System.Drawing.Color.Black; + this.linkLabel1.Location = new System.Drawing.Point(160, 131); + this.linkLabel1.Name = "linkLabel1"; + this.linkLabel1.Size = new System.Drawing.Size(110, 13); + this.linkLabel1.TabIndex = 2; + this.linkLabel1.TabStop = true; + this.linkLabel1.Text = "Mud Designer Forums"; + this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.BackColor = System.Drawing.Color.Black; + this.label1.ForeColor = System.Drawing.Color.White; + this.label1.Location = new System.Drawing.Point(7, 131); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(157, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Developers please visit the new"; + // // btnLogo // this.btnLogo.BackColor = System.Drawing.Color.Black; @@ -145,6 +180,7 @@ this.flowLayoutPanel1.Controls.Add(this.btnCurrencyEditor); this.flowLayoutPanel1.Controls.Add(this.btnRealmExplorer); this.flowLayoutPanel1.Controls.Add(this.btnZoneBuilder); + this.flowLayoutPanel1.Controls.Add(this.btnTest); this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 3); this.flowLayoutPanel1.Name = "flowLayoutPanel1"; @@ -413,39 +449,20 @@ this.Help.ReshowDelay = 100; this.Help.ToolTipTitle = "Toolkit Help"; // - // label1 + // btnTest // - this.label1.AutoSize = true; - this.label1.BackColor = System.Drawing.Color.Black; - this.label1.ForeColor = System.Drawing.Color.White; - this.label1.Location = new System.Drawing.Point(7, 131); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(157, 13); - this.label1.TabIndex = 1; - this.label1.Text = "Developers please visit the new"; - // - // linkLabel1 - // - this.linkLabel1.AutoSize = true; - this.linkLabel1.BackColor = System.Drawing.Color.Black; - this.linkLabel1.Location = new System.Drawing.Point(160, 131); - this.linkLabel1.Name = "linkLabel1"; - this.linkLabel1.Size = new System.Drawing.Size(110, 13); - this.linkLabel1.TabIndex = 2; - this.linkLabel1.TabStop = true; - this.linkLabel1.Text = "Mud Designer Forums"; - this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); - // - // label2 - // - this.label2.AutoSize = true; - this.label2.BackColor = System.Drawing.Color.Black; - this.label2.ForeColor = System.Drawing.Color.White; - this.label2.Location = new System.Drawing.Point(267, 131); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(227, 13); - this.label2.TabIndex = 3; - this.label2.Text = "to leave feedback and help build a community!"; + this.btnTest.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnTest.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnTest.Location = new System.Drawing.Point(3, 64); + this.btnTest.Name = "btnTest"; + this.btnTest.Size = new System.Drawing.Size(147, 55); + this.btnTest.TabIndex = 5; + this.btnTest.Text = "New All-In-One Test Designer"; + this.Help.SetToolTip(this.btnTest, "The Zone Builder provides tools to create and manage your MUDs\r\nZones & Rooms. Cr" + + "eate Rooms, link them together via Doors and\r\nconnect Zones together either with" + + "in the same Realm or cross-realms."); + this.btnTest.UseVisualStyleBackColor = true; + this.btnTest.Click += new System.EventHandler(this.btnTest_Click); // // ToolkitLauncher // @@ -514,6 +531,7 @@ private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.LinkLabel linkLabel1; + private System.Windows.Forms.Button btnTest; } } diff --git a/Mud Designer/Mud Designer.csproj b/Mud Designer/Mud Designer.csproj index 1e20367..fe1a3c0 100644 --- a/Mud Designer/Mud Designer.csproj +++ b/Mud Designer/Mud Designer.csproj @@ -85,6 +85,12 @@ ScriptEditor.cs + + Form + + + Designer.cs + @@ -134,6 +140,12 @@ + + UserControl + + + UIScriptControl.cs + @@ -168,6 +180,14 @@ ProjectSettings.cs Designer + + Designer.cs + Designer + + + UIScriptControl.cs + Designer + ResXFileCodeGenerator Resources.Designer.cs diff --git a/Mud Designer/MudEngine/UITypeEditors/UIScriptControl.Designer.cs b/Mud Designer/MudEngine/UITypeEditors/UIScriptControl.Designer.cs new file mode 100644 index 0000000..1cb6fff --- /dev/null +++ b/Mud Designer/MudEngine/UITypeEditors/UIScriptControl.Designer.cs @@ -0,0 +1,58 @@ +namespace MudDesigner.MudEngine.UITypeEditors +{ + partial class UIScriptControl + { + /// + /// 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 Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.SuspendLayout(); + // + // richTextBox1 + // + this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.richTextBox1.Location = new System.Drawing.Point(0, 0); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.Size = new System.Drawing.Size(599, 518); + this.richTextBox1.TabIndex = 0; + this.richTextBox1.Text = ""; + // + // UIScriptControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.richTextBox1); + this.Name = "UIScriptControl"; + this.Size = new System.Drawing.Size(599, 518); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.RichTextBox richTextBox1; + } +} diff --git a/Mud Designer/MudEngine/UITypeEditors/UIScriptControl.cs b/Mud Designer/MudEngine/UITypeEditors/UIScriptControl.cs new file mode 100644 index 0000000..1abeec4 --- /dev/null +++ b/Mud Designer/MudEngine/UITypeEditors/UIScriptControl.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +using MudDesigner.MudEngine.GameObjects; + +namespace MudDesigner.MudEngine.UITypeEditors +{ + public partial class UIScriptControl : UserControl + { + internal string Script + { + get + { + return richTextBox1.Text; + } + } + + public UIScriptControl(BaseObject obj) + { + InitializeComponent(); + richTextBox1.Text = obj.Script; + } + } +} diff --git a/Mud Designer/MudEngine/UITypeEditors/UIScriptControl.resx b/Mud Designer/MudEngine/UITypeEditors/UIScriptControl.resx new file mode 100644 index 0000000..ff31a6d --- /dev/null +++ b/Mud Designer/MudEngine/UITypeEditors/UIScriptControl.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/Mud Designer/MudEngine/UITypeEditors/UIScriptEditor.cs b/Mud Designer/MudEngine/UITypeEditors/UIScriptEditor.cs index b6ec99d..fbc3c0e 100644 --- a/Mud Designer/MudEngine/UITypeEditors/UIScriptEditor.cs +++ b/Mud Designer/MudEngine/UITypeEditors/UIScriptEditor.cs @@ -33,17 +33,31 @@ namespace MudDesigner.MudEngine.UITypeEditors return null; } - MudDesigner.Editors.ScriptEditor frm = new MudDesigner.Editors.ScriptEditor(baseObj); - frm.Show(); - string script = ""; - - while (frm.Created) + if (Program.CurrentEditor is Designer) { - script = frm.Script; - System.Windows.Forms.Application.DoEvents(); + UIScriptControl control = new UIScriptControl(baseObj); + control.Dock = DockStyle.Fill; + Designer frm = (Designer)Program.CurrentEditor; + frm.ControlContainer.Panel1.Controls.Clear(); + frm.ControlContainer.Panel1.Controls.Add(control); + string script = ""; + + while (control.Created) + { + if (!frm.ControlContainer.Panel1.Controls.Contains(control)) + break; + Application.DoEvents(); + script = control.Script; + } + + + control = null; + frm = null; + + return script; } - return script; + return null; } public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)