From df692b091c415ee0c9090d00698130368023626b Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 24 Sep 2019 18:22:02 +0900 Subject: [PATCH] Make LabelledComponent generic --- .../UserInterface/TestSceneLabelledComponent.cs | 8 ++++---- osu.Game.Tournament/Screens/SetupScreen.cs | 2 +- .../LabelledComponents/LabelledComponent.cs | 11 ++++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledComponent.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledComponent.cs index 73e0191adb..a762d561c2 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledComponent.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledComponent.cs @@ -25,7 +25,7 @@ namespace osu.Game.Tests.Visual.UserInterface { AddStep("create component", () => { - LabelledComponent component; + LabelledComponent component; Child = new Container { @@ -33,7 +33,7 @@ namespace osu.Game.Tests.Visual.UserInterface Origin = Anchor.Centre, Width = 500, AutoSizeAxes = Axes.Y, - Child = component = padded ? (LabelledComponent)new PaddedLabelledComponent() : new NonPaddedLabelledComponent(), + Child = component = padded ? (LabelledComponent)new PaddedLabelledComponent() : new NonPaddedLabelledComponent(), }; component.Label = "a sample component"; @@ -41,7 +41,7 @@ namespace osu.Game.Tests.Visual.UserInterface }); } - private class PaddedLabelledComponent : LabelledComponent + private class PaddedLabelledComponent : LabelledComponent { public PaddedLabelledComponent() : base(true) @@ -57,7 +57,7 @@ namespace osu.Game.Tests.Visual.UserInterface }; } - private class NonPaddedLabelledComponent : LabelledComponent + private class NonPaddedLabelledComponent : LabelledComponent { public NonPaddedLabelledComponent() : base(false) diff --git a/osu.Game.Tournament/Screens/SetupScreen.cs b/osu.Game.Tournament/Screens/SetupScreen.cs index 1cb4917790..7a44e7a0e1 100644 --- a/osu.Game.Tournament/Screens/SetupScreen.cs +++ b/osu.Game.Tournament/Screens/SetupScreen.cs @@ -89,7 +89,7 @@ namespace osu.Game.Tournament.Screens }; } - private class ActionableInfo : LabelledComponent + private class ActionableInfo : LabelledComponent { private OsuButton button; diff --git a/osu.Game/Screens/Edit/Setup/Components/LabelledComponents/LabelledComponent.cs b/osu.Game/Screens/Edit/Setup/Components/LabelledComponents/LabelledComponent.cs index 19e9c329d6..770065cb0e 100644 --- a/osu.Game/Screens/Edit/Setup/Components/LabelledComponents/LabelledComponent.cs +++ b/osu.Game/Screens/Edit/Setup/Components/LabelledComponents/LabelledComponent.cs @@ -11,7 +11,8 @@ using osuTK; namespace osu.Game.Screens.Edit.Setup.Components.LabelledComponents { - public abstract class LabelledComponent : CompositeDrawable + public abstract class LabelledComponent : CompositeDrawable + where T : Drawable { protected const float CONTENT_PADDING_VERTICAL = 10; protected const float CONTENT_PADDING_HORIZONTAL = 15; @@ -20,15 +21,15 @@ namespace osu.Game.Screens.Edit.Setup.Components.LabelledComponents /// /// The component that is being displayed. /// - protected readonly Drawable Component; + protected readonly T Component; private readonly OsuTextFlowContainer labelText; private readonly OsuTextFlowContainer descriptionText; /// - /// Creates a new . + /// Creates a new . /// - /// Whether the component should be padded or should be expanded to the bounds of this . + /// Whether the component should be padded or should be expanded to the bounds of this . protected LabelledComponent(bool padded) { RelativeSizeAxes = Axes.X; @@ -127,6 +128,6 @@ namespace osu.Game.Screens.Edit.Setup.Components.LabelledComponents /// Creates the component that should be displayed. /// /// The component. - protected abstract Drawable CreateComponent(); + protected abstract T CreateComponent(); } }