mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 21:43:04 +08:00
Remove generics from OSD registration methods
This commit is contained in:
parent
09dfea7e29
commit
c2c478750d
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Configuration.Tracking;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
@ -120,28 +121,27 @@ namespace osu.Game.Overlays
|
|||||||
Register(frameworkConfig);
|
Register(frameworkConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Dictionary<object, ITrackedSettings> trackedConfigManagers = new Dictionary<object, ITrackedSettings>();
|
private readonly Dictionary<object, TrackedSettings> trackedConfigManagers = new Dictionary<object, TrackedSettings>();
|
||||||
|
|
||||||
public void Register<T>(ConfigManager<T> configManager)
|
public void Register(ITrackableConfigManager configManager)
|
||||||
where T : struct
|
|
||||||
{
|
{
|
||||||
if (configManager == null) throw new ArgumentNullException(nameof(configManager));
|
if (configManager == null) throw new ArgumentNullException(nameof(configManager));
|
||||||
|
|
||||||
if (trackedConfigManagers.ContainsKey(configManager))
|
if (trackedConfigManagers.ContainsKey(configManager))
|
||||||
throw new InvalidOperationException($"{nameof(configManager)} is already registered.");
|
return;
|
||||||
|
|
||||||
var trackedSettings = configManager.CreateTrackedSettings();
|
var trackedSettings = configManager.CreateTrackedSettings();
|
||||||
if (trackedSettings == null)
|
if (trackedSettings == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
trackedSettings.LoadFrom(configManager);
|
configManager.LoadInto(trackedSettings);
|
||||||
|
|
||||||
trackedSettings.SettingChanged += display;
|
trackedSettings.SettingChanged += display;
|
||||||
|
|
||||||
trackedConfigManagers.Add(configManager, trackedSettings);
|
trackedConfigManagers.Add(configManager, trackedSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Unregister<T>(ConfigManager<T> configManager)
|
public void Unregister(ITrackableConfigManager configManager)
|
||||||
where T : struct
|
|
||||||
{
|
{
|
||||||
if (configManager == null) throw new ArgumentNullException(nameof(configManager));
|
if (configManager == null) throw new ArgumentNullException(nameof(configManager));
|
||||||
|
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// 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
|
namespace osu.Game.Rulesets.Configuration
|
||||||
{
|
{
|
||||||
public interface IRulesetConfigManager
|
public interface IRulesetConfigManager : ITrackableConfigManager, IConfigManager
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user