MUD Engine:

- Changed ValidateProjectPath to ValidateDataPaths. Now can use the engines current install location if a path is not supplied
 - ValidateDataPaths iterates through a new enumerator containing all of the data paths, and creates the directories if they dont exist.
 - GetDataPath method added for returning the absolute path to any of the save directories specified in the argument.
 - BaseObject now contains a readonly Filename property that returns the objects Name with it's Type assigned as the files extension.
 - BaseObject's Script property was added.
 - Room.StatDrain re-added. Changed property Type to boolean instead of custom struct.
 - Room Designer's constructor code was refracted to help clean it up. Plugin loading, doorway list compiling and room setup is now contained in three different methods.
 - Room Designer can now Save scripts.
 - Room Designer now has default scripts generated.
 - Changing the Object Management tabs to 'Script' now refreshes the script to display correctly.
 - Room Designer now accepts a single argument for specifying the name of a room to Load. Use "room=Room Name.room" as the syntax.
 - Room loading is implemented, but only via a supplied argument during application launch.
This commit is contained in:
Scionwest_cp 2009-11-25 21:21:50 -08:00
parent d7d92e49af
commit 1cc477f23c
13 changed files with 489 additions and 317 deletions

View file

@ -13,7 +13,7 @@ namespace CurrencyEditor
[STAThread] [STAThread]
static void Main() static void Main()
{ {
MUDEngine.Engine.ValidateProjectPath(Application.StartupPath); MUDEngine.Engine.ValidateDataPaths();
MUDEngine.FileSystem.FileSystem.FileType = MUDEngine.FileSystem.FileSystem.OutputFormats.XML; MUDEngine.FileSystem.FileSystem.FileType = MUDEngine.FileSystem.FileSystem.OutputFormats.XML;
Application.EnableVisualStyles(); Application.EnableVisualStyles();

View file

@ -7,26 +7,61 @@ namespace MUDEngine
{ {
public class Engine public class Engine
{ {
public enum SaveDataTypes
{
Root,
Currency,
Rooms,
Zones,
Realms,
}
/// <summary> /// <summary>
/// Used to ensure that the paths needed to run the game exists. /// Used to ensure that the paths needed to run the game exists.
/// If no path is supplied, the engine uses it's current install path.
/// </summary> /// </summary>
/// <param name="validatedPath"></param> /// <param name="validatedPath"></param>
public static void ValidateProjectPath(string validatedPath) public static void ValidateDataPaths()
{ {
string dataPath = System.IO.Path.Combine(validatedPath, "Data"); string assemblyPath = System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName;
string assemblyName = System.IO.Path.GetFileName(assemblyPath);
string installBase = assemblyPath.Substring(0, assemblyPath.Length - assemblyName.Length);
string rootPath = System.IO.Path.Combine(installBase, "Data");
ValidateDataPaths(rootPath);
}
if (!System.IO.Directory.Exists(dataPath)) /// <summary>
System.IO.Directory.CreateDirectory(dataPath); /// Checks the supplied directory to ensure that all of the engines needed
/// data folders are created
//begin checking directories /// </summary>
string[] paths = { "Rooms", "Zones", "Realms", "Currency" }; /// <param name="InstallPath"></param>
public static void ValidateDataPaths(string InstallPath)
foreach (var path in paths)
{ {
string createPath = System.IO.Path.Combine(dataPath, path); if (!System.IO.Directory.Exists(InstallPath))
if (!System.IO.Directory.Exists(createPath)) System.IO.Directory.CreateDirectory(InstallPath);
System.IO.Directory.CreateDirectory(createPath);
} foreach (SaveDataTypes value in Enum.GetValues(typeof(SaveDataTypes)))
{
string dataType = value.ToString();
if (!System.IO.Directory.Exists(System.IO.Path.Combine(InstallPath, dataType)))
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(InstallPath, dataType));
}
}
/// <summary>
/// Returns the complete path to the specified data's save folder.
/// </summary>
/// <param name="DataType"></param>
/// <returns></returns>
public static string GetDataPath(SaveDataTypes DataType)
{
string assemblyPath = System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName;
string assemblyName = System.IO.Path.GetFileName(assemblyPath);
string installBase = assemblyPath.Substring(0, assemblyPath.Length - assemblyName.Length);
string rootPath = System.IO.Path.Combine(installBase, "Data");
return System.IO.Path.Combine(rootPath, DataType.ToString());
} }
} }
} }

View file

@ -39,6 +39,7 @@
<Reference Include="System.Core"> <Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq"> <Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>

View file

@ -2,15 +2,19 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.ComponentModel; using System.ComponentModel;
using System.Collections.Generic; using System.Windows.Forms;
namespace MUDEngine.Objects namespace MUDEngine.Objects
{ {
public class BaseObject public class BaseObject
{ {
public virtual void OnEnter(object sender, EventArgs e)
{
}
[Category("Object Setup")] [Category("Object Setup")]
[RefreshProperties(RefreshProperties.All)] //Required to refresh Filename property in the editors propertygrid
public string Name public string Name
{ {
get; get;
@ -25,17 +29,26 @@ namespace MUDEngine.Objects
} }
[Browsable(false)] [Browsable(false)]
public ManagedScripting.CodeBuilding.ClassGenerator Script public string Script { get; set; }
[ReadOnly(true)]
[Category("Object Setup")]
public string Filename
{ {
get; //Returns the name of the object + the objects Type as it's extension.
set; //Filenames are generated by the class itself, users can not assign it.
get
{
string fileExtension = this.GetType().Name.ToLower();
return this.Name + "." + fileExtension;
}
} }
public void OnEnter() /// <summary>
{ /// Initializes the base object
} /// </summary>
public BaseObject()
public void OnExit()
{ {
} }
} }

View file

@ -32,11 +32,13 @@ namespace MUDEngine.Objects.Environment
set; set;
} }
/*public Stats StatDrain [Category("Room Information")]
[DefaultValue(false)]
public bool StatDrain
{ {
get; get;
set; set;
}*/ }
[Category("Room Information")] [Category("Room Information")]
[DefaultValue(0)] [DefaultValue(0)]
@ -54,17 +56,18 @@ namespace MUDEngine.Objects.Environment
set; set;
} }
[Browsable(false)]
public List<Door> InstalledDoors;
public Room() public Room()
{ {
InstalledDoors = new List<Door>(); InstalledDoors = new List<Door>();
Script = "";
this.Feel = "You feel nothing."; this.Feel = "You feel nothing.";
this.Listen = "You hear nothing of interest."; this.Listen = "You hear nothing of interest.";
this.Smell = "You don't smell anything unsual."; this.Smell = "You don't smell anything unsual.";
this.StatDrainAmount = 0; this.StatDrainAmount = 0;
} Name = "New Room";
}
[Browsable(false)]
public List<Door> InstalledDoors;
} }
} }

