summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-01-02 20:17:31 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-01-02 20:17:31 -0300
commit1597082c85a2bf3ddca0414de1fa32fb5f2e5350 (patch)
tree9329b37b872ef4b97ccd9ea7c2a9f2a234867303 /modules
parent61745855d0bb309cb0ebcd2d92fc15f7f6fb1840 (diff)
-Ability to roll-back script-exported properties to their default value on the script, closes #2128
Diffstat (limited to 'modules')
-rw-r--r--modules/gdscript/gd_script.cpp22
-rw-r--r--modules/gdscript/gd_script.h2
2 files changed, 24 insertions, 0 deletions
diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp
index 9dddfdc1d9..03e79393e2 100644
--- a/modules/gdscript/gd_script.cpp
+++ b/modules/gdscript/gd_script.cpp
@@ -1592,6 +1592,28 @@ void GDScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) {
}*/
#endif
+
+bool GDScript::get_property_default_value(const StringName& p_property, Variant &r_value) const {
+
+#ifdef TOOLS_ENABLED
+
+ //for (const Map<StringName,Variant>::Element *I=member_default_values.front();I;I=I->next()) {
+ // print_line("\t"+String(String(I->key())+":"+String(I->get())));
+ //}
+ const Map<StringName,Variant>::Element *E=member_default_values_cache.find(p_property);
+ if (E) {
+ r_value=E->get();
+ return true;
+ }
+
+ if (base_cache.is_valid()) {
+ return base_cache->get_property_default_value(p_property,r_value);
+ }
+#endif
+ return false;
+
+}
+
ScriptInstance* GDScript::instance_create(Object *p_this) {
diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h
index 173997a1fe..cf8f762a86 100644
--- a/modules/gdscript/gd_script.h
+++ b/modules/gdscript/gd_script.h
@@ -352,6 +352,8 @@ public:
Vector<uint8_t> get_as_byte_code() const;
+ bool get_property_default_value(const StringName& p_property,Variant& r_value) const;
+
virtual ScriptLanguage *get_language() const;
GDScript();