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