feat: added godot_macros.h
commit
0230e4e109
|
@ -0,0 +1,31 @@
|
|||
#ifndef UC_GODOT_MACROS_H
|
||||
#define UC_GODOT_MACROS_H
|
||||
|
||||
#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 GDRESOURCETYPE(_Class) vformat("%s/%s:%s", Variant::OBJECT, PROPERTY_HINT_RESOURCE_TYPE, #_Class)
|
||||
|
||||
#endif // !UC_GODOT_MACROS_H
|
Loading…
Reference in New Issue