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"
22 mt_color_orange = "#FF8800"
24 local menupath = core.get_mainmenu_path()
25 local basepath = core.get_builtin_path()
26 defaulttexturedir = core.get_texturepath_share() .. DIR_DELIM .. "base" ..
27 DIR_DELIM .. "pack" .. DIR_DELIM
29 dofile(basepath .. "common" .. DIR_DELIM .. "filterlist.lua")
30 dofile(basepath .. "fstk" .. DIR_DELIM .. "buttonbar.lua")
31 dofile(basepath .. "fstk" .. DIR_DELIM .. "dialog.lua")
32 dofile(basepath .. "fstk" .. DIR_DELIM .. "tabview.lua")
33 dofile(basepath .. "fstk" .. DIR_DELIM .. "ui.lua")
34 dofile(menupath .. DIR_DELIM .. "async_event.lua")
35 dofile(menupath .. DIR_DELIM .. "common.lua")
36 dofile(menupath .. DIR_DELIM .. "pkgmgr.lua")
37 dofile(menupath .. DIR_DELIM .. "serverlistmgr.lua")
38 dofile(menupath .. DIR_DELIM .. "game_theme.lua")
40 dofile(menupath .. DIR_DELIM .. "dlg_config_world.lua")
41 dofile(menupath .. DIR_DELIM .. "dlg_settings_advanced.lua")
42 dofile(menupath .. DIR_DELIM .. "dlg_contentstore.lua")
43 dofile(menupath .. DIR_DELIM .. "dlg_create_world.lua")
44 dofile(menupath .. DIR_DELIM .. "dlg_delete_content.lua")
45 dofile(menupath .. DIR_DELIM .. "dlg_delete_world.lua")
46 dofile(menupath .. DIR_DELIM .. "dlg_rename_modpack.lua")
50 tabs.settings = dofile(menupath .. DIR_DELIM .. "tab_settings.lua")
51 tabs.content = dofile(menupath .. DIR_DELIM .. "tab_content.lua")
52 tabs.about = dofile(menupath .. DIR_DELIM .. "tab_about.lua")
53 tabs.local_game = dofile(menupath .. DIR_DELIM .. "tab_local.lua")
54 tabs.play_online = dofile(menupath .. DIR_DELIM .. "tab_online.lua")
56 --------------------------------------------------------------------------------
57 local function main_event_handler(tabview, event)
58 if event == "MenuQuit" then
64 --------------------------------------------------------------------------------
65 local function init_globals()
67 gamedata.worldindex = 0
69 menudata.worldlist = filterlist.create(
72 -- Unique id comparison function
73 function(element, uid)
74 return element.name == uid
77 function(element, gameid)
78 return element.gameid == gameid
82 menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic)
83 menudata.worldlist:set_sortmode("alphabetic")
85 if not core.settings:get("menu_last_game") then
86 local default_game = core.settings:get("default_game") or "minetest"
87 core.settings:set("menu_last_game", default_game)
92 -- Create main tabview
93 local tv_main = tabview_create("maintab", {x = 12, y = 5.4}, {x = 0, y = 0})
95 tv_main:set_autosave_tab(true)
96 tv_main:add(tabs.local_game)
97 tv_main:add(tabs.play_online)
99 tv_main:add(tabs.content)
100 tv_main:add(tabs.settings)
101 tv_main:add(tabs.about)
103 tv_main:set_global_event_handler(main_event_handler)
104 tv_main:set_fixed_size(false)
106 local last_tab = core.settings:get("maintab_LAST")
107 if last_tab and tv_main.current_tab ~= last_tab then
108 tv_main:set_tab(last_tab)
111 -- In case the folder of the last selected game has been deleted,
112 -- display "Minetest" as a header
113 if tv_main.current_tab == "local" then
114 local game = pkgmgr.find_by_gameid(core.settings:get("menu_last_game"))
116 mm_game_theme.reset()
120 ui.set_default("maintab")