File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,11 @@ namespace geode {
4444 class Layout ;
4545 class LayoutOptions ;
4646 enum class Anchor ;
47+
48+ template <typename T>
49+ struct CCArrayExtCheck {
50+ using type = void ;
51+ };
4752}
4853
4954NS_CC_BEGIN
@@ -635,6 +640,21 @@ class CC_DLL CCNode : public CCObject
635640 */
636641 virtual CCArray* getChildren ();
637642
643+ /*
644+ * Like `getChildren()`, but returns a `CCArrayExt<CCNode>` instead.
645+ * You must include `<Geode/utils/cocos.hpp>` to use this, otherwise it won't compile
646+ */
647+ template <typename PleaseDontChangeMe = CCNode>
648+ inline auto getChildrenExt () {
649+ // CCArrayExt is defined in geode/utils/cocos.hpp, which we cannot include due to circular includes.
650+ // This is an incredibly hacky way to still be able to use the type
651+
652+ using CCArrayExt = geode::CCArrayExtCheck<PleaseDontChangeMe>::type;
653+ static_assert (!std::is_void_v<CCArrayExt>, " Please include <Geode/utils/cocos.hpp> to use getChildrenExt()" );
654+
655+ return CCArrayExt (getChildren ());
656+ }
657+
638658 /* *
639659 * Get the amount of children.
640660 *
Original file line number Diff line number Diff line change @@ -1642,3 +1642,8 @@ namespace geode::cocos {
16421642 */
16431643 void GEODE_DLL handleTouchPriority (cocos2d::CCNode* node, bool force = false );
16441644}
1645+
1646+ template <>
1647+ struct ::geode::CCArrayExtCheck<cocos2d::CCNode> {
1648+ using type = cocos::CCArrayExt<cocos2d::CCNode>;
1649+ };
You can’t perform that action at this time.
0 commit comments