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.
21 --------------------------------------------------------------------------------
22 function mm_texture.init()
23 mm_texture.defaulttexturedir = engine.get_gamepath() .. DIR_DELIM .. ".." ..
24 DIR_DELIM .. "textures" .. DIR_DELIM .. "base" ..
25 DIR_DELIM .. "pack" .. DIR_DELIM
26 mm_texture.basetexturedir = mm_texture.defaulttexturedir
28 mm_texture.texturepack = engine.setting_get("texture_path")
30 mm_texture.gameid = nil
33 --------------------------------------------------------------------------------
34 function mm_texture.update(tab,gamedetails)
35 if tab ~= "singleplayer" then
40 if gamedetails == nil then
44 mm_texture.update_game(gamedetails)
47 --------------------------------------------------------------------------------
48 function mm_texture.reset()
49 mm_texture.gameid = nil
51 local have_overlay = mm_texture.set_generic("overlay")
53 if not have_overlay then
54 have_bg = mm_texture.set_generic("background")
57 mm_texture.clear("header")
58 mm_texture.clear("footer")
59 engine.set_clouds(false)
61 mm_texture.set_generic("footer")
62 mm_texture.set_generic("header")
65 engine.setting_getbool("enable_clouds") then
66 engine.set_clouds(true)
70 --------------------------------------------------------------------------------
71 function mm_texture.update_game(gamedetails)
72 if mm_texture.gameid == gamedetails.id then
77 local have_overlay = mm_texture.set_game("overlay",gamedetails)
79 if not have_overlay then
80 have_bg = mm_texture.set_game("background",gamedetails)
83 mm_texture.clear("header")
84 mm_texture.clear("footer")
85 engine.set_clouds(false)
88 engine.setting_getbool("enable_clouds") then
89 engine.set_clouds(true)
92 mm_texture.set_game("footer",gamedetails)
93 mm_texture.set_game("header",gamedetails)
95 mm_texture.gameid = gamedetails.id
98 --------------------------------------------------------------------------------
99 function mm_texture.clear(identifier)
100 engine.set_background(identifier,"")
103 --------------------------------------------------------------------------------
104 function mm_texture.set_generic(identifier)
105 --try texture pack first
106 if mm_texture.texturepack ~= nil then
107 local path = mm_texture.texturepack .. DIR_DELIM .."menu_" ..
109 if engine.set_background(identifier,path) then
114 if mm_texture.defaulttexturedir ~= nil then
115 local path = mm_texture.defaulttexturedir .. DIR_DELIM .."menu_" ..
117 if engine.set_background(identifier,path) then
125 --------------------------------------------------------------------------------
126 function mm_texture.set_game(identifier,gamedetails)
128 if gamedetails == nil then
132 if mm_texture.texturepack ~= nil then
133 local path = mm_texture.basetexturedir ..
134 gamedetails.id .. "_menu_" .. identifier .. ".png"
136 if engine.set_background(identifier,path) then
141 local path = gamedetails.path .. DIR_DELIM .."menu" ..
142 DIR_DELIM .. identifier .. ".png"
143 if engine.set_background(identifier,path) then