Mud Designer:
- Auto-saving objects is now complete. - Removed Save Object button - Object Properties no longer displays the Project Information on startup - Objects that can be edited within the Designer are displayed in Blue in the treeview - Objects that can only be edited within another objects Mini-Editor are displayed in Red and cannot be edited within the main Designer - Folders are displayed in Black - Objects are not auto-saved until the objects Name is changed from 'New Object' - The designer checks to see if the object has been saved yet prior to creating a new object. - Double clicking an editable object (shown in blue text) now loads the object for editing. - Menu item Project->Game Objects->Environment->New Room opens the Zones Mini-Room Editor if a Zone is loaded. - Tooltips added to the Project Explorer and Object Properties panes Mud Engine: - FileManager returns the new directory layout when using GetDataPath - Added Zones to SaveDataTypes enum. - Game Objects now have a Description attribute attached to their public properties so the Designer can display a description of what the property is for within the Object Properties pane. - Added PreCacheObjects Boolean to ProjectInformation for pre-loading objects when the runtime is built. - All objects Filename is now set to readonly and cannot be edited within the Designer - Started work on Realm.GetZone() method. - Room.Zone is no longer hidden from the Object Properties Pane, but set to Readonly. - Began work on Moving a Zones Rooms when a Zone is moved within a Realm. - Removed un-needed code within the RealmEditor - UIRoomControl now creates and saves Rooms. Duplicate Rooms cannot be created and Room re-naming is implemented. - Removed remaining old code for previous Mud Designer Editors from within Program.cs
This commit is contained in:
parent
ecd2645421
commit
98857cc0de
19 changed files with 776 additions and 451 deletions
|
@ -18,8 +18,14 @@ namespace MudDesigner
|
|||
{
|
||||
public partial class Designer : Form
|
||||
{
|
||||
enum ObjectType
|
||||
{
|
||||
Zone,
|
||||
Room,
|
||||
}
|
||||
ProjectInformation _Project;
|
||||
BaseObject _GameObject;
|
||||
bool IsSaved;
|
||||
|
||||
public Designer()
|
||||
{
|
||||
|
@ -29,6 +35,7 @@ namespace MudDesigner
|
|||
//for use during our runtime
|
||||
_GameObject = new BaseObject();
|
||||
_Project = new ProjectInformation();
|
||||
IsSaved = true;
|
||||
|
||||
//Get out saved project file
|
||||
string projectPath = Path.Combine(Application.StartupPath, "Project");
|
||||
|
@ -51,9 +58,6 @@ namespace MudDesigner
|
|||
title.Append(_Project.Version);
|
||||
this.Text = title.ToString();
|
||||
|
||||
//Assign our Project Information to the propertygrid
|
||||
propertyObject.SelectedObject = _Project;
|
||||
|
||||
//build a collection of Realms for viewing
|
||||
InstallWidgetRealms(projectPath);
|
||||
}
|
||||
|
@ -65,7 +69,325 @@ namespace MudDesigner
|
|||
containerMain.Panel1.Controls.Add(new UIWidgets.RealmExplorer().InstallControl(projectPath));
|
||||
}
|
||||
|
||||
private void btnSaveObject_Click(object sender, EventArgs e)
|
||||
private void LoadObject(TreeNode selectedNode)
|
||||
{
|
||||
string projectPath = Path.Combine(Application.StartupPath, "Project");
|
||||
string objectFilename = "";
|
||||
|
||||
if (selectedNode.Text == "Project")
|
||||
{
|
||||
MessageBox.Show("You cannot edit the Project node in the Project Explorer.");
|
||||
return;
|
||||
}
|
||||
|
||||
//for root objects
|
||||
if (selectedNode.Parent.Text == "Project")
|
||||
{
|
||||
if (selectedNode.Text == "Game.xml")
|
||||
{
|
||||
objectFilename = selectedNode.FullPath;
|
||||
ProjectInformation project = new ProjectInformation();
|
||||
project = (ProjectInformation)FileManager.Load(objectFilename, project);
|
||||
lblObjectProperties.Text = "Project Properties (" + project.GameTitle + ")";
|
||||
propertyObject.SelectedObject = project;
|
||||
}
|
||||
}
|
||||
else if (selectedNode.Parent.Text == "Currencies")
|
||||
{
|
||||
objectFilename = selectedNode.FullPath;
|
||||
Currency currency = new Currency();
|
||||
currency = (Currency)FileManager.Load(objectFilename, currency);
|
||||
lblObjectProperties.Text = "Currency Properties (" + currency.Name + ")";
|
||||
propertyObject.SelectedObject = currency;
|
||||
}
|
||||
else if (selectedNode.Parent.Parent.Text == "Realms")
|
||||
{
|
||||
objectFilename = selectedNode.FullPath;
|
||||
//incase a directory was selected instead of a file to be edited.
|
||||
if (Path.GetExtension(objectFilename) == "")
|
||||
return;
|
||||
|
||||
Realm realm = new Realm();
|
||||
realm= (Realm)FileManager.Load(objectFilename, realm);
|
||||
lblObjectProperties.Text = "Realm Properties (" + realm.Name + ")";
|
||||
propertyObject.SelectedObject = realm;
|
||||
}
|
||||
else if (selectedNode.Parent.Parent.Text == "Zones")
|
||||
{
|
||||
//Zone selected already contained within a Realm
|
||||
objectFilename = selectedNode.FullPath;
|
||||
Zone z = new Zone();
|
||||
|
||||
//incase a directory was selected instead of a file to be edited.
|
||||
if (Path.GetExtension(objectFilename) == "")
|
||||
return;
|
||||
Zone zone = new Zone();
|
||||
zone= (Zone)FileManager.Load(objectFilename, zone);
|
||||
lblObjectProperties.Text = "Zone Properties (" + zone.Name + ")";
|
||||
propertyObject.SelectedObject = zone;
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidatePath(string path)
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
string projectPath = Path.Combine(Application.StartupPath, "Project");
|
||||
|
||||
RefreshProjectExplorer();
|
||||
}
|
||||
|
||||
private void PopulateTree(string dir, TreeNode node)
|
||||
{
|
||||
// get the information of the directory
|
||||
DirectoryInfo directory = new DirectoryInfo(dir);
|
||||
|
||||
// loop through each subdirectory
|
||||
foreach (DirectoryInfo d in directory.GetDirectories())
|
||||
{
|
||||
// create a new node
|
||||
TreeNode t = new TreeNode(d.Name);
|
||||
// populate the new node recursively
|
||||
PopulateTree(d.FullName, t);
|
||||
node.Nodes.Add(t); // add the node to the "master" node
|
||||
}
|
||||
// lastly, loop through each file in the directory, and add these as nodes
|
||||
foreach (FileInfo f in directory.GetFiles())
|
||||
{
|
||||
// create a new node
|
||||
TreeNode t = new TreeNode(f.Name);
|
||||
// add it to the "master"
|
||||
t.ForeColor = System.Drawing.Color.Blue;
|
||||
|
||||
if (node.Text == "Rooms")
|
||||
t.ForeColor = System.Drawing.Color.Red;
|
||||
node.Nodes.Add(t);
|
||||
}
|
||||
|
||||
treeExplorer.SelectedNode = node;
|
||||
}
|
||||
|
||||
private void btnRefreshObjects_Click(object sender, EventArgs e)
|
||||
{
|
||||
treeExplorer.Nodes.Clear();
|
||||
TreeNode node = new TreeNode("Project");
|
||||
treeExplorer.Nodes.Add(node);
|
||||
string projectPath = Path.Combine(Application.StartupPath, "Project");
|
||||
PopulateTree(projectPath, node);
|
||||
}
|
||||
|
||||
private void mnuEditObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (CheckSavedState())
|
||||
LoadObject(treeExplorer.SelectedNode);
|
||||
}
|
||||
|
||||
private void mnuProjectInformation_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (CheckSavedState())
|
||||
propertyObject.SelectedObject = _Project;
|
||||
}
|
||||
|
||||
private void mnuRealmEditor_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (CheckSavedState())
|
||||
propertyObject.SelectedObject = new Realm();
|
||||
}
|
||||
|
||||
private void currencyEditorToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (CheckSavedState())
|
||||
propertyObject.SelectedObject = new Currency();
|
||||
}
|
||||
|
||||
private void mnuZoneBuilder_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (CheckSavedState())
|
||||
propertyObject.SelectedObject = new Zone();
|
||||
}
|
||||
|
||||
private bool CheckSavedState()
|
||||
{
|
||||
if (IsSaved)
|
||||
return true;
|
||||
|
||||
DialogResult result = MessageBox.Show(lblObjectProperties.Text + " has not been saved! Do you wish to save it?", "Mud Designer", MessageBoxButtons.YesNoCancel);
|
||||
|
||||
if (result == DialogResult.No)
|
||||
return true;
|
||||
else if (result == DialogResult.Cancel)
|
||||
return false;
|
||||
else
|
||||
SaveSelected();
|
||||
|
||||
return true;
|
||||
}
|
||||
private void txtSearch_Enter(object sender, EventArgs e)
|
||||
{
|
||||
if (txtSearch.Text == "")
|
||||
return;
|
||||
|
||||
TreeNode node = FindNode(txtSearch.Text, treeExplorer.Nodes[0]);
|
||||
if (node == null)
|
||||
MessageBox.Show("No results found!", "Mud Designer");
|
||||
else
|
||||
{
|
||||
//TODO select the node
|
||||
}
|
||||
}
|
||||
|
||||
private TreeNode FindNode(string nodeText, TreeNode startNode)
|
||||
{
|
||||
foreach (TreeNode node in startNode.Nodes)
|
||||
{
|
||||
if (node.Text == nodeText)
|
||||
{
|
||||
return node;
|
||||
}
|
||||
if (node.Nodes.Count != 0)
|
||||
{
|
||||
TreeNode n = FindNode(nodeText, node);
|
||||
if (n == null) continue;
|
||||
else return n;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void deleteObjectToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
//Check if we are trying to delete the root node
|
||||
if (treeExplorer.SelectedNode.Text == "Project")
|
||||
{
|
||||
MessageBox.Show("You cannot delete the root item 'Project'", "Mud Designer");
|
||||
return;
|
||||
}
|
||||
|
||||
DialogResult result;
|
||||
ObjectType objectType = new ObjectType();
|
||||
|
||||
//Check if we are deleting a realm or zone, if so inform the user that
|
||||
//all zones/rooms within the object will be deleted as well.
|
||||
string fullPath = treeExplorer.SelectedNode.FullPath;
|
||||
TreeNode selectedNode = treeExplorer.SelectedNode;
|
||||
|
||||
if (fullPath.Contains("Realms") || fullPath.Contains("Zones"))
|
||||
{
|
||||
//ask if we want to delete this
|
||||
result = MessageBox.Show("Are you sure you want to delete"
|
||||
+ treeExplorer.SelectedNode.Text + "?\nAll Rooms or Zones within this item will be deleted!", "Mud Designer", MessageBoxButtons.YesNo);
|
||||
}
|
||||
else
|
||||
//ask if we want to delete this
|
||||
result = MessageBox.Show("Are you sure you want to delete"
|
||||
+ treeExplorer.SelectedNode.Text + "?", "Mud Designer", MessageBoxButtons.YesNo);
|
||||
|
||||
//User hit no, cancel
|
||||
if (result == DialogResult.No)
|
||||
return;
|
||||
|
||||
//Find out what we are deleting
|
||||
if (Path.GetExtension(fullPath) == "")
|
||||
{
|
||||
if (selectedNode.Text == "Zones")
|
||||
objectType = ObjectType.Zone;
|
||||
else if (selectedNode.Text == "Rooms")
|
||||
objectType = ObjectType.Room;
|
||||
}
|
||||
else if (Path.GetExtension(fullPath) == ".Room")
|
||||
{
|
||||
objectType = ObjectType.Room;
|
||||
}
|
||||
else if (Path.GetExtension(fullPath) == "Zone")
|
||||
{
|
||||
objectType = ObjectType.Zone;
|
||||
}
|
||||
|
||||
if (objectType == ObjectType.Zone)
|
||||
{
|
||||
Zone z = new Zone();
|
||||
string filename = Path.Combine(Application.StartupPath, treeExplorer.SelectedNode.FullPath);
|
||||
if (Path.GetExtension(treeExplorer.SelectedNode.FullPath) == "")
|
||||
{
|
||||
string[] zone = Directory.GetFiles(filename, "*.zone");
|
||||
if (zone.Length != 0)
|
||||
{
|
||||
filename = zone[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
Directory.Delete(treeExplorer.SelectedNode.FullPath, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
z = (Zone)FileManager.Load(filename, z);
|
||||
if (z.Realm != "")
|
||||
{
|
||||
string projectPath = Path.Combine(Application.StartupPath, "Project");
|
||||
string[] files = Directory.GetFiles(Path.Combine(projectPath, "Realms"), "*.realm", SearchOption.AllDirectories);
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
Realm r = new Realm();
|
||||
r = (Realm)FileManager.Load(file, r);
|
||||
if (r.Name == z.Realm)
|
||||
{
|
||||
r.Zones.Remove(z.Filename);
|
||||
FileManager.Save(file, r);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}//end if(object is zone)
|
||||
else if (objectType == ObjectType.Room)
|
||||
{
|
||||
//TODO Delete rooms from owning zone
|
||||
}
|
||||
|
||||
//Its a directory to delete if we have no extension assigned to it
|
||||
if (Path.GetExtension(treeExplorer.SelectedNode.FullPath) == "")
|
||||
{
|
||||
Directory.Delete(Path.Combine(Application.StartupPath, treeExplorer.SelectedNode.FullPath), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
string filename = Path.GetFileName(treeExplorer.SelectedNode.FullPath);
|
||||
fullPath = treeExplorer.SelectedNode.FullPath;
|
||||
string deletePath = fullPath.Substring(0, fullPath.Length - filename.Length);
|
||||
File.Delete(Path.Combine(Application.StartupPath, treeExplorer.SelectedNode.FullPath));
|
||||
Directory.Delete(Path.Combine(Application.StartupPath, deletePath), true);
|
||||
}
|
||||
//Just incase we have the zone or the realm selected that the zone belonged too.
|
||||
//users can re-save the current realm and if it contained the zone we just deleted
|
||||
//the zone will be still be saved as part of the realm.
|
||||
propertyObject.SelectedObject = null;
|
||||
RefreshProjectExplorer();
|
||||
}
|
||||
|
||||
public void RefreshProjectExplorer()
|
||||
{
|
||||
btnRefreshObjects_Click(null, null);
|
||||
}
|
||||
|
||||
private void propertyObject_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
|
||||
{
|
||||
IsSaved = false;
|
||||
if (propertyObject.SelectedObject is BaseObject)
|
||||
{
|
||||
BaseObject obj = (BaseObject)propertyObject.SelectedObject;
|
||||
|
||||
//Don't auto-save if we haven't assigned a valid name
|
||||
if (obj.Name == "New " + obj.GetType().Name)
|
||||
return;
|
||||
}
|
||||
SaveSelected();
|
||||
IsSaved = true;
|
||||
RefreshProjectExplorer();
|
||||
}
|
||||
|
||||
public void SaveSelected()
|
||||
{
|
||||
//Get the object Type
|
||||
Type t = propertyObject.SelectedObject.GetType();
|
||||
|
@ -126,266 +448,6 @@ namespace MudDesigner
|
|||
RefreshProjectExplorer();
|
||||
}
|
||||
|
||||
private void LoadObject(TreeNode selectedNode)
|
||||
{
|
||||
string projectPath = Path.Combine(Application.StartupPath, "Project");
|
||||
string objectFilename = "";
|
||||
|
||||
if (selectedNode.Text == "Project")
|
||||
{
|
||||
MessageBox.Show("You cannot edit the Project node in the Project Explorer.");
|
||||
return;
|
||||
}
|
||||
|
||||
//for root objects
|
||||
if (selectedNode.Parent.Text == "Project")
|
||||
{
|
||||
if (selectedNode.Text == "Game.xml")
|
||||
{
|
||||
objectFilename = selectedNode.FullPath;
|
||||
ProjectInformation project = new ProjectInformation();
|
||||
project = (ProjectInformation)FileManager.Load(objectFilename, project);
|
||||
lblObjectProperties.Text = "Project Properties (" + project.GameTitle + ")";
|
||||
propertyObject.SelectedObject = project;
|
||||
}
|
||||
}
|
||||
else if (selectedNode.Parent.Text == "Currencies")
|
||||
{
|
||||
objectFilename = selectedNode.FullPath;
|
||||
Currency currency = new Currency();
|
||||
currency = (Currency)FileManager.Load(objectFilename, currency);
|
||||
lblObjectProperties.Text = "Currency Properties (" + currency.Name + ")";
|
||||
propertyObject.SelectedObject = currency;
|
||||
}
|
||||
else if (selectedNode.Parent.Parent.Text == "Realms")
|
||||
{
|
||||
objectFilename = selectedNode.FullPath;
|
||||
//incase a directory was selected instead of a file to be edited.
|
||||
if (Path.GetExtension(objectFilename) == "")
|
||||
return;
|
||||
|
||||
Realm realm = new Realm();
|
||||
realm= (Realm)FileManager.Load(objectFilename, realm);
|
||||
lblObjectProperties.Text = "Realm Properties (" + realm.Name + ")";
|
||||
propertyObject.SelectedObject = realm;
|
||||
}
|
||||
else if (selectedNode.Parent.Parent.Text == "Zones")
|
||||
{
|
||||
//Zone selected already contained within a Realm
|
||||
objectFilename = selectedNode.FullPath;
|
||||
|
||||
//incase a directory was selected instead of a file to be edited.
|
||||
if (Path.GetExtension(objectFilename) == "")
|
||||
return;
|
||||
Zone zone = new Zone();
|
||||
zone= (Zone)FileManager.Load(objectFilename, zone);
|
||||
lblObjectProperties.Text = "Zone Properties (" + zone.Name + ")";
|
||||
propertyObject.SelectedObject = zone;
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidatePath(string path)
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
string projectPath = Path.Combine(Application.StartupPath, "Project");
|
||||
|
||||
RefreshProjectExplorer();
|
||||
}
|
||||
|
||||
private void PopulateTree(string dir, TreeNode node)
|
||||
{
|
||||
// get the information of the directory
|
||||
DirectoryInfo directory = new DirectoryInfo(dir);
|
||||
|
||||
// loop through each subdirectory
|
||||
foreach (DirectoryInfo d in directory.GetDirectories())
|
||||
{
|
||||
// create a new node
|
||||
TreeNode t = new TreeNode(d.Name);
|
||||
// populate the new node recursively
|
||||
PopulateTree(d.FullName, t);
|
||||
node.Nodes.Add(t); // add the node to the "master" node
|
||||
}
|
||||
// lastly, loop through each file in the directory, and add these as nodes
|
||||
foreach (FileInfo f in directory.GetFiles())
|
||||
{
|
||||
// create a new node
|
||||
TreeNode t = new TreeNode(f.Name);
|
||||
// add it to the "master"
|
||||
t.ForeColor = System.Drawing.Color.Blue;
|
||||
node.Nodes.Add(t);
|
||||
}
|
||||
|
||||
treeExplorer.SelectedNode = node;
|
||||
}
|
||||
|
||||
private void btnRefreshObjects_Click(object sender, EventArgs e)
|
||||
{
|
||||
treeExplorer.Nodes.Clear();
|
||||
TreeNode node = new TreeNode("Project");
|
||||
treeExplorer.Nodes.Add(node);
|
||||
string projectPath = Path.Combine(Application.StartupPath, "Project");
|
||||
PopulateTree(projectPath, node);
|
||||
}
|
||||
|
||||
private void mnuEditObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadObject(treeExplorer.SelectedNode);
|
||||
}
|
||||
|
||||
private void mnuProjectInformation_Click(object sender, EventArgs e)
|
||||
{
|
||||
propertyObject.SelectedObject = _Project;
|
||||
}
|
||||
|
||||
private void mnuRealmEditor_Click(object sender, EventArgs e)
|
||||
{
|
||||
propertyObject.SelectedObject = new Realm();
|
||||
}
|
||||
|
||||
private void currencyEditorToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
propertyObject.SelectedObject = new Currency();
|
||||
}
|
||||
|
||||
private void mnuZoneBuilder_Click(object sender, EventArgs e)
|
||||
{
|
||||
propertyObject.SelectedObject = new Zone();
|
||||
}
|
||||
|
||||
private void txtSearch_Enter(object sender, EventArgs e)
|
||||
{
|
||||
if (txtSearch.Text == "")
|
||||
return;
|
||||
|
||||
TreeNode node = FindNode(txtSearch.Text, treeExplorer.Nodes[0]);
|
||||
if (node == null)
|
||||
MessageBox.Show("No results found!", "Mud Designer");
|
||||
else
|
||||
{
|
||||
//TODO select the node
|
||||
}
|
||||
}
|
||||
|
||||
private TreeNode FindNode(string nodeText, TreeNode startNode)
|
||||
{
|
||||
foreach (TreeNode node in startNode.Nodes)
|
||||
{
|
||||
if (node.Text == nodeText)
|
||||
{
|
||||
return node;
|
||||
}
|
||||
if (node.Nodes.Count != 0)
|
||||
{
|
||||
TreeNode n = FindNode(nodeText, node);
|
||||
if (n == null) continue;
|
||||
else return n;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void deleteObjectToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (treeExplorer.SelectedNode.Text == "Project")
|
||||
{
|
||||
MessageBox.Show("You cannot delete the root item 'Project'", "Mud Designer");
|
||||
return;
|
||||
}
|
||||
DialogResult result;
|
||||
bool IsZone = false;
|
||||
//Check if we are deleting a realm or zone, if so inform the user that
|
||||
//all zones/rooms within the object will be deleted as well.
|
||||
if (treeExplorer.SelectedNode.FullPath.Contains("Realms") || treeExplorer.SelectedNode.FullPath.Contains("Zones"))
|
||||
{
|
||||
result = MessageBox.Show("Are you sure you want to delete"
|
||||
+ treeExplorer.SelectedNode.Text + "?\nAll Rooms or Zones within this item will be deleted!", "Mud Designer", MessageBoxButtons.YesNo);
|
||||
if (treeExplorer.SelectedNode.FullPath.Contains("Zones"))
|
||||
IsZone = true;
|
||||
}
|
||||
else
|
||||
result = MessageBox.Show("Are you sure you want to delete"
|
||||
+ treeExplorer.SelectedNode.Text + "?", "Mud Designer", MessageBoxButtons.YesNo);
|
||||
|
||||
if (result == DialogResult.No)
|
||||
return;
|
||||
|
||||
if (IsZone)
|
||||
{
|
||||
Zone z = new Zone();
|
||||
string filename = Path.Combine(Application.StartupPath, treeExplorer.SelectedNode.FullPath);
|
||||
if (Path.GetExtension(treeExplorer.SelectedNode.FullPath) == "")
|
||||
{
|
||||
string[] zone = Directory.GetFiles(filename, "*.zone");
|
||||
if (zone.Length != 0)
|
||||
{
|
||||
filename = zone[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
Directory.Delete(treeExplorer.SelectedNode.FullPath, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
z = (Zone)FileManager.Load(filename, z);
|
||||
if (z.Realm != "")
|
||||
{
|
||||
string projectPath = Path.Combine(Application.StartupPath, "Project");
|
||||
string[] files = Directory.GetFiles(Path.Combine(projectPath, "Realms"), "*.realm", SearchOption.AllDirectories);
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
Realm r = new Realm();
|
||||
r = (Realm)FileManager.Load(file, r);
|
||||
if (r.Name == z.Realm)
|
||||
{
|
||||
r.Zones.Remove(z.Filename);
|
||||
FileManager.Save(file, r);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Its a directory to delete if we have no extension assigned to it
|
||||
if (Path.GetExtension(treeExplorer.SelectedNode.FullPath) == "")
|
||||
{
|
||||
Directory.Delete(Path.Combine(Application.StartupPath, treeExplorer.SelectedNode.FullPath), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
string filename = Path.GetFileName(treeExplorer.SelectedNode.FullPath);
|
||||
string fullPath = treeExplorer.SelectedNode.FullPath;
|
||||
string deletePath = fullPath.Substring(0, fullPath.Length - filename.Length);
|
||||
File.Delete(Path.Combine(Application.StartupPath, treeExplorer.SelectedNode.FullPath));
|
||||
Directory.Delete(deletePath, true);
|
||||
}
|
||||
//Just incase we have the zone or the realm selected that the zone belonged too.
|
||||
//users can re-save the current realm and if it contained the zone we just deleted
|
||||
//the zone will be still be saved as part of the realm.
|
||||
propertyObject.SelectedObject = null;
|
||||
RefreshProjectExplorer();
|
||||
}
|
||||
|
||||
public void RefreshProjectExplorer()
|
||||
{
|
||||
btnRefreshObjects_Click(null, null);
|
||||
}
|
||||
|
||||
private void propertyObject_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
|
||||
{
|
||||
SaveSelected();
|
||||
RefreshProjectExplorer();
|
||||
}
|
||||
|
||||
public void SaveSelected()
|
||||
{
|
||||
btnSaveObject_Click(null, null);
|
||||
}
|
||||
|
||||
private void mnuAbout_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("Mud Designer.\n\nDownload at http://MudDesigner.Codeplex.com\n"
|
||||
|
@ -396,5 +458,28 @@ namespace MudDesigner
|
|||
{
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
private void treeExplorer_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
if (treeExplorer.SelectedNode.Text == "Project")
|
||||
return;
|
||||
mnuEditObject_Click(sender, e);
|
||||
}
|
||||
|
||||
private void newRoomToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (propertyObject.SelectedObject is Zone)
|
||||
{
|
||||
MudDesigner.MudEngine.UITypeEditors.UIRoomControl control = new MudDesigner.MudEngine.UITypeEditors.UIRoomControl((Zone)propertyObject.SelectedObject);
|
||||
|
||||
control.ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("You must have a zone loaded prior to attempting to create a Room!\n\n"
|
||||
+ "You can use a loaded Zones 'Rooms' property via the Object Properties pane to create and manage Rooms as well.", "Mud Designer");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue