Major Changes:

- Widget Development Resumed.
 - Corrected instances where the Project Information was not being saved.
 - Corrected instances where deleting a Realm was not happening correctly.

Minor Changes:
 - Realm Widget UI Tweaks
 - Realm Widget Improvements
 - Code Optimizations
This commit is contained in:
Scionwest_cp 2010-01-19 15:43:43 -08:00
parent d5ebbe186f
commit 6c8678a624
5 changed files with 107 additions and 17 deletions

View file

@ -41,6 +41,7 @@ namespace MudDesigner
BaseObject _GameObject; BaseObject _GameObject;
//Check for if the loaded object is saved yet or not. //Check for if the loaded object is saved yet or not.
bool IsSaved; bool IsSaved;
IWidget _Widget;
/// <summary> /// <summary>
/// Initializes the Designers Temporary objects, Project Information and varifies project paths. /// Initializes the Designers Temporary objects, Project Information and varifies project paths.
@ -53,6 +54,7 @@ namespace MudDesigner
//for use during our runtime //for use during our runtime
_GameObject = new BaseObject(); _GameObject = new BaseObject();
_Project = new ProjectInformation(); _Project = new ProjectInformation();
_Widget = new RealmWidget();
IsSaved = true; IsSaved = true;
//Get out saved project file //Get out saved project file
@ -66,6 +68,9 @@ namespace MudDesigner
//Display the Project directory structure in the Project Explorer //Display the Project directory structure in the Project Explorer
RefreshProjectExplorer(); RefreshProjectExplorer();
//Install out Realm Widget
this.containerMain.Panel1.Controls.Add(_Widget.Initialize());
} }
/// <summary> /// <summary>
@ -145,14 +150,15 @@ namespace MudDesigner
{ {
//We can use to get a copy of the currently selected object //We can use to get a copy of the currently selected object
//if it is a BaseObject (Aquire it's BaseObject.Filename) //if it is a BaseObject (Aquire it's BaseObject.Filename)
var obj = (BaseObject)propertyObject.SelectedObject; if (propertyObject.SelectedObject.GetType().BaseType.Name == "BaseObject")
_GameObject = (BaseObject)propertyObject.SelectedObject;
//Filepaths //Filepaths
string objectPath = ""; string objectPath = "";
string filename = ""; string filename = "";
//Scan through the available Types that can be saved //Scan through the available Types that can be saved
switch (obj.GetType().Name) switch (propertyObject.SelectedObject.GetType().Name)
{ {
//ProjectInformation //ProjectInformation
case "ProjectInformation": case "ProjectInformation":
@ -161,20 +167,20 @@ namespace MudDesigner
break; break;
//Currency //Currency
case "Currency": case "Currency":
filename = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Currencies), obj.Filename); filename = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Currencies), _GameObject.Filename);
obj.Save(filename); _GameObject.Save(filename);
break; break;
//Realm //Realm
case "Realm": case "Realm":
objectPath= Path.Combine(FileManager.GetDataPath(SaveDataTypes.Realms), obj.Name); objectPath = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Realms), _GameObject.Name);
filename = Path.Combine(objectPath, obj.Filename); filename = Path.Combine(objectPath, _GameObject.Filename);
obj.Save(filename); _GameObject.Save(filename);
break; break;
//Zone //Zone
case "Zone": case "Zone":
//Get the current Zone being edited. We need to check if it has a Realm //Get the current Zone being edited. We need to check if it has a Realm
Zone z = new Zone(); Zone z = new Zone();
z = (Zone)obj; z = (Zone)_GameObject;
//No realm assigned to it, so it's in the Root Zones directory. //No realm assigned to it, so it's in the Root Zones directory.
//Base our save path off of that //Base our save path off of that
if (z.Realm == "No Realm Associated.") if (z.Realm == "No Realm Associated.")
@ -189,7 +195,7 @@ namespace MudDesigner
filename = Path.Combine(objectPath, z.Filename); filename = Path.Combine(objectPath, z.Filename);
} }
//Save the Zone //Save the Zone
obj.Save(filename); _GameObject.Save(filename);
//Check if the Rooms Directory exists. //Check if the Rooms Directory exists.
string roomsPath = Path.Combine(objectPath, "Rooms"); string roomsPath = Path.Combine(objectPath, "Rooms");
@ -466,6 +472,9 @@ namespace MudDesigner
TreeNode selectedNode = treeExplorer.SelectedNode; TreeNode selectedNode = treeExplorer.SelectedNode;
bool IsFile = true; bool IsFile = true;
if (Path.GetExtension(selectedNode.Text) == "")
IsFile = false;
result = MessageBox.Show("Are you sure you want to delete this object?\n\nAll objects contained within it will be deleted too!", "Mud Designer", MessageBoxButtons.YesNo); result = MessageBox.Show("Are you sure you want to delete this object?\n\nAll objects contained within it will be deleted too!", "Mud Designer", MessageBoxButtons.YesNo);
//User hit no, cancel //User hit no, cancel
@ -534,6 +543,8 @@ namespace MudDesigner
SaveObject(); SaveObject();
IsSaved = true; IsSaved = true;
RefreshProjectExplorer(); RefreshProjectExplorer();
if (_Widget != null)
_Widget.Refresh();
} }
private void mnuAbout_Click(object sender, EventArgs e) private void mnuAbout_Click(object sender, EventArgs e)

View file

