- Complete re-work of the Realm Explorer and Zone Builder.

- Realm Explorer & Zone Builder now work together correctly.
 - Program.CurrentEditor now holds the currently running editor.
 - BaseObject.ToString() added to return the Name of the object if ToString() is used.
 - GetZone() method added to Realm.cs
This commit is contained in:
Scionwest_cp 2009-12-04 23:15:33 -08:00
parent 09fa576025
commit 3cfa72ef69
9 changed files with 330 additions and 298 deletions

View file

@ -26,15 +26,13 @@ namespace MudDesigner.Editors
InitializeComponent();
Program.Zone = new Zone();
Program.Realm = new Realm();
Program.Room = new Room();
_AvailableZones = new List<Zone>();
Program.ScriptEngine = new ScriptingEngine();
Program.ScriptEngine.CompileStyle = ManagedScripting.Compilers.BaseCompiler.ScriptCompileStyle.CompileToMemory;
Program.ScriptEngine.KeepTempFiles = false;
BuildZoneLists();
SetupScript();
propertyRealm.SelectedObject = Program.Realm;
string[] existingRealms = System.IO.Directory.GetFiles(FileManager.GetDataPath(SaveDataTypes.Realms));
@ -42,83 +40,20 @@ namespace MudDesigner.Editors
lstRealms.Items.Add(System.IO.Path.GetFileNameWithoutExtension(realm));
}
private void BuildZoneLists()
{
string[] zones = System.IO.Directory.GetFiles(FileManager.GetDataPath(SaveDataTypes.Zones), "*.zone");
bool available = true;
lstAvailableZones.Items.Clear();
lstZonesInRealm.Items.Clear();
foreach (string zone in zones)
{
string[] realms = System.IO.Directory.GetFiles(FileManager.GetDataPath(SaveDataTypes.Realms), "*.realm");
foreach (string realm in realms)
{
Realm r = new Realm();
r = (Realm)ManagedScripting.XmlSerialization.Load(realm, r);
foreach (Zone z in r.Zones)
{
if (z.Name == System.IO.Path.GetFileNameWithoutExtension(zone))
{
available = false;
break;
}
}
if (!available)
break;
}
if (!available)
break;
else
{
lstAvailableZones.Items.Add(System.IO.Path.GetFileNameWithoutExtension(zone));
}
}
}
private void SetupScript()
{
//Check if the realm script is empty. If so then generate a standard script for it.
if (String.IsNullOrEmpty(Program.Realm.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(Program.Realm.Script.Length, method.Create() + "\n");
}
Program.Realm.Script = script;
}
}
private void btnNewRealm_Click(object sender, EventArgs e)
{
Program.Zone = new Zone();
Program.Realm = new Realm();
SetupScript();
lstZones.Items.Clear();
propertyRealm.SelectedObject = Program.Realm;
lstZonesInRealm.Items.Clear();
}
private void btnSaveRealm_Click(object sender, EventArgs e)
{
string path = FileManager.GetDataPath(SaveDataTypes.Realms);
string filename = System.IO.Path.Combine(path, Program.Realm.Name + ".realm");
if (System.IO.File.Exists(filename))
string realmFile = System.IO.Path.Combine(path, Program.Realm.Name + ".realm");
if (System.IO.File.Exists(realmFile))
{
DialogResult result = MessageBox.Show("File exists!\nOverwrite?", "Realm Explorer", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
@ -126,7 +61,7 @@ namespace MudDesigner.Editors
return;
}
FileManager.Save(filename, Program.Realm);
FileManager.Save(realmFile, Program.Realm);
if (!lstRealms.Items.Contains(Program.Realm.Name))
lstRealms.Items.Add(Program.Realm.Name);
@ -136,26 +71,15 @@ namespace MudDesigner.Editors
{
if (lstRealms.SelectedIndex == -1)
return;
lstZones.Items.Clear();
string path = FileManager.GetDataPath(SaveDataTypes.Realms);
string filename = System.IO.Path.Combine(path, lstRealms.SelectedItem.ToString() + ".realm");
Program.Realm = (Realm)FileManager.Load(filename, Program.Realm);
string realmFile = System.IO.Path.Combine(path, lstRealms.SelectedItem.ToString() + ".realm");
Program.Realm = (Realm)FileManager.Load(realmFile, Program.Realm);
propertyRealm.SelectedObject = Program.Realm;
lstZonesInRealm.Items.Clear();
foreach (string file in System.IO.Directory.GetFiles(FileManager.GetDataPath(SaveDataTypes.Zones), "*.zone"))
{
Zone zone = new Zone();
zone = (Zone)FileManager.Load(file, zone);
if (zone.Realm == Program.Realm.Name)
lstZonesInRealm.Items.Add(zone.Name);
else if (String.IsNullOrEmpty(zone.Realm))
{
lstAvailableZones.Items.Add(zone.Name);
}
}
foreach (Zone zone in Program.Realm.Zones)
lstZones.Items.Add(zone.Name);
}
private void btnDeleteRealm_Click(object sender, EventArgs e)
@ -173,8 +97,8 @@ namespace MudDesigner.Editors
return;
string path = FileManager.GetDataPath(SaveDataTypes.Realms);
string filename = System.IO.Path.Combine(path, lstRealms.SelectedItem.ToString() + ".realm");
System.IO.File.Delete(filename);
string realmFile = System.IO.Path.Combine(path, lstRealms.SelectedItem.ToString() + ".realm");
System.IO.File.Delete(realmFile);
lstRealms.Items.Remove(lstRealms.SelectedItem);
}
@ -194,7 +118,7 @@ namespace MudDesigner.Editors
private void btnValidateScript_Click(object sender, EventArgs e)
{
Program.ScriptEngine.Compiler = ManagedScripting.ScriptingEngine.CompilerSelections.SourceCompiler;
Program.ScriptEngine.AddReference(Application.StartupPath + "/MUDEngine.dll");
Program.ScriptEngine.AddReference(FileManager.GetDataPath(SaveDataTypes.Root) + "\\Mud Designer.exe");
string code = "namespace MudDesigner.MudEngine.Objects.Environment\n"
+ "{\n"
+ " public class " + Program.Realm.Name.Replace(" ", "") + " : Realm\n"
@ -207,9 +131,20 @@ namespace MudDesigner.Editors
private void btnBuildZone_Click(object sender, EventArgs e)
{
if (lstRealms.SelectedIndex == -1)
{
MessageBox.Show("Select a Realm to build a Zone for.", "Realm Explorer", MessageBoxButtons.OK);
return;
}
ZoneBuilder form = new ZoneBuilder();
if (btnBuildZone.Text == "Edit Selected Zone")
form.IsEditingExisting = true;
form.Show();
this.Hide();
while (form.Created)
Application.DoEvents();
@ -218,23 +153,59 @@ namespace MudDesigner.Editors
this.Show();
}
private void btnPlaceZone_Click(object sender, EventArgs e)
private void btnMoveZone_Click(object sender, EventArgs e)
{
if (lstAvailableZones.SelectedIndex == -1)
if (lstZones.SelectedIndex == -1)
{
MessageBox.Show("Please select a Zone to add!", "Realm Explorer");
MessageBox.Show("Select a Zone to transfer first.", "Realm Explorer", MessageBoxButtons.OK);
return;
}
string path = FileManager.GetDataPath(SaveDataTypes.Zones);
string filename = System.IO.Path.Combine(path, lstAvailableZones.SelectedItem.ToString() + ".zone");
Zone zone = new Zone();
zone = (Zone)FileManager.Load(filename, zone);
zone.Realm = Program.Realm.Name;
FileManager.Save(filename, zone);
ExistingRealms form = new ExistingRealms(lstZones.SelectedItem.ToString());
form.Show();
this.Hide();
Program.Realm.Zones.Add(zone);
lstZonesInRealm.Items.Add(zone.Name);
while (form.Created)
Application.DoEvents();
this.Show();
}
private void btnUnselectZone_Click(object sender, EventArgs e)
{
lstZones.SelectedIndex = -1;
btnBuildZone.Text = "Build A Zone";
}
private void btnDeleteZone_Click(object sender, EventArgs e)
{
if (lstZones.SelectedIndex == -1)
{
MessageBox.Show("No zone selected for deletion.", "Realm Explorer", MessageBoxButtons.OK);
return;
}
Zone zone = Program.Realm.GetZone(lstZones.SelectedItem.ToString());
if (zone == null)
{
MessageBox.Show("Error deleting Zone.", "Realm Exporer");
return;
}
Program.Realm.Zones.Remove(zone);
string filename = System.IO.Path.Combine(FileManager.GetDataPath(SaveDataTypes.Zones), lstZones.SelectedItem.ToString() + ".zone");
if (System.IO.File.Exists(filename))
System.IO.File.Delete(filename);
filename = System.IO.Path.Combine(FileManager.GetDataPath(SaveDataTypes.Realms), Program.Realm.Name + ".realm");
lstZones.Items.Remove(lstZones.SelectedItem);
FileManager.Save(filename, Program.Realm);
}
private void lstZones_SelectedIndexChanged(object sender, EventArgs e)
{
btnBuildZone.Text = "Edit Selected Zone";
}
}
}

