@@ -129,23 +129,41 @@ function mm_texture.set_generic(identifier)
129129end
130130
131131---- ----------------------------------------------------------------------------
132- function mm_texture .set_game (identifier ,gamedetails )
132+ function mm_texture .set_game (identifier , gamedetails )
133133
134134 if gamedetails == nil then
135135 return false
136136 end
137137
138138 if mm_texture .texturepack ~= nil then
139139 local path = mm_texture .texturepack .. DIR_DELIM ..
140- gamedetails .id .. " _menu_" .. identifier .. " .png"
141- if core .set_background (identifier ,path ) then
140+ gamedetails .id .. " _menu_" .. identifier .. " .png"
141+ if core .set_background (identifier , path ) then
142142 return true
143143 end
144144 end
145145
146- local path = gamedetails .path .. DIR_DELIM .. " menu" ..
147- DIR_DELIM .. identifier .. " .png"
148- if core .set_background (identifier ,path ) then
146+ -- Find out how many randomized textures the subgame provides
147+ local n , filename
148+ local menu_files = core .get_dir_list (gamedetails .path .. DIR_DELIM .. " menu" , false )
149+ for i = 1 , # menu_files do
150+ local filename = identifier .. " ." .. i .. " .png"
151+ if table .indexof (menu_files , filename ) == - 1 then
152+ n = i - 1
153+ break
154+ end
155+ end
156+ -- Select random texture, 0 means standard texture
157+ n = math.random (0 , n )
158+ if n == 0 then
159+ filename = identifier .. " .png"
160+ else
161+ filename = identifier .. " ." .. n .. " .png"
162+ end
163+
164+ local path = gamedetails .path .. DIR_DELIM .. " menu" ..
165+ DIR_DELIM .. filename
166+ if core .set_background (identifier , path ) then
149167 return true
150168 end
151169
0 commit comments