Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Nov 29, 2024
1 parent bca22d2 commit 84281bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion AquaMai/AquaMai.Config/ConfigSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Text;
using AquaMai.Config.Attributes;
using AquaMai.Config.Interfaces;
using AquaMai.Config.Migration;
using Tomlet.Models;

namespace AquaMai.Config;
Expand Down Expand Up @@ -60,7 +61,7 @@ public string Serialize(IConfig config)
}

// Version
AppendEntry(sb, null, "Version", "2.0");
AppendEntry(sb, null, "Version", ConfigMigrationManager.Instance.LatestVersion);

foreach (var section in ((Config)config).reflectionManager.SectionValues)
{
Expand Down
6 changes: 6 additions & 0 deletions AquaMai/AquaMai.Config/ConfigView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public void SetValue(string path, object value)
}
current = (TomlTable)next;
}

if (value == null)
{
current.Keys.Remove(pathComponents.Last());
return;
}
current.Put(pathComponents.Last(), value);
}

Expand Down
10 changes: 4 additions & 6 deletions AquaMai/AquaMai.Config/Migration/ConfigMigration_V2_0_V2_1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ public class ConfigMigration_V2_0_V2_1 : IConfigMigration

public IConfigView Migrate(IConfigView src)
{
var dst = src;

dst.SetValue("Version", ToVersion);
src.SetValue("Version", ToVersion);

if (src.GetValueOrDefault<bool>("Tweaks.ResetTouchAfterTrack"))
{
dst.SetValue("Tweaks.ResetTouch.AfterTrack", true);
dst.SetValue("Tweaks.ResetTouchAfterTrack", null);
src.SetValue("Tweaks.ResetTouch.AfterTrack", true);
src.SetValue("Tweaks.ResetTouchAfterTrack", null);
}

return dst;
return src;
}
}

0 comments on commit 84281bb

Please sign in to comment.