Skip to content

Commit

Permalink
integrate next free layer button better
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Jul 25, 2024
1 parent 2d3c1cc commit 3d8a24a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 100 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.7.0
* Add button to quickly go to <cy>Next Free Layer</c>

## v6.6.5
* Fix <cj>Next Free</c> not taking into account trigger Target Group IDs on Android
* Fix issues with BetterEdit not being loaded on Android due to <cb>Custom Keybinds</c> missing
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"geode": "3.2.0",
"geode": "3.3.0",
"version": "6.7.0",
"gd": {
"win": "2.206",
Expand Down
97 changes: 0 additions & 97 deletions src/features/NextFreeLayer.cpp

This file was deleted.

40 changes: 38 additions & 2 deletions src/features/TypeInZLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class $modify(TypeInUI, EditorUI) {
layerMenu->setContentSize({ 130, layerMenu->getContentSize().height });

// Otherwise it clippety clips off the screen
layerMenu->setPositionX(layerMenu->getPositionX() - 10);
layerMenu->setPositionX(layerMenu->getPositionX() - 12 );

auto layerLockSpr = CCSprite::createWithSpriteFrameName("GJ_lockGray_001.png");
layerLockSpr->setScale(.75f);
Expand All @@ -37,6 +37,19 @@ class $modify(TypeInUI, EditorUI) {
);
layerLockBtn->setID("lock-layer"_spr);
layerMenu->insertBefore(layerLockBtn, nullptr);

// Next free layer button
auto nextFreeSpr = CCSprite::createWithSpriteFrameName("GJ_arrow_02_001.png");
nextFreeSpr->setScale(0.54f);
nextFreeSpr->setOpacity(175);
nextFreeSpr->setFlipX(true);

auto nextFreeBtn = CCMenuItemSpriteExtra::create(
nextFreeSpr, this, menu_selector(TypeInUI::onNextFreeLayer)
);
nextFreeBtn->setID("next-free-layer-button"_spr);
layerMenu->addChild(nextFreeBtn);

layerMenu->updateLayout();

m_currentLayerLabel = EditableBMLabelProxy::replace(
Expand All @@ -58,9 +71,10 @@ 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](auto* ev) {
m_fields->onUIHide.bind([this, layerLockBtn, nextFreeBtn](auto* ev) {
m_currentLayerLabel->setVisible(ev->show);
layerLockBtn->setVisible(ev->show);
nextFreeBtn->setVisible(ev->show);
});

return true;
Expand Down Expand Up @@ -95,6 +109,28 @@ class $modify(TypeInUI, EditorUI) {
m_currentLayerLabel->setColor(layerLocked ? ccc3(255, 150, 0) : ccc3(255, 255, 255));
}

void onNextFreeLayer(CCObject*) {
std::set<short> usedLayers;
for (auto obj : CCArrayExt<GameObject*>(m_editorLayer->m_objects)) {
usedLayers.insert(obj->m_editorLayer);
usedLayers.insert(obj->m_editorLayer2);
}

short nextFree ;
for (nextFree = 0; nextFree < std::numeric_limits<short>::max(); nextFree += 1) {
if (!usedLayers.contains(nextFree)) {
break;
}
}
m_editorLayer->m_currentLayer = nextFree;
m_currentLayerLabel->setString(fmt::format("{}", nextFree).c_str());

if (auto btn = this->querySelector("all-layers-button")) {
btn->setVisible(true);
}
this->updateLockBtn();
}

$override
void onLockLayer(CCObject* sender) {
EditorUI::onLockLayer(sender);
Expand Down
3 changes: 3 additions & 0 deletions src/features/about/AboutBEPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ void AboutBEPopup::onSupport(CCObject*) {
void AboutBEPopup::onSupporters(CCObject*) {
#ifdef BETTEREDIT_PRO
pro::SupportersPopup::create()->show();
#else
FLAlertLayer::create("BE Supporters", "Coming soon ;)", "OK")->show();
#endif
}

Expand Down Expand Up @@ -283,6 +285,7 @@ bool SpecialThanksPopup::setup() {
" * <co>Camila</c>\n"
" * <cl>Brittank88</c>\n"
" * <co>Alphalaneous</c>\n"
" * <cl>The Bearodactyl</c>\n"
"## Other thanks <3\n\n"
" * <cr>TWICE - Scientist MV</c> & <cr>TWICE - What is Love? MV</c>\n"
" * <cy>RobTop</c>\n"
Expand Down

0 comments on commit 3d8a24a

Please sign in to comment.