packs with missing dependencies test
This commit is contained in:
parent
e26b87e7e5
commit
de0b890459
@ -44,11 +44,15 @@ function place_pack(panel, packid, packinfo, callback)
|
||||
packinfo.id_verbose = packid
|
||||
packinfo.callback = callback
|
||||
panel:add(gui.template("pack", packinfo))
|
||||
if callback == "" then
|
||||
document["pack_"..packinfo.id].enabled = false
|
||||
end
|
||||
end
|
||||
|
||||
function refresh()
|
||||
packs_installed = pack.get_installed()
|
||||
packs_available = pack.get_available()
|
||||
packs_all = {unpack(packs_installed), unpack(packs_available)}
|
||||
|
||||
local packs_cur = document.packs_cur
|
||||
local packs_add = document.packs_add
|
||||
@ -67,7 +71,19 @@ function refresh()
|
||||
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
|
||||
|
||||
place_pack(packs_add, id, packinfo, callback)
|
||||
end
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
gravity='bottom-right'>
|
||||
%{creator}
|
||||
</label>
|
||||
<label if='%{missing}' pos='80,28' color='#FF4040'>missing '%{missing}'</label>
|
||||
<label pos='80,28' color='#FFFFFFB2'>
|
||||
%{description}
|
||||
</label>
|
||||
|
||||
@ -79,7 +79,7 @@ void Button::drawBackground(const DrawContext* pctx, Assets* assets) {
|
||||
glm::vec2 pos = calcPos();
|
||||
auto batch = pctx->getBatch2D();
|
||||
batch->texture(nullptr);
|
||||
if (enabled) {
|
||||
if (isEnabled()) {
|
||||
batch->setColor(isPressed() ? pressedColor : (hover ? hoverColor : color));
|
||||
} else {
|
||||
batch->setColor({color.r, color.g, color.b, color.a * 0.5f});
|
||||
|
||||
@ -11,7 +11,7 @@ Container::Container(glm::vec2 size) : UINode(size) {
|
||||
}
|
||||
|
||||
std::shared_ptr<UINode> Container::getAt(glm::vec2 pos, std::shared_ptr<UINode> self) {
|
||||
if (!interactive || !enabled) {
|
||||
if (!interactive || !isEnabled()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!isInside(pos)) return nullptr;
|
||||
@ -92,7 +92,12 @@ void Container::draw(const DrawContext* pctx, Assets* assets) {
|
||||
}
|
||||
|
||||
void Container::drawBackground(const DrawContext* pctx, Assets* assets) {
|
||||
glm::vec4 color = isPressed() ? pressedColor : (hover ? hoverColor : this->color);
|
||||
glm::vec4 color = this->color;
|
||||
if (isEnabled()) {
|
||||
color = (isPressed() ? pressedColor : (hover ? hoverColor : color));
|
||||
} else {
|
||||
color = glm::vec4(color.r, color.g, color.b, color.a * 0.5f);
|
||||
}
|
||||
if (color.a <= 0.001f)
|
||||
return;
|
||||
glm::vec2 pos = calcPos();
|
||||
|
||||
@ -22,7 +22,7 @@ void Image::draw(const DrawContext* pctx, Assets* assets) {
|
||||
setSize(glm::vec2(texture->getWidth(), texture->getHeight()));
|
||||
}
|
||||
batch->texture(texture);
|
||||
if (enabled) {
|
||||
if (isEnabled()) {
|
||||
batch->setColor(isPressed() ? pressedColor : (hover ? hoverColor : color));
|
||||
} else {
|
||||
batch->setColor({color.r, color.g, color.b, color.a * 0.5f});
|
||||
|
||||
@ -149,7 +149,11 @@ void Label::draw(const DrawContext* pctx, Assets* assets) {
|
||||
cache.update(text, multiline, textWrap);
|
||||
}
|
||||
|
||||
batch->setColor(getColor());
|
||||
if (isEnabled()) {
|
||||
batch->setColor(isPressed() ? pressedColor : (hover ? hoverColor : color));
|
||||
} else {
|
||||
batch->setColor({color.r, color.g, color.b, color.a * 0.5f});
|
||||
}
|
||||
|
||||
uint lineHeight = font->getLineHeight();
|
||||
if (cache.lines.size() > 1) {
|
||||
|
||||
@ -29,6 +29,9 @@ void UINode::setEnabled(bool flag) {
|
||||
}
|
||||
|
||||
bool UINode::isEnabled() const {
|
||||
if (enabled && parent) {
|
||||
return parent->isEnabled();
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
||||
|
||||
@ -47,6 +47,8 @@ namespace gui {
|
||||
class UINode {
|
||||
/// @brief element identifier used for direct access in UiDocument
|
||||
std::string id = "";
|
||||
/// @brief element enabled state
|
||||
bool enabled = true;
|
||||
protected:
|
||||
/// @brief element position within the parent element
|
||||
glm::vec2 pos {0.0f};
|
||||
@ -62,8 +64,6 @@ namespace gui {
|
||||
glm::vec4 pressedColor {1.0f};
|
||||
/// @brief element margin (only supported for Panel sub-nodes)
|
||||
glm::vec4 margin {1.0f};
|
||||
/// @brief element enabled state
|
||||
bool enabled = true;
|
||||
/// @brief is element visible
|
||||
bool visible = true;
|
||||
/// @brief is mouse over the element
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user