diff options
Diffstat (limited to 'editor/plugins')
24 files changed, 86 insertions, 86 deletions
diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index b9ad18ef51..f16ea36a23 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -552,7 +552,7 @@ void AnimationNodeBlendSpace1DEditor::_notification(int p_what) { if (error != error_label->get_text()) { error_label->set_text(error); - if (error != String()) { + if (!error.is_empty()) { error_panel->show(); } else { error_panel->hide(); diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 362b0b6cf7..b107478724 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -761,7 +761,7 @@ void AnimationNodeBlendSpace2DEditor::_notification(int p_what) { if (error != error_label->get_text()) { error_label->set_text(error); - if (error != String()) { + if (!error.is_empty()) { error_panel->show(); } else { error_panel->hide(); diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 2e051b9601..d9a6f19384 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -292,7 +292,7 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) { anode = EditorSettings::get_singleton()->get_resource_clipboard(); ERR_FAIL_COND(!anode.is_valid()); base_name = anode->get_class(); - } else if (add_options[p_idx].type != String()) { + } else if (!add_options[p_idx].type.is_empty()) { AnimationNode *an = Object::cast_to<AnimationNode>(ClassDB::instantiate(add_options[p_idx].type)); ERR_FAIL_COND(!an); anode = Ref<AnimationNode>(an); @@ -600,7 +600,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano String accum; for (int i = 0; i < path.get_name_count(); i++) { String name = path.get_name(i); - if (accum != String()) { + if (!accum.is_empty()) { accum += "/"; } accum += name; @@ -752,7 +752,7 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) { if (error != error_label->get_text()) { error_label->set_text(error); - if (error != String()) { + if (!error.is_empty()) { error_panel->show(); } else { error_panel->hide(); @@ -821,13 +821,13 @@ AnimationNodeBlendTreeEditor *AnimationNodeBlendTreeEditor::singleton = nullptr; void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<AnimationNode> p_node) { String prev_name = blend_tree->get_node_name(p_node); - ERR_FAIL_COND(prev_name == String()); + ERR_FAIL_COND(prev_name.is_empty()); GraphNode *gn = Object::cast_to<GraphNode>(graph->get_node(prev_name)); ERR_FAIL_COND(!gn); const String &new_name = p_text; - ERR_FAIL_COND(new_name == "" || new_name.find(".") != -1 || new_name.find("/") != -1); + ERR_FAIL_COND(new_name.is_empty() || new_name.find(".") != -1 || new_name.find("/") != -1); if (new_name == prev_name) { return; //nothing to do diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index f936871bce..14390511de 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -190,7 +190,7 @@ void AnimationPlayerEditor::_play_pressed() { current = animation->get_item_text(animation->get_selected()); } - if (current != "") { + if (!current.is_empty()) { if (current == player->get_assigned_animation()) { player->stop(); //so it won't blend with itself } @@ -207,7 +207,7 @@ void AnimationPlayerEditor::_play_from_pressed() { current = animation->get_item_text(animation->get_selected()); } - if (current != "") { + if (!current.is_empty()) { float time = player->get_current_animation_position(); if (current == player->get_assigned_animation() && player->is_playing()) { @@ -228,7 +228,7 @@ void AnimationPlayerEditor::_play_bw_pressed() { current = animation->get_item_text(animation->get_selected()); } - if (current != "") { + if (!current.is_empty()) { if (current == player->get_assigned_animation()) { player->stop(); //so it won't blend with itself } @@ -245,7 +245,7 @@ void AnimationPlayerEditor::_play_bw_from_pressed() { current = animation->get_item_text(animation->get_selected()); } - if (current != "") { + if (!current.is_empty()) { float time = player->get_current_animation_position(); if (current == player->get_assigned_animation()) { player->stop(); //so it won't blend with itself @@ -280,7 +280,7 @@ void AnimationPlayerEditor::_animation_selected(int p_which) { current = animation->get_item_text(animation->get_selected()); } - if (current != "") { + if (!current.is_empty()) { player->set_assigned_animation(current); Ref<Animation> anim = player->get_animation(current); @@ -397,7 +397,7 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource) String path; //file->set_current_path(current_path); - if (p_resource->get_path() != "") { + if (!p_resource->get_path().is_empty()) { path = p_resource->get_path(); if (extensions.size()) { if (extensions.find(p_resource->get_path().get_extension().to_lower()) == nullptr) { @@ -406,7 +406,7 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource) } } else { if (extensions.size()) { - if (p_resource->get_name() != "") { + if (!p_resource->get_name().is_empty()) { path = p_resource->get_name() + "." + extensions.front()->get().to_lower(); } else { String resource_name_snake_case = p_resource->get_class().camelcase_to_underscore(); @@ -486,7 +486,7 @@ void AnimationPlayerEditor::_animation_name_edited() { player->stop(); String new_name = name->get_text(); - if (new_name == "" || new_name.find(":") != -1 || new_name.find("/") != -1) { + if (new_name.is_empty() || new_name.find(":") != -1 || new_name.find("/") != -1) { error_dialog->set_text(TTR("Invalid animation name!")); error_dialog->popup_centered(); return; @@ -720,7 +720,7 @@ void AnimationPlayerEditor::_animation_edit() { void AnimationPlayerEditor::_save_animation(String p_file) { String current = animation->get_item_text(animation->get_selected()); - if (current != "") { + if (!current.is_empty()) { Ref<Animation> anim = player->get_animation(current); ERR_FAIL_COND(!Object::cast_to<Resource>(*anim)); @@ -1007,7 +1007,7 @@ void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_set, bool updating = true; String current = player->get_assigned_animation(); - if (current == "" || !player->has_animation(current)) { + if (current.is_empty() || !player->has_animation(current)) { updating = false; current = ""; return; @@ -1086,7 +1086,7 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) { } Ref<Animation> anim; - if (current != String()) { + if (!current.is_empty()) { anim = player->get_animation(current); } @@ -1141,7 +1141,7 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) { } String name = anim2->get_name(); - if (name == "") { + if (name.is_empty()) { name = TTR("Pasted Animation"); } diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 391565057c..cf3bc58af9 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -438,7 +438,7 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) { return; } - if (base_name == String()) { + if (base_name.is_empty()) { base_name = node->get_class().replace_first("AnimationNode", ""); } @@ -927,7 +927,7 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) { if (error != error_label->get_text()) { error_label->set_text(error); - if (error != String()) { + if (!error.is_empty()) { error_panel->show(); } else { error_panel->hide(); @@ -1059,7 +1059,7 @@ void AnimationNodeStateMachineEditor::_removed_from_graph() { void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) { const String &new_name = p_text; - ERR_FAIL_COND(new_name == "" || new_name.find(".") != -1 || new_name.find("/") != -1); + ERR_FAIL_COND(new_name.is_empty() || new_name.find(".") != -1 || new_name.find("/") != -1); if (new_name == prev_name) { return; // Nothing to do. diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 4f3b5db1da..0925b34ac1 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -343,7 +343,7 @@ void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int if (p_code != 200) { error_text = TTR("Request failed, return code:") + " " + itos(p_code); status->set_text(TTR("Failed:") + " " + itos(p_code)); - } else if (sha256 != "") { + } else if (!sha256.is_empty()) { String download_sha256 = FileAccess::get_sha256(download->get_download_file()); if (sha256 != download_sha256) { error_text = TTR("Bad download hash, assuming file has been tampered with.") + "\n"; @@ -354,7 +354,7 @@ void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int } break; } - if (error_text != String()) { + if (!error_text.is_empty()) { download_error->set_text(TTR("Asset Download Error:") + "\n" + error_text); download_error->popup_centered(); // Let the user retry the download. @@ -921,7 +921,7 @@ void EditorAssetLibrary::_search(int p_page) { support_list += String(support_key[i]) + "+"; } } - if (support_list != String()) { + if (!support_list.is_empty()) { args += "&support=" + support_list.substr(0, support_list.length() - 1); } @@ -934,7 +934,7 @@ void EditorAssetLibrary::_search(int p_page) { args += "&reverse=true"; } - if (filter->get_text() != String()) { + if (!filter->get_text().is_empty()) { args += "&filter=" + filter->get_text().uri_encode(); } @@ -1187,7 +1187,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const library_vb->add_child(asset_bottom_page); if (result.is_empty()) { - if (filter->get_text() != String()) { + if (!filter->get_text().is_empty()) { library_error->set_text( vformat(TTR("No results for \"%s\"."), filter->get_text())); } else { @@ -1218,7 +1218,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const item->connect("author_selected", callable_mp(this, &EditorAssetLibrary::_select_author)); item->connect("category_selected", callable_mp(this, &EditorAssetLibrary::_select_category)); - if (r.has("icon_url") && r["icon_url"] != "") { + if (r.has("icon_url") && !r["icon_url"].operator String().is_empty()) { _request_image(item->get_instance_id(), r["icon_url"], IMAGE_QUEUE_ICON, 0); } } @@ -1255,7 +1255,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const description->configure(r["title"], r["asset_id"], category_map[r["category_id"]], r["category_id"], r["author"], r["author_id"], r["cost"], r["version"], r["version_string"], r["description"], r["download_url"], r["browse_url"], r["download_hash"]); - if (r.has("icon_url") && r["icon_url"] != "") { + if (r.has("icon_url") && !r["icon_url"].operator String().is_empty()) { _request_image(description->get_instance_id(), r["icon_url"], IMAGE_QUEUE_ICON, 0); } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index d92564581d..4a19e7752e 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1460,7 +1460,7 @@ bool CanvasItemEditor::_gui_input_open_scene_on_double_click(const Ref<InputEven List<CanvasItem *> selection = _get_edited_canvas_items(); if (selection.size() == 1) { CanvasItem *canvas_item = selection[0]; - if (canvas_item->get_scene_file_path() != "" && canvas_item != editor->get_edited_scene()) { + if (!canvas_item->get_scene_file_path().is_empty() && canvas_item != editor->get_edited_scene()) { editor->open_request(canvas_item->get_scene_file_path()); return true; } @@ -5843,7 +5843,7 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons return false; } - if (editor->get_edited_scene()->get_scene_file_path() != "") { // cyclical instancing + if (!editor->get_edited_scene()->get_scene_file_path().is_empty()) { // cyclical instancing if (_cyclical_dependency_exists(editor->get_edited_scene()->get_scene_file_path(), instantiated_scene)) { memdelete(instantiated_scene); return false; diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 31cb0cd18d..3b85fad345 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -477,7 +477,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size } String code = scr->get_source_code().strip_edges(); - if (code == "") { + if (code.is_empty()) { return Ref<Texture2D>(); } diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp index c1a1e44ba2..f6788f80ba 100644 --- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp @@ -34,7 +34,7 @@ void GPUParticlesCollisionSDF3DEditorPlugin::_bake() { if (col_sdf) { if (col_sdf->get_texture().is_null() || !col_sdf->get_texture()->get_path().is_resource_file()) { String path = get_tree()->get_edited_scene_root()->get_scene_file_path(); - if (path == String()) { + if (path.is_empty()) { path = "res://" + col_sdf->get_name() + "_data.exr"; } else { String ext = path.get_extension(); diff --git a/editor/plugins/lightmap_gi_editor_plugin.cpp b/editor/plugins/lightmap_gi_editor_plugin.cpp index 123087446c..d7b469cb74 100644 --- a/editor/plugins/lightmap_gi_editor_plugin.cpp +++ b/editor/plugins/lightmap_gi_editor_plugin.cpp @@ -44,10 +44,10 @@ void LightmapGIEditorPlugin::_bake_select_file(const String &p_file) { switch (err) { case LightmapGI::BAKE_ERROR_NO_SAVE_PATH: { String scene_path = lightmap->get_scene_file_path(); - if (scene_path == String()) { + if (scene_path.is_empty()) { scene_path = lightmap->get_owner()->get_scene_file_path(); } - if (scene_path == String()) { + if (scene_path.is_empty()) { EditorNode::get_singleton()->show_warning(TTR("Can't determine a save path for lightmap images.\nSave your scene and try again.")); break; } diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp index 18e7480287..fd62f632dc 100644 --- a/editor/plugins/mesh_library_editor_plugin.cpp +++ b/editor/plugins/mesh_library_editor_plugin.cpp @@ -61,7 +61,7 @@ void MeshLibraryEditor::_menu_update_confirm(bool p_apply_xforms) { cd_update->hide(); apply_xforms = p_apply_xforms; String existing = mesh_library->get_meta("_editor_source_scene"); - ERR_FAIL_COND(existing == ""); + ERR_FAIL_COND(existing.is_empty()); _import_scene_cbk(existing); } diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp index 5514bccabb..517aca596a 100644 --- a/editor/plugins/multimesh_editor_plugin.cpp +++ b/editor/plugins/multimesh_editor_plugin.cpp @@ -48,7 +48,7 @@ void MultiMeshEditor::_populate() { Ref<Mesh> mesh; - if (mesh_source->get_text() == "") { + if (mesh_source->get_text().is_empty()) { Ref<MultiMesh> multimesh; multimesh = node->get_multimesh(); if (multimesh.is_null()) { @@ -89,7 +89,7 @@ void MultiMeshEditor::_populate() { } } - if (surface_source->get_text() == "") { + if (surface_source->get_text().is_empty()) { err_dialog->set_text(TTR("No surface source specified.")); err_dialog->popup_centered(); return; diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 2f14447bf9..f49b749046 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -4080,7 +4080,7 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po return false; } - if (editor->get_edited_scene()->get_scene_file_path() != "") { // cyclical instancing + if (!editor->get_edited_scene()->get_scene_file_path().is_empty()) { // cyclical instancing if (_cyclical_dependency_exists(editor->get_edited_scene()->get_scene_file_path(), instantiated_scene)) { memdelete(instantiated_scene); return false; diff --git a/editor/plugins/occluder_instance_3d_editor_plugin.cpp b/editor/plugins/occluder_instance_3d_editor_plugin.cpp index 0328b1bea6..1e85b19a84 100644 --- a/editor/plugins/occluder_instance_3d_editor_plugin.cpp +++ b/editor/plugins/occluder_instance_3d_editor_plugin.cpp @@ -42,10 +42,10 @@ void OccluderInstance3DEditorPlugin::_bake_select_file(const String &p_file) { switch (err) { case OccluderInstance3D::BAKE_ERROR_NO_SAVE_PATH: { String scene_path = occluder_instance->get_scene_file_path(); - if (scene_path == String()) { + if (scene_path.is_empty()) { scene_path = occluder_instance->get_owner()->get_scene_file_path(); } - if (scene_path == String()) { + if (scene_path.is_empty()) { EditorNode::get_singleton()->show_warning(TTR("Can't determine a save path for the occluder.\nSave your scene and try again.")); break; } diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 79cfcbec64..affcab9e7d 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -170,7 +170,7 @@ void Polygon2DEditor::_update_bone_list() { if (np.get_name_count()) { name = np.get_name(np.get_name_count() - 1); } - if (name == String()) { + if (name.is_empty()) { name = "Bone " + itos(i); } cb->set_text(name); diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index eae6916a92..30b7a26aab 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -110,7 +110,7 @@ void ResourcePreloaderEditor::_item_edited() { return; } - if (new_name == "" || new_name.find("\\") != -1 || new_name.find("/") != -1 || preloader->has_resource(new_name)) { + if (new_name.is_empty() || new_name.find("\\") != -1 || new_name.find("/") != -1 || preloader->has_resource(new_name)) { s->set_text(0, old_name); return; } @@ -147,10 +147,10 @@ void ResourcePreloaderEditor::_paste_pressed() { } String name = r->get_name(); - if (name == "") { + if (name.is_empty()) { name = r->get_path().get_file(); } - if (name == "") { + if (name.is_empty()) { name = r->get_class(); } @@ -300,7 +300,7 @@ void ResourcePreloaderEditor::drop_data_fw(const Point2 &p_point, const Variant if (r.is_valid()) { String basename; - if (r->get_name() != "") { + if (!r->get_name().is_empty()) { basename = r->get_name(); } else if (r->get_path().is_resource_file()) { basename = r->get_path().get_basename(); diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index 0f3c50a861..d1830bf5af 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -89,7 +89,7 @@ void EditorPropertyRootMotion::_node_assign() { String accum; for (int i = 0; i < path.get_name_count(); i++) { String name = path.get_name(i); - if (accum != String()) { + if (!accum.is_empty()) { accum += "/"; } accum += name; @@ -277,7 +277,7 @@ bool EditorInspectorRootMotionPlugin::can_handle(Object *p_object) { bool EditorInspectorRootMotionPlugin::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide) { if (p_path == "root_motion_track" && p_object->is_class("AnimationTree") && p_type == Variant::NODE_PATH) { EditorPropertyRootMotion *editor = memnew(EditorPropertyRootMotion); - if (p_hint == PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE && p_hint_text != String()) { + if (p_hint == PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE && !p_hint_text.is_empty()) { editor->setup(p_hint_text); } add_property_editor(p_path, editor); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 5dbcb3788d..caaac2c7d3 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -179,7 +179,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { for (const String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); - highlighter->add_color_region(beg, end, comment_color, end == ""); + highlighter->add_color_region(beg, end, comment_color, end.is_empty()); } /* Strings */ @@ -189,7 +189,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { for (const String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); - highlighter->add_color_region(beg, end, string_color, end == ""); + highlighter->add_color_region(beg, end, string_color, end.is_empty()); } } } @@ -321,7 +321,7 @@ void ScriptEditorQuickOpen::_update_search() { for (int i = 0; i < functions.size(); i++) { String file = functions[i]; - if ((search_box->get_text() == "" || file.findn(search_box->get_text()) != -1)) { + if ((search_box->get_text().is_empty() || file.findn(search_box->get_text()) != -1)) { TreeItem *ti = search_options->create_item(root); ti->set_text(0, file); if (root->get_first_child() == ti) { @@ -392,7 +392,7 @@ ScriptEditor *ScriptEditor::script_editor = nullptr; String ScriptEditor::_get_debug_tooltip(const String &p_text, Node *_se) { String val = EditorDebuggerNode::get_singleton()->get_var_value(p_text); - if (val != String()) { + if (!val.is_empty()) { return p_text + ": " + val; } else { return String(); @@ -1679,7 +1679,7 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) { String base = script->get_path(); loaded_scripts.insert(base); - if (base.begins_with("local://") || base == "") { + if (base.begins_with("local://") || base.is_empty()) { continue; } @@ -1831,7 +1831,7 @@ void ScriptEditor::_update_members_overview() { for (int i = 0; i < functions.size(); i++) { String filter = filter_methods->get_text(); String name = functions[i].get_slice(":", 0); - if (filter == "" || filter.is_subsequence_ofi(name)) { + if (filter.is_empty() || filter.is_subsequence_ofi(name)) { members_overview->add_item(name); members_overview->set_item_metadata(members_overview->get_item_count() - 1, functions[i].get_slice(":", 1).to_int() - 1); } @@ -2076,7 +2076,7 @@ void ScriptEditor::_update_script_names() { Vector<_ScriptEditorItemData> sedata_filtered; for (int i = 0; i < sedata.size(); i++) { String filter = filter_scripts->get_text(); - if (filter == "" || filter.is_subsequence_ofi(sedata[i].name)) { + if (filter.is_empty() || filter.is_subsequence_ofi(sedata[i].name)) { sedata_filtered.push_back(sedata[i]); } } @@ -2648,7 +2648,7 @@ void ScriptEditor::_editor_settings_changed() { _update_autosave_timer(); - if (current_theme == "") { + if (current_theme.is_empty()) { current_theme = EditorSettings::get_singleton()->get("text_editor/theme/color_theme"); } else if (current_theme != String(EditorSettings::get_singleton()->get("text_editor/theme/color_theme"))) { current_theme = EditorSettings::get_singleton()->get("text_editor/theme/color_theme"); @@ -2840,7 +2840,7 @@ bool ScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data for (int i = 0; i < files.size(); i++) { String file = files[i]; - if (file == "" || !FileAccess::exists(file)) { + if (file.is_empty() || !FileAccess::exists(file)) { continue; } if (ResourceLoader::exists(file, "Script")) { @@ -2920,7 +2920,7 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co int num_tabs_before = tab_container->get_child_count(); for (int i = 0; i < files.size(); i++) { String file = files[i]; - if (file == "" || !FileAccess::exists(file)) { + if (file.is_empty() || !FileAccess::exists(file)) { continue; } @@ -3126,7 +3126,7 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { for (int i = 0; i < helps.size(); i++) { String path = helps[i]; - if (path == "") { // invalid, skip + if (path.is_empty()) { // invalid, skip continue; } _help_class_open(path); @@ -3197,7 +3197,7 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) { } void ScriptEditor::_help_class_open(const String &p_class) { - if (p_class == "") { + if (p_class.is_empty()) { return; } diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 36bab83630..d5af7c5b38 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -205,7 +205,7 @@ void ScriptTextEditor::_set_theme_for_script() { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); if (!text_edit->has_string_delimiter(beg)) { - text_edit->add_string_delimiter(beg, end, end == ""); + text_edit->add_string_delimiter(beg, end, end.is_empty()); } if (!end.is_empty() && !text_edit->has_auto_brace_completion_open_key(beg)) { @@ -219,7 +219,7 @@ void ScriptTextEditor::_set_theme_for_script() { for (const String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); - text_edit->add_comment_delimiter(beg, end, end == ""); + text_edit->add_comment_delimiter(beg, end, end.is_empty()); if (!end.is_empty() && !text_edit->has_auto_brace_completion_open_key(beg)) { text_edit->add_auto_brace_completion_pair(beg, end); @@ -381,7 +381,7 @@ String ScriptTextEditor::get_name() { name = TTR("[unsaved]"); } else if (script->is_built_in()) { const String &script_name = script->get_name(); - if (script_name != "") { + if (!script_name.is_empty()) { // If the built-in script has a custom resource name defined, // display the built-in script name as follows: `ResourceName (scene_file.tscn)` name = vformat("%s (%s)", script_name, name.get_slice("::", 0)); @@ -990,7 +990,7 @@ void ScriptTextEditor::_gutter_clicked(int p_line, int p_gutter) { } String method = code_editor->get_text_editor()->get_line_gutter_metadata(p_line, p_gutter); - if (method == "") { + if (method.is_empty()) { return; } @@ -1137,7 +1137,7 @@ void ScriptTextEditor::_edit_option(int p_op) { if (expression.parse(line) == OK) { Variant result = expression.execute(Array(), Variant(), false); - if (expression.get_error_text() == "") { + if (expression.get_error_text().is_empty()) { results.push_back(whitespace + result.get_construct_string()); } else { results.push_back(line); @@ -1263,19 +1263,19 @@ void ScriptTextEditor::_edit_option(int p_op) { } break; case HELP_CONTEXTUAL: { String text = tx->get_selected_text(); - if (text == "") { + if (text.is_empty()) { text = tx->get_word_under_caret(); } - if (text != "") { + if (!text.is_empty()) { emit_signal(SNAME("request_help"), text); } } break; case LOOKUP_SYMBOL: { String text = tx->get_word_under_caret(); - if (text == "") { + if (text.is_empty()) { text = tx->get_selected_text(); } - if (text != "") { + if (!text.is_empty()) { _lookup_symbol(text, tx->get_caret_line(), tx->get_caret_column()); } } break; @@ -1560,10 +1560,10 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { } String word_at_pos = tx->get_word_at_pos(local_pos); - if (word_at_pos == "") { + if (word_at_pos.is_empty()) { word_at_pos = tx->get_word_under_caret(); } - if (word_at_pos == "") { + if (word_at_pos.is_empty()) { word_at_pos = tx->get_selected_text(); } diff --git a/editor/plugins/shader_file_editor_plugin.cpp b/editor/plugins/shader_file_editor_plugin.cpp index 1e62261244..517de1901f 100644 --- a/editor/plugins/shader_file_editor_plugin.cpp +++ b/editor/plugins/shader_file_editor_plugin.cpp @@ -97,7 +97,7 @@ void ShaderFileEditor::_version_selected(int p_option) { error_text->push_font(get_theme_font(SNAME("source"), SNAME("EditorFonts"))); - if (error == String()) { + if (error.is_empty()) { error_text->add_text(TTR("Shader stage compiled without errors.")); } else { error_text->add_text(error); @@ -107,7 +107,7 @@ void ShaderFileEditor::_version_selected(int p_option) { void ShaderFileEditor::_update_options() { ERR_FAIL_COND(shader_file.is_null()); - if (shader_file->get_base_error() != String()) { + if (!shader_file->get_base_error().is_empty()) { stage_hb->hide(); versions->hide(); error_text->clear(); @@ -136,7 +136,7 @@ void ShaderFileEditor::_update_options() { for (int i = 0; i < version_list.size(); i++) { String title = version_list[i]; - if (title == "") { + if (title.is_empty()) { title = "default"; } @@ -148,7 +148,7 @@ void ShaderFileEditor::_update_options() { bool failed = false; for (int j = 0; j < RD::SHADER_STAGE_MAX; j++) { String error = bytecode->get_stage_compile_error(RD::ShaderStage(j)); - if (error != String()) { + if (!error.is_empty()) { failed = true; } } @@ -182,7 +182,7 @@ void ShaderFileEditor::_update_options() { for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) { Vector<uint8_t> bc = bytecode->get_stage_bytecode(RD::ShaderStage(i)); String error = bytecode->get_stage_compile_error(RD::ShaderStage(i)); - bool disable = error == String() && bc.is_empty(); + bool disable = error.is_empty() && bc.is_empty(); stages[i]->set_disabled(disable); if (!disable) { if (stages[i]->is_pressed()) { diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index ceb2c8394d..cbde382d67 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -71,7 +71,7 @@ String TextEditor::get_name() { name = TTR("[unsaved]"); } else if (text_file->is_built_in()) { const String &text_file_name = text_file->get_name(); - if (text_file_name != "") { + if (!text_file_name.is_empty()) { // If the built-in text_file has a custom resource name defined, // display the built-in text_file name as follows: `ResourceName (scene_file.tscn)` name = vformat("%s (%s)", text_file_name, name.get_slice("::", 0)); diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp index 5336788d98..eea0d2789d 100644 --- a/editor/plugins/version_control_editor_plugin.cpp +++ b/editor/plugins/version_control_editor_plugin.cpp @@ -266,7 +266,7 @@ void VersionControlEditorPlugin::_display_file_diff(String p_file_path) { void VersionControlEditorPlugin::_refresh_file_diff() { String open_file = diff_file_name->get_text(); - if (open_file != "") { + if (!open_file.is_empty()) { _display_file_diff(diff_file_name->get_text()); } } @@ -299,7 +299,7 @@ void VersionControlEditorPlugin::_update_commit_status() { } void VersionControlEditorPlugin::_update_commit_button() { - commit_button->set_disabled(commit_message->get_text().strip_edges() == ""); + commit_button->set_disabled(commit_message->get_text().strip_edges().is_empty()); } void VersionControlEditorPlugin::_commit_message_gui_input(const Ref<InputEvent> &p_event) { diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 7673c31d00..365cfd9232 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -591,7 +591,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { if (vsnode->is_use_prop_slots()) { String error = vsnode->get_warning(visual_shader->get_mode(), p_type); - if (error != String()) { + if (!error.is_empty()) { Label *error_label = memnew(Label); error_label->add_theme_color_override("font_color", VisualShaderEditor::get_singleton()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); error_label->set_text(error); @@ -877,7 +877,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { node->add_child(offset); String error = vsnode->get_warning(visual_shader->get_mode(), p_type); - if (error != String()) { + if (!error.is_empty()) { Label *error_label = memnew(Label); error_label->add_theme_color_override("font_color", VisualShaderEditor::get_singleton()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); error_label->set_text(error); @@ -1191,7 +1191,7 @@ void VisualShaderEditor::update_custom_nodes() { category = category.rstrip("/"); category = category.lstrip("/"); category = "Addons/" + category; - if (subcategory != "") { + if (!subcategory.is_empty()) { category += "/" + subcategory; } @@ -1687,7 +1687,7 @@ void VisualShaderEditor::_change_input_port_name(const String &p_text, Object *p ERR_FAIL_COND(!line_edit); String validated_name = visual_shader->validate_port_name(p_text, node.ptr(), p_port_id, false); - if (validated_name == String() || prev_name == validated_name) { + if (validated_name.is_empty() || prev_name == validated_name) { line_edit->set_text(node->get_input_port_name(p_port_id)); return; } @@ -1715,7 +1715,7 @@ void VisualShaderEditor::_change_output_port_name(const String &p_text, Object * ERR_FAIL_COND(!line_edit); String validated_name = visual_shader->validate_port_name(p_text, node.ptr(), p_port_id, true); - if (validated_name == String() || prev_name == validated_name) { + if (validated_name.is_empty() || prev_name == validated_name) { line_edit->set_text(node->get_output_port_name(p_port_id)); return; } @@ -2410,7 +2410,7 @@ void VisualShaderEditor::_add_node(int p_idx, int p_op_idx, String p_resource_pa bool is_custom = add_options[p_idx].is_custom; - if (!is_custom && add_options[p_idx].type != String()) { + if (!is_custom && !add_options[p_idx].type.is_empty()) { VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instantiate(add_options[p_idx].type)); ERR_FAIL_COND(!vsn); diff --git a/editor/plugins/voxel_gi_editor_plugin.cpp b/editor/plugins/voxel_gi_editor_plugin.cpp index 4f3cb9e189..4e81fc4e77 100644 --- a/editor/plugins/voxel_gi_editor_plugin.cpp +++ b/editor/plugins/voxel_gi_editor_plugin.cpp @@ -34,7 +34,7 @@ void VoxelGIEditorPlugin::_bake() { if (voxel_gi) { if (voxel_gi->get_probe_data().is_null()) { String path = get_tree()->get_edited_scene_root()->get_scene_file_path(); - if (path == String()) { + if (path.is_empty()) { path = "res://" + voxel_gi->get_name() + "_data.res"; } else { String ext = path.get_extension(); |