Load dependencies and description from mod.conf
This commit is contained in:
parent
96afee3a52
commit
fc13f12584
|
@ -271,34 +271,13 @@ function modmgr.render_modlist(render_list)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function modmgr.get_dependencies(modfolder)
|
function modmgr.get_dependencies(path)
|
||||||
local toadd_hard = ""
|
if path == nil then
|
||||||
local toadd_soft = ""
|
return "", ""
|
||||||
if modfolder ~= nil then
|
|
||||||
local filename = modfolder ..
|
|
||||||
DIR_DELIM .. "depends.txt"
|
|
||||||
|
|
||||||
local hard_dependencies = {}
|
|
||||||
local soft_dependencies = {}
|
|
||||||
local dependencyfile = io.open(filename,"r")
|
|
||||||
if dependencyfile then
|
|
||||||
local dependency = dependencyfile:read("*l")
|
|
||||||
while dependency do
|
|
||||||
dependency = dependency:gsub("\r", "")
|
|
||||||
if string.sub(dependency, -1, -1) == "?" then
|
|
||||||
table.insert(soft_dependencies, string.sub(dependency, 1, -2))
|
|
||||||
else
|
|
||||||
table.insert(hard_dependencies, dependency)
|
|
||||||
end
|
|
||||||
dependency = dependencyfile:read()
|
|
||||||
end
|
|
||||||
dependencyfile:close()
|
|
||||||
end
|
|
||||||
toadd_hard = table.concat(hard_dependencies, ",")
|
|
||||||
toadd_soft = table.concat(soft_dependencies, ",")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return toadd_hard, toadd_soft
|
local info = core.get_mod_info(path)
|
||||||
|
return table.concat(info.depends, ","), table.concat(info.optional_depends, ",")
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
|
@ -40,12 +40,11 @@ local function get_formspec(tabview, name, tabdata)
|
||||||
end
|
end
|
||||||
|
|
||||||
if selected_mod ~= nil then
|
if selected_mod ~= nil then
|
||||||
local modscreenshot = nil
|
|
||||||
|
|
||||||
--check for screenshot beeing available
|
--check for screenshot beeing available
|
||||||
local screenshotfilename = selected_mod.path .. DIR_DELIM .. "screenshot.png"
|
local screenshotfilename = selected_mod.path .. DIR_DELIM .. "screenshot.png"
|
||||||
local error = nil
|
local screenshotfile, error = io.open(screenshotfilename,"r")
|
||||||
local screenshotfile,error = io.open(screenshotfilename,"r")
|
|
||||||
|
local modscreenshot
|
||||||
if error == nil then
|
if error == nil then
|
||||||
screenshotfile:close()
|
screenshotfile:close()
|
||||||
modscreenshot = screenshotfilename
|
modscreenshot = screenshotfilename
|
||||||
|
@ -55,33 +54,20 @@ local function get_formspec(tabview, name, tabdata)
|
||||||
modscreenshot = defaulttexturedir .. "no_screenshot.png"
|
modscreenshot = defaulttexturedir .. "no_screenshot.png"
|
||||||
end
|
end
|
||||||
|
|
||||||
retval = retval
|
|
||||||
.. "image[5.5,0;3,2;" .. core.formspec_escape(modscreenshot) .. "]"
|
|
||||||
.. "label[8.25,0.6;" .. selected_mod.name .. "]"
|
|
||||||
|
|
||||||
local descriptionlines = nil
|
|
||||||
error = nil
|
|
||||||
local descriptionfilename = selected_mod.path .. "description.txt"
|
|
||||||
local descriptionfile,error = io.open(descriptionfilename,"r")
|
|
||||||
if error == nil then
|
|
||||||
local descriptiontext = descriptionfile:read("*all")
|
|
||||||
|
|
||||||
descriptionlines = core.wrap_text(descriptiontext, 42, true)
|
|
||||||
descriptionfile:close()
|
|
||||||
else
|
|
||||||
descriptionlines = {}
|
|
||||||
descriptionlines[#descriptionlines + 1] = fgettext("No mod description available")
|
|
||||||
end
|
|
||||||
|
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"label[5.5,1.7;".. fgettext("Mod Information:") .. "]" ..
|
"image[5.5,0;3,2;" .. core.formspec_escape(modscreenshot) .. "]" ..
|
||||||
"textlist[5.5,2.2;6.2,2.4;description;"
|
"label[8.25,0.6;" .. selected_mod.name .. "]" ..
|
||||||
|
"label[5.5,1.7;".. fgettext("Mod Information:") .. "]" ..
|
||||||
|
"textlist[5.5,2.2;6.2,2.4;description;"
|
||||||
|
|
||||||
for i=1,#descriptionlines,1 do
|
|
||||||
|
local info = core.get_mod_info(selected_mod.path)
|
||||||
|
local desc = info.description or fgettext("No mod description available")
|
||||||
|
local descriptionlines = core.wrap_text(desc, 42, true)
|
||||||
|
for i = 1, #descriptionlines do
|
||||||
retval = retval .. core.formspec_escape(descriptionlines[i]) .. ","
|
retval = retval .. core.formspec_escape(descriptionlines[i]) .. ","
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if selected_mod.is_modpack then
|
if selected_mod.is_modpack then
|
||||||
retval = retval .. ";0]" ..
|
retval = retval .. ";0]" ..
|
||||||
"button[9.9,4.65;2,1;btn_mod_mgr_rename_modpack;" ..
|
"button[9.9,4.65;2,1;btn_mod_mgr_rename_modpack;" ..
|
||||||
|
@ -90,7 +76,8 @@ local function get_formspec(tabview, name, tabdata)
|
||||||
.. fgettext("Uninstall Selected Modpack") .. "]"
|
.. fgettext("Uninstall Selected Modpack") .. "]"
|
||||||
else
|
else
|
||||||
--show dependencies
|
--show dependencies
|
||||||
local toadd_hard, toadd_soft = modmgr.get_dependencies(selected_mod.path)
|
local toadd_hard = table.concat(info.depends, ",")
|
||||||
|
local toadd_soft = table.concat(info.optional_depends, ",")
|
||||||
if toadd_hard == "" and toadd_soft == "" then
|
if toadd_hard == "" and toadd_soft == "" then
|
||||||
retval = retval .. "," .. fgettext("No dependencies.")
|
retval = retval .. "," .. fgettext("No dependencies.")
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue