2024-01-30 09:36:58 +00:00
|
|
|
#ifndef UC_GODOT_MACROS_H
|
|
|
|
#define UC_GODOT_MACROS_H
|
|
|
|
|
2024-02-02 07:47:30 +00:00
|
|
|
#include "godot_cpp/classes/engine.hpp"
|
|
|
|
#include "godot_cpp/core/class_db.hpp"
|
|
|
|
|
2024-01-30 09:36:58 +00:00
|
|
|
#define MACRO_STRING_INNER(_Arg) #_Arg
|
|
|
|
#define MACRO_STRING(_Arg) MACRO_STRING_INNER(_Arg)
|
|
|
|
|
|
|
|
#define GDPROPERTY(_PropName, _PropType) \
|
|
|
|
ClassDB::bind_method(D_METHOD("get_" #_PropName), &CLASSNAME::get_##_PropName); \
|
|
|
|
ClassDB::bind_method(D_METHOD("set_" #_PropName, "value"), &CLASSNAME::set_##_PropName); \
|
|
|
|
ClassDB::add_property(MACRO_STRING(CLASSNAME), PropertyInfo(_PropType, #_PropName), "set_" #_PropName, \
|
|
|
|
"get_" #_PropName)
|
|
|
|
|
|
|
|
#define GDPROPERTY_HINTED(_PropName, _PropType, ...) \
|
|
|
|
ClassDB::bind_method(D_METHOD("get_" #_PropName), &CLASSNAME::get_##_PropName); \
|
|
|
|
ClassDB::bind_method(D_METHOD("set_" #_PropName, "value"), &CLASSNAME::set_##_PropName); \
|
|
|
|
ClassDB::add_property(MACRO_STRING(CLASSNAME), PropertyInfo(_PropType, #_PropName, __VA_ARGS__), \
|
|
|
|
"set_" #_PropName, "get_" #_PropName)
|
|
|
|
|
|
|
|
#define GDFUNCTION(_FnName) ClassDB::bind_method(D_METHOD(#_FnName), &CLASSNAME::_FnName)
|
|
|
|
|
|
|
|
#define GDFUNCTION_ARGS(_FnName, ...) ClassDB::bind_method(D_METHOD(#_FnName, __VA_ARGS__), &CLASSNAME::_FnName)
|
|
|
|
|
|
|
|
#define GDFUNCTION_STATIC(_FnName) \
|
|
|
|
ClassDB::bind_static_method(MACRO_STRING(CLASSNAME), D_METHOD(#_FnName), &CLASSNAME::_FnName)
|
|
|
|
|
|
|
|
#define GDFUNCTION_STATIC_ARGS(_FnName, ...) \
|
|
|
|
ClassDB::bind_static_method(MACRO_STRING(CLASSNAME), D_METHOD(#_FnName, __VA_ARGS__), &CLASSNAME::_FnName)
|
|
|
|
|
2024-03-20 10:35:13 +00:00
|
|
|
#define GDSIGNAL(...)\
|
|
|
|
ClassDB::add_signal(MACRO_STRING(CLASSNAME), MethodInfo(__VA_ARGS__))
|
|
|
|
|
2024-01-30 09:36:58 +00:00
|
|
|
#define GDRESOURCETYPE(_Class) vformat("%s/%s:%s", Variant::OBJECT, PROPERTY_HINT_RESOURCE_TYPE, #_Class)
|
|
|
|
|
2024-02-25 18:46:49 +00:00
|
|
|
#define GDEDITORONLY() if(!Engine::get_singleton()->is_editor_hint()) return;
|
|
|
|
#define GDGAMEONLY() if(Engine::get_singleton()->is_editor_hint()) return;
|
2024-02-02 07:47:05 +00:00
|
|
|
|
2024-01-30 09:36:58 +00:00
|
|
|
#endif // !UC_GODOT_MACROS_H
|