Mud Engine:

- Implemented a UITypeEditor for scripts to test developing custom UI Editors for PropertyGrids. It allows for scripts to be edited directly within the PropertyGrid now by launching the new ScriptEditor form. This is how most of the editors custom objects will be implemented into the PropertyGrids.
 - The Script property is now browsable within PropertyGrids now that they have a custom editor built.

Mud Designer:
 - ScriptEditor added.
 - Removed Script editor from within the Realm Explorer and I will do the same for the Zone Explorer and Room Builder.
 - All objects can now have a script attached to them from within any editor thanks to the new UITypeEditor approach being used.
This commit is contained in:
Scionwest_cp 2010-01-03 20:01:36 -08:00
parent 02c7bbca86
commit 90b7ca1a87
9 changed files with 282 additions and 38 deletions

View file

@ -88,7 +88,6 @@ namespace MudDesigner.Editors
Program.Realm = new Realm();
propertyRealm.SelectedObject = Program.Realm;
txtScript.Text = Program.Realm.Script;
}
private void btnSaveRealm_Click(object sender, EventArgs e)
@ -190,16 +189,10 @@ namespace MudDesigner.Editors
{
//load it.
Program.Realm = r;
txtScript.Text = Program.Realm.Script;
propertyRealm.SelectedObject = r;
break;
}
}
}
private void txtScript_TextChanged(object sender, EventArgs e)
{
Program.Realm.Script = txtScript.Text;
}
}
}

View file

@ -44,8 +44,6 @@
this.btnNewRealm = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.propertyRealm = new System.Windows.Forms.PropertyGrid();
this.tabScript = new System.Windows.Forms.TabPage();
this.txtScript = new System.Windows.Forms.RichTextBox();
this.tabControl1.SuspendLayout();
this.tabRealm.SuspendLayout();
this.splitContainer1.Panel1.SuspendLayout();
@ -54,7 +52,6 @@
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.tabScript.SuspendLayout();
this.SuspendLayout();
//
// button1
@ -96,7 +93,6 @@
// tabControl1
//
this.tabControl1.Controls.Add(this.tabRealm);
this.tabControl1.Controls.Add(this.tabScript);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Location = new System.Drawing.Point(0, 0);
this.tabControl1.Name = "tabControl1";
@ -228,27 +224,6 @@
this.propertyRealm.TabIndex = 18;
this.propertyRealm.ToolbarVisible = false;
//
// tabScript
//
this.tabScript.Controls.Add(this.txtScript);
this.tabScript.Location = new System.Drawing.Point(4, 22);
this.tabScript.Name = "tabScript";
this.tabScript.Padding = new System.Windows.Forms.Padding(3);
this.tabScript.Size = new System.Drawing.Size(462, 438);
this.tabScript.TabIndex = 1;
this.tabScript.Text = "Realm Script";
this.tabScript.UseVisualStyleBackColor = true;
//
// txtScript
//
this.txtScript.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtScript.Location = new System.Drawing.Point(3, 3);
this.txtScript.Name = "txtScript";
this.txtScript.Size = new System.Drawing.Size(456, 432);
this.txtScript.TabIndex = 0;
this.txtScript.Text = "";
this.txtScript.TextChanged += new System.EventHandler(this.txtScript_TextChanged);
//
// RealmExplorer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -269,7 +244,6 @@
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.tabScript.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -292,8 +266,6 @@
private System.Windows.Forms.Button btnNewRealm;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.PropertyGrid propertyRealm;
private System.Windows.Forms.TabPage tabScript;
private System.Windows.Forms.RichTextBox txtScript;

View file

@ -0,0 +1,59 @@
namespace MudDesigner.Editors
{
partial class ScriptEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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(575, 548);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = "";
//
// frmScriptEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(575, 548);
this.Controls.Add(this.richTextBox1);
this.Name = "frmScriptEditor";
this.Text = "frmScriptEditor";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.RichTextBox richTextBox1;
}
}

