From b17f0f593e136ca67e2de1e845d194069fa23318 Mon Sep 17 00:00:00 2001 From: Hakim Date: Fri, 7 Apr 2023 17:44:36 +0200 Subject: Use physical shortcuts for freelook navigation in the editor (cherry picked from commit 52de40310a9d98496aa3de5aaf457a7e60959b77) --- editor/editor_settings.cpp | 16 ++++++++-------- editor/editor_settings.h | 8 ++++---- editor/plugins/node_3d_editor_plugin.cpp | 16 ++++++++-------- editor/plugins/node_3d_editor_plugin.h | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) (limited to 'editor') diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 037bfbfd99..25c84e7447 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -1468,7 +1468,7 @@ Ref ED_GET_SHORTCUT(const String &p_path) { return sc; } -void ED_SHORTCUT_OVERRIDE(const String &p_path, const String &p_feature, Key p_keycode) { +void ED_SHORTCUT_OVERRIDE(const String &p_path, const String &p_feature, Key p_keycode, bool p_physical) { ERR_FAIL_NULL_MSG(EditorSettings::get_singleton(), "EditorSettings not instantiated yet."); Ref sc = EditorSettings::get_singleton()->get_shortcut(p_path); @@ -1477,10 +1477,10 @@ void ED_SHORTCUT_OVERRIDE(const String &p_path, const String &p_feature, Key p_k PackedInt32Array arr; arr.push_back((int32_t)p_keycode); - ED_SHORTCUT_OVERRIDE_ARRAY(p_path, p_feature, arr); + ED_SHORTCUT_OVERRIDE_ARRAY(p_path, p_feature, arr, p_physical); } -void ED_SHORTCUT_OVERRIDE_ARRAY(const String &p_path, const String &p_feature, const PackedInt32Array &p_keycodes) { +void ED_SHORTCUT_OVERRIDE_ARRAY(const String &p_path, const String &p_feature, const PackedInt32Array &p_keycodes, bool p_physical) { ERR_FAIL_NULL_MSG(EditorSettings::get_singleton(), "EditorSettings not instantiated yet."); Ref sc = EditorSettings::get_singleton()->get_shortcut(p_path); @@ -1505,7 +1505,7 @@ void ED_SHORTCUT_OVERRIDE_ARRAY(const String &p_path, const String &p_feature, c Ref ie; if (keycode != Key::NONE) { - ie = InputEventKey::create_reference(keycode); + ie = InputEventKey::create_reference(keycode, p_physical); events.push_back(ie); } } @@ -1518,13 +1518,13 @@ void ED_SHORTCUT_OVERRIDE_ARRAY(const String &p_path, const String &p_feature, c sc->set_meta("original", events.duplicate(true)); } -Ref ED_SHORTCUT(const String &p_path, const String &p_name, Key p_keycode) { +Ref ED_SHORTCUT(const String &p_path, const String &p_name, Key p_keycode, bool p_physical) { PackedInt32Array arr; arr.push_back((int32_t)p_keycode); - return ED_SHORTCUT_ARRAY(p_path, p_name, arr); + return ED_SHORTCUT_ARRAY(p_path, p_name, arr, p_physical); } -Ref ED_SHORTCUT_ARRAY(const String &p_path, const String &p_name, const PackedInt32Array &p_keycodes) { +Ref ED_SHORTCUT_ARRAY(const String &p_path, const String &p_name, const PackedInt32Array &p_keycodes, bool p_physical) { Array events; for (int i = 0; i < p_keycodes.size(); i++) { @@ -1539,7 +1539,7 @@ Ref ED_SHORTCUT_ARRAY(const String &p_path, const String &p_name, cons Ref ie; if (keycode != Key::NONE) { - ie = InputEventKey::create_reference(keycode); + ie = InputEventKey::create_reference(keycode, p_physical); events.push_back(ie); } } diff --git a/editor/editor_settings.h b/editor/editor_settings.h index e1d3e757e0..a21fb9fdfb 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -195,10 +195,10 @@ Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default, bool p_re Variant _EDITOR_GET(const String &p_setting); #define ED_IS_SHORTCUT(p_name, p_ev) (EditorSettings::get_singleton()->is_shortcut(p_name, p_ev)) -Ref ED_SHORTCUT(const String &p_path, const String &p_name, Key p_keycode = Key::NONE); -Ref ED_SHORTCUT_ARRAY(const String &p_path, const String &p_name, const PackedInt32Array &p_keycodes); -void ED_SHORTCUT_OVERRIDE(const String &p_path, const String &p_feature, Key p_keycode = Key::NONE); -void ED_SHORTCUT_OVERRIDE_ARRAY(const String &p_path, const String &p_feature, const PackedInt32Array &p_keycodes); +Ref ED_SHORTCUT(const String &p_path, const String &p_name, Key p_keycode = Key::NONE, bool p_physical = false); +Ref ED_SHORTCUT_ARRAY(const String &p_path, const String &p_name, const PackedInt32Array &p_keycodes, bool p_physical = false); +void ED_SHORTCUT_OVERRIDE(const String &p_path, const String &p_feature, Key p_keycode = Key::NONE, bool p_physical = false); +void ED_SHORTCUT_OVERRIDE_ARRAY(const String &p_path, const String &p_feature, const PackedInt32Array &p_keycodes, bool p_physical = false); Ref ED_GET_SHORTCUT(const String &p_path); #endif // EDITOR_SETTINGS_H diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 7c5b8600d4..cdd61d7067 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -4872,8 +4872,8 @@ void Node3DEditorViewport::finish_transform() { } // Register a shortcut and also add it as an input action with the same events. -void Node3DEditorViewport::register_shortcut_action(const String &p_path, const String &p_name, Key p_keycode) { - Ref sc = ED_SHORTCUT(p_path, p_name, p_keycode); +void Node3DEditorViewport::register_shortcut_action(const String &p_path, const String &p_name, Key p_keycode, bool p_physical) { + Ref sc = ED_SHORTCUT(p_path, p_name, p_keycode, p_physical); shortcut_changed_callback(sc, p_path); // Connect to the change event on the shortcut so the input binding can be updated. sc->connect("changed", callable_mp(this, &Node3DEditorViewport::shortcut_changed_callback).bind(sc, p_path)); @@ -5054,12 +5054,12 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p view_menu->get_popup()->set_item_tooltip(shadeless_idx, unsupported_tooltip); } - register_shortcut_action("spatial_editor/freelook_left", TTR("Freelook Left"), Key::A); - register_shortcut_action("spatial_editor/freelook_right", TTR("Freelook Right"), Key::D); - register_shortcut_action("spatial_editor/freelook_forward", TTR("Freelook Forward"), Key::W); - register_shortcut_action("spatial_editor/freelook_backwards", TTR("Freelook Backwards"), Key::S); - register_shortcut_action("spatial_editor/freelook_up", TTR("Freelook Up"), Key::E); - register_shortcut_action("spatial_editor/freelook_down", TTR("Freelook Down"), Key::Q); + register_shortcut_action("spatial_editor/freelook_left", TTR("Freelook Left"), Key::A, true); + register_shortcut_action("spatial_editor/freelook_right", TTR("Freelook Right"), Key::D, true); + register_shortcut_action("spatial_editor/freelook_forward", TTR("Freelook Forward"), Key::W, true); + register_shortcut_action("spatial_editor/freelook_backwards", TTR("Freelook Backwards"), Key::S, true); + register_shortcut_action("spatial_editor/freelook_up", TTR("Freelook Up"), Key::E, true); + register_shortcut_action("spatial_editor/freelook_down", TTR("Freelook Down"), Key::Q, true); register_shortcut_action("spatial_editor/freelook_speed_modifier", TTR("Freelook Speed Modifier"), Key::SHIFT); register_shortcut_action("spatial_editor/freelook_slow_modifier", TTR("Freelook Slow Modifier"), Key::ALT); diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index e5267e5fad..c4193f0420 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -441,7 +441,7 @@ private: void update_transform(Point2 p_mousepos, bool p_shift); void finish_transform(); - void register_shortcut_action(const String &p_path, const String &p_name, Key p_keycode); + void register_shortcut_action(const String &p_path, const String &p_name, Key p_keycode, bool p_physical = false); void shortcut_changed_callback(const Ref p_shortcut, const String &p_shortcut_path); protected: -- cgit v1.2.3 From f8517e1c4b05a0a6e5fbf85884d814145a136244 Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 7 Apr 2023 17:44:36 +0200 Subject: Remember directory when installing templates file (cherry picked from commit 551b6965ece72605cbe39f26bd8ea4d0d33bba2f) --- editor/export/export_template_manager.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'editor') diff --git a/editor/export/export_template_manager.cpp b/editor/export/export_template_manager.cpp index 658f797211..725dc1d6bb 100644 --- a/editor/export/export_template_manager.cpp +++ b/editor/export/export_template_manager.cpp @@ -529,6 +529,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ unzClose(pkg); _update_template_status(); + EditorSettings::get_singleton()->set_meta("export_template_download_directory", p_file.get_base_dir()); return true; } @@ -992,6 +993,7 @@ ExportTemplateManager::ExportTemplateManager() { install_file_dialog->set_title(TTR("Select Template File")); install_file_dialog->set_access(FileDialog::ACCESS_FILESYSTEM); install_file_dialog->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE); + install_file_dialog->set_current_dir(EditorSettings::get_singleton()->get_meta("export_template_download_directory", "")); install_file_dialog->add_filter("*.tpz", TTR("Godot Export Templates")); install_file_dialog->connect("file_selected", callable_mp(this, &ExportTemplateManager::_install_file_selected).bind(false)); add_child(install_file_dialog); -- cgit v1.2.3 From 62dbd512cc74532902ade9be4d28378b4c0ecf3e Mon Sep 17 00:00:00 2001 From: ajreckof <66184050+ajreckof@users.noreply.github.com> Date: Fri, 7 Apr 2023 17:44:37 +0200 Subject: Fix descriptions not showing for theme properties (cherry picked from commit 14140eb2d915d14f70fb34405ddbd93692a7ad33) --- editor/editor_inspector.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'editor') diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 44426dc143..8498ddecd6 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -3133,6 +3133,11 @@ void EditorInspector::update_tree() { StringName propname = property_prefix + p.name; bool found = false; + // Small hack for theme_overrides. They are listed under Control, but come from another class. + if (classname == "Control" && p.name.begins_with("theme_override_")) { + classname = get_edited_object()->get_class(); + } + // Search for the property description in the cache. HashMap>::Iterator E = doc_info_cache.find(classname); if (E) { -- cgit v1.2.3 From bcf991d3ec9f10fe5525979c331ab6c12120a6d7 Mon Sep 17 00:00:00 2001 From: "Ron B. Yeh" Date: Fri, 7 Apr 2023 17:44:37 +0200 Subject: Fix off-by-one issue where Go to Line dialog shows the incorrect line number (one less than the actual current line). (cherry picked from commit 1e9fd10f68e462a7fc6aac84e7659d0fcb0dc0e3) --- editor/code_editor.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'editor') diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 9a8a1097cd..121af0170c 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -42,7 +42,8 @@ void GotoLineDialog::popup_find_line(CodeEdit *p_edit) { text_editor = p_edit; - line->set_text(itos(text_editor->get_caret_line())); + // Add 1 because text_editor->get_caret_line() starts from 0, but the editor user interface starts from 1. + line->set_text(itos(text_editor->get_caret_line() + 1)); line->select_all(); popup_centered(Size2(180, 80) * EDSCALE); line->grab_focus(); @@ -53,12 +54,14 @@ int GotoLineDialog::get_line() const { } void GotoLineDialog::ok_pressed() { - if (get_line() < 1 || get_line() > text_editor->get_line_count()) { + // Subtract 1 because the editor user interface starts from 1, but text_editor->set_caret_line(n) starts from 0. + const int line_number = get_line() - 1; + if (line_number < 0 || line_number >= text_editor->get_line_count()) { return; } text_editor->remove_secondary_carets(); - text_editor->unfold_line(get_line() - 1); - text_editor->set_caret_line(get_line() - 1); + text_editor->unfold_line(line_number); + text_editor->set_caret_line(line_number); hide(); } @@ -1092,13 +1095,13 @@ void CodeTextEditor::remove_find_replace_bar() { } void CodeTextEditor::trim_trailing_whitespace() { - bool trimed_whitespace = false; + bool trimmed_whitespace = false; for (int i = 0; i < text_editor->get_line_count(); i++) { String line = text_editor->get_line(i); if (line.ends_with(" ") || line.ends_with("\t")) { - if (!trimed_whitespace) { + if (!trimmed_whitespace) { text_editor->begin_complex_operation(); - trimed_whitespace = true; + trimmed_whitespace = true; } int end = 0; @@ -1112,7 +1115,7 @@ void CodeTextEditor::trim_trailing_whitespace() { } } - if (trimed_whitespace) { + if (trimmed_whitespace) { text_editor->merge_overlapping_carets(); text_editor->end_complex_operation(); text_editor->queue_redraw(); -- cgit v1.2.3 From 1aa5fce3214323e1bfd25762acd3904304d360d1 Mon Sep 17 00:00:00 2001 From: Jean-Michel Bernard Date: Fri, 7 Apr 2023 17:44:37 +0200 Subject: Fix commenting collapsed function issue (cherry picked from commit 68ad3338ef321772903896a3a99878f0b3bd6bf3) --- editor/code_editor.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'editor') diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 121af0170c..7d29dfad92 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1587,11 +1587,17 @@ void CodeTextEditor::toggle_inline_comment(const String &delimiter) { Vector caret_edit_order = text_editor->get_caret_index_edit_order(); caret_edit_order.reverse(); int last_line = -1; + int folded_to = 0; for (const int &c1 : caret_edit_order) { int from = _get_affected_lines_from(c1); - from += from == last_line ? 1 : 0; + from += from == last_line ? 1 + folded_to : 0; int to = _get_affected_lines_to(c1); last_line = to; + // If last line is folded, extends to the end of the folded section + if (text_editor->is_line_folded(to)) { + folded_to = text_editor->get_next_visible_line_offset_from(to + 1, 1) - 1; + to += folded_to; + } // Check first if there's any uncommented lines in selection. bool is_commented = true; for (int line = from; line <= to; line++) { -- cgit v1.2.3 From 861399fbe58c05633cb51eaf381d976ed59e122a Mon Sep 17 00:00:00 2001 From: James Buck Date: Fri, 7 Apr 2023 17:44:37 +0200 Subject: Re-enable script editor File menu shortcuts when the menu is hidden (cherry picked from commit de49bec30e8e2fc5881871a50f9222d90aacc24f) --- editor/plugins/script_editor_plugin.cpp | 25 +++++++++++++++++++++++++ editor/plugins/script_editor_plugin.h | 1 + 2 files changed, 26 insertions(+) (limited to 'editor') diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 49c815526b..a749e6de41 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1561,6 +1561,30 @@ void ScriptEditor::_prepare_file_menu() { menu->set_item_disabled(menu->get_item_index(FILE_RUN), current_is_doc); } +void ScriptEditor::_file_menu_closed() { + PopupMenu *menu = file_menu->get_popup(); + + menu->set_item_disabled(menu->get_item_index(FILE_REOPEN_CLOSED), false); + + menu->set_item_disabled(menu->get_item_index(FILE_SAVE), false); + menu->set_item_disabled(menu->get_item_index(FILE_SAVE_AS), false); + menu->set_item_disabled(menu->get_item_index(FILE_SAVE_ALL), false); + + menu->set_item_disabled(menu->get_item_index(FILE_TOOL_RELOAD_SOFT), false); + menu->set_item_disabled(menu->get_item_index(FILE_COPY_PATH), false); + menu->set_item_disabled(menu->get_item_index(SHOW_IN_FILE_SYSTEM), false); + + menu->set_item_disabled(menu->get_item_index(WINDOW_PREV), false); + menu->set_item_disabled(menu->get_item_index(WINDOW_NEXT), false); + + menu->set_item_disabled(menu->get_item_index(FILE_CLOSE), false); + menu->set_item_disabled(menu->get_item_index(CLOSE_ALL), false); + menu->set_item_disabled(menu->get_item_index(CLOSE_OTHER_TABS), false); + menu->set_item_disabled(menu->get_item_index(CLOSE_DOCS), false); + + menu->set_item_disabled(menu->get_item_index(FILE_RUN), false); +} + void ScriptEditor::_tab_changed(int p_which) { ensure_select_current(); } @@ -3916,6 +3940,7 @@ ScriptEditor::ScriptEditor() { file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/toggle_scripts_panel", TTR("Toggle Scripts Panel"), KeyModifierMask::CMD_OR_CTRL | Key::BACKSLASH), TOGGLE_SCRIPTS_PANEL); file_menu->get_popup()->connect("id_pressed", callable_mp(this, &ScriptEditor::_menu_option)); file_menu->get_popup()->connect("about_to_popup", callable_mp(this, &ScriptEditor::_prepare_file_menu)); + file_menu->get_popup()->connect("popup_hide", callable_mp(this, &ScriptEditor::_file_menu_closed)); script_search_menu = memnew(MenuButton); script_search_menu->set_text(TTR("Search")); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index f8e684ae34..7d2f5ad22a 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -336,6 +336,7 @@ class ScriptEditor : public PanelContainer { bool _has_docs_tab() const; bool _has_script_tab() const; void _prepare_file_menu(); + void _file_menu_closed(); Tree *disk_changed_list = nullptr; ConfirmationDialog *disk_changed = nullptr; -- cgit v1.2.3 From 03827485d77663a15d1bfb56278a1e5da1dafa5c Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 7 Apr 2023 17:44:38 +0200 Subject: Properly remember snapping options per-project (cherry picked from commit 45b47d558473623d2ae3d11df1cbfb84fb72a1e5) --- editor/plugins/canvas_item_editor_plugin.cpp | 21 +++++++++++++++++++++ editor/plugins/canvas_item_editor_plugin.h | 12 +++++++----- editor/plugins/node_3d_editor_plugin.cpp | 13 +++++++++---- editor/plugins/texture_region_editor_plugin.cpp | 12 +++++++++--- 4 files changed, 46 insertions(+), 12 deletions(-) (limited to 'editor') diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 06cb3bc9b1..5c0fa8968b 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -895,6 +895,14 @@ void CanvasItemEditor::_commit_canvas_item_state(List p_canvas_ite void CanvasItemEditor::_snap_changed() { static_cast(snap_dialog)->get_fields(grid_offset, grid_step, primary_grid_steps, snap_rotation_offset, snap_rotation_step, snap_scale_step); + + EditorSettings::get_singleton()->set_project_metadata("2d_editor", "grid_offset", grid_offset); + EditorSettings::get_singleton()->set_project_metadata("2d_editor", "grid_step", grid_step); + EditorSettings::get_singleton()->set_project_metadata("2d_editor", "primary_grid_steps", primary_grid_steps); + EditorSettings::get_singleton()->set_project_metadata("2d_editor", "snap_rotation_offset", snap_rotation_offset); + EditorSettings::get_singleton()->set_project_metadata("2d_editor", "snap_rotation_step", snap_rotation_step); + EditorSettings::get_singleton()->set_project_metadata("2d_editor", "snap_scale_step", snap_scale_step); + grid_step_multiplier = 0; viewport->queue_redraw(); } @@ -4896,6 +4904,15 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) { viewport->queue_redraw(); } +void CanvasItemEditor::clear() { + grid_offset = EditorSettings::get_singleton()->get_project_metadata("2d_editor", "grid_offset", Vector2()); + grid_step = EditorSettings::get_singleton()->get_project_metadata("2d_editor", "grid_step", Vector2(8, 8)); + primary_grid_steps = EditorSettings::get_singleton()->get_project_metadata("2d_editor", "primary_grid_steps", 8); + snap_rotation_step = EditorSettings::get_singleton()->get_project_metadata("2d_editor", "snap_rotation_step", Math::deg_to_rad(15.0)); + snap_rotation_offset = EditorSettings::get_singleton()->get_project_metadata("2d_editor", "snap_rotation_offset", 0.0); + snap_scale_step = EditorSettings::get_singleton()->get_project_metadata("2d_editor", "snap_scale_step", 0.1); +} + void CanvasItemEditor::add_control_to_menu_panel(Control *p_control) { ERR_FAIL_COND(!p_control); @@ -5426,6 +5443,10 @@ void CanvasItemEditorPlugin::set_state(const Dictionary &p_state) { canvas_item_editor->set_state(p_state); } +void CanvasItemEditorPlugin::clear() { + canvas_item_editor->clear(); +} + void CanvasItemEditorPlugin::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 5ad8318ca0..e5f9b7b567 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -211,15 +211,15 @@ private: bool selected_from_canvas = false; + // Defaults are defined in clear(). Point2 grid_offset; - // A power-of-two value works better as a default grid size. - Point2 grid_step = Point2(8, 8); - int primary_grid_steps = 8; + Point2 grid_step; + int primary_grid_steps = 0; int grid_step_multiplier = 0; - real_t snap_rotation_step = Math::deg_to_rad(15.0); + real_t snap_rotation_step = 0.0; real_t snap_rotation_offset = 0.0; - real_t snap_scale_step = 0.1f; + real_t snap_scale_step = 0.0; bool smart_snap_active = false; bool grid_snap_active = false; @@ -526,6 +526,7 @@ public: static CanvasItemEditor *get_singleton() { return singleton; } Dictionary get_state() const; void set_state(const Dictionary &p_state); + void clear(); void add_control_to_menu_panel(Control *p_control); void remove_control_from_menu_panel(Control *p_control); @@ -575,6 +576,7 @@ public: virtual void make_visible(bool p_visible) override; virtual Dictionary get_state() const override; virtual void set_state(const Dictionary &p_state) override; + virtual void clear() override; CanvasItemEditor *get_canvas_item_editor() { return canvas_item_editor; } diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index cdd61d7067..27c97ff9f4 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -5995,6 +5995,10 @@ void Node3DEditor::_snap_changed() { snap_translate_value = snap_translate->get_text().to_float(); snap_rotate_value = snap_rotate->get_text().to_float(); snap_scale_value = snap_scale->get_text().to_float(); + + EditorSettings::get_singleton()->set_project_metadata("3d_editor", "snap_translate_value", snap_translate_value); + EditorSettings::get_singleton()->set_project_metadata("3d_editor", "snap_rotate_value", snap_rotate_value); + EditorSettings::get_singleton()->set_project_metadata("3d_editor", "snap_scale_value", snap_scale_value); } void Node3DEditor::_snap_update() { @@ -7853,6 +7857,11 @@ void Node3DEditor::clear() { settings_znear->set_value(EDITOR_GET("editors/3d/default_z_near")); settings_zfar->set_value(EDITOR_GET("editors/3d/default_z_far")); + snap_translate_value = EditorSettings::get_singleton()->get_project_metadata("3d_editor", "snap_translate_value", 1); + snap_rotate_value = EditorSettings::get_singleton()->get_project_metadata("3d_editor", "snap_rotate_value", 15); + snap_scale_value = EditorSettings::get_singleton()->get_project_metadata("3d_editor", "snap_scale_value", 10); + _snap_update(); + for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) { viewports[i]->reset(); } @@ -8307,10 +8316,6 @@ Node3DEditor::Node3DEditor() { /* SNAP DIALOG */ - snap_translate_value = 1; - snap_rotate_value = 15; - snap_scale_value = 10; - snap_dialog = memnew(ConfirmationDialog); snap_dialog->set_title(TTR("Snap Settings")); add_child(snap_dialog); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 96e9005850..f2e650a604 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -848,6 +848,12 @@ void TextureRegionEditor::_notification(int p_what) { if (snap_mode == SNAP_AUTOSLICE && is_visible() && autoslice_is_dirty) { _update_autoslice(); } + + if (!is_visible()) { + EditorSettings::get_singleton()->set_project_metadata("texture_region_editor", "snap_step", snap_step); + EditorSettings::get_singleton()->set_project_metadata("texture_region_editor", "snap_separation", snap_separation); + EditorSettings::get_singleton()->set_project_metadata("texture_region_editor", "snap_mode", snap_mode); + } } break; case NOTIFICATION_WM_WINDOW_FOCUS_IN: { @@ -1076,9 +1082,9 @@ TextureRegionEditor::TextureRegionEditor() { preview_tex = Ref(memnew(CanvasTexture)); // A power-of-two value works better as a default grid size. - snap_step = Vector2(8, 8); - snap_separation = Vector2(0, 0); - snap_mode = SNAP_NONE; + snap_step = EditorSettings::get_singleton()->get_project_metadata("texture_region_editor", "snap_step", Vector2(8, 8)); + snap_separation = EditorSettings::get_singleton()->get_project_metadata("texture_region_editor", "snap_separation", Vector2()); + snap_mode = EditorSettings::get_singleton()->get_project_metadata("texture_region_editor", "snap_mode", SNAP_NONE); edited_margin = -1; drag_index = -1; drag = false; -- cgit v1.2.3 From 87a9d2c87e5314d21a554077ae5e61c8284d1dc7 Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 7 Apr 2023 17:44:38 +0200 Subject: Improve editor state initialization (cherry picked from commit 13c8a9890d925fccd7a7988c63bc4867ed81ddeb) --- editor/editor_data.cpp | 7 +++++++ editor/plugins/canvas_item_editor_plugin.cpp | 16 +++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'editor') diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 3059ce445c..9bdd39f684 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -293,6 +293,13 @@ Dictionary EditorData::get_scene_editor_states(int p_idx) const { } void EditorData::set_editor_states(const Dictionary &p_states) { + if (p_states.is_empty()) { + for (EditorPlugin *ep : editor_plugins) { + ep->clear(); + } + return; + } + List keys; p_states.get_key_list(&keys); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 5c0fa8968b..e969f9ab30 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -4691,7 +4691,6 @@ void CanvasItemEditor::_reset_drag() { void CanvasItemEditor::_bind_methods() { ClassDB::bind_method("_get_editor_data", &CanvasItemEditor::_get_editor_data); - 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); @@ -4905,6 +4904,13 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) { } void CanvasItemEditor::clear() { + zoom = 1.0 / MAX(1, EDSCALE); + zoom_widget->set_zoom(zoom); + + view_offset = Point2(-150 - RULER_WIDTH, -95 - RULER_WIDTH); + previous_update_view_offset = view_offset; // Moves the view a little bit to the left so that (0,0) is visible. The values a relative to a 16/10 screen. + _update_scrollbars(); + grid_offset = EditorSettings::get_singleton()->get_project_metadata("2d_editor", "grid_offset", Vector2()); grid_step = EditorSettings::get_singleton()->get_project_metadata("2d_editor", "grid_step", Vector2(8, 8)); primary_grid_steps = EditorSettings::get_singleton()->get_project_metadata("2d_editor", "primary_grid_steps", 8); @@ -4956,10 +4962,6 @@ void CanvasItemEditor::center_at(const Point2 &p_pos) { } CanvasItemEditor::CanvasItemEditor() { - zoom = 1.0 / MAX(1, EDSCALE); - view_offset = Point2(-150 - RULER_WIDTH, -95 - RULER_WIDTH); - previous_update_view_offset = view_offset; // Moves the view a little bit to the left so that (0,0) is visible. The values a relative to a 16/10 screen - snap_target[0] = SNAP_TARGET_NONE; snap_target[1] = SNAP_TARGET_NONE; @@ -5406,8 +5408,8 @@ CanvasItemEditor::CanvasItemEditor() { set_process_shortcut_input(true); - // Update the menus' checkboxes - call_deferred(SNAME("set_state"), get_state()); + // Update the menus' checkboxes. + callable_mp(this, &CanvasItemEditor::set_state).bind(get_state()).call_deferred(); } CanvasItemEditor *CanvasItemEditor::singleton = nullptr; -- cgit v1.2.3 From 817da41d55cc50da2bf819f3b2d0204ecb145d7a Mon Sep 17 00:00:00 2001 From: Marius Hanl Date: Fri, 7 Apr 2023 17:44:38 +0200 Subject: Fix some theme values affect the editor by setting a default value for the theme constant 'h_separation' for MenuBar and Button and a default value for the theme color 'background_color' for TextEdit (cherry picked from commit c0905bc0af66c27f032466821ab1ea074d0e9804) --- editor/editor_themes.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'editor') diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 3e6b0ee07f..0d480c7896 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -859,6 +859,7 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_color("icon_pressed_color", "Button", icon_pressed_color); theme->set_color("icon_disabled_color", "Button", icon_disabled_color); + theme->set_constant("h_separation", "Button", 2 * EDSCALE); theme->set_constant("outline_size", "Button", 0 * EDSCALE); const float ACTION_BUTTON_EXTRA_MARGIN = 32 * EDSCALE; @@ -915,6 +916,7 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_color("icon_pressed_color", "MenuBar", icon_pressed_color); theme->set_color("icon_disabled_color", "MenuBar", icon_disabled_color); + theme->set_constant("h_separation", "MenuBar", 4 * EDSCALE); theme->set_constant("outline_size", "MenuBar", 0 * EDSCALE); // OptionButton @@ -1450,6 +1452,8 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_color("font_outline_color", "TextEdit", font_outline_color); theme->set_color("caret_color", "TextEdit", font_color); theme->set_color("selection_color", "TextEdit", selection_color); + theme->set_color("background_color", "TextEdit", Color(0, 0, 0, 0)); + theme->set_constant("line_spacing", "TextEdit", 4 * EDSCALE); theme->set_constant("outline_size", "TextEdit", 0 * EDSCALE); -- cgit v1.2.3 From cacc6c5ed564c7a48a56cf2689863d4090d74b13 Mon Sep 17 00:00:00 2001 From: Yuri Sizov Date: Fri, 7 Apr 2023 17:44:38 +0200 Subject: Prevent color conversion of the big Godot logo Use an off-white color from the palette that we explicitly don't convert. (cherry picked from commit ce741df43dd947e926c5034ac82ce7f3e83589a5) --- editor/icons/Logo.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'editor') diff --git a/editor/icons/Logo.svg b/editor/icons/Logo.svg index a4ad488396..6c7121e13b 100644 --- a/editor/icons/Logo.svg +++ b/editor/icons/Logo.svg @@ -1 +1 @@ - + -- cgit v1.2.3 From ba9f2981f19b3b2c721210b165e315540a7ecb49 Mon Sep 17 00:00:00 2001 From: Lyuma Date: Fri, 7 Apr 2023 17:44:39 +0200 Subject: gltf: Remove obsolete hack to embed gltf textures in advanced import (cherry picked from commit bd020b7d92dc99c3713b7d1b99da691b8d1e765e) --- editor/import/resource_importer_scene.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'editor') diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 3a147abade..7979688ed0 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -2302,11 +2302,6 @@ Node *ResourceImporterScene::pre_import(const String &p_source_file, const HashM Error err = OK; HashMap options_dupe = p_options; - // By default, the GLTF importer will extract embedded images into files on disk - // However, we do not want the advanced settings dialog to be able to write files on disk. - // To avoid this and also avoid compressing to basis every time, we are using the uncompressed option. - options_dupe["gltf/embedded_image_handling"] = 3; // Embed as Uncompressed defined in GLTFState::GLTFHandleBinary::HANDLE_BINARY_EMBED_AS_UNCOMPRESSED - Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, options_dupe, nullptr, &err); if (!scene || err != OK) { return nullptr; -- cgit v1.2.3 From 177be9bd37e3dfa4d591eea3bb8ab14a17d06007 Mon Sep 17 00:00:00 2001 From: kobewi Date: Sat, 8 Apr 2023 00:01:29 +0200 Subject: Initialize editor values on first launch (cherry picked from commit b0eadcfbce3182373501ab24e62544032c4aec82) --- editor/plugins/canvas_item_editor_plugin.cpp | 1 + editor/plugins/node_3d_editor_plugin.cpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'editor') diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index e969f9ab30..4814b9ae3b 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -5407,6 +5407,7 @@ CanvasItemEditor::CanvasItemEditor() { singleton = this; set_process_shortcut_input(true); + clear(); // Make sure values are initialized. // Update the menus' checkboxes. callable_mp(this, &CanvasItemEditor::set_state).bind(get_state()).call_deferred(); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 27c97ff9f4..e443548550 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -7866,7 +7866,10 @@ void Node3DEditor::clear() { viewports[i]->reset(); } - RenderingServer::get_singleton()->instance_set_visible(origin_instance, true); + if (origin_instance.is_valid()) { + RenderingServer::get_singleton()->instance_set_visible(origin_instance, true); + } + view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN), true); for (int i = 0; i < 3; ++i) { if (grid_enable[i]) { @@ -8654,6 +8657,7 @@ void fragment() { _load_default_preview_settings(); _preview_settings_changed(); } + clear(); // Make sure values are initialized. } Node3DEditor::~Node3DEditor() { memdelete(preview_node); -- cgit v1.2.3