Added beatmap colour settings checkbox and associated tests.

This commit is contained in:
Mysfit 2021-01-13 00:09:22 -05:00
parent 10fd4cf7c9
commit 5f10bcce02
6 changed files with 110 additions and 10 deletions

View File

@ -7,9 +7,12 @@
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.IO.Stores;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Rulesets.Osu.Configuration;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Play;
using osu.Game.Skinning;
@ -24,34 +27,81 @@ public class TestSceneLegacyBeatmapSkin : ScreenTestScene
[Resolved]
private AudioManager audio { get; set; }
[TestCase(true)]
[TestCase(false)]
public void TestBeatmapComboColours(bool customSkinColoursPresent)
private readonly Bindable<bool> beatmapSkins = new Bindable<bool>();
private readonly Bindable<bool> beatmapColours = new Bindable<bool>();
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
config.BindWith(OsuSetting.BeatmapSkins, beatmapSkins);
config.BindWith(OsuSetting.BeatmapColours, beatmapColours);
}
[TestCase(true, true, true)]
[TestCase(true, false, true)]
[TestCase(false, true, true)]
[TestCase(false, false, true)]
public void TestBeatmapComboColours(bool userHasCustomColours, bool useBeatmapSkin, bool useBeatmapColour)
{
ExposedPlayer player = null;
AddStep("load coloured beatmap", () => player = loadBeatmap(customSkinColoursPresent, true));
configureSettings(useBeatmapSkin, useBeatmapColour);
AddStep("load coloured beatmap", () => player = loadBeatmap(userHasCustomColours, true));
AddUntilStep("wait for player", () => player.IsLoaded);
AddAssert("is beatmap skin colours", () => player.UsableComboColours.SequenceEqual(TestBeatmapSkin.Colours));
}
[Test]
public void TestBeatmapNoComboColours()
[TestCase(true, false)]
[TestCase(false, false)]
public void TestBeatmapComboColoursOverride(bool useBeatmapSkin, bool useBeatmapColour)
{
ExposedPlayer player = null;
configureSettings(useBeatmapSkin, useBeatmapColour);
AddStep("load coloured beatmap", () => player = loadBeatmap(true, true));
AddUntilStep("wait for player", () => player.IsLoaded);
AddAssert("is user custom skin colours", () => player.UsableComboColours.SequenceEqual(TestSkin.Colours));
}
[TestCase(true, false)]
[TestCase(false, false)]
public void TestBeatmapComboColoursOverrideWithDefaultColours(bool useBeatmapSkin, bool useBeatmapColour)
{
ExposedPlayer player = null;
configureSettings(useBeatmapSkin, useBeatmapColour);
AddStep("load coloured beatmap", () => player = loadBeatmap(false, true));
AddUntilStep("wait for player", () => player.IsLoaded);
AddAssert("is default user skin colours", () => player.UsableComboColours.SequenceEqual(SkinConfiguration.DefaultComboColours));
}
[TestCase(true, true)]
[TestCase(false, true)]
[TestCase(true, false)]
[TestCase(false, false)]
public void TestBeatmapNoComboColours(bool useBeatmapSkin, bool useBeatmapColour)
{
ExposedPlayer player = null;
configureSettings(useBeatmapSkin, useBeatmapColour);
AddStep("load no-colour beatmap", () => player = loadBeatmap(false, false));
AddUntilStep("wait for player", () => player.IsLoaded);
AddAssert("is default user skin colours", () => player.UsableComboColours.SequenceEqual(SkinConfiguration.DefaultComboColours));
}
[Test]
public void TestBeatmapNoComboColoursSkinOverride()
[TestCase(true, true)]
[TestCase(false, true)]
[TestCase(true, false)]
[TestCase(false, false)]
public void TestBeatmapNoComboColoursSkinOverride(bool useBeatmapSkin, bool useBeatmapColour)
{
ExposedPlayer player = null;
configureSettings(useBeatmapSkin, useBeatmapColour);
AddStep("load custom-skin colour", () => player = loadBeatmap(true, false));
AddUntilStep("wait for player", () => player.IsLoaded);
@ -69,6 +119,18 @@ private ExposedPlayer loadBeatmap(bool userHasCustomColours, bool beatmapHasColo
return player;
}
private void configureSettings(bool beatmapSkins, bool beatmapColours)
{
AddStep($"{(beatmapSkins ? "enable" : "disable")} beatmap skins", () =>
{
this.beatmapSkins.Value = beatmapSkins;
});
AddStep($"{(beatmapColours ? "enable" : "disable")} beatmap colours", () =>
{
this.beatmapColours.Value = beatmapColours;
});
}
private class ExposedPlayer : Player
{
private readonly bool userHasCustomColours;

View File

@ -52,6 +52,31 @@ public void TestBeatmapSkinDefault()
checkNextHitObject(null);
}
[Test]
public void TestBeatmapColourDefault()
{
AddStep("enable user provider", () => testUserSkin.Enabled = true);
AddStep("enable beatmap skin", () => LocalConfig.Set<bool>(OsuSetting.BeatmapSkins, true));
AddStep("enable beatmap colours", () => LocalConfig.Set<bool>(OsuSetting.BeatmapColours, true));
checkNextHitObject("beatmap");
AddStep("enable beatmap skin", () => LocalConfig.Set<bool>(OsuSetting.BeatmapSkins, true));
AddStep("disable beatmap colours", () => LocalConfig.Set<bool>(OsuSetting.BeatmapColours, false));
checkNextHitObject("beatmap");
AddStep("disable beatmap skin", () => LocalConfig.Set<bool>(OsuSetting.BeatmapSkins, false));
AddStep("enable beatmap colours", () => LocalConfig.Set<bool>(OsuSetting.BeatmapColours, true));
checkNextHitObject("user");
AddStep("disable beatmap skin", () => LocalConfig.Set<bool>(OsuSetting.BeatmapSkins, false));
AddStep("disable beatmap colours", () => LocalConfig.Set<bool>(OsuSetting.BeatmapColours, false));
checkNextHitObject("user");
AddStep("disable user provider", () => testUserSkin.Enabled = false);
checkNextHitObject(null);
}
private void checkNextHitObject(string skin) =>
AddUntilStep($"check skin from {skin}", () =>
{

View File

@ -82,6 +82,7 @@ protected override void InitialiseDefaults()
Set(OsuSetting.ShowStoryboard, true);
Set(OsuSetting.BeatmapSkins, true);
Set(OsuSetting.BeatmapColours, true);
Set(OsuSetting.BeatmapHitsounds, true);
Set(OsuSetting.CursorRotation, true);
@ -250,6 +251,7 @@ public enum OsuSetting
ScreenshotCaptureMenuCursor,
SongSelectRightMouseScroll,
BeatmapSkins,
BeatmapColours,
BeatmapHitsounds,
IncreaseFirstObjectVisibility,
ScoreDisplayMode,

View File

@ -70,6 +70,11 @@ private void load(OsuConfigManager config)
Current = config.GetBindable<bool>(OsuSetting.BeatmapSkins)
},
new SettingsCheckbox
{
LabelText = "Beatmap colours",
Current = config.GetBindable<bool>(OsuSetting.BeatmapColours)
},
new SettingsCheckbox
{
LabelText = "Beatmap hitsounds",
Current = config.GetBindable<bool>(OsuSetting.BeatmapHitsounds)

View File

@ -14,6 +14,7 @@ public class VisualSettings : PlayerSettingsGroup
private readonly PlayerSliderBar<double> blurSliderBar;
private readonly PlayerCheckbox showStoryboardToggle;
private readonly PlayerCheckbox beatmapSkinsToggle;
private readonly PlayerCheckbox beatmapColorsToggle;
private readonly PlayerCheckbox beatmapHitsoundsToggle;
public VisualSettings()
@ -43,6 +44,7 @@ public VisualSettings()
},
showStoryboardToggle = new PlayerCheckbox { LabelText = "Storyboard / Video" },
beatmapSkinsToggle = new PlayerCheckbox { LabelText = "Beatmap skins" },
beatmapColorsToggle = new PlayerCheckbox { LabelText = "Beatmap colours" },
beatmapHitsoundsToggle = new PlayerCheckbox { LabelText = "Beatmap hitsounds" }
};
}
@ -54,6 +56,7 @@ private void load(OsuConfigManager config)
blurSliderBar.Current = config.GetBindable<double>(OsuSetting.BlurLevel);
showStoryboardToggle.Current = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
beatmapSkinsToggle.Current = config.GetBindable<bool>(OsuSetting.BeatmapSkins);
beatmapColorsToggle.Current = config.GetBindable<bool>(OsuSetting.BeatmapColours);
beatmapHitsoundsToggle.Current = config.GetBindable<bool>(OsuSetting.BeatmapHitsounds);
}
}