View file

@ -121,6 +121,12 @@
<ItemGroup> <ItemGroup>
<Content Include="EditorList.txt" /> <Content Include="EditorList.txt" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MUDEngine\MUDEngine.csproj">
<Project>{33828B3B-F227-4726-8FCD-3D9D780E643D}</Project>
<Name>MUDEngine</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View file

@ -36,12 +36,30 @@
this.btnProjectManager = new System.Windows.Forms.Button(); this.btnProjectManager = new System.Windows.Forms.Button();
this.btnCurrencyEditor = new System.Windows.Forms.Button(); this.btnCurrencyEditor = new System.Windows.Forms.Button();
this.btnRoomDesigner = new System.Windows.Forms.Button(); this.btnRoomDesigner = new System.Windows.Forms.Button();
this.tabFunctions = new System.Windows.Forms.TabPage();
this.groupBox9 = new System.Windows.Forms.GroupBox();
this.groupBox14 = new System.Windows.Forms.GroupBox();
this.groupBox12 = new System.Windows.Forms.GroupBox();
this.comReturnTypes = new System.Windows.Forms.ComboBox();
this.groupBox13 = new System.Windows.Forms.GroupBox();
this.txtFunctionName = new System.Windows.Forms.TextBox();
this.groupBox11 = new System.Windows.Forms.GroupBox();
this.comFunctions = new System.Windows.Forms.ComboBox();
this.groupBox8 = new System.Windows.Forms.GroupBox();
this.txtScript = new System.Windows.Forms.RichTextBox();
this.tabVariables = new System.Windows.Forms.TabPage();
this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout(); this.splitContainer1.SuspendLayout();
this.tabEditors.SuspendLayout(); this.tabEditors.SuspendLayout();
this.tabPage1.SuspendLayout(); this.tabPage1.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout(); this.flowLayoutPanel1.SuspendLayout();
this.tabFunctions.SuspendLayout();
this.groupBox9.SuspendLayout();
this.groupBox12.SuspendLayout();
this.groupBox13.SuspendLayout();
this.groupBox11.SuspendLayout();
this.groupBox8.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// splitContainer1 // splitContainer1
@ -135,7 +153,7 @@
this.btnCurrencyEditor.TabIndex = 1; this.btnCurrencyEditor.TabIndex = 1;
this.btnCurrencyEditor.Text = "Currency Editor"; this.btnCurrencyEditor.Text = "Currency Editor";
this.btnCurrencyEditor.UseVisualStyleBackColor = true; this.btnCurrencyEditor.UseVisualStyleBackColor = true;
this.btnCurrencyEditor.Click +=new System.EventHandler(btnCurrencyEditor_Click); this.btnCurrencyEditor.Click += new System.EventHandler(this.btnCurrencyEditor_Click);
// //
// btnRoomDesigner // btnRoomDesigner
// //
@ -147,7 +165,140 @@
this.btnRoomDesigner.TabIndex = 2; this.btnRoomDesigner.TabIndex = 2;
this.btnRoomDesigner.Text = "Room Designer"; this.btnRoomDesigner.Text = "Room Designer";
this.btnRoomDesigner.UseVisualStyleBackColor = true; this.btnRoomDesigner.UseVisualStyleBackColor = true;
this.btnRoomDesigner.Click += new System.EventHandler(btnRoomDesigner_Click); this.btnRoomDesigner.Click += new System.EventHandler(this.btnRoomDesigner_Click);
//
// 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;
//
// 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";
//
// 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;
//
// 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;
//
// 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;
//
// 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;
//
// 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 = "";
//
// 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;
// //
// frmMain // frmMain
// //
@ -167,6 +318,13 @@
this.tabEditors.ResumeLayout(false); this.tabEditors.ResumeLayout(false);
this.tabPage1.ResumeLayout(false); this.tabPage1.ResumeLayout(false);
this.flowLayoutPanel1.ResumeLayout(false); this.flowLayoutPanel1.ResumeLayout(false);
this.tabFunctions.ResumeLayout(false);
this.groupBox9.ResumeLayout(false);
this.groupBox12.ResumeLayout(false);
this.groupBox13.ResumeLayout(false);
this.groupBox13.PerformLayout();
this.groupBox11.ResumeLayout(false);
this.groupBox8.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -181,6 +339,18 @@
private System.Windows.Forms.Button btnProjectManager; private System.Windows.Forms.Button btnProjectManager;
private System.Windows.Forms.Button btnCurrencyEditor; private System.Windows.Forms.Button btnCurrencyEditor;
private System.Windows.Forms.Button btnRoomDesigner; private System.Windows.Forms.Button btnRoomDesigner;
private System.Windows.Forms.TabPage tabFunctions;
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;
private System.Windows.Forms.GroupBox groupBox8;
private System.Windows.Forms.RichTextBox txtScript;
private System.Windows.Forms.TabPage tabVariables;
} }
} }

