X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=builtin%2Fmainmenu%2Ftab_singleplayer.lua;h=1eab94da36a13d82b8abf571ec990d71ffff4f6e;hb=f70e0556fcf28b21b5a6717524caa29ccd49a516;hp=72f9188061d9eb3a60b24d55fd2d85d3aa5e678c;hpb=c3984569c06dc3c2890516e95adc38dcab9ec89a;p=oweals%2Fminetest.git diff --git a/builtin/mainmenu/tab_singleplayer.lua b/builtin/mainmenu/tab_singleplayer.lua index 72f918806..1eab94da3 100644 --- a/builtin/mainmenu/tab_singleplayer.lua +++ b/builtin/mainmenu/tab_singleplayer.lua @@ -15,6 +15,13 @@ --with this program; if not, write to the Free Software Foundation, Inc., --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 game, index = gamemgr.find_by_gameid(last_game_id) + + return game +end + local function singleplayer_refresh_gamebar() local old_bar = ui.find_by_name("game_button_bar") @@ -105,9 +112,8 @@ local function main_button_handler(this, fields, name, tabdata) if event.type == "CHG" then core.setting_set("mainmenu_last_selected_world", menudata.worldlist:get_raw_index(core.get_textlist_index("sp_worlds"))) + return true end - - return true end if menu_handle_key_up_down(fields,"sp_worlds","mainmenu_last_selected_world") then @@ -128,20 +134,22 @@ local function main_button_handler(this, fields, name, tabdata) world_doubleclick or fields["key_enter"] then local selected = core.get_textlist_index("sp_worlds") + if selected ~= nil then - gamedata.selected_world = menudata.worldlist:get_raw_index(selected) - gamedata.singleplayer = true + gamedata.selected_world = menudata.worldlist:get_raw_index(selected) + gamedata.singleplayer = true + core.start() end return true end if fields["world_create"] ~= nil then - print("create world dialog") local create_world_dlg = create_create_world_dlg(true) create_world_dlg:set_parent(this) - create_world_dlg:show() this:hide() + create_world_dlg:show() + mm_texture.update("singleplayer",current_game()) return true end @@ -156,8 +164,9 @@ local function main_button_handler(this, fields, name, tabdata) local index = menudata.worldlist:get_raw_index(selected) local delete_world_dlg = create_delete_world_dlg(world.name,index) delete_world_dlg:set_parent(this) - delete_world_dlg:show() this:hide() + delete_world_dlg:show() + mm_texture.update("singleplayer",current_game()) end end @@ -173,8 +182,9 @@ local function main_button_handler(this, fields, name, tabdata) if (configdialog ~= nil) then configdialog:set_parent(this) - configdialog:show() this:hide() + configdialog:show() + mm_texture.update("singleplayer",current_game()) end end @@ -191,13 +201,12 @@ local function on_change(type, old_tab, new_tab) end if (type == "ENTER") then - local last_game_id = core.setting_get("menu_last_game") - local game, index = gamemgr.find_by_gameid(last_game_id) + local game = current_game() if game then menudata.worldlist:set_filtercriteria(game.id) core.set_topleft_text(game.name) - mm_texture.update(new_tab,game) + mm_texture.update("singleplayer",game) end buttonbar:show() else