mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +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
|
@ -16,7 +16,7 @@
|
|||
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
local function current_game()
|
||||
local last_game_id = core.setting_get("menu_last_game")
|
||||
local last_game_id = core.settings:get("menu_last_game")
|
||||
local game, index = gamemgr.find_by_gameid(last_game_id)
|
||||
|
||||
return game
|
||||
|
@ -36,10 +36,10 @@ local function singleplayer_refresh_gamebar()
|
|||
if ("game_btnbar_" .. gamemgr.games[j].id == key) then
|
||||
mm_texture.update("singleplayer", gamemgr.games[j])
|
||||
core.set_topleft_text(gamemgr.games[j].name)
|
||||
core.setting_set("menu_last_game",gamemgr.games[j].id)
|
||||
core.settings:set("menu_last_game",gamemgr.games[j].id)
|
||||
menudata.worldlist:set_filtercriteria(gamemgr.games[j].id)
|
||||
local index = filterlist.get_current_index(menudata.worldlist,
|
||||
tonumber(core.setting_get("mainmenu_last_selected_world")))
|
||||
tonumber(core.settings:get("mainmenu_last_selected_world")))
|
||||
if not index or index < 1 then
|
||||
local selected = core.get_textlist_index("sp_worlds")
|
||||
if selected ~= nil and selected < #menudata.worldlist:get_list() then
|
||||
|
@ -89,7 +89,7 @@ local function get_formspec(tabview, name, tabdata)
|
|||
local retval = ""
|
||||
|
||||
local index = filterlist.get_current_index(menudata.worldlist,
|
||||
tonumber(core.setting_get("mainmenu_last_selected_world"))
|
||||
tonumber(core.settings:get("mainmenu_last_selected_world"))
|
||||
)
|
||||
|
||||
retval = retval ..
|
||||
|
@ -99,9 +99,9 @@ local function get_formspec(tabview, name, tabdata)
|
|||
"button[8.5,5;3.25,0.5;play;".. fgettext("Play") .. "]" ..
|
||||
"label[4,-0.25;".. fgettext("Select World:") .. "]"..
|
||||
"checkbox[0.25,0.25;cb_creative_mode;".. fgettext("Creative Mode") .. ";" ..
|
||||
dump(core.setting_getbool("creative_mode")) .. "]"..
|
||||
dump(core.settings:get_bool("creative_mode")) .. "]"..
|
||||
"checkbox[0.25,0.7;cb_enable_damage;".. fgettext("Enable Damage") .. ";" ..
|
||||
dump(core.setting_getbool("enable_damage")) .. "]"..
|
||||
dump(core.settings:get_bool("enable_damage")) .. "]"..
|
||||
"textlist[4,0.25;7.5,3.7;sp_worlds;" ..
|
||||
menu_render_worldlist() ..
|
||||
";" .. index .. "]"
|
||||
|
@ -125,7 +125,7 @@ local function main_button_handler(this, fields, name, tabdata)
|
|||
end
|
||||
|
||||
if event.type == "CHG" and selected ~= nil then
|
||||
core.setting_set("mainmenu_last_selected_world",
|
||||
core.settings:set("mainmenu_last_selected_world",
|
||||
menudata.worldlist:get_raw_index(selected))
|
||||
return true
|
||||
end
|
||||
|
@ -136,7 +136,7 @@ local function main_button_handler(this, fields, name, tabdata)
|
|||
end
|
||||
|
||||
if fields["cb_creative_mode"] then
|
||||
core.setting_set("creative_mode", fields["cb_creative_mode"])
|
||||
core.settings:set("creative_mode", fields["cb_creative_mode"])
|
||||
local selected = core.get_textlist_index("sp_worlds")
|
||||
menu_worldmt(selected, "creative_mode", fields["cb_creative_mode"])
|
||||
|
||||
|
@ -144,7 +144,7 @@ local function main_button_handler(this, fields, name, tabdata)
|
|||
end
|
||||
|
||||
if fields["cb_enable_damage"] then
|
||||
core.setting_set("enable_damage", fields["cb_enable_damage"])
|
||||
core.settings:set("enable_damage", fields["cb_enable_damage"])
|
||||
local selected = core.get_textlist_index("sp_worlds")
|
||||
menu_worldmt(selected, "enable_damage", fields["cb_enable_damage"])
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue