diff options
124 files changed, 2475 insertions, 692 deletions
diff --git a/.github/workflows/windows_builds.yml b/.github/workflows/windows_builds.yml index 8c88c8fa64..c0b291b252 100644 --- a/.github/workflows/windows_builds.yml +++ b/.github/workflows/windows_builds.yml @@ -5,7 +5,7 @@ on: [push, pull_request] # SCONS_CACHE for windows must be set in the build environment env: # Only used for the cache key. Increment version to force clean build. - GODOT_BASE_BRANCH: master + GODOT_BASE_BRANCH: master-v2 SCONSFLAGS: verbose=yes warnings=all werror=yes module_text_server_fb_enabled=yes SCONS_CACHE_MSVC_CONFIG: true @@ -57,6 +57,7 @@ jobs: target: ${{ matrix.target }} tools: ${{ matrix.tools }} tests: ${{ matrix.tests }} + scons-cache-limit: 8192 # Execute unit tests for the editor - name: Unit tests diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 7150459d84..706395afa9 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -2093,10 +2093,6 @@ int ClassDB::get_integer_constant(const StringName &p_class, const StringName &p return c; } -StringName ClassDB::get_category(const StringName &p_node) const { - return ::ClassDB::get_category(p_node); -} - bool ClassDB::has_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance) const { return ::ClassDB::has_enum(p_class, p_name, p_no_inheritance); } @@ -2168,7 +2164,6 @@ void ClassDB::_bind_methods() { ::ClassDB::bind_method(D_METHOD("class_get_enum_constants", "class", "enum", "no_inheritance"), &ClassDB::get_enum_constants, DEFVAL(false)); ::ClassDB::bind_method(D_METHOD("class_get_integer_constant_enum", "class", "name", "no_inheritance"), &ClassDB::get_integer_constant_enum, DEFVAL(false)); - ::ClassDB::bind_method(D_METHOD("class_get_category", "class"), &ClassDB::get_category); ::ClassDB::bind_method(D_METHOD("is_class_enabled", "class"), &ClassDB::is_class_enabled); } @@ -2296,6 +2291,18 @@ Vector<String> Engine::get_singleton_list() const { return ret; } +void Engine::register_script_language(ScriptLanguage *p_language) { + ScriptServer::register_language(p_language); +} + +int Engine::get_script_language_count() { + return ScriptServer::get_language_count(); +} + +ScriptLanguage *Engine::get_script_language(int p_index) const { + return ScriptServer::get_language(p_index); +} + void Engine::set_editor_hint(bool p_enabled) { ::Engine::get_singleton()->set_editor_hint(p_enabled); } @@ -2347,6 +2354,10 @@ void Engine::_bind_methods() { ClassDB::bind_method(D_METHOD("unregister_singleton", "name"), &Engine::unregister_singleton); ClassDB::bind_method(D_METHOD("get_singleton_list"), &Engine::get_singleton_list); + ClassDB::bind_method(D_METHOD("register_script_language", "language"), &Engine::register_script_language); + ClassDB::bind_method(D_METHOD("get_script_language_count"), &Engine::get_script_language_count); + ClassDB::bind_method(D_METHOD("get_script_language", "index"), &Engine::get_script_language); + ClassDB::bind_method(D_METHOD("is_editor_hint"), &Engine::is_editor_hint); ClassDB::bind_method(D_METHOD("set_print_error_messages", "enabled"), &Engine::set_print_error_messages); diff --git a/core/core_bind.h b/core/core_bind.h index a0fdf26dff..907f37c5fa 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -38,6 +38,7 @@ #include "core/io/image.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" +#include "core/object/script_language.h" #include "core/os/os.h" #include "core/os/semaphore.h" #include "core/os/thread.h" @@ -604,7 +605,6 @@ public: PackedStringArray get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const; bool has_integer_constant(const StringName &p_class, const StringName &p_name) const; int get_integer_constant(const StringName &p_class, const StringName &p_name) const; - StringName get_category(const StringName &p_node) const; bool has_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false) const; PackedStringArray get_enum_list(const StringName &p_class, bool p_no_inheritance = false) const; @@ -664,6 +664,10 @@ public: void unregister_singleton(const StringName &p_name); Vector<String> get_singleton_list() const; + void register_script_language(ScriptLanguage *p_language); + int get_script_language_count(); + ScriptLanguage *get_script_language(int p_index) const; + void set_editor_hint(bool p_enabled); bool is_editor_hint() const; diff --git a/core/doc_data.h b/core/doc_data.h index 9286b843be..194a39a729 100644 --- a/core/doc_data.h +++ b/core/doc_data.h @@ -152,7 +152,7 @@ public: struct ClassDoc { String name; String inherits; - String category; + String category; // FIXME: Wrongly used by VisualScriptPropertySelector, should be removed. String brief_description; String description; Vector<TutorialDoc> tutorials; diff --git a/core/extension/SCsub b/core/extension/SCsub index a3a54250c1..23727c1b76 100644 --- a/core/extension/SCsub +++ b/core/extension/SCsub @@ -2,6 +2,12 @@ Import("env") +import make_wrappers +from platform_methods import run_in_subprocess + +env.CommandNoCache(["ext_wrappers.gen.inc"], "make_wrappers.py", run_in_subprocess(make_wrappers.run)) + + env_extension = env.Clone() env_extension.add_source_files(env.core_sources, "*.cpp") diff --git a/core/extension/gdnative_interface.cpp b/core/extension/gdnative_interface.cpp index d0461611ec..b5b340731d 100644 --- a/core/extension/gdnative_interface.cpp +++ b/core/extension/gdnative_interface.cpp @@ -32,6 +32,7 @@ #include "core/config/engine.h" #include "core/object/class_db.h" +#include "core/object/script_language_extension.h" #include "core/os/memory.h" #include "core/variant/variant.h" #include "core/version.h" @@ -864,6 +865,13 @@ static GDObjectInstanceID gdnative_object_get_instance_id(const GDNativeObjectPt return (GDObjectInstanceID)o->get_instance_id(); } +static GDNativeScriptInstancePtr gdnative_script_instance_create(const GDNativeExtensionScriptInstanceInfo *p_info, GDNativeExtensionScriptInstanceDataPtr p_instance_data) { + ScriptInstanceExtension *script_instance_extension = memnew(ScriptInstanceExtension); + script_instance_extension->instance = p_instance_data; + script_instance_extension->native_info = p_info; + return reinterpret_cast<GDNativeScriptInstancePtr>(script_instance_extension); +} + static GDNativeMethodBindPtr gdnative_classdb_get_method_bind(const char *p_classname, const char *p_methodname, GDNativeInt p_hash) { MethodBind *mb = ClassDB::get_method(StringName(p_classname), StringName(p_methodname)); ERR_FAIL_COND_V(!mb, nullptr); @@ -1032,6 +1040,10 @@ void gdnative_setup_interface(GDNativeInterface *p_interface) { gdni.object_get_instance_from_id = gdnative_object_get_instance_from_id; gdni.object_get_instance_id = gdnative_object_get_instance_id; + /* SCRIPT INSTANCE */ + + gdni.script_instance_create = gdnative_script_instance_create; + /* CLASSDB */ gdni.classdb_construct_object = gdnative_classdb_construct_object; diff --git a/core/extension/gdnative_interface.h b/core/extension/gdnative_interface.h index c86bee316d..732a1b5af0 100644 --- a/core/extension/gdnative_interface.h +++ b/core/extension/gdnative_interface.h @@ -205,6 +205,17 @@ typedef struct { uint32_t usage; } GDNativePropertyInfo; +typedef struct { + const char *name; + GDNativePropertyInfo return_value; + uint32_t flags; // From GDNativeExtensionClassMethodFlags + int32_t id; + GDNativePropertyInfo *arguments; + uint32_t argument_count; + GDNativeVariantPtr default_arguments; + uint32_t default_argument_count; +} GDNativeMethodInfo; + typedef const GDNativePropertyInfo *(*GDNativeExtensionClassGetPropertyList)(GDExtensionClassInstancePtr p_instance, uint32_t *r_count); typedef void (*GDNativeExtensionClassFreePropertyList)(GDExtensionClassInstancePtr p_instance, const GDNativePropertyInfo *p_list); typedef void (*GDNativeExtensionClassNotification)(GDExtensionClassInstancePtr p_instance, int32_t p_what); @@ -289,6 +300,79 @@ typedef struct { GDNativeVariantPtr *default_arguments; } GDNativeExtensionClassMethodInfo; +/* SCRIPT INSTANCE EXTENSION */ + +typedef void *GDNativeExtensionScriptInstanceDataPtr; // Pointer to custom ScriptInstance native implementation + +typedef GDNativeBool (*GDNativeExtensionScriptInstanceSet)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value); +typedef GDNativeBool (*GDNativeExtensionScriptInstanceGet)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret); +typedef const GDNativePropertyInfo *(*GDNativeExtensionScriptInstanceGetPropertyList)(GDNativeExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count); +typedef void (*GDNativeExtensionScriptInstanceFreePropertyList)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativePropertyInfo *p_list); +typedef GDNativeVariantType (*GDNativeExtensionScriptInstanceGetPropertyType)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name, GDNativeBool *r_is_valid); + +typedef GDNativeObjectPtr (*GDNativeExtensionScriptInstanceGetOwner)(GDNativeExtensionScriptInstanceDataPtr p_instance); +typedef void (*GDNativeExtensionScriptInstancePropertyStateAdd)(const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value, void *p_userdata); +typedef void (*GDNativeExtensionScriptInstanceGetPropertyState)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeExtensionScriptInstancePropertyStateAdd p_add_func, void *p_userdata); + +typedef const GDNativeMethodInfo *(*GDNativeExtensionScriptInstanceGetMethodList)(GDNativeExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count); +typedef void (*GDNativeExtensionScriptInstanceFreeMethodList)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeMethodInfo *p_list); + +typedef GDNativeBool (*GDNativeExtensionScriptInstanceHasMethod)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name); + +typedef void (*GDNativeExtensionScriptInstanceCall)(GDNativeExtensionScriptInstanceDataPtr p_self, const GDNativeStringNamePtr p_method, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error); +typedef void (*GDNativeExtensionScriptInstanceNotification)(GDNativeExtensionScriptInstanceDataPtr p_instance, int32_t p_what); +typedef const char *(*GDNativeExtensionScriptInstanceToString)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeBool *r_is_valid); + +typedef void (*GDNativeExtensionScriptInstanceRefCountIncremented)(GDNativeExtensionScriptInstanceDataPtr p_instance); +typedef GDNativeBool (*GDNativeExtensionScriptInstanceRefCountDecremented)(GDNativeExtensionScriptInstanceDataPtr p_instance); + +typedef GDNativeObjectPtr (*GDNativeExtensionScriptInstanceGetScript)(GDNativeExtensionScriptInstanceDataPtr p_instance); +typedef GDNativeBool (*GDNativeExtensionScriptInstanceIsPlaceholder)(GDNativeExtensionScriptInstanceDataPtr p_instance); + +typedef void *GDNativeExtensionScriptLanguagePtr; + +typedef GDNativeExtensionScriptLanguagePtr (*GDNativeExtensionScriptInstanceGetLanguage)(GDNativeExtensionScriptInstanceDataPtr p_instance); + +typedef void (*GDNativeExtensionScriptInstanceFree)(GDNativeExtensionScriptInstanceDataPtr p_instance); + +typedef void *GDNativeScriptInstancePtr; // Pointer to ScriptInstance. + +typedef struct { + GDNativeExtensionScriptInstanceSet set_func; + GDNativeExtensionScriptInstanceGet get_func; + GDNativeExtensionScriptInstanceGetPropertyList get_property_list_func; + GDNativeExtensionScriptInstanceFreePropertyList free_property_list_func; + GDNativeExtensionScriptInstanceGetPropertyType get_property_type_func; + + GDNativeExtensionScriptInstanceGetOwner get_owner_func; + GDNativeExtensionScriptInstanceGetPropertyState get_property_state_func; + + GDNativeExtensionScriptInstanceGetMethodList get_method_list_func; + GDNativeExtensionScriptInstanceFreeMethodList free_method_list_func; + + GDNativeExtensionScriptInstanceHasMethod has_method_func; + + GDNativeExtensionScriptInstanceCall call_func; + GDNativeExtensionScriptInstanceNotification notification_func; + + GDNativeExtensionScriptInstanceToString to_string_func; + + GDNativeExtensionScriptInstanceRefCountIncremented refcount_incremented_func; + GDNativeExtensionScriptInstanceRefCountDecremented refcount_decremented_func; + + GDNativeExtensionScriptInstanceGetScript get_script_func; + + GDNativeExtensionScriptInstanceIsPlaceholder is_placeholder_func; + + GDNativeExtensionScriptInstanceSet set_fallback_func; + GDNativeExtensionScriptInstanceGet get_fallback_func; + + GDNativeExtensionScriptInstanceGetLanguage get_language_func; + + GDNativeExtensionScriptInstanceFree free_func; + +} GDNativeExtensionScriptInstanceInfo; + /* INTERFACE */ typedef struct { @@ -441,6 +525,10 @@ typedef struct { GDNativeObjectPtr (*object_get_instance_from_id)(GDObjectInstanceID p_instance_id); GDObjectInstanceID (*object_get_instance_id)(const GDNativeObjectPtr p_object); + /* SCRIPT INSTANCE */ + + GDNativeScriptInstancePtr (*script_instance_create)(const GDNativeExtensionScriptInstanceInfo *p_info, GDNativeExtensionScriptInstanceDataPtr p_instance_data); + /* CLASSDB */ GDNativeObjectPtr (*classdb_construct_object)(const char *p_classname); /* The passed class must be a built-in godot class, or an already-registered extension class. In both case, object_set_instance should be called to fully initialize the object. */ GDNativeMethodBindPtr (*classdb_get_method_bind)(const char *p_classname, const char *p_methodname, GDNativeInt p_hash); diff --git a/servers/extensions/make_wrappers.py b/core/extension/make_wrappers.py index 862d313fba..862d313fba 100644 --- a/servers/extensions/make_wrappers.py +++ b/core/extension/make_wrappers.py diff --git a/core/io/ip.h b/core/io/ip.h index ab00b7b0a6..ebd944a949 100644 --- a/core/io/ip.h +++ b/core/io/ip.h @@ -38,7 +38,6 @@ struct _IP_ResolverPrivate; class IP : public Object { GDCLASS(IP, Object); - OBJ_CATEGORY("Networking"); public: enum ResolverStatus { diff --git a/core/io/resource.h b/core/io/resource.h index b1e1c15541..8068000f32 100644 --- a/core/io/resource.h +++ b/core/io/resource.h @@ -48,7 +48,6 @@ private: class Resource : public RefCounted { GDCLASS(Resource, RefCounted); - OBJ_CATEGORY("Resources"); public: static void register_custom_data_to_otdb() { ClassDB::add_resource_base_extension("res", get_class_static()); } diff --git a/core/io/stream_peer.h b/core/io/stream_peer.h index e71941b7e1..4609e52aa2 100644 --- a/core/io/stream_peer.h +++ b/core/io/stream_peer.h @@ -39,7 +39,6 @@ class StreamPeer : public RefCounted { GDCLASS(StreamPeer, RefCounted); - OBJ_CATEGORY("Networking"); protected: static void _bind_methods(); diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h index f2c47b25cf..bf49cc8a5f 100644 --- a/core/io/stream_peer_tcp.h +++ b/core/io/stream_peer_tcp.h @@ -38,7 +38,6 @@ class StreamPeerTCP : public StreamPeer { GDCLASS(StreamPeerTCP, StreamPeer); - OBJ_CATEGORY("Networking"); public: enum Status { diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index e09c6cb97c..fd86a02b90 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -1485,9 +1485,10 @@ void ClassDB::add_virtual_method(const StringName &p_class, const MethodInfo &p_ if (p_object_core) { mi.flags |= METHOD_FLAG_OBJECT_CORE; } - if (p_arg_names.size()) { + + if (!p_object_core) { if (p_arg_names.size() != mi.arguments.size()) { - WARN_PRINT("Mismatch argument name count for virtual function: " + String(p_class) + "::" + p_method.name); + WARN_PRINT("Mismatch argument name count for virtual method: " + String(p_class) + "::" + p_method.name); } else { for (int i = 0; i < p_arg_names.size(); i++) { mi.arguments[i].name = p_arg_names[i]; @@ -1495,6 +1496,10 @@ void ClassDB::add_virtual_method(const StringName &p_class, const MethodInfo &p_ } } + if (classes[p_class].virtual_methods_map.has(p_method.name)) { + // overloading not supported + ERR_FAIL_MSG("Virtual method already bound '" + String(p_class) + "::" + p_method.name + "'."); + } classes[p_class].virtual_methods.push_back(mi); classes[p_class].virtual_methods_map[p_method.name] = mi; @@ -1551,15 +1556,6 @@ bool ClassDB::is_class_exposed(const StringName &p_class) { return ti->exposed; } -StringName ClassDB::get_category(const StringName &p_node) { - ERR_FAIL_COND_V(!classes.has(p_node), StringName()); -#ifdef DEBUG_ENABLED - return classes[p_node].category; -#else - return StringName(); -#endif -} - void ClassDB::add_resource_base_extension(const StringName &p_extension, const StringName &p_class) { if (resource_base_extensions.has(p_extension)) { return; diff --git a/core/object/class_db.h b/core/object/class_db.h index 4211601d15..b8a4b3ea2b 100644 --- a/core/object/class_db.h +++ b/core/object/class_db.h @@ -109,7 +109,6 @@ public: Set<StringName> methods_in_properties; List<MethodInfo> virtual_methods; Map<StringName, MethodInfo> virtual_methods_map; - StringName category; Map<StringName, Vector<Error>> method_error_values; #endif HashMap<StringName, PropertySetGet> property_setget; @@ -331,8 +330,6 @@ public: static Vector<Error> get_method_error_return_values(const StringName &p_class, const StringName &p_method); static Variant class_get_default_property_value(const StringName &p_class, const StringName &p_property, bool *r_valid = nullptr); - static StringName get_category(const StringName &p_node); - static void set_class_enabled(const StringName &p_class, bool p_enable); static bool is_class_enabled(const StringName &p_class); diff --git a/core/object/object.h b/core/object/object.h index 41365cfe51..dbaf9f13fd 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -344,16 +344,6 @@ public: m_inherits::get_inheritance_list_static(p_inheritance_list); \ p_inheritance_list->push_back(String(#m_class)); \ } \ - static String get_category_static() { \ - String category = m_inherits::get_category_static(); \ - if (_get_category != m_inherits::_get_category) { \ - if (!category.is_empty()) { \ - category += "/"; \ - } \ - category += _get_category(); \ - } \ - return category; \ - } \ virtual bool is_class(const String &p_class) const override { \ if (_get_extension() && _get_extension()->is_class(p_class)) { \ return true; \ @@ -454,12 +444,6 @@ protected: \ private: -#define OBJ_CATEGORY(m_category) \ -protected: \ - _FORCE_INLINE_ static String _get_category() { return m_category; } \ - \ -private: - #define OBJ_SAVE_TYPE(m_class) \ public: \ virtual String get_save_class() const override { return #m_class; } \ @@ -590,7 +574,6 @@ protected: virtual void _get_property_listv(List<PropertyInfo> *p_list, bool p_reversed) const {}; virtual void _notificationv(int p_notification, bool p_reversed) {} - static String _get_category() { return ""; } static void _bind_methods(); bool _set(const StringName &p_name, const Variant &p_property) { return false; }; bool _get(const StringName &p_name, Variant &r_property) const { return false; }; @@ -694,7 +677,6 @@ public: static String get_class_static() { return "Object"; } static String get_parent_class_static() { return String(); } - static String get_category_static() { return String(); } virtual String get_class() const { if (_extension) { diff --git a/core/object/script_language.h b/core/object/script_language.h index 8f6ee90069..6161a0fc0f 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -132,7 +132,7 @@ public: virtual Error reload(bool p_keep_state = false) = 0; #ifdef TOOLS_ENABLED - virtual const Vector<DocData::ClassDoc> &get_documentation() const = 0; + virtual Vector<DocData::ClassDoc> get_documentation() const = 0; #endif // TOOLS_ENABLED virtual bool has_method(const StringName &p_method) const = 0; @@ -212,99 +212,12 @@ public: virtual void property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid); virtual Variant property_get_fallback(const StringName &p_name, bool *r_valid); - virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const = 0; + virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const { return get_script()->get_rpc_methods(); } virtual ScriptLanguage *get_language() = 0; virtual ~ScriptInstance(); }; -struct ScriptCodeCompletionOption { - /* Keep enum in Sync with: */ - /* /scene/gui/code_edit.h - CodeEdit::CodeCompletionKind */ - enum Kind { - KIND_CLASS, - KIND_FUNCTION, - KIND_SIGNAL, - KIND_VARIABLE, - KIND_MEMBER, - KIND_ENUM, - KIND_CONSTANT, - KIND_NODE_PATH, - KIND_FILE_PATH, - KIND_PLAIN_TEXT, - }; - - enum Location { - LOCATION_LOCAL = 0, - LOCATION_PARENT_MASK = (1 << 8), - LOCATION_OTHER_USER_CODE = (1 << 9), - LOCATION_OTHER = (1 << 10), - }; - - Kind kind = KIND_PLAIN_TEXT; - String display; - String insert_text; - Color font_color; - RES icon; - Variant default_value; - Vector<Pair<int, int>> matches; - int location = LOCATION_OTHER; - - ScriptCodeCompletionOption() {} - - ScriptCodeCompletionOption(const String &p_text, Kind p_kind, int p_location = LOCATION_OTHER) { - display = p_text; - insert_text = p_text; - kind = p_kind; - location = p_location; - } -}; - -const int KIND_COUNT = 10; -const ScriptCodeCompletionOption::Kind KIND_SORT_ORDER[KIND_COUNT] = { - ScriptCodeCompletionOption::Kind::KIND_VARIABLE, - ScriptCodeCompletionOption::Kind::KIND_MEMBER, - ScriptCodeCompletionOption::Kind::KIND_FUNCTION, - ScriptCodeCompletionOption::Kind::KIND_ENUM, - ScriptCodeCompletionOption::Kind::KIND_SIGNAL, - ScriptCodeCompletionOption::Kind::KIND_CONSTANT, - ScriptCodeCompletionOption::Kind::KIND_CLASS, - ScriptCodeCompletionOption::Kind::KIND_NODE_PATH, - ScriptCodeCompletionOption::Kind::KIND_FILE_PATH, - ScriptCodeCompletionOption::Kind::KIND_PLAIN_TEXT, -}; - -struct ScriptCodeCompletionOptionCompare { - _FORCE_INLINE_ bool operator()(const ScriptCodeCompletionOption &l, const ScriptCodeCompletionOption &r) const { - if (l.location == r.location) { - // If locations are same, sort on kind - if (l.kind == r.kind) { - // If kinds are same, sort alphanumeric - return l.display < r.display; - } - - // Sort kinds based on the const sorting array defined above. Lower index = higher priority. - int l_index = -1; - int r_index = -1; - for (int i = 0; i < KIND_COUNT; i++) { - const ScriptCodeCompletionOption::Kind kind = KIND_SORT_ORDER[i]; - l_index = kind == l.kind ? i : l_index; - r_index = kind == r.kind ? i : r_index; - - if (l_index != -1 && r_index != -1) { - return l_index < r_index; - } - } - - // This return should never be hit unless something goes wrong. - // l and r should always have a Kind which is in the sort order array. - return l.display < r.display; - } - - return l.location < r.location; - } -}; - class ScriptCodeCompletionCache { static ScriptCodeCompletionCache *singleton; @@ -316,7 +229,8 @@ public: virtual ~ScriptCodeCompletionCache() {} }; -class ScriptLanguage { +class ScriptLanguage : public Object { + GDCLASS(ScriptLanguage, Object) public: virtual String get_name() const = 0; @@ -381,19 +295,55 @@ public: virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; } virtual bool overrides_external_editor() { return false; } - virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_force, String &r_call_hint) { return ERR_UNAVAILABLE; } + /* Keep enum in Sync with: */ + /* /scene/gui/code_edit.h - CodeEdit::CodeCompletionKind */ + enum CodeCompletionKind { + CODE_COMPLETION_KIND_CLASS, + CODE_COMPLETION_KIND_FUNCTION, + CODE_COMPLETION_KIND_SIGNAL, + CODE_COMPLETION_KIND_VARIABLE, + CODE_COMPLETION_KIND_MEMBER, + CODE_COMPLETION_KIND_ENUM, + CODE_COMPLETION_KIND_CONSTANT, + CODE_COMPLETION_KIND_NODE_PATH, + CODE_COMPLETION_KIND_FILE_PATH, + CODE_COMPLETION_KIND_PLAIN_TEXT, + CODE_COMPLETION_KIND_MAX + }; + + struct CodeCompletionOption { + CodeCompletionKind kind = CODE_COMPLETION_KIND_PLAIN_TEXT; + String display; + String insert_text; + Color font_color; + RES icon; + Variant default_value; + Vector<Pair<int, int>> matches; + + CodeCompletionOption() {} + + CodeCompletionOption(const String &p_text, CodeCompletionKind p_kind) { + display = p_text; + insert_text = p_text; + kind = p_kind; + } + }; + + virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<CodeCompletionOption> *r_options, bool &r_force, String &r_call_hint) { return ERR_UNAVAILABLE; } + + enum LookupResultType { + LOOKUP_RESULT_SCRIPT_LOCATION, + LOOKUP_RESULT_CLASS, + LOOKUP_RESULT_CLASS_CONSTANT, + LOOKUP_RESULT_CLASS_PROPERTY, + LOOKUP_RESULT_CLASS_METHOD, + LOOKUP_RESULT_CLASS_ENUM, + LOOKUP_RESULT_CLASS_TBD_GLOBALSCOPE, + LOOKUP_RESULT_MAX + }; struct LookupResult { - enum Type { - RESULT_SCRIPT_LOCATION, - RESULT_CLASS, - RESULT_CLASS_CONSTANT, - RESULT_CLASS_PROPERTY, - RESULT_CLASS_METHOD, - RESULT_CLASS_ENUM, - RESULT_CLASS_TBD_GLOBALSCOPE - }; - Type type; + LookupResultType type; Ref<Script> script; String class_name; String class_member; diff --git a/core/object/script_language_extension.cpp b/core/object/script_language_extension.cpp new file mode 100644 index 0000000000..bf0966c803 --- /dev/null +++ b/core/object/script_language_extension.cpp @@ -0,0 +1,175 @@ +/*************************************************************************/ +/* script_language_extension.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "script_language_extension.h" + +void ScriptExtension::_bind_methods() { + GDVIRTUAL_BIND(_editor_can_reload_from_file); + GDVIRTUAL_BIND(_placeholder_erased, "placeholder"); + + GDVIRTUAL_BIND(_can_instantiate); + GDVIRTUAL_BIND(_get_base_script); + GDVIRTUAL_BIND(_inherits_script, "script"); + + GDVIRTUAL_BIND(_get_instance_base_type); + GDVIRTUAL_BIND(_instance_create, "for_object"); + GDVIRTUAL_BIND(_placeholder_instance_create, "for_object"); + + GDVIRTUAL_BIND(_instance_has, "object"); + + GDVIRTUAL_BIND(_has_source_code); + GDVIRTUAL_BIND(_get_source_code); + + GDVIRTUAL_BIND(_set_source_code, "code"); + GDVIRTUAL_BIND(_reload, "keep_state"); + + GDVIRTUAL_BIND(_get_documentation); + + GDVIRTUAL_BIND(_has_method, "method"); + GDVIRTUAL_BIND(_get_method_info, "method"); + + GDVIRTUAL_BIND(_is_tool); + GDVIRTUAL_BIND(_is_valid); + GDVIRTUAL_BIND(_get_language); + + GDVIRTUAL_BIND(_has_script_signal, "signal"); + GDVIRTUAL_BIND(_get_script_signal_list); + + GDVIRTUAL_BIND(_get_property_default_value, "property"); + + GDVIRTUAL_BIND(_update_exports); + GDVIRTUAL_BIND(_get_script_method_list); + GDVIRTUAL_BIND(_get_script_property_list); + + GDVIRTUAL_BIND(_get_member_line, "member"); + + GDVIRTUAL_BIND(_get_constants); + GDVIRTUAL_BIND(_get_members); + GDVIRTUAL_BIND(_is_placeholder_fallback_enabled); + + GDVIRTUAL_BIND(_get_rpc_methods); +} + +void ScriptLanguageExtension::_bind_methods() { + GDVIRTUAL_BIND(_get_name); + GDVIRTUAL_BIND(_init); + GDVIRTUAL_BIND(_get_type); + GDVIRTUAL_BIND(_get_extension); + GDVIRTUAL_BIND(_execute_file, "path"); + GDVIRTUAL_BIND(_finish); + + GDVIRTUAL_BIND(_get_reserved_words); + GDVIRTUAL_BIND(_is_control_flow_keyword, "keyword"); + GDVIRTUAL_BIND(_get_comment_delimiters); + GDVIRTUAL_BIND(_get_string_delimiters); + GDVIRTUAL_BIND(_make_template, "template", "class_name", "base_class_name"); + GDVIRTUAL_BIND(_get_built_in_templates, "object"); + GDVIRTUAL_BIND(_is_using_templates); + GDVIRTUAL_BIND(_validate, "script", "path", "validate_functions", "validate_errors", "validate_warnings", "validate_safe_lines"); + + GDVIRTUAL_BIND(_validate_path, "path"); + GDVIRTUAL_BIND(_create_script); + GDVIRTUAL_BIND(_has_named_classes); + GDVIRTUAL_BIND(_supports_builtin_mode); + GDVIRTUAL_BIND(_supports_documentation); + GDVIRTUAL_BIND(_can_inherit_from_file); + GDVIRTUAL_BIND(_find_function, "class_name", "function_name"); + GDVIRTUAL_BIND(_make_function, "class_name", "function_name", "function_args"); + GDVIRTUAL_BIND(_open_in_external_editor, "script", "line", "column"); + GDVIRTUAL_BIND(_overrides_external_editor); + + GDVIRTUAL_BIND(_complete_code, "code", "path", "owner"); + GDVIRTUAL_BIND(_lookup_code, "code", "symbol", "path", "owner"); + GDVIRTUAL_BIND(_auto_indent_code, "code", "from_line", "to_line"); + + GDVIRTUAL_BIND(_add_global_constant, "name", "value"); + GDVIRTUAL_BIND(_add_named_global_constant, "name", "value"); + GDVIRTUAL_BIND(_remove_named_global_constant, "name"); + + GDVIRTUAL_BIND(_thread_enter); + GDVIRTUAL_BIND(_thread_exit); + GDVIRTUAL_BIND(_debug_get_error); + GDVIRTUAL_BIND(_debug_get_stack_level_count); + + GDVIRTUAL_BIND(_debug_get_stack_level_line, "level"); + GDVIRTUAL_BIND(_debug_get_stack_level_function, "level"); + GDVIRTUAL_BIND(_debug_get_stack_level_locals, "level", "max_subitems", "max_depth"); + GDVIRTUAL_BIND(_debug_get_stack_level_members, "level", "max_subitems", "max_depth"); + GDVIRTUAL_BIND(_debug_get_stack_level_instance, "level"); + GDVIRTUAL_BIND(_debug_get_globals, "max_subitems", "max_depth"); + GDVIRTUAL_BIND(_debug_parse_stack_level_expression, "level", "expression", "max_subitems", "max_depth"); + + GDVIRTUAL_BIND(_debug_get_current_stack_info); + + GDVIRTUAL_BIND(_reload_all_scripts); + GDVIRTUAL_BIND(_reload_tool_script, "script", "soft_reload"); + + GDVIRTUAL_BIND(_get_recognized_extensions); + GDVIRTUAL_BIND(_get_public_functions); + GDVIRTUAL_BIND(_get_public_constants); + + GDVIRTUAL_BIND(_profiling_start); + GDVIRTUAL_BIND(_profiling_stop); + + GDVIRTUAL_BIND(_profiling_get_accumulated_data, "info_array", "info_max"); + GDVIRTUAL_BIND(_profiling_get_frame_data, "info_array", "info_max"); + + GDVIRTUAL_BIND(_alloc_instance_binding_data, "object"); + GDVIRTUAL_BIND(_free_instance_binding_data, "data"); + + GDVIRTUAL_BIND(_refcount_incremented_instance_binding, "object"); + GDVIRTUAL_BIND(_refcount_decremented_instance_binding, "object"); + + GDVIRTUAL_BIND(_frame); + + GDVIRTUAL_BIND(_handles_global_class_type, "type"); + GDVIRTUAL_BIND(_get_global_class_name, "path"); + + BIND_ENUM_CONSTANT(LOOKUP_RESULT_SCRIPT_LOCATION); + BIND_ENUM_CONSTANT(LOOKUP_RESULT_CLASS); + BIND_ENUM_CONSTANT(LOOKUP_RESULT_CLASS_CONSTANT); + BIND_ENUM_CONSTANT(LOOKUP_RESULT_CLASS_PROPERTY); + BIND_ENUM_CONSTANT(LOOKUP_RESULT_CLASS_METHOD); + BIND_ENUM_CONSTANT(LOOKUP_RESULT_CLASS_ENUM); + BIND_ENUM_CONSTANT(LOOKUP_RESULT_CLASS_TBD_GLOBALSCOPE); + BIND_ENUM_CONSTANT(LOOKUP_RESULT_MAX); + + BIND_ENUM_CONSTANT(CODE_COMPLETION_KIND_CLASS); + BIND_ENUM_CONSTANT(CODE_COMPLETION_KIND_FUNCTION); + BIND_ENUM_CONSTANT(CODE_COMPLETION_KIND_SIGNAL); + BIND_ENUM_CONSTANT(CODE_COMPLETION_KIND_VARIABLE); + BIND_ENUM_CONSTANT(CODE_COMPLETION_KIND_MEMBER); + BIND_ENUM_CONSTANT(CODE_COMPLETION_KIND_ENUM); + BIND_ENUM_CONSTANT(CODE_COMPLETION_KIND_CONSTANT); + BIND_ENUM_CONSTANT(CODE_COMPLETION_KIND_NODE_PATH); + BIND_ENUM_CONSTANT(CODE_COMPLETION_KIND_FILE_PATH); + BIND_ENUM_CONSTANT(CODE_COMPLETION_KIND_PLAIN_TEXT); + BIND_ENUM_CONSTANT(CODE_COMPLETION_KIND_MAX); +} diff --git a/core/object/script_language_extension.h b/core/object/script_language_extension.h new file mode 100644 index 0000000000..b9ec79da26 --- /dev/null +++ b/core/object/script_language_extension.h @@ -0,0 +1,832 @@ +/*************************************************************************/ +/* script_language_extension.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef SCRIPT_LANGUAGE_EXTENSION_H +#define SCRIPT_LANGUAGE_EXTENSION_H + +#include "core/extension/ext_wrappers.gen.inc" +#include "core/object/gdvirtual.gen.inc" +#include "core/object/script_language.h" +#include "core/variant/native_ptr.h" +#include "core/variant/typed_array.h" + +class ScriptExtension : public Script { + GDCLASS(ScriptExtension, Script) + +protected: + EXBIND0R(bool, editor_can_reload_from_file) + + GDVIRTUAL1(_placeholder_erased, GDNativePtr<void>) + virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder) override { + GDVIRTUAL_CALL(_placeholder_erased, p_placeholder); + } + + static void _bind_methods(); + +public: + EXBIND0RC(bool, can_instantiate) + EXBIND0RC(Ref<Script>, get_base_script) + EXBIND1RC(bool, inherits_script, const Ref<Script> &) + EXBIND0RC(StringName, get_instance_base_type) + + GDVIRTUAL1RC(GDNativePtr<void>, _instance_create, Object *) + virtual ScriptInstance *instance_create(Object *p_this) override { + GDNativePtr<void> ret = nullptr; + GDVIRTUAL_REQUIRED_CALL(_instance_create, p_this, ret); + return reinterpret_cast<ScriptInstance *>(ret.operator void *()); + } + GDVIRTUAL1RC(GDNativePtr<void>, _placeholder_instance_create, Object *) + PlaceHolderScriptInstance *placeholder_instance_create(Object *p_this) override { + GDNativePtr<void> ret = nullptr; + GDVIRTUAL_REQUIRED_CALL(_placeholder_instance_create, p_this, ret); + return reinterpret_cast<PlaceHolderScriptInstance *>(ret.operator void *()); + } + + EXBIND1RC(bool, instance_has, const Object *) + EXBIND0RC(bool, has_source_code) + EXBIND0RC(String, get_source_code) + EXBIND1(set_source_code, const String &) + EXBIND1R(Error, reload, bool) + + GDVIRTUAL0RC(TypedArray<Dictionary>, _get_documentation) +#ifdef TOOLS_ENABLED + virtual Vector<DocData::ClassDoc> get_documentation() const override { + TypedArray<Dictionary> doc; + GDVIRTUAL_REQUIRED_CALL(_get_documentation, doc); + + Vector<DocData::ClassDoc> class_doc; +#ifndef _MSC_VER +#warning missing conversion from documentation to ClassDoc +#endif + return class_doc; + } +#endif // TOOLS_ENABLED + + EXBIND1RC(bool, has_method, const StringName &) + + GDVIRTUAL1RC(Dictionary, _get_method_info, const StringName &) + virtual MethodInfo get_method_info(const StringName &p_method) const override { + Dictionary mi; + GDVIRTUAL_REQUIRED_CALL(_get_method_info, p_method, mi); + return MethodInfo::from_dict(mi); + } + + EXBIND0RC(bool, is_tool) + EXBIND0RC(bool, is_valid) + + EXBIND0RC(ScriptLanguage *, get_language) + EXBIND1RC(bool, has_script_signal, const StringName &) + + GDVIRTUAL0RC(TypedArray<Dictionary>, _get_script_signal_list) + + virtual void get_script_signal_list(List<MethodInfo> *r_signals) const override { + TypedArray<Dictionary> sl; + GDVIRTUAL_REQUIRED_CALL(_get_script_signal_list, sl); + for (int i = 0; i < sl.size(); i++) { + r_signals->push_back(MethodInfo::from_dict(sl[i])); + } + } + + GDVIRTUAL1RC(bool, _has_property_default_value, const StringName &) + GDVIRTUAL1RC(Variant, _get_property_default_value, const StringName &) + + virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const override { + bool has_dv = false; + if (!GDVIRTUAL_REQUIRED_CALL(_has_property_default_value, p_property, has_dv) || !has_dv) { + return false; + } + Variant ret; + GDVIRTUAL_REQUIRED_CALL(_get_property_default_value, p_property, ret); + return ret; + } + + EXBIND0(update_exports) + + GDVIRTUAL0RC(TypedArray<Dictionary>, _get_script_method_list) + + virtual void get_script_method_list(List<MethodInfo> *r_methods) const override { + TypedArray<Dictionary> sl; + GDVIRTUAL_REQUIRED_CALL(_get_script_method_list, sl); + for (int i = 0; i < sl.size(); i++) { + r_methods->push_back(MethodInfo::from_dict(sl[i])); + } + } + + GDVIRTUAL0RC(TypedArray<Dictionary>, _get_script_property_list) + + virtual void get_script_property_list(List<PropertyInfo> *r_propertys) const override { + TypedArray<Dictionary> sl; + GDVIRTUAL_REQUIRED_CALL(_get_script_property_list, sl); + for (int i = 0; i < sl.size(); i++) { + r_propertys->push_back(PropertyInfo::from_dict(sl[i])); + } + } + + EXBIND1RC(int, get_member_line, const StringName &) + + GDVIRTUAL0RC(Dictionary, _get_constants) + + virtual void get_constants(Map<StringName, Variant> *p_constants) override { + Dictionary constants; + GDVIRTUAL_REQUIRED_CALL(_get_constants, constants); + List<Variant> keys; + constants.get_key_list(&keys); + for (const Variant &K : keys) { + p_constants->insert(K, constants[K]); + } + } + GDVIRTUAL0RC(TypedArray<StringName>, _get_members) + virtual void get_members(Set<StringName> *p_members) override { + TypedArray<StringName> members; + GDVIRTUAL_REQUIRED_CALL(_get_members, members); + for (int i = 0; i < members.size(); i++) { + p_members->insert(members[i]); + } + } + + EXBIND0RC(bool, is_placeholder_fallback_enabled) + + GDVIRTUAL0RC(TypedArray<Dictionary>, _get_rpc_methods) + + virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const override { + TypedArray<Dictionary> ret; + GDVIRTUAL_REQUIRED_CALL(_get_rpc_methods, ret); + Vector<Multiplayer::RPCConfig> rpcret; + for (int i = 0; i < ret.size(); i++) { + Dictionary d = ret[i]; + Multiplayer::RPCConfig rpc; + ERR_CONTINUE(!d.has("name")); + rpc.name = d["name"]; + ERR_CONTINUE(!d.has("rpc_mode")); + rpc.rpc_mode = Multiplayer::RPCMode(int(d["rpc_mode"])); + ERR_CONTINUE(!d.has("call_local")); + rpc.call_local = d["call_local"]; + ERR_CONTINUE(!d.has("transfer_mode")); + rpc.transfer_mode = Multiplayer::TransferMode(int(d["transfer_mode"])); + ERR_CONTINUE(!d.has("channel")); + rpc.channel = d["channel"]; + rpcret.push_back(rpc); + } + return rpcret; + } + + ScriptExtension() {} +}; + +typedef ScriptLanguage::ProfilingInfo ScriptLanguageExtensionProfilingInfo; + +GDVIRTUAL_NATIVE_PTR(ScriptLanguageExtensionProfilingInfo) + +class ScriptLanguageExtension : public ScriptLanguage { + GDCLASS(ScriptLanguageExtension, ScriptLanguage) +protected: + static void _bind_methods(); + +public: + EXBIND0RC(String, get_name) + + EXBIND0(init) + EXBIND0RC(String, get_type) + EXBIND0RC(String, get_extension) + EXBIND1R(Error, execute_file, const String &) + EXBIND0(finish) + + /* EDITOR FUNCTIONS */ + + GDVIRTUAL0RC(Vector<String>, _get_reserved_words) + + virtual void get_reserved_words(List<String> *p_words) const override { + Vector<String> ret; + GDVIRTUAL_REQUIRED_CALL(_get_reserved_words, ret); + for (int i = 0; i < ret.size(); i++) { + p_words->push_back(ret[i]); + } + } + EXBIND1RC(bool, is_control_flow_keyword, String) + + GDVIRTUAL0RC(Vector<String>, _get_comment_delimiters) + + virtual void get_comment_delimiters(List<String> *p_words) const override { + Vector<String> ret; + GDVIRTUAL_REQUIRED_CALL(_get_comment_delimiters, ret); + for (int i = 0; i < ret.size(); i++) { + p_words->push_back(ret[i]); + } + } + + GDVIRTUAL0RC(Vector<String>, _get_string_delimiters) + + virtual void get_string_delimiters(List<String> *p_words) const override { + Vector<String> ret; + GDVIRTUAL_REQUIRED_CALL(_get_string_delimiters, ret); + for (int i = 0; i < ret.size(); i++) { + p_words->push_back(ret[i]); + } + } + + EXBIND3RC(Ref<Script>, make_template, const String &, const String &, const String &) + + GDVIRTUAL1RC(TypedArray<Dictionary>, _get_built_in_templates, StringName) + + virtual Vector<ScriptTemplate> get_built_in_templates(StringName p_object) override { + TypedArray<Dictionary> ret; + GDVIRTUAL_REQUIRED_CALL(_get_built_in_templates, p_object, ret); + Vector<ScriptTemplate> stret; + for (int i = 0; i < ret.size(); i++) { + Dictionary d = ret[i]; + ScriptTemplate st; + ERR_CONTINUE(!d.has("inherit")); + st.inherit = d["inherit"]; + ERR_CONTINUE(!d.has("name")); + st.name = d["name"]; + ERR_CONTINUE(!d.has("description")); + st.description = d["description"]; + ERR_CONTINUE(!d.has("content")); + st.content = d["content"]; + ERR_CONTINUE(!d.has("id")); + st.id = d["id"]; + ERR_CONTINUE(!d.has("origin")); + st.origin = TemplateLocation(int(d["origin"])); + stret.push_back(st); + } + return stret; + } + + EXBIND0R(bool, is_using_templates) + + GDVIRTUAL6RC(Dictionary, _validate, const String &, const String &, bool, bool, bool, bool) + virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptError> *r_errors = nullptr, List<Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const override { + Dictionary ret; + GDVIRTUAL_REQUIRED_CALL(_validate, p_script, p_path, r_functions != nullptr, r_errors != nullptr, r_warnings != nullptr, r_safe_lines != nullptr, ret); + if (!ret.has("valid")) { + return false; + } + if (r_functions != nullptr && ret.has("functions")) { + Vector<String> functions = ret["functions"]; + for (int i = 0; i < functions.size(); i++) { + r_functions->push_back(functions[i]); + } + } + if (r_errors != nullptr && ret.has("errors")) { + Array errors = ret["errors"]; + for (int i = 0; i < errors.size(); i++) { + Dictionary err = errors[i]; + ERR_CONTINUE(!err.has("line")); + ERR_CONTINUE(!err.has("column")); + ERR_CONTINUE(!err.has("message")); + + ScriptError serr; + serr.line = err["line"]; + serr.column = err["column"]; + serr.message = err["message"]; + + r_errors->push_back(serr); + } + } + if (r_warnings != nullptr && ret.has("warnings")) { + ERR_FAIL_COND_V(!ret.has("warnings"), false); + Array warnings = ret["warnings"]; + for (int i = 0; i < warnings.size(); i++) { + Dictionary warn = warnings[i]; + ERR_CONTINUE(!warn.has("start_line")); + ERR_CONTINUE(!warn.has("end_line")); + ERR_CONTINUE(!warn.has("leftmost_column")); + ERR_CONTINUE(!warn.has("rightmost_column")); + ERR_CONTINUE(!warn.has("code")); + ERR_CONTINUE(!warn.has("string_code")); + ERR_CONTINUE(!warn.has("message")); + + Warning swarn; + swarn.start_line = warn["start_line"]; + swarn.end_line = warn["end_line"]; + swarn.leftmost_column = warn["leftmost_column"]; + swarn.rightmost_column = warn["rightmost_column"]; + swarn.code = warn["code"]; + swarn.string_code = warn["string_code"]; + swarn.message = warn["message"]; + + r_warnings->push_back(swarn); + } + } + if (r_safe_lines != nullptr && ret.has("safe_lines")) { + PackedInt32Array safe_lines = ret["safe_lines"]; + for (int i = 0; i < safe_lines.size(); i++) { + r_safe_lines->insert(safe_lines[i]); + } + } + return ret["valid"]; + } + + EXBIND1RC(String, validate_path, const String &) + GDVIRTUAL0RC(Object *, _create_script) + Script *create_script() const override { + Object *ret = nullptr; + GDVIRTUAL_REQUIRED_CALL(_create_script, ret); + return Object::cast_to<Script>(ret); + } + EXBIND0RC(bool, has_named_classes) + EXBIND0RC(bool, supports_builtin_mode) + EXBIND0RC(bool, supports_documentation) + EXBIND0RC(bool, can_inherit_from_file) + + EXBIND2RC(int, find_function, const String &, const String &) + EXBIND3RC(String, make_function, const String &, const String &, const PackedStringArray &) + EXBIND3R(Error, open_in_external_editor, const Ref<Script> &, int, int) + EXBIND0R(bool, overrides_external_editor) + + GDVIRTUAL3RC(Dictionary, _complete_code, const String &, const String &, Object *) + + virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<CodeCompletionOption> *r_options, bool &r_force, String &r_call_hint) override { + Dictionary ret; + GDVIRTUAL_REQUIRED_CALL(_complete_code, p_code, p_path, p_owner, ret); + if (!ret.has("result")) { + return ERR_UNAVAILABLE; + } + + if (r_options != nullptr && ret.has("options")) { + Array options = ret["options"]; + for (int i = 0; i < options.size(); i++) { + Dictionary op = options[i]; + CodeCompletionOption option; + ERR_CONTINUE(!op.has("kind")); + option.kind = CodeCompletionKind(int(op["kind"])); + ERR_CONTINUE(!op.has("display")); + option.display = op["display"]; + ERR_CONTINUE(!op.has("insert_text")); + option.insert_text = op["insert_text"]; + ERR_CONTINUE(!op.has("font_color")); + option.font_color = op["font_color"]; + ERR_CONTINUE(!op.has("icon")); + option.icon = op["icon"]; + ERR_CONTINUE(!op.has("default_value")); + option.default_value = op["default_value"]; + if (op.has("matches")) { + PackedInt32Array matches = op["matches"]; + ERR_CONTINUE(matches.size() & 1); + for (int j = 0; j < matches.size(); j += 2) { + option.matches.push_back(Pair<int, int>(matches[j], matches[j + 1])); + } + } + r_options->push_back(option); + } + } + + ERR_FAIL_COND_V(!ret.has("force"), ERR_UNAVAILABLE); + r_force = ret["force"]; + ERR_FAIL_COND_V(!ret.has("call_hint"), ERR_UNAVAILABLE); + r_call_hint = ret["call_hint"]; + ERR_FAIL_COND_V(!ret.has("result"), ERR_UNAVAILABLE); + Error result = Error(int(ret["result"])); + + return result; + } + + GDVIRTUAL4RC(Dictionary, _lookup_code, const String &, const String &, const String &, Object *) + + virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result) override { + Dictionary ret; + GDVIRTUAL_REQUIRED_CALL(_lookup_code, p_code, p_symbol, p_path, p_owner, ret); + if (!ret.has("result")) { + return ERR_UNAVAILABLE; + } + + ERR_FAIL_COND_V(!ret.has("type"), ERR_UNAVAILABLE); + r_result.type = LookupResultType(int(ret["type"])); + ERR_FAIL_COND_V(!ret.has("script"), ERR_UNAVAILABLE); + r_result.script = ret["script"]; + ERR_FAIL_COND_V(!ret.has("class_name"), ERR_UNAVAILABLE); + r_result.class_name = ret["class_name"]; + ERR_FAIL_COND_V(!ret.has("class_path"), ERR_UNAVAILABLE); + r_result.class_path = ret["class_path"]; + ERR_FAIL_COND_V(!ret.has("location"), ERR_UNAVAILABLE); + r_result.location = ret["location"]; + + Error result = Error(int(ret["result"])); + + return result; + } + + GDVIRTUAL3RC(String, _auto_indent_code, const String &, int, int) + virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const override { + String ret; + GDVIRTUAL_REQUIRED_CALL(_auto_indent_code, p_code, p_from_line, p_to_line, ret); + p_code = ret; + } + EXBIND2(add_global_constant, const StringName &, const Variant &) + EXBIND2(add_named_global_constant, const StringName &, const Variant &) + EXBIND1(remove_named_global_constant, const StringName &) + + /* MULTITHREAD FUNCTIONS */ + + //some VMs need to be notified of thread creation/exiting to allocate a stack + EXBIND0(thread_enter) + EXBIND0(thread_exit) + + EXBIND0RC(String, debug_get_error) + EXBIND0RC(int, debug_get_stack_level_count) + EXBIND1RC(int, debug_get_stack_level_line, int) + EXBIND1RC(String, debug_get_stack_level_function, int) + EXBIND1RC(String, debug_get_stack_level_source, int) + + GDVIRTUAL3R(Dictionary, _debug_get_stack_level_locals, int, int, int) + virtual void debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) override { + Dictionary ret; + GDVIRTUAL_REQUIRED_CALL(_debug_get_stack_level_locals, p_level, p_max_subitems, p_max_depth, ret); + if (ret.size() == 0) { + return; + } + if (p_locals != nullptr && ret.has("locals")) { + PackedStringArray strings = ret["locals"]; + for (int i = 0; i < strings.size(); i++) { + p_locals->push_back(strings[i]); + } + } + if (p_values != nullptr && ret.has("values")) { + Array values = ret["values"]; + for (int i = 0; i < values.size(); i++) { + p_values->push_back(values[i]); + } + } + } + GDVIRTUAL3R(Dictionary, _debug_get_stack_level_members, int, int, int) + virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) override { + Dictionary ret; + GDVIRTUAL_REQUIRED_CALL(_debug_get_stack_level_members, p_level, p_max_subitems, p_max_depth, ret); + if (ret.size() == 0) { + return; + } + if (p_members != nullptr && ret.has("members")) { + PackedStringArray strings = ret["members"]; + for (int i = 0; i < strings.size(); i++) { + p_members->push_back(strings[i]); + } + } + if (p_values != nullptr && ret.has("values")) { + Array values = ret["values"]; + for (int i = 0; i < values.size(); i++) { + p_values->push_back(values[i]); + } + } + } + GDVIRTUAL1R(GDNativePtr<void>, _debug_get_stack_level_instance, int) + + virtual ScriptInstance *debug_get_stack_level_instance(int p_level) override { + GDNativePtr<void> ret = nullptr; + GDVIRTUAL_REQUIRED_CALL(_debug_get_stack_level_instance, p_level, ret); + return reinterpret_cast<ScriptInstance *>(ret.operator void *()); + } + GDVIRTUAL2R(Dictionary, _debug_get_globals, int, int) + virtual void debug_get_globals(List<String> *p_globals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) override { + Dictionary ret; + GDVIRTUAL_REQUIRED_CALL(_debug_get_globals, p_max_subitems, p_max_depth, ret); + if (ret.size() == 0) { + return; + } + if (p_globals != nullptr && ret.has("globals")) { + PackedStringArray strings = ret["globals"]; + for (int i = 0; i < strings.size(); i++) { + p_globals->push_back(strings[i]); + } + } + if (p_values != nullptr && ret.has("values")) { + Array values = ret["values"]; + for (int i = 0; i < values.size(); i++) { + p_values->push_back(values[i]); + } + } + } + + EXBIND4R(String, debug_parse_stack_level_expression, int, const String &, int, int) + + GDVIRTUAL0R(TypedArray<Dictionary>, _debug_get_current_stack_info) + virtual Vector<StackInfo> debug_get_current_stack_info() override { + TypedArray<Dictionary> ret; + GDVIRTUAL_REQUIRED_CALL(_debug_get_current_stack_info, ret); + Vector<StackInfo> sret; + for (int i = 0; i < ret.size(); i++) { + StackInfo si; + Dictionary d = ret[i]; + ERR_CONTINUE(!d.has("file")); + ERR_CONTINUE(!d.has("func")); + ERR_CONTINUE(!d.has("line")); + si.file = d["file"]; + si.func = d["func"]; + si.line = d["line"]; + sret.push_back(si); + } + return sret; + } + + EXBIND0(reload_all_scripts) + EXBIND2(reload_tool_script, const Ref<Script> &, bool) + /* LOADER FUNCTIONS */ + + GDVIRTUAL0RC(PackedStringArray, _get_recognized_extensions) + + virtual void get_recognized_extensions(List<String> *p_extensions) const override { + PackedStringArray ret; + GDVIRTUAL_REQUIRED_CALL(_get_recognized_extensions, ret); + for (int i = 0; i < ret.size(); i++) { + p_extensions->push_back(ret[i]); + } + } + + GDVIRTUAL0RC(TypedArray<Dictionary>, _get_public_functions) + virtual void get_public_functions(List<MethodInfo> *p_functions) const override { + TypedArray<Dictionary> ret; + GDVIRTUAL_REQUIRED_CALL(_get_public_functions, ret); + for (int i = 0; i < ret.size(); i++) { + MethodInfo mi = MethodInfo::from_dict(ret[i]); + p_functions->push_back(mi); + } + } + GDVIRTUAL0RC(Dictionary, _get_public_constants) + virtual void get_public_constants(List<Pair<String, Variant>> *p_constants) const override { + Dictionary ret; + GDVIRTUAL_REQUIRED_CALL(_get_public_constants, ret); + for (int i = 0; i < ret.size(); i++) { + Dictionary d = ret[i]; + ERR_CONTINUE(!d.has("name")); + ERR_CONTINUE(!d.has("value")); + p_constants->push_back(Pair<String, Variant>(d["name"], d["value"])); + } + } + + EXBIND0(profiling_start) + EXBIND0(profiling_stop) + + GDVIRTUAL2R(int, _profiling_get_accumulated_data, GDNativePtr<ScriptLanguageExtensionProfilingInfo>, int) + + virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) override { + int ret = 0; + GDVIRTUAL_REQUIRED_CALL(_profiling_get_accumulated_data, p_info_arr, p_info_max, ret); + return ret; + } + + GDVIRTUAL2R(int, _profiling_get_frame_data, GDNativePtr<ScriptLanguageExtensionProfilingInfo>, int) + + virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) override { + int ret = 0; + GDVIRTUAL_REQUIRED_CALL(_profiling_get_accumulated_data, p_info_arr, p_info_max, ret); + return ret; + } + + GDVIRTUAL1R(GDNativePtr<void>, _alloc_instance_binding_data, Object *) + + virtual void *alloc_instance_binding_data(Object *p_object) override { + GDNativePtr<void> ret = nullptr; + GDVIRTUAL_REQUIRED_CALL(_alloc_instance_binding_data, p_object, ret); + return ret.operator void *(); + } + + GDVIRTUAL1(_free_instance_binding_data, GDNativePtr<void>) + + virtual void free_instance_binding_data(void *p_data) override { + GDVIRTUAL_REQUIRED_CALL(_free_instance_binding_data, p_data); + } + + EXBIND1(refcount_incremented_instance_binding, Object *) + EXBIND1R(bool, refcount_decremented_instance_binding, Object *) + + EXBIND0(frame) + + EXBIND1RC(bool, handles_global_class_type, const String &) + + GDVIRTUAL1RC(Dictionary, _get_global_class_name, const String &) + + virtual String get_global_class_name(const String &p_path, String *r_base_type = nullptr, String *r_icon_path = nullptr) const override { + Dictionary ret; + GDVIRTUAL_REQUIRED_CALL(_get_global_class_name, p_path, ret); + if (!ret.has("name")) { + return String(); + } + if (r_base_type != nullptr && ret.has("base_type")) { + *r_base_type = ret["base_type"]; + } + if (r_icon_path != nullptr && ret.has("icon_path")) { + *r_icon_path = ret["icon_path"]; + } + return ret["name"]; + } +}; + +VARIANT_ENUM_CAST(ScriptLanguageExtension::LookupResultType) +VARIANT_ENUM_CAST(ScriptLanguageExtension::CodeCompletionKind) + +class ScriptInstanceExtension : public ScriptInstance { +public: + const GDNativeExtensionScriptInstanceInfo *native_info; + GDNativeExtensionScriptInstanceDataPtr instance = nullptr; + +// There should not be warnings on explicit casts. +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wignored-qualifiers" +#endif + + virtual bool set(const StringName &p_name, const Variant &p_value) override { + if (native_info->set_func) { + return native_info->set_func(instance, (const GDNativeStringNamePtr)&p_name, (const GDNativeVariantPtr)&p_value); + } + return false; + } + virtual bool get(const StringName &p_name, Variant &r_ret) const override { + if (native_info->get_func) { + return native_info->get_func(instance, (const GDNativeStringNamePtr)&p_name, (GDNativeVariantPtr)&r_ret); + } + return false; + } + virtual void get_property_list(List<PropertyInfo> *p_list) const override { + if (native_info->get_property_list_func) { + uint32_t pcount; + const GDNativePropertyInfo *pinfo = native_info->get_property_list_func(instance, &pcount); + for (uint32_t i = 0; i < pcount; i++) { + p_list->push_back(PropertyInfo(Variant::Type(pinfo[i].type), pinfo[i].class_name, PropertyHint(pinfo[i].hint), pinfo[i].hint_string, pinfo[i].usage, pinfo[i].class_name)); + } + if (native_info->free_property_list_func) { + native_info->free_property_list_func(instance, pinfo); + } + } + } + virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const override { + if (native_info->get_property_type_func) { + GDNativeBool is_valid = 0; + GDNativeVariantType type = native_info->get_property_type_func(instance, (const GDNativeStringNamePtr)&p_name, &is_valid); + if (r_is_valid) { + *r_is_valid = is_valid != 0; + } + + return Variant::Type(type); + } + return Variant::NIL; + } + + virtual Object *get_owner() override { + if (native_info->get_owner_func) { + return (Object *)native_info->get_owner_func(instance); + } + return nullptr; + } + static void _add_property_with_state(const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value, void *p_userdata) { + List<Pair<StringName, Variant>> *state = (List<Pair<StringName, Variant>> *)p_userdata; + state->push_back(Pair<StringName, Variant>(*(const StringName *)p_name, *(const Variant *)p_value)); + } + virtual void get_property_state(List<Pair<StringName, Variant>> &state) override { + if (native_info->get_property_state_func) { + native_info->get_property_state_func(instance, _add_property_with_state, &state); + } + } + + virtual void get_method_list(List<MethodInfo> *p_list) const override { + if (native_info->get_method_list_func) { + uint32_t mcount; + const GDNativeMethodInfo *minfo = native_info->get_method_list_func(instance, &mcount); + for (uint32_t i = 0; i < mcount; i++) { + MethodInfo m; + m.name = minfo[i].name; + m.flags = minfo[i].flags; + m.id = minfo[i].id; + m.return_val = PropertyInfo(Variant::Type(minfo[i].return_value.type), minfo[i].return_value.class_name, PropertyHint(minfo[i].return_value.hint), minfo[i].return_value.hint_string, minfo[i].return_value.usage, minfo[i].return_value.class_name); + for (uint32_t j = 0; j < minfo[i].argument_count; j++) { + m.arguments.push_back(PropertyInfo(Variant::Type(minfo[i].arguments[j].type), minfo[i].arguments[j].class_name, PropertyHint(minfo[i].arguments[j].hint), minfo[i].arguments[j].hint_string, minfo[i].arguments[j].usage, minfo[i].arguments[j].class_name)); + } + const Variant *def_values = (const Variant *)minfo[i].default_arguments; + for (uint32_t j = 0; j < minfo[i].default_argument_count; j++) { + m.default_arguments.push_back(def_values[j]); + } + p_list->push_back(m); + } + if (native_info->free_method_list_func) { + native_info->free_method_list_func(instance, minfo); + } + } + } + virtual bool has_method(const StringName &p_method) const override { + if (native_info->has_method_func) { + return native_info->has_method_func(instance, (GDNativeStringNamePtr)&p_method); + } + return false; + } + + virtual Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override { + Variant ret; + if (native_info->call_func) { + GDNativeCallError ce; + native_info->call_func(instance, (const GDNativeStringNamePtr)&p_method, (const GDNativeVariantPtr *)p_args, p_argcount, (GDNativeVariantPtr)&ret, &ce); + r_error.error = Callable::CallError::Error(ce.error); + r_error.argument = ce.argument; + r_error.expected = ce.expected; + } + return ret; + } + + virtual void notification(int p_notification) override { + if (native_info->notification_func) { + native_info->notification_func(instance, p_notification); + } + } + virtual String to_string(bool *r_valid) override { + if (native_info->to_string_func) { + GDNativeBool valid; + String ret = native_info->to_string_func(instance, &valid); + if (r_valid) { + *r_valid = valid != 0; + } + return ret; + } + return String(); + } + + virtual void refcount_incremented() override { + if (native_info->refcount_incremented_func) { + native_info->refcount_incremented_func(instance); + } + } + virtual bool refcount_decremented() override { + if (native_info->refcount_decremented_func) { + return native_info->refcount_decremented_func(instance); + } + return false; + } + + virtual Ref<Script> get_script() const override { + if (native_info->get_script_func) { + GDNativeObjectPtr script = native_info->get_script_func(instance); + return Ref<Script>(reinterpret_cast<Script *>(script)); + } + return Ref<Script>(); + } + + virtual bool is_placeholder() const override { + if (native_info->is_placeholder_func) { + return native_info->is_placeholder_func(instance); + } + return false; + } + + virtual void property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid) override { + if (native_info->set_fallback_func) { + bool ret = native_info->set_fallback_func(instance, (const GDNativeStringNamePtr)&p_name, (const GDNativeVariantPtr)&p_value); + if (r_valid) { + *r_valid = ret; + } + } + } + virtual Variant property_get_fallback(const StringName &p_name, bool *r_valid) override { + Variant ret; + if (native_info->get_fallback_func) { + bool valid = native_info->get_fallback_func(instance, (const GDNativeStringNamePtr)&p_name, (GDNativeVariantPtr)&ret); + if (r_valid) { + *r_valid = valid; + } + } + return ret; + } + + virtual ScriptLanguage *get_language() override { + if (native_info->get_language_func) { + GDNativeExtensionScriptLanguagePtr lang = native_info->get_language_func(instance); + return reinterpret_cast<ScriptLanguage *>(lang); + } + return nullptr; + ; + } + virtual ~ScriptInstanceExtension() { + if (native_info->free_func) { + native_info->free_func(instance); + } + } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif +}; + +#endif // SCRIPT_LANGUAGE_EXTENSION_H diff --git a/core/os/main_loop.h b/core/os/main_loop.h index a6a32f0138..2bb1ea2ef4 100644 --- a/core/os/main_loop.h +++ b/core/os/main_loop.h @@ -38,7 +38,6 @@ class MainLoop : public Object { GDCLASS(MainLoop, Object); - OBJ_CATEGORY("Main Loop"); Ref<Script> initialize_script; diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 1a306e88fc..415b56cd83 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -71,6 +71,7 @@ #include "core/multiplayer/multiplayer_api.h" #include "core/multiplayer/multiplayer_peer.h" #include "core/object/class_db.h" +#include "core/object/script_language_extension.h" #include "core/object/undo_redo.h" #include "core/os/main_loop.h" #include "core/os/time.h" @@ -142,6 +143,10 @@ void register_core_types() { GDREGISTER_CLASS(Object); GDREGISTER_ABSTRACT_CLASS(Script); + GDREGISTER_ABSTRACT_CLASS(ScriptLanguage); + + GDREGISTER_VIRTUAL_CLASS(ScriptExtension); + GDREGISTER_VIRTUAL_CLASS(ScriptLanguageExtension); GDREGISTER_CLASS(RefCounted); GDREGISTER_CLASS(WeakRef); @@ -263,6 +268,7 @@ void register_core_types() { _engine_debugger = memnew(core_bind::EngineDebugger); GDREGISTER_NATIVE_STRUCT(AudioFrame, "float left;float right"); + GDREGISTER_NATIVE_STRUCT(ScriptLanguageExtensionProfilingInfo, "StringName signature;uint64_t call_count;uint64_t total_time;uint64_t self_time"); } void register_core_settings() { diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index a02f9c5823..c11925fa8c 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1656,6 +1656,8 @@ static void _register_variant_builtin_methods() { bind_method(Color, darkened, sarray("amount"), varray()); bind_method(Color, blend, sarray("over"), varray()); bind_method(Color, get_luminance, sarray(), varray()); + bind_method(Color, to_linear, sarray(), varray()); + bind_method(Color, to_srgb, sarray(), varray()); bind_method(Color, is_equal_approx, sarray("to"), varray()); diff --git a/doc/classes/ClassDB.xml b/doc/classes/ClassDB.xml index 835588b293..43210de686 100644 --- a/doc/classes/ClassDB.xml +++ b/doc/classes/ClassDB.xml @@ -23,13 +23,6 @@ Returns whether the specified [code]class[/code] is available or not. </description> </method> - <method name="class_get_category" qualifiers="const"> - <return type="StringName" /> - <argument index="0" name="class" type="StringName" /> - <description> - Returns a category associated with the class for use in documentation and the Asset Library. Debug mode required. - </description> - </method> <method name="class_get_enum_constants" qualifiers="const"> <return type="PackedStringArray" /> <argument index="0" name="class" type="StringName" /> diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml index e30d448a27..5b48804d9d 100644 --- a/doc/classes/Color.xml +++ b/doc/classes/Color.xml @@ -183,6 +183,7 @@ <description> Returns the luminance of the color in the [code][0.0, 1.0][/code] range. This is useful when determining light or dark color. Colors with a luminance smaller than 0.5 can be generally considered dark. + [b]Note:[/b] [method get_luminance] relies on the colour being in the linear color space to return an accurate relative luminance value. If the color is in the sRGB color space, use [method to_linear] to convert it to the linear color space first. </description> </method> <method name="get_named_color" qualifiers="static"> @@ -404,6 +405,12 @@ [/codeblocks] </description> </method> + <method name="to_linear" qualifiers="const"> + <return type="Color" /> + <description> + Returns the color converted to the linear color space. This assumes the original color is in the sRGB color space. See also [method to_srgb] which performs the opposite operation. + </description> + </method> <method name="to_rgba32" qualifiers="const"> <return type="int" /> <description> @@ -436,6 +443,12 @@ [/codeblocks] </description> </method> + <method name="to_srgb" qualifiers="const"> + <return type="Color" /> + <description> + Returns the color converted to the [url=https://en.wikipedia.org/wiki/SRGB]sRGB[/url] color space. This assumes the original color is in the linear color space. See also [method to_linear] which performs the opposite operation. + </description> + </method> </methods> <members> <member name="a" type="float" setter="" getter="" default="1.0"> diff --git a/doc/classes/Engine.xml b/doc/classes/Engine.xml index af4df321c1..506992e3af 100644 --- a/doc/classes/Engine.xml +++ b/doc/classes/Engine.xml @@ -94,6 +94,17 @@ [/codeblock] </description> </method> + <method name="get_script_language" qualifiers="const"> + <return type="ScriptLanguage" /> + <argument index="0" name="index" type="int" /> + <description> + </description> + </method> + <method name="get_script_language_count"> + <return type="int" /> + <description> + </description> + </method> <method name="get_singleton" qualifiers="const"> <return type="Object" /> <argument index="0" name="name" type="StringName" /> @@ -167,6 +178,12 @@ Returns [code]true[/code] if the game is inside the fixed process and physics phase of the game loop. </description> </method> + <method name="register_script_language"> + <return type="void" /> + <argument index="0" name="language" type="ScriptLanguage" /> + <description> + </description> + </method> <method name="register_singleton"> <return type="void" /> <argument index="0" name="name" type="StringName" /> diff --git a/doc/classes/Range.xml b/doc/classes/Range.xml index 9743d969ca..df6efd155a 100644 --- a/doc/classes/Range.xml +++ b/doc/classes/Range.xml @@ -11,7 +11,7 @@ <methods> <method name="_value_changed" qualifiers="virtual"> <return type="void" /> - <argument index="0" name="" type="float" /> + <argument index="0" name="new_value" type="float" /> <description> Called when the [Range]'s value is changed (following the same conditions as [signal value_changed]). </description> diff --git a/doc/classes/ScriptExtension.xml b/doc/classes/ScriptExtension.xml new file mode 100644 index 0000000000..91fa6206d7 --- /dev/null +++ b/doc/classes/ScriptExtension.xml @@ -0,0 +1,173 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="ScriptExtension" inherits="Script" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + <method name="_can_instantiate" qualifiers="virtual const"> + <return type="bool" /> + <description> + </description> + </method> + <method name="_editor_can_reload_from_file" qualifiers="virtual"> + <return type="bool" /> + <description> + </description> + </method> + <method name="_get_base_script" qualifiers="virtual const"> + <return type="Script" /> + <description> + </description> + </method> + <method name="_get_constants" qualifiers="virtual const"> + <return type="Dictionary" /> + <description> + </description> + </method> + <method name="_get_documentation" qualifiers="virtual const"> + <return type="Dictionary[]" /> + <description> + </description> + </method> + <method name="_get_instance_base_type" qualifiers="virtual const"> + <return type="StringName" /> + <description> + </description> + </method> + <method name="_get_language" qualifiers="virtual const"> + <return type="ScriptLanguage" /> + <description> + </description> + </method> + <method name="_get_member_line" qualifiers="virtual const"> + <return type="int" /> + <argument index="0" name="member" type="StringName" /> + <description> + </description> + </method> + <method name="_get_members" qualifiers="virtual const"> + <return type="StringName[]" /> + <description> + </description> + </method> + <method name="_get_method_info" qualifiers="virtual const"> + <return type="Dictionary" /> + <argument index="0" name="method" type="StringName" /> + <description> + </description> + </method> + <method name="_get_property_default_value" qualifiers="virtual const"> + <return type="Variant" /> + <argument index="0" name="property" type="StringName" /> + <description> + </description> + </method> + <method name="_get_rpc_methods" qualifiers="virtual const"> + <return type="Dictionary[]" /> + <description> + </description> + </method> + <method name="_get_script_method_list" qualifiers="virtual const"> + <return type="Dictionary[]" /> + <description> + </description> + </method> + <method name="_get_script_property_list" qualifiers="virtual const"> + <return type="Dictionary[]" /> + <description> + </description> + </method> + <method name="_get_script_signal_list" qualifiers="virtual const"> + <return type="Dictionary[]" /> + <description> + </description> + </method> + <method name="_get_source_code" qualifiers="virtual const"> + <return type="String" /> + <description> + </description> + </method> + <method name="_has_method" qualifiers="virtual const"> + <return type="bool" /> + <argument index="0" name="method" type="StringName" /> + <description> + </description> + </method> + <method name="_has_script_signal" qualifiers="virtual const"> + <return type="bool" /> + <argument index="0" name="signal" type="StringName" /> + <description> + </description> + </method> + <method name="_has_source_code" qualifiers="virtual const"> + <return type="bool" /> + <description> + </description> + </method> + <method name="_inherits_script" qualifiers="virtual const"> + <return type="bool" /> + <argument index="0" name="script" type="Script" /> + <description> + </description> + </method> + <method name="_instance_create" qualifiers="virtual const"> + <return type="void*" /> + <argument index="0" name="for_object" type="Object" /> + <description> + </description> + </method> + <method name="_instance_has" qualifiers="virtual const"> + <return type="bool" /> + <argument index="0" name="object" type="Object" /> + <description> + </description> + </method> + <method name="_is_placeholder_fallback_enabled" qualifiers="virtual const"> + <return type="bool" /> + <description> + </description> + </method> + <method name="_is_tool" qualifiers="virtual const"> + <return type="bool" /> + <description> + </description> + </method> + <method name="_is_valid" qualifiers="virtual const"> + <return type="bool" /> + <description> + </description> + </method> + <method name="_placeholder_erased" qualifiers="virtual"> + <return type="void" /> + <argument index="0" name="placeholder" type="void*" /> + <description> + </description> + </method> + <method name="_placeholder_instance_create" qualifiers="virtual const"> + <return type="void*" /> + <argument index="0" name="for_object" type="Object" /> + <description> + </description> + </method> + <method name="_reload" qualifiers="virtual"> + <return type="int" enum="Error" /> + <argument index="0" name="keep_state" type="bool" /> + <description> + </description> + </method> + <method name="_set_source_code" qualifiers="virtual"> + <return type="void" /> + <argument index="0" name="code" type="String" /> + <description> + </description> + </method> + <method name="_update_exports" qualifiers="virtual"> + <return type="void" /> + <description> + </description> + </method> + </methods> +</class> diff --git a/doc/classes/ScriptLanguage.xml b/doc/classes/ScriptLanguage.xml new file mode 100644 index 0000000000..b229e461f5 --- /dev/null +++ b/doc/classes/ScriptLanguage.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="ScriptLanguage" inherits="Object" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> +</class> diff --git a/doc/classes/ScriptLanguageExtension.xml b/doc/classes/ScriptLanguageExtension.xml new file mode 100644 index 0000000000..7225d93030 --- /dev/null +++ b/doc/classes/ScriptLanguageExtension.xml @@ -0,0 +1,404 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="ScriptLanguageExtension" inherits="ScriptLanguage" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + <method name="_add_global_constant" qualifiers="virtual"> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="value" type="Variant" /> + <description> + </description> + </method> + <method name="_add_named_global_constant" qualifiers="virtual"> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="value" type="Variant" /> + <description> + </description> + </method> + <method name="_alloc_instance_binding_data" qualifiers="virtual"> + <return type="void*" /> + <argument index="0" name="object" type="Object" /> + <description> + </description> + </method> + <method name="_auto_indent_code" qualifiers="virtual const"> + <return type="String" /> + <argument index="0" name="code" type="String" /> + <argument index="1" name="from_line" type="int" /> + <argument index="2" name="to_line" type="int" /> + <description> + </description> + </method> + <method name="_can_inherit_from_file" qualifiers="virtual const"> + <return type="bool" /> + <description> + </description> + </method> + <method name="_complete_code" qualifiers="virtual const"> + <return type="Dictionary" /> + <argument index="0" name="code" type="String" /> + <argument index="1" name="path" type="String" /> + <argument index="2" name="owner" type="Object" /> + <description> + </description> + </method> + <method name="_create_script" qualifiers="virtual const"> + <return type="Object" /> + <description> + </description> + </method> + <method name="_debug_get_current_stack_info" qualifiers="virtual"> + <return type="Dictionary[]" /> + <description> + </description> + </method> + <method name="_debug_get_error" qualifiers="virtual const"> + <return type="String" /> + <description> + </description> + </method> + <method name="_debug_get_globals" qualifiers="virtual"> + <return type="Dictionary" /> + <argument index="0" name="max_subitems" type="int" /> + <argument index="1" name="max_depth" type="int" /> + <description> + </description> + </method> + <method name="_debug_get_stack_level_count" qualifiers="virtual const"> + <return type="int" /> + <description> + </description> + </method> + <method name="_debug_get_stack_level_function" qualifiers="virtual const"> + <return type="String" /> + <argument index="0" name="level" type="int" /> + <description> + </description> + </method> + <method name="_debug_get_stack_level_instance" qualifiers="virtual"> + <return type="void*" /> + <argument index="0" name="level" type="int" /> + <description> + </description> + </method> + <method name="_debug_get_stack_level_line" qualifiers="virtual const"> + <return type="int" /> + <argument index="0" name="level" type="int" /> + <description> + </description> + </method> + <method name="_debug_get_stack_level_locals" qualifiers="virtual"> + <return type="Dictionary" /> + <argument index="0" name="level" type="int" /> + <argument index="1" name="max_subitems" type="int" /> + <argument index="2" name="max_depth" type="int" /> + <description> + </description> + </method> + <method name="_debug_get_stack_level_members" qualifiers="virtual"> + <return type="Dictionary" /> + <argument index="0" name="level" type="int" /> + <argument index="1" name="max_subitems" type="int" /> + <argument index="2" name="max_depth" type="int" /> + <description> + </description> + </method> + <method name="_debug_parse_stack_level_expression" qualifiers="virtual"> + <return type="String" /> + <argument index="0" name="level" type="int" /> + <argument index="1" name="expression" type="String" /> + <argument index="2" name="max_subitems" type="int" /> + <argument index="3" name="max_depth" type="int" /> + <description> + </description> + </method> + <method name="_execute_file" qualifiers="virtual"> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> + <description> + </description> + </method> + <method name="_find_function" qualifiers="virtual const"> + <return type="int" /> + <argument index="0" name="class_name" type="String" /> + <argument index="1" name="function_name" type="String" /> + <description> + </description> + </method> + <method name="_finish" qualifiers="virtual"> + <return type="void" /> + <description> + </description> + </method> + <method name="_frame" qualifiers="virtual"> + <return type="void" /> + <description> + </description> + </method> + <method name="_free_instance_binding_data" qualifiers="virtual"> + <return type="void" /> + <argument index="0" name="data" type="void*" /> + <description> + </description> + </method> + <method name="_get_built_in_templates" qualifiers="virtual const"> + <return type="Dictionary[]" /> + <argument index="0" name="object" type="StringName" /> + <description> + </description> + </method> + <method name="_get_comment_delimiters" qualifiers="virtual const"> + <return type="PackedStringArray" /> + <description> + </description> + </method> + <method name="_get_extension" qualifiers="virtual const"> + <return type="String" /> + <description> + </description> + </method> + <method name="_get_global_class_name" qualifiers="virtual const"> + <return type="Dictionary" /> + <argument index="0" name="path" type="String" /> + <description> + </description> + </method> + <method name="_get_name" qualifiers="virtual const"> + <return type="String" /> + <description> + </description> + </method> + <method name="_get_public_constants" qualifiers="virtual const"> + <return type="Dictionary" /> + <description> + </description> + </method> + <method name="_get_public_functions" qualifiers="virtual const"> + <return type="Dictionary[]" /> + <description> + </description> + </method> + <method name="_get_recognized_extensions" qualifiers="virtual const"> + <return type="PackedStringArray" /> + <description> + </description> + </method> + <method name="_get_reserved_words" qualifiers="virtual const"> + <return type="PackedStringArray" /> + <description> + </description> + </method> + <method name="_get_string_delimiters" qualifiers="virtual const"> + <return type="PackedStringArray" /> + <description> + </description> + </method> + <method name="_get_type" qualifiers="virtual const"> + <return type="String" /> + <description> + </description> + </method> + <method name="_handles_global_class_type" qualifiers="virtual const"> + <return type="bool" /> + <argument index="0" name="type" type="String" /> + <description> + </description> + </method> + <method name="_has_named_classes" qualifiers="virtual const"> + <return type="bool" /> + <description> + </description> + </method> + <method name="_init" qualifiers="virtual"> + <return type="void" /> + <description> + </description> + </method> + <method name="_is_control_flow_keyword" qualifiers="virtual const"> + <return type="bool" /> + <argument index="0" name="keyword" type="String" /> + <description> + </description> + </method> + <method name="_is_using_templates" qualifiers="virtual"> + <return type="bool" /> + <description> + </description> + </method> + <method name="_lookup_code" qualifiers="virtual const"> + <return type="Dictionary" /> + <argument index="0" name="code" type="String" /> + <argument index="1" name="symbol" type="String" /> + <argument index="2" name="path" type="String" /> + <argument index="3" name="owner" type="Object" /> + <description> + </description> + </method> + <method name="_make_function" qualifiers="virtual const"> + <return type="String" /> + <argument index="0" name="class_name" type="String" /> + <argument index="1" name="function_name" type="String" /> + <argument index="2" name="function_args" type="PackedStringArray" /> + <description> + </description> + </method> + <method name="_make_template" qualifiers="virtual const"> + <return type="Script" /> + <argument index="0" name="template" type="String" /> + <argument index="1" name="class_name" type="String" /> + <argument index="2" name="base_class_name" type="String" /> + <description> + </description> + </method> + <method name="_open_in_external_editor" qualifiers="virtual"> + <return type="int" enum="Error" /> + <argument index="0" name="script" type="Script" /> + <argument index="1" name="line" type="int" /> + <argument index="2" name="column" type="int" /> + <description> + </description> + </method> + <method name="_overrides_external_editor" qualifiers="virtual"> + <return type="bool" /> + <description> + </description> + </method> + <method name="_profiling_get_accumulated_data" qualifiers="virtual"> + <return type="int" /> + <argument index="0" name="info_array" type="ScriptLanguageExtensionProfilingInfo*" /> + <argument index="1" name="info_max" type="int" /> + <description> + </description> + </method> + <method name="_profiling_get_frame_data" qualifiers="virtual"> + <return type="int" /> + <argument index="0" name="info_array" type="ScriptLanguageExtensionProfilingInfo*" /> + <argument index="1" name="info_max" type="int" /> + <description> + </description> + </method> + <method name="_profiling_start" qualifiers="virtual"> + <return type="void" /> + <description> + </description> + </method> + <method name="_profiling_stop" qualifiers="virtual"> + <return type="void" /> + <description> + </description> + </method> + <method name="_refcount_decremented_instance_binding" qualifiers="virtual"> + <return type="bool" /> + <argument index="0" name="object" type="Object" /> + <description> + </description> + </method> + <method name="_refcount_incremented_instance_binding" qualifiers="virtual"> + <return type="void" /> + <argument index="0" name="object" type="Object" /> + <description> + </description> + </method> + <method name="_reload_all_scripts" qualifiers="virtual"> + <return type="void" /> + <description> + </description> + </method> + <method name="_reload_tool_script" qualifiers="virtual"> + <return type="void" /> + <argument index="0" name="script" type="Script" /> + <argument index="1" name="soft_reload" type="bool" /> + <description> + </description> + </method> + <method name="_remove_named_global_constant" qualifiers="virtual"> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <description> + </description> + </method> + <method name="_supports_builtin_mode" qualifiers="virtual const"> + <return type="bool" /> + <description> + </description> + </method> + <method name="_supports_documentation" qualifiers="virtual const"> + <return type="bool" /> + <description> + </description> + </method> + <method name="_thread_enter" qualifiers="virtual"> + <return type="void" /> + <description> + </description> + </method> + <method name="_thread_exit" qualifiers="virtual"> + <return type="void" /> + <description> + </description> + </method> + <method name="_validate" qualifiers="virtual const"> + <return type="Dictionary" /> + <argument index="0" name="script" type="String" /> + <argument index="1" name="path" type="String" /> + <argument index="2" name="validate_functions" type="bool" /> + <argument index="3" name="validate_errors" type="bool" /> + <argument index="4" name="validate_warnings" type="bool" /> + <argument index="5" name="validate_safe_lines" type="bool" /> + <description> + </description> + </method> + <method name="_validate_path" qualifiers="virtual const"> + <return type="String" /> + <argument index="0" name="path" type="String" /> + <description> + </description> + </method> + </methods> + <constants> + <constant name="LOOKUP_RESULT_SCRIPT_LOCATION" value="0" enum="LookupResultType"> + </constant> + <constant name="LOOKUP_RESULT_CLASS" value="1" enum="LookupResultType"> + </constant> + <constant name="LOOKUP_RESULT_CLASS_CONSTANT" value="2" enum="LookupResultType"> + </constant> + <constant name="LOOKUP_RESULT_CLASS_PROPERTY" value="3" enum="LookupResultType"> + </constant> + <constant name="LOOKUP_RESULT_CLASS_METHOD" value="4" enum="LookupResultType"> + </constant> + <constant name="LOOKUP_RESULT_CLASS_ENUM" value="5" enum="LookupResultType"> + </constant> + <constant name="LOOKUP_RESULT_CLASS_TBD_GLOBALSCOPE" value="6" enum="LookupResultType"> + </constant> + <constant name="LOOKUP_RESULT_MAX" value="7" enum="LookupResultType"> + </constant> + <constant name="CODE_COMPLETION_KIND_CLASS" value="0" enum="CodeCompletionKind"> + </constant> + <constant name="CODE_COMPLETION_KIND_FUNCTION" value="1" enum="CodeCompletionKind"> + </constant> + <constant name="CODE_COMPLETION_KIND_SIGNAL" value="2" enum="CodeCompletionKind"> + </constant> + <constant name="CODE_COMPLETION_KIND_VARIABLE" value="3" enum="CodeCompletionKind"> + </constant> + <constant name="CODE_COMPLETION_KIND_MEMBER" value="4" enum="CodeCompletionKind"> + </constant> + <constant name="CODE_COMPLETION_KIND_ENUM" value="5" enum="CodeCompletionKind"> + </constant> + <constant name="CODE_COMPLETION_KIND_CONSTANT" value="6" enum="CodeCompletionKind"> + </constant> + <constant name="CODE_COMPLETION_KIND_NODE_PATH" value="7" enum="CodeCompletionKind"> + </constant> + <constant name="CODE_COMPLETION_KIND_FILE_PATH" value="8" enum="CodeCompletionKind"> + </constant> + <constant name="CODE_COMPLETION_KIND_PLAIN_TEXT" value="9" enum="CodeCompletionKind"> + </constant> + <constant name="CODE_COMPLETION_KIND_MAX" value="10" enum="CodeCompletionKind"> + </constant> + </constants> +</class> diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 2896fda2d2..b6da21bc79 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -854,7 +854,7 @@ void CodeTextEditor::_code_complete_timer_timeout() { } void CodeTextEditor::_complete_request() { - List<ScriptCodeCompletionOption> entries; + List<ScriptLanguage::CodeCompletionOption> entries; String ctext = text_editor->get_text_for_code_completion(); _code_complete_script(ctext, &entries); bool forced = false; @@ -865,7 +865,7 @@ void CodeTextEditor::_complete_request() { return; } - for (const ScriptCodeCompletionOption &e : entries) { + for (const ScriptLanguage::CodeCompletionOption &e : entries) { Color font_color = completion_font_color; if (e.insert_text.begins_with("\"") || e.insert_text.begins_with("\'")) { font_color = completion_string_color; @@ -877,41 +877,41 @@ void CodeTextEditor::_complete_request() { text_editor->update_code_completion_options(forced); } -Ref<Texture2D> CodeTextEditor::_get_completion_icon(const ScriptCodeCompletionOption &p_option) { +Ref<Texture2D> CodeTextEditor::_get_completion_icon(const ScriptLanguage::CodeCompletionOption &p_option) { Ref<Texture2D> tex; switch (p_option.kind) { - case ScriptCodeCompletionOption::KIND_CLASS: { + case ScriptLanguage::CODE_COMPLETION_KIND_CLASS: { if (has_theme_icon(p_option.display, SNAME("EditorIcons"))) { tex = get_theme_icon(p_option.display, SNAME("EditorIcons")); } else { tex = get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); } } break; - case ScriptCodeCompletionOption::KIND_ENUM: + case ScriptLanguage::CODE_COMPLETION_KIND_ENUM: tex = get_theme_icon(SNAME("Enum"), SNAME("EditorIcons")); break; - case ScriptCodeCompletionOption::KIND_FILE_PATH: + case ScriptLanguage::CODE_COMPLETION_KIND_FILE_PATH: tex = get_theme_icon(SNAME("File"), SNAME("EditorIcons")); break; - case ScriptCodeCompletionOption::KIND_NODE_PATH: + case ScriptLanguage::CODE_COMPLETION_KIND_NODE_PATH: tex = get_theme_icon(SNAME("NodePath"), SNAME("EditorIcons")); break; - case ScriptCodeCompletionOption::KIND_VARIABLE: + case ScriptLanguage::CODE_COMPLETION_KIND_VARIABLE: tex = get_theme_icon(SNAME("Variant"), SNAME("EditorIcons")); break; - case ScriptCodeCompletionOption::KIND_CONSTANT: + case ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT: tex = get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons")); break; - case ScriptCodeCompletionOption::KIND_MEMBER: + case ScriptLanguage::CODE_COMPLETION_KIND_MEMBER: tex = get_theme_icon(SNAME("MemberProperty"), SNAME("EditorIcons")); break; - case ScriptCodeCompletionOption::KIND_SIGNAL: + case ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL: tex = get_theme_icon(SNAME("MemberSignal"), SNAME("EditorIcons")); break; - case ScriptCodeCompletionOption::KIND_FUNCTION: + case ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION: tex = get_theme_icon(SNAME("MemberMethod"), SNAME("EditorIcons")); break; - case ScriptCodeCompletionOption::KIND_PLAIN_TEXT: + case ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT: tex = get_theme_icon(SNAME("BoxMesh"), SNAME("EditorIcons")); break; default: diff --git a/editor/code_editor.h b/editor/code_editor.h index d7025e7fd9..bbc45d6ec0 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -134,7 +134,7 @@ public: FindReplaceBar(); }; -typedef void (*CodeTextEditorCodeCompleteFunc)(void *p_ud, const String &p_code, List<ScriptCodeCompletionOption> *r_options, bool &r_forced); +typedef void (*CodeTextEditorCodeCompleteFunc)(void *p_ud, const String &p_code, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_forced); class CodeTextEditor : public VBoxContainer { GDCLASS(CodeTextEditor, VBoxContainer); @@ -166,7 +166,7 @@ class CodeTextEditor : public VBoxContainer { void _update_text_editor_theme(); void _complete_request(); - Ref<Texture2D> _get_completion_icon(const ScriptCodeCompletionOption &p_option); + Ref<Texture2D> _get_completion_icon(const ScriptLanguage::CodeCompletionOption &p_option); void _font_resize_timeout(); bool _add_font_size(int p_delta); @@ -197,7 +197,7 @@ class CodeTextEditor : public VBoxContainer { protected: virtual void _load_theme_settings() {} virtual void _validate_script() {} - virtual void _code_complete_script(const String &p_code, List<ScriptCodeCompletionOption> *r_options) {} + virtual void _code_complete_script(const String &p_code, List<ScriptLanguage::CodeCompletionOption> *r_options) {} void _text_changed_idle_timeout(); void _code_complete_timer_timeout(); diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 40b53c2636..92345f024c 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -1763,7 +1763,7 @@ ScriptEditorDebugger::ScriptEditorDebugger() { inspector = memnew(EditorDebuggerInspector); inspector->set_h_size_flags(SIZE_EXPAND_FILL); inspector->set_v_size_flags(SIZE_EXPAND_FILL); - inspector->set_enable_capitalize_paths(false); + inspector->set_property_name_style(EditorPropertyNameProcessor::STYLE_RAW); inspector->set_read_only(true); inspector->connect("object_selected", callable_mp(this, &ScriptEditorDebugger::_remote_object_selected)); inspector->connect("object_edited", callable_mp(this, &ScriptEditorDebugger::_remote_object_edited)); diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index 3d5ca7de42..cf45848ed3 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -608,18 +608,24 @@ void EditorFeatureProfileManager::_class_list_item_selected() { TreeItem *properties = property_list->create_item(root); properties->set_text(0, TTR("Class Properties:")); + const EditorPropertyNameProcessor::Style text_style = EditorPropertyNameProcessor::get_settings_style(); + const EditorPropertyNameProcessor::Style tooltip_style = EditorPropertyNameProcessor::get_tooltip_style(text_style); + for (const PropertyInfo &E : props) { String name = E.name; if (!(E.usage & PROPERTY_USAGE_EDITOR)) { continue; } + const String text = EditorPropertyNameProcessor::get_singleton()->process_name(name, text_style); + const String tooltip = EditorPropertyNameProcessor::get_singleton()->process_name(name, tooltip_style); + TreeItem *property = property_list->create_item(properties); property->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); property->set_editable(0, true); property->set_selectable(0, true); property->set_checked(0, !edited->is_class_property_disabled(class_name, name)); - property->set_text(0, EditorPropertyNameProcessor::get_singleton()->process_name(name)); - property->set_tooltip(0, EditorPropertyNameProcessor::get_singleton()->make_tooltip_for_name(name)); + property->set_text(0, text); + property->set_tooltip(0, tooltip); property->set_metadata(0, name); String icon_type = Variant::get_type_name(E.type); property->set_icon(0, EditorNode::get_singleton()->get_class_icon(icon_type)); diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index fe19e73db9..ab403c4212 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -1308,6 +1308,18 @@ void EditorFileDialog::_update_favorites() { favorite->set_pressed(false); Vector<String> favorited = EditorSettings::get_singleton()->get_favorites(); + + bool fav_changed = false; + for (int i = favorited.size() - 1; i >= 0; i--) { + if (!dir_access->dir_exists(favorited[i])) { + favorited.remove_at(i); + fav_changed = true; + } + } + if (fav_changed) { + EditorSettings::get_singleton()->set_favorites(favorited); + } + for (int i = 0; i < favorited.size(); i++) { bool cres = favorited[i].begins_with("res://"); if (cres != res) { diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 98ba3ae3d8..f3d9449c6c 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -888,7 +888,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess if (script == nullptr) { continue; } - const Vector<DocData::ClassDoc> &docs = script->get_documentation(); + Vector<DocData::ClassDoc> docs = script->get_documentation(); for (int j = 0; j < docs.size(); j++) { EditorHelp::get_doc_data()->add_doc(docs[j]); } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 18c9a9f495..483082858e 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -44,14 +44,14 @@ #include "scene/property_utils.h" #include "scene/resources/packed_scene.h" -static bool _property_path_matches(const String &p_property_path, const String &p_filter) { +static bool _property_path_matches(const String &p_property_path, const String &p_filter, EditorPropertyNameProcessor::Style p_style) { if (p_property_path.findn(p_filter) != -1) { return true; } const Vector<String> sections = p_property_path.split("/"); for (int i = 0; i < sections.size(); i++) { - if (p_filter.is_subsequence_ofn(EditorPropertyNameProcessor::get_singleton()->process_name(sections[i]))) { + if (p_filter.is_subsequence_ofn(EditorPropertyNameProcessor::get_singleton()->process_name(sections[i], p_style))) { return true; } } @@ -2456,6 +2456,8 @@ void EditorInspector::update_tree() { _parse_added_editors(main_vbox, ped); } + bool in_script_variables = false; + // Get the lists of editors for properties. for (List<PropertyInfo>::Element *E_property = plist.front(); E_property; E_property = E_property->next()) { PropertyInfo &p = E_property->get(); @@ -2547,6 +2549,9 @@ void EditorInspector::update_tree() { if (category->icon.is_null() && has_theme_icon(base_type, SNAME("EditorIcons"))) { category->icon = get_theme_icon(base_type, SNAME("EditorIcons")); } + in_script_variables = true; + } else { + in_script_variables = false; } if (category->icon.is_null()) { if (!type.is_empty()) { // Can happen for built-in scripts. @@ -2673,18 +2678,22 @@ void EditorInspector::update_tree() { // Get the property label's string. String name_override = (path.contains("/")) ? path.substr(path.rfind("/") + 1) : path; - String property_label_string = name_override; - if (capitalize_paths) { - // Capitalize paths. - int dot = property_label_string.find("."); + String feature_tag; + { + const int dot = name_override.find("."); if (dot != -1) { + feature_tag = name_override.right(dot); name_override = name_override.substr(0, dot); - property_label_string = EditorPropertyNameProcessor::get_singleton()->process_name(name_override) + property_label_string.substr(dot); - } else { - property_label_string = EditorPropertyNameProcessor::get_singleton()->process_name(property_label_string); } } + // Don't localize properties in Script Variables category. + EditorPropertyNameProcessor::Style name_style = property_name_style; + if (in_script_variables && name_style == EditorPropertyNameProcessor::STYLE_LOCALIZED) { + name_style = EditorPropertyNameProcessor::STYLE_CAPITALIZED; + } + const String property_label_string = EditorPropertyNameProcessor::get_singleton()->process_name(name_override, name_style) + feature_tag; + // Remove the property from the path. int idx = path.rfind("/"); if (idx > -1) { @@ -2696,7 +2705,7 @@ void EditorInspector::update_tree() { // Ignore properties that do not fit the filter. if (use_filter && !filter.is_empty()) { const String property_path = property_prefix + (path.is_empty() ? "" : path + "/") + name_override; - if (!_property_path_matches(property_path, filter)) { + if (!_property_path_matches(property_path, filter, property_name_style)) { continue; } } @@ -2733,15 +2742,13 @@ void EditorInspector::update_tree() { current_vbox->add_child(section); sections.push_back(section); - String label = component; - if (capitalize_paths) { - label = EditorPropertyNameProcessor::get_singleton()->process_name(label); - } + const String label = EditorPropertyNameProcessor::get_singleton()->process_name(component, property_name_style); + const String tooltip = EditorPropertyNameProcessor::get_singleton()->process_name(component, EditorPropertyNameProcessor::get_tooltip_style(property_name_style)); Color c = sscolor; c.a /= level; section->setup(acc_path, label, object, c, use_folding, section_depth); - section->set_tooltip(EditorPropertyNameProcessor::get_singleton()->make_tooltip_for_name(component)); + section->set_tooltip(tooltip); // Add editors at the start of a group. for (Ref<EditorInspectorPlugin> &ped : valid_plugins) { @@ -2773,7 +2780,7 @@ void EditorInspector::update_tree() { editor_inspector_array = memnew(EditorInspectorArray); String array_label = path.contains("/") ? path.substr(path.rfind("/") + 1) : path; - array_label = EditorPropertyNameProcessor::get_singleton()->process_name(property_label_string); + array_label = EditorPropertyNameProcessor::get_singleton()->process_name(property_label_string, property_name_style); int page = per_array_page.has(array_element_prefix) ? per_array_page[array_element_prefix] : 0; editor_inspector_array->setup_with_move_element_function(object, array_label, array_element_prefix, page, c, use_folding); editor_inspector_array->connect("page_change_request", callable_mp(this, &EditorInspector::_page_change_request), varray(array_element_prefix)); @@ -3037,12 +3044,15 @@ void EditorInspector::set_read_only(bool p_read_only) { update_tree(); } -bool EditorInspector::is_capitalize_paths_enabled() const { - return capitalize_paths; +EditorPropertyNameProcessor::Style EditorInspector::get_property_name_style() const { + return property_name_style; } -void EditorInspector::set_enable_capitalize_paths(bool p_capitalize) { - capitalize_paths = p_capitalize; +void EditorInspector::set_property_name_style(EditorPropertyNameProcessor::Style p_style) { + if (property_name_style == p_style) { + return; + } + property_name_style = p_style; update_tree(); } diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index d625a8043c..87703564b9 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -31,6 +31,7 @@ #ifndef EDITOR_INSPECTOR_H #define EDITOR_INSPECTOR_H +#include "editor_property_name_processor.h" #include "scene/gui/box_container.h" #include "scene/gui/button.h" #include "scene/gui/dialogs.h" @@ -448,7 +449,7 @@ class EditorInspector : public ScrollContainer { bool hide_script = true; bool hide_metadata = true; bool use_doc_hints = false; - bool capitalize_paths = true; + EditorPropertyNameProcessor::Style property_name_style = EditorPropertyNameProcessor::STYLE_CAPITALIZED; bool use_filter = false; bool autoclear = false; bool use_folding = false; @@ -545,8 +546,9 @@ public: void set_keying(bool p_active); void set_read_only(bool p_read_only); - bool is_capitalize_paths_enabled() const; - void set_enable_capitalize_paths(bool p_capitalize); + EditorPropertyNameProcessor::Style get_property_name_style() const; + void set_property_name_style(EditorPropertyNameProcessor::Style p_style); + void set_autoclear(bool p_enable); void set_show_categories(bool p_show); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 65101792b7..92ab20b999 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6055,9 +6055,10 @@ EditorNode::EditorNode() { EDITOR_DEF("interface/editor/save_on_focus_loss", false); EDITOR_DEF("interface/editor/show_update_spinner", false); EDITOR_DEF("interface/editor/update_continuously", false); - EDITOR_DEF("interface/editor/translate_properties", true); + EDITOR_DEF("interface/editor/localize_settings", true); EDITOR_DEF_RST("interface/scene_tabs/restore_scenes_on_load", true); - EDITOR_DEF_RST("interface/inspector/capitalize_properties", true); + EDITOR_DEF_RST("interface/inspector/default_property_name_style", EditorPropertyNameProcessor::STYLE_CAPITALIZED); + EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "interface/inspector/default_property_name_style", PROPERTY_HINT_ENUM, "Raw,Capitalized,Localized")); EDITOR_DEF_RST("interface/inspector/default_float_step", 0.001); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::FLOAT, "interface/inspector/default_float_step", PROPERTY_HINT_RANGE, "0,1,0")); EDITOR_DEF_RST("interface/inspector/disable_folding", false); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index b495d29911..cdb96bd0c8 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -3221,7 +3221,7 @@ void EditorPropertyResource::update_property() { sub_inspector->set_use_doc_hints(true); sub_inspector->set_sub_inspector(true); - sub_inspector->set_enable_capitalize_paths(bool(EDITOR_GET("interface/inspector/capitalize_properties"))); + sub_inspector->set_property_name_style(InspectorDock::get_singleton()->get_property_name_style()); sub_inspector->connect("property_keyed", callable_mp(this, &EditorPropertyResource::_sub_inspector_property_keyed)); sub_inspector->connect("resource_selected", callable_mp(this, &EditorPropertyResource::_sub_inspector_resource_selected)); diff --git a/editor/editor_property_name_processor.cpp b/editor/editor_property_name_processor.cpp index f55b2b61c8..d89247b429 100644 --- a/editor/editor_property_name_processor.cpp +++ b/editor/editor_property_name_processor.cpp @@ -34,6 +34,28 @@ EditorPropertyNameProcessor *EditorPropertyNameProcessor::singleton = nullptr; +EditorPropertyNameProcessor::Style EditorPropertyNameProcessor::get_default_inspector_style() { + const Style style = (Style)EDITOR_GET("interface/inspector/default_property_name_style").operator int(); + if (style == STYLE_LOCALIZED && !is_localization_available()) { + return STYLE_CAPITALIZED; + } + return style; +} + +EditorPropertyNameProcessor::Style EditorPropertyNameProcessor::get_settings_style() { + const bool translate = EDITOR_GET("interface/editor/localize_settings"); + return translate ? STYLE_LOCALIZED : STYLE_CAPITALIZED; +} + +EditorPropertyNameProcessor::Style EditorPropertyNameProcessor::get_tooltip_style(Style p_style) { + return p_style == STYLE_LOCALIZED ? STYLE_CAPITALIZED : STYLE_LOCALIZED; +} + +bool EditorPropertyNameProcessor::is_localization_available() { + const Vector<String> forbidden = String("en").split(","); + return forbidden.find(EDITOR_GET("interface/editor/editor_language")) == -1; +} + String EditorPropertyNameProcessor::_capitalize_name(const String &p_name) const { const Map<String, String>::Element *cached = capitalize_string_cache.find(p_name); if (cached) { @@ -55,20 +77,21 @@ String EditorPropertyNameProcessor::_capitalize_name(const String &p_name) const return capitalized; } -String EditorPropertyNameProcessor::process_name(const String &p_name) const { - const String capitalized_string = _capitalize_name(p_name); - if (EDITOR_GET("interface/editor/translate_properties")) { - return TTRGET(capitalized_string); - } - return capitalized_string; -} +String EditorPropertyNameProcessor::process_name(const String &p_name, Style p_style) const { + switch (p_style) { + case STYLE_RAW: { + return p_name; + } break; + + case STYLE_CAPITALIZED: { + return _capitalize_name(p_name); + } break; -String EditorPropertyNameProcessor::make_tooltip_for_name(const String &p_name) const { - const String capitalized_string = _capitalize_name(p_name); - if (EDITOR_GET("interface/editor/translate_properties")) { - return capitalized_string; + case STYLE_LOCALIZED: { + return TTRGET(_capitalize_name(p_name)); + } break; } - return TTRGET(capitalized_string); + ERR_FAIL_V_MSG(p_name, "Unexpected property name style."); } EditorPropertyNameProcessor::EditorPropertyNameProcessor() { @@ -84,6 +107,8 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["adb"] = "ADB"; capitalize_string_remaps["ao"] = "AO"; capitalize_string_remaps["apk"] = "APK"; + capitalize_string_remaps["arm64-v8a"] = "arm64-v8a"; + capitalize_string_remaps["armeabi-v7a"] = "armeabi-v7a"; capitalize_string_remaps["arvr"] = "ARVR"; capitalize_string_remaps["bg"] = "BG"; capitalize_string_remaps["bp"] = "BP"; @@ -130,6 +155,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["ipad"] = "iPad"; capitalize_string_remaps["iphone"] = "iPhone"; capitalize_string_remaps["ipv6"] = "IPv6"; + capitalize_string_remaps["ir"] = "IR"; capitalize_string_remaps["jit"] = "JIT"; capitalize_string_remaps["k1"] = "K1"; capitalize_string_remaps["k2"] = "K2"; @@ -139,10 +165,12 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["lowpass"] = "Low-pass"; capitalize_string_remaps["macos"] = "macOS"; capitalize_string_remaps["mb"] = "(MB)"; // Unit. + capitalize_string_remaps["mms"] = "MMS"; capitalize_string_remaps["ms"] = "(ms)"; // Unit // Not used for now as AudioEffectReverb has a `msec` property. //capitalize_string_remaps["msec"] = "(msec)"; // Unit. capitalize_string_remaps["msaa"] = "MSAA"; + capitalize_string_remaps["nfc"] = "NFC"; capitalize_string_remaps["normalmap"] = "Normal Map"; capitalize_string_remaps["ok"] = "OK"; capitalize_string_remaps["opengl"] = "OpenGL"; @@ -162,6 +190,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["sdfgi"] = "SDFGI"; capitalize_string_remaps["sdk"] = "SDK"; capitalize_string_remaps["sec"] = "(sec)"; // Unit. + capitalize_string_remaps["sms"] = "SMS"; capitalize_string_remaps["srgb"] = "sRGB"; capitalize_string_remaps["ssao"] = "SSAO"; capitalize_string_remaps["ssh"] = "SSH"; @@ -182,12 +211,15 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["uv2"] = "UV2"; capitalize_string_remaps["uwp"] = "UWP"; capitalize_string_remaps["vector2"] = "Vector2"; + capitalize_string_remaps["vpn"] = "VPN"; capitalize_string_remaps["vram"] = "VRAM"; capitalize_string_remaps["vsync"] = "V-Sync"; + capitalize_string_remaps["wap"] = "WAP"; capitalize_string_remaps["webp"] = "WebP"; capitalize_string_remaps["webrtc"] = "WebRTC"; capitalize_string_remaps["websocket"] = "WebSocket"; capitalize_string_remaps["wifi"] = "Wi-Fi"; + capitalize_string_remaps["x86"] = "x86"; capitalize_string_remaps["xr"] = "XR"; capitalize_string_remaps["xy"] = "XY"; capitalize_string_remaps["xz"] = "XZ"; diff --git a/editor/editor_property_name_processor.h b/editor/editor_property_name_processor.h index 616c4cac46..351736550f 100644 --- a/editor/editor_property_name_processor.h +++ b/editor/editor_property_name_processor.h @@ -41,16 +41,27 @@ class EditorPropertyNameProcessor : public Node { mutable Map<String, String> capitalize_string_cache; Map<String, String> capitalize_string_remaps; + // Capitalizes property path segments. String _capitalize_name(const String &p_name) const; public: + // Matches `interface/inspector/capitalize_properties` editor setting. + enum Style { + STYLE_RAW, + STYLE_CAPITALIZED, + STYLE_LOCALIZED, + }; + static EditorPropertyNameProcessor *get_singleton() { return singleton; } - // Capitalize & localize property path segments. - String process_name(const String &p_name) const; + static Style get_default_inspector_style(); + static Style get_settings_style(); + static Style get_tooltip_style(Style p_style); + + static bool is_localization_available(); - // Make tooltip string for names processed by process_name(). - String make_tooltip_for_name(const String &p_name) const; + // Turns property path segment into the given style. + String process_name(const String &p_name, Style p_style) const; EditorPropertyNameProcessor(); ~EditorPropertyNameProcessor(); diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index 627fa0eb35..801a1a4641 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -32,15 +32,16 @@ #include "editor/editor_property_name_processor.h" #include "editor/editor_scale.h" +#include "editor/editor_settings.h" -static bool _property_path_matches(const String &p_property_path, const String &p_filter) { +static bool _property_path_matches(const String &p_property_path, const String &p_filter, EditorPropertyNameProcessor::Style p_style) { if (p_property_path.findn(p_filter) != -1) { return true; } const Vector<String> sections = p_property_path.split("/"); for (int i = 0; i < sections.size(); i++) { - if (p_filter.is_subsequence_ofn(EditorPropertyNameProcessor::get_singleton()->process_name(sections[i]))) { + if (p_filter.is_subsequence_ofn(EditorPropertyNameProcessor::get_singleton()->process_name(sections[i], p_style))) { return true; } } @@ -235,6 +236,9 @@ void SectionedInspector::update_category_list() { filter = search_box->get_text(); } + const EditorPropertyNameProcessor::Style name_style = EditorPropertyNameProcessor::get_settings_style(); + const EditorPropertyNameProcessor::Style tooltip_style = EditorPropertyNameProcessor::get_tooltip_style(name_style); + for (PropertyInfo &pi : pinfo) { if (pi.usage & PROPERTY_USAGE_CATEGORY) { continue; @@ -246,7 +250,7 @@ void SectionedInspector::update_category_list() { continue; } - if (!filter.is_empty() && !_property_path_matches(pi.name, filter)) { + if (!filter.is_empty() && !_property_path_matches(pi.name, filter, name_style)) { continue; } @@ -274,8 +278,12 @@ void SectionedInspector::update_category_list() { if (!section_map.has(metasection)) { TreeItem *ms = sections->create_item(parent); section_map[metasection] = ms; - ms->set_text(0, EditorPropertyNameProcessor::get_singleton()->process_name(sectionarr[i])); - ms->set_tooltip(0, EditorPropertyNameProcessor::get_singleton()->make_tooltip_for_name(sectionarr[i])); + + const String text = EditorPropertyNameProcessor::get_singleton()->process_name(sectionarr[i], name_style); + const String tooltip = EditorPropertyNameProcessor::get_singleton()->process_name(sectionarr[i], tooltip_style); + + ms->set_text(0, text); + ms->set_tooltip(0, tooltip); ms->set_metadata(0, metasection); ms->set_selectable(0, false); } @@ -304,6 +312,14 @@ void SectionedInspector::_search_changed(const String &p_what) { update_category_list(); } +void SectionedInspector::_notification(int p_what) { + switch (p_what) { + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { + inspector->set_property_name_style(EditorPropertyNameProcessor::get_settings_style()); + } break; + } +} + EditorInspector *SectionedInspector::get_inspector() { return inspector; } @@ -337,6 +353,7 @@ SectionedInspector::SectionedInspector() : inspector->set_v_size_flags(SIZE_EXPAND_FILL); right_vb->add_child(inspector, true); inspector->set_use_doc_hints(true); + inspector->set_property_name_style(EditorPropertyNameProcessor::get_settings_style()); sections->connect("cell_selected", callable_mp(this, &SectionedInspector::_section_selected)); } diff --git a/editor/editor_sectioned_inspector.h b/editor/editor_sectioned_inspector.h index f81c4631e4..7c21e00c03 100644 --- a/editor/editor_sectioned_inspector.h +++ b/editor/editor_sectioned_inspector.h @@ -58,6 +58,9 @@ class SectionedInspector : public HSplitContainer { void _search_changed(const String &p_what); +protected: + void _notification(int p_what); + public: void register_search_box(LineEdit *p_box); EditorInspector *get_inspector(); diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp index 63b5b5b803..285b909b66 100644 --- a/editor/editor_settings_dialog.cpp +++ b/editor/editor_settings_dialog.cpp @@ -142,6 +142,8 @@ void EditorSettingsDialog::_notification(int p_what) { if (update_shortcuts_tab) { _update_shortcuts(); } + + inspector->update_category_list(); } break; } } @@ -415,6 +417,9 @@ void EditorSettingsDialog::_update_shortcuts() { List<String> slist; EditorSettings::get_singleton()->get_shortcut_list(&slist); + const EditorPropertyNameProcessor::Style name_style = EditorPropertyNameProcessor::get_settings_style(); + const EditorPropertyNameProcessor::Style tooltip_style = EditorPropertyNameProcessor::get_tooltip_style(name_style); + for (const String &E : slist) { Ref<Shortcut> sc = EditorSettings::get_singleton()->get_shortcut(E); if (!sc->has_meta("original")) { @@ -431,9 +436,11 @@ void EditorSettingsDialog::_update_shortcuts() { } else { section = shortcuts->create_item(root); - String item_name = EditorPropertyNameProcessor::get_singleton()->process_name(section_name); + const String item_name = EditorPropertyNameProcessor::get_singleton()->process_name(section_name, name_style); + const String tooltip = EditorPropertyNameProcessor::get_singleton()->process_name(section_name, tooltip_style); + section->set_text(0, item_name); - section->set_tooltip(0, EditorPropertyNameProcessor::get_singleton()->make_tooltip_for_name(section_name)); + section->set_tooltip(0, tooltip); section->set_selectable(0, false); section->set_selectable(1, false); section->set_custom_bg_color(0, shortcuts->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 2100a787c8..ee7ed77957 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -224,6 +224,19 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo favorites->set_collapsed(p_uncollapsed_paths.find("Favorites") < 0); Vector<String> favorite_paths = EditorSettings::get_singleton()->get_favorites(); + + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + bool fav_changed = false; + for (int i = favorite_paths.size() - 1; i >= 0; i--) { + if (!da->dir_exists(favorite_paths[i])) { + favorite_paths.remove_at(i); + fav_changed = true; + } + } + if (fav_changed) { + EditorSettings::get_singleton()->set_favorites(favorite_paths); + } + for (int i = 0; i < favorite_paths.size(); i++) { String fave = favorite_paths[i]; if (!fave.begins_with("res://")) { diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index 8d6db7d1e0..e2fa624fc6 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -171,6 +171,11 @@ bool ResourceImporterTexture::get_option_visibility(const String &p_path, const if (compress_mode < COMPRESS_VRAM_COMPRESSED) { return false; } + } else if (p_option == "compress/normal_map") { + int compress_mode = int(p_options["compress/mode"]); + if (compress_mode == COMPRESS_LOSSLESS) { + return false; + } } else if (p_option == "mipmaps/limit") { return p_options["mipmaps/generate"]; diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index 5045e4a541..302bc98499 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -844,6 +844,10 @@ void SceneImportSettings::_notification(int p_what) { case NOTIFICATION_READY: { connect("confirmed", callable_mp(this, &SceneImportSettings::_re_import)); } break; + + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { + inspector->set_property_name_style(EditorPropertyNameProcessor::get_settings_style()); + } break; } } @@ -1231,6 +1235,7 @@ SceneImportSettings::SceneImportSettings() { inspector = memnew(EditorInspector); inspector->set_custom_minimum_size(Size2(300 * EDSCALE, 0)); + inspector->set_property_name_style(EditorPropertyNameProcessor::get_settings_style()); property_split->add_child(inspector); diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 9f1daac69f..4df46f2348 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -564,6 +564,7 @@ void ImportDock::_notification(int p_what) { switch (p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { imported->add_theme_style_override("normal", get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))); + import_opts->set_property_name_style(EditorPropertyNameProcessor::get_settings_style()); } break; case NOTIFICATION_ENTER_TREE: { @@ -638,6 +639,7 @@ ImportDock::ImportDock() { import_opts = memnew(EditorInspector); content->add_child(import_opts); import_opts->set_v_size_flags(SIZE_EXPAND_FILL); + import_opts->set_property_name_style(EditorPropertyNameProcessor::get_settings_style()); import_opts->connect("property_edited", callable_mp(this, &ImportDock::_property_edited)); import_opts->connect("property_toggled", callable_mp(this, &ImportDock::_property_toggled)); diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 9ebea79435..b6dba7ec36 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -37,6 +37,13 @@ InspectorDock *InspectorDock::singleton = nullptr; +void InspectorDock::_prepare_menu() { + PopupMenu *menu = object_menu->get_popup(); + for (int i = EditorPropertyNameProcessor::STYLE_RAW; i <= EditorPropertyNameProcessor::STYLE_LOCALIZED; i++) { + menu->set_item_checked(menu->get_item_index(PROPERTY_NAME_STYLE_RAW + i), i == property_name_style); + } +} + void InspectorDock::_menu_option(int p_option) { _menu_option_confirm(p_option, false); } @@ -175,6 +182,13 @@ void InspectorDock::_menu_option_confirm(int p_option, bool p_confirmed) { } break; + case PROPERTY_NAME_STYLE_RAW: + case PROPERTY_NAME_STYLE_CAPITALIZED: + case PROPERTY_NAME_STYLE_LOCALIZED: { + property_name_style = (EditorPropertyNameProcessor::Style)(p_option - PROPERTY_NAME_STYLE_RAW); + inspector->set_property_name_style(property_name_style); + } break; + default: { if (p_option >= OBJECT_METHOD_BASE) { ERR_FAIL_COND(!current); @@ -499,8 +513,19 @@ void InspectorDock::update(Object *p_object) { p->clear(); p->add_icon_shortcut(get_theme_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons")), ED_SHORTCUT("property_editor/expand_all", TTR("Expand All")), EXPAND_ALL); p->add_icon_shortcut(get_theme_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons")), ED_SHORTCUT("property_editor/collapse_all", TTR("Collapse All")), COLLAPSE_ALL); - p->add_separator(); + p->add_separator(TTR("Property Name Style")); + p->add_radio_check_item(TTR("Raw"), PROPERTY_NAME_STYLE_RAW); + p->add_radio_check_item(TTR("Capitalized"), PROPERTY_NAME_STYLE_CAPITALIZED); + p->add_radio_check_item(TTR("Localized"), PROPERTY_NAME_STYLE_LOCALIZED); + + if (!EditorPropertyNameProcessor::is_localization_available()) { + const int index = p->get_item_index(PROPERTY_NAME_STYLE_LOCALIZED); + p->set_item_disabled(index, true); + p->set_item_tooltip(index, TTR("Localization not available for current language.")); + } + + p->add_separator(); p->add_shortcut(ED_SHORTCUT("property_editor/copy_params", TTR("Copy Properties")), OBJECT_COPY_PARAMS); p->add_shortcut(ED_SHORTCUT("property_editor/paste_params", TTR("Paste Properties")), OBJECT_PASTE_PARAMS); @@ -534,12 +559,18 @@ void InspectorDock::go_back() { _edit_back(); } +EditorPropertyNameProcessor::Style InspectorDock::get_property_name_style() const { + return property_name_style; +} + InspectorDock::InspectorDock(EditorData &p_editor_data) { singleton = this; set_name("Inspector"); editor_data = &p_editor_data; + property_name_style = EditorPropertyNameProcessor::get_default_inspector_style(); + HBoxContainer *general_options_hb = memnew(HBoxContainer); add_child(general_options_hb); @@ -632,6 +663,7 @@ InspectorDock::InspectorDock(EditorData &p_editor_data) { object_menu->set_shortcut_context(this); property_tools_hb->add_child(object_menu); object_menu->set_tooltip(TTR("Manage object properties.")); + object_menu->get_popup()->connect("about_to_popup", callable_mp(this, &InspectorDock::_prepare_menu)); object_menu->get_popup()->connect("id_pressed", callable_mp(this, &InspectorDock::_menu_option)); warning = memnew(Button); @@ -680,7 +712,7 @@ InspectorDock::InspectorDock(EditorData &p_editor_data) { inspector->set_use_doc_hints(true); inspector->set_hide_script(false); inspector->set_hide_metadata(false); - inspector->set_enable_capitalize_paths(bool(EDITOR_GET("interface/inspector/capitalize_properties"))); + inspector->set_property_name_style(EditorPropertyNameProcessor::get_default_inspector_style()); inspector->set_use_folding(!bool(EDITOR_GET("interface/inspector/disable_folding"))); inspector->register_text_enter(search); inspector->set_undo_redo(&editor_data->get_undo_redo()); diff --git a/editor/inspector_dock.h b/editor/inspector_dock.h index 27552407bd..7e653c4750 100644 --- a/editor/inspector_dock.h +++ b/editor/inspector_dock.h @@ -62,6 +62,11 @@ class InspectorDock : public VBoxContainer { COLLAPSE_ALL, EXPAND_ALL, + // Matches `EditorPropertyNameProcessor::Style`. + PROPERTY_NAME_STYLE_RAW, + PROPERTY_NAME_STYLE_CAPITALIZED, + PROPERTY_NAME_STYLE_LOCALIZED, + OBJECT_METHOD_BASE = 500 }; @@ -94,6 +99,9 @@ class InspectorDock : public VBoxContainer { ConfirmationDialog *unique_resources_confirmation; Tree *unique_resources_list_tree; + EditorPropertyNameProcessor::Style property_name_style; + + void _prepare_menu(); void _menu_option(int p_option); void _menu_confirm_current(); void _menu_option_confirm(int p_option, bool p_confirmed); @@ -139,6 +147,8 @@ public: Container *get_addon_area(); EditorInspector *get_inspector() { return inspector; } + EditorPropertyNameProcessor::Style get_property_name_style() const; + InspectorDock(EditorData &p_editor_data); ~InspectorDock(); }; diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 2da5978fab..bbaf2bef98 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1348,7 +1348,7 @@ void ScriptEditor::_menu_option(int p_option) { } if (script != nullptr) { - const Vector<DocData::ClassDoc> &documentations = script->get_documentation(); + Vector<DocData::ClassDoc> documentations = script->get_documentation(); for (int j = 0; j < documentations.size(); j++) { const DocData::ClassDoc &doc = documentations.get(j); if (EditorHelp::get_doc_data()->has_doc(doc.name)) { @@ -1361,7 +1361,7 @@ void ScriptEditor::_menu_option(int p_option) { EditorNode::get_singleton()->save_resource_as(resource); if (script != nullptr) { - const Vector<DocData::ClassDoc> &documentations = script->get_documentation(); + Vector<DocData::ClassDoc> documentations = script->get_documentation(); for (int j = 0; j < documentations.size(); j++) { const DocData::ClassDoc &doc = documentations.get(j); EditorHelp::get_doc_data()->add_doc(doc); @@ -2464,7 +2464,7 @@ void ScriptEditor::save_current_script() { } if (script != nullptr) { - const Vector<DocData::ClassDoc> &documentations = script->get_documentation(); + Vector<DocData::ClassDoc> documentations = script->get_documentation(); for (int j = 0; j < documentations.size(); j++) { const DocData::ClassDoc &doc = documentations.get(j); if (EditorHelp::get_doc_data()->has_doc(doc.name)) { @@ -2486,7 +2486,7 @@ void ScriptEditor::save_current_script() { } if (script != nullptr) { - const Vector<DocData::ClassDoc> &documentations = script->get_documentation(); + Vector<DocData::ClassDoc> documentations = script->get_documentation(); for (int j = 0; j < documentations.size(); j++) { const DocData::ClassDoc &doc = documentations.get(j); EditorHelp::get_doc_data()->add_doc(doc); @@ -2537,7 +2537,7 @@ void ScriptEditor::save_all_scripts() { } if (script != nullptr) { - const Vector<DocData::ClassDoc> &documentations = script->get_documentation(); + Vector<DocData::ClassDoc> documentations = script->get_documentation(); for (int j = 0; j < documentations.size(); j++) { const DocData::ClassDoc &doc = documentations.get(j); if (EditorHelp::get_doc_data()->has_doc(doc.name)) { @@ -2549,7 +2549,7 @@ void ScriptEditor::save_all_scripts() { EditorNode::get_singleton()->save_resource(edited_res); //external script, save it if (script != nullptr) { - const Vector<DocData::ClassDoc> &documentations = script->get_documentation(); + Vector<DocData::ClassDoc> documentations = script->get_documentation(); for (int j = 0; j < documentations.size(); j++) { const DocData::ClassDoc &doc = documentations.get(j); EditorHelp::get_doc_data()->add_doc(doc); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 30ca1c605f..c1b0a32fc7 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -684,12 +684,12 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo } } -void ScriptTextEditor::_code_complete_scripts(void *p_ud, const String &p_code, List<ScriptCodeCompletionOption> *r_options, bool &r_force) { +void ScriptTextEditor::_code_complete_scripts(void *p_ud, const String &p_code, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_force) { ScriptTextEditor *ste = (ScriptTextEditor *)p_ud; ste->_code_complete_script(p_code, r_options, r_force); } -void ScriptTextEditor::_code_complete_script(const String &p_code, List<ScriptCodeCompletionOption> *r_options, bool &r_force) { +void ScriptTextEditor::_code_complete_script(const String &p_code, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_force) { if (color_panel->is_visible()) { return; } @@ -771,7 +771,7 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c _goto_line(p_row); switch (result.type) { - case ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION: { + case ScriptLanguage::LOOKUP_RESULT_SCRIPT_LOCATION: { if (result.script.is_valid()) { emit_signal(SNAME("request_open_script_at_line"), result.script, result.location - 1); } else { @@ -779,10 +779,10 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c goto_line_centered(result.location - 1); } } break; - case ScriptLanguage::LookupResult::RESULT_CLASS: { + case ScriptLanguage::LOOKUP_RESULT_CLASS: { emit_signal(SNAME("go_to_help"), "class_name:" + result.class_name); } break; - case ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT: { + case ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT: { StringName cname = result.class_name; bool success; while (true) { @@ -798,11 +798,11 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c emit_signal(SNAME("go_to_help"), "class_constant:" + result.class_name + ":" + result.class_member); } break; - case ScriptLanguage::LookupResult::RESULT_CLASS_PROPERTY: { + case ScriptLanguage::LOOKUP_RESULT_CLASS_PROPERTY: { emit_signal(SNAME("go_to_help"), "class_property:" + result.class_name + ":" + result.class_member); } break; - case ScriptLanguage::LookupResult::RESULT_CLASS_METHOD: { + case ScriptLanguage::LOOKUP_RESULT_CLASS_METHOD: { StringName cname = result.class_name; while (true) { @@ -817,7 +817,7 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c emit_signal(SNAME("go_to_help"), "class_method:" + result.class_name + ":" + result.class_member); } break; - case ScriptLanguage::LookupResult::RESULT_CLASS_ENUM: { + case ScriptLanguage::LOOKUP_RESULT_CLASS_ENUM: { StringName cname = result.class_name; StringName success; while (true) { @@ -833,9 +833,11 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c emit_signal(SNAME("go_to_help"), "class_enum:" + result.class_name + ":" + result.class_member); } break; - case ScriptLanguage::LookupResult::RESULT_CLASS_TBD_GLOBALSCOPE: { + case ScriptLanguage::LOOKUP_RESULT_CLASS_TBD_GLOBALSCOPE: { emit_signal(SNAME("go_to_help"), "class_global:" + result.class_name + ":" + result.class_member); } break; + default: { + } } } else if (ProjectSettings::get_singleton()->has_autoload(p_symbol)) { // Check for Autoload scenes. diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index 1e2284b403..5c3a66404e 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -162,8 +162,8 @@ protected: void _update_bookmark_list(); void _bookmark_item_pressed(int p_idx); - static void _code_complete_scripts(void *p_ud, const String &p_code, List<ScriptCodeCompletionOption> *r_options, bool &r_force); - void _code_complete_script(const String &p_code, List<ScriptCodeCompletionOption> *r_options, bool &r_force); + static void _code_complete_scripts(void *p_ud, const String &p_code, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_force); + void _code_complete_script(const String &p_code, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_force); void _load_theme_settings(); void _set_theme_for_script(); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index dbe6ca192c..070f1fac1e 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -222,7 +222,7 @@ static ShaderLanguage::DataType _get_global_variable_type(const StringName &p_va return (ShaderLanguage::DataType)RS::global_variable_type_get_shader_datatype(gvt); } -void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptCodeCompletionOption> *r_options) { +void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptLanguage::CodeCompletionOption> *r_options) { _check_shader_mode(); ShaderLanguage sl; diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h index b1391e4f66..600b14362e 100644 --- a/editor/plugins/shader_editor_plugin.h +++ b/editor/plugins/shader_editor_plugin.h @@ -65,7 +65,7 @@ protected: static void _bind_methods(); virtual void _load_theme_settings() override; - virtual void _code_complete_script(const String &p_code, List<ScriptCodeCompletionOption> *r_options) override; + virtual void _code_complete_script(const String &p_code, List<ScriptLanguage::CodeCompletionOption> *r_options) override; public: virtual void _validate_script() override; diff --git a/editor/project_export.cpp b/editor/project_export.cpp index cd9aef1e99..1344afbd3a 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -68,6 +68,10 @@ void ProjectExportDialog::_notification(int p_what) { connect("confirmed", callable_mp(this, &ProjectExportDialog::_export_pck_zip)); _update_export_all(); } break; + + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { + parameters->set_property_name_style(EditorPropertyNameProcessor::get_settings_style()); + } break; } } @@ -1066,6 +1070,7 @@ ProjectExportDialog::ProjectExportDialog() { sections->add_child(parameters); parameters->set_name(TTR("Options")); parameters->set_v_size_flags(Control::SIZE_EXPAND_FILL); + parameters->set_property_name_style(EditorPropertyNameProcessor::get_settings_style()); parameters->connect("property_edited", callable_mp(this, &ProjectExportDialog::_update_parameters)); EditorExport::get_singleton()->connect("export_presets_updated", callable_mp(this, &ProjectExportDialog::_force_update_current_preset_parameters)); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 13ece9011b..1d3b18a7d1 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2547,10 +2547,10 @@ void SceneTreeDock::_files_dropped(Vector<String> p_files, NodePath p_to, int p_ property_drop_node = node; resource_drop_path = res_path; - bool capitalize = bool(EDITOR_GET("interface/inspector/capitalize_properties")); + const EditorPropertyNameProcessor::Style style = InspectorDock::get_singleton()->get_property_name_style(); menu_properties->clear(); for (const String &p : valid_properties) { - menu_properties->add_item(capitalize ? p.capitalize() : p); + menu_properties->add_item(EditorPropertyNameProcessor::get_singleton()->process_name(p, style)); menu_properties->set_item_metadata(-1, p); } diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp index 70a43d24ba..864afa5c1c 100644 --- a/editor/shader_globals_editor.cpp +++ b/editor/shader_globals_editor.cpp @@ -477,7 +477,7 @@ ShaderGlobalsEditor::ShaderGlobalsEditor() { inspector->set_v_size_flags(SIZE_EXPAND_FILL); add_child(inspector); inspector->set_use_wide_editors(true); - inspector->set_enable_capitalize_paths(false); + inspector->set_property_name_style(EditorPropertyNameProcessor::STYLE_RAW); inspector->set_use_deletable_properties(true); inspector->connect("property_deleted", callable_mp(this, &ShaderGlobalsEditor::_variable_deleted), varray(), CONNECT_DEFERRED); diff --git a/modules/csg/SCsub b/modules/csg/SCsub index 641a42c187..c7307ddefd 100644 --- a/modules/csg/SCsub +++ b/modules/csg/SCsub @@ -3,7 +3,10 @@ Import("env") Import("env_modules") +# Godot's own source files env_csg = env_modules.Clone() # Godot's own source files env_csg.add_source_files(env.modules_sources, "*.cpp") +if env["tools"]: + env_csg.add_source_files(env.modules_sources, "editor/*.cpp") diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/editor/csg_gizmos.cpp index 95a0fc7ada..be29810252 100644 --- a/modules/csg/csg_gizmos.cpp +++ b/modules/csg/editor/csg_gizmos.cpp @@ -30,6 +30,8 @@ #include "csg_gizmos.h" +#ifdef TOOLS_ENABLED + #include "editor/editor_settings.h" #include "editor/plugins/node_3d_editor_plugin.h" #include "scene/3d/camera_3d.h" @@ -425,3 +427,5 @@ EditorPluginCSG::EditorPluginCSG() { Ref<CSGShape3DGizmoPlugin> gizmo_plugin = Ref<CSGShape3DGizmoPlugin>(memnew(CSGShape3DGizmoPlugin)); Node3DEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin); } + +#endif // TOOLS_ENABLED diff --git a/modules/csg/csg_gizmos.h b/modules/csg/editor/csg_gizmos.h index 43efe57e64..fa51010f98 100644 --- a/modules/csg/csg_gizmos.h +++ b/modules/csg/editor/csg_gizmos.h @@ -31,7 +31,9 @@ #ifndef CSG_GIZMOS_H #define CSG_GIZMOS_H -#include "csg_shape.h" +#ifdef TOOLS_ENABLED + +#include "../csg_shape.h" #include "editor/editor_plugin.h" #include "editor/plugins/node_3d_editor_gizmos.h" @@ -60,4 +62,6 @@ public: EditorPluginCSG(); }; +#endif // TOOLS_ENABLED + #endif // CSG_GIZMOS_H diff --git a/modules/csg/register_types.cpp b/modules/csg/register_types.cpp index f8db42b1a9..72ed027dc9 100644 --- a/modules/csg/register_types.cpp +++ b/modules/csg/register_types.cpp @@ -30,12 +30,15 @@ #include "register_types.h" -#include "csg_gizmos.h" +#ifndef _3D_DISABLED + #include "csg_shape.h" -void register_csg_types() { -#ifndef _3D_DISABLED +#ifdef TOOLS_ENABLED +#include "editor/csg_gizmos.h" +#endif +void register_csg_types() { GDREGISTER_ABSTRACT_CLASS(CSGShape3D); GDREGISTER_ABSTRACT_CLASS(CSGPrimitive3D); GDREGISTER_CLASS(CSGMesh3D); @@ -49,8 +52,9 @@ void register_csg_types() { #ifdef TOOLS_ENABLED EditorPlugins::add_by_type<EditorPluginCSG>(); #endif -#endif } void unregister_csg_types() { } + +#endif // _3D_DISABLED diff --git a/modules/gdscript/SCsub b/modules/gdscript/SCsub index c6121ec7fe..2f507db548 100644 --- a/modules/gdscript/SCsub +++ b/modules/gdscript/SCsub @@ -10,6 +10,8 @@ env_gdscript.add_source_files(env.modules_sources, "*.cpp") if env["tools"]: env_gdscript.add_source_files(env.modules_sources, "./editor/*.cpp") + SConscript("editor/script_templates/SCsub") + # Those two modules are required for the language server protocol if env["module_jsonrpc_enabled"] and env["module_websocket_enabled"]: env_gdscript.add_source_files(env.modules_sources, "./language_server/*.cpp") @@ -18,8 +20,7 @@ if env["tools"]: # in regular builds where all modules are enabled. env_gdscript.Append(CPPDEFINES=["GDSCRIPT_NO_LSP"]) + if env["tests"]: env_gdscript.Append(CPPDEFINES=["TESTS_ENABLED"]) env_gdscript.add_source_files(env.modules_sources, "./tests/*.cpp") - -SConscript("editor_templates/SCsub") diff --git a/modules/gdscript/editor_templates/CharacterBody2D/basic_movement.gd b/modules/gdscript/editor/script_templates/CharacterBody2D/basic_movement.gd index 34b5ba45b7..a379d915a9 100644 --- a/modules/gdscript/editor_templates/CharacterBody2D/basic_movement.gd +++ b/modules/gdscript/editor/script_templates/CharacterBody2D/basic_movement.gd @@ -2,8 +2,9 @@ extends _BASE_ -const SPEED: float = 300.0 -const JUMP_VELOCITY: float = -400.0 + +const SPEED = 300.0 +const JUMP_VELOCITY = -400.0 # Get the gravity from the project settings to be synced with RigidDynamicBody nodes. var gravity: int = ProjectSettings.get_setting("physics/2d/default_gravity") diff --git a/modules/gdscript/editor_templates/CharacterBody3D/basic_movement.gd b/modules/gdscript/editor/script_templates/CharacterBody3D/basic_movement.gd index cbc9cf1064..360b199e56 100644 --- a/modules/gdscript/editor_templates/CharacterBody3D/basic_movement.gd +++ b/modules/gdscript/editor/script_templates/CharacterBody3D/basic_movement.gd @@ -2,8 +2,9 @@ extends _BASE_ -const SPEED: float = 5.0 -const JUMP_VELOCITY: float = 4.5 + +const SPEED = 5.0 +const JUMP_VELOCITY = 4.5 # Get the gravity from the project settings to be synced with RigidDynamicBody nodes. var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity") diff --git a/modules/gdscript/editor_templates/EditorPlugin/plugin.gd b/modules/gdscript/editor/script_templates/EditorPlugin/plugin.gd index 8614bb8b17..b27b3e5655 100644 --- a/modules/gdscript/editor_templates/EditorPlugin/plugin.gd +++ b/modules/gdscript/editor/script_templates/EditorPlugin/plugin.gd @@ -2,10 +2,12 @@ @tool extends EditorPlugin + func _enter_tree() -> void: - # Initialization of the plugin goes here. - pass + # Initialization of the plugin goes here. + pass + func _exit_tree() -> void: - # Clean-up of the plugin goes here. - pass + # Clean-up of the plugin goes here. + pass diff --git a/modules/gdscript/editor_templates/EditorScript/basic_editor_script.gd b/modules/gdscript/editor/script_templates/EditorScript/basic_editor_script.gd index fdb174c7ed..fdb8550d43 100644 --- a/modules/gdscript/editor_templates/EditorScript/basic_editor_script.gd +++ b/modules/gdscript/editor/script_templates/EditorScript/basic_editor_script.gd @@ -2,6 +2,7 @@ @tool extends EditorScript + +# Called when the script is executed (using File -> Run in Script Editor). func _run() -> void: - # Called when the script is executed (using File -> Run in Script Editor). - pass + pass diff --git a/modules/gdscript/editor_templates/Node/default.gd b/modules/gdscript/editor/script_templates/Node/default.gd index ee5c0b99cc..cb96a21537 100644 --- a/modules/gdscript/editor_templates/Node/default.gd +++ b/modules/gdscript/editor/script_templates/Node/default.gd @@ -2,10 +2,12 @@ extends _BASE_ + # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # Replace with function body. + # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass diff --git a/modules/gdscript/editor_templates/Object/empty.gd b/modules/gdscript/editor/script_templates/Object/empty.gd index 387786b0a4..387786b0a4 100644 --- a/modules/gdscript/editor_templates/Object/empty.gd +++ b/modules/gdscript/editor/script_templates/Object/empty.gd diff --git a/modules/gdscript/editor_templates/SCsub b/modules/gdscript/editor/script_templates/SCsub index 2266ef2d01..2266ef2d01 100644 --- a/modules/gdscript/editor_templates/SCsub +++ b/modules/gdscript/editor/script_templates/SCsub diff --git a/modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd b/modules/gdscript/editor/script_templates/VisualShaderNodeCustom/basic.gd index cf6d68333d..283a95d3b4 100644 --- a/modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd +++ b/modules/gdscript/editor/script_templates/VisualShaderNodeCustom/basic.gd @@ -1,38 +1,50 @@ # meta-description: Visual shader's node plugin template @tool -extends _BASE_ class_name VisualShaderNode_CLASS_ +extends _BASE_ + func _get_name() -> String: return "_CLASS_" + func _get_category() -> String: return "" + func _get_description() -> String: return "" + func _get_return_icon_type() -> int: return PORT_TYPE_SCALAR + func _get_input_port_count() -> int: return 0 + func _get_input_port_name(port: int) -> String: return "" + func _get_input_port_type(port: int) -> int: return PORT_TYPE_SCALAR + func _get_output_port_count() -> int: return 1 + func _get_output_port_name(port: int) -> String: return "result" + func _get_output_port_type(port: int) -> int: return PORT_TYPE_SCALAR -func _get_code(input_vars: Array[String], output_vars: Array[String], mode: int, type: int) -> String: + +func _get_code(input_vars: Array[String], output_vars: Array[String], + mode: int, type: int) -> String: return output_vars[0] + " = 0.0;" diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h index 30e60e2b91..f7fa967883 100644 --- a/modules/gdscript/gdscript.h +++ b/modules/gdscript/gdscript.h @@ -212,7 +212,7 @@ public: virtual void update_exports() override; #ifdef TOOLS_ENABLED - virtual const Vector<DocData::ClassDoc> &get_documentation() const override { + virtual Vector<DocData::ClassDoc> get_documentation() const override { return docs; } #endif // TOOLS_ENABLED @@ -455,7 +455,7 @@ public: virtual bool can_inherit_from_file() const override { return true; } virtual int find_function(const String &p_function, const String &p_code) const override; virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const override; - virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) override; + virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) override; #ifdef TOOLS_ENABLED virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result) override; #endif diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 23b847a8af..fd8fcea7b3 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -33,7 +33,6 @@ #include "core/config/engine.h" #include "core/core_constants.h" #include "core/io/file_access.h" -#include "editor_templates/templates.gen.h" #include "gdscript_analyzer.h" #include "gdscript_compiler.h" #include "gdscript_parser.h" @@ -44,6 +43,7 @@ #include "core/config/project_settings.h" #include "editor/editor_file_system.h" #include "editor/editor_settings.h" +#include "editor/script_templates/templates.gen.h" #endif void GDScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const { @@ -64,20 +64,20 @@ Ref<Script> GDScriptLanguage::make_template(const String &p_template, const Stri Ref<GDScript> script; script.instantiate(); String processed_template = p_template; + bool type_hints = false; #ifdef TOOLS_ENABLED - if (!EDITOR_GET("text_editor/completion/add_type_hints")) { + type_hints = EDITOR_GET("text_editor/completion/add_type_hints"); +#endif + if (!type_hints) { processed_template = processed_template.replace(": int", "") .replace(": String", "") + .replace(": Array[String]", "") .replace(": float", "") .replace(":=", "=") + .replace(" -> String", "") + .replace(" -> int", "") .replace(" -> void", ""); } -#else - processed_template = processed_template.replace(": int", "") - .replace(": String", "") - .replace(": float", "") - .replace(" -> void", ""); -#endif processed_template = processed_template.replace("_BASE_", p_base_class_name) .replace("_CLASS_", p_class_name) @@ -88,11 +88,13 @@ Ref<Script> GDScriptLanguage::make_template(const String &p_template, const Stri Vector<ScriptLanguage::ScriptTemplate> GDScriptLanguage::get_built_in_templates(StringName p_object) { Vector<ScriptLanguage::ScriptTemplate> templates; +#ifdef TOOLS_ENABLED for (int i = 0; i < TEMPLATES_ARRAY_SIZE; i++) { if (TEMPLATES[i].inherit == p_object) { templates.append(TEMPLATES[i]); } } +#endif return templates; } @@ -483,89 +485,6 @@ struct GDScriptCompletionIdentifier { const GDScriptParser::ExpressionNode *assigned_expression = nullptr; }; -// LOCATION METHODS -// These methods are used to populate the `ScriptCodeCompletionOption::location` integer. -// For these methods, the location is based on the depth in the inheritance chain that the property -// appears. For example, if you are completing code in a class that inherits Node2D, a property found on Node2D -// will have a "better" (lower) location "score" than a property that is found on CanvasItem. - -static int _get_property_location(StringName p_class, StringName p_property) { - if (!ClassDB::has_property(p_class, p_property)) { - return ScriptCodeCompletionOption::LOCATION_OTHER; - } - - int depth = 0; - StringName class_test = p_class; - while (class_test && !ClassDB::has_property(class_test, p_property, true)) { - class_test = ClassDB::get_parent_class(class_test); - depth++; - } - - return depth | ScriptCodeCompletionOption::LOCATION_PARENT_MASK; -} - -static int _get_constant_location(StringName p_class, StringName p_constant) { - if (!ClassDB::has_integer_constant(p_class, p_constant)) { - return ScriptCodeCompletionOption::LOCATION_OTHER; - } - - int depth = 0; - StringName class_test = p_class; - while (class_test && !ClassDB::has_integer_constant(class_test, p_constant, true)) { - class_test = ClassDB::get_parent_class(class_test); - depth++; - } - - return depth | ScriptCodeCompletionOption::LOCATION_PARENT_MASK; -} - -static int _get_signal_location(StringName p_class, StringName p_signal) { - if (!ClassDB::has_signal(p_class, p_signal)) { - return ScriptCodeCompletionOption::LOCATION_OTHER; - } - - int depth = 0; - StringName class_test = p_class; - while (class_test && !ClassDB::has_signal(class_test, p_signal, true)) { - class_test = ClassDB::get_parent_class(class_test); - depth++; - } - - return depth | ScriptCodeCompletionOption::LOCATION_PARENT_MASK; -} - -static int _get_method_location(StringName p_class, StringName p_method) { - if (!ClassDB::has_method(p_class, p_method)) { - return ScriptCodeCompletionOption::LOCATION_OTHER; - } - - int depth = 0; - StringName class_test = p_class; - while (class_test && !ClassDB::has_method(class_test, p_method, true)) { - class_test = ClassDB::get_parent_class(class_test); - depth++; - } - - return depth | ScriptCodeCompletionOption::LOCATION_PARENT_MASK; -} - -static int _get_enum_constant_location(StringName p_class, StringName p_enum_constant) { - if (!ClassDB::get_integer_constant_enum(p_class, p_enum_constant)) { - return ScriptCodeCompletionOption::LOCATION_OTHER; - } - - int depth = 0; - StringName class_test = p_class; - while (class_test && !ClassDB::get_integer_constant_enum(class_test, p_enum_constant, true)) { - class_test = ClassDB::get_parent_class(class_test); - depth++; - } - - return depth | ScriptCodeCompletionOption::LOCATION_PARENT_MASK; -} - -// END LOCATION METHODS - static String _get_visual_datatype(const PropertyInfo &p_info, bool p_is_arg = true) { if (p_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM) { String enum_name = p_info.class_name; @@ -720,11 +639,11 @@ static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_functio return arghint; } -static void _get_directory_contents(EditorFileSystemDirectory *p_dir, Map<String, ScriptCodeCompletionOption> &r_list) { +static void _get_directory_contents(EditorFileSystemDirectory *p_dir, Map<String, ScriptLanguage::CodeCompletionOption> &r_list) { const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\""; for (int i = 0; i < p_dir->get_file_count(); i++) { - ScriptCodeCompletionOption option(p_dir->get_file_path(i), ScriptCodeCompletionOption::KIND_FILE_PATH); + ScriptLanguage::CodeCompletionOption option(p_dir->get_file_path(i), ScriptLanguage::CODE_COMPLETION_KIND_FILE_PATH); option.insert_text = option.display.quote(quote_style); r_list.insert(option.display, option); } @@ -734,29 +653,29 @@ static void _get_directory_contents(EditorFileSystemDirectory *p_dir, Map<String } } -static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_annotation, int p_argument, const String p_quote_style, Map<String, ScriptCodeCompletionOption> &r_result) { +static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_annotation, int p_argument, const String p_quote_style, Map<String, ScriptLanguage::CodeCompletionOption> &r_result) { if (p_annotation->name == SNAME("@export_range")) { if (p_argument == 3 || p_argument == 4) { // Slider hint. - ScriptCodeCompletionOption slider1("or_greater", ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption slider1("or_greater", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); slider1.insert_text = slider1.display.quote(p_quote_style); r_result.insert(slider1.display, slider1); - ScriptCodeCompletionOption slider2("or_lesser", ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption slider2("or_lesser", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); slider2.insert_text = slider2.display.quote(p_quote_style); r_result.insert(slider2.display, slider2); } } else if (p_annotation->name == SNAME("@export_exp_easing")) { if (p_argument == 0 || p_argument == 1) { // Easing hint. - ScriptCodeCompletionOption hint1("attenuation", ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption hint1("attenuation", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); hint1.insert_text = hint1.display.quote(p_quote_style); r_result.insert(hint1.display, hint1); - ScriptCodeCompletionOption hint2("inout", ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption hint2("inout", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); hint2.insert_text = hint2.display.quote(p_quote_style); r_result.insert(hint2.display, hint2); } } else if (p_annotation->name == SNAME("@export_node_path")) { - ScriptCodeCompletionOption node("Node", ScriptCodeCompletionOption::KIND_CLASS); + ScriptLanguage::CodeCompletionOption node("Node", ScriptLanguage::CODE_COMPLETION_KIND_CLASS); r_result.insert(node.display, node); List<StringName> node_types; ClassDB::get_inheriters_from_class("Node", &node_types); @@ -764,23 +683,23 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a if (!ClassDB::is_class_exposed(E)) { continue; } - ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CLASS); + ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_CLASS); r_result.insert(option.display, option); } } else if (p_annotation->name == SNAME("@warning_ignore")) { for (int warning_code = 0; warning_code < GDScriptWarning::WARNING_MAX; warning_code++) { - ScriptCodeCompletionOption warning(GDScriptWarning::get_name_from_code((GDScriptWarning::Code)warning_code).to_lower(), ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption warning(GDScriptWarning::get_name_from_code((GDScriptWarning::Code)warning_code).to_lower(), ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); r_result.insert(warning.display, warning); } } } -static void _list_available_types(bool p_inherit_only, GDScriptParser::CompletionContext &p_context, Map<String, ScriptCodeCompletionOption> &r_result) { +static void _list_available_types(bool p_inherit_only, GDScriptParser::CompletionContext &p_context, Map<String, ScriptLanguage::CodeCompletionOption> &r_result) { List<StringName> native_types; ClassDB::get_class_list(&native_types); for (const StringName &E : native_types) { if (ClassDB::is_class_exposed(E) && !Engine::get_singleton()->has_singleton(E)) { - ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CLASS); + ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_CLASS); r_result.insert(option.display, option); } } @@ -791,7 +710,7 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completio List<StringName> enums; ClassDB::get_enum_list(p_context.current_class->base_type.native_type, &enums); for (const StringName &E : enums) { - ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_ENUM); + ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_ENUM); r_result.insert(option.display, option); } } @@ -802,18 +721,18 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completio const GDScriptParser::ClassNode::Member &member = current->members[i]; switch (member.type) { case GDScriptParser::ClassNode::Member::CLASS: { - ScriptCodeCompletionOption option(member.m_class->identifier->name, ScriptCodeCompletionOption::KIND_CLASS, ScriptCodeCompletionOption::LOCATION_LOCAL); + ScriptLanguage::CodeCompletionOption option(member.m_class->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_CLASS); r_result.insert(option.display, option); } break; case GDScriptParser::ClassNode::Member::ENUM: { if (!p_inherit_only) { - ScriptCodeCompletionOption option(member.m_enum->identifier->name, ScriptCodeCompletionOption::KIND_ENUM, ScriptCodeCompletionOption::LOCATION_LOCAL); + ScriptLanguage::CodeCompletionOption option(member.m_enum->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_ENUM); r_result.insert(option.display, option); } } break; case GDScriptParser::ClassNode::Member::CONSTANT: { if (member.constant->get_datatype().is_meta_type && p_context.current_class->outer != nullptr) { - ScriptCodeCompletionOption option(member.constant->identifier->name, ScriptCodeCompletionOption::KIND_CLASS, ScriptCodeCompletionOption::LOCATION_LOCAL); + ScriptLanguage::CodeCompletionOption option(member.constant->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_CLASS); r_result.insert(option.display, option); } } break; @@ -829,7 +748,7 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completio List<StringName> global_classes; ScriptServer::get_global_class_list(&global_classes); for (const StringName &E : global_classes) { - ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CLASS, ScriptCodeCompletionOption::LOCATION_OTHER_USER_CODE); + ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_CLASS); r_result.insert(option.display, option); } @@ -840,19 +759,19 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completio if (!info.is_singleton || info.path.get_extension().to_lower() != "gd") { continue; } - ScriptCodeCompletionOption option(info.name, ScriptCodeCompletionOption::KIND_CLASS, ScriptCodeCompletionOption::LOCATION_OTHER_USER_CODE); + ScriptLanguage::CodeCompletionOption option(info.name, ScriptLanguage::CODE_COMPLETION_KIND_CLASS); r_result.insert(option.display, option); } } -static void _find_identifiers_in_suite(const GDScriptParser::SuiteNode *p_suite, Map<String, ScriptCodeCompletionOption> &r_result) { +static void _find_identifiers_in_suite(const GDScriptParser::SuiteNode *p_suite, Map<String, ScriptLanguage::CodeCompletionOption> &r_result) { for (int i = 0; i < p_suite->locals.size(); i++) { - ScriptCodeCompletionOption option; + ScriptLanguage::CodeCompletionOption option; if (p_suite->locals[i].type == GDScriptParser::SuiteNode::Local::CONSTANT) { - option = ScriptCodeCompletionOption(p_suite->locals[i].name, ScriptCodeCompletionOption::KIND_CONSTANT, ScriptCodeCompletionOption::LOCATION_LOCAL); + option = ScriptLanguage::CodeCompletionOption(p_suite->locals[i].name, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT); option.default_value = p_suite->locals[i].constant->initializer->reduced_value; } else { - option = ScriptCodeCompletionOption(p_suite->locals[i].name, ScriptCodeCompletionOption::KIND_VARIABLE, ScriptCodeCompletionOption::LOCATION_LOCAL); + option = ScriptLanguage::CodeCompletionOption(p_suite->locals[i].name, ScriptLanguage::CODE_COMPLETION_KIND_VARIABLE); } r_result.insert(option.display, option); } @@ -861,26 +780,24 @@ static void _find_identifiers_in_suite(const GDScriptParser::SuiteNode *p_suite, } } -static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base, bool p_only_functions, Map<String, ScriptCodeCompletionOption> &r_result, int p_recursion_depth); +static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base, bool p_only_functions, Map<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth); -static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class, bool p_only_functions, bool p_static, bool p_parent_only, Map<String, ScriptCodeCompletionOption> &r_result, int p_recursion_depth) { +static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class, bool p_only_functions, bool p_static, bool p_parent_only, Map<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth) { ERR_FAIL_COND(p_recursion_depth > COMPLETION_RECURSION_LIMIT); if (!p_parent_only) { bool outer = false; const GDScriptParser::ClassNode *clss = p_class; - int classes_processed = 0; while (clss) { for (int i = 0; i < clss->members.size(); i++) { - const int location = (classes_processed + p_recursion_depth) | ScriptCodeCompletionOption::LOCATION_PARENT_MASK; const GDScriptParser::ClassNode::Member &member = clss->members[i]; - ScriptCodeCompletionOption option; + ScriptLanguage::CodeCompletionOption option; switch (member.type) { case GDScriptParser::ClassNode::Member::VARIABLE: if (p_only_functions || outer || (p_static)) { continue; } - option = ScriptCodeCompletionOption(member.variable->identifier->name, ScriptCodeCompletionOption::KIND_MEMBER, location); + option = ScriptLanguage::CodeCompletionOption(member.variable->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER); break; case GDScriptParser::ClassNode::Member::CONSTANT: if (p_only_functions) { @@ -889,7 +806,7 @@ static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class, if (r_result.has(member.constant->identifier->name)) { continue; } - option = ScriptCodeCompletionOption(member.constant->identifier->name, ScriptCodeCompletionOption::KIND_CONSTANT, location); + option = ScriptLanguage::CodeCompletionOption(member.constant->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT); if (member.constant->initializer) { option.default_value = member.constant->initializer->reduced_value; } @@ -898,25 +815,25 @@ static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class, if (p_only_functions) { continue; } - option = ScriptCodeCompletionOption(member.m_class->identifier->name, ScriptCodeCompletionOption::KIND_CLASS, location); + option = ScriptLanguage::CodeCompletionOption(member.m_class->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_CLASS); break; case GDScriptParser::ClassNode::Member::ENUM_VALUE: if (p_only_functions) { continue; } - option = ScriptCodeCompletionOption(member.enum_value.identifier->name, ScriptCodeCompletionOption::KIND_CONSTANT, location); + option = ScriptLanguage::CodeCompletionOption(member.enum_value.identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT); break; case GDScriptParser::ClassNode::Member::ENUM: if (p_only_functions) { continue; } - option = ScriptCodeCompletionOption(member.m_enum->identifier->name, ScriptCodeCompletionOption::KIND_ENUM, location); + option = ScriptLanguage::CodeCompletionOption(member.m_enum->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_ENUM); break; case GDScriptParser::ClassNode::Member::FUNCTION: if (outer || (p_static && !member.function->is_static) || member.function->identifier->name.operator String().begins_with("@")) { continue; } - option = ScriptCodeCompletionOption(member.function->identifier->name, ScriptCodeCompletionOption::KIND_FUNCTION, location); + option = ScriptLanguage::CodeCompletionOption(member.function->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION); if (member.function->parameters.size() > 0) { option.insert_text += "("; } else { @@ -927,7 +844,7 @@ static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class, if (p_only_functions || outer) { continue; } - option = ScriptCodeCompletionOption(member.signal->identifier->name, ScriptCodeCompletionOption::KIND_SIGNAL, location); + option = ScriptLanguage::CodeCompletionOption(member.signal->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL); break; case GDScriptParser::ClassNode::Member::UNDEFINED: break; @@ -936,7 +853,6 @@ static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class, } outer = true; clss = clss->outer; - classes_processed++; } } @@ -948,14 +864,14 @@ static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class, _find_identifiers_in_base(base_type, p_only_functions, r_result, p_recursion_depth + 1); } -static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base, bool p_only_functions, Map<String, ScriptCodeCompletionOption> &r_result, int p_recursion_depth) { +static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base, bool p_only_functions, Map<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth) { ERR_FAIL_COND(p_recursion_depth > COMPLETION_RECURSION_LIMIT); GDScriptParser::DataType base_type = p_base.type; bool _static = base_type.is_meta_type; if (_static && base_type.kind != GDScriptParser::DataType::BUILTIN) { - ScriptCodeCompletionOption option("new", ScriptCodeCompletionOption::KIND_FUNCTION); + ScriptLanguage::CodeCompletionOption option("new", ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION); option.insert_text += "("; r_result.insert(option.display, option); } @@ -975,24 +891,21 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base List<PropertyInfo> members; scr->get_script_property_list(&members); for (const PropertyInfo &E : members) { - int location = p_recursion_depth + _get_property_location(scr->get_class_name(), E.class_name); - ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_MEMBER, location); + ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER); r_result.insert(option.display, option); } } Map<StringName, Variant> constants; scr->get_constants(&constants); for (const KeyValue<StringName, Variant> &E : constants) { - int location = p_recursion_depth + _get_constant_location(scr->get_class_name(), E.key); - ScriptCodeCompletionOption option(E.key.operator String(), ScriptCodeCompletionOption::KIND_CONSTANT, location); + ScriptLanguage::CodeCompletionOption option(E.key.operator String(), ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT); r_result.insert(option.display, option); } List<MethodInfo> signals; scr->get_script_signal_list(&signals); for (const MethodInfo &E : signals) { - int location = p_recursion_depth + _get_signal_location(scr->get_class_name(), E.name); - ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_SIGNAL, location); + ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL); r_result.insert(option.display, option); } } @@ -1003,8 +916,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base if (E.name.begins_with("@")) { continue; } - int location = p_recursion_depth + _get_method_location(scr->get_class_name(), E.name); - ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_FUNCTION, location); + ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION); if (E.arguments.size()) { option.insert_text += "("; } else { @@ -1034,8 +946,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base List<String> constants; ClassDB::get_integer_constant_list(type, &constants); for (const String &E : constants) { - int location = p_recursion_depth + _get_constant_location(type, StringName(E)); - ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CONSTANT, location); + ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT); r_result.insert(option.display, option); } @@ -1049,8 +960,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base if (E.name.contains("/")) { continue; } - int location = p_recursion_depth + _get_property_location(type, E.class_name); - ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_MEMBER, location); + ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER); r_result.insert(option.display, option); } } @@ -1063,8 +973,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base if (E.name.begins_with("_")) { continue; } - int location = p_recursion_depth + _get_method_location(type, E.name); - ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_FUNCTION, location); + ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION); if (E.arguments.size()) { option.insert_text += "("; } else { @@ -1073,6 +982,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base r_result.insert(option.display, option); } } + return; } break; case GDScriptParser::DataType::BUILTIN: { @@ -1093,7 +1003,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base for (const PropertyInfo &E : members) { if (!String(E.name).contains("/")) { - ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_MEMBER); + ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER); r_result.insert(option.display, option); } } @@ -1102,7 +1012,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base List<MethodInfo> methods; tmp.get_method_list(&methods); for (const MethodInfo &E : methods) { - ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_FUNCTION); + ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION); if (E.arguments.size()) { option.insert_text += "("; } else { @@ -1120,7 +1030,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base } } -static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool p_only_functions, Map<String, ScriptCodeCompletionOption> &r_result, int p_recursion_depth) { +static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool p_only_functions, Map<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth) { if (!p_only_functions && p_context.current_suite) { // This includes function parameters, since they are also locals. _find_identifiers_in_suite(p_context.current_suite, r_result); @@ -1135,7 +1045,7 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool for (const StringName &E : functions) { MethodInfo function = GDScriptUtilityFunctions::get_function_info(E); - ScriptCodeCompletionOption option(String(E), ScriptCodeCompletionOption::KIND_FUNCTION); + ScriptLanguage::CodeCompletionOption option(String(E), ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION); if (function.arguments.size() || (function.flags & METHOD_FLAG_VARARG)) { option.insert_text += "("; } else { @@ -1156,7 +1066,7 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool static_assert((sizeof(_type_names) / sizeof(*_type_names)) == Variant::VARIANT_MAX, "Completion for builtin types is incomplete"); for (int i = 0; i < Variant::VARIANT_MAX; i++) { - ScriptCodeCompletionOption option(_type_names[i], ScriptCodeCompletionOption::KIND_CLASS); + ScriptLanguage::CodeCompletionOption option(_type_names[i], ScriptLanguage::CODE_COMPLETION_KIND_CLASS); r_result.insert(option.display, option); } @@ -1168,7 +1078,7 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool const char **kw = _keywords; while (*kw) { - ScriptCodeCompletionOption option(*kw, ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption option(*kw, ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); r_result.insert(option.display, option); kw++; } @@ -1181,7 +1091,7 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool const char **kws = _keywords_with_space; while (*kws) { - ScriptCodeCompletionOption option(*kws, ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption option(*kws, ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); option.insert_text += " "; r_result.insert(option.display, option); kws++; @@ -1194,7 +1104,7 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool const char **kwa = _keywords_with_args; while (*kwa) { - ScriptCodeCompletionOption option(*kwa, ScriptCodeCompletionOption::KIND_FUNCTION); + ScriptLanguage::CodeCompletionOption option(*kwa, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION); option.insert_text += "("; r_result.insert(option.display, option); kwa++; @@ -1204,7 +1114,7 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool Variant::get_utility_function_list(&utility_func_names); for (List<StringName>::Element *E = utility_func_names.front(); E; E = E->next()) { - ScriptCodeCompletionOption option(E->get(), ScriptCodeCompletionOption::KIND_FUNCTION); + ScriptLanguage::CodeCompletionOption option(E->get(), ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION); option.insert_text += "("; r_result.insert(option.display, option); } @@ -1214,17 +1124,17 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool if (!E.value().is_singleton) { continue; } - ScriptCodeCompletionOption option(E.key(), ScriptCodeCompletionOption::KIND_CONSTANT); + ScriptLanguage::CodeCompletionOption option(E.key(), ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT); r_result.insert(option.display, option); } // Native classes and global constants. for (const KeyValue<StringName, int> &E : GDScriptLanguage::get_singleton()->get_global_map()) { - ScriptCodeCompletionOption option; + ScriptLanguage::CodeCompletionOption option; if (ClassDB::class_exists(E.key) || Engine::get_singleton()->has_singleton(E.key)) { - option = ScriptCodeCompletionOption(E.key.operator String(), ScriptCodeCompletionOption::KIND_CLASS); + option = ScriptLanguage::CodeCompletionOption(E.key.operator String(), ScriptLanguage::CODE_COMPLETION_KIND_CLASS); } else { - option = ScriptCodeCompletionOption(E.key.operator String(), ScriptCodeCompletionOption::KIND_CONSTANT); + option = ScriptLanguage::CodeCompletionOption(E.key.operator String(), ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT); } r_result.insert(option.display, option); } @@ -2302,20 +2212,20 @@ static bool _guess_method_return_type_from_base(GDScriptParser::CompletionContex return false; } -static void _find_enumeration_candidates(GDScriptParser::CompletionContext &p_context, const String &p_enum_hint, Map<String, ScriptCodeCompletionOption> &r_result) { +static void _find_enumeration_candidates(GDScriptParser::CompletionContext &p_context, const String &p_enum_hint, Map<String, ScriptLanguage::CodeCompletionOption> &r_result) { if (!p_enum_hint.contains(".")) { // Global constant or in the current class. StringName current_enum = p_enum_hint; if (p_context.current_class && p_context.current_class->has_member(current_enum) && p_context.current_class->get_member(current_enum).type == GDScriptParser::ClassNode::Member::ENUM) { const GDScriptParser::EnumNode *_enum = p_context.current_class->get_member(current_enum).m_enum; for (int i = 0; i < _enum->values.size(); i++) { - ScriptCodeCompletionOption option(_enum->values[i].identifier->name, ScriptCodeCompletionOption::KIND_ENUM); + ScriptLanguage::CodeCompletionOption option(_enum->values[i].identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_ENUM); r_result.insert(option.display, option); } } else { for (int i = 0; i < CoreConstants::get_global_constant_count(); i++) { if (CoreConstants::get_global_constant_enum(i) == current_enum) { - ScriptCodeCompletionOption option(CoreConstants::get_global_constant_name(i), ScriptCodeCompletionOption::KIND_ENUM); + ScriptLanguage::CodeCompletionOption option(CoreConstants::get_global_constant_name(i), ScriptLanguage::CODE_COMPLETION_KIND_ENUM); r_result.insert(option.display, option); } } @@ -2332,14 +2242,13 @@ static void _find_enumeration_candidates(GDScriptParser::CompletionContext &p_co ClassDB::get_enum_constants(class_name, enum_name, &enum_constants); for (const StringName &E : enum_constants) { String candidate = class_name + "." + E; - int location = _get_enum_constant_location(class_name, E); - ScriptCodeCompletionOption option(candidate, ScriptCodeCompletionOption::KIND_ENUM, location); + ScriptLanguage::CodeCompletionOption option(candidate, ScriptLanguage::CODE_COMPLETION_KIND_ENUM); r_result.insert(option.display, option); } } } -static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, const GDScriptCompletionIdentifier &p_base, const StringName &p_method, int p_argidx, bool p_static, Map<String, ScriptCodeCompletionOption> &r_result, String &r_arghint) { +static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, const GDScriptCompletionIdentifier &p_base, const StringName &p_method, int p_argidx, bool p_static, Map<String, ScriptLanguage::CodeCompletionOption> &r_result, String &r_arghint) { Variant base = p_base.value; GDScriptParser::DataType base_type = p_base.type; @@ -2380,7 +2289,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c if (opt.is_quoted()) { opt = opt.unquote().quote(quote_style); // Handle user preference. } - ScriptCodeCompletionOption option(opt, ScriptCodeCompletionOption::KIND_FUNCTION); + ScriptLanguage::CodeCompletionOption option(opt, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION); r_result.insert(option.display, option); } } @@ -2407,7 +2316,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c continue; } String name = s.get_slice("/", 1); - ScriptCodeCompletionOption option("/root/" + name, ScriptCodeCompletionOption::KIND_NODE_PATH); + ScriptLanguage::CodeCompletionOption option("/root/" + name, ScriptLanguage::CODE_COMPLETION_KIND_NODE_PATH); option.insert_text = option.display.quote(quote_style); r_result.insert(option.display, option); } @@ -2423,7 +2332,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c continue; } String name = s.get_slice("/", 1); - ScriptCodeCompletionOption option(name, ScriptCodeCompletionOption::KIND_CONSTANT); + ScriptLanguage::CodeCompletionOption option(name, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT); option.insert_text = option.display.quote(quote_style); r_result.insert(option.display, option); } @@ -2458,7 +2367,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c } } -static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, const GDScriptParser::Node *p_call, int p_argidx, Map<String, ScriptCodeCompletionOption> &r_result, bool &r_forced, String &r_arghint) { +static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, const GDScriptParser::Node *p_call, int p_argidx, Map<String, ScriptLanguage::CodeCompletionOption> &r_result, bool &r_forced, String &r_arghint) { if (p_call->type == GDScriptParser::Node::PRELOAD) { if (p_argidx == 0 && bool(EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths"))) { _get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), r_result); @@ -2537,7 +2446,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c r_forced = r_result.size() > 0; } -::Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) { +::Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) { const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\""; GDScriptParser parser; @@ -2547,7 +2456,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c analyzer.analyze(); r_forced = false; - Map<String, ScriptCodeCompletionOption> options; + Map<String, ScriptLanguage::CodeCompletionOption> options; GDScriptParser::CompletionContext completion_context = parser.get_completion_context(); completion_context.base = p_owner; @@ -2560,7 +2469,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c List<MethodInfo> annotations; parser.get_annotation_list(&annotations); for (const MethodInfo &E : annotations) { - ScriptCodeCompletionOption option(E.name.substr(1), ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption option(E.name.substr(1), ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); if (E.arguments.size() > 0) { option.insert_text += "("; } @@ -2580,7 +2489,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c List<StringName> constants; Variant::get_constants_for_type(completion_context.builtin_type, &constants); for (const StringName &E : constants) { - ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CONSTANT); + ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT); bool valid = false; Variant default_value = Variant::get_constant_value(completion_context.builtin_type, E, &valid); if (valid) { @@ -2594,7 +2503,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c r_forced = true; } break; case GDScriptParser::COMPLETION_TYPE_NAME_OR_VOID: { - ScriptCodeCompletionOption option("void", ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption option("void", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); options.insert(option.display, option); } [[fallthrough]]; @@ -2604,16 +2513,16 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c } break; case GDScriptParser::COMPLETION_PROPERTY_DECLARATION_OR_TYPE: { _list_available_types(false, completion_context, options); - ScriptCodeCompletionOption get("get", ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption get("get", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); options.insert(get.display, get); - ScriptCodeCompletionOption set("set", ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption set("set", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); options.insert(set.display, set); r_forced = true; } break; case GDScriptParser::COMPLETION_PROPERTY_DECLARATION: { - ScriptCodeCompletionOption get("get", ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption get("get", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); options.insert(get.display, get); - ScriptCodeCompletionOption set("set", ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption set("set", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); options.insert(set.display, set); r_forced = true; } break; @@ -2629,7 +2538,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c if (member.function->is_static) { continue; } - ScriptCodeCompletionOption option(member.function->identifier->name, ScriptCodeCompletionOption::KIND_FUNCTION); + ScriptLanguage::CodeCompletionOption option(member.function->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION); options.insert(option.display, option); } r_forced = true; @@ -2799,7 +2708,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c } method_hint += ":"; - ScriptCodeCompletionOption option(method_hint, ScriptCodeCompletionOption::KIND_FUNCTION); + ScriptLanguage::CodeCompletionOption option(method_hint, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION); options.insert(option.display, option); } } break; @@ -2822,7 +2731,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c if (!opt.replace("/", "_").is_valid_identifier()) { opt = opt.quote(quote_style); // Handle user preference. } - ScriptCodeCompletionOption option(opt, ScriptCodeCompletionOption::KIND_NODE_PATH); + ScriptLanguage::CodeCompletionOption option(opt, ScriptLanguage::CODE_COMPLETION_KIND_NODE_PATH); options.insert(option.display, option); } @@ -2831,7 +2740,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c for (OrderedHashMap<StringName, ProjectSettings::AutoloadInfo>::Element E = autoloads.front(); E; E = E.next()) { String path = "/root/" + E.key(); - ScriptCodeCompletionOption option(path.quote(quote_style), ScriptCodeCompletionOption::KIND_NODE_PATH); + ScriptLanguage::CodeCompletionOption option(path.quote(quote_style), ScriptLanguage::CODE_COMPLETION_KIND_NODE_PATH); options.insert(option.display, option); } } @@ -2844,18 +2753,16 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c } break; } - for (const KeyValue<String, ScriptCodeCompletionOption> &E : options) { + for (const KeyValue<String, ScriptLanguage::CodeCompletionOption> &E : options) { r_options->push_back(E.value); } - r_options->sort_custom_inplace<ScriptCodeCompletionOptionCompare>(); - return OK; } #else -Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) { +Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) { return OK; } @@ -2954,7 +2861,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co case GDScriptParser::DataType::CLASS: { if (base_type.class_type) { if (base_type.class_type->has_member(p_symbol)) { - r_result.type = ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION; + r_result.type = ScriptLanguage::LOOKUP_RESULT_SCRIPT_LOCATION; r_result.location = base_type.class_type->get_member(p_symbol).get_line(); r_result.class_path = base_type.script_path; r_result.script = GDScriptCache::get_shallow_script(r_result.class_path); @@ -2968,7 +2875,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co if (scr.is_valid()) { int line = scr->get_member_line(p_symbol); if (line >= 0) { - r_result.type = ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION; + r_result.type = ScriptLanguage::LOOKUP_RESULT_SCRIPT_LOCATION; r_result.location = line; r_result.script = scr; return OK; @@ -2992,7 +2899,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co } if (ClassDB::has_method(class_name, p_symbol, true)) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_METHOD; r_result.class_name = base_type.native_type; r_result.class_member = p_symbol; return OK; @@ -3002,7 +2909,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co ClassDB::get_virtual_methods(class_name, &virtual_methods, true); for (const MethodInfo &E : virtual_methods) { if (E.name == p_symbol) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_METHOD; r_result.class_name = base_type.native_type; r_result.class_member = p_symbol; return OK; @@ -3011,7 +2918,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co StringName enum_name = ClassDB::get_integer_constant_enum(class_name, p_symbol, true); if (enum_name != StringName()) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_ENUM; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_ENUM; r_result.class_name = base_type.native_type; r_result.class_member = enum_name; return OK; @@ -3021,7 +2928,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co ClassDB::get_integer_constant_list(class_name, &constants, true); for (const String &E : constants) { if (E == p_symbol) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT; r_result.class_name = base_type.native_type; r_result.class_member = p_symbol; return OK; @@ -3029,7 +2936,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co } if (ClassDB::has_property(class_name, p_symbol, true)) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_PROPERTY; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_PROPERTY; r_result.class_name = base_type.native_type; r_result.class_member = p_symbol; return OK; @@ -3046,7 +2953,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co base_type.kind = GDScriptParser::DataType::UNRESOLVED; if (Variant::has_constant(base_type.builtin_type, p_symbol)) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT; r_result.class_name = Variant::get_type_name(base_type.builtin_type); r_result.class_member = p_symbol; return OK; @@ -3066,7 +2973,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co } if (v.has_method(p_symbol)) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_METHOD; r_result.class_name = Variant::get_type_name(base_type.builtin_type); r_result.class_member = p_symbol; return OK; @@ -3075,7 +2982,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co bool valid = false; v.get(p_symbol, &valid); if (valid) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_PROPERTY; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_PROPERTY; r_result.class_name = Variant::get_type_name(base_type.builtin_type); r_result.class_member = p_symbol; return OK; @@ -3093,7 +3000,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co ::Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result) { // Before parsing, try the usual stuff if (ClassDB::class_exists(p_symbol)) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS; r_result.class_name = p_symbol; return OK; } @@ -3101,21 +3008,21 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co for (int i = 0; i < Variant::VARIANT_MAX; i++) { Variant::Type t = Variant::Type(i); if (Variant::get_type_name(t) == p_symbol) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS; r_result.class_name = Variant::get_type_name(t); return OK; } } if (GDScriptUtilityFunctions::function_exists(p_symbol)) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_METHOD; r_result.class_name = "@GDScript"; r_result.class_member = p_symbol; return OK; } if ("PI" == p_symbol || "TAU" == p_symbol || "INF" == p_symbol || "NAN" == p_symbol) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT; r_result.class_name = "@GDScript"; r_result.class_member = p_symbol; return OK; @@ -3132,7 +3039,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co bool success = false; ClassDB::get_integer_constant(context.current_class->extends[0], p_symbol, &success); if (success) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT; r_result.class_name = context.current_class->extends[0]; r_result.class_member = p_symbol; return OK; @@ -3143,7 +3050,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co switch (context.type) { case GDScriptParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT; r_result.class_name = Variant::get_type_name(context.builtin_type); r_result.class_member = p_symbol; return OK; @@ -3171,7 +3078,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co const GDScriptParser::SuiteNode *suite = context.current_suite; while (suite) { if (suite->has_local(p_symbol)) { - r_result.type = ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION; + r_result.type = ScriptLanguage::LOOKUP_RESULT_SCRIPT_LOCATION; r_result.location = suite->get_local(p_symbol).start_line; return OK; } @@ -3196,7 +3103,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co } if (FileAccess::exists(script)) { - r_result.type = ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION; + r_result.type = ScriptLanguage::LOOKUP_RESULT_SCRIPT_LOCATION; r_result.location = 0; r_result.script = ResourceLoader::load(script); return OK; @@ -3212,10 +3119,10 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co Object *obj = value; if (obj) { if (Object::cast_to<GDScriptNativeClass>(obj)) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS; r_result.class_name = Object::cast_to<GDScriptNativeClass>(obj)->get_name(); } else { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS; r_result.class_name = obj->get_class(); } @@ -3232,18 +3139,18 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co // Otherwise these codes would work StringName enumName = ClassDB::get_integer_constant_enum("@GlobalScope", p_symbol, true); if (enumName != nullptr) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_ENUM; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_ENUM; r_result.class_name = "@GlobalScope"; r_result.class_member = enumName; return OK; } else { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT; r_result.class_name = "@GlobalScope"; r_result.class_member = p_symbol; return OK; }*/ - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_TBD_GLOBALSCOPE; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_TBD_GLOBALSCOPE; r_result.class_name = "@GlobalScope"; r_result.class_member = p_symbol; return OK; @@ -3252,7 +3159,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co List<StringName> utility_functions; Variant::get_utility_function_list(&utility_functions); if (utility_functions.find(p_symbol) != nullptr) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_TBD_GLOBALSCOPE; + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_TBD_GLOBALSCOPE; r_result.class_name = "@GlobalScope"; r_result.class_member = p_symbol; return OK; diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp index 961295b076..d5ef8fed74 100644 --- a/modules/gdscript/language_server/gdscript_text_document.cpp +++ b/modules/gdscript/language_server/gdscript_text_document.cpp @@ -166,49 +166,51 @@ Array GDScriptTextDocument::completion(const Dictionary &p_params) { params.load(p_params); Dictionary request_data = params.to_json(); - List<ScriptCodeCompletionOption> options; + List<ScriptLanguage::CodeCompletionOption> options; GDScriptLanguageProtocol::get_singleton()->get_workspace()->completion(params, &options); if (!options.is_empty()) { int i = 0; arr.resize(options.size()); - for (const ScriptCodeCompletionOption &option : options) { + for (const ScriptLanguage::CodeCompletionOption &option : options) { lsp::CompletionItem item; item.label = option.display; item.data = request_data; switch (option.kind) { - case ScriptCodeCompletionOption::KIND_ENUM: + case ScriptLanguage::CODE_COMPLETION_KIND_ENUM: item.kind = lsp::CompletionItemKind::Enum; break; - case ScriptCodeCompletionOption::KIND_CLASS: + case ScriptLanguage::CODE_COMPLETION_KIND_CLASS: item.kind = lsp::CompletionItemKind::Class; break; - case ScriptCodeCompletionOption::KIND_MEMBER: + case ScriptLanguage::CODE_COMPLETION_KIND_MEMBER: item.kind = lsp::CompletionItemKind::Property; break; - case ScriptCodeCompletionOption::KIND_FUNCTION: + case ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION: item.kind = lsp::CompletionItemKind::Method; break; - case ScriptCodeCompletionOption::KIND_SIGNAL: + case ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL: item.kind = lsp::CompletionItemKind::Event; break; - case ScriptCodeCompletionOption::KIND_CONSTANT: + case ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT: item.kind = lsp::CompletionItemKind::Constant; break; - case ScriptCodeCompletionOption::KIND_VARIABLE: + case ScriptLanguage::CODE_COMPLETION_KIND_VARIABLE: item.kind = lsp::CompletionItemKind::Variable; break; - case ScriptCodeCompletionOption::KIND_FILE_PATH: + case ScriptLanguage::CODE_COMPLETION_KIND_FILE_PATH: item.kind = lsp::CompletionItemKind::File; break; - case ScriptCodeCompletionOption::KIND_NODE_PATH: + case ScriptLanguage::CODE_COMPLETION_KIND_NODE_PATH: item.kind = lsp::CompletionItemKind::Snippet; break; - case ScriptCodeCompletionOption::KIND_PLAIN_TEXT: + case ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT: item.kind = lsp::CompletionItemKind::Text; break; + default: { + } } arr[i] = item.to_json(); diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp index d20b243616..1bf0b40842 100644 --- a/modules/gdscript/language_server/gdscript_workspace.cpp +++ b/modules/gdscript/language_server/gdscript_workspace.cpp @@ -571,7 +571,7 @@ Node *GDScriptWorkspace::_get_owner_scene_node(String p_path) { return owner_scene_node; } -void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<ScriptCodeCompletionOption> *r_options) { +void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<ScriptLanguage::CodeCompletionOption> *r_options) { String path = get_file_path(p_params.textDocument.uri); String call_hint; bool forced = false; @@ -638,7 +638,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocu symbol_identifier = "_init"; } if (OK == GDScriptLanguage::get_singleton()->lookup_code(parser->get_text_for_lookup_symbol(pos, symbol_identifier, p_func_required), symbol_identifier, path, nullptr, ret)) { - if (ret.type == ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION) { + if (ret.type == ScriptLanguage::LOOKUP_RESULT_SCRIPT_LOCATION) { String target_script_path = path; if (!ret.script.is_null()) { target_script_path = ret.script->get_path(); diff --git a/modules/gdscript/language_server/gdscript_workspace.h b/modules/gdscript/language_server/gdscript_workspace.h index ce5bba5f00..92e78f8992 100644 --- a/modules/gdscript/language_server/gdscript_workspace.h +++ b/modules/gdscript/language_server/gdscript_workspace.h @@ -85,7 +85,7 @@ public: String get_file_uri(const String &p_path) const; void publish_diagnostics(const String &p_path); - void completion(const lsp::CompletionParams &p_params, List<ScriptCodeCompletionOption> *r_options); + void completion(const lsp::CompletionParams &p_params, List<ScriptLanguage::CodeCompletionOption> *r_options); const lsp::DocumentSymbol *resolve_symbol(const lsp::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name = "", bool p_func_required = false); void resolve_related_symbols(const lsp::TextDocumentPositionParams &p_doc_pos, List<const lsp::DocumentSymbol *> &r_list); diff --git a/modules/gltf/SCsub b/modules/gltf/SCsub index 5d03ee8361..3379404a00 100644 --- a/modules/gltf/SCsub +++ b/modules/gltf/SCsub @@ -4,7 +4,8 @@ Import("env") Import("env_modules") env_gltf = env_modules.Clone() -env_gltf.Prepend(CPPPATH=["."]) # Godot's own source files env_gltf.add_source_files(env.modules_sources, "*.cpp") +if env["tools"]: + env_gltf.add_source_files(env.modules_sources, "editor/*.cpp") diff --git a/modules/gltf/editor_scene_exporter_gltf_plugin.cpp b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp index 601c70791c..23a7b7fed6 100644 --- a/modules/gltf/editor_scene_exporter_gltf_plugin.cpp +++ b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp @@ -28,23 +28,24 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#if TOOLS_ENABLED +#ifdef TOOLS_ENABLED + #include "editor_scene_exporter_gltf_plugin.h" +#include "../gltf_document.h" +#include "../gltf_state.h" + #include "core/config/project_settings.h" #include "core/error/error_list.h" #include "core/object/object.h" #include "core/templates/vector.h" #include "editor/editor_file_dialog.h" #include "editor/editor_file_system.h" -#include "gltf_document.h" -#include "gltf_state.h" +#include "editor/editor_node.h" #include "scene/3d/mesh_instance_3d.h" #include "scene/gui/check_box.h" #include "scene/main/node.h" -#include "editor/editor_node.h" - String SceneExporterGLTFPlugin::get_name() const { return "ConvertGLTF2"; } diff --git a/modules/gltf/editor_scene_exporter_gltf_plugin.h b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.h index c2c3f5710c..5af46bc752 100644 --- a/modules/gltf/editor_scene_exporter_gltf_plugin.h +++ b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.h @@ -31,7 +31,8 @@ #ifndef EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H #define EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H -#if TOOLS_ENABLED +#ifdef TOOLS_ENABLED + #include "editor/editor_plugin.h" #include "editor_scene_importer_gltf.h" @@ -47,5 +48,7 @@ public: bool has_main_screen() const override; SceneExporterGLTFPlugin(); }; + #endif // TOOLS_ENABLED + #endif // EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H diff --git a/modules/gltf/editor_scene_importer_gltf.cpp b/modules/gltf/editor/editor_scene_importer_gltf.cpp index f063cc1e2b..f9193c2a42 100644 --- a/modules/gltf/editor_scene_importer_gltf.cpp +++ b/modules/gltf/editor/editor_scene_importer_gltf.cpp @@ -28,11 +28,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#if TOOLS_ENABLED +#ifdef TOOLS_ENABLED + #include "editor_scene_importer_gltf.h" -#include "gltf_document.h" -#include "gltf_state.h" +#include "../gltf_document.h" +#include "../gltf_state.h" #include "scene/3d/node_3d.h" #include "scene/animation/animation_player.h" diff --git a/modules/gltf/editor_scene_importer_gltf.h b/modules/gltf/editor/editor_scene_importer_gltf.h index 4410559b3d..206fe63426 100644 --- a/modules/gltf/editor_scene_importer_gltf.h +++ b/modules/gltf/editor/editor_scene_importer_gltf.h @@ -30,10 +30,11 @@ #ifndef EDITOR_SCENE_IMPORTER_GLTF_H #define EDITOR_SCENE_IMPORTER_GLTF_H + #ifdef TOOLS_ENABLED -#include "gltf_state.h" -#include "gltf_document_extension.h" +#include "../gltf_document_extension.h" +#include "../gltf_state.h" #include "editor/import/resource_importer_scene.h" #include "scene/main/node.h" @@ -51,5 +52,7 @@ public: virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps) override; }; + #endif // TOOLS_ENABLED + #endif // EDITOR_SCENE_IMPORTER_GLTF_H diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp index 6ab202096d..ef30628dbb 100644 --- a/modules/gltf/register_types.cpp +++ b/modules/gltf/register_types.cpp @@ -30,9 +30,8 @@ #include "register_types.h" -#include "editor/editor_node.h" -#include "editor_scene_exporter_gltf_plugin.h" -#include "editor_scene_importer_gltf.h" +#ifndef _3D_DISABLED + #include "gltf_accessor.h" #include "gltf_animation.h" #include "gltf_buffer_view.h" @@ -49,18 +48,19 @@ #include "gltf_state.h" #include "gltf_texture.h" -#ifndef _3D_DISABLED #ifdef TOOLS_ENABLED +#include "editor/editor_node.h" +#include "editor/editor_scene_exporter_gltf_plugin.h" +#include "editor/editor_scene_importer_gltf.h" + static void _editor_init() { Ref<EditorSceneFormatImporterGLTF> import_gltf; import_gltf.instantiate(); ResourceImporterScene::get_singleton()->add_importer(import_gltf); } #endif -#endif void register_gltf_types() { -#ifndef _3D_DISABLED #ifdef TOOLS_ENABLED ClassDB::APIType prev_api = ClassDB::get_current_api(); ClassDB::set_current_api(ClassDB::API_EDITOR); @@ -84,8 +84,9 @@ void register_gltf_types() { GDREGISTER_CLASS(GLTFDocumentExtensionConvertImporterMesh); GDREGISTER_CLASS(GLTFDocumentExtension); GDREGISTER_CLASS(GLTFDocument); -#endif } void unregister_gltf_types() { } + +#endif // _3D_DISABLED diff --git a/modules/gridmap/SCsub b/modules/gridmap/SCsub index 970ce534f0..52777235b8 100644 --- a/modules/gridmap/SCsub +++ b/modules/gridmap/SCsub @@ -5,4 +5,7 @@ Import("env_modules") env_gridmap = env_modules.Clone() +# Godot's own source files env_gridmap.add_source_files(env.modules_sources, "*.cpp") +if env["tools"]: + env_gridmap.add_source_files(env.modules_sources, "editor/*.cpp") diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/editor/grid_map_editor_plugin.cpp index e8e096d52b..68968325dd 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/editor/grid_map_editor_plugin.cpp @@ -29,14 +29,16 @@ /*************************************************************************/ #include "grid_map_editor_plugin.h" + +#ifdef TOOLS_ENABLED + #include "core/input/input.h" +#include "core/os/keyboard.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/plugins/node_3d_editor_plugin.h" #include "scene/3d/camera_3d.h" - -#include "core/os/keyboard.h" #include "scene/main/window.h" void GridMapEditor::_node_removed(Node *p_node) { @@ -1479,3 +1481,5 @@ GridMapEditorPlugin::GridMapEditorPlugin() { GridMapEditorPlugin::~GridMapEditorPlugin() { } + +#endif // TOOLS_ENABLED diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/editor/grid_map_editor_plugin.h index c44c4ca7e0..adb0da6e2c 100644 --- a/modules/gridmap/grid_map_editor_plugin.h +++ b/modules/gridmap/editor/grid_map_editor_plugin.h @@ -31,8 +31,10 @@ #ifndef GRID_MAP_EDITOR_PLUGIN_H #define GRID_MAP_EDITOR_PLUGIN_H +#ifdef TOOLS_ENABLED + +#include "../grid_map.h" #include "editor/editor_plugin.h" -#include "grid_map.h" #include "scene/gui/item_list.h" #include "scene/gui/slider.h" #include "scene/gui/spin_box.h" @@ -249,4 +251,6 @@ public: ~GridMapEditorPlugin(); }; -#endif // CUBE_GRID_MAP_EDITOR_PLUGIN_H +#endif // TOOLS_ENABLED + +#endif // GRID_MAP_EDITOR_PLUGIN_H diff --git a/modules/gridmap/register_types.cpp b/modules/gridmap/register_types.cpp index f05c5de18b..d7c9f5c92e 100644 --- a/modules/gridmap/register_types.cpp +++ b/modules/gridmap/register_types.cpp @@ -28,21 +28,25 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "register_types.h" #ifndef _3D_DISABLED + +#include "register_types.h" + #include "core/object/class_db.h" #include "grid_map.h" -#include "grid_map_editor_plugin.h" + +#ifdef TOOLS_ENABLED +#include "editor/grid_map_editor_plugin.h" #endif void register_gridmap_types() { -#ifndef _3D_DISABLED GDREGISTER_CLASS(GridMap); #ifdef TOOLS_ENABLED EditorPlugins::add_by_type<GridMapEditorPlugin>(); #endif -#endif } void unregister_gridmap_types() { } + +#endif // _3D_DISABLED diff --git a/modules/mono/SCsub b/modules/mono/SCsub index db35e804aa..3bafa351a9 100644 --- a/modules/mono/SCsub +++ b/modules/mono/SCsub @@ -63,5 +63,4 @@ elif env["platform"] == "android": if env["tools"]: env_mono.add_source_files(env.modules_sources, "editor/*.cpp") - -SConscript("editor_templates/SCsub") + SConscript("editor/script_templates/SCsub") diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 7ed0422236..0953bde9bb 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -45,17 +45,17 @@ #ifdef TOOLS_ENABLED #include "core/os/keyboard.h" #include "editor/bindings_generator.h" +#include "editor/editor_internal_calls.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" #include "editor/node_dock.h" +#include "editor/script_templates/templates.gen.h" #endif #ifdef DEBUG_METHODS_ENABLED #include "class_db_api_json.h" #endif -#include "editor/editor_internal_calls.h" -#include "editor_templates/templates.gen.h" #include "godotsharp_dirs.h" #include "mono_gd/gd_mono_cache.h" #include "mono_gd/gd_mono_class.h" @@ -373,11 +373,13 @@ Ref<Script> CSharpLanguage::make_template(const String &p_template, const String Vector<ScriptLanguage::ScriptTemplate> CSharpLanguage::get_built_in_templates(StringName p_object) { Vector<ScriptLanguage::ScriptTemplate> templates; +#ifdef TOOLS_ENABLED for (int i = 0; i < TEMPLATES_ARRAY_SIZE; i++) { if (TEMPLATES[i].inherit == p_object) { templates.append(TEMPLATES[i]); } } +#endif return templates; } diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index 3b97d2acc4..1e5f218c95 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -202,9 +202,9 @@ public: void set_source_code(const String &p_code) override; #ifdef TOOLS_ENABLED - virtual const Vector<DocData::ClassDoc> &get_documentation() const override { + virtual Vector<DocData::ClassDoc> get_documentation() const override { // TODO - static Vector<DocData::ClassDoc> docs; + Vector<DocData::ClassDoc> docs; return docs; } #endif // TOOLS_ENABLED diff --git a/modules/mono/editor_templates/CharacterBody2D/basic_movement.cs b/modules/mono/editor/script_templates/CharacterBody2D/basic_movement.cs index 2ca81ab7cd..2ca81ab7cd 100644 --- a/modules/mono/editor_templates/CharacterBody2D/basic_movement.cs +++ b/modules/mono/editor/script_templates/CharacterBody2D/basic_movement.cs diff --git a/modules/mono/editor_templates/CharacterBody3D/basic_movement.cs b/modules/mono/editor/script_templates/CharacterBody3D/basic_movement.cs index a6935fe497..a6935fe497 100644 --- a/modules/mono/editor_templates/CharacterBody3D/basic_movement.cs +++ b/modules/mono/editor/script_templates/CharacterBody3D/basic_movement.cs diff --git a/modules/mono/editor_templates/EditorPlugin/plugin.cs b/modules/mono/editor/script_templates/EditorPlugin/plugin.cs index 6e6a799be6..eba5fd12a4 100644 --- a/modules/mono/editor_templates/EditorPlugin/plugin.cs +++ b/modules/mono/editor/script_templates/EditorPlugin/plugin.cs @@ -1,4 +1,5 @@ // meta-description: Basic plugin template + #if TOOLS using _BINDINGS_NAMESPACE_; using System; diff --git a/modules/mono/editor_templates/EditorScript/basic_editor_script.cs b/modules/mono/editor/script_templates/EditorScript/basic_editor_script.cs index 2088822890..1b347edc1c 100644 --- a/modules/mono/editor_templates/EditorScript/basic_editor_script.cs +++ b/modules/mono/editor/script_templates/EditorScript/basic_editor_script.cs @@ -1,4 +1,5 @@ // meta-description: Basic editor script template + #if TOOLS using _BINDINGS_NAMESPACE_; using System; @@ -6,9 +7,9 @@ using System; [Tool] public partial class _CLASS_ : _BASE_ { + // Called when the script is executed (using File -> Run in Script Editor). public override void _Run() { - // Called when the script is executed (using File -> Run in Script Editor). } } #endif diff --git a/modules/mono/editor_templates/Node/default.cs b/modules/mono/editor/script_templates/Node/default.cs index 73d69dd993..4c86d1666f 100644 --- a/modules/mono/editor_templates/Node/default.cs +++ b/modules/mono/editor/script_templates/Node/default.cs @@ -8,12 +8,10 @@ public partial class _CLASS_ : _BASE_ // Called when the node enters the scene tree for the first time. public override void _Ready() { - } // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process(float delta) { - } } diff --git a/modules/mono/editor_templates/Object/empty.cs b/modules/mono/editor/script_templates/Object/empty.cs index e5bee64fe1..34526d514f 100644 --- a/modules/mono/editor_templates/Object/empty.cs +++ b/modules/mono/editor/script_templates/Object/empty.cs @@ -5,5 +5,4 @@ using System; public partial class _CLASS_ : _BASE_ { - } diff --git a/modules/mono/editor_templates/SCsub b/modules/mono/editor/script_templates/SCsub index 39f6cb5c01..39f6cb5c01 100644 --- a/modules/mono/editor_templates/SCsub +++ b/modules/mono/editor/script_templates/SCsub diff --git a/modules/mono/editor_templates/VisualShaderNodeCustom/basic.cs b/modules/mono/editor/script_templates/VisualShaderNodeCustom/basic.cs index a1b93e7daa..a1b93e7daa 100644 --- a/modules/mono/editor_templates/VisualShaderNodeCustom/basic.cs +++ b/modules/mono/editor/script_templates/VisualShaderNodeCustom/basic.cs diff --git a/modules/navigation/SCsub b/modules/navigation/SCsub index 22b5509b32..24a6b12639 100644 --- a/modules/navigation/SCsub +++ b/modules/navigation/SCsub @@ -57,6 +57,8 @@ env.modules_sources += thirdparty_obj module_obj = [] env_navigation.add_source_files(module_obj, "*.cpp") +if env["tools"]: + env_navigation.add_source_files(module_obj, "editor/*.cpp") env.modules_sources += module_obj # Needed to force rebuilding the module files when the thirdparty library is updated. diff --git a/modules/navigation/navigation_mesh_editor_plugin.cpp b/modules/navigation/editor/navigation_mesh_editor_plugin.cpp index 511490ba07..c243e3e6e3 100644 --- a/modules/navigation/navigation_mesh_editor_plugin.cpp +++ b/modules/navigation/editor/navigation_mesh_editor_plugin.cpp @@ -28,13 +28,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifdef TOOLS_ENABLED #include "navigation_mesh_editor_plugin.h" +#ifdef TOOLS_ENABLED + +#include "../navigation_mesh_generator.h" #include "core/io/marshalls.h" #include "core/io/resource_saver.h" #include "editor/editor_node.h" -#include "navigation_mesh_generator.h" #include "scene/3d/mesh_instance_3d.h" #include "scene/gui/box_container.h" @@ -153,4 +154,4 @@ NavigationMeshEditorPlugin::NavigationMeshEditorPlugin() { NavigationMeshEditorPlugin::~NavigationMeshEditorPlugin() { } -#endif +#endif // TOOLS_ENABLED diff --git a/modules/navigation/navigation_mesh_editor_plugin.h b/modules/navigation/editor/navigation_mesh_editor_plugin.h index d581b453b3..3c3e804fd2 100644 --- a/modules/navigation/navigation_mesh_editor_plugin.h +++ b/modules/navigation/editor/navigation_mesh_editor_plugin.h @@ -81,6 +81,6 @@ public: ~NavigationMeshEditorPlugin(); }; -#endif +#endif // TOOLS_ENABLED -#endif +#endif // NAVIGATION_MESH_EDITOR_PLUGIN_H diff --git a/modules/navigation/register_types.cpp b/modules/navigation/register_types.cpp index e2264e843c..218f2c2937 100644 --- a/modules/navigation/register_types.cpp +++ b/modules/navigation/register_types.cpp @@ -40,7 +40,7 @@ #endif #ifdef TOOLS_ENABLED -#include "navigation_mesh_editor_plugin.h" +#include "editor/navigation_mesh_editor_plugin.h" #endif #ifndef _3D_DISABLED diff --git a/modules/text_server_adv/SCsub b/modules/text_server_adv/SCsub index e999700d55..dfd3bb3f1e 100644 --- a/modules/text_server_adv/SCsub +++ b/modules/text_server_adv/SCsub @@ -37,7 +37,7 @@ def make_icu_data(target, source, env): thirdparty_obj = [] freetype_enabled = env.module_check_dependencies("text_server_adv", ["freetype"], True) -msdngen_enabled = env.module_check_dependencies("text_server_adv", ["msdfgen"], True) +msdfgen_enabled = env.module_check_dependencies("text_server_adv", ["msdfgen"], True) if env["builtin_harfbuzz"]: env_harfbuzz = env_modules.Clone() @@ -117,20 +117,25 @@ if env["builtin_harfbuzz"]: ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] - env_harfbuzz.Append( - CPPPATH=[ - "#thirdparty/harfbuzz/src", - "#thirdparty/icu4c/common/", - ] - ) + env_harfbuzz.Append(CPPPATH=["#thirdparty/harfbuzz/src"]) + + env_harfbuzz.Append(CCFLAGS=["-DHAVE_ICU"]) + if env["builtin_icu"]: + env_harfbuzz.Append(CPPPATH=["#thirdparty/icu4c/common/"]) + env_harfbuzz.Append(CCFLAGS=["-DHAVE_ICU_BUILTIN"]) if freetype_enabled: env_harfbuzz.Append( - CPPPATH=[ - "#thirdparty/freetype/include", - "#thirdparty/graphite/include", + CCFLAGS=[ + "-DHAVE_FREETYPE", + "-DHAVE_GRAPHITE2", ] ) + if env["builtin_freetype"]: + env_harfbuzz.Append(CPPPATH=["#thirdparty/freetype/include"]) + if env["builtin_graphite"]: + env_harfbuzz.Append(CPPPATH=["#thirdparty/graphite/include"]) + env_harfbuzz.Append(CCFLAGS=["-DGRAPHITE2_STATIC"]) if env["platform"] == "android" or env["platform"] == "linuxbsd": env_harfbuzz.Append(CCFLAGS=["-DHAVE_PTHREAD"]) @@ -141,21 +146,7 @@ if env["builtin_harfbuzz"]: else: env_harfbuzz.Append(CCFLAGS=["-DHB_NO_MT"]) - env_harfbuzz.Append( - CCFLAGS=[ - "-DHAVE_ICU_BUILTIN", - "-DHAVE_ICU", - ] - ) - - if freetype_enabled: - env_harfbuzz.Append( - CCFLAGS=[ - "-DHAVE_FREETYPE", - "-DHAVE_GRAPHITE2", - "-DGRAPHITE2_STATIC", - ] - ) + env_text_server_adv.Append(CPPPATH=["#thirdparty/harfbuzz/src"]) lib = env_harfbuzz.add_library("harfbuzz_builtin", thirdparty_sources) thirdparty_obj += lib @@ -481,6 +472,10 @@ if env["builtin_icu"]: "-DICU_DATA_NAME=" + icu_data_name, ] ) + if env_text_server_adv["tools"]: + env_text_server_adv.Append(CXXFLAGS=["-DICU_STATIC_DATA"]) + + env_text_server_adv.Append(CPPPATH=["#thirdparty/icu4c/common/"]) lib = env_icu.add_library("icu_builtin", thirdparty_sources) thirdparty_obj += lib @@ -503,30 +498,14 @@ if env["builtin_icu"]: module_obj = [] -if env_text_server_adv["tools"]: - env_text_server_adv.Append(CXXFLAGS=["-DICU_STATIC_DATA"]) +if env["builtin_msdfgen"] and msdfgen_enabled: + env_text_server_adv.Append(CPPPATH=["#thirdparty/msdfgen"]) -env_text_server_adv.Append( - CPPPATH=[ - "#thirdparty/harfbuzz/src", - "#thirdparty/icu4c/common/", - ] -) +if env["builtin_freetype"] and freetype_enabled: + env_text_server_adv.Append(CPPPATH=["#thirdparty/freetype/include"]) -if msdngen_enabled: - env_text_server_adv.Append( - CPPPATH=[ - "#thirdparty/msdfgen", - ] - ) - -if freetype_enabled: - env_text_server_adv.Append( - CPPPATH=[ - "#thirdparty/freetype/include", - "#thirdparty/graphite/include", - ] - ) +if env["builtin_graphite"] and freetype_enabled: + env_text_server_adv.Append(CPPPATH=["#thirdparty/graphite/include"]) env_text_server_adv.add_source_files(module_obj, "*.cpp") env.modules_sources += module_obj diff --git a/modules/text_server_fb/SCsub b/modules/text_server_fb/SCsub index 31d1db6167..121f38fcd5 100644 --- a/modules/text_server_fb/SCsub +++ b/modules/text_server_fb/SCsub @@ -4,22 +4,14 @@ Import("env") Import("env_modules") freetype_enabled = env.module_check_dependencies("text_server_fb", ["freetype"], True) -msdngen_enabled = env.module_check_dependencies("text_server_fb", ["msdfgen"], True) +msdfgen_enabled = env.module_check_dependencies("text_server_fb", ["msdfgen"], True) env_text_server_fb = env_modules.Clone() -if msdngen_enabled: - env_text_server_fb.Append( - CPPPATH=[ - "#thirdparty/msdfgen", - ] - ) +if env["builtin_msdfgen"] and msdfgen_enabled: + env_text_server_fb.Append(CPPPATH=["#thirdparty/msdfgen"]) -if freetype_enabled: - env_text_server_fb.Append( - CPPPATH=[ - "#thirdparty/freetype/include", - ] - ) +if env["builtin_freetype"] and freetype_enabled: + env_text_server_fb.Append(CPPPATH=["#thirdparty/freetype/include"]) env_text_server_fb.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index d4dffdfc7a..d72bdf9128 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -338,8 +338,8 @@ public: virtual Error reload(bool p_keep_state = false) override; #ifdef TOOLS_ENABLED - virtual const Vector<DocData::ClassDoc> &get_documentation() const override { - static Vector<DocData::ClassDoc> docs; + virtual Vector<DocData::ClassDoc> get_documentation() const override { + Vector<DocData::ClassDoc> docs; return docs; } #endif // TOOLS_ENABLED diff --git a/modules/websocket/SCsub b/modules/websocket/SCsub index 63c941c4a8..dc0661995f 100644 --- a/modules/websocket/SCsub +++ b/modules/websocket/SCsub @@ -41,6 +41,8 @@ elif env["builtin_wslay"]: module_obj = [] env_ws.add_source_files(module_obj, "*.cpp") +if env["tools"]: + env_ws.add_source_files(module_obj, "editor/*.cpp") env.modules_sources += module_obj # Needed to force rebuilding the module files when the thirdparty library is updated. diff --git a/modules/websocket/editor_debugger_server_websocket.cpp b/modules/websocket/editor/editor_debugger_server_websocket.cpp index 4f1a56f00b..0443147d98 100644 --- a/modules/websocket/editor_debugger_server_websocket.cpp +++ b/modules/websocket/editor/editor_debugger_server_websocket.cpp @@ -30,11 +30,13 @@ #include "editor_debugger_server_websocket.h" +#ifdef TOOLS_ENABLED + +#include "../remote_debugger_peer_websocket.h" #include "core/config/project_settings.h" #include "editor/editor_log.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" -#include "modules/websocket/remote_debugger_peer_websocket.h" void EditorDebuggerServerWebSocket::_peer_connected(int p_id, String _protocol) { pending_peers.push_back(p_id); @@ -129,3 +131,5 @@ EditorDebuggerServer *EditorDebuggerServerWebSocket::create(const String &p_prot ERR_FAIL_COND_V(p_protocol != "ws://", nullptr); return memnew(EditorDebuggerServerWebSocket); } + +#endif // TOOLS_ENABLED diff --git a/modules/websocket/editor_debugger_server_websocket.h b/modules/websocket/editor/editor_debugger_server_websocket.h index cc14bf62ba..7c0705302d 100644 --- a/modules/websocket/editor_debugger_server_websocket.h +++ b/modules/websocket/editor/editor_debugger_server_websocket.h @@ -31,8 +31,10 @@ #ifndef EDITOR_DEBUGGER_SERVER_WEBSOCKET_H #define EDITOR_DEBUGGER_SERVER_WEBSOCKET_H +#ifdef TOOLS_ENABLED + +#include "../websocket_server.h" #include "editor/debugger/editor_debugger_server.h" -#include "modules/websocket/websocket_server.h" class EditorDebuggerServerWebSocket : public EditorDebuggerServer { GDCLASS(EditorDebuggerServerWebSocket, EditorDebuggerServer); @@ -60,4 +62,6 @@ public: ~EditorDebuggerServerWebSocket(); }; +#endif // TOOLS_ENABLED + #endif // EDITOR_DEBUGGER_SERVER_WEBSOCKET_H diff --git a/modules/websocket/register_types.cpp b/modules/websocket/register_types.cpp index ff900f496f..6d63938d4f 100644 --- a/modules/websocket/register_types.cpp +++ b/modules/websocket/register_types.cpp @@ -29,8 +29,10 @@ /*************************************************************************/ #include "register_types.h" + #include "core/config/project_settings.h" #include "core/error/error_macros.h" + #ifdef JAVASCRIPT_ENABLED #include "emscripten.h" #include "emws_client.h" @@ -40,10 +42,11 @@ #include "wsl_client.h" #include "wsl_server.h" #endif + #ifdef TOOLS_ENABLED #include "editor/debugger/editor_debugger_server.h" +#include "editor/editor_debugger_server_websocket.h" #include "editor/editor_node.h" -#include "editor_debugger_server_websocket.h" #endif #ifdef TOOLS_ENABLED diff --git a/modules/websocket/remote_debugger_peer_websocket.h b/modules/websocket/remote_debugger_peer_websocket.h index ddf5425d81..84f9506625 100644 --- a/modules/websocket/remote_debugger_peer_websocket.h +++ b/modules/websocket/remote_debugger_peer_websocket.h @@ -31,12 +31,13 @@ #ifndef REMOTE_DEBUGGER_PEER_WEBSOCKET_H #define REMOTE_DEBUGGER_PEER_WEBSOCKET_H +#include "core/debugger/remote_debugger_peer.h" + #ifdef JAVASCRIPT_ENABLED -#include "modules/websocket/emws_client.h" +#include "emws_client.h" #else -#include "modules/websocket/wsl_client.h" +#include "wsl_client.h" #endif -#include "core/debugger/remote_debugger_peer.h" class RemoteDebuggerPeerWebSocket : public RemoteDebuggerPeer { Ref<WebSocketClient> ws_client; diff --git a/scene/3d/collision_shape_3d.h b/scene/3d/collision_shape_3d.h index bd5595f974..fbcabf6529 100644 --- a/scene/3d/collision_shape_3d.h +++ b/scene/3d/collision_shape_3d.h @@ -37,7 +37,6 @@ class CollisionObject3D; class CollisionShape3D : public Node3D { GDCLASS(CollisionShape3D, Node3D); - OBJ_CATEGORY("3D Physics Nodes"); Ref<Shape3D> shape; diff --git a/scene/3d/light_3d.h b/scene/3d/light_3d.h index 81c25f01c3..383fa644e5 100644 --- a/scene/3d/light_3d.h +++ b/scene/3d/light_3d.h @@ -35,7 +35,6 @@ class Light3D : public VisualInstance3D { GDCLASS(Light3D, VisualInstance3D); - OBJ_CATEGORY("3D Light Nodes"); public: enum Param { diff --git a/scene/3d/node_3d.h b/scene/3d/node_3d.h index 65d0e071cf..6d857a83ea 100644 --- a/scene/3d/node_3d.h +++ b/scene/3d/node_3d.h @@ -50,7 +50,6 @@ public: class Node3D : public Node { GDCLASS(Node3D, Node); - OBJ_CATEGORY("3D"); public: enum RotationEditMode { diff --git a/scene/3d/visual_instance_3d.h b/scene/3d/visual_instance_3d.h index 1c044ba681..f8fd4378fe 100644 --- a/scene/3d/visual_instance_3d.h +++ b/scene/3d/visual_instance_3d.h @@ -35,7 +35,6 @@ class VisualInstance3D : public Node3D { GDCLASS(VisualInstance3D, Node3D); - OBJ_CATEGORY("3D Visual Nodes"); RID base; RID instance; diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index c4fc69f370..a68f6b9d5b 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -62,7 +62,6 @@ public: class AnimationPlayer : public Node { GDCLASS(AnimationPlayer, Node); - OBJ_CATEGORY("Animation Nodes"); public: enum AnimationProcessCallback { diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index 3fa0cec302..e094c4546b 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -1782,10 +1782,10 @@ void CodeEdit::request_code_completion(bool p_force) { /* Don't re-query if all existing options are quoted types, eg path, signal. */ bool ignored = code_completion_active && !code_completion_options.is_empty(); if (ignored) { - ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_PLAIN_TEXT; - const ScriptCodeCompletionOption *previous_option = nullptr; + ScriptLanguage::CodeCompletionKind kind = ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT; + const ScriptLanguage::CodeCompletionOption *previous_option = nullptr; for (int i = 0; i < code_completion_options.size(); i++) { - const ScriptCodeCompletionOption ¤t_option = code_completion_options[i]; + const ScriptLanguage::CodeCompletionOption ¤t_option = code_completion_options[i]; if (!previous_option) { previous_option = ¤t_option; kind = current_option.kind; @@ -1795,7 +1795,7 @@ void CodeEdit::request_code_completion(bool p_force) { break; } } - ignored = ignored && (kind == ScriptCodeCompletionOption::KIND_FILE_PATH || kind == ScriptCodeCompletionOption::KIND_NODE_PATH || kind == ScriptCodeCompletionOption::KIND_SIGNAL); + ignored = ignored && (kind == ScriptLanguage::CODE_COMPLETION_KIND_FILE_PATH || kind == ScriptLanguage::CODE_COMPLETION_KIND_NODE_PATH || kind == ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL); } if (ignored) { @@ -1818,8 +1818,8 @@ void CodeEdit::request_code_completion(bool p_force) { } void CodeEdit::add_code_completion_option(CodeCompletionKind p_type, const String &p_display_text, const String &p_insert_text, const Color &p_text_color, const RES &p_icon, const Variant &p_value) { - ScriptCodeCompletionOption completion_option; - completion_option.kind = (ScriptCodeCompletionOption::Kind)p_type; + ScriptLanguage::CodeCompletionOption completion_option; + completion_option.kind = (ScriptLanguage::CodeCompletionKind)p_type; completion_option.display = p_display_text; completion_option.insert_text = p_insert_text; completion_option.font_color = p_text_color; @@ -2702,7 +2702,7 @@ void CodeEdit::_filter_code_completion_candidates_impl() { TypedArray<Dictionary> completion_options_sources; completion_options_sources.resize(code_completion_option_sources.size()); int i = 0; - for (const ScriptCodeCompletionOption &E : code_completion_option_sources) { + for (const ScriptLanguage::CodeCompletionOption &E : code_completion_option_sources) { Dictionary option; option["kind"] = E.kind; option["display_text"] = E.display; @@ -2727,8 +2727,8 @@ void CodeEdit::_filter_code_completion_candidates_impl() { /* Convert back into options. */ int max_width = 0; for (i = 0; i < completion_options.size(); i++) { - ScriptCodeCompletionOption option; - option.kind = (ScriptCodeCompletionOption::Kind)(int)completion_options[i].get("kind"); + ScriptLanguage::CodeCompletionOption option; + option.kind = (ScriptLanguage::CodeCompletionKind)(int)completion_options[i].get("kind"); option.display = completion_options[i].get("display_text"); option.insert_text = completion_options[i].get("insert_text"); option.font_color = completion_options[i].get("font_color"); @@ -2821,15 +2821,15 @@ void CodeEdit::_filter_code_completion_candidates_impl() { code_completion_options.clear(); code_completion_base = string_to_complete; - Vector<ScriptCodeCompletionOption> completion_options_casei; - Vector<ScriptCodeCompletionOption> completion_options_substr; - Vector<ScriptCodeCompletionOption> completion_options_substr_casei; - Vector<ScriptCodeCompletionOption> completion_options_subseq; - Vector<ScriptCodeCompletionOption> completion_options_subseq_casei; + Vector<ScriptLanguage::CodeCompletionOption> completion_options_casei; + Vector<ScriptLanguage::CodeCompletionOption> completion_options_substr; + Vector<ScriptLanguage::CodeCompletionOption> completion_options_substr_casei; + Vector<ScriptLanguage::CodeCompletionOption> completion_options_subseq; + Vector<ScriptLanguage::CodeCompletionOption> completion_options_subseq_casei; int max_width = 0; String string_to_complete_lower = string_to_complete.to_lower(); - for (ScriptCodeCompletionOption &option : code_completion_option_sources) { + for (ScriptLanguage::CodeCompletionOption &option : code_completion_option_sources) { if (single_quote && option.display.is_quoted()) { option.display = option.display.unquote().quote("'"); } diff --git a/scene/gui/code_edit.h b/scene/gui/code_edit.h index cb1309ced3..596a065f12 100644 --- a/scene/gui/code_edit.h +++ b/scene/gui/code_edit.h @@ -38,7 +38,7 @@ class CodeEdit : public TextEdit { public: /* Keep enum in sync with: */ - /* /core/object/script_language.h - ScriptCodeCompletionOption::Kind */ + /* /core/object/script_language.h - ScriptLanguage::CodeCompletionKind */ enum CodeCompletionKind { KIND_CLASS, KIND_FUNCTION, @@ -208,15 +208,15 @@ private: Color code_completion_existing_color = Color(0, 0, 0, 0); bool code_completion_active = false; - Vector<ScriptCodeCompletionOption> code_completion_options; + Vector<ScriptLanguage::CodeCompletionOption> code_completion_options; int code_completion_line_ofs = 0; int code_completion_current_selected = 0; int code_completion_longest_line = 0; Rect2i code_completion_rect; Set<char32_t> code_completion_prefixes; - List<ScriptCodeCompletionOption> code_completion_option_submitted; - List<ScriptCodeCompletionOption> code_completion_option_sources; + List<ScriptLanguage::CodeCompletionOption> code_completion_option_submitted; + List<ScriptLanguage::CodeCompletionOption> code_completion_option_sources; String code_completion_base; void _filter_code_completion_candidates_impl(); diff --git a/scene/gui/control.h b/scene/gui/control.h index 9f78d003ae..4240d52b65 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -44,7 +44,6 @@ class Panel; class Control : public CanvasItem { GDCLASS(Control, CanvasItem); - OBJ_CATEGORY("GUI Nodes"); public: enum Anchor { diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index 2fb6452a97..2eb41f1631 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -282,7 +282,7 @@ void Range::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_greater"), "set_allow_greater", "is_greater_allowed"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_lesser"), "set_allow_lesser", "is_lesser_allowed"); - GDVIRTUAL_BIND(_value_changed); + GDVIRTUAL_BIND(_value_changed, "new_value"); ADD_LINKED_PROPERTY("min_value", "value"); ADD_LINKED_PROPERTY("min_value", "max_value"); diff --git a/scene/main/node.h b/scene/main/node.h index f5fbcf6587..196d23c14f 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -43,7 +43,6 @@ class PropertyTweener; class Node : public Object { GDCLASS(Node, Object); - OBJ_CATEGORY("Nodes"); public: enum ProcessMode { diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 0c7a9fda4a..a9138e13b2 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1603,29 +1603,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { _gui_call_input(mouse_focus, mb); } - // In case the mouse was released after for example dragging a scrollbar, - // check whether the current control is different from the stored one. If - // it is different, rather than wait for it to be updated the next time the - // mouse is moved, notify the control so that it can e.g. drop the highlight. - // This code is duplicated from the mm.is_valid()-case further below. - Control *over = nullptr; - if (gui.mouse_focus) { - over = gui.mouse_focus; - } else { - over = gui_find_control(mpos); - } - - if (gui.mouse_focus_mask == MouseButton::NONE && over != gui.mouse_over) { - _drop_mouse_over(); - _gui_cancel_tooltip(); - - if (over) { - _gui_call_notification(over, Control::NOTIFICATION_MOUSE_ENTER); - } - } - - gui.mouse_over = over; - set_input_as_handled(); } } @@ -1685,9 +1662,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { } Control *over = nullptr; - if (gui.mouse_focus) { - over = gui.mouse_focus; - } else if (gui.mouse_in_viewport) { + if (gui.mouse_in_viewport) { over = gui_find_control(mpos); } @@ -1701,6 +1676,10 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { } } + if (gui.mouse_focus) { + over = gui.mouse_focus; + } + DisplayServer::CursorShape ds_cursor_shape = (DisplayServer::CursorShape)Input::get_singleton()->get_default_cursor_shape(); if (over) { diff --git a/servers/extensions/SCsub b/servers/extensions/SCsub index eac66ea283..ba73353f2a 100644 --- a/servers/extensions/SCsub +++ b/servers/extensions/SCsub @@ -2,11 +2,6 @@ Import("env") -import make_wrappers -from platform_methods import run_in_subprocess - -env.CommandNoCache(["ext_wrappers.gen.inc"], "make_wrappers.py", run_in_subprocess(make_wrappers.run)) - env_object = env.Clone() env_object.add_source_files(env.servers_sources, "*.cpp") diff --git a/servers/extensions/physics_server_3d_extension.h b/servers/extensions/physics_server_3d_extension.h index b40ab8a295..41a7746183 100644 --- a/servers/extensions/physics_server_3d_extension.h +++ b/servers/extensions/physics_server_3d_extension.h @@ -31,11 +31,11 @@ #ifndef PHYSICS_SERVER_3D_EXTENSION_H #define PHYSICS_SERVER_3D_EXTENSION_H +#include "core/extension/ext_wrappers.gen.inc" #include "core/object/script_language.h" #include "core/variant/native_ptr.h" #include "core/variant/type_info.h" #include "core/variant/typed_array.h" -#include "servers/extensions/ext_wrappers.gen.inc" #include "servers/physics_server_3d.h" class PhysicsDirectBodyState3DExtension : public PhysicsDirectBodyState3D { diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 08f1ced803..a6f3a48398 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -9034,7 +9034,7 @@ Error ShaderLanguage::compile(const String &p_code, const ShaderCompileInfo &p_i return OK; } -Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_info, List<ScriptCodeCompletionOption> *r_options, String &r_call_hint) { +Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_info, List<ScriptLanguage::CodeCompletionOption> *r_options, String &r_call_hint) { clear(); code = p_code; @@ -9053,7 +9053,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ } break; case COMPLETION_SHADER_TYPE: { for (const String &shader_type : p_info.shader_types) { - ScriptCodeCompletionOption option(shader_type, ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption option(shader_type, ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); r_options->push_back(option); } return OK; @@ -9073,7 +9073,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ if (!found) { for (int j = 0; j < info.options.size(); j++) { - ScriptCodeCompletionOption option(String(info.name) + "_" + String(info.options[j]), ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption option(String(info.name) + "_" + String(info.options[j]), ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); r_options->push_back(option); } } @@ -9081,7 +9081,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ const String name = String(info.name); if (!shader->render_modes.has(name)) { - ScriptCodeCompletionOption option(name, ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption option(name, ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); r_options->push_back(option); } } @@ -9093,7 +9093,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ if (shader->structs.has(completion_struct)) { StructNode *node = shader->structs[completion_struct].shader_struct; for (int i = 0; i < node->members.size(); i++) { - ScriptCodeCompletionOption option(node->members[i]->name, ScriptCodeCompletionOption::KIND_MEMBER); + ScriptLanguage::CodeCompletionOption option(node->members[i]->name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER); r_options->push_back(option); } } @@ -9115,7 +9115,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ if (found) { continue; } - ScriptCodeCompletionOption option(E.key, ScriptCodeCompletionOption::KIND_FUNCTION); + ScriptLanguage::CodeCompletionOption option(E.key, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION); r_options->push_back(option); } @@ -9124,7 +9124,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ case COMPLETION_IDENTIFIER: case COMPLETION_FUNCTION_CALL: { bool comp_ident = completion_type == COMPLETION_IDENTIFIER; - Map<String, ScriptCodeCompletionOption::Kind> matches; + Map<String, ScriptLanguage::CodeCompletionKind> matches; StringName skip_function; BlockNode *block = completion_block; @@ -9133,7 +9133,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ if (comp_ident) { for (const KeyValue<StringName, BlockNode::Variable> &E : block->variables) { if (E.value.line < completion_line) { - matches.insert(E.key, ScriptCodeCompletionOption::KIND_VARIABLE); + matches.insert(E.key, ScriptLanguage::CODE_COMPLETION_KIND_VARIABLE); } } } @@ -9141,7 +9141,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ if (block->parent_function) { if (comp_ident) { for (int i = 0; i < block->parent_function->arguments.size(); i++) { - matches.insert(block->parent_function->arguments[i].name, ScriptCodeCompletionOption::KIND_VARIABLE); + matches.insert(block->parent_function->arguments[i].name, ScriptLanguage::CODE_COMPLETION_KIND_VARIABLE); } } skip_function = block->parent_function->name; @@ -9152,9 +9152,9 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ if (comp_ident) { if (p_info.functions.has("global")) { for (const KeyValue<StringName, BuiltInInfo> &E : p_info.functions["global"].built_ins) { - ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_MEMBER; + ScriptLanguage::CodeCompletionKind kind = ScriptLanguage::CODE_COMPLETION_KIND_MEMBER; if (E.value.constant) { - kind = ScriptCodeCompletionOption::KIND_CONSTANT; + kind = ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT; } matches.insert(E.key, kind); } @@ -9162,9 +9162,9 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ if (p_info.functions.has("constants")) { for (const KeyValue<StringName, BuiltInInfo> &E : p_info.functions["constants"].built_ins) { - ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_MEMBER; + ScriptLanguage::CodeCompletionKind kind = ScriptLanguage::CODE_COMPLETION_KIND_MEMBER; if (E.value.constant) { - kind = ScriptCodeCompletionOption::KIND_CONSTANT; + kind = ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT; } matches.insert(E.key, kind); } @@ -9172,22 +9172,22 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ if (skip_function != StringName() && p_info.functions.has(skip_function)) { for (const KeyValue<StringName, BuiltInInfo> &E : p_info.functions[skip_function].built_ins) { - ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_MEMBER; + ScriptLanguage::CodeCompletionKind kind = ScriptLanguage::CODE_COMPLETION_KIND_MEMBER; if (E.value.constant) { - kind = ScriptCodeCompletionOption::KIND_CONSTANT; + kind = ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT; } matches.insert(E.key, kind); } } for (const KeyValue<StringName, ShaderNode::Constant> &E : shader->constants) { - matches.insert(E.key, ScriptCodeCompletionOption::KIND_CONSTANT); + matches.insert(E.key, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT); } for (const KeyValue<StringName, ShaderNode::Varying> &E : shader->varyings) { - matches.insert(E.key, ScriptCodeCompletionOption::KIND_VARIABLE); + matches.insert(E.key, ScriptLanguage::CODE_COMPLETION_KIND_VARIABLE); } for (const KeyValue<StringName, ShaderNode::Uniform> &E : shader->uniforms) { - matches.insert(E.key, ScriptCodeCompletionOption::KIND_MEMBER); + matches.insert(E.key, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER); } } @@ -9195,7 +9195,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ if (!shader->functions[i].callable || shader->functions[i].name == skip_function) { continue; } - matches.insert(String(shader->functions[i].name), ScriptCodeCompletionOption::KIND_FUNCTION); + matches.insert(String(shader->functions[i].name), ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION); } int idx = 0; @@ -9203,7 +9203,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ if (stages && stages->has(skip_function)) { for (const KeyValue<StringName, StageFunctionInfo> &E : (*stages)[skip_function].stage_functions) { - matches.insert(String(E.key), ScriptCodeCompletionOption::KIND_FUNCTION); + matches.insert(String(E.key), ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION); } } @@ -9212,7 +9212,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ idx++; continue; } - matches.insert(String(builtin_func_defs[idx].name), ScriptCodeCompletionOption::KIND_FUNCTION); + matches.insert(String(builtin_func_defs[idx].name), ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION); idx++; } @@ -9226,15 +9226,15 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ continue; } if (builtin_func_defs[idx].tag == completion_class) { - matches.insert(String(builtin_func_defs[idx].name), ScriptCodeCompletionOption::KIND_FUNCTION); + matches.insert(String(builtin_func_defs[idx].name), ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION); } idx++; } } - for (const KeyValue<String, ScriptCodeCompletionOption::Kind> &E : matches) { - ScriptCodeCompletionOption option(E.key, E.value); - if (E.value == ScriptCodeCompletionOption::KIND_FUNCTION) { + for (const KeyValue<String, ScriptLanguage::CodeCompletionKind> &E : matches) { + ScriptLanguage::CodeCompletionOption option(E.key, E.value); + if (E.value == ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION) { option.insert_text += "("; } r_options->push_back(option); @@ -9483,18 +9483,18 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ } for (int i = 0; i < limit; i++) { - r_options->push_back(ScriptCodeCompletionOption(String::chr(colv[i]), ScriptCodeCompletionOption::KIND_PLAIN_TEXT)); - r_options->push_back(ScriptCodeCompletionOption(String::chr(coordv[i]), ScriptCodeCompletionOption::KIND_PLAIN_TEXT)); - r_options->push_back(ScriptCodeCompletionOption(String::chr(coordt[i]), ScriptCodeCompletionOption::KIND_PLAIN_TEXT)); + r_options->push_back(ScriptLanguage::CodeCompletionOption(String::chr(colv[i]), ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT)); + r_options->push_back(ScriptLanguage::CodeCompletionOption(String::chr(coordv[i]), ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT)); + r_options->push_back(ScriptLanguage::CodeCompletionOption(String::chr(coordt[i]), ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT)); } } break; case COMPLETION_HINT: { if (completion_base == DataType::TYPE_VEC4) { - ScriptCodeCompletionOption option("hint_color", ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption option("hint_color", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); r_options->push_back(option); } else if ((completion_base == DataType::TYPE_INT || completion_base == DataType::TYPE_FLOAT) && !completion_base_array) { - ScriptCodeCompletionOption option("hint_range", ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption option("hint_range", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); if (completion_base == DataType::TYPE_INT) { option.insert_text = "hint_range(0, 100, 1)"; @@ -9530,12 +9530,12 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ } for (int i = 0; i < options.size(); i++) { - ScriptCodeCompletionOption option(options[i], ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption option(options[i], ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); r_options->push_back(option); } } if (!completion_base_array) { - ScriptCodeCompletionOption option("instance_index", ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption option("instance_index", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); option.insert_text = "instance_index(0)"; r_options->push_back(option); } diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index f39b21621d..e5ac14a7db 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -1091,7 +1091,7 @@ public: }; Error compile(const String &p_code, const ShaderCompileInfo &p_info); - Error complete(const String &p_code, const ShaderCompileInfo &p_info, List<ScriptCodeCompletionOption> *r_options, String &r_call_hint); + Error complete(const String &p_code, const ShaderCompileInfo &p_info, List<ScriptLanguage::CodeCompletionOption> *r_options, String &r_call_hint); String get_error_text(); int get_error_line(); diff --git a/tests/core/math/test_color.h b/tests/core/math/test_color.h index 702f17a9cf..6f40f8ecc0 100644 --- a/tests/core/math/test_color.h +++ b/tests/core/math/test_color.h @@ -144,6 +144,24 @@ TEST_CASE("[Color] Conversion methods") { "The string representation should match the expected value."); } +TEST_CASE("[Color] Linear <-> sRGB conversion") { + const Color color = Color(0.35, 0.5, 0.6, 0.7); + const Color color_linear = color.to_linear(); + const Color color_srgb = color.to_srgb(); + CHECK_MESSAGE( + color_linear.is_equal_approx(Color(0.100481, 0.214041, 0.318547, 0.7)), + "The color converted to linear color space should match the expected value."); + CHECK_MESSAGE( + color_srgb.is_equal_approx(Color(0.62621, 0.735357, 0.797738, 0.7)), + "The color converted to sRGB color space should match the expected value."); + CHECK_MESSAGE( + color_linear.to_srgb().is_equal_approx(Color(0.35, 0.5, 0.6, 0.7)), + "The linear color converted back to sRGB color space should match the expected value."); + CHECK_MESSAGE( + color_srgb.to_linear().is_equal_approx(Color(0.35, 0.5, 0.6, 0.7)), + "The sRGB color converted back to linear color space should match the expected value."); +} + TEST_CASE("[Color] Named colors") { CHECK_MESSAGE( Color::named("red").is_equal_approx(Color::hex(0xFF0000FF)), |