Skip to content

Commit

Permalink
fix layer lock button being incorrectly visible sometimes
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Jan 3, 2025
1 parent 1665a7e commit 7aa483b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# BetterEdit 6

## v6.10.0-alpha.4
* Fix <cy>Layer Lock Button</c> sometimes being visible on All

## v6.10.0-alpha.3
* Add <cl>Create Loop</c> keybind
* Fix <cj>Next Free</c> not working for Editor Layers
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"geode": "4.1.0",
"version": "6.10.0-alpha.3",
"version": "6.10.0-alpha.4",
"gd": {
"win": "2.2074",
"mac": "2.2074",
Expand Down
14 changes: 7 additions & 7 deletions src/features/TypeInZLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class $modify(TypeInUI, EditorUI) {
m_editorLayer->m_currentLayer = numFromString<int>(str).unwrapOr(-1);
},
[this](auto) {
this->updateLockBtn();
this->updateLockBtn(true);
}
);
m_currentLayerLabel = proxy;
Expand All @@ -74,16 +74,16 @@ class $modify(TypeInUI, EditorUI) {
static_cast<CCSprite*>(this->getChildByID("layer-locked-sprite"))->setOpacity(0);

m_fields->onUIHide.setFilter(UIShowFilter(this));
m_fields->onUIHide.bind([this, layerLockBtn, nextFreeBtn](auto* ev) {
m_fields->onUIHide.bind([this, nextFreeBtn](auto* ev) {
m_currentLayerLabel->setVisible(ev->show);
layerLockBtn->setVisible(ev->show);
nextFreeBtn->setVisible(ev->show);
this->updateLockBtn(ev->show);
});

return true;
}

void updateLockBtn() {
void updateLockBtn(bool show) {
auto layerMenu = this->getChildByID("layer-menu");
if (!layerMenu) return;
auto lockBtn = static_cast<CCMenuItemSpriteExtra*>(layerMenu->getChildByID("lock-layer"_spr));
Expand All @@ -108,7 +108,7 @@ class $modify(TypeInUI, EditorUI) {
lockBtn->setNormalImage(spr);
spr->setAnchorPoint((layerLocked || onAll) ? ccp(.47f, .48f) : ccp(.5f, .2f));

lockBtn->setVisible(m_editorLayer->m_layerLockingEnabled && !onAll);
lockBtn->setVisible(show && m_editorLayer->m_layerLockingEnabled && !onAll);
m_currentLayerLabel->setColor(layerLocked ? ccc3(255, 150, 0) : ccc3(255, 255, 255));
}

Expand All @@ -131,12 +131,12 @@ class $modify(TypeInUI, EditorUI) {
if (auto btn = this->querySelector("all-layers-button")) {
btn->setVisible(true);
}
this->updateLockBtn();
this->updateLockBtn(true);
}

$override
void onLockLayer(CCObject* sender) {
EditorUI::onLockLayer(sender);
this->updateLockBtn();
this->updateLockBtn(true);
}
};
8 changes: 0 additions & 8 deletions src/utils/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,6 @@ class $modify(HideUI, EditorUI) {
EditorUI::showUI(show);
UIShowEvent(this, show).post();

m_currentLayerLabel->setVisible(show);

auto lockBtn = static_cast<CCMenuItemSpriteExtra*>(
this->querySelector("layer-menu hjfod.betteredit/lock-layer")
);
if (lockBtn) {
lockBtn->setVisible(show);
}
m_tabsMenu->setVisible(show && m_selectedMode == 2);
}
};
Expand Down

0 comments on commit 7aa483b

Please sign in to comment.