diff options
Diffstat (limited to 'editor')
40 files changed, 507 insertions, 127 deletions
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 6e701cb6bd..98fcde17c4 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -148,6 +148,11 @@ bool CreateDialog::_should_hide_type(const String &p_type) const { return true; } + StringName native_type = ScriptServer::get_global_class_native_base(p_type); + if (ClassDB::class_exists(native_type) && !ClassDB::can_instantiate(native_type)) { + return true; + } + String script_path = ScriptServer::get_global_class_path(p_type); if (script_path.begins_with("res://addons/")) { if (!EditorNode::get_singleton()->is_addon_plugin_enabled(script_path.get_slicec('/', 3))) { diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 38934ae8a5..e4730faf38 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -670,7 +670,7 @@ EditorProfiler::EditorProfiler() { variables->connect("item_edited", callable_mp(this, &EditorProfiler::_item_edited)); graph = memnew(TextureRect); - graph->set_ignore_texture_size(true); + graph->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE); graph->set_mouse_filter(MOUSE_FILTER_STOP); graph->connect("draw", callable_mp(this, &EditorProfiler::_graph_tex_draw)); graph->connect("gui_input", callable_mp(this, &EditorProfiler::_graph_tex_input)); diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index 91d9204863..1a06e85f90 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -798,7 +798,7 @@ EditorVisualProfiler::EditorVisualProfiler() { variables->connect("cell_selected", callable_mp(this, &EditorVisualProfiler::_item_selected)); graph = memnew(TextureRect); - graph->set_ignore_texture_size(true); + graph->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE); graph->set_mouse_filter(MOUSE_FILTER_STOP); graph->connect("draw", callable_mp(this, &EditorVisualProfiler::_graph_tex_draw)); graph->connect("gui_input", callable_mp(this, &EditorVisualProfiler::_graph_tex_input)); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 12aa44891d..8723354e84 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -1361,38 +1361,22 @@ void EditorInspectorSection::_notification(int p_what) { } break; case NOTIFICATION_DRAG_BEGIN: { - Dictionary dd = get_viewport()->gui_get_drag_data(); - - // Only allow dropping if the section contains properties which can take the dragged data. - bool children_can_drop = false; - for (int child_idx = 0; child_idx < vbox->get_child_count(); child_idx++) { - Control *editor_property = Object::cast_to<Control>(vbox->get_child(child_idx)); - - // Test can_drop_data and can_drop_data_fw, since can_drop_data only works if set up with forwarding or if script attached. - if (editor_property && (editor_property->can_drop_data(Point2(), dd) || editor_property->call("_can_drop_data_fw", Point2(), dd, this))) { - children_can_drop = true; - break; - } - } - - dropping = children_can_drop; - queue_redraw(); + dropping_for_unfold = true; } break; case NOTIFICATION_DRAG_END: { - dropping = false; - queue_redraw(); + dropping_for_unfold = false; } break; case NOTIFICATION_MOUSE_ENTER: { - if (dropping) { + if (dropping || dropping_for_unfold) { dropping_unfold_timer->start(); } queue_redraw(); } break; case NOTIFICATION_MOUSE_EXIT: { - if (dropping) { + if (dropping || dropping_for_unfold) { dropping_unfold_timer->stop(); } queue_redraw(); diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index af8d1e6806..699a88e657 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -276,6 +276,7 @@ class EditorInspectorSection : public Container { Timer *dropping_unfold_timer = nullptr; bool dropping = false; + bool dropping_for_unfold = false; HashSet<StringName> revertable_properties; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index ab79031ad2..ae9261864f 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -608,6 +608,9 @@ void EditorNode::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { + if (progress_dialog) { + progress_dialog->queue_free(); + } editor_data.save_editor_external_data(); FileAccess::set_file_close_fail_notify_callback(nullptr); log->deinit(); // Do not get messages anymore. @@ -688,6 +691,7 @@ void EditorNode::_notification(int p_what) { if (theme_changed) { theme = create_custom_theme(theme_base->get_theme()); + DisplayServer::set_early_window_clear_color_override(true, theme->get_color(SNAME("background"), SNAME("Editor"))); theme_base->set_theme(theme); gui_base->set_theme(theme); @@ -4307,7 +4311,7 @@ bool EditorNode::is_object_of_custom_type(const Object *p_object, const StringNa void EditorNode::progress_add_task(const String &p_task, const String &p_label, int p_steps, bool p_can_cancel) { if (singleton->cmdline_export_mode) { print_line(p_task + ": begin: " + p_label + " steps: " + itos(p_steps)); - } else { + } else if (singleton->progress_dialog) { singleton->progress_dialog->add_task(p_task, p_label, p_steps, p_can_cancel); } } @@ -4316,15 +4320,17 @@ bool EditorNode::progress_task_step(const String &p_task, const String &p_state, if (singleton->cmdline_export_mode) { print_line("\t" + p_task + ": step " + itos(p_step) + ": " + p_state); return false; - } else { + } else if (singleton->progress_dialog) { return singleton->progress_dialog->task_step(p_task, p_state, p_step, p_force_refresh); + } else { + return false; } } void EditorNode::progress_end_task(const String &p_task) { if (singleton->cmdline_export_mode) { print_line(p_task + ": end"); - } else { + } else if (singleton->progress_dialog) { singleton->progress_dialog->end_task(p_task); } } @@ -6235,6 +6241,7 @@ EditorNode::EditorNode() { // Exporters might need the theme. EditorColorMap::create(); theme = create_custom_theme(); + DisplayServer::set_early_window_clear_color_override(true, theme->get_color(SNAME("background"), SNAME("Editor"))); register_exporters(); @@ -6289,7 +6296,6 @@ EditorNode::EditorNode() { resource_preview = memnew(EditorResourcePreview); add_child(resource_preview); progress_dialog = memnew(ProgressDialog); - gui_base->add_child(progress_dialog); // Take up all screen. gui_base->set_anchor(SIDE_RIGHT, Control::ANCHOR_END); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 8ef394a59f..6c917a0c4f 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -4584,6 +4584,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ return editor; } else { EditorPropertyDictionary *editor = memnew(EditorPropertyDictionary); + editor->setup(p_hint); return editor; } } break; diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index ed667aa7c8..069e80fc05 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -818,6 +818,10 @@ void EditorPropertyDictionary::_change_type_menu(int p_index) { update_property(); } +void EditorPropertyDictionary::setup(PropertyHint p_hint) { + property_hint = p_hint; +} + void EditorPropertyDictionary::update_property() { Variant updated_val = get_edited_object()->get(get_edited_property()); @@ -929,7 +933,13 @@ void EditorPropertyDictionary::update_property() { prop = editor; } break; case Variant::STRING: { - prop = memnew(EditorPropertyText); + if (i != amount && property_hint == PROPERTY_HINT_MULTILINE_TEXT) { + // If this is NOT the new key field and there's a multiline hint, + // show the field as multiline + prop = memnew(EditorPropertyMultilineText); + } else { + prop = memnew(EditorPropertyText); + } } break; diff --git a/editor/editor_properties_array_dict.h b/editor/editor_properties_array_dict.h index 96fc2dce24..73a16e3687 100644 --- a/editor/editor_properties_array_dict.h +++ b/editor/editor_properties_array_dict.h @@ -154,6 +154,7 @@ class EditorPropertyDictionary : public EditorProperty { EditorSpinSlider *size_sliderv = nullptr; Button *button_add_item = nullptr; EditorPaginator *paginator = nullptr; + PropertyHint property_hint; void _page_changed(int p_page); void _edit_pressed(); @@ -169,6 +170,7 @@ protected: void _notification(int p_what); public: + void setup(PropertyHint p_hint); virtual void update_property() override; EditorPropertyDictionary(); }; diff --git a/editor/editor_property_name_processor.cpp b/editor/editor_property_name_processor.cpp index 195457c239..18ba19f5f6 100644 --- a/editor/editor_property_name_processor.cpp +++ b/editor/editor_property_name_processor.cpp @@ -211,6 +211,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["rmb"] = "RMB"; capitalize_string_remaps["rpc"] = "RPC"; capitalize_string_remaps["s3tc"] = "S3TC"; + capitalize_string_remaps["scp"] = "SCP"; capitalize_string_remaps["sdf"] = "SDF"; capitalize_string_remaps["sdfgi"] = "SDFGI"; capitalize_string_remaps["sdk"] = "SDK"; diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 6b733e11f7..81b2fff97a 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -958,7 +958,7 @@ EditorResourcePicker::EditorResourcePicker(bool p_hide_assign_button_controls) { if (!p_hide_assign_button_controls) { preview_rect = memnew(TextureRect); - preview_rect->set_ignore_texture_size(true); + preview_rect->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE); preview_rect->set_anchors_and_offsets_preset(PRESET_FULL_RECT); preview_rect->set_offset(SIDE_TOP, 1); preview_rect->set_offset(SIDE_BOTTOM, -1); diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index b0eb4c3d55..eab4e08cec 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -154,7 +154,9 @@ Error EditorRunNative::run_native(int p_idx, int p_platform) { Error err = eep->run(preset, p_idx, flags); result_dialog_log->clear(); if (eep->fill_log_messages(result_dialog_log, err)) { - result_dialog->popup_centered_ratio(0.5); + if (eep->get_worst_message_type() >= EditorExportPlatform::EXPORT_MESSAGE_ERROR) { + result_dialog->popup_centered_ratio(0.5); + } } return err; } diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index ea03b1c744..177266e366 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -253,6 +253,12 @@ void EditorSpinSlider::_value_input_gui_input(const Ref<InputEvent> &p_event) { value_input_dirty = true; set_process_internal(true); } break; + case Key::ESCAPE: { + value_input_closed_frame = Engine::get_singleton()->get_frames_drawn(); + if (value_input_popup) { + value_input_popup->hide(); + } + } break; default: break; } @@ -479,10 +485,10 @@ void EditorSpinSlider::_notification(int p_what) { } break; case NOTIFICATION_FOCUS_ENTER: { - if ((Input::get_singleton()->is_action_pressed("ui_focus_next") || Input::get_singleton()->is_action_pressed("ui_focus_prev")) && !value_input_just_closed) { + if ((Input::get_singleton()->is_action_pressed("ui_focus_next") || Input::get_singleton()->is_action_pressed("ui_focus_prev")) && value_input_closed_frame != Engine::get_singleton()->get_frames_drawn()) { _focus_entered(); } - value_input_just_closed = false; + value_input_closed_frame = 0; } break; } } @@ -553,7 +559,7 @@ void EditorSpinSlider::_evaluate_input_text() { //text_submitted signal void EditorSpinSlider::_value_input_submitted(const String &p_text) { - value_input_just_closed = true; + value_input_closed_frame = Engine::get_singleton()->get_frames_drawn(); if (value_input_popup) { value_input_popup->hide(); } @@ -562,7 +568,7 @@ void EditorSpinSlider::_value_input_submitted(const String &p_text) { //modal_closed signal void EditorSpinSlider::_value_input_closed() { _evaluate_input_text(); - value_input_just_closed = true; + value_input_closed_frame = Engine::get_singleton()->get_frames_drawn(); } //focus_exited signal @@ -578,7 +584,7 @@ void EditorSpinSlider::_value_focus_exited() { // -> TAB was pressed // -> modal_close was not called // -> need to close/hide manually - if (!value_input_just_closed) { //value_input_just_closed should do the same + if (value_input_closed_frame != Engine::get_singleton()->get_frames_drawn()) { if (value_input_popup) { value_input_popup->hide(); } @@ -672,6 +678,7 @@ void EditorSpinSlider::_ensure_input_popup() { add_child(value_input_popup); value_input = memnew(LineEdit); + value_input->set_focus_mode(FOCUS_CLICK); value_input_popup->add_child(value_input); value_input->set_anchors_and_offsets_preset(PRESET_FULL_RECT); value_input_popup->connect("hidden", callable_mp(this, &EditorSpinSlider::_value_input_closed)); diff --git a/editor/editor_spin_slider.h b/editor/editor_spin_slider.h index 99eb953166..a4d810b18b 100644 --- a/editor/editor_spin_slider.h +++ b/editor/editor_spin_slider.h @@ -65,7 +65,7 @@ class EditorSpinSlider : public Range { Control *value_input_popup = nullptr; LineEdit *value_input = nullptr; - bool value_input_just_closed = false; + uint64_t value_input_closed_frame = 0; bool value_input_dirty = false; bool hide_slider = false; diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index d8252bed9c..7a880d2ab3 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -753,6 +753,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Editor background Color background_color_opaque = background_color; background_color_opaque.a = 1.0; + theme->set_color("background", "Editor", background_color_opaque); theme->set_stylebox("Background", "EditorStyles", make_flat_stylebox(background_color_opaque, default_margin_size, default_margin_size, default_margin_size, default_margin_size)); // Focus diff --git a/editor/export/editor_export.cpp b/editor/export/editor_export.cpp index f48cabf207..cc96107f97 100644 --- a/editor/export/editor_export.cpp +++ b/editor/export/editor_export.cpp @@ -170,6 +170,12 @@ void EditorExport::_notification(int p_what) { case NOTIFICATION_PROCESS: { update_export_presets(); } break; + + case NOTIFICATION_EXIT_TREE: { + for (int i = 0; i < export_platforms.size(); i++) { + export_platforms.write[i]->cleanup(); + } + } break; } } diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index 028071ff62..6478f99fb1 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -444,8 +444,10 @@ HashSet<String> EditorExportPlatform::get_features(const Ref<EditorExportPreset> result.insert("template"); if (p_debug) { + result.insert("debug"); result.insert("template_debug"); } else { + result.insert("release"); result.insert("template_release"); } @@ -1320,6 +1322,121 @@ Error EditorExportPlatform::_add_shared_object(void *p_userdata, const SharedObj return OK; } +void EditorExportPlatform::zip_folder_recursive(zipFile &p_zip, const String &p_root_path, const String &p_folder, const String &p_pkg_name) { + String dir = p_folder.is_empty() ? p_root_path : p_root_path.path_join(p_folder); + + Ref<DirAccess> da = DirAccess::open(dir); + da->list_dir_begin(); + String f = da->get_next(); + while (!f.is_empty()) { + if (f == "." || f == "..") { + f = da->get_next(); + continue; + } + if (da->is_link(f)) { + OS::DateTime dt = OS::get_singleton()->get_datetime(); + + zip_fileinfo zipfi; + zipfi.tmz_date.tm_year = dt.year; + zipfi.tmz_date.tm_mon = dt.month - 1; // Note: "tm" month range - 0..11, Godot month range - 1..12, https://www.cplusplus.com/reference/ctime/tm/ + zipfi.tmz_date.tm_mday = dt.day; + zipfi.tmz_date.tm_hour = dt.hour; + zipfi.tmz_date.tm_min = dt.minute; + zipfi.tmz_date.tm_sec = dt.second; + zipfi.dosDate = 0; + // 0120000: symbolic link type + // 0000755: permissions rwxr-xr-x + // 0000644: permissions rw-r--r-- + uint32_t _mode = 0120644; + zipfi.external_fa = (_mode << 16L) | !(_mode & 0200); + zipfi.internal_fa = 0; + + zipOpenNewFileInZip4(p_zip, + p_folder.path_join(f).utf8().get_data(), + &zipfi, + nullptr, + 0, + nullptr, + 0, + nullptr, + Z_DEFLATED, + Z_DEFAULT_COMPRESSION, + 0, + -MAX_WBITS, + DEF_MEM_LEVEL, + Z_DEFAULT_STRATEGY, + nullptr, + 0, + 0x0314, // "version made by", 0x03 - Unix, 0x14 - ZIP specification version 2.0, required to store Unix file permissions + 0); + + String target = da->read_link(f); + zipWriteInFileInZip(p_zip, target.utf8().get_data(), target.utf8().size()); + zipCloseFileInZip(p_zip); + } else if (da->current_is_dir()) { + zip_folder_recursive(p_zip, p_root_path, p_folder.path_join(f), p_pkg_name); + } else { + bool _is_executable = is_executable(dir.path_join(f)); + + OS::DateTime dt = OS::get_singleton()->get_datetime(); + + zip_fileinfo zipfi; + zipfi.tmz_date.tm_year = dt.year; + zipfi.tmz_date.tm_mon = dt.month - 1; // Note: "tm" month range - 0..11, Godot month range - 1..12, https://www.cplusplus.com/reference/ctime/tm/ + zipfi.tmz_date.tm_mday = dt.day; + zipfi.tmz_date.tm_hour = dt.hour; + zipfi.tmz_date.tm_min = dt.minute; + zipfi.tmz_date.tm_sec = dt.second; + zipfi.dosDate = 0; + // 0100000: regular file type + // 0000755: permissions rwxr-xr-x + // 0000644: permissions rw-r--r-- + uint32_t _mode = (_is_executable ? 0100755 : 0100644); + zipfi.external_fa = (_mode << 16L) | !(_mode & 0200); + zipfi.internal_fa = 0; + + zipOpenNewFileInZip4(p_zip, + p_folder.path_join(f).utf8().get_data(), + &zipfi, + nullptr, + 0, + nullptr, + 0, + nullptr, + Z_DEFLATED, + Z_DEFAULT_COMPRESSION, + 0, + -MAX_WBITS, + DEF_MEM_LEVEL, + Z_DEFAULT_STRATEGY, + nullptr, + 0, + 0x0314, // "version made by", 0x03 - Unix, 0x14 - ZIP specification version 2.0, required to store Unix file permissions + 0); + + Ref<FileAccess> fa = FileAccess::open(dir.path_join(f), FileAccess::READ); + if (fa.is_null()) { + add_message(EXPORT_MESSAGE_ERROR, TTR("ZIP Creation"), vformat(TTR("Could not open file to read from path \"%s\"."), dir.path_join(f))); + return; + } + const int bufsize = 16384; + uint8_t buf[bufsize]; + + while (true) { + uint64_t got = fa->get_buffer(buf, bufsize); + if (got == 0) { + break; + } + zipWriteInFileInZip(p_zip, buf, got); + } + + zipCloseFileInZip(p_zip); + } + f = da->get_next(); + } + da->list_dir_end(); +} + Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, Vector<SharedObject> *p_so_files, bool p_embed, int64_t *r_embedded_start, int64_t *r_embedded_size) { EditorProgress ep("savepack", TTR("Packing"), 102, true); @@ -1640,5 +1757,123 @@ bool EditorExportPlatform::can_export(const Ref<EditorExportPreset> &p_preset, S return valid; } +Error EditorExportPlatform::ssh_run_on_remote(const String &p_host, const String &p_port, const Vector<String> &p_ssh_args, const String &p_cmd_args, String *r_out, int p_port_fwd) const { + String ssh_path = EditorSettings::get_singleton()->get("export/ssh/ssh"); + if (ssh_path.is_empty()) { + ssh_path = "ssh"; + } + + List<String> args; + args.push_back("-p"); + args.push_back(p_port); + for (const String &E : p_ssh_args) { + args.push_back(E); + } + if (p_port_fwd > 0) { + args.push_back("-R"); + args.push_back(vformat("%d:localhost:%d", p_port_fwd, p_port_fwd)); + } + args.push_back(p_host); + args.push_back(p_cmd_args); + + String out; + int exit_code = -1; + + if (OS::get_singleton()->is_stdout_verbose()) { + OS::get_singleton()->print("Executing: %s", ssh_path.utf8().get_data()); + for (const String &arg : args) { + OS::get_singleton()->print(" %s", arg.utf8().get_data()); + } + OS::get_singleton()->print("\n"); + } + + Error err = OS::get_singleton()->execute(ssh_path, args, &out, &exit_code, true); + if (out.is_empty()) { + print_verbose(vformat("Exit code: %d", exit_code)); + } else { + print_verbose(vformat("Exit code: %d, Output: %s", exit_code, out.replace("\r\n", "\n"))); + } + if (r_out) { + *r_out = out.replace("\r\n", "\n").get_slice("\n", 0); + } + if (err != OK) { + return err; + } else if (exit_code != 0) { + if (!out.is_empty()) { + print_line(out); + } + return FAILED; + } + return OK; +} + +Error EditorExportPlatform::ssh_run_on_remote_no_wait(const String &p_host, const String &p_port, const Vector<String> &p_ssh_args, const String &p_cmd_args, OS::ProcessID *r_pid, int p_port_fwd) const { + String ssh_path = EditorSettings::get_singleton()->get("export/ssh/ssh"); + if (ssh_path.is_empty()) { + ssh_path = "ssh"; + } + + List<String> args; + args.push_back("-p"); + args.push_back(p_port); + for (const String &E : p_ssh_args) { + args.push_back(E); + } + if (p_port_fwd > 0) { + args.push_back("-R"); + args.push_back(vformat("%d:localhost:%d", p_port_fwd, p_port_fwd)); + } + args.push_back(p_host); + args.push_back(p_cmd_args); + + if (OS::get_singleton()->is_stdout_verbose()) { + OS::get_singleton()->print("Executing: %s", ssh_path.utf8().get_data()); + for (const String &arg : args) { + OS::get_singleton()->print(" %s", arg.utf8().get_data()); + } + OS::get_singleton()->print("\n"); + } + + return OS::get_singleton()->create_process(ssh_path, args, r_pid); +} + +Error EditorExportPlatform::ssh_push_to_remote(const String &p_host, const String &p_port, const Vector<String> &p_scp_args, const String &p_src_file, const String &p_dst_file) const { + String scp_path = EditorSettings::get_singleton()->get("export/ssh/scp"); + if (scp_path.is_empty()) { + scp_path = "scp"; + } + + List<String> args; + args.push_back("-P"); + args.push_back(p_port); + for (const String &E : p_scp_args) { + args.push_back(E); + } + args.push_back(p_src_file); + args.push_back(vformat("%s:%s", p_host, p_dst_file)); + + String out; + int exit_code = -1; + + if (OS::get_singleton()->is_stdout_verbose()) { + OS::get_singleton()->print("Executing: %s", scp_path.utf8().get_data()); + for (const String &arg : args) { + OS::get_singleton()->print(" %s", arg.utf8().get_data()); + } + OS::get_singleton()->print("\n"); + } + + Error err = OS::get_singleton()->execute(scp_path, args, &out, &exit_code, true); + if (err != OK) { + return err; + } else if (exit_code != 0) { + if (!out.is_empty()) { + print_line(out); + } + return FAILED; + } + return OK; +} + EditorExportPlatform::EditorExportPlatform() { } diff --git a/editor/export/editor_export_platform.h b/editor/export/editor_export_platform.h index d3d8a8f186..1fb35759ac 100644 --- a/editor/export/editor_export_platform.h +++ b/editor/export/editor_export_platform.h @@ -35,6 +35,7 @@ class EditorFileSystemDirectory; struct EditorProgress; #include "core/io/dir_access.h" +#include "core/io/zip_io.h" #include "editor_export_preset.h" #include "editor_export_shared_object.h" #include "scene/gui/rich_text_label.h" @@ -92,7 +93,6 @@ private: void _export_find_resources(EditorFileSystemDirectory *p_dir, HashSet<String> &p_paths); void _export_find_dependencies(const String &p_path, HashSet<String> &p_paths); - void gen_debug_flags(Vector<String> &r_flags, int p_flags); static Error _save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); static Error _save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); @@ -126,6 +126,13 @@ protected: bool exists_export_template(String template_file_name, String *err) const; String find_export_template(String template_file_name, String *err = nullptr) const; void gen_export_flags(Vector<String> &r_flags, int p_flags); + void gen_debug_flags(Vector<String> &r_flags, int p_flags); + + virtual void zip_folder_recursive(zipFile &p_zip, const String &p_root_path, const String &p_folder, const String &p_pkg_name); + + Error ssh_run_on_remote(const String &p_host, const String &p_port, const Vector<String> &p_ssh_args, const String &p_cmd_args, String *r_out = nullptr, int p_port_fwd = -1) const; + Error ssh_run_on_remote_no_wait(const String &p_host, const String &p_port, const Vector<String> &p_ssh_args, const String &p_cmd_args, OS::ProcessID *r_pid = nullptr, int p_port_fwd = -1) const; + Error ssh_push_to_remote(const String &p_host, const String &p_port, const Vector<String> &p_scp_args, const String &p_src_file, const String &p_dst_file) const; public: virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const = 0; @@ -215,6 +222,7 @@ public: DEBUG_FLAG_VIEW_NAVIGATION = 16, }; + virtual void cleanup() {} virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) { return OK; } virtual Ref<Texture2D> get_run_icon() const { return get_logo(); } diff --git a/editor/export/editor_export_platform_pc.h b/editor/export/editor_export_platform_pc.h index c71a62ee5c..8c24f2fc68 100644 --- a/editor/export/editor_export_platform_pc.h +++ b/editor/export/editor_export_platform_pc.h @@ -62,7 +62,6 @@ public: virtual Error modify_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { return OK; }; virtual Error export_project_data(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags); - void set_extension(const String &p_extension, const String &p_feature_key = "default"); void set_name(const String &p_name); void set_os_name(const String &p_name); diff --git a/editor/export/editor_export_plugin.cpp b/editor/export/editor_export_plugin.cpp index f34ebfa541..784dbc116a 100644 --- a/editor/export/editor_export_plugin.cpp +++ b/editor/export/editor_export_plugin.cpp @@ -34,6 +34,7 @@ #include "core/io/dir_access.h" #include "core/io/file_access.h" #include "editor/editor_paths.h" +#include "editor/editor_settings.h" #include "editor/export/editor_export_platform.h" #include "scene/resources/resource_format_text.h" @@ -226,4 +227,8 @@ void EditorExportPlugin::_bind_methods() { } EditorExportPlugin::EditorExportPlugin() { + GLOBAL_DEF("editor/export/convert_text_resources_to_binary", false); + + EDITOR_DEF("export/ssh/ssh", ""); + EDITOR_DEF("export/ssh/scp", ""); } diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index a67da0c2b1..f1fd1d5a03 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -217,6 +217,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ Vector<Vector3> vertices; Vector<Vector3> normals; Vector<Vector2> uvs; + Vector<Color> colors; String name; HashMap<String, HashMap<String, Ref<StandardMaterial3D>>> material_map; @@ -249,6 +250,19 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ vtx.y = v[2].to_float() * scale_mesh.y + offset_mesh.y; vtx.z = v[3].to_float() * scale_mesh.z + offset_mesh.z; vertices.push_back(vtx); + //vertex color + if (v.size() == 7) { + while (colors.size() < vertices.size() - 1) { + colors.push_back(Color(1.0, 1.0, 1.0)); + } + Color c; + c.r = v[4].to_float(); + c.g = v[5].to_float(); + c.b = v[6].to_float(); + colors.push_back(c); + } else if (!colors.is_empty()) { + colors.push_back(Color(1.0, 1.0, 1.0)); + } } else if (l.begins_with("vt ")) { //uv Vector<String> v = l.split(" ", false); @@ -317,6 +331,9 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ ERR_FAIL_INDEX_V(vtx, vertices.size(), ERR_FILE_CORRUPT); Vector3 vertex = vertices[vtx]; + if (!colors.is_empty()) { + surf_tool->set_color(colors[vtx]); + } if (!smoothing) { smooth_group++; } @@ -356,7 +373,11 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ print_verbose("OBJ: Current material " + current_material + " has " + itos(material_map.has(current_material_library) && material_map[current_material_library].has(current_material))); if (material_map.has(current_material_library) && material_map[current_material_library].has(current_material)) { - surf_tool->set_material(material_map[current_material_library][current_material]); + Ref<StandardMaterial3D> &material = material_map[current_material_library][current_material]; + if (!colors.is_empty()) { + material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); + } + surf_tool->set_material(material); } mesh = surf_tool->commit(mesh, mesh_flags); diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index ec3eb1a494..10f2ce25d9 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -267,7 +267,7 @@ void AnimationPlayerEditor::_stop_pressed() { return; } - player->stop(false); + player->pause(); play->set_pressed(false); stop->set_pressed(true); } @@ -1155,7 +1155,7 @@ void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_set, bool player->seek_delta(pos, pos - cpos); } else { - player->stop(true); + player->stop(); player->seek(pos, true); } } diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index c2dac83416..9f2cfc8d9c 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -293,7 +293,7 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() { preview = memnew(TextureRect); previews_vbox->add_child(preview); - preview->set_ignore_texture_size(true); + preview->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE); preview->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED); preview->set_custom_minimum_size(Size2(640 * EDSCALE, 345 * EDSCALE)); preview->set_v_size_flags(Control::SIZE_EXPAND_FILL); diff --git a/editor/plugins/bone_map_editor_plugin.cpp b/editor/plugins/bone_map_editor_plugin.cpp index dfcf9256c4..c913a9b0ab 100644 --- a/editor/plugins/bone_map_editor_plugin.cpp +++ b/editor/plugins/bone_map_editor_plugin.cpp @@ -316,7 +316,7 @@ void BoneMapper::create_editor() { profile_texture = memnew(TextureRect); profile_texture->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED); - profile_texture->set_ignore_texture_size(true); + profile_texture->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE); profile_texture->set_h_size_flags(Control::SIZE_FILL); profile_texture->set_v_size_flags(Control::SIZE_FILL); bone_mapper_field->add_child(profile_texture); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 7f9a23463c..bd7b7ff1cb 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -4370,8 +4370,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { show_rulers = !show_rulers; int idx = view_menu->get_popup()->get_item_index(SHOW_RULERS); view_menu->get_popup()->set_item_checked(idx, show_rulers); - _update_scrollbars(); - viewport->queue_redraw(); + update_viewport(); } break; case SHOW_GUIDES: { show_guides = !show_guides; @@ -4683,25 +4682,18 @@ void CanvasItemEditor::_focus_selection(int p_op) { } else { rect = rect.merge(canvas_item_rect); } - }; - - if (p_op == VIEW_CENTER_TO_SELECTION) { - center = rect.get_center(); - Vector2 offset = viewport->get_size() / 2 - EditorNode::get_singleton()->get_scene_root()->get_global_canvas_transform().xform(center); - view_offset -= (offset / zoom).round(); - update_viewport(); - - } else { // VIEW_FRAME_TO_SELECTION + } - if (rect.size.x > CMP_EPSILON && rect.size.y > CMP_EPSILON) { - real_t scale_x = viewport->get_size().x / rect.size.x; - real_t scale_y = viewport->get_size().y / rect.size.y; - zoom = scale_x < scale_y ? scale_x : scale_y; - zoom *= 0.90; - viewport->queue_redraw(); - zoom_widget->set_zoom(zoom); - call_deferred(SNAME("_popup_callback"), VIEW_CENTER_TO_SELECTION); - } + if (p_op == VIEW_FRAME_TO_SELECTION && rect.size.x > CMP_EPSILON && rect.size.y > CMP_EPSILON) { + real_t scale_x = viewport->get_size().x / rect.size.x; + real_t scale_y = viewport->get_size().y / rect.size.y; + zoom = scale_x < scale_y ? scale_x : scale_y; + zoom *= 0.90; + zoom_widget->set_zoom(zoom); + viewport->queue_redraw(); // Redraw to update the global canvas transform after zoom changes. + call_deferred(SNAME("center_at"), rect.get_center()); // Defer because the updated transform is needed. + } else { + center_at(rect.get_center()); } } @@ -4715,6 +4707,7 @@ void CanvasItemEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("set_state"), &CanvasItemEditor::set_state); ClassDB::bind_method(D_METHOD("update_viewport"), &CanvasItemEditor::update_viewport); + ClassDB::bind_method(D_METHOD("center_at", "position"), &CanvasItemEditor::center_at); ClassDB::bind_method("_set_owner_for_node_and_children", &CanvasItemEditor::_set_owner_for_node_and_children); @@ -4961,6 +4954,12 @@ void CanvasItemEditor::focus_selection() { _focus_selection(VIEW_CENTER_TO_SELECTION); } +void CanvasItemEditor::center_at(const Point2 &p_pos) { + Vector2 offset = viewport->get_size() / 2 - EditorNode::get_singleton()->get_scene_root()->get_global_canvas_transform().xform(p_pos); + view_offset -= (offset / zoom).round(); + update_viewport(); +} + CanvasItemEditor::CanvasItemEditor() { zoom = 1.0 / MAX(1, EDSCALE); view_offset = Point2(-150 - RULER_WIDTH, -95 - RULER_WIDTH); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 8f02f02c32..f4fcc8a3d2 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -550,6 +550,7 @@ public: void edit(CanvasItem *p_canvas_item); void focus_selection(); + void center_at(const Point2 &p_pos); EditorSelection *editor_selection = nullptr; diff --git a/editor/plugins/gradient_texture_2d_editor_plugin.cpp b/editor/plugins/gradient_texture_2d_editor_plugin.cpp index 703a44403d..e03353a67b 100644 --- a/editor/plugins/gradient_texture_2d_editor_plugin.cpp +++ b/editor/plugins/gradient_texture_2d_editor_plugin.cpp @@ -178,7 +178,7 @@ void GradientTexture2DEditorRect::_notification(int p_what) { GradientTexture2DEditorRect::GradientTexture2DEditorRect() { checkerboard = memnew(TextureRect); checkerboard->set_stretch_mode(TextureRect::STRETCH_TILE); - checkerboard->set_ignore_texture_size(true); + checkerboard->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE); checkerboard->set_draw_behind_parent(true); add_child(checkerboard, false, INTERNAL_MODE_FRONT); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 7603a5e55d..f4ec026504 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -1551,7 +1551,7 @@ SpriteFramesEditor::SpriteFramesEditor() { split_sheet_vb->add_child(split_sheet_panel); split_sheet_preview = memnew(TextureRect); - split_sheet_preview->set_ignore_texture_size(true); + split_sheet_preview->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE); split_sheet_preview->set_mouse_filter(MOUSE_FILTER_PASS); split_sheet_preview->connect("draw", callable_mp(this, &SpriteFramesEditor::_sheet_preview_draw)); split_sheet_preview->connect("gui_input", callable_mp(this, &SpriteFramesEditor::_sheet_preview_input)); diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 2dab3fa278..2fb624b713 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -128,7 +128,7 @@ TexturePreview::TexturePreview(Ref<Texture2D> p_texture, bool p_show_metadata) { texture_display->set_texture(p_texture); texture_display->set_anchors_preset(TextureRect::PRESET_FULL_RECT); texture_display->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED); - texture_display->set_ignore_texture_size(true); + texture_display->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE); add_child(texture_display); if (p_show_metadata) { diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 59f2159167..05d32e1d08 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -824,10 +824,18 @@ void TextureRegionEditor::_update_autoslice() { void TextureRegionEditor::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_EXIT_TREE: { + get_tree()->disconnect("node_removed", callable_mp(this, &TextureRegionEditor::_node_removed)); + } break; + + case NOTIFICATION_ENTER_TREE: { + get_tree()->connect("node_removed", callable_mp(this, &TextureRegionEditor::_node_removed)); + [[fallthrough]]; + } case NOTIFICATION_THEME_CHANGED: { edit_draw->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); } break; + case NOTIFICATION_READY: { zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); @@ -840,11 +848,13 @@ void TextureRegionEditor::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EDITOR_GET("editors/panning/simple_panning"))); } break; + case NOTIFICATION_VISIBILITY_CHANGED: { if (snap_mode == SNAP_AUTOSLICE && is_visible() && autoslice_is_dirty) { _update_autoslice(); } } break; + case NOTIFICATION_WM_WINDOW_FOCUS_IN: { // This happens when the user leaves the Editor and returns, // they could have changed the textures, so the cache is cleared. @@ -867,7 +877,6 @@ void TextureRegionEditor::_node_removed(Object *p_obj) { void TextureRegionEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_edit_region"), &TextureRegionEditor::_edit_region); - ClassDB::bind_method(D_METHOD("_node_removed"), &TextureRegionEditor::_node_removed); ClassDB::bind_method(D_METHOD("_zoom_on_position"), &TextureRegionEditor::_zoom_on_position); ClassDB::bind_method(D_METHOD("_update_rect"), &TextureRegionEditor::_update_rect); } diff --git a/editor/plugins/tiles/atlas_merging_dialog.cpp b/editor/plugins/tiles/atlas_merging_dialog.cpp index 7edf6e3a30..4128029fc6 100644 --- a/editor/plugins/tiles/atlas_merging_dialog.cpp +++ b/editor/plugins/tiles/atlas_merging_dialog.cpp @@ -56,7 +56,7 @@ void AtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> p_atla new_texture_region_size = new_texture_region_size.max(atlas_source->get_texture_region_size()); } - // Generate the merged TileSetAtlasSource. + // Generate the new texture. Vector2i atlas_offset; int line_height = 0; for (int source_index = 0; source_index < p_atlas_sources.size(); source_index++) { @@ -72,28 +72,6 @@ void AtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> p_atla Rect2i new_tile_rect_in_altas = Rect2i(atlas_offset + tile_id, atlas_source->get_tile_size_in_atlas(tile_id)); - // Create tiles and alternatives, then copy their properties. - for (int alternative_index = 0; alternative_index < atlas_source->get_alternative_tiles_count(tile_id); alternative_index++) { - int alternative_id = atlas_source->get_alternative_tile_id(tile_id, alternative_index); - if (alternative_id == 0) { - merged->create_tile(new_tile_rect_in_altas.position, new_tile_rect_in_altas.size); - } else { - merged->create_alternative_tile(new_tile_rect_in_altas.position, alternative_index); - } - - // Copy the properties. - TileData *original_tile_data = atlas_source->get_tile_data(tile_id, alternative_id); - List<PropertyInfo> properties; - original_tile_data->get_property_list(&properties); - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - const StringName &property_name = E->get().name; - merged->set(property_name, original_tile_data->get(property_name)); - } - - // Add to the mapping. - merged_mapping[source_index][tile_id] = new_tile_rect_in_altas.position; - } - // Copy the texture. for (int frame = 0; frame < atlas_source->get_tile_animation_frames_count(tile_id); frame++) { Rect2i src_rect = atlas_source->get_tile_texture_region(tile_id, frame); @@ -103,6 +81,9 @@ void AtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> p_atla } output_image->blit_rect(atlas_source->get_texture()->get_image(), src_rect, dst_rect_wide.get_center() - src_rect.size / 2); } + + // Add to the mapping. + merged_mapping[source_index][tile_id] = new_tile_rect_in_altas.position; } // Compute the atlas offset. @@ -115,8 +96,43 @@ void AtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> p_atla } } - merged->set_name(p_atlas_sources[0]->get_name()); merged->set_texture(ImageTexture::create_from_image(output_image)); + + // Copy the tiles to the merged TileSetAtlasSource. + for (int source_index = 0; source_index < p_atlas_sources.size(); source_index++) { + Ref<TileSetAtlasSource> atlas_source = p_atlas_sources[source_index]; + for (KeyValue<Vector2i, Vector2i> tile_mapping : merged_mapping[source_index]) { + // Create tiles and alternatives, then copy their properties. + for (int alternative_index = 0; alternative_index < atlas_source->get_alternative_tiles_count(tile_mapping.key); alternative_index++) { + int alternative_id = atlas_source->get_alternative_tile_id(tile_mapping.key, alternative_index); + if (alternative_id == 0) { + merged->create_tile(tile_mapping.value, atlas_source->get_tile_size_in_atlas(tile_mapping.key)); + } else { + merged->create_alternative_tile(tile_mapping.value, alternative_index); + } + + // Copy the properties. + TileData *src_tile_data = atlas_source->get_tile_data(tile_mapping.key, alternative_id); + List<PropertyInfo> properties; + src_tile_data->get_property_list(&properties); + + TileData *dst_tile_data = merged->get_tile_data(tile_mapping.value, alternative_id); + for (PropertyInfo property : properties) { + if (!(property.usage & PROPERTY_USAGE_STORAGE)) { + continue; + } + Variant value = src_tile_data->get(property.name); + Variant default_value = ClassDB::class_get_default_property_value("TileData", property.name); + if (default_value.get_type() != Variant::NIL && bool(Variant::evaluate(Variant::OP_EQUAL, value, default_value))) { + continue; + } + dst_tile_data->set(property.name, value); + } + } + } + } + + merged->set_name(p_atlas_sources[0]->get_name()); merged->set_texture_region_size(new_texture_region_size); } } @@ -151,6 +167,8 @@ void AtlasMergingDialog::_merge_confirmed(String p_path) { Ref<ImageTexture> output_image_texture = merged->get_texture(); output_image_texture->get_image()->save_png(p_path); + ResourceLoader::import(p_path); + Ref<Texture2D> new_texture_resource = ResourceLoader::load(p_path, "Texture2D"); merged->set_texture(new_texture_resource); @@ -225,6 +243,14 @@ bool AtlasMergingDialog::_get(const StringName &p_name, Variant &r_ret) const { return false; } +void AtlasMergingDialog::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_VISIBILITY_CHANGED: { + _update_texture(); + } break; + } +} + void AtlasMergingDialog::update_tile_set(Ref<TileSet> p_tile_set) { ERR_FAIL_COND(!p_tile_set.is_valid()); tile_set = p_tile_set; @@ -300,7 +326,7 @@ AtlasMergingDialog::AtlasMergingDialog() { preview = memnew(TextureRect); preview->set_h_size_flags(Control::SIZE_EXPAND_FILL); preview->set_v_size_flags(Control::SIZE_EXPAND_FILL); - preview->set_ignore_texture_size(true); + preview->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE); preview->hide(); preview->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED); atlas_merging_right_panel->add_child(preview); diff --git a/editor/plugins/tiles/atlas_merging_dialog.h b/editor/plugins/tiles/atlas_merging_dialog.h index 032541c90e..bf1b56894f 100644 --- a/editor/plugins/tiles/atlas_merging_dialog.h +++ b/editor/plugins/tiles/atlas_merging_dialog.h @@ -75,6 +75,8 @@ protected: bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; + void _notification(int p_what); + public: void update_tile_set(Ref<TileSet> p_tile_set); diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index dd4daa45b7..e9c313a372 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -3303,12 +3303,16 @@ void TileMapEditorTerrainsPlugin::_update_theme() { void TileMapEditorTerrainsPlugin::edit(ObjectID p_tile_map_id, int p_tile_map_layer) { _stop_dragging(); // Avoids staying in a wrong drag state. - tile_map_id = p_tile_map_id; - tile_map_layer = p_tile_map_layer; + if (tile_map_id != p_tile_map_id) { + tile_map_id = p_tile_map_id; - _update_terrains_cache(); - _update_terrains_tree(); - _update_tiles_list(); + // Clear the selection. + _update_terrains_cache(); + _update_terrains_tree(); + _update_tiles_list(); + } + + tile_map_layer = p_tile_map_layer; } TileMapEditorTerrainsPlugin::TileMapEditorTerrainsPlugin() { diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp index b40e588e07..19ee0ae98d 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.cpp +++ b/editor/plugins/tiles/tiles_editor_plugin.cpp @@ -185,26 +185,34 @@ void TilesEditorPlugin::_notification(int p_what) { } void TilesEditorPlugin::make_visible(bool p_visible) { - is_visible = p_visible; - - if (is_visible) { + if (p_visible || is_tile_map_selected()) { // Disable and hide invalid editors. TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); tileset_editor_button->set_visible(tile_set.is_valid()); tilemap_editor_button->set_visible(tile_map); - if (tile_map && !is_editing_tile_set) { + if (tile_map && (!is_editing_tile_set || !p_visible)) { EditorNode::get_singleton()->make_bottom_panel_item_visible(tilemap_editor); } else { EditorNode::get_singleton()->make_bottom_panel_item_visible(tileset_editor); } - + is_visible = true; } else { tileset_editor_button->hide(); tilemap_editor_button->hide(); EditorNode::get_singleton()->hide_bottom_panel(); + is_visible = false; } } +bool TilesEditorPlugin::is_tile_map_selected() { + TypedArray<Node> selection = get_editor_interface()->get_selection()->get_selected_nodes(); + if (selection.size() == 1 && Object::cast_to<TileMap>(selection[0])) { + return true; + } + + return false; +} + void TilesEditorPlugin::queue_pattern_preview(Ref<TileSet> p_tile_set, Ref<TileMapPattern> p_pattern, Callable p_callback) { ERR_FAIL_COND(!p_tile_set.is_valid()); ERR_FAIL_COND(!p_pattern.is_valid()); @@ -362,19 +370,24 @@ void TilesEditorPlugin::edit(Object *p_object) { } else if (p_object->is_class("TileSet")) { tile_set = Ref<TileSet>(p_object); if (tile_map) { - if (tile_map->get_tileset() != tile_set || !tile_map->is_inside_tree()) { + if (tile_map->get_tileset() != tile_set || !tile_map->is_inside_tree() || !is_tile_map_selected()) { tile_map = nullptr; tile_map_id = ObjectID(); } } is_editing_tile_set = true; - EditorNode::get_singleton()->make_bottom_panel_item_visible(tileset_editor); } } // Update the editors. _update_editors(); + // If the tileset is being edited, the visibility function must be called + // here after _update_editors has been called. + if (is_editing_tile_set) { + EditorNode::get_singleton()->make_bottom_panel_item_visible(tileset_editor); + } + // Add change listener. if (tile_map) { tile_map->connect("changed", callable_mp(this, &TilesEditorPlugin::_tile_map_changed)); diff --git a/editor/plugins/tiles/tiles_editor_plugin.h b/editor/plugins/tiles/tiles_editor_plugin.h index 5b91584aa3..50073e59c6 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.h +++ b/editor/plugins/tiles/tiles_editor_plugin.h @@ -110,6 +110,8 @@ public: virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) override { return tilemap_editor->forward_canvas_gui_input(p_event); } virtual void forward_canvas_draw_over_viewport(Control *p_overlay) override { tilemap_editor->forward_canvas_draw_over_viewport(p_overlay); } + bool is_tile_map_selected(); + // Pattern preview API. void queue_pattern_preview(Ref<TileSet> p_tile_set, Ref<TileMapPattern> p_pattern, Callable p_callback); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 46ec3bcdd1..56dbdb49eb 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -177,8 +177,8 @@ void VisualShaderGraphPlugin::update_node(VisualShader::Type p_type, int p_node_ if (p_type != visual_shader->get_shader_type() || !links.has(p_node_id)) { return; } - remove_node(p_type, p_node_id); - add_node(p_type, p_node_id); + remove_node(p_type, p_node_id, true); + add_node(p_type, p_node_id, true); } void VisualShaderGraphPlugin::set_input_port_default_value(VisualShader::Type p_type, int p_node_id, int p_port_id, Variant p_value) { @@ -305,8 +305,8 @@ void VisualShaderGraphPlugin::update_parameter_refs() { for (KeyValue<int, Link> &E : links) { VisualShaderNodeParameterRef *ref = Object::cast_to<VisualShaderNodeParameterRef>(E.value.visual_node); if (ref) { - remove_node(E.value.type, E.key); - add_node(E.value.type, E.key); + remove_node(E.value.type, E.key, true); + add_node(E.value.type, E.key, true); } } } @@ -356,7 +356,7 @@ void VisualShaderGraphPlugin::update_theme() { vector_expanded_color[3] = editor->get_theme_color(SNAME("axis_w_color"), SNAME("Editor")); // alpha } -void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { +void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool p_just_update) { if (!visual_shader.is_valid() || p_type != visual_shader->get_shader_type()) { return; } @@ -424,7 +424,12 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { graph->add_child(node); node->set_theme(vstheme); editor->_update_created_node(node); - register_link(p_type, p_id, vsnode.ptr(), node); + + if (p_just_update) { + links[p_id].graph_node = node; + } else { + register_link(p_type, p_id, vsnode.ptr(), node); + } if (is_resizable) { size = resizable_node->get_size(); @@ -1038,11 +1043,13 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { } } -void VisualShaderGraphPlugin::remove_node(VisualShader::Type p_type, int p_id) { +void VisualShaderGraphPlugin::remove_node(VisualShader::Type p_type, int p_id, bool p_just_update) { if (visual_shader->get_shader_type() == p_type && links.has(p_id)) { links[p_id].graph_node->get_parent()->remove_child(links[p_id].graph_node); memdelete(links[p_id].graph_node); - links.erase(p_id); + if (!p_just_update) { + links.erase(p_id); + } } } @@ -1913,7 +1920,7 @@ void VisualShaderEditor::_update_graph() { graph_plugin->update_theme(); for (int n_i = 0; n_i < nodes.size(); n_i++) { - graph_plugin->add_node(type, nodes[n_i]); + graph_plugin->add_node(type, nodes[n_i], false); } graph_plugin->make_dirty(false); @@ -2967,8 +2974,8 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, Stri } undo_redo->add_do_method(visual_shader.ptr(), "add_node", type, vsnode, position, id_to_use); undo_redo->add_undo_method(visual_shader.ptr(), "remove_node", type, id_to_use); - undo_redo->add_do_method(graph_plugin.ptr(), "add_node", type, id_to_use); - undo_redo->add_undo_method(graph_plugin.ptr(), "remove_node", type, id_to_use); + undo_redo->add_do_method(graph_plugin.ptr(), "add_node", type, id_to_use, false); + undo_redo->add_undo_method(graph_plugin.ptr(), "remove_node", type, id_to_use, false); VisualShaderNodeExpression *expr = Object::cast_to<VisualShaderNodeExpression>(vsnode.ptr()); if (expr) { @@ -3361,7 +3368,7 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) { undo_redo->add_do_method(visual_shader.ptr(), "remove_node", type, F); undo_redo->add_undo_method(visual_shader.ptr(), "add_node", type, node, visual_shader->get_node_position(type, F), F); - undo_redo->add_undo_method(graph_plugin.ptr(), "add_node", type, F); + undo_redo->add_undo_method(graph_plugin.ptr(), "add_node", type, F, false); VisualShaderNodeParameter *parameter = Object::cast_to<VisualShaderNodeParameter>(node.ptr()); if (parameter) { @@ -3391,7 +3398,7 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) { // delete nodes from the graph for (const int &F : p_nodes) { - undo_redo->add_do_method(graph_plugin.ptr(), "remove_node", type, F); + undo_redo->add_do_method(graph_plugin.ptr(), "remove_node", type, F, false); } // update parameter refs if any parameter has been deleted @@ -4131,7 +4138,7 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, List<CopyItem> &r_items, c } undo_redo->add_do_method(visual_shader.ptr(), "add_node", type, node, item.position + p_offset, id_from); - undo_redo->add_do_method(graph_plugin.ptr(), "add_node", type, id_from); + undo_redo->add_do_method(graph_plugin.ptr(), "add_node", type, id_from, false); added_set.insert(id_from); id_from++; @@ -4153,7 +4160,7 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, List<CopyItem> &r_items, c continue; } undo_redo->add_undo_method(visual_shader.ptr(), "remove_node", type, id_from); - undo_redo->add_undo_method(graph_plugin.ptr(), "remove_node", type, id_from); + undo_redo->add_undo_method(graph_plugin.ptr(), "remove_node", type, id_from, false); id_from++; } diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index a43d44473f..88f5e3359c 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -119,8 +119,8 @@ public: void make_dirty(bool p_enabled); void update_node(VisualShader::Type p_type, int p_id); void update_node_deferred(VisualShader::Type p_type, int p_node_id); - void add_node(VisualShader::Type p_type, int p_id); - void remove_node(VisualShader::Type p_type, int p_id); + void add_node(VisualShader::Type p_type, int p_id, bool p_just_update); + void remove_node(VisualShader::Type p_type, int p_id, bool p_just_update); void connect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port); void disconnect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port); void show_port_preview(VisualShader::Type p_type, int p_node_id, int p_port_id); diff --git a/editor/progress_dialog.cpp b/editor/progress_dialog.cpp index 4ecf3338bc..db11f80826 100644 --- a/editor/progress_dialog.cpp +++ b/editor/progress_dialog.cpp @@ -32,6 +32,7 @@ #include "core/object/message_queue.h" #include "core/os/os.h" +#include "editor/editor_node.h" #include "editor/editor_scale.h" #include "main/main.h" #include "servers/display_server.h" @@ -133,6 +134,14 @@ void BackgroundProgress::end_task(const String &p_task) { ProgressDialog *ProgressDialog::singleton = nullptr; void ProgressDialog::_notification(int p_what) { + if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { + if (!is_visible()) { + Node *p = get_parent(); + if (p) { + p->remove_child(this); + } + } + } } void ProgressDialog::_popup() { @@ -146,8 +155,17 @@ void ProgressDialog::_popup() { main->set_offset(SIDE_TOP, style->get_margin(SIDE_TOP)); main->set_offset(SIDE_BOTTOM, -style->get_margin(SIDE_BOTTOM)); - //raise(); - popup_centered(ms); + EditorNode *ed = EditorNode::get_singleton(); + if (ed && !is_inside_tree()) { + Window *w = ed->get_window(); + while (w && w->get_exclusive_child()) { + w = w->get_exclusive_child(); + } + if (w && w != this) { + w->add_child(this); + popup_centered(ms); + } + } } void ProgressDialog::add_task(const String &p_task, const String &p_label, int p_steps, bool p_can_cancel) { diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index b4ffc7d78d..c4f5eb777e 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1233,7 +1233,7 @@ void ProjectList::load_project_icon(int p_index) { // The default project icon is 128×128 to look crisp on hiDPI displays, // but we want the actual displayed size to be 64×64 on loDPI displays. - item.control->icon->set_ignore_texture_size(true); + item.control->icon->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE); item.control->icon->set_custom_minimum_size(Size2(64, 64) * EDSCALE); item.control->icon->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED); @@ -1273,7 +1273,7 @@ ProjectList::Item ProjectList::load_project_data(const String &p_path, bool p_fa PackedStringArray unsupported_features = ProjectSettings::get_unsupported_features(project_features); uint64_t last_edited = 0; - if (FileAccess::exists(conf)) { + if (cf_err == OK) { // The modification date marks the date the project was last edited. // This is because the `project.godot` file will always be modified // when editing a project (but not when running it). @@ -2653,8 +2653,9 @@ ProjectManager::ProjectManager() { AcceptDialog::set_swap_cancel_ok(swap_cancel_ok == 2); } - set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); - set_theme(create_custom_theme()); + Ref<Theme> theme = create_custom_theme(); + set_theme(theme); + DisplayServer::set_early_window_clear_color_override(true, theme->get_color(SNAME("background"), SNAME("Editor"))); set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 2f50172f54..b4f1ca5d0b 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -993,6 +993,10 @@ void SceneTreeEditor::_renamed() { } if (new_name == n->get_name()) { + if (which->get_text(0).is_empty()) { + which->set_text(0, new_name); + } + return; } |