Save all FastFlag values as strings

turns out that the json deserializer does not, in fact, automatically typecast to string
This commit is contained in:
pizzaboxer 2023-07-23 23:45:40 +01:00
parent df422cceb5
commit 62a44f1c2c
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
2 changed files with 14 additions and 4 deletions

View File

@ -3,7 +3,7 @@ using System.Windows.Media.Animation;
namespace Bloxstrap namespace Bloxstrap
{ {
public class FastFlagManager : JsonManager<Dictionary<string, string>> public class FastFlagManager : JsonManager<Dictionary<string, object>>
{ {
public override string FileLocation => Path.Combine(Directories.Modifications, "ClientSettings\\ClientAppSettings.json"); public override string FileLocation => Path.Combine(Directories.Modifications, "ClientSettings\\ClientAppSettings.json");
@ -124,8 +124,8 @@ namespace Bloxstrap
public string? GetValue(string key) public string? GetValue(string key)
{ {
// check if we have an updated change for it pushed first // check if we have an updated change for it pushed first
if (Prop.TryGetValue(key, out string? value) && value is not null) if (Prop.TryGetValue(key, out object? value) && value is not null)
return value; return value.ToString();
return null; return null;
} }
@ -169,6 +169,16 @@ namespace Bloxstrap
return mapping.First().Key; return mapping.First().Key;
} }
public override void Save()
{
// convert all flag values to strings before saving
foreach (var pair in Prop)
Prop[pair.Key] = pair.Value.ToString()!;
base.Save();
}
public override void Load() public override void Load()
{ {
base.Load(); base.Load();

View File

@ -42,7 +42,7 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
{ {
// Enabled = true, // Enabled = true,
Name = pair.Key, Name = pair.Key,
Value = pair.Value Value = pair.Value.ToString()!
}; };
/* if (entry.Name.StartsWith("Disable")) /* if (entry.Name.StartsWith("Disable"))