diff options
Diffstat (limited to 'editor')
89 files changed, 507 insertions, 507 deletions
diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index 9df76b8657..a8d3bfcc90 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -761,7 +761,7 @@ void ActionMapEditor::_add_action_pressed() { } void ActionMapEditor::_add_action(const String &p_name) { - if (p_name == "" || !_is_action_name_valid(p_name)) { + if (p_name.is_empty() || !_is_action_name_valid(p_name)) { show_message(TTR("Invalid action name. It cannot be empty nor contain '/', ':', '=', '\\' or '\"'")); return; } @@ -785,7 +785,7 @@ void ActionMapEditor::_action_edited() { return; } - if (new_name == "" || !_is_action_name_valid(new_name)) { + if (new_name.is_empty() || !_is_action_name_valid(new_name)) { ti->set_text(0, old_name); show_message(TTR("Invalid action name. It cannot be empty nor contain '/', ':', '=', '\\' or '\"'")); return; diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index c212523c98..e7251662b7 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -650,7 +650,7 @@ public: List<StringName> anims; ap->get_animation_list(&anims); for (const StringName &E : anims) { - if (animations != String()) { + if (!animations.is_empty()) { animations += ","; } @@ -659,7 +659,7 @@ public: } } - if (animations != String()) { + if (!animations.is_empty()) { animations += ","; } animations += "[stop]"; @@ -1332,7 +1332,7 @@ public: List<StringName> anims; ap->get_animation_list(&anims); for (List<StringName>::Element *G = anims.front(); G; G = G->next()) { - if (animations != String()) { + if (!animations.is_empty()) { animations += ","; } @@ -1341,7 +1341,7 @@ public: } } - if (animations != String()) { + if (!animations.is_empty()) { animations += ","; } animations += "[stop]"; @@ -2665,7 +2665,7 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { if (stream.is_valid()) { if (stream->get_path().is_resource_file()) { stream_name = stream->get_path().get_file(); - } else if (stream->get_name() != "") { + } else if (!stream->get_name().is_empty()) { stream_name = stream->get_name(); } else { stream_name = stream->get_class(); @@ -3657,7 +3657,7 @@ void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_ // Let's build a node path. String path = root->get_path_to(p_node); - if (p_sub != "") { + if (!p_sub.is_empty()) { path += ":" + p_sub; } @@ -3697,7 +3697,7 @@ bool AnimationTrackEditor::has_track(Node3D *p_node, const String &p_sub, const // Let's build a node path. String path = root->get_path_to(p_node); - if (p_sub != "") { + if (!p_sub.is_empty()) { path += ":" + p_sub; } @@ -3762,7 +3762,7 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p EditorHistory *history = EditorNode::get_singleton()->get_editor_history(); for (int i = 1; i < history->get_path_size(); i++) { String prop = history->get_path_property(i); - ERR_FAIL_COND(prop == ""); + ERR_FAIL_COND(prop.is_empty()); path += ":" + prop; } @@ -3862,7 +3862,7 @@ void AnimationTrackEditor::insert_value_key(const String &p_property, const Vari for (int i = 1; i < history->get_path_size(); i++) { String prop = history->get_path_property(i); - ERR_FAIL_COND(prop == ""); + ERR_FAIL_COND(prop.is_empty()); path += ":" + prop; } @@ -6021,7 +6021,7 @@ void AnimationTrackEditor::_pick_track_select_recursive(TreeItem *p_item, const NodePath np = p_item->get_metadata(0); Node *node = get_node(np); - if (p_filter != String() && ((String)node->get_name()).findn(p_filter) != -1) { + if (!p_filter.is_empty() && ((String)node->get_name()).findn(p_filter) != -1) { p_select_candidates.push_back(node); } diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 371ea17c68..c024c909a3 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1534,7 +1534,7 @@ void CodeTextEditor::set_edit_state(const Variant &p_state) { void CodeTextEditor::set_error(const String &p_error) { error->set_text(p_error); - if (p_error != "") { + if (!p_error.is_empty()) { error->set_default_cursor_shape(CURSOR_POINTING_HAND); } else { error->set_default_cursor_shape(CURSOR_ARROW); @@ -1547,7 +1547,7 @@ void CodeTextEditor::set_error_pos(int p_line, int p_column) { } void CodeTextEditor::goto_error() { - if (error->get_text() != "") { + if (!error->get_text().is_empty()) { text_editor->unfold_line(error_line); text_editor->set_caret_line(error_line); text_editor->set_caret_column(error_column); diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 2088a7e1c4..4945414237 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -111,7 +111,7 @@ public: void ConnectDialog::ok_pressed() { String method_name = dst_method->get_text(); - if (method_name == "") { + if (method_name.is_empty()) { error->set_text(TTR("Method in target node must be specified.")); error->popup_centered(); return; @@ -234,7 +234,7 @@ void ConnectDialog::_add_bind() { */ void ConnectDialog::_remove_bind() { String st = bind_editor->get_selected_path(); - if (st == "") { + if (st.is_empty()) { return; } int idx = st.get_slice("/", 1).to_int() - 1; @@ -969,7 +969,7 @@ void ConnectionsDock::update_tree() { } else if (pi.type != Variant::NIL) { tname = Variant::get_type_name(pi.type); } - signaldesc += (pi.name == "" ? String("arg " + itos(i)) : pi.name) + ": " + tname; + signaldesc += (pi.name.is_empty() ? String("arg " + itos(i)) : pi.name) + ": " + tname; argnames.push_back(pi.name + ":" + tname); } } @@ -1001,7 +1001,7 @@ void ConnectionsDock::update_tree() { if (!found) { DocTools *dd = EditorHelp::get_doc_data(); Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(base); - while (F && descr == String()) { + while (F && descr.is_empty()) { for (int i = 0; i < F->get().signals.size(); i++) { if (F->get().signals[i].name == signal_name.operator String()) { descr = DTR(F->get().signals[i].description); diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 921c03e8ad..6bf14df8a1 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -173,7 +173,7 @@ void CreateDialog::_update_search() { _configure_search_option_item(root, base_type, ClassDB::class_exists(base_type)); const String search_text = search_box->get_text(); - bool empty_search = search_text == ""; + bool empty_search = search_text.is_empty(); // Filter all candidate results. Vector<String> candidates; @@ -244,7 +244,7 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const String r_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, icon_fallback)); } - if (search_box->get_text() != "") { + if (!search_box->get_text().is_empty()) { r_item->set_collapsed(false); } else { // Don't collapse the root node or an abstract node on the first tree level. @@ -322,7 +322,7 @@ void CreateDialog::_cleanup() { void CreateDialog::_confirmed() { String selected_item = get_selected_type(); - if (selected_item == String()) { + if (selected_item.is_empty()) { return; } @@ -642,7 +642,7 @@ void CreateDialog::_load_favorites_and_history() { while (!f->eof_reached()) { String l = f->get_line().strip_edges(); - if (l != String()) { + if (!l.is_empty()) { favorite_list.push_back(l); } } diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 71e501056c..4f7dc78017 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -79,7 +79,7 @@ void ScriptEditorDebugger::_put_msg(String p_message, Array p_data) { void ScriptEditorDebugger::debug_copy() { String msg = reason->get_text(); - if (msg == "") { + if (msg.is_empty()) { return; } DisplayServer::get_singleton()->clipboard_set(msg); @@ -312,7 +312,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da if (is_move_to_foreground()) { DisplayServer::get_singleton()->window_move_to_foreground(); } - if (error != "") { + if (!error.is_empty()) { tabs->set_current_tab(0); } profiler->set_enabled(false); @@ -1083,7 +1083,7 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n Resource *res = Object::cast_to<Resource>(p_base); - if (res && res->get_path() != String()) { + if (res && !res->get_path().is_empty()) { String respath = res->get_path(); int pathid = _get_res_path_cache(respath); @@ -1113,7 +1113,7 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p if (p_value.is_ref()) { Ref<Resource> res = p_value; - if (res.is_valid() && res->get_path() != String()) { + if (res.is_valid() && !res->get_path().is_empty()) { Array msg; msg.push_back(pathid); msg.push_back(p_property); @@ -1133,13 +1133,13 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p Resource *res = Object::cast_to<Resource>(p_base); - if (res && res->get_path() != String()) { + if (res && !res->get_path().is_empty()) { String respath = res->get_path(); int pathid = _get_res_path_cache(respath); if (p_value.is_ref()) { Ref<Resource> res2 = p_value; - if (res2.is_valid() && res2->get_path() != String()) { + if (res2.is_valid() && !res2->get_path().is_empty()) { Array msg; msg.push_back(pathid); msg.push_back(p_property); diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index 7ab5d9a97c..1cc8cc01ce 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -75,7 +75,7 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String String path = efsd->get_file_path(i); for (KeyValue<String, String> &E : candidates[file]) { - if (E.value == String()) { + if (E.value.is_empty()) { E.value = path; continue; } @@ -135,7 +135,7 @@ void DependencyEditor::_fix_all() { for (KeyValue<String, Map<String, String>> &E : candidates) { for (const KeyValue<String, String> &F : E.value) { - if (F.value != String()) { + if (!F.value.is_empty()) { remaps[F.key] = F.value; } } diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index f1d427648a..8191b343f7 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -252,17 +252,17 @@ void DocTools::remove_from(const DocTools &p_data) { } void DocTools::add_doc(const DocData::ClassDoc &p_class_doc) { - ERR_FAIL_COND(p_class_doc.name == ""); + ERR_FAIL_COND(p_class_doc.name.is_empty()); class_list[p_class_doc.name] = p_class_doc; } void DocTools::remove_doc(const String &p_class_name) { - ERR_FAIL_COND(p_class_name == "" || !class_list.has(p_class_name)); + ERR_FAIL_COND(p_class_name.is_empty() || !class_list.has(p_class_name)); class_list.erase(p_class_name); } bool DocTools::has_doc(const String &p_class_name) { - if (p_class_name == "") { + if (p_class_name.is_empty()) { return false; } return class_list.has(p_class_name); @@ -437,7 +437,7 @@ void DocTools::generate(bool p_basic_types) { method_list.sort(); for (const MethodInfo &E : method_list) { - if (E.name == "" || (E.name[0] == '_' && !(E.flags & METHOD_FLAG_VIRTUAL))) { + if (E.name.is_empty() || (E.name[0] == '_' && !(E.flags & METHOD_FLAG_VIRTUAL))) { continue; //hidden, don't count } @@ -459,21 +459,21 @@ void DocTools::generate(bool p_basic_types) { } if (E.flags & METHOD_FLAG_CONST) { - if (method.qualifiers != "") { + if (!method.qualifiers.is_empty()) { method.qualifiers += " "; } method.qualifiers += "const"; } if (E.flags & METHOD_FLAG_VARARG) { - if (method.qualifiers != "") { + if (!method.qualifiers.is_empty()) { method.qualifiers += " "; } method.qualifiers += "vararg"; } if (E.flags & METHOD_FLAG_STATIC) { - if (method.qualifiers != "") { + if (!method.qualifiers.is_empty()) { method.qualifiers += " "; } method.qualifiers += "static"; @@ -736,21 +736,21 @@ void DocTools::generate(bool p_basic_types) { DocData::return_doc_from_retinfo(method, mi.return_val); if (mi.flags & METHOD_FLAG_VARARG) { - if (method.qualifiers != "") { + if (!method.qualifiers.is_empty()) { method.qualifiers += " "; } method.qualifiers += "vararg"; } if (mi.flags & METHOD_FLAG_CONST) { - if (method.qualifiers != "") { + if (!method.qualifiers.is_empty()) { method.qualifiers += " "; } method.qualifiers += "const"; } if (mi.flags & METHOD_FLAG_STATIC) { - if (method.qualifiers != "") { + if (!method.qualifiers.is_empty()) { method.qualifiers += " "; } method.qualifiers += "static"; @@ -885,7 +885,7 @@ void DocTools::generate(bool p_basic_types) { md.name = mi.name; if (mi.flags & METHOD_FLAG_VARARG) { - if (md.qualifiers != "") { + if (!md.qualifiers.is_empty()) { md.qualifiers += " "; } md.qualifiers += "vararg"; @@ -1005,7 +1005,7 @@ Error DocTools::load_classes(const String &p_dir) { da->list_dir_begin(); String path; path = da->get_next(); - while (path != String()) { + while (!path.is_empty()) { if (!da->current_is_dir() && path.ends_with("xml")) { Ref<XMLParser> parser = memnew(XMLParser); Error err2 = parser->open(p_dir.plus_file(path)); @@ -1035,7 +1035,7 @@ Error DocTools::erase_classes(const String &p_dir) { da->list_dir_begin(); String path; path = da->get_next(); - while (path != String()) { + while (!path.is_empty()) { if (!da->current_is_dir() && path.ends_with("xml")) { to_erase.push_back(path); } @@ -1236,7 +1236,7 @@ Error DocTools::_load(Ref<XMLParser> parser) { } static void _write_string(FileAccess *f, int p_tablevel, const String &p_string) { - if (p_string == "") { + if (p_string.is_empty()) { return; } String tab; @@ -1254,15 +1254,15 @@ static void _write_method_doc(FileAccess *f, const String &p_name, Vector<DocDat const DocData::MethodDoc &m = p_method_docs[i]; String qualifiers; - if (m.qualifiers != "") { + if (!m.qualifiers.is_empty()) { qualifiers += " qualifiers=\"" + m.qualifiers.xml_escape() + "\""; } _write_string(f, 2, "<" + p_name + " name=\"" + m.name.xml_escape() + "\"" + qualifiers + ">"); - if (m.return_type != "") { + if (!m.return_type.is_empty()) { String enum_text; - if (m.return_enum != String()) { + if (!m.return_enum.is_empty()) { enum_text = " enum=\"" + m.return_enum + "\""; } _write_string(f, 3, "<return type=\"" + m.return_type + "\"" + enum_text + " />"); @@ -1277,11 +1277,11 @@ static void _write_method_doc(FileAccess *f, const String &p_name, Vector<DocDat const DocData::ArgumentDoc &a = m.arguments[j]; String enum_text; - if (a.enumeration != String()) { + if (!a.enumeration.is_empty()) { enum_text = " enum=\"" + a.enumeration + "\""; } - if (a.default_value != "") { + if (!a.default_value.is_empty()) { _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\"" + enum_text + " default=\"" + a.default_value.xml_escape(true) + "\" />"); } else { _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\"" + enum_text + " />"); @@ -1319,7 +1319,7 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str _write_string(f, 0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); String header = "<class name=\"" + c.name + "\""; - if (c.inherits != "") { + if (!c.inherits.is_empty()) { header += " inherits=\"" + c.inherits + "\""; } header += String(" version=\"") + VERSION_BRANCH + "\""; @@ -1353,10 +1353,10 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str for (int i = 0; i < c.properties.size(); i++) { String additional_attributes; - if (c.properties[i].enumeration != String()) { + if (!c.properties[i].enumeration.is_empty()) { additional_attributes += " enum=\"" + c.properties[i].enumeration + "\""; } - if (c.properties[i].default_value != String()) { + if (!c.properties[i].default_value.is_empty()) { additional_attributes += " default=\"" + c.properties[i].default_value.xml_escape(true) + "\""; } @@ -1380,13 +1380,13 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str for (int i = 0; i < c.constants.size(); i++) { const DocData::ConstantDoc &k = c.constants[i]; if (k.is_value_valid) { - if (k.enumeration != String()) { + if (!k.enumeration.is_empty()) { _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\" enum=\"" + k.enumeration + "\">"); } else { _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\">"); } } else { - if (k.enumeration != String()) { + if (!k.enumeration.is_empty()) { _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"platform-dependent\" enum=\"" + k.enumeration + "\">"); } else { _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"platform-dependent\">"); @@ -1406,7 +1406,7 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str for (int i = 0; i < c.theme_properties.size(); i++) { const DocData::ThemeItemDoc &ti = c.theme_properties[i]; - if (ti.default_value != "") { + if (!ti.default_value.is_empty()) { _write_string(f, 2, "<theme_item name=\"" + ti.name + "\" data_type=\"" + ti.data_type + "\" type=\"" + ti.type + "\" default=\"" + ti.default_value.xml_escape(true) + "\">"); } else { _write_string(f, 2, "<theme_item name=\"" + ti.name + "\" data_type=\"" + ti.data_type + "\" type=\"" + ti.type + "\">"); diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 8dd3045887..6c64c53837 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -88,7 +88,7 @@ void EditorAssetInstaller::_item_edited() { String path = item->get_metadata(0); updating = true; - if (path == String() || item == tree->get_root()) { //a dir or root + if (path.is_empty() || item == tree->get_root()) { //a dir or root _update_subitems(item, item->is_checked(0), true); } @@ -212,7 +212,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { depth--; } - if (skip || path == String()) { + if (skip || path.is_empty()) { continue; } @@ -307,7 +307,7 @@ void EditorAssetInstaller::ok_pressed() { if (status_map.has(name) && status_map[name]->is_checked(0)) { String path = status_map[name]->get_metadata(0); - if (path == String()) { // a dir + if (path.is_empty()) { // a dir String dirpath; TreeItem *t = status_map[name]; diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 86da3f89a6..418d7d58ef 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -340,22 +340,22 @@ void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) { } void EditorAutoloadSettings::_autoload_text_submitted(const String p_name) { - if (autoload_add_path->get_text() != "" && _autoload_name_is_valid(p_name, nullptr)) { + if (!autoload_add_path->get_text().is_empty() && _autoload_name_is_valid(p_name, nullptr)) { _autoload_add(); } } void EditorAutoloadSettings::_autoload_path_text_changed(const String p_path) { add_autoload->set_disabled( - p_path == "" || !_autoload_name_is_valid(autoload_add_name->get_text(), nullptr)); + p_path.is_empty() || !_autoload_name_is_valid(autoload_add_name->get_text(), nullptr)); } void EditorAutoloadSettings::_autoload_text_changed(const String p_name) { String error_string; bool is_name_valid = _autoload_name_is_valid(p_name, &error_string); - add_autoload->set_disabled(autoload_add_path->get_text() == "" || !is_name_valid); + add_autoload->set_disabled(autoload_add_path->get_text().is_empty() || !is_name_valid); error_message->set_text(error_string); - error_message->set_visible(autoload_add_name->get_text() != "" && !is_name_valid); + error_message->set_visible(!autoload_add_name->get_text().is_empty() && !is_name_valid); } Node *EditorAutoloadSettings::_create_autoload(const String &p_path) { diff --git a/editor/editor_command_palette.cpp b/editor/editor_command_palette.cpp index 1b1a7a4a09..6bc23c352a 100644 --- a/editor/editor_command_palette.cpp +++ b/editor/editor_command_palette.cpp @@ -164,7 +164,7 @@ void EditorCommandPalette::_sbox_input(const Ref<InputEvent> &p_ie) { void EditorCommandPalette::_confirmed() { TreeItem *selected_option = search_options->get_selected(); String command_key = selected_option != nullptr ? selected_option->get_metadata(0) : ""; - if (command_key != "") { + if (!command_key.is_empty()) { hide(); execute_command(command_key); } diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 6fd8cb47ea..390a2998d6 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -100,7 +100,7 @@ void EditorHistory::_add_object(ObjectID p_object, const String &p_property, int history.resize(current + 1); //clip history to next } - if (p_property != "" && has_prev) { + if (!p_property.is_empty() && has_prev) { //add a sub property History &pr = history.write[current]; h = pr; @@ -566,7 +566,7 @@ void EditorData::remove_scene(int p_idx) { current_edited_scene--; } - if (edited_scene[p_idx].path != String()) { + if (!edited_scene[p_idx].path.is_empty()) { ScriptEditor::get_singleton()->close_builtin_scripts_from_scene(edited_scene[p_idx].path); } @@ -583,7 +583,7 @@ bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String> if (p_node == p_root) { ss = p_node->get_scene_inherited_state(); - } else if (p_node->get_scene_file_path() != String()) { + } else if (!p_node->get_scene_file_path().is_empty()) { ss = p_node->get_scene_instance_state(); } @@ -647,7 +647,7 @@ bool EditorData::check_and_update_scene(int p_idx) { memdelete(edited_scene[p_idx].root); edited_scene.write[p_idx].root = new_scene; - if (new_scene->get_scene_file_path() != "") { + if (!new_scene->get_scene_file_path().is_empty()) { edited_scene.write[p_idx].path = new_scene->get_scene_file_path(); } edited_scene.write[p_idx].selection = new_selection; @@ -682,14 +682,14 @@ void EditorData::set_edited_scene_root(Node *p_root) { ERR_FAIL_INDEX(current_edited_scene, edited_scene.size()); edited_scene.write[current_edited_scene].root = p_root; if (p_root) { - if (p_root->get_scene_file_path() != "") { + if (!p_root->get_scene_file_path().is_empty()) { edited_scene.write[current_edited_scene].path = p_root->get_scene_file_path(); } else { p_root->set_scene_file_path(edited_scene[current_edited_scene].path); } } - if (edited_scene[current_edited_scene].path != "") { + if (!edited_scene[current_edited_scene].path.is_empty()) { edited_scene.write[current_edited_scene].file_modified_time = FileAccess::get_modified_time(edited_scene[current_edited_scene].path); } } @@ -764,7 +764,7 @@ Ref<Script> EditorData::get_scene_root_script(int p_idx) const { Ref<Script> s = edited_scene[p_idx].root->get_script(); if (!s.is_valid() && edited_scene[p_idx].root->get_child_count()) { Node *n = edited_scene[p_idx].root->get_child(0); - while (!s.is_valid() && n && n->get_scene_file_path() == String()) { + while (!s.is_valid() && n && n->get_scene_file_path().is_empty()) { s = n->get_script(); n = n->get_parent(); } @@ -777,7 +777,7 @@ String EditorData::get_scene_title(int p_idx, bool p_always_strip_extension) con if (!edited_scene[p_idx].root) { return TTR("[empty]"); } - if (edited_scene[p_idx].root->get_scene_file_path() == "") { + if (edited_scene[p_idx].root->get_scene_file_path().is_empty()) { return TTR("[unsaved]"); } @@ -818,7 +818,7 @@ String EditorData::get_scene_path(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), String()); if (edited_scene[p_idx].root) { - if (edited_scene[p_idx].root->get_scene_file_path() == "") { + if (edited_scene[p_idx].root->get_scene_file_path().is_empty()) { edited_scene[p_idx].root->set_scene_file_path(edited_scene[p_idx].path); } else { return edited_scene[p_idx].root->get_scene_file_path(); diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp index f91dedf25d..61b655098f 100644 --- a/editor/editor_dir_dialog.cpp +++ b/editor/editor_dir_dialog.cpp @@ -49,7 +49,7 @@ void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p if (!p_item->get_parent()) { p_item->set_text(0, "res://"); } else { - if (!opened_paths.has(path) && (p_select_path == String() || !p_select_path.begins_with(path))) { + if (!opened_paths.has(path) && (p_select_path.is_empty() || !p_select_path.begins_with(path))) { p_item->set_collapsed(true); } diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 55a2c319fe..95affb09b6 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -264,7 +264,7 @@ void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags) String passwd = EditorSettings::get_singleton()->get("filesystem/file_server/password"); r_flags.push_back("--remote-fs"); r_flags.push_back(host + ":" + itos(port)); - if (passwd != "") { + if (!passwd.is_empty()) { r_flags.push_back("--remote-fs-password"); r_flags.push_back(passwd); } @@ -528,7 +528,7 @@ void EditorExportPlatform::_edit_files_with_filter(DirAccess *da, const Vector<S } void EditorExportPlatform::_edit_filter_list(Set<String> &r_list, const String &p_filter, bool exclude) { - if (p_filter == "") { + if (p_filter.is_empty()) { return; } Vector<String> split = p_filter.split(","); @@ -683,12 +683,12 @@ EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_contai result.features_pv.push_back(E); } - if (p_preset->get_custom_features() != String()) { + if (!p_preset->get_custom_features().is_empty()) { Vector<String> tmp_custom_list = p_preset->get_custom_features().split(","); for (int i = 0; i < tmp_custom_list.size(); i++) { String f = tmp_custom_list[i].strip_edges(); - if (f != String()) { + if (!f.is_empty()) { result.features.insert(f); result.features_pv.push_back(f); } @@ -994,12 +994,12 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & Vector<String> custom_list; - if (p_preset->get_custom_features() != String()) { + if (!p_preset->get_custom_features().is_empty()) { Vector<String> tmp_custom_list = p_preset->get_custom_features().split(","); for (int i = 0; i < tmp_custom_list.size(); i++) { String f = tmp_custom_list[i].strip_edges(); - if (f != String()) { + if (!f.is_empty()) { custom_list.push_back(f); } } @@ -1033,14 +1033,14 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & // Store icon and splash images directly, they need to bypass the import system and be loaded as images String icon = ProjectSettings::get_singleton()->get("application/config/icon"); String splash = ProjectSettings::get_singleton()->get("application/boot_splash/image"); - if (icon != String() && FileAccess::exists(icon)) { + if (!icon.is_empty() && FileAccess::exists(icon)) { Vector<uint8_t> array = FileAccess::get_file_as_array(icon); err = p_func(p_udata, icon, array, idx, total, enc_in_filters, enc_ex_filters, key); if (err != OK) { return err; } } - if (splash != String() && FileAccess::exists(splash) && icon != splash) { + if (!splash.is_empty() && FileAccess::exists(splash) && icon != splash) { Vector<uint8_t> array = FileAccess::get_file_as_array(splash); err = p_func(p_udata, splash, array, idx, total, enc_in_filters, enc_ex_filters, key); if (err != OK) { @@ -1359,7 +1359,7 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags String passwd = EditorSettings::get_singleton()->get("filesystem/file_server/password"); r_flags.push_back("--remote-fs"); r_flags.push_back(host + ":" + itos(port)); - if (passwd != "") { + if (!passwd.is_empty()) { r_flags.push_back("--remote-fs-password"); r_flags.push_back(passwd); } @@ -1855,7 +1855,7 @@ Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_pr template_path = template_path.strip_edges(); - if (template_path == String()) { + if (template_path.is_empty()) { if (p_preset->get("binary_format/64_bits")) { if (p_debug) { template_path = find_export_template(debug_file_64); @@ -1871,7 +1871,7 @@ Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_pr } } - if (template_path != String() && !FileAccess::exists(template_path)) { + if (!template_path.is_empty() && !FileAccess::exists(template_path)) { EditorNode::get_singleton()->show_warning(TTR("Template file not found:") + "\n" + template_path); return ERR_FILE_NOT_FOUND; } diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index 78175ff022..2ca91043e1 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -310,7 +310,7 @@ EditorFeatureProfile::EditorFeatureProfile() {} void EditorFeatureProfileManager::_notification(int p_what) { if (p_what == NOTIFICATION_READY) { current_profile = EDITOR_GET("_default_feature_profile"); - if (current_profile != String()) { + if (!current_profile.is_empty()) { current.instantiate(); Error err = current->load_from_file(EditorSettings::get_singleton()->get_feature_profiles_dir().plus_file(current_profile + ".profile")); if (err != OK) { @@ -334,7 +334,7 @@ String EditorFeatureProfileManager::_get_selected_profile() { void EditorFeatureProfileManager::_update_profile_list(const String &p_select_profile) { String selected_profile; - if (p_select_profile == String()) { //default, keep + if (p_select_profile.is_empty()) { //default, keep if (profile_list->get_selected() >= 0) { selected_profile = profile_list->get_item_metadata(profile_list->get_selected()); if (!FileAccess::exists(EditorSettings::get_singleton()->get_feature_profiles_dir().plus_file(selected_profile + ".profile"))) { @@ -352,7 +352,7 @@ void EditorFeatureProfileManager::_update_profile_list(const String &p_select_pr d->list_dir_begin(); while (true) { String f = d->get_next(); - if (f == String()) { + if (f.is_empty()) { break; } @@ -371,7 +371,7 @@ void EditorFeatureProfileManager::_update_profile_list(const String &p_select_pr for (int i = 0; i < profiles.size(); i++) { String name = profiles[i]; - if (i == 0 && selected_profile == String()) { + if (i == 0 && selected_profile.is_empty()) { selected_profile = name; } @@ -386,15 +386,15 @@ void EditorFeatureProfileManager::_update_profile_list(const String &p_select_pr } } - class_list_vbc->set_visible(selected_profile != String()); - property_list_vbc->set_visible(selected_profile != String()); - no_profile_selected_help->set_visible(selected_profile == String()); - profile_actions[PROFILE_CLEAR]->set_disabled(current_profile == String()); - profile_actions[PROFILE_ERASE]->set_disabled(selected_profile == String()); - profile_actions[PROFILE_EXPORT]->set_disabled(selected_profile == String()); - profile_actions[PROFILE_SET]->set_disabled(selected_profile == String()); + class_list_vbc->set_visible(!selected_profile.is_empty()); + property_list_vbc->set_visible(!selected_profile.is_empty()); + no_profile_selected_help->set_visible(selected_profile.is_empty()); + profile_actions[PROFILE_CLEAR]->set_disabled(current_profile.is_empty()); + profile_actions[PROFILE_ERASE]->set_disabled(selected_profile.is_empty()); + profile_actions[PROFILE_EXPORT]->set_disabled(selected_profile.is_empty()); + profile_actions[PROFILE_SET]->set_disabled(selected_profile.is_empty()); - current_profile_name->set_text(current_profile != String() ? current_profile : TTR("(none)")); + current_profile_name->set_text(!current_profile.is_empty() ? current_profile : TTR("(none)")); _update_selected_profile(); } @@ -412,7 +412,7 @@ void EditorFeatureProfileManager::_profile_action(int p_action) { } break; case PROFILE_SET: { String selected = _get_selected_profile(); - ERR_FAIL_COND(selected == String()); + ERR_FAIL_COND(selected.is_empty()); if (selected == current_profile) { return; // Nothing to do here. } @@ -438,7 +438,7 @@ void EditorFeatureProfileManager::_profile_action(int p_action) { } break; case PROFILE_ERASE: { String selected = _get_selected_profile(); - ERR_FAIL_COND(selected == String()); + ERR_FAIL_COND(selected.is_empty()); erase_profile_dialog->set_text(vformat(TTR("Remove currently selected profile, '%s'? Cannot be undone."), selected)); erase_profile_dialog->popup_centered(Size2(240, 60) * EDSCALE); @@ -448,7 +448,7 @@ void EditorFeatureProfileManager::_profile_action(int p_action) { void EditorFeatureProfileManager::_erase_selected_profile() { String selected = _get_selected_profile(); - ERR_FAIL_COND(selected == String()); + ERR_FAIL_COND(selected.is_empty()); DirAccessRef da = DirAccess::open(EditorSettings::get_singleton()->get_feature_profiles_dir()); ERR_FAIL_COND_MSG(!da, "Cannot open directory '" + EditorSettings::get_singleton()->get_feature_profiles_dir() + "'."); @@ -718,7 +718,7 @@ void EditorFeatureProfileManager::_update_selected_profile() { class_list->clear(); String profile = _get_selected_profile(); - if (profile == String()) { //nothing selected, nothing edited + if (profile.is_empty()) { //nothing selected, nothing edited property_list->clear(); edited.unref(); return; @@ -822,7 +822,7 @@ void EditorFeatureProfileManager::_export_profile(const String &p_path) { void EditorFeatureProfileManager::_save_and_update() { String edited_path = _get_selected_profile(); - ERR_FAIL_COND(edited_path == String()); + ERR_FAIL_COND(edited_path.is_empty()); ERR_FAIL_COND(edited.is_null()); edited->save_to_file(EditorSettings::get_singleton()->get_feature_profiles_dir().plus_file(edited_path + ".profile")); diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index b5300bdc1b..a35458d284 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -274,7 +274,7 @@ void EditorFileDialog::_post_popup() { file_box->set_visible(true); } - if (is_visible() && get_current_file() != "") { + if (is_visible() && !get_current_file().is_empty()) { _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); } diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 4f02a82fb5..d515b58e37 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -241,7 +241,7 @@ void EditorFileSystem::_scan_filesystem() { first = false; continue; } - if (l == String()) { + if (l.is_empty()) { continue; } @@ -295,7 +295,7 @@ void EditorFileSystem::_scan_filesystem() { { FileAccessRef f2 = FileAccess::open(update_cache, FileAccess::READ); String l = f2->get_line().strip_edges(); - while (l != String()) { + while (!l.is_empty()) { file_cache.erase(l); //erase cache for this, so it gets updated l = f2->get_line().strip_edges(); } @@ -405,7 +405,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo return false; //parse error, try reimport manually (Avoid reimport loop on broken file) } - if (assign != String()) { + if (!assign.is_empty()) { if (assign.begins_with("path")) { to_check.push_back(value); } else if (assign == "files") { @@ -476,7 +476,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo memdelete(md5s); return false; // parse error } - if (assign != String()) { + if (!assign.is_empty()) { if (!p_only_imported_files) { if (assign == "source_md5") { source_md5 = value; @@ -497,11 +497,11 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo //check source md5 matching if (!p_only_imported_files) { - if (source_file != String() && source_file != p_path) { + if (!source_file.is_empty() && source_file != p_path) { return true; //file was moved, reimport } - if (source_md5 == String()) { + if (source_md5.is_empty()) { return true; //lacks md5, so just reimport } @@ -510,7 +510,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo return true; } - if (dest_files.size() && dest_md5 != String()) { + if (dest_files.size() && !dest_md5.is_empty()) { md5 = FileAccess::get_multiple_md5(dest_files); if (md5 != dest_md5) { return true; @@ -710,7 +710,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess da->list_dir_begin(); while (true) { String f = da->get_next(); - if (f == "") { + if (f.is_empty()) { break; } @@ -820,7 +820,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess scan_actions.push_back(ia); } - if (fc->type == String()) { + if (fc->type.is_empty()) { fi->type = ResourceLoader::get_resource_type(path); fi->import_group_file = ResourceLoader::get_import_group_file(path); //there is also the chance that file type changed due to reimport, must probably check this somehow here (or kind of note it for next time in another file?) @@ -932,7 +932,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const da->list_dir_begin(); while (true) { String f = da->get_next(); - if (f == "") { + if (f.is_empty()) { break; } @@ -1246,7 +1246,7 @@ void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory *p_dir, p_file->store_line("::" + p_dir->get_path() + "::" + String::num(p_dir->modified_time)); for (int i = 0; i < p_dir->files.size(); i++) { - if (p_dir->files[i]->import_group_file != String()) { + if (!p_dir->files[i]->import_group_file.is_empty()) { group_file_cache.insert(p_dir->files[i]->import_group_file); } String s = p_dir->files[i]->file + "::" + p_dir->files[i]->type + "::" + itos(p_dir->files[i]->uid) + "::" + itos(p_dir->files[i]->modified_time) + "::" + itos(p_dir->files[i]->import_modified_time) + "::" + itos(p_dir->files[i]->import_valid) + "::" + p_dir->files[i]->import_group_file + "::" + p_dir->files[i]->script_class_name + "<>" + p_dir->files[i]->script_class_extends + "<>" + p_dir->files[i]->script_class_icon_path; @@ -1386,7 +1386,7 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p f = f.substr(6, f.length()); f = f.replace("\\", "/"); - if (f == String()) { + if (f.is_empty()) { return filesystem; } @@ -1465,7 +1465,7 @@ void EditorFileSystem::_scan_script_classes(EditorFileSystemDirectory *p_dir) { int filecount = p_dir->files.size(); const EditorFileSystemDirectory::FileInfo *const *files = p_dir->files.ptr(); for (int i = 0; i < filecount; i++) { - if (files[i]->script_class_name == String()) { + if (files[i]->script_class_name.is_empty()) { continue; } @@ -1545,7 +1545,7 @@ void EditorFileSystem::update_file(const String &p_file) { } String type = ResourceLoader::get_resource_type(p_file); - if (type == "" && textfile_extensions.has(p_file.get_extension())) { + if (type.is_empty() && textfile_extensions.has(p_file.get_extension())) { type = "TextFile"; } ResourceUID::ID uid = ResourceLoader::get_resource_uid(p_file); @@ -1616,9 +1616,9 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector ERR_CONTINUE(err != OK); ERR_CONTINUE(!config->has_section_key("remap", "importer")); String file_importer_name = config->get_value("remap", "importer"); - ERR_CONTINUE(file_importer_name == String()); + ERR_CONTINUE(file_importer_name.is_empty()); - if (importer_name != String() && importer_name != file_importer_name) { + if (!importer_name.is_empty() && importer_name != file_importer_name) { EditorNode::get_singleton()->show_warning(vformat(TTR("There are multiple importers for different types pointing to file %s, import aborted"), p_group_file)); ERR_FAIL_V(ERR_FILE_CORRUPT); } @@ -1656,7 +1656,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector return OK; // (do nothing) } - ERR_FAIL_COND_V(importer_name == String(), ERR_UNCONFIGURED); + ERR_FAIL_COND_V(importer_name.is_empty(), ERR_UNCONFIGURED); Ref<ResourceImporter> importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(importer_name); @@ -1677,7 +1677,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector if (version > 0) { f->store_line("importer_version=" + itos(version)); } - if (importer->get_resource_type() != "") { + if (!importer->get_resource_type().is_empty()) { f->store_line("type=\"" + importer->get_resource_type() + "\""); } @@ -1759,7 +1759,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector if (ResourceCache::has(file)) { Resource *r = ResourceCache::get(file); - if (r->get_import_path() != String()) { + if (!r->get_import_path().is_empty()) { String dst_path = ResourceFormatImporter::get_singleton()->get_internal_resource_path(file); r->set_import_path(dst_path); r->set_import_last_modified_time(0); @@ -1783,7 +1783,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName Map<StringName, Variant> params; String importer_name; //empty by default though - if (p_custom_importer != String()) { + if (!p_custom_importer.is_empty()) { importer_name = p_custom_importer; } if (p_custom_options != nullptr) { @@ -1808,7 +1808,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName } if (cf->has_section("remap")) { - if (p_custom_importer == String()) { + if (p_custom_importer.is_empty()) { importer_name = cf->get_value("remap", "importer"); } @@ -1834,7 +1834,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName Ref<ResourceImporter> importer; bool load_default = false; //find the importer - if (importer_name != "") { + if (!importer_name.is_empty()) { importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(importer_name); } @@ -1894,7 +1894,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName if (version > 0) { f->store_line("importer_version=" + itos(version)); } - if (importer->get_resource_type() != "") { + if (!importer->get_resource_type().is_empty()) { f->store_line("type=\"" + importer->get_resource_type() + "\""); } @@ -1907,7 +1907,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName Vector<String> dest_paths; if (err == OK) { - if (importer->get_save_extension() == "") { + if (importer->get_save_extension().is_empty()) { //no path } else if (import_variants.size()) { //import with variants @@ -2003,7 +2003,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName if (ResourceCache::has(p_file)) { Resource *r = ResourceCache::get(p_file); - if (r->get_import_path() != String()) { + if (!r->get_import_path().is_empty()) { String dst_path = ResourceFormatImporter::get_singleton()->get_internal_resource_path(p_file); r->set_import_path(dst_path); r->set_import_last_modified_time(0); @@ -2062,7 +2062,7 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { groups_to_reimport.insert(file); //groups do not belong to grups group_file = String(); - } else if (group_file != String()) { + } else if (!group_file.is_empty()) { //it's a group file, add group to import and skip this file groups_to_reimport.insert(group_file); } else { diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp index c98606730c..b8341ee406 100644 --- a/editor/editor_folding.cpp +++ b/editor/editor_folding.cpp @@ -113,7 +113,7 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p if (E.usage & PROPERTY_USAGE_EDITOR) { if (E.type == Variant::OBJECT) { RES res = p_node->get(E.name); - if (res.is_valid() && !resources.has(res) && res->get_path() != String() && !res->get_path().is_resource_file()) { + if (res.is_valid() && !resources.has(res) && !res->get_path().is_empty() && !res->get_path().is_resource_file()) { Vector<String> res_unfolds = _get_unfolds(res.ptr()); resource_folds.push_back(res->get_path()); resource_folds.push_back(res_unfolds); @@ -243,8 +243,8 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) { //can unfold if (E.usage & PROPERTY_USAGE_EDITOR) { - if (group != "") { //group - if (group_base == String() || E.name.begins_with(group_base)) { + if (!group.is_empty()) { //group + if (group_base.is_empty() || E.name.begins_with(group_base)) { bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E.name); if (can_revert) { unfold_group.insert(group); @@ -262,7 +262,7 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) { if (E.type == Variant::OBJECT) { RES res = p_object->get(E.name); - if (res.is_valid() && !resources.has(res) && res->get_path() != String() && !res->get_path().is_resource_file()) { + if (res.is_valid() && !resources.has(res) && !res->get_path().is_empty() && !res->get_path().is_resource_file()) { resources.insert(res); _do_object_unfolds(res.ptr(), resources); } diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index a644e3e991..c65bfa6472 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -78,7 +78,7 @@ } \ { \ Dictionary variations; \ - if (m_variations != String()) { \ + if (!m_variations.is_empty()) { \ Vector<String> variation_tags = m_variations.split(","); \ for (int i = 0; i < variation_tags.size(); i++) { \ Vector<String> tokens = variation_tags[i].split("="); \ @@ -104,7 +104,7 @@ } \ { \ Dictionary variations; \ - if (m_variations != String()) { \ + if (!m_variations.is_empty()) { \ Vector<String> variation_tags = m_variations.split(","); \ for (int i = 0; i < variation_tags.size(); i++) { \ Vector<String> tokens = variation_tags[i].split("="); \ @@ -130,7 +130,7 @@ } \ { \ Dictionary variations; \ - if (m_variations != String()) { \ + if (!m_variations.is_empty()) { \ Vector<String> variation_tags = m_variations.split(","); \ for (int i = 0; i < variation_tags.size(); i++) { \ Vector<String> tokens = variation_tags[i].split("="); \ diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 56718e4090..fc1e7ef389 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -250,7 +250,7 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview class_desc->add_text(" "); } - if (p_overview && p_method.description != "") { + if (p_overview && !p_method.description.is_empty()) { class_desc->push_meta("@method " + p_method.name); } @@ -258,7 +258,7 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview _add_text(p_method.name); class_desc->pop(); - if (p_overview && p_method.description != "") { + if (p_overview && !p_method.description.is_empty()) { class_desc->pop(); //meta } @@ -275,7 +275,7 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview _add_text(p_method.arguments[j].name); class_desc->add_text(": "); _add_type(p_method.arguments[j].type, p_method.arguments[j].enumeration); - if (p_method.arguments[j].default_value != "") { + if (!p_method.arguments[j].default_value.is_empty()) { class_desc->push_color(symbol_color); class_desc->add_text(" = "); class_desc->pop(); @@ -301,7 +301,7 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview class_desc->push_color(symbol_color); class_desc->add_text(")"); class_desc->pop(); - if (p_method.qualifiers != "") { + if (!p_method.qualifiers.is_empty()) { class_desc->push_color(qualifier_color); class_desc->add_text(" "); _add_text(p_method.qualifiers); @@ -375,7 +375,7 @@ void EditorHelp::_update_method_list(const Vector<DocData::MethodDoc> p_methods, if (i < m.size() - 1 && new_prefix == m[i + 1].name.substr(0, 3) && new_prefix != group_prefix) { is_new_group = i > 0; group_prefix = new_prefix; - } else if (group_prefix != "" && new_prefix != group_prefix) { + } else if (!group_prefix.is_empty() && new_prefix != group_prefix) { is_new_group = true; group_prefix = ""; } @@ -387,7 +387,7 @@ void EditorHelp::_update_method_list(const Vector<DocData::MethodDoc> p_methods, class_desc->pop(); //cell } - if (m[i].description != "" || m[i].errors_returned.size() > 0) { + if (!m[i].description.is_empty() || m[i].errors_returned.size() > 0) { r_method_descrpitons = true; } @@ -521,19 +521,19 @@ void EditorHelp::_update_doc() { // Inheritance tree // Ascendents - if (cd.inherits != "") { + if (!cd.inherits.is_empty()) { class_desc->push_color(title_color); class_desc->push_font(doc_font); class_desc->add_text(TTR("Inherits:") + " "); String inherits = cd.inherits; - while (inherits != "") { + while (!inherits.is_empty()) { _add_type(inherits); inherits = doc->class_list[inherits].inherits; - if (inherits != "") { + if (!inherits.is_empty()) { class_desc->add_text(" < "); } } @@ -577,7 +577,7 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); // Brief description - if (cd.brief_description != "") { + if (!cd.brief_description.is_empty()) { class_desc->push_color(text_color); class_desc->push_font(doc_bold_font); class_desc->push_indent(1); @@ -591,7 +591,7 @@ void EditorHelp::_update_doc() { } // Class description - if (cd.description != "") { + if (!cd.description.is_empty()) { section_line.push_back(Pair<String, int>(TTR("Description"), class_desc->get_line_count() - 2)); description_line = class_desc->get_line_count() - 2; class_desc->push_color(title_color); @@ -694,16 +694,16 @@ void EditorHelp::_update_doc() { bool describe = false; - if (cd.properties[i].setter != "") { + if (!cd.properties[i].setter.is_empty()) { skip_methods.insert(cd.properties[i].setter); describe = true; } - if (cd.properties[i].getter != "") { + if (!cd.properties[i].getter.is_empty()) { skip_methods.insert(cd.properties[i].getter); describe = true; } - if (cd.properties[i].description != "") { + if (!cd.properties[i].description.is_empty()) { describe = true; } @@ -735,7 +735,7 @@ void EditorHelp::_update_doc() { class_desc->push_cell(); class_desc->push_font(doc_code_font); - if (cd.properties[i].default_value != "") { + if (!cd.properties[i].default_value.is_empty()) { class_desc->push_color(symbol_color); if (cd.properties[i].overridden) { class_desc->add_text(" ["); @@ -764,18 +764,18 @@ void EditorHelp::_update_doc() { class_desc->push_cell(); class_desc->push_font(doc_code_font); - if (cd.is_script_doc && (cd.properties[i].setter != "" || cd.properties[i].getter != "")) { + if (cd.is_script_doc && (!cd.properties[i].setter.is_empty() || !cd.properties[i].getter.is_empty())) { class_desc->push_color(symbol_color); class_desc->add_text(" [" + TTR("property:") + " "); class_desc->pop(); // color - if (cd.properties[i].setter != "") { + if (!cd.properties[i].setter.is_empty()) { class_desc->push_color(value_color); class_desc->add_text("setter"); class_desc->pop(); // color } - if (cd.properties[i].getter != "") { - if (cd.properties[i].setter != "") { + if (!cd.properties[i].getter.is_empty()) { + if (!cd.properties[i].setter.is_empty()) { class_desc->push_color(symbol_color); class_desc->add_text(", "); class_desc->pop(); // color @@ -914,7 +914,7 @@ void EditorHelp::_update_doc() { class_desc->pop(); // Theme item default value. - if (cd.theme_properties[i].default_value != "") { + if (!cd.theme_properties[i].default_value.is_empty()) { class_desc->push_color(symbol_color); class_desc->add_text(" [" + TTR("default:") + " "); class_desc->pop(); @@ -929,7 +929,7 @@ void EditorHelp::_update_doc() { class_desc->pop(); // monofont // Theme item description. - if (cd.theme_properties[i].description != "") { + if (!cd.theme_properties[i].description.is_empty()) { class_desc->push_font(doc_font); class_desc->push_color(comment_color); class_desc->push_indent(1); @@ -985,7 +985,7 @@ void EditorHelp::_update_doc() { _add_text(cd.signals[i].arguments[j].name); class_desc->add_text(": "); _add_type(cd.signals[i].arguments[j].type); - if (cd.signals[i].arguments[j].default_value != "") { + if (!cd.signals[i].arguments[j].default_value.is_empty()) { class_desc->push_color(symbol_color); class_desc->add_text(" = "); class_desc->pop(); @@ -999,7 +999,7 @@ void EditorHelp::_update_doc() { class_desc->add_text(")"); class_desc->pop(); class_desc->pop(); // end monofont - if (cd.signals[i].description != "") { + if (!cd.signals[i].description.is_empty()) { class_desc->push_font(doc_font); class_desc->push_color(comment_color); class_desc->push_indent(1); @@ -1114,7 +1114,7 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); - if (enum_list[i].description.strip_edges() != "") { + if (!enum_list[i].description.strip_edges().is_empty()) { class_desc->push_font(doc_font); class_desc->push_color(comment_color); _add_text(DTR(enum_list[i].description)); @@ -1183,7 +1183,7 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); - if (constants[i].description != "") { + if (!constants[i].description.is_empty()) { class_desc->push_font(doc_font); class_desc->push_color(comment_color); _add_text(DTR(constants[i].description)); @@ -1239,7 +1239,7 @@ void EditorHelp::_update_doc() { _add_text(cd.properties[i].name); class_desc->pop(); // color - if (cd.properties[i].default_value != "") { + if (!cd.properties[i].default_value.is_empty()) { class_desc->push_color(symbol_color); class_desc->add_text(" [" + TTR("default:") + " "); class_desc->pop(); // color @@ -1253,18 +1253,18 @@ void EditorHelp::_update_doc() { class_desc->pop(); // color } - if (cd.is_script_doc && (cd.properties[i].setter != "" || cd.properties[i].getter != "")) { + if (cd.is_script_doc && (!cd.properties[i].setter.is_empty() || !cd.properties[i].getter.is_empty())) { class_desc->push_color(symbol_color); class_desc->add_text(" [" + TTR("property:") + " "); class_desc->pop(); // color - if (cd.properties[i].setter != "") { + if (!cd.properties[i].setter.is_empty()) { class_desc->push_color(value_color); class_desc->add_text("setter"); class_desc->pop(); // color } - if (cd.properties[i].getter != "") { - if (cd.properties[i].setter != "") { + if (!cd.properties[i].getter.is_empty()) { + if (!cd.properties[i].setter.is_empty()) { class_desc->push_color(symbol_color); class_desc->add_text(", "); class_desc->pop(); // color @@ -1289,7 +1289,7 @@ void EditorHelp::_update_doc() { method_map[methods[j].name] = methods[j]; } - if (cd.properties[i].setter != "") { + if (!cd.properties[i].setter.is_empty()) { class_desc->push_cell(); class_desc->pop(); // cell @@ -1313,7 +1313,7 @@ void EditorHelp::_update_doc() { method_line[cd.properties[i].setter] = property_line[cd.properties[i].name]; } - if (cd.properties[i].getter != "") { + if (!cd.properties[i].getter.is_empty()) { class_desc->push_cell(); class_desc->pop(); // cell diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index 578e21861e..bf7280dfd0 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -161,7 +161,7 @@ void EditorHelpSearch::popup_dialog(const String &p_term) { popup_centered_ratio(0.5F); } - if (p_term == "") { + if (p_term.is_empty()) { search_box->clear(); } else { if (old_term == p_term) { @@ -331,7 +331,7 @@ bool EditorHelpSearch::Runner::_phase_match_classes() { // Match class name. if (search_flags & SEARCH_CLASSES) { - match.name = term == "" || _match_string(term, class_doc.name); + match.name = term.is_empty() || _match_string(term, class_doc.name); } // Match members if the term is long enough. @@ -513,7 +513,7 @@ TreeItem *EditorHelpSearch::Runner::_create_class_hierarchy(const ClassMatch &p_ // Ensure parent nodes are created first. TreeItem *parent = root_item; - if (p_match.doc->inherits != "") { + if (!p_match.doc->inherits.is_empty()) { if (class_items.has(p_match.doc->inherits)) { parent = class_items[p_match.doc->inherits]; } else { @@ -558,7 +558,7 @@ TreeItem *EditorHelpSearch::Runner::_create_method_item(TreeItem *p_parent, cons for (int i = 0; i < p_doc->arguments.size(); i++) { const DocData::ArgumentDoc &arg = p_doc->arguments[i]; tooltip += arg.type + " " + arg.name; - if (arg.default_value != "") { + if (!arg.default_value.is_empty()) { tooltip += " = " + arg.default_value; } if (i < p_doc->arguments.size() - 1) { @@ -574,7 +574,7 @@ TreeItem *EditorHelpSearch::Runner::_create_signal_item(TreeItem *p_parent, cons for (int i = 0; i < p_doc->arguments.size(); i++) { const DocData::ArgumentDoc &arg = p_doc->arguments[i]; tooltip += arg.type + " " + arg.name; - if (arg.default_value != "") { + if (!arg.default_value.is_empty()) { tooltip += " = " + arg.default_value; } if (i < p_doc->arguments.size() - 1) { diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 8187f982e1..14185ce2a4 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -2239,7 +2239,7 @@ void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref<Edit ep->property_usage = 0; } - if (F.label != String()) { + if (!F.label.is_empty()) { ep->set_label(F.label); } @@ -2438,7 +2438,7 @@ void EditorInspector::update_tree() { } } if (category->icon.is_null()) { - if (type != String()) { // Can happen for built-in scripts. + if (!type.is_empty()) { // Can happen for built-in scripts. category->icon = EditorNode::get_singleton()->get_class_icon(type, "Object"); } } @@ -2459,7 +2459,7 @@ void EditorInspector::update_tree() { class_descr_cache[type2] = descr; } - category->set_tooltip(p.name + "::" + (class_descr_cache[type2] == "" ? "" : class_descr_cache[type2])); + category->set_tooltip(p.name + "::" + (class_descr_cache[type2].is_empty() ? "" : class_descr_cache[type2])); } // Add editors at the start of a category. @@ -2529,7 +2529,7 @@ void EditorInspector::update_tree() { } } else { // Check if we exit or not a subgroup. If there is a prefix, remove it from the property label string. - if (subgroup != "" && subgroup_base != "") { + if (!subgroup.is_empty() && !subgroup_base.is_empty()) { if (path.begins_with(subgroup_base)) { path = path.trim_prefix(subgroup_base); } else if (subgroup_base.begins_with(path)) { @@ -2540,7 +2540,7 @@ void EditorInspector::update_tree() { } // Check if we exit or not a group. If there is a prefix, remove it from the property label string. - if (group != "" && group_base != "" && subgroup == "") { + if (!group.is_empty() && !group_base.is_empty() && subgroup.is_empty()) { if (path.begins_with(group_base)) { path = path.trim_prefix(group_base); } else if (group_base.begins_with(path)) { @@ -2552,10 +2552,10 @@ void EditorInspector::update_tree() { } // Add the group and subgroup to the path. - if (subgroup != "") { + if (!subgroup.is_empty()) { path = subgroup + "/" + path; } - if (group != "") { + if (!group.is_empty()) { path = group + "/" + path; } } @@ -2584,7 +2584,7 @@ void EditorInspector::update_tree() { } // Ignore properties that do not fit the filter. - if (use_filter && filter != "") { + if (use_filter && !filter.is_empty()) { if (!filter.is_subsequence_ofi(path) && !filter.is_subsequence_ofi(property_label_string) && property_prefix.to_lower().find(filter.to_lower()) == -1) { continue; } @@ -2707,7 +2707,7 @@ void EditorInspector::update_tree() { // Get the class name. StringName classname = object->get_class_name(); - if (object_class != String()) { + if (!object_class.is_empty()) { classname = object_class; } @@ -2729,7 +2729,7 @@ void EditorInspector::update_tree() { // Build the property description String and add it to the cache. DocTools *dd = EditorHelp::get_doc_data(); Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(classname); - while (F && descr == String()) { + while (F && descr.is_empty()) { for (int i = 0; i < F->get().properties.size(); i++) { if (F->get().properties[i].name == propname.operator String()) { descr = DTR(F->get().properties[i].description); @@ -2781,7 +2781,7 @@ void EditorInspector::update_tree() { //and set label? } - if (F.label != String()) { + if (!F.label.is_empty()) { ep->set_label(F.label); } else { // Use the existing one. @@ -2820,7 +2820,7 @@ void EditorInspector::update_tree() { ep->connect("multiple_properties_changed", callable_mp(this, &EditorInspector::_multiple_properties_changed)); ep->connect("resource_selected", callable_mp(this, &EditorInspector::_resource_selected), varray(), CONNECT_DEFERRED); ep->connect("object_id_selected", callable_mp(this, &EditorInspector::_object_id_selected), varray(), CONNECT_DEFERRED); - if (doc_hint != String()) { + if (!doc_hint.is_empty()) { ep->set_tooltip(property_prefix + p.name + "::" + doc_hint); } else { ep->set_tooltip(property_prefix + p.name); @@ -3050,7 +3050,7 @@ void EditorInspector::_edit_request_change(Object *p_object, const String &p_pro return; } - if (p_property == String()) { + if (p_property.is_empty()) { update_tree_pending = true; } else { pending.insert(p_property); diff --git a/editor/editor_layouts_dialog.cpp b/editor/editor_layouts_dialog.cpp index 4cdeeb2396..7c8965d6f4 100644 --- a/editor/editor_layouts_dialog.cpp +++ b/editor/editor_layouts_dialog.cpp @@ -74,7 +74,7 @@ void EditorLayoutsDialog::ok_pressed() { for (int i = 0; i < selected_items.size(); ++i) { emit_signal(SNAME("name_confirmed"), layout_names->get_item_text(selected_items[i])); } - } else if (name->is_visible() && name->get_text() != "") { + } else if (name->is_visible() && !name->get_text().is_empty()) { emit_signal(SNAME("name_confirmed"), name->get_text()); } } diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index 5ace9ae03e..7bd98b0f0b 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -162,11 +162,11 @@ void EditorLog::_clear_request() { void EditorLog::_copy_request() { String text = log->get_selected_text(); - if (text == "") { + if (text.is_empty()) { text = log->get_text(); } - if (text != "") { + if (!text.is_empty()) { DisplayServer::get_singleton()->clipboard_set(text); } } @@ -237,7 +237,7 @@ void EditorLog::_add_log_line(LogMessage &p_message, bool p_replace_previous) { // Only add the message to the log if it passes the filters. bool filter_active = type_filter_map[p_message.type]->is_active(); String search_text = search_box->get_text(); - bool search_match = search_text == String() || p_message.text.findn(search_text) > -1; + bool search_match = search_text.is_empty() || p_message.text.findn(search_text) > -1; if (!filter_active || !search_match) { return; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 3f20734e3f..00a776ba4d 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -858,7 +858,7 @@ void EditorNode::_resources_changed(const Vector<String> &p_resources) { continue; } - if (res->get_import_path() != String()) { + if (!res->get_import_path().is_empty()) { // this is an imported resource, will be reloaded if reimported via the _resources_reimported() callback continue; } @@ -886,7 +886,7 @@ void EditorNode::_fs_changed() { // FIXME: Move this to a cleaner location, it's hacky to do this is _fs_changed. String export_error; - if (export_defer.preset != "" && !EditorFileSystem::get_singleton()->is_scanning()) { + if (!export_defer.preset.is_empty() && !EditorFileSystem::get_singleton()->is_scanning()) { String preset_name = export_defer.preset; // Ensures export_project does not loop infinitely, because notifications may // come during the export. @@ -1006,7 +1006,7 @@ void EditorNode::_sources_changed(bool p_exist) { _load_docks(); - if (defer_load_scene != "") { + if (!defer_load_scene.is_empty()) { load_scene(defer_load_scene); defer_load_scene = ""; } @@ -1242,7 +1242,7 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String preferred.move_to_front(tres_element); } - if (p_at_path != String()) { + if (!p_at_path.is_empty()) { file->set_current_dir(p_at_path); if (p_resource->get_path().is_resource_file()) { file->set_current_file(p_resource->get_path().get_file()); @@ -1254,7 +1254,7 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String file->set_current_file(String()); } } - } else if (p_resource->get_path() != "") { + } else if (!p_resource->get_path().is_empty()) { file->set_current_path(p_resource->get_path()); if (extensions.size()) { String ext = p_resource->get_path().get_extension().to_lower(); @@ -1676,7 +1676,7 @@ void EditorNode::_save_scene(String p_file, int idx) { return; } - if (scene->get_scene_file_path() != String() && _validate_scene_recursive(scene->get_scene_file_path(), scene)) { + if (!scene->get_scene_file_path().is_empty() && _validate_scene_recursive(scene->get_scene_file_path(), scene)) { show_accept(TTR("This scene can't be saved because there is a cyclic instancing inclusion.\nPlease resolve it and then attempt to save again."), TTR("OK")); return; } @@ -1780,7 +1780,7 @@ void EditorNode::restart_editor() { args.push_back("--path"); args.push_back(ProjectSettings::get_singleton()->get_resource_path()); args.push_back("-e"); - if (to_reopen != String()) { + if (!to_reopen.is_empty()) { args.push_back(to_reopen); } @@ -1792,13 +1792,13 @@ void EditorNode::_save_all_scenes() { for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { Node *scene = editor_data.get_edited_scene_root(i); if (scene) { - if (scene->get_scene_file_path() != "" && DirAccess::exists(scene->get_scene_file_path().get_base_dir())) { + if (!scene->get_scene_file_path().is_empty() && DirAccess::exists(scene->get_scene_file_path().get_base_dir())) { if (i != editor_data.get_edited_scene()) { _save_scene(scene->get_scene_file_path(), i); } else { _save_scene_with_preview(scene->get_scene_file_path()); } - } else if (scene->get_scene_file_path() != "") { + } else if (!scene->get_scene_file_path().is_empty()) { all_saved = false; } } @@ -1818,7 +1818,7 @@ void EditorNode::_mark_unsaved_scenes() { } String path = node->get_scene_file_path(); - if (!(path == String() || FileAccess::exists(path))) { + if (!(path.is_empty() || FileAccess::exists(path))) { if (i == editor_data.get_edited_scene()) { set_current_version(-1); } else { @@ -2080,7 +2080,7 @@ void EditorNode::push_item(Object *p_object, const String &p_property, bool p_in if (id != editor_history.get_current()) { if (p_inspector_only) { editor_history.add_object_inspector_only(id); - } else if (p_property == "") { + } else if (p_property.is_empty()) { editor_history.add_object(id); } else { editor_history.add_object(id, p_property); @@ -2193,7 +2193,7 @@ void EditorNode::_edit_current() { inspector_dock->update(nullptr); } - if (get_edited_scene() && get_edited_scene()->get_scene_file_path() != String()) { + if (get_edited_scene() && !get_edited_scene()->get_scene_file_path().is_empty()) { String source_scene = get_edited_scene()->get_scene_file_path(); if (FileAccess::exists(source_scene + ".import")) { editable_warning = TTR("This scene was imported, so changes to it won't be kept.\nInstancing it or inheriting will allow making changes to it.\nPlease read the documentation relevant to importing scenes to better understand this workflow."); @@ -2316,7 +2316,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) { String run_filename; - if (p_current || (editor_data.get_edited_scene_root() && p_custom != String() && p_custom == editor_data.get_edited_scene_root()->get_scene_file_path())) { + if (p_current || (editor_data.get_edited_scene_root() && !p_custom.is_empty() && p_custom == editor_data.get_edited_scene_root()->get_scene_file_path())) { Node *scene = editor_data.get_edited_scene_root(); if (!scene) { @@ -2324,7 +2324,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) { return; } - if (scene->get_scene_file_path() == "") { + if (scene->get_scene_file_path().is_empty()) { current_option = -1; _menu_option(FILE_SAVE_AS_SCENE); // Set the option to save and run so when the dialog is accepted, the scene runs. @@ -2334,11 +2334,11 @@ void EditorNode::_run(bool p_current, const String &p_custom) { } run_filename = scene->get_scene_file_path(); - } else if (p_custom != "") { + } else if (!p_custom.is_empty()) { run_filename = p_custom; } - if (run_filename == "") { + if (run_filename.is_empty()) { // evidently, run the scene if (!ensure_main_scene(false)) { return; @@ -2349,7 +2349,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) { if (unsaved_cache) { Node *scene = editor_data.get_edited_scene_root(); - if (scene && scene->get_scene_file_path() != "") { // Only autosave if there is a scene and if it has a path. + if (scene && !scene->get_scene_file_path().is_empty()) { // Only autosave if there is a scene and if it has a path. _save_scene_with_preview(scene->get_scene_file_path()); } } @@ -2381,7 +2381,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) { if (p_current) { play_scene_button->set_pressed(true); play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); - } else if (p_custom != "") { + } else if (!p_custom.is_empty()) { run_custom_filename = p_custom; play_custom_scene_button->set_pressed(true); play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); @@ -2501,7 +2501,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { if (scene_root) { String scene_filename = scene_root->get_scene_file_path(); save_confirmation->get_ok_button()->set_text(TTR("Save & Close")); - save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene_filename != "" ? scene_filename : "unsaved scene")); + save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), !scene_filename.is_empty() ? scene_filename : "unsaved scene")); save_confirmation->popup_centered(); break; } @@ -2519,7 +2519,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { case FILE_SAVE_SCENE: { int scene_idx = (p_option == FILE_SAVE_SCENE) ? -1 : tab_closing; Node *scene = editor_data.get_edited_scene_root(scene_idx); - if (scene && scene->get_scene_file_path() != "") { + if (scene && !scene->get_scene_file_path().is_empty()) { if (DirAccess::exists(scene->get_scene_file_path().get_base_dir())) { if (scene_idx != editor_data.get_edited_scene()) { _save_scene_with_preview(scene->get_scene_file_path(), scene_idx); @@ -2575,7 +2575,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); } - if (scene->get_scene_file_path() != "") { + if (!scene->get_scene_file_path().is_empty()) { String path = scene->get_scene_file_path(); file->set_current_path(path); if (extensions.size()) { @@ -2649,7 +2649,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { if (!editor_data.get_undo_redo().undo()) { log->add_message(TTR("Nothing to undo."), EditorLog::MSG_TYPE_EDITOR); - } else if (action != "") { + } else if (!action.is_empty()) { log->add_message(vformat(TTR("Undo: %s"), action), EditorLog::MSG_TYPE_EDITOR); } } @@ -2676,7 +2676,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { String filename = scene->get_scene_file_path(); - if (filename == String()) { + if (filename.is_empty()) { show_warning(TTR("Can't reload a scene that was never saved.")); break; } @@ -2746,7 +2746,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { case FILE_SHOW_IN_FILESYSTEM: { String path = editor_data.get_scene_path(editor_data.get_edited_scene()); - if (path != String()) { + if (!path.is_empty()) { filesystem_dock->navigate_to_path(path); } } break; @@ -3011,7 +3011,7 @@ void EditorNode::_discard_changes(const String &p_str) { Node *scene = editor_data.get_edited_scene_root(tab_closing); if (scene != nullptr) { String scene_filename = scene->get_scene_file_path(); - if (scene_filename != "") { + if (!scene_filename.is_empty()) { previous_scenes.push_back(scene_filename); } } @@ -3138,7 +3138,7 @@ void EditorNode::_editor_select(int p_which) { } void EditorNode::select_editor_by_name(const String &p_name) { - ERR_FAIL_COND(p_name == ""); + ERR_FAIL_COND(p_name.is_empty()); for (int i = 0; i < main_editor_buttons.size(); i++) { if (main_editor_buttons[i]->get_text() == p_name) { @@ -4491,13 +4491,13 @@ void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String &p String names; for (int j = 0; j < dock_slot[i]->get_tab_count(); j++) { String name = dock_slot[i]->get_tab_control(j)->get_name(); - if (names != "") { + if (!names.is_empty()) { names += ","; } names += name; } - if (names != "") { + if (!names.is_empty()) { p_layout->set_value(p_section, "dock_" + itos(i + 1), names); } } @@ -4522,7 +4522,7 @@ void EditorNode::_save_open_scenes_to_config(Ref<ConfigFile> p_layout, const Str Array scenes; for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { String path = editor_data.get_scene_path(i); - if (path == "") { + if (path.is_empty()) { continue; } scenes.push_back(path); @@ -4789,7 +4789,7 @@ bool EditorNode::ensure_main_scene(bool p_from_native) { pick_main_scene->set_meta("from_native", p_from_native); // whether from play button or native run String main_scene = GLOBAL_DEF("application/run/main_scene", ""); - if (main_scene == "") { + if (main_scene.is_empty()) { current_option = -1; pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in \"Project Settings\" under the 'application' category.")); pick_main_scene->popup_centered(); @@ -4852,7 +4852,7 @@ bool EditorNode::is_run_playing() const { String EditorNode::get_run_playing_scene() const { String run_filename = editor_run.get_running_scene(); - if (run_filename == "" && is_run_playing()) { + if (run_filename.is_empty() && is_run_playing()) { run_filename = GLOBAL_DEF("application/run/main_scene", ""); // Must be the main scene then. } @@ -4978,7 +4978,7 @@ void EditorNode::_scene_tab_closed(int p_tab, int option) { : editor_data.get_scene_version(p_tab) != 0; if (unsaved) { save_confirmation->get_ok_button()->set_text(TTR("Save & Close")); - save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene->get_scene_file_path() != "" ? scene->get_scene_file_path() : "unsaved scene")); + save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), !scene->get_scene_file_path().is_empty() ? scene->get_scene_file_path() : "unsaved scene")); save_confirmation->popup_centered(); } else { _discard_changes(); @@ -4998,7 +4998,7 @@ void EditorNode::_scene_tab_hovered(int p_tab) { tab_preview_panel->hide(); } else { String path = editor_data.get_scene_path(p_tab); - if (path != String()) { + if (!path.is_empty()) { EditorResourcePreview::get_singleton()->queue_resource_preview(path, this, "_thumbnail_done", p_tab); } } @@ -5307,7 +5307,7 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) { drag_control->add_child(drag_preview); if (p_res->get_path().is_resource_file()) { label->set_text(p_res->get_path().get_file()); - } else if (p_res->get_name() != "") { + } else if (!p_res->get_name().is_empty()) { label->set_text(p_res->get_name()); } else { label->set_text(p_res->get_class()); @@ -5446,7 +5446,7 @@ void EditorNode::_add_dropped_files_recursive(const Vector<String> &p_files, Str sub_dir->list_dir_begin(); String next_file = sub_dir->get_next(); - while (next_file != "") { + while (!next_file.is_empty()) { if (next_file == "." || next_file == "..") { next_file = sub_dir->get_next(); continue; diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp index 45c0232072..b6797825b0 100644 --- a/editor/editor_path.cpp +++ b/editor/editor_path.cpp @@ -130,14 +130,14 @@ void EditorPath::update_path() { name = r->get_name(); } - if (name == "") { + if (name.is_empty()) { name = r->get_class(); } } else if (obj->is_class("EditorDebuggerRemoteObject")) { name = obj->call("get_title"); } else if (Object::cast_to<Node>(obj)) { name = Object::cast_to<Node>(obj)->get_name(); - } else if (Object::cast_to<Resource>(obj) && Object::cast_to<Resource>(obj)->get_name() != "") { + } else if (Object::cast_to<Resource>(obj) && !Object::cast_to<Resource>(obj)->get_name().is_empty()) { name = Object::cast_to<Resource>(obj)->get_name(); } else { name = obj->get_class(); diff --git a/editor/editor_paths.cpp b/editor/editor_paths.cpp index 5b48cc2638..e747cdc29e 100644 --- a/editor/editor_paths.cpp +++ b/editor/editor_paths.cpp @@ -131,7 +131,7 @@ EditorPaths::EditorPaths() { } } - paths_valid = (data_path != "" && config_path != "" && cache_path != ""); + paths_valid = (!data_path.is_empty() && !config_path.is_empty() && !cache_path.is_empty()); ERR_FAIL_COND_MSG(!paths_valid, "Editor data, config, or cache paths are invalid."); // Validate or create each dir and its relevant subdirectories. diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 3261e6ddaf..9682a847ca 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -295,7 +295,7 @@ Error EditorInterface::save_scene() { if (!get_edited_scene_root()) { return ERR_CANT_CREATE; } - if (get_edited_scene_root()->get_scene_file_path() == String()) { + if (get_edited_scene_root()->get_scene_file_path().is_empty()) { return ERR_CANT_CREATE; } diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index aa313f0c50..6aeede78b6 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -165,7 +165,7 @@ Vector<String> EditorPluginSettings::_get_plugins(const String &p_dir) { Vector<String> plugins; da->list_dir_begin(); - for (String path = da->get_next(); path != String(); path = da->get_next()) { + for (String path = da->get_next(); !path.is_empty(); path = da->get_next()) { if (path[0] == '.' || !da->current_is_dir()) { continue; } diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 5280a8e7d3..07df2cedd5 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -380,7 +380,7 @@ void EditorPropertyPath::_path_pressed() { dialog->set_file_mode(save_mode ? EditorFileDialog::FILE_MODE_SAVE_FILE : EditorFileDialog::FILE_MODE_OPEN_FILE); for (int i = 0; i < extensions.size(); i++) { String e = extensions[i].strip_edges(); - if (e != String()) { + if (!e.is_empty()) { dialog->add_filter(extensions[i].strip_edges()); } } @@ -706,7 +706,7 @@ void EditorPropertyFlags::setup(const Vector<String> &p_options) { bool first = true; for (int i = 0; i < p_options.size(); i++) { String option = p_options[i].strip_edges(); - if (option != "") { + if (!option.is_empty()) { CheckBox *cb = memnew(CheckBox); cb->set_text(option); cb->set_clip_text(true); @@ -1055,7 +1055,7 @@ void EditorPropertyLayers::setup(LayerType p_layer_type) { name = ProjectSettings::get_singleton()->get(basename + vformat("/layer_%d", i + 1)); } - if (name == "") { + if (name.is_empty()) { name = vformat(TTR("Layer %d"), i + 1); } @@ -1186,7 +1186,7 @@ void EditorPropertyObjectID::_edit_pressed() { void EditorPropertyObjectID::update_property() { String type = base_type; - if (type == "") { + if (type.is_empty()) { type = "Object"; } @@ -3229,7 +3229,7 @@ static EditorPropertyRangeHint _parse_range_hint(PropertyHint p_hint, const Stri } } - if ((hint.radians || degrees) && hint.suffix == String()) { + if ((hint.radians || degrees) && hint.suffix.is_empty()) { hint.suffix = U"\u00B0"; } @@ -3514,10 +3514,10 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ } break; case Variant::NODE_PATH: { EditorPropertyNodePath *editor = memnew(EditorPropertyNodePath); - 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, Vector<StringName>(), (p_usage & PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT)); } - if (p_hint == PROPERTY_HINT_NODE_PATH_VALID_TYPES && p_hint_text != String()) { + if (p_hint == PROPERTY_HINT_NODE_PATH_VALID_TYPES && !p_hint_text.is_empty()) { Vector<String> types = p_hint_text.split(",", false); Vector<StringName> sn = Variant(types); //convert via variant editor->setup(NodePath(), sn, (p_usage & PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT)); diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 0f59c8281f..858de7fb78 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -431,7 +431,7 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const { // When the subtype is of type Object, an additional subtype may be specified in the hint string // (e.g. Resource, Texture2D, ShaderMaterial, etc). We want the allowed type to be that, not just "Object". - if (subtype == Variant::OBJECT && subtype_hint_string != "") { + if (subtype == Variant::OBJECT && !subtype_hint_string.is_empty()) { allowed_type = subtype_hint_string; } diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 0703677dc8..6a6634d7e5 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -52,7 +52,7 @@ void EditorResourcePicker::_update_resource() { } else { assign_button->set_icon(EditorNode::get_singleton()->get_object_icon(edited_resource.operator->(), "Object")); - if (edited_resource->get_name() != String()) { + if (!edited_resource->get_name().is_empty()) { assign_button->set_text(edited_resource->get_name()); } else if (edited_resource->get_path().is_resource_file()) { assign_button->set_text(edited_resource->get_path().get_file()); @@ -113,7 +113,7 @@ void EditorResourcePicker::_file_selected(const String &p_path) { RES loaded_resource = ResourceLoader::load(p_path); ERR_FAIL_COND_MSG(loaded_resource.is_null(), "Cannot load resource from path '" + p_path + "'."); - if (base_type != "") { + if (!base_type.is_empty()) { bool any_type_matches = false; for (int i = 0; i < base_type.get_slice_count(","); i++) { @@ -180,7 +180,7 @@ void EditorResourcePicker::_update_menu_items() { RES cb = EditorSettings::get_singleton()->get_resource_clipboard(); bool paste_valid = false; if (cb.is_valid()) { - if (base_type == "") { + if (base_type.is_empty()) { paste_valid = true; } else { for (int i = 0; i < base_type.get_slice_count(","); i++) { @@ -391,7 +391,7 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) { } // By default provide generic "New ..." options. - if (base_type != "") { + if (!base_type.is_empty()) { int idx = 0; Set<String> allowed_types; @@ -571,7 +571,7 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const { String file = files[0]; String file_type = EditorFileSystem::get_singleton()->get_file_type(file); - if (file_type != "" && _is_type_valid(file_type, allowed_types)) { + if (!file_type.is_empty() && _is_type_valid(file_type, allowed_types)) { return true; } } diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index e9c0b40268..15fc3b1db3 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -141,7 +141,7 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref< type = ResourceLoader::get_resource_type(p_item.path); } - if (type == "") { + if (type.is_empty()) { r_texture = Ref<ImageTexture>(); r_small_texture = Ref<ImageTexture>(); return; //could not guess type diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index 3f4418d5f2..92dae89b33 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -180,7 +180,7 @@ Error EditorRun::run(const String &p_scene) { args.push_back("--skip-breakpoints"); } - if (p_scene != "") { + if (!p_scene.is_empty()) { args.push_back(p_scene); } @@ -244,7 +244,7 @@ Error EditorRun::run(const String &p_scene) { } status = STATUS_PLAY; - if (p_scene != "") { + if (!p_scene.is_empty()) { running_scene = p_scene; } diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index 751cc7a574..c7a9171709 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -45,7 +45,7 @@ class SectionedInspectorFilter : public Object { } String name = p_name; - if (section != "") { + if (!section.is_empty()) { name = section + "/" + name; } @@ -60,7 +60,7 @@ class SectionedInspectorFilter : public Object { } String name = p_name; - if (section != "") { + if (!section.is_empty()) { name = section + "/" + name; } @@ -155,7 +155,7 @@ String SectionedInspector::get_current_section() const { String SectionedInspector::get_full_item_path(const String &p_item) { String base = get_current_section(); - if (base != "") { + if (!base.is_empty()) { return base + "/" + p_item; } else { return p_item; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 613e0ba7a0..95248b22b5 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -389,14 +389,14 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { best = locale; } - if (best == String() && host_lang.begins_with(locale)) { + if (best.is_empty() && host_lang.begins_with(locale)) { best = locale; } etl++; } - if (best == String()) { + if (best.is_empty()) { best = "en"; } @@ -989,7 +989,7 @@ void EditorSettings::setup_network() { if (ip == current) { selected = ip; } - if (hint != "") { + if (!hint.is_empty()) { hint += ","; } hint += ip; @@ -1008,7 +1008,7 @@ void EditorSettings::save() { return; } - if (singleton->config_file_path == "") { + if (singleton->config_file_path.is_empty()) { ERR_PRINT("Cannot save EditorSettings config, no valid path"); return; } @@ -1218,7 +1218,7 @@ void EditorSettings::load_favorites() { FileAccess *f = FileAccess::open(get_project_settings_dir().plus_file("favorites"), FileAccess::READ); if (f) { String line = f->get_line().strip_edges(); - while (line != "") { + while (!line.is_empty()) { favorites.push_back(line); line = f->get_line().strip_edges(); } @@ -1228,7 +1228,7 @@ void EditorSettings::load_favorites() { f = FileAccess::open(get_project_settings_dir().plus_file("recent_dirs"), FileAccess::READ); if (f) { String line = f->get_line().strip_edges(); - while (line != "") { + while (!line.is_empty()) { recent_dirs.push_back(line); line = f->get_line().strip_edges(); } @@ -1252,7 +1252,7 @@ void EditorSettings::list_text_editor_themes() { List<String> custom_themes; d->list_dir_begin(); String file = d->get_next(); - while (file != String()) { + while (!file.is_empty()) { if (file.get_extension() == "tet" && !_is_default_text_editor_theme(file.get_basename().to_lower())) { custom_themes.push_back(file.get_basename()); } @@ -1371,7 +1371,7 @@ Vector<String> EditorSettings::get_script_templates(const String &p_extension, c if (d) { d->list_dir_begin(); String file = d->get_next(); - while (file != String()) { + while (!file.is_empty()) { if (file.get_extension() == p_extension) { templates.push_back(file.get_basename()); } diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 5565ec8f90..c0fa259deb 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -262,9 +262,9 @@ void EditorSpinSlider::_update_value_input_stylebox() { // The margin values below were determined by empirical testing. if (is_layout_rtl()) { stylebox->set_default_margin(SIDE_LEFT, 0); - stylebox->set_default_margin(SIDE_RIGHT, (get_label() != String() ? 23 : 16) * EDSCALE); + stylebox->set_default_margin(SIDE_RIGHT, (!get_label().is_empty() ? 23 : 16) * EDSCALE); } else { - stylebox->set_default_margin(SIDE_LEFT, (get_label() != String() ? 23 : 16) * EDSCALE); + stylebox->set_default_margin(SIDE_LEFT, (!get_label().is_empty() ? 23 : 16) * EDSCALE); stylebox->set_default_margin(SIDE_RIGHT, 0); } @@ -308,7 +308,7 @@ void EditorSpinSlider::_draw_spin_slider() { lc = fc; } - if (flat && label != String()) { + if (flat && !label.is_empty()) { Color label_bg_color = get_theme_color(SNAME("dark_color_3"), SNAME("Editor")); if (rtl) { draw_rect(Rect2(Vector2(size.width - (sb->get_offset().x * 2 + label_width), 0), Vector2(sb->get_offset().x * 2 + label_width, size.height)), label_bg_color); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 637394d136..7bbac11754 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1553,7 +1553,7 @@ Ref<Theme> create_custom_theme(const Ref<Theme> p_theme) { Ref<Theme> theme = create_editor_theme(p_theme); const String custom_theme_path = EditorSettings::get_singleton()->get("interface/theme/custom_theme"); - if (custom_theme_path != "") { + if (!custom_theme_path.is_empty()) { Ref<Theme> custom_theme = ResourceLoader::load(custom_theme_path); if (custom_theme.is_valid()) { theme->merge_with(custom_theme); diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index f63fcb2938..d9613687f1 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -53,7 +53,7 @@ void ExportTemplateManager::_update_template_status() { da->list_dir_begin(); if (err == OK) { String c = da->get_next(); - while (c != String()) { + while (!c.is_empty()) { if (da->current_is_dir() && !c.begins_with(".")) { templates.insert(c); } @@ -424,7 +424,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ ret = unzGoToNextFile(pkg); } - if (version == String()) { + if (version.is_empty()) { EditorNode::get_singleton()->show_warning(TTR("No version.txt found inside the export templates file.")); unzClose(pkg); return false; diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp index 8f019a95fd..66bcbb4d5d 100644 --- a/editor/fileserver/editor_file_server.cpp +++ b/editor/fileserver/editor_file_server.cpp @@ -88,7 +88,7 @@ void EditorFileServer::_subthread_start(void *s) { ERR_FAIL(); } } else { - if (cd->efs->password != "") { + if (!cd->efs->password.is_empty()) { encode_uint32(ERR_INVALID_DATA, buf4); cd->connection->put_data(buf4, 4); OS::get_singleton()->delay_usec(1000000); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 39452b7192..72fc9fbc6e 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -64,7 +64,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory // Create a tree item for the subdirectory. TreeItem *subdirectory_item = tree->create_item(p_parent); String dname = p_dir->get_name(); - if (dname == "") { + if (dname.is_empty()) { dname = "res://"; } @@ -923,7 +923,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { files->select(item_index, false); } - if (!p_keep_selection && file != "" && fname == file) { + if (!p_keep_selection && !file.is_empty() && fname == file) { files->select(item_index, true); files->ensure_current_is_visible(); } @@ -1670,7 +1670,7 @@ Vector<String> FileSystemDock::_remove_self_included_paths(Vector<String> select selected_strings.sort_custom<NaturalNoCaseComparator>(); String last_path = ""; for (int i = 0; i < selected_strings.size(); i++) { - if (last_path != "" && selected_strings[i].begins_with(last_path)) { + if (!last_path.is_empty() && selected_strings[i].begins_with(last_path)) { selected_strings.remove_at(i); i--; } @@ -2016,7 +2016,7 @@ void FileSystemDock::_search_changed(const String &p_text, const Control *p_from tree_search_box->set_text(searched_string); } - bool unfold_path = (p_text == String() && path != String()); + bool unfold_path = (p_text.is_empty() && !path.is_empty()); switch (display_mode) { case DISPLAY_MODE_TREE_ONLY: { _update_tree(searched_string.length() == 0 ? uncollapsed_paths_before_search : Vector<String>(), false, false, unfold_path); @@ -2665,7 +2665,7 @@ void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &f DirAccess *da = DirAccess::open(p_path); da->list_dir_begin(); String n = da->get_next(); - while (n != String()) { + while (!n.is_empty()) { if (n != "." && n != ".." && !n.ends_with(".import")) { String npath = p_path + n + (da->current_is_dir() ? "/" : ""); _get_imported_files(npath, files); @@ -2720,7 +2720,7 @@ void FileSystemDock::_update_import_dock() { if (cf->has_section_key("remap", "type")) { type = cf->get_value("remap", "type"); } - if (import_type == "") { + if (import_type.is_empty()) { import_type = type; } else if (import_type != type) { // All should be the same type. diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 56356ff25b..9f7abfa19d 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -114,7 +114,7 @@ void FindInFiles::_notification(int p_notification) { } void FindInFiles::start() { - if (_pattern == "") { + if (_pattern.is_empty()) { print_verbose("Nothing to search, pattern is empty"); emit_signal(SNAME(SIGNAL_FINISHED)); return; @@ -224,7 +224,7 @@ void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders) { for (int i = 0; i < 1000; ++i) { String file = dir->get_next(); - if (file == "") { + if (file.is_empty()) { break; } diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index ce5e0e03fd..788c7dc029 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -227,7 +227,7 @@ void GroupDialog::_group_renamed() { } } - if (name == "") { + if (name.is_empty()) { renamed_group->set_text(0, selected_group); error->set_text(TTR("Invalid group name.")); error->popup_centered(); diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp index c34379f1ec..c1f577f176 100644 --- a/editor/import/collada.cpp +++ b/editor/import/collada.cpp @@ -1362,7 +1362,7 @@ Collada::Node *Collada::_parse_visual_instance_geometry(XMLParser &parser) { } else if (parser.get_node_name() == "skeleton") { parser.read(); String uri = _uri_to_id(parser.get_node_data()); - if (uri != "") { + if (!uri.is_empty()) { geom->skeletons.push_back(uri); } } @@ -1464,7 +1464,7 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { bool found_name = false; - if (id == "") { + if (id.is_empty()) { id = "%NODEID%" + itos(Math::rand()); } else { @@ -1479,7 +1479,7 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { Node *node = nullptr; name = parser.has_attribute("name") ? parser.get_attribute_value_safe("name") : parser.get_attribute_value_safe("id"); - if (name == "") { + if (name.is_empty()) { name = id; } else { found_name = true; @@ -1499,7 +1499,7 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { joint->sid = parser.get_attribute_value_safe("name"); } - if (joint->sid != "") { + if (!joint->sid.is_empty()) { state.sid_to_node_map[joint->sid] = id; } @@ -1696,16 +1696,16 @@ void Collada::_parse_animation(XMLParser &parser) { source_param_types[current_source] = Vector<String>(); } else if (name == "float_array") { - if (current_source != "") { + if (!current_source.is_empty()) { float_sources[current_source] = _read_float_array(parser); } } else if (name == "Name_array") { - if (current_source != "") { + if (!current_source.is_empty()) { string_sources[current_source] = _read_string_array(parser); } } else if (name == "accessor") { - if (current_source != "" && parser.has_attribute("stride")) { + if (!current_source.is_empty() && parser.has_attribute("stride")) { source_strides[current_source] = parser.get_attribute_value("stride").to_int(); } } else if (name == "sampler") { @@ -1725,7 +1725,7 @@ void Collada::_parse_animation(XMLParser &parser) { } } else if (name == "input") { - if (current_sampler != "") { + if (!current_sampler.is_empty()) { samplers[current_sampler][parser.get_attribute_value("semantic")] = parser.get_attribute_value("source"); } @@ -1838,7 +1838,7 @@ void Collada::_parse_animation(XMLParser &parser) { track.component = track.param.get_slice(".", 1).to_upper(); } track.param = track.param.get_slice(".", 0); - if (names.size() > 1 && track.component == "") { + if (names.size() > 1 && track.component.is_empty()) { //this is a guess because the collada spec is ambiguous here... //i suppose if you have many names (outputs) you can't use a component and i should abide to that. track.component = name; @@ -1855,7 +1855,7 @@ void Collada::_parse_animation(XMLParser &parser) { state.referenced_tracks[target].push_back(state.animation_tracks.size() - 1); - if (id != "") { + if (!id.is_empty()) { if (!state.by_id_tracks.has(id)) { state.by_id_tracks[id] = Vector<int>(); } @@ -1953,10 +1953,10 @@ void Collada::_parse_library(XMLParser &parser) { while (parser.read() == OK) { if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { if (parser.get_node_name() == "mesh") { - state.mesh_name_map[id] = (name2 != "") ? name2 : id; + state.mesh_name_map[id] = (!name2.is_empty()) ? name2 : id; _parse_mesh_geometry(parser, id, name2); } else if (parser.get_node_name() == "spline") { - state.mesh_name_map[id] = (name2 != "") ? name2 : id; + state.mesh_name_map[id] = (!name2.is_empty()) ? name2 : id; _parse_curve_geometry(parser, id, name2); } else if (!parser.is_empty()) { parser.skip_section(); @@ -2286,7 +2286,7 @@ void Collada::_find_morph_nodes(VisualScene *p_vscene, Node *p_node) { if (nj->controller) { String base = nj->source; - while (base != "" && !state.mesh_data_map.has(base)) { + while (!base.is_empty() && !state.mesh_data_map.has(base)) { if (state.skin_controller_data_map.has(base)) { SkinControllerData &sk = state.skin_controller_data_map[base]; base = sk.base; diff --git a/editor/import/dynamicfont_import_settings.cpp b/editor/import/dynamicfont_import_settings.cpp index 83c0f56d87..b63c2bf350 100644 --- a/editor/import/dynamicfont_import_settings.cpp +++ b/editor/import/dynamicfont_import_settings.cpp @@ -1597,7 +1597,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() { menu_langs = memnew(PopupMenu); menu_langs->set_name("Language"); - for (int i = 0; langs[i].name != String(); i++) { + for (int i = 0; !langs[i].name.is_empty(); i++) { if (langs[i].name == "-") { menu_langs->add_separator(); } else { @@ -1609,7 +1609,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() { menu_scripts = memnew(PopupMenu); menu_scripts->set_name("Script"); - for (int i = 0; scripts[i].name != String(); i++) { + for (int i = 0; !scripts[i].name.is_empty(); i++) { if (scripts[i].name == "-") { menu_scripts->add_separator(); } else { @@ -1826,7 +1826,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() { glyph_tree->connect("item_selected", callable_mp(this, &DynamicFontImportSettings::_range_selected)); glyph_tree->set_v_size_flags(Control::SIZE_EXPAND_FILL); glyph_root = glyph_tree->create_item(); - for (int i = 0; unicode_ranges[i].name != String(); i++) { + for (int i = 0; !unicode_ranges[i].name.is_empty(); i++) { _add_glyph_range_item(unicode_ranges[i].start, unicode_ranges[i].end, unicode_ranges[i].name); } diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index 076c0cc62b..91f8e5b910 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -303,7 +303,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) { } break; } - if (p_node->name != "") { + if (!p_node->name.is_empty()) { node->set_name(p_node->name); } NodeMap nm; @@ -317,7 +317,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) { p_parent->add_child(node, true); node->set_owner(scene); - if (p_node->empty_draw_type != "") { + if (!p_node->empty_draw_type.is_empty()) { node->set_meta("empty_draw_type", Variant(p_node->empty_draw_type)); } @@ -340,9 +340,9 @@ Error ColladaImport::_create_material(const String &p_target) { Ref<StandardMaterial3D> material = memnew(StandardMaterial3D); String base_name; - if (src_mat.name != "") { + if (!src_mat.name.is_empty()) { base_name = src_mat.name; - } else if (effect.name != "") { + } else if (!effect.name.is_empty()) { base_name = effect.name; } else { base_name = "Material"; @@ -360,9 +360,9 @@ Error ColladaImport::_create_material(const String &p_target) { // DIFFUSE - if (effect.diffuse.texture != "") { + if (!effect.diffuse.texture.is_empty()) { String texfile = effect.get_texture_path(effect.diffuse.texture, collada); - if (texfile != "") { + if (!texfile.is_empty()) { if (texfile.begins_with("/")) { texfile = texfile.replace_first("/", "res://"); } @@ -381,9 +381,9 @@ Error ColladaImport::_create_material(const String &p_target) { // SPECULAR - if (effect.specular.texture != "") { + if (!effect.specular.texture.is_empty()) { String texfile = effect.get_texture_path(effect.specular.texture, collada); - if (texfile != "") { + if (!texfile.is_empty()) { if (texfile.begins_with("/")) { texfile = texfile.replace_first("/", "res://"); } @@ -406,9 +406,9 @@ Error ColladaImport::_create_material(const String &p_target) { // EMISSION - if (effect.emission.texture != "") { + if (!effect.emission.texture.is_empty()) { String texfile = effect.get_texture_path(effect.emission.texture, collada); - if (texfile != "") { + if (!texfile.is_empty()) { if (texfile.begins_with("/")) { texfile = texfile.replace_first("/", "res://"); } @@ -433,9 +433,9 @@ Error ColladaImport::_create_material(const String &p_target) { // NORMAL - if (effect.bump.texture != "") { + if (!effect.bump.texture.is_empty()) { String texfile = effect.get_texture_path(effect.bump.texture, collada); - if (texfile != "") { + if (!texfile.is_empty()) { if (texfile.begins_with("/")) { texfile = texfile.replace_first("/", "res://"); } @@ -525,7 +525,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p normal_ofs = vertex_ofs; } - if (normal_source_id != "") { + if (!normal_source_id.is_empty()) { ERR_FAIL_COND_V(!meshdata.sources.has(normal_source_id), ERR_INVALID_DATA); normal_src = &meshdata.sources[normal_source_id]; } @@ -545,7 +545,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p binormal_ofs = vertex_ofs; } - if (binormal_source_id != "") { + if (!binormal_source_id.is_empty()) { ERR_FAIL_COND_V(!meshdata.sources.has(binormal_source_id), ERR_INVALID_DATA); binormal_src = &meshdata.sources[binormal_source_id]; } @@ -565,7 +565,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p tangent_ofs = vertex_ofs; } - if (tangent_source_id != "") { + if (!tangent_source_id.is_empty()) { ERR_FAIL_COND_V(!meshdata.sources.has(tangent_source_id), ERR_INVALID_DATA); tangent_src = &meshdata.sources[tangent_source_id]; } @@ -585,7 +585,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p uv_ofs = vertex_ofs; } - if (uv_source_id != "") { + if (!uv_source_id.is_empty()) { ERR_FAIL_COND_V(!meshdata.sources.has(uv_source_id), ERR_INVALID_DATA); uv_src = &meshdata.sources[uv_source_id]; } @@ -605,7 +605,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p uv2_ofs = vertex_ofs; } - if (uv2_source_id != "") { + if (!uv2_source_id.is_empty()) { ERR_FAIL_COND_V(!meshdata.sources.has(uv2_source_id), ERR_INVALID_DATA); uv2_src = &meshdata.sources[uv2_source_id]; } @@ -625,7 +625,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p color_ofs = vertex_ofs; } - if (color_source_id != "") { + if (!color_source_id.is_empty()) { ERR_FAIL_COND_V(!meshdata.sources.has(color_source_id), ERR_INVALID_DATA); color_src = &meshdata.sources[color_source_id]; } @@ -914,7 +914,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p material = material_cache[target]; } - } else if (p.material != "") { + } else if (!p.material.is_empty()) { WARN_PRINT("Collada: Unreferenced material in geometry instance: " + p.material); } } @@ -1198,7 +1198,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres } } - ERR_FAIL_COND_V_MSG(ngsource != "", ERR_INVALID_DATA, "Controller instance source '" + ngsource + "' is neither skin or morph!"); + ERR_FAIL_COND_V_MSG(!ngsource.is_empty(), ERR_INVALID_DATA, "Controller instance source '" + ngsource + "' is neither skin or morph!"); } else { meshid = ng2->source; @@ -1215,13 +1215,13 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres mesh = Ref<ImporterMesh>(memnew(ImporterMesh)); const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid]; String name = meshdata.name; - if (name == "") { + if (name.is_empty()) { name = "Mesh"; } int counter = 2; while (mesh_unique_names.has(name)) { name = meshdata.name; - if (name == "") { + if (name.is_empty()) { name = "Mesh"; } name += itos(counter++); @@ -1261,7 +1261,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres } mi->set_surface_material(i, material); - } else if (matname != "") { + } else if (!matname.is_empty()) { WARN_PRINT("Collada: Unreferenced material in geometry instance: " + matname); } } @@ -1343,7 +1343,7 @@ void ColladaImport::_fix_param_animation_tracks() { // test source(s) String source = ng->source; - while (source != "") { + while (!source.is_empty()) { if (collada.state.skin_controller_data_map.has(source)) { const Collada::SkinControllerData &skin = collada.state.skin_controller_data_map[source]; @@ -1796,7 +1796,7 @@ Node *EditorSceneFormatImporterCollada::import_scene(const String &p_path, uint3 AnimationPlayer *ap = memnew(AnimationPlayer); for (int i = 0; i < state.animations.size(); i++) { String name; - if (state.animations[i]->get_name() == "") { + if (state.animations[i]->get_name().is_empty()) { name = "default"; } else { name = state.animations[i]->get_name(); diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp index 7948d9e577..7a226802f2 100644 --- a/editor/import/resource_importer_csv_translation.cpp +++ b/editor/import/resource_importer_csv_translation.cpp @@ -113,7 +113,7 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const while (line.size() == locales.size() + 1) { String key = line[0]; - if (key != "") { + if (!key.is_empty()) { for (int i = 1; i < line.size(); i++) { translations.write[i - 1]->add_message(key, line[i].c_unescape()); } diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index bb68de99b1..9e3cdbdeff 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -235,7 +235,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ while (l.length() && l[l.length() - 1] == '\\') { String add = f->get_line().strip_edges(); l += add; - if (add == String()) { + if (add.is_empty()) { break; } } @@ -301,7 +301,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ surf_tool->set_normal(normals[norm]); } - if (face[idx].size() >= 2 && face[idx][1] != String()) { + if (face[idx].size() >= 2 && !face[idx][1].is_empty()) { int uv = face[idx][1].to_int() - 1; if (uv < 0) { uv += uvs.size() + 1; @@ -363,9 +363,9 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ mesh = surf_tool->commit(mesh, mesh_flags); - if (current_material != String()) { + if (!current_material.is_empty()) { mesh->surface_set_name(mesh->get_surface_count() - 1, current_material.get_basename()); - } else if (current_group != String()) { + } else if (!current_group.is_empty()) { mesh->surface_set_name(mesh->get_surface_count() - 1, current_group); } diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index a25b694a60..330c7125fe 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -481,7 +481,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<I fixed_name = _fixstr(name, "convcolonly"); } - ERR_FAIL_COND_V(fixed_name == String(), nullptr); + ERR_FAIL_COND_V(fixed_name.is_empty(), nullptr); if (shapes.size()) { StaticBody3D *col = memnew(StaticBody3D); @@ -577,7 +577,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<I fixed_name = _fixstr(name, "convcol"); } - if (fixed_name != String()) { + if (!fixed_name.is_empty()) { if (mi->get_parent() && !mi->get_parent()->has_node(fixed_name)) { mi->set_name(fixed_name); } @@ -710,7 +710,7 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref< mat_id = mat->get_name(); } - if (mat_id != String() && p_material_data.has(mat_id)) { + if (!mat_id.is_empty() && p_material_data.has(mat_id)) { Dictionary matdata = p_material_data[mat_id]; for (int j = 0; j < post_importer_plugins.size(); j++) { @@ -1433,7 +1433,7 @@ void ResourceImporterScene::get_import_options(const String &p_path, List<Import String script_ext_hint; for (const String &E : script_extentions) { - if (script_ext_hint != "") { + if (!script_ext_hint.is_empty()) { script_ext_hint += ","; } script_ext_hint += "*." + E; @@ -1559,7 +1559,7 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m mesh_id = src_mesh_node->get_mesh()->get_name(); } - if (mesh_id != String() && p_mesh_data.has(mesh_id)) { + if (!mesh_id.is_empty() && p_mesh_data.has(mesh_id)) { Dictionary mesh_settings = p_mesh_data[mesh_id]; if (mesh_settings.has("generate/shadow_meshes")) { @@ -1649,7 +1649,7 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m } } - if (save_to_file != String()) { + if (!save_to_file.is_empty()) { Ref<Mesh> existing = Ref<Resource>(ResourceCache::get(save_to_file)); if (existing.is_valid()) { //if somehow an existing one is useful, create @@ -2051,7 +2051,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p String post_import_script_path = p_options["import_script/path"]; Ref<EditorScenePostImport> post_import_script; - if (post_import_script_path != "") { + if (!post_import_script_path.is_empty()) { Ref<Script> scr = ResourceLoader::load(post_import_script_path); if (!scr.is_valid()) { EditorNode::add_io_error(TTR("Couldn't load post-import script:") + " " + post_import_script_path); diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index 5690d49a55..a376596f9b 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -92,7 +92,7 @@ void SceneImportSettings::_fill_material(Tree *p_tree, const Ref<Material> &p_ma if (p_material->has_meta("import_id")) { import_id = p_material->get_meta("import_id"); has_import_id = true; - } else if (p_material->get_name() != "") { + } else if (!p_material->get_name().is_empty()) { import_id = p_material->get_name(); has_import_id = true; } else { @@ -148,7 +148,7 @@ void SceneImportSettings::_fill_mesh(Tree *p_tree, const Ref<Mesh> &p_mesh, Tree if (p_mesh->has_meta("import_id")) { import_id = p_mesh->get_meta("import_id"); has_import_id = true; - } else if (p_mesh->get_name() != String()) { + } else if (!p_mesh->get_name().is_empty()) { import_id = p_mesh->get_name(); has_import_id = true; } else { @@ -414,7 +414,7 @@ void SceneImportSettings::_update_camera() { float rot_y = cam_rot_y; float zoom = cam_zoom; - if (selected_type == "Node" || selected_type == "") { + if (selected_type == "Node" || selected_type.is_empty()) { camera_aabb = contents_aabb; } else { if (mesh_preview->get_mesh().is_valid()) { diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index cc6b4e66e4..3507eaff94 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -525,7 +525,7 @@ void ImportDock::_reimport() { Ref<ResourceImporter> importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(importer_name); ERR_CONTINUE(!importer.is_valid()); String group_file_property = importer->get_option_group_file(); - if (group_file_property != String()) { + if (!group_file_property.is_empty()) { //can import from a group (as in, atlas) ERR_CONTINUE(!params->values.has(group_file_property)); String group_file = params->values[group_file_property]; diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 5622d0b145..f594a5a3a8 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -312,7 +312,7 @@ void InspectorDock::_prepare_history() { Resource *r = Object::cast_to<Resource>(obj); if (r->get_path().is_resource_file()) { text = r->get_path().get_file(); - } else if (r->get_name() != String()) { + } else if (!r->get_name().is_empty()) { text = r->get_name(); } else { text = r->get_class(); @@ -460,7 +460,7 @@ void InspectorDock::open_resource(const String &p_type) { void InspectorDock::set_warning(const String &p_message) { warning->hide(); - if (p_message != String()) { + if (!p_message.is_empty()) { warning->show(); warning_dialog->set_text(p_message); } diff --git a/editor/multi_node_edit.cpp b/editor/multi_node_edit.cpp index 1e707c1a60..1a30770b53 100644 --- a/editor/multi_node_edit.cpp +++ b/editor/multi_node_edit.cpp @@ -75,7 +75,7 @@ bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value, ur->add_do_property(n, name, path); } else { Variant new_value; - if (p_field == "") { + if (p_field.is_empty()) { // whole value new_value = p_value; } else { 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(); diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 20990cc301..0b748c12b6 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -178,7 +178,7 @@ void ProjectExportDialog::_update_export_all() { Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_preset(i); bool needs_templates; String error; - if (preset->get_export_path() == "" || !preset->get_platform()->can_export(preset, error, needs_templates)) { + if (preset->get_export_path().is_empty() || !preset->get_platform()->can_export(preset, error, needs_templates)) { can_export = false; break; } @@ -244,7 +244,7 @@ void ProjectExportDialog::_edit_preset(int p_index) { bool needs_templates; String error; if (!current->get_platform()->can_export(current, error, needs_templates)) { - if (error != String()) { + if (!error.is_empty()) { Vector<String> items = error.split("\n", false); error = ""; for (int i = 0; i < items.size(); i++) { @@ -336,7 +336,7 @@ void ProjectExportDialog::_update_feature_list() { Vector<String> custom_list = custom.split(","); for (int i = 0; i < custom_list.size(); i++) { String f = custom_list[i].strip_edges(); - if (f != String()) { + if (!f.is_empty()) { features.push_back(f); } } @@ -871,7 +871,7 @@ void ProjectExportDialog::_open_export_template_manager() { void ProjectExportDialog::_validate_export_path(const String &p_path) { // Disable export via OK button or Enter key if LineEdit has an empty filename - bool invalid_path = (p_path.get_file().get_basename() == ""); + bool invalid_path = (p_path.get_file().get_basename().is_empty()); // Check if state change before needlessly messing with signals if (invalid_path && export_project->get_ok_button()->is_disabled()) { @@ -904,7 +904,7 @@ void ProjectExportDialog::_export_project() { export_project->add_filter("*." + extension_list[i] + " ; " + platform->get_name() + " Export"); } - if (current->get_export_path() != "") { + if (!current->get_export_path().is_empty()) { export_project->set_current_path(current->get_export_path()); } else { if (extension_list.size() >= 1) { @@ -1292,10 +1292,10 @@ ProjectExportDialog::ProjectExportDialog() { default_filename = EditorSettings::get_singleton()->get_project_metadata("export_options", "default_filename", ""); // If no default set, use project name - if (default_filename == "") { + if (default_filename.is_empty()) { // If no project name defined, use a sane default default_filename = ProjectSettings::get_singleton()->get("application/config/name"); - if (default_filename == "") { + if (default_filename.is_empty()) { default_filename = "UnnamedProject"; } } diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index e6964a8337..134f238bb6 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -161,7 +161,7 @@ private: } } - if (valid_path == "") { + if (valid_path.is_empty()) { set_message(TTR("The path specified doesn't exist."), MESSAGE_ERROR); memdelete(d); get_ok_button()->set_disabled(true); @@ -175,7 +175,7 @@ private: valid_install_path = install_path->get_text().strip_edges(); } - if (valid_install_path == "") { + if (valid_install_path.is_empty()) { set_message(TTR("The path specified doesn't exist."), MESSAGE_ERROR, INSTALL_PATH); memdelete(d); get_ok_button()->set_disabled(true); @@ -184,7 +184,7 @@ private: } if (mode == MODE_IMPORT || mode == MODE_RENAME) { - if (valid_path != "" && !d->file_exists("project.godot")) { + if (!valid_path.is_empty() && !d->file_exists("project.godot")) { if (valid_path.ends_with(".zip")) { FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); @@ -225,7 +225,7 @@ private: d->list_dir_begin(); is_folder_empty = true; String n = d->get_next(); - while (n != String()) { + while (!n.is_empty()) { if (!n.begins_with(".")) { // Allow `.`, `..` (reserved current/parent folder names) // and hidden files/folders to be present. @@ -265,7 +265,7 @@ private: d->list_dir_begin(); is_folder_empty = true; String n = d->get_next(); - while (n != String()) { + while (!n.is_empty()) { if (!n.begins_with(".")) { // Allow `.`, `..` (reserved current/parent folder names) // and hidden files/folders to be present. @@ -295,16 +295,16 @@ private: void _path_text_changed(const String &p_path) { String sp = _test_path(); - if (sp != "") { + if (!sp.is_empty()) { // If the project name is empty or default, infer the project name from the selected folder name - if (project_name->get_text().strip_edges() == "" || project_name->get_text().strip_edges() == TTR("New Game Project")) { + if (project_name->get_text().strip_edges().is_empty() || project_name->get_text().strip_edges() == TTR("New Game Project")) { sp = sp.replace("\\", "/"); int lidx = sp.rfind("/"); if (lidx != -1) { sp = sp.substr(lidx + 1, sp.length()).capitalize(); } - if (sp == "" && mode == MODE_IMPORT) { + if (sp.is_empty() && mode == MODE_IMPORT) { sp = TTR("Imported Project"); } @@ -313,7 +313,7 @@ private: } } - if (created_folder_path != "" && created_folder_path != p_path) { + if (!created_folder_path.is_empty() && created_folder_path != p_path) { _remove_created_folder(); } } @@ -382,7 +382,7 @@ private: void _create_folder() { const String project_name_no_edges = project_name->get_text().strip_edges(); - if (project_name_no_edges == "" || created_folder_path != "" || project_name_no_edges.ends_with(".")) { + if (project_name_no_edges.is_empty() || !created_folder_path.is_empty() || project_name_no_edges.ends_with(".")) { set_message(TTR("Invalid project name."), MESSAGE_WARNING); return; } @@ -417,7 +417,7 @@ private: _test_path(); - if (p_text.strip_edges() == "") { + if (p_text.strip_edges().is_empty()) { set_message(TTR("It would be a good idea to name your project."), MESSAGE_ERROR); } } @@ -432,7 +432,7 @@ private: if (mode == MODE_RENAME) { String dir2 = _test_path(); - if (dir2 == "") { + if (dir2.is_empty()) { set_message(TTR("Invalid project path (changed anything?)."), MESSAGE_ERROR); return; } @@ -546,7 +546,7 @@ private: String path = fname; - if (path == String() || path == zip_root || !zip_root.is_subsequence_of(path)) { + if (path.is_empty() || path == zip_root || !zip_root.is_subsequence_of(path)) { // } else if (path.ends_with("/")) { // a dir @@ -617,7 +617,7 @@ private: } void _remove_created_folder() { - if (created_folder_path != "") { + if (!created_folder_path.is_empty()) { DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); d->remove(created_folder_path); memdelete(d); @@ -717,7 +717,7 @@ public: } else { fav_dir = EditorSettings::get_singleton()->get("filesystem/directories/default_project_path"); - if (fav_dir != "") { + if (!fav_dir.is_empty()) { project_path->set_text(fav_dir); fdialog->set_current_dir(fav_dir); } else { @@ -1158,7 +1158,7 @@ void ProjectList::load_project_icon(int p_index) { Ref<Texture2D> default_icon = get_theme_icon(SNAME("DefaultProjectIcon"), SNAME("EditorIcons")); Ref<Texture2D> icon; - if (item.icon != "") { + if (!item.icon.is_empty()) { Ref<Image> img; img.instantiate(); Error err = img->load(item.icon.replace_first("res://", item.path + "/")); @@ -1191,7 +1191,7 @@ ProjectList::Item ProjectList::load_project_data(const String &p_property_key, b String project_name = TTR("Unnamed Project"); if (cf_err == OK) { String cf_project_name = static_cast<String>(cf->get_value("application", "config/name", "")); - if (cf_project_name != "") { + if (!cf_project_name.is_empty()) { project_name = cf_project_name.xml_unescape(); } config_version = (int)cf->get_value("", "config_version", 0); @@ -1473,7 +1473,7 @@ void ProjectList::sort_projects() { Item &item = _projects.write[i]; bool visible = true; - if (_search_term != "") { + if (!_search_term.is_empty()) { String search_path; if (_search_term.find("/") != -1) { // Search path will match the whole path @@ -1785,7 +1785,7 @@ void ProjectList::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) { const Item &clicked_project = _projects[clicked_index]; if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { - if (mb->is_shift_pressed() && _selected_project_keys.size() > 0 && _last_clicked != "" && clicked_project.project_key != _last_clicked) { + if (mb->is_shift_pressed() && _selected_project_keys.size() > 0 && !_last_clicked.is_empty() && clicked_project.project_key != _last_clicked) { int anchor_index = -1; for (int i = 0; i < _projects.size(); ++i) { const Item &p = _projects[i]; @@ -2193,7 +2193,7 @@ void ProjectManager::_run_project_confirm() { for (int i = 0; i < selected_list.size(); ++i) { const String &selected_main = selected_list[i].main_scene; - if (selected_main == "") { + if (selected_main.is_empty()) { run_error_diag->set_text(TTR("Can't run project: no main scene defined.\nPlease edit the project and set the main scene in the Project Settings under the \"Application\" category.")); run_error_diag->popup_centered(); continue; @@ -2246,7 +2246,7 @@ void ProjectManager::_scan_dir(const String &path, List<String> *r_projects) { ERR_FAIL_COND_MSG(error != OK, "Could not scan directory at: " + path); da->list_dir_begin(); String n = da->get_next(); - while (n != String()) { + while (!n.is_empty()) { if (da->current_is_dir() && !n.begins_with(".")) { _scan_dir(da->get_current_dir().plus_file(n), r_projects); } else if (n == "project.godot") { @@ -2388,7 +2388,7 @@ void ProjectManager::_files_dropped(PackedStringArray p_files, int p_screen) { if (dir->change_dir(folders[0]) == OK) { dir->list_dir_begin(); String file = dir->get_next(); - while (confirm && file != String()) { + while (confirm && !file.is_empty()) { if (!dir->current_is_dir() && file.ends_with("project.godot")) { confirm = false; } @@ -2826,7 +2826,7 @@ ProjectManager::ProjectManager() { } String autoscan_path = EditorSettings::get_singleton()->get("filesystem/directories/autoscan_project_path"); - if (autoscan_path != "") { + if (!autoscan_path.is_empty()) { if (dir_access->dir_exists(autoscan_path)) { _scan_begin(autoscan_path); } else { diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 519427787d..f6975594cb 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -78,7 +78,7 @@ void ProjectSettingsEditor::_advanced_toggled(bool p_button_pressed) { } void ProjectSettingsEditor::_setting_selected(const String &p_path) { - if (p_path == String()) { + if (p_path.is_empty()) { return; } @@ -147,12 +147,12 @@ void ProjectSettingsEditor::_update_property_box() { const Vector<String> t = setting.split(".", true, 1); const String name = t[0]; const String feature = (t.size() == 2) ? t[1] : ""; - bool feature_invalid = (t.size() == 2) && (t[1] == ""); + bool feature_invalid = (t.size() == 2) && (t[1].is_empty()); add_button->set_disabled(true); del_button->set_disabled(true); - if (feature != "") { + if (!feature.is_empty()) { feature_invalid = true; for (int i = 1; i < feature_box->get_item_count(); i++) { if (feature == feature_box->get_item_text(i)) { @@ -163,11 +163,11 @@ void ProjectSettingsEditor::_update_property_box() { } } - if (feature == "" || feature_invalid) { + if (feature.is_empty() || feature_invalid) { feature_box->select(0); } - if (property_box->get_text() == "") { + if (property_box->get_text().is_empty()) { return; } @@ -244,7 +244,7 @@ void ProjectSettingsEditor::_add_feature_overrides() { Vector<String> custom_list = custom.split(","); for (int j = 0; j < custom_list.size(); j++) { String f = custom_list[j].strip_edges(); - if (f != String()) { + if (!f.is_empty()) { presets.insert(f); } } diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 01eae1e4ec..abe1bcf9e5 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -482,7 +482,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: Vector<String> flags = hint_text.split(","); for (int i = 0; i < flags.size(); i++) { String flag = flags[i]; - if (flag == "") { + if (flag.is_empty()) { continue; } menu->add_check_item(flag, i); @@ -552,7 +552,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: add_child(create_dialog); } - if (hint_text != String()) { + if (!hint_text.is_empty()) { create_dialog->set_base_type(hint_text); } else { create_dialog->set_base_type("Object"); @@ -853,7 +853,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: if (p_name == "script" && hint_text == "Script" && Object::cast_to<Node>(owner)) { menu->add_item(TTR("New Script"), OBJ_MENU_NEW_SCRIPT); menu->add_separator(); - } else if (hint_text != "") { + } else if (!hint_text.is_empty()) { int idx = 0; Vector<EditorData::CustomType> custom_resources; @@ -933,7 +933,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: RES cb = EditorSettings::get_singleton()->get_resource_clipboard(); bool paste_valid = false; if (cb.is_valid()) { - if (hint_text == "") { + if (hint_text.is_empty()) { paste_valid = true; } else { for (int i = 0; i < hint_text.get_slice_count(","); i++) { @@ -1108,7 +1108,7 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) { return; } - if (hint == PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE && hint_text != String()) { + if (hint == PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE && !hint_text.is_empty()) { Node *node = get_node(hint_text); if (node) { Node *tonode = node->get_node(p_path); @@ -1191,7 +1191,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { file->clear_filters(); - if (hint_text != "") { + if (!hint_text.is_empty()) { Vector<String> extensions = hint_text.split(","); for (int i = 0; i < extensions.size(); i++) { String filter = extensions[i]; diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 877b4552c1..838686ead6 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -181,7 +181,7 @@ void PropertySelector::_update_search() { continue; } - if (search_box->get_text() != String() && E.name.findn(search_text) == -1) { + if (!search_box->get_text().is_empty() && E.name.findn(search_text) == -1) { continue; } @@ -194,7 +194,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() != String() && E.name.findn(search_text) != -1) { + if (!found && !search_box->get_text().is_empty() && E.name.findn(search_text) != -1) { item->select(0); found = true; } @@ -269,7 +269,7 @@ void PropertySelector::_update_search() { continue; } - if (search_box->get_text() != String() && name.findn(search_text) == -1) { + if (!search_box->get_text().is_empty() && name.findn(search_text) == -1) { continue; } @@ -318,7 +318,7 @@ void PropertySelector::_update_search() { item->set_metadata(0, name); item->set_selectable(0, true); - if (!found && search_box->get_text() != String() && name.findn(search_text) != -1) { + if (!found && !search_box->get_text().is_empty() && name.findn(search_text) != -1) { item->select(0); found = true; } @@ -353,7 +353,7 @@ void PropertySelector::_item_selected() { String class_type; if (type != Variant::NIL) { class_type = Variant::get_type_name(type); - } else if (base_type != String()) { + } else if (!base_type.is_empty()) { class_type = base_type; } else if (instance) { class_type = instance->get_class(); @@ -362,7 +362,7 @@ void PropertySelector::_item_selected() { DocTools *dd = EditorHelp::get_doc_data(); String text; if (properties) { - while (class_type != String()) { + while (!class_type.is_empty()) { Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(class_type); if (E) { for (int i = 0; i < E->get().properties.size(); i++) { @@ -373,7 +373,7 @@ void PropertySelector::_item_selected() { } } - if (text != String()) { + if (!text.is_empty()) { break; } @@ -381,7 +381,7 @@ void PropertySelector::_item_selected() { class_type = ClassDB::get_parent_class(class_type); } } else { - while (class_type != String()) { + while (!class_type.is_empty()) { Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(class_type); if (E) { for (int i = 0; i < E->get().methods.size(); i++) { @@ -392,7 +392,7 @@ void PropertySelector::_item_selected() { } } - if (text != String()) { + if (!text.is_empty()) { break; } @@ -401,7 +401,7 @@ void PropertySelector::_item_selected() { } } - if (text != String()) { + if (!text.is_empty()) { // Display both property name and description, since the help bit may be displayed // far away from the location (especially if the dialog was resized to be taller). help_bit->set_text(vformat("[b]%s[/b]: %s", name, text)); diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index 7868414d89..b4ab6493ef 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -79,7 +79,7 @@ void EditorQuickOpen::_build_search_cache(EditorFileSystemDirectory *p_efsd) { void EditorQuickOpen::_update_search() { const String search_text = search_box->get_text(); - const bool empty_search = search_text == ""; + const bool empty_search = search_text.is_empty(); // Filter possible candidates. Vector<Entry> entries; diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index b36275322a..1934850160 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -190,7 +190,7 @@ void SceneTreeDock::_perform_instantiate_scenes(const Vector<String> &p_files, N break; } - if (edited_scene->get_scene_file_path() != "") { + if (!edited_scene->get_scene_file_path().is_empty()) { if (_cyclical_dependency_exists(edited_scene->get_scene_file_path(), instantiated_scene)) { accept->set_text(vformat(TTR("Cannot instance the scene '%s' because the current scene exists within one of its nodes."), p_files[i])); accept->popup_centered(); @@ -467,7 +467,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } bool has_cycle = false; - if (edited_scene->get_scene_file_path() != String()) { + if (!edited_scene->get_scene_file_path().is_empty()) { for (Node *E : node_clipboard) { if (edited_scene->get_scene_file_path() == E->get_scene_file_path()) { has_cycle = true; @@ -810,7 +810,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { return; } - if (node->get_scene_file_path() != String()) { + if (!node->get_scene_file_path().is_empty()) { accept->set_text(TTR("Instantiated scenes can't become root")); accept->popup_centered(); return; @@ -889,7 +889,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { Node *node = remove_list[0]; if (node == editor_data->get_edited_scene_root()) { msg = vformat(TTR("Delete the root node \"%s\"?"), node->get_name()); - } else if (node->get_scene_file_path() == "" && node->get_child_count() > 0) { + } else if (node->get_scene_file_path().is_empty() && node->get_child_count() > 0) { // Display this message only for non-instantiated scenes msg = vformat(TTR("Delete node \"%s\" and its children?"), node->get_name()); } else { @@ -936,7 +936,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; } - if (tocopy != editor_data->get_edited_scene_root() && tocopy->get_scene_file_path() != "") { + if (tocopy != editor_data->get_edited_scene_root() && !tocopy->get_scene_file_path().is_empty()) { accept->set_text(TTR("Can't save the branch of an already instantiated scene.\nTo create a variation of a scene, you can make an inherited scene based on the instantiated scene using Scene > New Inherited Scene... instead.")); accept->popup_centered(); break; @@ -1052,7 +1052,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; } - ERR_FAIL_COND(node->get_scene_file_path() == String()); + ERR_FAIL_COND(node->get_scene_file_path().is_empty()); undo_redo->create_action(TTR("Make Local")); undo_redo->add_do_method(node, "set_scene_file_path", ""); undo_redo->add_undo_method(node, "set_scene_file_path", node->get_scene_file_path()); @@ -1703,7 +1703,7 @@ bool SceneTreeDock::_validate_no_instance() { List<Node *> selection = editor_selection->get_selected_node_list(); for (Node *E : selection) { - if (E != edited_scene && E->get_scene_file_path() != "") { + if (E != edited_scene && !E->get_scene_file_path().is_empty()) { accept->set_text(TTR("This operation can't be done on instantiated scenes.")); accept->popup_centered(); return false; @@ -2761,7 +2761,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { bool can_replace = true; for (Node *E : selection) { - if (E != edited_scene && (E->get_owner() != edited_scene || E->get_scene_file_path() != "")) { + if (E != edited_scene && (E->get_owner() != edited_scene || !E->get_scene_file_path().is_empty())) { can_replace = false; break; } @@ -2793,7 +2793,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_icon_shortcut(get_theme_icon(SNAME("CopyNodePath"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH); } - bool is_external = (selection[0]->get_scene_file_path() != ""); + bool is_external = (!selection[0]->get_scene_file_path().is_empty()); if (is_external) { bool is_inherited = selection[0]->get_scene_inherited_state() != nullptr; bool is_top_level = selection[0]->get_owner() == nullptr; @@ -2906,9 +2906,9 @@ void SceneTreeDock::attach_script_to_selected(bool p_extend) { Ref<Script> existing = selected->get_script(); String path = selected->get_scene_file_path(); - if (path == "") { + if (path.is_empty()) { String root_path = editor_data->get_edited_scene_root()->get_scene_file_path(); - if (root_path == "") { + if (root_path.is_empty()) { path = String("res://").plus_file(selected->get_name()); } else { path = root_path.get_base_dir().plus_file(selected->get_name()); @@ -2956,7 +2956,7 @@ void SceneTreeDock::attach_shader_to_selected(int p_preferred_mode) { } String path = selected_shader_material->get_path(); - if (path == "") { + if (path.is_empty()) { String root_path; if (editor_data->get_edited_scene_root()) { root_path = editor_data->get_edited_scene_root()->get_scene_file_path(); @@ -2967,7 +2967,7 @@ void SceneTreeDock::attach_shader_to_selected(int p_preferred_mode) { } else { shader_name = selected_shader_material->get_name(); } - if (root_path == "") { + if (root_path.is_empty()) { path = String("res://").plus_file(shader_name); } else { path = root_path.get_base_dir().plus_file(shader_name); @@ -3070,7 +3070,7 @@ void SceneTreeDock::_update_create_root_dialog() { while (!f->eof_reached()) { String l = f->get_line().strip_edges(); - if (l != String()) { + if (!l.is_empty()) { Button *button = memnew(Button); favorite_nodes->add_child(button); button->set_text(l); diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index d64efcc2ac..4569841af6 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -120,7 +120,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i undo_redo->commit_action(); } else if (p_id == BUTTON_WARNING) { String config_err = n->get_configuration_warnings_as_string(); - if (config_err == String()) { + if (config_err.is_empty()) { return; } config_err = config_err.word_wrap(80); @@ -297,16 +297,16 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll item->add_button(0, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_SUBSCENE, false, TTR("Open in Editor")); String tooltip = String(p_node->get_name()) + "\n" + TTR("Inherits:") + " " + p_node->get_scene_inherited_state()->get_path() + "\n" + TTR("Type:") + " " + p_node->get_class(); - if (p_node->get_editor_description() != String()) { + if (!p_node->get_editor_description().is_empty()) { tooltip += "\n\n" + p_node->get_editor_description(); } item->set_tooltip(0, tooltip); - } else if (p_node != get_scene_node() && p_node->get_scene_file_path() != "" && can_open_instance) { + } else if (p_node != get_scene_node() && !p_node->get_scene_file_path().is_empty() && can_open_instance) { item->add_button(0, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_SUBSCENE, false, TTR("Open in Editor")); String tooltip = String(p_node->get_name()) + "\n" + TTR("Instance:") + " " + p_node->get_scene_file_path() + "\n" + TTR("Type:") + " " + p_node->get_class(); - if (p_node->get_editor_description() != String()) { + if (!p_node->get_editor_description().is_empty()) { tooltip += "\n\n" + p_node->get_editor_description(); } @@ -318,7 +318,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll } String tooltip = String(p_node->get_name()) + "\n" + TTR("Type:") + " " + type; - if (p_node->get_editor_description() != String()) { + if (!p_node->get_editor_description().is_empty()) { tooltip += "\n\n" + p_node->get_editor_description(); } @@ -955,7 +955,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from Node *n = get_node(np); if (n) { // Only allow selection if not part of an instantiated scene. - if (!n->get_owner() || n->get_owner() == get_scene_node() || n->get_owner()->get_scene_file_path() == String()) { + if (!n->get_owner() || n->get_owner() == get_scene_node() || n->get_owner()->get_scene_file_path().is_empty()) { selected.push_back(n); icons.push_back(next->get_icon(0)); } @@ -1069,7 +1069,7 @@ bool SceneTreeEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_d } } - return String(d["type"]) == "nodes" && filter == String(); + return String(d["type"]) == "nodes" && filter.is_empty(); } void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index afb1d5107c..0e96a1d247 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -101,7 +101,7 @@ void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_ parent_name->set_text(p_base_name); parent_name->deselect(); - if (p_base_path != "") { + if (!p_base_path.is_empty()) { initial_bp = p_base_path.get_basename(); file_path->set_text(initial_bp + "." + ScriptServer::get_language(language_menu->get_selected())->get_extension()); current_language = language_menu->get_selected(); @@ -163,10 +163,10 @@ bool ScriptCreateDialog::_validate_class(const String &p_string) { String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must_exist) { String p = p_path.strip_edges(); - if (p == "") { + if (p.is_empty()) { return TTR("Path is empty."); } - if (p.get_file().get_basename() == "") { + if (p.get_file().get_basename().is_empty()) { return TTR("Filename is empty."); } @@ -227,7 +227,7 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must /* Let ScriptLanguage do custom validation */ String path_error = ScriptServer::get_language(language_menu->get_selected())->validate_path(p); - if (path_error != "") { + if (!path_error.is_empty()) { return path_error; } @@ -295,7 +295,7 @@ void ScriptCreateDialog::_create_new() { String cname_param = _get_class_name(); Ref<Script> scr; - if (script_template != "") { + if (!script_template.is_empty()) { scr = ResourceLoader::load(script_template); if (scr.is_null()) { alert->set_text(vformat(TTR("Error loading template '%s'"), script_template)); @@ -358,7 +358,7 @@ void ScriptCreateDialog::_lang_changed(int l) { String selected_ext = "." + language->get_extension(); String path = file_path->get_text(); String extension = ""; - if (path != "") { + if (!path.is_empty()) { if (path.find(".") != -1) { extension = path.get_extension(); } @@ -582,7 +582,7 @@ void ScriptCreateDialog::_path_changed(const String &p_path) { is_new_script_created = true; String path_error = _validate_path(p_path, false); - if (path_error != "") { + if (!path_error.is_empty()) { _msg_path_valid(false, path_error); _update_dialog(); return; diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index a39fdb3878..8e12cb76ef 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -148,7 +148,7 @@ void EditorSettingsDialog::unhandled_input(const Ref<InputEvent> &p_event) { if (ED_IS_SHORTCUT("ui_undo", p_event)) { String action = undo_redo->get_current_action_name(); - if (action != "") { + if (!action.is_empty()) { EditorNode::get_log()->add_message("Undo: " + action, EditorLog::MSG_TYPE_EDITOR); } undo_redo->undo(); @@ -158,7 +158,7 @@ void EditorSettingsDialog::unhandled_input(const Ref<InputEvent> &p_event) { if (ED_IS_SHORTCUT("ui_redo", p_event)) { undo_redo->redo(); String action = undo_redo->get_current_action_name(); - if (action != "") { + if (!action.is_empty()) { EditorNode::get_log()->add_message("Redo: " + action, EditorLog::MSG_TYPE_EDITOR); } handled = true; diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp index a958226394..302f7f78c5 100644 --- a/editor/shader_create_dialog.cpp +++ b/editor/shader_create_dialog.cpp @@ -220,7 +220,7 @@ void ShaderCreateDialog::_language_changed(int p_language) { String path = file_path->get_text(); String extension = ""; - if (path != "") { + if (!path.is_empty()) { if (path.find(".") != -1) { extension = path.get_extension(); } @@ -303,7 +303,7 @@ void ShaderCreateDialog::_path_changed(const String &p_path) { is_new_shader_created = true; String path_error = _validate_path(p_path); - if (path_error != "") { + if (!path_error.is_empty()) { _msg_path_valid(false, path_error); _update_dialog(); return; @@ -325,7 +325,7 @@ void ShaderCreateDialog::_path_submitted(const String &p_path) { } void ShaderCreateDialog::config(const String &p_base_path, bool p_built_in_enabled, bool p_load_enabled, int p_preferred_type, int p_preferred_mode) { - if (p_base_path != "") { + if (!p_base_path.is_empty()) { initial_base_path = p_base_path.get_basename(); file_path->set_text(initial_base_path + "." + language_data[language_menu->get_selected()].default_extension); current_language = language_menu->get_selected(); @@ -355,10 +355,10 @@ void ShaderCreateDialog::config(const String &p_base_path, bool p_built_in_enabl String ShaderCreateDialog::_validate_path(const String &p_path) { String p = p_path.strip_edges(); - if (p == "") { + if (p.is_empty()) { return TTR("Path is empty."); } - if (p.get_file().get_basename() == "") { + if (p.get_file().get_basename().is_empty()) { return TTR("Filename is empty."); } diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp index d504d3b137..31c1dc85a8 100644 --- a/editor/shader_globals_editor.cpp +++ b/editor/shader_globals_editor.cpp @@ -372,7 +372,7 @@ static Variant create_var(RS::GlobalVariableType p_type) { void ShaderGlobalsEditor::_variable_added() { String var = variable_name->get_text().strip_edges(); - if (var == "" || !var.is_valid_identifier()) { + if (var.is_empty() || !var.is_valid_identifier()) { EditorNode::get_singleton()->show_warning(TTR("Please specify a valid variable identifier name.")); return; } |