From 3066d76e33070f0ec598b522b519fd6c1ddaf10e Mon Sep 17 00:00:00 2001 From: HybridDog Date: Thu, 7 Mar 2019 08:23:03 +0100 Subject: World config: Make depends easier to read (#7396) * Do not always show every depends textfieds When there are no dependencies, it does not longer show an empty list. * Adjust the list height to avoid a scrollbar when possible * change minimum height and no dependencies message * Do not get depends for modpacks --- builtin/mainmenu/dlg_config_world.lua | 47 ++++++++++++++++++++++++++++------- builtin/mainmenu/pkgmgr.lua | 4 +-- 2 files changed, 40 insertions(+), 11 deletions(-) (limited to 'builtin') diff --git a/builtin/mainmenu/dlg_config_world.lua b/builtin/mainmenu/dlg_config_world.lua index daa8099c4..97218df9c 100644 --- a/builtin/mainmenu/dlg_config_world.lua +++ b/builtin/mainmenu/dlg_config_world.lua @@ -31,8 +31,6 @@ local function get_formspec(data) "label[0.5,0;" .. fgettext("World:") .. "]" .. "label[1.75,0;" .. data.worldspec.name .. "]" - local hard_deps, soft_deps = pkgmgr.get_dependencies(mod.path) - if mod.is_modpack or mod.type == "game" then local info = minetest.formspec_escape( core.get_content_info(mod.path).description) @@ -46,15 +44,46 @@ local function get_formspec(data) retval = retval .. "textarea[0.25,0.7;5.75,7.2;;" .. info .. ";]" else + local hard_deps, soft_deps = pkgmgr.get_dependencies(mod.path) + local hard_deps_str = table.concat(hard_deps, ",") + local soft_deps_str = table.concat(soft_deps, ",") + retval = retval .. "label[0,0.7;" .. fgettext("Mod:") .. "]" .. - "label[0.75,0.7;" .. mod.name .. "]" .. - "label[0,1.25;" .. fgettext("Dependencies:") .. "]" .. - "textlist[0,1.75;5,2.125;world_config_depends;" .. hard_deps .. - ";0]" .. - "label[0,3.875;" .. fgettext("Optional dependencies:") .. "]" .. - "textlist[0,4.375;5,1.8;world_config_optdepends;" .. - soft_deps .. ";0]" + "label[0.75,0.7;" .. mod.name .. "]" + + if hard_deps_str == "" then + if soft_deps_str == "" then + retval = retval .. + "label[0,1.25;" .. + fgettext("No (optional) dependencies") .. "]" + else + retval = retval .. + "label[0,1.25;" .. fgettext("No hard dependencies") .. + "]" .. + "label[0,1.75;" .. fgettext("Optional dependencies:") .. + "]" .. + "textlist[0,2.25;5,4;world_config_optdepends;" .. + soft_deps_str .. ";0]" + end + else + if soft_deps_str == "" then + retval = retval .. + "label[0,1.25;" .. fgettext("Dependencies:") .. "]" .. + "textlist[0,1.75;5,4;world_config_depends;" .. + hard_deps_str .. ";0]" .. + "label[0,6;" .. fgettext("No optional dependencies") .. "]" + else + retval = retval .. + "label[0,1.25;" .. fgettext("Dependencies:") .. "]" .. + "textlist[0,1.75;5,2.125;world_config_depends;" .. + hard_deps_str .. ";0]" .. + "label[0,3.9;" .. fgettext("Optional dependencies:") .. + "]" .. + "textlist[0,4.375;5,1.8;world_config_optdepends;" .. + soft_deps_str .. ";0]" + end + end end retval = retval .. "button[3.25,7;2.5,0.5;btn_config_world_save;" .. diff --git a/builtin/mainmenu/pkgmgr.lua b/builtin/mainmenu/pkgmgr.lua index 60a496093..dee4dabbb 100644 --- a/builtin/mainmenu/pkgmgr.lua +++ b/builtin/mainmenu/pkgmgr.lua @@ -332,11 +332,11 @@ end -------------------------------------------------------------------------------- function pkgmgr.get_dependencies(path) if path == nil then - return "", "" + return {}, {} end local info = core.get_content_info(path) - return table.concat(info.depends or {}, ","), table.concat(info.optional_depends or {}, ",") + return info.depends or {}, info.optional_depends or {} end ----------- tests whether all of the mods in the modpack are enabled ----------- -- cgit v1.2.3