summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-08-06 09:32:52 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-08-06 09:33:59 -0300
commit475e8b28b28962a24b783597f9a3cabf4a370dee (patch)
tree6c6d86841bafdfbbd7a07d5593813d422413f06a /core
parenta18c8606bbc16e3274b8be9f79715023b10ce3e2 (diff)
keep default exported script values unless overriden, closes #8127
Diffstat (limited to 'core')
-rw-r--r--core/object.h1
-rw-r--r--core/script_language.cpp33
2 files changed, 34 insertions, 0 deletions
diff --git a/core/object.h b/core/object.h
index ca2090094e..fd3bb624ec 100644
--- a/core/object.h
+++ b/core/object.h
@@ -105,6 +105,7 @@ enum PropertyUsageFlags {
PROPERTY_USAGE_STORE_IF_NULL = 16384,
PROPERTY_USAGE_ANIMATE_AS_TRIGGER = 32768,
PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED = 65536,
+ PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE = 1 << 17,
PROPERTY_USAGE_DEFAULT = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK,
PROPERTY_USAGE_DEFAULT_INTL = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK | PROPERTY_USAGE_INTERNATIONALIZED,
diff --git a/core/script_language.cpp b/core/script_language.cpp
index aeb1573840..bb99e0abae 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -280,8 +280,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;
}
@@ -291,12 +306,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());
}
}
@@ -336,6 +361,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()) {