// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using System.Collections.Generic; using System.Linq; using osu.Game.Overlays.Settings; using osu.Game.Rulesets.Mods; namespace osu.Game.Configuration { /// /// A helper class for tracking changes to the settings of a set of s. /// /// /// Ensure to dispose when usage is finished. /// public class ModSettingChangeTracker : IDisposable { /// /// Notifies that the setting of a has changed. /// public Action SettingChanged; private readonly List settings = new List(); /// /// Creates a new for a set of s. /// /// The set of s whose settings need to be tracked. public ModSettingChangeTracker(IEnumerable mods) { foreach (var mod in mods) { foreach (var setting in mod.CreateSettingsControls().OfType()) { setting.SettingChanged += () => SettingChanged?.Invoke(mod); settings.Add(setting); } } } public void Dispose() { SettingChanged = null; foreach (var r in settings) r.Dispose(); settings.Clear(); } } }