mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 01:02:54 +08:00
Apply nullability to SkinComponentToolbox
and split out reflection method to get all skinnable components
This commit is contained in:
parent
f9f9b65c86
commit
5b98a73edc
@ -98,5 +98,14 @@ namespace osu.Game.Screens.Play.HUD
|
||||
return Drawable.Empty();
|
||||
}
|
||||
}
|
||||
|
||||
public static Type[] GetAllAvailableDrawables()
|
||||
{
|
||||
return typeof(OsuGame).Assembly.GetTypes()
|
||||
.Where(t => !t.IsInterface && !t.IsAbstract)
|
||||
.Where(t => typeof(ISkinnableDrawable).IsAssignableFrom(t))
|
||||
.OrderBy(t => t.Name)
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,8 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -16,24 +13,25 @@ using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens.Edit.Components;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Skinning.Editor
|
||||
{
|
||||
public class SkinComponentToolbox : EditorSidebarSection
|
||||
{
|
||||
public Action<Type> RequestPlacement;
|
||||
public Action<Type>? RequestPlacement;
|
||||
|
||||
private readonly CompositeDrawable target;
|
||||
private readonly CompositeDrawable? target;
|
||||
|
||||
public SkinComponentToolbox(CompositeDrawable target = null)
|
||||
private FillFlowContainer fill = null!;
|
||||
|
||||
public SkinComponentToolbox(CompositeDrawable? target = null)
|
||||
: base("Components")
|
||||
{
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
private FillFlowContainer fill;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -52,12 +50,7 @@ namespace osu.Game.Skinning.Editor
|
||||
{
|
||||
fill.Clear();
|
||||
|
||||
var skinnableTypes = typeof(OsuGame).Assembly.GetTypes()
|
||||
.Where(t => !t.IsInterface && !t.IsAbstract)
|
||||
.Where(t => typeof(ISkinnableDrawable).IsAssignableFrom(t))
|
||||
.OrderBy(t => t.Name)
|
||||
.ToArray();
|
||||
|
||||
var skinnableTypes = SkinnableInfo.GetAllAvailableDrawables();
|
||||
foreach (var type in skinnableTypes)
|
||||
attemptAddComponent(type);
|
||||
}
|
||||
@ -90,21 +83,21 @@ namespace osu.Game.Skinning.Editor
|
||||
|
||||
public class ToolboxComponentButton : OsuButton
|
||||
{
|
||||
public Action<Type>? RequestPlacement;
|
||||
|
||||
protected override bool ShouldBeConsideredForInput(Drawable child) => false;
|
||||
|
||||
public override bool PropagateNonPositionalInputSubTree => false;
|
||||
|
||||
private readonly Drawable component;
|
||||
private readonly CompositeDrawable dependencySource;
|
||||
private readonly CompositeDrawable? dependencySource;
|
||||
|
||||
public Action<Type> RequestPlacement;
|
||||
|
||||
private Container innerContainer;
|
||||
private Container innerContainer = null!;
|
||||
|
||||
private const float contracted_size = 60;
|
||||
private const float expanded_size = 120;
|
||||
|
||||
public ToolboxComponentButton(Drawable component, CompositeDrawable dependencySource)
|
||||
public ToolboxComponentButton(Drawable component, CompositeDrawable? dependencySource)
|
||||
{
|
||||
this.component = component;
|
||||
this.dependencySource = dependencySource;
|
||||
@ -184,9 +177,9 @@ namespace osu.Game.Skinning.Editor
|
||||
|
||||
public class DependencyBorrowingContainer : Container
|
||||
{
|
||||
private readonly CompositeDrawable donor;
|
||||
private readonly CompositeDrawable? donor;
|
||||
|
||||
public DependencyBorrowingContainer(CompositeDrawable donor)
|
||||
public DependencyBorrowingContainer(CompositeDrawable? donor)
|
||||
{
|
||||
this.donor = donor;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user