Skip to content

Commit 8ff209c

Browse files
ZughyZughy
and
Zughy
authoredJan 21, 2021
Load system-wide texture packs too (#10791)
Co-authored-by: Zughy <4279489-marco_a@users.noreply.gitlab.com>
1 parent 45ccfe2 commit 8ff209c

File tree

1 file changed

+34
-25
lines changed

1 file changed

+34
-25
lines changed
 

‎builtin/mainmenu/pkgmgr.lua

+34-25
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,34 @@ local function cleanup_path(temppath)
7272
return temppath
7373
end
7474

75+
local function load_texture_packs(txtpath, retval)
76+
local list = core.get_dir_list(txtpath, true)
77+
local current_texture_path = core.settings:get("texture_path")
78+
79+
for _, item in ipairs(list) do
80+
if item ~= "base" then
81+
local name = item
82+
83+
local path = txtpath .. DIR_DELIM .. item .. DIR_DELIM
84+
if path == current_texture_path then
85+
name = fgettext("$1 (Enabled)", name)
86+
end
87+
88+
local conf = Settings(path .. "texture_pack.conf")
89+
90+
retval[#retval + 1] = {
91+
name = item,
92+
author = conf:get("author"),
93+
release = tonumber(conf:get("release") or "0"),
94+
list_name = name,
95+
type = "txp",
96+
path = path,
97+
enabled = path == current_texture_path,
98+
}
99+
end
100+
end
101+
end
102+
75103
function get_mods(path,retval,modpack)
76104
local mods = core.get_dir_list(path, true)
77105

@@ -112,7 +140,7 @@ function get_mods(path,retval,modpack)
112140
toadd.type = "mod"
113141

114142
-- Check modpack.txt
115-
-- Note: modpack.conf is already checked above
143+
-- Note: modpack.conf is already checked above
116144
local modpackfile = io.open(prefix .. DIR_DELIM .. "modpack.txt")
117145
if modpackfile then
118146
modpackfile:close()
@@ -136,32 +164,13 @@ pkgmgr = {}
136164

137165
function pkgmgr.get_texture_packs()
138166
local txtpath = core.get_texturepath()
139-
local list = core.get_dir_list(txtpath, true)
167+
local txtpath_system = core.get_texturepath_share()
140168
local retval = {}
141169

142-
local current_texture_path = core.settings:get("texture_path")
143-
144-
for _, item in ipairs(list) do
145-
if item ~= "base" then
146-
local name = item
147-
148-
local path = txtpath .. DIR_DELIM .. item .. DIR_DELIM
149-
if path == current_texture_path then
150-
name = fgettext("$1 (Enabled)", name)
151-
end
152-
153-
local conf = Settings(path .. "texture_pack.conf")
154-
155-
retval[#retval + 1] = {
156-
name = item,
157-
author = conf:get("author"),
158-
release = tonumber(conf:get("release") or "0"),
159-
list_name = name,
160-
type = "txp",
161-
path = path,
162-
enabled = path == current_texture_path,
163-
}
164-
end
170+
load_texture_packs(txtpath, retval)
171+
-- on portable versions these two paths coincide. It avoids loading the path twice
172+
if txtpath ~= txtpath_system then
173+
load_texture_packs(txtpath_system, retval)
165174
end
166175

167176
table.sort(retval, function(a, b)

0 commit comments

Comments
 (0)