mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Replace settings tab with button
This commit is contained in:
parent
798b9eae4a
commit
48ab1835da
3 changed files with 58 additions and 31 deletions
|
@ -51,30 +51,13 @@ dofile(menupath .. DIR_DELIM .. "dlg_register.lua")
|
|||
dofile(menupath .. DIR_DELIM .. "dlg_rename_modpack.lua")
|
||||
dofile(menupath .. DIR_DELIM .. "dlg_version_info.lua")
|
||||
|
||||
local tabs = {}
|
||||
|
||||
tabs.settings = {
|
||||
name = "settings",
|
||||
caption = fgettext("Settings"),
|
||||
cbf_formspec = function()
|
||||
return "button[0.1,0.1;3,0.8;open_settings;" .. fgettext("Open Settings") .. "]"
|
||||
end,
|
||||
cbf_button_handler = function(tabview, fields)
|
||||
if fields.open_settings then
|
||||
local dlg = create_settings_dlg()
|
||||
dlg:set_parent(tabview)
|
||||
tabview:hide()
|
||||
dlg:show()
|
||||
return true
|
||||
end
|
||||
end,
|
||||
local tabs = {
|
||||
content = dofile(menupath .. DIR_DELIM .. "tab_content.lua"),
|
||||
about = dofile(menupath .. DIR_DELIM .. "tab_about.lua"),
|
||||
local_game = dofile(menupath .. DIR_DELIM .. "tab_local.lua"),
|
||||
play_online = dofile(menupath .. DIR_DELIM .. "tab_online.lua")
|
||||
}
|
||||
|
||||
tabs.content = dofile(menupath .. DIR_DELIM .. "tab_content.lua")
|
||||
tabs.about = dofile(menupath .. DIR_DELIM .. "tab_about.lua")
|
||||
tabs.local_game = dofile(menupath .. DIR_DELIM .. "tab_local.lua")
|
||||
tabs.play_online = dofile(menupath .. DIR_DELIM .. "tab_online.lua")
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
local function main_event_handler(tabview, event)
|
||||
if event == "MenuQuit" then
|
||||
|
@ -121,7 +104,6 @@ local function init_globals()
|
|||
tv_main:add(tabs.local_game)
|
||||
tv_main:add(tabs.play_online)
|
||||
tv_main:add(tabs.content)
|
||||
tv_main:add(tabs.settings)
|
||||
tv_main:add(tabs.about)
|
||||
|
||||
tv_main:set_global_event_handler(main_event_handler)
|
||||
|
@ -132,6 +114,19 @@ local function init_globals()
|
|||
tv_main:set_tab(last_tab)
|
||||
end
|
||||
|
||||
tv_main:set_end_button({
|
||||
icon = defaulttexturedir .. "settings_btn.png",
|
||||
label = fgettext("Settings"),
|
||||
name = "open_settings",
|
||||
on_click = function(tabview)
|
||||
local dlg = create_settings_dlg()
|
||||
dlg:set_parent(tabview)
|
||||
tabview:hide()
|
||||
dlg:show()
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
-- In case the folder of the last selected game has been deleted,
|
||||
-- display "Minetest" as a header
|
||||
if tv_main.current_tab == "local" and not game then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue