diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 3efaa02a31..509622c2fe 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -60,6 +60,9 @@ namespace osu.Game.Configuration Set(OsuSetting.ShowFpsDisplay, false); Set(OsuSetting.ShowStoryboard, true); + Set(OsuSetting.BeatmapSkins, true); + Set(OsuSetting.BeatmapHitsounds, true); + Set(OsuSetting.CursorRotation, true); Set(OsuSetting.MenuParallax, true); @@ -133,6 +136,8 @@ namespace osu.Game.Configuration Skin, ScreenshotFormat, ScreenshotCaptureMenuCursor, - SongSelectRightMouseScroll + SongSelectRightMouseScroll, + BeatmapSkins, + BeatmapHitsounds } } diff --git a/osu.Game/Screens/Play/PlayerSettings/VisualSettings.cs b/osu.Game/Screens/Play/PlayerSettings/VisualSettings.cs index 92d069a224..439e344020 100644 --- a/osu.Game/Screens/Play/PlayerSettings/VisualSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/VisualSettings.cs @@ -15,6 +15,8 @@ namespace osu.Game.Screens.Play.PlayerSettings private readonly PlayerSliderBar dimSliderBar; private readonly PlayerSliderBar blurSliderBar; private readonly PlayerCheckbox showStoryboardToggle; + private readonly PlayerCheckbox beatmapSkinsToggle; + private readonly PlayerCheckbox beatmapHitsoundsToggle; public VisualSettings() { @@ -34,7 +36,9 @@ namespace osu.Game.Screens.Play.PlayerSettings { Text = "Toggles:" }, - showStoryboardToggle = new PlayerCheckbox { LabelText = "Storyboards" } + showStoryboardToggle = new PlayerCheckbox { LabelText = "Storyboards" }, + beatmapSkinsToggle = new PlayerCheckbox { LabelText = "Beatmap skins" }, + beatmapHitsoundsToggle = new PlayerCheckbox { LabelText = "Beatmap hitsounds" } }; } @@ -44,6 +48,8 @@ namespace osu.Game.Screens.Play.PlayerSettings dimSliderBar.Bindable = config.GetBindable(OsuSetting.DimLevel); blurSliderBar.Bindable = config.GetBindable(OsuSetting.BlurLevel); showStoryboardToggle.Bindable = config.GetBindable(OsuSetting.ShowStoryboard); + beatmapSkinsToggle.Bindable = config.GetBindable(OsuSetting.BeatmapSkins); + beatmapHitsoundsToggle.Bindable = config.GetBindable(OsuSetting.BeatmapHitsounds); } } } diff --git a/osu.Game/Skinning/LocalSkinOverrideContainer.cs b/osu.Game/Skinning/LocalSkinOverrideContainer.cs index bfbb1719df..ad6a033936 100644 --- a/osu.Game/Skinning/LocalSkinOverrideContainer.cs +++ b/osu.Game/Skinning/LocalSkinOverrideContainer.cs @@ -4,9 +4,11 @@ using System; using osu.Framework.Allocation; using osu.Framework.Audio.Sample; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Textures; +using osu.Game.Configuration; namespace osu.Game.Skinning { @@ -14,17 +16,37 @@ namespace osu.Game.Skinning { public event Action SourceChanged; - public Drawable GetDrawableComponent(string componentName) => source.GetDrawableComponent(componentName) ?? fallbackSource?.GetDrawableComponent(componentName); + private Bindable beatmapSkins = new Bindable(); + private Bindable beatmapHitsounds = new Bindable(); - public Texture GetTexture(string componentName) => source.GetTexture(componentName) ?? fallbackSource.GetTexture(componentName); + public Drawable GetDrawableComponent(string componentName) + { + Drawable sourceDrawable; + if (beatmapSkins && (sourceDrawable = source.GetDrawableComponent(componentName)) != null) + return sourceDrawable; + return fallbackSource?.GetDrawableComponent(componentName); + } - public SampleChannel GetSample(string sampleName) => source.GetSample(sampleName) ?? fallbackSource?.GetSample(sampleName); + public Texture GetTexture(string componentName) + { + Texture sourceTexture; + if (beatmapSkins && (sourceTexture = source.GetTexture(componentName)) != null) + return sourceTexture; + return fallbackSource.GetTexture(componentName); + } + + public SampleChannel GetSample(string sampleName) + { + SampleChannel sourceChannel; + if (beatmapHitsounds && (sourceChannel = source.GetSample(sampleName)) != null) + return sourceChannel; + return fallbackSource?.GetSample(sampleName); + } public TValue? GetValue(Func query) where TConfiguration : SkinConfiguration where TValue : struct { TValue? val = null; - var conf = (source as Skin)?.Configuration as TConfiguration; - if (conf != null) + if ((source as Skin)?.Configuration is TConfiguration conf) val = query?.Invoke(conf); return val ?? fallbackSource?.GetValue(query); @@ -33,8 +55,7 @@ namespace osu.Game.Skinning public TValue GetValue(Func query) where TConfiguration : SkinConfiguration where TValue : class { TValue val = null; - var conf = (source as Skin)?.Configuration as TConfiguration; - if (conf != null) + if ((source as Skin)?.Configuration is TConfiguration conf) val = query?.Invoke(conf); return val ?? fallbackSource?.GetValue(query); @@ -60,6 +81,18 @@ namespace osu.Game.Skinning return dependencies; } + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + beatmapSkins = config.GetBindable(OsuSetting.BeatmapSkins); + beatmapSkins.ValueChanged += val => onSourceChanged(); + beatmapSkins.TriggerChange(); + + beatmapHitsounds = config.GetBindable(OsuSetting.BeatmapHitsounds); + beatmapHitsounds.ValueChanged += val => onSourceChanged(); + beatmapHitsounds.TriggerChange(); + } + protected override void LoadComplete() { base.LoadComplete();