diff --git a/flash.toml b/flash.toml index 802f1a85..31edba5a 100644 --- a/flash.toml +++ b/flash.toml @@ -10,27 +10,24 @@ tree = "https://github.com/geode-sdk/geode/tree/main" [[sources]] name = "Geode" -dir = "loader/include/Geode" -# todo: Make flash infer this from cmake -strip-include-prefix = "loader/include" +dir = "loader/include" include = [ - "**/*.hpp", - "**/*.h", + "Geode/**/*.hpp", + "Geode/**/*.h", ] exclude = [ - "modify/Comparer.hpp", - "platform/*.hpp", - "c++stl/*.hpp", + "Geode/modify/Comparer.hpp", + "Geode/platform/*.hpp", + "Geode/c++stl/*.hpp", # All of the relevant cocos headers are included through Geode headers - "cocos/**/*.h" + "Geode/cocos/**/*.h" ] [[sources]] name = "Bindings" -dir = "build-docs/codegenned/Geode/binding" -strip-include-prefix = "build-docs/codegenned" +dir = "build-docs/codegenned" include = [ - "*.hpp" + "Geode/binding/*.hpp" ] # Bindings are generated at compile time exists-online = false @@ -51,6 +48,7 @@ config-args = [ "-DCMAKE_CXX_FLAGS=-m32", "-DWIN32=On" ] + # We want to build codegen in order to get the bindings build = true build-dir = "build-docs" diff --git a/loader/include/Geode/cocos/base_nodes/CCNode.h b/loader/include/Geode/cocos/base_nodes/CCNode.h index 74296ac3..9a0c02b4 100644 --- a/loader/include/Geode/cocos/base_nodes/CCNode.h +++ b/loader/include/Geode/cocos/base_nodes/CCNode.h @@ -1375,7 +1375,7 @@ public: * * @note The additional transform will be concatenated at the end of nodeToParentTransform. * It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't). - * @code + * @example // create a batchNode CCSpriteBatchNode* batch= CCSpriteBatchNode::create("Icon-114.png"); this->addChild(batch); @@ -1416,7 +1416,6 @@ public: // Sets the additional transform to spriteB, spriteB's rotation will based on its pseudo parent i.e. spriteA. spriteB->setAdditionalTransform(t); - * @endcode */ void setAdditionalTransform(const CCAffineTransform& additionalTransform); diff --git a/loader/include/Geode/loader/Mod.hpp b/loader/include/Geode/loader/Mod.hpp index 7025de87..dd49bae1 100644 --- a/loader/include/Geode/loader/Mod.hpp +++ b/loader/include/Geode/loader/Mod.hpp @@ -36,8 +36,8 @@ namespace geode { class ModImpl; /** - * @class Mod * Represents a Mod ingame. + * @class Mod */ class GEODE_DLL Mod { protected: @@ -361,6 +361,3 @@ namespace geode { inline char const* operator"" _spr(char const* str, size_t) { return geode::Mod::get()->expandSpriteName(str); } - -// this header uses Mod -#include "ModEvent.hpp" diff --git a/loader/include/Geode/loader/ModEvent.hpp b/loader/include/Geode/loader/ModEvent.hpp index af45f9d8..496a66e8 100644 --- a/loader/include/Geode/loader/ModEvent.hpp +++ b/loader/include/Geode/loader/ModEvent.hpp @@ -1,11 +1,13 @@ #pragma once #include "Event.hpp" -#include "Mod.hpp" #include namespace geode { + class Mod; + inline Mod* getMod(); + enum class ModEventType { Loaded, Unloaded, @@ -49,7 +51,7 @@ namespace { \ } \ static inline auto GEODE_CONCAT(Exec, __LINE__) = (new geode::EventListener( \ &GEODE_CONCAT(geodeExecFunction, __LINE__),\ - geode::ModStateFilter(geode::Mod::get(), geode::ModEventType::type)\ + geode::ModStateFilter(geode::getMod(), geode::ModEventType::type)\ ), 0); \ template \ void GEODE_CONCAT(geodeExecFunction, __LINE__)(ModStateEvent*) diff --git a/loader/include/Geode/utils/cocos.hpp b/loader/include/Geode/utils/cocos.hpp index 5f737812..db3a5aeb 100644 --- a/loader/include/Geode/utils/cocos.hpp +++ b/loader/include/Geode/utils/cocos.hpp @@ -193,13 +193,57 @@ namespace geode { * * Use-cases include, for example, non-CCNode class members, or nodes that * are not always in the scene tree. + * + * @tparam T A type that inherits from CCObject. * - * @example class MyNode : public CCNode { + * @example[flash] + * #include + * + * USE_GEODE_NAMESPACE(); + * + * //!flash-snippet-start + * class MyNode : public CCNode { * protected: * // no need to manually call retain or * // release on this array; Ref manages it * // for you :3 * Ref m_list = CCArray::create(); + * + * bool init() { + * if (!CCNode::init()) + * return false; + * + * // No need to do m_list = CCArray::create() + * // or m_list->retain() :3 + * + * return true; + * } + * }; + * //!flash-snippet-end + * + * @example[flash] + * #include + * #include + * + * USE_GEODE_NAMESPACE(); + * + * class ModifyMenuLayer : public MenuLayer { + * bool init() { + * if (!MenuLayer::init()) + * return false; + * + * //!flash-snippet-start + * // Save a child from the current layer into a menu + * Ref menu = static_cast(this->getChildByID("main-menu")); + * + * // Remove the menu from its parent + * menu->removeFromParent(); + * + * // Menu will still point to a valid CCMenu as long as the menu variable exist + * //!flash-snippet-end + * + * return true; + * } * }; */ template @@ -215,6 +259,7 @@ namespace geode { /** * Construct a Ref of an object. The object will be retained and * managed until Ref goes out of scope + * @param obj Object to construct the Ref from */ Ref(T* obj) : m_obj(obj) { CC_SAFE_RETAIN(obj);