From 5f7008072eed0c4cd8dc50d7fd623d259cd4fb31 Mon Sep 17 00:00:00 2001 From: dankmeme01 <42031238+dankmeme01@users.noreply.github.com> Date: Sun, 13 Oct 2024 14:16:31 +0200 Subject: [PATCH] deprecate global getChildOfType --- loader/include/Geode/cocos/base_nodes/CCNode.h | 5 +++++ loader/include/Geode/utils/cocos.hpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/loader/include/Geode/cocos/base_nodes/CCNode.h b/loader/include/Geode/cocos/base_nodes/CCNode.h index d2059079..d5255c55 100644 --- a/loader/include/Geode/cocos/base_nodes/CCNode.h +++ b/loader/include/Geode/cocos/base_nodes/CCNode.h @@ -1125,6 +1125,11 @@ public: GEODE_DLL geode::EventListenerProtocol* getEventListener(std::string const& id); GEODE_DLL size_t getEventListenerCount(); + /** + * Get nth child that is a given type. Checks bounds. + * @returns Child at index cast to the given type, + * or nullptr if index exceeds bounds + */ template T* getChildByType(int index) { size_t indexCounter = 0; diff --git a/loader/include/Geode/utils/cocos.hpp b/loader/include/Geode/utils/cocos.hpp index 0c16818b..5d517a6d 100644 --- a/loader/include/Geode/utils/cocos.hpp +++ b/loader/include/Geode/utils/cocos.hpp @@ -620,7 +620,9 @@ namespace geode::cocos { * @returns Child at index cast to the given type, * or nullptr if index exceeds bounds */ + template + [[deprecated("Use CCNode::getChildByType instead")]] static Type* getChildOfType(cocos2d::CCNode* node, int index) { return node->getChildByType(index); }