docs stuff i think

This commit is contained in:
HJfod 2023-01-21 14:17:33 +02:00
parent 4813dbb5ee
commit f8737dde43
5 changed files with 62 additions and 21 deletions

View file

@ -10,27 +10,24 @@ tree = "https://github.com/geode-sdk/geode/tree/main"
[[sources]] [[sources]]
name = "Geode" name = "Geode"
dir = "loader/include/Geode" dir = "loader/include"
# todo: Make flash infer this from cmake
strip-include-prefix = "loader/include"
include = [ include = [
"**/*.hpp", "Geode/**/*.hpp",
"**/*.h", "Geode/**/*.h",
] ]
exclude = [ exclude = [
"modify/Comparer.hpp", "Geode/modify/Comparer.hpp",
"platform/*.hpp", "Geode/platform/*.hpp",
"c++stl/*.hpp", "Geode/c++stl/*.hpp",
# All of the relevant cocos headers are included through Geode headers # All of the relevant cocos headers are included through Geode headers
"cocos/**/*.h" "Geode/cocos/**/*.h"
] ]
[[sources]] [[sources]]
name = "Bindings" name = "Bindings"
dir = "build-docs/codegenned/Geode/binding" dir = "build-docs/codegenned"
strip-include-prefix = "build-docs/codegenned"
include = [ include = [
"*.hpp" "Geode/binding/*.hpp"
] ]
# Bindings are generated at compile time # Bindings are generated at compile time
exists-online = false exists-online = false
@ -51,6 +48,7 @@ config-args = [
"-DCMAKE_CXX_FLAGS=-m32", "-DCMAKE_CXX_FLAGS=-m32",
"-DWIN32=On" "-DWIN32=On"
] ]
# We want to build codegen in order to get the bindings # We want to build codegen in order to get the bindings
build = true build = true
build-dir = "build-docs" build-dir = "build-docs"

View file

@ -1375,7 +1375,7 @@ public:
* *
* @note The additional transform will be concatenated at the end of nodeToParentTransform. * @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). * 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 // create a batchNode
CCSpriteBatchNode* batch= CCSpriteBatchNode::create("Icon-114.png"); CCSpriteBatchNode* batch= CCSpriteBatchNode::create("Icon-114.png");
this->addChild(batch); 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. // Sets the additional transform to spriteB, spriteB's rotation will based on its pseudo parent i.e. spriteA.
spriteB->setAdditionalTransform(t); spriteB->setAdditionalTransform(t);
* @endcode
*/ */
void setAdditionalTransform(const CCAffineTransform& additionalTransform); void setAdditionalTransform(const CCAffineTransform& additionalTransform);

View file

@ -36,8 +36,8 @@ namespace geode {
class ModImpl; class ModImpl;
/** /**
* @class Mod
* Represents a Mod ingame. * Represents a Mod ingame.
* @class Mod
*/ */
class GEODE_DLL Mod { class GEODE_DLL Mod {
protected: protected:
@ -361,6 +361,3 @@ namespace geode {
inline char const* operator"" _spr(char const* str, size_t) { inline char const* operator"" _spr(char const* str, size_t) {
return geode::Mod::get()->expandSpriteName(str); return geode::Mod::get()->expandSpriteName(str);
} }
// this header uses Mod
#include "ModEvent.hpp"

View file

@ -1,11 +1,13 @@
#pragma once #pragma once
#include "Event.hpp" #include "Event.hpp"
#include "Mod.hpp"
#include <optional> #include <optional>
namespace geode { namespace geode {
class Mod;
inline Mod* getMod();
enum class ModEventType { enum class ModEventType {
Loaded, Loaded,
Unloaded, Unloaded,
@ -49,7 +51,7 @@ namespace { \
} \ } \
static inline auto GEODE_CONCAT(Exec, __LINE__) = (new geode::EventListener( \ static inline auto GEODE_CONCAT(Exec, __LINE__) = (new geode::EventListener( \
&GEODE_CONCAT(geodeExecFunction, __LINE__)<GEODE_CONCAT(ExecFuncUnique, __LINE__)>,\ &GEODE_CONCAT(geodeExecFunction, __LINE__)<GEODE_CONCAT(ExecFuncUnique, __LINE__)>,\
geode::ModStateFilter(geode::Mod::get(), geode::ModEventType::type)\ geode::ModStateFilter(geode::getMod(), geode::ModEventType::type)\
), 0); \ ), 0); \
template<class> \ template<class> \
void GEODE_CONCAT(geodeExecFunction, __LINE__)(ModStateEvent*) void GEODE_CONCAT(geodeExecFunction, __LINE__)(ModStateEvent*)

View file

@ -193,13 +193,57 @@ namespace geode {
* *
* Use-cases include, for example, non-CCNode class members, or nodes that * Use-cases include, for example, non-CCNode class members, or nodes that
* are not always in the scene tree. * are not always in the scene tree.
*
* @tparam T A type that inherits from CCObject.
* *
* @example class MyNode : public CCNode { * @example[flash]
* #include <Geode/utils/cocos.hpp>
*
* USE_GEODE_NAMESPACE();
*
* //!flash-snippet-start
* class MyNode : public CCNode {
* protected: * protected:
* // no need to manually call retain or * // no need to manually call retain or
* // release on this array; Ref manages it * // release on this array; Ref manages it
* // for you :3 * // for you :3
* Ref<CCArray> m_list = CCArray::create(); * Ref<CCArray> 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 <Geode/utils/cocos.hpp>
* #include <Geode/modify/MenuLayer.hpp>
*
* 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<CCMenu> menu = static_cast<CCMenu*>(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 <class T> template <class T>
@ -215,6 +259,7 @@ namespace geode {
/** /**
* Construct a Ref of an object. The object will be retained and * Construct a Ref of an object. The object will be retained and
* managed until Ref goes out of scope * managed until Ref goes out of scope
* @param obj Object to construct the Ref from
*/ */
Ref(T* obj) : m_obj(obj) { Ref(T* obj) : m_obj(obj) {
CC_SAFE_RETAIN(obj); CC_SAFE_RETAIN(obj);