diff options
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r-- | editor/editor_node.cpp | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index f06ef39bc3..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; @@ -6150,7 +6150,7 @@ EditorNode::EditorNode() { Label *dock_label = memnew(Label); dock_label->set_text(TTR("Dock Position")); dock_label->set_h_size_flags(Control::SIZE_EXPAND_FILL); - dock_label->set_align(Label::ALIGN_CENTER); + dock_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); dock_hb->add_child(dock_label); dock_tab_move_right = memnew(Button); @@ -6190,7 +6190,7 @@ EditorNode::EditorNode() { dock_slot[i]->set_v_size_flags(Control::SIZE_EXPAND_FILL); dock_slot[i]->set_popup(dock_select_popup); dock_slot[i]->connect("pre_popup_pressed", callable_mp(this, &EditorNode::_dock_pre_popup), varray(i)); - dock_slot[i]->set_tab_align(TabContainer::ALIGN_LEFT); + dock_slot[i]->set_tab_alignment(TabContainer::ALIGNMENT_LEFT); dock_slot[i]->set_drag_to_rearrange_enabled(true); dock_slot[i]->set_tabs_rearrange_group(1); dock_slot[i]->connect("tab_changed", callable_mp(this, &EditorNode::_dock_tab_changed)); @@ -6230,7 +6230,7 @@ EditorNode::EditorNode() { scene_tabs->add_theme_style_override("tab_unselected", gui_base->get_theme_stylebox(SNAME("SceneTabBG"), SNAME("EditorStyles"))); scene_tabs->set_select_with_rmb(true); scene_tabs->add_tab("unsaved"); - scene_tabs->set_tab_align(TabBar::ALIGN_LEFT); + scene_tabs->set_tab_alignment(TabBar::ALIGNMENT_LEFT); scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/scene_tabs/always_show_close_button", false)) ? TabBar::CLOSE_BUTTON_SHOW_ALWAYS : TabBar::CLOSE_BUTTON_SHOW_ACTIVE_ONLY)); scene_tabs->set_min_width(int(EDITOR_DEF("interface/scene_tabs/minimum_width", 50)) * EDSCALE); scene_tabs->set_drag_to_rearrange_enabled(true); |