1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-30 19:22:14 +00:00

add option to remember passwords

This commit is contained in:
Abdurahman Elmawi 2025-06-28 16:53:25 +03:00
parent 604e96ba0a
commit ea24973f0d
2 changed files with 15 additions and 3 deletions

View file

@ -96,6 +96,11 @@ local function get_formspec(tabview, name, tabdata)
tabdata.search_for = "" tabdata.search_for = ""
end end
local password = ""
if core.settings:get_bool("remember_password") then
password = core.settings:get("password")
end
local retval = local retval =
-- Search -- Search
"field[0.25,0.25;7,0.75;te_search;;" .. core.formspec_escape(tabdata.search_for) .. "]" .. "field[0.25,0.25;7,0.75;te_search;;" .. core.formspec_escape(tabdata.search_for) .. "]" ..
@ -130,7 +135,7 @@ local function get_formspec(tabview, name, tabdata)
"label[0.25,0;" .. fgettext("Name") .. "]" .. "label[0.25,0;" .. fgettext("Name") .. "]" ..
"label[2.875,0;" .. fgettext("Password") .. "]" .. "label[2.875,0;" .. fgettext("Password") .. "]" ..
"field[0.25,0.2;2.625,0.75;te_name;;" .. core.formspec_escape(core.settings:get("name")) .. "]" .. "field[0.25,0.2;2.625,0.75;te_name;;" .. core.formspec_escape(core.settings:get("name")) .. "]" ..
"pwdfield[2.875,0.2;2.625,0.75;te_pwd;;" .. core.formspec_escape(core.settings:get("password")) .. "]" .. "pwdfield[2.875,0.2;2.625,0.75;te_pwd;;" .. core.formspec_escape(password) .. "]" ..
"container_end[]" .. "container_end[]" ..
-- Connect -- Connect
@ -443,8 +448,12 @@ local function main_button_handler(tabview, fields, name, tabdata)
core.settings:set("name", fields.te_name) core.settings:set("name", fields.te_name)
end end
if fields.te_pwd then if core.settings:get_bool("remember_password") then
core.settings:set("password", fields.te_pwd) if fields.te_pwd then
core.settings:set("password", fields.te_pwd)
end
else
core.settings:set("password", "")
end end
if fields.servers then if fields.servers then

View file

@ -871,6 +871,9 @@ tooltip_append_itemname (Append item name) bool false
# Use a cloud animation for the main menu background. # Use a cloud animation for the main menu background.
menu_clouds (Clouds in menu) bool true menu_clouds (Clouds in menu) bool true
# Remember last entered password in the 'Join Game' tab
remember_password (Remember password) bool false
[**HUD] [**HUD]
# Modifies the size of the HUD elements. # Modifies the size of the HUD elements.