mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 01:17:35 +09:00
Add OsuModSettingsTextBox
and OsuModSettingsNumberBox
This commit is contained in:
parent
c644e11e5a
commit
fe39a47797
10
osu.Game/Graphics/UserInterface/OsuModSettingsNumberBox.cs
Normal file
10
osu.Game/Graphics/UserInterface/OsuModSettingsNumberBox.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
44
osu.Game/Graphics/UserInterface/OsuModSettingsTextBox.cs
Normal file
44
osu.Game/Graphics/UserInterface/OsuModSettingsTextBox.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ namespace osu.Game.Overlays.Settings
|
|||||||
{
|
{
|
||||||
public class SettingsTextBox : SettingsItem<string>
|
public class SettingsTextBox : SettingsItem<string>
|
||||||
{
|
{
|
||||||
protected override Drawable CreateControl() => new OsuTextBox
|
protected override Drawable CreateControl() => new OsuModSettingsTextBox
|
||||||
{
|
{
|
||||||
Margin = new MarginPadding { Top = 5 },
|
Margin = new MarginPadding { Top = 5 },
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
|
@ -50,7 +50,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly OsuNumberBox seedNumberBox;
|
private readonly OsuModSettingsNumberBox seedNumberBox;
|
||||||
|
|
||||||
public SeedControl()
|
public SeedControl()
|
||||||
{
|
{
|
||||||
@ -76,7 +76,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
{
|
{
|
||||||
new Drawable[]
|
new Drawable[]
|
||||||
{
|
{
|
||||||
seedNumberBox = new OsuNumberBox
|
seedNumberBox = new OsuModSettingsNumberBox
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
CommitOnFocusLost = true
|
CommitOnFocusLost = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user