godot-cpp-utils
A collection of utility classes, functions and macros for use with Godot and GDExtension.
|
C-style preprocessor macros to simplify using godot's C++ API. More...
#include "godot_cpp/classes/engine.hpp"
#include "godot_cpp/core/class_db.hpp"
#include "godot_cpp/variant/string.hpp"
Go to the source code of this file.
Macros | |
#define | GDPROPERTY(PropName_, PropType_) |
Register property. | |
#define | GDPROPERTY_HINTED(PropName_, PropType_, ...) |
Register a hinted property. | |
#define | GDFUNCTION(FnName_) godot::ClassDB::bind_method(godot::D_METHOD(#FnName_), &CLASSNAME::FnName_) |
Register a function CLASSNAME::FnName_() to godot. | |
#define | GDFUNCTION_ARGS(FnName_, ...) godot::ClassDB::bind_method(godot::D_METHOD(#FnName_, __VA_ARGS__), &CLASSNAME::FnName_) |
Register a function CLASSNAME::FnName_(...) to godot. | |
#define | GDFUNCTION_STATIC(FnName_) godot::ClassDB::bind_static_method(MACRO_STRING(CLASSNAME), godot::D_METHOD(#FnName_), &CLASSNAME::_FnName) |
Register a static member function CLASSNAME::FnName_() to godot. | |
#define | GDFUNCTION_STATIC_ARGS(FnName_, ...) godot::ClassDB::bind_static_method(MACRO_STRING(CLASSNAME), godot::D_METHOD(#FnName_, __VA_ARGS__), &CLASSNAME::FnName_) |
Register a static member function CLASSNAME::FnName_(...) to godot. | |
#define | GDSIGNAL(...) godot::ClassDB::add_signal(MACRO_STRING(CLASSNAME), godot::MethodInfo(__VA_ARGS__)) |
Declare a godot Observer signal. | |
#define | GDRESOURCETYPE(Class_) godot::vformat("%s/%s:%s", godot::Variant::OBJECT, godot::PROPERTY_HINT_RESOURCE_TYPE, #Class_) |
Construct godot resource type hint. | |
#define | GDEDITORONLY() if(!godot::Engine::get_singleton()->is_editor_hint()) return; |
Execute the rest of the function only if currently running as editor. | |
#define | GDGAMEONLY() if(godot::Engine::get_singleton()->is_editor_hint()) return; |
Execute the rest of the function only if currently running as game. | |
#define | GDENUM(Name_, ...) |
Declare a scoped enum struct. | |
C-style preprocessor macros to simplify using godot's C++ API.
#define GDEDITORONLY | ( | ) | if(!godot::Engine::get_singleton()->is_editor_hint()) return; |
Execute the rest of the function only if currently running as editor.
Useful for _ready, _enter/_exit, _process, etc. functions.
#define GDENUM | ( | Name_, | |
... | |||
) |
Declare a scoped enum struct.
Declares a struct Name_ with an enum Value and a single variable and a get_property_hint() function.
#define GDFUNCTION | ( | FnName_ | ) | godot::ClassDB::bind_method(godot::D_METHOD(#FnName_), &CLASSNAME::FnName_) |
Register a function CLASSNAME::FnName_() to godot.
Requires setting CLASSNAME as a #define first.
#define GDFUNCTION_ARGS | ( | FnName_, | |
... | |||
) | godot::ClassDB::bind_method(godot::D_METHOD(#FnName_, __VA_ARGS__), &CLASSNAME::FnName_) |
Register a function CLASSNAME::FnName_(...) to godot.
Requires setting CLASSNAME as a #define first.
#define GDFUNCTION_STATIC | ( | FnName_ | ) | godot::ClassDB::bind_static_method(MACRO_STRING(CLASSNAME), godot::D_METHOD(#FnName_), &CLASSNAME::_FnName) |
Register a static member function CLASSNAME::FnName_() to godot.
Requires setting CLASSNAME as a #define first.
#define GDFUNCTION_STATIC_ARGS | ( | FnName_, | |
... | |||
) | godot::ClassDB::bind_static_method(MACRO_STRING(CLASSNAME), godot::D_METHOD(#FnName_, __VA_ARGS__), &CLASSNAME::FnName_) |
Register a static member function CLASSNAME::FnName_(...) to godot.
Requires setting CLASSNAME as a #define first.
#define GDGAMEONLY | ( | ) | if(godot::Engine::get_singleton()->is_editor_hint()) return; |
Execute the rest of the function only if currently running as game.
Useful for _ready, _enter/_exit, _process, etc. functions.
#define GDPROPERTY | ( | PropName_, | |
PropType_ | |||
) |
Register property.
Register variable CLASSNAME::PropName_ with variant type PropType_. Requires setting CLASSNAME as a #define first. Also requires a CLASSNAME::get_PropName_ and CLASSNAME::set_PropName_ to exist.
#define GDPROPERTY_HINTED | ( | PropName_, | |
PropType_, | |||
... | |||
) |
Register a hinted property.
Register variable CLASSNAME::PropName_ with variant type PropType_. Requires setting CLASSNAME as a #define first, and CLASSNAME::get_PropName and CLASSNAME::set_PropName_ to exist.
#define GDRESOURCETYPE | ( | Class_ | ) | godot::vformat("%s/%s:%s", godot::Variant::OBJECT, godot::PROPERTY_HINT_RESOURCE_TYPE, #Class_) |
Construct godot resource type hint.
Use when registering properties of arrays of resource classes.