diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/core_bind.cpp | 28 | ||||
-rw-r--r-- | core/core_bind.h | 6 | ||||
-rw-r--r-- | core/input/input.cpp | 4 | ||||
-rw-r--r-- | core/input/input.h | 3 | ||||
-rw-r--r-- | core/object/object.cpp | 13 | ||||
-rw-r--r-- | core/object/object.h | 3 | ||||
-rw-r--r-- | core/string/translation.cpp | 23 | ||||
-rw-r--r-- | core/string/translation.h | 4 |
8 files changed, 75 insertions, 9 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 8ccf7d1f51..a0df1b6240 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -1519,6 +1519,30 @@ bool ClassDB::is_class_enabled(const StringName &p_class) const { return ::ClassDB::is_class_enabled(p_class); } +#ifdef TOOLS_ENABLED +void ClassDB::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { + const String pf = p_function; + bool first_argument_is_class = false; + if (p_idx == 0) { + first_argument_is_class = (pf == "get_inheriters_from_class" || pf == "get_parent_class" || + pf == "class_exists" || pf == "can_instantiate" || pf == "instantiate" || + pf == "class_has_signal" || pf == "class_get_signal" || pf == "class_get_signal_list" || + pf == "class_get_property_list" || pf == "class_get_property" || pf == "class_set_property" || + pf == "class_has_method" || pf == "class_get_method_list" || + pf == "class_get_integer_constant_list" || pf == "class_has_integer_constant" || pf == "class_get_integer_constant" || + pf == "class_has_enum" || pf == "class_get_enum_list" || pf == "class_get_enum_constants" || pf == "class_get_integer_constant_enum" || + pf == "is_class_enabled"); + } + if (first_argument_is_class || pf == "is_parent_class") { + for (const String &E : get_class_list()) { + r_options->push_back(E.quote()); + } + } + + Object::get_argument_options(p_function, p_idx, r_options); +} +#endif + void ClassDB::_bind_methods() { ::ClassDB::bind_method(D_METHOD("get_class_list"), &ClassDB::get_class_list); ::ClassDB::bind_method(D_METHOD("get_inheriters_from_class", "class"), &ClassDB::get_inheriters_from_class); @@ -1725,8 +1749,9 @@ bool Engine::is_printing_error_messages() const { return ::Engine::get_singleton()->is_printing_error_messages(); } +#ifdef TOOLS_ENABLED void Engine::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { - String pf = p_function; + const String pf = p_function; if (p_idx == 0 && (pf == "has_singleton" || pf == "get_singleton" || pf == "unregister_singleton")) { for (const String &E : get_singleton_list()) { r_options->push_back(E.quote()); @@ -1734,6 +1759,7 @@ void Engine::get_argument_options(const StringName &p_function, int p_idx, List< } Object::get_argument_options(p_function, p_idx, r_options); } +#endif void Engine::_bind_methods() { ClassDB::bind_method(D_METHOD("set_physics_ticks_per_second", "physics_ticks_per_second"), &Engine::set_physics_ticks_per_second); diff --git a/core/core_bind.h b/core/core_bind.h index 3440531124..64ab4dd7e2 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -460,6 +460,10 @@ public: bool is_class_enabled(const StringName &p_class) const; +#ifdef TOOLS_ENABLED + virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override; +#endif + ClassDB() {} ~ClassDB() {} }; @@ -530,7 +534,9 @@ public: void set_print_error_messages(bool p_enabled); bool is_printing_error_messages() const; +#ifdef TOOLS_ENABLED virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override; +#endif Engine() { singleton = this; } }; diff --git a/core/input/input.cpp b/core/input/input.cpp index 4117cc8c9c..3de0ed39ec 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -181,8 +181,9 @@ void Input::_bind_methods() { ADD_SIGNAL(MethodInfo("joy_connection_changed", PropertyInfo(Variant::INT, "device"), PropertyInfo(Variant::BOOL, "connected"))); } +#ifdef TOOLS_ENABLED void Input::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { - String pf = p_function; + const String pf = p_function; if ((p_idx == 0 && (pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" || pf == "is_action_just_pressed" || pf == "is_action_just_released" || pf == "get_action_strength" || pf == "get_action_raw_strength")) || (p_idx < 2 && pf == "get_axis") || @@ -201,6 +202,7 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, List<S } Object::get_argument_options(p_function, p_idx, r_options); } +#endif void Input::VelocityTrack::update(const Vector2 &p_delta_p, const Vector2 &p_screen_delta_p) { uint64_t tick = OS::get_singleton()->get_ticks_usec(); diff --git a/core/input/input.h b/core/input/input.h index 367bb93188..d1f284e8f7 100644 --- a/core/input/input.h +++ b/core/input/input.h @@ -270,7 +270,10 @@ protected: public: void set_mouse_mode(MouseMode p_mode); MouseMode get_mouse_mode() const; + +#ifdef TOOLS_ENABLED void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override; +#endif static Input *get_singleton(); diff --git a/core/object/object.cpp b/core/object/object.cpp index d9a5713c20..b34182cdaa 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -2096,15 +2096,17 @@ void ObjectDB::debug_objects(DebugFunc p_func) { spin_lock.unlock(); } +#ifdef TOOLS_ENABLED void Object::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { + const String pf = p_function; if (p_idx == 0) { - if (p_function == "connect" || p_function == "is_connected" || p_function == "disconnect" || p_function == "emit_signal" || p_function == "has_signal") { + if (pf == "connect" || pf == "is_connected" || pf == "disconnect" || pf == "emit_signal" || pf == "has_signal") { List<MethodInfo> signals; get_signal_list(&signals); for (const MethodInfo &E : signals) { r_options->push_back(E.name.quote()); } - } else if (p_function == "call" || p_function == "call_deferred" || p_function == "callv" || p_function == "has_method") { + } else if (pf == "call" || pf == "call_deferred" || pf == "callv" || pf == "has_method") { List<MethodInfo> methods; get_method_list(&methods); for (const MethodInfo &E : methods) { @@ -2113,7 +2115,7 @@ void Object::get_argument_options(const StringName &p_function, int p_idx, List< } r_options->push_back(E.name.quote()); } - } else if (p_function == "set" || p_function == "set_deferred" || p_function == "get") { + } else if (pf == "set" || pf == "set_deferred" || pf == "get") { List<PropertyInfo> properties; get_property_list(&properties); for (const PropertyInfo &E : properties) { @@ -2121,13 +2123,13 @@ void Object::get_argument_options(const StringName &p_function, int p_idx, List< r_options->push_back(E.name.quote()); } } - } else if (p_function == "set_meta" || p_function == "get_meta" || p_function == "has_meta" || p_function == "remove_meta") { + } else if (pf == "set_meta" || pf == "get_meta" || pf == "has_meta" || pf == "remove_meta") { for (const KeyValue<StringName, Variant> &K : metadata) { r_options->push_back(String(K.key).quote()); } } } else if (p_idx == 2) { - if (p_function == "connect") { + if (pf == "connect") { // Ideally, the constants should be inferred by the parameter. // But a parameter's PropertyInfo does not store the enum they come from, so this will do for now. List<StringName> constants; @@ -2138,6 +2140,7 @@ void Object::get_argument_options(const StringName &p_function, int p_idx, List< } } } +#endif SpinLock ObjectDB::spin_lock; uint32_t ObjectDB::slot_count = 0; diff --git a/core/object/object.h b/core/object/object.h index a062b8aa62..f97691841f 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -956,8 +956,6 @@ public: Variant::Type get_static_property_type(const StringName &p_property, bool *r_valid = nullptr) const; Variant::Type get_static_property_type_indexed(const Vector<StringName> &p_path, bool *r_valid = nullptr) const; - virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; - // Translate message (internationalization). String tr(const StringName &p_message, const StringName &p_context = "") const; String tr_n(const StringName &p_message, const StringName &p_message_plural, int p_n, const StringName &p_context = "") const; @@ -969,6 +967,7 @@ public: _FORCE_INLINE_ bool can_translate_messages() const { return _can_translate; } #ifdef TOOLS_ENABLED + virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; void editor_set_section_unfold(const String &p_section, bool p_unfolded); bool editor_is_section_unfolded(const String &p_section); const HashSet<String> &editor_get_section_folding() const { return editor_section_folding; } diff --git a/core/string/translation.cpp b/core/string/translation.cpp index 2f25f56eac..0a0052d6cb 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -1012,6 +1012,29 @@ bool TranslationServer::is_placeholder(String &p_message, int p_index) const { p_message[p_index + 1] == 'o' || p_message[p_index + 1] == 'x' || p_message[p_index + 1] == 'X' || p_message[p_index + 1] == 'f'); } +#ifdef TOOLS_ENABLED +void TranslationServer::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { + const String pf = p_function; + if (p_idx == 0) { + HashMap<String, String> *target_hash_map = nullptr; + if (pf == "get_language_name") { + target_hash_map = &language_map; + } else if (pf == "get_script_name") { + target_hash_map = &script_map; + } else if (pf == "get_country_name") { + target_hash_map = &country_name_map; + } + + if (target_hash_map) { + for (const KeyValue<String, String> &E : *target_hash_map) { + r_options->push_back(E.key.quote()); + } + } + } + Object::get_argument_options(p_function, p_idx, r_options); +} +#endif // TOOLS_ENABLED + void TranslationServer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_locale", "locale"), &TranslationServer::set_locale); ClassDB::bind_method(D_METHOD("get_locale"), &TranslationServer::get_locale); diff --git a/core/string/translation.h b/core/string/translation.h index bd7082dc9d..470ba88232 100644 --- a/core/string/translation.h +++ b/core/string/translation.h @@ -197,6 +197,10 @@ public: void load_translations(); +#ifdef TOOLS_ENABLED + virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override; +#endif // TOOLS_ENABLED + TranslationServer(); }; |