1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:37:28 +08:00

Move combo colours to GlobalSkinColours

This commit is contained in:
Dean Herbert 2020-02-07 14:58:07 +09:00
parent 55a8e88609
commit 7460018cd3
10 changed files with 22 additions and 19 deletions

View File

@ -89,7 +89,7 @@ namespace osu.Game.Rulesets.Osu.Tests
public IReadOnlyList<Color4> UsableComboColours => public IReadOnlyList<Color4> UsableComboColours =>
GameplayClockContainer.ChildrenOfType<BeatmapSkinProvidingContainer>() GameplayClockContainer.ChildrenOfType<BeatmapSkinProvidingContainer>()
.First() .First()
.GetConfig<GlobalSkinConfiguration, IReadOnlyList<Color4>>(GlobalSkinConfiguration.ComboColours)?.Value; .GetConfig<GlobalSkinColours, IReadOnlyList<Color4>>(GlobalSkinColours.ComboColours)?.Value;
} }
private class CustomSkinWorkingBeatmap : ClockBackedTestWorkingBeatmap private class CustomSkinWorkingBeatmap : ClockBackedTestWorkingBeatmap

View File

@ -126,10 +126,10 @@ namespace osu.Game.Tests.Gameplay
{ {
switch (lookup) switch (lookup)
{ {
case GlobalSkinConfiguration global: case GlobalSkinColours global:
switch (global) switch (global)
{ {
case GlobalSkinConfiguration.ComboColours: case GlobalSkinColours.ComboColours:
return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>>(ComboColours)); return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>>(ComboColours));
} }

View File

@ -95,7 +95,7 @@ namespace osu.Game.Tests.Skins
[Test] [Test]
public void TestGlobalLookup() public void TestGlobalLookup()
{ {
AddAssert("Check combo colours", () => requester.GetConfig<GlobalSkinConfiguration, IReadOnlyList<Color4>>(GlobalSkinConfiguration.ComboColours)?.Value?.Count > 0); AddAssert("Check combo colours", () => requester.GetConfig<GlobalSkinColours, IReadOnlyList<Color4>>(GlobalSkinColours.ComboColours)?.Value?.Count > 0);
} }
[Test] [Test]
@ -121,7 +121,7 @@ namespace osu.Game.Tests.Skins
public void TestEmptyComboColours() public void TestEmptyComboColours()
{ {
AddAssert("Check retrieved combo colours is skin default colours", () => AddAssert("Check retrieved combo colours is skin default colours", () =>
requester.GetConfig<GlobalSkinConfiguration, IReadOnlyList<Color4>>(GlobalSkinConfiguration.ComboColours)?.Value?.SequenceEqual(SkinConfiguration.DefaultComboColours) ?? false); requester.GetConfig<GlobalSkinColours, IReadOnlyList<Color4>>(GlobalSkinColours.ComboColours)?.Value?.SequenceEqual(SkinConfiguration.DefaultComboColours) ?? false);
} }
[Test] [Test]
@ -136,7 +136,7 @@ namespace osu.Game.Tests.Skins
AddStep("Disallow default colours fallback in source2", () => source2.Configuration.AllowDefaultComboColoursFallback = false); AddStep("Disallow default colours fallback in source2", () => source2.Configuration.AllowDefaultComboColoursFallback = false);
AddAssert("Check retrieved combo colours from source1", () => AddAssert("Check retrieved combo colours from source1", () =>
requester.GetConfig<GlobalSkinConfiguration, IReadOnlyList<Color4>>(GlobalSkinConfiguration.ComboColours)?.Value?.SequenceEqual(source1.Configuration.ComboColours) ?? false); requester.GetConfig<GlobalSkinColours, IReadOnlyList<Color4>>(GlobalSkinColours.ComboColours)?.Value?.SequenceEqual(source1.Configuration.ComboColours) ?? false);
} }
[Test] [Test]

View File

@ -349,7 +349,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
{ {
if (HitObject is IHasComboInformation combo) if (HitObject is IHasComboInformation combo)
{ {
var comboColours = CurrentSkin.GetConfig<GlobalSkinConfiguration, IReadOnlyList<Color4>>(GlobalSkinConfiguration.ComboColours)?.Value; var comboColours = CurrentSkin.GetConfig<GlobalSkinColours, IReadOnlyList<Color4>>(GlobalSkinColours.ComboColours)?.Value;
AccentColour.Value = comboColours?.Count > 0 ? comboColours[combo.ComboIndex % comboColours.Count] : Color4.White; AccentColour.Value = comboColours?.Count > 0 ? comboColours[combo.ComboIndex % comboColours.Count] : Color4.White;
} }
} }

