- Zone.RefreshRoomList method was renamed to Zone.RebuildRoomCollection.

Designer:
 - Room Editor now adjusts all of a Rooms connected doorways to connect to a re-named Room. No need to manually load and edit each Room connected to 'Bedroom' after it was renamed from 'New Room'
This commit is contained in:
Scionwest_cp 2010-01-28 18:56:58 -08:00
parent 5f9a707b4c
commit 2ec31c0170
6 changed files with 63 additions and 3 deletions

View file

@ -105,7 +105,7 @@ namespace MudDesigner.MudEngine.GameObjects.Environment
/// This is a time consuming process if there are a large amount of /// This is a time consuming process if there are a large amount of
/// of rooms, use sparingly. /// of rooms, use sparingly.
/// </summary> /// </summary>
public void RefreshRoomList() public void RebuildRoomCollection()
{ {
Rooms = new List<Room>(); Rooms = new List<Room>();
//Create our collection of Rooms. //Create our collection of Rooms.

View file

@ -127,7 +127,16 @@ namespace MudDesigner.MudEngine.UITypeEditors
r.Doorways.Add(d); r.Doorways.Add(d);
r.Save(Path.Combine(roomPath, r.Filename)); 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));
} }
} }
} }

View file

@ -141,6 +141,7 @@
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Room Designer"; this.Text = "Room Designer";
this.Load += new System.EventHandler(this.UIRoomControl_Load); this.Load += new System.EventHandler(this.UIRoomControl_Load);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.UIRoomControl_FormClosing);
this.groupBox1.ResumeLayout(false); this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout(); this.groupBox1.PerformLayout();
this.toolStrip1.ResumeLayout(false); this.toolStrip1.ResumeLayout(false);

View file

@ -137,6 +137,29 @@ namespace MudDesigner.MudEngine.UITypeEditors
File.Delete(Path.Combine(savePath, fullFilename)); File.Delete(Path.Combine(savePath, fullFilename));
lstRooms.Items.RemoveAt(lstRooms.Items.IndexOf(e.OldValue + ".Room")); 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); _Room = (Room)_Room.Load(roomFile);
propertyRoom.SelectedObject = _Room; propertyRoom.SelectedObject = _Room;
} }
private void UIRoomControl_FormClosing(object sender, FormClosingEventArgs e)
{
if (!CheckSavedState())
e.Cancel = true;
}
} }
} }

View file

@ -5,8 +5,10 @@ using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Drawing.Design; using System.Drawing.Design;
using System.IO;
using MudDesigner.MudEngine.GameObjects.Environment; using MudDesigner.MudEngine.GameObjects.Environment;
using MudDesigner.MudEngine.FileSystem;
namespace MudDesigner.MudEngine.UITypeEditors namespace MudDesigner.MudEngine.UITypeEditors
{ {
@ -18,6 +20,23 @@ namespace MudDesigner.MudEngine.UITypeEditors
UIRoomControl ctl; UIRoomControl ctl;
ctl = new UIRoomControl(obj); 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(); ctl.ShowDialog();
return ctl.Rooms; return ctl.Rooms;

View file

@ -33,6 +33,8 @@ namespace MudDesigner
//Run the toolkit //Run the toolkit
Designer = new Designer(); 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); Application.Run(Designer);
} }
} }