From 60692b4e45649612bea131671b01d7739cb2c50b Mon Sep 17 00:00:00 2001 From: Ekaterina Vaartis Date: Sun, 25 Dec 2022 01:46:57 +0300 Subject: Implement export_multiline support for Array[String] and Dictionary For arrays, specifically check if it's a string array and pass the type on to the editor. For dictionaries, save the hint on the type and use it later to draw the multiline editor, except for when adding a string key, because that doesn't make much sense. All string values however will be drawn as multiline. --- editor/editor_properties.cpp | 1 + editor/editor_properties_array_dict.cpp | 12 +++++++++++- editor/editor_properties_array_dict.h | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'editor') diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 4c9b18efe7..1df4917d94 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -4647,6 +4647,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ return editor; } else { EditorPropertyDictionary *editor = memnew(EditorPropertyDictionary); + editor->setup(p_hint); return editor; } } break; diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 451cb7cfee..6c86b5247c 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -818,6 +818,10 @@ void EditorPropertyDictionary::_change_type_menu(int p_index) { update_property(); } +void EditorPropertyDictionary::setup(PropertyHint p_hint) { + property_hint = p_hint; +} + void EditorPropertyDictionary::update_property() { Variant updated_val = get_edited_object()->get(get_edited_property()); @@ -929,7 +933,13 @@ void EditorPropertyDictionary::update_property() { prop = editor; } break; case Variant::STRING: { - prop = memnew(EditorPropertyText); + if (i != amount && property_hint == PROPERTY_HINT_MULTILINE_TEXT) { + // If this is NOT the new key field and there's a multiline hint, + // show the field as multiline + prop = memnew(EditorPropertyMultilineText); + } else { + prop = memnew(EditorPropertyText); + } } break; diff --git a/editor/editor_properties_array_dict.h b/editor/editor_properties_array_dict.h index ae61418528..68fb2f5f59 100644 --- a/editor/editor_properties_array_dict.h +++ b/editor/editor_properties_array_dict.h @@ -154,6 +154,7 @@ class EditorPropertyDictionary : public EditorProperty { EditorSpinSlider *size_sliderv = nullptr; Button *button_add_item = nullptr; EditorPaginator *paginator = nullptr; + PropertyHint property_hint; void _page_changed(int p_page); void _edit_pressed(); @@ -169,6 +170,7 @@ protected: void _notification(int p_what); public: + void setup(PropertyHint p_hint); virtual void update_property() override; EditorPropertyDictionary(); }; -- cgit v1.2.3