Skip to content
Snippets Groups Projects
Commit eaca4b81 authored by spnati_edit's avatar spnati_edit
Browse files

move markers to editor.xml

parent 886cd3c9
No related branches found
No related tags found
No related merge requests found
......@@ -89,6 +89,7 @@ namespace SPNATI_Character_Editor
data = data ?? new CharacterEditorData();
data.LinkOwner(character);
_editorData[character] = data;
character.Markers.Merge(data.Markers);
}
public static CharacterEditorData GetEditorData(Character character)
......
......@@ -49,6 +49,12 @@ namespace SPNATI_Character_Editor
/// </summary>
public int NextId;
[XmlElement("markers")]
/// <summary>
/// Cached information about what markers are set in this character's dialog
/// </summary>
public MarkerData Markers;
/// <summary>
/// Deferred initialization of things that aren't part of serialization and don't need to exist until the character's lines are being worked on
/// </summary>
......@@ -126,6 +132,9 @@ namespace SPNATI_Character_Editor
public void OnBeforeSerialize()
{
Markers = _character.Markers;
Markers.OnBeforeSerialize();
Notes.Clear();
foreach (KeyValuePair<int, string> kvp in _notes)
{
......@@ -145,6 +154,8 @@ namespace SPNATI_Character_Editor
{
_notes[note.Id] = note.Text;
}
Markers?.OnAfterDeserialize();
}
public bool IsCalledOut(Case c)
......
......@@ -20,6 +20,7 @@ namespace SPNATI_Character_Editor
/// <param name="data"></param>
public void Merge(MarkerData data)
{
if (data == null) { return; }
foreach (var marker in data.Markers)
{
Add(marker);
......
......@@ -66,12 +66,32 @@ namespace SPNATI_Character_Editor
string timestamp = GetTimeStamp();
bool success = BackupAndExportXml(character, character, "behaviour", timestamp) &&
BackupAndExportXml(character, character.Metadata, "meta", timestamp) &&
BackupAndExportXml(character, character.Markers, "markers", timestamp) &&
BackupAndExportXml(character, CharacterDatabase.GetEditorData(character), "editor", timestamp) &&
BackupAndExportXml(character, character.Collectibles, "collectibles", timestamp);
// clean up old files
DeleteFile(character, "markers.xml");
DeleteFile(character, "behaviour.edit.bak");
DeleteFile(character, "meta.edit.bak");
DeleteFile(character, "markers.edit.bak");
DeleteFile(character, "editor.edit.bak");
return success;
}
private static void DeleteFile(Character character, string file)
{
string filePath = Path.Combine(Config.GetRootDirectory(character), file);
if (File.Exists(filePath))
{
try
{
File.Delete(filePath);
}
catch { }
}
}
private static string GetTimeStamp()
{
return DateTime.Now.ToString("yyyyMMddHHmmss");
......@@ -93,7 +113,6 @@ namespace SPNATI_Character_Editor
string timestamp = GetTimeStamp();
bool success = ExportXml(character, Path.Combine(dir, $"behaviour-{timestamp}.bak")) &&
ExportXml(character.Metadata, Path.Combine(dir, $"meta-{timestamp}.bak")) &&
ExportXml(character.Markers, Path.Combine(dir, $"markers-{timestamp}.bak")) &&
ExportXml(CharacterDatabase.GetEditorData(character), Path.Combine(dir, $"editor-{timestamp}.bak")) &&
ExportXml(character.Collectibles, Path.Combine(dir, $"collectibles-{timestamp}.bak"));
return success;
......
<h3>General</h3>
<ul>
<li>A "Recent" list has been added to Character and Skin searches.</li>
<li>Marker data has been moved into editor.xml to consolidate non-game files. markers.xml will be deleted upon your next save.</li>
</ul>
<h3>Bug Fixes</h3>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment