mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:12:57 +08:00
Make commit action abstract
This commit is contained in:
parent
930cd15649
commit
387326db0d
@ -118,12 +118,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
public bool ButtonLoading => CommitButton.ChildrenOfType<LoadingSpinner>().Single().IsPresent && !CommitButton.ChildrenOfType<SpriteText>().Single().IsPresent;
|
public bool ButtonLoading => CommitButton.ChildrenOfType<LoadingSpinner>().Single().IsPresent && !CommitButton.ChildrenOfType<SpriteText>().Single().IsPresent;
|
||||||
|
|
||||||
public TestCommentEditor()
|
protected override void OnCommit(string value)
|
||||||
{
|
|
||||||
OnCommit = onCommit;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onCommit(string value)
|
|
||||||
{
|
{
|
||||||
CommitButton.IsLoadingSpinnerShown = true;
|
CommitButton.IsLoadingSpinnerShown = true;
|
||||||
CommittedText = value;
|
CommittedText = value;
|
||||||
@ -138,6 +133,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
private partial class TestCancellableCommentEditor : CancellableCommentEditor
|
private partial class TestCancellableCommentEditor : CancellableCommentEditor
|
||||||
{
|
{
|
||||||
public new FillFlowContainer ButtonsContainer => base.ButtonsContainer;
|
public new FillFlowContainer ButtonsContainer => base.ButtonsContainer;
|
||||||
|
|
||||||
protected override LocalisableString FooterText => @"Wow, another one. Sicc";
|
protected override LocalisableString FooterText => @"Wow, another one. Sicc";
|
||||||
|
|
||||||
public bool Cancelled { get; private set; }
|
public bool Cancelled { get; private set; }
|
||||||
@ -147,6 +143,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
OnCancel = () => Cancelled = true;
|
OnCancel = () => Cancelled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnCommit(string text)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
protected override LocalisableString CommitButtonText => @"Save";
|
protected override LocalisableString CommitButtonText => @"Save";
|
||||||
protected override LocalisableString TextBoxPlaceholder => @"Multiline textboxes soon";
|
protected override LocalisableString TextBoxPlaceholder => @"Multiline textboxes soon";
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ using osu.Framework.Graphics.UserInterface;
|
|||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using System;
|
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
@ -23,8 +22,6 @@ namespace osu.Game.Overlays.Comments
|
|||||||
{
|
{
|
||||||
private const int side_padding = 8;
|
private const int side_padding = 8;
|
||||||
|
|
||||||
public Action<string>? OnCommit;
|
|
||||||
|
|
||||||
protected abstract LocalisableString FooterText { get; }
|
protected abstract LocalisableString FooterText { get; }
|
||||||
|
|
||||||
protected abstract LocalisableString CommitButtonText { get; }
|
protected abstract LocalisableString CommitButtonText { get; }
|
||||||
@ -98,11 +95,7 @@ namespace osu.Game.Overlays.Comments
|
|||||||
Text = CommitButtonText,
|
Text = CommitButtonText,
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.CentreRight,
|
||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
Action = () =>
|
Action = () => OnCommit(Current.Value)
|
||||||
{
|
|
||||||
OnCommit?.Invoke(Current.Value);
|
|
||||||
Current.Value = string.Empty;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,6 +114,8 @@ namespace osu.Game.Overlays.Comments
|
|||||||
Current.BindValueChanged(text => CommitButton.IsBlocked.Value = string.IsNullOrEmpty(text.NewValue), true);
|
Current.BindValueChanged(text => CommitButton.IsBlocked.Value = string.IsNullOrEmpty(text.NewValue), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract void OnCommit(string text);
|
||||||
|
|
||||||
private partial class EditorTextBox : BasicTextBox
|
private partial class EditorTextBox : BasicTextBox
|
||||||
{
|
{
|
||||||
protected override float LeftRightPadding => side_padding;
|
protected override float LeftRightPadding => side_padding;
|
||||||
@ -151,7 +146,7 @@ namespace osu.Game.Overlays.Comments
|
|||||||
protected override Drawable GetDrawableCharacter(char c) => new FallingDownContainer
|
protected override Drawable GetDrawableCharacter(char c) => new FallingDownContainer
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
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) }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user