2013-08-11 04:09:45 +02:00
|
|
|
print = engine.debug
|
|
|
|
math.randomseed(os.time())
|
2013-07-08 02:28:36 +02:00
|
|
|
os.setlocale("C", "numeric")
|
|
|
|
|
2013-08-25 12:54:16 +02:00
|
|
|
local errorfct = error
|
|
|
|
error = function(text)
|
|
|
|
print(debug.traceback(""))
|
|
|
|
errorfct(text)
|
|
|
|
end
|
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
local scriptpath = engine.get_scriptdir()
|
|
|
|
|
2013-07-15 22:56:53 +02:00
|
|
|
mt_color_grey = "#AAAAAA"
|
|
|
|
mt_color_blue = "#0000DD"
|
|
|
|
mt_color_green = "#00DD00"
|
|
|
|
mt_color_dark_green = "#003300"
|
|
|
|
|
2013-07-16 20:56:18 +02:00
|
|
|
--for all other colors ask sfan5 to complete his worK!
|
|
|
|
|
2013-08-11 04:09:45 +02:00
|
|
|
dofile(scriptpath .. DIR_DELIM .. "misc_helpers.lua")
|
2013-07-15 23:02:18 +02:00
|
|
|
dofile(scriptpath .. DIR_DELIM .. "filterlist.lua")
|
2013-06-23 18:30:21 +02:00
|
|
|
dofile(scriptpath .. DIR_DELIM .. "modmgr.lua")
|
|
|
|
dofile(scriptpath .. DIR_DELIM .. "modstore.lua")
|
|
|
|
dofile(scriptpath .. DIR_DELIM .. "gamemgr.lua")
|
2013-07-16 20:56:18 +02:00
|
|
|
dofile(scriptpath .. DIR_DELIM .. "mm_textures.lua")
|
|
|
|
dofile(scriptpath .. DIR_DELIM .. "mm_menubar.lua")
|
2013-11-26 18:15:31 +01:00
|
|
|
dofile(scriptpath .. DIR_DELIM .. "async_event.lua")
|
2013-06-23 18:30:21 +02:00
|
|
|
|
2013-07-16 20:56:18 +02:00
|
|
|
menu = {}
|
2013-06-23 18:30:21 +02:00
|
|
|
local tabbuilder = {}
|
2013-07-14 13:19:37 +02:00
|
|
|
local worldlist = nil
|
2013-06-23 18:30:21 +02:00
|
|
|
|
2013-08-02 15:18:48 +02:00
|
|
|
--------------------------------------------------------------------------------
|
2013-08-14 19:22:23 +02:00
|
|
|
local function filter_texture_pack_list(list)
|
|
|
|
retval = {"None"}
|
|
|
|
for _,i in ipairs(list) do
|
2013-08-02 15:18:48 +02:00
|
|
|
if i~="base" then
|
2013-08-14 19:22:23 +02:00
|
|
|
table.insert(retval, i)
|
2013-08-02 15:18:48 +02:00
|
|
|
end
|
|
|
|
end
|
2013-08-14 19:22:23 +02:00
|
|
|
return retval
|
2013-08-02 15:18:48 +02:00
|
|
|
end
|
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
--------------------------------------------------------------------------------
|
2013-07-16 20:56:18 +02:00
|
|
|
function menu.render_favorite(spec,render_details)
|
2013-06-23 18:30:21 +02:00
|
|
|
local text = ""
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if spec.name ~= nil then
|
2013-08-14 20:21:39 +02:00
|
|
|
text = text .. engine.formspec_escape(spec.name:trim())
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-12 22:42:50 +02:00
|
|
|
-- if spec.description ~= nil and
|
2013-08-14 20:21:39 +02:00
|
|
|
-- engine.formspec_escape(spec.description):trim() ~= "" then
|
|
|
|
-- text = text .. " (" .. engine.formspec_escape(spec.description) .. ")"
|
2013-07-12 22:42:50 +02:00
|
|
|
-- end
|
2013-06-23 18:30:21 +02:00
|
|
|
else
|
|
|
|
if spec.address ~= nil then
|
|
|
|
text = text .. spec.address:trim()
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-22 22:53:37 +02:00
|
|
|
if spec.port ~= nil then
|
|
|
|
text = text .. ":" .. spec.port
|
|
|
|
end
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-12 22:55:19 +02:00
|
|
|
if not render_details then
|
|
|
|
return text
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
local details = ""
|
|
|
|
if spec.password == true then
|
2013-07-12 21:56:42 +02:00
|
|
|
details = details .. "*"
|
2013-06-23 18:30:21 +02:00
|
|
|
else
|
2013-07-12 21:56:42 +02:00
|
|
|
details = details .. "_"
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if spec.creative then
|
|
|
|
details = details .. "C"
|
|
|
|
else
|
2013-07-12 21:56:42 +02:00
|
|
|
details = details .. "_"
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if spec.damage then
|
|
|
|
details = details .. "D"
|
|
|
|
else
|
2013-07-12 21:56:42 +02:00
|
|
|
details = details .. "_"
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if spec.pvp then
|
|
|
|
details = details .. "P"
|
|
|
|
else
|
2013-07-12 21:56:42 +02:00
|
|
|
details = details .. "_"
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
2013-07-15 23:28:55 +02:00
|
|
|
details = details .. " "
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-15 23:28:55 +02:00
|
|
|
local playercount = ""
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-15 23:28:55 +02:00
|
|
|
if spec.clients ~= nil and
|
|
|
|
spec.clients_max ~= nil then
|
|
|
|
playercount = string.format("%03d",spec.clients) .. "/" ..
|
|
|
|
string.format("%03d",spec.clients_max) .. " "
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-08-14 20:21:39 +02:00
|
|
|
return playercount .. engine.formspec_escape(details) .. text
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
os.tempfolder = function()
|
|
|
|
local filetocheck = os.tmpname()
|
|
|
|
os.remove(filetocheck)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
local randname = "MTTempModFolder_" .. math.random(0,10000)
|
|
|
|
if DIR_DELIM == "\\" then
|
|
|
|
local tempfolder = os.getenv("TEMP")
|
|
|
|
return tempfolder .. filetocheck
|
|
|
|
else
|
|
|
|
local backstring = filetocheck:reverse()
|
|
|
|
return filetocheck:sub(0,filetocheck:len()-backstring:find(DIR_DELIM)+1) ..randname
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function init_globals()
|
|
|
|
--init gamedata
|
|
|
|
gamedata.worldindex = 0
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-14 13:19:37 +02:00
|
|
|
worldlist = filterlist.create(
|
|
|
|
engine.get_worlds,
|
|
|
|
compare_worlds,
|
|
|
|
function(element,uid)
|
|
|
|
if element.name == uid then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end, --unique id compare fct
|
|
|
|
function(element,gameid)
|
|
|
|
if element.gameid == gameid then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end --filter fct
|
|
|
|
)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-14 13:19:37 +02:00
|
|
|
filterlist.add_sort_mechanism(worldlist,"alphabetic",sort_worlds_alphabetic)
|
|
|
|
filterlist.set_sortmode(worldlist,"alphabetic")
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function update_menu()
|
|
|
|
|
2013-09-17 09:18:50 +02:00
|
|
|
local formspec
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
-- handle errors
|
|
|
|
if gamedata.errormessage ~= nil then
|
2013-09-17 09:18:50 +02:00
|
|
|
formspec = "size[12,5.2]" ..
|
2013-06-23 18:30:21 +02:00
|
|
|
"field[1,2;10,2;;ERROR: " ..
|
2013-11-26 18:15:31 +01:00
|
|
|
gamedata.errormessage ..
|
2013-06-23 18:30:21 +02:00
|
|
|
";]"..
|
2013-08-14 19:22:23 +02:00
|
|
|
"button[4.5,4.2;3,0.5;btn_error_confirm;" .. fgettext("Ok") .. "]"
|
2013-06-23 18:30:21 +02:00
|
|
|
else
|
2013-09-17 09:18:50 +02:00
|
|
|
formspec = tabbuilder.gettab()
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
engine.update_formspec(formspec)
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
2013-07-09 23:17:38 +02:00
|
|
|
function menu.render_world_list()
|
2013-06-23 18:30:21 +02:00
|
|
|
local retval = ""
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-14 13:19:37 +02:00
|
|
|
local current_worldlist = filterlist.get_list(worldlist)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-09 23:17:38 +02:00
|
|
|
for i,v in ipairs(current_worldlist) do
|
|
|
|
if retval ~= "" then
|
|
|
|
retval = retval ..","
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-08-29 14:12:16 +02:00
|
|
|
retval = retval .. engine.formspec_escape(v.name) ..
|
|
|
|
" \\[" .. engine.formspec_escape(v.gameid) .. "\\]"
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
2013-07-09 23:17:38 +02:00
|
|
|
|
|
|
|
return retval
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
|
2013-08-02 15:18:48 +02:00
|
|
|
--------------------------------------------------------------------------------
|
2013-08-14 19:22:23 +02:00
|
|
|
function menu.render_texture_pack_list(list)
|
2013-08-02 15:18:48 +02:00
|
|
|
local retval = ""
|
|
|
|
|
2013-08-14 19:22:23 +02:00
|
|
|
for i,v in ipairs(list) do
|
2013-08-02 15:18:48 +02:00
|
|
|
if retval ~= "" then
|
|
|
|
retval = retval ..","
|
|
|
|
end
|
|
|
|
|
|
|
|
retval = retval .. v
|
|
|
|
end
|
|
|
|
|
|
|
|
return retval
|
|
|
|
end
|
|
|
|
|
2013-11-26 18:15:31 +01:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function menu.asyncOnlineFavourites()
|
|
|
|
menu.favorites = {}
|
|
|
|
engine.handle_async(
|
|
|
|
function(param)
|
|
|
|
return engine.get_favorites("online")
|
|
|
|
end,
|
|
|
|
nil,
|
|
|
|
function(result)
|
|
|
|
menu.favorites = result
|
|
|
|
engine.event_handler("Refresh")
|
|
|
|
end
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function menu.init()
|
|
|
|
--init menu data
|
|
|
|
gamemgr.update_gamelist()
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
menu.last_game = tonumber(engine.setting_get("main_menu_last_game_idx"))
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if type(menu.last_game) ~= "number" then
|
|
|
|
menu.last_game = 1
|
|
|
|
end
|
|
|
|
|
|
|
|
if engine.setting_getbool("public_serverlist") then
|
2013-11-26 18:15:31 +01:00
|
|
|
menu.asyncOnlineFavourites()
|
2013-06-23 18:30:21 +02:00
|
|
|
else
|
|
|
|
menu.favorites = engine.get_favorites("local")
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
|
|
|
menu.defaulttexturedir = engine.get_texturepath() .. DIR_DELIM .. "base" ..
|
2013-07-16 20:56:18 +02:00
|
|
|
DIR_DELIM .. "pack" .. DIR_DELIM
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function menu.lastgame()
|
|
|
|
if menu.last_game > 0 and menu.last_game <= #gamemgr.games then
|
|
|
|
return gamemgr.games[menu.last_game]
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if #gamemgr.games >= 1 then
|
|
|
|
menu.last_game = 1
|
|
|
|
return gamemgr.games[menu.last_game]
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
--error case!!
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
2013-07-09 23:17:38 +02:00
|
|
|
function menu.update_last_game()
|
|
|
|
|
2013-07-14 13:19:37 +02:00
|
|
|
local current_world = filterlist.get_raw_element(worldlist,
|
2013-07-09 23:17:38 +02:00
|
|
|
engine.setting_get("mainmenu_last_selected_world")
|
|
|
|
)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-09 23:17:38 +02:00
|
|
|
if current_world == nil then
|
|
|
|
return
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-08-19 13:55:04 +02:00
|
|
|
local gamespec, i = gamemgr.find_by_gameid(current_world.gameid)
|
|
|
|
if i ~= nil then
|
|
|
|
menu.last_game = i
|
|
|
|
engine.setting_set("main_menu_last_game_idx",menu.last_game)
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
2013-07-09 23:17:38 +02:00
|
|
|
function menu.handle_key_up_down(fields,textlist,settingname)
|
|
|
|
|
|
|
|
if fields["key_up"] then
|
|
|
|
local oldidx = engine.get_textlist_index(textlist)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-09 23:17:38 +02:00
|
|
|
if oldidx > 1 then
|
|
|
|
local newidx = oldidx -1
|
|
|
|
engine.setting_set(settingname,
|
2013-07-15 23:02:18 +02:00
|
|
|
filterlist.get_raw_index(worldlist,newidx))
|
2013-07-08 21:02:42 +02:00
|
|
|
end
|
2013-07-09 23:17:38 +02:00
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-09 23:17:38 +02:00
|
|
|
if fields["key_down"] then
|
|
|
|
local oldidx = engine.get_textlist_index(textlist)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-14 13:19:37 +02:00
|
|
|
if oldidx < filterlist.size(worldlist) then
|
2013-07-09 23:17:38 +02:00
|
|
|
local newidx = oldidx + 1
|
|
|
|
engine.setting_set(settingname,
|
2013-07-15 23:02:18 +02:00
|
|
|
filterlist.get_raw_index(worldlist,newidx))
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function tabbuilder.dialog_create_world()
|
2013-07-03 07:25:26 +02:00
|
|
|
local mapgens = {"v6", "v7", "indev", "singlenode", "math"}
|
|
|
|
|
2013-09-17 09:18:50 +02:00
|
|
|
local current_seed = engine.setting_get("fixed_map_seed") or ""
|
|
|
|
local current_mg = engine.setting_get("mg_name")
|
2013-07-03 07:25:26 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2013-11-26 18:15:31 +01:00
|
|
|
local retval =
|
2013-08-14 19:22:23 +02:00
|
|
|
"label[2,0;" .. fgettext("World name") .. "]"..
|
2013-06-23 18:30:21 +02:00
|
|
|
"field[4.5,0.4;6,0.5;te_world_name;;]" ..
|
2013-09-17 09:18:50 +02:00
|
|
|
|
|
|
|
"label[2,1;" .. fgettext("Seed") .. "]"..
|
|
|
|
"field[4.5,1.4;6,0.5;te_seed;;".. current_seed .. "]" ..
|
|
|
|
|
|
|
|
"label[2,2;" .. fgettext("Mapgen") .. "]"..
|
|
|
|
"dropdown[4.2,2;6.3;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" ..
|
|
|
|
|
|
|
|
"label[2,3;" .. fgettext("Game") .. "]"..
|
|
|
|
"textlist[4.2,3;5.8,2.3;games;" .. gamemgr.gamelist() ..
|
|
|
|
";" .. menu.last_game .. ";true]" ..
|
|
|
|
|
|
|
|
"button[5,5.5;2.6,0.5;world_create_confirm;" .. fgettext("Create") .. "]" ..
|
|
|
|
"button[7.5,5.5;2.8,0.5;world_create_cancel;" .. fgettext("Cancel") .. "]"
|
2013-06-23 18:30:21 +02:00
|
|
|
|
|
|
|
return retval
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function tabbuilder.dialog_delete_world()
|
2013-08-14 19:22:23 +02:00
|
|
|
return "label[2,2;" ..
|
|
|
|
fgettext("Delete World \"$1\"?", filterlist.get_raw_list(worldlist)[menu.world_to_del].name) .. "]"..
|
|
|
|
"button[3.5,4.2;2.6,0.5;world_delete_confirm;" .. fgettext("Yes").. "]" ..
|
|
|
|
"button[6,4.2;2.8,0.5;world_delete_cancel;" .. fgettext("No") .. "]"
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
2013-09-17 09:18:50 +02:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
function tabbuilder.gettab()
|
2013-09-17 09:18:50 +02:00
|
|
|
local tsize = tabbuilder.tabsizes[tabbuilder.current_tab] or {width=12, height=5.2}
|
|
|
|
local retval = "size[" .. tsize.width .. "," .. tsize.height .. "]"
|
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if tabbuilder.show_buttons then
|
|
|
|
retval = retval .. tabbuilder.tab_header()
|
|
|
|
end
|
|
|
|
|
2013-09-17 09:18:50 +02:00
|
|
|
local buildfunc = tabbuilder.tabfuncs[tabbuilder.current_tab]
|
|
|
|
if buildfunc ~= nil then
|
|
|
|
retval = retval .. buildfunc()
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
retval = retval .. modmgr.gettab(tabbuilder.current_tab)
|
|
|
|
retval = retval .. gamemgr.gettab(tabbuilder.current_tab)
|
|
|
|
retval = retval .. modstore.gettab(tabbuilder.current_tab)
|
|
|
|
|
|
|
|
return retval
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function tabbuilder.handle_create_world_buttons(fields)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-08 21:02:42 +02:00
|
|
|
if fields["world_create_confirm"] or
|
|
|
|
fields["key_enter"] then
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
local worldname = fields["te_world_name"]
|
|
|
|
local gameindex = engine.get_textlist_index("games")
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if gameindex > 0 and
|
|
|
|
worldname ~= "" then
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-07 21:53:40 +02:00
|
|
|
local message = nil
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-18 00:35:58 +02:00
|
|
|
if not filterlist.uid_exists_raw(worldlist,worldname) then
|
2013-07-07 21:53:40 +02:00
|
|
|
engine.setting_set("mg_name",fields["dd_mapgen"])
|
|
|
|
message = engine.create_world(worldname,gameindex)
|
|
|
|
else
|
2013-08-14 19:22:23 +02:00
|
|
|
message = fgettext("A world named \"$1\" already exists", worldname)
|
2013-07-07 21:53:40 +02:00
|
|
|
end
|
2013-09-17 09:18:50 +02:00
|
|
|
|
|
|
|
engine.setting_set("fixed_map_seed", fields["te_seed"])
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if message ~= nil then
|
|
|
|
gamedata.errormessage = message
|
|
|
|
else
|
2013-07-07 21:53:40 +02:00
|
|
|
menu.last_game = gameindex
|
|
|
|
engine.setting_set("main_menu_last_game_idx",gameindex)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-14 13:19:37 +02:00
|
|
|
filterlist.refresh(worldlist)
|
2013-07-09 23:17:38 +02:00
|
|
|
engine.setting_set("mainmenu_last_selected_world",
|
2013-07-15 23:02:18 +02:00
|
|
|
filterlist.raw_index_by_uid(worldlist,worldname))
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
else
|
2013-11-26 18:15:31 +01:00
|
|
|
gamedata.errormessage =
|
2013-08-14 19:22:23 +02:00
|
|
|
fgettext("No worldname given or no game selected")
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["games"] then
|
|
|
|
tabbuilder.skipformupdate = true
|
|
|
|
return
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-09 23:17:38 +02:00
|
|
|
--close dialog
|
2013-06-23 18:30:21 +02:00
|
|
|
tabbuilder.is_dialog = false
|
|
|
|
tabbuilder.show_buttons = true
|
|
|
|
tabbuilder.current_tab = engine.setting_get("main_menu_tab")
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function tabbuilder.handle_delete_world_buttons(fields)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["world_delete_confirm"] then
|
2013-11-26 18:15:31 +01:00
|
|
|
if menu.world_to_del > 0 and
|
2013-07-14 13:19:37 +02:00
|
|
|
menu.world_to_del <= #filterlist.get_raw_list(worldlist) then
|
2013-07-09 23:17:38 +02:00
|
|
|
engine.delete_world(menu.world_to_del)
|
|
|
|
menu.world_to_del = 0
|
2013-07-14 13:19:37 +02:00
|
|
|
filterlist.refresh(worldlist)
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
tabbuilder.is_dialog = false
|
|
|
|
tabbuilder.show_buttons = true
|
|
|
|
tabbuilder.current_tab = engine.setting_get("main_menu_tab")
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function tabbuilder.handle_multiplayer_buttons(fields)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-07 21:53:40 +02:00
|
|
|
if fields["te_name"] ~= nil then
|
|
|
|
gamedata.playername = fields["te_name"]
|
|
|
|
engine.setting_set("name", fields["te_name"])
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["favourites"] ~= nil then
|
|
|
|
local event = explode_textlist_event(fields["favourites"])
|
|
|
|
if event.typ == "DCL" then
|
2013-11-28 21:43:06 +01:00
|
|
|
if event.index <= #menu.favorites then
|
|
|
|
gamedata.address = menu.favorites[event.index].address
|
|
|
|
gamedata.port = menu.favorites[event.index].port
|
|
|
|
gamedata.playername = fields["te_name"]
|
|
|
|
if fields["te_pwd"] ~= nil then
|
|
|
|
gamedata.password = fields["te_pwd"]
|
|
|
|
end
|
|
|
|
gamedata.selected_world = 0
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-11-28 21:43:06 +01:00
|
|
|
if menu.favorites ~= nil then
|
|
|
|
gamedata.servername = menu.favorites[event.index].name
|
|
|
|
gamedata.serverdescription = menu.favorites[event.index].description
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-11-28 21:43:06 +01:00
|
|
|
if gamedata.address ~= nil and
|
|
|
|
gamedata.port ~= nil then
|
|
|
|
engine.setting_set("address",gamedata.address)
|
|
|
|
engine.setting_set("remote_port",gamedata.port)
|
|
|
|
engine.start()
|
|
|
|
end
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if event.typ == "CHG" then
|
2013-11-28 21:43:06 +01:00
|
|
|
if event.index <= #menu.favorites then
|
|
|
|
local address = menu.favorites[event.index].address
|
|
|
|
local port = menu.favorites[event.index].port
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-11-28 21:43:06 +01:00
|
|
|
if address ~= nil and
|
|
|
|
port ~= nil then
|
|
|
|
engine.setting_set("address",address)
|
|
|
|
engine.setting_set("remote_port",port)
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-11-28 21:43:06 +01:00
|
|
|
menu.fav_selected = event.index
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-07 21:53:40 +02:00
|
|
|
if fields["key_up"] ~= nil or
|
|
|
|
fields["key_down"] ~= nil then
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-07 21:53:40 +02:00
|
|
|
local fav_idx = engine.get_textlist_index("favourites")
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-07 21:53:40 +02:00
|
|
|
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
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-12 22:42:50 +02:00
|
|
|
local address = menu.favorites[fav_idx].address
|
2013-07-07 21:53:40 +02:00
|
|
|
local port = menu.favorites[fav_idx].port
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-07 21:53:40 +02:00
|
|
|
if address ~= nil and
|
|
|
|
port ~= nil then
|
|
|
|
engine.setting_set("address",address)
|
2013-11-28 21:43:06 +01:00
|
|
|
engine.setting_set("remote_port",port)
|
2013-07-07 21:53:40 +02:00
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-07 21:53:40 +02:00
|
|
|
menu.fav_selected = fav_idx
|
|
|
|
return
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["cb_public_serverlist"] ~= nil then
|
2013-09-10 21:24:49 +02:00
|
|
|
engine.setting_set("public_serverlist", fields["cb_public_serverlist"])
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if engine.setting_getbool("public_serverlist") then
|
2013-11-26 18:15:31 +01:00
|
|
|
menu.asyncOnlineFavourites()
|
2013-06-23 18:30:21 +02:00
|
|
|
else
|
|
|
|
menu.favorites = engine.get_favorites("local")
|
|
|
|
end
|
2013-07-09 21:54:30 +02:00
|
|
|
menu.fav_selected = nil
|
2013-07-07 21:53:40 +02:00
|
|
|
return
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if fields["btn_delete_favorite"] ~= nil then
|
|
|
|
local current_favourite = engine.get_textlist_index("favourites")
|
|
|
|
engine.delete_favorite(current_favourite)
|
|
|
|
menu.favorites = engine.get_favorites()
|
2013-07-09 21:54:30 +02:00
|
|
|
menu.fav_selected = nil
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
engine.setting_set("address","")
|
2013-11-28 21:43:06 +01:00
|
|
|
engine.setting_set("remote_port","30000")
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2013-07-07 21:53:40 +02:00
|
|
|
if fields["btn_mp_connect"] ~= nil or
|
2013-11-28 21:43:06 +01:00
|
|
|
fields["key_enter"] ~= nil then
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
gamedata.playername = fields["te_name"]
|
|
|
|
gamedata.password = fields["te_pwd"]
|
|
|
|
gamedata.address = fields["te_address"]
|
|
|
|
gamedata.port = fields["te_port"]
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-09 21:54:30 +02:00
|
|
|
local fav_idx = engine.get_textlist_index("favourites")
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-09 21:54:30 +02:00
|
|
|
if fav_idx > 0 and fav_idx <= #menu.favorites and
|
|
|
|
menu.favorites[fav_idx].address == fields["te_address"] and
|
2013-11-28 21:43:06 +01:00
|
|
|
menu.favorites[fav_idx].port == fields["te_port"] then
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-09 21:54:30 +02:00
|
|
|
gamedata.servername = menu.favorites[fav_idx].name
|
|
|
|
gamedata.serverdescription = menu.favorites[fav_idx].description
|
|
|
|
else
|
2013-11-28 21:43:06 +01:00
|
|
|
gamedata.servername = ""
|
|
|
|
gamedata.serverdescription = ""
|
2013-07-09 21:54:30 +02:00
|
|
|
end
|
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
gamedata.selected_world = 0
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-11-28 21:43:06 +01:00
|
|
|
engine.setting_set("address",fields["te_address"])
|
|
|
|
engine.setting_set("remote_port",fields["te_port"])
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
engine.start()
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function tabbuilder.handle_server_buttons(fields)
|
|
|
|
|
|
|
|
local world_doubleclick = false
|
|
|
|
|
2013-07-07 21:53:40 +02:00
|
|
|
if fields["srv_worlds"] ~= nil then
|
|
|
|
local event = explode_textlist_event(fields["srv_worlds"])
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-07 21:53:40 +02:00
|
|
|
if event.typ == "DCL" then
|
2013-06-23 18:30:21 +02:00
|
|
|
world_doubleclick = true
|
|
|
|
end
|
2013-07-07 21:53:40 +02:00
|
|
|
if event.typ == "CHG" then
|
2013-07-09 23:17:38 +02:00
|
|
|
engine.setting_set("mainmenu_last_selected_world",
|
2013-07-15 23:02:18 +02:00
|
|
|
filterlist.get_raw_index(worldlist,engine.get_textlist_index("srv_worlds")))
|
2013-07-07 21:53:40 +02:00
|
|
|
end
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-09 23:17:38 +02:00
|
|
|
menu.handle_key_up_down(fields,"srv_worlds","mainmenu_last_selected_world")
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["cb_creative_mode"] then
|
2013-09-10 21:24:49 +02:00
|
|
|
engine.setting_set("creative_mode", fields["cb_creative_mode"])
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["cb_enable_damage"] then
|
2013-09-10 21:24:49 +02:00
|
|
|
engine.setting_set("enable_damage", fields["cb_enable_damage"])
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
2013-07-09 22:09:17 +02:00
|
|
|
|
|
|
|
if fields["cb_server_announce"] then
|
2013-09-10 21:24:49 +02:00
|
|
|
engine.setting_set("server_announce", fields["cb_server_announce"])
|
2013-07-09 22:09:17 +02:00
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["start_server"] ~= nil or
|
2013-07-07 21:53:40 +02:00
|
|
|
world_doubleclick or
|
|
|
|
fields["key_enter"] then
|
2013-06-23 18:30:21 +02:00
|
|
|
local selected = engine.get_textlist_index("srv_worlds")
|
|
|
|
if selected > 0 then
|
|
|
|
gamedata.playername = fields["te_playername"]
|
2013-07-07 21:53:40 +02:00
|
|
|
gamedata.password = fields["te_passwd"]
|
2013-06-23 18:30:21 +02:00
|
|
|
gamedata.port = fields["te_serverport"]
|
2013-07-07 21:53:40 +02:00
|
|
|
gamedata.address = ""
|
2013-07-15 23:02:18 +02:00
|
|
|
gamedata.selected_world = filterlist.get_raw_index(worldlist,selected)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-11-28 21:43:06 +01:00
|
|
|
engine.setting_set("port",gamedata.port)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
menu.update_last_game(gamedata.selected_world)
|
|
|
|
engine.start()
|
|
|
|
end
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["world_create"] ~= nil then
|
|
|
|
tabbuilder.current_tab = "dialog_create_world"
|
|
|
|
tabbuilder.is_dialog = true
|
|
|
|
tabbuilder.show_buttons = false
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["world_delete"] ~= nil then
|
|
|
|
local selected = engine.get_textlist_index("srv_worlds")
|
2013-07-09 23:17:38 +02:00
|
|
|
if selected > 0 and
|
2013-07-14 13:19:37 +02:00
|
|
|
selected <= filterlist.size(worldlist) then
|
|
|
|
local world = filterlist.get_list(worldlist)[selected]
|
2013-07-09 23:17:38 +02:00
|
|
|
if world ~= nil and
|
|
|
|
world.name ~= nil and
|
|
|
|
world.name ~= "" then
|
2013-07-15 23:02:18 +02:00
|
|
|
menu.world_to_del = filterlist.get_raw_index(worldlist,selected)
|
2013-06-23 18:30:21 +02:00
|
|
|
tabbuilder.current_tab = "dialog_delete_world"
|
|
|
|
tabbuilder.is_dialog = true
|
|
|
|
tabbuilder.show_buttons = false
|
|
|
|
else
|
2013-07-09 23:17:38 +02:00
|
|
|
menu.world_to_del = 0
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["world_configure"] ~= nil then
|
|
|
|
selected = engine.get_textlist_index("srv_worlds")
|
|
|
|
if selected > 0 then
|
2013-07-15 23:02:18 +02:00
|
|
|
modmgr.world_config_selected_world = filterlist.get_raw_index(worldlist,selected)
|
2013-06-23 18:30:21 +02:00
|
|
|
if modmgr.init_worldconfig() then
|
|
|
|
tabbuilder.current_tab = "dialog_configure_world"
|
|
|
|
tabbuilder.is_dialog = true
|
|
|
|
tabbuilder.show_buttons = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function tabbuilder.handle_settings_buttons(fields)
|
|
|
|
if fields["cb_fancy_trees"] then
|
2013-09-10 21:24:49 +02:00
|
|
|
engine.setting_set("new_style_leaves", fields["cb_fancy_trees"])
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
if fields["cb_smooth_lighting"] then
|
2013-09-10 21:24:49 +02:00
|
|
|
engine.setting_set("smooth_lighting", fields["cb_smooth_lighting"])
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
if fields["cb_3d_clouds"] then
|
2013-09-10 21:24:49 +02:00
|
|
|
engine.setting_set("enable_3d_clouds", fields["cb_3d_clouds"])
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
if fields["cb_opaque_water"] then
|
2013-09-10 21:24:49 +02:00
|
|
|
engine.setting_set("opaque_water", fields["cb_opaque_water"])
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["cb_mipmapping"] then
|
2013-09-10 21:24:49 +02:00
|
|
|
engine.setting_set("mip_map", fields["cb_mipmapping"])
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
if fields["cb_anisotrophic"] then
|
2013-09-10 21:24:49 +02:00
|
|
|
engine.setting_set("anisotropic_filter", fields["cb_anisotrophic"])
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
if fields["cb_bilinear"] then
|
2013-09-10 21:24:49 +02:00
|
|
|
engine.setting_set("bilinear_filter", fields["cb_bilinear"])
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
if fields["cb_trilinear"] then
|
2013-09-10 21:24:49 +02:00
|
|
|
engine.setting_set("trilinear_filter", fields["cb_trilinear"])
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["cb_shaders"] then
|
2013-11-23 08:55:48 +01:00
|
|
|
if (engine.setting_get("video_driver") == "direct3d8" or engine.setting_get("video_driver") == "direct3d9") then
|
|
|
|
engine.setting_set("enable_shaders", "false")
|
|
|
|
gamedata.errormessage = fgettext("To enable shaders the OpenGL driver needs to be used.")
|
|
|
|
else
|
|
|
|
engine.setting_set("enable_shaders", fields["cb_shaders"])
|
|
|
|
end
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
if fields["cb_pre_ivis"] then
|
2013-09-10 21:24:49 +02:00
|
|
|
engine.setting_set("preload_item_visuals", fields["cb_pre_ivis"])
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
if fields["cb_particles"] then
|
2013-09-10 21:24:49 +02:00
|
|
|
engine.setting_set("enable_particles", fields["cb_particles"])
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
if fields["cb_finite_liquid"] then
|
2013-09-10 21:24:49 +02:00
|
|
|
engine.setting_set("liquid_finite", fields["cb_finite_liquid"])
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
2013-12-03 17:21:40 +01:00
|
|
|
if fields["cb_bumpmapping"] then
|
|
|
|
engine.setting_set("enable_bumpmapping", fields["cb_bumpmapping"])
|
|
|
|
end
|
|
|
|
if fields["cb_parallax"] then
|
|
|
|
engine.setting_set("enable_parallax_occlusion", fields["cb_parallax"])
|
|
|
|
end
|
|
|
|
if fields["cb_waving_water"] then
|
|
|
|
engine.setting_set("enable_waving_water", fields["cb_waving_water"])
|
|
|
|
end
|
|
|
|
if fields["cb_waving_leaves"] then
|
|
|
|
engine.setting_set("enable_waving_leaves", fields["cb_waving_leaves"])
|
|
|
|
end
|
|
|
|
if fields["cb_waving_plants"] then
|
|
|
|
engine.setting_set("enable_waving_plants", fields["cb_waving_plants"])
|
|
|
|
end
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["btn_change_keys"] ~= nil then
|
|
|
|
engine.show_keys_menu()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function tabbuilder.handle_singleplayer_buttons(fields)
|
|
|
|
|
|
|
|
local world_doubleclick = false
|
|
|
|
|
|
|
|
if fields["sp_worlds"] ~= nil then
|
|
|
|
local event = explode_textlist_event(fields["sp_worlds"])
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if event.typ == "DCL" then
|
|
|
|
world_doubleclick = true
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-07 21:53:40 +02:00
|
|
|
if event.typ == "CHG" then
|
2013-07-09 23:17:38 +02:00
|
|
|
engine.setting_set("mainmenu_last_selected_world",
|
2013-07-15 23:02:18 +02:00
|
|
|
filterlist.get_raw_index(worldlist,engine.get_textlist_index("sp_worlds")))
|
2013-07-07 21:53:40 +02:00
|
|
|
end
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-09 23:17:38 +02:00
|
|
|
menu.handle_key_up_down(fields,"sp_worlds","mainmenu_last_selected_world")
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["cb_creative_mode"] then
|
2013-09-10 21:24:49 +02:00
|
|
|
engine.setting_set("creative_mode", fields["cb_creative_mode"])
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["cb_enable_damage"] then
|
2013-09-10 21:24:49 +02:00
|
|
|
engine.setting_set("enable_damage", fields["cb_enable_damage"])
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if fields["play"] ~= nil or
|
2013-07-07 21:53:40 +02:00
|
|
|
world_doubleclick or
|
|
|
|
fields["key_enter"] then
|
2013-06-23 18:30:21 +02:00
|
|
|
local selected = engine.get_textlist_index("sp_worlds")
|
|
|
|
if selected > 0 then
|
2013-07-15 23:02:18 +02:00
|
|
|
gamedata.selected_world = filterlist.get_raw_index(worldlist,selected)
|
2013-06-23 18:30:21 +02:00
|
|
|
gamedata.singleplayer = true
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
menu.update_last_game(gamedata.selected_world)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
engine.start()
|
|
|
|
end
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["world_create"] ~= nil then
|
|
|
|
tabbuilder.current_tab = "dialog_create_world"
|
|
|
|
tabbuilder.is_dialog = true
|
|
|
|
tabbuilder.show_buttons = false
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["world_delete"] ~= nil then
|
|
|
|
local selected = engine.get_textlist_index("sp_worlds")
|
2013-07-09 23:17:38 +02:00
|
|
|
if selected > 0 and
|
2013-07-14 13:19:37 +02:00
|
|
|
selected <= filterlist.size(worldlist) then
|
|
|
|
local world = filterlist.get_list(worldlist)[selected]
|
2013-07-09 23:17:38 +02:00
|
|
|
if world ~= nil and
|
|
|
|
world.name ~= nil and
|
|
|
|
world.name ~= "" then
|
2013-07-15 23:02:18 +02:00
|
|
|
menu.world_to_del = filterlist.get_raw_index(worldlist,selected)
|
2013-06-23 18:30:21 +02:00
|
|
|
tabbuilder.current_tab = "dialog_delete_world"
|
|
|
|
tabbuilder.is_dialog = true
|
|
|
|
tabbuilder.show_buttons = false
|
|
|
|
else
|
2013-07-09 23:17:38 +02:00
|
|
|
menu.world_to_del = 0
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["world_configure"] ~= nil then
|
|
|
|
selected = engine.get_textlist_index("sp_worlds")
|
|
|
|
if selected > 0 then
|
2013-07-15 23:02:18 +02:00
|
|
|
modmgr.world_config_selected_world = filterlist.get_raw_index(worldlist,selected)
|
2013-06-23 18:30:21 +02:00
|
|
|
if modmgr.init_worldconfig() then
|
|
|
|
tabbuilder.current_tab = "dialog_configure_world"
|
|
|
|
tabbuilder.is_dialog = true
|
|
|
|
tabbuilder.show_buttons = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-08-02 15:18:48 +02:00
|
|
|
--------------------------------------------------------------------------------
|
2013-08-14 19:22:23 +02:00
|
|
|
function tabbuilder.handle_texture_pack_buttons(fields)
|
2013-08-02 15:18:48 +02:00
|
|
|
if fields["TPs"] ~= nil then
|
|
|
|
local event = explode_textlist_event(fields["TPs"])
|
|
|
|
if event.typ == "CHG" or event.typ=="DCL" then
|
|
|
|
local index = engine.get_textlist_index("TPs")
|
|
|
|
engine.setting_set("mainmenu_last_selected_TP",
|
|
|
|
index)
|
2013-08-14 19:22:23 +02:00
|
|
|
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
|
|
|
|
local new_path = engine.get_texturepath()..DIR_DELIM..list[current_index]
|
|
|
|
if list[current_index] == "None" then new_path = "" end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-08-14 19:22:23 +02:00
|
|
|
engine.setting_set("texture_path", new_path)
|
|
|
|
end
|
2013-08-02 15:18:48 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function tabbuilder.tab_header()
|
|
|
|
|
|
|
|
if tabbuilder.last_tab_index == nil then
|
|
|
|
tabbuilder.last_tab_index = 1
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
local toadd = ""
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
for i=1,#tabbuilder.current_buttons,1 do
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if toadd ~= "" then
|
|
|
|
toadd = toadd .. ","
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
toadd = toadd .. tabbuilder.current_buttons[i].caption
|
|
|
|
end
|
|
|
|
return "tabheader[-0.3,-0.99;main_tab;" .. toadd ..";" .. tabbuilder.last_tab_index .. ";true;false]"
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function tabbuilder.handle_tab_buttons(fields)
|
|
|
|
|
|
|
|
if fields["main_tab"] then
|
|
|
|
local index = tonumber(fields["main_tab"])
|
|
|
|
tabbuilder.last_tab_index = index
|
|
|
|
tabbuilder.current_tab = tabbuilder.current_buttons[index].name
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
engine.setting_set("main_menu_tab",tabbuilder.current_tab)
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
--handle tab changes
|
|
|
|
if tabbuilder.current_tab ~= tabbuilder.old_tab then
|
2013-10-23 12:58:23 +02:00
|
|
|
if tabbuilder.current_tab ~= "singleplayer" and not tabbuilder.is_dialog then
|
2013-07-16 20:56:18 +02:00
|
|
|
menu.update_gametype(true)
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if tabbuilder.current_tab == "singleplayer" then
|
|
|
|
menu.update_gametype()
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
tabbuilder.old_tab = tabbuilder.current_tab
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function tabbuilder.tab_multiplayer()
|
2013-07-07 21:53:40 +02:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
local retval =
|
2013-08-14 19:22:23 +02:00
|
|
|
"vertlabel[0,-0.25;".. fgettext("CLIENT") .. "]" ..
|
|
|
|
"label[1,-0.25;".. fgettext("Favorites:") .. "]"..
|
|
|
|
"label[1,4.25;".. fgettext("Address/Port") .. "]"..
|
|
|
|
"label[9,2.75;".. fgettext("Name/Password") .. "]" ..
|
2013-06-23 18:30:21 +02:00
|
|
|
"field[1.25,5.25;5.5,0.5;te_address;;" ..engine.setting_get("address") .."]" ..
|
2013-11-28 21:43:06 +01:00
|
|
|
"field[6.75,5.25;2.25,0.5;te_port;;" ..engine.setting_get("remote_port") .."]" ..
|
2013-08-14 19:22:23 +02:00
|
|
|
"checkbox[1,3.6;cb_public_serverlist;".. fgettext("Public Serverlist") .. ";" ..
|
2013-07-09 21:54:30 +02:00
|
|
|
dump(engine.setting_getbool("public_serverlist")) .. "]"
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-09 21:54:30 +02:00
|
|
|
if not engine.setting_getbool("public_serverlist") then
|
2013-11-26 18:15:31 +01:00
|
|
|
retval = retval ..
|
2013-08-14 19:22:23 +02:00
|
|
|
"button[6.45,3.95;2.25,0.5;btn_delete_favorite;".. fgettext("Delete") .. "]"
|
2013-07-09 21:54:30 +02:00
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-09 21:54:30 +02:00
|
|
|
retval = retval ..
|
2013-08-14 19:22:23 +02:00
|
|
|
"button[9,4.95;2.5,0.5;btn_mp_connect;".. fgettext("Connect") .. "]" ..
|
2013-07-13 00:00:06 +02:00
|
|
|
"field[9.3,3.75;2.5,0.5;te_name;;" ..engine.setting_get("name") .."]" ..
|
|
|
|
"pwdfield[9.3,4.5;2.5,0.5;te_pwd;]" ..
|
|
|
|
"textarea[9.3,0.25;2.5,2.75;;"
|
2013-11-26 18:15:31 +01:00
|
|
|
if menu.fav_selected ~= nil and
|
2013-07-12 22:42:50 +02:00
|
|
|
menu.favorites[menu.fav_selected].description ~= nil then
|
2013-11-26 18:15:31 +01:00
|
|
|
retval = retval ..
|
2013-08-14 20:21:39 +02:00
|
|
|
engine.formspec_escape(menu.favorites[menu.fav_selected].description,true)
|
2013-07-12 22:42:50 +02:00
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
|
|
|
retval = retval ..
|
2013-07-12 22:42:50 +02:00
|
|
|
";]" ..
|
2013-06-23 18:30:21 +02:00
|
|
|
"textlist[1,0.35;7.5,3.35;favourites;"
|
|
|
|
|
2013-07-12 22:55:19 +02:00
|
|
|
local render_details = engine.setting_getbool("public_serverlist")
|
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if #menu.favorites > 0 then
|
2013-07-16 20:56:18 +02:00
|
|
|
retval = retval .. menu.render_favorite(menu.favorites[1],render_details)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
for i=2,#menu.favorites,1 do
|
2013-07-16 20:56:18 +02:00
|
|
|
retval = retval .. "," .. menu.render_favorite(menu.favorites[i],render_details)
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
end
|
2013-07-09 21:54:30 +02:00
|
|
|
|
2013-07-07 21:53:40 +02:00
|
|
|
if menu.fav_selected ~= nil then
|
|
|
|
retval = retval .. ";" .. menu.fav_selected .. "]"
|
|
|
|
else
|
|
|
|
retval = retval .. ";0]"
|
|
|
|
end
|
2013-06-23 18:30:21 +02:00
|
|
|
|
|
|
|
return retval
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function tabbuilder.tab_server()
|
2013-07-09 23:17:38 +02:00
|
|
|
|
2013-07-14 13:19:37 +02:00
|
|
|
local index = filterlist.get_current_index(worldlist,
|
2013-07-09 23:17:38 +02:00
|
|
|
tonumber(engine.setting_get("mainmenu_last_selected_world"))
|
|
|
|
)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
|
|
|
local retval =
|
2013-08-14 19:22:23 +02:00
|
|
|
"button[4,4.15;2.6,0.5;world_delete;".. fgettext("Delete") .. "]" ..
|
|
|
|
"button[6.5,4.15;2.8,0.5;world_create;".. fgettext("New") .. "]" ..
|
|
|
|
"button[9.2,4.15;2.55,0.5;world_configure;".. fgettext("Configure") .. "]" ..
|
|
|
|
"button[8.5,4.9;3.25,0.5;start_server;".. fgettext("Start Game") .. "]" ..
|
|
|
|
"label[4,-0.25;".. fgettext("Select World:") .. "]"..
|
|
|
|
"vertlabel[0,-0.25;".. fgettext("START SERVER") .. "]" ..
|
|
|
|
"checkbox[0.5,0.25;cb_creative_mode;".. fgettext("Creative Mode") .. ";" ..
|
2013-06-23 18:30:21 +02:00
|
|
|
dump(engine.setting_getbool("creative_mode")) .. "]"..
|
2013-08-14 19:22:23 +02:00
|
|
|
"checkbox[0.5,0.7;cb_enable_damage;".. fgettext("Enable Damage") .. ";" ..
|
2013-06-23 18:30:21 +02:00
|
|
|
dump(engine.setting_getbool("enable_damage")) .. "]"..
|
2013-08-14 19:22:23 +02:00
|
|
|
"checkbox[0.5,1.15;cb_server_announce;".. fgettext("Public") .. ";" ..
|
2013-07-09 22:09:17 +02:00
|
|
|
dump(engine.setting_getbool("server_announce")) .. "]"..
|
2013-08-14 19:22:23 +02:00
|
|
|
"field[0.8,3.2;3,0.5;te_playername;".. fgettext("Name") .. ";" ..
|
2013-06-23 18:30:21 +02:00
|
|
|
engine.setting_get("name") .. "]" ..
|
2013-08-14 19:22:23 +02:00
|
|
|
"pwdfield[0.8,4.2;3,0.5;te_passwd;".. fgettext("Password") .. "]" ..
|
2013-11-26 18:15:31 +01:00
|
|
|
"field[0.8,5.2;3,0.5;te_serverport;".. fgettext("Server Port") .. ";" ..
|
2013-11-28 21:43:06 +01:00
|
|
|
engine.setting_get("port") .."]" ..
|
2013-07-09 23:17:38 +02:00
|
|
|
"textlist[4,0.25;7.5,3.7;srv_worlds;" ..
|
|
|
|
menu.render_world_list() ..
|
|
|
|
";" .. index .. "]"
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
return retval
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function tabbuilder.tab_settings()
|
2013-12-03 17:21:40 +01:00
|
|
|
tab_string =
|
|
|
|
"vertlabel[0,0;" .. fgettext("SETTINGS") .. "]" ..
|
|
|
|
"checkbox[1,0;cb_fancy_trees;".. fgettext("Fancy Trees") .. ";"
|
2013-08-14 19:22:23 +02:00
|
|
|
.. dump(engine.setting_getbool("new_style_leaves")) .. "]"..
|
2013-12-03 17:21:40 +01:00
|
|
|
"checkbox[1,0.5;cb_smooth_lighting;".. fgettext("Smooth Lighting")
|
2013-08-14 19:22:23 +02:00
|
|
|
.. ";".. dump(engine.setting_getbool("smooth_lighting")) .. "]"..
|
2013-12-03 17:21:40 +01:00
|
|
|
"checkbox[1,1;cb_3d_clouds;".. fgettext("3D Clouds") .. ";"
|
2013-08-14 19:22:23 +02:00
|
|
|
.. dump(engine.setting_getbool("enable_3d_clouds")) .. "]"..
|
2013-12-03 17:21:40 +01:00
|
|
|
"checkbox[1,1.5;cb_opaque_water;".. fgettext("Opaque Water") .. ";"
|
2013-08-14 19:22:23 +02:00
|
|
|
.. dump(engine.setting_getbool("opaque_water")) .. "]"..
|
2013-12-03 17:21:40 +01:00
|
|
|
"checkbox[1,2.0;cb_pre_ivis;".. fgettext("Preload item visuals") .. ";"
|
|
|
|
.. dump(engine.setting_getbool("preload_item_visuals")) .. "]"..
|
|
|
|
"checkbox[1,2.5;cb_particles;".. fgettext("Enable Particles") .. ";"
|
|
|
|
.. dump(engine.setting_getbool("enable_particles")) .. "]"..
|
|
|
|
"checkbox[1,3.0;cb_finite_liquid;".. fgettext("Finite Liquid") .. ";"
|
|
|
|
.. dump(engine.setting_getbool("liquid_finite")) .. "]"..
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-12-03 17:21:40 +01:00
|
|
|
"checkbox[4.5,0;cb_mipmapping;".. fgettext("Mip-Mapping") .. ";"
|
2013-08-14 19:22:23 +02:00
|
|
|
.. dump(engine.setting_getbool("mip_map")) .. "]"..
|
2013-12-03 17:21:40 +01:00
|
|
|
"checkbox[4.5,0.5;cb_anisotrophic;".. fgettext("Anisotropic Filtering") .. ";"
|
2013-08-14 19:22:23 +02:00
|
|
|
.. dump(engine.setting_getbool("anisotropic_filter")) .. "]"..
|
2013-12-03 17:21:40 +01:00
|
|
|
"checkbox[4.5,1.0;cb_bilinear;".. fgettext("Bi-Linear Filtering") .. ";"
|
2013-08-14 19:22:23 +02:00
|
|
|
.. dump(engine.setting_getbool("bilinear_filter")) .. "]"..
|
2013-12-03 17:21:40 +01:00
|
|
|
"checkbox[4.5,1.5;cb_trilinear;".. fgettext("Tri-Linear Filtering") .. ";"
|
2013-08-14 19:22:23 +02:00
|
|
|
.. dump(engine.setting_getbool("trilinear_filter")) .. "]"..
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-12-03 17:21:40 +01:00
|
|
|
"checkbox[8,0;cb_shaders;".. fgettext("Shaders") .. ";"
|
2013-08-14 19:22:23 +02:00
|
|
|
.. dump(engine.setting_getbool("enable_shaders")) .. "]"..
|
2013-12-03 17:21:40 +01:00
|
|
|
"button[1,4.5;2.25,0.5;btn_change_keys;".. fgettext("Change keys") .. "]"
|
|
|
|
|
|
|
|
if engine.setting_getbool("enable_shaders") then
|
|
|
|
tab_string = tab_string ..
|
|
|
|
"checkbox[8,0.5;cb_bumpmapping;".. fgettext("Bumpmapping") .. ";"
|
|
|
|
.. dump(engine.setting_getbool("enable_bumpmapping")) .. "]"..
|
|
|
|
"checkbox[8,1.0;cb_parallax;".. fgettext("Parallax Occlusion") .. ";"
|
|
|
|
.. dump(engine.setting_getbool("enable_parallax_occlusion")) .. "]"..
|
|
|
|
"checkbox[8,1.5;cb_waving_water;".. fgettext("Waving Water") .. ";"
|
|
|
|
.. dump(engine.setting_getbool("enable_waving_water")) .. "]"..
|
|
|
|
"checkbox[8,2.0;cb_waving_leaves;".. fgettext("Waving Leaves") .. ";"
|
|
|
|
.. dump(engine.setting_getbool("enable_waving_leaves")) .. "]"..
|
|
|
|
"checkbox[8,2.5;cb_waving_plants;".. fgettext("Waving Plants") .. ";"
|
|
|
|
.. dump(engine.setting_getbool("enable_waving_plants")) .. "]"
|
|
|
|
else
|
|
|
|
tab_string = tab_string ..
|
|
|
|
"textlist[8.33,0.7;4,1;;#888888" .. fgettext("Bumpmapping") .. ";0;true]" ..
|
|
|
|
"textlist[8.33,1.2;4,1;;#888888" .. fgettext("Parallax Occlusion") .. ";0;true]" ..
|
|
|
|
"textlist[8.33,1.7;4,1;;#888888" .. fgettext("Waving Water") .. ";0;true]" ..
|
|
|
|
"textlist[8.33,2.2;4,1;;#888888" .. fgettext("Waving Leaves") .. ";0;true]" ..
|
|
|
|
"textlist[8.33,2.7;4,1;;#888888" .. fgettext("Waving Plants") .. ";0;true]"
|
|
|
|
end
|
|
|
|
return tab_string
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function tabbuilder.tab_singleplayer()
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-07-14 13:19:37 +02:00
|
|
|
local index = filterlist.get_current_index(worldlist,
|
2013-07-09 23:17:38 +02:00
|
|
|
tonumber(engine.setting_get("mainmenu_last_selected_world"))
|
|
|
|
)
|
2013-06-23 18:30:21 +02:00
|
|
|
|
2013-08-14 19:22:23 +02:00
|
|
|
return "button[4,4.15;2.6,0.5;world_delete;".. fgettext("Delete") .. "]" ..
|
|
|
|
"button[6.5,4.15;2.8,0.5;world_create;".. fgettext("New") .. "]" ..
|
|
|
|
"button[9.2,4.15;2.55,0.5;world_configure;".. fgettext("Configure") .. "]" ..
|
|
|
|
"button[8.5,4.95;3.25,0.5;play;".. fgettext("Play") .. "]" ..
|
|
|
|
"label[4,-0.25;".. fgettext("Select World:") .. "]"..
|
|
|
|
"vertlabel[0,-0.25;".. fgettext("SINGLE PLAYER") .. "]" ..
|
|
|
|
"checkbox[0.5,0.25;cb_creative_mode;".. fgettext("Creative Mode") .. ";" ..
|
2013-06-23 18:30:21 +02:00
|
|
|
dump(engine.setting_getbool("creative_mode")) .. "]"..
|
2013-08-14 19:22:23 +02:00
|
|
|
"checkbox[0.5,0.7;cb_enable_damage;".. fgettext("Enable Damage") .. ";" ..
|
2013-06-23 18:30:21 +02:00
|
|
|
dump(engine.setting_getbool("enable_damage")) .. "]"..
|
|
|
|
"textlist[4,0.25;7.5,3.7;sp_worlds;" ..
|
2013-07-09 23:17:38 +02:00
|
|
|
menu.render_world_list() ..
|
2013-06-23 18:30:21 +02:00
|
|
|
";" .. index .. "]" ..
|
|
|
|
menubar.formspec
|
|
|
|
end
|
|
|
|
|
2013-08-02 15:18:48 +02:00
|
|
|
--------------------------------------------------------------------------------
|
2013-08-14 19:22:23 +02:00
|
|
|
function tabbuilder.tab_texture_packs()
|
|
|
|
local retval = "label[4,-0.25;".. fgettext("Select texture pack:") .. "]"..
|
|
|
|
"vertlabel[0,-0.25;".. fgettext("TEXTURE PACKS") .. "]" ..
|
|
|
|
"textlist[4,0.25;7.5,5.0;TPs;"
|
|
|
|
|
2013-11-26 18:15:31 +01:00
|
|
|
local current_texture_path = engine.setting_get("texture_path")
|
|
|
|
local list = filter_texture_pack_list(engine.get_dirlist(engine.get_texturepath(), true))
|
2013-08-02 15:18:48 +02:00
|
|
|
local index = tonumber(engine.setting_get("mainmenu_last_selected_TP"))
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-08-02 15:18:48 +02:00
|
|
|
if index == nil then index = 1 end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-08-14 19:22:23 +02:00
|
|
|
if current_texture_path == "" then
|
|
|
|
retval = retval ..
|
|
|
|
menu.render_texture_pack_list(list) ..
|
2013-08-04 18:37:19 +02:00
|
|
|
";" .. index .. "]"
|
2013-08-14 19:22:23 +02:00
|
|
|
return retval
|
2013-08-02 15:18:48 +02:00
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-08-14 19:22:23 +02:00
|
|
|
local infofile = current_texture_path ..DIR_DELIM.."info.txt"
|
|
|
|
local infotext = ""
|
|
|
|
local f = io.open(infofile, "r")
|
2013-08-02 15:18:48 +02:00
|
|
|
if f==nil then
|
2013-08-14 19:22:23 +02:00
|
|
|
infotext = fgettext("No information available")
|
2013-08-02 15:18:48 +02:00
|
|
|
else
|
2013-08-14 19:22:23 +02:00
|
|
|
infotext = f:read("*all")
|
2013-08-02 15:18:48 +02:00
|
|
|
f:close()
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-08-14 19:22:23 +02:00
|
|
|
local screenfile = current_texture_path..DIR_DELIM.."screenshot.png"
|
|
|
|
local no_screenshot = nil
|
|
|
|
if not file_exists(screenfile) then
|
|
|
|
screenfile = nil
|
|
|
|
no_screenshot = engine.get_texturepath()..DIR_DELIM..
|
|
|
|
"base"..DIR_DELIM.."pack"..DIR_DELIM.."no_screenshot.png"
|
|
|
|
end
|
2013-08-02 15:18:48 +02:00
|
|
|
|
2013-08-14 19:22:23 +02:00
|
|
|
return retval ..
|
|
|
|
menu.render_texture_pack_list(list) ..
|
2013-08-02 15:18:48 +02:00
|
|
|
";" .. index .. "]" ..
|
2013-08-20 22:38:14 +02:00
|
|
|
"image[0.65,0.25;4.0,3.7;"..engine.formspec_escape(screenfile or no_screenshot).."]"..
|
2013-08-14 19:22:23 +02:00
|
|
|
"textarea[1.0,3.25;3.7,1.5;;"..engine.formspec_escape(infotext or "")..";]"
|
2013-08-02 15:18:48 +02:00
|
|
|
end
|
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function tabbuilder.tab_credits()
|
2013-08-20 22:38:14 +02:00
|
|
|
local logofile = menu.defaulttexturedir .. "logo.png"
|
2013-06-23 18:30:21 +02:00
|
|
|
return "vertlabel[0,-0.5;CREDITS]" ..
|
|
|
|
"label[0.5,3;Minetest " .. engine.get_version() .. "]" ..
|
2013-11-26 18:15:31 +01:00
|
|
|
"label[0.5,3.3;http://minetest.net]" ..
|
2013-08-20 22:38:14 +02:00
|
|
|
"image[0.5,1;" .. engine.formspec_escape(logofile) .. "]" ..
|
2013-06-23 18:30:21 +02:00
|
|
|
"textlist[3.5,-0.25;8.5,5.8;list_credits;" ..
|
2013-08-14 19:22:23 +02:00
|
|
|
"#FFFF00" .. fgettext("Core Developers") .."," ..
|
2013-06-23 18:30:21 +02:00
|
|
|
"Perttu Ahola (celeron55) <celeron55@gmail.com>,"..
|
|
|
|
"Ryan Kwolek (kwolekr) <kwolekr@minetest.net>,"..
|
|
|
|
"PilzAdam <pilzadam@minetest.net>," ..
|
2013-08-14 18:35:38 +02:00
|
|
|
"Ilya Zhuravlev (xyz) <xyz@minetest.net>,"..
|
2013-06-23 18:30:21 +02:00
|
|
|
"Lisa Milne (darkrose) <lisa@ltmnet.com>,"..
|
|
|
|
"Maciej Kasatkin (RealBadAngel) <mk@realbadangel.pl>,"..
|
|
|
|
"proller <proler@gmail.com>,"..
|
|
|
|
"sfan5 <sfan5@live.de>,"..
|
|
|
|
"kahrl <kahrl@gmx.net>,"..
|
2013-11-01 12:27:50 +01:00
|
|
|
"sapier,"..
|
2013-11-01 21:30:30 +01:00
|
|
|
"ShadowNinja <shadowninja@minetest.net>,"..
|
2013-11-23 20:05:07 +01:00
|
|
|
"Nathanael Courant (Nore/Novatux) <nore@mesecons.net>,"..
|
2013-11-09 14:28:00 +01:00
|
|
|
"BlockMen,"..
|
2013-06-23 18:30:21 +02:00
|
|
|
","..
|
2013-08-14 19:22:23 +02:00
|
|
|
"#FFFF00" .. fgettext("Active Contributors") .. "," ..
|
2013-06-23 18:30:21 +02:00
|
|
|
"Vanessa Ezekowitz (VanessaE) <vanessaezekowitz@gmail.com>,"..
|
|
|
|
"Jurgen Doser (doserj) <jurgen.doser@gmail.com>,"..
|
|
|
|
"Jeija <jeija@mesecons.net>,"..
|
|
|
|
"MirceaKitsune <mirceakitsune@gmail.com>,"..
|
2013-07-07 19:54:38 +02:00
|
|
|
"dannydark <the_skeleton_of_a_child@yahoo.co.uk>,"..
|
2013-06-23 18:30:21 +02:00
|
|
|
"0gb.us <0gb.us@0gb.us>,"..
|
|
|
|
"," ..
|
2013-08-14 19:22:23 +02:00
|
|
|
"#FFFF00" .. fgettext("Previous Contributors") .. "," ..
|
2013-06-23 18:30:21 +02:00
|
|
|
"Guiseppe Bilotta (Oblomov) <guiseppe.bilotta@gmail.com>,"..
|
|
|
|
"Jonathan Neuschafer <j.neuschaefer@gmx.net>,"..
|
|
|
|
"Nils Dagsson Moskopp (erlehmann) <nils@dieweltistgarnichtso.net>,"..
|
|
|
|
"Constantin Wenger (SpeedProg) <constantin.wenger@googlemail.com>,"..
|
|
|
|
"matttpt <matttpt@gmail.com>,"..
|
|
|
|
"JacobF <queatz@gmail.com>,"..
|
|
|
|
";0;true]"
|
|
|
|
end
|
|
|
|
|
2013-09-17 09:18:50 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function tabbuilder.init()
|
|
|
|
tabbuilder.tabfuncs = {
|
|
|
|
singleplayer = tabbuilder.tab_singleplayer,
|
|
|
|
multiplayer = tabbuilder.tab_multiplayer,
|
|
|
|
server = tabbuilder.tab_server,
|
|
|
|
settings = tabbuilder.tab_settings,
|
|
|
|
texture_packs = tabbuilder.tab_texture_packs,
|
|
|
|
credits = tabbuilder.tab_credits,
|
|
|
|
dialog_create_world = tabbuilder.dialog_create_world,
|
|
|
|
dialog_delete_world = tabbuilder.dialog_delete_world
|
|
|
|
}
|
|
|
|
|
|
|
|
tabbuilder.tabsizes = {
|
|
|
|
dialog_create_world = {width=12, height=7},
|
|
|
|
dialog_delete_world = {width=12, height=5.2}
|
|
|
|
}
|
|
|
|
|
|
|
|
tabbuilder.current_tab = engine.setting_get("main_menu_tab")
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-09-17 09:18:50 +02:00
|
|
|
if tabbuilder.current_tab == nil or
|
|
|
|
tabbuilder.current_tab == "" then
|
|
|
|
tabbuilder.current_tab = "singleplayer"
|
|
|
|
engine.setting_set("main_menu_tab",tabbuilder.current_tab)
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-09-17 09:18:50 +02:00
|
|
|
--initialize tab buttons
|
|
|
|
tabbuilder.last_tab = nil
|
|
|
|
tabbuilder.show_buttons = true
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-09-17 09:18:50 +02:00
|
|
|
tabbuilder.current_buttons = {}
|
|
|
|
table.insert(tabbuilder.current_buttons,{name="singleplayer", caption=fgettext("Singleplayer")})
|
|
|
|
table.insert(tabbuilder.current_buttons,{name="multiplayer", caption=fgettext("Client")})
|
|
|
|
table.insert(tabbuilder.current_buttons,{name="server", caption=fgettext("Server")})
|
|
|
|
table.insert(tabbuilder.current_buttons,{name="settings", caption=fgettext("Settings")})
|
|
|
|
table.insert(tabbuilder.current_buttons,{name="texture_packs", caption=fgettext("Texture Packs")})
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-09-17 09:18:50 +02:00
|
|
|
if engine.setting_getbool("main_menu_game_mgr") then
|
|
|
|
table.insert(tabbuilder.current_buttons,{name="game_mgr", caption=fgettext("Games")})
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-09-17 09:18:50 +02:00
|
|
|
if engine.setting_getbool("main_menu_mod_mgr") then
|
|
|
|
table.insert(tabbuilder.current_buttons,{name="mod_mgr", caption=fgettext("Mods")})
|
|
|
|
end
|
|
|
|
table.insert(tabbuilder.current_buttons,{name="credits", caption=fgettext("Credits")})
|
2013-11-26 18:15:31 +01:00
|
|
|
|
|
|
|
|
2013-09-17 09:18:50 +02:00
|
|
|
for i=1,#tabbuilder.current_buttons,1 do
|
|
|
|
if tabbuilder.current_buttons[i].name == tabbuilder.current_tab then
|
|
|
|
tabbuilder.last_tab_index = i
|
|
|
|
end
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-09-17 09:18:50 +02:00
|
|
|
if tabbuilder.current_tab ~= "singleplayer" then
|
|
|
|
menu.update_gametype(true)
|
|
|
|
else
|
|
|
|
menu.update_gametype()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function tabbuilder.checkretval(retval)
|
|
|
|
|
|
|
|
if retval ~= nil then
|
|
|
|
if retval.current_tab ~= nil then
|
|
|
|
tabbuilder.current_tab = retval.current_tab
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if retval.is_dialog ~= nil then
|
|
|
|
tabbuilder.is_dialog = retval.is_dialog
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if retval.show_buttons ~= nil then
|
|
|
|
tabbuilder.show_buttons = retval.show_buttons
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if retval.skipformupdate ~= nil then
|
|
|
|
tabbuilder.skipformupdate = retval.skipformupdate
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
|
|
|
if retval.ignore_menu_quit == true then
|
|
|
|
tabbuilder.ignore_menu_quit = true
|
|
|
|
else
|
|
|
|
tabbuilder.ignore_menu_quit = false
|
|
|
|
end
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- initialize callbacks
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
engine.button_handler = function(fields)
|
|
|
|
--print("Buttonhandler: tab: " .. tabbuilder.current_tab .. " fields: " .. dump(fields))
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if fields["btn_error_confirm"] then
|
|
|
|
gamedata.errormessage = nil
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
local retval = modmgr.handle_buttons(tabbuilder.current_tab,fields)
|
|
|
|
tabbuilder.checkretval(retval)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
retval = gamemgr.handle_buttons(tabbuilder.current_tab,fields)
|
|
|
|
tabbuilder.checkretval(retval)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
retval = modstore.handle_buttons(tabbuilder.current_tab,fields)
|
|
|
|
tabbuilder.checkretval(retval)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if tabbuilder.current_tab == "dialog_create_world" then
|
|
|
|
tabbuilder.handle_create_world_buttons(fields)
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if tabbuilder.current_tab == "dialog_delete_world" then
|
|
|
|
tabbuilder.handle_delete_world_buttons(fields)
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if tabbuilder.current_tab == "singleplayer" then
|
|
|
|
tabbuilder.handle_singleplayer_buttons(fields)
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-08-02 15:18:48 +02:00
|
|
|
if tabbuilder.current_tab == "texture_packs" then
|
2013-08-14 19:22:23 +02:00
|
|
|
tabbuilder.handle_texture_pack_buttons(fields)
|
2013-08-02 15:18:48 +02:00
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if tabbuilder.current_tab == "multiplayer" then
|
|
|
|
tabbuilder.handle_multiplayer_buttons(fields)
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if tabbuilder.current_tab == "settings" then
|
|
|
|
tabbuilder.handle_settings_buttons(fields)
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if tabbuilder.current_tab == "server" then
|
|
|
|
tabbuilder.handle_server_buttons(fields)
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
--tab buttons
|
|
|
|
tabbuilder.handle_tab_buttons(fields)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
--menubar buttons
|
|
|
|
menubar.handle_buttons(fields)
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
if not tabbuilder.skipformupdate then
|
|
|
|
--update menu
|
|
|
|
update_menu()
|
|
|
|
else
|
|
|
|
tabbuilder.skipformupdate = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
engine.event_handler = function(event)
|
|
|
|
if event == "MenuQuit" then
|
|
|
|
if tabbuilder.is_dialog then
|
2013-11-26 18:15:31 +01:00
|
|
|
if tabbuilder.ignore_menu_quit then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
tabbuilder.is_dialog = false
|
|
|
|
tabbuilder.show_buttons = true
|
|
|
|
tabbuilder.current_tab = engine.setting_get("main_menu_tab")
|
2013-07-14 13:19:37 +02:00
|
|
|
menu.update_gametype()
|
2013-06-23 18:30:21 +02:00
|
|
|
update_menu()
|
|
|
|
else
|
|
|
|
engine.close()
|
|
|
|
end
|
|
|
|
end
|
2013-11-26 18:15:31 +01:00
|
|
|
|
|
|
|
if event == "Refresh" then
|
|
|
|
update_menu()
|
|
|
|
end
|
2013-06-23 18:30:21 +02:00
|
|
|
end
|
|
|
|
|
2013-07-16 20:56:18 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function menu.update_gametype(reset)
|
2013-11-09 11:01:16 +01:00
|
|
|
local game = menu.lastgame()
|
|
|
|
|
|
|
|
if reset or game == nil then
|
2013-07-16 20:56:18 +02:00
|
|
|
mm_texture.reset()
|
|
|
|
engine.set_topleft_text("")
|
|
|
|
filterlist.set_filtercriteria(worldlist,nil)
|
|
|
|
else
|
|
|
|
mm_texture.update(tabbuilder.current_tab,game)
|
|
|
|
engine.set_topleft_text(game.name)
|
|
|
|
filterlist.set_filtercriteria(worldlist,game.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- menu startup
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
init_globals()
|
2013-07-16 20:56:18 +02:00
|
|
|
mm_texture.init()
|
2013-06-23 18:30:21 +02:00
|
|
|
menu.init()
|
|
|
|
tabbuilder.init()
|
|
|
|
menubar.refresh()
|
|
|
|
modstore.init()
|
2013-07-09 23:17:38 +02:00
|
|
|
|
2013-07-28 23:14:42 +02:00
|
|
|
engine.sound_play("main_menu", true)
|
2013-07-16 20:56:18 +02:00
|
|
|
|
2013-06-23 18:30:21 +02:00
|
|
|
update_menu()
|