Began work on Environment save code.
Restructured the project save data folder layout when the engine starts. The XMLData class now creates directories if they are missing. Individual classes no longer need to check if a path is valid before saving. Filenames are now automatically generated and no longer assigned by developers. This change has been made across all classes that are savable which required some changing of the Save() method arguments.
This commit is contained in:
parent
a6d346da3d
commit
ee3cd897f2
12 changed files with 101 additions and 28 deletions
|
@ -18,6 +18,14 @@ namespace MudEngine.GameScripts
|
|||
[DefaultValue("Scripted Object")]
|
||||
public String Name { get; set; }
|
||||
|
||||
public String Filename
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(this.Game.SavePaths.GetPath(DataTypes.Root), this.Name + "." + this.Game.SavePaths.GetExtension(DataTypes.Root));
|
||||
}
|
||||
}
|
||||
|
||||
public String ID { get; set; }
|
||||
|
||||
public String Description { get; set; }
|
||||
|
@ -37,15 +45,15 @@ namespace MudEngine.GameScripts
|
|||
this.SaveData = new XMLData(this.GetType().Name);
|
||||
}
|
||||
|
||||
public virtual Boolean Save(String filename)
|
||||
public virtual Boolean Save()
|
||||
{
|
||||
return this.Save(filename, false);
|
||||
return this.Save(false);
|
||||
}
|
||||
|
||||
public virtual Boolean Save(String filename, Boolean ignoreFileWrite)
|
||||
public virtual Boolean Save(Boolean ignoreFileWrite)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
File.Delete(filename);
|
||||
if (File.Exists(this.Filename))
|
||||
File.Delete(this.Filename);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -55,7 +63,7 @@ namespace MudEngine.GameScripts
|
|||
this.SaveData.AddSaveData("Description", Description);
|
||||
|
||||
if (!ignoreFileWrite)
|
||||
this.SaveData.Save(filename);
|
||||
this.SaveData.Save(this.Filename);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue