Skip to content

Commit

Permalink
switch to modhelper.storage
Browse files Browse the repository at this point in the history
  • Loading branch information
misternebula committed Feb 19, 2024
1 parent b8ea5c9 commit 2b2fd15
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/OWML.ModHelper.Menus/NewMenuSystem/MenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ void SaveConfig()

foreach (var (name, setting) in mod.ModHelper.Config.Settings)
{
var configPath = $"{mod.ModHelper.Manifest.ModFolderPath}{Constants.ModConfigFileName}";

var settingType = GetSettingType(setting);
var label = name;
var tooltip = "";
Expand Down Expand Up @@ -199,7 +197,7 @@ void SaveConfig()
settingCheckbox.OnValueChanged += (bool newValue) =>
{
mod.ModHelper.Config.SetSettingsValue(name, newValue);
JsonHelper.SaveJsonObject(configPath, mod.ModHelper.Config);
mod.ModHelper.Storage.Save(mod.ModHelper.Config, Constants.ModConfigFileName);
};
break;
case "toggle":
Expand All @@ -211,7 +209,7 @@ void SaveConfig()
settingToggle.OnValueChanged += (bool newValue) =>
{
mod.ModHelper.Config.SetSettingsValue(name, newValue);
JsonHelper.SaveJsonObject(configPath, mod.ModHelper.Config);
mod.ModHelper.Storage.Save(mod.ModHelper.Config, Constants.ModConfigFileName);
};
break;
case "selector":
Expand All @@ -223,7 +221,7 @@ void SaveConfig()
settingSelector.OnValueChanged += (int newIndex, string newSelection) =>
{
mod.ModHelper.Config.SetSettingsValue(name, newSelection);
JsonHelper.SaveJsonObject(configPath, mod.ModHelper.Config);
mod.ModHelper.Storage.Save(mod.ModHelper.Config, Constants.ModConfigFileName);
};
break;
case "separator":
Expand All @@ -239,7 +237,7 @@ void SaveConfig()
{
_console.WriteLine($"changed to {newValue}");
mod.ModHelper.Config.SetSettingsValue(name, newValue);
JsonHelper.SaveJsonObject(configPath, mod.ModHelper.Config);
mod.ModHelper.Storage.Save(mod.ModHelper.Config, Constants.ModConfigFileName);
};
break;
case "text":
Expand All @@ -252,7 +250,7 @@ void SaveConfig()
var newValue = textInputPopup.GetInputText();
_console.WriteLine($"changed to {newValue}");
mod.ModHelper.Config.SetSettingsValue(name, newValue);
JsonHelper.SaveJsonObject(configPath, mod.ModHelper.Config);
mod.ModHelper.Storage.Save(mod.ModHelper.Config, Constants.ModConfigFileName);
};
break;
default:
Expand Down

0 comments on commit 2b2fd15

Please sign in to comment.