mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-10 19:32:10 +00:00
Fix #16337
This commit is contained in:
parent
b1cb5fcb9f
commit
fb77f37232
1 changed files with 50 additions and 39 deletions
|
@ -2,7 +2,6 @@
|
||||||
-- Copyright (C) 2013 sapier
|
-- Copyright (C) 2013 sapier
|
||||||
-- SPDX-License-Identifier: LGPL-2.1-or-later
|
-- SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
|
|
||||||
mm_game_theme = {}
|
mm_game_theme = {}
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
@ -83,19 +82,27 @@ end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function mm_game_theme.clear_single(identifier)
|
function mm_game_theme.clear_single(identifier)
|
||||||
core.set_background(identifier,"")
|
core.set_background(identifier, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
local valid_image_extensions = {
|
||||||
|
".png",
|
||||||
|
".jpg",
|
||||||
|
".jpeg",
|
||||||
|
}
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function mm_game_theme.set_engine_single(identifier)
|
function mm_game_theme.set_engine_single(identifier)
|
||||||
--try texture pack first
|
--try texture pack first
|
||||||
if mm_game_theme.texturepack ~= nil then
|
if mm_game_theme.texturepack ~= nil then
|
||||||
local path = mm_game_theme.texturepack .. DIR_DELIM .."menu_" ..
|
for _, extension in pairs(valid_image_extensions) do
|
||||||
identifier .. ".png"
|
local path = mm_game_theme.texturepack .. DIR_DELIM .. "menu_" .. identifier .. extension
|
||||||
if core.set_background(identifier,path) then
|
if core.set_background(identifier, path) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local path = defaulttexturedir .. DIR_DELIM .. "menu_" .. identifier .. ".png"
|
local path = defaulttexturedir .. DIR_DELIM .. "menu_" .. identifier .. ".png"
|
||||||
if core.set_background(identifier, path) then
|
if core.set_background(identifier, path) then
|
||||||
|
@ -106,12 +113,16 @@ function mm_game_theme.set_engine_single(identifier)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
function mm_game_theme.set_game_single(identifier, gamedetails)
|
function mm_game_theme.set_game_single(identifier, gamedetails)
|
||||||
|
local extensions_randomised = table.copy(valid_image_extensions)
|
||||||
|
table.shuffle(valid_image_extensions)
|
||||||
|
for _, extension in pairs(extensions_randomised) do
|
||||||
assert(gamedetails ~= nil)
|
assert(gamedetails ~= nil)
|
||||||
|
|
||||||
if mm_game_theme.texturepack ~= nil then
|
if mm_game_theme.texturepack ~= nil then
|
||||||
local path = mm_game_theme.texturepack .. DIR_DELIM ..
|
local path = mm_game_theme.texturepack .. DIR_DELIM .. gamedetails.id .. "_menu_" .. identifier .. extension
|
||||||
gamedetails.id .. "_menu_" .. identifier .. ".png"
|
|
||||||
if core.set_background(identifier, path) then
|
if core.set_background(identifier, path) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -122,7 +133,7 @@ function mm_game_theme.set_game_single(identifier, gamedetails)
|
||||||
local filename
|
local filename
|
||||||
local menu_files = core.get_dir_list(gamedetails.path .. DIR_DELIM .. "menu", false)
|
local menu_files = core.get_dir_list(gamedetails.path .. DIR_DELIM .. "menu", false)
|
||||||
for i = 1, #menu_files do
|
for i = 1, #menu_files do
|
||||||
filename = identifier .. "." .. i .. ".png"
|
filename = identifier .. "." .. i .. extension
|
||||||
if table.indexof(menu_files, filename) == -1 then
|
if table.indexof(menu_files, filename) == -1 then
|
||||||
n = i - 1
|
n = i - 1
|
||||||
break
|
break
|
||||||
|
@ -131,24 +142,24 @@ function mm_game_theme.set_game_single(identifier, gamedetails)
|
||||||
-- Select random texture, 0 means standard texture
|
-- Select random texture, 0 means standard texture
|
||||||
n = math.random(0, n)
|
n = math.random(0, n)
|
||||||
if n == 0 then
|
if n == 0 then
|
||||||
filename = identifier .. ".png"
|
filename = identifier .. extension
|
||||||
else
|
else
|
||||||
filename = identifier .. "." .. n .. ".png"
|
filename = identifier .. "." .. n .. extension
|
||||||
end
|
end
|
||||||
|
|
||||||
local path = gamedetails.path .. DIR_DELIM .. "menu" ..
|
local path = gamedetails.path .. DIR_DELIM .. "menu" .. DIR_DELIM .. filename
|
||||||
DIR_DELIM .. filename
|
|
||||||
if core.set_background(identifier, path) then
|
if core.set_background(identifier, path) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function mm_game_theme.set_dirt_bg()
|
function mm_game_theme.set_dirt_bg()
|
||||||
if mm_game_theme.texturepack ~= nil then
|
if mm_game_theme.texturepack ~= nil then
|
||||||
local path = mm_game_theme.texturepack .. DIR_DELIM .."default_dirt.png"
|
local path = mm_game_theme.texturepack .. DIR_DELIM .. "default_dirt.png"
|
||||||
if core.set_background("background", path, true, 128) then
|
if core.set_background("background", path, true, 128) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue