summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/debugger/engine_debugger.cpp2
-rw-r--r--core/extension/extension_api_dump.cpp2
-rw-r--r--core/io/ip_address.cpp2
-rw-r--r--core/string/ustring.cpp2
-rw-r--r--core/string/ustring.h2
-rw-r--r--core/variant/variant_call.cpp1
-rw-r--r--doc/classes/EditorPlugin.xml8
-rw-r--r--doc/classes/EditorSettings.xml3
-rw-r--r--doc/classes/Object.xml2
-rw-r--r--doc/classes/String.xml12
-rw-r--r--doc/classes/StringName.xml10
-rw-r--r--drivers/alsa/audio_driver_alsa.cpp2
-rw-r--r--drivers/egl/egl_manager.cpp2
-rw-r--r--drivers/gles3/storage/config.cpp2
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.cpp4
-rw-r--r--editor/animation_track_editor.cpp2
-rw-r--r--editor/connections_dialog.cpp2
-rw-r--r--editor/create_dialog.cpp2
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_parser.cpp2
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_parser.h2
-rw-r--r--editor/debugger/editor_debugger_node.cpp2
-rw-r--r--editor/debugger/editor_file_server.cpp2
-rw-r--r--editor/dependency_editor.cpp4
-rw-r--r--editor/doc_tools.cpp2
-rw-r--r--editor/editor_dock_manager.cpp79
-rw-r--r--editor/editor_dock_manager.h11
-rw-r--r--editor/editor_file_system.cpp4
-rw-r--r--editor/editor_help_search.cpp8
-rw-r--r--editor/editor_inspector.cpp2
-rw-r--r--editor/editor_log.cpp2
-rw-r--r--editor/editor_node.cpp33
-rw-r--r--editor/editor_node.h1
-rw-r--r--editor/editor_property_name_processor.cpp2
-rw-r--r--editor/editor_quick_open.cpp2
-rw-r--r--editor/editor_sectioned_inspector.cpp2
-rw-r--r--editor/editor_settings.cpp5
-rw-r--r--editor/filesystem_dock.cpp6
-rw-r--r--editor/import/3d/resource_importer_obj.cpp2
-rw-r--r--editor/import/3d/resource_importer_scene.cpp12
-rw-r--r--editor/input_event_configuration_dialog.cpp8
-rw-r--r--editor/plugins/editor_plugin.cpp6
-rw-r--r--editor/plugins/editor_plugin.h2
-rw-r--r--editor/plugins/script_editor_plugin.cpp4
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp2
-rw-r--r--editor/plugins/theme_editor_plugin.cpp4
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp2
-rw-r--r--editor/project_manager/project_list.cpp2
-rw-r--r--editor/property_selector.cpp8
-rw-r--r--editor/rename_dialog.cpp2
-rw-r--r--editor/scene_tree_dock.cpp2
-rw-r--r--main/main.cpp2
-rw-r--r--modules/csg/csg.cpp2
-rw-r--r--modules/gdscript/language_server/gdscript_workspace.cpp2
-rw-r--r--modules/gdscript/tests/test_lsp.h2
-rw-r--r--modules/gltf/editor/editor_scene_exporter_gltf_settings.cpp2
-rw-r--r--modules/gltf/gltf_document.cpp2
-rw-r--r--modules/gltf/skin_tool.cpp24
-rw-r--r--modules/mono/editor/bindings_generator.cpp6
-rw-r--r--modules/multiplayer/editor/replication_editor.cpp2
-rw-r--r--modules/openxr/action_map/openxr_action_map.cpp8
-rw-r--r--modules/openxr/action_map/openxr_action_set.cpp2
-rw-r--r--modules/openxr/action_map/openxr_interaction_profile.cpp2
-rw-r--r--modules/openxr/openxr_interface.cpp2
-rw-r--r--modules/regex/regex.cpp2
-rw-r--r--modules/text_server_adv/text_server_adv.h40
-rw-r--r--modules/text_server_fb/text_server_fb.h40
-rw-r--r--modules/upnp/upnp.cpp8
-rw-r--r--platform/android/export/export_plugin.cpp8
-rw-r--r--platform/android/os_android.cpp4
-rw-r--r--platform/ios/export/export_plugin.cpp106
-rw-r--r--platform/linuxbsd/joypad_linux.cpp6
-rw-r--r--platform/linuxbsd/os_linuxbsd.cpp4
-rw-r--r--platform/macos/export/export_plugin.cpp46
-rw-r--r--platform/windows/export/export_plugin.cpp14
-rw-r--r--scene/3d/skeleton_3d.cpp2
-rw-r--r--scene/gui/split_container.cpp4
-rw-r--r--scene/gui/texture_progress_bar.cpp2
-rw-r--r--scene/main/http_request.cpp2
-rw-r--r--scene/resources/mesh.cpp2
-rw-r--r--servers/audio/audio_stream.cpp2
-rw-r--r--servers/rendering/rendering_device.cpp8
-rw-r--r--tests/core/object/test_class_db.h12
-rw-r--r--tests/core/string/test_string.h15
-rw-r--r--tests/test_main.cpp8
84 files changed, 414 insertions, 268 deletions
diff --git a/core/debugger/engine_debugger.cpp b/core/debugger/engine_debugger.cpp
index a7655c874a..97a020e4c3 100644
--- a/core/debugger/engine_debugger.cpp
+++ b/core/debugger/engine_debugger.cpp
@@ -137,7 +137,7 @@ void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, co
script_debugger = memnew(ScriptDebugger);
// Tell the OS that we want to handle termination signals.
OS::get_singleton()->initialize_debugging();
- } else if (p_uri.find("://") >= 0) {
+ } else if (p_uri.contains("://")) {
const String proto = p_uri.substr(0, p_uri.find("://") + 3);
if (!protocols.has(proto)) {
return;
diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp
index 1c9b4dc3e8..848b6f3886 100644
--- a/core/extension/extension_api_dump.cpp
+++ b/core/extension/extension_api_dump.cpp
@@ -1201,7 +1201,7 @@ Dictionary GDExtensionAPIDump::generate_extension_api(bool p_include_docs) {
if (F.name.begins_with("_")) {
continue; //hidden property
}
- if (F.name.find("/") >= 0) {
+ if (F.name.contains("/")) {
// Ignore properties with '/' (slash) in the name. These are only meant for use in the inspector.
continue;
}
diff --git a/core/io/ip_address.cpp b/core/io/ip_address.cpp
index ce74bb36d6..a93876a2b5 100644
--- a/core/io/ip_address.cpp
+++ b/core/io/ip_address.cpp
@@ -202,7 +202,7 @@ IPAddress::IPAddress(const String &p_string) {
// Wildcard (not a valid IP)
wildcard = true;
- } else if (p_string.find(":") >= 0) {
+ } else if (p_string.contains(":")) {
// IPv6
_parse_ipv6(p_string);
valid = true;
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp
index 7cd1a39d38..3d37e17ef8 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -3964,7 +3964,7 @@ String String::format(const Variant &values, const String &placeholder) const {
Variant v_val = values_arr[i];
String val = v_val;
- if (placeholder.find("_") > -1) {
+ if (placeholder.contains("_")) {
new_string = new_string.replace(placeholder.replace("_", i_as_str), val);
} else {
new_string = new_string.replace_first(placeholder, val);
diff --git a/core/string/ustring.h b/core/string/ustring.h
index a020c7d372..9df2d56e80 100644
--- a/core/string/ustring.h
+++ b/core/string/ustring.h
@@ -429,6 +429,8 @@ public:
_FORCE_INLINE_ bool is_empty() const { return length() == 0; }
_FORCE_INLINE_ bool contains(const char *p_str) const { return find(p_str) != -1; }
_FORCE_INLINE_ bool contains(const String &p_str) const { return find(p_str) != -1; }
+ _FORCE_INLINE_ bool containsn(const char *p_str) const { return findn(p_str) != -1; }
+ _FORCE_INLINE_ bool containsn(const String &p_str) const { return findn(p_str) != -1; }
// path functions
bool is_absolute_path() const;
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index c5861f3fbb..9b7777f480 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -1707,6 +1707,7 @@ static void _register_variant_builtin_methods() {
bind_string_method(sha256_buffer, sarray(), varray());
bind_string_method(is_empty, sarray(), varray());
bind_string_methodv(contains, static_cast<bool (String::*)(const String &) const>(&String::contains), sarray("what"), varray());
+ bind_string_methodv(containsn, static_cast<bool (String::*)(const String &) const>(&String::containsn), sarray("what"), varray());
bind_string_method(is_absolute_path, sarray(), varray());
bind_string_method(is_relative_path, sarray(), varray());
diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml
index e874b44cfc..89b9e7d6c2 100644
--- a/doc/classes/EditorPlugin.xml
+++ b/doc/classes/EditorPlugin.xml
@@ -727,6 +727,14 @@
Removes a callback previously added by [method add_undo_redo_inspector_hook_callback].
</description>
</method>
+ <method name="set_dock_tab_icon">
+ <return type="void" />
+ <param index="0" name="control" type="Control" />
+ <param index="1" name="icon" type="Texture2D" />
+ <description>
+ Sets the tab icon for the given control in a dock slot. Setting to [code]null[/code] removes the icon.
+ </description>
+ </method>
<method name="set_force_draw_over_forwarding_enabled">
<return type="void" />
<description>
diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml
index 6aa81803b7..f31f8135ff 100644
--- a/doc/classes/EditorSettings.xml
+++ b/doc/classes/EditorSettings.xml
@@ -632,6 +632,9 @@
If set to [b]Auto[/b], the editor scale is automatically determined based on the screen resolution and reported display DPI. This heuristic is not always ideal, which means you can get better results by setting the editor scale manually.
If set to [b]Custom[/b], the scaling value in [member interface/editor/custom_display_scale] will be used.
</member>
+ <member name="interface/editor/dock_tab_style" type="int" setter="" getter="">
+ Tab style of editor docks.
+ </member>
<member name="interface/editor/editor_language" type="String" setter="" getter="">
The language to use for the editor interface.
Translations are provided by the community. If you spot a mistake, [url=$DOCS_URL/contributing/documentation/editor_and_docs_localization.html]contribute to editor translations on Weblate![/url]
diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml
index 68d2d6411c..b0dec2d00a 100644
--- a/doc/classes/Object.xml
+++ b/doc/classes/Object.xml
@@ -1034,6 +1034,7 @@
Translates a [param message], using the translation catalogs configured in the Project Settings. Further [param context] can be specified to help with the translation. Note that most [Control] nodes automatically translate their strings, so this method is mostly useful for formatted strings or custom drawn text.
If [method can_translate_messages] is [code]false[/code], or no translation is available, this method returns the [param message] without changes. See [method set_message_translation].
For detailed examples, see [url=$DOCS_URL/tutorials/i18n/internationalizing_games.html]Internationalizing games[/url].
+ [b]Note:[/b] This method can't be used without an [Object] instance, as it requires the [method can_translate_messages] method. To translate strings in a static context, use [method TranslationServer.translate].
</description>
</method>
<method name="tr_n" qualifiers="const">
@@ -1048,6 +1049,7 @@
The [param n] is the number, or amount, of the message's subject. It is used by the translation system to fetch the correct plural form for the current language.
For detailed examples, see [url=$DOCS_URL/tutorials/i18n/localization_using_gettext.html]Localization using gettext[/url].
[b]Note:[/b] Negative and [float] numbers may not properly apply to some countable subjects. It's recommended to handle these cases with [method tr].
+ [b]Note:[/b] This method can't be used without an [Object] instance, as it requires the [method can_translate_messages] method. To translate strings in a static context, use [method TranslationServer.translate_plural].
</description>
</method>
</methods>
diff --git a/doc/classes/String.xml b/doc/classes/String.xml
index 13bf994e83..450e483f69 100644
--- a/doc/classes/String.xml
+++ b/doc/classes/String.xml
@@ -126,7 +126,7 @@
[/codeblock]
</description>
</method>
- <method name="contains" qualifiers="const" keywords="includes, has">
+ <method name="contains" qualifiers="const">
<return type="bool" />
<param index="0" name="what" type="String" />
<description>
@@ -142,7 +142,15 @@
GD.Print("team".Contains("I")); // Prints false
[/csharp]
[/codeblocks]
- If you need to know where [param what] is within the string, use [method find].
+ If you need to know where [param what] is within the string, use [method find]. See also [method containsn].
+ </description>
+ </method>
+ <method name="containsn" qualifiers="const">
+ <return type="bool" />
+ <param index="0" name="what" type="String" />
+ <description>
+ Returns [code]true[/code] if the string contains [param what], [b]ignoring case[/b].
+ If you need to know where [param what] is within the string, use [method findn]. See also [method contains].
</description>
</method>
<method name="count" qualifiers="const">
diff --git a/doc/classes/StringName.xml b/doc/classes/StringName.xml
index fbb73fd483..76586b7968 100644
--- a/doc/classes/StringName.xml
+++ b/doc/classes/StringName.xml
@@ -126,7 +126,15 @@
GD.Print("team".Contains("I")); // Prints false
[/csharp]
[/codeblocks]
- If you need to know where [param what] is within the string, use [method find].
+ If you need to know where [param what] is within the string, use [method find]. See also [method containsn].
+ </description>
+ </method>
+ <method name="containsn" qualifiers="const">
+ <return type="bool" />
+ <param index="0" name="what" type="String" />
+ <description>
+ Returns [code]true[/code] if the string contains [param what], [b]ignoring case[/b].
+ If you need to know where [param what] is within the string, use [method findn]. See also [method contains].
</description>
</method>
<method name="count" qualifiers="const">
diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp
index 764d66c3b8..0c9635339b 100644
--- a/drivers/alsa/audio_driver_alsa.cpp
+++ b/drivers/alsa/audio_driver_alsa.cpp
@@ -52,7 +52,7 @@ Error AudioDriverALSA::init_output_device() {
// If there is a specified output device check that it is really present
if (output_device_name != "Default") {
PackedStringArray list = get_output_device_list();
- if (list.find(output_device_name) == -1) {
+ if (!list.has(output_device_name)) {
output_device_name = "Default";
new_output_device = "Default";
}
diff --git a/drivers/egl/egl_manager.cpp b/drivers/egl/egl_manager.cpp
index 4eddfd027b..6073856747 100644
--- a/drivers/egl/egl_manager.cpp
+++ b/drivers/egl/egl_manager.cpp
@@ -383,7 +383,7 @@ Error EGLManager::initialize() {
ERR_FAIL_COND_V(eglGetError() != EGL_SUCCESS, ERR_BUG);
const char *platform = _get_platform_extension_name();
- if (extensions_string.split(" ").find(platform) < 0) {
+ if (!extensions_string.split(" ").has(platform)) {
ERR_FAIL_V_MSG(ERR_UNAVAILABLE, vformat("EGL platform extension \"%s\" not found.", platform));
}
diff --git a/drivers/gles3/storage/config.cpp b/drivers/gles3/storage/config.cpp
index 1a41b60836..6b5e227782 100644
--- a/drivers/gles3/storage/config.cpp
+++ b/drivers/gles3/storage/config.cpp
@@ -157,7 +157,7 @@ Config::Config() {
continue;
}
- if (renderer.findn(v) != -1) {
+ if (renderer.containsn(v)) {
use_depth_prepass = false;
}
}
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
index 20382e7f7c..669e6c2aa9 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
@@ -183,7 +183,7 @@ Error AudioDriverPulseAudio::init_output_device() {
// If there is a specified output device, check that it is really present
if (output_device_name != "Default") {
PackedStringArray list = get_output_device_list();
- if (list.find(output_device_name) == -1) {
+ if (!list.has(output_device_name)) {
output_device_name = "Default";
new_output_device = "Default";
}
@@ -695,7 +695,7 @@ Error AudioDriverPulseAudio::init_input_device() {
// If there is a specified input device, check that it is really present
if (input_device_name != "Default") {
PackedStringArray list = get_input_device_list();
- if (list.find(input_device_name) == -1) {
+ if (!list.has(input_device_name)) {
input_device_name = "Default";
new_input_device = "Default";
}
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 9c7f4c33d6..f21a0816ca 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -7122,7 +7122,7 @@ void AnimationTrackEditor::_pick_track_select_recursive(TreeItem *p_item, const
NodePath np = p_item->get_metadata(0);
Node *node = get_node_or_null(np);
- if (node && !p_filter.is_empty() && ((String)node->get_name()).findn(p_filter) != -1) {
+ if (node && !p_filter.is_empty() && ((String)node->get_name()).containsn(p_filter)) {
p_select_candidates.push_back(node);
}
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index 787cae22cb..478067629e 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -282,7 +282,7 @@ List<MethodInfo> ConnectDialog::_filter_method_list(const List<MethodInfo> &p_me
List<MethodInfo> ret;
for (const MethodInfo &mi : p_methods) {
- if (!p_search_string.is_empty() && mi.name.findn(p_search_string) == -1) {
+ if (!p_search_string.is_empty() && !mi.name.containsn(p_search_string)) {
continue;
}
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index b00f059b36..2c7f6fb21a 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -376,7 +376,7 @@ float CreateDialog::_score_type(const String &p_type, const String &p_search) co
score *= _is_type_preferred(p_type) ? 1.0f : 0.9f;
// Add score for being a favorite type.
- score *= (favorite_list.find(p_type) > -1) ? 1.0f : 0.8f;
+ score *= favorite_list.has(p_type) ? 1.0f : 0.8f;
// Look through at most 5 recent items
bool in_recent = false;
diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp
index 3c0420d2f0..4210baeed2 100644
--- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp
+++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp
@@ -358,7 +358,7 @@ Dictionary DebugAdapterParser::req_setBreakpoints(const Dictionary &p_params) co
}
// If path contains \, it's a Windows path, so we need to convert it to /, and make the drive letter uppercase
- if (source.path.find("\\") != -1) {
+ if (source.path.contains("\\")) {
source.path = source.path.replace("\\", "/");
source.path = source.path.substr(0, 1).to_upper() + source.path.substr(1);
}
diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.h b/editor/debugger/debug_adapter/debug_adapter_parser.h
index 9860e96498..8fd2c2b3e2 100644
--- a/editor/debugger/debug_adapter/debug_adapter_parser.h
+++ b/editor/debugger/debug_adapter/debug_adapter_parser.h
@@ -50,7 +50,7 @@ private:
if (p_path.contains("\\")) {
String project_path = ProjectSettings::get_singleton()->get_resource_path();
String path = p_path.replace("\\", "/");
- return path.findn(project_path) != -1;
+ return path.containsn(project_path);
}
return p_path.begins_with(ProjectSettings::get_singleton()->get_resource_path());
}
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp
index 3ee8a33e70..931e360a34 100644
--- a/editor/debugger/editor_debugger_node.cpp
+++ b/editor/debugger/editor_debugger_node.cpp
@@ -262,7 +262,7 @@ void EditorDebuggerNode::set_keep_open(bool p_keep_open) {
}
Error EditorDebuggerNode::start(const String &p_uri) {
- ERR_FAIL_COND_V(p_uri.find("://") < 0, ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(!p_uri.contains("://"), ERR_INVALID_PARAMETER);
if (keep_open && current_uri == p_uri && server.is_valid()) {
return OK;
}
diff --git a/editor/debugger/editor_file_server.cpp b/editor/debugger/editor_file_server.cpp
index e84eb14636..1092b07054 100644
--- a/editor/debugger/editor_file_server.cpp
+++ b/editor/debugger/editor_file_server.cpp
@@ -80,7 +80,7 @@ void EditorFileServer::_scan_files_changed(EditorFileSystemDirectory *efd, const
_add_file(remapped_path, mt, files_to_send, cached_files);
} else if (remap.begins_with("path.")) {
String feature = remap.get_slice(".", 1);
- if (p_tags.find(feature) != -1) {
+ if (p_tags.has(feature)) {
String remapped_path = cf->get_value("remap", remap);
uint64_t mt = FileAccess::get_modified_time(remapped_path);
_add_file(remapped_path, mt, files_to_send, cached_files);
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index 8c3cad3e89..84d6cb67d8 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -642,11 +642,11 @@ void DependencyRemoveDialog::ok_pressed() {
for (int i = 0; i < previous_favorites.size(); ++i) {
if (previous_favorites[i].ends_with("/")) {
- if (dirs_to_delete.find(previous_favorites[i]) < 0) {
+ if (!dirs_to_delete.has(previous_favorites[i])) {
new_favorites.push_back(previous_favorites[i]);
}
} else {
- if (files_to_delete.find(previous_favorites[i]) < 0) {
+ if (!files_to_delete.has(previous_favorites[i])) {
new_favorites.push_back(previous_favorites[i]);
}
}
diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp
index 7fce3c45f8..b58e82b7e7 100644
--- a/editor/doc_tools.cpp
+++ b/editor/doc_tools.cpp
@@ -1638,7 +1638,7 @@ Error DocTools::save_classes(const String &p_default_path, const HashMap<String,
String schema_path;
if (p_use_relative_schema) {
// Modules are nested deep, so change the path to reference the same schema everywhere.
- schema_path = save_path.find("modules/") != -1 ? "../../../doc/class.xsd" : "../class.xsd";
+ schema_path = save_path.contains("modules/") ? "../../../doc/class.xsd" : "../class.xsd";
} else {
schema_path = "https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd";
}
diff --git a/editor/editor_dock_manager.cpp b/editor/editor_dock_manager.cpp
index 06dd33d8ab..4956fa867a 100644
--- a/editor/editor_dock_manager.cpp
+++ b/editor/editor_dock_manager.cpp
@@ -33,12 +33,10 @@
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
#include "scene/gui/label.h"
-#include "scene/gui/popup.h"
#include "scene/gui/split_container.h"
#include "scene/gui/tab_container.h"
#include "scene/main/window.h"
-#include "editor/editor_command_palette.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
@@ -47,6 +45,12 @@
#include "editor/themes/editor_scale.h"
#include "editor/window_wrapper.h"
+enum class TabStyle {
+ TEXT_ONLY,
+ ICON_ONLY,
+ TEXT_AND_ICON,
+};
+
EditorDockManager *EditorDockManager::singleton = nullptr;
void DockSplitContainer::_update_visibility() {
@@ -156,7 +160,7 @@ void EditorDockManager::_update_docks_menu() {
docks_menu->clear();
docks_menu->reset_size();
- const Ref<Texture2D> icon = docks_menu->get_editor_theme_icon(SNAME("Window"));
+ const Ref<Texture2D> default_icon = docks_menu->get_editor_theme_icon(SNAME("Window"));
const Color closed_icon_color_mod = Color(1, 1, 1, 0.5);
// Add docks.
@@ -169,7 +173,8 @@ void EditorDockManager::_update_docks_menu() {
} else {
docks_menu->add_item(dock.value.title, id);
}
- docks_menu->set_item_icon(id, icon);
+ const Ref<Texture2D> icon = dock.value.icon_name ? docks_menu->get_editor_theme_icon(dock.value.icon_name) : dock.value.icon;
+ docks_menu->set_item_icon(id, icon.is_valid() ? icon : default_icon);
if (!dock.value.open) {
docks_menu->set_item_icon_modulate(id, closed_icon_color_mod);
}
@@ -344,7 +349,9 @@ void EditorDockManager::_move_dock(Control *p_dock, Control *p_target, int p_tab
p_target->set_block_signals(false);
TabContainer *dock_tab_container = Object::cast_to<TabContainer>(p_target);
if (dock_tab_container) {
- dock_tab_container->set_tab_title(dock_tab_container->get_tab_idx_from_control(p_dock), all_docks[p_dock].title);
+ if (dock_tab_container->is_inside_tree()) {
+ _update_tab_style(p_dock);
+ }
if (p_tab_index >= 0) {
_move_dock_tab_index(p_dock, p_tab_index, p_set_current);
}
@@ -352,6 +359,42 @@ void EditorDockManager::_move_dock(Control *p_dock, Control *p_target, int p_tab
}
}
+void EditorDockManager::_update_tab_style(Control *p_dock) {
+ const DockInfo &dock_info = all_docks[p_dock];
+ if (!dock_info.enabled || !dock_info.open) {
+ return; // Disabled by feature profile or manually closed by user.
+ }
+ if (dock_info.dock_window || dock_info.at_bottom) {
+ return; // Floating or sent to bottom.
+ }
+
+ TabContainer *tab_container = get_dock_tab_container(p_dock);
+ ERR_FAIL_NULL(tab_container);
+ int index = tab_container->get_tab_idx_from_control(p_dock);
+ ERR_FAIL_COND(index == -1);
+
+ const TabStyle style = (TabStyle)EDITOR_GET("interface/editor/dock_tab_style").operator int();
+ switch (style) {
+ case TabStyle::TEXT_ONLY: {
+ tab_container->set_tab_title(index, dock_info.title);
+ tab_container->set_tab_icon(index, Ref<Texture2D>());
+ tab_container->set_tab_tooltip(index, String());
+ } break;
+ case TabStyle::ICON_ONLY: {
+ const Ref<Texture2D> icon = dock_info.icon_name ? tab_container->get_editor_theme_icon(dock_info.icon_name) : dock_info.icon;
+ tab_container->set_tab_title(index, icon.is_valid() ? String() : dock_info.title);
+ tab_container->set_tab_icon(index, icon);
+ tab_container->set_tab_tooltip(index, icon.is_valid() ? dock_info.title : String());
+ } break;
+ case TabStyle::TEXT_AND_ICON: {
+ const Ref<Texture2D> icon = dock_info.icon_name ? tab_container->get_editor_theme_icon(dock_info.icon_name) : dock_info.icon;
+ tab_container->set_tab_title(index, dock_info.title);
+ tab_container->set_tab_icon(index, icon);
+ tab_container->set_tab_tooltip(index, String());
+ } break;
+ }
+}
+
void EditorDockManager::save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section) const {
// Save docks by dock slot.
for (int i = 0; i < DOCK_SLOT_MAX; i++) {
@@ -665,14 +708,15 @@ void EditorDockManager::focus_dock(Control *p_dock) {
tab_container->set_current_tab(tab_index);
}
-void EditorDockManager::add_dock(Control *p_dock, const String &p_title, DockSlot p_slot, const Ref<Shortcut> &p_shortcut) {
+void EditorDockManager::add_dock(Control *p_dock, const String &p_title, DockSlot p_slot, const Ref<Shortcut> &p_shortcut, const StringName &p_icon_name) {
ERR_FAIL_NULL(p_dock);
ERR_FAIL_COND_MSG(all_docks.has(p_dock), vformat("Cannot add dock '%s', already added.", p_dock->get_name()));
DockInfo dock_info;
- dock_info.title = !p_title.is_empty() ? p_title : String(p_dock->get_name());
+ dock_info.title = p_title.is_empty() ? String(p_dock->get_name()) : p_title;
dock_info.dock_slot_index = p_slot;
dock_info.shortcut = p_shortcut;
+ dock_info.icon_name = p_icon_name;
all_docks[p_dock] = dock_info;
if (p_slot != DOCK_SLOT_NONE) {
@@ -695,6 +739,14 @@ void EditorDockManager::remove_dock(Control *p_dock) {
_update_layout();
}
+void EditorDockManager::set_dock_tab_icon(Control *p_dock, const Ref<Texture2D> &p_icon) {
+ ERR_FAIL_NULL(p_dock);
+ ERR_FAIL_COND_MSG(!all_docks.has(p_dock), vformat("Cannot set tab icon for unknown dock '%s'.", p_dock->get_name()));
+
+ all_docks[p_dock].icon = p_icon;
+ _update_tab_style(p_dock);
+}
+
void EditorDockManager::set_docks_visible(bool p_show) {
if (docks_visible == p_show) {
return;
@@ -710,6 +762,19 @@ bool EditorDockManager::are_docks_visible() const {
return docks_visible;
}
+void EditorDockManager::update_tab_styles() {
+ for (const KeyValue<Control *, DockInfo> &dock : all_docks) {
+ _update_tab_style(dock.key);
+ }
+}
+
+void EditorDockManager::set_tab_icon_max_width(int p_max_width) {
+ for (int i = 0; i < DOCK_SLOT_MAX; i++) {
+ TabContainer *tab_container = dock_slot[i];
+ tab_container->add_theme_constant_override(SNAME("icon_max_width"), p_max_width);
+ }
+}
+
void EditorDockManager::add_vsplit(DockSplitContainer *p_split) {
vsplits.push_back(p_split);
p_split->connect("dragged", callable_mp(this, &EditorDockManager::_dock_split_dragged));
diff --git a/editor/editor_dock_manager.h b/editor/editor_dock_manager.h
index cbb076c809..226222c55a 100644
--- a/editor/editor_dock_manager.h
+++ b/editor/editor_dock_manager.h
@@ -87,6 +87,8 @@ private:
WindowWrapper *dock_window = nullptr;
int dock_slot_index = DOCK_SLOT_NONE;
Ref<Shortcut> shortcut;
+ Ref<Texture2D> icon; // Only used when `icon_name` is empty.
+ StringName icon_name;
};
static EditorDockManager *singleton;
@@ -126,9 +128,14 @@ private:
void _move_dock_tab_index(Control *p_dock, int p_tab_index, bool p_set_current);
void _move_dock(Control *p_dock, Control *p_target, int p_tab_index = -1, bool p_set_current = true);
+ void _update_tab_style(Control *p_dock);
+
public:
static EditorDockManager *get_singleton() { return singleton; }
+ void update_tab_styles();
+ void set_tab_icon_max_width(int p_max_width);
+
void add_vsplit(DockSplitContainer *p_split);
void add_hsplit(DockSplitContainer *p_split);
void register_dock_slot(DockSlot p_dock_slot, TabContainer *p_tab_container);
@@ -150,9 +157,11 @@ public:
void set_docks_visible(bool p_show);
bool are_docks_visible() const;
- void add_dock(Control *p_dock, const String &p_title = "", DockSlot p_slot = DOCK_SLOT_NONE, const Ref<Shortcut> &p_shortcut = nullptr);
+ void add_dock(Control *p_dock, const String &p_title = "", DockSlot p_slot = DOCK_SLOT_NONE, const Ref<Shortcut> &p_shortcut = nullptr, const StringName &p_icon_name = StringName());
void remove_dock(Control *p_dock);
+ void set_dock_tab_icon(Control *p_dock, const Ref<Texture2D> &p_icon);
+
EditorDockManager();
};
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 1e91a326b3..bee1275d64 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -269,7 +269,7 @@ void EditorFileSystem::_scan_filesystem() {
FileCache fc;
fc.type = split[1];
- if (fc.type.find("/") != -1) {
+ if (fc.type.contains("/")) {
fc.type = fc.type.get_slice("/", 0);
fc.resource_script_class = fc.type.get_slice("/", 1);
}
@@ -2707,7 +2707,7 @@ void EditorFileSystem::_update_extensions() {
}
void EditorFileSystem::add_import_format_support_query(Ref<EditorFileSystemImportFormatSupportQuery> p_query) {
- ERR_FAIL_COND(import_support_queries.find(p_query) != -1);
+ ERR_FAIL_COND(import_support_queries.has(p_query));
import_support_queries.push_back(p_query);
}
void EditorFileSystem::remove_import_format_support_query(Ref<EditorFileSystemImportFormatSupportQuery> p_query) {
diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp
index ff381d68c0..1e0c0e9fd8 100644
--- a/editor/editor_help_search.cpp
+++ b/editor/editor_help_search.cpp
@@ -40,7 +40,7 @@
bool EditorHelpSearch::_all_terms_in_name(const Vector<String> &p_terms, const String &p_name) const {
for (int i = 0; i < p_terms.size(); i++) {
- if (p_name.findn(p_terms[i]) < 0) {
+ if (!p_name.containsn(p_terms[i])) {
return false;
}
}
@@ -109,7 +109,7 @@ Dictionary EditorHelpSearch::_native_search_cb(const String &p_search_string, in
if (class_doc.name.is_empty()) {
continue;
}
- if (class_doc.name.findn(term) > -1) {
+ if (class_doc.name.containsn(term)) {
ret[vformat("class_name:%s", class_doc.name)] = class_doc.name;
}
if (term.length() > 1 || term == "@") {
@@ -744,9 +744,9 @@ String EditorHelpSearch::Runner::_match_keywords_in_all_terms(const String &p_ke
bool EditorHelpSearch::Runner::_match_string(const String &p_term, const String &p_string) const {
if (search_flags & SEARCH_CASE_SENSITIVE) {
- return p_string.find(p_term) > -1;
+ return p_string.contains(p_term);
} else {
- return p_string.findn(p_term) > -1;
+ return p_string.containsn(p_term);
}
}
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 7c69ac589a..9599479c83 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -52,7 +52,7 @@
#include "scene/resources/style_box_flat.h"
bool EditorInspector::_property_path_matches(const String &p_property_path, const String &p_filter, EditorPropertyNameProcessor::Style p_style) {
- if (p_property_path.findn(p_filter) != -1) {
+ if (p_property_path.containsn(p_filter)) {
return true;
}
diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp
index b8da550d8a..ab4950f01b 100644
--- a/editor/editor_log.cpp
+++ b/editor/editor_log.cpp
@@ -322,7 +322,7 @@ void EditorLog::_rebuild_log() {
bool EditorLog::_check_display_message(LogMessage &p_message) {
bool filter_active = type_filter_map[p_message.type]->is_active();
String search_text = search_box->get_text();
- bool search_match = search_text.is_empty() || p_message.text.findn(search_text) > -1;
+ bool search_match = search_text.is_empty() || p_message.text.containsn(search_text);
return filter_active && search_match;
}
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 33b46b82bc..d7f197b569 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -544,6 +544,9 @@ void EditorNode::_update_theme(bool p_skip_creation) {
}
}
}
+
+ editor_dock_manager->update_tab_styles();
+ editor_dock_manager->set_tab_icon_max_width(theme->get_constant(SNAME("class_icon_size"), EditorStringName(Editor)));
}
void EditorNode::update_preview_themes(int p_mode) {
@@ -752,7 +755,7 @@ void EditorNode::_notification(int p_what) {
case NOTIFICATION_APPLICATION_FOCUS_OUT: {
// Save on focus loss before applying the FPS limit to avoid slowing down the saving process.
if (EDITOR_GET("interface/editor/save_on_focus_loss")) {
- _menu_option_confirm(FILE_SAVE_SCENE, false);
+ _menu_option_confirm(FILE_SAVE_SCENE_SILENTLY, false);
}
// Set a low FPS cap to decrease CPU/GPU usage while the editor is unfocused.
@@ -789,6 +792,10 @@ void EditorNode::_notification(int p_what) {
recent_scenes->reset_size();
}
+ if (EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/dock_tab_style")) {
+ editor_dock_manager->update_tab_styles();
+ }
+
if (EditorSettings::get_singleton()->check_changed_settings_in_group("interface/scene_tabs")) {
scene_tabs->update_scene_tabs();
}
@@ -2391,7 +2398,7 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update
Ref<Resource> res = Object::cast_to<Resource>(current_obj);
if (p_skip_foreign && res.is_valid()) {
const int current_tab = scene_tabs->get_current_tab();
- if (res->get_path().find("::") > -1 && res->get_path().get_slice("::", 0) != editor_data.get_scene_path(current_tab)) {
+ if (res->get_path().contains("::") && res->get_path().get_slice("::", 0) != editor_data.get_scene_path(current_tab)) {
// Trying to edit resource that belongs to another scene; abort.
current_obj = nullptr;
}
@@ -2666,6 +2673,16 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
case FILE_CLOSE: {
_scene_tab_closed(editor_data.get_edited_scene());
} break;
+ case FILE_SAVE_SCENE_SILENTLY: {
+ // Save scene without displaying progress dialog. Used to work around
+ // errors about parent node being busy setting up children
+ // when Save on Focus Loss kicks in.
+ Node *scene = editor_data.get_edited_scene_root();
+ if (scene && !scene->get_scene_file_path().is_empty() && DirAccess::exists(scene->get_scene_file_path().get_base_dir())) {
+ _save_scene(scene->get_scene_file_path());
+ save_editor_layout_delayed();
+ }
+ } break;
case SCENE_TAB_CLOSE:
case FILE_SAVE_SCENE: {
int scene_idx = (p_option == FILE_SAVE_SCENE) ? -1 : tab_closing_idx;
@@ -7045,22 +7062,22 @@ EditorNode::EditorNode() {
history_dock = memnew(HistoryDock);
// Scene: Top left.
- editor_dock_manager->add_dock(SceneTreeDock::get_singleton(), TTR("Scene"), EditorDockManager::DOCK_SLOT_LEFT_UR);
+ editor_dock_manager->add_dock(SceneTreeDock::get_singleton(), TTR("Scene"), EditorDockManager::DOCK_SLOT_LEFT_UR, nullptr, "PackedScene");
// Import: Top left, behind Scene.
- editor_dock_manager->add_dock(ImportDock::get_singleton(), TTR("Import"), EditorDockManager::DOCK_SLOT_LEFT_UR);
+ editor_dock_manager->add_dock(ImportDock::get_singleton(), TTR("Import"), EditorDockManager::DOCK_SLOT_LEFT_UR, nullptr, "FileAccess");
// FileSystem: Bottom left.
- editor_dock_manager->add_dock(FileSystemDock::get_singleton(), TTR("FileSystem"), EditorDockManager::DOCK_SLOT_LEFT_BR, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_filesystem_bottom_panel", TTR("Toggle FileSystem Bottom Panel"), KeyModifierMask::ALT | Key::F));
+ editor_dock_manager->add_dock(FileSystemDock::get_singleton(), TTR("FileSystem"), EditorDockManager::DOCK_SLOT_LEFT_BR, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_filesystem_bottom_panel", TTR("Toggle FileSystem Bottom Panel"), KeyModifierMask::ALT | Key::F), "Folder");
// Inspector: Full height right.
- editor_dock_manager->add_dock(InspectorDock::get_singleton(), TTR("Inspector"), EditorDockManager::DOCK_SLOT_RIGHT_UL);
+ editor_dock_manager->add_dock(InspectorDock::get_singleton(), TTR("Inspector"), EditorDockManager::DOCK_SLOT_RIGHT_UL, nullptr, "AnimationTrackList");
// Node: Full height right, behind Inspector.
- editor_dock_manager->add_dock(NodeDock::get_singleton(), TTR("Node"), EditorDockManager::DOCK_SLOT_RIGHT_UL);
+ editor_dock_manager->add_dock(NodeDock::get_singleton(), TTR("Node"), EditorDockManager::DOCK_SLOT_RIGHT_UL, nullptr, "Object");
// History: Full height right, behind Node.
- editor_dock_manager->add_dock(history_dock, TTR("History"), EditorDockManager::DOCK_SLOT_RIGHT_UL);
+ editor_dock_manager->add_dock(history_dock, TTR("History"), EditorDockManager::DOCK_SLOT_RIGHT_UL, nullptr, "History");
// Add some offsets to left_r and main hsplits to make LEFT_R and RIGHT_L docks wider than minsize.
left_r_hsplit->set_split_offset(270 * EDSCALE);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 54c84bc6a6..6b3359eaee 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -159,6 +159,7 @@ private:
FILE_NEW_INHERITED_SCENE,
FILE_OPEN_SCENE,
FILE_SAVE_SCENE,
+ FILE_SAVE_SCENE_SILENTLY,
FILE_SAVE_AS_SCENE,
FILE_SAVE_ALL_SCENES,
FILE_SAVE_AND_RUN,
diff --git a/editor/editor_property_name_processor.cpp b/editor/editor_property_name_processor.cpp
index a00b50c191..f23cab676c 100644
--- a/editor/editor_property_name_processor.cpp
+++ b/editor/editor_property_name_processor.cpp
@@ -63,7 +63,7 @@ bool EditorPropertyNameProcessor::is_localization_available() {
return false;
}
const Vector<String> forbidden = String("en").split(",");
- return forbidden.find(EDITOR_GET("interface/editor/editor_language")) == -1;
+ return !forbidden.has(EDITOR_GET("interface/editor/editor_language"));
}
String EditorPropertyNameProcessor::_capitalize_name(const String &p_name) const {
diff --git a/editor/editor_quick_open.cpp b/editor/editor_quick_open.cpp
index f8df0f9fa8..d7a02ace24 100644
--- a/editor/editor_quick_open.cpp
+++ b/editor/editor_quick_open.cpp
@@ -160,7 +160,7 @@ float EditorQuickOpen::_score_search_result(const PackedStringArray &p_search_to
}
// Prioritize matches at the front of the path token.
- if (min_match_idx == 0 || p_path.find("/" + s) != -1) {
+ if (min_match_idx == 0 || p_path.contains("/" + s)) {
token_score += 1.0f;
}
diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp
index f13af8e4ca..22120bfc01 100644
--- a/editor/editor_sectioned_inspector.cpp
+++ b/editor/editor_sectioned_inspector.cpp
@@ -36,7 +36,7 @@
#include "editor/themes/editor_scale.h"
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) {
+ if (p_property_path.containsn(p_filter)) {
return true;
}
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index d1aa69294e..c019d46034 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -400,6 +400,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
// Editor
EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/editor/localize_settings", true, "")
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/dock_tab_style", 0, "Text Only,Icon Only,Text and Icon")
EDITOR_SETTING_USAGE(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/ui_layout_direction", 0, "Based on Application Locale,Left-to-Right,Right-to-Left,Based on System Locale", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED)
// Display what the Auto display scale setting effectively corresponds to.
@@ -969,7 +970,7 @@ bool EditorSettings::_save_text_editor_theme(const String &p_file) {
keys.sort();
for (const String &key : keys) {
- if (key.begins_with("text_editor/theme/highlighting/") && key.find("color") >= 0) {
+ if (key.begins_with("text_editor/theme/highlighting/") && key.contains("color")) {
cf->set_value(theme_section, key.replace("text_editor/theme/highlighting/", ""), ((Color)props[key].variant).to_html());
}
}
@@ -1448,7 +1449,7 @@ void EditorSettings::load_text_editor_theme() {
// don't load if it's not already there!
if (has_setting("text_editor/theme/highlighting/" + key)) {
// make sure it is actually a color
- if (val.is_valid_html_color() && key.find("color") >= 0) {
+ if (val.is_valid_html_color() && key.contains("color")) {
props["text_editor/theme/highlighting/" + key].variant = Color::html(val); // change manually to prevent "Settings changed" console spam
}
}
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index ef77e5340b..4c7c723dd5 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -261,7 +261,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
if (p_unfold_path && current_path.begins_with(lpath) && current_path != lpath) {
subdirectory_item->set_collapsed(false);
} else {
- subdirectory_item->set_collapsed(uncollapsed_paths.find(lpath) < 0);
+ subdirectory_item->set_collapsed(!uncollapsed_paths.has(lpath));
}
if (!searched_tokens.is_empty() && _matches_all_search_tokens(dname)) {
parent_should_expand = true;
@@ -407,7 +407,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo
favorites_item->set_icon(0, get_editor_theme_icon(SNAME("Favorites")));
favorites_item->set_text(0, TTR("Favorites:"));
favorites_item->set_metadata(0, "Favorites");
- favorites_item->set_collapsed(p_uncollapsed_paths.find("Favorites") < 0);
+ favorites_item->set_collapsed(!p_uncollapsed_paths.has("Favorites"));
Vector<String> favorite_paths = EditorSettings::get_singleton()->get_favorites();
@@ -2300,7 +2300,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
TreeItem *selected = tree->get_root();
selected = tree->get_next_selected(selected);
while (selected) {
- if (p_selected.find(selected->get_metadata(0)) >= 0) {
+ if (p_selected.has(selected->get_metadata(0))) {
selected->set_collapsed(false);
}
selected = tree->get_next_selected(selected);
diff --git a/editor/import/3d/resource_importer_obj.cpp b/editor/import/3d/resource_importer_obj.cpp
index f5bf60175a..6d68e93c75 100644
--- a/editor/import/3d/resource_importer_obj.cpp
+++ b/editor/import/3d/resource_importer_obj.cpp
@@ -217,7 +217,7 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes,
0x14c, // IMAGE_FILE_MACHINE_I386
0x200, // IMAGE_FILE_MACHINE_IA64
};
- ERR_FAIL_COND_V_MSG(coff_header_machines.find(first_bytes) != -1, ERR_FILE_CORRUPT, vformat("Couldn't read OBJ file '%s', it seems to be binary, corrupted, or empty.", p_path));
+ ERR_FAIL_COND_V_MSG(coff_header_machines.has(first_bytes), ERR_FILE_CORRUPT, vformat("Couldn't read OBJ file '%s', it seems to be binary, corrupted, or empty.", p_path));
f->seek(0);
Ref<ImporterMesh> mesh;
diff --git a/editor/import/3d/resource_importer_scene.cpp b/editor/import/3d/resource_importer_scene.cpp
index 707be84381..36cbf253cc 100644
--- a/editor/import/3d/resource_importer_scene.cpp
+++ b/editor/import/3d/resource_importer_scene.cpp
@@ -387,7 +387,7 @@ static bool _teststr(const String &p_what, const String &p_str) {
what = what.substr(0, what.length() - 1);
}
- if (what.findn("$" + p_str) != -1) { //blender and other stuff
+ if (what.containsn("$" + p_str)) { // Blender and other stuff.
return true;
}
if (what.to_lower().ends_with("-" + p_str)) { //collada only supports "_" and "-" besides letters
@@ -410,7 +410,7 @@ static String _fixstr(const String &p_what, const String &p_str) {
String end = p_what.substr(what.length(), p_what.length() - what.length());
- if (what.findn("$" + p_str) != -1) { //blender and other stuff
+ if (what.containsn("$" + p_str)) { // Blender and other stuff.
return what.replace("$" + p_str, "") + end;
}
if (what.to_lower().ends_with("-" + p_str)) { //collada only supports "_" and "-" besides letters
@@ -2086,12 +2086,12 @@ bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategor
p_options.has("generate/physics") &&
p_options["generate/physics"].operator bool();
- if (p_option.find("physics/") >= 0) {
+ if (p_option.contains("physics/")) {
// Show if need to generate collisions.
return generate_physics;
}
- if (p_option.find("decomposition/") >= 0) {
+ if (p_option.contains("decomposition/")) {
// Show if need to generate collisions.
if (generate_physics &&
// Show if convex is enabled.
@@ -2285,8 +2285,8 @@ bool ResourceImporterScene::get_internal_option_update_view_required(InternalImp
if (
p_option == "generate/physics" ||
p_option == "physics/shape_type" ||
- p_option.find("decomposition/") >= 0 ||
- p_option.find("primitive/") >= 0) {
+ p_option.contains("decomposition/") ||
+ p_option.contains("primitive/")) {
return true;
}
} break;
diff --git a/editor/input_event_configuration_dialog.cpp b/editor/input_event_configuration_dialog.cpp
index a667f94a62..143de82765 100644
--- a/editor/input_event_configuration_dialog.cpp
+++ b/editor/input_event_configuration_dialog.cpp
@@ -285,7 +285,7 @@ void InputEventConfigurationDialog::_update_input_list() {
for (int i = 0; i < keycode_get_count(); i++) {
String name = keycode_get_name_by_index(i);
- if (!search_term.is_empty() && name.findn(search_term) == -1) {
+ if (!search_term.is_empty() && !name.containsn(search_term)) {
continue;
}
@@ -309,7 +309,7 @@ void InputEventConfigurationDialog::_update_input_list() {
mb->set_button_index(mouse_buttons[i]);
String desc = EventListenerLineEdit::get_event_text(mb, false);
- if (!search_term.is_empty() && desc.findn(search_term) == -1) {
+ if (!search_term.is_empty() && !desc.containsn(search_term)) {
continue;
}
@@ -332,7 +332,7 @@ void InputEventConfigurationDialog::_update_input_list() {
joyb->set_button_index((JoyButton)i);
String desc = EventListenerLineEdit::get_event_text(joyb, false);
- if (!search_term.is_empty() && desc.findn(search_term) == -1) {
+ if (!search_term.is_empty() && !desc.containsn(search_term)) {
continue;
}
@@ -358,7 +358,7 @@ void InputEventConfigurationDialog::_update_input_list() {
joym->set_axis_value(direction);
String desc = EventListenerLineEdit::get_event_text(joym, false);
- if (!search_term.is_empty() && desc.findn(search_term) == -1) {
+ if (!search_term.is_empty() && !desc.containsn(search_term)) {
continue;
}
diff --git a/editor/plugins/editor_plugin.cpp b/editor/plugins/editor_plugin.cpp
index f42a1555a2..2b3c187352 100644
--- a/editor/plugins/editor_plugin.cpp
+++ b/editor/plugins/editor_plugin.cpp
@@ -100,6 +100,11 @@ void EditorPlugin::remove_control_from_bottom_panel(Control *p_control) {
EditorNode::get_bottom_panel()->remove_item(p_control);
}
+void EditorPlugin::set_dock_tab_icon(Control *p_control, const Ref<Texture2D> &p_icon) {
+ ERR_FAIL_NULL(p_control);
+ EditorDockManager::get_singleton()->set_dock_tab_icon(p_control, p_icon);
+}
+
void EditorPlugin::add_control_to_container(CustomControlContainer p_location, Control *p_control) {
ERR_FAIL_NULL(p_control);
@@ -565,6 +570,7 @@ void EditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("remove_control_from_docks", "control"), &EditorPlugin::remove_control_from_docks);
ClassDB::bind_method(D_METHOD("remove_control_from_bottom_panel", "control"), &EditorPlugin::remove_control_from_bottom_panel);
ClassDB::bind_method(D_METHOD("remove_control_from_container", "container", "control"), &EditorPlugin::remove_control_from_container);
+ ClassDB::bind_method(D_METHOD("set_dock_tab_icon", "control", "icon"), &EditorPlugin::set_dock_tab_icon);
ClassDB::bind_method(D_METHOD("add_tool_menu_item", "name", "callable"), &EditorPlugin::add_tool_menu_item);
ClassDB::bind_method(D_METHOD("add_tool_submenu_item", "name", "submenu"), &EditorPlugin::add_tool_submenu_item);
ClassDB::bind_method(D_METHOD("remove_tool_menu_item", "name"), &EditorPlugin::remove_tool_menu_item);
diff --git a/editor/plugins/editor_plugin.h b/editor/plugins/editor_plugin.h
index f45a512b89..f6c4b35407 100644
--- a/editor/plugins/editor_plugin.h
+++ b/editor/plugins/editor_plugin.h
@@ -151,6 +151,8 @@ public:
void remove_control_from_docks(Control *p_control);
void remove_control_from_bottom_panel(Control *p_control);
+ void set_dock_tab_icon(Control *p_control, const Ref<Texture2D> &p_icon);
+
void add_tool_menu_item(const String &p_name, const Callable &p_callable);
void add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu);
void remove_tool_menu_item(const String &p_name);
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 2f479527f3..723dbf5d6c 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -374,7 +374,7 @@ void ScriptEditorQuickOpen::_update_search() {
for (int i = 0; i < functions.size(); i++) {
String file = functions[i];
- if ((search_box->get_text().is_empty() || file.findn(search_box->get_text()) != -1)) {
+ if ((search_box->get_text().is_empty() || file.containsn(search_box->get_text()))) {
TreeItem *ti = search_options->create_item(root);
ti->set_text(0, file);
if (root->get_first_child() == ti) {
@@ -742,7 +742,7 @@ void ScriptEditor::_add_recent_script(const String &p_path) {
}
Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scripts", Array());
- if (rc.find(p_path) != -1) {
+ if (rc.has(p_path)) {
rc.erase(p_path);
}
rc.push_front(p_path);
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index a28952d8e7..eef9557ca8 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1312,7 +1312,7 @@ void SpriteFramesEditor::_update_library_impl() {
TreeItem *selected = nullptr;
for (const StringName &E : anim_names) {
String name = E;
- if (searching && name.to_lower().find(searched_string) < 0) {
+ if (searching && !name.to_lower().contains(searched_string)) {
continue;
}
TreeItem *it = animations->create_item(anim_root);
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index 166ed05748..4cc88aab34 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -106,7 +106,7 @@ void ThemeItemImportTree::_update_items_tree() {
type_node->set_checked(IMPORT_ITEM_DATA, false);
type_node->set_editable(IMPORT_ITEM_DATA, true);
- bool is_matching_filter = (filter_text.is_empty() || type_name.findn(filter_text) > -1);
+ bool is_matching_filter = (filter_text.is_empty() || type_name.containsn(filter_text));
bool has_filtered_items = false;
for (int i = 0; i < Theme::DATA_TYPE_MAX; i++) {
@@ -120,7 +120,7 @@ void ThemeItemImportTree::_update_items_tree() {
for (const StringName &F : names) {
String item_name = (String)F;
- bool is_item_matching_filter = (item_name.findn(filter_text) > -1);
+ bool is_item_matching_filter = item_name.containsn(filter_text);
if (!filter_text.is_empty() && !is_matching_filter && !is_item_matching_filter) {
continue;
}
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index e3f7aa5e6d..35db52a42e 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -1957,7 +1957,7 @@ void VisualShaderEditor::_update_options_menu() {
}
for (int i = 0; i < add_options.size(); i++) {
- if (!use_filter || add_options[i].name.findn(filter) != -1) {
+ if (!use_filter || add_options[i].name.containsn(filter)) {
// port type filtering
if (members_output_port_type != VisualShaderNode::PORT_TYPE_MAX || members_input_port_type != VisualShaderNode::PORT_TYPE_MAX) {
Ref<VisualShaderNode> vsn;
diff --git a/editor/project_manager/project_list.cpp b/editor/project_manager/project_list.cpp
index d125754dd7..b7520abc99 100644
--- a/editor/project_manager/project_list.cpp
+++ b/editor/project_manager/project_list.cpp
@@ -545,7 +545,7 @@ void ProjectList::sort_projects() {
}
// When searching, display projects whose name or path contain the search term and whose tags match the searched tags.
- item_visible = !missing_tags && (search_term.is_empty() || item.project_name.findn(search_term) != -1 || search_path.findn(search_term) != -1);
+ item_visible = !missing_tags && (search_term.is_empty() || item.project_name.containsn(search_term) || search_path.containsn(search_term));
}
item.control->set_visible(item_visible);
diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp
index eef68d918a..77ab629ba6 100644
--- a/editor/property_selector.cpp
+++ b/editor/property_selector.cpp
@@ -190,7 +190,7 @@ void PropertySelector::_update_search() {
continue;
}
- if (!search_box->get_text().is_empty() && E.name.findn(search_text) == -1) {
+ if (!search_box->get_text().is_empty() && !E.name.containsn(search_text)) {
continue;
}
@@ -203,7 +203,7 @@ void PropertySelector::_update_search() {
item->set_metadata(0, E.name);
item->set_icon(0, type_icons[E.type]);
- if (!found && !search_box->get_text().is_empty() && E.name.findn(search_text) != -1) {
+ if (!found && !search_box->get_text().is_empty() && E.name.containsn(search_text)) {
item->select(0);
found = true;
}
@@ -281,7 +281,7 @@ void PropertySelector::_update_search() {
continue;
}
- if (!search_box->get_text().is_empty() && name.findn(search_text) == -1) {
+ if (!search_box->get_text().is_empty() && !name.containsn(search_text)) {
continue;
}
@@ -330,7 +330,7 @@ void PropertySelector::_update_search() {
item->set_metadata(0, name);
item->set_selectable(0, true);
- if (!found && !search_box->get_text().is_empty() && name.findn(search_text) != -1) {
+ if (!found && !search_box->get_text().is_empty() && name.containsn(search_text)) {
item->select(0);
found = true;
}
diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp
index 9fca334e7c..45c437b5f3 100644
--- a/editor/rename_dialog.cpp
+++ b/editor/rename_dialog.cpp
@@ -473,7 +473,7 @@ void RenameDialog::_error_handler(void *p_self, const char *p_func, const char *
String source_file = String::utf8(p_file);
// Only show first error that is related to "regex"
- if (self->has_errors || source_file.find("regex") < 0) {
+ if (self->has_errors || !source_file.contains("regex")) {
return;
}
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index ee2a43bd55..3a1de937e2 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -1297,7 +1297,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
StringName name = node->get_name();
- if (new_unique_names.find(name) != -1 || get_tree()->get_edited_scene_root()->get_node_or_null(UNIQUE_NODE_PREFIX + String(name)) != nullptr) {
+ if (new_unique_names.has(name) || get_tree()->get_edited_scene_root()->get_node_or_null(UNIQUE_NODE_PREFIX + String(name)) != nullptr) {
cant_be_set_unique_names.push_back(name);
} else {
new_unique_nodes.push_back(node);
diff --git a/main/main.cpp b/main/main.cpp
index e30584ebb9..1ba336221f 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -2993,7 +2993,7 @@ Error Main::setup2() {
// Dummy text driver cannot draw any text, making the editor unusable if selected.
continue;
}
- if (!text_driver_options.is_empty() && text_driver_options.find(",") == -1) {
+ if (!text_driver_options.is_empty() && !text_driver_options.contains(",")) {
// Not the first option; add a comma before it as a separator for the property hint.
text_driver_options += ",";
}
diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp
index cec03b7246..a4a3c768e9 100644
--- a/modules/csg/csg.cpp
+++ b/modules/csg/csg.cpp
@@ -852,7 +852,7 @@ int CSGBrushOperation::Build2DFaces::_add_vertex(const Vertex2D &p_vertex) {
}
void CSGBrushOperation::Build2DFaces::_add_vertex_idx_sorted(Vector<int> &r_vertex_indices, int p_new_vertex_index) {
- if (p_new_vertex_index >= 0 && r_vertex_indices.find(p_new_vertex_index) == -1) {
+ if (p_new_vertex_index >= 0 && !r_vertex_indices.has(p_new_vertex_index)) {
ERR_FAIL_COND_MSG(p_new_vertex_index >= vertices.size(), "Invalid vertex index.");
// The first vertex.
diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp
index 819611099e..09defdf8cd 100644
--- a/modules/gdscript/language_server/gdscript_workspace.cpp
+++ b/modules/gdscript/language_server/gdscript_workspace.cpp
@@ -695,7 +695,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocu
} else {
ScriptLanguage::LookupResult ret;
- if (symbol_identifier == "new" && parser->get_lines()[p_doc_pos.position.line].replace(" ", "").replace("\t", "").find("new(") > -1) {
+ if (symbol_identifier == "new" && parser->get_lines()[p_doc_pos.position.line].replace(" ", "").replace("\t", "").contains("new(")) {
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)) {
diff --git a/modules/gdscript/tests/test_lsp.h b/modules/gdscript/tests/test_lsp.h
index 6192272f80..b85c727bc5 100644
--- a/modules/gdscript/tests/test_lsp.h
+++ b/modules/gdscript/tests/test_lsp.h
@@ -227,7 +227,7 @@ Vector<InlineTestData> read_tests(const String &p_path) {
if (InlineTestData::try_parse(lines, i, d)) {
if (!d.name.is_empty()) {
// Safety check: names must be unique.
- if (names.find(d.name) != -1) {
+ if (names.has(d.name)) {
FAIL(vformat("Duplicated name '%s' in '%s'. Names must be unique!", d.name, p_path));
}
names.append(d.name);
diff --git a/modules/gltf/editor/editor_scene_exporter_gltf_settings.cpp b/modules/gltf/editor/editor_scene_exporter_gltf_settings.cpp
index d11300343a..fc184c9342 100644
--- a/modules/gltf/editor/editor_scene_exporter_gltf_settings.cpp
+++ b/modules/gltf/editor/editor_scene_exporter_gltf_settings.cpp
@@ -77,7 +77,7 @@ void EditorSceneExporterGLTFSettings::_get_property_list(List<PropertyInfo> *p_l
for (PropertyInfo prop : _property_list) {
if (prop.name == "lossy_quality") {
String image_format = get("image_format");
- bool is_image_format_lossy = image_format == "JPEG" || image_format.findn("Lossy") != -1;
+ bool is_image_format_lossy = image_format == "JPEG" || image_format.containsn("Lossy");
prop.usage = is_image_format_lossy ? PROPERTY_USAGE_DEFAULT : PROPERTY_USAGE_STORAGE;
}
p_list->push_back(prop);
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index 4c32a29ce0..575702bc54 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -7032,7 +7032,7 @@ void GLTFDocument::_build_parent_hierachy(Ref<GLTFState> p_state) {
Vector<Ref<GLTFDocumentExtension>> GLTFDocument::all_document_extensions;
void GLTFDocument::register_gltf_document_extension(Ref<GLTFDocumentExtension> p_extension, bool p_first_priority) {
- if (all_document_extensions.find(p_extension) == -1) {
+ if (!all_document_extensions.has(p_extension)) {
if (p_first_priority) {
all_document_extensions.insert(0, p_extension);
} else {
diff --git a/modules/gltf/skin_tool.cpp b/modules/gltf/skin_tool.cpp
index 2fb55a5f9e..a344334d93 100644
--- a/modules/gltf/skin_tool.cpp
+++ b/modules/gltf/skin_tool.cpp
@@ -57,9 +57,9 @@ bool SkinTool::_capture_nodes_in_skin(const Vector<Ref<GLTFNode>> &nodes, Ref<GL
if (found_joint) {
// Mark it if we happen to find another skins joint...
- if (current_node->joint && p_skin->joints.find(p_node_index) < 0) {
+ if (current_node->joint && !p_skin->joints.has(p_node_index)) {
p_skin->joints.push_back(p_node_index);
- } else if (p_skin->non_joints.find(p_node_index) < 0) {
+ } else if (!p_skin->non_joints.has(p_node_index)) {
p_skin->non_joints.push_back(p_node_index);
}
}
@@ -79,7 +79,7 @@ void SkinTool::_capture_nodes_for_multirooted_skin(Vector<Ref<GLTFNode>> &r_node
const SkinNodeIndex parent = r_nodes[node_index]->parent;
disjoint_set.insert(node_index);
- if (p_skin->joints.find(parent) >= 0) {
+ if (p_skin->joints.has(parent)) {
disjoint_set.create_union(parent, node_index);
}
}
@@ -109,9 +109,9 @@ void SkinTool::_capture_nodes_for_multirooted_skin(Vector<Ref<GLTFNode>> &r_node
while (r_nodes[current_node]->height > maxHeight) {
SkinNodeIndex parent = r_nodes[current_node]->parent;
- if (r_nodes[parent]->joint && p_skin->joints.find(parent) < 0) {
+ if (r_nodes[parent]->joint && !p_skin->joints.has(parent)) {
p_skin->joints.push_back(parent);
- } else if (p_skin->non_joints.find(parent) < 0) {
+ } else if (!p_skin->non_joints.has(parent)) {
p_skin->non_joints.push_back(parent);
}
@@ -138,9 +138,9 @@ void SkinTool::_capture_nodes_for_multirooted_skin(Vector<Ref<GLTFNode>> &r_node
const SkinNodeIndex current_node = roots[i];
const SkinNodeIndex parent = r_nodes[current_node]->parent;
- if (r_nodes[parent]->joint && p_skin->joints.find(parent) < 0) {
+ if (r_nodes[parent]->joint && !p_skin->joints.has(parent)) {
p_skin->joints.push_back(parent);
- } else if (p_skin->non_joints.find(parent) < 0) {
+ } else if (!p_skin->non_joints.has(parent)) {
p_skin->non_joints.push_back(parent);
}
@@ -166,7 +166,7 @@ Error SkinTool::_expand_skin(Vector<Ref<GLTFNode>> &r_nodes, Ref<GLTFSkin> p_ski
const SkinNodeIndex parent = r_nodes[node_index]->parent;
disjoint_set.insert(node_index);
- if (all_skin_nodes.find(parent) >= 0) {
+ if (all_skin_nodes.has(parent)) {
disjoint_set.create_union(parent, node_index);
}
}
@@ -216,7 +216,7 @@ Error SkinTool::_verify_skin(Vector<Ref<GLTFNode>> &r_nodes, Ref<GLTFSkin> p_ski
const SkinNodeIndex parent = r_nodes[node_index]->parent;
disjoint_set.insert(node_index);
- if (all_skin_nodes.find(parent) >= 0) {
+ if (all_skin_nodes.has(parent)) {
disjoint_set.create_union(parent, node_index);
}
}
@@ -365,7 +365,7 @@ Error SkinTool::_determine_skeletons(
for (int j = 0; j < groups.size() && i != j; ++j) {
const Vector<SkinNodeIndex> &group = groups[j];
- if (group.find(node_i_parent) >= 0) {
+ if (group.has(node_i_parent)) {
const SkinNodeIndex node_j = highest_group_members[j];
skeleton_sets.create_union(node_i, node_j);
}
@@ -393,7 +393,7 @@ Error SkinTool::_determine_skeletons(
// If any of the the skeletons nodes exist in a skin, that skin now maps to the skeleton
for (int i = 0; i < skeleton_nodes.size(); ++i) {
SkinNodeIndex skel_node_i = skeleton_nodes[i];
- if (skin->joints.find(skel_node_i) >= 0 || skin->non_joints.find(skel_node_i) >= 0) {
+ if (skin->joints.has(skel_node_i) || skin->non_joints.has(skel_node_i)) {
skin->skeleton = skel_i;
continue;
}
@@ -454,7 +454,7 @@ Error SkinTool::_reparent_non_joint_skeleton_subtrees(
subtree_set.insert(node_i);
const SkinNodeIndex parent_i = nodes[node_i]->parent;
- if (parent_i >= 0 && p_non_joints.find(parent_i) >= 0 && !nodes[parent_i]->joint) {
+ if (parent_i >= 0 && p_non_joints.has(parent_i) && !nodes[parent_i]->joint) {
subtree_set.create_union(parent_i, node_i);
}
}
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index eb75f05a23..9a76a25639 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -873,7 +873,7 @@ void BindingsGenerator::_append_text_method(StringBuilder &p_output, const TypeI
}
void BindingsGenerator::_append_text_member(StringBuilder &p_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts) {
- if (p_link_target.find("/") >= 0) {
+ if (p_link_target.contains("/")) {
// Properties with '/' (slash) in the name are not declared in C#, so there is nothing to reference.
_append_text_undeclared(p_output, p_link_target);
} else if (!p_target_itype || !p_target_itype->is_object_type) {
@@ -1154,7 +1154,7 @@ void BindingsGenerator::_append_xml_method(StringBuilder &p_xml_output, const Ty
}
void BindingsGenerator::_append_xml_member(StringBuilder &p_xml_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts) {
- if (p_link_target.find("/") >= 0) {
+ if (p_link_target.contains("/")) {
// Properties with '/' (slash) in the name are not declared in C#, so there is nothing to reference.
_append_xml_undeclared(p_xml_output, p_link_target);
} else if (!p_target_itype || !p_target_itype->is_object_type) {
@@ -3654,7 +3654,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
continue;
}
- if (property.name.find("/") >= 0) {
+ if (property.name.contains("/")) {
// Ignore properties with '/' (slash) in the name. These are only meant for use in the inspector.
continue;
}
diff --git a/modules/multiplayer/editor/replication_editor.cpp b/modules/multiplayer/editor/replication_editor.cpp
index 73e53a6a07..08e7ba360a 100644
--- a/modules/multiplayer/editor/replication_editor.cpp
+++ b/modules/multiplayer/editor/replication_editor.cpp
@@ -81,7 +81,7 @@ void ReplicationEditor::_pick_node_select_recursive(TreeItem *p_item, const Stri
NodePath np = p_item->get_metadata(0);
Node *node = get_node(np);
- if (!p_filter.is_empty() && ((String)node->get_name()).findn(p_filter) != -1) {
+ if (!p_filter.is_empty() && ((String)node->get_name()).containsn(p_filter)) {
p_select_candidates.push_back(node);
}
diff --git a/modules/openxr/action_map/openxr_action_map.cpp b/modules/openxr/action_map/openxr_action_map.cpp
index ba0e4f6cdd..5430a41d6d 100644
--- a/modules/openxr/action_map/openxr_action_map.cpp
+++ b/modules/openxr/action_map/openxr_action_map.cpp
@@ -59,7 +59,7 @@ void OpenXRActionMap::set_action_sets(Array p_action_sets) {
for (int i = 0; i < p_action_sets.size(); i++) {
Ref<OpenXRActionSet> action_set = p_action_sets[i];
- if (action_set.is_valid() && action_sets.find(action_set) == -1) {
+ if (action_set.is_valid() && !action_sets.has(action_set)) {
action_sets.push_back(action_set);
}
}
@@ -93,7 +93,7 @@ Ref<OpenXRActionSet> OpenXRActionMap::get_action_set(int p_idx) const {
void OpenXRActionMap::add_action_set(Ref<OpenXRActionSet> p_action_set) {
ERR_FAIL_COND(p_action_set.is_null());
- if (action_sets.find(p_action_set) == -1) {
+ if (!action_sets.has(p_action_set)) {
action_sets.push_back(p_action_set);
emit_changed();
}
@@ -112,7 +112,7 @@ void OpenXRActionMap::set_interaction_profiles(Array p_interaction_profiles) {
for (int i = 0; i < p_interaction_profiles.size(); i++) {
Ref<OpenXRInteractionProfile> interaction_profile = p_interaction_profiles[i];
- if (interaction_profile.is_valid() && interaction_profiles.find(interaction_profile) == -1) {
+ if (interaction_profile.is_valid() && !interaction_profiles.has(interaction_profile)) {
interaction_profiles.push_back(interaction_profile);
}
}
@@ -146,7 +146,7 @@ Ref<OpenXRInteractionProfile> OpenXRActionMap::get_interaction_profile(int p_idx
void OpenXRActionMap::add_interaction_profile(Ref<OpenXRInteractionProfile> p_interaction_profile) {
ERR_FAIL_COND(p_interaction_profile.is_null());
- if (interaction_profiles.find(p_interaction_profile) == -1) {
+ if (!interaction_profiles.has(p_interaction_profile)) {
interaction_profiles.push_back(p_interaction_profile);
emit_changed();
}
diff --git a/modules/openxr/action_map/openxr_action_set.cpp b/modules/openxr/action_map/openxr_action_set.cpp
index 4855f9e4b7..d583af2b2f 100644
--- a/modules/openxr/action_map/openxr_action_set.cpp
+++ b/modules/openxr/action_map/openxr_action_set.cpp
@@ -124,7 +124,7 @@ Ref<OpenXRAction> OpenXRActionSet::get_action(const String p_name) const {
void OpenXRActionSet::add_action(Ref<OpenXRAction> p_action) {
ERR_FAIL_COND(p_action.is_null());
- if (actions.find(p_action) == -1) {
+ if (!actions.has(p_action)) {
if (p_action->action_set && p_action->action_set != this) {
// action should only relate to our action set
p_action->action_set->remove_action(p_action);
diff --git a/modules/openxr/action_map/openxr_interaction_profile.cpp b/modules/openxr/action_map/openxr_interaction_profile.cpp
index 65ee652732..2579697d05 100644
--- a/modules/openxr/action_map/openxr_interaction_profile.cpp
+++ b/modules/openxr/action_map/openxr_interaction_profile.cpp
@@ -172,7 +172,7 @@ Ref<OpenXRIPBinding> OpenXRInteractionProfile::get_binding_for_action(const Ref<
void OpenXRInteractionProfile::add_binding(Ref<OpenXRIPBinding> p_binding) {
ERR_FAIL_COND(p_binding.is_null());
- if (bindings.find(p_binding) == -1) {
+ if (!bindings.has(p_binding)) {
ERR_FAIL_COND_MSG(get_binding_for_action(p_binding->get_action()).is_valid(), "There is already a binding for this action in this interaction profile");
bindings.push_back(p_binding);
diff --git a/modules/openxr/openxr_interface.cpp b/modules/openxr/openxr_interface.cpp
index b92d1edb90..fbbc61a91c 100644
--- a/modules/openxr/openxr_interface.cpp
+++ b/modules/openxr/openxr_interface.cpp
@@ -391,7 +391,7 @@ OpenXRInterface::Action *OpenXRInterface::create_action(ActionSet *p_action_set,
// we link our actions back to our trackers so we know which actions to check when we're processing our trackers
for (int i = 0; i < p_trackers.size(); i++) {
- if (p_trackers[i]->actions.find(action) == -1) {
+ if (!p_trackers[i]->actions.has(action)) {
p_trackers[i]->actions.push_back(action);
}
}
diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp
index 4a1037431a..9f34a6ca6a 100644
--- a/modules/regex/regex.cpp
+++ b/modules/regex/regex.cpp
@@ -370,7 +370,7 @@ PackedStringArray RegEx::get_names() const {
for (uint32_t i = 0; i < count; i++) {
String name = &table[i * entry_size + 1];
- if (result.find(name) < 0) {
+ if (!result.has(name)) {
result.append(name);
}
}
diff --git a/modules/text_server_adv/text_server_adv.h b/modules/text_server_adv/text_server_adv.h
index 7e29f984c1..8895a83089 100644
--- a/modules/text_server_adv/text_server_adv.h
+++ b/modules/text_server_adv/text_server_adv.h
@@ -389,54 +389,54 @@ class TextServerAdvanced : public TextServerExtension {
_FORCE_INLINE_ bool _get_tag_hidden(int64_t p_tag) const;
_FORCE_INLINE_ int _font_get_weight_by_name(const String &p_sty_name) const {
String sty_name = p_sty_name.replace(" ", "").replace("-", "");
- if (sty_name.find("thin") >= 0 || sty_name.find("hairline") >= 0) {
+ if (sty_name.contains("thin") || sty_name.contains("hairline")) {
return 100;
- } else if (sty_name.find("extralight") >= 0 || sty_name.find("ultralight") >= 0) {
+ } else if (sty_name.contains("extralight") || sty_name.contains("ultralight")) {
return 200;
- } else if (sty_name.find("light") >= 0) {
+ } else if (sty_name.contains("light")) {
return 300;
- } else if (sty_name.find("semilight") >= 0) {
+ } else if (sty_name.contains("semilight")) {
return 350;
- } else if (sty_name.find("regular") >= 0) {
+ } else if (sty_name.contains("regular")) {
return 400;
- } else if (sty_name.find("medium") >= 0) {
+ } else if (sty_name.contains("medium")) {
return 500;
- } else if (sty_name.find("semibold") >= 0 || sty_name.find("demibold") >= 0) {
+ } else if (sty_name.contains("semibold") || sty_name.contains("demibold")) {
return 600;
- } else if (sty_name.find("bold") >= 0) {
+ } else if (sty_name.contains("bold")) {
return 700;
- } else if (sty_name.find("extrabold") >= 0 || sty_name.find("ultrabold") >= 0) {
+ } else if (sty_name.contains("extrabold") || sty_name.contains("ultrabold")) {
return 800;
- } else if (sty_name.find("black") >= 0 || sty_name.find("heavy") >= 0) {
+ } else if (sty_name.contains("black") || sty_name.contains("heavy")) {
return 900;
- } else if (sty_name.find("extrablack") >= 0 || sty_name.find("ultrablack") >= 0) {
+ } else if (sty_name.contains("extrablack") || sty_name.contains("ultrablack")) {
return 950;
}
return 400;
}
_FORCE_INLINE_ int _font_get_stretch_by_name(const String &p_sty_name) const {
String sty_name = p_sty_name.replace(" ", "").replace("-", "");
- if (sty_name.find("ultracondensed") >= 0) {
+ if (sty_name.contains("ultracondensed")) {
return 50;
- } else if (sty_name.find("extracondensed") >= 0) {
+ } else if (sty_name.contains("extracondensed")) {
return 63;
- } else if (sty_name.find("condensed") >= 0) {
+ } else if (sty_name.contains("condensed")) {
return 75;
- } else if (sty_name.find("semicondensed") >= 0) {
+ } else if (sty_name.contains("semicondensed")) {
return 87;
- } else if (sty_name.find("semiexpanded") >= 0) {
+ } else if (sty_name.contains("semiexpanded")) {
return 113;
- } else if (sty_name.find("expanded") >= 0) {
+ } else if (sty_name.contains("expanded")) {
return 125;
- } else if (sty_name.find("extraexpanded") >= 0) {
+ } else if (sty_name.contains("extraexpanded")) {
return 150;
- } else if (sty_name.find("ultraexpanded") >= 0) {
+ } else if (sty_name.contains("ultraexpanded")) {
return 200;
}
return 100;
}
_FORCE_INLINE_ bool _is_ital_style(const String &p_sty_name) const {
- return (p_sty_name.find("italic") >= 0) || (p_sty_name.find("oblique") >= 0);
+ return p_sty_name.contains("italic") || p_sty_name.contains("oblique");
}
// Shaped text cache data.
diff --git a/modules/text_server_fb/text_server_fb.h b/modules/text_server_fb/text_server_fb.h
index 31370c7da7..9ad20c7b26 100644
--- a/modules/text_server_fb/text_server_fb.h
+++ b/modules/text_server_fb/text_server_fb.h
@@ -335,54 +335,54 @@ class TextServerFallback : public TextServerExtension {
_FORCE_INLINE_ int _font_get_weight_by_name(const String &p_sty_name) const {
String sty_name = p_sty_name.replace(" ", "").replace("-", "");
- if (sty_name.find("thin") >= 0 || sty_name.find("hairline") >= 0) {
+ if (sty_name.contains("thin") || sty_name.contains("hairline")) {
return 100;
- } else if (sty_name.find("extralight") >= 0 || sty_name.find("ultralight") >= 0) {
+ } else if (sty_name.contains("extralight") || sty_name.contains("ultralight")) {
return 200;
- } else if (sty_name.find("light") >= 0) {
+ } else if (sty_name.contains("light")) {
return 300;
- } else if (sty_name.find("semilight") >= 0) {
+ } else if (sty_name.contains("semilight")) {
return 350;
- } else if (sty_name.find("regular") >= 0) {
+ } else if (sty_name.contains("regular")) {
return 400;
- } else if (sty_name.find("medium") >= 0) {
+ } else if (sty_name.contains("medium")) {
return 500;
- } else if (sty_name.find("semibold") >= 0 || sty_name.find("demibold") >= 0) {
+ } else if (sty_name.contains("semibold") || sty_name.contains("demibold")) {
return 600;
- } else if (sty_name.find("bold") >= 0) {
+ } else if (sty_name.contains("bold")) {
return 700;
- } else if (sty_name.find("extrabold") >= 0 || sty_name.find("ultrabold") >= 0) {
+ } else if (sty_name.contains("extrabold") || sty_name.contains("ultrabold")) {
return 800;
- } else if (sty_name.find("black") >= 0 || sty_name.find("heavy") >= 0) {
+ } else if (sty_name.contains("black") || sty_name.contains("heavy")) {
return 900;
- } else if (sty_name.find("extrablack") >= 0 || sty_name.find("ultrablack") >= 0) {
+ } else if (sty_name.contains("extrablack") || sty_name.contains("ultrablack")) {
return 950;
}
return 400;
}
_FORCE_INLINE_ int _font_get_stretch_by_name(const String &p_sty_name) const {
String sty_name = p_sty_name.replace(" ", "").replace("-", "");
- if (sty_name.find("ultracondensed") >= 0) {
+ if (sty_name.contains("ultracondensed")) {
return 50;
- } else if (sty_name.find("extracondensed") >= 0) {
+ } else if (sty_name.contains("extracondensed")) {
return 63;
- } else if (sty_name.find("condensed") >= 0) {
+ } else if (sty_name.contains("condensed")) {
return 75;
- } else if (sty_name.find("semicondensed") >= 0) {
+ } else if (sty_name.contains("semicondensed")) {
return 87;
- } else if (sty_name.find("semiexpanded") >= 0) {
+ } else if (sty_name.contains("semiexpanded")) {
return 113;
- } else if (sty_name.find("expanded") >= 0) {
+ } else if (sty_name.contains("expanded")) {
return 125;
- } else if (sty_name.find("extraexpanded") >= 0) {
+ } else if (sty_name.contains("extraexpanded")) {
return 150;
- } else if (sty_name.find("ultraexpanded") >= 0) {
+ } else if (sty_name.contains("ultraexpanded")) {
return 200;
}
return 100;
}
_FORCE_INLINE_ bool _is_ital_style(const String &p_sty_name) const {
- return (p_sty_name.find("italic") >= 0) || (p_sty_name.find("oblique") >= 0);
+ return p_sty_name.contains("italic") || p_sty_name.contains("oblique");
}
// Shaped text cache data.
diff --git a/modules/upnp/upnp.cpp b/modules/upnp/upnp.cpp
index 95453c1ecd..70f0ea346b 100644
--- a/modules/upnp/upnp.cpp
+++ b/modules/upnp/upnp.cpp
@@ -37,10 +37,10 @@
bool UPNP::is_common_device(const String &dev) const {
return dev.is_empty() ||
- dev.find("InternetGatewayDevice") >= 0 ||
- dev.find("WANIPConnection") >= 0 ||
- dev.find("WANPPPConnection") >= 0 ||
- dev.find("rootdevice") >= 0;
+ dev.contains("InternetGatewayDevice") ||
+ dev.contains("WANIPConnection") ||
+ dev.contains("WANPPPConnection") ||
+ dev.contains("rootdevice");
}
int UPNP::discover(int timeout, int ttl, const String &device_filter) {
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp
index 30d57cade5..eebef3f969 100644
--- a/platform/android/export/export_plugin.cpp
+++ b/platform/android/export/export_plugin.cpp
@@ -816,11 +816,11 @@ Error EditorExportPlatformAndroid::copy_gradle_so(void *p_userdata, const Shared
}
bool EditorExportPlatformAndroid::_has_read_write_storage_permission(const Vector<String> &p_permissions) {
- return p_permissions.find("android.permission.READ_EXTERNAL_STORAGE") != -1 || p_permissions.find("android.permission.WRITE_EXTERNAL_STORAGE") != -1;
+ return p_permissions.has("android.permission.READ_EXTERNAL_STORAGE") || p_permissions.has("android.permission.WRITE_EXTERNAL_STORAGE");
}
bool EditorExportPlatformAndroid::_has_manage_external_storage_permission(const Vector<String> &p_permissions) {
- return p_permissions.find("android.permission.MANAGE_EXTERNAL_STORAGE") != -1;
+ return p_permissions.has("android.permission.MANAGE_EXTERNAL_STORAGE");
}
bool EditorExportPlatformAndroid::_uses_vulkan() {
@@ -924,7 +924,7 @@ void EditorExportPlatformAndroid::_get_permissions(const Ref<EditorExportPreset>
}
}
if (p_give_internet) {
- if (r_permissions.find("android.permission.INTERNET") == -1) {
+ if (!r_permissions.has("android.permission.INTERNET")) {
r_permissions.push_back("android.permission.INTERNET");
}
}
@@ -2716,7 +2716,7 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<Edit
}
String package_name = p_preset->get("package/unique_name");
- if (package_name.find("$genname") >= 0 && !is_project_name_valid()) {
+ if (package_name.contains("$genname") && !is_project_name_valid()) {
// Warning only, so don't override `valid`.
err += vformat(TTR("The project name does not meet the requirement for the package name format and will be updated to \"%s\". Please explicitly specify the package name if needed."), get_valid_basename());
err += "\n";
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index c60125c34e..764959eef3 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -586,11 +586,11 @@ Vector<String> OS_Android::get_system_font_path_for_text(const String &p_font_na
}
if (score > best_score) {
best_score = score;
- if (ret.find(root.path_join(E->get().filename)) < 0) {
+ if (!ret.has(root.path_join(E->get().filename))) {
ret.insert(0, root.path_join(E->get().filename));
}
} else if (score == best_score || E->get().script.is_empty()) {
- if (ret.find(root.path_join(E->get().filename)) < 0) {
+ if (!ret.has(root.path_join(E->get().filename))) {
ret.push_back(root.path_join(E->get().filename));
}
}
diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp
index c35c72d093..6a452f08fa 100644
--- a/platform/ios/export/export_plugin.cpp
+++ b/platform/ios/export/export_plugin.cpp
@@ -400,65 +400,65 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
str.parse_utf8((const char *)pfile.ptr(), pfile.size());
Vector<String> lines = str.split("\n");
for (int i = 0; i < lines.size(); i++) {
- if (lines[i].find("$binary") != -1) {
+ if (lines[i].contains("$binary")) {
strnew += lines[i].replace("$binary", p_config.binary_name) + "\n";
- } else if (lines[i].find("$modules_buildfile") != -1) {
+ } else if (lines[i].contains("$modules_buildfile")) {
strnew += lines[i].replace("$modules_buildfile", p_config.modules_buildfile) + "\n";
- } else if (lines[i].find("$modules_fileref") != -1) {
+ } else if (lines[i].contains("$modules_fileref")) {
strnew += lines[i].replace("$modules_fileref", p_config.modules_fileref) + "\n";
- } else if (lines[i].find("$modules_buildphase") != -1) {
+ } else if (lines[i].contains("$modules_buildphase")) {
strnew += lines[i].replace("$modules_buildphase", p_config.modules_buildphase) + "\n";
- } else if (lines[i].find("$modules_buildgrp") != -1) {
+ } else if (lines[i].contains("$modules_buildgrp")) {
strnew += lines[i].replace("$modules_buildgrp", p_config.modules_buildgrp) + "\n";
- } else if (lines[i].find("$name") != -1) {
+ } else if (lines[i].contains("$name")) {
strnew += lines[i].replace("$name", p_config.pkg_name) + "\n";
- } else if (lines[i].find("$bundle_identifier") != -1) {
+ } else if (lines[i].contains("$bundle_identifier")) {
strnew += lines[i].replace("$bundle_identifier", p_preset->get("application/bundle_identifier")) + "\n";
- } else if (lines[i].find("$short_version") != -1) {
+ } else if (lines[i].contains("$short_version")) {
strnew += lines[i].replace("$short_version", p_preset->get_version("application/short_version")) + "\n";
- } else if (lines[i].find("$version") != -1) {
+ } else if (lines[i].contains("$version")) {
strnew += lines[i].replace("$version", p_preset->get_version("application/version")) + "\n";
- } else if (lines[i].find("$min_version") != -1) {
+ } else if (lines[i].contains("$min_version")) {
strnew += lines[i].replace("$min_version", p_preset->get("application/min_ios_version")) + "\n";
- } else if (lines[i].find("$signature") != -1) {
+ } else if (lines[i].contains("$signature")) {
strnew += lines[i].replace("$signature", p_preset->get("application/signature")) + "\n";
- } else if (lines[i].find("$team_id") != -1) {
+ } else if (lines[i].contains("$team_id")) {
strnew += lines[i].replace("$team_id", p_preset->get("application/app_store_team_id")) + "\n";
- } else if (lines[i].find("$default_build_config") != -1) {
+ } else if (lines[i].contains("$default_build_config")) {
strnew += lines[i].replace("$default_build_config", p_debug ? "Debug" : "Release") + "\n";
- } else if (lines[i].find("$export_method") != -1) {
+ } else if (lines[i].contains("$export_method")) {
int export_method = p_preset->get(p_debug ? "application/export_method_debug" : "application/export_method_release");
strnew += lines[i].replace("$export_method", export_method_string[export_method]) + "\n";
- } else if (lines[i].find("$provisioning_profile_uuid_release") != -1) {
+ } else if (lines[i].contains("$provisioning_profile_uuid_release")) {
strnew += lines[i].replace("$provisioning_profile_uuid_release", p_preset->get_or_env("application/provisioning_profile_uuid_release", ENV_IOS_PROFILE_UUID_RELEASE)) + "\n";
- } else if (lines[i].find("$provisioning_profile_uuid_debug") != -1) {
+ } else if (lines[i].contains("$provisioning_profile_uuid_debug")) {
strnew += lines[i].replace("$provisioning_profile_uuid_debug", p_preset->get_or_env("application/provisioning_profile_uuid_debug", ENV_IOS_PROFILE_UUID_DEBUG)) + "\n";
- } else if (lines[i].find("$code_sign_style_debug") != -1) {
+ } else if (lines[i].contains("$code_sign_style_debug")) {
if (dbg_manual) {
strnew += lines[i].replace("$code_sign_style_debug", "Manual") + "\n";
} else {
strnew += lines[i].replace("$code_sign_style_debug", "Automatic") + "\n";
}
- } else if (lines[i].find("$code_sign_style_release") != -1) {
+ } else if (lines[i].contains("$code_sign_style_release")) {
if (rel_manual) {
strnew += lines[i].replace("$code_sign_style_release", "Manual") + "\n";
} else {
strnew += lines[i].replace("$code_sign_style_release", "Automatic") + "\n";
}
- } else if (lines[i].find("$provisioning_profile_uuid") != -1) {
+ } else if (lines[i].contains("$provisioning_profile_uuid")) {
String uuid = p_debug ? p_preset->get_or_env("application/provisioning_profile_uuid_debug", ENV_IOS_PROFILE_UUID_DEBUG) : p_preset->get_or_env("application/provisioning_profile_uuid_release", ENV_IOS_PROFILE_UUID_RELEASE);
strnew += lines[i].replace("$provisioning_profile_uuid", uuid) + "\n";
- } else if (lines[i].find("$code_sign_identity_debug") != -1) {
+ } else if (lines[i].contains("$code_sign_identity_debug")) {
strnew += lines[i].replace("$code_sign_identity_debug", dbg_sign_id) + "\n";
- } else if (lines[i].find("$code_sign_identity_release") != -1) {
+ } else if (lines[i].contains("$code_sign_identity_release")) {
strnew += lines[i].replace("$code_sign_identity_release", rel_sign_id) + "\n";
- } else if (lines[i].find("$additional_plist_content") != -1) {
+ } else if (lines[i].contains("$additional_plist_content")) {
strnew += lines[i].replace("$additional_plist_content", p_config.plist_content) + "\n";
- } else if (lines[i].find("$godot_archs") != -1) {
+ } else if (lines[i].contains("$godot_archs")) {
strnew += lines[i].replace("$godot_archs", p_config.architectures) + "\n";
- } else if (lines[i].find("$linker_flags") != -1) {
+ } else if (lines[i].contains("$linker_flags")) {
strnew += lines[i].replace("$linker_flags", p_config.linker_flags) + "\n";
- } else if (lines[i].find("$targeted_device_family") != -1) {
+ } else if (lines[i].contains("$targeted_device_family")) {
String xcode_value;
switch ((int)p_preset->get("application/targeted_device_family")) {
case 0: // iPhone
@@ -472,16 +472,16 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
break;
}
strnew += lines[i].replace("$targeted_device_family", xcode_value) + "\n";
- } else if (lines[i].find("$cpp_code") != -1) {
+ } else if (lines[i].contains("$cpp_code")) {
strnew += lines[i].replace("$cpp_code", p_config.cpp_code) + "\n";
- } else if (lines[i].find("$docs_in_place") != -1) {
+ } else if (lines[i].contains("$docs_in_place")) {
strnew += lines[i].replace("$docs_in_place", ((bool)p_preset->get("user_data/accessible_from_files_app")) ? "<true/>" : "<false/>") + "\n";
- } else if (lines[i].find("$docs_sharing") != -1) {
+ } else if (lines[i].contains("$docs_sharing")) {
strnew += lines[i].replace("$docs_sharing", ((bool)p_preset->get("user_data/accessible_from_itunes_sharing")) ? "<true/>" : "<false/>") + "\n";
- } else if (lines[i].find("$entitlements_push_notifications") != -1) {
+ } else if (lines[i].contains("$entitlements_push_notifications")) {
bool is_on = p_preset->get("capabilities/push_notifications");
strnew += lines[i].replace("$entitlements_push_notifications", is_on ? "<key>aps-environment</key><string>development</string>" : "") + "\n";
- } else if (lines[i].find("$required_device_capabilities") != -1) {
+ } else if (lines[i].contains("$required_device_capabilities")) {
String capabilities;
// I've removed armv7 as we can run on 64bit only devices
@@ -503,7 +503,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
}
strnew += lines[i].replace("$required_device_capabilities", capabilities);
- } else if (lines[i].find("$interface_orientations") != -1) {
+ } else if (lines[i].contains("$interface_orientations")) {
String orientations;
const DisplayServer::ScreenOrientation screen_orientation =
DisplayServer::ScreenOrientation(int(GLOBAL_GET("display/window/handheld/orientation")));
@@ -541,35 +541,35 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
}
strnew += lines[i].replace("$interface_orientations", orientations);
- } else if (lines[i].find("$camera_usage_description") != -1) {
+ } else if (lines[i].contains("$camera_usage_description")) {
String description = p_preset->get("privacy/camera_usage_description");
strnew += lines[i].replace("$camera_usage_description", description) + "\n";
- } else if (lines[i].find("$microphone_usage_description") != -1) {
+ } else if (lines[i].contains("$microphone_usage_description")) {
String description = p_preset->get("privacy/microphone_usage_description");
strnew += lines[i].replace("$microphone_usage_description", description) + "\n";
- } else if (lines[i].find("$photolibrary_usage_description") != -1) {
+ } else if (lines[i].contains("$photolibrary_usage_description")) {
String description = p_preset->get("privacy/photolibrary_usage_description");
strnew += lines[i].replace("$photolibrary_usage_description", description) + "\n";
- } else if (lines[i].find("$plist_launch_screen_name") != -1) {
+ } else if (lines[i].contains("$plist_launch_screen_name")) {
String value = "<key>UILaunchStoryboardName</key>\n<string>Launch Screen</string>";
strnew += lines[i].replace("$plist_launch_screen_name", value) + "\n";
- } else if (lines[i].find("$pbx_launch_screen_file_reference") != -1) {
+ } else if (lines[i].contains("$pbx_launch_screen_file_reference")) {
String value = "90DD2D9D24B36E8000717FE1 = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = \"Launch Screen.storyboard\"; sourceTree = \"<group>\"; };";
strnew += lines[i].replace("$pbx_launch_screen_file_reference", value) + "\n";
- } else if (lines[i].find("$pbx_launch_screen_copy_files") != -1) {
+ } else if (lines[i].contains("$pbx_launch_screen_copy_files")) {
String value = "90DD2D9D24B36E8000717FE1 /* Launch Screen.storyboard */,";
strnew += lines[i].replace("$pbx_launch_screen_copy_files", value) + "\n";
- } else if (lines[i].find("$pbx_launch_screen_build_phase") != -1) {
+ } else if (lines[i].contains("$pbx_launch_screen_build_phase")) {
String value = "90DD2D9E24B36E8000717FE1 /* Launch Screen.storyboard in Resources */,";
strnew += lines[i].replace("$pbx_launch_screen_build_phase", value) + "\n";
- } else if (lines[i].find("$pbx_launch_screen_build_reference") != -1) {
+ } else if (lines[i].contains("$pbx_launch_screen_build_reference")) {
String value = "90DD2D9E24B36E8000717FE1 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 90DD2D9D24B36E8000717FE1 /* Launch Screen.storyboard */; };";
strnew += lines[i].replace("$pbx_launch_screen_build_reference", value) + "\n";
#ifndef DISABLE_DEPRECATED
- } else if (lines[i].find("$pbx_launch_image_usage_setting") != -1) {
+ } else if (lines[i].contains("$pbx_launch_image_usage_setting")) {
strnew += lines[i].replace("$pbx_launch_image_usage_setting", "") + "\n";
#endif
- } else if (lines[i].find("$launch_screen_image_mode") != -1) {
+ } else if (lines[i].contains("$launch_screen_image_mode")) {
int image_scale_mode = p_preset->get("storyboard/image_scale_mode");
String value;
@@ -586,7 +586,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
}
strnew += lines[i].replace("$launch_screen_image_mode", value) + "\n";
- } else if (lines[i].find("$launch_screen_background_color") != -1) {
+ } else if (lines[i].contains("$launch_screen_background_color")) {
bool use_custom = p_preset->get("storyboard/use_custom_bg_color");
Color color = use_custom ? p_preset->get("storyboard/custom_bg_color") : GLOBAL_GET("application/boot_splash/bg_color");
const String value_format = "red=\"$red\" green=\"$green\" blue=\"$blue\" alpha=\"$alpha\"";
@@ -599,7 +599,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
String value = value_format.format(value_dictionary, "$_");
strnew += lines[i].replace("$launch_screen_background_color", value) + "\n";
- } else if (lines[i].find("$pbx_locale_file_reference") != -1) {
+ } else if (lines[i].contains("$pbx_locale_file_reference")) {
String locale_files;
Vector<String> translations = GLOBAL_GET("internationalization/locale/translations");
if (translations.size() > 0) {
@@ -618,7 +618,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
}
}
strnew += lines[i].replace("$pbx_locale_file_reference", locale_files);
- } else if (lines[i].find("$pbx_locale_build_reference") != -1) {
+ } else if (lines[i].contains("$pbx_locale_build_reference")) {
String locale_files;
Vector<String> translations = GLOBAL_GET("internationalization/locale/translations");
if (translations.size() > 0) {
@@ -637,10 +637,10 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
}
}
strnew += lines[i].replace("$pbx_locale_build_reference", locale_files);
- } else if (lines[i].find("$swift_runtime_migration") != -1) {
+ } else if (lines[i].contains("$swift_runtime_migration")) {
String value = !p_config.use_swift_runtime ? "" : "LastSwiftMigration = 1250;";
strnew += lines[i].replace("$swift_runtime_migration", value) + "\n";
- } else if (lines[i].find("$swift_runtime_build_settings") != -1) {
+ } else if (lines[i].contains("$swift_runtime_build_settings")) {
String value = !p_config.use_swift_runtime ? "" : R"(
CLANG_ENABLE_MODULES = YES;
SWIFT_OBJC_BRIDGING_HEADER = "$binary/dummy.h";
@@ -648,25 +648,25 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
)";
value = value.replace("$binary", p_config.binary_name);
strnew += lines[i].replace("$swift_runtime_build_settings", value) + "\n";
- } else if (lines[i].find("$swift_runtime_fileref") != -1) {
+ } else if (lines[i].contains("$swift_runtime_fileref")) {
String value = !p_config.use_swift_runtime ? "" : R"(
90B4C2AA2680BC560039117A /* dummy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "dummy.h"; sourceTree = "<group>"; };
90B4C2B52680C7E90039117A /* dummy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "dummy.swift"; sourceTree = "<group>"; };
)";
strnew += lines[i].replace("$swift_runtime_fileref", value) + "\n";
- } else if (lines[i].find("$swift_runtime_binary_files") != -1) {
+ } else if (lines[i].contains("$swift_runtime_binary_files")) {
String value = !p_config.use_swift_runtime ? "" : R"(
90B4C2AA2680BC560039117A /* dummy.h */,
90B4C2B52680C7E90039117A /* dummy.swift */,
)";
strnew += lines[i].replace("$swift_runtime_binary_files", value) + "\n";
- } else if (lines[i].find("$swift_runtime_buildfile") != -1) {
+ } else if (lines[i].contains("$swift_runtime_buildfile")) {
String value = !p_config.use_swift_runtime ? "" : "90B4C2B62680C7E90039117A /* dummy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90B4C2B52680C7E90039117A /* dummy.swift */; };";
strnew += lines[i].replace("$swift_runtime_buildfile", value) + "\n";
- } else if (lines[i].find("$swift_runtime_build_phase") != -1) {
+ } else if (lines[i].contains("$swift_runtime_build_phase")) {
String value = !p_config.use_swift_runtime ? "" : "90B4C2B62680C7E90039117A /* dummy.swift */,";
strnew += lines[i].replace("$swift_runtime_build_phase", value) + "\n";
- } else if (lines[i].find("$priv_collection") != -1) {
+ } else if (lines[i].contains("$priv_collection")) {
bool section_opened = false;
for (uint64_t j = 0; j < sizeof(data_collect_type_info) / sizeof(data_collect_type_info[0]); ++j) {
bool data_collected = p_preset->get(vformat("privacy/collected_data/%s/collected", data_collect_type_info[j].prop_name));
@@ -710,7 +710,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
if (section_opened) {
strnew += "\t</array>\n";
}
- } else if (lines[i].find("$priv_tracking") != -1) {
+ } else if (lines[i].contains("$priv_tracking")) {
bool tracking = p_preset->get("privacy/tracking_enabled");
strnew += "\t<key>NSPrivacyTracking</key>\n";
if (tracking) {
@@ -727,7 +727,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
}
strnew += "\t</array>\n";
}
- } else if (lines[i].find("$priv_api_types") != -1) {
+ } else if (lines[i].contains("$priv_api_types")) {
strnew += "\t<array>\n";
for (uint64_t j = 0; j < sizeof(api_info) / sizeof(api_info[0]); ++j) {
int api_access = p_preset->get(vformat("privacy/%s_access_reasons", api_info[j].prop_name));
diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp
index 827c567785..6e546c4531 100644
--- a/platform/linuxbsd/joypad_linux.cpp
+++ b/platform/linuxbsd/joypad_linux.cpp
@@ -175,7 +175,7 @@ void JoypadLinux::enumerate_joypads(udev *p_udev) {
if (devnode) {
String devnode_str = devnode;
- if (devnode_str.find(ignore_str) == -1) {
+ if (!devnode_str.contains(ignore_str)) {
open_joypad(devnode);
}
}
@@ -214,7 +214,7 @@ void JoypadLinux::monitor_joypads(udev *p_udev) {
const char *devnode = udev_device_get_devnode(dev);
if (devnode) {
String devnode_str = devnode;
- if (devnode_str.find(ignore_str) == -1) {
+ if (!devnode_str.contains(ignore_str)) {
if (action == "add") {
open_joypad(devnode);
} else if (String(action) == "remove") {
@@ -244,7 +244,7 @@ void JoypadLinux::monitor_joypads() {
continue;
}
sprintf(fname, "/dev/input/%.*s", 16, current->d_name);
- if (attached_devices.find(fname) == -1) {
+ if (!attached_devices.has(fname)) {
open_joypad(fname);
}
}
diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp
index 68b4cd7f5a..6355562feb 100644
--- a/platform/linuxbsd/os_linuxbsd.cpp
+++ b/platform/linuxbsd/os_linuxbsd.cpp
@@ -184,7 +184,7 @@ String OS_LinuxBSD::get_processor_name() const {
while (!f->eof_reached()) {
const String line = f->get_line();
- if (line.find("model name") != -1) {
+ if (line.contains("model name")) {
return line.split(":")[1].strip_edges();
}
}
@@ -269,7 +269,7 @@ String OS_LinuxBSD::get_systemd_os_release_info_value(const String &key) const {
if (f.is_valid()) {
while (!f->eof_reached()) {
const String line = f->get_line();
- if (line.find(key) != -1) {
+ if (line.contains(key)) {
String value = line.split("=")[1].strip_edges();
value = value.trim_prefix("\"");
return value.trim_suffix("\"");
diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp
index 5f52d33318..96d64ef209 100644
--- a/platform/macos/export/export_plugin.cpp
+++ b/platform/macos/export/export_plugin.cpp
@@ -650,42 +650,42 @@ void EditorExportPlatformMacOS::_fix_plist(const Ref<EditorExportPreset> &p_pres
str.parse_utf8((const char *)plist.ptr(), plist.size());
Vector<String> lines = str.split("\n");
for (int i = 0; i < lines.size(); i++) {
- if (lines[i].find("$binary") != -1) {
+ if (lines[i].contains("$binary")) {
strnew += lines[i].replace("$binary", p_binary) + "\n";
- } else if (lines[i].find("$name") != -1) {
+ } else if (lines[i].contains("$name")) {
strnew += lines[i].replace("$name", GLOBAL_GET("application/config/name")) + "\n";
- } else if (lines[i].find("$bundle_identifier") != -1) {
+ } else if (lines[i].contains("$bundle_identifier")) {
strnew += lines[i].replace("$bundle_identifier", p_preset->get("application/bundle_identifier")) + "\n";
- } else if (lines[i].find("$short_version") != -1) {
+ } else if (lines[i].contains("$short_version")) {
strnew += lines[i].replace("$short_version", p_preset->get_version("application/short_version")) + "\n";
- } else if (lines[i].find("$version") != -1) {
+ } else if (lines[i].contains("$version")) {
strnew += lines[i].replace("$version", p_preset->get_version("application/version")) + "\n";
- } else if (lines[i].find("$signature") != -1) {
+ } else if (lines[i].contains("$signature")) {
strnew += lines[i].replace("$signature", p_preset->get("application/signature")) + "\n";
- } else if (lines[i].find("$app_category") != -1) {
+ } else if (lines[i].contains("$app_category")) {
String cat = p_preset->get("application/app_category");
strnew += lines[i].replace("$app_category", cat.to_lower()) + "\n";
- } else if (lines[i].find("$copyright") != -1) {
+ } else if (lines[i].contains("$copyright")) {
strnew += lines[i].replace("$copyright", p_preset->get("application/copyright")) + "\n";
- } else if (lines[i].find("$min_version") != -1) {
+ } else if (lines[i].contains("$min_version")) {
strnew += lines[i].replace("$min_version", p_preset->get("application/min_macos_version")) + "\n";
- } else if (lines[i].find("$highres") != -1) {
+ } else if (lines[i].contains("$highres")) {
strnew += lines[i].replace("$highres", p_preset->get("display/high_res") ? "\t<true/>" : "\t<false/>") + "\n";
- } else if (lines[i].find("$additional_plist_content") != -1) {
+ } else if (lines[i].contains("$additional_plist_content")) {
strnew += lines[i].replace("$additional_plist_content", p_preset->get("application/additional_plist_content")) + "\n";
- } else if (lines[i].find("$platfbuild") != -1) {
+ } else if (lines[i].contains("$platfbuild")) {
strnew += lines[i].replace("$platfbuild", p_preset->get("xcode/platform_build")) + "\n";
- } else if (lines[i].find("$sdkver") != -1) {
+ } else if (lines[i].contains("$sdkver")) {
strnew += lines[i].replace("$sdkver", p_preset->get("xcode/sdk_version")) + "\n";
- } else if (lines[i].find("$sdkname") != -1) {
+ } else if (lines[i].contains("$sdkname")) {
strnew += lines[i].replace("$sdkname", p_preset->get("xcode/sdk_name")) + "\n";
- } else if (lines[i].find("$sdkbuild") != -1) {
+ } else if (lines[i].contains("$sdkbuild")) {
strnew += lines[i].replace("$sdkbuild", p_preset->get("xcode/sdk_build")) + "\n";
- } else if (lines[i].find("$xcodever") != -1) {
+ } else if (lines[i].contains("$xcodever")) {
strnew += lines[i].replace("$xcodever", p_preset->get("xcode/xcode_version")) + "\n";
- } else if (lines[i].find("$xcodebuild") != -1) {
+ } else if (lines[i].contains("$xcodebuild")) {
strnew += lines[i].replace("$xcodebuild", p_preset->get("xcode/xcode_build")) + "\n";
- } else if (lines[i].find("$usage_descriptions") != -1) {
+ } else if (lines[i].contains("$usage_descriptions")) {
String descriptions;
if (!((String)p_preset->get("privacy/microphone_usage_description")).is_empty()) {
descriptions += "\t<key>NSMicrophoneUsageDescription</key>\n";
@@ -1081,7 +1081,7 @@ Error EditorExportPlatformMacOS::_code_sign_directory(const Ref<EditorExportPres
continue;
}
- if (extensions_to_sign.find(current_file.get_extension()) > -1) {
+ if (extensions_to_sign.has(current_file.get_extension())) {
int ftype = MachO::get_filetype(current_file_path);
Error code_sign_error{ _code_sign(p_preset, current_file_path, (ftype == 2 || ftype == 5) ? p_helper_ent_path : p_ent_path, false, (ftype == 2 || ftype == 5)) };
if (code_sign_error != OK) {
@@ -1202,7 +1202,7 @@ Error EditorExportPlatformMacOS::_copy_and_sign_files(Ref<DirAccess> &dir_access
// If it is a directory, find and sign all dynamic libraries.
err = _code_sign_directory(p_preset, p_in_app_path, p_ent_path, p_helper_ent_path, p_should_error_on_non_code_sign);
} else {
- if (extensions_to_sign.find(p_in_app_path.get_extension()) > -1) {
+ if (extensions_to_sign.has(p_in_app_path.get_extension())) {
int ftype = MachO::get_filetype(p_in_app_path);
err = _code_sign(p_preset, p_in_app_path, (ftype == 2 || ftype == 5) ? p_helper_ent_path : p_ent_path, false, (ftype == 2 || ftype == 5));
}
@@ -1260,7 +1260,7 @@ Error EditorExportPlatformMacOS::_create_pkg(const Ref<EditorExportPreset> &p_pr
}
print_verbose("productbuild returned: " + str);
- if (str.find("productbuild: error:") != -1) {
+ if (str.contains("productbuild: error:")) {
add_message(EXPORT_MESSAGE_ERROR, TTR("PKG Creation"), TTR("`productbuild` failed."));
return FAILED;
}
@@ -1292,8 +1292,8 @@ Error EditorExportPlatformMacOS::_create_dmg(const String &p_dmg_path, const Str
}
print_verbose("hdiutil returned: " + str);
- if (str.find("create failed") != -1) {
- if (str.find("File exists") != -1) {
+ if (str.contains("create failed")) {
+ if (str.contains("File exists")) {
add_message(EXPORT_MESSAGE_ERROR, TTR("DMG Creation"), TTR("`hdiutil create` failed - file exists."));
} else {
add_message(EXPORT_MESSAGE_ERROR, TTR("DMG Creation"), TTR("`hdiutil create` failed."));
diff --git a/platform/windows/export/export_plugin.cpp b/platform/windows/export/export_plugin.cpp
index a3c86611a4..6ce9d27dc5 100644
--- a/platform/windows/export/export_plugin.cpp
+++ b/platform/windows/export/export_plugin.cpp
@@ -347,7 +347,7 @@ String EditorExportPlatformWindows::get_export_option_warning(const EditorExport
PackedStringArray version_array = file_version.split(".", false);
if (version_array.size() != 4 || !version_array[0].is_valid_int() ||
!version_array[1].is_valid_int() || !version_array[2].is_valid_int() ||
- !version_array[3].is_valid_int() || file_version.find("-") > -1) {
+ !version_array[3].is_valid_int() || file_version.contains("-")) {
return TTR("Invalid file version.");
}
}
@@ -357,7 +357,7 @@ String EditorExportPlatformWindows::get_export_option_warning(const EditorExport
PackedStringArray version_array = product_version.split(".", false);
if (version_array.size() != 4 || !version_array[0].is_valid_int() ||
!version_array[1].is_valid_int() || !version_array[2].is_valid_int() ||
- !version_array[3].is_valid_int() || product_version.find("-") > -1) {
+ !version_array[3].is_valid_int() || product_version.contains("-")) {
return TTR("Invalid product version.");
}
}
@@ -569,13 +569,13 @@ Error EditorExportPlatformWindows::_rcedit_add_data(const Ref<EditorExportPreset
DirAccess::remove_file_or_error(tmp_icon_path);
}
- if (err != OK || (str.find("not found") != -1) || (str.find("not recognized") != -1)) {
+ if (err != OK || str.contains("not found") || str.contains("not recognized")) {
add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), TTR("Could not start rcedit executable. Configure rcedit path in the Editor Settings (Export > Windows > rcedit), or disable \"Application > Modify Resources\" in the export preset."));
return err;
}
print_line("rcedit (" + p_path + "): " + str);
- if (str.find("Fatal error") != -1) {
+ if (str.contains("Fatal error")) {
add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), vformat(TTR("rcedit failed to modify executable: %s."), str));
return FAILED;
}
@@ -718,7 +718,7 @@ Error EditorExportPlatformWindows::_code_sign(const Ref<EditorExportPreset> &p_p
String str;
Error err = OS::get_singleton()->execute(signtool_path, args, &str, nullptr, true);
- if (err != OK || (str.find("not found") != -1) || (str.find("not recognized") != -1)) {
+ if (err != OK || str.contains("not found") || str.contains("not recognized")) {
#ifdef WINDOWS_ENABLED
add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Could not start signtool executable. Configure signtool path in the Editor Settings (Export > Windows > signtool), or disable \"Codesign\" in the export preset."));
#else
@@ -729,9 +729,9 @@ Error EditorExportPlatformWindows::_code_sign(const Ref<EditorExportPreset> &p_p
print_line("codesign (" + p_path + "): " + str);
#ifndef WINDOWS_ENABLED
- if (str.find("SignTool Error") != -1) {
+ if (str.contains("SignTool Error")) {
#else
- if (str.find("Failed") != -1) {
+ if (str.contains("Failed")) {
#endif
add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Signtool failed to sign executable: %s."), str));
return FAILED;
diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp
index 2ddccb0253..72b5b53b19 100644
--- a/scene/3d/skeleton_3d.cpp
+++ b/scene/3d/skeleton_3d.cpp
@@ -253,7 +253,7 @@ void Skeleton3D::_update_process_order() {
int parent_bone_idx = bonesptr[i].parent;
// Check to see if this node is already added to the parent.
- if (bonesptr[parent_bone_idx].child_bones.find(i) < 0) {
+ if (!bonesptr[parent_bone_idx].child_bones.has(i)) {
// Add the child node.
bonesptr[parent_bone_idx].child_bones.push_back(i);
} else {
diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp
index 4ea67eec49..98b1db4a96 100644
--- a/scene/gui/split_container.cpp
+++ b/scene/gui/split_container.cpp
@@ -126,8 +126,8 @@ Control *SplitContainer::get_containable_child(int p_idx) const {
int idx = 0;
for (int i = 0; i < get_child_count(false); i++) {
- Control *c = as_sortable_control(get_child(i, false));
- if (!c) {
+ Control *c = Object::cast_to<Control>(get_child(i, false));
+ if (!c || !c->is_visible() || c->is_set_as_top_level()) {
continue;
}
diff --git a/scene/gui/texture_progress_bar.cpp b/scene/gui/texture_progress_bar.cpp
index bbe5ddf1c3..dc48945d9b 100644
--- a/scene/gui/texture_progress_bar.cpp
+++ b/scene/gui/texture_progress_bar.cpp
@@ -526,7 +526,7 @@ void TextureProgressBar::_notification(int p_what) {
Vector<Point2> points;
for (const float &f : pts) {
Point2 uv = unit_val_to_uv(f);
- if (uvs.find(uv) >= 0) {
+ if (uvs.has(uv)) {
continue;
}
points.push_back(progress_offset + Point2(uv.x * s.x, uv.y * s.y));
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index 0f89784369..3469b806a6 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -239,7 +239,7 @@ bool HTTPRequest::_handle_response(bool *ret_value) {
String new_request;
for (const String &E : rheaders) {
- if (E.findn("Location: ") != -1) {
+ if (E.containsn("Location: ")) {
new_request = E.substr(9, E.length()).strip_edges();
}
}
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index 73f3009fd1..8b5e438aea 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -1880,7 +1880,7 @@ void ArrayMesh::set_blend_shape_name(int p_index, const StringName &p_name) {
do {
shape_name = String(p_name) + " " + itos(count);
count++;
- } while (blend_shapes.find(shape_name) != -1);
+ } while (blend_shapes.has(shape_name));
}
blend_shapes.write[p_index] = shape_name;
diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp
index b5333d91c6..051ed59632 100644
--- a/servers/audio/audio_stream.cpp
+++ b/servers/audio/audio_stream.cpp
@@ -618,7 +618,7 @@ Ref<AudioStreamPlayback> AudioStreamRandomizer::instance_playback_sequential() {
if (entry.stream.is_null()) {
continue;
}
- if (local_pool.find(entry.stream) != -1) {
+ if (local_pool.has(entry.stream)) {
WARN_PRINT("Duplicate stream in sequential playback pool");
continue;
}
diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp
index 1ee5362f2c..31fc51efaa 100644
--- a/servers/rendering/rendering_device.cpp
+++ b/servers/rendering/rendering_device.cpp
@@ -671,9 +671,9 @@ RID RenderingDevice::texture_create(const TextureFormat &p_format, const Texture
TextureFormat format = p_format;
if (format.shareable_formats.size()) {
- ERR_FAIL_COND_V_MSG(format.shareable_formats.find(format.format) == -1, RID(),
+ ERR_FAIL_COND_V_MSG(!format.shareable_formats.has(format.format), RID(),
"If supplied a list of shareable formats, the current format must be present in the list");
- ERR_FAIL_COND_V_MSG(p_view.format_override != DATA_FORMAT_MAX && format.shareable_formats.find(p_view.format_override) == -1, RID(),
+ ERR_FAIL_COND_V_MSG(p_view.format_override != DATA_FORMAT_MAX && !format.shareable_formats.has(p_view.format_override), RID(),
"If supplied a list of shareable formats, the current view format override must be present in the list");
}
@@ -854,7 +854,7 @@ RID RenderingDevice::texture_create_shared(const TextureView &p_view, RID p_with
} else {
ERR_FAIL_INDEX_V(p_view.format_override, DATA_FORMAT_MAX, RID());
- ERR_FAIL_COND_V_MSG(texture.allowed_shared_formats.find(p_view.format_override) == -1, RID(),
+ ERR_FAIL_COND_V_MSG(!texture.allowed_shared_formats.has(p_view.format_override), RID(),
"Format override is not in the list of allowed shareable formats for original texture.");
tv.format = p_view.format_override;
}
@@ -984,7 +984,7 @@ RID RenderingDevice::texture_create_shared_from_slice(const TextureView &p_view,
} else {
ERR_FAIL_INDEX_V(p_view.format_override, DATA_FORMAT_MAX, RID());
- ERR_FAIL_COND_V_MSG(texture.allowed_shared_formats.find(p_view.format_override) == -1, RID(),
+ ERR_FAIL_COND_V_MSG(!texture.allowed_shared_formats.has(p_view.format_override), RID(),
"Format override is not in the list of allowed shareable formats for original texture.");
tv.format = p_view.format_override;
}
diff --git a/tests/core/object/test_class_db.h b/tests/core/object/test_class_db.h
index fb62d0f056..381d759e5b 100644
--- a/tests/core/object/test_class_db.h
+++ b/tests/core/object/test_class_db.h
@@ -195,12 +195,12 @@ struct Context {
}
bool has_type(const TypeReference &p_type_ref) const {
- if (builtin_types.find(p_type_ref.name) >= 0) {
+ if (builtin_types.has(p_type_ref.name)) {
return true;
}
if (p_type_ref.is_enum) {
- if (enum_types.find(p_type_ref.name) >= 0) {
+ if (enum_types.has(p_type_ref.name)) {
return true;
}
@@ -355,7 +355,7 @@ void validate_property(const Context &p_context, const ExposedClass &p_class, co
const ArgumentData &idx_arg = getter->arguments.front()->get();
if (idx_arg.type.name != p_context.names_cache.int_type) {
// If not an int, it can be an enum
- TEST_COND(p_context.enum_types.find(idx_arg.type.name) < 0,
+ TEST_COND(!p_context.enum_types.has(idx_arg.type.name),
"Invalid type '", idx_arg.type.name, "' for index argument of property getter: '", p_class.name, ".", String(p_prop.name), "'.");
}
}
@@ -367,7 +367,7 @@ void validate_property(const Context &p_context, const ExposedClass &p_class, co
if (idx_arg.type.name != p_context.names_cache.int_type) {
// Assume the index parameter is an enum
// If not an int, it can be an enum
- TEST_COND(p_context.enum_types.find(idx_arg.type.name) < 0,
+ TEST_COND(!p_context.enum_types.has(idx_arg.type.name),
"Invalid type '", idx_arg.type.name, "' for index argument of property setter: '", p_class.name, ".", String(p_prop.name), "'.");
}
}
@@ -736,7 +736,7 @@ void add_exposed_classes(Context &r_context) {
for (const StringName &E : K.value.constants) {
const StringName &constant_name = E;
- TEST_FAIL_COND(String(constant_name).find("::") != -1,
+ TEST_FAIL_COND(String(constant_name).contains("::"),
"Enum constant contains '::', check bindings to remove the scope: '",
String(class_name), ".", String(enum_.name), ".", String(constant_name), "'.");
int64_t *value = class_info->constant_map.getptr(constant_name);
@@ -758,7 +758,7 @@ void add_exposed_classes(Context &r_context) {
for (const String &E : constants) {
const String &constant_name = E;
- TEST_FAIL_COND(constant_name.find("::") != -1,
+ TEST_FAIL_COND(constant_name.contains("::"),
"Constant contains '::', check bindings to remove the scope: '",
String(class_name), ".", constant_name, "'.");
int64_t *value = class_info->constant_map.getptr(StringName(E));
diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h
index 18828c3b70..cf57183a02 100644
--- a/tests/core/string/test_string.h
+++ b/tests/core/string/test_string.h
@@ -297,6 +297,19 @@ TEST_CASE("[String] Contains") {
CHECK(!s.contains(String("\\char_test.tscn")));
}
+TEST_CASE("[String] Contains case insensitive") {
+ String s = "C:\\Godot\\project\\string_test.tscn";
+ CHECK(s.containsn("Godot"));
+ CHECK(s.containsn("godot"));
+ CHECK(s.containsn(String("Project\\string_test")));
+ CHECK(s.containsn(String("\\string_Test.tscn")));
+
+ CHECK(!s.containsn("Godoh"));
+ CHECK(!s.containsn("godoh"));
+ CHECK(!s.containsn(String("project\\string test")));
+ CHECK(!s.containsn(String("\\char_test.tscn")));
+}
+
TEST_CASE("[String] Test chr") {
CHECK(String::chr('H') == "H");
CHECK(String::chr(0x3012)[0] == 0x3012);
@@ -376,7 +389,7 @@ TEST_CASE("[String] Find") {
MULTICHECK_STRING_INT_EQ(s, rfind, "", 15, -1);
}
-TEST_CASE("[String] Find no case") {
+TEST_CASE("[String] Find case insensitive") {
String s = "Pretty Whale Whale";
MULTICHECK_STRING_EQ(s, findn, "WHA", 7);
MULTICHECK_STRING_INT_EQ(s, findn, "WHA", 9, 13);
diff --git a/tests/test_main.cpp b/tests/test_main.cpp
index 69d8113e64..41fc21b469 100644
--- a/tests/test_main.cpp
+++ b/tests/test_main.cpp
@@ -242,7 +242,7 @@ struct GodotTestCaseListener : public doctest::IReporter {
String name = String(p_in.m_name);
String suite_name = String(p_in.m_test_suite);
- if (name.find("[SceneTree]") != -1 || name.find("[Editor]") != -1) {
+ if (name.contains("[SceneTree]") || name.contains("[Editor]")) {
memnew(MessageQueue);
memnew(Input);
@@ -291,7 +291,7 @@ struct GodotTestCaseListener : public doctest::IReporter {
}
#ifdef TOOLS_ENABLED
- if (name.find("[Editor]") != -1) {
+ if (name.contains("[Editor]")) {
Engine::get_singleton()->set_editor_hint(true);
EditorPaths::create();
EditorSettings::create();
@@ -301,7 +301,7 @@ struct GodotTestCaseListener : public doctest::IReporter {
return;
}
- if (name.find("Audio") != -1) {
+ if (name.contains("Audio")) {
// The last driver index should always be the dummy driver.
int dummy_idx = AudioDriverManager::get_driver_count() - 1;
AudioDriverManager::initialize(dummy_idx);
@@ -311,7 +311,7 @@ struct GodotTestCaseListener : public doctest::IReporter {
}
#ifndef _3D_DISABLED
- if (suite_name.find("[Navigation]") != -1 && navigation_server_2d == nullptr && navigation_server_3d == nullptr) {
+ if (suite_name.contains("[Navigation]") && navigation_server_2d == nullptr && navigation_server_3d == nullptr) {
ERR_PRINT_OFF;
navigation_server_3d = NavigationServer3DManager::new_default_server();
navigation_server_2d = NavigationServer2DManager::new_default_server();