Fix startup after removing last game (#13015)

This commit is contained in:
Jude Melton-Houghton 2022-12-03 11:35:38 -05:00 committed by GitHub
parent 291c42ed57
commit b85831e389
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -86,9 +86,12 @@ local function init_globals()
menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic) menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic)
menudata.worldlist:set_sortmode("alphabetic") menudata.worldlist:set_sortmode("alphabetic")
if not core.settings:get("menu_last_game") then local gameid = core.settings:get("menu_last_game")
local default_game = core.settings:get("default_game") or "minetest" local game = gameid and pkgmgr.find_by_gameid(gameid)
core.settings:set("menu_last_game", default_game) if not game then
gameid = core.settings:get("default_game") or "minetest"
game = pkgmgr.find_by_gameid(gameid)
core.settings:set("menu_last_game", gameid)
end end
mm_game_theme.init() mm_game_theme.init()
@ -115,12 +118,9 @@ local function init_globals()
-- In case the folder of the last selected game has been deleted, -- In case the folder of the last selected game has been deleted,
-- display "Minetest" as a header -- display "Minetest" as a header
if tv_main.current_tab == "local" then if tv_main.current_tab == "local" and not game then
local game = pkgmgr.find_by_gameid(core.settings:get("menu_last_game"))
if game == nil then
mm_game_theme.reset() mm_game_theme.reset()
end end
end
ui.set_default("maintab") ui.set_default("maintab")
check_new_version() check_new_version()