- 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.
128 lines
4.8 KiB
C#
128 lines
4.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.IO;
|
|
|
|
namespace MudDesigner.MudEngine.FileSystem
|
|
{
|
|
public static class FileManager
|
|
{
|
|
public enum OutputFormats
|
|
{
|
|
XML = 0,
|
|
}
|
|
|
|
/// <summary>
|
|
/// The filetype that the MUDs files will be saved as
|
|
/// </summary>
|
|
public static OutputFormats FileType
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Saves the object using the specified output format
|
|
/// </summary>
|
|
/// <param name="Filename"></param>
|
|
/// <param name="o"></param>
|
|
public static void Save(string Filename, object o)
|
|
{
|
|
if (FileType == OutputFormats.XML)
|
|
{
|
|
XmlSerialization.Save(Filename, o);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Loads the object using the specified FileType format
|
|
/// </summary>
|
|
/// <param name="Filename"></param>
|
|
/// <param name="o"></param>
|
|
/// <returns></returns>
|
|
public static object Load(string Filename, object o)
|
|
{
|
|
if (FileType == OutputFormats.XML)
|
|
{
|
|
return XmlSerialization.Load(Filename, o);
|
|
}
|
|
else return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Used to ensure that the paths needed to run the game exists.
|
|
/// If no path is supplied, the engine uses it's current install path.
|
|
/// </summary>
|
|
/// <param name="validatedPath"></param>
|
|
public static void ValidateDataPaths()
|
|
{
|
|
string assemblyPath = System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName;
|
|
string assemblyName = System.IO.Path.GetFileName(assemblyPath);
|
|
string installBase = assemblyPath.Substring(0, assemblyPath.Length - assemblyName.Length);
|
|
string rootPath = System.IO.Path.Combine(installBase, "Data");
|
|
ValidateDataPaths(rootPath);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Checks the supplied directory to ensure that all of the engines needed
|
|
/// data folders are created. Only use if you want to point your projects in
|
|
/// different directory other than InstallBase\Data
|
|
/// </summary>
|
|
/// <param name="InstallPath"></param>
|
|
public static void ValidateDataPaths(string InstallPath)
|
|
{
|
|
if (!InstallPath.EndsWith("data", true, null))
|
|
InstallPath = System.IO.Path.Combine(InstallPath, "Data");
|
|
|
|
if (!System.IO.Directory.Exists(InstallPath))
|
|
System.IO.Directory.CreateDirectory(InstallPath);
|
|
|
|
foreach (SaveDataTypes value in Enum.GetValues(typeof(SaveDataTypes)))
|
|
{
|
|
string dataType = value.ToString();
|
|
if (value.ToString() == "Root")
|
|
continue;
|
|
|
|
if (!System.IO.Directory.Exists(System.IO.Path.Combine(InstallPath, dataType)))
|
|
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(InstallPath, dataType));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the complete path to the specified data's save folder.
|
|
/// </summary>
|
|
/// <param name="DataType"></param>
|
|
/// <returns></returns>
|
|
public static string GetDataPath(SaveDataTypes DataType)
|
|
{
|
|
string assemblyPath = System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName;
|
|
string assemblyName = System.IO.Path.GetFileName(assemblyPath);
|
|
string installBase = assemblyPath.Substring(0, assemblyPath.Length - assemblyName.Length);
|
|
string rootPath = System.IO.Path.Combine(installBase, "Data");
|
|
|
|
if (DataType == SaveDataTypes.Root)
|
|
return rootPath;
|
|
else
|
|
return System.IO.Path.Combine(rootPath, DataType.ToString());
|
|
}
|
|
|
|
public static string GetDataPath(string Realm, string Zone)
|
|
{
|
|
string assemblyPath = System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName;
|
|
string assemblyName = System.IO.Path.GetFileName(assemblyPath);
|
|
string installBase = assemblyPath.Substring(0, assemblyPath.Length - assemblyName.Length);
|
|
string rootPath = System.IO.Path.Combine(installBase, "Data");
|
|
string realmsPath = System.IO.Path.Combine(rootPath, Realm);
|
|
|
|
return System.IO.Path.Combine(realmsPath, Zone);
|
|
}
|
|
|
|
public static string GetDataPath(string Realm, string Zone, string Room)
|
|
{
|
|
return System.IO.Path.Combine(GetDataPath(Realm, Zone), Room);
|
|
}
|
|
|
|
//TODO Write CopyDirectory method.
|
|
}
|
|
}
|