From d01421b951bc308583caa0c687f0715ab55f34de Mon Sep 17 00:00:00 2001 From: Boudewijn Popkema Date: Wed, 21 Feb 2024 23:15:37 +0100 Subject: [PATCH] clear remembered username when checkbox is unticked --- osu.Game/Overlays/Login/LoginForm.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Login/LoginForm.cs b/osu.Game/Overlays/Login/LoginForm.cs index 80dfca93d2..a77baa3186 100644 --- a/osu.Game/Overlays/Login/LoginForm.cs +++ b/osu.Game/Overlays/Login/LoginForm.cs @@ -13,11 +13,11 @@ using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; +using osu.Game.Localisation; using osu.Game.Online.API; using osu.Game.Overlays.Settings; using osu.Game.Resources.Localisation.Web; using osuTK; -using osu.Game.Localisation; namespace osu.Game.Overlays.Login { @@ -26,6 +26,7 @@ public partial class LoginForm : FillFlowContainer private TextBox username = null!; private TextBox password = null!; private ShakeContainer shakeSignIn = null!; + private SettingsCheckbox rememberUsername = null!; [Resolved] private IAPIProvider api { get; set; } = null!; @@ -82,7 +83,7 @@ private void load(OsuConfigManager config, AccountCreationOverlay accountCreatio }, }, }, - new SettingsCheckbox + rememberUsername = new SettingsCheckbox { LabelText = LoginPanelStrings.RememberUsername, Current = config.GetBindable(OsuSetting.SaveUsername), @@ -130,6 +131,7 @@ private void load(OsuConfigManager config, AccountCreationOverlay accountCreatio forgottenPasswordLink.AddLink(LayoutStrings.PopupLoginLoginForgot, $"{api.WebsiteRootUrl}/home/password-reset"); password.OnCommit += (_, _) => performLogin(); + rememberUsername.SettingChanged += () => onRememberUsernameChanged(config); if (api.LastLoginError?.Message is string error) { @@ -146,6 +148,12 @@ private void performLogin() shakeSignIn.Shake(); } + private void onRememberUsernameChanged(OsuConfigManager config) + { + if (rememberUsername.Current.Value == false) + config.SetValue(OsuSetting.Username, string.Empty); + } + protected override bool OnClick(ClickEvent e) => true; protected override void OnFocus(FocusEvent e)