1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 20:22:55 +08:00

Add OsuModSettingsTextBox and OsuModSettingsNumberBox

This commit is contained in:
Pasi4K5 2021-06-12 00:34:53 +02:00
parent c644e11e5a
commit fe39a47797
4 changed files with 57 additions and 3 deletions

View File

@ -0,0 +1,10 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
namespace osu.Game.Graphics.UserInterface
{
public class OsuModSettingsNumberBox : OsuModSettingsTextBox
{
protected override bool CanAddCharacter(char character) => char.IsNumber(character);
}
}

View File

@ -0,0 +1,44 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics.Colour;
using osu.Framework.Input.Events;
namespace osu.Game.Graphics.UserInterface
{
public class OsuModSettingsTextBox : OsuTextBox
{
private const float border_thickness = 3;
private SRGBColour borderColourFocused;
private SRGBColour borderColourUnfocused;
[BackgroundDependencyLoader]
private void load(OsuColour colour)
{
borderColourUnfocused = colour.Gray4.Opacity(0.5f);
borderColourFocused = BorderColour;
BorderThickness = border_thickness;
BorderColour = borderColourUnfocused;
}
protected override void OnFocus(FocusEvent e)
{
base.OnFocus(e);
BorderThickness = border_thickness;
BorderColour = borderColourFocused;
}
protected override void OnFocusLost(FocusLostEvent e)
{
base.OnFocusLost(e);
BorderThickness = border_thickness;
BorderColour = borderColourUnfocused;
}
}
}

View File

@ -8,7 +8,7 @@ namespace osu.Game.Overlays.Settings
{
public class SettingsTextBox : SettingsItem<string>
{
protected override Drawable CreateControl() => new OsuTextBox
protected override Drawable CreateControl() => new OsuModSettingsTextBox
{
Margin = new MarginPadding { Top = 5 },
RelativeSizeAxes = Axes.X,

View File

@ -50,7 +50,7 @@ namespace osu.Game.Rulesets.Mods
}
}
private readonly OsuNumberBox seedNumberBox;
private readonly OsuModSettingsNumberBox seedNumberBox;
public SeedControl()
{
@ -76,7 +76,7 @@ namespace osu.Game.Rulesets.Mods
{
new Drawable[]
{
seedNumberBox = new OsuNumberBox
seedNumberBox = new OsuModSettingsNumberBox
{
RelativeSizeAxes = Axes.X,
CommitOnFocusLost = true