diff --git a/src/GDExtensionTemplate.cpp b/src/GDExtensionTemplate.cpp index 91fd7ea..aac2994 100644 --- a/src/GDExtensionTemplate.cpp +++ b/src/GDExtensionTemplate.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Unlicense #include "godot_cpp/core/class_db.hpp" +#include "godot_cpp/core/version.hpp" #include "GDExtensionTemplate.h" #include "Version.h" @@ -24,9 +25,27 @@ godot::String GDExtensionTemplate::version() return VersionInfo::VERSION_STR.data(); } +/*! +@brief Get the godot-cpp version string for this extension. + +@details +The version string is generated using godot-cpp's core/version.hpp. + +@return The version string (e.g. "godot-cpp v4.2.0-stable"). +*/ +godot::String GDExtensionTemplate::godotCPPVersion() +{ + return "godot-cpp v" + godot::uitos( GODOT_VERSION_MAJOR ) + "." + + godot::uitos( GODOT_VERSION_MINOR ) + "." + godot::uitos( GODOT_VERSION_PATCH ) + "-" + + GODOT_VERSION_STATUS; +} + /// Bind our methods so GDScript can access them. void GDExtensionTemplate::_bind_methods() { godot::ClassDB::bind_static_method( "GDExtensionTemplate", godot::D_METHOD( "version" ), &GDExtensionTemplate::version ); + godot::ClassDB::bind_static_method( "GDExtensionTemplate", + godot::D_METHOD( "godot_cpp_version" ), + &GDExtensionTemplate::godotCPPVersion ); } diff --git a/src/GDExtensionTemplate.h b/src/GDExtensionTemplate.h index 038aa40..5eb40d0 100644 --- a/src/GDExtensionTemplate.h +++ b/src/GDExtensionTemplate.h @@ -14,6 +14,7 @@ class GDExtensionTemplate : public godot::Object public: static godot::String version(); + static godot::String godotCPPVersion(); private: static void _bind_methods();