mirror of https://github.com/ppy/osu
Fix deserialise failing with some old skins
This commit is contained in:
parent
3943fe96f4
commit
885d832e98
|
@ -248,9 +248,33 @@ public void UpdateDrawableTarget(SkinnableContainer targetContainer)
|
|||
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