From cc764afe3e6d9c6fd9385ecf13de3314b6dd698c Mon Sep 17 00:00:00 2001 From: Liam DeVoe Date: Wed, 21 Jun 2023 00:58:43 -0400 Subject: [PATCH] use two separate buttons for posting / login --- osu.Game/Overlays/Comments/CommentEditor.cs | 46 ++++++++++++--------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/osu.Game/Overlays/Comments/CommentEditor.cs b/osu.Game/Overlays/Comments/CommentEditor.cs index 4898d8b7c7..8f7c8ced57 100644 --- a/osu.Game/Overlays/Comments/CommentEditor.cs +++ b/osu.Game/Overlays/Comments/CommentEditor.cs @@ -31,6 +31,7 @@ namespace osu.Game.Overlays.Comments protected readonly Bindable Current = new Bindable(string.Empty); private RoundedButton commitButton = null!; + private RoundedButton logInButton = null!; private LoadingSpinner loadingSpinner = null!; protected TextBox TextBox { get; private set; } = null!; @@ -122,9 +123,19 @@ namespace osu.Game.Overlays.Comments AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(5, 0), - Child = commitButton = new EditorButton + Children = new Drawable[] { - Action = () => commitOrLogIn(Current.Value) + commitButton = new EditorButton + { + Action = () => OnCommit(Current.Value), + Text = GetCommitButtonText(true) + }, + logInButton = new EditorButton + { + Width = 100, + Action = () => loginOverlay?.Show(), + Text = GetCommitButtonText(false) + } } }, loadingSpinner = new LoadingSpinner @@ -154,29 +165,24 @@ namespace osu.Game.Overlays.Comments protected abstract void OnCommit(string text); - private void commitOrLogIn(string text) - { - if (!API.IsLoggedIn) - { - loginOverlay?.Show(); - return; - } - - OnCommit(text); - } - - private void updateCommitButtonState() - { - bool textBoxValid = loadingSpinner.State.Value == Visibility.Hidden && !string.IsNullOrEmpty(Current.Value); - commitButton.Enabled.Value = textBoxValid || !API.IsLoggedIn; - commitButton.Text = GetCommitButtonText(API.IsLoggedIn); - } + private void updateCommitButtonState() => + commitButton.Enabled.Value = loadingSpinner.State.Value == Visibility.Hidden && !string.IsNullOrEmpty(Current.Value); private void updateStateForLoggedIn() { TextBox.PlaceholderText = GetPlaceholderText(API.IsLoggedIn); TextBox.ReadOnly = !API.IsLoggedIn; - updateCommitButtonState(); + + if (API.IsLoggedIn) + { + commitButton.Show(); + logInButton.Hide(); + } + else + { + commitButton.Hide(); + logInButton.Show(); + } } private partial class EditorTextBox : OsuTextBox