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 --for all other colors ask sfan5 to complete his work!
25 local menupath = core.get_mainmenu_path()
26 local basepath = core.get_builtin_path()
27 local menustyle = core.settings:get("main_menu_style")
28 if menustyle == "auto" then
29 menustyle = PLATFORM == "Android" and "simple" or "full"
31 defaulttexturedir = core.get_texturepath_share() .. DIR_DELIM .. "base" ..
32 DIR_DELIM .. "pack" .. DIR_DELIM
34 dofile(basepath .. "common" .. DIR_DELIM .. "async_event.lua")
35 dofile(basepath .. "common" .. DIR_DELIM .. "filterlist.lua")
36 dofile(basepath .. "fstk" .. DIR_DELIM .. "buttonbar.lua")
37 dofile(basepath .. "fstk" .. DIR_DELIM .. "dialog.lua")
38 dofile(basepath .. "fstk" .. DIR_DELIM .. "tabview.lua")
39 dofile(basepath .. "fstk" .. DIR_DELIM .. "ui.lua")
40 dofile(menupath .. DIR_DELIM .. "common.lua")
41 dofile(menupath .. DIR_DELIM .. "pkgmgr.lua")
42 dofile(menupath .. DIR_DELIM .. "textures.lua")
44 dofile(menupath .. DIR_DELIM .. "dlg_config_world.lua")
45 dofile(menupath .. DIR_DELIM .. "dlg_settings_advanced.lua")
46 dofile(menupath .. DIR_DELIM .. "dlg_contentstore.lua")
47 if menustyle ~= "simple" then
48 dofile(menupath .. DIR_DELIM .. "dlg_create_world.lua")
49 dofile(menupath .. DIR_DELIM .. "dlg_delete_content.lua")
50 dofile(menupath .. DIR_DELIM .. "dlg_delete_world.lua")
51 dofile(menupath .. DIR_DELIM .. "dlg_rename_modpack.lua")
56 tabs.settings = dofile(menupath .. DIR_DELIM .. "tab_settings.lua")
57 tabs.content = dofile(menupath .. DIR_DELIM .. "tab_content.lua")
58 tabs.credits = dofile(menupath .. DIR_DELIM .. "tab_credits.lua")
59 if menustyle == "simple" then
60 tabs.simple_main = dofile(menupath .. DIR_DELIM .. "tab_simple_main.lua")
62 tabs.local_game = dofile(menupath .. DIR_DELIM .. "tab_local.lua")
63 tabs.play_online = dofile(menupath .. DIR_DELIM .. "tab_online.lua")
66 --------------------------------------------------------------------------------
67 local function main_event_handler(tabview, event)
68 if event == "MenuQuit" then
74 --------------------------------------------------------------------------------
75 local function init_globals()
77 gamedata.worldindex = 0
79 if menustyle == "simple" then
80 local world_list = core.get_worlds()
83 local found_singleplayerworld = false
84 for i, world in ipairs(world_list) do
85 if world.name == "singleplayerworld" then
86 found_singleplayerworld = true
92 if not found_singleplayerworld then
93 core.create_world("singleplayerworld", 1)
95 world_list = core.get_worlds()
97 for i, world in ipairs(world_list) do
98 if world.name == "singleplayerworld" then
105 gamedata.worldindex = world_index
107 menudata.worldlist = filterlist.create(
110 -- Unique id comparison function
111 function(element, uid)
112 return element.name == uid
115 function(element, gameid)
116 return element.gameid == gameid
120 menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic)
121 menudata.worldlist:set_sortmode("alphabetic")
123 if not core.settings:get("menu_last_game") then
124 local default_game = core.settings:get("default_game") or "minetest"
125 core.settings:set("menu_last_game", default_game)
131 -- Create main tabview
132 local tv_main = tabview_create("maintab", {x = 12, y = 5.4}, {x = 0, y = 0})
134 if menustyle == "simple" then
135 tv_main:add(tabs.simple_main)
137 tv_main:set_autosave_tab(true)
138 tv_main:add(tabs.local_game)
139 tv_main:add(tabs.play_online)
142 tv_main:add(tabs.content)
143 tv_main:add(tabs.settings)
144 tv_main:add(tabs.credits)
146 tv_main:set_global_event_handler(main_event_handler)
147 tv_main:set_fixed_size(false)
149 if menustyle ~= "simple" then
150 tv_main:set_tab(core.settings:get("maintab_LAST"))
152 ui.set_default("maintab")
157 core.sound_play("main_menu", true)