diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_node.cpp | 134 | ||||
-rw-r--r-- | editor/editor_node.h | 11 | ||||
-rw-r--r-- | editor/editor_plugin.cpp | 1 | ||||
-rw-r--r-- | editor/editor_toaster.cpp | 4 | ||||
-rw-r--r-- | editor/export/project_export.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/gdextension_export_plugin.h | 129 | ||||
-rw-r--r-- | editor/plugins/tiles/tiles_editor_plugin.cpp | 6 | ||||
-rw-r--r-- | editor/progress_dialog.cpp | 4 | ||||
-rw-r--r-- | editor/project_manager.cpp | 2 |
9 files changed, 196 insertions, 97 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 6fcf092834..b36f74db9c 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -151,6 +151,51 @@ EditorNode *EditorNode::singleton = nullptr; // The metadata key used to store and retrieve the version text to copy to the clipboard. static const String META_TEXT_TO_COPY = "text_to_copy"; +class AcceptDialogAutoReparent : public AcceptDialog { + GDCLASS(AcceptDialogAutoReparent, AcceptDialog); + +protected: + void _notification(int p_what) { + if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { + if (!is_visible()) { + Node *p = get_parent(); + if (p) { + p->remove_child(this); + } + } + } + } + +public: + void attach_and_popup_centered() { + 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(); + } + } + } + + void attach_and_popup_centered_ratio(float p_ratio = 0.8) { + 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_ratio(p_ratio); + } + } + } +}; + void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vector<String> &r_filenames) { ERR_FAIL_COND_MSG(p_full_paths.size() != r_filenames.size(), vformat("disambiguate_filenames requires two string vectors of same length (%d != %d).", p_full_paths.size(), r_filenames.size())); @@ -615,6 +660,21 @@ void EditorNode::_notification(int p_what) { if (progress_dialog) { progress_dialog->queue_free(); } + if (load_error_dialog) { + load_error_dialog->queue_free(); + } + if (execute_output_dialog) { + execute_output_dialog->queue_free(); + } + if (warning) { + warning->queue_free(); + } + if (accept) { + accept->queue_free(); + } + if (save_accept) { + save_accept->queue_free(); + } editor_data.save_editor_external_data(); FileAccess::set_file_close_fail_notify_callback(nullptr); log->deinit(); // Do not get messages anymore. @@ -4266,9 +4326,11 @@ void EditorNode::add_io_error(const String &p_error) { void EditorNode::_load_error_notify(void *p_ud, const String &p_text) { EditorNode *en = static_cast<EditorNode *>(p_ud); - en->load_errors->add_image(en->gui_base->get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); - en->load_errors->add_text(p_text + "\n"); - en->load_error_dialog->popup_centered_ratio(0.5); + if (en && en->load_error_dialog) { + en->load_errors->add_image(en->gui_base->get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); + en->load_errors->add_text(p_text + "\n"); + en->load_error_dialog->attach_and_popup_centered_ratio(0.5); + } } bool EditorNode::_find_scene_in_use(Node *p_node, const String &p_path) const { @@ -4639,23 +4701,27 @@ Error EditorNode::export_preset(const String &p_preset, const String &p_path, bo void EditorNode::show_accept(const String &p_text, const String &p_title) { current_menu_option = -1; - accept->set_ok_button_text(p_title); - accept->set_text(p_text); - accept->popup_centered(); + if (accept) { + accept->set_ok_button_text(p_title); + accept->set_text(p_text); + accept->attach_and_popup_centered(); + } } void EditorNode::show_save_accept(const String &p_text, const String &p_title) { current_menu_option = -1; - save_accept->set_ok_button_text(p_title); - save_accept->set_text(p_text); - save_accept->popup_centered(); + if (save_accept) { + save_accept->set_ok_button_text(p_title); + save_accept->set_text(p_text); + save_accept->attach_and_popup_centered(); + } } void EditorNode::show_warning(const String &p_text, const String &p_title) { - if (warning->is_inside_tree()) { + if (warning) { warning->set_text(p_text); warning->set_title(p_title); - warning->popup_centered(); + warning->attach_and_popup_centered(); } else { WARN_PRINT(p_title + " " + p_text); } @@ -4795,6 +4861,7 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) { dock_slot[nrect]->add_child(dock); dock_popup_selected_idx = nrect; dock_slot[nrect]->set_current_tab(dock_slot[nrect]->get_tab_count() - 1); + dock_slot[nrect]->set_tab_title(dock_slot[nrect]->get_tab_count() - 1, TTRGET(dock->get_name())); dock_slot[nrect]->show(); dock_select->queue_redraw(); @@ -5152,6 +5219,7 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String } dock_slot[i]->add_child(node); dock_slot[i]->move_child(node, 0); + dock_slot[i]->set_tab_title(0, TTRGET(node->get_name())); dock_slot[i]->show(); } } @@ -6549,11 +6617,13 @@ static void _execute_thread(void *p_ud) { } int EditorNode::execute_and_show_output(const String &p_title, const String &p_path, const List<String> &p_arguments, bool p_close_on_ok, bool p_close_on_errors) { - execute_output_dialog->set_title(p_title); - execute_output_dialog->get_ok_button()->set_disabled(true); - execute_outputs->clear(); - execute_outputs->set_scroll_follow(true); - execute_output_dialog->popup_centered_ratio(); + if (execute_output_dialog) { + execute_output_dialog->set_title(p_title); + execute_output_dialog->get_ok_button()->set_disabled(true); + execute_outputs->clear(); + execute_outputs->set_scroll_follow(true); + execute_output_dialog->attach_and_popup_centered_ratio(); + } ExecuteThreadArgs eta; eta.path = p_path; @@ -6571,6 +6641,7 @@ int EditorNode::execute_and_show_output(const String &p_title, const String &p_p String to_add = eta.output.substr(prev_len, eta.output.length()); prev_len = eta.output.length(); execute_outputs->add_text(to_add); + DisplayServer::get_singleton()->process_events(); // Get rid of pending events. Main::iteration(); } } @@ -6580,14 +6651,16 @@ int EditorNode::execute_and_show_output(const String &p_title, const String &p_p eta.execute_output_thread.wait_to_finish(); execute_outputs->add_text("\nExit Code: " + itos(eta.exitcode)); - if (p_close_on_errors && eta.exitcode != 0) { - execute_output_dialog->hide(); - } - if (p_close_on_ok && eta.exitcode == 0) { - execute_output_dialog->hide(); - } + if (execute_output_dialog) { + if (p_close_on_errors && eta.exitcode != 0) { + execute_output_dialog->hide(); + } + if (p_close_on_ok && eta.exitcode == 0) { + execute_output_dialog->hide(); + } - execute_output_dialog->get_ok_button()->set_disabled(false); + execute_output_dialog->get_ok_button()->set_disabled(false); + } return eta.exitcode; } @@ -7158,12 +7231,10 @@ EditorNode::EditorNode() { prev_scene->set_position(Point2(3, 24)); prev_scene->hide(); - accept = memnew(AcceptDialog); - gui_base->add_child(accept); + accept = memnew(AcceptDialogAutoReparent); accept->connect("confirmed", callable_mp(this, &EditorNode::_menu_confirm_current)); - save_accept = memnew(AcceptDialog); - gui_base->add_child(save_accept); + save_accept = memnew(AcceptDialogAutoReparent); save_accept->connect("confirmed", callable_mp(this, &EditorNode::_menu_option).bind((int)MenuOptions::FILE_SAVE_AS_SCENE)); project_export = memnew(ProjectExportDialog); @@ -7208,9 +7279,8 @@ EditorNode::EditorNode() { gui_base->add_child(fbx_importer_manager); #endif - warning = memnew(AcceptDialog); + warning = memnew(AcceptDialogAutoReparent); warning->add_button(TTR("Copy Text"), true, "copy"); - gui_base->add_child(warning); warning->connect("custom_action", callable_mp(this, &EditorNode::_copy_warning)); ED_SHORTCUT("editor/next_tab", TTR("Next Scene Tab"), KeyModifierMask::CMD_OR_CTRL + Key::TAB); @@ -7978,17 +8048,15 @@ EditorNode::EditorNode() { set_process_shortcut_input(true); load_errors = memnew(RichTextLabel); - load_error_dialog = memnew(AcceptDialog); + load_error_dialog = memnew(AcceptDialogAutoReparent); load_error_dialog->add_child(load_errors); load_error_dialog->set_title(TTR("Load Errors")); - gui_base->add_child(load_error_dialog); execute_outputs = memnew(RichTextLabel); execute_outputs->set_selection_enabled(true); - execute_output_dialog = memnew(AcceptDialog); + execute_output_dialog = memnew(AcceptDialogAutoReparent); execute_output_dialog->add_child(execute_outputs); execute_output_dialog->set_title(""); - gui_base->add_child(execute_output_dialog); EditorFileSystem::get_singleton()->connect("sources_changed", callable_mp(this, &EditorNode::_sources_changed)); EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &EditorNode::_fs_changed)); diff --git a/editor/editor_node.h b/editor/editor_node.h index 8ad5969249..e0aea7abde 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -45,6 +45,7 @@ typedef void (*EditorPluginInitializeCallback)(); typedef bool (*EditorBuildCallback)(); class AcceptDialog; +class AcceptDialogAutoReparent; class AudioStreamPreviewGenerator; class BackgroundProgress; class CenterContainer; @@ -370,10 +371,10 @@ private: PluginConfigDialog *plugin_config_dialog = nullptr; RichTextLabel *load_errors = nullptr; - AcceptDialog *load_error_dialog = nullptr; + AcceptDialogAutoReparent *load_error_dialog = nullptr; RichTextLabel *execute_outputs = nullptr; - AcceptDialog *execute_output_dialog = nullptr; + AcceptDialogAutoReparent *execute_output_dialog = nullptr; Ref<Theme> theme; @@ -388,10 +389,10 @@ private: ConfirmationDialog *import_confirmation = nullptr; ConfirmationDialog *pick_main_scene = nullptr; Button *select_current_scene_button = nullptr; - AcceptDialog *accept = nullptr; - AcceptDialog *save_accept = nullptr; + AcceptDialogAutoReparent *accept = nullptr; + AcceptDialogAutoReparent *save_accept = nullptr; EditorAbout *about = nullptr; - AcceptDialog *warning = nullptr; + AcceptDialogAutoReparent *warning = nullptr; int overridden_default_layout = -1; Ref<ConfigFile> default_layout; diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 7b01ae69bf..fb2110dea3 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -137,6 +137,7 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh RS::get_singleton()->instance_set_transform(light_instance2, xform * Transform3D().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0))); ep.step(TTR("Thumbnail..."), i); + DisplayServer::get_singleton()->process_events(); Main::iteration(); Main::iteration(); Ref<Image> img = RS::get_singleton()->texture_2d_get(viewport_texture); diff --git a/editor/editor_toaster.cpp b/editor/editor_toaster.cpp index 73b645f351..10c3e963af 100644 --- a/editor/editor_toaster.cpp +++ b/editor/editor_toaster.cpp @@ -90,10 +90,10 @@ void EditorToaster::_notification(int p_what) { } // Hide element if it is not visible anymore. - if (modulate_fade.a <= 0 && element.key->is_visible()) { + if (modulate_fade.a <= 0.0 && element.key->is_visible()) { element.key->hide(); needs_update = true; - } else if (modulate_fade.a >= 0 && !element.key->is_visible()) { + } else if (modulate_fade.a > 0.0 && !element.key->is_visible()) { element.key->show(); needs_update = true; } diff --git a/editor/export/project_export.cpp b/editor/export/project_export.cpp index e9ea0012be..a7ac95bd5b 100644 --- a/editor/export/project_export.cpp +++ b/editor/export/project_export.cpp @@ -943,8 +943,8 @@ void ProjectExportDialog::_export_pck_zip_selected(const String &p_path) { } void ProjectExportDialog::_open_export_template_manager() { - EditorNode::get_singleton()->open_export_template_manager(); hide(); + EditorNode::get_singleton()->open_export_template_manager(); } void ProjectExportDialog::_validate_export_path(const String &p_path) { diff --git a/editor/plugins/gdextension_export_plugin.h b/editor/plugins/gdextension_export_plugin.h index f3d2867030..d1c47ab14e 100644 --- a/editor/plugins/gdextension_export_plugin.h +++ b/editor/plugins/gdextension_export_plugin.h @@ -54,67 +54,94 @@ void GDExtensionExportPlugin::_export_file(const String &p_path, const String &p String entry_symbol = config->get_value("configuration", "entry_symbol"); - PackedStringArray tags; - String library_path = GDExtension::find_extension_library( - p_path, config, [p_features](String p_feature) { return p_features.has(p_feature); }, &tags); - if (!library_path.is_empty()) { - add_shared_object(library_path, tags); - - if (p_features.has("iOS") && (library_path.ends_with(".a") || library_path.ends_with(".xcframework"))) { - String additional_code = "extern void register_dynamic_symbol(char *name, void *address);\n" - "extern void add_ios_init_callback(void (*cb)());\n" - "\n" - "extern \"C\" void $ENTRY();\n" - "void $ENTRY_init() {\n" - " if (&$ENTRY) register_dynamic_symbol((char *)\"$ENTRY\", (void *)$ENTRY);\n" - "}\n" - "struct $ENTRY_struct {\n" - " $ENTRY_struct() {\n" - " add_ios_init_callback($ENTRY_init);\n" - " }\n" - "};\n" - "$ENTRY_struct $ENTRY_struct_instance;\n\n"; - additional_code = additional_code.replace("$ENTRY", entry_symbol); - add_ios_cpp_code(additional_code); - - String linker_flags = "-Wl,-U,_" + entry_symbol; - add_ios_linker_flags(linker_flags); - } - } else { - Vector<String> features_vector; - for (const String &E : p_features) { - features_vector.append(E); + HashSet<String> all_archs; + all_archs.insert("x86_32"); + all_archs.insert("x86_64"); + all_archs.insert("arm32"); + all_archs.insert("arm64"); + all_archs.insert("rv64"); + all_archs.insert("ppc32"); + all_archs.insert("ppc64"); + all_archs.insert("wasm32"); + all_archs.insert("universal"); + + HashSet<String> archs; + HashSet<String> features_wo_arch; + for (const String &tag : p_features) { + if (all_archs.has(tag)) { + archs.insert(tag); + } else { + features_wo_arch.insert(tag); } - ERR_FAIL_MSG(vformat("No suitable library found for GDExtension: %s. Possible feature flags for your platform: %s", p_path, String(", ").join(features_vector))); } - List<String> dependencies; - if (config->has_section("dependencies")) { - config->get_section_keys("dependencies", &dependencies); + if (archs.is_empty()) { + archs.insert("unknown_arch"); // Not archs specified, still try to match. } - for (const String &E : dependencies) { - Vector<String> dependency_tags = E.split("."); - bool all_tags_met = true; - for (int i = 0; i < dependency_tags.size(); i++) { - String tag = dependency_tags[i].strip_edges(); - if (!p_features.has(tag)) { - all_tags_met = false; - break; + for (const String &arch_tag : archs) { + PackedStringArray tags; + String library_path = GDExtension::find_extension_library( + p_path, config, [features_wo_arch, arch_tag](String p_feature) { return features_wo_arch.has(p_feature) || (p_feature == arch_tag); }, &tags); + if (!library_path.is_empty()) { + add_shared_object(library_path, tags); + + if (p_features.has("iOS") && (library_path.ends_with(".a") || library_path.ends_with(".xcframework"))) { + String additional_code = "extern void register_dynamic_symbol(char *name, void *address);\n" + "extern void add_ios_init_callback(void (*cb)());\n" + "\n" + "extern \"C\" void $ENTRY();\n" + "void $ENTRY_init() {\n" + " if (&$ENTRY) register_dynamic_symbol((char *)\"$ENTRY\", (void *)$ENTRY);\n" + "}\n" + "struct $ENTRY_struct {\n" + " $ENTRY_struct() {\n" + " add_ios_init_callback($ENTRY_init);\n" + " }\n" + "};\n" + "$ENTRY_struct $ENTRY_struct_instance;\n\n"; + additional_code = additional_code.replace("$ENTRY", entry_symbol); + add_ios_cpp_code(additional_code); + + String linker_flags = "-Wl,-U,_" + entry_symbol; + add_ios_linker_flags(linker_flags); + } + } else { + Vector<String> features_vector; + for (const String &E : p_features) { + features_vector.append(E); } + ERR_FAIL_MSG(vformat("No suitable library found for GDExtension: %s. Possible feature flags for your platform: %s", p_path, String(", ").join(features_vector))); } - if (all_tags_met) { - Dictionary dependency = config->get_value("dependencies", E); - for (const Variant *key = dependency.next(nullptr); key; key = dependency.next(key)) { - String dependency_path = *key; - String target_path = dependency[*key]; - if (dependency_path.is_relative_path()) { - dependency_path = p_path.get_base_dir().path_join(dependency_path); + List<String> dependencies; + if (config->has_section("dependencies")) { + config->get_section_keys("dependencies", &dependencies); + } + + for (const String &E : dependencies) { + Vector<String> dependency_tags = E.split("."); + bool all_tags_met = true; + for (int i = 0; i < dependency_tags.size(); i++) { + String tag = dependency_tags[i].strip_edges(); + if (!p_features.has(tag)) { + all_tags_met = false; + break; + } + } + + if (all_tags_met) { + Dictionary dependency = config->get_value("dependencies", E); + for (const Variant *key = dependency.next(nullptr); key; key = dependency.next(key)) { + String dependency_path = *key; + String target_path = dependency[*key]; + if (dependency_path.is_relative_path()) { + dependency_path = p_path.get_base_dir().path_join(dependency_path); + } + add_shared_object(dependency_path, dependency_tags, target_path); } - add_shared_object(dependency_path, dependency_tags, target_path); + break; } - break; } } } diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp index 78522dfa73..1682d07e13 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.cpp +++ b/editor/plugins/tiles/tiles_editor_plugin.cpp @@ -145,7 +145,10 @@ void TilesEditorPlugin::_tile_map_changed() { void TilesEditorPlugin::_update_editors() { // If tile_map is not edited, we change the edited only if we are not editing a tile_set. - tileset_editor->edit(tile_set); + if (tile_set.is_valid()) { + tileset_editor->edit(tile_set); + } + TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); if (tile_map) { tilemap_editor->edit(tile_map); @@ -158,6 +161,7 @@ void TilesEditorPlugin::_update_editors() { // Make sure the tile set editor is visible if we have one assigned. tileset_editor_button->set_visible(is_visible && tile_set.is_valid()); + tilemap_editor_button->set_visible(is_visible && tile_map); // Update visibility of bottom panel buttons. if (tileset_editor_button->is_pressed() && !tile_set.is_valid()) { diff --git a/editor/progress_dialog.cpp b/editor/progress_dialog.cpp index 9695a7042d..4d76fdc997 100644 --- a/editor/progress_dialog.cpp +++ b/editor/progress_dialog.cpp @@ -221,9 +221,7 @@ bool ProgressDialog::task_step(const String &p_task, const String &p_state, int t.state->set_text(p_state); last_progress_tick = OS::get_singleton()->get_ticks_usec(); - if (cancel_hb->is_visible()) { - DisplayServer::get_singleton()->process_events(); - } + DisplayServer::get_singleton()->process_events(); #ifndef ANDROID_ENABLED Main::iteration(); // this will not work on a lot of platforms, so it's only meant for the editor diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 2f3f4dd2e1..341a2f519d 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -2974,7 +2974,7 @@ ProjectManager::ProjectManager() { ask_update_settings = memnew(ConfirmationDialog); ask_update_settings->set_autowrap(true); ask_update_settings->get_ok_button()->connect("pressed", callable_mp(this, &ProjectManager::_confirm_update_settings)); - full_convert_button = ask_update_settings->add_button("Convert Full Project", !GLOBAL_GET("gui/common/swap_cancel_ok")); + full_convert_button = ask_update_settings->add_button(TTR("Convert Full Project"), !GLOBAL_GET("gui/common/swap_cancel_ok")); full_convert_button->connect("pressed", callable_mp(this, &ProjectManager::_full_convert_button_pressed)); add_child(ask_update_settings); |