dependencies lock
This commit is contained in:
parent
de0b890459
commit
7c5e15fade
@ -37,53 +37,68 @@ end
|
|||||||
|
|
||||||
function place_pack(panel, packid, packinfo, callback)
|
function place_pack(panel, packid, packinfo, callback)
|
||||||
packinfo.id = packid
|
packinfo.id = packid
|
||||||
callback = callback or ""
|
if packinfo.error then
|
||||||
|
callback = nil
|
||||||
|
end
|
||||||
if packinfo.has_indices then
|
if packinfo.has_indices then
|
||||||
packid = packid.."*"
|
packid = packid.."*"
|
||||||
end
|
end
|
||||||
packinfo.id_verbose = packid
|
packinfo.id_verbose = packid
|
||||||
packinfo.callback = callback
|
packinfo.callback = callback
|
||||||
panel:add(gui.template("pack", packinfo))
|
panel:add(gui.template("pack", packinfo))
|
||||||
if callback == "" then
|
if not callback then
|
||||||
document["pack_"..packinfo.id].enabled = false
|
document["pack_"..packinfo.id].enabled = false
|
||||||
end
|
end
|
||||||
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()
|
function refresh()
|
||||||
packs_installed = pack.get_installed()
|
packs_installed = pack.get_installed()
|
||||||
packs_available = pack.get_available()
|
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_cur = document.packs_cur
|
||||||
local packs_add = document.packs_add
|
local packs_add = document.packs_add
|
||||||
|
|
||||||
packs_cur:clear()
|
packs_cur:clear()
|
||||||
packs_add:clear()
|
packs_add:clear()
|
||||||
refresh_changes()
|
|
||||||
|
|
||||||
for i,id in ipairs(packs_installed) do
|
for i,id in ipairs(packs_installed) do
|
||||||
local packinfo = pack.get_info(id)
|
local packinfo = pack.get_info(id)
|
||||||
packinfo.index = i
|
packinfo.index = i
|
||||||
callback = id ~= "base" and string.format('move_pack("%s")', id) or nil
|
callback = id ~= "base" and string.format('move_pack("%s")', id) or nil
|
||||||
|
packinfo.error = check_dependencies(packinfo)
|
||||||
place_pack(packs_cur, id, packinfo, callback)
|
place_pack(packs_cur, id, packinfo, callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i,id in ipairs(packs_available) do
|
for i,id in ipairs(packs_available) do
|
||||||
local packinfo = pack.get_info(id)
|
local packinfo = pack.get_info(id)
|
||||||
packinfo.index = i
|
packinfo.index = i
|
||||||
packinfo.missing = ""
|
|
||||||
callback = string.format('move_pack("%s")', id)
|
callback = string.format('move_pack("%s")', id)
|
||||||
if packinfo.dependencies then
|
packinfo.error = check_dependencies(packinfo)
|
||||||
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
|
|
||||||
|
|
||||||
place_pack(packs_add, id, packinfo, callback)
|
place_pack(packs_add, id, packinfo, callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -98,4 +113,5 @@ function refresh()
|
|||||||
document["pack_"..id]:move_into(packs_cur)
|
document["pack_"..id]:move_into(packs_cur)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
refresh_changes()
|
||||||
end
|
end
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
gravity='bottom-right'>
|
gravity='bottom-right'>
|
||||||
%{creator}
|
%{creator}
|
||||||
</label>
|
</label>
|
||||||
<label if='%{missing}' pos='80,28' color='#FF4040'>missing '%{missing}'</label>
|
<label if='%{error}' pos='80,28' size='290,50' multiline='true' color='#FF4040'>%{error}</label>
|
||||||
<label pos='80,28' color='#FFFFFFB2'>
|
<label pos='80,28' color='#FFFFFFB2'>
|
||||||
%{description}
|
%{description}
|
||||||
</label>
|
</label>
|
||||||
|
|||||||
@ -530,7 +530,7 @@ void UiXmlReader::addIgnore(const std::string& tag) {
|
|||||||
std::shared_ptr<UINode> UiXmlReader::readUINode(xml::xmlelement element) {
|
std::shared_ptr<UINode> UiXmlReader::readUINode(xml::xmlelement element) {
|
||||||
if (element->has("if")) {
|
if (element->has("if")) {
|
||||||
const auto& cond = element->attr("if").getText();
|
const auto& cond = element->attr("if").getText();
|
||||||
if (cond.empty() || cond == "false") {
|
if (cond.empty() || cond == "false" || cond == "nil") {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user