#ifndef UC_GODOT_MACROS_H #define UC_GODOT_MACROS_H #include "godot_cpp/classes/engine.hpp" #include "godot_cpp/core/class_db.hpp" #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) #define GDSIGNAL(...)\ ClassDB::add_signal(MACRO_STRING(CLASSNAME), MethodInfo(__VA_ARGS__)) #define GDRESOURCETYPE(_Class) vformat("%s/%s:%s", Variant::OBJECT, PROPERTY_HINT_RESOURCE_TYPE, #_Class) #define GDEDITORONLY() if(!Engine::get_singleton()->is_editor_hint()) return; #define GDGAMEONLY() if(Engine::get_singleton()->is_editor_hint()) return; #endif // !UC_GODOT_MACROS_H