summaryrefslogtreecommitdiffstats
path: root/test/src/example.cpp
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2022-08-19 10:30:06 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2022-08-22 12:59:38 +0300
commit270ad28931e57b7babdd7316c9b3d66b6f6a9e58 (patch)
tree1cfaaf40a9e9bb694f1aee1b2968beb2b936bee8 /test/src/example.cpp
parentf4542530058db4c5af2fac4b763005e6e8564db2 (diff)
downloadredot-cpp-270ad28931e57b7babdd7316c9b3d66b6f6a9e58.tar.gz
Add support for `_notification`, `_set`, `_get`, `_get_property_list`, `_property_can_revert`, `_property_get_revert`, and `_to_string` methods.
Diffstat (limited to 'test/src/example.cpp')
-rw-r--r--test/src/example.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/src/example.cpp b/test/src/example.cpp
index 992f29c..1cdc89a 100644
--- a/test/src/example.cpp
+++ b/test/src/example.cpp
@@ -58,6 +58,51 @@ int Example::def_args(int p_a, int p_b) {
return p_a + p_b;
}
+void Example::_notification(int p_what) {
+ UtilityFunctions::print("Notification: ", String::num(p_what));
+}
+
+bool Example::_set(const StringName &p_name, const Variant &p_value) {
+ if (p_name == StringName("property_from_list")) {
+ property_from_list = p_value;
+ return true;
+ }
+ return false;
+}
+
+bool Example::_get(const StringName &p_name, Variant &r_ret) const {
+ if (p_name == StringName("property_from_list")) {
+ r_ret = property_from_list;
+ return true;
+ }
+ return false;
+}
+
+String Example::_to_string() const {
+ return "[ GDExtension::Example <--> Instance ID:" + itos(get_instance_id()) + " ]";
+}
+
+void Example::_get_property_list(List<PropertyInfo> *p_list) const {
+ p_list->push_back(PropertyInfo(Variant::VECTOR3, "property_from_list"));
+}
+
+bool Example::_property_can_revert(const StringName &p_name) const {
+ if (p_name == StringName("property_from_list") && property_from_list != Vector3(42, 42, 42)) {
+ return true;
+ } else {
+ return false;
+ }
+};
+
+bool Example::_property_get_revert(const StringName &p_name, Variant &r_property) const {
+ if (p_name == StringName("property_from_list")) {
+ r_property = Vector3(42, 42, 42);
+ return true;
+ } else {
+ return false;
+ }
+};
+
void Example::_bind_methods() {
// Methods.
ClassDB::bind_method(D_METHOD("simple_func"), &Example::simple_func);