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, 53 insertions, 41 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index f3086d416b..a8dc14427d 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -57,8 +57,10 @@
#include "scene/gui/split_container.h"
#include "scene/gui/tab_container.h"
#include "scene/gui/tabs.h"
-#include "scene/gui/texture_progress.h"
+#include "scene/gui/texture_progress_bar.h"
+#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
+#include "servers/display_server.h"
#include "servers/navigation_server_2d.h"
#include "servers/navigation_server_3d.h"
#include "servers/physics_server_2d.h"
@@ -172,12 +174,10 @@
#include "editor/progress_dialog.h"
#include "editor/project_export.h"
#include "editor/project_settings_editor.h"
-#include "editor/pvrtc_compress.h"
#include "editor/quick_open.h"
#include "editor/register_exporters.h"
#include "editor/settings_config_dialog.h"
-#include "scene/main/window.h"
-#include "servers/display_server.h"
+
#include <stdio.h>
#include <stdlib.h>
@@ -525,6 +525,9 @@ void EditorNode::_notification(int p_what) {
scene_root->set_sdf_oversize(sdf_oversize);
Viewport::SDFScale sdf_scale = Viewport::SDFScale(int(GLOBAL_GET("rendering/quality/2d_sdf/scale")));
scene_root->set_sdf_scale(sdf_scale);
+
+ float lod_threshold = GLOBAL_GET("rendering/quality/mesh_lod/threshold_pixels");
+ scene_root->set_lod_threshold(lod_threshold);
}
ResourceImporterTexture::get_singleton()->update_imports();
@@ -1416,6 +1419,17 @@ int EditorNode::_save_external_resources() {
return saved;
}
+static void _reset_animation_players(Node *p_node, List<Ref<AnimatedValuesBackup>> *r_anim_backups) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
+ AnimationPlayer *player = Object::cast_to<AnimationPlayer>(p_node->get_child(i));
+ if (player && player->is_reset_on_save_enabled() && player->can_apply_reset()) {
+ Ref<AnimatedValuesBackup> old_values = player->apply_reset();
+ r_anim_backups->push_back(old_values);
+ }
+ _reset_animation_players(p_node->get_child(i), r_anim_backups);
+ }
+}
+
void EditorNode::_save_scene(String p_file, int idx) {
Node *scene = editor_data.get_edited_scene_root(idx);
@@ -1430,6 +1444,8 @@ void EditorNode::_save_scene(String p_file, int idx) {
}
editor_data.apply_changes_in_editors();
+ List<Ref<AnimatedValuesBackup>> anim_backups;
+ _reset_animation_players(scene, &anim_backups);
_save_default_environment();
_set_scene_metadata(p_file, idx);
@@ -1477,6 +1493,11 @@ void EditorNode::_save_scene(String p_file, int idx) {
_save_external_resources();
editor_data.save_editor_external_data();
+
+ for (List<Ref<AnimatedValuesBackup>>::Element *E = anim_backups.front(); E; E = E->next()) {
+ E->get()->restore();
+ }
+
if (err == OK) {
scene->set_filename(ProjectSettings::get_singleton()->localize_path(p_file));
if (idx < 0 || idx == editor_data.get_edited_scene()) {
@@ -2271,7 +2292,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
if (unsaved_cache || p_option == FILE_CLOSE_ALL_AND_QUIT || p_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER) {
String scene_filename = editor_data.get_edited_scene_root(tab_closing)->get_filename();
- save_confirmation->get_ok()->set_text(TTR("Save & Close"));
+ 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->popup_centered();
break;
@@ -2362,8 +2383,8 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case FILE_SAVE_BEFORE_RUN: {
if (!p_confirmed) {
- confirmation->get_cancel()->set_text(TTR("No"));
- confirmation->get_ok()->set_text(TTR("Yes"));
+ confirmation->get_cancel_button()->set_text(TTR("No"));
+ confirmation->get_ok_button()->set_text(TTR("Yes"));
confirmation->set_text(TTR("This scene has never been saved. Save before running?"));
confirmation->popup_centered();
break;
@@ -2427,7 +2448,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
case FILE_EXTERNAL_OPEN_SCENE: {
if (unsaved_cache && !p_confirmed) {
- confirmation->get_ok()->set_text(TTR("Open"));
+ confirmation->get_ok_button()->set_text(TTR("Open"));
confirmation->set_text(TTR("Current scene not saved. Open anyway?"));
confirmation->popup_centered();
break;
@@ -2483,7 +2504,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
}
if (unsaved_cache && !p_confirmed) {
- confirmation->get_ok()->set_text(TTR("Reload Saved Scene"));
+ confirmation->get_ok_button()->set_text(TTR("Reload Saved Scene"));
confirmation->set_text(
TTR("The current scene has unsaved changes.\nReload the saved scene anyway? This action cannot be undone."));
confirmation->popup_centered();
@@ -2587,7 +2608,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
if (_next_unsaved_scene(!save_each) == -1) {
bool confirm = EDITOR_GET("interface/editor/quit_confirmation");
if (confirm) {
- confirmation->get_ok()->set_text(p_option == FILE_QUIT ? TTR("Quit") : TTR("Yes"));
+ confirmation->get_ok_button()->set_text(p_option == FILE_QUIT ? TTR("Quit") : TTR("Yes"));
confirmation->set_text(p_option == FILE_QUIT ? TTR("Exit the editor?") : TTR("Open Project Manager?"));
confirmation->popup_centered();
} else {
@@ -2605,7 +2626,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
i = _next_unsaved_scene(true, ++i);
}
- save_confirmation->get_ok()->set_text(TTR("Save & Quit"));
+ save_confirmation->get_ok_button()->set_text(TTR("Save & Quit"));
save_confirmation->set_text((p_option == FILE_QUIT ? TTR("Save changes to the following scene(s) before quitting?") : TTR("Save changes the following scene(s) before opening Project Manager?")) + unsaved_scenes);
save_confirmation->popup_centered();
}
@@ -2743,16 +2764,13 @@ void EditorNode::_tool_menu_option(int p_idx) {
} break;
case TOOLS_CUSTOM: {
if (tool_menu->get_item_submenu(p_idx) == "") {
- Array params = tool_menu->get_item_metadata(p_idx);
-
- Object *handler = ObjectDB::get_instance(params[0]);
- String callback = params[1];
- Variant *ud = &params[2];
+ Callable callback = tool_menu->get_item_metadata(p_idx);
Callable::CallError ce;
+ Variant result;
+ callback.call(nullptr, 0, result, ce);
- handler->call(callback, (const Variant **)&ud, 1, ce);
if (ce.error != Callable::CallError::CALL_OK) {
- String err = Variant::get_call_error_text(handler, callback, (const Variant **)&ud, 1, ce);
+ String err = Variant::get_callable_error_text(callback, nullptr, 0, ce);
ERR_PRINT("Error calling function from tool menu: " + err);
}
} // else it's a submenu so don't do anything.
@@ -3654,6 +3672,9 @@ void EditorNode::register_editor_types() {
ClassDB::register_class<ScriptCreateDialog>();
ClassDB::register_class<EditorFeatureProfile>();
ClassDB::register_class<EditorSpinSlider>();
+ ClassDB::register_class<EditorSceneImporterMesh>();
+ ClassDB::register_class<EditorSceneImporterMeshNode>();
+
ClassDB::register_virtual_class<FileSystemDock>();
// FIXME: Is this stuff obsolete, or should it be ported to new APIs?
@@ -3945,7 +3966,7 @@ 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_option = -1;
- accept->get_ok()->set_text(p_title);
+ accept->get_ok_button()->set_text(p_title);
accept->set_text(p_text);
accept->popup_centered();
}
@@ -4644,14 +4665,14 @@ void EditorNode::_layout_menu_option(int p_id) {
case SETTINGS_LAYOUT_SAVE: {
current_option = p_id;
layout_dialog->set_title(TTR("Save Layout"));
- layout_dialog->get_ok()->set_text(TTR("Save"));
+ layout_dialog->get_ok_button()->set_text(TTR("Save"));
layout_dialog->popup_centered();
layout_dialog->set_name_line_enabled(true);
} break;
case SETTINGS_LAYOUT_DELETE: {
current_option = p_id;
layout_dialog->set_title(TTR("Delete Layout"));
- layout_dialog->get_ok()->set_text(TTR("Delete"));
+ layout_dialog->get_ok_button()->set_text(TTR("Delete"));
layout_dialog->popup_centered();
layout_dialog->set_name_line_enabled(false);
} break;
@@ -4693,7 +4714,7 @@ void EditorNode::_scene_tab_closed(int p_tab, int option) {
saved_version != editor_data.get_undo_redo().get_version() :
editor_data.get_scene_version(p_tab) != 0;
if (unsaved) {
- save_confirmation->get_ok()->set_text(TTR("Save & Close"));
+ save_confirmation->get_ok_button()->set_text(TTR("Save & Close"));
save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene->get_filename() != "" ? scene->get_filename() : "unsaved scene"));
save_confirmation->popup_centered();
} else {
@@ -5083,17 +5104,10 @@ Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_paths, Control *
return drag_data;
}
-void EditorNode::add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud) {
- ERR_FAIL_NULL(p_handler);
+void EditorNode::add_tool_menu_item(const String &p_name, const Callable &p_callback) {
int idx = tool_menu->get_item_count();
tool_menu->add_item(p_name, TOOLS_CUSTOM);
-
- Array parameters;
- parameters.push_back(p_handler->get_instance_id());
- parameters.push_back(p_callback);
- parameters.push_back(p_ud);
-
- tool_menu->set_item_metadata(idx, parameters);
+ tool_menu->set_item_metadata(idx, p_callback);
}
void EditorNode::add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu) {
@@ -5472,7 +5486,7 @@ 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()->set_disabled(true);
+ execute_output_dialog->get_ok_button()->set_disabled(true);
execute_outputs->clear();
execute_outputs->set_scroll_follow(true);
execute_output_dialog->popup_centered_ratio();
@@ -5513,7 +5527,7 @@ int EditorNode::execute_and_show_output(const String &p_title, const String &p_p
execute_output_dialog->hide();
}
- execute_output_dialog->get_ok()->set_disabled(false);
+ execute_output_dialog->get_ok_button()->set_disabled(false);
return eta.exitcode;
}
@@ -5726,8 +5740,6 @@ EditorNode::EditorNode() {
EditorInspector::add_inspector_plugin(smp);
}
- _pvrtc_register_compressors();
-
editor_selection = memnew(EditorSelection);
EditorFileSystem *efs = memnew(EditorFileSystem);
@@ -6387,7 +6399,7 @@ EditorNode::EditorNode() {
#endif
video_restart_dialog = memnew(ConfirmationDialog);
video_restart_dialog->set_text(TTR("Changing the video driver requires restarting the editor."));
- video_restart_dialog->get_ok()->set_text(TTR("Save & Restart"));
+ video_restart_dialog->get_ok_button()->set_text(TTR("Save & Restart"));
video_restart_dialog->connect("confirmed", callable_mp(this, &EditorNode::_menu_option), varray(SET_VIDEO_DRIVER_SAVE_AND_RESTART));
gui_base->add_child(video_restart_dialog);
@@ -6534,19 +6546,19 @@ EditorNode::EditorNode() {
custom_build_manage_templates = memnew(ConfirmationDialog);
custom_build_manage_templates->set_text(TTR("Android build template is missing, please install relevant templates."));
- custom_build_manage_templates->get_ok()->set_text(TTR("Manage Templates"));
+ custom_build_manage_templates->get_ok_button()->set_text(TTR("Manage Templates"));
custom_build_manage_templates->connect("confirmed", callable_mp(this, &EditorNode::_menu_option), varray(SETTINGS_MANAGE_EXPORT_TEMPLATES));
gui_base->add_child(custom_build_manage_templates);
install_android_build_template = memnew(ConfirmationDialog);
install_android_build_template->set_text(TTR("This will set up your project for custom Android builds by installing the source template to \"res://android/build\".\nYou can then apply modifications and build your own custom APK on export (adding modules, changing the AndroidManifest.xml, etc.).\nNote that in order to make custom builds instead of using pre-built APKs, the \"Use Custom Build\" option should be enabled in the Android export preset."));
- install_android_build_template->get_ok()->set_text(TTR("Install"));
+ install_android_build_template->get_ok_button()->set_text(TTR("Install"));
install_android_build_template->connect("confirmed", callable_mp(this, &EditorNode::_menu_confirm_current));
gui_base->add_child(install_android_build_template);
remove_android_build_template = memnew(ConfirmationDialog);
remove_android_build_template->set_text(TTR("The Android build template is already installed in this project and it won't be overwritten.\nRemove the \"res://android/build\" directory manually before attempting this operation again."));
- remove_android_build_template->get_ok()->set_text(TTR("Show in File Manager"));
+ remove_android_build_template->get_ok_button()->set_text(TTR("Show in File Manager"));
remove_android_build_template->connect("confirmed", callable_mp(this, &EditorNode::_menu_option), varray(FILE_EXPLORE_ANDROID_BUILD_TEMPLATES));
gui_base->add_child(remove_android_build_template);
@@ -6749,7 +6761,7 @@ EditorNode::EditorNode() {
set_process(true);
open_imported = memnew(ConfirmationDialog);
- open_imported->get_ok()->set_text(TTR("Open Anyway"));
+ open_imported->get_ok_button()->set_text(TTR("Open Anyway"));
new_inherited_button = open_imported->add_button(TTR("New Inherited"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "inherit");
open_imported->connect("confirmed", callable_mp(this, &EditorNode::_open_imported));
open_imported->connect("custom_action", callable_mp(this, &EditorNode::_inherit_imported));
@@ -6799,7 +6811,7 @@ EditorNode::EditorNode() {
pick_main_scene = memnew(ConfirmationDialog);
gui_base->add_child(pick_main_scene);
- pick_main_scene->get_ok()->set_text(TTR("Select"));
+ pick_main_scene->get_ok_button()->set_text(TTR("Select"));
pick_main_scene->connect("confirmed", callable_mp(this, &EditorNode::_menu_option), varray(SETTINGS_PICK_MAIN_SCENE));
for (int i = 0; i < _init_callbacks.size(); i++) {