diff options
author | jp <jeanpatrick.guerrero@gmail.com> | 2015-07-04 17:53:00 +0200 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2015-07-10 16:52:57 -0400 |
commit | c3dead719ae737a2e61f7e0e81cfc1b614790edd (patch) | |
tree | 087dc0aef8970a82cd043c2749490f9b4bd25ffb /builtin | |
parent | 1a1774a1051790ef85b1bd8b047ac45a3676b5d6 (diff) | |
download | minetest-c3dead719ae737a2e61f7e0e81cfc1b614790edd.tar.gz minetest-c3dead719ae737a2e61f7e0e81cfc1b614790edd.tar.bz2 minetest-c3dead719ae737a2e61f7e0e81cfc1b614790edd.zip |
Fix remnant bugs on mainmenu
- Stop attempting to start a world when no world's created/selected in server tab
- Better world's indexes handling between subgames lists
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/mainmenu/tab_server.lua | 9 | ||||
-rw-r--r-- | builtin/mainmenu/tab_singleplayer.lua | 9 |
2 files changed, 12 insertions, 6 deletions
diff --git a/builtin/mainmenu/tab_server.lua b/builtin/mainmenu/tab_server.lua index 62747c572..d08eecc21 100644 --- a/builtin/mainmenu/tab_server.lua +++ b/builtin/mainmenu/tab_server.lua @@ -113,12 +113,12 @@ local function main_button_handler(this, fields, name, tabdata) world_doubleclick or fields["key_enter"] then local selected = core.get_textlist_index("srv_worlds") - if selected ~= nil then + gamedata.selected_world = menudata.worldlist:get_raw_index(selected) + if selected ~= nil and gamedata.selected_world ~= 0 then gamedata.playername = fields["te_playername"] gamedata.password = fields["te_passwd"] gamedata.port = fields["te_serverport"] gamedata.address = "" - gamedata.selected_world = menudata.worldlist:get_raw_index(selected) core.setting_set("port",gamedata.port) if fields["te_serveraddr"] ~= nil then @@ -133,8 +133,11 @@ local function main_button_handler(this, fields, name, tabdata) end core.start() - return true + else + gamedata.errormessage = + fgettext("No world created or selected!") end + return true end if fields["world_create"] ~= nil then diff --git a/builtin/mainmenu/tab_singleplayer.lua b/builtin/mainmenu/tab_singleplayer.lua index 4ae4dde35..a40918af9 100644 --- a/builtin/mainmenu/tab_singleplayer.lua +++ b/builtin/mainmenu/tab_singleplayer.lua @@ -40,10 +40,13 @@ local function singleplayer_refresh_gamebar() menudata.worldlist:set_filtercriteria(gamemgr.games[j].id) local index = filterlist.get_current_index(menudata.worldlist, tonumber(core.setting_get("mainmenu_last_selected_world"))) - local selected = core.get_textlist_index("sp_worlds") if not index or index < 1 then - index = math.min(core.get_textlist_index("sp_worlds"), - #menudata.worldlist:get_list()) + local selected = core.get_textlist_index("sp_worlds") + if selected ~= nil and selected < #menudata.worldlist:get_list() then + index = selected + else + index = #menudata.worldlist:get_list() + end end menu_worldmt_legacy(index) return true |