View file

@ -21,7 +21,7 @@ namespace Project_Manager
static void Main() static void Main()
{ {
//Make sure all our paths are created before we start working with the editor. //Make sure all our paths are created before we start working with the editor.
Engine.ValidateProjectPath(Application.StartupPath); MUDEngine.Engine.ValidateDataPaths();
FileSystem.FileType = FileSystem.OutputFormats.XML; FileSystem.FileType = FileSystem.OutputFormats.XML;
project = new ProjectInformation(); project = new ProjectInformation();

View file

@ -1,4 +1,5 @@
using System; using System;
using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
@ -11,14 +12,50 @@ namespace RoomDesigner
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
[STAThread] [STAThread]
static void Main() static void Main(string[] arguments)
{ {
MUDEngine.Engine.ValidateProjectPath(Application.StartupPath); MUDEngine.Engine.ValidateDataPaths();
MUDEngine.FileSystem.FileSystem.FileType = MUDEngine.FileSystem.FileSystem.OutputFormats.XML; MUDEngine.FileSystem.FileSystem.FileType = MUDEngine.FileSystem.FileSystem.OutputFormats.XML;
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
//Check if we have a valid room supplied in the arguments.
//The Zone editor can launch the Room Designer, if the user
//chooses to edit a room from within the Zone Editor. Currently
//Zone editor is the only planned editor that can allow users to
//edit existing rooms. Simplifies it, as I don't need to design
//a Realm/Zone/Room explorer in the Room or Realm editors.
if (arguments.Length == 0)
{
Application.Run(new frmMain());
}
else
{
foreach (string argument in arguments)
{
//check if it's a room specified.
if (argument.ToLower().StartsWith("room="))
{
int startIndex = "room=".Length;
string room = argument.Substring(startIndex);
string file = Path.Combine(Application.StartupPath, "Data\\Rooms\\") + room;
if (File.Exists(file))
{
Application.Run(new frmMain(room));
}
else
{
MessageBox.Show("Unable to locate the specified file."
+ "Please ensure that it exists or the correct argument format was used.\n"
+ "Room: " + file,
"Room Designer", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
Application.Run(new frmMain()); Application.Run(new frmMain());
} }
} }
} }
}
}
}
}

