mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 02:02:53 +08:00
Add ability to retrieve serialisable drawables for specific rulesets
This commit is contained in:
parent
ffb99364b9
commit
2267aa1ac2
@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Extensions;
|
using osu.Game.Extensions;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
@ -100,13 +101,18 @@ namespace osu.Game.Skinning
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Type[] GetAllAvailableDrawables()
|
/// <summary>
|
||||||
|
/// Retrieve all types available which support serialisation.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ruleset">The ruleset to filter results to. If <c>null</c>, global components will be returned instead.</param>
|
||||||
|
public static Type[] GetAllAvailableDrawables(RulesetInfo? ruleset = null)
|
||||||
{
|
{
|
||||||
return typeof(OsuGame).Assembly.GetTypes()
|
return (ruleset?.CreateInstance().GetType() ?? typeof(OsuGame))
|
||||||
.Where(t => !t.IsInterface && !t.IsAbstract)
|
.Assembly.GetTypes()
|
||||||
.Where(t => typeof(ISerialisableDrawable).IsAssignableFrom(t))
|
.Where(t => !t.IsInterface && !t.IsAbstract)
|
||||||
.OrderBy(t => t.Name)
|
.Where(t => typeof(ISerialisableDrawable).IsAssignableFrom(t))
|
||||||
.ToArray();
|
.OrderBy(t => t.Name)
|
||||||
|
.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user