mirror of
https://github.com/godotengine/godot.git
synced 2025-01-23 19:12:24 -05:00
parent
e19da5ab6a
commit
8ecef3496c
4 changed files with 62 additions and 34 deletions
|
@ -2654,34 +2654,42 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
|
||||||
} break;
|
} break;
|
||||||
case Variant::ARRAY: {
|
case Variant::ARRAY: {
|
||||||
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
||||||
|
editor->setup(Variant::ARRAY);
|
||||||
add_property_editor(p_path, editor);
|
add_property_editor(p_path, editor);
|
||||||
} break;
|
} break;
|
||||||
case Variant::POOL_BYTE_ARRAY: {
|
case Variant::POOL_BYTE_ARRAY: {
|
||||||
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
||||||
|
editor->setup(Variant::POOL_BYTE_ARRAY);
|
||||||
add_property_editor(p_path, editor);
|
add_property_editor(p_path, editor);
|
||||||
} break; // 20
|
} break; // 20
|
||||||
case Variant::POOL_INT_ARRAY: {
|
case Variant::POOL_INT_ARRAY: {
|
||||||
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
||||||
|
editor->setup(Variant::POOL_INT_ARRAY);
|
||||||
add_property_editor(p_path, editor);
|
add_property_editor(p_path, editor);
|
||||||
} break;
|
} break;
|
||||||
case Variant::POOL_REAL_ARRAY: {
|
case Variant::POOL_REAL_ARRAY: {
|
||||||
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
||||||
|
editor->setup(Variant::POOL_REAL_ARRAY);
|
||||||
add_property_editor(p_path, editor);
|
add_property_editor(p_path, editor);
|
||||||
} break;
|
} break;
|
||||||
case Variant::POOL_STRING_ARRAY: {
|
case Variant::POOL_STRING_ARRAY: {
|
||||||
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
||||||
|
editor->setup(Variant::POOL_STRING_ARRAY);
|
||||||
add_property_editor(p_path, editor);
|
add_property_editor(p_path, editor);
|
||||||
} break;
|
} break;
|
||||||
case Variant::POOL_VECTOR2_ARRAY: {
|
case Variant::POOL_VECTOR2_ARRAY: {
|
||||||
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
||||||
|
editor->setup(Variant::POOL_VECTOR2_ARRAY);
|
||||||
add_property_editor(p_path, editor);
|
add_property_editor(p_path, editor);
|
||||||
} break;
|
} break;
|
||||||
case Variant::POOL_VECTOR3_ARRAY: {
|
case Variant::POOL_VECTOR3_ARRAY: {
|
||||||
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
||||||
|
editor->setup(Variant::POOL_VECTOR3_ARRAY);
|
||||||
add_property_editor(p_path, editor);
|
add_property_editor(p_path, editor);
|
||||||
} break; // 25
|
} break; // 25
|
||||||
case Variant::POOL_COLOR_ARRAY: {
|
case Variant::POOL_COLOR_ARRAY: {
|
||||||
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
||||||
|
editor->setup(Variant::POOL_COLOR_ARRAY);
|
||||||
add_property_editor(p_path, editor);
|
add_property_editor(p_path, editor);
|
||||||
} break;
|
} break;
|
||||||
default: {}
|
default: {}
|
||||||
|
|
|
@ -172,28 +172,9 @@ void EditorPropertyArray::update_property() {
|
||||||
|
|
||||||
Variant array = get_edited_object()->get(get_edited_property());
|
Variant array = get_edited_object()->get(get_edited_property());
|
||||||
|
|
||||||
if ((!array.is_array()) != edit->is_disabled()) {
|
String arrtype = "";
|
||||||
|
switch (array_type) {
|
||||||
if (array.is_array()) {
|
|
||||||
edit->set_disabled(false);
|
|
||||||
edit->set_pressed(false);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
edit->set_disabled(true);
|
|
||||||
if (vbox) {
|
|
||||||
memdelete(vbox);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!array.is_array()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String arrtype;
|
|
||||||
switch (array.get_type()) {
|
|
||||||
case Variant::ARRAY: {
|
case Variant::ARRAY: {
|
||||||
|
|
||||||
arrtype = "Array";
|
arrtype = "Array";
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
@ -229,6 +210,15 @@ void EditorPropertyArray::update_property() {
|
||||||
default: {}
|
default: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!array.is_array()) {
|
||||||
|
edit->set_text(arrtype + "[" + Variant::get_type_name(array.get_type()) + "]");
|
||||||
|
edit->set_pressed(false);
|
||||||
|
if (vbox) {
|
||||||
|
memdelete(vbox);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
edit->set_text(arrtype + "[" + itos(array.call("size")) + "]");
|
edit->set_text(arrtype + "[" + itos(array.call("size")) + "]");
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
|
@ -418,41 +408,56 @@ void EditorPropertyArray::update_property() {
|
||||||
case Variant::DICTIONARY: {
|
case Variant::DICTIONARY: {
|
||||||
prop = memnew(EditorPropertyDictionary);
|
prop = memnew(EditorPropertyDictionary);
|
||||||
|
|
||||||
} break;
|
|
||||||
case Variant::ARRAY: {
|
|
||||||
|
|
||||||
prop = memnew(EditorPropertyArray);
|
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
// arrays
|
// arrays
|
||||||
|
case Variant::ARRAY: {
|
||||||
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
||||||
|
editor->setup(Variant::ARRAY);
|
||||||
|
prop = editor;
|
||||||
|
|
||||||
|
} break;
|
||||||
case Variant::POOL_BYTE_ARRAY: {
|
case Variant::POOL_BYTE_ARRAY: {
|
||||||
prop = memnew(EditorPropertyArray);
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
||||||
|
editor->setup(Variant::POOL_BYTE_ARRAY);
|
||||||
|
prop = editor;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case Variant::POOL_INT_ARRAY: {
|
case Variant::POOL_INT_ARRAY: {
|
||||||
prop = memnew(EditorPropertyArray);
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
||||||
|
editor->setup(Variant::POOL_INT_ARRAY);
|
||||||
|
prop = editor;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case Variant::POOL_REAL_ARRAY: {
|
case Variant::POOL_REAL_ARRAY: {
|
||||||
|
|
||||||
prop = memnew(EditorPropertyArray);
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
||||||
|
editor->setup(Variant::POOL_REAL_ARRAY);
|
||||||
|
prop = editor;
|
||||||
} break;
|
} break;
|
||||||
case Variant::POOL_STRING_ARRAY: {
|
case Variant::POOL_STRING_ARRAY: {
|
||||||
|
|
||||||
prop = memnew(EditorPropertyArray);
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
||||||
|
editor->setup(Variant::POOL_STRING_ARRAY);
|
||||||
|
prop = editor;
|
||||||
} break;
|
} break;
|
||||||
case Variant::POOL_VECTOR2_ARRAY: {
|
case Variant::POOL_VECTOR2_ARRAY: {
|
||||||
|
|
||||||
prop = memnew(EditorPropertyArray);
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
||||||
|
editor->setup(Variant::POOL_VECTOR2_ARRAY);
|
||||||
|
prop = editor;
|
||||||
} break;
|
} break;
|
||||||
case Variant::POOL_VECTOR3_ARRAY: {
|
case Variant::POOL_VECTOR3_ARRAY: {
|
||||||
prop = memnew(EditorPropertyArray);
|
|
||||||
|
|
||||||
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
||||||
|
editor->setup(Variant::POOL_VECTOR3_ARRAY);
|
||||||
|
prop = editor;
|
||||||
} break;
|
} break;
|
||||||
case Variant::POOL_COLOR_ARRAY: {
|
case Variant::POOL_COLOR_ARRAY: {
|
||||||
prop = memnew(EditorPropertyArray);
|
|
||||||
|
|
||||||
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
||||||
|
editor->setup(Variant::POOL_COLOR_ARRAY);
|
||||||
|
prop = editor;
|
||||||
} break;
|
} break;
|
||||||
default: {}
|
default: {}
|
||||||
}
|
}
|
||||||
|
@ -496,6 +501,14 @@ void EditorPropertyArray::_notification(int p_what) {
|
||||||
}
|
}
|
||||||
void EditorPropertyArray::_edit_pressed() {
|
void EditorPropertyArray::_edit_pressed() {
|
||||||
|
|
||||||
|
Variant array = get_edited_object()->get(get_edited_property());
|
||||||
|
if (!array.is_array()) {
|
||||||
|
Variant::CallError ce;
|
||||||
|
array = Variant::construct(array_type, NULL, 0, ce);
|
||||||
|
|
||||||
|
get_edited_object()->set(get_edited_property(), array);
|
||||||
|
}
|
||||||
|
|
||||||
get_edited_object()->editor_set_section_unfold(get_edited_property(), edit->is_pressed());
|
get_edited_object()->editor_set_section_unfold(get_edited_property(), edit->is_pressed());
|
||||||
update_property();
|
update_property();
|
||||||
}
|
}
|
||||||
|
@ -522,6 +535,11 @@ void EditorPropertyArray::_length_changed(double p_page) {
|
||||||
update_property();
|
update_property();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorPropertyArray::setup(Variant::Type p_array_type) {
|
||||||
|
|
||||||
|
array_type = p_array_type;
|
||||||
|
}
|
||||||
|
|
||||||
void EditorPropertyArray::_bind_methods() {
|
void EditorPropertyArray::_bind_methods() {
|
||||||
ClassDB::bind_method("_edit_pressed", &EditorPropertyArray::_edit_pressed);
|
ClassDB::bind_method("_edit_pressed", &EditorPropertyArray::_edit_pressed);
|
||||||
ClassDB::bind_method("_page_changed", &EditorPropertyArray::_page_changed);
|
ClassDB::bind_method("_page_changed", &EditorPropertyArray::_page_changed);
|
||||||
|
|
|
@ -62,6 +62,7 @@ class EditorPropertyArray : public EditorProperty {
|
||||||
EditorSpinSlider *length;
|
EditorSpinSlider *length;
|
||||||
EditorSpinSlider *page;
|
EditorSpinSlider *page;
|
||||||
HBoxContainer *page_hb;
|
HBoxContainer *page_hb;
|
||||||
|
Variant::Type array_type;
|
||||||
|
|
||||||
void _page_changed(double p_page);
|
void _page_changed(double p_page);
|
||||||
void _length_changed(double p_page);
|
void _length_changed(double p_page);
|
||||||
|
@ -75,6 +76,7 @@ protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
void setup(Variant::Type p_array_type);
|
||||||
virtual void update_property();
|
virtual void update_property();
|
||||||
EditorPropertyArray();
|
EditorPropertyArray();
|
||||||
};
|
};
|
||||||
|
|
|
@ -4093,7 +4093,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
|
||||||
#endif
|
#endif
|
||||||
tokenizer->advance();
|
tokenizer->advance();
|
||||||
|
|
||||||
Node *subexpr = _parse_and_reduce_expression(p_class, false, autoexport);
|
Node *subexpr = _parse_and_reduce_expression(p_class, false, autoexport || member._export.type != Variant::NIL);
|
||||||
if (!subexpr) {
|
if (!subexpr) {
|
||||||
if (_recover_from_completion()) {
|
if (_recover_from_completion()) {
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue