diff --git a/osu.Game/Overlays/OnScreenDisplay.cs b/osu.Game/Overlays/OnScreenDisplay.cs index 354c29531d..cc47f3bfa0 100644 --- a/osu.Game/Overlays/OnScreenDisplay.cs +++ b/osu.Game/Overlays/OnScreenDisplay.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Configuration; +using osu.Framework.Configuration.Tracking; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -120,28 +121,27 @@ namespace osu.Game.Overlays Register(frameworkConfig); } - private readonly Dictionary trackedConfigManagers = new Dictionary(); + private readonly Dictionary trackedConfigManagers = new Dictionary(); - public void Register(ConfigManager configManager) - where T : struct + public void Register(ITrackableConfigManager configManager) { if (configManager == null) throw new ArgumentNullException(nameof(configManager)); if (trackedConfigManagers.ContainsKey(configManager)) - throw new InvalidOperationException($"{nameof(configManager)} is already registered."); + return; var trackedSettings = configManager.CreateTrackedSettings(); if (trackedSettings == null) return; - trackedSettings.LoadFrom(configManager); + configManager.LoadInto(trackedSettings); + trackedSettings.SettingChanged += display; trackedConfigManagers.Add(configManager, trackedSettings); } - public void Unregister(ConfigManager configManager) - where T : struct + public void Unregister(ITrackableConfigManager configManager) { if (configManager == null) throw new ArgumentNullException(nameof(configManager)); diff --git a/osu.Game/Rulesets/Configuration/IRulesetConfigManager.cs b/osu.Game/Rulesets/Configuration/IRulesetConfigManager.cs index 08fb6f53d6..8d386242a9 100644 --- a/osu.Game/Rulesets/Configuration/IRulesetConfigManager.cs +++ b/osu.Game/Rulesets/Configuration/IRulesetConfigManager.cs @@ -1,9 +1,12 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Configuration; +using osu.Framework.Configuration.Tracking; + namespace osu.Game.Rulesets.Configuration { - public interface IRulesetConfigManager + public interface IRulesetConfigManager : ITrackableConfigManager, IConfigManager { } }