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:
parent
d5ebbe186f
commit
6c8678a624
5 changed files with 107 additions and 17 deletions
|
@ -41,6 +41,7 @@ namespace MudDesigner
|
|||
BaseObject _GameObject;
|
||||
//Check for if the loaded object is saved yet or not.
|
||||
bool IsSaved;
|
||||
IWidget _Widget;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the Designers Temporary objects, Project Information and varifies project paths.
|
||||
|
@ -53,6 +54,7 @@ namespace MudDesigner
|
|||
//for use during our runtime
|
||||
_GameObject = new BaseObject();
|
||||
_Project = new ProjectInformation();
|
||||
_Widget = new RealmWidget();
|
||||
IsSaved = true;
|
||||
|
||||
//Get out saved project file
|
||||
|
@ -66,6 +68,9 @@ namespace MudDesigner
|
|||
|
||||
//Display the Project directory structure in the Project Explorer
|
||||
RefreshProjectExplorer();
|
||||
|
||||
//Install out Realm Widget
|
||||
this.containerMain.Panel1.Controls.Add(_Widget.Initialize());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -145,14 +150,15 @@ namespace MudDesigner
|
|||
{
|
||||
//We can use to get a copy of the currently selected object
|
||||
//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
|
||||
string objectPath = "";
|
||||
string filename = "";
|
||||
|
||||
//Scan through the available Types that can be saved
|
||||
switch (obj.GetType().Name)
|
||||
switch (propertyObject.SelectedObject.GetType().Name)
|
||||
{
|
||||
//ProjectInformation
|
||||
case "ProjectInformation":
|
||||
|
@ -161,20 +167,20 @@ namespace MudDesigner
|
|||
break;
|
||||
//Currency
|
||||
case "Currency":
|
||||
filename = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Currencies), obj.Filename);
|
||||
obj.Save(filename);
|
||||
filename = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Currencies), _GameObject.Filename);
|
||||
_GameObject.Save(filename);
|
||||
break;
|
||||
//Realm
|
||||
case "Realm":
|
||||
objectPath= Path.Combine(FileManager.GetDataPath(SaveDataTypes.Realms), obj.Name);
|
||||
filename = Path.Combine(objectPath, obj.Filename);
|
||||
obj.Save(filename);
|
||||
objectPath = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Realms), _GameObject.Name);
|
||||
filename = Path.Combine(objectPath, _GameObject.Filename);
|
||||
_GameObject.Save(filename);
|
||||
break;
|
||||
//Zone
|
||||
case "Zone":
|
||||
//Get the current Zone being edited. We need to check if it has a Realm
|
||||
Zone z = new Zone();
|
||||
z = (Zone)obj;
|
||||
z = (Zone)_GameObject;
|
||||
//No realm assigned to it, so it's in the Root Zones directory.
|
||||
//Base our save path off of that
|
||||
if (z.Realm == "No Realm Associated.")
|
||||
|
@ -189,7 +195,7 @@ namespace MudDesigner
|
|||
filename = Path.Combine(objectPath, z.Filename);
|
||||
}
|
||||
//Save the Zone
|
||||
obj.Save(filename);
|
||||
_GameObject.Save(filename);
|
||||
|
||||
//Check if the Rooms Directory exists.
|
||||
string roomsPath = Path.Combine(objectPath, "Rooms");
|
||||
|
@ -466,6 +472,9 @@ namespace MudDesigner
|
|||
TreeNode selectedNode = treeExplorer.SelectedNode;
|
||||
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);
|
||||
|
||||
//User hit no, cancel
|
||||
|
@ -534,6 +543,8 @@ namespace MudDesigner
|
|||
SaveObject();
|
||||
IsSaved = true;
|
||||
RefreshProjectExplorer();
|
||||
if (_Widget != null)
|
||||
_Widget.Refresh();
|
||||
}
|
||||
|
||||
private void mnuAbout_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace MudDesigner.MudEngine.UITypeEditors
|
|||
string realmsPath = Path.Combine(projectPath, "Realms");
|
||||
savePath = "";
|
||||
|
||||
if (zone.Realm == "No Realm Associated")
|
||||
if (zone.Realm == "No Realm Associated.")
|
||||
{
|
||||
//Project/Zones/ZoneName
|
||||
savePath = Path.Combine(zonesPath, zone.Name);
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MudDesigner.UIWidgets
|
||||
{
|
||||
public interface IWidget
|
||||
{
|
||||
void InstallControl(string path);
|
||||
Control Initialize();
|
||||
void Refresh();
|
||||
}
|
||||
}
|
||||
|
|
2
Mud Designer/UIWidgets/RealmWidget.Designer.cs
generated
2
Mud Designer/UIWidgets/RealmWidget.Designer.cs
generated
|
@ -1,6 +1,6 @@
|
|||
namespace MudDesigner.UIWidgets
|
||||
{
|
||||
partial class RealmExplorer
|
||||
partial class RealmWidget
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
|
|
@ -11,26 +11,47 @@ using System.IO;
|
|||
using MudDesigner.MudEngine.FileSystem;
|
||||
using MudDesigner.MudEngine.GameObjects;
|
||||
using MudDesigner.MudEngine.GameObjects.Environment;
|
||||
|
||||
namespace MudDesigner.UIWidgets
|
||||
{
|
||||
public partial class RealmExplorer : UserControl
|
||||
public partial class RealmWidget : UserControl, IWidget
|
||||
{
|
||||
public RealmExplorer()
|
||||
public RealmWidget()
|
||||
{
|
||||
InitializeComponent();
|
||||
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
|
||||
|
||||
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)FileManager.Load(realmFile, realm);
|
||||
realm = (Realm)realm.Load(realmFile);
|
||||
|
||||
Button button = new Button();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue