2 --Copyright (C) 2013 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.
20 --------------------------------------------------------------------------------
21 function menubar.handle_buttons(fields)
22 for i=1,#menubar.buttons,1 do
23 if fields[menubar.buttons[i].btn_name] ~= nil then
24 menu.last_game = menubar.buttons[i].index
25 engine.setting_set("main_menu_last_game_idx",menu.last_game)
26 menu.update_gametype()
31 --------------------------------------------------------------------------------
32 function menubar.refresh()
34 menubar.formspec = "box[-0.3,5.625;12.4,1.2;#000000]" ..
35 "box[-0.3,5.6;12.4,0.05;#FFFFFF]"
38 local button_base = -0.08
40 local maxbuttons = #gamemgr.games
42 if maxbuttons > 11 then
46 for i=1,maxbuttons,1 do
48 local btn_name = "menubar_btn_" .. gamemgr.games[i].id
49 local buttonpos = button_base + (i-1) * 1.1
50 if gamemgr.games[i].menuicon_path ~= nil and
51 gamemgr.games[i].menuicon_path ~= "" then
53 menubar.formspec = menubar.formspec ..
54 "image_button[" .. buttonpos .. ",5.72;1.165,1.175;" ..
55 engine.formspec_escape(gamemgr.games[i].menuicon_path) .. ";" ..
56 btn_name .. ";;true;false]"
59 local part1 = gamemgr.games[i].id:sub(1,5)
60 local part2 = gamemgr.games[i].id:sub(6,10)
61 local part3 = gamemgr.games[i].id:sub(11)
63 local text = part1 .. "\n" .. part2
66 text = text .. "\n" .. part3
68 menubar.formspec = menubar.formspec ..
69 "image_button[" .. buttonpos .. ",5.72;1.165,1.175;;" ..btn_name ..
70 ";" .. text .. ";true;true]"
78 table.insert(menubar.buttons,toadd)