2 --Copyright (C) 2014 sapier
4 --This program is free software; you can redistribute it and/or modify
5 --it under the terms of the GNU Lesser General Public License as published by
6 --the Free Software Foundation; either version 2.1 of the License, or
7 --(at your option) any later version.
9 --This program is distributed in the hope that it will be useful,
10 --but WITHOUT ANY WARRANTY; without even the implied warranty of
11 --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 --GNU Lesser General Public License for more details.
14 --You should have received a copy of the GNU Lesser General Public License along
15 --with this program; if not, write to the Free Software Foundation, Inc.,
16 --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 mt_color_grey = "#AAAAAA"
19 mt_color_blue = "#6389FF"
20 mt_color_green = "#72FF63"
21 mt_color_dark_green = "#25C191"
23 local menupath = core.get_mainmenu_path()
24 local basepath = core.get_builtin_path()
25 defaulttexturedir = core.get_texturepath_share() .. DIR_DELIM .. "base" ..
26 DIR_DELIM .. "pack" .. DIR_DELIM
28 dofile(basepath .. "common" .. DIR_DELIM .. "filterlist.lua")
29 dofile(basepath .. "fstk" .. DIR_DELIM .. "buttonbar.lua")
30 dofile(basepath .. "fstk" .. DIR_DELIM .. "dialog.lua")
31 dofile(basepath .. "fstk" .. DIR_DELIM .. "tabview.lua")
32 dofile(basepath .. "fstk" .. DIR_DELIM .. "ui.lua")
33 dofile(menupath .. DIR_DELIM .. "async_event.lua")
34 dofile(menupath .. DIR_DELIM .. "common.lua")
35 dofile(menupath .. DIR_DELIM .. "pkgmgr.lua")
36 dofile(menupath .. DIR_DELIM .. "textures.lua")
38 dofile(menupath .. DIR_DELIM .. "dlg_config_world.lua")
39 dofile(menupath .. DIR_DELIM .. "dlg_settings_advanced.lua")
40 dofile(menupath .. DIR_DELIM .. "dlg_contentstore.lua")
41 dofile(menupath .. DIR_DELIM .. "dlg_create_world.lua")
42 dofile(menupath .. DIR_DELIM .. "dlg_delete_content.lua")
43 dofile(menupath .. DIR_DELIM .. "dlg_delete_world.lua")
44 dofile(menupath .. DIR_DELIM .. "dlg_rename_modpack.lua")
48 tabs.settings = dofile(menupath .. DIR_DELIM .. "tab_settings.lua")
49 tabs.content = dofile(menupath .. DIR_DELIM .. "tab_content.lua")
50 tabs.credits = dofile(menupath .. DIR_DELIM .. "tab_credits.lua")
51 tabs.local_game = dofile(menupath .. DIR_DELIM .. "tab_local.lua")
52 tabs.play_online = dofile(menupath .. DIR_DELIM .. "tab_online.lua")
54 --------------------------------------------------------------------------------
55 local function main_event_handler(tabview, event)
56 if event == "MenuQuit" then
62 --------------------------------------------------------------------------------
63 local function init_globals()
65 gamedata.worldindex = 0
67 menudata.worldlist = filterlist.create(
70 -- Unique id comparison function
71 function(element, uid)
72 return element.name == uid
75 function(element, gameid)
76 return element.gameid == gameid
80 menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic)
81 menudata.worldlist:set_sortmode("alphabetic")
83 if not core.settings:get("menu_last_game") then
84 local default_game = core.settings:get("default_game") or "minetest"
85 core.settings:set("menu_last_game", default_game)
90 -- Create main tabview
91 local tv_main = tabview_create("maintab", {x = 12, y = 5.4}, {x = 0, y = 0})
93 tv_main:set_autosave_tab(true)
94 tv_main:add(tabs.local_game)
95 tv_main:add(tabs.play_online)
97 tv_main:add(tabs.content)
98 tv_main:add(tabs.settings)
99 tv_main:add(tabs.credits)
101 tv_main:set_global_event_handler(main_event_handler)
102 tv_main:set_fixed_size(false)
104 local last_tab = core.settings:get("maintab_LAST")
105 if last_tab and tv_main.current_tab ~= last_tab then
106 tv_main:set_tab(last_tab)
108 ui.set_default("maintab")
113 core.sound_play("main_menu", true)