keep default exported script values unless overriden, closes #8127
This commit is contained in:
parent
a18c8606bb
commit
475e8b28b2
|
@ -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,
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -3858,7 +3858,7 @@ void PropertyEditor::_item_edited() {
|
|||
break;
|
||||
|
||||
if (type == Variant::INT)
|
||||
_edit_set(name, round(item->get_range(1)), refresh_all);
|
||||
_edit_set(name, int64_t(round(item->get_range(1))), refresh_all);
|
||||
else
|
||||
_edit_set(name, item->get_range(1), refresh_all);
|
||||
} break;
|
||||
|
|
|
@ -516,6 +516,9 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
|
|||
|
||||
bool isdefault = ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && value.is_zero()) || ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && value.is_one());
|
||||
|
||||
if (E->get().usage & PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE) {
|
||||
isdefault = true; //is script default value
|
||||
}
|
||||
/*
|
||||
if (nd.instance<0 && ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && value.is_zero()) || ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && value.is_one())) {
|
||||
continue;
|
||||
|
|
|
@ -194,6 +194,7 @@ void ImageTexture::create(int p_width, int p_height, Image::Format p_format, uin
|
|||
}
|
||||
void ImageTexture::create_from_image(const Ref<Image> &p_image, uint32_t p_flags) {
|
||||
|
||||
ERR_FAIL_COND(p_image.is_null());
|
||||
flags = p_flags;
|
||||
w = p_image->get_width();
|
||||
h = p_image->get_height();
|
||||
|
|
Loading…
Reference in New Issue