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
1 changed files with 8 additions and 8 deletions

View File

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