mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
Use a settings object for the main settings
This unifies the settings APIs. This also unifies the sync and async registration APIs, since the async registration API did not support adding non-functions to the API table.
This commit is contained in:
parent
a024042bf5
commit
43d1f375d1
46 changed files with 411 additions and 417 deletions
|
@ -39,14 +39,14 @@ local function get_formspec(tabview, name, tabdata)
|
|||
-- Address / Port
|
||||
"label[7.75,-0.25;" .. fgettext("Address / Port") .. "]" ..
|
||||
"field[8,0.65;3.25,0.5;te_address;;" ..
|
||||
core.formspec_escape(core.setting_get("address")) .. "]" ..
|
||||
core.formspec_escape(core.settings:get("address")) .. "]" ..
|
||||
"field[11.1,0.65;1.4,0.5;te_port;;" ..
|
||||
core.formspec_escape(core.setting_get("remote_port")) .. "]" ..
|
||||
core.formspec_escape(core.settings:get("remote_port")) .. "]" ..
|
||||
|
||||
-- Name / Password
|
||||
"label[7.75,0.95;" .. fgettext("Name / Password") .. "]" ..
|
||||
"field[8,1.85;2.9,0.5;te_name;;" ..
|
||||
core.formspec_escape(core.setting_get("name")) .. "]" ..
|
||||
core.formspec_escape(core.settings:get("name")) .. "]" ..
|
||||
"pwdfield[10.73,1.85;1.77,0.5;te_pwd;]" ..
|
||||
|
||||
-- Description Background
|
||||
|
@ -135,7 +135,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
|||
|
||||
if fields.te_name then
|
||||
gamedata.playername = fields.te_name
|
||||
core.setting_set("name", fields.te_name)
|
||||
core.settings:set("name", fields.te_name)
|
||||
end
|
||||
|
||||
if fields.favourites then
|
||||
|
@ -163,8 +163,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
|||
gamedata.serverdescription = fav.description
|
||||
|
||||
if gamedata.address and gamedata.port then
|
||||
core.setting_set("address", gamedata.address)
|
||||
core.setting_set("remote_port", gamedata.port)
|
||||
core.settings:set("address", gamedata.address)
|
||||
core.settings:set("remote_port", gamedata.port)
|
||||
core.start()
|
||||
end
|
||||
end
|
||||
|
@ -187,8 +187,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
|||
end
|
||||
|
||||
if address and port then
|
||||
core.setting_set("address", address)
|
||||
core.setting_set("remote_port", port)
|
||||
core.settings:set("address", address)
|
||||
core.settings:set("remote_port", port)
|
||||
end
|
||||
tabdata.fav_selected = event.row
|
||||
end
|
||||
|
@ -219,8 +219,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
|||
local port = fav.port
|
||||
gamedata.serverdescription = fav.description
|
||||
if address and port then
|
||||
core.setting_set("address", address)
|
||||
core.setting_set("remote_port", port)
|
||||
core.settings:set("address", address)
|
||||
core.settings:set("remote_port", port)
|
||||
end
|
||||
|
||||
tabdata.fav_selected = fav_idx
|
||||
|
@ -235,8 +235,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
|||
asyncOnlineFavourites()
|
||||
tabdata.fav_selected = nil
|
||||
|
||||
core.setting_set("address", "")
|
||||
core.setting_set("remote_port", "30000")
|
||||
core.settings:set("address", "")
|
||||
core.settings:set("remote_port", "30000")
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -293,8 +293,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
|||
end)
|
||||
menudata.search_result = search_result
|
||||
local first_server = search_result[1]
|
||||
core.setting_set("address", first_server.address)
|
||||
core.setting_set("remote_port", first_server.port)
|
||||
core.settings:set("address", first_server.address)
|
||||
core.settings:set("remote_port", first_server.port)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
@ -325,8 +325,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
|||
gamedata.serverdescription = ""
|
||||
end
|
||||
|
||||
core.setting_set("address", fields.te_address)
|
||||
core.setting_set("remote_port", fields.te_port)
|
||||
core.settings:set("address", fields.te_address)
|
||||
core.settings:set("remote_port", fields.te_port)
|
||||
|
||||
core.start()
|
||||
return true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue