Fixed mainmenu lua errors because of changes in get_textlist_index
Fixed lua error when none of the worlds or servers selected are and connect, delete or configure buttons used.
This commit is contained in:
parent
b11b48ec07
commit
66b24cc9ff
|
@ -296,7 +296,7 @@ function menu.handle_key_up_down(fields,textlist,settingname)
|
|||
if fields["key_up"] then
|
||||
local oldidx = engine.get_textlist_index(textlist)
|
||||
|
||||
if oldidx > 1 then
|
||||
if oldidx ~= nil and oldidx > 1 then
|
||||
local newidx = oldidx -1
|
||||
engine.setting_set(settingname,
|
||||
filterlist.get_raw_index(worldlist,newidx))
|
||||
|
@ -306,7 +306,7 @@ function menu.handle_key_up_down(fields,textlist,settingname)
|
|||
if fields["key_down"] then
|
||||
local oldidx = engine.get_textlist_index(textlist)
|
||||
|
||||
if oldidx < filterlist.size(worldlist) then
|
||||
if oldidx ~= nil and oldidx < filterlist.size(worldlist) then
|
||||
local newidx = oldidx + 1
|
||||
engine.setting_set(settingname,
|
||||
filterlist.get_raw_index(worldlist,newidx))
|
||||
|
@ -392,7 +392,7 @@ function tabbuilder.handle_create_world_buttons(fields)
|
|||
local worldname = fields["te_world_name"]
|
||||
local gameindex = engine.get_textlist_index("games")
|
||||
|
||||
if gameindex > 0 and
|
||||
if gameindex ~= nil and
|
||||
worldname ~= "" then
|
||||
|
||||
local message = nil
|
||||
|
@ -506,11 +506,13 @@ function tabbuilder.handle_multiplayer_buttons(fields)
|
|||
|
||||
local fav_idx = engine.get_textlist_index("favourites")
|
||||
|
||||
if fields["key_up"] ~= nil and fav_idx > 1 then
|
||||
fav_idx = fav_idx -1
|
||||
else if fields["key_down"] and fav_idx < #menu.favorites then
|
||||
fav_idx = fav_idx +1
|
||||
end end
|
||||
if fav_idx ~= nil then
|
||||
if fields["key_up"] ~= nil and fav_idx > 1 then
|
||||
fav_idx = fav_idx -1
|
||||
else if fields["key_down"] and fav_idx < #menu.favorites then
|
||||
fav_idx = fav_idx +1
|
||||
end end
|
||||
end
|
||||
|
||||
local address = menu.favorites[fav_idx].address
|
||||
local port = menu.favorites[fav_idx].port
|
||||
|
@ -539,6 +541,7 @@ function tabbuilder.handle_multiplayer_buttons(fields)
|
|||
|
||||
if fields["btn_delete_favorite"] ~= nil then
|
||||
local current_favourite = engine.get_textlist_index("favourites")
|
||||
if current_favourite == nil then return end
|
||||
engine.delete_favorite(current_favourite)
|
||||
menu.favorites = engine.get_favorites()
|
||||
menu.fav_selected = nil
|
||||
|
@ -559,7 +562,7 @@ function tabbuilder.handle_multiplayer_buttons(fields)
|
|||
|
||||
local fav_idx = engine.get_textlist_index("favourites")
|
||||
|
||||
if fav_idx > 0 and fav_idx <= #menu.favorites and
|
||||
if fav_idx ~= nil and fav_idx <= #menu.favorites and
|
||||
menu.favorites[fav_idx].address == fields["te_address"] and
|
||||
menu.favorites[fav_idx].port == fields["te_port"] then
|
||||
|
||||
|
@ -615,7 +618,7 @@ function tabbuilder.handle_server_buttons(fields)
|
|||
world_doubleclick or
|
||||
fields["key_enter"] then
|
||||
local selected = engine.get_textlist_index("srv_worlds")
|
||||
if selected > 0 then
|
||||
if selected ~= nil then
|
||||
gamedata.playername = fields["te_playername"]
|
||||
gamedata.password = fields["te_passwd"]
|
||||
gamedata.port = fields["te_serverport"]
|
||||
|
@ -637,7 +640,7 @@ function tabbuilder.handle_server_buttons(fields)
|
|||
|
||||
if fields["world_delete"] ~= nil then
|
||||
local selected = engine.get_textlist_index("srv_worlds")
|
||||
if selected > 0 and
|
||||
if selected ~= nil and
|
||||
selected <= filterlist.size(worldlist) then
|
||||
local world = filterlist.get_list(worldlist)[selected]
|
||||
if world ~= nil and
|
||||
|
@ -655,7 +658,7 @@ function tabbuilder.handle_server_buttons(fields)
|
|||
|
||||
if fields["world_configure"] ~= nil then
|
||||
selected = engine.get_textlist_index("srv_worlds")
|
||||
if selected > 0 then
|
||||
if selected ~= nil then
|
||||
modmgr.world_config_selected_world = filterlist.get_raw_index(worldlist,selected)
|
||||
if modmgr.init_worldconfig() then
|
||||
tabbuilder.current_tab = "dialog_configure_world"
|
||||
|
@ -763,7 +766,7 @@ function tabbuilder.handle_singleplayer_buttons(fields)
|
|||
world_doubleclick or
|
||||
fields["key_enter"] then
|
||||
local selected = engine.get_textlist_index("sp_worlds")
|
||||
if selected > 0 then
|
||||
if selected ~= nil then
|
||||
gamedata.selected_world = filterlist.get_raw_index(worldlist,selected)
|
||||
gamedata.singleplayer = true
|
||||
|
||||
|
@ -781,7 +784,7 @@ function tabbuilder.handle_singleplayer_buttons(fields)
|
|||
|
||||
if fields["world_delete"] ~= nil then
|
||||
local selected = engine.get_textlist_index("sp_worlds")
|
||||
if selected > 0 and
|
||||
if selected ~= nil and
|
||||
selected <= filterlist.size(worldlist) then
|
||||
local world = filterlist.get_list(worldlist)[selected]
|
||||
if world ~= nil and
|
||||
|
@ -799,7 +802,7 @@ function tabbuilder.handle_singleplayer_buttons(fields)
|
|||
|
||||
if fields["world_configure"] ~= nil then
|
||||
selected = engine.get_textlist_index("sp_worlds")
|
||||
if selected > 0 then
|
||||
if selected ~= nil then
|
||||
modmgr.world_config_selected_world = filterlist.get_raw_index(worldlist,selected)
|
||||
if modmgr.init_worldconfig() then
|
||||
tabbuilder.current_tab = "dialog_configure_world"
|
||||
|
@ -820,7 +823,7 @@ function tabbuilder.handle_texture_pack_buttons(fields)
|
|||
index)
|
||||
local list = filter_texture_pack_list(engine.get_dirlist(engine.get_texturepath(), true))
|
||||
local current_index = engine.get_textlist_index("TPs")
|
||||
if #list >= current_index then
|
||||
if current_index ~= nil and #list >= current_index then
|
||||
local new_path = engine.get_texturepath()..DIR_DELIM..list[current_index]
|
||||
if list[current_index] == "None" then new_path = "" end
|
||||
|
||||
|
|
|
@ -1067,7 +1067,7 @@ function modmgr.get_global_mod(idx)
|
|||
return nil
|
||||
end
|
||||
|
||||
if idx < 1 or idx > filterlist.size(modmgr.global_mods) then
|
||||
if idx == nil or idx < 1 or idx > filterlist.size(modmgr.global_mods) then
|
||||
return nil
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue