osu/osu.Game/Overlays/Settings/RulesetSettingsSubsection.cs

39 lines
1.3 KiB
C#
Raw Normal View History

// 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.Allocation;
using osu.Game.Rulesets;
2018-07-11 08:25:57 +00:00
using osu.Game.Rulesets.Configuration;
namespace osu.Game.Overlays.Settings
{
/// <summary>
/// A <see cref="SettingsSubsection"/> which provides subclasses with the <see cref="IRulesetConfigManager"/>
/// from the <see cref="Ruleset"/>'s <see cref="Ruleset.CreateConfig()"/>.
/// </summary>
public abstract class RulesetSettingsSubsection : SettingsSubsection
{
private readonly Ruleset ruleset;
2018-07-11 08:25:57 +00:00
protected IRulesetConfigManager Config;
protected RulesetSettingsSubsection(Ruleset ruleset)
{
this.ruleset = ruleset;
}
private DependencyContainer dependencies;
2018-07-11 08:07:14 +00:00
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
2018-07-11 08:07:14 +00:00
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
2018-07-11 08:25:57 +00:00
Config = dependencies.Get<RulesetConfigCache>().GetConfigFor(ruleset);
if (Config != null)
dependencies.Cache(Config);
return dependencies;
}
}
}