diff --git a/osu.Game/Configuration/DatabasedSetting.cs b/osu.Game/Configuration/DatabasedSetting.cs index b1644a3cd3..c284c10872 100644 --- a/osu.Game/Configuration/DatabasedSetting.cs +++ b/osu.Game/Configuration/DatabasedSetting.cs @@ -7,7 +7,7 @@ using osu.Game.Database; namespace osu.Game.Configuration { [Table("Settings")] - public class DatabasedSetting : Setting, IHasPrimaryKey + public class DatabasedSetting : IHasPrimaryKey { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int ID { get; set; } @@ -27,5 +27,23 @@ namespace osu.Game.Configuration get => Value.ToString(); set => Value = value; } + + public object Key; + public object Value; + + public DatabasedSetting(object key, object value) + { + Key = key; + Value = value; + } + + /// + /// Constructor for derived classes that may require serialisation. + /// + public DatabasedSetting() + { + } + + public override string ToString() => $"{Key}=>{Value}"; } } diff --git a/osu.Game/Configuration/Setting.cs b/osu.Game/Configuration/Setting.cs index 8c1d967ad9..5f282702bb 100644 --- a/osu.Game/Configuration/Setting.cs +++ b/osu.Game/Configuration/Setting.cs @@ -1,41 +1 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -namespace osu.Game.Configuration -{ - /// - /// A binding of a to an action. - /// - public class Setting - { - /// - /// The combination of keys which will trigger this binding. - /// - public object Key; - - /// - /// The resultant action which is triggered by this binding. - /// - public object Value; - - /// - /// Construct a new instance. - /// - /// The combination of keys which will trigger this binding. - /// The resultant action which is triggered by this binding. Usually an enum type. - public Setting(object key, object value) - { - Key = key; - Value = value; - } - - /// - /// Constructor for derived classes that may require serialisation. - /// - public Setting() - { - } - - public override string ToString() => $"{Key}=>{Value}"; - } -} + \ No newline at end of file diff --git a/osu.Game/Configuration/SettingsStore.cs b/osu.Game/Configuration/SettingsStore.cs index 3bcdc05496..6bb186604f 100644 --- a/osu.Game/Configuration/SettingsStore.cs +++ b/osu.Game/Configuration/SettingsStore.cs @@ -26,14 +26,13 @@ namespace osu.Game.Configuration public List Query(int? rulesetId = null) => GetContext().DatabasedSetting.Where(b => b.RulesetID == rulesetId).ToList(); - public void Update(Setting setting) + public void Update(DatabasedSetting setting) { - var dbSetting = (DatabasedSetting)setting; - var context = GetContext(); - Refresh(ref dbSetting); - dbSetting.Value = setting.Value; + Refresh(ref setting); + + setting.Value = setting.Value; context.SaveChanges(); SettingChanged?.Invoke();