diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index e0134fcf41..86c3985436 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -17,7 +17,6 @@ namespace osu.Game.Configuration Set(OsuConfig.MouseSpeed, 1.0); Set(OsuConfig.Username, string.Empty); - Set(OsuConfig.Password, string.Empty); Set(OsuConfig.Token, string.Empty); Set(OsuConfig.PlayMode, PlayMode.Osu); @@ -144,8 +143,6 @@ namespace osu.Game.Configuration Set(OsuConfig.HiddenShowFirstApproach, true); Set(OsuConfig.ComboColourSliderBall, true); Set(OsuConfig.AlternativeChatFont, false); - Set(OsuConfig.Password, string.Empty); - Set(OsuConfig.Username, string.Empty); Set(OsuConfig.DisplayStarsMaximum, 10.0, 0.0, 10.0); Set(OsuConfig.DisplayStarsMinimum, 0.0, 0.0, 10.0); Set(OsuConfig.AudioDevice, string.Empty); @@ -171,6 +168,16 @@ namespace osu.Game.Configuration Set(OsuConfig.CanForceOptimusCompatibility, true); Set(OsuConfig.ConfineMouse, Get(OsuConfig.ConfineMouseToFullscreen) ? ConfineMouseMode.Fullscreen : ConfineMouseMode.Never); + + + GetBindable(OsuConfig.SavePassword).ValueChanged += delegate + { + if (Get(OsuConfig.SavePassword)) Set(OsuConfig.SaveUsername, true); + }; + GetBindable(OsuConfig.SaveUsername).ValueChanged += delegate + { + if (!Get(OsuConfig.SaveUsername)) Set(OsuConfig.SavePassword, false); + }; #pragma warning restore CS0612 // Type or member is obsolete } @@ -314,7 +321,6 @@ namespace osu.Game.Configuration HiddenShowFirstApproach, ComboColourSliderBall, AlternativeChatFont, - Password, Username, DisplayStarsMaximum, DisplayStarsMinimum, diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index a853e93879..31cee2ed39 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -70,7 +70,6 @@ namespace osu.Game Dependencies.Cache(API = new APIAccess { Username = LocalConfig.Get(OsuConfig.Username), - Password = LocalConfig.Get(OsuConfig.Password), Token = LocalConfig.Get(OsuConfig.Token) }); @@ -83,7 +82,6 @@ namespace osu.Game { case APIState.Online: LocalConfig.Set(OsuConfig.Username, LocalConfig.Get(OsuConfig.SaveUsername) ? API.Username : string.Empty); - LocalConfig.Set(OsuConfig.Password, LocalConfig.Get(OsuConfig.SavePassword) ? API.Password : string.Empty); break; } } @@ -119,7 +117,7 @@ namespace osu.Game //refresh token may have changed. if (LocalConfig != null && API != null) { - LocalConfig.Set(OsuConfig.Token, API.Token); + LocalConfig.Set(OsuConfig.Token, LocalConfig.Get(OsuConfig.SavePassword) ? API.Token : string.Empty); LocalConfig.Save(); } diff --git a/osu.Game/Overlays/Options/General/LoginOptions.cs b/osu.Game/Overlays/Options/General/LoginOptions.cs index 03789c59c9..333b794d58 100644 --- a/osu.Game/Overlays/Options/General/LoginOptions.cs +++ b/osu.Game/Overlays/Options/General/LoginOptions.cs @@ -11,14 +11,12 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; - +using osu.Game.Configuration; + namespace osu.Game.Overlays.Options.General { public class LoginOptions : OptionsSubsection, IOnlineComponent { - private Container loginForm; - - private Action performLogout; protected override string Header => "Sign In"; [BackgroundDependencyLoader(permitNulls: true)] @@ -76,30 +74,11 @@ namespace osu.Game.Overlays.Options.General class LoginForm : FlowContainer { private TextBox username; - private TextBox password; + private PasswordTextBox password; private APIAccess api; - public LoginForm() - { - Direction = FlowDirection.VerticalOnly; - AutoSizeAxes = Axes.Y; - RelativeSizeAxes = Axes.X; - Spacing = new Vector2(0, 5); - // TODO: Wire things up - Children = new Drawable[] - { - new SpriteText { Text = "Username" }, - username = new TextBox { Height = 20, RelativeSizeAxes = Axes.X, Text = api?.Username ?? string.Empty }, - new SpriteText { Text = "Password" }, - password = new PasswordTextBox { Height = 20, RelativeSizeAxes = Axes.X }, - new OsuButton - { - RelativeSizeAxes = Axes.X, - Text = "Log in", - Action = performLogin - } - }; - } + private CheckBoxOption saveUsername; + private CheckBoxOption savePassword; private void performLogin() { @@ -108,9 +87,51 @@ namespace osu.Game.Overlays.Options.General } [BackgroundDependencyLoader(permitNulls: true)] - private void load(APIAccess api) + private void load(APIAccess api, OsuConfigManager config) { this.api = api; + Direction = FlowDirection.VerticalOnly; + AutoSizeAxes = Axes.Y; + RelativeSizeAxes = Axes.X; + Spacing = new Vector2(0, 5); + Children = new Drawable[] + { + new SpriteText { Text = "Username" }, + username = new TextBox + { + Height = 20, + RelativeSizeAxes = Axes.X, + Text = api?.Username ?? string.Empty + }, + new SpriteText { Text = "Password" }, + password = new PasswordTextBox + { + Height = 20, + RelativeSizeAxes = Axes.X + }, + saveUsername = new CheckBoxOption + { + LabelText = "Remember Username", + Bindable = config.GetBindable(OsuConfig.SaveUsername), + }, + savePassword = new CheckBoxOption + { + LabelText = "Remember Password", + Bindable = config.GetBindable(OsuConfig.SavePassword), + }, + new OsuButton + { + RelativeSizeAxes = Axes.X, + Text = "Log in", + Action = performLogin + }, + new OsuButton + { + RelativeSizeAxes = Axes.X, + Text = "Register", + //Action = registerLink + } + }; } } }