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 = core.get_texturepath() .. DIR_DELIM .. "base" ..
24 DIR_DELIM .. "pack" .. DIR_DELIM
25 mm_texture.basetexturedir = mm_texture.defaulttexturedir
27 mm_texture.texturepack = core.setting_get("texture_path")
29 mm_texture.gameid = nil
32 --------------------------------------------------------------------------------
33 function mm_texture.update(tab,gamedetails)
34 if tab ~= "singleplayer" then
39 if gamedetails == nil then
43 mm_texture.update_game(gamedetails)
46 --------------------------------------------------------------------------------
47 function mm_texture.reset()
48 mm_texture.gameid = nil
50 local have_overlay = mm_texture.set_generic("overlay")
52 if not have_overlay then
53 have_bg = mm_texture.set_generic("background")
56 mm_texture.clear("header")
57 mm_texture.clear("footer")
58 core.set_clouds(false)
60 mm_texture.set_generic("footer")
61 mm_texture.set_generic("header")
64 core.setting_getbool("menu_clouds") then
69 --------------------------------------------------------------------------------
70 function mm_texture.update_game(gamedetails)
71 if mm_texture.gameid == gamedetails.id then
76 local have_overlay = mm_texture.set_game("overlay",gamedetails)
78 if not have_overlay then
79 have_bg = mm_texture.set_game("background",gamedetails)
82 mm_texture.clear("header")
83 mm_texture.clear("footer")
84 core.set_clouds(false)
87 core.setting_getbool("menu_clouds") then
91 mm_texture.set_game("footer",gamedetails)
92 mm_texture.set_game("header",gamedetails)
94 mm_texture.gameid = gamedetails.id
97 --------------------------------------------------------------------------------
98 function mm_texture.clear(identifier)
99 core.set_background(identifier,"")
102 --------------------------------------------------------------------------------
103 function mm_texture.set_generic(identifier)
104 --try texture pack first
105 if mm_texture.texturepack ~= nil then
106 local path = mm_texture.texturepack .. DIR_DELIM .."menu_" ..
108 if core.set_background(identifier,path) then
113 if mm_texture.defaulttexturedir ~= nil then
114 local path = mm_texture.defaulttexturedir .. DIR_DELIM .."menu_" ..
116 if core.set_background(identifier,path) then
124 --------------------------------------------------------------------------------
125 function mm_texture.set_game(identifier,gamedetails)
127 if gamedetails == nil then
131 if mm_texture.texturepack ~= nil then
132 local path = mm_texture.texturepack .. DIR_DELIM ..
133 gamedetails.id .. "_menu_" .. identifier .. ".png"
134 if core.set_background(identifier,path) then
139 local path = gamedetails.path .. DIR_DELIM .."menu" ..
140 DIR_DELIM .. identifier .. ".png"
141 if core.set_background(identifier,path) then