diff --git a/Mud Designer/MudEngine/GameObjects/Environment/Zone.cs b/Mud Designer/MudEngine/GameObjects/Environment/Zone.cs index 589a107..2461217 100644 --- a/Mud Designer/MudEngine/GameObjects/Environment/Zone.cs +++ b/Mud Designer/MudEngine/GameObjects/Environment/Zone.cs @@ -105,7 +105,7 @@ namespace MudDesigner.MudEngine.GameObjects.Environment /// This is a time consuming process if there are a large amount of /// of rooms, use sparingly. /// - public void RefreshRoomList() + public void RebuildRoomCollection() { Rooms = new List(); //Create our collection of Rooms. diff --git a/Mud Designer/MudEngine/UITypeEditors/UIDoorwayControl.cs b/Mud Designer/MudEngine/UITypeEditors/UIDoorwayControl.cs index a07dfd3..e525adf 100644 --- a/Mud Designer/MudEngine/UITypeEditors/UIDoorwayControl.cs +++ b/Mud Designer/MudEngine/UITypeEditors/UIDoorwayControl.cs @@ -107,7 +107,7 @@ namespace MudDesigner.MudEngine.UITypeEditors if (!File.Exists(filePath)) { - DialogResult result = + 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) @@ -127,7 +127,16 @@ namespace MudDesigner.MudEngine.UITypeEditors r.Doorways.Add(d); r.Save(Path.Combine(roomPath, r.Filename)); } - + } + else + { + Room r = new Room(); + r.Name = e.ChangedItem.Value.ToString(); + r.Realm = _Room.Realm; + r.Zone = _Room.Zone; + Door d = new Door(TravelDirections.GetReverseDirection(_Door.TravelDirection), _Room.Name); + r.Doorways.Add(d); + r.Save(Path.Combine(roomPath, r.Filename)); } } } diff --git a/Mud Designer/MudEngine/UITypeEditors/UIRoomControl.Designer.cs b/Mud Designer/MudEngine/UITypeEditors/UIRoomControl.Designer.cs index 8895048..d546c60 100644 --- a/Mud Designer/MudEngine/UITypeEditors/UIRoomControl.Designer.cs +++ b/Mud Designer/MudEngine/UITypeEditors/UIRoomControl.Designer.cs @@ -141,6 +141,7 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Room Designer"; this.Load += new System.EventHandler(this.UIRoomControl_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.UIRoomControl_FormClosing); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.toolStrip1.ResumeLayout(false); diff --git a/Mud Designer/MudEngine/UITypeEditors/UIRoomControl.cs b/Mud Designer/MudEngine/UITypeEditors/UIRoomControl.cs index 2e78e61..8d9de48 100644 --- a/Mud Designer/MudEngine/UITypeEditors/UIRoomControl.cs +++ b/Mud Designer/MudEngine/UITypeEditors/UIRoomControl.cs @@ -137,6 +137,29 @@ namespace MudDesigner.MudEngine.UITypeEditors File.Delete(Path.Combine(savePath, fullFilename)); lstRooms.Items.RemoveAt(lstRooms.Items.IndexOf(e.OldValue + ".Room")); } + + //loop through each doorway in the current room + //we will need to update the connected Rooms incase this room changes + //its roomname + foreach (Door d in _Room.Doorways) + { + //Load the connected room + Room r = new Room(); + fullFilename = Path.Combine(savePath, d.ConnectedRoom + ".room"); + r = (Room)r.Load(fullFilename); + //Loop though each of its doorways to see if any of them are attached + //to are old room name + foreach (Door renamedDoor in r.Doorways) + { + if (renamedDoor.ConnectedRoom == e.OldValue.ToString()) + { + //Change the old room name to the new room name + renamedDoor.ConnectedRoom = _Room.Name; + } + } + //All the doorways for this room have been corrected, now save it. + r.Save(fullFilename); + } } } @@ -191,5 +214,11 @@ namespace MudDesigner.MudEngine.UITypeEditors _Room = (Room)_Room.Load(roomFile); propertyRoom.SelectedObject = _Room; } + + private void UIRoomControl_FormClosing(object sender, FormClosingEventArgs e) + { + if (!CheckSavedState()) + e.Cancel = true; + } } } diff --git a/Mud Designer/MudEngine/UITypeEditors/UIRoomEditor.cs b/Mud Designer/MudEngine/UITypeEditors/UIRoomEditor.cs index 0cd1af6..21816dd 100644 --- a/Mud Designer/MudEngine/UITypeEditors/UIRoomEditor.cs +++ b/Mud Designer/MudEngine/UITypeEditors/UIRoomEditor.cs @@ -5,8 +5,10 @@ using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing.Design; +using System.IO; using MudDesigner.MudEngine.GameObjects.Environment; +using MudDesigner.MudEngine.FileSystem; namespace MudDesigner.MudEngine.UITypeEditors { @@ -18,6 +20,23 @@ namespace MudDesigner.MudEngine.UITypeEditors UIRoomControl ctl; ctl = new UIRoomControl(obj); + string zonePath = ""; + if (obj.Realm == "No Realm Associated.") + { + zonePath = FileManager.GetDataPath(SaveDataTypes.Zones); + zonePath = Path.Combine(zonePath, obj.Name); + } + else + zonePath = FileManager.GetDataPath(obj.Realm, obj.Name); + + string filename = Path.Combine(zonePath, obj.Filename); + + if (!File.Exists(filename)) + { + MessageBox.Show("You must save the Zone prior to managing it's Rooms", "Mud Designer", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return obj.Rooms; + } + ctl.ShowDialog(); return ctl.Rooms; diff --git a/Mud Designer/Program.cs b/Mud Designer/Program.cs index 0030ae9..f7294cd 100644 --- a/Mud Designer/Program.cs +++ b/Mud Designer/Program.cs @@ -33,6 +33,8 @@ namespace MudDesigner //Run the toolkit Designer = new Designer(); + MessageBox.Show("Please note that objects are auto-saved, but they are only saved after the objects name has been changed from the default value of 'New Object'", "Mud Designer"); + Application.Run(Designer); } }