diff options
Diffstat (limited to 'modules/gdscript')
-rw-r--r-- | modules/gdscript/gd_editor.cpp | 69 | ||||
-rw-r--r-- | modules/gdscript/gd_function.cpp | 18 | ||||
-rw-r--r-- | modules/gdscript/gd_function.h | 2 | ||||
-rw-r--r-- | modules/gdscript/gd_tokenizer.cpp | 2 |
4 files changed, 20 insertions, 71 deletions
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index 5d404e2f7d..eea5b15236 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -1321,7 +1321,7 @@ static void _find_identifiers(GDCompletionContext &context, int p_line, bool p_o static const char *_type_names[Variant::VARIANT_MAX] = { "null", "bool", "int", "float", "String", "Vector2", "Rect2", "Vector3", "Transform2D", "Plane", "Quat", "AABB", "Basis", "Transform", - "Color", "Image", "NodePath", "RID", "Object", "InputEvent", "Dictionary", "Array", "RawArray", "IntArray", "FloatArray", "StringArray", + "Color", "NodePath", "RID", "Object", "Dictionary", "Array", "RawArray", "IntArray", "FloatArray", "StringArray", "Vector2Array", "Vector3Array", "ColorArray" }; @@ -1425,22 +1425,7 @@ void get_directory_contents(EditorFileSystemDirectory *p_dir, Set<String> &r_lis static void _find_type_arguments(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, const StringName &p_method, const GDCompletionIdentifier &id, int p_argidx, Set<String> &result, String &arghint) { //print_line("find type arguments?"); - if (id.type == Variant::INPUT_EVENT && String(p_method) == "is_action" && p_argidx == 0) { - - List<PropertyInfo> pinfo; - GlobalConfig::get_singleton()->get_property_list(&pinfo); - - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - - if (!pi.name.begins_with("input/")) - continue; - - String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length()); - result.insert("\"" + name + "\""); - } - - } else if (id.type == Variant::OBJECT && id.obj_type != StringName()) { + if (id.type == Variant::OBJECT && id.obj_type != StringName()) { MethodBind *m = ClassDB::get_method(id.obj_type, p_method); if (!m) { @@ -2266,54 +2251,8 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base } } else { - if (t.type == Variant::INPUT_EVENT) { - - //this is hardcoded otherwise it's not obvious - Set<String> exclude; - - for (int i = 0; i < InputEvent::TYPE_MAX; i++) { - - InputEvent ie; - ie.type = InputEvent::Type(i); - static const char *evnames[] = { - "# Common", - "# Key", - "# MouseMotion", - "# MouseButton", - "# JoypadMotion", - "# JoypadButton", - "# ScreenTouch", - "# ScreenDrag", - "# Action" - }; - - r_options->push_back(evnames[i]); - - Variant v = ie; - - if (i == 0) { - List<MethodInfo> mi; - v.get_method_list(&mi); - for (List<MethodInfo>::Element *E = mi.front(); E; E = E->next()) { - r_options->push_back(E->get().name + "("); - } - } - - List<PropertyInfo> pi; - v.get_property_list(&pi); - - for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) { - - if (i == 0) - exclude.insert(E->get().name); - else if (exclude.has(E->get().name)) - continue; - - r_options->push_back(E->get().name); - } - } - return OK; - } else { + //check InputEvent hint + { if (t.value.get_type() == Variant::NIL) { Variant::CallError ce; t.value = Variant::construct(t.type, NULL, 0, ce); diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp index 608256c88a..fb32d23ad5 100644 --- a/modules/gdscript/gd_function.cpp +++ b/modules/gdscript/gd_function.cpp @@ -1433,9 +1433,21 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount return ret; } -bool GDFunctionState::is_valid() const { +bool GDFunctionState::is_valid(bool p_extended_check) const { + + if (function == NULL) + return false; + + if (p_extended_check) { + //class instance gone? + if (state.instance_id && !ObjectDB::get_instance(state.instance_id)) + return false; + //script gone? + if (state.script_id && !ObjectDB::get_instance(state.script_id)) + return false; + } - return function != NULL; + return true; } Variant GDFunctionState::resume(const Variant &p_arg) { @@ -1464,7 +1476,7 @@ Variant GDFunctionState::resume(const Variant &p_arg) { void GDFunctionState::_bind_methods() { ClassDB::bind_method(D_METHOD("resume:Variant", "arg"), &GDFunctionState::resume, DEFVAL(Variant())); - ClassDB::bind_method(D_METHOD("is_valid"), &GDFunctionState::is_valid); + ClassDB::bind_method(D_METHOD("is_valid", "extended_check"), &GDFunctionState::is_valid, DEFVAL(false)); ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &GDFunctionState::_signal_callback, MethodInfo("_signal_callback")); } diff --git a/modules/gdscript/gd_function.h b/modules/gdscript/gd_function.h index f0bf33147b..6d20b19777 100644 --- a/modules/gdscript/gd_function.h +++ b/modules/gdscript/gd_function.h @@ -237,7 +237,7 @@ protected: static void _bind_methods(); public: - bool is_valid() const; + bool is_valid(bool p_extended_check = false) const; Variant resume(const Variant &p_arg = Variant()); GDFunctionState(); ~GDFunctionState(); diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp index 13674f1f9a..5e1a48ae86 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gd_tokenizer.cpp @@ -800,10 +800,8 @@ void GDTokenizerText::_advance() { { Variant::BASIS, "Basis" }, { Variant::TRANSFORM, "Transform" }, { Variant::COLOR, "Color" }, - { Variant::IMAGE, "Image" }, { Variant::_RID, "RID" }, { Variant::OBJECT, "Object" }, - { Variant::INPUT_EVENT, "InputEvent" }, { Variant::NODE_PATH, "NodePath" }, { Variant::DICTIONARY, "Dictionary" }, { Variant::ARRAY, "Array" }, |