Skip to content

Commit

Permalink
save options as XML string
Browse files Browse the repository at this point in the history
  • Loading branch information
kianzarrin committed Dec 16, 2022
1 parent a79a95a commit d81d704
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 17 deletions.
6 changes: 3 additions & 3 deletions TLM/TLM/Lifecycle/SerializableDataExtension.cs
Expand Up @@ -221,8 +221,8 @@ public class SerializableDataExtension
// load Path Find Update
PathfinderUpdates.SavegamePathfinderEdition = _configuration.SavegamePathfinderEdition;

if(_configuration.Options != null) {
OptionsManager.Instance.LoadData(_configuration.Options);
if(!string.IsNullOrEmpty(_configuration.SavedGameOptionsXML)) {
OptionsManager.Instance.LoadData(_configuration.SavedGameOptionsXML);
}

// load ext. citizens
Expand Down Expand Up @@ -459,7 +459,7 @@ public class SerializableDataExtension

try {
if (TMPELifecycle.PlayMode) {
configuration.Options = OptionsManager.Instance.SaveData(ref success);
configuration.SavedGameOptionsXML = OptionsManager.Instance.SaveData(ref success);

// forward compatibility. only needed for a short time:
SerializableData.SaveData("TMPE_Options", OptionsManager.Instance.SaveDataLegacy(ref success));
Expand Down
8 changes: 4 additions & 4 deletions TLM/TLM/Manager/Impl/OptionsManager.cs
Expand Up @@ -102,20 +102,20 @@ public bool MayPublishSegmentChanges()
/// </summary>
/// <param name="success">Current success state of SaveData operation.</param>
/// <returns>Returns <c>true</c> if successful, otherwise <c>false</c>.</returns>
public SavedGameOptions SaveData(ref bool success) {
public string SaveData(ref bool success) {
try {
return SavedGameOptions.Instance.Save();
return SavedGameOptions.Instance.Serialize();
} catch (Exception ex) {
ex.LogException();
success = false;
return null; // try and salvage some of the settings
}
}

public bool LoadData(SavedGameOptions options) {
public bool LoadData(string xml) {
try {
SavedGameOptions.Available = false;
SavedGameOptions.Load(options);
SavedGameOptions.Deserialize(xml);
return true;
} catch(Exception ex) {
ex.LogException();
Expand Down
2 changes: 1 addition & 1 deletion TLM/TLM/State/Configuration.cs
Expand Up @@ -302,7 +302,7 @@ public class ExtCitizenData {
}
}

public SavedGameOptions Options;
public string SavedGameOptionsXML;

/// <summary>
/// Stored ext. citizen data
Expand Down
9 changes: 0 additions & 9 deletions TLM/TLM/State/SavedGameOptions.cs
Expand Up @@ -154,13 +154,4 @@ public class SavedGameOptions {
}
return false;
}

public SavedGameOptions Save() {
return this.MemberwiseClone() as SavedGameOptions;
}

public static void Load(SavedGameOptions options) {
Instance = options ?? new();
Instance.Awake();
}
}

0 comments on commit d81d704

Please sign in to comment.