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()
33 menubar.formspec = "box[-0.3,5.625;12.4,1.3;000000]" ..
34 "box[-0.3,5.6;12.4,0.05;FFFFFF]"
37 local button_base = -0.25
39 local maxbuttons = #gamemgr.games
41 if maxbuttons > 10 then
45 for i=1,maxbuttons,1 do
47 local btn_name = "menubar_btn_" .. gamemgr.games[i].id
48 local buttonpos = button_base + (i-1) * 1.245
49 if gamemgr.games[i].menuicon_path ~= nil and
50 gamemgr.games[i].menuicon_path ~= "" then
52 menubar.formspec = menubar.formspec ..
53 "image_button[" .. buttonpos .. ",5.7;1.3,1.3;" ..
54 gamemgr.games[i].menuicon_path .. ";" .. btn_name .. ";;true;false]"
57 local part1 = gamemgr.games[i].id:sub(1,5)
58 local part2 = gamemgr.games[i].id:sub(6,10)
59 local part3 = gamemgr.games[i].id:sub(11)
61 local text = part1 .. "\n" .. part2
64 text = text .. "\n" .. part3
66 menubar.formspec = menubar.formspec ..
67 "image_button[" .. buttonpos .. ",5.7;1.3,1.3;;" ..btn_name ..
68 ";" .. text .. ";true;true]"
76 table.insert(menubar.buttons,toadd)