1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 03:22:55 +08:00

Merge pull request #2432 from UselessToucan/ignore_beatmap_skin

Add toggles for beatmap skins and hitsounds
This commit is contained in:
Dean Herbert 2018-04-25 16:43:09 +09:00 committed by GitHub
commit 306f05b7bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 9 deletions

View File

@ -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
}
}

View File

@ -15,6 +15,8 @@ namespace osu.Game.Screens.Play.PlayerSettings
private readonly PlayerSliderBar<double> dimSliderBar;
private readonly PlayerSliderBar<double> 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<double>(OsuSetting.DimLevel);
blurSliderBar.Bindable = config.GetBindable<double>(OsuSetting.BlurLevel);
showStoryboardToggle.Bindable = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
beatmapSkinsToggle.Bindable = config.GetBindable<bool>(OsuSetting.BeatmapSkins);
beatmapHitsoundsToggle.Bindable = config.GetBindable<bool>(OsuSetting.BeatmapHitsounds);
}
}
}

View File

@ -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<bool> beatmapSkins = new Bindable<bool>();
private Bindable<bool> beatmapHitsounds = new Bindable<bool>();
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<TConfiguration, TValue>(Func<TConfiguration, TValue?> 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<TConfiguration, TValue>(Func<TConfiguration, TValue> 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<bool>(OsuSetting.BeatmapSkins);
beatmapSkins.ValueChanged += val => onSourceChanged();
beatmapSkins.TriggerChange();
beatmapHitsounds = config.GetBindable<bool>(OsuSetting.BeatmapHitsounds);
beatmapHitsounds.ValueChanged += val => onSourceChanged();
beatmapHitsounds.TriggerChange();
}
protected override void LoadComplete()
{
base.LoadComplete();