Visual settings: Ignore beatmap skin

This commit is contained in:
TocoToucan 2018-04-20 18:17:57 +03:00
parent 295e1c78ee
commit 606e088713
3 changed files with 33 additions and 4 deletions

View File

@ -15,6 +15,7 @@ protected override void InitialiseDefaults()
// UI/selection defaults
Set(OsuSetting.Ruleset, 0, 0, int.MaxValue);
Set(OsuSetting.Skin, 0, 0, int.MaxValue);
Set(OsuSetting.IgnoreBeatmapSkin, false);
Set(OsuSetting.BeatmapDetailTab, BeatmapDetailTab.Details);
@ -133,6 +134,7 @@ public enum OsuSetting
Skin,
ScreenshotFormat,
ScreenshotCaptureMenuCursor,
SongSelectRightMouseScroll
SongSelectRightMouseScroll,
IgnoreBeatmapSkin
}
}

View File

@ -15,6 +15,7 @@ public class VisualSettings : PlayerSettingsGroup
private readonly PlayerSliderBar<double> dimSliderBar;
private readonly PlayerSliderBar<double> blurSliderBar;
private readonly PlayerCheckbox showStoryboardToggle;
private readonly PlayerCheckbox ignoreBeatmapSkinToggle;
public VisualSettings()
{
@ -34,7 +35,8 @@ public VisualSettings()
{
Text = "Toggles:"
},
showStoryboardToggle = new PlayerCheckbox { LabelText = "Storyboards" }
showStoryboardToggle = new PlayerCheckbox { LabelText = "Storyboards" },
ignoreBeatmapSkinToggle = new PlayerCheckbox { LabelText = "Ignore beatmap skin" }
};
}
@ -44,6 +46,7 @@ private void load(OsuConfigManager config)
dimSliderBar.Bindable = config.GetBindable<double>(OsuSetting.DimLevel);
blurSliderBar.Bindable = config.GetBindable<double>(OsuSetting.BlurLevel);
showStoryboardToggle.Bindable = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
ignoreBeatmapSkinToggle.Bindable = config.GetBindable<bool>(OsuSetting.IgnoreBeatmapSkin);
}
}
}

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,9 +16,21 @@ public class LocalSkinOverrideContainer : Container, ISkinSource
{
public event Action SourceChanged;
public Drawable GetDrawableComponent(string componentName) => source.GetDrawableComponent(componentName) ?? fallbackSource?.GetDrawableComponent(componentName);
public Drawable GetDrawableComponent(string componentName)
{
Drawable sourceDrawable;
if (!ignoreBeatmapSkin && (sourceDrawable = source.GetDrawableComponent(componentName)) != null)
return sourceDrawable;
return fallbackSource?.GetDrawableComponent(componentName);
}
public Texture GetTexture(string componentName) => source.GetTexture(componentName) ?? fallbackSource.GetTexture(componentName);
public Texture GetTexture(string componentName)
{
Texture sourceTexture;
if (!ignoreBeatmapSkin && (sourceTexture = source.GetTexture(componentName)) != null)
return sourceTexture;
return fallbackSource.GetTexture(componentName);
}
public SampleChannel GetSample(string sampleName) => source.GetSample(sampleName) ?? fallbackSource?.GetSample(sampleName);
@ -60,6 +74,16 @@ protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnl
return dependencies;
}
private Bindable<bool> ignoreBeatmapSkin = new Bindable<bool>();
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
ignoreBeatmapSkin = config.GetBindable<bool>(OsuSetting.IgnoreBeatmapSkin);
ignoreBeatmapSkin.ValueChanged += val => onSourceChanged();
ignoreBeatmapSkin.TriggerChange();
}
protected override void LoadComplete()
{
base.LoadComplete();