Files
@ a321f999a1ea
Branch filter:
Location: ATITD-Tools/Desert-Paint-Codex/Services/SettingsService.cs - annotation
a321f999a1ea
1.6 KiB
text/x-csharp
Fix a crash when trying to reorder the reaction list after recording the first reaction in the list.
40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 |
using DesertPaintCodex.Models;
using DesertPaintCodex.Util;
namespace DesertPaintCodex.Services
{
internal static class SettingsService
{
private static bool _loaded = false;
private static readonly Settings _settings = new();
public static void Get(string key, out int value, int defaultValue)
{
LoadIfNeeded();
if (!_settings.TryGet(key, out value))
{
value = defaultValue;
}
}
public static void Get(string key, out bool value, bool defaultValue)
{
LoadIfNeeded();
if (!_settings.TryGet(key, out value))
{
value = defaultValue;
}
}
public static void Set(string key, int value)
{
LoadIfNeeded();
_settings.Set(key, value);
}
public static void Set(string key, bool value)
{
LoadIfNeeded();
_settings.Set(key, value);
}
public static void Save()
{
LoadIfNeeded();
string settingsPath = System.IO.Path.Combine(FileUtils.AppDataPath, "settings");
_settings.Save(settingsPath);
}
public static bool Load()
{
_loaded = true;
string settingsPath = System.IO.Path.Combine(FileUtils.AppDataPath, "settings");
return _settings.Load(settingsPath);
}
private static void LoadIfNeeded()
{
if (_loaded) return;
Load();
}
}
}
|