1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Don't break when multiple dialogs are shown on startup (#16204)

This commit is contained in:
grorp 2025-06-01 15:24:14 +02:00 committed by GitHub
parent a2460df316
commit 56a7f0b7cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 30 additions and 26 deletions

View file

@ -118,7 +118,7 @@ function ui.update()
if (active_toplevel_ui_elements > 1) then
core.log("warning", "more than one active ui "..
"element, self most likely isn't intended")
"element, this most likely isn't intended")
end
if (active_toplevel_ui_elements == 0) then

View file

@ -33,13 +33,13 @@ end
local function buttonhandler(this, fields)
if fields.reconfigure then
local parent = this.parent
close_dialog(this)
local maintab = ui.find_by_name("maintab")
local dlg = create_settings_dlg("controls_keyboard_and_mouse")
dlg:set_parent(maintab)
maintab:hide()
dlg:set_parent(parent)
parent:hide()
dlg:show()
return true
@ -74,7 +74,7 @@ local function create_rebind_keys_dlg()
return dlg
end
function migrate_keybindings()
function migrate_keybindings(parent)
-- Show migration dialog if the user upgraded from an earlier version
-- and this has not yet been shown before, *or* if keys settings had to be changed
if core.is_first_run then
@ -95,14 +95,14 @@ function migrate_keybindings()
end
if not has_migration then
return
return parent
end
local maintab = ui.find_by_name("maintab")
local dlg = create_rebind_keys_dlg()
dlg:set_parent(maintab)
maintab:hide()
dlg:set_parent(parent)
parent:hide()
dlg:show()
ui.update()
return dlg
end

View file

@ -11,7 +11,7 @@
local SETTING_NAME = "no_mtg_notification"
function check_reinstall_mtg()
function check_reinstall_mtg(parent)
-- used to be in minetest.conf
if core.settings:get_bool(SETTING_NAME) then
cache_settings:set_bool(SETTING_NAME, true)
@ -19,14 +19,14 @@ function check_reinstall_mtg()
end
if cache_settings:get_bool(SETTING_NAME) then
return
return parent
end
local games = core.get_games()
for _, game in ipairs(games) do
if game.id == "minetest" then
cache_settings:set_bool(SETTING_NAME, true)
return
return parent
end
end
@ -40,16 +40,16 @@ function check_reinstall_mtg()
end
if not mtg_world_found then
cache_settings:set_bool(SETTING_NAME, true)
return
return parent
end
local maintab = ui.find_by_name("maintab")
local dlg = create_reinstall_mtg_dlg()
dlg:set_parent(maintab)
maintab:hide()
dlg:set_parent(parent)
parent:hide()
dlg:show()
ui.update()
return dlg
end
local function get_formspec(dialogdata)
@ -74,22 +74,22 @@ end
local function buttonhandler(this, fields)
if fields.reinstall then
local parent = this.parent
-- Don't set "no_mtg_notification" here so that the dialog will be shown
-- again if downloading MTG fails for whatever reason.
this:delete()
local maintab = ui.find_by_name("maintab")
local dlg = create_contentdb_dlg(nil, "minetest/minetest")
dlg:set_parent(maintab)
maintab:hide()
dlg:set_parent(parent)
parent:hide()
dlg:show()
return true
end
if fields.dismiss then
cache_settings:set_bool("no_mtg_notification", true)
cache_settings:set_bool(SETTING_NAME, true)
this:delete()
return true
end

View file

@ -112,8 +112,12 @@ local function init_globals()
tv_main:show()
ui.update()
check_reinstall_mtg()
migrate_keybindings()
-- synchronous, chain parents to only show one at a time
local parent = tv_main
parent = migrate_keybindings(parent)
check_reinstall_mtg(parent)
-- asynchronous, will only be shown if we're still on "maintab"
check_new_version()
end