1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

Initial commit

This commit is contained in:
Craftplacer 2020-08-29 10:33:43 +02:00
parent 4031f2d311
commit 4cb9e1d443
11 changed files with 38 additions and 16 deletions

View File

@ -110,7 +110,7 @@ namespace osu.Game.Rulesets.Osu.Tests
this.hasColours = hasColours;
}
protected override ISkin GetSkin() => new TestBeatmapSkin(BeatmapInfo, hasColours);
protected override IBeatmapSkin GetSkin() => new TestBeatmapSkin(BeatmapInfo, hasColours);
}
private class TestBeatmapSkin : LegacyBeatmapSkin

View File

@ -80,15 +80,18 @@ namespace osu.Game.Rulesets.Osu.Tests
public class CustomSkinWorkingBeatmap : ClockBackedTestWorkingBeatmap
{
private readonly ISkinSource skin;
private readonly ISkinSource skinSource;
public CustomSkinWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock frameBasedClock, AudioManager audio, ISkinSource skin)
: base(beatmap, storyboard, frameBasedClock, audio)
{
this.skin = skin;
if (!(skinSource is IBeatmapSkin))
throw new ArgumentException("The provided skin source must be of type IBeatmapSkin.");
skinSource = skin;
}
protected override ISkin GetSkin() => skin;
protected override IBeatmapSkin GetSkin() => (IBeatmapSkin)skinSource;
}
public class SkinProvidingPlayer : TestPlayer

View File

@ -116,7 +116,8 @@ namespace osu.Game.Tests.Gameplay
AddAssert("sample playback rate matches mod rates", () => sample.Channel.AggregateFrequency.Value == expectedRate);
}
private class TestSkin : LegacySkin
// TODO: adding IBeatmapSkin changes are as minimal as possible, but this shouldn't exist or should be reworked to work with LegacyBeatmapSkin
private class TestSkin : LegacySkin, IBeatmapSkin
{
public TestSkin(string resourceName, AudioManager audioManager)
: base(DefaultLegacySkin.Info, new TestResourceStore(resourceName), audioManager, "skin.ini")
@ -156,7 +157,7 @@ namespace osu.Game.Tests.Gameplay
this.audio = audio;
}
protected override ISkin GetSkin() => new TestSkin("test-sample", audio);
protected override IBeatmapSkin GetSkin() => new TestSkin("test-sample", audio);
}
private class TestDrawableStoryboardSample : DrawableStoryboardSample

View File

@ -140,7 +140,7 @@ namespace osu.Game.Beatmaps
return storyboard;
}
protected override ISkin GetSkin()
protected override IBeatmapSkin GetSkin()
{
try
{

View File

@ -44,7 +44,7 @@ namespace osu.Game.Beatmaps
/// <summary>
/// Retrieves the <see cref="Skin"/> which this <see cref="WorkingBeatmap"/> provides.
/// </summary>
ISkin Skin { get; }
IBeatmapSkin Skin { get; }
/// <summary>
/// Constructs a playable <see cref="IBeatmap"/> from <see cref="Beatmap"/> using the applicable converters for a specific <see cref="RulesetInfo"/>.

View File

@ -44,7 +44,7 @@ namespace osu.Game.Beatmaps
background = new RecyclableLazy<Texture>(GetBackground, BackgroundStillValid);
waveform = new RecyclableLazy<Waveform>(GetWaveform);
storyboard = new RecyclableLazy<Storyboard>(GetStoryboard);
skin = new RecyclableLazy<ISkin>(GetSkin);
skin = new RecyclableLazy<IBeatmapSkin>(GetSkin);
total_count.Value++;
}
@ -275,10 +275,10 @@ namespace osu.Game.Beatmaps
private readonly RecyclableLazy<Storyboard> storyboard;
public bool SkinLoaded => skin.IsResultAvailable;
public ISkin Skin => skin.Value;
public IBeatmapSkin Skin => skin.Value;
protected virtual ISkin GetSkin() => new DefaultSkin();
private readonly RecyclableLazy<ISkin> skin;
protected virtual IBeatmapSkin GetSkin() => new DefaultBeatmapSkin();
private readonly RecyclableLazy<IBeatmapSkin> skin;
/// <summary>
/// Transfer pieces of a beatmap to a new one, where possible, to save on loading.

View File

@ -11,7 +11,7 @@ namespace osu.Game.Skinning
/// <summary>
/// A container which overrides existing skin options with beatmap-local values.
/// </summary>
public class BeatmapSkinProvidingContainer : SkinProvidingContainer
public class BeatmapSkinProvidingContainer : SkinProvidingContainer, IBeatmapSkin
{
private readonly Bindable<bool> beatmapSkins = new Bindable<bool>();
private readonly Bindable<bool> beatmapHitsounds = new Bindable<bool>();
@ -21,7 +21,7 @@ namespace osu.Game.Skinning
protected override bool AllowTextureLookup(string componentName) => beatmapSkins.Value;
protected override bool AllowSampleLookup(ISampleInfo componentName) => beatmapHitsounds.Value;
public BeatmapSkinProvidingContainer(ISkin skin)
public BeatmapSkinProvidingContainer(IBeatmapSkin skin)
: base(skin)
{
}

View File

@ -0,0 +1,9 @@
// 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.
namespace osu.Game.Skinning
{
public class DefaultBeatmapSkin : DefaultSkin, IBeatmapSkin
{
}
}

View File

@ -0,0 +1,9 @@
// 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.
namespace osu.Game.Skinning
{
public interface IBeatmapSkin : ISkin
{
}
}

View File

@ -11,7 +11,7 @@ using osu.Game.Rulesets.Objects.Legacy;
namespace osu.Game.Skinning
{
public class LegacyBeatmapSkin : LegacySkin
public class LegacyBeatmapSkin : LegacySkin, IBeatmapSkin
{
protected override bool AllowManiaSkin => false;
protected override bool UseCustomSampleBanks => true;

View File

@ -188,7 +188,7 @@ namespace osu.Game.Tests.Beatmaps
this.resourceStore = resourceStore;
}
protected override ISkin GetSkin() => new LegacyBeatmapSkin(skinBeatmapInfo, resourceStore, AudioManager);
protected override IBeatmapSkin GetSkin() => new LegacyBeatmapSkin(skinBeatmapInfo, resourceStore, AudioManager);
}
}
}