mirror of
https://github.com/osukey/osukey.git
synced 2025-07-23 11:20:03 +09:00
Consume new method rather than caching skin sources on top of Player
This commit is contained in:
@ -101,15 +101,10 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
AddAssert("is custom hyper dash fruit colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashFruitColour == TestSkin.HYPER_DASH_FRUIT_COLOUR);
|
AddAssert("is custom hyper dash fruit colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashFruitColour == TestSkin.HYPER_DASH_FRUIT_COLOUR);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ExposedPlayer CreateTestPlayer(bool userHasCustomColours) => new CatchExposedPlayer(userHasCustomColours);
|
protected override ExposedPlayer CreateTestPlayer() => new CatchExposedPlayer();
|
||||||
|
|
||||||
private class CatchExposedPlayer : ExposedPlayer
|
private class CatchExposedPlayer : ExposedPlayer
|
||||||
{
|
{
|
||||||
public CatchExposedPlayer(bool userHasCustomColours)
|
|
||||||
: base(userHasCustomColours)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color4 UsableHyperDashColour =>
|
public Color4 UsableHyperDashColour =>
|
||||||
GameplayClockContainer.ChildrenOfType<BeatmapSkinProvidingContainer>()
|
GameplayClockContainer.ChildrenOfType<BeatmapSkinProvidingContainer>()
|
||||||
.First()
|
.First()
|
||||||
|
@ -21,7 +21,6 @@ using osu.Game.Graphics.Sprites;
|
|||||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Storyboards;
|
using osu.Game.Storyboards;
|
||||||
using osu.Game.Tests.Visual;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Tests
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
{
|
{
|
||||||
@ -99,7 +98,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private AudioManager audio { get; set; }
|
private AudioManager audio { get; set; }
|
||||||
|
|
||||||
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new SkinProvidingPlayer(testUserSkin);
|
protected override ISkin GetPlayerSkin() => testUserSkin;
|
||||||
|
|
||||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) => new CustomSkinWorkingBeatmap(beatmap, storyboard, Clock, audio, testBeatmapSkin);
|
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) => new CustomSkinWorkingBeatmap(beatmap, storyboard, Clock, audio, testBeatmapSkin);
|
||||||
|
|
||||||
@ -116,27 +115,6 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
protected override ISkin GetSkin() => skin;
|
protected override ISkin GetSkin() => skin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SkinProvidingPlayer : TestPlayer
|
|
||||||
{
|
|
||||||
private readonly TestSource userSkin;
|
|
||||||
|
|
||||||
public SkinProvidingPlayer(TestSource userSkin)
|
|
||||||
{
|
|
||||||
this.userSkin = userSkin;
|
|
||||||
}
|
|
||||||
|
|
||||||
private DependencyContainer dependencies;
|
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
||||||
{
|
|
||||||
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
||||||
|
|
||||||
dependencies.CacheAs<ISkinSource>(userSkin);
|
|
||||||
|
|
||||||
return dependencies;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class TestSource : ISkinSource
|
public class TestSource : ISkinSource
|
||||||
{
|
{
|
||||||
private readonly string identifier;
|
private readonly string identifier;
|
||||||
@ -164,8 +142,8 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
|
|
||||||
public ISample GetSample(ISampleInfo sampleInfo) => null;
|
public ISample GetSample(ISampleInfo sampleInfo) => null;
|
||||||
|
|
||||||
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => default;
|
|
||||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => null;
|
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => null;
|
||||||
|
|
||||||
public ISkin FindProvider(Func<ISkin, bool> lookupFunction) => null;
|
public ISkin FindProvider(Func<ISkin, bool> lookupFunction) => null;
|
||||||
|
|
||||||
public event Action SourceChanged;
|
public event Action SourceChanged;
|
||||||
|
@ -47,15 +47,11 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
|
|
||||||
private readonly TestResourceStore userSkinResourceStore = new TestResourceStore();
|
private readonly TestResourceStore userSkinResourceStore = new TestResourceStore();
|
||||||
private readonly TestResourceStore beatmapSkinResourceStore = new TestResourceStore();
|
private readonly TestResourceStore beatmapSkinResourceStore = new TestResourceStore();
|
||||||
private SkinSourceDependencyContainer dependencies;
|
|
||||||
private IBeatmap currentTestBeatmap;
|
private IBeatmap currentTestBeatmap;
|
||||||
|
|
||||||
protected sealed override bool HasCustomSteps => true;
|
protected sealed override bool HasCustomSteps => true;
|
||||||
protected override bool Autoplay => true;
|
protected override bool Autoplay => true;
|
||||||
|
|
||||||
protected sealed override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
||||||
=> new DependencyContainer(dependencies = new SkinSourceDependencyContainer(base.CreateChildDependencies(parent)));
|
|
||||||
|
|
||||||
protected sealed override IBeatmap CreateBeatmap(RulesetInfo ruleset) => currentTestBeatmap;
|
protected sealed override IBeatmap CreateBeatmap(RulesetInfo ruleset) => currentTestBeatmap;
|
||||||
|
|
||||||
protected sealed override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
protected sealed override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
||||||
@ -63,6 +59,8 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
|
|
||||||
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new TestPlayer(false);
|
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new TestPlayer(false);
|
||||||
|
|
||||||
|
protected override ISkin GetPlayerSkin() => Skin;
|
||||||
|
|
||||||
protected void CreateTestWithBeatmap(string filename)
|
protected void CreateTestWithBeatmap(string filename)
|
||||||
{
|
{
|
||||||
CreateTest(() =>
|
CreateTest(() =>
|
||||||
@ -109,8 +107,7 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Need to refresh the cached skin source to refresh the skin resource store.
|
Skin = new LegacySkin(userSkinInfo, this);
|
||||||
dependencies.SkinSource = new SkinProvidingContainer(Skin = new LegacySkin(userSkinInfo, this));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,39 +129,6 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private class SkinSourceDependencyContainer : IReadOnlyDependencyContainer
|
|
||||||
{
|
|
||||||
public ISkinSource SkinSource;
|
|
||||||
|
|
||||||
private readonly IReadOnlyDependencyContainer fallback;
|
|
||||||
|
|
||||||
public SkinSourceDependencyContainer(IReadOnlyDependencyContainer fallback)
|
|
||||||
{
|
|
||||||
this.fallback = fallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
public object Get(Type type)
|
|
||||||
{
|
|
||||||
if (type == typeof(ISkinSource))
|
|
||||||
return SkinSource;
|
|
||||||
|
|
||||||
return fallback.Get(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public object Get(Type type, CacheInfo info)
|
|
||||||
{
|
|
||||||
if (type == typeof(ISkinSource))
|
|
||||||
return SkinSource;
|
|
||||||
|
|
||||||
return fallback.Get(type, info);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Inject<T>(T instance) where T : class
|
|
||||||
{
|
|
||||||
// Never used directly
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TestResourceStore : IResourceStore<byte[]>
|
private class TestResourceStore : IResourceStore<byte[]>
|
||||||
{
|
{
|
||||||
public readonly List<string> PerformedLookups = new List<string>();
|
public readonly List<string> PerformedLookups = new List<string>();
|
||||||
|
@ -4,13 +4,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Screens.Play;
|
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -49,36 +47,24 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
|
|
||||||
protected virtual ExposedPlayer LoadBeatmap(bool userHasCustomColours)
|
protected virtual ExposedPlayer LoadBeatmap(bool userHasCustomColours)
|
||||||
{
|
{
|
||||||
ExposedPlayer player;
|
|
||||||
|
|
||||||
Beatmap.Value = testBeatmap;
|
Beatmap.Value = testBeatmap;
|
||||||
|
|
||||||
LoadScreen(player = CreateTestPlayer(userHasCustomColours));
|
ExposedPlayer player = CreateTestPlayer();
|
||||||
|
|
||||||
|
player.Skin = new TestSkin(userHasCustomColours);
|
||||||
|
|
||||||
|
LoadScreen(player);
|
||||||
|
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual ExposedPlayer CreateTestPlayer(bool userHasCustomColours) => new ExposedPlayer(userHasCustomColours);
|
protected virtual ExposedPlayer CreateTestPlayer() => new ExposedPlayer();
|
||||||
|
|
||||||
protected class ExposedPlayer : Player
|
protected class ExposedPlayer : TestPlayer
|
||||||
{
|
{
|
||||||
protected readonly bool UserHasCustomColours;
|
public ExposedPlayer()
|
||||||
|
: base(false, false)
|
||||||
public ExposedPlayer(bool userHasCustomColours)
|
|
||||||
: base(new PlayerConfiguration
|
|
||||||
{
|
|
||||||
AllowPause = false,
|
|
||||||
ShowResults = false,
|
|
||||||
})
|
|
||||||
{
|
{
|
||||||
UserHasCustomColours = userHasCustomColours;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
||||||
{
|
|
||||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
||||||
dependencies.CacheAs<ISkinSource>(new TestSkin(UserHasCustomColours));
|
|
||||||
return dependencies;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IReadOnlyList<Color4> UsableComboColours =>
|
public IReadOnlyList<Color4> UsableComboColours =>
|
||||||
|
@ -5,7 +5,6 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Rulesets;
|
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
@ -15,15 +14,12 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
protected LegacySkin LegacySkin { get; private set; }
|
protected LegacySkin LegacySkin { get; private set; }
|
||||||
|
|
||||||
private ISkinSource legacySkinSource;
|
protected override ISkin GetPlayerSkin() => LegacySkin;
|
||||||
|
|
||||||
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new SkinProvidingPlayer(legacySkinSource);
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(SkinManager skins)
|
private void load(SkinManager skins)
|
||||||
{
|
{
|
||||||
LegacySkin = new DefaultLegacySkin(skins);
|
LegacySkin = new DefaultLegacySkin(skins);
|
||||||
legacySkinSource = new SkinProvidingContainer(LegacySkin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
@ -48,16 +44,5 @@ namespace osu.Game.Tests.Visual
|
|||||||
t.Reload();
|
t.Reload();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SkinProvidingPlayer : TestPlayer
|
|
||||||
{
|
|
||||||
[Cached(typeof(ISkinSource))]
|
|
||||||
private readonly ISkinSource skinSource;
|
|
||||||
|
|
||||||
public SkinProvidingPlayer(ISkinSource skinSource)
|
|
||||||
{
|
|
||||||
this.skinSource = skinSource;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user