mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 09:03:01 +08:00
Make versionless skins fallback to version 1.0
This commit is contained in:
parent
8438ee7e07
commit
a4208f35c4
@ -106,7 +106,7 @@ namespace osu.Game.Tests.Skins
|
|||||||
var decoder = new LegacySkinDecoder();
|
var decoder = new LegacySkinDecoder();
|
||||||
using (var resStream = TestResources.OpenResource("skin-empty.ini"))
|
using (var resStream = TestResources.OpenResource("skin-empty.ini"))
|
||||||
using (var stream = new LineBufferedReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
Assert.IsNull(decoder.Decode(stream).LegacyVersion);
|
Assert.That(decoder.Decode(stream).LegacyVersion, Is.EqualTo(1.0m));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// 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 osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
|
||||||
@ -18,6 +19,20 @@ namespace osu.Game.Skinning
|
|||||||
Configuration.AllowDefaultComboColoursFallback = false;
|
Configuration.AllowDefaultComboColoursFallback = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
||||||
|
{
|
||||||
|
switch (lookup)
|
||||||
|
{
|
||||||
|
case LegacySkinConfiguration.LegacySetting s when s == LegacySkinConfiguration.LegacySetting.Version:
|
||||||
|
if (Configuration.LegacyVersion is decimal version)
|
||||||
|
return SkinUtils.As<TValue>(new Bindable<decimal>(version));
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.GetConfig<TLookup, TValue>(lookup);
|
||||||
|
}
|
||||||
|
|
||||||
private static SkinInfo createSkinInfo(BeatmapInfo beatmap) =>
|
private static SkinInfo createSkinInfo(BeatmapInfo beatmap) =>
|
||||||
new SkinInfo { Name = beatmap.ToString(), Creator = beatmap.Metadata.Author.ToString() };
|
new SkinInfo { Name = beatmap.ToString(), Creator = beatmap.Metadata.Author.ToString() };
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ namespace osu.Game.Skinning
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Configuration = new LegacySkinConfiguration { LegacyVersion = LegacySkinConfiguration.LATEST_VERSION };
|
Configuration = new LegacySkinConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (storage != null)
|
if (storage != null)
|
||||||
@ -122,10 +122,7 @@ namespace osu.Game.Skinning
|
|||||||
switch (legacy)
|
switch (legacy)
|
||||||
{
|
{
|
||||||
case LegacySkinConfiguration.LegacySetting.Version:
|
case LegacySkinConfiguration.LegacySetting.Version:
|
||||||
if (Configuration.LegacyVersion is decimal version)
|
return SkinUtils.As<TValue>(new Bindable<decimal>(Configuration.LegacyVersion ?? LegacySkinConfiguration.LATEST_VERSION));
|
||||||
return SkinUtils.As<TValue>(new Bindable<decimal>(version));
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -52,5 +52,12 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
base.ParseLine(skin, section, line);
|
base.ParseLine(skin, section, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override LegacySkinConfiguration CreateTemplateObject()
|
||||||
|
{
|
||||||
|
var config = base.CreateTemplateObject();
|
||||||
|
config.LegacyVersion = 1.0m;
|
||||||
|
return config;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user