make sure array is created if not existing, as noted by Guilherme Felipe
This commit is contained in:
parent
d50921b550
commit
b0be30d9ef
4 changed files with 14 additions and 7 deletions
|
@ -3057,12 +3057,11 @@ String String::world_wrap(int p_chars_per_line) const {
|
||||||
if (i-from>=p_chars_per_line) {
|
if (i-from>=p_chars_per_line) {
|
||||||
if (last_space==-1) {
|
if (last_space==-1) {
|
||||||
ret+=substr(from,i-from+1)+"\n";
|
ret+=substr(from,i-from+1)+"\n";
|
||||||
from=i+1;
|
|
||||||
} else {
|
} else {
|
||||||
ret+=substr(from,last_space-from)+"\n";
|
ret+=substr(from,last_space-from)+"\n";
|
||||||
i=last_space;
|
i=last_space; //rewind
|
||||||
from=i+1;
|
|
||||||
}
|
}
|
||||||
|
from=i+1;
|
||||||
last_space=-1;
|
last_space=-1;
|
||||||
} else if (operator[](i)==' ' || operator[](i)=='\t') {
|
} else if (operator[](i)==' ' || operator[](i)=='\t') {
|
||||||
last_space=i;
|
last_space=i;
|
||||||
|
|
|
@ -9,7 +9,12 @@ Variant ArrayPropertyEdit::get_array() const{
|
||||||
Object*o = ObjectDB::get_instance(obj);
|
Object*o = ObjectDB::get_instance(obj);
|
||||||
if (!o)
|
if (!o)
|
||||||
return Array();
|
return Array();
|
||||||
return o->get(property);
|
Variant arr=o->get(property);
|
||||||
|
if (!arr.is_array()) {
|
||||||
|
Variant::CallError ce;
|
||||||
|
arr=Variant::construct(default_type,NULL,0,ce);
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArrayPropertyEdit::_notif_change() {
|
void ArrayPropertyEdit::_notif_change() {
|
||||||
|
@ -195,11 +200,12 @@ void ArrayPropertyEdit::_get_property_list( List<PropertyInfo> *p_list) const{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArrayPropertyEdit::edit(Object* p_obj,const StringName& p_prop) {
|
void ArrayPropertyEdit::edit(Object* p_obj,const StringName& p_prop,Variant::Type p_deftype) {
|
||||||
|
|
||||||
page=0;
|
page=0;
|
||||||
property=p_prop;
|
property=p_prop;
|
||||||
obj=p_obj->get_instance_ID();
|
obj=p_obj->get_instance_ID();
|
||||||
|
default_type=p_deftype;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,5 +226,6 @@ ArrayPropertyEdit::ArrayPropertyEdit()
|
||||||
vtypes+=",";
|
vtypes+=",";
|
||||||
vtypes+=Variant::get_type_name( Variant::Type(i) );
|
vtypes+=Variant::get_type_name( Variant::Type(i) );
|
||||||
}
|
}
|
||||||
|
default_type=Variant::NIL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ class ArrayPropertyEdit : public Reference {
|
||||||
StringName property;
|
StringName property;
|
||||||
String vtypes;
|
String vtypes;
|
||||||
Variant get_array() const;
|
Variant get_array() const;
|
||||||
|
Variant::Type default_type;
|
||||||
|
|
||||||
void _notif_change();
|
void _notif_change();
|
||||||
void _notif_changev(const String& p_v);
|
void _notif_changev(const String& p_v);
|
||||||
|
@ -27,7 +28,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void edit(Object* p_obj,const StringName& p_prop);
|
void edit(Object* p_obj, const StringName& p_prop, Variant::Type p_deftype);
|
||||||
|
|
||||||
ArrayPropertyEdit();
|
ArrayPropertyEdit();
|
||||||
};
|
};
|
||||||
|
|
|
@ -3143,7 +3143,7 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<ArrayPropertyEdit> ape = memnew( ArrayPropertyEdit );
|
Ref<ArrayPropertyEdit> ape = memnew( ArrayPropertyEdit );
|
||||||
ape->edit(obj,n);
|
ape->edit(obj,n,Variant::Type(t));
|
||||||
|
|
||||||
EditorNode::get_singleton()->push_item(ape.ptr());
|
EditorNode::get_singleton()->push_item(ape.ptr());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue