diff options
| author | George Marques | 2018-01-30 02:06:19 -0200 |
|---|---|---|
| committer | Hein-Pieter van Braam | 2018-02-19 22:13:44 +0100 |
| commit | d7f73031fb59fedb98c0c3c2b2782d11dda1d376 (patch) | |
| tree | a5a01269cf400974ad97f8b7bedf46db0b9d255d | |
| parent | ba36ef54659f4939b9ec19a56453dffc343eac58 (diff) | |
| download | godot-d7f73031fb59fedb98c0c3c2b2782d11dda1d376.tar.gz godot-d7f73031fb59fedb98c0c3c2b2782d11dda1d376.tar.zst godot-d7f73031fb59fedb98c0c3c2b2782d11dda1d376.zip | |
Show default values in docs for GDScript built-in functions
(cherry picked from commit dca2ae78dd04530bf96c3d550e57fc945876ea95)
| -rw-r--r-- | editor/doc/doc_data.cpp | 8 | ||||
| -rw-r--r-- | modules/gdscript/gdscript_editor.cpp | 4 | ||||
| -rw-r--r-- | modules/gdscript/gdscript_functions.cpp | 2 |
3 files changed, 12 insertions, 2 deletions
diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index 58eaab78e..3a418e5f3 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -611,6 +611,14 @@ void DocData::generate(bool p_basic_types) { ArgumentDoc ad; argument_doc_from_arginfo(ad, mi.arguments[i]); + + int darg_idx = i - (mi.arguments.size() - mi.default_arguments.size()); + + if (darg_idx >= 0) { + Variant default_arg = E->get().default_arguments[darg_idx]; + ad.default_value = default_arg.get_construct_string(); + } + md.arguments.push_back(ad); } diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index c4269ab4a..505562324 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -369,8 +369,8 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const mi.name = "yield"; mi.arguments.push_back(PropertyInfo(Variant::OBJECT, "object")); mi.arguments.push_back(PropertyInfo(Variant::STRING, "signal")); - mi.default_arguments.push_back(Variant::NIL); - mi.default_arguments.push_back(Variant::STRING); + mi.default_arguments.push_back(Variant()); + mi.default_arguments.push_back(String()); mi.return_val = PropertyInfo(Variant::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, "GDScriptFunctionState"); p_functions->push_back(mi); } diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp index eceec2781..c067d5409 100644 --- a/modules/gdscript/gdscript_functions.cpp +++ b/modules/gdscript/gdscript_functions.cpp @@ -1760,12 +1760,14 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) { case COLOR8: { MethodInfo mi("Color8", PropertyInfo(Variant::INT, "r8"), PropertyInfo(Variant::INT, "g8"), PropertyInfo(Variant::INT, "b8"), PropertyInfo(Variant::INT, "a8")); + mi.default_arguments.push_back(255); mi.return_val.type = Variant::COLOR; return mi; } break; case COLORN: { MethodInfo mi("ColorN", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::REAL, "alpha")); + mi.default_arguments.push_back(1.0f); mi.return_val.type = Variant::COLOR; return mi; } break; |