View file

@ -32,36 +32,37 @@
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.lstRealms = new System.Windows.Forms.ListBox();
this.propertyRealm = new System.Windows.Forms.PropertyGrid();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.btnRemoveZone = new System.Windows.Forms.Button();
this.btnPlaceZone = new System.Windows.Forms.Button();
this.btnBuildZone = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.lstZonesInRealm = new System.Windows.Forms.ListBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.lstAvailableZones = new System.Windows.Forms.ListBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabOptions = new System.Windows.Forms.TabPage();
this.btnValidateScript = new System.Windows.Forms.Button();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.btnDeleteZone = new System.Windows.Forms.Button();
this.btnUnselectZone = new System.Windows.Forms.Button();
this.btnMoveZone = new System.Windows.Forms.Button();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.lstZones = new System.Windows.Forms.ListBox();
this.btnBuildZone = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.btnClose = new System.Windows.Forms.Button();
this.btnSaveRealm = new System.Windows.Forms.Button();
this.btnDeleteRealm = new System.Windows.Forms.Button();
this.btnNewRealm = new System.Windows.Forms.Button();
this.tabScript = new System.Windows.Forms.TabPage();
this.txtScript = new System.Windows.Forms.RichTextBox();
this.btnValidateScript = new System.Windows.Forms.Button();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.Panel2.SuspendLayout();
this.splitContainer2.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabOptions.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox2.SuspendLayout();
this.tabScript.SuspendLayout();
this.SuspendLayout();
//
@ -78,11 +79,8 @@
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.groupBox4);
this.splitContainer1.Panel2.Controls.Add(this.groupBox3);
this.splitContainer1.Panel2.Controls.Add(this.groupBox2);
this.splitContainer1.Panel2.Controls.Add(this.groupBox1);
this.splitContainer1.Size = new System.Drawing.Size(465, 488);
this.splitContainer1.Size = new System.Drawing.Size(529, 488);
this.splitContainer1.SplitterDistance = 193;
this.splitContainer1.TabIndex = 0;
//
@ -111,6 +109,7 @@
this.lstRealms.Location = new System.Drawing.Point(0, 0);
this.lstRealms.Name = "lstRealms";
this.lstRealms.Size = new System.Drawing.Size(193, 212);
this.lstRealms.Sorted = true;
this.lstRealms.TabIndex = 0;
this.lstRealms.SelectedIndexChanged += new System.EventHandler(this.lstRealms_SelectedIndexChanged);
//
@ -123,94 +122,12 @@
this.propertyRealm.TabIndex = 0;
this.propertyRealm.ToolbarVisible = false;
//
// groupBox4
//
this.groupBox4.Controls.Add(this.btnRemoveZone);
this.groupBox4.Controls.Add(this.btnPlaceZone);
this.groupBox4.Controls.Add(this.btnBuildZone);
this.groupBox4.Location = new System.Drawing.Point(2, 256);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(260, 88);
this.groupBox4.TabIndex = 3;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Realm Zone Setup";
//
// btnRemoveZone
//
this.btnRemoveZone.Dock = System.Windows.Forms.DockStyle.Top;
this.btnRemoveZone.Location = new System.Drawing.Point(3, 62);
this.btnRemoveZone.Name = "btnRemoveZone";
this.btnRemoveZone.Size = new System.Drawing.Size(254, 23);
this.btnRemoveZone.TabIndex = 3;
this.btnRemoveZone.Text = "Remove Zone From Realm";
this.btnRemoveZone.UseVisualStyleBackColor = true;
//
// btnPlaceZone
//
this.btnPlaceZone.Dock = System.Windows.Forms.DockStyle.Top;
this.btnPlaceZone.Location = new System.Drawing.Point(3, 39);
this.btnPlaceZone.Name = "btnPlaceZone";
this.btnPlaceZone.Size = new System.Drawing.Size(254, 23);
this.btnPlaceZone.TabIndex = 2;
this.btnPlaceZone.Text = "Place Zone In Realm";
this.btnPlaceZone.UseVisualStyleBackColor = true;
this.btnPlaceZone.Click += new System.EventHandler(this.btnPlaceZone_Click);
//
// btnBuildZone
//
this.btnBuildZone.Dock = System.Windows.Forms.DockStyle.Top;
this.btnBuildZone.Location = new System.Drawing.Point(3, 16);
this.btnBuildZone.Name = "btnBuildZone";
this.btnBuildZone.Size = new System.Drawing.Size(254, 23);
this.btnBuildZone.TabIndex = 1;
this.btnBuildZone.Text = "Build A Zone";
this.btnBuildZone.UseVisualStyleBackColor = true;
this.btnBuildZone.Click += new System.EventHandler(this.btnBuildZone_Click);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.lstZonesInRealm);
this.groupBox3.Location = new System.Drawing.Point(2, 350);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(260, 135);
this.groupBox3.TabIndex = 2;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Zones contained within Realm";
//
// lstZonesInRealm
//
this.lstZonesInRealm.Dock = System.Windows.Forms.DockStyle.Fill;
this.lstZonesInRealm.FormattingEnabled = true;
this.lstZonesInRealm.Location = new System.Drawing.Point(3, 16);
this.lstZonesInRealm.Name = "lstZonesInRealm";
this.lstZonesInRealm.Size = new System.Drawing.Size(254, 108);
this.lstZonesInRealm.TabIndex = 1;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.lstAvailableZones);
this.groupBox2.Location = new System.Drawing.Point(2, 148);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(260, 102);
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Available Zones";
//
// lstAvailableZones
//
this.lstAvailableZones.Dock = System.Windows.Forms.DockStyle.Fill;
this.lstAvailableZones.FormattingEnabled = true;
this.lstAvailableZones.Location = new System.Drawing.Point(3, 16);
this.lstAvailableZones.Name = "lstAvailableZones";
this.lstAvailableZones.Size = new System.Drawing.Size(254, 82);
this.lstAvailableZones.TabIndex = 1;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.tabControl1);
this.groupBox1.Location = new System.Drawing.Point(0, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(265, 142);
this.groupBox1.Size = new System.Drawing.Size(332, 459);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Realm Setup";
@ -223,72 +140,155 @@
this.tabControl1.Location = new System.Drawing.Point(3, 16);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(259, 123);
this.tabControl1.Size = new System.Drawing.Size(326, 440);
this.tabControl1.TabIndex = 0;
this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged);
//
// tabOptions
//
this.tabOptions.Controls.Add(this.btnValidateScript);
this.tabOptions.Controls.Add(this.btnClose);
this.tabOptions.Controls.Add(this.btnSaveRealm);
this.tabOptions.Controls.Add(this.btnDeleteRealm);
this.tabOptions.Controls.Add(this.btnNewRealm);
this.tabOptions.Controls.Add(this.groupBox5);
this.tabOptions.Controls.Add(this.groupBox3);
this.tabOptions.Controls.Add(this.groupBox2);
this.tabOptions.Location = new System.Drawing.Point(4, 22);
this.tabOptions.Name = "tabOptions";
this.tabOptions.Padding = new System.Windows.Forms.Padding(3);
this.tabOptions.Size = new System.Drawing.Size(251, 97);
this.tabOptions.Size = new System.Drawing.Size(318, 414);
this.tabOptions.TabIndex = 0;
this.tabOptions.Text = "Explorer Options";
this.tabOptions.Text = "Realm Options";
this.tabOptions.UseVisualStyleBackColor = true;
//
// btnValidateScript
// groupBox5
//
this.btnValidateScript.Dock = System.Windows.Forms.DockStyle.Bottom;
this.btnValidateScript.Location = new System.Drawing.Point(3, 71);
this.btnValidateScript.Name = "btnValidateScript";
this.btnValidateScript.Size = new System.Drawing.Size(245, 23);
this.btnValidateScript.TabIndex = 8;
this.btnValidateScript.Text = "Validate Script";
this.btnValidateScript.UseVisualStyleBackColor = true;
this.btnValidateScript.Click += new System.EventHandler(this.btnValidateScript_Click);
this.groupBox5.Location = new System.Drawing.Point(3, 297);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(312, 114);
this.groupBox5.TabIndex = 14;
this.groupBox5.TabStop = false;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.btnDeleteZone);
this.groupBox3.Controls.Add(this.btnUnselectZone);
this.groupBox3.Controls.Add(this.btnMoveZone);
this.groupBox3.Controls.Add(this.groupBox4);
this.groupBox3.Controls.Add(this.btnBuildZone);
this.groupBox3.Location = new System.Drawing.Point(3, 88);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(312, 206);
this.groupBox3.TabIndex = 13;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Zone Setup";
//
// btnDeleteZone
//
this.btnDeleteZone.Location = new System.Drawing.Point(104, 175);
this.btnDeleteZone.Name = "btnDeleteZone";
this.btnDeleteZone.Size = new System.Drawing.Size(101, 23);
this.btnDeleteZone.TabIndex = 16;
this.btnDeleteZone.Text = "Delete Zone";
this.btnDeleteZone.UseVisualStyleBackColor = true;
this.btnDeleteZone.Click += new System.EventHandler(this.btnDeleteZone_Click);
//
// btnUnselectZone
//
this.btnUnselectZone.Location = new System.Drawing.Point(211, 175);
this.btnUnselectZone.Name = "btnUnselectZone";
this.btnUnselectZone.Size = new System.Drawing.Size(95, 23);
this.btnUnselectZone.TabIndex = 15;
this.btnUnselectZone.Text = "Unselect Zone";
this.btnUnselectZone.UseVisualStyleBackColor = true;
this.btnUnselectZone.Click += new System.EventHandler(this.btnUnselectZone_Click);
//
// btnMoveZone
//
this.btnMoveZone.Location = new System.Drawing.Point(3, 175);
this.btnMoveZone.Name = "btnMoveZone";
this.btnMoveZone.Size = new System.Drawing.Size(95, 23);
this.btnMoveZone.TabIndex = 14;
this.btnMoveZone.Text = "Move Zone";
this.btnMoveZone.UseVisualStyleBackColor = true;
this.btnMoveZone.Click += new System.EventHandler(this.btnMoveZone_Click);
//
// groupBox4
//
this.groupBox4.Controls.Add(this.lstZones);
this.groupBox4.Location = new System.Drawing.Point(3, 45);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(306, 132);
this.groupBox4.TabIndex = 13;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Zones within Realm";
//
// lstZones
//
this.lstZones.Dock = System.Windows.Forms.DockStyle.Fill;
this.lstZones.FormattingEnabled = true;
this.lstZones.Location = new System.Drawing.Point(3, 16);
this.lstZones.Name = "lstZones";
this.lstZones.Size = new System.Drawing.Size(300, 108);
this.lstZones.TabIndex = 0;
this.lstZones.SelectedIndexChanged += new System.EventHandler(this.lstZones_SelectedIndexChanged);
//
// btnBuildZone
//
this.btnBuildZone.Dock = System.Windows.Forms.DockStyle.Top;
this.btnBuildZone.Location = new System.Drawing.Point(3, 16);
this.btnBuildZone.Name = "btnBuildZone";
this.btnBuildZone.Size = new System.Drawing.Size(306, 23);
this.btnBuildZone.TabIndex = 12;
this.btnBuildZone.Text = "Build A Zone";
this.btnBuildZone.UseVisualStyleBackColor = true;
this.btnBuildZone.Click += new System.EventHandler(this.btnBuildZone_Click);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.btnClose);
this.groupBox2.Controls.Add(this.btnSaveRealm);
this.groupBox2.Controls.Add(this.btnDeleteRealm);
this.groupBox2.Controls.Add(this.btnNewRealm);
this.groupBox2.Location = new System.Drawing.Point(3, 6);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(312, 76);
this.groupBox2.TabIndex = 12;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Editor Options";
//
// btnClose
//
this.btnClose.Location = new System.Drawing.Point(139, 35);
this.btnClose.Location = new System.Drawing.Point(197, 48);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(109, 23);
this.btnClose.TabIndex = 7;
this.btnClose.TabIndex = 11;
this.btnClose.Text = "Close Explorer";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// btnSaveRealm
//
this.btnSaveRealm.Location = new System.Drawing.Point(139, 6);
this.btnSaveRealm.Location = new System.Drawing.Point(197, 19);
this.btnSaveRealm.Name = "btnSaveRealm";
this.btnSaveRealm.Size = new System.Drawing.Size(109, 23);
this.btnSaveRealm.TabIndex = 6;
this.btnSaveRealm.TabIndex = 10;
this.btnSaveRealm.Text = "Save Realm";
this.btnSaveRealm.UseVisualStyleBackColor = true;
this.btnSaveRealm.Click += new System.EventHandler(this.btnSaveRealm_Click);
//
// btnDeleteRealm
//
this.btnDeleteRealm.Location = new System.Drawing.Point(3, 35);
this.btnDeleteRealm.Location = new System.Drawing.Point(6, 48);
this.btnDeleteRealm.Name = "btnDeleteRealm";
this.btnDeleteRealm.Size = new System.Drawing.Size(114, 23);
this.btnDeleteRealm.TabIndex = 5;
this.btnDeleteRealm.TabIndex = 9;
this.btnDeleteRealm.Text = "Delete Realm";
this.btnDeleteRealm.UseVisualStyleBackColor = true;
this.btnDeleteRealm.Click += new System.EventHandler(this.btnDeleteRealm_Click);
//
// btnNewRealm
//
this.btnNewRealm.Location = new System.Drawing.Point(3, 6);
this.btnNewRealm.Location = new System.Drawing.Point(6, 19);
this.btnNewRealm.Name = "btnNewRealm";
this.btnNewRealm.Size = new System.Drawing.Size(114, 23);
this.btnNewRealm.TabIndex = 4;
this.btnNewRealm.TabIndex = 8;
this.btnNewRealm.Text = "New Realm";
this.btnNewRealm.UseVisualStyleBackColor = true;
this.btnNewRealm.Click += new System.EventHandler(this.btnNewRealm_Click);
@ -296,10 +296,11 @@
// tabScript
//
this.tabScript.Controls.Add(this.txtScript);
this.tabScript.Controls.Add(this.btnValidateScript);
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(251, 97);
this.tabScript.Size = new System.Drawing.Size(318, 414);
this.tabScript.TabIndex = 1;
this.tabScript.Text = "Script";
this.tabScript.UseVisualStyleBackColor = true;
@ -307,17 +308,28 @@
// txtScript
//
this.txtScript.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtScript.Location = new System.Drawing.Point(3, 3);
this.txtScript.Location = new System.Drawing.Point(3, 26);
this.txtScript.Name = "txtScript";
this.txtScript.Size = new System.Drawing.Size(245, 91);
this.txtScript.TabIndex = 0;
this.txtScript.Size = new System.Drawing.Size(312, 385);
this.txtScript.TabIndex = 11;
this.txtScript.Text = "";
//
// btnValidateScript
//
this.btnValidateScript.Dock = System.Windows.Forms.DockStyle.Top;
this.btnValidateScript.Location = new System.Drawing.Point(3, 3);
this.btnValidateScript.Name = "btnValidateScript";
this.btnValidateScript.Size = new System.Drawing.Size(312, 23);
this.btnValidateScript.TabIndex = 10;
this.btnValidateScript.Text = "Validate Script";
this.btnValidateScript.UseVisualStyleBackColor = true;
this.btnValidateScript.Click += new System.EventHandler(this.btnValidateScript_Click);
//
// RealmExplorer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(465, 488);
this.ClientSize = new System.Drawing.Size(529, 488);
this.Controls.Add(this.splitContainer1);
this.Name = "RealmExplorer";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
@ -328,12 +340,12 @@
this.splitContainer2.Panel1.ResumeLayout(false);
this.splitContainer2.Panel2.ResumeLayout(false);
this.splitContainer2.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.tabControl1.ResumeLayout(false);
this.tabOptions.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.tabScript.ResumeLayout(false);
this.ResumeLayout(false);
@ -346,23 +358,24 @@
private System.Windows.Forms.ListBox lstRealms;
private System.Windows.Forms.PropertyGrid propertyRealm;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.ListBox lstAvailableZones;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.ListBox lstZonesInRealm;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Button btnPlaceZone;
private System.Windows.Forms.Button btnBuildZone;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabOptions;
private System.Windows.Forms.TabPage tabScript;
private System.Windows.Forms.Button btnValidateScript;
private System.Windows.Forms.RichTextBox txtScript;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button btnBuildZone;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnSaveRealm;
private System.Windows.Forms.Button btnDeleteRealm;
private System.Windows.Forms.Button btnNewRealm;
private System.Windows.Forms.TabPage tabScript;
private System.Windows.Forms.RichTextBox txtScript;
private System.Windows.Forms.Button btnValidateScript;
private System.Windows.Forms.Button btnRemoveZone;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Button btnMoveZone;
private System.Windows.Forms.GroupBox groupBox5;
internal System.Windows.Forms.ListBox lstZones;
private System.Windows.Forms.Button btnUnselectZone;
private System.Windows.Forms.Button btnDeleteZone;
}

