1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 05:22:54 +08:00

Move gameplay configuration to interface to allow editor overriding

This commit is contained in:
Dean Herbert 2022-11-08 18:24:57 +09:00
parent 75bf023f14
commit dd4cd3cf8e
4 changed files with 34 additions and 6 deletions

View File

@ -0,0 +1,23 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Bindables;
namespace osu.Game.Configuration
{
/// <summary>
/// A settings provider which generally sources from <see cref="OsuConfigManager"/> (global user settings)
/// but can allow overriding settings by caching more locally. For instance, in the editor.
/// </summary>
/// <remarks>
/// More settings can be moved into this interface as required.
/// </remarks>
[Cached]
public interface IGameplaySettings
{
IBindable<float> ComboColourNormalisationAmount { get; }
IBindable<float> PositionalHitsoundsLevel { get; }
}
}

View File

@ -6,6 +6,7 @@
using System;
using System.Diagnostics;
using System.Globalization;
using osu.Framework.Bindables;
using osu.Framework.Configuration;
using osu.Framework.Configuration.Tracking;
using osu.Framework.Extensions;
@ -27,7 +28,7 @@ using osu.Game.Skinning;
namespace osu.Game.Configuration
{
[ExcludeFromDynamicCompile]
public class OsuConfigManager : IniConfigManager<OsuSetting>
public class OsuConfigManager : IniConfigManager<OsuSetting>, IGameplaySettings
{
public OsuConfigManager(Storage storage)
: base(storage)
@ -276,6 +277,9 @@ namespace osu.Game.Configuration
public Func<Guid, string> LookupSkinName { private get; set; } = _ => @"unknown";
public Func<GlobalAction, LocalisableString> LookupKeyBindings { get; set; } = _ => @"unknown";
IBindable<float> IGameplaySettings.ComboColourNormalisationAmount => GetOriginalBindable<float>(OsuSetting.ComboColourNormalisationAmount);
IBindable<float> IGameplaySettings.PositionalHitsoundsLevel => GetOriginalBindable<float>(OsuSetting.PositionalHitsoundsLevel);
}
// IMPORTANT: These are used in user configuration files.

View File

@ -262,6 +262,7 @@ namespace osu.Game
dependencies.Cache(largeStore);
dependencies.CacheAs(LocalConfig);
dependencies.CacheAs<IGameplaySettings>(LocalConfig);
InitialiseFonts();

View File

@ -129,8 +129,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
private readonly BindableList<HitSampleInfo> samplesBindable = new BindableList<HitSampleInfo>();
private readonly Bindable<int> comboIndexBindable = new Bindable<int>();
private readonly Bindable<float> positionalHitsoundsLevel = new Bindable<float>();
private readonly Bindable<float> comboColourBrightness = new Bindable<float>();
private readonly IBindable<float> positionalHitsoundsLevel = new Bindable<float>();
private readonly IBindable<float> comboColourBrightness = new Bindable<float>();
private readonly Bindable<int> comboIndexWithOffsetsBindable = new Bindable<int>();
protected override bool RequiresChildrenUpdate => true;
@ -171,10 +171,10 @@ namespace osu.Game.Rulesets.Objects.Drawables
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config, ISkinSource skinSource)
private void load(IGameplaySettings gameplaySettings, ISkinSource skinSource)
{
config.BindWith(OsuSetting.PositionalHitsoundsLevel, positionalHitsoundsLevel);
config.BindWith(OsuSetting.ComboColourNormalisationAmount, comboColourBrightness);
positionalHitsoundsLevel.BindTo(gameplaySettings.PositionalHitsoundsLevel);
comboColourBrightness.BindTo(gameplaySettings.ComboColourNormalisationAmount);
// Explicit non-virtual function call in case a DrawableHitObject overrides AddInternal.
base.AddInternal(Samples = new PausableSkinnableSound());