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

Rename CreateLegacySkinProvider to CreateSkinTransformer and apply to all skins

This commit is contained in:
Dean Herbert 2022-09-15 17:36:14 +09:00
parent 96a89f4fca
commit c7f8f948b9
9 changed files with 60 additions and 18 deletions

View File

@ -182,7 +182,16 @@ namespace osu.Game.Rulesets.Catch
public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => new CatchDifficultyCalculator(RulesetInfo, beatmap);
public override ISkin CreateLegacySkinProvider(ISkin skin, IBeatmap beatmap) => new CatchLegacySkinTransformer(skin);
public override ISkin? CreateSkinTransformer(ISkin skin, IBeatmap beatmap)
{
switch (skin)
{
case LegacySkin:
return new CatchLegacySkinTransformer(skin);
}
return null;
}
public override PerformanceCalculator CreatePerformanceCalculator() => new CatchPerformanceCalculator();

View File

@ -62,7 +62,16 @@ namespace osu.Game.Rulesets.Mania
public override HitObjectComposer CreateHitObjectComposer() => new ManiaHitObjectComposer(this);
public override ISkin CreateLegacySkinProvider(ISkin skin, IBeatmap beatmap) => new ManiaLegacySkinTransformer(skin, beatmap);
public override ISkin? CreateSkinTransformer(ISkin skin, IBeatmap beatmap)
{
switch (skin)
{
case LegacySkin:
return new ManiaLegacySkinTransformer(skin, beatmap);
}
return null;
}
public override IEnumerable<Mod> ConvertFromLegacyMods(LegacyMods mods)
{

View File

@ -71,7 +71,7 @@ namespace osu.Game.Rulesets.Osu.Tests
var tintingSkin = skinManager.GetSkin(DefaultLegacySkin.CreateInfo());
tintingSkin.Configuration.ConfigDictionary["AllowSliderBallTint"] = "1";
var provider = Ruleset.Value.CreateInstance().CreateLegacySkinProvider(tintingSkin, Beatmap.Value.Beatmap);
var provider = Ruleset.Value.CreateInstance().CreateSkinTransformer(tintingSkin, Beatmap.Value.Beatmap);
Child = new SkinProvidingContainer(provider)
{

View File

@ -231,7 +231,16 @@ namespace osu.Game.Rulesets.Osu
public override RulesetSettingsSubsection CreateSettings() => new OsuSettingsSubsection(this);
public override ISkin CreateLegacySkinProvider(ISkin skin, IBeatmap beatmap) => new OsuLegacySkinTransformer(skin);
public override ISkin? CreateSkinTransformer(ISkin skin, IBeatmap beatmap)
{
switch (skin)
{
case LegacySkin:
return new OsuLegacySkinTransformer(skin);
}
return null;
}
public int LegacyID => 0;

View File

@ -43,7 +43,16 @@ namespace osu.Game.Rulesets.Taiko
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap, this);
public override ISkin CreateLegacySkinProvider(ISkin skin, IBeatmap beatmap) => new TaikoLegacySkinTransformer(skin);
public override ISkin? CreateSkinTransformer(ISkin skin, IBeatmap beatmap)
{
switch (skin)
{
case LegacySkin:
return new TaikoLegacySkinTransformer(skin);
}
return null;
}
public const string SHORT_NAME = "taiko";

View File

@ -122,7 +122,7 @@ namespace osu.Game.Tests.Visual.Gameplay
private class TestOsuRuleset : OsuRuleset
{
public override ISkin CreateLegacySkinProvider(ISkin skin, IBeatmap beatmap) => new TestOsuLegacySkinTransformer(skin);
public override ISkin CreateSkinTransformer(ISkin skin, IBeatmap beatmap) => new TestOsuLegacySkinTransformer(skin);
private class TestOsuLegacySkinTransformer : OsuLegacySkinTransformer
{

View File

@ -200,7 +200,13 @@ namespace osu.Game.Rulesets
public ModAutoplay? GetAutoplayMod() => CreateMod<ModAutoplay>();
public virtual ISkin? CreateLegacySkinProvider(ISkin skin, IBeatmap beatmap) => null;
/// <summary>
/// Create a transformer which adds lookups specific to a ruleset to skin sources.
/// </summary>
/// <param name="skin">The source skin.</param>
/// <param name="beatmap">The current beatmap.</param>
/// <returns>A skin with a transformer applied, or null if no transformation is provided by this ruleset.</returns>
public virtual ISkin? CreateSkinTransformer(ISkin skin, IBeatmap beatmap) => null;
protected Ruleset()
{

View File

@ -41,7 +41,7 @@ namespace osu.Game.Skinning
Ruleset = ruleset;
Beatmap = beatmap;
InternalChild = new BeatmapSkinProvidingContainer(beatmapSkin is LegacySkin ? GetLegacyRulesetTransformedSkin(beatmapSkin) : beatmapSkin)
InternalChild = new BeatmapSkinProvidingContainer(beatmapSkin is LegacySkin ? GetRulesetTransformedSkin(beatmapSkin) : beatmapSkin)
{
Child = Content = new Container
{
@ -67,16 +67,16 @@ namespace osu.Game.Skinning
Debug.Assert(ParentSource != null);
foreach (var skin in ParentSource.AllSources)
foreach (var source in ParentSource.AllSources)
{
switch (skin)
switch (source)
{
case LegacySkin legacySkin:
sources.Add(GetLegacyRulesetTransformedSkin(legacySkin));
case Skin skin:
sources.Add(GetRulesetTransformedSkin(skin));
break;
default:
sources.Add(skin);
sources.Add(source);
break;
}
}
@ -94,16 +94,16 @@ namespace osu.Game.Skinning
SetSources(sources);
}
protected ISkin GetLegacyRulesetTransformedSkin(ISkin legacySkin)
protected ISkin GetRulesetTransformedSkin(ISkin skin)
{
if (legacySkin == null)
if (skin == null)
return null;
var rulesetTransformed = Ruleset.CreateLegacySkinProvider(legacySkin, Beatmap);
var rulesetTransformed = Ruleset.CreateSkinTransformer(skin, Beatmap);
if (rulesetTransformed != null)
return rulesetTransformed;
return legacySkin;
return skin;
}
protected override void Dispose(bool isDisposing)

View File

@ -83,7 +83,7 @@ namespace osu.Game.Tests.Visual
ISkin provider = skin;
if (provider is LegacySkin legacyProvider)
provider = Ruleset.Value.CreateInstance().CreateLegacySkinProvider(legacyProvider, beatmap);
provider = Ruleset.Value.CreateInstance().CreateSkinTransformer(legacyProvider, beatmap);
var children = new Container
{