View File

@ -123,7 +123,7 @@ namespace osu.Game.Screens.Menu
Color4 defaultColour = Color4.White.Opacity(0.2f); Color4 defaultColour = Color4.White.Opacity(0.2f);
if (user.Value?.IsSupporter ?? false) if (user.Value?.IsSupporter ?? false)
AccentColour = skin.Value.GetConfig<GlobalSkinColour, Color4>(GlobalSkinColour.MenuGlow)?.Value ?? defaultColour; AccentColour = skin.Value.GetConfig<GlobalSkinColours, Color4>(GlobalSkinColours.MenuGlow)?.Value ?? defaultColour;
else else
AccentColour = defaultColour; AccentColour = defaultColour;
} }

View File

@ -112,7 +112,7 @@ namespace osu.Game.Screens.Menu
Color4 baseColour = colours.Blue; Color4 baseColour = colours.Blue;
if (user.Value?.IsSupporter ?? false) if (user.Value?.IsSupporter ?? false)
baseColour = skin.Value.GetConfig<GlobalSkinColour, Color4>(GlobalSkinColour.MenuGlow)?.Value ?? baseColour; baseColour = skin.Value.GetConfig<GlobalSkinColours, Color4>(GlobalSkinColours.MenuGlow)?.Value ?? baseColour;
// linear colour looks better in this case, so let's use it for now. // linear colour looks better in this case, so let's use it for now.
Color4 gradientDark = baseColour.Opacity(0).ToLinear(); Color4 gradientDark = baseColour.Opacity(0).ToLinear();

View File

@ -31,10 +31,10 @@ namespace osu.Game.Skinning
{ {
// todo: this code is pulled from LegacySkin and should not exist. // todo: this code is pulled from LegacySkin and should not exist.
// will likely change based on how databased storage of skin configuration goes. // will likely change based on how databased storage of skin configuration goes.
case GlobalSkinConfiguration global: case GlobalSkinColours global:
switch (global) switch (global)
{ {
case GlobalSkinConfiguration.ComboColours: case GlobalSkinColours.ComboColours:
return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>>(Configuration.ComboColours)); return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>>(Configuration.ComboColours));
} }

View File

@ -3,8 +3,9 @@
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
public enum GlobalSkinColour public enum GlobalSkinColours
{ {
ComboColours,
MenuGlow MenuGlow
} }
} }

View File

@ -5,6 +5,5 @@ namespace osu.Game.Skinning
{ {
public enum GlobalSkinConfiguration public enum GlobalSkinConfiguration
{ {
ComboColours
} }
} }

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -68,22 +69,22 @@ namespace osu.Game.Skinning
{ {
switch (lookup) switch (lookup)
{ {
case GlobalSkinConfiguration global: case GlobalSkinColours colour:
switch (global) switch (colour)
{ {
case GlobalSkinConfiguration.ComboColours: case GlobalSkinColours.ComboColours:
var comboColours = Configuration.ComboColours; var comboColours = Configuration.ComboColours;
if (comboColours != null) if (comboColours != null)
return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>>(comboColours)); return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>>(comboColours));
break; break;
default:
return SkinUtils.As<TValue>(getCustomColour(colour.ToString()));
} }
break; break;
case GlobalSkinColour colour:
return SkinUtils.As<TValue>(getCustomColour(colour.ToString()));
case LegacySkinConfiguration.LegacySetting legacy: case LegacySkinConfiguration.LegacySetting legacy:
switch (legacy) switch (legacy)
{ {
@ -100,6 +101,8 @@ namespace osu.Game.Skinning
return SkinUtils.As<TValue>(getCustomColour(customColour.Lookup.ToString())); return SkinUtils.As<TValue>(getCustomColour(customColour.Lookup.ToString()));
default: default:
// handles lookups like GlobalSkinConfiguration
try try
{ {
if (Configuration.ConfigDictionary.TryGetValue(lookup.ToString(), out var val)) if (Configuration.ConfigDictionary.TryGetValue(lookup.ToString(), out var val))