Merge pull request #13423 from frenzibyte/transformers-per-skin

Refactor ruleset skin transforming logic to be per-`ISkin` rather than one `ISkinSource`
This commit is contained in:
Dean Herbert
2021-06-22 21:24:56 +09:00
committed by GitHub
23 changed files with 414 additions and 248 deletions

View File

@ -116,12 +116,12 @@ namespace osu.Game.Tests.Visual.Gameplay
private class TestOsuRuleset : OsuRuleset
{
public override ISkin CreateLegacySkinProvider(ISkinSource source, IBeatmap beatmap) => new TestOsuLegacySkinTransformer(source);
public override ISkin CreateLegacySkinProvider(ISkin skin, IBeatmap beatmap) => new TestOsuLegacySkinTransformer(skin);
private class TestOsuLegacySkinTransformer : OsuLegacySkinTransformer
{
public TestOsuLegacySkinTransformer(ISkinSource source)
: base(source)
public TestOsuLegacySkinTransformer(ISkin skin)
: base(skin)
{
}
}

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using NUnit.Framework;
@ -167,7 +168,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public void Disable()
{
allow = false;
TriggerSourceChanged();
OnSourceChanged();
}
public SwitchableSkinProvidingContainer(ISkin skin)
@ -330,6 +331,8 @@ namespace osu.Game.Tests.Visual.Gameplay
public ISkin FindProvider(Func<ISkin, bool> lookupFunction) => throw new NotImplementedException();
public IEnumerable<ISkin> AllSources => throw new NotImplementedException();
public event Action SourceChanged
{
add { }

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
@ -146,7 +147,8 @@ namespace osu.Game.Tests.Visual.Gameplay
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => source?.GetTexture(componentName, wrapModeS, wrapModeT);
public ISample GetSample(ISampleInfo sampleInfo) => source?.GetSample(sampleInfo);
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => source?.GetConfig<TLookup, TValue>(lookup);
public ISkin FindProvider(Func<ISkin, bool> lookupFunction) => source?.FindProvider(lookupFunction);
public ISkin FindProvider(Func<ISkin, bool> lookupFunction) => lookupFunction(this) ? this : source?.FindProvider(lookupFunction);
public IEnumerable<ISkin> AllSources => new[] { this }.Concat(source?.AllSources ?? Enumerable.Empty<ISkin>());
public void TriggerSourceChanged()
{