1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 17:02:55 +08:00

Refactor editor selection/blueprint components to be generic

This commit is contained in:
Dean Herbert 2021-04-27 15:40:35 +09:00
parent 2d17219c8f
commit fca173225a
3 changed files with 16 additions and 5 deletions

View File

@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
@ -13,6 +12,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Testing;
using osu.Game.Configuration;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu;
@ -50,7 +50,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
Alpha = 0.7f,
Alpha = 0.9f,
},
new FillFlowContainer
{
@ -106,12 +106,23 @@ namespace osu.Game.Tests.Visual.Gameplay
private IReadOnlyList<Drawable> createSkinSourceComponents()
{
var hudComponents = typeof(SkinnableHUDComponent).Assembly.GetTypes().Where(t => typeof(SkinnableHUDComponent).IsAssignableFrom(t)).ToArray();
Drawable[] hudComponents = typeof(SkinnableHUDComponent).Assembly
.GetTypes()
.Where(t => typeof(SkinnableHUDComponent).IsAssignableFrom(t))
.Where(t => !t.IsAbstract)
.Select(t => Activator.CreateInstance(t) as Drawable)
.ToArray();
List<Drawable> drawables = new List<Drawable>();
foreach (var component in hudComponents)
{
drawables.Add(new OsuSpriteText
{
Text = component.GetType().Name
});
drawables.AddRange(component.CreateSettingsControls());
}
return drawables;
}

View File

@ -6,7 +6,7 @@ using osu.Game.Skinning;
namespace osu.Game.Screens.Play.HUD
{
public class SkinnableComboCounter : SkinnableDrawable, IComboCounter
public class SkinnableComboCounter : SkinnableHUDComponent, IComboCounter
{
public Bindable<int> Current { get; } = new Bindable<int>();

View File

@ -9,7 +9,7 @@ using osu.Game.Skinning;
namespace osu.Game.Screens.Play.HUD
{
public class SkinnableHealthDisplay : SkinnableDrawable, IHealthDisplay
public class SkinnableHealthDisplay : SkinnableHUDComponent, IHealthDisplay
{
public Bindable<double> Current { get; } = new BindableDouble(1)
{