From a6f02106a46d8a5e7cd503baecd1c2d9e7c12efe Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 8 Feb 2017 14:01:17 +0900 Subject: [PATCH] Use new placeholder logic. --- osu.Game/Graphics/UserInterface/OsuTextBox.cs | 9 ++++++ osu.Game/Overlays/Options/OptionTextBox.cs | 18 ++++++------ .../Options/Sections/General/LoginOptions.cs | 4 ++- osu.Game/Screens/Select/SearchTextBox.cs | 29 ++----------------- 4 files changed, 23 insertions(+), 37 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTextBox.cs b/osu.Game/Graphics/UserInterface/OsuTextBox.cs index cb78656bea..0e551380ed 100644 --- a/osu.Game/Graphics/UserInterface/OsuTextBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuTextBox.cs @@ -3,6 +3,8 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Game.Graphics.Sprites; @@ -19,6 +21,13 @@ namespace osu.Game.Graphics.UserInterface protected override float LeftRightPadding => 10; + protected override SpriteText CreatePlaceholder() => new OsuSpriteText + { + Font = @"Exo2.0-MediumItalic", + Colour = new Color4(180, 180, 180, 255), + Margin = new MarginPadding { Left = 2 }, + }; + public OsuTextBox() { Height = 40; diff --git a/osu.Game/Overlays/Options/OptionTextBox.cs b/osu.Game/Overlays/Options/OptionTextBox.cs index 74730481ab..18fcfa6fca 100644 --- a/osu.Game/Overlays/Options/OptionTextBox.cs +++ b/osu.Game/Overlays/Options/OptionTextBox.cs @@ -26,16 +26,16 @@ namespace osu.Game.Overlays.Options } } } - - protected override string InternalText + + public OptionTextBox() { - get { return base.InternalText; } - set - { - base.InternalText = value; - if (bindable != null) - bindable.Value = value; - } + OnChange += onChange; + } + + private void onChange(TextBox sender, bool newText) + { + if (bindable != null) + bindable.Value = Text; } private void bindableValueChanged(object sender, EventArgs e) diff --git a/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs b/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs index 398cb969e3..916159fc88 100644 --- a/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs +++ b/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs @@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Options.Sections.General { private bool bounding = true; - protected override string Header => "Sign In"; + protected override string Header => "Account"; public override RectangleF BoundingBox => bounding ? base.BoundingBox : RectangleF.Empty; @@ -112,11 +112,13 @@ namespace osu.Game.Overlays.Options.Sections.General { username = new OsuTextBox { + PlaceholderText = "Username", RelativeSizeAxes = Axes.X, Text = api?.Username ?? string.Empty }, password = new OsuPasswordTextBox { + PlaceholderText = "Password", RelativeSizeAxes = Axes.X }, saveUsername = new OsuCheckbox diff --git a/osu.Game/Screens/Select/SearchTextBox.cs b/osu.Game/Screens/Select/SearchTextBox.cs index b8ba491f8f..a96209d0d8 100644 --- a/osu.Game/Screens/Select/SearchTextBox.cs +++ b/osu.Game/Screens/Select/SearchTextBox.cs @@ -34,38 +34,11 @@ namespace osu.Game.Screens.Select } } - private SpriteText placeholder; - - protected override string InternalText - { - get { return base.InternalText; } - set - { - base.InternalText = value; - if (placeholder != null) - { - if (string.IsNullOrEmpty(value)) - placeholder.Text = "type to search"; - else - placeholder.Text = string.Empty; - } - } - } - public SearchTextBox() { Height = 35; Add(new Drawable[] { - placeholder = new SpriteText - { - Font = @"Exo2.0-MediumItalic", - Text = "type to search", - Colour = new Color4(180, 180, 180, 255), - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Margin = new MarginPadding { Left = 10 }, - }, new TextAwesome { Icon = FontAwesome.fa_search, @@ -74,6 +47,8 @@ namespace osu.Game.Screens.Select Margin = new MarginPadding { Right = 10 }, } }); + + PlaceholderText = "type to search"; } protected override void Update()