From 6e9f9f2177fc18d62f2b71035845f37340e38e5b Mon Sep 17 00:00:00 2001 From: 83N170 <83N170@mail.com> Date: Fri, 25 Oct 2024 15:30:23 +0100 Subject: [PATCH 1/5] Added remember password buttons to UI --- .../chobby/components/configuration.lua | 1 + .../chobby/components/login_window.lua | 32 +++++++++++++++++++ LuaMenu/widgets/chobby/i18n/chililobby.lua | 2 ++ LuaMenu/widgets/gui_settings_window.lua | 22 +++++++++++++ 4 files changed, 57 insertions(+) diff --git a/LuaMenu/widgets/chobby/components/configuration.lua b/LuaMenu/widgets/chobby/components/configuration.lua index 39b04475f..675fce645 100644 --- a/LuaMenu/widgets/chobby/components/configuration.lua +++ b/LuaMenu/widgets/chobby/components/configuration.lua @@ -76,6 +76,7 @@ function Configuration:init() self.suggestedNameFromSteam = false self.password = false self.autoLogin = true + self.rememberPassword = false self.uploadLogPrompt = 'Prompt' self.firstLoginEver = true self.canAuthenticateWithSteam = false diff --git a/LuaMenu/widgets/chobby/components/login_window.lua b/LuaMenu/widgets/chobby/components/login_window.lua index b0ffd69a2..c0b91e3a2 100644 --- a/LuaMenu/widgets/chobby/components/login_window.lua +++ b/LuaMenu/widgets/chobby/components/login_window.lua @@ -396,6 +396,38 @@ function LoginWindow:init(failFunction, cancelText, windowClassname, params) } registerChildren[#registerChildren + 1] = self.cbAutoLoginRegister + self.cbRememberPassword = Checkbox:New { + x = 15, + width = 215, + y = self.windowHeight - 145, + height = 35, + boxalign = "right", + boxsize = 15, + caption = i18n("rememberPassword"), + checked = Configuration.rememberPassword, + objectOverrideFont = WG.Chobby.Configuration:GetFont(2), + OnClick = {function (obj) + Configuration:SetConfigValue("rememberPassword", obj.checked) + end}, + } + loginChildren[#loginChildren+1] = self.cbRememberPassword + + self.cbRememberPasswordRegister = Checkbox:New { + x = 15, + width = 215, + y = self.windowHeight - 145, + height = 35, + boxalign = "right", + boxsize = 15, + caption = i18n("rememberPassword"), + checked = Configuration.rememberPassword, + objectOverrideFont = WG.Chobby.Configuration:GetFont(2), + OnClick = {function (obj) + Configuration:SetConfigValue("rememberPassword", obj.checked) + end}, + } + registerChildren[#registerChildren + 1] = self.cbRememberPasswordRegister + self.txtError = TextBox:New { x = 15, right = 15, diff --git a/LuaMenu/widgets/chobby/i18n/chililobby.lua b/LuaMenu/widgets/chobby/i18n/chililobby.lua index 8e8fb2cc9..3ba209c1c 100644 --- a/LuaMenu/widgets/chobby/i18n/chililobby.lua +++ b/LuaMenu/widgets/chobby/i18n/chililobby.lua @@ -42,6 +42,7 @@ return { alt_acknowledgement = 'By pressing Register, you acknowledge the\nrules concerning alt accounts.', register_steam_long = "Enter a username for multiplayer", autoLogin = "Login automatically", + rememberPassword = "Remember password", authenticateSteam = "Authenticate with Steam", play_offline = "Play offline", keys = "Keys", @@ -367,6 +368,7 @@ return { register_long = "Account erstellen", register_steam_long = "Benutzername für den Mehrspieler-Modus wählen", autoLogin = "Automatisch einloggen", + rememberPassword = "Passwort merken", authenticateSteam = "Mit Steam authentifizieren", play_offline = "Offline spielen", -- gui_battle_status_panel diff --git a/LuaMenu/widgets/gui_settings_window.lua b/LuaMenu/widgets/gui_settings_window.lua index 7cabe7d6e..92041d84d 100644 --- a/LuaMenu/widgets/gui_settings_window.lua +++ b/LuaMenu/widgets/gui_settings_window.lua @@ -993,6 +993,25 @@ local function GetLobbyTabControls() children[#children + 1] = autoLogin offset = offset + ITEM_OFFSET + local rememberPassword = Checkbox:New { + x = 20, + width = CHECK_WIDTH, + y = offset, + height = 30, + boxalign = "right", + boxsize = 20, + caption = i18n("rememberPassword"), + checked = Configuration.rememberPassword or false, + objectOverrideFont = WG.Chobby.Configuration:GetFont(2), + OnChange = {function (obj, newState) + freezeSettings = true + Configuration:SetConfigValue("rememberPassword", newState) + freezeSettings = false + end}, + } + children[#children + 1] = rememberPassword + offset = offset + ITEM_OFFSET + local cbQueueExitConfirmPromptDoNotAskAgain cbQueueExitConfirmPromptDoNotAskAgain, offset = AddCheckboxSetting(offset, i18n("queueExitConfirmPromptDoNotAskAgain"), "queueExitConfirmPromptDoNotAskAgain", true, nil , i18n("queueExitConfirmPromptDoNotAskAgain_tooltip")) children[#children + 1] = cbQueueExitConfirmPromptDoNotAskAgain @@ -1193,6 +1212,9 @@ local function GetLobbyTabControls() if key == "autoLogin" then autoLogin:SetToggle(value) end + if key == "rememberPassword" then + rememberPassword:SetToggle(value) + end if key == "randomSkirmishSetup" then if value == true then Spring.SetConfigInt("randomSkirmishSetup", 1) From 6d4ba6cd75a620f2987b7b9ea37dfed2d3495fb0 Mon Sep 17 00:00:00 2001 From: 83N170 <83N170@mail.com> Date: Fri, 25 Oct 2024 16:07:07 +0100 Subject: [PATCH 2/5] Clear password on exit --- LuaMenu/widgets/chobby/components/interface_root.lua | 3 +++ LuaMenu/widgets/chobby/components/login_window.lua | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/LuaMenu/widgets/chobby/components/interface_root.lua b/LuaMenu/widgets/chobby/components/interface_root.lua index e3dfb6e39..8aa2ca90f 100644 --- a/LuaMenu/widgets/chobby/components/interface_root.lua +++ b/LuaMenu/widgets/chobby/components/interface_root.lua @@ -387,6 +387,9 @@ function GetInterfaceRoot(optionsParent, mainWindowParent, fontFunction) -- Exit button local function ExitSpring() + if not Configuration.rememberPassword then + Configuration.password = "" + end Spring.Echo("Quitting...") Spring.Quit() end diff --git a/LuaMenu/widgets/chobby/components/login_window.lua b/LuaMenu/widgets/chobby/components/login_window.lua index c0b91e3a2..ae261858c 100644 --- a/LuaMenu/widgets/chobby/components/login_window.lua +++ b/LuaMenu/widgets/chobby/components/login_window.lua @@ -399,7 +399,7 @@ function LoginWindow:init(failFunction, cancelText, windowClassname, params) self.cbRememberPassword = Checkbox:New { x = 15, width = 215, - y = self.windowHeight - 145, + y = self.windowHeight - 215, height = 35, boxalign = "right", boxsize = 15, @@ -415,7 +415,7 @@ function LoginWindow:init(failFunction, cancelText, windowClassname, params) self.cbRememberPasswordRegister = Checkbox:New { x = 15, width = 215, - y = self.windowHeight - 145, + y = self.windowHeight - 215, height = 35, boxalign = "right", boxsize = 15, From c6a701c09d66d985cacd4ea7b57a18fedf80b61a Mon Sep 17 00:00:00 2001 From: 83N170 <83N170@mail.com> Date: Fri, 25 Oct 2024 16:29:38 +0100 Subject: [PATCH 3/5] Change default to remember password to maintain existing behaviour --- LuaMenu/widgets/chobby/components/configuration.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LuaMenu/widgets/chobby/components/configuration.lua b/LuaMenu/widgets/chobby/components/configuration.lua index 675fce645..651c99a2b 100644 --- a/LuaMenu/widgets/chobby/components/configuration.lua +++ b/LuaMenu/widgets/chobby/components/configuration.lua @@ -76,7 +76,7 @@ function Configuration:init() self.suggestedNameFromSteam = false self.password = false self.autoLogin = true - self.rememberPassword = false + self.rememberPassword = true self.uploadLogPrompt = 'Prompt' self.firstLoginEver = true self.canAuthenticateWithSteam = false From 3a117c14d3dc06f2f2bc2650a49e93e834c480d5 Mon Sep 17 00:00:00 2001 From: 83N170 <83N170@mail.com> Date: Sun, 27 Oct 2024 21:22:18 +0000 Subject: [PATCH 4/5] Fix copying config data --- LuaMenu/widgets/chobby/components/configuration.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/LuaMenu/widgets/chobby/components/configuration.lua b/LuaMenu/widgets/chobby/components/configuration.lua index 651c99a2b..4a45b1757 100644 --- a/LuaMenu/widgets/chobby/components/configuration.lua +++ b/LuaMenu/widgets/chobby/components/configuration.lua @@ -646,6 +646,7 @@ function Configuration:GetConfigData() uiScalesForScreenSizes = self.uiScalesForScreenSizes, password = self.password, autoLogin = self.autoLogin, + rememberPassword = self.rememberPassword, uploadLogPrompt = self.uploadLogPrompt, firstLoginEver = self.firstLoginEver, wantAuthenticateWithSteam = self.wantAuthenticateWithSteam, From 484c4346b83e4ec929ae65380ab75421de77c8fb Mon Sep 17 00:00:00 2001 From: 83N170 <83N170@mail.com> Date: Mon, 28 Oct 2024 07:56:57 +0000 Subject: [PATCH 5/5] Only copy password if remembered --- LuaMenu/widgets/chobby/components/configuration.lua | 8 ++++++-- LuaMenu/widgets/chobby/components/interface_root.lua | 3 --- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/LuaMenu/widgets/chobby/components/configuration.lua b/LuaMenu/widgets/chobby/components/configuration.lua index 4a45b1757..3d6be3ee5 100644 --- a/LuaMenu/widgets/chobby/components/configuration.lua +++ b/LuaMenu/widgets/chobby/components/configuration.lua @@ -636,6 +636,10 @@ function Configuration:SetConfigData(data) end function Configuration:GetConfigData() + local rememberedPassword = false + if self.rememberPassword then + rememberedPassword = self.password + end return { tempChangedShowSkill = self.tempChangedShowSkill, -- should be removed at 1.1.2024 autoLaunchAsSpectator = self.autoLaunchAsSpectator, @@ -644,9 +648,9 @@ function Configuration:GetConfigData() userName = self.userName, suggestedNameFromSteam = self.suggestedNameFromSteam, uiScalesForScreenSizes = self.uiScalesForScreenSizes, - password = self.password, - autoLogin = self.autoLogin, rememberPassword = self.rememberPassword, + password = rememberedPassword, + autoLogin = self.autoLogin, uploadLogPrompt = self.uploadLogPrompt, firstLoginEver = self.firstLoginEver, wantAuthenticateWithSteam = self.wantAuthenticateWithSteam, diff --git a/LuaMenu/widgets/chobby/components/interface_root.lua b/LuaMenu/widgets/chobby/components/interface_root.lua index 8aa2ca90f..e3dfb6e39 100644 --- a/LuaMenu/widgets/chobby/components/interface_root.lua +++ b/LuaMenu/widgets/chobby/components/interface_root.lua @@ -387,9 +387,6 @@ function GetInterfaceRoot(optionsParent, mainWindowParent, fontFunction) -- Exit button local function ExitSpring() - if not Configuration.rememberPassword then - Configuration.password = "" - end Spring.Echo("Quitting...") Spring.Quit() end