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:
parent
75bf023f14
commit
dd4cd3cf8e
23
osu.Game/Configuration/IGameplaySettings.cs
Normal file
23
osu.Game/Configuration/IGameplaySettings.cs
Normal 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; }
|
||||
}
|
||||
}
|
@ -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.
|
||||
|
@ -262,6 +262,7 @@ namespace osu.Game
|
||||
dependencies.Cache(largeStore);
|
||||
|
||||
dependencies.CacheAs(LocalConfig);
|
||||
dependencies.CacheAs<IGameplaySettings>(LocalConfig);
|
||||
|
||||
InitialiseFonts();
|
||||
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user