Skip to content

Commit 6dd22dd

Browse files
authored
Add support for JPEG mod screenshots (#16911)
1 parent 1270d68 commit 6dd22dd

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

builtin/mainmenu/tab_content.lua

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,26 @@ local function get_formspec(tabview, name, tabdata)
8585
end
8686

8787
if selected_pkg then
88-
-- Check for screenshot being available
89-
local screenshotfilename = selected_pkg.path .. DIR_DELIM .. "screenshot.png"
90-
local screenshotfile, error = io.open(screenshotfilename, "r")
88+
local valid_screenshots = {
89+
-- See also contentdb/app/tasks/importtasks.py, def import_repo_screenshot
90+
selected_pkg.path .. DIR_DELIM .. "screenshot.png",
91+
selected_pkg.path .. DIR_DELIM .. "screenshot.jpg",
92+
selected_pkg.path .. DIR_DELIM .. "screenshot.jpeg",
93+
}
9194

95+
-- Check for screenshot being available
9296
local modscreenshot
93-
if not error then
94-
screenshotfile:close()
95-
modscreenshot = screenshotfilename
96-
else
97+
for _, screenshotfilename in ipairs(valid_screenshots) do
98+
local screenshotfile, err = io.open(screenshotfilename, "r")
99+
if not err then
100+
screenshotfile:close()
101+
modscreenshot = screenshotfilename
102+
break
103+
end
104+
end
105+
106+
-- Fallback to no_screenshot if no screenshot is avaliable
107+
if not modscreenshot then
97108
modscreenshot = defaulttexturedir .. "no_screenshot.png"
98109
end
99110

0 commit comments

Comments
 (0)