mirror of
https://github.com/ppy/osu.git
synced 2024-12-17 02:12:56 +08:00
Merge pull request #29577 from peppy/skin-deserialise-fix
Fix some older lazer skins failing to load properly
This commit is contained in:
commit
a30fe9daff
BIN
osu.Game.Tests/Resources/Archives/argon-invalid-drawable.osk
Normal file
BIN
osu.Game.Tests/Resources/Archives/argon-invalid-drawable.osk
Normal file
Binary file not shown.
@ -12,6 +12,7 @@ using osu.Framework.IO.Stores;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.IO.Archives;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Screens.Play.HUD.HitErrorMeters;
|
||||
using osu.Game.Skinning;
|
||||
@ -125,6 +126,18 @@ namespace osu.Game.Tests.Skins
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDeserialiseInvalidDrawables()
|
||||
{
|
||||
using (var stream = TestResources.OpenResource("Archives/argon-invalid-drawable.osk"))
|
||||
using (var storage = new ZipArchiveReader(stream))
|
||||
{
|
||||
var skin = new TestSkin(new SkinInfo(), null, storage);
|
||||
|
||||
Assert.That(skin.LayoutInfos.Any(kvp => kvp.Value.AllDrawables.Any(d => d.Type == typeof(StarFountain))), Is.False);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDeserialiseModifiedClassic()
|
||||
{
|
||||
|
@ -248,9 +248,33 @@ namespace osu.Game.Skinning
|
||||
applyMigration(layout, target, i);
|
||||
|
||||
layout.Version = SkinLayoutInfo.LATEST_VERSION;
|
||||
|
||||
foreach (var kvp in layout.DrawableInfo.ToArray())
|
||||
{
|
||||
foreach (var di in kvp.Value)
|
||||
{
|
||||
if (!isValidDrawable(di))
|
||||
layout.DrawableInfo[kvp.Key] = kvp.Value.Where(i => i.Type != di.Type).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
private bool isValidDrawable(SerialisedDrawableInfo di)
|
||||
{
|
||||
if (!typeof(ISerialisableDrawable).IsAssignableFrom(di.Type))
|
||||
return false;
|
||||
|
||||
foreach (var child in di.Children)
|
||||
{
|
||||
if (!isValidDrawable(child))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void applyMigration(SkinLayoutInfo layout, GlobalSkinnableContainers target, int version)
|
||||
{
|
||||
switch (version)
|
||||
|
Loading…
Reference in New Issue
Block a user