diff --git a/loader/include/Geode/cocos/base_nodes/Layout.hpp b/loader/include/Geode/cocos/base_nodes/Layout.hpp index 5a14dc1f..44b5f8e4 100644 --- a/loader/include/Geode/cocos/base_nodes/Layout.hpp +++ b/loader/include/Geode/cocos/base_nodes/Layout.hpp @@ -433,23 +433,23 @@ public: * Basically main use case is for FLAlertLayers (setting the size of the * background and `m_buttonMenu` based on `m_mainLayer`) */ -class AutoSizeLayout : public cocos2d::AnchorLayout { +class CopySizeLayout : public cocos2d::AnchorLayout { protected: cocos2d::CCArray* m_targets; public: - static AutoSizeLayout* create(); - virtual ~AutoSizeLayout(); + static CopySizeLayout* create(); + virtual ~CopySizeLayout(); /** * Add a target to be automatically resized. Any targets' layouts will * also be updated when this layout is updated */ - AutoSizeLayout* add(cocos2d::CCNode* target); + CopySizeLayout* add(cocos2d::CCNode* target); /** * Remove a target from being automatically resized */ - AutoSizeLayout* remove(cocos2d::CCNode* target); + CopySizeLayout* remove(cocos2d::CCNode* target); void apply(cocos2d::CCNode* in) override; cocos2d::CCSize getSizeHint(cocos2d::CCNode* in) const override; diff --git a/loader/include/Geode/ui/Popup.hpp b/loader/include/Geode/ui/Popup.hpp index b512e05e..c10e4eed 100644 --- a/loader/include/Geode/ui/Popup.hpp +++ b/loader/include/Geode/ui/Popup.hpp @@ -53,7 +53,7 @@ namespace geode { m_mainLayer->setPosition(winSize / 2); m_mainLayer->setContentSize(m_size); m_mainLayer->setLayout( - cocos2d::AutoSizeLayout::create() + cocos2d::CopySizeLayout::create() ->add(m_buttonMenu) ->add(m_bgSprite) ); diff --git a/loader/src/cocos2d-ext/AutoSizeLayout.cpp b/loader/src/cocos2d-ext/AutoSizeLayout.cpp deleted file mode 100644 index ed19594c..00000000 --- a/loader/src/cocos2d-ext/AutoSizeLayout.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include -#include -#include -#include -#include - -using namespace geode::prelude; - -AutoSizeLayout* AutoSizeLayout::create() { - auto ret = new AutoSizeLayout(); - ret->m_targets = CCArray::create(); - ret->m_targets->retain(); - ret->autorelease(); - return ret; -} - -AutoSizeLayout::~AutoSizeLayout() { - m_targets->release(); -} - -AutoSizeLayout* AutoSizeLayout::add(CCNode* target) { - m_targets->addObject(target); - return this; -} - -AutoSizeLayout* AutoSizeLayout::remove(CCNode* target) { - m_targets->removeObject(target); - return this; -} - -void AutoSizeLayout::apply(CCNode* in) { - AnchorLayout::apply(in); - for (auto& node : CCArrayExt(m_targets)) { - // Prevent accidental infinite loop - if (node == in) continue; - node->ignoreAnchorPointForPosition(false); - node->setContentSize(in->getContentSize()); - node->setPosition(in->getContentSize() / 2); - node->updateLayout(); - } -} - -CCSize AutoSizeLayout::getSizeHint(CCNode* in) const { - return in->getContentSize(); -}