summaryrefslogtreecommitdiff
path: root/editor/editor_node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r--editor/editor_node.cpp94
1 files changed, 43 insertions, 51 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 6aaf0b063f..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.");
@@ -2315,10 +2315,8 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons")));
String run_filename;
- String args;
- bool skip_breakpoints;
- 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) {
@@ -2326,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.
@@ -2336,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;
@@ -2351,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());
}
}
@@ -2371,17 +2369,11 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
make_bottom_panel_item_visible(log);
}
- List<String> breakpoints;
- editor_data.get_editor_breakpoints(&breakpoints);
-
- args = ProjectSettings::get_singleton()->get("editor/run/main_run_args");
- skip_breakpoints = EditorDebuggerNode::get_singleton()->is_skip_breakpoints();
-
EditorDebuggerNode::get_singleton()->start();
- Error error = editor_run.run(run_filename, args, breakpoints, skip_breakpoints);
+ Error error = editor_run.run(run_filename);
if (error != OK) {
EditorDebuggerNode::get_singleton()->stop();
- show_accept(TTR("Could not start subprocess!"), TTR("OK"));
+ show_accept(TTR("Could not start subprocess(es)!"), TTR("OK"));
return;
}
@@ -2389,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")));
@@ -2509,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;
}
@@ -2527,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);
@@ -2583,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()) {
@@ -2657,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);
}
}
@@ -2684,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;
}
@@ -2754,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;
@@ -3019,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);
}
}
@@ -3146,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) {
@@ -4244,7 +4236,6 @@ void EditorNode::_dock_make_float() {
Size2 dock_size = dock->get_size() + borders * 2; // remember size
Point2 dock_screen_pos = dock->get_global_position() + get_tree()->get_root()->get_position() - borders;
- print_line("dock pos: " + dock->get_global_position() + " window pos: " + get_tree()->get_root()->get_position());
int dock_index = dock->get_index();
dock_slot[dock_popup_selected]->remove_child(dock);
@@ -4500,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);
}
}
@@ -4531,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);
@@ -4798,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();
@@ -4861,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.
}
@@ -4987,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();
@@ -5007,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);
}
}
@@ -5060,7 +5051,8 @@ void EditorNode::_scene_tab_input(const Ref<InputEvent> &p_input) {
scene_tabs_context_menu->add_item(TTR("Close Tabs to the Right"), FILE_CLOSE_RIGHT);
scene_tabs_context_menu->add_item(TTR("Close All Tabs"), FILE_CLOSE_ALL);
}
- scene_tabs_context_menu->set_position(mb->get_global_position());
+ scene_tabs_context_menu->set_position(scene_tabs->get_screen_position() + mb->get_position());
+ scene_tabs_context_menu->reset_size();
scene_tabs_context_menu->popup();
}
if (mb->get_button_index() == MouseButton::WHEEL_UP && mb->is_pressed()) {
@@ -5315,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());
@@ -5454,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;
@@ -6158,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);
@@ -6198,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));
@@ -6238,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);
@@ -7018,7 +7010,7 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(PhysicalBone3DEditorPlugin(this)));
add_editor_plugin(memnew(MeshEditorPlugin(this)));
add_editor_plugin(memnew(MaterialEditorPlugin(this)));
- add_editor_plugin(memnew(GPUParticlesCollisionSDFEditorPlugin(this)));
+ add_editor_plugin(memnew(GPUParticlesCollisionSDF3DEditorPlugin(this)));
add_editor_plugin(memnew(InputEventEditorPlugin(this)));
add_editor_plugin(memnew(SubViewportPreviewEditorPlugin(this)));
add_editor_plugin(memnew(TextControlEditorPlugin(this)));