Make settings works with current caching structure

Will likely pull out that `RulesetConfigCache` next, but this is an
"everything works" state.
This commit is contained in:
Dean Herbert
2021-09-15 14:39:47 +09:00
parent 14314476f0
commit a2f1752344
12 changed files with 101 additions and 121 deletions

View File

@ -4,15 +4,14 @@
using System.Collections.Generic;
using System.Linq;
using osu.Game.Database;
using Realms;
namespace osu.Game.Configuration
{
public class RealmSettingsStore
public class SettingsStore
{
private readonly RealmContextFactory realmFactory;
public RealmSettingsStore(RealmContextFactory realmFactory)
public SettingsStore(RealmContextFactory realmFactory)
{
this.realmFactory = realmFactory;
}
@ -27,21 +26,5 @@ namespace osu.Game.Configuration
using (var context = realmFactory.GetForRead())
return context.Realm.All<RealmSetting>().Where(b => b.RulesetID == rulesetId && b.Variant == variant).ToList();
}
public void Update(RealmSetting setting)
{
using (ContextFactory.GetForWrite())
{
var newValue = setting.Value;
Refresh(ref setting);
setting.Value = newValue;
}
}
public void Delete(RealmSetting setting)
{
using (var usage = ContextFactory.GetForWrite())
usage.Context.Remove(setting);
}
}
}