MUD Engine:
* Added Attributes namespace to hold custom attributes. * UnusableAttribute.cs - Added to tag classes as unusable by the editors regardless if they inherit from BaseObject or not. * BaseObject.cs - Contains OnEnter and OnExit methods * InitialLocation.cs - UnusableAttribute tag applied. Room Designer: * frmMain.cs - Additional Script UI design. * frmMain.cs - Added plugin support. Plugin support is being tested. Room Designer is the testbed. It will ultimately end up inside MUDEngine.Engine. Curently (if ROOT/Plugins exists) loads all .dll files contained within the plugin directory. All classes inheriting from BaseObject and not tagged with the UnusableAttribute attribute automatically get added to the script editor.
This commit is contained in:
parent
0fc5a65f96
commit
6999457b19
7 changed files with 387 additions and 18 deletions
26
MUDEngine/Attributes/UnusableAttribute.cs
Normal file
26
MUDEngine/Attributes/UnusableAttribute.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MUDEngine.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
|
||||
public class UnusableAttribute : System.Attribute
|
||||
{
|
||||
private bool _IsUseable;
|
||||
public UnusableAttribute (bool useable)
|
||||
{
|
||||
_IsUseable = useable;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets if the class can be instanced or not. Regardless of what Type it inherits from
|
||||
/// </summary>
|
||||
public bool IsUseable
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -54,6 +54,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Engine.cs" />
|
||||
<Compile Include="Attributes\UnusableAttribute.cs" />
|
||||
<Compile Include="Objects\BaseObject.cs" />
|
||||
<Compile Include="FileSystem\FileSystem.cs" />
|
||||
<Compile Include="FileSystem\XmlSerialization.cs" />
|
||||
|
|
|
@ -24,10 +24,19 @@ namespace MUDEngine.Objects
|
|||
set;
|
||||
}
|
||||
|
||||
public ManagedScripting.ScriptObject Script
|
||||
[Browsable(false)]
|
||||
public ManagedScripting.CodeBuilding.ClassGenerator Script
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public void OnEnter()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnExit()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
namespace MUDEngine.Objects.Environment
|
||||
using MUDEngine.Attributes;
|
||||
|
||||
namespace MUDEngine.Objects.Environment
|
||||
{
|
||||
[Unusable(true)]
|
||||
public struct StartingLocation
|
||||
{
|
||||
public Room Room;
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ManagedScriptingWIN, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\ManagedScriptingWIN.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
|
|
227
RoomDesigner/frmMain.Designer.cs
generated
227
RoomDesigner/frmMain.Designer.cs
generated
|
@ -49,6 +49,20 @@
|
|||
this.propertyDoor = new System.Windows.Forms.PropertyGrid();
|
||||
this.groupBox6 = new System.Windows.Forms.GroupBox();
|
||||
this.lstDirections = new System.Windows.Forms.ListBox();
|
||||
this.tabScript = new System.Windows.Forms.TabPage();
|
||||
this.tabControl2 = new System.Windows.Forms.TabControl();
|
||||
this.tabFunctions = new System.Windows.Forms.TabPage();
|
||||
this.tabVariables = new System.Windows.Forms.TabPage();
|
||||
this.groupBox8 = new System.Windows.Forms.GroupBox();
|
||||
this.txtScript = new System.Windows.Forms.RichTextBox();
|
||||
this.groupBox11 = new System.Windows.Forms.GroupBox();
|
||||
this.comFunctions = new System.Windows.Forms.ComboBox();
|
||||
this.groupBox9 = new System.Windows.Forms.GroupBox();
|
||||
this.groupBox13 = new System.Windows.Forms.GroupBox();
|
||||
this.txtFunctionName = new System.Windows.Forms.TextBox();
|
||||
this.groupBox12 = new System.Windows.Forms.GroupBox();
|
||||
this.comReturnTypes = new System.Windows.Forms.ComboBox();
|
||||
this.groupBox14 = new System.Windows.Forms.GroupBox();
|
||||
this.containerMain.Panel1.SuspendLayout();
|
||||
this.containerMain.Panel2.SuspendLayout();
|
||||
this.containerMain.SuspendLayout();
|
||||
|
@ -66,6 +80,14 @@
|
|||
this.groupBox7.SuspendLayout();
|
||||
this.groupBox10.SuspendLayout();
|
||||
this.groupBox6.SuspendLayout();
|
||||
this.tabScript.SuspendLayout();
|
||||
this.tabControl2.SuspendLayout();
|
||||
this.tabFunctions.SuspendLayout();
|
||||
this.groupBox8.SuspendLayout();
|
||||
this.groupBox11.SuspendLayout();
|
||||
this.groupBox9.SuspendLayout();
|
||||
this.groupBox13.SuspendLayout();
|
||||
this.groupBox12.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// containerMain
|
||||
|
@ -82,8 +104,8 @@
|
|||
// containerMain.Panel2
|
||||
//
|
||||
this.containerMain.Panel2.Controls.Add(this.containerDesigner);
|
||||
this.containerMain.Size = new System.Drawing.Size(784, 564);
|
||||
this.containerMain.SplitterDistance = 236;
|
||||
this.containerMain.Size = new System.Drawing.Size(792, 564);
|
||||
this.containerMain.SplitterDistance = 238;
|
||||
this.containerMain.TabIndex = 0;
|
||||
//
|
||||
// containerSidebar
|
||||
|
@ -102,7 +124,7 @@
|
|||
// containerSidebar.Panel2
|
||||
//
|
||||
this.containerSidebar.Panel2.Controls.Add(this.groupBox2);
|
||||
this.containerSidebar.Size = new System.Drawing.Size(234, 562);
|
||||
this.containerSidebar.Size = new System.Drawing.Size(236, 562);
|
||||
this.containerSidebar.SplitterDistance = 109;
|
||||
this.containerSidebar.TabIndex = 0;
|
||||
//
|
||||
|
@ -142,13 +164,14 @@
|
|||
this.btnNewRoom.TabIndex = 0;
|
||||
this.btnNewRoom.Text = "New Room";
|
||||
this.btnNewRoom.UseVisualStyleBackColor = true;
|
||||
this.btnNewRoom.Click += new System.EventHandler(this.btnNewRoom_Click);
|
||||
//
|
||||
// btnCloseEditor
|
||||
//
|
||||
this.btnCloseEditor.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.btnCloseEditor.Location = new System.Drawing.Point(0, 86);
|
||||
this.btnCloseEditor.Name = "btnCloseEditor";
|
||||
this.btnCloseEditor.Size = new System.Drawing.Size(234, 23);
|
||||
this.btnCloseEditor.Size = new System.Drawing.Size(236, 23);
|
||||
this.btnCloseEditor.TabIndex = 3;
|
||||
this.btnCloseEditor.Text = "Close Editor";
|
||||
this.btnCloseEditor.UseVisualStyleBackColor = true;
|
||||
|
@ -160,7 +183,7 @@
|
|||
this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.groupBox2.Location = new System.Drawing.Point(0, 0);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(234, 449);
|
||||
this.groupBox2.Size = new System.Drawing.Size(236, 449);
|
||||
this.groupBox2.TabIndex = 0;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Room Setup";
|
||||
|
@ -170,7 +193,7 @@
|
|||
this.propertyRoom.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.propertyRoom.Location = new System.Drawing.Point(3, 16);
|
||||
this.propertyRoom.Name = "propertyRoom";
|
||||
this.propertyRoom.Size = new System.Drawing.Size(228, 430);
|
||||
this.propertyRoom.Size = new System.Drawing.Size(230, 430);
|
||||
this.propertyRoom.TabIndex = 3;
|
||||
//
|
||||
// containerDesigner
|
||||
|
@ -187,7 +210,7 @@
|
|||
// containerDesigner.Panel2
|
||||
//
|
||||
this.containerDesigner.Panel2.Controls.Add(this.groupBox5);
|
||||
this.containerDesigner.Size = new System.Drawing.Size(542, 562);
|
||||
this.containerDesigner.Size = new System.Drawing.Size(548, 562);
|
||||
this.containerDesigner.SplitterDistance = 318;
|
||||
this.containerDesigner.TabIndex = 0;
|
||||
//
|
||||
|
@ -197,7 +220,7 @@
|
|||
this.groupBox4.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.groupBox4.Location = new System.Drawing.Point(0, 0);
|
||||
this.groupBox4.Name = "groupBox4";
|
||||
this.groupBox4.Size = new System.Drawing.Size(542, 318);
|
||||
this.groupBox4.Size = new System.Drawing.Size(548, 318);
|
||||
this.groupBox4.TabIndex = 2;
|
||||
this.groupBox4.TabStop = false;
|
||||
this.groupBox4.Text = "Object Management";
|
||||
|
@ -207,11 +230,12 @@
|
|||
this.tabControl1.Controls.Add(this.tabBooks);
|
||||
this.tabControl1.Controls.Add(this.tabEquipment);
|
||||
this.tabControl1.Controls.Add(this.tabItems);
|
||||
this.tabControl1.Controls.Add(this.tabScript);
|
||||
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tabControl1.Location = new System.Drawing.Point(3, 16);
|
||||
this.tabControl1.Name = "tabControl1";
|
||||
this.tabControl1.SelectedIndex = 0;
|
||||
this.tabControl1.Size = new System.Drawing.Size(536, 299);
|
||||
this.tabControl1.Size = new System.Drawing.Size(542, 299);
|
||||
this.tabControl1.TabIndex = 0;
|
||||
//
|
||||
// tabBooks
|
||||
|
@ -250,7 +274,7 @@
|
|||
this.groupBox5.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.groupBox5.Location = new System.Drawing.Point(0, 0);
|
||||
this.groupBox5.Name = "groupBox5";
|
||||
this.groupBox5.Size = new System.Drawing.Size(542, 240);
|
||||
this.groupBox5.Size = new System.Drawing.Size(548, 240);
|
||||
this.groupBox5.TabIndex = 0;
|
||||
this.groupBox5.TabStop = false;
|
||||
this.groupBox5.Text = "Door Installation";
|
||||
|
@ -261,7 +285,7 @@
|
|||
this.groupBox7.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.groupBox7.Location = new System.Drawing.Point(174, 16);
|
||||
this.groupBox7.Name = "groupBox7";
|
||||
this.groupBox7.Size = new System.Drawing.Size(365, 221);
|
||||
this.groupBox7.Size = new System.Drawing.Size(371, 221);
|
||||
this.groupBox7.TabIndex = 1;
|
||||
this.groupBox7.TabStop = false;
|
||||
this.groupBox7.Text = "Install Options";
|
||||
|
@ -270,7 +294,7 @@
|
|||
//
|
||||
this.groupBox10.Controls.Add(this.propertyDoor);
|
||||
this.groupBox10.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.groupBox10.Location = new System.Drawing.Point(6, 16);
|
||||
this.groupBox10.Location = new System.Drawing.Point(12, 16);
|
||||
this.groupBox10.Name = "groupBox10";
|
||||
this.groupBox10.Size = new System.Drawing.Size(356, 202);
|
||||
this.groupBox10.TabIndex = 7;
|
||||
|
@ -307,11 +331,165 @@
|
|||
this.lstDirections.TabIndex = 0;
|
||||
this.lstDirections.SelectedIndexChanged += new System.EventHandler(this.lstDirections_SelectedIndexChanged);
|
||||
//
|
||||
// tabScript
|
||||
//
|
||||
this.tabScript.Controls.Add(this.tabControl2);
|
||||
this.tabScript.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabScript.Name = "tabScript";
|
||||
this.tabScript.Size = new System.Drawing.Size(534, 273);
|
||||
this.tabScript.TabIndex = 3;
|
||||
this.tabScript.Text = "Script";
|
||||
this.tabScript.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tabControl2
|
||||
//
|
||||
this.tabControl2.Controls.Add(this.tabFunctions);
|
||||
this.tabControl2.Controls.Add(this.tabVariables);
|
||||
this.tabControl2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tabControl2.Location = new System.Drawing.Point(0, 0);
|
||||
this.tabControl2.Name = "tabControl2";
|
||||
this.tabControl2.SelectedIndex = 0;
|
||||
this.tabControl2.Size = new System.Drawing.Size(534, 273);
|
||||
this.tabControl2.TabIndex = 0;
|
||||
//
|
||||
// tabFunctions
|
||||
//
|
||||
this.tabFunctions.Controls.Add(this.groupBox9);
|
||||
this.tabFunctions.Controls.Add(this.groupBox8);
|
||||
this.tabFunctions.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabFunctions.Name = "tabFunctions";
|
||||
this.tabFunctions.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabFunctions.Size = new System.Drawing.Size(526, 247);
|
||||
this.tabFunctions.TabIndex = 0;
|
||||
this.tabFunctions.Text = "Functions";
|
||||
this.tabFunctions.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tabVariables
|
||||
//
|
||||
this.tabVariables.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabVariables.Name = "tabVariables";
|
||||
this.tabVariables.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabVariables.Size = new System.Drawing.Size(526, 247);
|
||||
this.tabVariables.TabIndex = 1;
|
||||
this.tabVariables.Text = "Variables";
|
||||
this.tabVariables.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBox8
|
||||
//
|
||||
this.groupBox8.Controls.Add(this.txtScript);
|
||||
this.groupBox8.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.groupBox8.Location = new System.Drawing.Point(3, 3);
|
||||
this.groupBox8.Name = "groupBox8";
|
||||
this.groupBox8.Size = new System.Drawing.Size(359, 241);
|
||||
this.groupBox8.TabIndex = 2;
|
||||
this.groupBox8.TabStop = false;
|
||||
this.groupBox8.Text = "Room Script";
|
||||
//
|
||||
// txtScript
|
||||
//
|
||||
this.txtScript.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.txtScript.Location = new System.Drawing.Point(3, 16);
|
||||
this.txtScript.Name = "txtScript";
|
||||
this.txtScript.Size = new System.Drawing.Size(353, 222);
|
||||
this.txtScript.TabIndex = 0;
|
||||
this.txtScript.Text = "";
|
||||
//
|
||||
// groupBox11
|
||||
//
|
||||
this.groupBox11.Controls.Add(this.comFunctions);
|
||||
this.groupBox11.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.groupBox11.Location = new System.Drawing.Point(3, 16);
|
||||
this.groupBox11.Name = "groupBox11";
|
||||
this.groupBox11.Size = new System.Drawing.Size(152, 41);
|
||||
this.groupBox11.TabIndex = 0;
|
||||
this.groupBox11.TabStop = false;
|
||||
this.groupBox11.Text = "Existing Functions";
|
||||
//
|
||||
// comFunctions
|
||||
//
|
||||
this.comFunctions.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.comFunctions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comFunctions.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.comFunctions.FormattingEnabled = true;
|
||||
this.comFunctions.Location = new System.Drawing.Point(3, 16);
|
||||
this.comFunctions.Name = "comFunctions";
|
||||
this.comFunctions.Size = new System.Drawing.Size(146, 21);
|
||||
this.comFunctions.Sorted = true;
|
||||
this.comFunctions.TabIndex = 0;
|
||||
//
|
||||
// groupBox9
|
||||
//
|
||||
this.groupBox9.Controls.Add(this.groupBox14);
|
||||
this.groupBox9.Controls.Add(this.groupBox12);
|
||||
this.groupBox9.Controls.Add(this.groupBox13);
|
||||
this.groupBox9.Controls.Add(this.groupBox11);
|
||||
this.groupBox9.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.groupBox9.Location = new System.Drawing.Point(365, 3);
|
||||
this.groupBox9.Name = "groupBox9";
|
||||
this.groupBox9.Size = new System.Drawing.Size(158, 241);
|
||||
this.groupBox9.TabIndex = 3;
|
||||
this.groupBox9.TabStop = false;
|
||||
this.groupBox9.Text = "Script Setup";
|
||||
//
|
||||
// groupBox13
|
||||
//
|
||||
this.groupBox13.Controls.Add(this.txtFunctionName);
|
||||
this.groupBox13.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.groupBox13.Location = new System.Drawing.Point(3, 57);
|
||||
this.groupBox13.Name = "groupBox13";
|
||||
this.groupBox13.Size = new System.Drawing.Size(152, 41);
|
||||
this.groupBox13.TabIndex = 6;
|
||||
this.groupBox13.TabStop = false;
|
||||
this.groupBox13.Text = "Function Name";
|
||||
//
|
||||
// txtFunctionName
|
||||
//
|
||||
this.txtFunctionName.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.txtFunctionName.Location = new System.Drawing.Point(3, 16);
|
||||
this.txtFunctionName.Name = "txtFunctionName";
|
||||
this.txtFunctionName.Size = new System.Drawing.Size(146, 20);
|
||||
this.txtFunctionName.TabIndex = 0;
|
||||
//
|
||||
// groupBox12
|
||||
//
|
||||
this.groupBox12.Controls.Add(this.comReturnTypes);
|
||||
this.groupBox12.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.groupBox12.Location = new System.Drawing.Point(3, 98);
|
||||
this.groupBox12.Name = "groupBox12";
|
||||
this.groupBox12.Size = new System.Drawing.Size(152, 41);
|
||||
this.groupBox12.TabIndex = 7;
|
||||
this.groupBox12.TabStop = false;
|
||||
this.groupBox12.Text = "Returnable Types";
|
||||
//
|
||||
// comReturnTypes
|
||||
//
|
||||
this.comReturnTypes.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.comReturnTypes.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.comReturnTypes.FormattingEnabled = true;
|
||||
this.comReturnTypes.Items.AddRange(new object[] {
|
||||
"bool",
|
||||
"int",
|
||||
"string"});
|
||||
this.comReturnTypes.Location = new System.Drawing.Point(3, 16);
|
||||
this.comReturnTypes.Name = "comReturnTypes";
|
||||
this.comReturnTypes.Size = new System.Drawing.Size(146, 21);
|
||||
this.comReturnTypes.Sorted = true;
|
||||
this.comReturnTypes.TabIndex = 0;
|
||||
//
|
||||
// groupBox14
|
||||
//
|
||||
this.groupBox14.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.groupBox14.Location = new System.Drawing.Point(3, 139);
|
||||
this.groupBox14.Name = "groupBox14";
|
||||
this.groupBox14.Size = new System.Drawing.Size(152, 96);
|
||||
this.groupBox14.TabIndex = 8;
|
||||
this.groupBox14.TabStop = false;
|
||||
//
|
||||
// frmMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(784, 564);
|
||||
this.ClientSize = new System.Drawing.Size(792, 564);
|
||||
this.Controls.Add(this.containerMain);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
|
@ -336,6 +514,15 @@
|
|||
this.groupBox7.ResumeLayout(false);
|
||||
this.groupBox10.ResumeLayout(false);
|
||||
this.groupBox6.ResumeLayout(false);
|
||||
this.tabScript.ResumeLayout(false);
|
||||
this.tabControl2.ResumeLayout(false);
|
||||
this.tabFunctions.ResumeLayout(false);
|
||||
this.groupBox8.ResumeLayout(false);
|
||||
this.groupBox11.ResumeLayout(false);
|
||||
this.groupBox9.ResumeLayout(false);
|
||||
this.groupBox13.ResumeLayout(false);
|
||||
this.groupBox13.PerformLayout();
|
||||
this.groupBox12.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
@ -363,6 +550,20 @@
|
|||
private System.Windows.Forms.GroupBox groupBox7;
|
||||
private System.Windows.Forms.GroupBox groupBox10;
|
||||
private System.Windows.Forms.PropertyGrid propertyDoor;
|
||||
private System.Windows.Forms.TabPage tabScript;
|
||||
private System.Windows.Forms.TabControl tabControl2;
|
||||
private System.Windows.Forms.TabPage tabFunctions;
|
||||
private System.Windows.Forms.GroupBox groupBox8;
|
||||
private System.Windows.Forms.RichTextBox txtScript;
|
||||
private System.Windows.Forms.TabPage tabVariables;
|
||||
private System.Windows.Forms.GroupBox groupBox9;
|
||||
private System.Windows.Forms.GroupBox groupBox14;
|
||||
private System.Windows.Forms.GroupBox groupBox12;
|
||||
private System.Windows.Forms.ComboBox comReturnTypes;
|
||||
private System.Windows.Forms.GroupBox groupBox13;
|
||||
private System.Windows.Forms.TextBox txtFunctionName;
|
||||
private System.Windows.Forms.GroupBox groupBox11;
|
||||
private System.Windows.Forms.ComboBox comFunctions;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ using MUDEngine.Objects.Environment;
|
|||
using MUDEngine.Objects;
|
||||
using MUDEngine;
|
||||
using MUDEngine.FileSystem;
|
||||
using MUDEngine.Attributes;
|
||||
|
||||
namespace RoomDesigner
|
||||
{
|
||||
|
@ -22,6 +23,9 @@ namespace RoomDesigner
|
|||
//Doorway currently loaded.
|
||||
Door _CurrentDoor;
|
||||
|
||||
ManagedScripting.ScriptingEngine _ScriptEngine;
|
||||
List<System.Reflection.Assembly> _Plugins;
|
||||
|
||||
public frmMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -38,22 +42,117 @@ namespace RoomDesigner
|
|||
//Instead of updating the editor each time a new travel direction is implemented,
|
||||
//we simply build an array that contains each travel direction currently available
|
||||
//within the engine by getting each element from the AvailableTravelDirections enum
|
||||
AvailableTravelDirections type = new AvailableTravelDirections();
|
||||
AvailableTravelDirections direction = new AvailableTravelDirections();
|
||||
|
||||
//Build an array of travel directions currently implemented
|
||||
Array Values = System.Enum.GetValues(type.GetType());
|
||||
Array Values = System.Enum.GetValues(direction.GetType());
|
||||
|
||||
//Loop through each travel direction within the array and add it
|
||||
//to the lstDirections listbox.
|
||||
foreach (int Value in Values)
|
||||
{
|
||||
string Display = Enum.GetName(type.GetType(), Value);
|
||||
string Display = Enum.GetName(direction.GetType(), Value);
|
||||
//The array contains a 'None' direction. As the editor will allow for
|
||||
//installing and uninstalling doorways, we don't need to show a 'None' direction
|
||||
//in the listbox.
|
||||
if (!Display.Equals("None"))
|
||||
this.lstDirections.Items.Add(Display);
|
||||
}
|
||||
|
||||
//Load all of our plugin .dll files. This is the only directory not generated by
|
||||
//the engine, developers will need to manually create the folder if they want to
|
||||
//create plugins
|
||||
LoadPlugins();
|
||||
|
||||
//Before we loop through the plugins list to build our combo box return values
|
||||
//we need to add the MUDEngine.dll to the list, so that it's objects can be
|
||||
//used as return values with the engines scripts.
|
||||
//We can use Assembly.Load("MUDEngine.dll") but that would load a 2nd copy
|
||||
//of the engine in memory, as RoomDesigner.exe already has it loaded in memory.
|
||||
//To prevent duplicate copies in memory, we will search every assembly currently
|
||||
//loaded by the application instead until we find our engine.
|
||||
|
||||
//Build an array of assemblies currently loaded in memory by RoomDesigner.exe
|
||||
System.Reflection.Assembly[] tempList = System.AppDomain.CurrentDomain.GetAssemblies();
|
||||
|
||||
//Loop through each assembly in the array and find the mud engine
|
||||
foreach (System.Reflection.Assembly a in tempList)
|
||||
{
|
||||
//Check the assemblies manifest name to see if it matches our mud engine name
|
||||
if (a.ManifestModule.Name.ToLower() == "mudengine.dll")
|
||||
{
|
||||
//Found the engine, add it to the plugins list so that we can
|
||||
//add it's BaseObject inherited classes to the Script tab's
|
||||
//Return Type combo box.
|
||||
_Plugins.Add(a);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Loop through each plugin, and add it's objects to the return type
|
||||
//combo box, so scripts can inherit from them.
|
||||
foreach (System.Reflection.Assembly assembly in _Plugins)
|
||||
{
|
||||
//Loop through each time within this specific plugin assembly
|
||||
foreach (Type type in assembly.GetTypes())
|
||||
{
|
||||
//Check if the current Type inherits from BaseObject
|
||||
if (type.BaseType.Name == "BaseObject")
|
||||
{
|
||||
//Now that we know it inherits from BaseObject
|
||||
//we need to make sure that it is a useable class
|
||||
//or it's for internal use only. This can be set by
|
||||
//the developer using the UnusableAttribute attribute
|
||||
//on the class
|
||||
bool isUseable = true;
|
||||
foreach (object attribute in type.GetCustomAttributes(false))
|
||||
{
|
||||
//Check if the Type contains the UnsableAttribute attribute
|
||||
if (attribute is UnusableAttribute)
|
||||
{
|
||||
//It does, exit the loop and declare it unuseable
|
||||
isUseable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//If the class does not contain the UnusableAttribute attribute
|
||||
//we can use it as a return value for our scripts.
|
||||
if (isUseable)
|
||||
{
|
||||
comReturnTypes.Items.Add(type.Name);
|
||||
}
|
||||
}
|
||||
}//foreach Type loop
|
||||
}//foreach Assembly loop
|
||||
|
||||
//Instance the scripting engine and set it up.
|
||||
_ScriptEngine = new ManagedScripting.ScriptingEngine();
|
||||
_ScriptEngine.Compiler = ManagedScripting.ScriptingEngine.CompilerSelections.SourceCompiler;
|
||||
_ScriptEngine.CompileStyle = ManagedScripting.Compilers.BaseCompiler.ScriptCompileStyle.CompileToMemory;
|
||||
_ScriptEngine.KeepTempFiles = false;
|
||||
}
|
||||
|
||||
private void LoadPlugins()
|
||||
{
|
||||
//Check if the plugin path exists.
|
||||
string pluginPath = System.IO.Path.Combine(Application.StartupPath, "Plugins");
|
||||
if (!System.IO.Directory.Exists(pluginPath))
|
||||
return;
|
||||
|
||||
|
||||
_Plugins = new List<System.Reflection.Assembly>();
|
||||
|
||||
//Now loop through every .dll file in the plugins directory and load it into memory
|
||||
//A copy is stored within a collection for use later if needed.
|
||||
foreach (string assembly in System.IO.Directory.GetFiles(pluginPath, "*.dll"))
|
||||
{
|
||||
_Plugins.Add(System.Reflection.Assembly.LoadFile(assembly));
|
||||
|
||||
}
|
||||
|
||||
//TODO: Look for ways to allow Types to inherit from a Windows Control, and add each
|
||||
//control to a new tab or menu item, allowing for editor plugins as well.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -135,6 +234,12 @@ namespace RoomDesigner
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a string into an AvailableTravelDirections enum equivilant if it
|
||||
/// exists within the enum list.
|
||||
/// </summary>
|
||||
/// <param name="Direction"></param>
|
||||
/// <returns></returns>
|
||||
private AvailableTravelDirections GetDirection(string Direction)
|
||||
{
|
||||
foreach (AvailableTravelDirections value in Enum.GetValues(typeof(AvailableTravelDirections)))
|
||||
|
@ -190,6 +295,9 @@ namespace RoomDesigner
|
|||
_CurrentRoom.InstalledDoors.Add(_CurrentDoor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uninstalls the doorway from the room.
|
||||
/// </summary>
|
||||
private void UninstallDoor()
|
||||
{
|
||||
foreach (Door door in _CurrentRoom.InstalledDoors)
|
||||
|
@ -201,5 +309,22 @@ namespace RoomDesigner
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the room.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btnNewRoom_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult result = MessageBox.Show("Are you sure you want to create a new room?", "Room Designer", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
if (result == DialogResult.No)
|
||||
return;
|
||||
|
||||
_CurrentRoom = new Room();
|
||||
_CurrentDoor = new Door(AvailableTravelDirections.None);
|
||||
propertyDoor.SelectedObject = null;
|
||||
propertyRoom.SelectedObject = _CurrentRoom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue