Engine:
- 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:
parent
5f9a707b4c
commit
2ec31c0170
6 changed files with 63 additions and 3 deletions
|
@ -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.
|
||||
/// </summary>
|
||||
public void RefreshRoomList()
|
||||
public void RebuildRoomCollection()
|
||||
{
|
||||
Rooms = new List<Room>();
|
||||
//Create our collection of Rooms.
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue