1 local scriptpath = engine.get_scriptdir()
3 dofile(scriptpath .. DIR_DELIM .. "modmgr.lua")
4 dofile(scriptpath .. DIR_DELIM .. "modstore.lua")
5 dofile(scriptpath .. DIR_DELIM .. "gamemgr.lua")
11 --------------------------------------------------------------------------------
12 function render_favourite(spec)
15 if spec.name ~= nil then
16 text = text .. spec.name:trim()
18 if spec.description ~= nil then
19 --TODO make sure there's no invalid chat in spec.description
20 text = text .. " (" .. fs_escape_string(spec.description) .. ")"
23 if spec.address ~= nil then
24 text = text .. spec.address:trim()
29 if spec.password == true then
36 details = details .. "C"
38 details = details .. " "
42 details = details .. "D"
44 details = details .. " "
48 details = details .. "P"
50 details = details .. " "
53 text = text .. ":" .. spec.port:trim()
58 --------------------------------------------------------------------------------
59 os.tempfolder = function()
60 local filetocheck = os.tmpname()
61 os.remove(filetocheck)
63 local randname = "MTTempModFolder_" .. math.random(0,10000)
64 if DIR_DELIM == "\\" then
65 local tempfolder = os.getenv("TEMP")
66 return tempfolder .. filetocheck
68 local backstring = filetocheck:reverse()
69 return filetocheck:sub(0,filetocheck:len()-backstring:find(DIR_DELIM)+1) ..randname
74 --------------------------------------------------------------------------------
75 function cleanup_path(temppath)
77 local parts = temppath:split("-")
80 if temppath ~= "" then
81 temppath = temppath .. "_"
83 temppath = temppath .. parts[i]
86 parts = temppath:split(".")
89 if temppath ~= "" then
90 temppath = temppath .. "_"
92 temppath = temppath .. parts[i]
95 parts = temppath:split("'")
98 if temppath ~= "" then
99 temppath = temppath .. ""
101 temppath = temppath .. parts[i]
104 parts = temppath:split(" ")
107 if temppath ~= "" then
110 temppath = temppath .. parts[i]
116 --------------------------------------------------------------------------------
117 function menu.update_gametype()
118 if (menu.game_last_check == nil or
119 menu.game_last_check ~= menu.last_game) and
120 tabbuilder.current_tab == "singleplayer" then
122 local gamedetails = menu.lastgame()
123 engine.set_topleft_text(gamedetails.name)
126 local path_background_texture = gamedetails.path .. DIR_DELIM .."menu" ..
127 DIR_DELIM .. "background.png"
128 if engine.set_background("background",path_background_texture) then
129 engine.set_clouds(false)
131 engine.set_clouds(true)
135 local path_overlay_texture = gamedetails.path .. DIR_DELIM .."menu" ..
136 DIR_DELIM .. "overlay.png"
137 engine.set_background("overlay",path_overlay_texture)
140 local path_overlay_texture = gamedetails.path .. DIR_DELIM .."menu" ..
141 DIR_DELIM .. "header.png"
142 engine.set_background("header",path_overlay_texture)
145 local path_overlay_texture = gamedetails.path .. DIR_DELIM .."menu" ..
146 DIR_DELIM .. "footer.png"
147 engine.set_background("footer",path_overlay_texture)
149 menu.game_last_check = menu.last_game
151 if menu.game_last_check ~= menu.last_game then
152 menu.game_last_check = menu.last_game
153 menu.reset_gametype()
158 --------------------------------------------------------------------------------
159 function menu.reset_gametype()
160 menu.game_last_check = nil
161 engine.set_clouds(true)
162 engine.set_background("background","")
163 engine.set_background("overlay",menu.basetexturedir .. "menu_overlay.png")
164 engine.set_background("header",menu.basetexturedir .. "menu_header.png")
165 engine.set_background("footer",menu.basetexturedir .. "menu_footer.png")
166 engine.set_topleft_text("")
169 --------------------------------------------------------------------------------
170 function get_last_folder(text,count)
171 local parts = text:split(DIR_DELIM)
179 retval = retval .. parts[#parts - (count-i)] .. DIR_DELIM
185 --------------------------------------------------------------------------------
186 function init_globals()
188 gamedata.worldindex = 0
191 --------------------------------------------------------------------------------
192 function identify_filetype(name)
194 if name:sub(-3):lower() == "zip" then
201 if name:sub(-6):lower() == "tar.gz" or
202 name:sub(-3):lower() == "tgz"then
209 if name:sub(-6):lower() == "tar.bz2" then
216 if name:sub(-2):lower() == "7z" then
229 --------------------------------------------------------------------------------
230 function update_menu()
232 local formspec = "size[12,5.2]"
235 if gamedata.errormessage ~= nil then
236 formspec = formspec ..
237 "field[1,2;10,2;;ERROR: " ..
238 gamedata.errormessage ..
240 "button[4.5,4.2;3,0.5;btn_error_confirm;Ok]"
242 formspec = formspec .. tabbuilder.gettab()
245 engine.update_formspec(formspec)
248 --------------------------------------------------------------------------------
249 function menu.filtered_game_list()
252 local current_game = menu.lastgame()
254 for i=1,#menu.worldlist,1 do
255 if menu.worldlist[i].gameid == current_game.id then
257 retval = retval ..","
260 retval = retval .. menu.worldlist[i].name ..
261 " [[" .. menu.worldlist[i].gameid .. "]]"
268 --------------------------------------------------------------------------------
269 function menu.filtered_game_list_raw()
272 local current_game = menu.lastgame()
274 for i=1,#menu.worldlist,1 do
275 if menu.worldlist[i].gameid == current_game.id then
276 table.insert(retval,menu.worldlist[i])
283 --------------------------------------------------------------------------------
284 function menu.filtered_index_to_plain(filtered_index)
286 local current_game = menu.lastgame()
290 for i=1,#menu.worldlist,1 do
291 if menu.worldlist[i].gameid == current_game.id then
292 temp_idx = temp_idx +1
295 if temp_idx == filtered_index then
302 --------------------------------------------------------------------------------
305 gamemgr.update_gamelist()
307 menu.worldlist = engine.get_worlds()
309 menu.last_world = tonumber(engine.setting_get("main_menu_last_world_idx"))
310 menu.last_game = tonumber(engine.setting_get("main_menu_last_game_idx"))
312 if type(menu.last_world) ~= "number" then
316 if type(menu.last_game) ~= "number" then
320 if engine.setting_getbool("public_serverlist") then
321 menu.favorites = engine.get_favorites("online")
323 menu.favorites = engine.get_favorites("local")
327 menu.basetexturedir = engine.get_gamepath() .. DIR_DELIM .. ".." ..
328 DIR_DELIM .. "textures" .. DIR_DELIM .. "base" ..
329 DIR_DELIM .. "pack" .. DIR_DELIM
332 --------------------------------------------------------------------------------
333 function menu.lastgame()
334 if menu.last_game > 0 and menu.last_game <= #gamemgr.games then
335 return gamemgr.games[menu.last_game]
338 if #gamemgr.games >= 1 then
340 return gamemgr.games[menu.last_game]
347 --------------------------------------------------------------------------------
348 function menu.lastworld()
349 if menu.last_world ~= nil and
350 menu.last_world > 0 and
351 menu.last_world <= #menu.worldlist then
352 return menu.worldlist[menu.last_world]
355 if #menu.worldlist >= 1 then
357 return menu.worldlist[menu.last_world]
364 --------------------------------------------------------------------------------
365 function menu.update_last_game(world_idx)
366 if gamedata.selected_world <= #menu.worldlist then
367 local world = menu.worldlist[gamedata.selected_world]
369 for i=1,#gamemgr.games,1 do
370 if gamemgr.games[i].id == world.gameid then
372 engine.setting_set("main_menu_last_game_idx",menu.last_game)
379 --------------------------------------------------------------------------------
380 function menubar.handle_buttons(fields)
381 for i=1,#menubar.buttons,1 do
382 if fields[menubar.buttons[i].btn_name] ~= nil then
383 menu.last_game = menubar.buttons[i].index
384 engine.setting_set("main_menu_last_game_idx",menu.last_game)
385 menu.update_gametype()
390 --------------------------------------------------------------------------------
391 function menubar.refresh()
392 menubar.formspec = "box[-2,7.625;15.75,1.75;BLK]"
395 local button_base = -1.8
397 local maxbuttons = #gamemgr.games
399 if maxbuttons > 12 then
403 for i=1,maxbuttons,1 do
405 local btn_name = "menubar_btn_" .. gamemgr.games[i].id
406 local buttonpos = button_base + (i-1) * 1.3
407 if gamemgr.games[i].menuicon_path ~= nil and
408 gamemgr.games[i].menuicon_path ~= "" then
410 menubar.formspec = menubar.formspec ..
411 "image_button[" .. buttonpos .. ",7.9;1.3,1.3;" ..
412 gamemgr.games[i].menuicon_path .. ";" .. btn_name .. ";;true;false]"
415 local part1 = gamemgr.games[i].id:sub(1,5)
416 local part2 = gamemgr.games[i].id:sub(6,10)
417 local part3 = gamemgr.games[i].id:sub(11)
419 local text = part1 .. "\n" .. part2
422 text = text .. "\n" .. part3
424 menubar.formspec = menubar.formspec ..
425 "image_button[" .. buttonpos .. ",7.9;1.3,1.3;;" ..btn_name ..
426 ";" .. text .. ";true;true]"
434 table.insert(menubar.buttons,toadd)
438 --------------------------------------------------------------------------------
439 function tabbuilder.dialog_create_world()
441 "label[2,0;World name]"..
442 "label[2,1;Mapgen]"..
443 "field[4.5,0.4;6,0.5;te_world_name;;]" ..
445 "button[5,4.5;2.6,0.5;world_create_confirm;Create]" ..
446 "button[7.5,4.5;2.8,0.5;world_create_cancel;Cancel]" ..
447 "dropdown[4.2,1;6.3;dd_mapgen;v6,v7,indev,singlenode,math;1]" .. --TODO read from minetest
448 "textlist[4.2,1.9;5.8,2.3;games;" ..
449 gamemgr.gamelist() ..
450 ";" .. menu.last_game .. ";true]"
455 --------------------------------------------------------------------------------
456 function tabbuilder.dialog_delete_world()
457 return "label[2,2;Delete World \"" .. menu.lastworld().name .. "\"?]"..
458 "button[3.5,4.2;2.6,0.5;world_delete_confirm;Yes]" ..
459 "button[6,4.2;2.8,0.5;world_delete_cancel;No]"
462 --------------------------------------------------------------------------------
463 function tabbuilder.gettab()
466 if tabbuilder.show_buttons then
467 retval = retval .. tabbuilder.tab_header()
470 if tabbuilder.current_tab == "singleplayer" then
471 retval = retval .. tabbuilder.tab_singleplayer()
474 if tabbuilder.current_tab == "multiplayer" then
475 retval = retval .. tabbuilder.tab_multiplayer()
478 if tabbuilder.current_tab == "server" then
479 retval = retval .. tabbuilder.tab_server()
482 if tabbuilder.current_tab == "settings" then
483 retval = retval .. tabbuilder.tab_settings()
486 if tabbuilder.current_tab == "credits" then
487 retval = retval .. tabbuilder.tab_credits()
490 if tabbuilder.current_tab == "dialog_create_world" then
491 retval = retval .. tabbuilder.dialog_create_world()
494 if tabbuilder.current_tab == "dialog_delete_world" then
495 retval = retval .. tabbuilder.dialog_delete_world()
498 retval = retval .. modmgr.gettab(tabbuilder.current_tab)
499 retval = retval .. gamemgr.gettab(tabbuilder.current_tab)
500 retval = retval .. modstore.gettab(tabbuilder.current_tab)
505 --------------------------------------------------------------------------------
506 function tabbuilder.handle_create_world_buttons(fields)
508 if fields["world_create_confirm"] then
510 local worldname = fields["te_world_name"]
511 local gameindex = engine.get_textlist_index("games")
515 engine.setting_set("mg_name",fields["dd_mapgen"])
516 local message = engine.create_world(worldname,gameindex)
518 menu.last_game = gameindex
519 engine.setting_set("main_menu_last_game_idx",gameindex)
521 if message ~= nil then
522 gamedata.errormessage = message
524 menu.worldlist = engine.get_worlds()
526 local worldlist = menu.worldlist
528 if tabbuilder.current_tab == "singleplayer" then
529 worldlist = menu.filtered_game_list_raw()
534 for i=1,#worldlist,1 do
535 if worldlist[i].name == worldname then
537 print("found new world index: " .. index)
542 if tabbuilder.current_tab == "singleplayer" then
543 engine.setting_set("main_menu_singleplayer_world_idx",index)
545 menu.last_world = index
549 gamedata.errormessage = "No worldname given or no game selected"
553 if fields["games"] then
554 tabbuilder.skipformupdate = true
558 tabbuilder.is_dialog = false
559 tabbuilder.show_buttons = true
560 tabbuilder.current_tab = engine.setting_get("main_menu_tab")
563 --------------------------------------------------------------------------------
564 function tabbuilder.handle_delete_world_buttons(fields)
566 if fields["world_delete_confirm"] then
567 if menu.last_world > 0 and
568 menu.last_world < #menu.worldlist then
569 engine.delete_world(menu.last_world)
570 menu.worldlist = engine.get_worlds()
575 tabbuilder.is_dialog = false
576 tabbuilder.show_buttons = true
577 tabbuilder.current_tab = engine.setting_get("main_menu_tab")
580 --------------------------------------------------------------------------------
581 function tabbuilder.handle_multiplayer_buttons(fields)
582 if fields["favourites"] ~= nil then
583 local event = explode_textlist_event(fields["favourites"])
584 if event.typ == "DCL" then
585 gamedata.address = menu.favorites[event.index].name
586 if gamedata.address == nil then
587 gamedata.address = menu.favorites[event.index].address
589 gamedata.port = menu.favorites[event.index].port
590 gamedata.playername = fields["te_name"]
591 gamedata.password = fields["te_pwd"]
592 gamedata.selected_world = 0
594 if gamedata.address ~= nil and
595 gamedata.port ~= nil then
601 if event.typ == "CHG" then
602 local address = menu.favorites[event.index].name
603 if address == nil then
604 address = menu.favorites[event.index].address
606 local port = menu.favorites[event.index].port
608 if address ~= nil and
610 engine.setting_set("address",address)
611 engine.setting_set("port",port)
617 if fields["cb_public_serverlist"] ~= nil then
618 engine.setting_setbool("public_serverlist",
619 tabbuilder.tobool(fields["cb_public_serverlist"]))
621 if engine.setting_getbool("public_serverlist") then
622 menu.favorites = engine.get_favorites("online")
624 menu.favorites = engine.get_favorites("local")
628 if fields["btn_delete_favorite"] ~= nil then
629 local current_favourite = engine.get_textlist_index("favourites")
630 engine.delete_favorite(current_favourite)
631 menu.favorites = engine.get_favorites()
633 engine.setting_set("address","")
634 engine.setting_get("port","")
639 if fields["btn_mp_connect"] ~= nil then
640 gamedata.playername = fields["te_name"]
641 gamedata.password = fields["te_pwd"]
642 gamedata.address = fields["te_address"]
643 gamedata.port = fields["te_port"]
644 gamedata.selected_world = 0
651 --------------------------------------------------------------------------------
652 function tabbuilder.handle_server_buttons(fields)
654 local world_doubleclick = false
656 if fields["worlds"] ~= nil then
657 local event = explode_textlist_event(fields["worlds"])
659 if event.typ == "DBL" then
660 world_doubleclick = true
664 if fields["cb_creative_mode"] then
665 engine.setting_setbool("creative_mode",tabbuilder.tobool(fields["cb_creative_mode"]))
668 if fields["cb_enable_damage"] then
669 engine.setting_setbool("enable_damage",tabbuilder.tobool(fields["cb_enable_damage"]))
672 if fields["start_server"] ~= nil or
673 world_doubleclick then
674 local selected = engine.get_textlist_index("srv_worlds")
676 gamedata.playername = fields["te_playername"]
677 gamedata.password = fields["te_pwd"]
678 gamedata.address = ""
679 gamedata.port = fields["te_serverport"]
680 gamedata.selected_world = selected
682 engine.setting_set("main_menu_tab",tabbuilder.current_tab)
683 engine.setting_set("main_menu_last_world_idx",gamedata.selected_world)
685 menu.update_last_game(gamedata.selected_world)
690 if fields["world_create"] ~= nil then
691 tabbuilder.current_tab = "dialog_create_world"
692 tabbuilder.is_dialog = true
693 tabbuilder.show_buttons = false
696 if fields["world_delete"] ~= nil then
697 local selected = engine.get_textlist_index("srv_worlds")
699 menu.last_world = engine.get_textlist_index("worlds")
700 if menu.lastworld() ~= nil and
701 menu.lastworld().name ~= nil and
702 menu.lastworld().name ~= "" then
703 tabbuilder.current_tab = "dialog_delete_world"
704 tabbuilder.is_dialog = true
705 tabbuilder.show_buttons = false
712 if fields["world_configure"] ~= nil then
713 selected = engine.get_textlist_index("srv_worlds")
715 modmgr.world_config_selected_world = selected
716 if modmgr.init_worldconfig() then
717 tabbuilder.current_tab = "dialog_configure_world"
718 tabbuilder.is_dialog = true
719 tabbuilder.show_buttons = false
725 --------------------------------------------------------------------------------
726 function tabbuilder.tobool(text)
727 if text == "true" then
734 --------------------------------------------------------------------------------
735 function tabbuilder.handle_settings_buttons(fields)
736 if fields["cb_fancy_trees"] then
737 engine.setting_setbool("new_style_leaves",tabbuilder.tobool(fields["cb_fancy_trees"]))
740 if fields["cb_smooth_lighting"] then
741 engine.setting_setbool("smooth_lighting",tabbuilder.tobool(fields["cb_smooth_lighting"]))
743 if fields["cb_3d_clouds"] then
744 engine.setting_setbool("enable_3d_clouds",tabbuilder.tobool(fields["cb_3d_clouds"]))
746 if fields["cb_opaque_water"] then
747 engine.setting_setbool("opaque_water",tabbuilder.tobool(fields["cb_opaque_water"]))
750 if fields["cb_mipmapping"] then
751 engine.setting_setbool("mip_map",tabbuilder.tobool(fields["cb_mipmapping"]))
753 if fields["cb_anisotrophic"] then
754 engine.setting_setbool("anisotropic_filter",tabbuilder.tobool(fields["cb_anisotrophic"]))
756 if fields["cb_bilinear"] then
757 engine.setting_setbool("bilinear_filter",tabbuilder.tobool(fields["cb_bilinear"]))
759 if fields["cb_trilinear"] then
760 engine.setting_setbool("trilinear_filter",tabbuilder.tobool(fields["cb_trilinear"]))
763 if fields["cb_shaders"] then
764 engine.setting_setbool("enable_shaders",tabbuilder.tobool(fields["cb_shaders"]))
766 if fields["cb_pre_ivis"] then
767 engine.setting_setbool("preload_item_visuals",tabbuilder.tobool(fields["cb_pre_ivis"]))
769 if fields["cb_particles"] then
770 engine.setting_setbool("enable_particles",tabbuilder.tobool(fields["cb_particles"]))
772 if fields["cb_finite_liquid"] then
773 engine.setting_setbool("liquid_finite",tabbuilder.tobool(fields["cb_finite_liquid"]))
776 if fields["btn_change_keys"] ~= nil then
777 engine.show_keys_menu()
781 --------------------------------------------------------------------------------
782 function tabbuilder.handle_singleplayer_buttons(fields)
784 local world_doubleclick = false
786 if fields["sp_worlds"] ~= nil then
787 local event = explode_textlist_event(fields["sp_worlds"])
789 if event.typ == "DCL" then
790 world_doubleclick = true
794 if fields["cb_creative_mode"] then
795 engine.setting_setbool("creative_mode",tabbuilder.tobool(fields["cb_creative_mode"]))
798 if fields["cb_enable_damage"] then
799 engine.setting_setbool("enable_damage",tabbuilder.tobool(fields["cb_enable_damage"]))
802 if fields["play"] ~= nil or
803 world_doubleclick then
804 local selected = engine.get_textlist_index("sp_worlds")
806 gamedata.selected_world = menu.filtered_index_to_plain(selected)
807 gamedata.singleplayer = true
809 engine.setting_set("main_menu_tab",tabbuilder.current_tab)
810 engine.setting_set("main_menu_singleplayer_world_idx",selected)
812 menu.update_last_game(gamedata.selected_world)
818 if fields["world_create"] ~= nil then
819 tabbuilder.current_tab = "dialog_create_world"
820 tabbuilder.is_dialog = true
821 tabbuilder.show_buttons = false
824 if fields["world_delete"] ~= nil then
825 local selected = engine.get_textlist_index("sp_worlds")
827 menu.last_world = menu.filtered_index_to_plain(selected)
828 if menu.lastworld() ~= nil and
829 menu.lastworld().name ~= nil and
830 menu.lastworld().name ~= "" then
831 tabbuilder.current_tab = "dialog_delete_world"
832 tabbuilder.is_dialog = true
833 tabbuilder.show_buttons = false
840 if fields["world_configure"] ~= nil then
841 selected = engine.get_textlist_index("sp_worlds")
843 modmgr.world_config_selected_world = menu.filtered_index_to_plain(selected)
844 if modmgr.init_worldconfig() then
845 tabbuilder.current_tab = "dialog_configure_world"
846 tabbuilder.is_dialog = true
847 tabbuilder.show_buttons = false
853 --------------------------------------------------------------------------------
854 function tabbuilder.tab_header()
856 if tabbuilder.last_tab_index == nil then
857 tabbuilder.last_tab_index = 1
862 for i=1,#tabbuilder.current_buttons,1 do
868 toadd = toadd .. tabbuilder.current_buttons[i].caption
870 return "tabheader[-0.3,-0.99;main_tab;" .. toadd ..";" .. tabbuilder.last_tab_index .. ";true;false]"
873 --------------------------------------------------------------------------------
874 function tabbuilder.handle_tab_buttons(fields)
876 if fields["main_tab"] then
877 local index = tonumber(fields["main_tab"])
878 tabbuilder.last_tab_index = index
879 tabbuilder.current_tab = tabbuilder.current_buttons[index].name
881 engine.setting_set("main_menu_tab",tabbuilder.current_tab)
885 if tabbuilder.current_tab ~= tabbuilder.old_tab then
886 if tabbuilder.current_tab ~= "singleplayer" then
887 menu.reset_gametype()
891 if tabbuilder.current_tab == "singleplayer" then
892 menu.update_gametype()
895 tabbuilder.old_tab = tabbuilder.current_tab
898 --------------------------------------------------------------------------------
899 function tabbuilder.init()
900 tabbuilder.current_tab = engine.setting_get("main_menu_tab")
902 if tabbuilder.current_tab == nil or
903 tabbuilder.current_tab == "" then
904 tabbuilder.current_tab = "singleplayer"
905 engine.setting_set("main_menu_tab",tabbuilder.current_tab)
909 --initialize tab buttons
910 tabbuilder.last_tab = nil
911 tabbuilder.show_buttons = true
913 tabbuilder.current_buttons = {}
914 table.insert(tabbuilder.current_buttons,{name="singleplayer", caption="Singleplayer"})
915 table.insert(tabbuilder.current_buttons,{name="multiplayer", caption="Client"})
916 table.insert(tabbuilder.current_buttons,{name="server", caption="Server"})
917 table.insert(tabbuilder.current_buttons,{name="settings", caption="Settings"})
919 if engine.setting_getbool("main_menu_game_mgr") then
920 table.insert(tabbuilder.current_buttons,{name="game_mgr", caption="Games"})
923 if engine.setting_getbool("main_menu_mod_mgr") then
924 table.insert(tabbuilder.current_buttons,{name="mod_mgr", caption="Mods"})
926 table.insert(tabbuilder.current_buttons,{name="credits", caption="Credits"})
929 for i=1,#tabbuilder.current_buttons,1 do
930 if tabbuilder.current_buttons[i].name == tabbuilder.current_tab then
931 tabbuilder.last_tab_index = i
935 menu.update_gametype()
938 --------------------------------------------------------------------------------
939 function tabbuilder.tab_multiplayer()
941 "vertlabel[0,-0.25;CLIENT]" ..
942 "label[1,-0.25;Favorites:]"..
943 "label[1,4.25;Address/Port]"..
944 "label[9,0;Name/Password]" ..
945 "field[1.25,5.25;5.5,0.5;te_address;;" ..engine.setting_get("address") .."]" ..
946 "field[6.75,5.25;2.25,0.5;te_port;;" ..engine.setting_get("port") .."]" ..
947 "button[6.45,3.95;2.25,0.5;btn_delete_favorite;Delete]" ..
948 "button[9,4.95;2.5,0.5;btn_mp_connect;Connect]" ..
949 "field[9.25,1;2.5,0.5;te_name;;" ..engine.setting_get("name") .."]" ..
950 "pwdfield[9.25,1.75;2.5,0.5;te_pwd;]" ..
951 "checkbox[1,3.6;cb_public_serverlist;Public Serverlist;" ..
952 dump(engine.setting_getbool("public_serverlist")) .. "]" ..
953 "textlist[1,0.35;7.5,3.35;favourites;"
955 if #menu.favorites > 0 then
956 retval = retval .. render_favourite(menu.favorites[1])
958 for i=2,#menu.favorites,1 do
959 retval = retval .. "," .. render_favourite(menu.favorites[i])
963 retval = retval .. ";1]"
968 --------------------------------------------------------------------------------
969 function tabbuilder.tab_server()
971 "button[4,4.15;2.6,0.5;world_delete;Delete]" ..
972 "button[6.5,4.15;2.8,0.5;world_create;New]" ..
973 "button[9.2,4.15;2.55,0.5;world_configure;Configure]" ..
974 "button[8.5,4.9;3.25,0.5;start_server;Start Game]" ..
975 "label[4,-0.25;Select World:]"..
976 "vertlabel[0,-0.25;START SERVER]" ..
977 "checkbox[0.5,0.25;cb_creative_mode;Creative Mode;" ..
978 dump(engine.setting_getbool("creative_mode")) .. "]"..
979 "checkbox[0.5,0.7;cb_enable_damage;Enable Damage;" ..
980 dump(engine.setting_getbool("enable_damage")) .. "]"..
981 "field[0.8,2.2;3,0.5;te_playername;Name;" ..
982 engine.setting_get("name") .. "]" ..
983 "pwdfield[0.8,3.2;3,0.5;te_passwd;Password]" ..
984 "field[0.8,5.2;3,0.5;te_serverport;Server Port;30000]" ..
985 "textlist[4,0.25;7.5,3.7;srv_worlds;"
987 if #menu.worldlist > 0 then
988 retval = retval .. menu.worldlist[1].name ..
989 " [[" .. menu.worldlist[1].gameid .. "]]"
991 for i=2,#menu.worldlist,1 do
992 retval = retval .. "," .. menu.worldlist[i].name ..
993 " [[" .. menu.worldlist[i].gameid .. "]]"
997 retval = retval .. ";" .. menu.last_world .. "]"
1002 --------------------------------------------------------------------------------
1003 function tabbuilder.tab_settings()
1004 return "vertlabel[0,0;SETTINGS]" ..
1005 "checkbox[1,0.75;cb_fancy_trees;Fancy trees;" .. dump(engine.setting_getbool("new_style_leaves")) .. "]"..
1006 "checkbox[1,1.25;cb_smooth_lighting;Smooth Lighting;".. dump(engine.setting_getbool("smooth_lighting")) .. "]"..
1007 "checkbox[1,1.75;cb_3d_clouds;3D Clouds;" .. dump(engine.setting_getbool("enable_3d_clouds")) .. "]"..
1008 "checkbox[1,2.25;cb_opaque_water;Opaque Water;" .. dump(engine.setting_getbool("opaque_water")) .. "]"..
1010 "checkbox[4,0.75;cb_mipmapping;Mip-Mapping;" .. dump(engine.setting_getbool("mip_map")) .. "]"..
1011 "checkbox[4,1.25;cb_anisotrophic;Anisotropic Filtering;".. dump(engine.setting_getbool("anisotropic_filter")) .. "]"..
1012 "checkbox[4,1.75;cb_bilinear;Bi-Linear Filtering;" .. dump(engine.setting_getbool("bilinear_filter")) .. "]"..
1013 "checkbox[4,2.25;cb_trilinear;Tri-Linear Filtering;" .. dump(engine.setting_getbool("trilinear_filter")) .. "]"..
1015 "checkbox[7.5,0.75;cb_shaders;Shaders;" .. dump(engine.setting_getbool("enable_shaders")) .. "]"..
1016 "checkbox[7.5,1.25;cb_pre_ivis;Preload item visuals;".. dump(engine.setting_getbool("preload_item_visuals")) .. "]"..
1017 "checkbox[7.5,1.75;cb_particles;Enable Particles;" .. dump(engine.setting_getbool("enable_particles")) .. "]"..
1018 "checkbox[7.5,2.25;cb_finite_liquid;Finite Liquid;" .. dump(engine.setting_getbool("liquid_finite")) .. "]"..
1020 "button[1,3.75;2.25,0.5;btn_change_keys;Change keys]"
1023 --------------------------------------------------------------------------------
1024 function tabbuilder.tab_singleplayer()
1025 local index = engine.setting_get("main_menu_singleplayer_world_idx")
1027 if index == nil then
1031 return "button[4,4.15;2.6,0.5;world_delete;Delete]" ..
1032 "button[6.5,4.15;2.8,0.5;world_create;New]" ..
1033 "button[9.2,4.15;2.55,0.5;world_configure;Configure]" ..
1034 "button[8.5,4.95;3.25,0.5;play;Play]" ..
1035 "label[4,-0.25;Select World:]"..
1036 "vertlabel[0,-0.25;SINGLE PLAYER]" ..
1037 "checkbox[0.5,0.25;cb_creative_mode;Creative Mode;" ..
1038 dump(engine.setting_getbool("creative_mode")) .. "]"..
1039 "checkbox[0.5,0.7;cb_enable_damage;Enable Damage;" ..
1040 dump(engine.setting_getbool("enable_damage")) .. "]"..
1041 "textlist[4,0.25;7.5,3.7;sp_worlds;" ..
1042 menu.filtered_game_list() ..
1043 ";" .. index .. "]" ..
1047 --------------------------------------------------------------------------------
1048 function tabbuilder.tab_credits()
1049 return "vertlabel[0,-0.5;CREDITS]" ..
1050 "label[0.5,3;Minetest " .. engine.get_version() .. "]" ..
1051 "label[0.5,3.3;http://minetest.net]" ..
1052 "image[0.5,1;" .. menu.basetexturedir .. "logo.png]" ..
1053 "textlist[3.5,-0.25;8.5,5.8;list_credits;" ..
1054 "#YLWCore Developers," ..
1055 "Perttu Ahola (celeron55) <celeron55@gmail.com>,"..
1056 "Ryan Kwolek (kwolekr) <kwolekr@minetest.net>,"..
1057 "PilzAdam <pilzadam@minetest.net>," ..
1058 "IIya Zhuravlev (thexyz) <xyz@minetest.net>,"..
1059 "Lisa Milne (darkrose) <lisa@ltmnet.com>,"..
1060 "Maciej Kasatkin (RealBadAngel) <mk@realbadangel.pl>,"..
1061 "proller <proler@gmail.com>,"..
1062 "sfan5 <sfan5@live.de>,"..
1063 "kahrl <kahrl@gmx.net>,"..
1065 "#YLWActive Contributors," ..
1067 "Vanessa Ezekowitz (VanessaE) <vanessaezekowitz@gmail.com>,"..
1068 "Jurgen Doser (doserj) <jurgen.doser@gmail.com>,"..
1069 "Jeija <jeija@mesecons.net>,"..
1070 "MirceaKitsune <mirceakitsune@gmail.com>,"..
1072 "dannydark <the_skeleton_of_a_child@yahoo.co.uk>"..
1073 "0gb.us <0gb.us@0gb.us>,"..
1075 "#YLWPrevious Contributors," ..
1076 "Guiseppe Bilotta (Oblomov) <guiseppe.bilotta@gmail.com>,"..
1077 "Jonathan Neuschafer <j.neuschaefer@gmx.net>,"..
1078 "Nils Dagsson Moskopp (erlehmann) <nils@dieweltistgarnichtso.net>,"..
1079 "Constantin Wenger (SpeedProg) <constantin.wenger@googlemail.com>,"..
1080 "matttpt <matttpt@gmail.com>,"..
1081 "JacobF <queatz@gmail.com>,"..
1085 --------------------------------------------------------------------------------
1086 function tabbuilder.checkretval(retval)
1088 if retval ~= nil then
1089 if retval.current_tab ~= nil then
1090 tabbuilder.current_tab = retval.current_tab
1093 if retval.is_dialog ~= nil then
1094 tabbuilder.is_dialog = retval.is_dialog
1097 if retval.show_buttons ~= nil then
1098 tabbuilder.show_buttons = retval.show_buttons
1101 if retval.skipformupdate ~= nil then
1102 tabbuilder.skipformupdate = retval.skipformupdate
1107 --------------------------------------------------------------------------------
1108 --------------------------------------------------------------------------------
1109 -- initialize callbacks
1110 --------------------------------------------------------------------------------
1111 --------------------------------------------------------------------------------
1112 engine.button_handler = function(fields)
1113 --print("Buttonhandler: tab: " .. tabbuilder.current_tab .. " fields: " .. dump(fields))
1115 if fields["btn_error_confirm"] then
1116 gamedata.errormessage = nil
1119 local retval = modmgr.handle_buttons(tabbuilder.current_tab,fields)
1120 tabbuilder.checkretval(retval)
1122 retval = gamemgr.handle_buttons(tabbuilder.current_tab,fields)
1123 tabbuilder.checkretval(retval)
1125 retval = modstore.handle_buttons(tabbuilder.current_tab,fields)
1126 tabbuilder.checkretval(retval)
1128 if tabbuilder.current_tab == "dialog_create_world" then
1129 tabbuilder.handle_create_world_buttons(fields)
1132 if tabbuilder.current_tab == "dialog_delete_world" then
1133 tabbuilder.handle_delete_world_buttons(fields)
1136 if tabbuilder.current_tab == "singleplayer" then
1137 tabbuilder.handle_singleplayer_buttons(fields)
1140 if tabbuilder.current_tab == "multiplayer" then
1141 tabbuilder.handle_multiplayer_buttons(fields)
1144 if tabbuilder.current_tab == "settings" then
1145 tabbuilder.handle_settings_buttons(fields)
1148 if tabbuilder.current_tab == "server" then
1149 tabbuilder.handle_server_buttons(fields)
1153 tabbuilder.handle_tab_buttons(fields)
1156 menubar.handle_buttons(fields)
1158 if not tabbuilder.skipformupdate then
1162 tabbuilder.skipformupdate = false
1166 --------------------------------------------------------------------------------
1167 engine.event_handler = function(event)
1168 if event == "MenuQuit" then
1169 if tabbuilder.is_dialog then
1170 tabbuilder.is_dialog = false
1171 tabbuilder.show_buttons = true
1172 tabbuilder.current_tab = engine.setting_get("main_menu_tab")
1180 --------------------------------------------------------------------------------
1181 --------------------------------------------------------------------------------
1183 --------------------------------------------------------------------------------
1184 --------------------------------------------------------------------------------