diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-04-21 15:23:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-21 15:23:35 +0200 |
commit | 79f82bd74284a3a90177d6446449d2a69285130f (patch) | |
tree | 8b20a991315c19c23a83b37eed22ac6ec0d34597 /editor | |
parent | 1061cf9f6634601d7c2b17b81f8f4699ee71d670 (diff) | |
parent | 5d4dc2d45caef77cdb52e365bc02f64d54046df5 (diff) |
Merge pull request #38063 from reduz/implement-typed-arrays
Add ability to bind typed arrays to script API
Diffstat (limited to 'editor')
-rw-r--r-- | editor/doc_data.cpp | 6 | ||||
-rw-r--r-- | editor/editor_help.cpp | 14 |
2 files changed, 19 insertions, 1 deletions
diff --git a/editor/doc_data.cpp b/editor/doc_data.cpp index dd9bacaa80..310e78ee60 100644 --- a/editor/doc_data.cpp +++ b/editor/doc_data.cpp @@ -193,6 +193,8 @@ static void return_doc_from_retinfo(DocData::MethodDoc &p_method, const Property p_method.return_type = "int"; } else if (p_retinfo.class_name != StringName()) { p_method.return_type = p_retinfo.class_name; + } else if (p_retinfo.type == Variant::ARRAY && p_retinfo.hint == PROPERTY_HINT_ARRAY_TYPE) { + p_method.return_type = p_retinfo.hint_string + "[]"; } else if (p_retinfo.hint == PROPERTY_HINT_RESOURCE_TYPE) { p_method.return_type = p_retinfo.hint_string; } else if (p_retinfo.type == Variant::NIL && p_retinfo.usage & PROPERTY_USAGE_NIL_IS_VARIANT) { @@ -215,6 +217,8 @@ static void argument_doc_from_arginfo(DocData::ArgumentDoc &p_argument, const Pr p_argument.type = "int"; } else if (p_arginfo.class_name != StringName()) { p_argument.type = p_arginfo.class_name; + } else if (p_arginfo.type == Variant::ARRAY && p_arginfo.hint == PROPERTY_HINT_ARRAY_TYPE) { + p_argument.type = p_arginfo.hint_string + "[]"; } else if (p_arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE) { p_argument.type = p_arginfo.hint_string; } else if (p_arginfo.type == Variant::NIL) { @@ -354,6 +358,8 @@ void DocData::generate(bool p_basic_types) { prop.type = "int"; } else if (retinfo.class_name != StringName()) { prop.type = retinfo.class_name; + } else if (retinfo.type == Variant::ARRAY && retinfo.hint == PROPERTY_HINT_ARRAY_TYPE) { + prop.type = retinfo.hint_string + "[]"; } else if (retinfo.hint == PROPERTY_HINT_RESOURCE_TYPE) { prop.type = retinfo.hint_string; diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index a36e2f360e..bad70d9714 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -198,7 +198,12 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) { const Color text_color = get_theme_color("default_color", "RichTextLabel"); const Color type_color = get_theme_color("accent_color", "Editor").linear_interpolate(text_color, 0.5); class_desc->push_color(type_color); + bool add_array = false; if (can_ref) { + if (t.ends_with("[]")) { + add_array = true; + t = t.replace("[]", ""); + } if (p_enum.empty()) { class_desc->push_meta("#" + t); //class } else { @@ -206,8 +211,15 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) { } } class_desc->add_text(t); - if (can_ref) + if (can_ref) { class_desc->pop(); + if (add_array) { + class_desc->add_text(" "); + class_desc->push_meta("#Array"); //class + class_desc->add_text("[]"); + class_desc->pop(); + } + } class_desc->pop(); } |