2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-06-11 12:28:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2018-06-11 12:28:50 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-04-25 16:36:17 +08:00
|
|
|
|
using osu.Game.Configuration;
|
2018-06-11 12:28:50 +08:00
|
|
|
|
using osu.Game.Rulesets;
|
2018-07-11 16:25:57 +08:00
|
|
|
|
using osu.Game.Rulesets.Configuration;
|
2018-06-11 12:28:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Settings
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A <see cref="SettingsSubsection"/> which provides subclasses with the <see cref="IRulesetConfigManager"/>
|
2019-04-25 16:36:17 +08:00
|
|
|
|
/// from the <see cref="Ruleset"/>'s <see cref="Ruleset.CreateConfig(SettingsStore)"/>.
|
2018-06-11 12:28:50 +08:00
|
|
|
|
/// </summary>
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public abstract partial class RulesetSettingsSubsection : SettingsSubsection
|
2018-06-11 12:28:50 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly Ruleset ruleset;
|
|
|
|
|
|
2018-07-11 16:25:57 +08:00
|
|
|
|
protected IRulesetConfigManager Config;
|
|
|
|
|
|
2018-06-11 12:28:50 +08:00
|
|
|
|
protected RulesetSettingsSubsection(Ruleset ruleset)
|
|
|
|
|
{
|
|
|
|
|
this.ruleset = ruleset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DependencyContainer dependencies;
|
|
|
|
|
|
2018-07-11 16:07:14 +08:00
|
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
2018-06-11 12:28:50 +08:00
|
|
|
|
{
|
2018-07-11 16:07:14 +08:00
|
|
|
|
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
2018-06-11 12:28:50 +08:00
|
|
|
|
|
2021-12-24 02:02:10 +08:00
|
|
|
|
Config = dependencies.Get<IRulesetConfigCache>().GetConfigFor(ruleset);
|
2018-07-11 16:25:57 +08:00
|
|
|
|
if (Config != null)
|
|
|
|
|
dependencies.Cache(Config);
|
2018-06-11 12:28:50 +08:00
|
|
|
|
|
|
|
|
|
return dependencies;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|