1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 21:02:55 +08:00

Remove generics from OSD registration methods

This commit is contained in:
smoogipoo 2018-01-18 16:57:32 +09:00
parent 09dfea7e29
commit c2c478750d
2 changed files with 11 additions and 8 deletions

View File

@ -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<object, ITrackedSettings> trackedConfigManagers = new Dictionary<object, ITrackedSettings>();
private readonly Dictionary<object, TrackedSettings> trackedConfigManagers = new Dictionary<object, TrackedSettings>();
public void Register<T>(ConfigManager<T> 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<T>(ConfigManager<T> configManager)
where T : struct
public void Unregister(ITrackableConfigManager configManager)
{
if (configManager == null) throw new ArgumentNullException(nameof(configManager));

View File

@ -1,9 +1,12 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// 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
{
}
}