View file

@ -0,0 +1,30 @@
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;
namespace MudDesigner.Editors
{
public partial class ScriptEditor : Form
{
public string Script
{
get
{
return richTextBox1.Text;
}
}
public ScriptEditor(BaseObject baseObject)
{
InitializeComponent();
richTextBox1.Text = baseObject.Script;
}
}
}

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -79,6 +79,12 @@
<Compile Include="Editors\ExistingRealms.Designer.cs">
<DependentUpon>ExistingRealms.cs</DependentUpon>
</Compile>
<Compile Include="Editors\ScriptEditor.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Editors\ScriptEditor.Designer.cs">
<DependentUpon>ScriptEditor.cs</DependentUpon>
</Compile>
<Compile Include="MudEngine\FileSystem\SaveDataTypes.cs" />
<Compile Include="MudEngine\GameManagement\GameScript.cs" />
<Compile Include="MudEngine\GameObjects\Bag.cs" />
@ -142,6 +148,10 @@
<DependentUpon>ExistingRealms.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Editors\ScriptEditor.resx">
<DependentUpon>ScriptEditor.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Editors\ZoneBuilder.resx">
<DependentUpon>ZoneBuilder.cs</DependentUpon>
<SubType>Designer</SubType>
@ -179,6 +189,7 @@
</Compile>
<Compile Include="MudEngine\FileSystem\XmlSerialization.cs" />
<Compile Include="Settings.cs" />
<Compile Include="MudEngine\UITypeEditors\UIScriptEditor.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">

View file

@ -6,13 +6,15 @@ using System.ComponentModel;
using System.Windows.Forms;
using System.Xml.Serialization;
using MudDesigner.MudEngine.Interfaces;
using MudDesigner.MudEngine.UITypeEditors;
namespace MudDesigner.MudEngine.GameObjects
{
public class BaseObject : IGameObject
{
[Category("Object Setup")]
[RefreshProperties(RefreshProperties.All)] //Required to refresh Filename property in the editors propertygrid
//Required to refresh Filename property in the editors propertygrid
[RefreshProperties(RefreshProperties.All)]
public string Name
{
get
@ -32,8 +34,9 @@ namespace MudDesigner.MudEngine.GameObjects
get;
set;
}
[Browsable(false)]
[Category("Object Setup")]
[EditorAttribute(typeof(UIScriptEditor), typeof(System.Drawing.Design.UITypeEditor))]
public string Script { get; set; }
[Category("Object Setup")]

View file

@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -51,6 +52,7 @@ namespace MudDesigner.MudEngine.GameObjects.Environment
set;
}
public Room TestRoom { get; set; }
public Room()
{
InstalledDoors = new List<Door>();

View file

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MudDesigner.MudEngine.GameObjects;
using MudDesigner.MudEngine.GameObjects.Environment;
using System.Windows.Forms;
namespace MudDesigner.MudEngine.UITypeEditors
{
public class UIScriptEditor : System.Drawing.Design.UITypeEditor
{
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
{
object obj = context.Instance;
Type[] types = System.Reflection.Assembly.GetExecutingAssembly().GetTypes();
BaseObject baseObj = new BaseObject();
bool IsOk = false;
foreach (Type type in types)
{
if (type == obj.GetType())
{
baseObj = (BaseObject)obj;
IsOk = true;
}
}
if (!IsOk)
{
MessageBox.Show("Unable to locate the Type specified\n"
+ obj.GetType().Name);
return null;
}
MudDesigner.Editors.ScriptEditor frm = new MudDesigner.Editors.ScriptEditor(baseObj);
frm.Show();
string script = "";
while (frm.Created)
{
script = frm.Script;
System.Windows.Forms.Application.DoEvents();
}
return script;
}
public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
{
return System.Drawing.Design.UITypeEditorEditStyle.Modal;
}
}
}