Menu content tab: Fix clipped description and missing depends (#7703)

This commit is contained in:
SmallJoker 2018-09-07 03:46:58 +02:00 committed by Paramat
parent a4f41e7bfc
commit 6ed9c6fb3a
1 changed files with 21 additions and 24 deletions

View File

@ -81,50 +81,45 @@ local function get_formspec(tabview, name, tabdata)
modscreenshot = defaulttexturedir .. "no_screenshot.png" modscreenshot = defaulttexturedir .. "no_screenshot.png"
end end
local info = core.get_content_info(selected_pkg.path)
local desc = fgettext("No package description available")
if info.description and info.description:trim() ~= "" then
desc = info.description
end
retval = retval .. retval = retval ..
"image[5.5,0;3,2;" .. core.formspec_escape(modscreenshot) .. "]" .. "image[5.5,0;3,2;" .. core.formspec_escape(modscreenshot) .. "]" ..
"label[8.25,0.6;" .. core.formspec_escape(selected_pkg.name) .. "]" .. "label[8.25,0.6;" .. core.formspec_escape(selected_pkg.name) .. "]" ..
"label[5.5,1.7;".. fgettext("Information:") .. "]" .. "box[5.5,2.2;6.15,2.35;#000]"
"textlist[5.5,2.2;6.2,2.4;description;"
local info = core.get_content_info(selected_pkg.path)
local desc = info.description or fgettext("No package description available")
local descriptionlines = core.wrap_text(desc, 42, true)
for i = 1, #descriptionlines do
retval = retval .. core.formspec_escape(descriptionlines[i]) .. ","
end
if selected_pkg.type == "mod" then if selected_pkg.type == "mod" then
if selected_pkg.is_modpack then if selected_pkg.is_modpack then
retval = retval .. ";0]" .. retval = retval ..
"button[8.65,4.65;3.25,1;btn_mod_mgr_rename_modpack;" .. "button[8.65,4.65;3.25,1;btn_mod_mgr_rename_modpack;" ..
fgettext("Rename") .. "]" fgettext("Rename") .. "]"
else else
--show dependencies --show dependencies
local toadd_hard = table.concat(info.depends or {}, ",") desc = desc .. "\n\n"
local toadd_soft = table.concat(info.optional_depends or {}, ",") local toadd_hard = table.concat(info.depends or {}, "\n")
local toadd_soft = table.concat(info.optional_depends or {}, "\n")
if toadd_hard == "" and toadd_soft == "" then if toadd_hard == "" and toadd_soft == "" then
retval = retval .. "," .. fgettext("No dependencies.") desc = desc .. fgettext("No dependencies.")
else else
if toadd_hard ~= "" then if toadd_hard ~= "" then
retval = retval .. "," .. fgettext("Dependencies:") .. "," desc = desc ..fgettext("Dependencies:") ..
retval = retval .. toadd_hard "\n" .. toadd_hard
end end
if toadd_soft ~= "" then if toadd_soft ~= "" then
if toadd_hard ~= "" then if toadd_hard ~= "" then
retval = retval .. "," desc = desc .. "\n\n"
end end
retval = retval .. "," .. fgettext("Optional dependencies:") .. "," desc = desc .. fgettext("Optional dependencies:") ..
retval = retval .. toadd_soft "\n" .. toadd_soft
end end
end end
retval = retval .. ";0]"
end end
else else
retval = retval .. ";0]"
if selected_pkg.type == "txp" then if selected_pkg.type == "txp" then
if selected_pkg.enabled then if selected_pkg.enabled then
retval = retval .. retval = retval ..
@ -138,8 +133,10 @@ local function get_formspec(tabview, name, tabdata)
end end
end end
retval = retval .. "button[5.5,4.65;3.25,1;btn_mod_mgr_delete_mod;" retval = retval .. "textarea[5.85,2.2;6.35,2.9;;" ..
.. fgettext("Uninstall Package") .. "]" fgettext("Information:") .. ";" .. desc .. "]" ..
"button[5.5,4.65;3.25,1;btn_mod_mgr_delete_mod;" ..
fgettext("Uninstall Package") .. "]"
end end
return retval return retval
end end