View file

@ -43,26 +43,18 @@
this.tabBooks = new System.Windows.Forms.TabPage(); this.tabBooks = new System.Windows.Forms.TabPage();
this.tabEquipment = new System.Windows.Forms.TabPage(); this.tabEquipment = new System.Windows.Forms.TabPage();
this.tabItems = new System.Windows.Forms.TabPage(); this.tabItems = new System.Windows.Forms.TabPage();
this.tabScript = new System.Windows.Forms.TabPage();
this.tabControl2 = new System.Windows.Forms.TabControl();
this.tabFunctions = new System.Windows.Forms.TabPage();
this.groupBox8 = new System.Windows.Forms.GroupBox();
this.txtScript = new System.Windows.Forms.RichTextBox();
this.tabVariables = new System.Windows.Forms.TabPage();
this.groupBox5 = new System.Windows.Forms.GroupBox(); this.groupBox5 = new System.Windows.Forms.GroupBox();
this.groupBox7 = new System.Windows.Forms.GroupBox(); this.groupBox7 = new System.Windows.Forms.GroupBox();
this.groupBox10 = new System.Windows.Forms.GroupBox(); this.groupBox10 = new System.Windows.Forms.GroupBox();
this.propertyDoor = new System.Windows.Forms.PropertyGrid(); this.propertyDoor = new System.Windows.Forms.PropertyGrid();
this.groupBox6 = new System.Windows.Forms.GroupBox(); this.groupBox6 = new System.Windows.Forms.GroupBox();
this.lstDirections = new System.Windows.Forms.ListBox(); 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.Panel1.SuspendLayout();
this.containerMain.Panel2.SuspendLayout(); this.containerMain.Panel2.SuspendLayout();
this.containerMain.SuspendLayout(); this.containerMain.SuspendLayout();
@ -76,18 +68,14 @@
this.containerDesigner.SuspendLayout(); this.containerDesigner.SuspendLayout();
this.groupBox4.SuspendLayout(); this.groupBox4.SuspendLayout();
this.tabControl1.SuspendLayout(); this.tabControl1.SuspendLayout();
this.groupBox5.SuspendLayout();
this.groupBox7.SuspendLayout();
this.groupBox10.SuspendLayout();
this.groupBox6.SuspendLayout();
this.tabScript.SuspendLayout(); this.tabScript.SuspendLayout();
this.tabControl2.SuspendLayout(); this.tabControl2.SuspendLayout();
this.tabFunctions.SuspendLayout(); this.tabFunctions.SuspendLayout();
this.groupBox8.SuspendLayout(); this.groupBox8.SuspendLayout();
this.groupBox11.SuspendLayout(); this.groupBox5.SuspendLayout();
this.groupBox9.SuspendLayout(); this.groupBox7.SuspendLayout();
this.groupBox13.SuspendLayout(); this.groupBox10.SuspendLayout();
this.groupBox12.SuspendLayout(); this.groupBox6.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// containerMain // containerMain
@ -155,6 +143,7 @@
this.btnSaveRoom.TabIndex = 1; this.btnSaveRoom.TabIndex = 1;
this.btnSaveRoom.Text = "Save Room"; this.btnSaveRoom.Text = "Save Room";
this.btnSaveRoom.UseVisualStyleBackColor = true; this.btnSaveRoom.UseVisualStyleBackColor = true;
this.btnSaveRoom.Click += new System.EventHandler(this.btnSaveRoom_Click);
// //
// btnNewRoom // btnNewRoom
// //
@ -195,6 +184,7 @@
this.propertyRoom.Name = "propertyRoom"; this.propertyRoom.Name = "propertyRoom";
this.propertyRoom.Size = new System.Drawing.Size(230, 430); this.propertyRoom.Size = new System.Drawing.Size(230, 430);
this.propertyRoom.TabIndex = 3; this.propertyRoom.TabIndex = 3;
this.propertyRoom.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyRoom_PropertyValueChanged);
// //
// containerDesigner // containerDesigner
// //
@ -237,13 +227,14 @@
this.tabControl1.SelectedIndex = 0; this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(542, 299); this.tabControl1.Size = new System.Drawing.Size(542, 299);
this.tabControl1.TabIndex = 0; this.tabControl1.TabIndex = 0;
this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged);
// //
// tabBooks // tabBooks
// //
this.tabBooks.Location = new System.Drawing.Point(4, 22); this.tabBooks.Location = new System.Drawing.Point(4, 22);
this.tabBooks.Name = "tabBooks"; this.tabBooks.Name = "tabBooks";
this.tabBooks.Padding = new System.Windows.Forms.Padding(3); this.tabBooks.Padding = new System.Windows.Forms.Padding(3);
this.tabBooks.Size = new System.Drawing.Size(528, 273); this.tabBooks.Size = new System.Drawing.Size(534, 273);
this.tabBooks.TabIndex = 0; this.tabBooks.TabIndex = 0;
this.tabBooks.Text = "Books"; this.tabBooks.Text = "Books";
this.tabBooks.UseVisualStyleBackColor = true; this.tabBooks.UseVisualStyleBackColor = true;
@ -253,7 +244,7 @@
this.tabEquipment.Location = new System.Drawing.Point(4, 22); this.tabEquipment.Location = new System.Drawing.Point(4, 22);
this.tabEquipment.Name = "tabEquipment"; this.tabEquipment.Name = "tabEquipment";
this.tabEquipment.Padding = new System.Windows.Forms.Padding(3); this.tabEquipment.Padding = new System.Windows.Forms.Padding(3);
this.tabEquipment.Size = new System.Drawing.Size(528, 273); this.tabEquipment.Size = new System.Drawing.Size(534, 273);
this.tabEquipment.TabIndex = 1; this.tabEquipment.TabIndex = 1;
this.tabEquipment.Text = "Equipment"; this.tabEquipment.Text = "Equipment";
this.tabEquipment.UseVisualStyleBackColor = true; this.tabEquipment.UseVisualStyleBackColor = true;
@ -262,11 +253,73 @@
// //
this.tabItems.Location = new System.Drawing.Point(4, 22); this.tabItems.Location = new System.Drawing.Point(4, 22);
this.tabItems.Name = "tabItems"; this.tabItems.Name = "tabItems";
this.tabItems.Size = new System.Drawing.Size(528, 273); this.tabItems.Size = new System.Drawing.Size(534, 273);
this.tabItems.TabIndex = 2; this.tabItems.TabIndex = 2;
this.tabItems.Text = "Items"; this.tabItems.Text = "Items";
this.tabItems.UseVisualStyleBackColor = true; this.tabItems.UseVisualStyleBackColor = true;
// //
// 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.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;
//
// groupBox8
//
this.groupBox8.Controls.Add(this.txtScript);
this.groupBox8.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox8.Location = new System.Drawing.Point(3, 3);
this.groupBox8.Name = "groupBox8";
this.groupBox8.Size = new System.Drawing.Size(520, 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(514, 222);
this.txtScript.TabIndex = 0;
this.txtScript.Text = "";
//
// 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;
//
// groupBox5 // groupBox5
// //
this.groupBox5.Controls.Add(this.groupBox7); this.groupBox5.Controls.Add(this.groupBox7);
@ -331,160 +384,6 @@
this.lstDirections.TabIndex = 0; this.lstDirections.TabIndex = 0;
this.lstDirections.SelectedIndexChanged += new System.EventHandler(this.lstDirections_SelectedIndexChanged); 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 // frmMain
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -510,19 +409,14 @@
this.containerDesigner.ResumeLayout(false); this.containerDesigner.ResumeLayout(false);
this.groupBox4.ResumeLayout(false); this.groupBox4.ResumeLayout(false);
this.tabControl1.ResumeLayout(false); this.tabControl1.ResumeLayout(false);
this.groupBox5.ResumeLayout(false);
this.groupBox7.ResumeLayout(false);
this.groupBox10.ResumeLayout(false);
this.groupBox6.ResumeLayout(false);
this.tabScript.ResumeLayout(false); this.tabScript.ResumeLayout(false);
this.tabControl2.ResumeLayout(false); this.tabControl2.ResumeLayout(false);
this.tabFunctions.ResumeLayout(false); this.tabFunctions.ResumeLayout(false);
this.groupBox8.ResumeLayout(false); this.groupBox8.ResumeLayout(false);
this.groupBox11.ResumeLayout(false); this.groupBox5.ResumeLayout(false);
this.groupBox9.ResumeLayout(false); this.groupBox7.ResumeLayout(false);
this.groupBox13.ResumeLayout(false); this.groupBox10.ResumeLayout(false);
this.groupBox13.PerformLayout(); this.groupBox6.ResumeLayout(false);
this.groupBox12.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -556,14 +450,6 @@
private System.Windows.Forms.GroupBox groupBox8; private System.Windows.Forms.GroupBox groupBox8;
private System.Windows.Forms.RichTextBox txtScript; private System.Windows.Forms.RichTextBox txtScript;
private System.Windows.Forms.TabPage tabVariables; 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;
} }
} }

