mirror of
https://github.com/ppy/osu
synced 2025-01-07 14:49:57 +00:00
Merge pull request #13463 from Pasi4K5/enhance-mod-settings-text-box-visibility
Enhance text box visibility in mod settings
This commit is contained in:
commit
b871ee4e71
@ -2,16 +2,20 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
public class SettingsNumberBox : SettingsItem<string>
|
||||
{
|
||||
protected override Drawable CreateControl() => new OsuNumberBox
|
||||
protected override Drawable CreateControl() => new NumberBox
|
||||
{
|
||||
Margin = new MarginPadding { Top = 5 },
|
||||
RelativeSizeAxes = Axes.X,
|
||||
};
|
||||
|
||||
public class NumberBox : SettingsTextBox.TextBox
|
||||
{
|
||||
protected override bool CanAddCharacter(char character) => char.IsNumber(character);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,60 @@
|
||||
// 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;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
public class SettingsTextBox : SettingsItem<string>
|
||||
{
|
||||
protected override Drawable CreateControl() => new OsuTextBox
|
||||
protected override Drawable CreateControl() => new TextBox
|
||||
{
|
||||
Margin = new MarginPadding { Top = 5 },
|
||||
RelativeSizeAxes = Axes.X,
|
||||
CommitOnFocusLost = true,
|
||||
};
|
||||
|
||||
public class TextBox : OsuTextBox
|
||||
{
|
||||
private const float border_thickness = 3;
|
||||
|
||||
private Color4 borderColourFocused;
|
||||
private Color4 borderColourUnfocused;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colour)
|
||||
{
|
||||
borderColourUnfocused = colour.Gray4.Opacity(0.5f);
|
||||
borderColourFocused = BorderColour;
|
||||
|
||||
updateBorder();
|
||||
}
|
||||
|
||||
protected override void OnFocus(FocusEvent e)
|
||||
{
|
||||
base.OnFocus(e);
|
||||
|
||||
updateBorder();
|
||||
}
|
||||
|
||||
protected override void OnFocusLost(FocusLostEvent e)
|
||||
{
|
||||
base.OnFocusLost(e);
|
||||
|
||||
updateBorder();
|
||||
}
|
||||
|
||||
private void updateBorder()
|
||||
{
|
||||
BorderThickness = border_thickness;
|
||||
BorderColour = HasFocus ? borderColourFocused : borderColourUnfocused;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.Settings;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
@ -50,7 +49,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
}
|
||||
}
|
||||
|
||||
private readonly OsuNumberBox seedNumberBox;
|
||||
private readonly SettingsNumberBox.NumberBox seedNumberBox;
|
||||
|
||||
public SeedControl()
|
||||
{
|
||||
@ -76,7 +75,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
seedNumberBox = new OsuNumberBox
|
||||
seedNumberBox = new SettingsNumberBox.NumberBox
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
CommitOnFocusLost = true
|
||||
|
Loading…
Reference in New Issue
Block a user