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_lightblue
= "#99CCFF"
21 mt_color_green
= "#72FF63"
22 mt_color_dark_green
= "#25C191"
23 mt_color_orange
= "#FF8800"
24 mt_color_red
= "#FF3300"
26 local menupath
= core
.get_mainmenu_path()
27 local basepath
= core
.get_builtin_path()
28 defaulttexturedir
= core
.get_texturepath_share() .. DIR_DELIM
.. "base" ..
29 DIR_DELIM
.. "pack" .. DIR_DELIM
31 dofile(basepath
.. "common" .. DIR_DELIM
.. "filterlist.lua")
32 dofile(basepath
.. "fstk" .. DIR_DELIM
.. "buttonbar.lua")
33 dofile(basepath
.. "fstk" .. DIR_DELIM
.. "dialog.lua")
34 dofile(basepath
.. "fstk" .. DIR_DELIM
.. "tabview.lua")
35 dofile(basepath
.. "fstk" .. DIR_DELIM
.. "ui.lua")
36 dofile(menupath
.. DIR_DELIM
.. "async_event.lua")
37 dofile(menupath
.. DIR_DELIM
.. "common.lua")
38 dofile(menupath
.. DIR_DELIM
.. "serverlistmgr.lua")
39 dofile(menupath
.. DIR_DELIM
.. "game_theme.lua")
40 dofile(menupath
.. DIR_DELIM
.. "content" .. DIR_DELIM
.. "init.lua")
42 dofile(menupath
.. DIR_DELIM
.. "dlg_config_world.lua")
43 dofile(menupath
.. DIR_DELIM
.. "settings" .. DIR_DELIM
.. "init.lua")
44 dofile(menupath
.. DIR_DELIM
.. "dlg_create_world.lua")
45 dofile(menupath
.. DIR_DELIM
.. "dlg_delete_content.lua")
46 dofile(menupath
.. DIR_DELIM
.. "dlg_delete_world.lua")
47 dofile(menupath
.. DIR_DELIM
.. "dlg_register.lua")
48 dofile(menupath
.. DIR_DELIM
.. "dlg_rename_modpack.lua")
49 dofile(menupath
.. DIR_DELIM
.. "dlg_version_info.lua")
50 dofile(menupath
.. DIR_DELIM
.. "dlg_reinstall_mtg.lua")
53 content
= dofile(menupath
.. DIR_DELIM
.. "tab_content.lua"),
54 about
= dofile(menupath
.. DIR_DELIM
.. "tab_about.lua"),
55 local_game
= dofile(menupath
.. DIR_DELIM
.. "tab_local.lua"),
56 play_online
= dofile(menupath
.. DIR_DELIM
.. "tab_online.lua")
59 --------------------------------------------------------------------------------
60 local function main_event_handler(tabview
, event
)
61 if event
== "MenuQuit" then
67 --------------------------------------------------------------------------------
68 local function init_globals()
70 gamedata
.worldindex
= 0
72 menudata
.worldlist
= filterlist
.create(
75 -- Unique id comparison function
76 function(element
, uid
)
77 return element
.name
== uid
80 function(element
, gameid
)
81 return element
.gameid
== gameid
85 menudata
.worldlist
:add_sort_mechanism("alphabetic", sort_worlds_alphabetic
)
86 menudata
.worldlist
:set_sortmode("alphabetic")
89 mm_game_theme
.set_engine() -- This is just a fallback.
91 -- Create main tabview
92 local tv_main
= tabview_create("maintab", {x
= 15.5, y
= 7.1}, {x
= 0, y
= 0})
94 tv_main
:set_autosave_tab(true)
95 tv_main
:add(tabs
.local_game
)
96 tv_main
:add(tabs
.play_online
)
97 tv_main
:add(tabs
.content
)
98 tv_main
:add(tabs
.about
)
100 tv_main
:set_global_event_handler(main_event_handler
)
101 tv_main
:set_fixed_size(false)
103 local last_tab
= core
.settings
:get("maintab_LAST")
104 if last_tab
and tv_main
.current_tab
~= last_tab
then
105 tv_main
:set_tab(last_tab
)
108 tv_main
:set_end_button({
109 icon
= defaulttexturedir
.. "settings_btn.png",
110 label
= fgettext("Settings"),
111 name
= "open_settings",
112 on_click
= function(tabview
)
113 local dlg
= create_settings_dlg()
114 dlg
:set_parent(tabview
)
121 ui
.set_default("maintab")
125 check_reinstall_mtg()