mirror of
https://github.com/ppy/osu.git
synced 2025-02-11 07:52:54 +08:00
Split ModSettingChangeTracker into separate file
This commit is contained in:
parent
822c66033f
commit
4a405bb859
39
osu.Game/Configuration/ModSettingChangeTracker.cs
Normal file
39
osu.Game/Configuration/ModSettingChangeTracker.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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
|
||||||
|
{
|
||||||
|
public class ModSettingChangeTracker : IDisposable
|
||||||
|
{
|
||||||
|
public Action<Mod> SettingChanged;
|
||||||
|
|
||||||
|
private readonly List<ISettingsItem> references = new List<ISettingsItem>();
|
||||||
|
|
||||||
|
public ModSettingChangeTracker(IEnumerable<Mod> mods)
|
||||||
|
{
|
||||||
|
foreach (var mod in mods)
|
||||||
|
{
|
||||||
|
foreach (var setting in mod.CreateSettingsControls().OfType<ISettingsItem>())
|
||||||
|
{
|
||||||
|
setting.SettingChanged += () => SettingChanged?.Invoke(mod);
|
||||||
|
references.Add(setting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
SettingChanged = null;
|
||||||
|
|
||||||
|
foreach (var r in references)
|
||||||
|
r.Dispose();
|
||||||
|
references.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,7 +9,6 @@ using JetBrains.Annotations;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Overlays.Settings;
|
using osu.Game.Overlays.Settings;
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
|
|
||||||
namespace osu.Game.Configuration
|
namespace osu.Game.Configuration
|
||||||
{
|
{
|
||||||
@ -141,32 +140,4 @@ namespace osu.Game.Configuration
|
|||||||
return orderedRelative.Concat(unordered);
|
return orderedRelative.Concat(unordered);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ModSettingChangeTracker : IDisposable
|
|
||||||
{
|
|
||||||
public Action<Mod> SettingChanged;
|
|
||||||
|
|
||||||
private readonly List<ISettingsItem> references = new List<ISettingsItem>();
|
|
||||||
|
|
||||||
public ModSettingChangeTracker(IEnumerable<Mod> mods)
|
|
||||||
{
|
|
||||||
foreach (var mod in mods)
|
|
||||||
{
|
|
||||||
foreach (var setting in mod.CreateSettingsControls().OfType<ISettingsItem>())
|
|
||||||
{
|
|
||||||
setting.SettingChanged += () => SettingChanged?.Invoke(mod);
|
|
||||||
references.Add(setting);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
SettingChanged = null;
|
|
||||||
|
|
||||||
foreach (var r in references)
|
|
||||||
r.Dispose();
|
|
||||||
references.Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user