Major Changes:
- Rooms are now saved within the selected Zone. - Fixed Project Explorer not displaying project directory structure on Designer startup. Engine: - Re-wrote Zone.GetRoom() to use the more efficient LINQ query. - Zone.RefreshRoomList now saves itself after re-building the Room collection - UIRoomControl now has a public Rooms collection for use by the UIRoomEditor - UIRoomEditor now returns the modified UIRoomControl.Rooms collection to the Designers properties pane instead of an empty collection. Designer: - Project Explorer now displays project directory structure on load. This was broken during Designers Constructor re-write. - Added additional comments to increase readability of source.
This commit is contained in:
parent
afd74530cd
commit
42e6fef109
7 changed files with 86 additions and 11 deletions
3
Mud Designer/..svnbridge/.svnbridge
Normal file
3
Mud Designer/..svnbridge/.svnbridge
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Properties><Property><Name>svn:ignore</Name><Value>bin
|
||||||
|
obj
|
||||||
|
</Value></Property></Properties></ItemProperties>
|
42
Mud Designer/Designer.Designer.cs
generated
42
Mud Designer/Designer.Designer.cs
generated
|
@ -86,6 +86,10 @@
|
||||||
this.propertyObject = new System.Windows.Forms.PropertyGrid();
|
this.propertyObject = new System.Windows.Forms.PropertyGrid();
|
||||||
this.lblObjectProperties = new System.Windows.Forms.Label();
|
this.lblObjectProperties = new System.Windows.Forms.Label();
|
||||||
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
||||||
|
this.addObjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.environmentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.mnuNewRealmShortcut = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.mnuNewZoneShortcut = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
this.containerMain.Panel2.SuspendLayout();
|
this.containerMain.Panel2.SuspendLayout();
|
||||||
this.containerMain.SuspendLayout();
|
this.containerMain.SuspendLayout();
|
||||||
|
@ -444,11 +448,12 @@
|
||||||
// contextMenuStrip1
|
// contextMenuStrip1
|
||||||
//
|
//
|
||||||
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.addObjectToolStripMenuItem,
|
||||||
this.mnuEditObject,
|
this.mnuEditObject,
|
||||||
this.toolStripMenuItem1,
|
this.toolStripMenuItem1,
|
||||||
this.mnuDeleteSelectedObject});
|
this.mnuDeleteSelectedObject});
|
||||||
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
||||||
this.contextMenuStrip1.Size = new System.Drawing.Size(153, 76);
|
this.contextMenuStrip1.Size = new System.Drawing.Size(153, 98);
|
||||||
//
|
//
|
||||||
// mnuEditObject
|
// mnuEditObject
|
||||||
//
|
//
|
||||||
|
@ -555,6 +560,37 @@
|
||||||
this.toolTip1.ShowAlways = true;
|
this.toolTip1.ShowAlways = true;
|
||||||
this.toolTip1.ToolTipTitle = "Mud Designer Help";
|
this.toolTip1.ToolTipTitle = "Mud Designer Help";
|
||||||
//
|
//
|
||||||
|
// addObjectToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.addObjectToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.environmentToolStripMenuItem});
|
||||||
|
this.addObjectToolStripMenuItem.Name = "addObjectToolStripMenuItem";
|
||||||
|
this.addObjectToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||||
|
this.addObjectToolStripMenuItem.Text = "Add Object";
|
||||||
|
//
|
||||||
|
// environmentToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.environmentToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.mnuNewRealmShortcut,
|
||||||
|
this.mnuNewZoneShortcut});
|
||||||
|
this.environmentToolStripMenuItem.Name = "environmentToolStripMenuItem";
|
||||||
|
this.environmentToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||||
|
this.environmentToolStripMenuItem.Text = "Environment";
|
||||||
|
//
|
||||||
|
// mnuNewRealmShortcut
|
||||||
|
//
|
||||||
|
this.mnuNewRealmShortcut.Name = "mnuNewRealmShortcut";
|
||||||
|
this.mnuNewRealmShortcut.Size = new System.Drawing.Size(152, 22);
|
||||||
|
this.mnuNewRealmShortcut.Text = "New Realm";
|
||||||
|
this.mnuNewRealmShortcut.Click += new System.EventHandler(this.mnuNewRealm_Click);
|
||||||
|
//
|
||||||
|
// mnuNewZoneShortcut
|
||||||
|
//
|
||||||
|
this.mnuNewZoneShortcut.Name = "mnuNewZoneShortcut";
|
||||||
|
this.mnuNewZoneShortcut.Size = new System.Drawing.Size(152, 22);
|
||||||
|
this.mnuNewZoneShortcut.Text = "New Zone";
|
||||||
|
this.mnuNewZoneShortcut.Click += new System.EventHandler(this.mnuNewZone_Click);
|
||||||
|
//
|
||||||
// Designer
|
// Designer
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
@ -641,6 +677,10 @@
|
||||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
|
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
|
||||||
private System.Windows.Forms.PropertyGrid propertyObject;
|
private System.Windows.Forms.PropertyGrid propertyObject;
|
||||||
private System.Windows.Forms.ToolStripMenuItem mnuNewRoom;
|
private System.Windows.Forms.ToolStripMenuItem mnuNewRoom;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem addObjectToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem environmentToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem mnuNewRealmShortcut;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem mnuNewZoneShortcut;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,8 @@ namespace MudDesigner
|
||||||
|
|
||||||
//ensure the path exists
|
//ensure the path exists
|
||||||
ValidatePath(projectPath);
|
ValidatePath(projectPath);
|
||||||
|
|
||||||
|
RefreshProjectExplorer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -136,16 +138,20 @@ namespace MudDesigner
|
||||||
//for root objects
|
//for root objects
|
||||||
switch (objType)
|
switch (objType)
|
||||||
{
|
{
|
||||||
|
//A non-editable object was found
|
||||||
case ObjectType.Nothing:
|
case ObjectType.Nothing:
|
||||||
return;
|
return;
|
||||||
|
//Project Information file
|
||||||
case ObjectType.Project:
|
case ObjectType.Project:
|
||||||
_Project = (ProjectInformation)_Project.Load(FileManager.GetDataPath(SaveDataTypes.Root));
|
_Project = (ProjectInformation)_Project.Load(FileManager.GetDataPath(SaveDataTypes.Root));
|
||||||
break;
|
break;
|
||||||
|
//Currency File
|
||||||
case ObjectType.Currency:
|
case ObjectType.Currency:
|
||||||
Currency currency = new Currency();
|
Currency currency = new Currency();
|
||||||
objectFilename = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Currencies), selectedNode.Text);
|
objectFilename = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Currencies), selectedNode.Text);
|
||||||
propertyObject.SelectedObject = (Currency)currency.Load(objectFilename);
|
propertyObject.SelectedObject = (Currency)currency.Load(objectFilename);
|
||||||
break;
|
break;
|
||||||
|
//Realm File selected
|
||||||
case ObjectType.Realm:
|
case ObjectType.Realm:
|
||||||
objectName = Path.GetFileNameWithoutExtension(selectedNode.Parent.Text);
|
objectName = Path.GetFileNameWithoutExtension(selectedNode.Parent.Text);
|
||||||
objectPath = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Realms), objectName);
|
objectPath = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Realms), objectName);
|
||||||
|
@ -153,6 +159,7 @@ namespace MudDesigner
|
||||||
_GameObject = new Realm();
|
_GameObject = new Realm();
|
||||||
propertyObject.SelectedObject = _GameObject.Load(objectFilename);
|
propertyObject.SelectedObject = _GameObject.Load(objectFilename);
|
||||||
break;
|
break;
|
||||||
|
//Zone File located under Project/Zones
|
||||||
case ObjectType.ZoneRoot:
|
case ObjectType.ZoneRoot:
|
||||||
objectName = Path.GetFileNameWithoutExtension(selectedNode.Parent.Text);
|
objectName = Path.GetFileNameWithoutExtension(selectedNode.Parent.Text);
|
||||||
objectPath = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Zones), objectName);
|
objectPath = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Zones), objectName);
|
||||||
|
@ -160,6 +167,7 @@ namespace MudDesigner
|
||||||
_GameObject = new Zone();
|
_GameObject = new Zone();
|
||||||
propertyObject.SelectedObject = _GameObject.Load(objectFilename);
|
propertyObject.SelectedObject = _GameObject.Load(objectFilename);
|
||||||
break;
|
break;
|
||||||
|
//Zone File located under Project/Realms/Zones
|
||||||
case ObjectType.ZoneWithinRealm:
|
case ObjectType.ZoneWithinRealm:
|
||||||
TreeNode grandparent = selectedNode.Parent.Parent;
|
TreeNode grandparent = selectedNode.Parent.Parent;
|
||||||
objectName = Path.GetFileNameWithoutExtension(selectedNode.Parent.Text);
|
objectName = Path.GetFileNameWithoutExtension(selectedNode.Parent.Text);
|
||||||
|
@ -179,8 +187,6 @@ namespace MudDesigner
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(path))
|
if (!Directory.Exists(path))
|
||||||
Directory.CreateDirectory(path);
|
Directory.CreateDirectory(path);
|
||||||
|
|
||||||
string projectPath = Path.Combine(Application.StartupPath, "Project");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -189,15 +195,20 @@ namespace MudDesigner
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private bool CheckSavedState()
|
private bool CheckSavedState()
|
||||||
{
|
{
|
||||||
|
//No need to continue if the save flag is already set
|
||||||
if (IsSaved)
|
if (IsSaved)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
//Inform the user
|
||||||
DialogResult result = MessageBox.Show(lblObjectProperties.Text + " has not been saved! Do you wish to save it?", "Mud Designer", MessageBoxButtons.YesNoCancel);
|
DialogResult result = MessageBox.Show(lblObjectProperties.Text + " has not been saved! Do you wish to save it?", "Mud Designer", MessageBoxButtons.YesNoCancel);
|
||||||
|
|
||||||
|
//Don't save it. Return true so that it can be overwrote
|
||||||
if (result == DialogResult.No)
|
if (result == DialogResult.No)
|
||||||
return true;
|
return true;
|
||||||
|
//User hit cancel, it's not saved so return false.
|
||||||
else if (result == DialogResult.Cancel)
|
else if (result == DialogResult.Cancel)
|
||||||
return false;
|
return false;
|
||||||
|
//User hit Yes, so save the object
|
||||||
else
|
else
|
||||||
SaveSelected();
|
SaveSelected();
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
namespace MudDesigner.MudEngine.GameObjects.Environment
|
namespace MudDesigner.MudEngine.GameObjects.Environment
|
||||||
|
|
|
@ -64,17 +64,29 @@ namespace MudDesigner.MudEngine.GameObjects.Environment
|
||||||
//throw new NotSupportedException("Parameterless constructors of Type " + this.GetType().FullName + " is not supported.");
|
//throw new NotSupportedException("Parameterless constructors of Type " + this.GetType().FullName + " is not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="RoomName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public Room GetRoom(string RoomName)
|
public Room GetRoom(string RoomName)
|
||||||
{
|
{
|
||||||
foreach (Room r in Rooms)
|
var filterQuery =
|
||||||
{
|
from room in Rooms
|
||||||
if (r.Name == RoomName)
|
where room.Name == RoomName
|
||||||
return r;
|
select room;
|
||||||
}
|
|
||||||
|
foreach (var room in filterQuery)
|
||||||
|
return room;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clears out the Zones room collection and re-builds it.
|
||||||
|
/// This is a time consuming process if there are a large amount of
|
||||||
|
/// of rooms, use sparingly.
|
||||||
|
/// </summary>
|
||||||
public void RefreshRoomList()
|
public void RefreshRoomList()
|
||||||
{
|
{
|
||||||
Rooms = new List<Room>();
|
Rooms = new List<Room>();
|
||||||
|
@ -89,12 +101,18 @@ namespace MudDesigner.MudEngine.GameObjects.Environment
|
||||||
//Zone exists, so it's already been saved.
|
//Zone exists, so it's already been saved.
|
||||||
string[] rooms = Directory.GetFiles(zonePath, "*.room");
|
string[] rooms = Directory.GetFiles(zonePath, "*.room");
|
||||||
|
|
||||||
|
//Clear the existing collection of Rooms
|
||||||
|
this.Rooms.Clear();
|
||||||
|
//Build a new one based off of the files
|
||||||
foreach (string file in rooms)
|
foreach (string file in rooms)
|
||||||
{
|
{
|
||||||
Room r = new Room();
|
Room r = new Room();
|
||||||
r = (Room)FileManager.Load(file, r);
|
r = (Room)FileManager.Load(file, r);
|
||||||
this.Rooms.Add(r);
|
this.Rooms.Add(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Save the re-built Room collection
|
||||||
|
this.Save(Path.Combine(zonePath, this.Filename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,14 @@ namespace MudDesigner.MudEngine.UITypeEditors
|
||||||
bool IsSaved;
|
bool IsSaved;
|
||||||
Room _Room;
|
Room _Room;
|
||||||
string savePath = "";
|
string savePath = "";
|
||||||
|
public List<Room> Rooms { get; set; }
|
||||||
|
|
||||||
public UIRoomControl(Zone zone)
|
public UIRoomControl(Zone zone)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
IsSaved = true;
|
IsSaved = true;
|
||||||
_Room = new Room();
|
_Room = new Room();
|
||||||
|
Rooms = new List<Room>();
|
||||||
|
|
||||||
string projectPath = Path.Combine(Application.StartupPath, "Project");
|
string projectPath = Path.Combine(Application.StartupPath, "Project");
|
||||||
string zonesPath = Path.Combine(projectPath, "Zones");
|
string zonesPath = Path.Combine(projectPath, "Zones");
|
||||||
|
@ -81,6 +83,7 @@ namespace MudDesigner.MudEngine.UITypeEditors
|
||||||
if (!lstRooms.Items.Contains(_Room.Filename))
|
if (!lstRooms.Items.Contains(_Room.Filename))
|
||||||
lstRooms.Items.Add(_Room.Filename);
|
lstRooms.Items.Add(_Room.Filename);
|
||||||
|
|
||||||
|
Rooms.Add(_Room);
|
||||||
IsSaved = true;
|
IsSaved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace MudDesigner.MudEngine.UITypeEditors
|
||||||
|
|
||||||
ctl.ShowDialog();
|
ctl.ShowDialog();
|
||||||
|
|
||||||
return new List<Room>();
|
return ctl.Rooms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue