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()
440 local mapgens = {"v6", "v7", "indev", "singlenode", "math"}
442 local current_mg = engine.setting_get("mg_name")
447 for k,v in pairs(mapgens) do
448 if current_mg == v then
452 mglist = mglist .. v .. ","
454 mglist = mglist:sub(1, -2)
457 "label[2,0;World name]"..
458 "label[2,1;Mapgen]"..
459 "field[4.5,0.4;6,0.5;te_world_name;;]" ..
461 "button[5,4.5;2.6,0.5;world_create_confirm;Create]" ..
462 "button[7.5,4.5;2.8,0.5;world_create_cancel;Cancel]" ..
463 "dropdown[4.2,1;6.3;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" ..
464 "textlist[4.2,1.9;5.8,2.3;games;" ..
465 gamemgr.gamelist() ..
466 ";" .. menu.last_game .. ";true]"
471 --------------------------------------------------------------------------------
472 function tabbuilder.dialog_delete_world()
473 return "label[2,2;Delete World \"" .. menu.lastworld().name .. "\"?]"..
474 "button[3.5,4.2;2.6,0.5;world_delete_confirm;Yes]" ..
475 "button[6,4.2;2.8,0.5;world_delete_cancel;No]"
478 --------------------------------------------------------------------------------
479 function tabbuilder.gettab()
482 if tabbuilder.show_buttons then
483 retval = retval .. tabbuilder.tab_header()
486 if tabbuilder.current_tab == "singleplayer" then
487 retval = retval .. tabbuilder.tab_singleplayer()
490 if tabbuilder.current_tab == "multiplayer" then
491 retval = retval .. tabbuilder.tab_multiplayer()
494 if tabbuilder.current_tab == "server" then
495 retval = retval .. tabbuilder.tab_server()
498 if tabbuilder.current_tab == "settings" then
499 retval = retval .. tabbuilder.tab_settings()
502 if tabbuilder.current_tab == "credits" then
503 retval = retval .. tabbuilder.tab_credits()
506 if tabbuilder.current_tab == "dialog_create_world" then
507 retval = retval .. tabbuilder.dialog_create_world()
510 if tabbuilder.current_tab == "dialog_delete_world" then
511 retval = retval .. tabbuilder.dialog_delete_world()
514 retval = retval .. modmgr.gettab(tabbuilder.current_tab)
515 retval = retval .. gamemgr.gettab(tabbuilder.current_tab)
516 retval = retval .. modstore.gettab(tabbuilder.current_tab)
521 --------------------------------------------------------------------------------
522 function tabbuilder.handle_create_world_buttons(fields)
524 if fields["world_create_confirm"] then
526 local worldname = fields["te_world_name"]
527 local gameindex = engine.get_textlist_index("games")
531 engine.setting_set("mg_name",fields["dd_mapgen"])
532 local message = engine.create_world(worldname,gameindex)
534 menu.last_game = gameindex
535 engine.setting_set("main_menu_last_game_idx",gameindex)
537 if message ~= nil then
538 gamedata.errormessage = message
540 menu.worldlist = engine.get_worlds()
542 local worldlist = menu.worldlist
544 if tabbuilder.current_tab == "singleplayer" then
545 worldlist = menu.filtered_game_list_raw()
550 for i=1,#worldlist,1 do
551 if worldlist[i].name == worldname then
557 engine.setting_set("main_menu_singleplayer_world_idx", index)
558 menu.last_world = index
561 gamedata.errormessage = "No worldname given or no game selected"
565 if fields["games"] then
566 tabbuilder.skipformupdate = true
570 tabbuilder.is_dialog = false
571 tabbuilder.show_buttons = true
572 tabbuilder.current_tab = engine.setting_get("main_menu_tab")
575 --------------------------------------------------------------------------------
576 function tabbuilder.handle_delete_world_buttons(fields)
578 if fields["world_delete_confirm"] then
579 if menu.last_world > 0 and
580 menu.last_world < #menu.worldlist then
581 engine.delete_world(menu.last_world)
582 menu.worldlist = engine.get_worlds()
587 tabbuilder.is_dialog = false
588 tabbuilder.show_buttons = true
589 tabbuilder.current_tab = engine.setting_get("main_menu_tab")
592 --------------------------------------------------------------------------------
593 function tabbuilder.handle_multiplayer_buttons(fields)
594 if fields["favourites"] ~= nil then
595 local event = explode_textlist_event(fields["favourites"])
596 if event.typ == "DCL" then
597 gamedata.address = menu.favorites[event.index].name
598 if gamedata.address == nil then
599 gamedata.address = menu.favorites[event.index].address
601 gamedata.port = menu.favorites[event.index].port
602 gamedata.playername = fields["te_name"]
603 gamedata.password = fields["te_pwd"]
604 gamedata.selected_world = 0
606 if gamedata.address ~= nil and
607 gamedata.port ~= nil then
613 if event.typ == "CHG" then
614 local address = menu.favorites[event.index].name
615 if address == nil then
616 address = menu.favorites[event.index].address
618 local port = menu.favorites[event.index].port
620 if address ~= nil and
622 engine.setting_set("address",address)
623 engine.setting_set("port",port)
629 if fields["cb_public_serverlist"] ~= nil then
630 engine.setting_setbool("public_serverlist",
631 tabbuilder.tobool(fields["cb_public_serverlist"]))
633 if engine.setting_getbool("public_serverlist") then
634 menu.favorites = engine.get_favorites("online")
636 menu.favorites = engine.get_favorites("local")
640 if fields["btn_delete_favorite"] ~= nil then
641 local current_favourite = engine.get_textlist_index("favourites")
642 engine.delete_favorite(current_favourite)
643 menu.favorites = engine.get_favorites()
645 engine.setting_set("address","")
646 engine.setting_get("port","")
651 if fields["btn_mp_connect"] ~= nil then
652 gamedata.playername = fields["te_name"]
653 gamedata.password = fields["te_pwd"]
654 gamedata.address = fields["te_address"]
655 gamedata.port = fields["te_port"]
656 gamedata.selected_world = 0
663 --------------------------------------------------------------------------------
664 function tabbuilder.handle_server_buttons(fields)
666 local world_doubleclick = false
668 if fields["worlds"] ~= nil then
669 local event = explode_textlist_event(fields["worlds"])
671 if event.typ == "DBL" then
672 world_doubleclick = true
676 if fields["cb_creative_mode"] then
677 engine.setting_setbool("creative_mode",tabbuilder.tobool(fields["cb_creative_mode"]))
680 if fields["cb_enable_damage"] then
681 engine.setting_setbool("enable_damage",tabbuilder.tobool(fields["cb_enable_damage"]))
684 if fields["start_server"] ~= nil or
685 world_doubleclick then
686 local selected = engine.get_textlist_index("srv_worlds")
688 gamedata.playername = fields["te_playername"]
689 gamedata.password = fields["te_pwd"]
690 gamedata.address = ""
691 gamedata.port = fields["te_serverport"]
692 gamedata.selected_world = selected
694 engine.setting_set("main_menu_tab",tabbuilder.current_tab)
695 engine.setting_set("main_menu_last_world_idx",gamedata.selected_world)
697 menu.update_last_game(gamedata.selected_world)
702 if fields["world_create"] ~= nil then
703 tabbuilder.current_tab = "dialog_create_world"
704 tabbuilder.is_dialog = true
705 tabbuilder.show_buttons = false
708 if fields["world_delete"] ~= nil then
709 local selected = engine.get_textlist_index("srv_worlds")
711 menu.last_world = engine.get_textlist_index("worlds")
712 if menu.lastworld() ~= nil and
713 menu.lastworld().name ~= nil and
714 menu.lastworld().name ~= "" then
715 tabbuilder.current_tab = "dialog_delete_world"
716 tabbuilder.is_dialog = true
717 tabbuilder.show_buttons = false
724 if fields["world_configure"] ~= nil then
725 selected = engine.get_textlist_index("srv_worlds")
727 modmgr.world_config_selected_world = selected
728 if modmgr.init_worldconfig() then
729 tabbuilder.current_tab = "dialog_configure_world"
730 tabbuilder.is_dialog = true
731 tabbuilder.show_buttons = false
737 --------------------------------------------------------------------------------
738 function tabbuilder.tobool(text)
739 if text == "true" then
746 --------------------------------------------------------------------------------
747 function tabbuilder.handle_settings_buttons(fields)
748 if fields["cb_fancy_trees"] then
749 engine.setting_setbool("new_style_leaves",tabbuilder.tobool(fields["cb_fancy_trees"]))
752 if fields["cb_smooth_lighting"] then
753 engine.setting_setbool("smooth_lighting",tabbuilder.tobool(fields["cb_smooth_lighting"]))
755 if fields["cb_3d_clouds"] then
756 engine.setting_setbool("enable_3d_clouds",tabbuilder.tobool(fields["cb_3d_clouds"]))
758 if fields["cb_opaque_water"] then
759 engine.setting_setbool("opaque_water",tabbuilder.tobool(fields["cb_opaque_water"]))
762 if fields["cb_mipmapping"] then
763 engine.setting_setbool("mip_map",tabbuilder.tobool(fields["cb_mipmapping"]))
765 if fields["cb_anisotrophic"] then
766 engine.setting_setbool("anisotropic_filter",tabbuilder.tobool(fields["cb_anisotrophic"]))
768 if fields["cb_bilinear"] then
769 engine.setting_setbool("bilinear_filter",tabbuilder.tobool(fields["cb_bilinear"]))
771 if fields["cb_trilinear"] then
772 engine.setting_setbool("trilinear_filter",tabbuilder.tobool(fields["cb_trilinear"]))
775 if fields["cb_shaders"] then
776 engine.setting_setbool("enable_shaders",tabbuilder.tobool(fields["cb_shaders"]))
778 if fields["cb_pre_ivis"] then
779 engine.setting_setbool("preload_item_visuals",tabbuilder.tobool(fields["cb_pre_ivis"]))
781 if fields["cb_particles"] then
782 engine.setting_setbool("enable_particles",tabbuilder.tobool(fields["cb_particles"]))
784 if fields["cb_finite_liquid"] then
785 engine.setting_setbool("liquid_finite",tabbuilder.tobool(fields["cb_finite_liquid"]))
788 if fields["btn_change_keys"] ~= nil then
789 engine.show_keys_menu()
793 --------------------------------------------------------------------------------
794 function tabbuilder.handle_singleplayer_buttons(fields)
796 local world_doubleclick = false
798 if fields["sp_worlds"] ~= nil then
799 local event = explode_textlist_event(fields["sp_worlds"])
801 if event.typ == "DCL" then
802 world_doubleclick = true
806 if fields["cb_creative_mode"] then
807 engine.setting_setbool("creative_mode",tabbuilder.tobool(fields["cb_creative_mode"]))
810 if fields["cb_enable_damage"] then
811 engine.setting_setbool("enable_damage",tabbuilder.tobool(fields["cb_enable_damage"]))
814 if fields["play"] ~= nil or
815 world_doubleclick then
816 local selected = engine.get_textlist_index("sp_worlds")
818 gamedata.selected_world = menu.filtered_index_to_plain(selected)
819 gamedata.singleplayer = true
821 engine.setting_set("main_menu_tab",tabbuilder.current_tab)
822 engine.setting_set("main_menu_singleplayer_world_idx",selected)
824 menu.update_last_game(gamedata.selected_world)
830 if fields["world_create"] ~= nil then
831 tabbuilder.current_tab = "dialog_create_world"
832 tabbuilder.is_dialog = true
833 tabbuilder.show_buttons = false
836 if fields["world_delete"] ~= nil then
837 local selected = engine.get_textlist_index("sp_worlds")
839 menu.last_world = menu.filtered_index_to_plain(selected)
840 if menu.lastworld() ~= nil and
841 menu.lastworld().name ~= nil and
842 menu.lastworld().name ~= "" then
843 tabbuilder.current_tab = "dialog_delete_world"
844 tabbuilder.is_dialog = true
845 tabbuilder.show_buttons = false
852 if fields["world_configure"] ~= nil then
853 selected = engine.get_textlist_index("sp_worlds")
855 modmgr.world_config_selected_world = menu.filtered_index_to_plain(selected)
856 if modmgr.init_worldconfig() then
857 tabbuilder.current_tab = "dialog_configure_world"
858 tabbuilder.is_dialog = true
859 tabbuilder.show_buttons = false
865 --------------------------------------------------------------------------------
866 function tabbuilder.tab_header()
868 if tabbuilder.last_tab_index == nil then
869 tabbuilder.last_tab_index = 1
874 for i=1,#tabbuilder.current_buttons,1 do
880 toadd = toadd .. tabbuilder.current_buttons[i].caption
882 return "tabheader[-0.3,-0.99;main_tab;" .. toadd ..";" .. tabbuilder.last_tab_index .. ";true;false]"
885 --------------------------------------------------------------------------------
886 function tabbuilder.handle_tab_buttons(fields)
888 if fields["main_tab"] then
889 local index = tonumber(fields["main_tab"])
890 tabbuilder.last_tab_index = index
891 tabbuilder.current_tab = tabbuilder.current_buttons[index].name
893 engine.setting_set("main_menu_tab",tabbuilder.current_tab)
897 if tabbuilder.current_tab ~= tabbuilder.old_tab then
898 if tabbuilder.current_tab ~= "singleplayer" then
899 menu.reset_gametype()
903 if tabbuilder.current_tab == "singleplayer" then
904 menu.update_gametype()
907 tabbuilder.old_tab = tabbuilder.current_tab
910 --------------------------------------------------------------------------------
911 function tabbuilder.init()
912 tabbuilder.current_tab = engine.setting_get("main_menu_tab")
914 if tabbuilder.current_tab == nil or
915 tabbuilder.current_tab == "" then
916 tabbuilder.current_tab = "singleplayer"
917 engine.setting_set("main_menu_tab",tabbuilder.current_tab)
921 --initialize tab buttons
922 tabbuilder.last_tab = nil
923 tabbuilder.show_buttons = true
925 tabbuilder.current_buttons = {}
926 table.insert(tabbuilder.current_buttons,{name="singleplayer", caption="Singleplayer"})
927 table.insert(tabbuilder.current_buttons,{name="multiplayer", caption="Client"})
928 table.insert(tabbuilder.current_buttons,{name="server", caption="Server"})
929 table.insert(tabbuilder.current_buttons,{name="settings", caption="Settings"})
931 if engine.setting_getbool("main_menu_game_mgr") then
932 table.insert(tabbuilder.current_buttons,{name="game_mgr", caption="Games"})
935 if engine.setting_getbool("main_menu_mod_mgr") then
936 table.insert(tabbuilder.current_buttons,{name="mod_mgr", caption="Mods"})
938 table.insert(tabbuilder.current_buttons,{name="credits", caption="Credits"})
941 for i=1,#tabbuilder.current_buttons,1 do
942 if tabbuilder.current_buttons[i].name == tabbuilder.current_tab then
943 tabbuilder.last_tab_index = i
947 menu.update_gametype()
950 --------------------------------------------------------------------------------
951 function tabbuilder.tab_multiplayer()
953 "vertlabel[0,-0.25;CLIENT]" ..
954 "label[1,-0.25;Favorites:]"..
955 "label[1,4.25;Address/Port]"..
956 "label[9,0;Name/Password]" ..
957 "field[1.25,5.25;5.5,0.5;te_address;;" ..engine.setting_get("address") .."]" ..
958 "field[6.75,5.25;2.25,0.5;te_port;;" ..engine.setting_get("port") .."]" ..
959 "button[6.45,3.95;2.25,0.5;btn_delete_favorite;Delete]" ..
960 "button[9,4.95;2.5,0.5;btn_mp_connect;Connect]" ..
961 "field[9.25,1;2.5,0.5;te_name;;" ..engine.setting_get("name") .."]" ..
962 "pwdfield[9.25,1.75;2.5,0.5;te_pwd;]" ..
963 "checkbox[1,3.6;cb_public_serverlist;Public Serverlist;" ..
964 dump(engine.setting_getbool("public_serverlist")) .. "]" ..
965 "textlist[1,0.35;7.5,3.35;favourites;"
967 if #menu.favorites > 0 then
968 retval = retval .. render_favourite(menu.favorites[1])
970 for i=2,#menu.favorites,1 do
971 retval = retval .. "," .. render_favourite(menu.favorites[i])
975 retval = retval .. ";1]"
980 --------------------------------------------------------------------------------
981 function tabbuilder.tab_server()
983 "button[4,4.15;2.6,0.5;world_delete;Delete]" ..
984 "button[6.5,4.15;2.8,0.5;world_create;New]" ..
985 "button[9.2,4.15;2.55,0.5;world_configure;Configure]" ..
986 "button[8.5,4.9;3.25,0.5;start_server;Start Game]" ..
987 "label[4,-0.25;Select World:]"..
988 "vertlabel[0,-0.25;START SERVER]" ..
989 "checkbox[0.5,0.25;cb_creative_mode;Creative Mode;" ..
990 dump(engine.setting_getbool("creative_mode")) .. "]"..
991 "checkbox[0.5,0.7;cb_enable_damage;Enable Damage;" ..
992 dump(engine.setting_getbool("enable_damage")) .. "]"..
993 "field[0.8,2.2;3,0.5;te_playername;Name;" ..
994 engine.setting_get("name") .. "]" ..
995 "pwdfield[0.8,3.2;3,0.5;te_passwd;Password]" ..
996 "field[0.8,5.2;3,0.5;te_serverport;Server Port;30000]" ..
997 "textlist[4,0.25;7.5,3.7;srv_worlds;"
999 if #menu.worldlist > 0 then
1000 retval = retval .. menu.worldlist[1].name ..
1001 " [[" .. menu.worldlist[1].gameid .. "]]"
1003 for i=2,#menu.worldlist,1 do
1004 retval = retval .. "," .. menu.worldlist[i].name ..
1005 " [[" .. menu.worldlist[i].gameid .. "]]"
1009 retval = retval .. ";" .. menu.last_world .. "]"
1014 --------------------------------------------------------------------------------
1015 function tabbuilder.tab_settings()
1016 return "vertlabel[0,0;SETTINGS]" ..
1017 "checkbox[1,0.75;cb_fancy_trees;Fancy trees;" .. dump(engine.setting_getbool("new_style_leaves")) .. "]"..
1018 "checkbox[1,1.25;cb_smooth_lighting;Smooth Lighting;".. dump(engine.setting_getbool("smooth_lighting")) .. "]"..
1019 "checkbox[1,1.75;cb_3d_clouds;3D Clouds;" .. dump(engine.setting_getbool("enable_3d_clouds")) .. "]"..
1020 "checkbox[1,2.25;cb_opaque_water;Opaque Water;" .. dump(engine.setting_getbool("opaque_water")) .. "]"..
1022 "checkbox[4,0.75;cb_mipmapping;Mip-Mapping;" .. dump(engine.setting_getbool("mip_map")) .. "]"..
1023 "checkbox[4,1.25;cb_anisotrophic;Anisotropic Filtering;".. dump(engine.setting_getbool("anisotropic_filter")) .. "]"..
1024 "checkbox[4,1.75;cb_bilinear;Bi-Linear Filtering;" .. dump(engine.setting_getbool("bilinear_filter")) .. "]"..
1025 "checkbox[4,2.25;cb_trilinear;Tri-Linear Filtering;" .. dump(engine.setting_getbool("trilinear_filter")) .. "]"..
1027 "checkbox[7.5,0.75;cb_shaders;Shaders;" .. dump(engine.setting_getbool("enable_shaders")) .. "]"..
1028 "checkbox[7.5,1.25;cb_pre_ivis;Preload item visuals;".. dump(engine.setting_getbool("preload_item_visuals")) .. "]"..
1029 "checkbox[7.5,1.75;cb_particles;Enable Particles;" .. dump(engine.setting_getbool("enable_particles")) .. "]"..
1030 "checkbox[7.5,2.25;cb_finite_liquid;Finite Liquid;" .. dump(engine.setting_getbool("liquid_finite")) .. "]"..
1032 "button[1,3.75;2.25,0.5;btn_change_keys;Change keys]"
1035 --------------------------------------------------------------------------------
1036 function tabbuilder.tab_singleplayer()
1037 local index = engine.setting_get("main_menu_singleplayer_world_idx")
1039 if index == nil then
1043 return "button[4,4.15;2.6,0.5;world_delete;Delete]" ..
1044 "button[6.5,4.15;2.8,0.5;world_create;New]" ..
1045 "button[9.2,4.15;2.55,0.5;world_configure;Configure]" ..
1046 "button[8.5,4.95;3.25,0.5;play;Play]" ..
1047 "label[4,-0.25;Select World:]"..
1048 "vertlabel[0,-0.25;SINGLE PLAYER]" ..
1049 "checkbox[0.5,0.25;cb_creative_mode;Creative Mode;" ..
1050 dump(engine.setting_getbool("creative_mode")) .. "]"..
1051 "checkbox[0.5,0.7;cb_enable_damage;Enable Damage;" ..
1052 dump(engine.setting_getbool("enable_damage")) .. "]"..
1053 "textlist[4,0.25;7.5,3.7;sp_worlds;" ..
1054 menu.filtered_game_list() ..
1055 ";" .. index .. "]" ..
1059 --------------------------------------------------------------------------------
1060 function tabbuilder.tab_credits()
1061 return "vertlabel[0,-0.5;CREDITS]" ..
1062 "label[0.5,3;Minetest " .. engine.get_version() .. "]" ..
1063 "label[0.5,3.3;http://minetest.net]" ..
1064 "image[0.5,1;" .. menu.basetexturedir .. "logo.png]" ..
1065 "textlist[3.5,-0.25;8.5,5.8;list_credits;" ..
1066 "#YLWCore Developers," ..
1067 "Perttu Ahola (celeron55) <celeron55@gmail.com>,"..
1068 "Ryan Kwolek (kwolekr) <kwolekr@minetest.net>,"..
1069 "PilzAdam <pilzadam@minetest.net>," ..
1070 "IIya Zhuravlev (thexyz) <xyz@minetest.net>,"..
1071 "Lisa Milne (darkrose) <lisa@ltmnet.com>,"..
1072 "Maciej Kasatkin (RealBadAngel) <mk@realbadangel.pl>,"..
1073 "proller <proler@gmail.com>,"..
1074 "sfan5 <sfan5@live.de>,"..
1075 "kahrl <kahrl@gmx.net>,"..
1077 "#YLWActive Contributors," ..
1079 "Vanessa Ezekowitz (VanessaE) <vanessaezekowitz@gmail.com>,"..
1080 "Jurgen Doser (doserj) <jurgen.doser@gmail.com>,"..
1081 "Jeija <jeija@mesecons.net>,"..
1082 "MirceaKitsune <mirceakitsune@gmail.com>,"..
1084 "dannydark <the_skeleton_of_a_child@yahoo.co.uk>"..
1085 "0gb.us <0gb.us@0gb.us>,"..
1087 "#YLWPrevious Contributors," ..
1088 "Guiseppe Bilotta (Oblomov) <guiseppe.bilotta@gmail.com>,"..
1089 "Jonathan Neuschafer <j.neuschaefer@gmx.net>,"..
1090 "Nils Dagsson Moskopp (erlehmann) <nils@dieweltistgarnichtso.net>,"..
1091 "Constantin Wenger (SpeedProg) <constantin.wenger@googlemail.com>,"..
1092 "matttpt <matttpt@gmail.com>,"..
1093 "JacobF <queatz@gmail.com>,"..
1097 --------------------------------------------------------------------------------
1098 function tabbuilder.checkretval(retval)
1100 if retval ~= nil then
1101 if retval.current_tab ~= nil then
1102 tabbuilder.current_tab = retval.current_tab
1105 if retval.is_dialog ~= nil then
1106 tabbuilder.is_dialog = retval.is_dialog
1109 if retval.show_buttons ~= nil then
1110 tabbuilder.show_buttons = retval.show_buttons
1113 if retval.skipformupdate ~= nil then
1114 tabbuilder.skipformupdate = retval.skipformupdate
1119 --------------------------------------------------------------------------------
1120 --------------------------------------------------------------------------------
1121 -- initialize callbacks
1122 --------------------------------------------------------------------------------
1123 --------------------------------------------------------------------------------
1124 engine.button_handler = function(fields)
1125 --print("Buttonhandler: tab: " .. tabbuilder.current_tab .. " fields: " .. dump(fields))
1127 if fields["btn_error_confirm"] then
1128 gamedata.errormessage = nil
1131 local retval = modmgr.handle_buttons(tabbuilder.current_tab,fields)
1132 tabbuilder.checkretval(retval)
1134 retval = gamemgr.handle_buttons(tabbuilder.current_tab,fields)
1135 tabbuilder.checkretval(retval)
1137 retval = modstore.handle_buttons(tabbuilder.current_tab,fields)
1138 tabbuilder.checkretval(retval)
1140 if tabbuilder.current_tab == "dialog_create_world" then
1141 tabbuilder.handle_create_world_buttons(fields)
1144 if tabbuilder.current_tab == "dialog_delete_world" then
1145 tabbuilder.handle_delete_world_buttons(fields)
1148 if tabbuilder.current_tab == "singleplayer" then
1149 tabbuilder.handle_singleplayer_buttons(fields)
1152 if tabbuilder.current_tab == "multiplayer" then
1153 tabbuilder.handle_multiplayer_buttons(fields)
1156 if tabbuilder.current_tab == "settings" then
1157 tabbuilder.handle_settings_buttons(fields)
1160 if tabbuilder.current_tab == "server" then
1161 tabbuilder.handle_server_buttons(fields)
1165 tabbuilder.handle_tab_buttons(fields)
1168 menubar.handle_buttons(fields)
1170 if not tabbuilder.skipformupdate then
1174 tabbuilder.skipformupdate = false
1178 --------------------------------------------------------------------------------
1179 engine.event_handler = function(event)
1180 if event == "MenuQuit" then
1181 if tabbuilder.is_dialog then
1182 tabbuilder.is_dialog = false
1183 tabbuilder.show_buttons = true
1184 tabbuilder.current_tab = engine.setting_get("main_menu_tab")
1192 --------------------------------------------------------------------------------
1193 --------------------------------------------------------------------------------
1195 --------------------------------------------------------------------------------
1196 --------------------------------------------------------------------------------