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

Make OsuTextBox use OsuSpriteText.

This commit is contained in:
Dean Herbert 2017-02-08 11:19:58 +09:00
parent e720bed9e5
commit 5a89ba1040
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
2 changed files with 15 additions and 3 deletions

View File

@ -8,6 +8,7 @@ using osu.Framework.Input;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Overlays; using osu.Game.Overlays;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
@ -17,10 +18,12 @@ namespace osu.Game.Graphics.UserInterface
protected override Color4 BackgroundFocused => OsuColour.Gray(0.3f).Opacity(0.8f); protected override Color4 BackgroundFocused => OsuColour.Gray(0.3f).Opacity(0.8f);
protected override Color4 BackgroundCommit => BorderColour; protected override Color4 BackgroundCommit => BorderColour;
protected override float LeftRightPadding => 10;
public OsuTextBox() public OsuTextBox()
{ {
Height = 40; Height = 40;
TextContainer.Height = OsuSpriteText.FONT_SIZE / Height; TextContainer.Height = 0.5f;
CornerRadius = 5; CornerRadius = 5;
} }
@ -43,6 +46,8 @@ namespace osu.Game.Graphics.UserInterface
base.OnFocusLost(state); base.OnFocusLost(state);
} }
protected override SpriteText GetDrawableCharacter(char c) => new OsuSpriteText { Text = c.ToString() };
} }
public class OsuPasswordTextBox : OsuTextBox public class OsuPasswordTextBox : OsuTextBox

View File

@ -12,10 +12,11 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
public class SearchTextBox : TextBox public class SearchTextBox : OsuTextBox
{ {
protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255); protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255);
protected override Color4 BackgroundFocused => new Color4(10, 10, 10, 255); protected override Color4 BackgroundFocused => new Color4(10, 10, 10, 255);
@ -54,7 +55,6 @@ namespace osu.Game.Screens.Select
public SearchTextBox() public SearchTextBox()
{ {
Height = 35; Height = 35;
TextContainer.Padding = new MarginPadding(5);
Add(new Drawable[] Add(new Drawable[]
{ {
placeholder = new SpriteText placeholder = new SpriteText
@ -82,6 +82,13 @@ namespace osu.Game.Screens.Select
base.Update(); base.Update();
} }
protected override bool OnFocus(InputState state)
{
var result = base.OnFocus(state);
BorderThickness = 0;
return result;
}
protected override void OnFocusLost(InputState state) protected override void OnFocusLost(InputState state)
{ {
if (state.Keyboard.Keys.Any(key => key == Key.Escape)) if (state.Keyboard.Keys.Any(key => key == Key.Escape))