View file

@ -23,25 +23,92 @@ namespace RoomDesigner
//Doorway currently loaded. //Doorway currently loaded.
Door _CurrentDoor; Door _CurrentDoor;
//Scripting engine and it's components.
ManagedScripting.ScriptingEngine _ScriptEngine; ManagedScripting.ScriptingEngine _ScriptEngine;
ManagedScripting.CodeBuilding.ClassGenerator _CurrentClass;
ManagedScripting.CodeBuilding.MethodSetup _CurrentCodeBlock;
//Collection of plugins from within the 'plugins' folder
List<System.Reflection.Assembly> _Plugins; List<System.Reflection.Assembly> _Plugins;
public frmMain() public frmMain(params object[] parameters)
{ {
InitializeComponent(); InitializeComponent();
SetupEditor(parameters);
}
private void SetupEditor(params object[] parameters)
{
//Initialize the Room & Doorway //Initialize the Room & Doorway
_CurrentRoom = new Room(); _CurrentRoom = new Room();
_CurrentDoor = new Door(AvailableTravelDirections.None); _CurrentDoor = new Door(AvailableTravelDirections.None);
//Show the user(s) the rooms properties
propertyRoom.SelectedObject = _CurrentRoom;
//This instances a copy of AvailableTravelDirections which is a list of //This instances a copy of AvailableTravelDirections which is a list of
//currently available directions users can travel within rooms. //currently available directions users can travel within rooms.
//Instead of updating the editor each time a new travel direction is implemented, //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 //we simply build an array that contains each travel direction currently available
//within the engine by getting each element from the AvailableTravelDirections enum //within the engine by getting each element from the AvailableTravelDirections enum
BuildDoorwayList();
//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();
//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;
//Get the current rooms scripts.
//TODO: Add Doorway script support
SetupRoomScript();
if (parameters.Length != 0)
{
string rooms = Engine.GetDataPath(Engine.SaveDataTypes.Rooms);
string filename = System.IO.Path.Combine(rooms, parameters[0].ToString());
//Room to load should always be the first arg.
if (System.IO.File.Exists(filename))
{
_CurrentRoom = (Room)ManagedScripting.XmlSerialization.Load(filename, _CurrentRoom);
}
}
//Show the user(s) the rooms properties
propertyRoom.SelectedObject = _CurrentRoom;
}
private void SetupRoomScript()
{
//Check if the rooms script is empty. If so then generate a standard script for it.
if (String.IsNullOrEmpty(_CurrentRoom.Script))
{
//Instance a new method helper class
ManagedScripting.CodeBuilding.MethodSetup method = new ManagedScripting.CodeBuilding.MethodSetup();
string script = "";
//Setup our method. All objects inheriting from BaseObject will have the standard
//methods created for them.
string[] names = new string[] { "OnCreate", "OnDestroy", "OnEnter", "OnExit" };
foreach (string name in names)
{
method = new ManagedScripting.CodeBuilding.MethodSetup();
method.Name = name;
method.ReturnType = "void";
method.IsOverride = true;
method.Modifier = ManagedScripting.CodeBuilding.ClassGenerator.Modifiers.Public;
method.Code = new string[] { "base." + method.Name + "();" };
script = script.Insert(_CurrentRoom.Script.Length, method.Create());
}
_CurrentRoom.Script = script;
}
}
private void BuildDoorwayList()
{
AvailableTravelDirections direction = new AvailableTravelDirections(); AvailableTravelDirections direction = new AvailableTravelDirections();
//Build an array of travel directions currently implemented //Build an array of travel directions currently implemented
@ -58,79 +125,6 @@ namespace RoomDesigner
if (!Display.Equals("None")) if (!Display.Equals("None"))
this.lstDirections.Items.Add(Display); 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() private void LoadPlugins()
@ -147,7 +141,6 @@ namespace RoomDesigner
foreach (string assembly in System.IO.Directory.GetFiles(pluginPath, "*.dll")) foreach (string assembly in System.IO.Directory.GetFiles(pluginPath, "*.dll"))
{ {
_Plugins.Add(System.Reflection.Assembly.LoadFile(assembly)); _Plugins.Add(System.Reflection.Assembly.LoadFile(assembly));
} }
//TODO: Look for ways to allow Types to inherit from a Windows Control, and add each //TODO: Look for ways to allow Types to inherit from a Windows Control, and add each
@ -274,15 +267,10 @@ namespace RoomDesigner
//that the user has selected within the list box. If so then we //that the user has selected within the list box. If so then we
//need to prompt the user to ensure it's ok to overwrite the previous //need to prompt the user to ensure it's ok to overwrite the previous
//door with a new door. //door with a new door.
//TODO: Look at this closer, do i need this messagebox?
foreach (Door newDoor in _CurrentRoom.InstalledDoors) foreach (Door newDoor in _CurrentRoom.InstalledDoors)
{ {
if (newDoor.TravelDirection == _CurrentDoor.TravelDirection) if (newDoor.TravelDirection == _CurrentDoor.TravelDirection)
{ {
/*DialogResult result = MessageBox.Show("Door already exists! Overwrite it?", "Room Designer", MessageBoxButtons.YesNo);
if (result == DialogResult.No)
return;
*/
_CurrentRoom.InstalledDoors.Remove(newDoor); _CurrentRoom.InstalledDoors.Remove(newDoor);
_CurrentRoom.InstalledDoors.Add(_CurrentDoor); _CurrentRoom.InstalledDoors.Add(_CurrentDoor);
IsInstalled = true; IsInstalled = true;
@ -322,8 +310,41 @@ namespace RoomDesigner
_CurrentRoom = new Room(); _CurrentRoom = new Room();
_CurrentDoor = new Door(AvailableTravelDirections.None); _CurrentDoor = new Door(AvailableTravelDirections.None);
_CurrentClass = new ManagedScripting.CodeBuilding.ClassGenerator();
_CurrentCodeBlock = new ManagedScripting.CodeBuilding.MethodSetup();
propertyDoor.SelectedObject = null; propertyDoor.SelectedObject = null;
propertyRoom.SelectedObject = _CurrentRoom; propertyRoom.SelectedObject = _CurrentRoom;
} }
private void btnSaveRoom_Click(object sender, EventArgs e)
{
string savePath = Engine.GetDataPath(Engine.SaveDataTypes.Rooms);
string filePath = System.IO.Path.Combine(savePath, _CurrentRoom.Name + ".room");
if (System.IO.File.Exists(filePath))
{
DialogResult result = MessageBox.Show("File exists! Overwrite?", "Room Designer", MessageBoxButtons.YesNo);
if (result == DialogResult.No)
return;
}
ManagedScripting.XmlSerialization.Save(filePath, _CurrentRoom);
MessageBox.Show("Saved.", "Room Designer");
}
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedTab.Text == "Script")
{
txtScript.Text = _CurrentRoom.Script;
}
}
private void propertyRoom_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
{
//propertyRoom.Refresh();
}
} }
} }

View file

@ -13,7 +13,7 @@ namespace VisualDesigner
[STAThread] [STAThread]
static void Main() static void Main()
{ {
MUDEngine.Engine.ValidateProjectPath(Application.StartupPath); MUDEngine.Engine.ValidateDataPaths();
MUDEngine.FileSystem.FileSystem.FileType = MUDEngine.FileSystem.FileSystem.OutputFormats.XML; MUDEngine.FileSystem.FileSystem.FileType = MUDEngine.FileSystem.FileSystem.OutputFormats.XML;
Application.EnableVisualStyles(); Application.EnableVisualStyles();