diff --git a/Mud Designer/Designer.cs b/Mud Designer/Designer.cs
index 83dc124..455f71f 100644
--- a/Mud Designer/Designer.cs
+++ b/Mud Designer/Designer.cs
@@ -542,7 +542,6 @@ namespace MudDesigner
}
SaveObject();
IsSaved = true;
- RefreshProjectExplorer();
if (_Widget != null)
_Widget.Refresh();
}
diff --git a/Mud Designer/Mud Designer.csproj b/Mud Designer/Mud Designer.csproj
index 18bdb76..32c71ae 100644
--- a/Mud Designer/Mud Designer.csproj
+++ b/Mud Designer/Mud Designer.csproj
@@ -93,6 +93,13 @@
+
+
+ Form
+
+
+ UIDoorwayControl.cs
+
Form
@@ -119,6 +126,10 @@
Designer.cs
Designer
+
+ UIDoorwayControl.cs
+ Designer
+
UIRealmControl.cs
Designer
diff --git a/Mud Designer/MudEngine/GameObjects/Environment/Door.cs b/Mud Designer/MudEngine/GameObjects/Environment/Door.cs
index d613b88..54752a4 100644
--- a/Mud Designer/MudEngine/GameObjects/Environment/Door.cs
+++ b/Mud Designer/MudEngine/GameObjects/Environment/Door.cs
@@ -56,10 +56,5 @@ namespace MudDesigner.MudEngine.GameObjects.Environment
ConnectedRoom = connectedRoom;
TravelDirection = travelDirection;
}
-
- public override string ToString()
- {
- return this.TravelDirection.ToString();
- }
}
}
diff --git a/Mud Designer/MudEngine/GameObjects/Environment/Room.cs b/Mud Designer/MudEngine/GameObjects/Environment/Room.cs
index 359f606..366f8b3 100644
--- a/Mud Designer/MudEngine/GameObjects/Environment/Room.cs
+++ b/Mud Designer/MudEngine/GameObjects/Environment/Room.cs
@@ -5,6 +5,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
+using System.Drawing.Design;
+
+using MudDesigner.MudEngine.UITypeEditors;
namespace MudDesigner.MudEngine.GameObjects.Environment
{
@@ -36,14 +39,10 @@ namespace MudDesigner.MudEngine.GameObjects.Environment
}
}
- public AvailableTravelDirections Directions
- {
- get;
- set;
- }
-
[Category("Environment Information")]
[Description("Allows for linking of Rooms together via Doorways")]
+ [EditorAttribute(typeof(UIDoorwayEditor), typeof(UITypeEditor))]
+ [RefreshProperties(RefreshProperties.All)]
public List Doorways
{
get;
@@ -77,12 +76,22 @@ namespace MudDesigner.MudEngine.GameObjects.Environment
set;
}
- public Room TestRoom { get; set; }
public Room()
{
Doorways = new List();
IsSafe = false;
}
+
+ public bool DoorwayExist(string travelDirection)
+ {
+ foreach (Door door in Doorways)
+ {
+ if (door.TravelDirection.ToString().ToLower() == travelDirection.ToLower())
+ return true;
+ }
+
+ return false;
+ }
}
}
diff --git a/Mud Designer/MudEngine/UITypeEditors/UIDoorwayControl.Designer.cs b/Mud Designer/MudEngine/UITypeEditors/UIDoorwayControl.Designer.cs
new file mode 100644
index 0000000..4349c4c
--- /dev/null
+++ b/Mud Designer/MudEngine/UITypeEditors/UIDoorwayControl.Designer.cs
@@ -0,0 +1,140 @@
+namespace MudDesigner.MudEngine.UITypeEditors
+{
+ partial class UIDoorwayControl
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.lstInstalledDoors = new System.Windows.Forms.ListBox();
+ this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.btnAddDoorway = new System.Windows.Forms.Button();
+ this.btnRemoveDoorway = new System.Windows.Forms.Button();
+ this.propertyDoorway = new System.Windows.Forms.PropertyGrid();
+ this.groupBox1.SuspendLayout();
+ this.groupBox2.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.lstInstalledDoors);
+ this.groupBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.groupBox1.ForeColor = System.Drawing.Color.Gray;
+ this.groupBox1.Location = new System.Drawing.Point(12, 12);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(256, 220);
+ this.groupBox1.TabIndex = 0;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Installed Doorways";
+ //
+ // lstInstalledDoors
+ //
+ this.lstInstalledDoors.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.lstInstalledDoors.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.lstInstalledDoors.FormattingEnabled = true;
+ this.lstInstalledDoors.Location = new System.Drawing.Point(3, 16);
+ this.lstInstalledDoors.Name = "lstInstalledDoors";
+ this.lstInstalledDoors.Size = new System.Drawing.Size(250, 199);
+ this.lstInstalledDoors.TabIndex = 0;
+ this.lstInstalledDoors.SelectedIndexChanged += new System.EventHandler(this.lstInstalledDoors_SelectedIndexChanged);
+ //
+ // groupBox2
+ //
+ this.groupBox2.Controls.Add(this.propertyDoorway);
+ this.groupBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.groupBox2.ForeColor = System.Drawing.Color.Gray;
+ this.groupBox2.Location = new System.Drawing.Point(306, 12);
+ this.groupBox2.Name = "groupBox2";
+ this.groupBox2.Size = new System.Drawing.Size(270, 249);
+ this.groupBox2.TabIndex = 1;
+ this.groupBox2.TabStop = false;
+ this.groupBox2.Text = "Installed Doorways";
+ //
+ // btnAddDoorway
+ //
+ this.btnAddDoorway.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.btnAddDoorway.Location = new System.Drawing.Point(15, 238);
+ this.btnAddDoorway.Name = "btnAddDoorway";
+ this.btnAddDoorway.Size = new System.Drawing.Size(106, 23);
+ this.btnAddDoorway.TabIndex = 2;
+ this.btnAddDoorway.Text = "Add Doorway";
+ this.btnAddDoorway.UseVisualStyleBackColor = true;
+ this.btnAddDoorway.Click += new System.EventHandler(this.btnAddDoorway_Click);
+ //
+ // btnRemoveDoorway
+ //
+ this.btnRemoveDoorway.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.btnRemoveDoorway.Location = new System.Drawing.Point(159, 238);
+ this.btnRemoveDoorway.Name = "btnRemoveDoorway";
+ this.btnRemoveDoorway.Size = new System.Drawing.Size(106, 23);
+ this.btnRemoveDoorway.TabIndex = 3;
+ this.btnRemoveDoorway.Text = "Remove Doorway";
+ this.btnRemoveDoorway.UseVisualStyleBackColor = true;
+ //
+ // propertyDoorway
+ //
+ this.propertyDoorway.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.propertyDoorway.Location = new System.Drawing.Point(3, 16);
+ this.propertyDoorway.Name = "propertyDoorway";
+ this.propertyDoorway.Size = new System.Drawing.Size(264, 230);
+ this.propertyDoorway.TabIndex = 0;
+ this.propertyDoorway.ToolbarVisible = false;
+ this.propertyDoorway.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyDoorway_PropertyValueChanged);
+ //
+ // UIDoorwayManager
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
+ this.ClientSize = new System.Drawing.Size(591, 270);
+ this.Controls.Add(this.btnRemoveDoorway);
+ this.Controls.Add(this.btnAddDoorway);
+ this.Controls.Add(this.groupBox2);
+ this.Controls.Add(this.groupBox1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "UIDoorwayManager";
+ this.ShowIcon = false;
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "UIDoorwayManager";
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox2.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.ListBox lstInstalledDoors;
+ private System.Windows.Forms.GroupBox groupBox2;
+ private System.Windows.Forms.Button btnAddDoorway;
+ private System.Windows.Forms.Button btnRemoveDoorway;
+ private System.Windows.Forms.PropertyGrid propertyDoorway;
+ }
+}
\ No newline at end of file
diff --git a/Mud Designer/MudEngine/UITypeEditors/UIDoorwayControl.cs b/Mud Designer/MudEngine/UITypeEditors/UIDoorwayControl.cs
new file mode 100644
index 0000000..1254673
--- /dev/null
+++ b/Mud Designer/MudEngine/UITypeEditors/UIDoorwayControl.cs
@@ -0,0 +1,149 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using System.IO;
+
+using MudDesigner.MudEngine.GameObjects;
+using MudDesigner.MudEngine.GameObjects.Environment;
+using MudDesigner.MudEngine.GameManagement;
+using MudDesigner.MudEngine.FileSystem;
+
+namespace MudDesigner.MudEngine.UITypeEditors
+{
+ public partial class UIDoorwayControl : Form
+ {
+ Room _Room;
+ Door _Door;
+
+ public UIDoorwayControl(Room room)
+ {
+ InitializeComponent();
+
+ _Room = new Room();
+ _Room = room;
+
+ foreach (Door d in _Room.Doorways)
+ {
+ lstInstalledDoors.Items.Add(d.TravelDirection.ToString());
+ }
+ }
+
+ private void btnAddDoorway_Click(object sender, EventArgs e)
+ {
+ _Door = new Door();
+ Array directions = Enum.GetValues(typeof(AvailableTravelDirections));
+ bool IsAvailableDirection = true;
+
+ foreach (int direction in directions)
+ {
+ //None value; Don't use the None value when linking rooms.
+ if (direction == 0)
+ continue;
+
+ string availableDirection = Enum.GetName(typeof(AvailableTravelDirections), direction);
+
+ if (_Room.DoorwayExist(availableDirection))
+ IsAvailableDirection = false;
+ else
+ {
+ IsAvailableDirection = true;
+
+ _Door.TravelDirection = (AvailableTravelDirections)Enum.Parse(typeof(AvailableTravelDirections), availableDirection);
+ lstInstalledDoors.Items.Add(_Door.TravelDirection.ToString());
+ _Room.Doorways.Add(_Door);
+ propertyDoorway.SelectedObject = _Door;
+ break;
+ }
+ }
+
+ if (!IsAvailableDirection)
+ {
+ MessageBox.Show("There are no available doorways remaining to add.", "Mud Designer");
+ return;
+ }
+ }
+
+ private void propertyDoorway_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
+ {
+ if (e.ChangedItem.Label == "TravelDirection")
+ {
+ if (e.ChangedItem.Value.ToString() == "None")
+ {
+ MessageBox.Show("This is not a valid Direction.", "Mud Designer");
+ _Door = (Door)propertyDoorway.SelectedObject;
+ _Door.TravelDirection = (AvailableTravelDirections)e.OldValue;
+ propertyDoorway.Refresh();
+ return;
+ }
+ else if (_Room.DoorwayExist(e.ChangedItem.Value.ToString()))
+ {
+ MessageBox.Show("This direction has already been installed into the room. Please select another direction.", "Mud Designer");
+ _Door = (Door)propertyDoorway.SelectedObject;
+ _Door.TravelDirection = (AvailableTravelDirections)e.OldValue;
+ propertyDoorway.Refresh();
+ return;
+ }
+ }
+ else if (e.ChangedItem.Label == "ConnectedRoom")
+ {
+ string zonePath = "";
+
+ if (_Room.Realm == "No Realm Associated.")
+ {
+ zonePath = FileManager.GetDataPath(SaveDataTypes.Zones);
+ }
+ else
+ zonePath = FileManager.GetDataPath(_Room.Realm, _Room.Zone);
+
+ zonePath = Path.Combine(zonePath, _Room.Zone);
+ string roomPath = Path.Combine(zonePath, "Rooms");
+ string roomFile = e.ChangedItem.Value.ToString() + ".Room";
+ string filePath = Path.Combine(roomPath, roomFile);
+
+ if (!File.Exists(filePath))
+ {
+ DialogResult result =
+ MessageBox.Show("Warning! The supplied Room does not exists, would you like the Designer to automatically generate it for you?", "Mud Designer", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
+
+ if (result == DialogResult.No)
+ {
+ _Door = (Door)propertyDoorway.SelectedObject;
+ _Door.ConnectedRoom = (string)e.OldValue;
+ propertyDoorway.Refresh();
+ return;
+ }
+ else
+ {
+ Room r = new Room();
+ r.Name = e.ChangedItem.Value.ToString();
+ r.Realm = _Room.Realm;
+ r.Zone = _Room.Zone;
+ r.Save(Path.Combine(roomPath, r.Filename));
+ }
+
+ }
+ }
+ }
+
+ private void lstInstalledDoors_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ if (lstInstalledDoors.SelectedIndex == -1)
+ return;
+
+ foreach (Door door in _Room.Doorways)
+ {
+ if (door.TravelDirection.ToString() == lstInstalledDoors.SelectedItem.ToString())
+ {
+ _Door = door;
+ propertyDoorway.SelectedObject = _Door;
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/Mud Designer/MudEngine/UITypeEditors/UIDoorwayControl.resx b/Mud Designer/MudEngine/UITypeEditors/UIDoorwayControl.resx
new file mode 100644
index 0000000..ff31a6d
--- /dev/null
+++ b/Mud Designer/MudEngine/UITypeEditors/UIDoorwayControl.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Mud Designer/MudEngine/UITypeEditors/UIDoorwayEditor.cs b/Mud Designer/MudEngine/UITypeEditors/UIDoorwayEditor.cs
new file mode 100644
index 0000000..4a17fe7
--- /dev/null
+++ b/Mud Designer/MudEngine/UITypeEditors/UIDoorwayEditor.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Drawing.Design;
+using System.IO;
+
+using MudDesigner.MudEngine.GameObjects.Environment;
+using MudDesigner.MudEngine.FileSystem;
+
+namespace MudDesigner.MudEngine.UITypeEditors
+{
+ public class UIDoorwayEditor : UITypeEditor
+ {
+ public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
+ {
+ Room room = new Room();
+ room = (Room)context.Instance;
+
+ UIDoorwayControl ctl = new UIDoorwayControl(room);
+ ctl.ShowDialog();
+
+ //Load the Zone that this room belongs to.
+ string zonePath = "";
+
+ if (room.Realm == "No Realm Associated.")
+ {
+ zonePath = FileManager.GetDataPath(SaveDataTypes.Zones);
+ }
+ else
+ {
+ zonePath = FileManager.GetDataPath(room.Realm, room.Zone);
+ }
+
+ zonePath = Path.Combine(zonePath, room.Zone);
+ string zoneFile = Path.Combine(zonePath, room.Zone + ".zone");
+ Zone z = new Zone();
+ z = (Zone)z.Load(zoneFile);
+
+ //Get an instance of the current Room Editor so we can refresh it.
+ //it requires the zone it belongs to, to be passed into the constructor
+ UIRoomControl roomEd =(UIRoomControl)Program.CurrentEditor;
+
+ roomEd.RefreshRoomList();
+
+ return room.Doorways;
+ }
+
+ public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
+ {
+ return System.Drawing.Design.UITypeEditorEditStyle.Modal;
+ }
+ }
+}
diff --git a/Mud Designer/MudEngine/UITypeEditors/UIRoomControl.Designer.cs b/Mud Designer/MudEngine/UITypeEditors/UIRoomControl.Designer.cs
index 654cfa9..8895048 100644
--- a/Mud Designer/MudEngine/UITypeEditors/UIRoomControl.Designer.cs
+++ b/Mud Designer/MudEngine/UITypeEditors/UIRoomControl.Designer.cs
@@ -157,8 +157,8 @@
private System.Windows.Forms.ToolStripButton btnNewRoom;
private System.Windows.Forms.ToolStripLabel toolStripLabel1;
private System.Windows.Forms.ToolStripTextBox txtFindRoom;
- private System.Windows.Forms.ListBox lstRooms;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.PropertyGrid propertyRoom;
+ public System.Windows.Forms.ListBox lstRooms;
}
}
\ No newline at end of file
diff --git a/Mud Designer/MudEngine/UITypeEditors/UIRoomControl.cs b/Mud Designer/MudEngine/UITypeEditors/UIRoomControl.cs
index 3b660a8..534b3bd 100644
--- a/Mud Designer/MudEngine/UITypeEditors/UIRoomControl.cs
+++ b/Mud Designer/MudEngine/UITypeEditors/UIRoomControl.cs
@@ -53,6 +53,8 @@ namespace MudDesigner.MudEngine.UITypeEditors
//Project/Realms/RealmName/Zones/ZoneName/Rooms
savePath = Path.Combine(savePath, "Rooms");
}
+
+ Program.CurrentEditor = this;
}
private bool CheckSavedState()
@@ -89,6 +91,20 @@ namespace MudDesigner.MudEngine.UITypeEditors
IsSaved = true;
}
+ internal void RefreshRoomList()
+ {
+ if (Directory.Exists(savePath))
+ {
+ lstRooms.Items.Clear();
+ string[] files = Directory.GetFiles(savePath);
+
+ foreach (string file in files)
+ {
+ lstRooms.Items.Add(Path.GetFileName(file));
+ }
+ }
+ }
+
private void propertyRoom_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
{
IsSaved = false;
@@ -143,15 +159,7 @@ namespace MudDesigner.MudEngine.UITypeEditors
private void UIRoomControl_Load(object sender, EventArgs e)
{
- if (Directory.Exists(savePath))
- {
- string[] files = Directory.GetFiles(savePath);
-
- foreach (string file in files)
- {
- lstRooms.Items.Add(Path.GetFileName(file));
- }
- }
+ RefreshRoomList();
}
private void lstRooms_MouseDoubleClick(object sender, MouseEventArgs e)
diff --git a/Mud Designer/MudEngine/UITypeEditors/UIRoomEditor.cs b/Mud Designer/MudEngine/UITypeEditors/UIRoomEditor.cs
index 76beb26..0cd1af6 100644
--- a/Mud Designer/MudEngine/UITypeEditors/UIRoomEditor.cs
+++ b/Mud Designer/MudEngine/UITypeEditors/UIRoomEditor.cs
@@ -16,7 +16,6 @@ namespace MudDesigner.MudEngine.UITypeEditors
{
Zone obj = (Zone)context.Instance;
UIRoomControl ctl;
-
ctl = new UIRoomControl(obj);
ctl.ShowDialog();
diff --git a/Mud Designer/Program.cs b/Mud Designer/Program.cs
index d87ecce..0030ae9 100644
--- a/Mud Designer/Program.cs
+++ b/Mud Designer/Program.cs
@@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
+using System.Drawing.Design;
+
//MudEngine
using MudDesigner.MudEngine;
using MudDesigner.MudEngine.FileSystem;
@@ -17,7 +19,8 @@ namespace MudDesigner
static class Program
{
public static Designer Designer{ get; set; }
-
+ internal static Form CurrentEditor { get; set; }
+
///
/// The main entry point for the application.
///