mirror of
https://github.com/ppy/osu.git
synced 2025-03-24 11:07:20 +08:00
Moved SkinProvidingContainer bindable fetching to common method. Replaced redundant test boolean declarations with inline values.
This commit is contained in:
parent
1248d39d7e
commit
8b95817f7a
@ -36,41 +36,41 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
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)
|
||||
[TestCase(true, true)]
|
||||
[TestCase(true, false)]
|
||||
[TestCase(false, true)]
|
||||
[TestCase(false, false)]
|
||||
public void TestBeatmapComboColours(bool userHasCustomColours, bool useBeatmapSkin)
|
||||
{
|
||||
ExposedPlayer player = null;
|
||||
|
||||
configureSettings(useBeatmapSkin, useBeatmapColour);
|
||||
configureSettings(useBeatmapSkin, true);
|
||||
AddStep("load coloured beatmap", () => player = loadBeatmap(userHasCustomColours, true));
|
||||
AddUntilStep("wait for player", () => player.IsLoaded);
|
||||
|
||||
AddAssert("is beatmap skin colours", () => player.UsableComboColours.SequenceEqual(TestBeatmapSkin.Colours));
|
||||
}
|
||||
|
||||
[TestCase(true, false)]
|
||||
[TestCase(false, false)]
|
||||
public void TestBeatmapComboColoursOverride(bool useBeatmapSkin, bool useBeatmapColour)
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void TestBeatmapComboColoursOverride(bool useBeatmapSkin)
|
||||
{
|
||||
ExposedPlayer player = null;
|
||||
|
||||
configureSettings(useBeatmapSkin, useBeatmapColour);
|
||||
configureSettings(useBeatmapSkin, false);
|
||||
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)
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void TestBeatmapComboColoursOverrideWithDefaultColours(bool useBeatmapSkin)
|
||||
{
|
||||
ExposedPlayer player = null;
|
||||
|
||||
configureSettings(useBeatmapSkin, useBeatmapColour);
|
||||
configureSettings(useBeatmapSkin, false);
|
||||
AddStep("load coloured beatmap", () => player = loadBeatmap(false, true));
|
||||
AddUntilStep("wait for player", () => player.IsLoaded);
|
||||
|
||||
|
@ -80,30 +80,28 @@ namespace osu.Game.Skinning
|
||||
switch (global)
|
||||
{
|
||||
case GlobalSkinColours.ComboColours:
|
||||
var bindable = skin.GetConfig<TLookup, TValue>(lookup);
|
||||
if (bindable != null && AllowColourLookup)
|
||||
return bindable;
|
||||
else
|
||||
return fallbackSource?.GetConfig<TLookup, TValue>(lookup);
|
||||
return getBindable<TLookup, TValue>(lookup, AllowColourLookup);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if (AllowConfigurationLookup)
|
||||
{
|
||||
var bindable = skin.GetConfig<TLookup, TValue>(lookup);
|
||||
if (bindable != null)
|
||||
return bindable;
|
||||
}
|
||||
|
||||
break;
|
||||
return getBindable<TLookup, TValue>(lookup, AllowConfigurationLookup);
|
||||
}
|
||||
}
|
||||
|
||||
return fallbackSource?.GetConfig<TLookup, TValue>(lookup);
|
||||
}
|
||||
|
||||
private IBindable<TValue> getBindable<TLookup, TValue>(TLookup lookup, bool bindableReturnCheck)
|
||||
{
|
||||
var bindable = skin.GetConfig<TLookup, TValue>(lookup);
|
||||
if (bindable != null && bindableReturnCheck)
|
||||
return bindable;
|
||||
else
|
||||
return fallbackSource?.GetConfig<TLookup, TValue>(lookup);
|
||||
}
|
||||
|
||||
protected virtual void TriggerSourceChanged() => SourceChanged?.Invoke();
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
|
Loading…
x
Reference in New Issue
Block a user