diff --git a/res/layouts/pages/content.xml.lua b/res/layouts/pages/content.xml.lua
index 5cab6efd..5bfbb885 100644
--- a/res/layouts/pages/content.xml.lua
+++ b/res/layouts/pages/content.xml.lua
@@ -37,53 +37,68 @@ end
function place_pack(panel, packid, packinfo, callback)
packinfo.id = packid
- callback = callback or ""
+ if packinfo.error then
+ callback = nil
+ end
if packinfo.has_indices then
packid = packid.."*"
end
packinfo.id_verbose = packid
packinfo.callback = callback
panel:add(gui.template("pack", packinfo))
- if callback == "" then
+ if not callback then
document["pack_"..packinfo.id].enabled = false
end
end
+function check_dependencies(packinfo)
+ if packinfo.dependencies == nil then
+ return
+ end
+ for i,dep in ipairs(packinfo.dependencies) do
+ local depid = dep:sub(2,-1)
+ if dep:sub(1,1) == '!' then
+ if not table.has(packs_all, depid) then
+ packinfo.description = ""
+ return string.format(
+ "%s (%s)", gui.str("error.dependency-not-found"), depid
+ )
+ end
+ if document["pack_"..depid] then
+ document["pack_"..depid].enabled = false
+ end
+ end
+ end
+ return
+end
+
function refresh()
packs_installed = pack.get_installed()
packs_available = pack.get_available()
- packs_all = {unpack(packs_installed), unpack(packs_available)}
-
+ packs_all = {unpack(packs_installed)}
+ for i,k in ipairs(packs_available) do
+ table.insert(packs_all, k)
+ end
+
local packs_cur = document.packs_cur
local packs_add = document.packs_add
packs_cur:clear()
packs_add:clear()
- refresh_changes()
for i,id in ipairs(packs_installed) do
local packinfo = pack.get_info(id)
packinfo.index = i
callback = id ~= "base" and string.format('move_pack("%s")', id) or nil
+ packinfo.error = check_dependencies(packinfo)
place_pack(packs_cur, id, packinfo, callback)
end
for i,id in ipairs(packs_available) do
local packinfo = pack.get_info(id)
packinfo.index = i
- packinfo.missing = ""
callback = string.format('move_pack("%s")', id)
- if packinfo.dependencies then
- for j,dep in ipairs(packinfo.dependencies) do
- local depid = dep:sub(2,-1)
- if dep:sub(1,1) == '!' and not table.has(packs_all, depid) then
- packinfo.missing = depid
- packinfo.description = ""
- callback = ''
- end
- end
- end
-
+ packinfo.error = check_dependencies(packinfo)
place_pack(packs_add, id, packinfo, callback)
end
@@ -98,4 +113,5 @@ function refresh()
document["pack_"..id]:move_into(packs_cur)
end
end
+ refresh_changes()
end
diff --git a/res/layouts/templates/pack.xml b/res/layouts/templates/pack.xml
index 6117a5e5..3978a6c7 100644
--- a/res/layouts/templates/pack.xml
+++ b/res/layouts/templates/pack.xml
@@ -7,7 +7,7 @@
gravity='bottom-right'>
%{creator}
-
+
diff --git a/src/graphics/ui/gui_xml.cpp b/src/graphics/ui/gui_xml.cpp
index 96f756b6..656785fe 100644
--- a/src/graphics/ui/gui_xml.cpp
+++ b/src/graphics/ui/gui_xml.cpp
@@ -530,7 +530,7 @@ void UiXmlReader::addIgnore(const std::string& tag) {
std::shared_ptr UiXmlReader::readUINode(xml::xmlelement element) {
if (element->has("if")) {
const auto& cond = element->attr("if").getText();
- if (cond.empty() || cond == "false") {
+ if (cond.empty() || cond == "false" || cond == "nil") {
return nullptr;
}
}