@ -35,7 +35,7 @@ namespace MudDesigner.MudEngine.UITypeEditors
string realmsPath = Path.Combine(projectPath, "Realms"); string realmsPath = Path.Combine(projectPath, "Realms");
savePath = ""; savePath = "";
if (zone.Realm == "No Realm Associated") if (zone.Realm == "No Realm Associated.")
{ {
//Project/Zones/ZoneName //Project/Zones/ZoneName
savePath = Path.Combine(zonesPath, zone.Name); savePath = Path.Combine(zonesPath, zone.Name);

View file

@ -2,11 +2,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms;
namespace MudDesigner.UIWidgets namespace MudDesigner.UIWidgets
{ {
public interface IWidget public interface IWidget
{ {
void InstallControl(string path); Control Initialize();
void Refresh();
} }
} }

View file

@ -1,6 +1,6 @@
namespace MudDesigner.UIWidgets namespace MudDesigner.UIWidgets
{ {
partial class RealmExplorer partial class RealmWidget
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View file

@ -11,26 +11,47 @@ using System.IO;
using MudDesigner.MudEngine.FileSystem; using MudDesigner.MudEngine.FileSystem;
using MudDesigner.MudEngine.GameObjects; using MudDesigner.MudEngine.GameObjects;
using MudDesigner.MudEngine.GameObjects.Environment; using MudDesigner.MudEngine.GameObjects.Environment;
namespace MudDesigner.UIWidgets namespace MudDesigner.UIWidgets
{ {
public partial class RealmExplorer : UserControl public partial class RealmWidget : UserControl, IWidget
{ {
public RealmExplorer() public RealmWidget()
{ {
InitializeComponent(); InitializeComponent();
this.Dock = DockStyle.Fill; this.Dock = DockStyle.Fill;
} }
public Control InstallControl(string projectPath) public Control Initialize()
{ {
string[] files = Directory.GetFiles(Path.Combine(projectPath, "Realms"), "*.realm", SearchOption.AllDirectories); string[] files = new string[]{};
if (Directory.Exists(FileManager.GetDataPath(SaveDataTypes.Realms)))
files = Directory.GetFiles(FileManager.GetDataPath(SaveDataTypes.Realms), "*.realm", SearchOption.AllDirectories);
//TODO: Add if (files.length==0) statement and set a 'No Realms' label in container //TODO: Add if (files.length==0) statement and set a 'No Realms' label in container
if (files.Length == 0)
{
Button button = new Button();
button.FlatStyle = FlatStyle.Flat;
button.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(48, 48, 48);
button.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(48, 48, 48);
button.Font = new Font(new FontFamily(System.Drawing.Text.GenericFontFamilies.Serif), 12f, FontStyle.Bold);
button.BackColor = System.Drawing.Color.FromArgb(48, 48, 48);
button.ForeColor = System.Drawing.Color.LightGray;
button.Size = new System.Drawing.Size(160, 128);
button.Name = "btnNoRealms";
button.Text = "No Existing Realms.";
button.Dock = DockStyle.Fill;
this.Controls.Clear();
this.Controls.Add(button);
}
foreach (string realmFile in files) foreach (string realmFile in files)
{ {
Realm realm = new Realm(); Realm realm = new Realm();
realm = (Realm)FileManager.Load(realmFile, realm); realm = (Realm)realm.Load(realmFile);
Button button = new Button(); Button button = new Button();
button.FlatStyle = FlatStyle.Flat; button.FlatStyle = FlatStyle.Flat;
@ -51,5 +72,61 @@ namespace MudDesigner.UIWidgets
{ {
} }
public override void Refresh()
{
this.Controls.Clear();
FlowLayoutPanel flowContainer = new FlowLayoutPanel();
flowContainer.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
flowContainer.Dock = System.Windows.Forms.DockStyle.Fill;
flowContainer.Location = new System.Drawing.Point(0, 0);
flowContainer.Name = "flowContainer";
flowContainer.Padding = new System.Windows.Forms.Padding(10);
flowContainer.Size = new System.Drawing.Size(537, 502);
flowContainer.TabIndex = 0;
string[] files = new string[] { };
if (Directory.Exists(FileManager.GetDataPath(SaveDataTypes.Realms)))
files = Directory.GetFiles(FileManager.GetDataPath(SaveDataTypes.Realms), "*.realm", SearchOption.AllDirectories);
//TODO: Add if (files.length==0) statement and set a 'No Realms' label in container
if (files.Length == 0)
{
Button button = new Button();
button.FlatStyle = FlatStyle.Flat;
button.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(48, 48, 48);
button.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(48, 48, 48);
button.Font = new Font(new FontFamily(System.Drawing.Text.GenericFontFamilies.Serif), 12f, FontStyle.Bold);
button.BackColor = System.Drawing.Color.FromArgb(48, 48, 48);
button.ForeColor = System.Drawing.Color.LightGray;
button.Size = new System.Drawing.Size(160, 128);
button.Name = "btnNoRealms";
button.Text = "No Existing Realms.";
button.Dock = DockStyle.Fill;
this.Controls.Clear();
this.Controls.Add(button);
}
foreach (string realmFile in files)
{
Realm realm = new Realm();
realm = (Realm)realm.Load(realmFile);
Button button = new Button();
button.FlatStyle = FlatStyle.Flat;
button.Font = new Font(new FontFamily(System.Drawing.Text.GenericFontFamilies.Serif), 12f, FontStyle.Bold);
button.BackColor = System.Drawing.Color.FromArgb(48, 48, 48);
button.ForeColor = System.Drawing.Color.LightGray;
button.Size = new System.Drawing.Size(160, 128);
button.Name = "btn" + realm.Name;
button.Text = realm.Name;
button.Click += new EventHandler(button_Click);
flowContainer.Controls.Add(button);
}
base.Refresh();
}
} }
} }