Test Designer:
- UIControls namespace renamed to UIWidgets - RealmExplorer Control renamed to RealmWidget - RealmWidget now handles scanning and populating the Widget with existing realms rather than the designer handling it. - Object saving re-wrote - Zone Creation implemented - Adding Zones to Realms implemented - Removal of Zones from within Realms implemented - Support for stand-alone Zones added. Unlike the previous version of the 'Mud Designer Realm Explorer & Zone Builder', Zones can be built without being placed within a Realm - Deleting a Zone removes it from the Realms collection - Custom UITypeEditor added for adding Zones to Realms. - Menu item Project->Game Management has been re-structured - Saved file extensions on objects changed from .XML back to .ObjectType (example .realm) - RefreshProjectExplorer method added for refreshing the project explorer's directory structure - All calls to btnRefreshObjects_Click has been replaced with RefreshProjectExplorer() - The Project Explorer can now delete any object (file or folder) underneath the Project Root node. - The Project Explorer now has the files it contains highlighted as blue to help readability. - Changed the Project Explorer's root object from "Game Objects" to "Project" - Began implementation of the Project Explorer's search feature. - SaveSelected method added to save the current object contained within the property grid. - Anytime an Objects Property is changed the designer now automatically saves the object. - Object Properties label now displays the Type of object being edited and the objects name (Example 'Zone Properties (Village of Tespa)') Mud Designer: - The New Test Designer has been set as the startup object, as the old designer toolkit is being phased out. Mud Engine: - Added UIRealmControl class, a custom control used by the designer to edit the Realm.Zones property. - UIRealmEditor class added, manages the UIRealmControl.
This commit is contained in:
parent
83311d4200
commit
ae672a29e1
14 changed files with 765 additions and 267 deletions
|
@ -61,33 +61,8 @@ namespace MudDesigner
|
|||
private void InstallWidgetRealms(string projectPath)
|
||||
{
|
||||
ValidatePath(Path.Combine(projectPath, "Realms"));
|
||||
string[] files = Directory.GetFiles(Path.Combine(projectPath, "Realms"), "*.xml");
|
||||
|
||||
if (files.Length == 0)
|
||||
return;
|
||||
|
||||
UninstallWidget();
|
||||
foreach (string realmFile in files)
|
||||
{
|
||||
Realm realm = new Realm();
|
||||
realm = (Realm)FileManager.Load(realmFile, realm);
|
||||
|
||||
Button button = new Button();
|
||||
button.FlatStyle = FlatStyle.Flat;
|
||||
button.BackColor = System.Drawing.Color.FromArgb(48,48,48 );
|
||||
button.Size = new System.Drawing.Size(130,100);
|
||||
button.Name = "btn" + realm.Name;
|
||||
button.Text = realm.Name;
|
||||
flowContainer.Controls.Add(button);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uninstalls the currently installed widget
|
||||
/// </summary>
|
||||
public void UninstallWidget()
|
||||
{
|
||||
flowContainer.Controls.Clear();
|
||||
containerMain.Panel1.Controls.Clear();
|
||||
containerMain.Panel1.Controls.Add(new UIWidgets.RealmExplorer().InstallControl(projectPath));
|
||||
}
|
||||
|
||||
private void btnSaveObject_Click(object sender, EventArgs e)
|
||||
|
@ -96,7 +71,7 @@ namespace MudDesigner
|
|||
Type t = propertyObject.SelectedObject.GetType();
|
||||
//We can use to get a copy of the currently selected object
|
||||
//if it is a BaseObject (Aquire it's BaseObject.Filename)
|
||||
BaseObject obj = new BaseObject();
|
||||
var obj = new BaseObject();
|
||||
|
||||
//Filepaths
|
||||
string projectPath = Path.Combine(Application.StartupPath, "Project");
|
||||
|
@ -111,7 +86,7 @@ namespace MudDesigner
|
|||
}
|
||||
else if (t == typeof(Currency))
|
||||
{
|
||||
obj = (BaseObject)propertyObject.SelectedObject;
|
||||
obj = (Currency)propertyObject.SelectedObject;
|
||||
objectPath = Path.Combine(projectPath, "Currencies");
|
||||
ValidatePath(objectPath);
|
||||
filename = Path.Combine(objectPath, obj.Filename);
|
||||
|
@ -119,49 +94,93 @@ namespace MudDesigner
|
|||
}
|
||||
else if (t == typeof(Realm))
|
||||
{
|
||||
obj = (BaseObject)propertyObject.SelectedObject;
|
||||
obj = (Realm)propertyObject.SelectedObject;
|
||||
objectPath = Path.Combine(projectPath, "Realms");
|
||||
ValidatePath(objectPath);
|
||||
objectPath = Path.Combine(objectPath, obj.Name);
|
||||
filename = Path.Combine(objectPath, obj.Filename);
|
||||
objectPath = Path.Combine(objectPath, "Zones");
|
||||
ValidatePath(objectPath);
|
||||
FileManager.Save(filename, obj);
|
||||
}
|
||||
else if (t == typeof(Zone))
|
||||
{
|
||||
Zone zone = (Zone)propertyObject.SelectedObject;
|
||||
if (string.IsNullOrEmpty(zone.Realm))
|
||||
{
|
||||
objectPath = Path.Combine(projectPath, "Zones");
|
||||
objectPath = Path.Combine(objectPath, zone.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
objectPath = Path.Combine(projectPath, "Realms");
|
||||
objectPath = Path.Combine(objectPath, zone.Realm);
|
||||
objectPath = Path.Combine(objectPath, "Zones");
|
||||
objectPath = Path.Combine(objectPath, zone.Name);
|
||||
filename = Path.Combine(objectPath, zone.Filename);
|
||||
}
|
||||
ValidatePath(objectPath);
|
||||
filename = Path.Combine(objectPath, zone.Filename);
|
||||
FileManager.Save(filename, zone);
|
||||
}
|
||||
|
||||
btnRefreshObjects_Click(null, null);
|
||||
RefreshProjectExplorer();
|
||||
}
|
||||
|
||||
private void LoadObject(TreeNode selectedNode)
|
||||
{
|
||||
string projectPath = Path.Combine(Application.StartupPath, "Project");
|
||||
string objectPath = "";
|
||||
string objectFilename = "";
|
||||
|
||||
if (selectedNode.Text == "Game Objects")
|
||||
if (selectedNode.Text == "Project")
|
||||
{
|
||||
MessageBox.Show("You cannot edit the Game Object node in the Project Explorer.");
|
||||
MessageBox.Show("You cannot edit the Project node in the Project Explorer.");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (selectedNode.Parent.Text)
|
||||
//for root objects
|
||||
if (selectedNode.Parent.Text == "Project")
|
||||
{
|
||||
case "Game Objects":
|
||||
if (selectedNode.Text == "Game.xml")
|
||||
{
|
||||
objectFilename = Path.Combine(projectPath, selectedNode.Text);
|
||||
propertyObject.SelectedObject = (ProjectInformation)FileManager.Load(objectFilename, new ProjectInformation());
|
||||
objectFilename = selectedNode.FullPath;
|
||||
ProjectInformation project = new ProjectInformation();
|
||||
project = (ProjectInformation)FileManager.Load(objectFilename, project);
|
||||
lblObjectProperties.Text = "Project Properties (" + project.GameTitle + ")";
|
||||
propertyObject.SelectedObject = project;
|
||||
}
|
||||
break;
|
||||
}
|
||||
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;
|
||||
|
||||
case "Currencies":
|
||||
objectPath = Path.Combine(projectPath, selectedNode.Parent.Text);
|
||||
objectFilename = Path.Combine(objectPath, selectedNode.Text);
|
||||
propertyObject.SelectedObject = (Currency)FileManager.Load(objectFilename, new Currency());
|
||||
break;
|
||||
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;
|
||||
|
||||
case "Realms":
|
||||
objectPath = Path.Combine(projectPath, selectedNode.Parent.Text);
|
||||
objectFilename = Path.Combine(objectPath, selectedNode.Text);
|
||||
propertyObject.SelectedObject = (Realm)FileManager.Load(objectFilename, new Realm());
|
||||
break;
|
||||
//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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,7 +191,7 @@ namespace MudDesigner
|
|||
|
||||
string projectPath = Path.Combine(Application.StartupPath, "Project");
|
||||
|
||||
btnRefreshObjects_Click(null, null);
|
||||
RefreshProjectExplorer();
|
||||
}
|
||||
|
||||
private void PopulateTree(string dir, TreeNode node)
|
||||
|
@ -195,6 +214,7 @@ namespace MudDesigner
|
|||
// 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);
|
||||
}
|
||||
|
||||
|
@ -204,18 +224,12 @@ namespace MudDesigner
|
|||
private void btnRefreshObjects_Click(object sender, EventArgs e)
|
||||
{
|
||||
treeExplorer.Nodes.Clear();
|
||||
TreeNode node = new TreeNode("Game Objects");
|
||||
TreeNode node = new TreeNode("Project");
|
||||
treeExplorer.Nodes.Add(node);
|
||||
string projectPath = Path.Combine(Application.StartupPath, "Project");
|
||||
PopulateTree(projectPath, node);
|
||||
}
|
||||
|
||||
private void currencyEditorToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Currency obj = new Currency();
|
||||
propertyObject.SelectedObject = obj;
|
||||
}
|
||||
|
||||
private void mnuEditObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadObject(treeExplorer.SelectedNode);
|
||||
|
@ -230,5 +244,146 @@ namespace MudDesigner
|
|||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue