]> git.lizzy.rs Git - dragonfireclient.git/blob - builtin/mainmenu/gamemgr.lua
Add new leaves style - simple (glasslike drawtype)
[dragonfireclient.git] / builtin / mainmenu / gamemgr.lua
1 --Minetest
2 --Copyright (C) 2013 sapier
3 --
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.
8 --
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.
13 --
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.
17
18 gamemgr = {}
19
20 --------------------------------------------------------------------------------
21 function gamemgr.find_by_gameid(gameid)
22         for i=1,#gamemgr.games,1 do
23                 if gamemgr.games[i].id == gameid then
24                         return gamemgr.games[i], i
25                 end
26         end
27         return nil, nil
28 end
29
30 --------------------------------------------------------------------------------
31 function gamemgr.get_game_mods(gamespec, retval)
32         if gamespec ~= nil and
33                 gamespec.gamemods_path ~= nil and
34                 gamespec.gamemods_path ~= "" then
35                 get_mods(gamespec.gamemods_path, retval)
36         end
37 end
38
39 --------------------------------------------------------------------------------
40 function gamemgr.get_game_modlist(gamespec)
41         local retval = ""
42         local game_mods = {}
43         gamemgr.get_game_mods(gamespec, game_mods)
44         for i=1,#game_mods,1 do
45                 if retval ~= "" then
46                         retval = retval..","
47                 end
48                 retval = retval .. game_mods[i].name
49         end
50         return retval
51 end
52
53 --------------------------------------------------------------------------------
54 function gamemgr.get_game(index)
55         if index > 0 and index <= #gamemgr.games then
56                 return gamemgr.games[index]
57         end
58
59         return nil
60 end
61
62 --------------------------------------------------------------------------------
63 function gamemgr.update_gamelist()
64         gamemgr.games = core.get_games()
65 end
66
67 --------------------------------------------------------------------------------
68 function gamemgr.gamelist()
69         local retval = ""
70         if #gamemgr.games > 0 then
71                 retval = retval .. gamemgr.games[1].name
72
73                 for i=2,#gamemgr.games,1 do
74                         retval = retval .. "," .. gamemgr.games[i].name
75                 end
76         end
77         return retval
78 end
79
80 --------------------------------------------------------------------------------
81 -- read initial data
82 --------------------------------------------------------------------------------
83 gamemgr.update_gamelist()