From f013a1e37fd8f9184bbaa6e6c13841d611aa06e7 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 5 Nov 2021 10:12:41 +0300 Subject: [PATCH] Move `CreateContent()` to BDL --- .../Graphics/UserInterface/LoadingButton.cs | 40 ++++++++++++------- osu.Game/Overlays/Comments/CommentEditor.cs | 3 +- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/LoadingButton.cs b/osu.Game/Graphics/UserInterface/LoadingButton.cs index 81dc023d7e..a75cf0639c 100644 --- a/osu.Game/Graphics/UserInterface/LoadingButton.cs +++ b/osu.Game/Graphics/UserInterface/LoadingButton.cs @@ -1,7 +1,9 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; using osu.Game.Graphics.Containers; using osuTK; @@ -22,15 +24,9 @@ namespace osu.Game.Graphics.UserInterface Enabled.Value = !isLoading; if (value) - { loading.Show(); - OnLoadStarted(); - } else - { loading.Hide(); - OnLoadFinished(); - } } } @@ -44,18 +40,34 @@ namespace osu.Game.Graphics.UserInterface protected LoadingButton() { - AddRange(new[] + Add(loading = new LoadingSpinner { - CreateContent(), - loading = new LoadingSpinner - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(12) - } + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(12), + Depth = -1, }); } + [BackgroundDependencyLoader] + private void load() + { + Add(CreateContent()); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + loading.State.BindValueChanged(s => + { + if (s.NewValue == Visibility.Visible) + OnLoadStarted(); + else + OnLoadFinished(); + }, true); + } + protected override bool OnClick(ClickEvent e) { if (!Enabled.Value) diff --git a/osu.Game/Overlays/Comments/CommentEditor.cs b/osu.Game/Overlays/Comments/CommentEditor.cs index 1847de8660..3ff4cfad4a 100644 --- a/osu.Game/Overlays/Comments/CommentEditor.cs +++ b/osu.Game/Overlays/Comments/CommentEditor.cs @@ -198,8 +198,6 @@ namespace osu.Game.Overlays.Comments IdleColour = colourProvider.Light4; HoverColour = colourProvider.Light3; blockedBackground.Colour = colourProvider.Background5; - - drawableText.Text = text; } protected override void LoadComplete() @@ -237,6 +235,7 @@ namespace osu.Game.Overlays.Comments Origin = Anchor.Centre, Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), Margin = new MarginPadding { Horizontal = 20 }, + Text = text, } } };