X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=builtin%2Fmainmenu%2Ftab_singleplayer.lua;h=1f96a85dba288eadc703002a2679b48c6961b214;hb=5229a229a606b25c2f620ba2b276f453ce99df51;hp=72f9188061d9eb3a60b24d55fd2d85d3aa5e678c;hpb=c3984569c06dc3c2890516e95adc38dcab9ec89a;p=oweals%2Fminetest.git diff --git a/builtin/mainmenu/tab_singleplayer.lua b/builtin/mainmenu/tab_singleplayer.lua index 72f918806..1f96a85db 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") @@ -28,6 +35,7 @@ local function singleplayer_refresh_gamebar() for j=1,#gamemgr.games,1 do if ("game_btnbar_" .. gamemgr.games[j].id == key) then mm_texture.update("singleplayer", gamemgr.games[j]) + core.set_topleft_text(gamemgr.games[j].name) core.setting_set("menu_last_game",gamemgr.games[j].id) menudata.worldlist:set_filtercriteria(gamemgr.games[j].id) return true @@ -45,6 +53,7 @@ local function singleplayer_refresh_gamebar() local image = nil local text = nil + local tooltip = core.formspec_escape(gamemgr.games[i].name) if gamemgr.games[i].menuicon_path ~= nil and gamemgr.games[i].menuicon_path ~= "" then @@ -61,7 +70,7 @@ local function singleplayer_refresh_gamebar() text = text .. "\n" .. part3 end end - btnbar:add_button(btn_name, text, image) + btnbar:add_button(btn_name, text, image, tooltip) end end @@ -105,9 +114,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 +136,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 +166,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 +184,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 +203,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