mirror of
https://github.com/moparisthebest/minetest
synced 2024-11-05 08:55:01 -05:00
Lua main menu: Fix crash on init lua error, mapgen dropdown index, and new worlds not saving index
This commit is contained in:
parent
ad4c065344
commit
a225efaec5
@ -437,6 +437,22 @@ end
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function tabbuilder.dialog_create_world()
|
function tabbuilder.dialog_create_world()
|
||||||
|
local mapgens = {"v6", "v7", "indev", "singlenode", "math"}
|
||||||
|
|
||||||
|
local current_mg = engine.setting_get("mg_name")
|
||||||
|
|
||||||
|
local mglist = ""
|
||||||
|
local selindex = 1
|
||||||
|
local i = 1
|
||||||
|
for k,v in pairs(mapgens) do
|
||||||
|
if current_mg == v then
|
||||||
|
selindex = i
|
||||||
|
end
|
||||||
|
i = i + 1
|
||||||
|
mglist = mglist .. v .. ","
|
||||||
|
end
|
||||||
|
mglist = mglist:sub(1, -2)
|
||||||
|
|
||||||
local retval =
|
local retval =
|
||||||
"label[2,0;World name]"..
|
"label[2,0;World name]"..
|
||||||
"label[2,1;Mapgen]"..
|
"label[2,1;Mapgen]"..
|
||||||
@ -444,7 +460,7 @@ function tabbuilder.dialog_create_world()
|
|||||||
"label[2,2;Game]"..
|
"label[2,2;Game]"..
|
||||||
"button[5,4.5;2.6,0.5;world_create_confirm;Create]" ..
|
"button[5,4.5;2.6,0.5;world_create_confirm;Create]" ..
|
||||||
"button[7.5,4.5;2.8,0.5;world_create_cancel;Cancel]" ..
|
"button[7.5,4.5;2.8,0.5;world_create_cancel;Cancel]" ..
|
||||||
"dropdown[4.2,1;6.3;dd_mapgen;v6,v7,indev,singlenode,math;1]" .. --TODO read from minetest
|
"dropdown[4.2,1;6.3;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" ..
|
||||||
"textlist[4.2,1.9;5.8,2.3;games;" ..
|
"textlist[4.2,1.9;5.8,2.3;games;" ..
|
||||||
gamemgr.gamelist() ..
|
gamemgr.gamelist() ..
|
||||||
";" .. menu.last_game .. ";true]"
|
";" .. menu.last_game .. ";true]"
|
||||||
@ -534,16 +550,12 @@ function tabbuilder.handle_create_world_buttons(fields)
|
|||||||
for i=1,#worldlist,1 do
|
for i=1,#worldlist,1 do
|
||||||
if worldlist[i].name == worldname then
|
if worldlist[i].name == worldname then
|
||||||
index = i
|
index = i
|
||||||
print("found new world index: " .. index)
|
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if tabbuilder.current_tab == "singleplayer" then
|
engine.setting_set("main_menu_singleplayer_world_idx", index)
|
||||||
engine.setting_set("main_menu_singleplayer_world_idx",index)
|
menu.last_world = index
|
||||||
else
|
|
||||||
menu.last_world = index
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
gamedata.errormessage = "No worldname given or no game selected"
|
gamedata.errormessage = "No worldname given or no game selected"
|
||||||
@ -805,7 +817,7 @@ function tabbuilder.handle_singleplayer_buttons(fields)
|
|||||||
if selected > 0 then
|
if selected > 0 then
|
||||||
gamedata.selected_world = menu.filtered_index_to_plain(selected)
|
gamedata.selected_world = menu.filtered_index_to_plain(selected)
|
||||||
gamedata.singleplayer = true
|
gamedata.singleplayer = true
|
||||||
|
|
||||||
engine.setting_set("main_menu_tab",tabbuilder.current_tab)
|
engine.setting_set("main_menu_tab",tabbuilder.current_tab)
|
||||||
engine.setting_set("main_menu_singleplayer_world_idx",selected)
|
engine.setting_set("main_menu_singleplayer_world_idx",selected)
|
||||||
|
|
||||||
@ -1023,7 +1035,7 @@ end
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function tabbuilder.tab_singleplayer()
|
function tabbuilder.tab_singleplayer()
|
||||||
local index = engine.setting_get("main_menu_singleplayer_world_idx")
|
local index = engine.setting_get("main_menu_singleplayer_world_idx")
|
||||||
|
|
||||||
if index == nil then
|
if index == nil then
|
||||||
index = 0
|
index = 0
|
||||||
end
|
end
|
||||||
|
@ -299,6 +299,8 @@ GUIEngine::~GUIEngine()
|
|||||||
{
|
{
|
||||||
video::IVideoDriver* driver = m_device->getVideoDriver();
|
video::IVideoDriver* driver = m_device->getVideoDriver();
|
||||||
assert(driver != 0);
|
assert(driver != 0);
|
||||||
|
|
||||||
|
//TODO: clean up m_menu here
|
||||||
|
|
||||||
lua_close(m_engineluastack);
|
lua_close(m_engineluastack);
|
||||||
|
|
||||||
@ -309,8 +311,9 @@ GUIEngine::~GUIEngine()
|
|||||||
if (m_textures[i] != 0)
|
if (m_textures[i] != 0)
|
||||||
driver->removeTexture(m_textures[i]);
|
driver->removeTexture(m_textures[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_cloud.clouds->drop();
|
if (m_cloud.clouds)
|
||||||
|
m_cloud.clouds->drop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user