diff options
Diffstat (limited to 'builtin/mainmenu/pkgmgr.lua')
-rw-r--r-- | builtin/mainmenu/pkgmgr.lua | 65 |
1 files changed, 37 insertions, 28 deletions
diff --git a/builtin/mainmenu/pkgmgr.lua b/builtin/mainmenu/pkgmgr.lua index 5b8807310..19127d8d3 100644 --- a/builtin/mainmenu/pkgmgr.lua +++ b/builtin/mainmenu/pkgmgr.lua @@ -72,6 +72,34 @@ local function cleanup_path(temppath) return temppath end +local function load_texture_packs(txtpath, retval) + local list = core.get_dir_list(txtpath, true) + local current_texture_path = core.settings:get("texture_path") + + for _, item in ipairs(list) do + if item ~= "base" then + local name = item + + local path = txtpath .. DIR_DELIM .. item .. DIR_DELIM + if path == current_texture_path then + name = fgettext("$1 (Enabled)", name) + end + + local conf = Settings(path .. "texture_pack.conf") + + retval[#retval + 1] = { + name = item, + author = conf:get("author"), + release = tonumber(conf:get("release") or "0"), + list_name = name, + type = "txp", + path = path, + enabled = path == current_texture_path, + } + end + end +end + function get_mods(path,retval,modpack) local mods = core.get_dir_list(path, true) @@ -112,7 +140,7 @@ function get_mods(path,retval,modpack) toadd.type = "mod" -- Check modpack.txt - -- Note: modpack.conf is already checked above + -- Note: modpack.conf is already checked above local modpackfile = io.open(prefix .. DIR_DELIM .. "modpack.txt") if modpackfile then modpackfile:close() @@ -136,32 +164,13 @@ pkgmgr = {} function pkgmgr.get_texture_packs() local txtpath = core.get_texturepath() - local list = core.get_dir_list(txtpath, true) + local txtpath_system = core.get_texturepath_share() local retval = {} - local current_texture_path = core.settings:get("texture_path") - - for _, item in ipairs(list) do - if item ~= "base" then - local name = item - - local path = txtpath .. DIR_DELIM .. item .. DIR_DELIM - if path == current_texture_path then - name = fgettext("$1 (Enabled)", name) - end - - local conf = Settings(path .. "texture_pack.conf") - - retval[#retval + 1] = { - name = item, - author = conf:get("author"), - release = tonumber(conf:get("release") or "0"), - list_name = name, - type = "txp", - path = path, - enabled = path == current_texture_path, - } - end + load_texture_packs(txtpath, retval) + -- on portable versions these two paths coincide. It avoids loading the path twice + if txtpath ~= txtpath_system then + load_texture_packs(txtpath_system, retval) end table.sort(retval, function(a, b) @@ -450,7 +459,7 @@ function pkgmgr.enable_mod(this, toset) if not toset then -- Mod(s) were disabled, so no dependencies need to be enabled table.sort(toggled_mods) - minetest.log("info", "Following mods were disabled: " .. + core.log("info", "Following mods were disabled: " .. table.concat(toggled_mods, ", ")) return end @@ -487,7 +496,7 @@ function pkgmgr.enable_mod(this, toset) enabled_mods[name] = true local mod_to_enable = list[mod_ids[name]] if not mod_to_enable then - minetest.log("warning", "Mod dependency \"" .. name .. + core.log("warning", "Mod dependency \"" .. name .. "\" not found!") else if mod_to_enable.enabled == false then @@ -508,7 +517,7 @@ function pkgmgr.enable_mod(this, toset) -- Log the list of enabled mods table.sort(toggled_mods) - minetest.log("info", "Following mods were enabled: " .. + core.log("info", "Following mods were enabled: " .. table.concat(toggled_mods, ", ")) end |