aboutsummaryrefslogtreecommitdiff
path: root/core/script_language.cpp
diff options
context:
space:
mode:
authorJuan Linietsky2017-08-06 09:32:52 -0300
committerRémi Verschelde2017-08-13 20:29:43 +0200
commitc1b630105002393c7b6f35523eb760eaac5f56d9 (patch)
tree4d5be7d9af8038b77d11a033351c1fae6ec33cc8 /core/script_language.cpp
parent17b04adcc350e6ae8dc5cd9dc3037106384179a1 (diff)
downloadgodot-c1b630105002393c7b6f35523eb760eaac5f56d9.tar.gz
godot-c1b630105002393c7b6f35523eb760eaac5f56d9.tar.zst
godot-c1b630105002393c7b6f35523eb760eaac5f56d9.zip
Diffstat (limited to 'core/script_language.cpp')
-rw-r--r--core/script_language.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/core/script_language.cpp b/core/script_language.cpp
index c196f6bd1..e128def81 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -277,8 +277,23 @@ ScriptDebugger::ScriptDebugger() {
bool PlaceHolderScriptInstance::set(const StringName &p_name, const Variant &p_value) {
if (values.has(p_name)) {
+ Variant defval;
+ if (script->get_property_default_value(p_name, defval)) {
+ if (defval == p_value) {
+ values.erase(p_name);
+ return true;
+ }
+ }
values[p_name] = p_value;
return true;
+ } else {
+ Variant defval;
+ if (script->get_property_default_value(p_name, defval)) {
+ if (defval != p_value) {
+ values[p_name] = p_value;
+ }
+ return true;
+ }
}
return false;
}
@@ -288,12 +303,22 @@ bool PlaceHolderScriptInstance::get(const StringName &p_name, Variant &r_ret) co
r_ret = values[p_name];
return true;
}
+
+ Variant defval;
+ if (script->get_property_default_value(p_name, defval)) {
+ r_ret = defval;
+ return true;
+ }
return false;
}
void PlaceHolderScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
+ PropertyInfo pinfo = E->get();
+ if (!values.has(pinfo.name)) {
+ pinfo.usage |= PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE;
+ }
p_properties->push_back(E->get());
}
}
@@ -333,6 +358,14 @@ void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, c
if (!new_values.has(E->key()))
to_remove.push_back(E->key());
+
+ Variant defval;
+ if (script->get_property_default_value(E->key(), defval)) {
+ //remove because it's the same as the default value
+ if (defval == E->get()) {
+ to_remove.push_back(E->key());
+ }
+ }
}
while (to_remove.size()) {