View File

@ -15,6 +15,7 @@ namespace osu.Game.Skinning
public class BeatmapSkinProvidingContainer : SkinProvidingContainer
{
private Bindable<bool> beatmapSkins;
private Bindable<bool> beatmapColours;
private Bindable<bool> beatmapHitsounds;
protected override bool AllowConfigurationLookup
@ -24,10 +25,10 @@ protected override bool AllowConfigurationLookup
if (beatmapSkins == null)
throw new InvalidOperationException($"{nameof(BeatmapSkinProvidingContainer)} needs to be loaded before being consumed.");
return beatmapSkins.Value;
return beatmapColours.Value;
}
}
protected override bool AllowDrawableLookup(ISkinComponent component)
{
if (beatmapSkins == null)
@ -62,6 +63,7 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
var config = parent.Get<OsuConfigManager>();
beatmapSkins = config.GetBindable<bool>(OsuSetting.BeatmapSkins);
beatmapColours = config.GetBindable<bool>(OsuSetting.BeatmapColours);
beatmapHitsounds = config.GetBindable<bool>(OsuSetting.BeatmapHitsounds);
return base.CreateChildDependencies(parent);
@ -71,6 +73,7 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
private void load()
{
beatmapSkins.BindValueChanged(_ => TriggerSourceChanged());
beatmapColours.BindValueChanged(_ => TriggerSourceChanged());
beatmapHitsounds.BindValueChanged(_ => TriggerSourceChanged());
}
}