View file

@ -28,6 +28,7 @@ namespace MudDesigner.Editors
private void btnProjectSettings_Click(object sender, EventArgs e)
{
ProjectSettings form = new ProjectSettings();
Program.CurrentEditor = form;
form.Show();
this.Hide();
@ -42,6 +43,7 @@ namespace MudDesigner.Editors
private void btnCurrencyEditor_Click(object sender, EventArgs e)
{
CurrencyEditor form = new CurrencyEditor();
Program.CurrentEditor = form;
form.Show();
this.Hide();
@ -56,6 +58,7 @@ namespace MudDesigner.Editors
private void btnRoomDesigner_Click(object sender, EventArgs e)
{
RoomDesigner form = new RoomDesigner();
Program.CurrentEditor = form;
form.Show();
this.Hide();
@ -70,6 +73,7 @@ namespace MudDesigner.Editors
private void btnRealmExplorer_Click(object sender, EventArgs e)
{
RealmExplorer form = new RealmExplorer();
Program.CurrentEditor = form;
form.Show();
this.Hide();
@ -84,6 +88,7 @@ namespace MudDesigner.Editors
private void btnZoneBuilder_Click(object sender, EventArgs e)
{
ZoneBuilder form = new ZoneBuilder();
Program.CurrentEditor = form;
form.Show();
this.Hide();

View file

@ -19,24 +19,11 @@ namespace MudDesigner.Editors
{
public partial class ZoneBuilder : Form
{
internal bool IsEditingExisting = false;
public ZoneBuilder()
{
InitializeComponent();
Program.Room = new Room();
Program.Zone = new Zone();
Program.ScriptEngine = new ScriptingEngine();
Program.ScriptEngine.CompileStyle = ManagedScripting.Compilers.BaseCompiler.ScriptCompileStyle.CompileToMemory;
Program.ScriptEngine.Compiler = ScriptingEngine.CompilerSelections.SourceCompiler;
propertyZone.SelectedObject = Program.Zone;
txtScript.Text = Program.Zone.Script;
string[] rooms = System.IO.Directory.GetFiles(FileManager.GetDataPath(SaveDataTypes.Rooms), "*.room");
foreach (string room in rooms)
{
lstRooms.Items.Add(System.IO.Path.GetFileNameWithoutExtension(room));
}
}
private void btnRoomEditor_Click(object sender, EventArgs e)
@ -73,17 +60,39 @@ namespace MudDesigner.Editors
this.Show();
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnSaveZone_Click(object sender, EventArgs e)
{
//build the save file name
string path = FileManager.GetDataPath(SaveDataTypes.Zones);
string filename = System.IO.Path.Combine(path, Program.Zone.Name + ".zone");
string zoneFile = System.IO.Path.Combine(path, Program.Zone.Name + ".zone");
path = FileManager.GetDataPath(SaveDataTypes.Realms);
string realmFile = System.IO.Path.Combine(path, Program.Realm.Name + ".realm");
FileManager.Save(filename, Program.Zone);
//get a copy of the currently running (but hidden) realm explorer
RealmExplorer form = (RealmExplorer)Program.CurrentEditor;
//Check if the currently selected realm currently contains the zone already
//in its lists of zones. It could already be there and the user is just editing it.
if (!form.lstZones.Items.Contains(Program.Zone.Name))
form.lstZones.Items.Add(Program.Zone.Name);
//Set the zones owning realm to the current realm
Program.Zone.Realm = Program.Realm.Name;
//Add the zone to the realms zone collection
if (!Program.Realm.Zones.Contains(Program.Realm.GetZone(Program.Zone.Name)))
Program.Realm.Zones.Add(Program.Zone);
//Save the zone and modified realm.
FileManager.Save(zoneFile, Program.Zone);
FileManager.Save(realmFile, Program.Realm);
//Reset the zone and room
Program.Zone = new Zone();
Program.Room = new Room();
propertyZone.SelectedObject = Program.Zone;
this.Close();
}
private void btnNewZone_Click(object sender, EventArgs e)
@ -107,5 +116,35 @@ namespace MudDesigner.Editors
+ "}\n";
MessageBox.Show(Program.ScriptEngine.Compile(code), "Script Compiling", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void ZoneBuilder_Load(object sender, EventArgs e)
{
Program.Room = new Room();
Program.Zone = new Zone();
Program.ScriptEngine = new ScriptingEngine();
Program.ScriptEngine.CompileStyle = ManagedScripting.Compilers.BaseCompiler.ScriptCompileStyle.CompileToMemory;
Program.ScriptEngine.Compiler = ScriptingEngine.CompilerSelections.SourceCompiler;
if (IsEditingExisting)
{
string path = FileManager.GetDataPath(SaveDataTypes.Zones);
RealmExplorer form = (RealmExplorer)Program.CurrentEditor;
string zoneFile = form.lstZones.SelectedItem.ToString() + ".zone";
string fullFilePath = System.IO.Path.Combine(path, zoneFile);
Program.Zone = (Zone)FileManager.Load(fullFilePath, Program.Zone);
}
propertyZone.SelectedObject = Program.Zone;
txtScript.Text = Program.Zone.Script;
string[] rooms = System.IO.Directory.GetFiles(FileManager.GetDataPath(SaveDataTypes.Rooms), "*.room");
foreach (string room in rooms)
{
lstRooms.Items.Add(System.IO.Path.GetFileNameWithoutExtension(room));
}
}
}
}

View file

@ -32,9 +32,7 @@
this.propertyZone = new System.Windows.Forms.PropertyGrid();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnValidateScript = new System.Windows.Forms.Button();
this.btnClose = new System.Windows.Forms.Button();
this.btnSaveZone = new System.Windows.Forms.Button();
this.btnDeleteZone = new System.Windows.Forms.Button();
this.btnNewZone = new System.Windows.Forms.Button();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.tabControl1 = new System.Windows.Forms.TabControl();
@ -77,23 +75,21 @@
// propertyZone
//
this.propertyZone.Dock = System.Windows.Forms.DockStyle.Fill;
this.propertyZone.Location = new System.Drawing.Point(0, 99);
this.propertyZone.Location = new System.Drawing.Point(0, 71);
this.propertyZone.Name = "propertyZone";
this.propertyZone.Size = new System.Drawing.Size(210, 475);
this.propertyZone.Size = new System.Drawing.Size(210, 503);
this.propertyZone.TabIndex = 1;
this.propertyZone.ToolbarVisible = false;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.btnValidateScript);
this.groupBox1.Controls.Add(this.btnClose);
this.groupBox1.Controls.Add(this.btnSaveZone);
this.groupBox1.Controls.Add(this.btnDeleteZone);
this.groupBox1.Controls.Add(this.btnNewZone);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top;
this.groupBox1.Location = new System.Drawing.Point(0, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(210, 99);
this.groupBox1.Size = new System.Drawing.Size(210, 71);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Zone Setup";
@ -101,7 +97,7 @@
// btnValidateScript
//
this.btnValidateScript.Dock = System.Windows.Forms.DockStyle.Bottom;
this.btnValidateScript.Location = new System.Drawing.Point(3, 73);
this.btnValidateScript.Location = new System.Drawing.Point(3, 45);
this.btnValidateScript.Name = "btnValidateScript";
this.btnValidateScript.Size = new System.Drawing.Size(204, 23);
this.btnValidateScript.TabIndex = 13;
@ -109,16 +105,6 @@
this.btnValidateScript.UseVisualStyleBackColor = true;
this.btnValidateScript.Click += new System.EventHandler(this.btnValidateScript_Click);
//
// btnClose
//
this.btnClose.Location = new System.Drawing.Point(110, 48);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(97, 23);
this.btnClose.TabIndex = 12;
this.btnClose.Text = "Close Builder";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// btnSaveZone
//
this.btnSaveZone.Location = new System.Drawing.Point(110, 19);
@ -129,15 +115,6 @@
this.btnSaveZone.UseVisualStyleBackColor = true;
this.btnSaveZone.Click += new System.EventHandler(this.btnSaveZone_Click);
//
// btnDeleteZone
//
this.btnDeleteZone.Location = new System.Drawing.Point(3, 48);
this.btnDeleteZone.Name = "btnDeleteZone";
this.btnDeleteZone.Size = new System.Drawing.Size(102, 23);
this.btnDeleteZone.TabIndex = 10;
this.btnDeleteZone.Text = "Delete Zone";
this.btnDeleteZone.UseVisualStyleBackColor = true;
//
// btnNewZone
//
this.btnNewZone.Location = new System.Drawing.Point(3, 19);
@ -238,7 +215,7 @@
this.btnRoomEditor.UseVisualStyleBackColor = true;
this.btnRoomEditor.Click += new System.EventHandler(this.btnRoomEditor_Click);
//
// frmMain
// ZoneBuilder
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
@ -247,9 +224,10 @@
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "frmMain";
this.Name = "ZoneBuilder";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Zone Builder";
this.Load += new System.EventHandler(this.ZoneBuilder_Load);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.ResumeLayout(false);
@ -269,9 +247,7 @@
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button btnValidateScript;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnSaveZone;
private System.Windows.Forms.Button btnDeleteZone;
private System.Windows.Forms.Button btnNewZone;
private System.Windows.Forms.PropertyGrid propertyZone;
private System.Windows.Forms.SplitContainer splitContainer2;

View file

@ -52,6 +52,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Editors\ExistingRealms.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Editors\ExistingRealms.Designer.cs">
<DependentUpon>ExistingRealms.cs</DependentUpon>
</Compile>
<Compile Include="MudEngine\FileSystem\SaveDataTypes.cs" />
<Compile Include="MudEngine\GameObjects\BaseObject.cs" />
<Compile Include="MudEngine\GameObjects\Currency.cs" />
@ -110,6 +116,10 @@
<DependentUpon>CurrencyEditor.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Editors\ExistingRealms.resx">
<DependentUpon>ExistingRealms.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Editors\ZoneBuilder.resx">
<DependentUpon>ZoneBuilder.cs</DependentUpon>
<SubType>Designer</SubType>

View file

@ -93,6 +93,11 @@ namespace MudDesigner.MudEngine.Objects
}
}
public override string ToString()
{
return this.Name;
}
public virtual void OnEnter()
{
}

View file

@ -14,5 +14,16 @@ namespace MudDesigner.MudEngine.Objects.Environment
{
Zones = new List<Zone>();
}
public Zone GetZone(string ZoneName)
{
foreach(Zone zone in Zones)
{
if (zone.Name == ZoneName)
return zone;
}
return null;
}
}
}

View file

@ -18,6 +18,7 @@ namespace MudDesigner
public static Zone Zone {get;set;}
public static Room Room { get; set; }
public static ManagedScripting.ScriptingEngine ScriptEngine { get; set; }
public static Form CurrentEditor { get; set; }
/// <summary>
/// The main entry point for the application.
@ -25,9 +26,10 @@ namespace MudDesigner
[STAThread]
static void Main()
{
Project = new ProjectInformation();
FileManager.ValidateDataPaths();
FileManager.FileType = FileManager.OutputFormats.XML;
Project = new ProjectInformation();
string filename = System.IO.Path.Combine(FileManager.GetDataPath(SaveDataTypes.Root), "Project.Xml");
if (System.IO.File.Exists(filename))