1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 01:52:55 +08:00

Make commit action abstract

This commit is contained in:
ansel 2023-01-06 22:51:57 +03:00
parent 930cd15649
commit 387326db0d
2 changed files with 10 additions and 15 deletions

View File

@ -118,12 +118,7 @@ namespace osu.Game.Tests.Visual.UserInterface
public bool ButtonLoading => CommitButton.ChildrenOfType<LoadingSpinner>().Single().IsPresent && !CommitButton.ChildrenOfType<SpriteText>().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";
}

View File

@ -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<string>? 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) }
};
}