diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneCommentEditor.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneCommentEditor.cs index a0a1c2481f..aeaca5ac21 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneCommentEditor.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneCommentEditor.cs @@ -118,12 +118,7 @@ namespace osu.Game.Tests.Visual.UserInterface public bool ButtonLoading => CommitButton.ChildrenOfType().Single().IsPresent && !CommitButton.ChildrenOfType().Single().IsPresent; - public TestCommentEditor() - { - OnCommit = onCommit; - } - - private void onCommit(string value) + protected override void OnCommit(string value) { CommitButton.IsLoadingSpinnerShown = true; CommittedText = value; @@ -138,6 +133,7 @@ namespace osu.Game.Tests.Visual.UserInterface private partial class TestCancellableCommentEditor : CancellableCommentEditor { public new FillFlowContainer ButtonsContainer => base.ButtonsContainer; + protected override LocalisableString FooterText => @"Wow, another one. Sicc"; public bool Cancelled { get; private set; } @@ -147,6 +143,10 @@ namespace osu.Game.Tests.Visual.UserInterface OnCancel = () => Cancelled = true; } + protected override void OnCommit(string text) + { + } + protected override LocalisableString CommitButtonText => @"Save"; protected override LocalisableString TextBoxPlaceholder => @"Multiline textboxes soon"; } diff --git a/osu.Game/Overlays/Comments/CommentEditor.cs b/osu.Game/Overlays/Comments/CommentEditor.cs index 092a92f935..c7c66874d1 100644 --- a/osu.Game/Overlays/Comments/CommentEditor.cs +++ b/osu.Game/Overlays/Comments/CommentEditor.cs @@ -11,7 +11,6 @@ using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.Sprites; using osuTK.Graphics; using osu.Game.Graphics.UserInterface; -using System; using osuTK; using osu.Framework.Bindables; using osu.Framework.Localisation; @@ -23,8 +22,6 @@ namespace osu.Game.Overlays.Comments { private const int side_padding = 8; - public Action? OnCommit; - protected abstract LocalisableString FooterText { get; } protected abstract LocalisableString CommitButtonText { get; } @@ -98,11 +95,7 @@ namespace osu.Game.Overlays.Comments Text = CommitButtonText, Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, - Action = () => - { - OnCommit?.Invoke(Current.Value); - Current.Value = string.Empty; - } + Action = () => OnCommit(Current.Value) } } } @@ -121,6 +114,8 @@ namespace osu.Game.Overlays.Comments Current.BindValueChanged(text => CommitButton.IsBlocked.Value = string.IsNullOrEmpty(text.NewValue), true); } + protected abstract void OnCommit(string text); + private partial class EditorTextBox : BasicTextBox { protected override float LeftRightPadding => side_padding; @@ -151,7 +146,7 @@ namespace osu.Game.Overlays.Comments protected override Drawable GetDrawableCharacter(char c) => new FallingDownContainer { AutoSizeAxes = Axes.Both, - Child = new OsuSpriteText { Text = c.ToString(), Font = OsuFont.GetFont(size: CalculatedTextSize) }, + Child = new OsuSpriteText { Text = c.ToString(), Font = OsuFont.GetFont(size: CalculatedTextSize) } }; }