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 = "#0000DD"
20 mt_color_green = "#00DD00"
21 mt_color_dark_green = "#003300"
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 defaulttexturedir = core.get_texturepath_share() .. DIR_DELIM .. "base" ..
28 DIR_DELIM .. "pack" .. DIR_DELIM
30 dofile(basepath .. DIR_DELIM .. "common" .. DIR_DELIM .. "async_event.lua")
31 dofile(basepath .. DIR_DELIM .. "common" .. DIR_DELIM .. "filterlist.lua")
32 dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "buttonbar.lua")
33 dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "dialog.lua")
34 dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "tabview.lua")
35 dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "ui.lua")
36 dofile(menupath .. DIR_DELIM .. "common.lua")
37 dofile(menupath .. DIR_DELIM .. "gamemgr.lua")
38 dofile(menupath .. DIR_DELIM .. "modmgr.lua")
39 dofile(menupath .. DIR_DELIM .. "store.lua")
40 dofile(menupath .. DIR_DELIM .. "textures.lua")
42 dofile(menupath .. DIR_DELIM .. "dlg_config_world.lua")
43 dofile(menupath .. DIR_DELIM .. "dlg_settings_advanced.lua")
44 if PLATFORM ~= "Android" then
45 dofile(menupath .. DIR_DELIM .. "dlg_create_world.lua")
46 dofile(menupath .. DIR_DELIM .. "dlg_delete_mod.lua")
47 dofile(menupath .. DIR_DELIM .. "dlg_delete_world.lua")
48 dofile(menupath .. DIR_DELIM .. "dlg_rename_modpack.lua")
53 tabs.settings = dofile(menupath .. DIR_DELIM .. "tab_settings.lua")
54 tabs.mods = dofile(menupath .. DIR_DELIM .. "tab_mods.lua")
55 tabs.credits = dofile(menupath .. DIR_DELIM .. "tab_credits.lua")
56 if PLATFORM == "Android" then
57 tabs.simple_main = dofile(menupath .. DIR_DELIM .. "tab_simple_main.lua")
59 tabs.singleplayer = dofile(menupath .. DIR_DELIM .. "tab_singleplayer.lua")
60 tabs.multiplayer = dofile(menupath .. DIR_DELIM .. "tab_multiplayer.lua")
61 tabs.server = dofile(menupath .. DIR_DELIM .. "tab_server.lua")
62 tabs.texturepacks = dofile(menupath .. DIR_DELIM .. "tab_texturepacks.lua")
65 --------------------------------------------------------------------------------
66 local function main_event_handler(tabview, event)
67 if event == "MenuQuit" then
73 --------------------------------------------------------------------------------
74 local function init_globals()
76 gamedata.worldindex = 0
78 if PLATFORM == "Android" then
79 local world_list = core.get_worlds()
80 local world_index = table.indexof(world_list, "singleplayerworld")
82 if world_index == -1 then
83 core.create_world("singleplayerworld", 1)
85 world_list = core.get_worlds()
86 world_index = table.indexof(world_list, "singleplayerworld")
89 gamedata.worldindex = world_index
91 menudata.worldlist = filterlist.create(
94 -- Unique id comparison function
95 function(element, uid)
96 return element.name == uid
99 function(element, gameid)
100 return element.gameid == gameid
104 menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic)
105 menudata.worldlist:set_sortmode("alphabetic")
107 if not core.setting_get("menu_last_game") then
108 local default_game = core.setting_get("default_game") or "minetest"
109 core.setting_set("menu_last_game", default_game)
115 -- Create main tabview
116 local tv_main = tabview_create("maintab", {x = 12, y = 5.2}, {x = 0, y = 0})
118 if PLATFORM == "Android" then
119 tv_main:add(tabs.simple_main)
120 tv_main:add(tabs.settings)
122 tv_main:set_autosave_tab(true)
123 tv_main:add(tabs.singleplayer)
124 tv_main:add(tabs.multiplayer)
125 tv_main:add(tabs.server)
126 tv_main:add(tabs.settings)
127 tv_main:add(tabs.texturepacks)
130 tv_main:add(tabs.mods)
131 tv_main:add(tabs.credits)
133 tv_main:set_global_event_handler(main_event_handler)
134 tv_main:set_fixed_size(false)
136 if PLATFORM ~= "Android" then
137 tv_main:set_tab(core.setting_get("maintab_LAST"))
139 ui.set_default("maintab")
142 -- Create modstore ui
143 if PLATFORM == "Android" then
144 modstore.init({x = 12, y = 6}, 3, 2)
146 modstore.init({x = 12, y = 8}, 4, 3)
151 core.sound_play("main_menu", true)