Skip to content

Commit 3066d76

Browse files
HybridDognerzhul
authored andcommitted
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
1 parent bb35d06 commit 3066d76

File tree

2 files changed

+40
-11
lines changed

2 files changed

+40
-11
lines changed

builtin/mainmenu/dlg_config_world.lua

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ local function get_formspec(data)
3131
"label[0.5,0;" .. fgettext("World:") .. "]" ..
3232
"label[1.75,0;" .. data.worldspec.name .. "]"
3333

34-
local hard_deps, soft_deps = pkgmgr.get_dependencies(mod.path)
35-
3634
if mod.is_modpack or mod.type == "game" then
3735
local info = minetest.formspec_escape(
3836
core.get_content_info(mod.path).description)
@@ -46,15 +44,46 @@ local function get_formspec(data)
4644
retval = retval ..
4745
"textarea[0.25,0.7;5.75,7.2;;" .. info .. ";]"
4846
else
47+
local hard_deps, soft_deps = pkgmgr.get_dependencies(mod.path)
48+
local hard_deps_str = table.concat(hard_deps, ",")
49+
local soft_deps_str = table.concat(soft_deps, ",")
50+
4951
retval = retval ..
5052
"label[0,0.7;" .. fgettext("Mod:") .. "]" ..
51-
"label[0.75,0.7;" .. mod.name .. "]" ..
52-
"label[0,1.25;" .. fgettext("Dependencies:") .. "]" ..
53-
"textlist[0,1.75;5,2.125;world_config_depends;" .. hard_deps ..
54-
";0]" ..
55-
"label[0,3.875;" .. fgettext("Optional dependencies:") .. "]" ..
56-
"textlist[0,4.375;5,1.8;world_config_optdepends;" ..
57-
soft_deps .. ";0]"
53+
"label[0.75,0.7;" .. mod.name .. "]"
54+
55+
if hard_deps_str == "" then
56+
if soft_deps_str == "" then
57+
retval = retval ..
58+
"label[0,1.25;" ..
59+
fgettext("No (optional) dependencies") .. "]"
60+
else
61+
retval = retval ..
62+
"label[0,1.25;" .. fgettext("No hard dependencies") ..
63+
"]" ..
64+
"label[0,1.75;" .. fgettext("Optional dependencies:") ..
65+
"]" ..
66+
"textlist[0,2.25;5,4;world_config_optdepends;" ..
67+
soft_deps_str .. ";0]"
68+
end
69+
else
70+
if soft_deps_str == "" then
71+
retval = retval ..
72+
"label[0,1.25;" .. fgettext("Dependencies:") .. "]" ..
73+
"textlist[0,1.75;5,4;world_config_depends;" ..
74+
hard_deps_str .. ";0]" ..
75+
"label[0,6;" .. fgettext("No optional dependencies") .. "]"
76+
else
77+
retval = retval ..
78+
"label[0,1.25;" .. fgettext("Dependencies:") .. "]" ..
79+
"textlist[0,1.75;5,2.125;world_config_depends;" ..
80+
hard_deps_str .. ";0]" ..
81+
"label[0,3.9;" .. fgettext("Optional dependencies:") ..
82+
"]" ..
83+
"textlist[0,4.375;5,1.8;world_config_optdepends;" ..
84+
soft_deps_str .. ";0]"
85+
end
86+
end
5887
end
5988
retval = retval ..
6089
"button[3.25,7;2.5,0.5;btn_config_world_save;" ..

builtin/mainmenu/pkgmgr.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,11 @@ end
332332
--------------------------------------------------------------------------------
333333
function pkgmgr.get_dependencies(path)
334334
if path == nil then
335-
return "", ""
335+
return {}, {}
336336
end
337337

338338
local info = core.get_content_info(path)
339-
return table.concat(info.depends or {}, ","), table.concat(info.optional_depends or {}, ",")
339+
return info.depends or {}, info.optional_depends or {}
340340
end
341341

342342
----------- tests whether all of the mods in the modpack are enabled -----------

0 commit comments

Comments
 (0)