summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/action_map_editor.cpp780
-rw-r--r--editor/action_map_editor.h114
-rw-r--r--editor/animation_bezier_editor.cpp14
-rw-r--r--editor/animation_track_editor.cpp103
-rw-r--r--editor/animation_track_editor_plugins.cpp36
-rw-r--r--editor/code_editor.cpp796
-rw-r--r--editor/code_editor.h5
-rw-r--r--editor/connections_dialog.cpp100
-rw-r--r--editor/connections_dialog.h1
-rw-r--r--editor/create_dialog.cpp43
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_protocol.cpp14
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_server.cpp8
-rw-r--r--editor/debugger/editor_debugger_inspector.cpp10
-rw-r--r--editor/debugger/editor_debugger_node.cpp7
-rw-r--r--editor/debugger/editor_performance_profiler.cpp8
-rw-r--r--editor/debugger/script_editor_debugger.cpp40
-rw-r--r--editor/dependency_editor.cpp6
-rw-r--r--editor/dependency_editor.h2
-rw-r--r--editor/editor_asset_installer.cpp16
-rw-r--r--editor/editor_audio_buses.cpp8
-rw-r--r--editor/editor_autoload_settings.cpp49
-rw-r--r--editor/editor_build_profile.cpp3
-rw-r--r--editor/editor_command_palette.h6
-rw-r--r--editor/editor_file_dialog.cpp26
-rw-r--r--editor/editor_file_system.cpp46
-rw-r--r--editor/editor_fonts.cpp22
-rw-r--r--editor/editor_help.cpp17
-rw-r--r--editor/editor_help_search.cpp88
-rw-r--r--editor/editor_help_search.h3
-rw-r--r--editor/editor_inspector.cpp32
-rw-r--r--editor/editor_locale_dialog.cpp10
-rw-r--r--editor/editor_log.cpp25
-rw-r--r--editor/editor_node.cpp184
-rw-r--r--editor/editor_node.h6
-rw-r--r--editor/editor_path.cpp14
-rw-r--r--editor/editor_plugin.cpp20
-rw-r--r--editor/editor_plugin.h10
-rw-r--r--editor/editor_plugin_settings.cpp6
-rw-r--r--editor/editor_properties.cpp210
-rw-r--r--editor/editor_properties.h33
-rw-r--r--editor/editor_properties_array_dict.cpp44
-rw-r--r--editor/editor_resource_picker.cpp16
-rw-r--r--editor/editor_resource_preview.cpp6
-rw-r--r--editor/editor_sectioned_inspector.cpp10
-rw-r--r--editor/editor_settings.cpp21
-rw-r--r--editor/editor_settings_dialog.cpp73
-rw-r--r--editor/editor_settings_dialog.h6
-rw-r--r--editor/editor_spin_slider.cpp2
-rw-r--r--editor/editor_themes.cpp9
-rw-r--r--editor/editor_toaster.cpp22
-rw-r--r--editor/editor_zoom_widget.cpp10
-rw-r--r--editor/editor_zoom_widget.h2
-rw-r--r--editor/event_listener_line_edit.cpp131
-rw-r--r--editor/event_listener_line_edit.h74
-rw-r--r--editor/export/editor_export_platform.h1
-rw-r--r--editor/export/editor_export_platform_pc.cpp6
-rw-r--r--editor/export/export_template_manager.cpp30
-rw-r--r--editor/export/project_export.cpp30
-rw-r--r--editor/filesystem_dock.cpp116
-rw-r--r--editor/filesystem_dock.h6
-rw-r--r--editor/find_in_files.cpp4
-rw-r--r--editor/find_in_files.h2
-rw-r--r--editor/groups_editor.cpp144
-rw-r--r--editor/groups_editor.h11
-rw-r--r--editor/icons/BoneMapHumanBody.svg27
-rw-r--r--editor/icons/PickerShapeCircle.svg1
-rw-r--r--editor/icons/PickerShapeRectangle.svg1
-rw-r--r--editor/icons/PickerShapeRectangleWheel.svg58
-rw-r--r--editor/import/audio_stream_import_settings.cpp14
-rw-r--r--editor/import/collada.cpp8
-rw-r--r--editor/import/dynamic_font_import_settings.cpp12
-rw-r--r--editor/import/editor_import_plugin.cpp4
-rw-r--r--editor/import/resource_importer_layered_texture.cpp18
-rw-r--r--editor/import/resource_importer_scene.cpp237
-rw-r--r--editor/import/resource_importer_scene.h2
-rw-r--r--editor/import/resource_importer_texture.cpp33
-rw-r--r--editor/input_event_configuration_dialog.cpp700
-rw-r--r--editor/input_event_configuration_dialog.h124
-rw-r--r--editor/inspector_dock.cpp16
-rw-r--r--editor/plugin_config_dialog.cpp8
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.cpp4
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.cpp26
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp24
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp49
-rw-r--r--editor/plugins/animation_player_editor_plugin.h3
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp22
-rw-r--r--editor/plugins/audio_stream_randomizer_editor_plugin.cpp16
-rw-r--r--editor/plugins/bone_map_editor_plugin.h1
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp465
-rw-r--r--editor/plugins/cpu_particles_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/editor_resource_conversion_plugin.cpp2
-rw-r--r--editor/plugins/gpu_particles_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/gpu_particles_3d_editor_plugin.cpp22
-rw-r--r--editor/plugins/gradient_editor.cpp4
-rw-r--r--editor/plugins/input_event_editor_plugin.cpp11
-rw-r--r--editor/plugins/line_2d_editor_plugin.cpp6
-rw-r--r--editor/plugins/mesh_instance_3d_editor_plugin.cpp19
-rw-r--r--editor/plugins/mesh_instance_3d_editor_plugin.h1
-rw-r--r--editor/plugins/node_3d_editor_gizmos.cpp172
-rw-r--r--editor/plugins/node_3d_editor_gizmos.h6
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp44
-rw-r--r--editor/plugins/path_3d_editor_plugin.cpp22
-rw-r--r--editor/plugins/path_3d_editor_plugin.h2
-rw-r--r--editor/plugins/polygon_3d_editor_plugin.cpp2
-rw-r--r--editor/plugins/polygon_3d_editor_plugin.h4
-rw-r--r--editor/plugins/script_editor_plugin.cpp287
-rw-r--r--editor/plugins/script_editor_plugin.h3
-rw-r--r--editor/plugins/script_text_editor.cpp57
-rw-r--r--editor/plugins/script_text_editor.h1
-rw-r--r--editor/plugins/shader_editor_plugin.cpp6
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.cpp36
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.h2
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp109
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.h10
-rw-r--r--editor/plugins/text_editor.cpp11
-rw-r--r--editor/plugins/text_editor.h1
-rw-r--r--editor/plugins/text_shader_editor.cpp107
-rw-r--r--editor/plugins/text_shader_editor.h1
-rw-r--r--editor/plugins/tiles/tile_atlas_view.cpp2
-rw-r--r--editor/plugins/tiles/tile_data_editors.cpp37
-rw-r--r--editor/plugins/tiles/tile_map_editor.cpp31
-rw-r--r--editor/plugins/tiles/tile_set_atlas_source_editor.cpp23
-rw-r--r--editor/plugins/tiles/tile_set_editor.cpp84
-rw-r--r--editor/plugins/tiles/tiles_editor_plugin.cpp8
-rw-r--r--editor/plugins/tiles/tiles_editor_plugin.h2
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp304
-rw-r--r--editor/project_converter_3_to_4.cpp42
-rw-r--r--editor/project_manager.cpp26
-rw-r--r--editor/project_settings_editor.cpp14
-rw-r--r--editor/project_settings_editor.h2
-rw-r--r--editor/rename_dialog.cpp6
-rw-r--r--editor/scene_create_dialog.cpp6
-rw-r--r--editor/scene_tree_dock.cpp108
-rw-r--r--editor/scene_tree_dock.h10
-rw-r--r--editor/scene_tree_editor.cpp95
-rw-r--r--editor/scene_tree_editor.h2
-rw-r--r--editor/script_create_dialog.cpp10
-rw-r--r--editor/script_create_dialog.h4
-rw-r--r--editor/shader_create_dialog.cpp30
139 files changed, 4210 insertions, 3162 deletions
diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp
index b6348c5952..9b1ff78727 100644
--- a/editor/action_map_editor.cpp
+++ b/editor/action_map_editor.cpp
@@ -28,731 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "action_map_editor.h"
-
-#include "core/input/input_map.h"
-#include "core/os/keyboard.h"
+#include "editor/action_map_editor.h"
#include "editor/editor_scale.h"
-#include "scene/gui/separator.h"
-
-/////////////////////////////////////////
-
-// Maps to 2*axis if value is neg, or 2*axis+1 if value is pos.
-static const char *_joy_axis_descriptions[(size_t)JoyAxis::MAX * 2] = {
- TTRC("Left Stick Left, Joystick 0 Left"),
- TTRC("Left Stick Right, Joystick 0 Right"),
- TTRC("Left Stick Up, Joystick 0 Up"),
- TTRC("Left Stick Down, Joystick 0 Down"),
- TTRC("Right Stick Left, Joystick 1 Left"),
- TTRC("Right Stick Right, Joystick 1 Right"),
- TTRC("Right Stick Up, Joystick 1 Up"),
- TTRC("Right Stick Down, Joystick 1 Down"),
- TTRC("Joystick 2 Left"),
- TTRC("Left Trigger, Sony L2, Xbox LT, Joystick 2 Right"),
- TTRC("Joystick 2 Up"),
- TTRC("Right Trigger, Sony R2, Xbox RT, Joystick 2 Down"),
- TTRC("Joystick 3 Left"),
- TTRC("Joystick 3 Right"),
- TTRC("Joystick 3 Up"),
- TTRC("Joystick 3 Down"),
- TTRC("Joystick 4 Left"),
- TTRC("Joystick 4 Right"),
- TTRC("Joystick 4 Up"),
- TTRC("Joystick 4 Down"),
-};
-
-String InputEventConfigurationDialog::get_event_text(const Ref<InputEvent> &p_event, bool p_include_device) const {
- ERR_FAIL_COND_V_MSG(p_event.is_null(), String(), "Provided event is not a valid instance of InputEvent");
-
- String text = p_event->as_text();
-
- Ref<InputEventKey> key = p_event;
- if (key.is_valid() && key->is_command_or_control_autoremap()) {
-#ifdef MACOS_ENABLED
- text = text.replace("Command", "Command/Ctrl");
-#else
- text = text.replace("Ctrl", "Command/Ctrl");
-#endif
- }
- Ref<InputEventMouse> mouse = p_event;
- Ref<InputEventJoypadMotion> jp_motion = p_event;
- Ref<InputEventJoypadButton> jp_button = p_event;
- if (jp_motion.is_valid()) {
- // Joypad motion events will display slightly differently than what the event->as_text() provides. See #43660.
- String desc = TTR("Unknown Joypad Axis");
- if (jp_motion->get_axis() < JoyAxis::MAX) {
- desc = RTR(_joy_axis_descriptions[2 * (size_t)jp_motion->get_axis() + (jp_motion->get_axis_value() < 0 ? 0 : 1)]);
- }
-
- text = vformat("Joypad Axis %s %s (%s)", itos((int64_t)jp_motion->get_axis()), jp_motion->get_axis_value() < 0 ? "-" : "+", desc);
- }
- if (p_include_device && (mouse.is_valid() || jp_button.is_valid() || jp_motion.is_valid())) {
- String device_string = _get_device_string(p_event->get_device());
- text += vformat(" - %s", device_string);
- }
-
- return text;
-}
-
-void InputEventConfigurationDialog::_set_event(const Ref<InputEvent> &p_event, bool p_update_input_list_selection) {
- if (p_event.is_valid()) {
- event = p_event;
-
- // Update Label
- event_as_text->set_text(get_event_text(event, true));
-
- Ref<InputEventKey> k = p_event;
- Ref<InputEventMouseButton> mb = p_event;
- Ref<InputEventJoypadButton> joyb = p_event;
- Ref<InputEventJoypadMotion> joym = p_event;
- Ref<InputEventWithModifiers> mod = p_event;
-
- // Update option values and visibility
- bool show_mods = false;
- bool show_device = false;
- bool show_phys_key = false;
-
- if (mod.is_valid()) {
- show_mods = true;
- mod_checkboxes[MOD_ALT]->set_pressed(mod->is_alt_pressed());
- mod_checkboxes[MOD_SHIFT]->set_pressed(mod->is_shift_pressed());
- mod_checkboxes[MOD_CTRL]->set_pressed(mod->is_ctrl_pressed());
- mod_checkboxes[MOD_META]->set_pressed(mod->is_meta_pressed());
-
- autoremap_command_or_control_checkbox->set_pressed(mod->is_command_or_control_autoremap());
- }
-
- if (k.is_valid()) {
- show_phys_key = true;
- physical_key_checkbox->set_pressed(k->get_physical_keycode() != Key::NONE && k->get_keycode() == Key::NONE);
-
- } else if (joyb.is_valid() || joym.is_valid() || mb.is_valid()) {
- show_device = true;
- _set_current_device(event->get_device());
- }
-
- mod_container->set_visible(show_mods);
- device_container->set_visible(show_device);
- physical_key_checkbox->set_visible(show_phys_key);
- additional_options_container->show();
-
- // Update selected item in input list.
- if (p_update_input_list_selection && (k.is_valid() || joyb.is_valid() || joym.is_valid() || mb.is_valid())) {
- TreeItem *category = input_list_tree->get_root()->get_first_child();
- while (category) {
- TreeItem *input_item = category->get_first_child();
-
- if (input_item != nullptr) {
- // input_type should always be > 0, unless the tree structure has been misconfigured.
- int input_type = input_item->get_parent()->get_meta("__type", 0);
- if (input_type == 0) {
- return;
- }
-
- // If event type matches input types of this category.
- if ((k.is_valid() && input_type == INPUT_KEY) || (joyb.is_valid() && input_type == INPUT_JOY_BUTTON) || (joym.is_valid() && input_type == INPUT_JOY_MOTION) || (mb.is_valid() && input_type == INPUT_MOUSE_BUTTON)) {
- // Loop through all items of this category until one matches.
- while (input_item) {
- bool key_match = k.is_valid() && (Variant(k->get_keycode()) == input_item->get_meta("__keycode") || Variant(k->get_physical_keycode()) == input_item->get_meta("__keycode"));
- bool joyb_match = joyb.is_valid() && Variant(joyb->get_button_index()) == input_item->get_meta("__index");
- bool joym_match = joym.is_valid() && Variant(joym->get_axis()) == input_item->get_meta("__axis") && joym->get_axis_value() == (float)input_item->get_meta("__value");
- bool mb_match = mb.is_valid() && Variant(mb->get_button_index()) == input_item->get_meta("__index");
- if (key_match || joyb_match || joym_match || mb_match) {
- category->set_collapsed(false);
- input_item->select(0);
- input_list_tree->ensure_cursor_is_visible();
- return;
- }
- input_item = input_item->get_next();
- }
- }
- }
-
- category->set_collapsed(true); // Event not in this category, so collapse;
- category = category->get_next();
- }
- }
- } else {
- // Event is not valid, reset dialog
- event = p_event;
- Vector<String> strings;
-
- // Reset message, promp for input according to which input types are allowed.
- String text = TTR("Perform an Input (%s).");
-
- if (allowed_input_types & INPUT_KEY) {
- strings.append(TTR("Key"));
- }
-
- if (allowed_input_types & INPUT_JOY_BUTTON) {
- strings.append(TTR("Joypad Button"));
- }
- if (allowed_input_types & INPUT_JOY_MOTION) {
- strings.append(TTR("Joypad Axis"));
- }
- if (allowed_input_types & INPUT_MOUSE_BUTTON) {
- strings.append(TTR("Mouse Button in area below"));
- }
- if (strings.size() == 0) {
- text = TTR("Input Event dialog has been misconfigured: No input types are allowed.");
- event_as_text->set_text(text);
- } else {
- String insert_text = String(", ").join(strings);
- event_as_text->set_text(vformat(text, insert_text));
- }
-
- additional_options_container->hide();
- input_list_tree->deselect_all();
- _update_input_list();
- }
-}
-
-void InputEventConfigurationDialog::_tab_selected(int p_tab) {
- Callable signal_method = callable_mp(this, &InputEventConfigurationDialog::_listen_window_input);
- if (p_tab == 0) {
- // Start Listening.
- if (!is_connected("window_input", signal_method)) {
- connect("window_input", signal_method);
- }
- } else {
- // Stop Listening.
- if (is_connected("window_input", signal_method)) {
- disconnect("window_input", signal_method);
- }
- input_list_tree->call_deferred(SNAME("ensure_cursor_is_visible"));
- if (input_list_tree->get_selected() == nullptr) {
- // If nothing selected, scroll to top.
- input_list_tree->scroll_to_item(input_list_tree->get_root());
- }
- }
-}
-
-void InputEventConfigurationDialog::_listen_window_input(const Ref<InputEvent> &p_event) {
- // Ignore if echo or not pressed
- if (p_event->is_echo() || !p_event->is_pressed()) {
- return;
- }
-
- // Ignore mouse motion
- Ref<InputEventMouseMotion> mm = p_event;
- if (mm.is_valid()) {
- return;
- }
-
- // Ignore mouse button if not in the detection rect
- Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid()) {
- Rect2 r = mouse_detection_rect->get_rect();
- if (!r.has_point(mouse_detection_rect->get_local_mouse_position() + r.get_position())) {
- return;
- }
- }
-
- // Create an editable reference
- Ref<InputEvent> received_event = p_event;
-
- // Check what the type is and if it is allowed.
- Ref<InputEventKey> k = received_event;
- Ref<InputEventJoypadButton> joyb = received_event;
- Ref<InputEventJoypadMotion> joym = received_event;
-
- int type = 0;
- if (k.is_valid()) {
- type = INPUT_KEY;
- } else if (joyb.is_valid()) {
- type = INPUT_JOY_BUTTON;
- } else if (joym.is_valid()) {
- type = INPUT_JOY_MOTION;
- } else if (mb.is_valid()) {
- type = INPUT_MOUSE_BUTTON;
- }
-
- if (!(allowed_input_types & type)) {
- return;
- }
-
- if (joym.is_valid()) {
- float axis_value = joym->get_axis_value();
- if (ABS(axis_value) < 0.9) {
- // Ignore motion below 0.9 magnitude to avoid accidental touches
- return;
- } else {
- // Always make the value 1 or -1 for display consistency
- joym->set_axis_value(SIGN(axis_value));
- }
- }
-
- if (k.is_valid()) {
- k->set_pressed(false); // To avoid serialisation of 'pressed' property - doesn't matter for actions anyway.
- // Maintain physical keycode option state
- if (physical_key_checkbox->is_pressed()) {
- k->set_keycode(Key::NONE);
- } else {
- k->set_physical_keycode(Key::NONE);
- }
- }
-
- Ref<InputEventWithModifiers> mod = received_event;
- if (mod.is_valid()) {
- mod->set_window_id(0);
- }
-
- // Maintain device selection.
- received_event->set_device(_get_current_device());
-
- _set_event(received_event);
- set_input_as_handled();
-}
-
-void InputEventConfigurationDialog::_search_term_updated(const String &) {
- _update_input_list();
-}
-
-void InputEventConfigurationDialog::_update_input_list() {
- input_list_tree->clear();
-
- TreeItem *root = input_list_tree->create_item();
- String search_term = input_list_search->get_text();
-
- bool collapse = input_list_search->get_text().is_empty();
-
- if (allowed_input_types & INPUT_KEY) {
- TreeItem *kb_root = input_list_tree->create_item(root);
- kb_root->set_text(0, TTR("Keyboard Keys"));
- kb_root->set_icon(0, icon_cache.keyboard);
- kb_root->set_collapsed(collapse);
- kb_root->set_meta("__type", INPUT_KEY);
-
- for (int i = 0; i < keycode_get_count(); i++) {
- String name = keycode_get_name_by_index(i);
-
- if (!search_term.is_empty() && name.findn(search_term) == -1) {
- continue;
- }
-
- TreeItem *item = input_list_tree->create_item(kb_root);
- item->set_text(0, name);
- item->set_meta("__keycode", keycode_get_value_by_index(i));
- }
- }
-
- if (allowed_input_types & INPUT_MOUSE_BUTTON) {
- TreeItem *mouse_root = input_list_tree->create_item(root);
- mouse_root->set_text(0, TTR("Mouse Buttons"));
- mouse_root->set_icon(0, icon_cache.mouse);
- mouse_root->set_collapsed(collapse);
- mouse_root->set_meta("__type", INPUT_MOUSE_BUTTON);
-
- MouseButton mouse_buttons[9] = { MouseButton::LEFT, MouseButton::RIGHT, MouseButton::MIDDLE, MouseButton::WHEEL_UP, MouseButton::WHEEL_DOWN, MouseButton::WHEEL_LEFT, MouseButton::WHEEL_RIGHT, MouseButton::MB_XBUTTON1, MouseButton::MB_XBUTTON2 };
- for (int i = 0; i < 9; i++) {
- Ref<InputEventMouseButton> mb;
- mb.instantiate();
- mb->set_button_index(mouse_buttons[i]);
- String desc = get_event_text(mb, false);
-
- if (!search_term.is_empty() && desc.findn(search_term) == -1) {
- continue;
- }
-
- TreeItem *item = input_list_tree->create_item(mouse_root);
- item->set_text(0, desc);
- item->set_meta("__index", mouse_buttons[i]);
- }
- }
-
- if (allowed_input_types & INPUT_JOY_BUTTON) {
- TreeItem *joyb_root = input_list_tree->create_item(root);
- joyb_root->set_text(0, TTR("Joypad Buttons"));
- joyb_root->set_icon(0, icon_cache.joypad_button);
- joyb_root->set_collapsed(collapse);
- joyb_root->set_meta("__type", INPUT_JOY_BUTTON);
-
- for (int i = 0; i < (int)JoyButton::MAX; i++) {
- Ref<InputEventJoypadButton> joyb;
- joyb.instantiate();
- joyb->set_button_index((JoyButton)i);
- String desc = get_event_text(joyb, false);
-
- if (!search_term.is_empty() && desc.findn(search_term) == -1) {
- continue;
- }
-
- TreeItem *item = input_list_tree->create_item(joyb_root);
- item->set_text(0, desc);
- item->set_meta("__index", i);
- }
- }
-
- if (allowed_input_types & INPUT_JOY_MOTION) {
- TreeItem *joya_root = input_list_tree->create_item(root);
- joya_root->set_text(0, TTR("Joypad Axes"));
- joya_root->set_icon(0, icon_cache.joypad_axis);
- joya_root->set_collapsed(collapse);
- joya_root->set_meta("__type", INPUT_JOY_MOTION);
-
- for (int i = 0; i < (int)JoyAxis::MAX * 2; i++) {
- int axis = i / 2;
- int direction = (i & 1) ? 1 : -1;
- Ref<InputEventJoypadMotion> joym;
- joym.instantiate();
- joym->set_axis((JoyAxis)axis);
- joym->set_axis_value(direction);
- String desc = get_event_text(joym, false);
-
- if (!search_term.is_empty() && desc.findn(search_term) == -1) {
- continue;
- }
-
- TreeItem *item = input_list_tree->create_item(joya_root);
- item->set_text(0, desc);
- item->set_meta("__axis", i >> 1);
- item->set_meta("__value", (i & 1) ? 1 : -1);
- }
- }
-}
-
-void InputEventConfigurationDialog::_mod_toggled(bool p_checked, int p_index) {
- Ref<InputEventWithModifiers> ie = event;
-
- // Not event with modifiers
- if (ie.is_null()) {
- return;
- }
-
- if (p_index == 0) {
- ie->set_alt_pressed(p_checked);
- } else if (p_index == 1) {
- ie->set_shift_pressed(p_checked);
- } else if (p_index == 2) {
- if (!autoremap_command_or_control_checkbox->is_pressed()) {
- ie->set_ctrl_pressed(p_checked);
- }
- } else if (p_index == 3) {
- if (!autoremap_command_or_control_checkbox->is_pressed()) {
- ie->set_meta_pressed(p_checked);
- }
- }
-
- _set_event(ie);
-}
-
-void InputEventConfigurationDialog::_autoremap_command_or_control_toggled(bool p_checked) {
- Ref<InputEventWithModifiers> ie = event;
- if (ie.is_valid()) {
- ie->set_command_or_control_autoremap(p_checked);
- _set_event(ie);
- }
-
- if (p_checked) {
- mod_checkboxes[MOD_META]->hide();
- mod_checkboxes[MOD_CTRL]->hide();
- } else {
- mod_checkboxes[MOD_META]->show();
- mod_checkboxes[MOD_CTRL]->show();
- }
-}
-
-void InputEventConfigurationDialog::_physical_keycode_toggled(bool p_checked) {
- Ref<InputEventKey> k = event;
-
- if (k.is_null()) {
- return;
- }
-
- if (p_checked) {
- k->set_physical_keycode(k->get_keycode());
- k->set_keycode(Key::NONE);
- } else {
- k->set_keycode((Key)k->get_physical_keycode());
- k->set_physical_keycode(Key::NONE);
- }
-
- _set_event(k);
-}
-
-void InputEventConfigurationDialog::_input_list_item_selected() {
- TreeItem *selected = input_list_tree->get_selected();
-
- // Invalid tree selection - type only exists on the "category" items, which are not a valid selection.
- if (selected->has_meta("__type")) {
- return;
- }
-
- InputEventConfigurationDialog::InputType input_type = (InputEventConfigurationDialog::InputType)(int)selected->get_parent()->get_meta("__type");
-
- switch (input_type) {
- case InputEventConfigurationDialog::INPUT_KEY: {
- Key keycode = (Key)(int)selected->get_meta("__keycode");
- Ref<InputEventKey> k;
- k.instantiate();
-
- if (physical_key_checkbox->is_pressed()) {
- k->set_physical_keycode(keycode);
- k->set_keycode(Key::NONE);
- } else {
- k->set_physical_keycode(Key::NONE);
- k->set_keycode(keycode);
- }
-
- // Maintain modifier state from checkboxes
- k->set_alt_pressed(mod_checkboxes[MOD_ALT]->is_pressed());
- k->set_shift_pressed(mod_checkboxes[MOD_SHIFT]->is_pressed());
- if (autoremap_command_or_control_checkbox->is_pressed()) {
- k->set_command_or_control_autoremap(true);
- } else {
- k->set_ctrl_pressed(mod_checkboxes[MOD_CTRL]->is_pressed());
- k->set_meta_pressed(mod_checkboxes[MOD_META]->is_pressed());
- }
-
- _set_event(k, false);
- } break;
- case InputEventConfigurationDialog::INPUT_MOUSE_BUTTON: {
- MouseButton idx = (MouseButton)(int)selected->get_meta("__index");
- Ref<InputEventMouseButton> mb;
- mb.instantiate();
- mb->set_button_index(idx);
- // Maintain modifier state from checkboxes
- mb->set_alt_pressed(mod_checkboxes[MOD_ALT]->is_pressed());
- mb->set_shift_pressed(mod_checkboxes[MOD_SHIFT]->is_pressed());
- if (autoremap_command_or_control_checkbox->is_pressed()) {
- mb->set_command_or_control_autoremap(true);
- } else {
- mb->set_ctrl_pressed(mod_checkboxes[MOD_CTRL]->is_pressed());
- mb->set_meta_pressed(mod_checkboxes[MOD_META]->is_pressed());
- }
-
- // Maintain selected device
- mb->set_device(_get_current_device());
-
- _set_event(mb, false);
- } break;
- case InputEventConfigurationDialog::INPUT_JOY_BUTTON: {
- JoyButton idx = (JoyButton)(int)selected->get_meta("__index");
- Ref<InputEventJoypadButton> jb = InputEventJoypadButton::create_reference(idx);
-
- // Maintain selected device
- jb->set_device(_get_current_device());
-
- _set_event(jb, false);
- } break;
- case InputEventConfigurationDialog::INPUT_JOY_MOTION: {
- JoyAxis axis = (JoyAxis)(int)selected->get_meta("__axis");
- int value = selected->get_meta("__value");
-
- Ref<InputEventJoypadMotion> jm;
- jm.instantiate();
- jm->set_axis(axis);
- jm->set_axis_value(value);
-
- // Maintain selected device
- jm->set_device(_get_current_device());
-
- _set_event(jm, false);
- } break;
- }
-}
-
-void InputEventConfigurationDialog::_device_selection_changed(int p_option_button_index) {
- // Subtract 1 as option index 0 corresponds to "All Devices" (value of -1)
- // and option index 1 corresponds to device 0, etc...
- event->set_device(p_option_button_index - 1);
- event_as_text->set_text(get_event_text(event, true));
-}
-
-void InputEventConfigurationDialog::_set_current_device(int p_device) {
- device_id_option->select(p_device + 1);
-}
-
-int InputEventConfigurationDialog::_get_current_device() const {
- return device_id_option->get_selected() - 1;
-}
-
-String InputEventConfigurationDialog::_get_device_string(int p_device) const {
- if (p_device == InputMap::ALL_DEVICES) {
- return TTR("All Devices");
- }
- return TTR("Device") + " " + itos(p_device);
-}
-
-void InputEventConfigurationDialog::_notification(int p_what) {
- switch (p_what) {
- case NOTIFICATION_ENTER_TREE:
- case NOTIFICATION_THEME_CHANGED: {
- input_list_search->set_right_icon(input_list_search->get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
-
- physical_key_checkbox->set_icon(get_theme_icon(SNAME("KeyboardPhysical"), SNAME("EditorIcons")));
-
- icon_cache.keyboard = get_theme_icon(SNAME("Keyboard"), SNAME("EditorIcons"));
- icon_cache.mouse = get_theme_icon(SNAME("Mouse"), SNAME("EditorIcons"));
- icon_cache.joypad_button = get_theme_icon(SNAME("JoyButton"), SNAME("EditorIcons"));
- icon_cache.joypad_axis = get_theme_icon(SNAME("JoyAxis"), SNAME("EditorIcons"));
-
- _update_input_list();
- } break;
- }
-}
-
-void InputEventConfigurationDialog::popup_and_configure(const Ref<InputEvent> &p_event) {
- if (p_event.is_valid()) {
- _set_event(p_event);
- } else {
- // Clear Event
- _set_event(p_event);
-
- // Clear Checkbox Values
- for (int i = 0; i < MOD_MAX; i++) {
- mod_checkboxes[i]->set_pressed(false);
- }
-
- // Enable the Physical Key checkbox by default to encourage its use.
- // Physical Key should be used for most game inputs as it allows keys to work
- // on non-QWERTY layouts out of the box.
- // This is especially important for WASD movement layouts.
- physical_key_checkbox->set_pressed(true);
-
- autoremap_command_or_control_checkbox->set_pressed(false);
- _set_current_device(0);
-
- // Switch to "Listen" tab
- tab_container->set_current_tab(0);
-
- // Select "All Devices" by default.
- device_id_option->select(0);
- }
-
- popup_centered(Size2(0, 400) * EDSCALE);
-}
-
-Ref<InputEvent> InputEventConfigurationDialog::get_event() const {
- return event;
-}
-
-void InputEventConfigurationDialog::set_allowed_input_types(int p_type_masks) {
- allowed_input_types = p_type_masks;
-}
-
-InputEventConfigurationDialog::InputEventConfigurationDialog() {
- allowed_input_types = INPUT_KEY | INPUT_MOUSE_BUTTON | INPUT_JOY_BUTTON | INPUT_JOY_MOTION | INPUT_MOUSE_BUTTON;
-
- set_title(TTR("Event Configuration"));
- set_min_size(Size2i(550 * EDSCALE, 0)); // Min width
-
- VBoxContainer *main_vbox = memnew(VBoxContainer);
- add_child(main_vbox);
-
- tab_container = memnew(TabContainer);
- tab_container->set_use_hidden_tabs_for_min_size(true);
- tab_container->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- tab_container->set_theme_type_variation("TabContainerOdd");
- tab_container->connect("tab_selected", callable_mp(this, &InputEventConfigurationDialog::_tab_selected));
- main_vbox->add_child(tab_container);
-
- // Listen to input tab
- VBoxContainer *vb = memnew(VBoxContainer);
- vb->set_name(TTR("Listen for Input"));
- event_as_text = memnew(Label);
- event_as_text->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
- vb->add_child(event_as_text);
- // Mouse button detection rect (Mouse button event outside this rect will be ignored)
- mouse_detection_rect = memnew(Panel);
- mouse_detection_rect->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- vb->add_child(mouse_detection_rect);
- tab_container->add_child(vb);
-
- // List of all input options to manually select from.
-
- VBoxContainer *manual_vbox = memnew(VBoxContainer);
- manual_vbox->set_name(TTR("Manual Selection"));
- manual_vbox->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- tab_container->add_child(manual_vbox);
-
- input_list_search = memnew(LineEdit);
- input_list_search->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- input_list_search->set_placeholder(TTR("Filter Inputs"));
- input_list_search->set_clear_button_enabled(true);
- input_list_search->connect("text_changed", callable_mp(this, &InputEventConfigurationDialog::_search_term_updated));
- manual_vbox->add_child(input_list_search);
-
- input_list_tree = memnew(Tree);
- input_list_tree->set_custom_minimum_size(Size2(0, 100 * EDSCALE)); // Min height for tree
- input_list_tree->connect("item_selected", callable_mp(this, &InputEventConfigurationDialog::_input_list_item_selected));
- input_list_tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- manual_vbox->add_child(input_list_tree);
-
- input_list_tree->set_hide_root(true);
- input_list_tree->set_columns(1);
-
- _update_input_list();
-
- // Additional Options
- additional_options_container = memnew(VBoxContainer);
- additional_options_container->hide();
-
- Label *opts_label = memnew(Label);
- opts_label->set_theme_type_variation("HeaderSmall");
- opts_label->set_text(TTR("Additional Options"));
- additional_options_container->add_child(opts_label);
-
- // Device Selection
- device_container = memnew(HBoxContainer);
- device_container->set_h_size_flags(Control::SIZE_EXPAND_FILL);
-
- Label *device_label = memnew(Label);
- device_label->set_theme_type_variation("HeaderSmall");
- device_label->set_text(TTR("Device:"));
- device_container->add_child(device_label);
-
- device_id_option = memnew(OptionButton);
- device_id_option->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- for (int i = -1; i < 8; i++) {
- device_id_option->add_item(_get_device_string(i));
- }
- device_id_option->connect("item_selected", callable_mp(this, &InputEventConfigurationDialog::_device_selection_changed));
- _set_current_device(InputMap::ALL_DEVICES);
- device_container->add_child(device_id_option);
-
- device_container->hide();
- additional_options_container->add_child(device_container);
-
- // Modifier Selection
- mod_container = memnew(HBoxContainer);
- for (int i = 0; i < MOD_MAX; i++) {
- String name = mods[i];
- mod_checkboxes[i] = memnew(CheckBox);
- mod_checkboxes[i]->connect("toggled", callable_mp(this, &InputEventConfigurationDialog::_mod_toggled).bind(i));
- mod_checkboxes[i]->set_text(name);
- mod_checkboxes[i]->set_tooltip_text(TTR(mods_tip[i]));
- mod_container->add_child(mod_checkboxes[i]);
- }
-
- mod_container->add_child(memnew(VSeparator));
-
- autoremap_command_or_control_checkbox = memnew(CheckBox);
- autoremap_command_or_control_checkbox->connect("toggled", callable_mp(this, &InputEventConfigurationDialog::_autoremap_command_or_control_toggled));
- autoremap_command_or_control_checkbox->set_pressed(false);
- autoremap_command_or_control_checkbox->set_text(TTR("Command / Control (auto)"));
- autoremap_command_or_control_checkbox->set_tooltip_text(TTR("Automatically remaps between 'Meta' ('Command') and 'Control' depending on current platform."));
- mod_container->add_child(autoremap_command_or_control_checkbox);
-
- mod_container->hide();
- additional_options_container->add_child(mod_container);
-
- // Physical Key Checkbox
-
- physical_key_checkbox = memnew(CheckBox);
- physical_key_checkbox->set_text(TTR("Use Physical Keycode"));
- physical_key_checkbox->set_tooltip_text(TTR("Stores the physical position of the key on the keyboard rather than the key's value. Used for compatibility with non-latin layouts.\nThis should generally be enabled for most game shortcuts, but not in non-game applications."));
- physical_key_checkbox->connect("toggled", callable_mp(this, &InputEventConfigurationDialog::_physical_keycode_toggled));
- physical_key_checkbox->hide();
- additional_options_container->add_child(physical_key_checkbox);
-
- main_vbox->add_child(additional_options_container);
-
- // Default to first tab
- tab_container->set_current_tab(0);
-}
-
-/////////////////////////////////////////
+#include "editor/event_listener_line_edit.h"
+#include "editor/input_event_configuration_dialog.h"
+#include "scene/gui/check_button.h"
+#include "scene/gui/tree.h"
static bool _is_action_name_valid(const String &p_name) {
const char32_t *cstr = p_name.get_data();
@@ -944,6 +225,12 @@ void ActionMapEditor::_search_term_updated(const String &) {
update_action_list();
}
+void ActionMapEditor::_search_by_event(const Ref<InputEvent> &p_event) {
+ if (p_event.is_null() || (p_event->is_pressed() && !p_event->is_echo())) {
+ update_action_list();
+ }
+}
+
Variant ActionMapEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
TreeItem *selected = action_tree->get_selected();
if (!selected) {
@@ -1084,6 +371,22 @@ InputEventConfigurationDialog *ActionMapEditor::get_configuration_dialog() {
return event_config_dialog;
}
+bool ActionMapEditor::_should_display_action(const String &p_name, const Array &p_events) const {
+ const Ref<InputEvent> search_ev = action_list_search_by_event->get_event();
+ bool event_match = true;
+ if (search_ev.is_valid()) {
+ event_match = false;
+ for (int i = 0; i < p_events.size(); ++i) {
+ const Ref<InputEvent> ev = p_events[i];
+ if (ev.is_valid() && ev->is_match(search_ev, true)) {
+ event_match = true;
+ }
+ }
+ }
+
+ return event_match && action_list_search->get_text().is_subsequence_ofn(p_name);
+}
+
void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_infos) {
if (!p_action_infos.is_empty()) {
actions_cache = p_action_infos;
@@ -1101,8 +404,8 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info
uneditable_count++;
}
- String search_term = action_list_search->get_text();
- if (!search_term.is_empty() && action_info.name.findn(search_term) == -1) {
+ const Array events = action_info.action["events"];
+ if (!_should_display_action(action_info.name, events)) {
continue;
}
@@ -1110,7 +413,6 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info
continue;
}
- const Array events = action_info.action["events"];
const Variant deadzone = action_info.action["deadzone"];
// Update Tree...
@@ -1206,16 +508,22 @@ ActionMapEditor::ActionMapEditor() {
action_list_search = memnew(LineEdit);
action_list_search->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- action_list_search->set_placeholder(TTR("Filter Actions"));
+ action_list_search->set_placeholder(TTR("Filter by name..."));
action_list_search->set_clear_button_enabled(true);
action_list_search->connect("text_changed", callable_mp(this, &ActionMapEditor::_search_term_updated));
top_hbox->add_child(action_list_search);
- show_builtin_actions_checkbutton = memnew(CheckButton);
- show_builtin_actions_checkbutton->set_pressed(false);
- show_builtin_actions_checkbutton->set_text(TTR("Show Built-in Actions"));
- show_builtin_actions_checkbutton->connect("toggled", callable_mp(this, &ActionMapEditor::set_show_builtin_actions));
- top_hbox->add_child(show_builtin_actions_checkbutton);
+ action_list_search_by_event = memnew(EventListenerLineEdit);
+ action_list_search_by_event->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ action_list_search_by_event->set_stretch_ratio(0.75);
+ action_list_search_by_event->connect("event_changed", callable_mp(this, &ActionMapEditor::_search_by_event));
+ top_hbox->add_child(action_list_search_by_event);
+
+ Button *clear_all_search = memnew(Button);
+ clear_all_search->set_text(TTR("Clear All"));
+ clear_all_search->connect("pressed", callable_mp(action_list_search_by_event, &EventListenerLineEdit::clear_event));
+ clear_all_search->connect("pressed", callable_mp(action_list_search, &LineEdit::clear));
+ top_hbox->add_child(clear_all_search);
// Adding Action line edit + button
add_hbox = memnew(HBoxContainer);
@@ -1236,6 +544,12 @@ ActionMapEditor::ActionMapEditor() {
// Disable the button and set its tooltip.
_add_edit_text_changed(add_edit->get_text());
+ show_builtin_actions_checkbutton = memnew(CheckButton);
+ show_builtin_actions_checkbutton->set_pressed(false);
+ show_builtin_actions_checkbutton->set_text(TTR("Show Built-in Actions"));
+ show_builtin_actions_checkbutton->connect("toggled", callable_mp(this, &ActionMapEditor::set_show_builtin_actions));
+ add_hbox->add_child(show_builtin_actions_checkbutton);
+
main_vbox->add_child(add_hbox);
// Action Editor Tree
diff --git a/editor/action_map_editor.h b/editor/action_map_editor.h
index 36d21fe258..d56ee6f9eb 100644
--- a/editor/action_map_editor.h
+++ b/editor/action_map_editor.h
@@ -31,109 +31,16 @@
#ifndef ACTION_MAP_EDITOR_H
#define ACTION_MAP_EDITOR_H
-#include "scene/gui/check_box.h"
-#include "scene/gui/check_button.h"
-#include "scene/gui/color_rect.h"
-#include "scene/gui/dialogs.h"
-#include "scene/gui/label.h"
-#include "scene/gui/option_button.h"
-#include "scene/gui/tab_container.h"
-#include "scene/gui/tree.h"
-
-// Confirmation Dialog used when configuring an input event.
-// Separate from ActionMapEditor for code cleanliness and separation of responsibilities.
-class InputEventConfigurationDialog : public ConfirmationDialog {
- GDCLASS(InputEventConfigurationDialog, ConfirmationDialog);
+#include "scene/gui/control.h"
-public:
- enum InputType {
- INPUT_KEY = 1,
- INPUT_MOUSE_BUTTON = 2,
- INPUT_JOY_BUTTON = 4,
- INPUT_JOY_MOTION = 8
- };
-
-private:
- struct IconCache {
- Ref<Texture2D> keyboard;
- Ref<Texture2D> mouse;
- Ref<Texture2D> joypad_button;
- Ref<Texture2D> joypad_axis;
- } icon_cache;
-
- Ref<InputEvent> event = Ref<InputEvent>();
-
- TabContainer *tab_container = nullptr;
-
- // Listening for input
- Label *event_as_text = nullptr;
- Panel *mouse_detection_rect = nullptr;
-
- // List of All Key/Mouse/Joypad input options.
- int allowed_input_types;
- Tree *input_list_tree = nullptr;
- LineEdit *input_list_search = nullptr;
-
- // Additional Options, shown depending on event selected
- VBoxContainer *additional_options_container = nullptr;
-
- HBoxContainer *device_container = nullptr;
- OptionButton *device_id_option = nullptr;
-
- HBoxContainer *mod_container = nullptr; // Contains the subcontainer and the store command checkbox.
-
- enum ModCheckbox {
- MOD_ALT,
- MOD_SHIFT,
- MOD_CTRL,
- MOD_META,
- MOD_MAX
- };
-#if defined(MACOS_ENABLED)
- String mods[MOD_MAX] = { "Option", "Shift", "Ctrl", "Command" };
-#elif defined(WINDOWS_ENABLED)
- String mods[MOD_MAX] = { "Alt", "Shift", "Ctrl", "Windows" };
-#else
- String mods[MOD_MAX] = { "Alt", "Shift", "Ctrl", "Meta" };
-#endif
- String mods_tip[MOD_MAX] = { "Alt or Option key", "Shift key", "Control key", "Meta/Windows or Command key" };
-
- CheckBox *mod_checkboxes[MOD_MAX];
- CheckBox *autoremap_command_or_control_checkbox = nullptr;
-
- CheckBox *physical_key_checkbox = nullptr;
-
- void _set_event(const Ref<InputEvent> &p_event, bool p_update_input_list_selection = true);
-
- void _tab_selected(int p_tab);
- void _listen_window_input(const Ref<InputEvent> &p_event);
-
- void _search_term_updated(const String &p_term);
- void _update_input_list();
- void _input_list_item_selected();
-
- void _mod_toggled(bool p_checked, int p_index);
- void _autoremap_command_or_control_toggled(bool p_checked);
- void _physical_keycode_toggled(bool p_checked);
-
- void _device_selection_changed(int p_option_button_index);
- void _set_current_device(int p_device);
- int _get_current_device() const;
- String _get_device_string(int p_device) const;
-
-protected:
- void _notification(int p_what);
-
-public:
- // Pass an existing event to configure it. Alternatively, pass no event to start with a blank configuration.
- void popup_and_configure(const Ref<InputEvent> &p_event = Ref<InputEvent>());
- Ref<InputEvent> get_event() const;
- String get_event_text(const Ref<InputEvent> &p_event, bool p_include_device) const;
-
- void set_allowed_input_types(int p_type_masks);
-
- InputEventConfigurationDialog();
-};
+class Button;
+class HBoxContainer;
+class EventListenerLineEdit;
+class LineEdit;
+class CheckButton;
+class AcceptDialog;
+class InputEventConfigurationDialog;
+class Tree;
class ActionMapEditor : public Control {
GDCLASS(ActionMapEditor, Control);
@@ -174,6 +81,7 @@ private:
bool show_builtin_actions = false;
CheckButton *show_builtin_actions_checkbutton = nullptr;
LineEdit *action_list_search = nullptr;
+ EventListenerLineEdit *action_list_search_by_event = nullptr;
HBoxContainer *add_hbox = nullptr;
LineEdit *add_edit = nullptr;
@@ -191,6 +99,8 @@ private:
void _tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _tree_item_activated();
void _search_term_updated(const String &p_search_term);
+ void _search_by_event(const Ref<InputEvent> &p_event);
+ bool _should_display_action(const String &p_name, const Array &p_events) const;
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp
index 3b87b3e65e..604758300d 100644
--- a/editor/animation_bezier_editor.cpp
+++ b/editor/animation_bezier_editor.cpp
@@ -338,14 +338,14 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
Ref<Texture2D> unlock = get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons"));
float lock_hpos = remove_hpos - hsep - lock->get_width();
- Ref<Texture2D> visible = get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"));
- Ref<Texture2D> hidden = get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons"));
- float visibility_hpos = lock_hpos - hsep - visible->get_width();
+ Ref<Texture2D> visibility_visible = get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"));
+ Ref<Texture2D> visibility_hidden = get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons"));
+ float visibility_hpos = lock_hpos - hsep - visibility_visible->get_width();
Ref<Texture2D> solo = get_theme_icon(SNAME("AudioBusSolo"), SNAME("EditorIcons"));
float solo_hpos = visibility_hpos - hsep - solo->get_width();
- float buttons_width = remove->get_width() + lock->get_width() + visible->get_width() + solo->get_width() + hsep * 3;
+ float buttons_width = remove->get_width() + lock->get_width() + visibility_visible->get_width() + solo->get_width() + hsep * 3;
for (int i = 0; i < tracks.size(); ++i) {
// RELATED TRACKS TITLES
@@ -418,11 +418,11 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
draw_texture(unlock, lock_rect.position);
}
- Rect2 visible_rect = Rect2(visibility_hpos, icon_start_height - visible->get_height() / 2.0, visible->get_width(), visible->get_height());
+ Rect2 visible_rect = Rect2(visibility_hpos, icon_start_height - visibility_visible->get_height() / 2.0, visibility_visible->get_width(), visibility_visible->get_height());
if (hidden_tracks.has(current_track)) {
- draw_texture(hidden, visible_rect.position);
+ draw_texture(visibility_hidden, visible_rect.position);
} else {
- draw_texture(visible, visible_rect.position);
+ draw_texture(visibility_visible, visible_rect.position);
}
Rect2 solo_rect = Rect2(solo_hpos, icon_start_height - solo->get_height() / 2.0, solo->get_width(), solo->get_height());
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 9529460ab1..5c4ef35f1c 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -2029,14 +2029,14 @@ void AnimationTrackEdit::_notification(int p_what) {
draw_texture(check, check_rect.position);
ofs += check->get_width() + hsep;
- Ref<Texture2D> type_icon = _get_key_type_icon();
- draw_texture(type_icon, Point2(ofs, int(get_size().height - type_icon->get_height()) / 2));
- ofs += type_icon->get_width() + hsep;
+ Ref<Texture2D> key_type_icon = _get_key_type_icon();
+ draw_texture(key_type_icon, Point2(ofs, int(get_size().height - key_type_icon->get_height()) / 2));
+ ofs += key_type_icon->get_width() + hsep;
- NodePath path = animation->track_get_path(track);
+ NodePath anim_path = animation->track_get_path(track);
Node *node = nullptr;
- if (root && root->has_node(path)) {
- node = root->get_node(path);
+ if (root && root->has_node(anim_path)) {
+ node = root->get_node(anim_path);
}
String text;
@@ -2053,7 +2053,7 @@ void AnimationTrackEdit::_notification(int p_what) {
} else if (animation->track_get_type(track) == Animation::TYPE_ANIMATION) {
text = TTR("Anim Clips:");
} else {
- text += path.get_concatenated_subnames();
+ text += anim_path.get_concatenated_subnames();
}
text_color.a *= 0.7;
} else if (node) {
@@ -2062,14 +2062,14 @@ void AnimationTrackEdit::_notification(int p_what) {
draw_texture(icon, Point2(ofs, int(get_size().height - icon->get_height()) / 2));
icon_cache = icon;
- text = String() + node->get_name() + ":" + path.get_concatenated_subnames();
+ text = String() + node->get_name() + ":" + anim_path.get_concatenated_subnames();
ofs += hsep;
ofs += icon->get_width();
} else {
- icon_cache = type_icon;
+ icon_cache = key_type_icon;
- text = path;
+ text = anim_path;
}
path_cache = text;
@@ -2853,9 +2853,9 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
if (ape) {
AnimationPlayer *ap = ape->get_player();
if (ap) {
- NodePath path = animation->track_get_path(track);
- Node *nd = ap->get_node(ap->get_root())->get_node(NodePath(path.get_concatenated_names()));
- StringName prop = path.get_concatenated_subnames();
+ NodePath npath = animation->track_get_path(track);
+ Node *nd = ap->get_node(ap->get_root())->get_node(NodePath(npath.get_concatenated_names()));
+ StringName prop = npath.get_concatenated_subnames();
PropertyInfo prop_info;
ClassDB::get_property_info(nd->get_class(), prop, &prop_info);
bool is_angle = prop_info.type == Variant::FLOAT && prop_info.hint_string.find("radians") != -1;
@@ -4463,24 +4463,24 @@ void AnimationTrackEditor::_update_tracks() {
return;
}
- bool read_only = false;
+ bool file_read_only = false;
if (!animation->get_path().is_resource_file()) {
int srpos = animation->get_path().find("::");
if (srpos != -1) {
String base = animation->get_path().substr(0, srpos);
if (ResourceLoader::get_resource_type(base) == "PackedScene") {
if (!get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->get_scene_file_path() != base) {
- read_only = true;
+ file_read_only = true;
}
} else {
if (FileAccess::exists(base + ".import")) {
- read_only = true;
+ file_read_only = true;
}
}
}
} else {
if (FileAccess::exists(animation->get_path() + ".import")) {
- read_only = true;
+ file_read_only = true;
}
}
@@ -4612,7 +4612,7 @@ void AnimationTrackEditor::_update_tracks() {
track_edit->set_undo_redo(undo_redo);
track_edit->set_timeline(timeline);
track_edit->set_root(root);
- track_edit->set_animation_and_track(animation, i, read_only);
+ track_edit->set_animation_and_track(animation, i, file_read_only);
track_edit->set_play_position(timeline->get_play_position());
track_edit->set_editor(this);
@@ -5072,10 +5072,8 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
return;
}
- Vector3 scale = base->get_scale();
-
undo_redo->create_action(TTR("Add Scale Key"));
- undo_redo->add_do_method(animation.ptr(), "scale_track_insert_key", p_track, p_ofs, scale);
+ undo_redo->add_do_method(animation.ptr(), "scale_track_insert_key", p_track, p_ofs, base->get_scale());
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", p_track, p_ofs);
undo_redo->commit_action();
@@ -5671,18 +5669,18 @@ void AnimationTrackEditor::goto_prev_step(bool p_from_mouse_event) {
if (animation.is_null()) {
return;
}
- float step = animation->get_step();
- if (step == 0) {
- step = 1;
+ float anim_step = animation->get_step();
+ if (anim_step == 0) {
+ anim_step = 1;
}
if (p_from_mouse_event && Input::get_singleton()->is_key_pressed(Key::SHIFT)) {
// Use more precise snapping when holding Shift.
// This is used when scrobbling the timeline using Alt + Mouse wheel.
- step *= 0.25;
+ anim_step *= 0.25;
}
float pos = timeline->get_play_position();
- pos = Math::snapped(pos - step, step);
+ pos = Math::snapped(pos - anim_step, anim_step);
if (pos < 0) {
pos = 0;
}
@@ -5694,21 +5692,21 @@ void AnimationTrackEditor::goto_next_step(bool p_from_mouse_event, bool p_timeli
if (animation.is_null()) {
return;
}
- float step = animation->get_step();
- if (step == 0) {
- step = 1;
+ float anim_step = animation->get_step();
+ if (anim_step == 0) {
+ anim_step = 1;
}
if (p_from_mouse_event && Input::get_singleton()->is_key_pressed(Key::SHIFT)) {
// Use more precise snapping when holding Shift.
// This is used when scrobbling the timeline using Alt + Mouse wheel.
// Do not use precise snapping when using the menu action or keyboard shortcut,
// as the default keyboard shortcut requires pressing Shift.
- step *= 0.25;
+ anim_step *= 0.25;
}
float pos = timeline->get_play_position();
- pos = Math::snapped(pos + step, step);
+ pos = Math::snapped(pos + anim_step, anim_step);
if (pos > animation->get_length()) {
pos = animation->get_length();
}
@@ -5801,9 +5799,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
} break;
case EDIT_COPY_TRACKS_CONFIRM: {
track_clipboard.clear();
- TreeItem *root = track_copy_select->get_root();
- if (root) {
- TreeItem *it = root->get_first_child();
+ TreeItem *tree_root = track_copy_select->get_root();
+ if (tree_root) {
+ TreeItem *it = tree_root->get_first_child();
while (it) {
Dictionary md = it->get_metadata(0);
int idx = md["track_idx"];
@@ -6037,7 +6035,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
bool is_using_angle = animation->track_get_interpolation_type(track) == Animation::INTERPOLATION_LINEAR_ANGLE || animation->track_get_interpolation_type(track) == Animation::INTERPOLATION_CUBIC_ANGLE;
// Make insert queue.
- Vector<Pair<real_t, Variant>> insert_queue;
+ Vector<Pair<real_t, Variant>> insert_queue_new;
for (int i = 0; i < len; i++) {
// Check neighboring keys.
if (keys[i] + 1 == keys[i + 1]) {
@@ -6058,15 +6056,15 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
Pair<real_t, Variant> keydata;
keydata.first = from_t + delta_t;
keydata.second = Tween::interpolate_variant(from_v, delta_v, delta_t, duration, transition_type, ease_type);
- insert_queue.append(keydata);
+ insert_queue_new.append(keydata);
}
}
}
// Do insertion.
- for (int i = 0; i < insert_queue.size(); i++) {
- undo_redo->add_do_method(animation.ptr(), "track_insert_key", track, insert_queue[i].first, insert_queue[i].second);
- undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", track, insert_queue[i].first);
+ for (int i = 0; i < insert_queue_new.size(); i++) {
+ undo_redo->add_do_method(animation.ptr(), "track_insert_key", track, insert_queue_new[i].first, insert_queue_new[i].second);
+ undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", track, insert_queue_new[i].first);
}
++E;
@@ -6213,7 +6211,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
bool is_using_angle = it == Animation::INTERPOLATION_LINEAR_ANGLE || it == Animation::INTERPOLATION_CUBIC_ANGLE;
// Make insert queue.
- Vector<Pair<real_t, Variant>> insert_queue;
+ Vector<Pair<real_t, Variant>> insert_queue_new;
switch (type) {
case Animation::TYPE_POSITION_3D: {
@@ -6223,7 +6221,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
Vector3 v;
animation->position_track_interpolate(i, delta_t, &v);
keydata.second = v;
- insert_queue.append(keydata);
+ insert_queue_new.append(keydata);
}
} break;
case Animation::TYPE_ROTATION_3D: {
@@ -6233,7 +6231,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
Quaternion v;
animation->rotation_track_interpolate(i, delta_t, &v);
keydata.second = v;
- insert_queue.append(keydata);
+ insert_queue_new.append(keydata);
}
} break;
case Animation::TYPE_SCALE_3D: {
@@ -6243,7 +6241,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
Vector3 v;
animation->scale_track_interpolate(i, delta_t, &v);
keydata.second = v;
- insert_queue.append(keydata);
+ insert_queue_new.append(keydata);
}
} break;
case Animation::TYPE_BLEND_SHAPE: {
@@ -6253,7 +6251,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
float v;
animation->blend_shape_track_interpolate(i, delta_t, &v);
keydata.second = v;
- insert_queue.append(keydata);
+ insert_queue_new.append(keydata);
}
} break;
case Animation::TYPE_VALUE: {
@@ -6261,7 +6259,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
Pair<real_t, Variant> keydata;
keydata.first = delta_t;
keydata.second = animation->value_track_interpolate(i, delta_t);
- insert_queue.append(keydata);
+ insert_queue_new.append(keydata);
}
} break;
default: {
@@ -6276,9 +6274,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
// Insert keys.
undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_type", i, is_using_angle ? Animation::INTERPOLATION_LINEAR_ANGLE : Animation::INTERPOLATION_LINEAR);
- for (int j = insert_queue.size() - 1; j >= 0; j--) {
- undo_redo->add_do_method(animation.ptr(), "track_insert_key", i, insert_queue[j].first, insert_queue[j].second);
- undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", i, insert_queue[j].first);
+ for (int j = insert_queue_new.size() - 1; j >= 0; j--) {
+ undo_redo->add_do_method(animation.ptr(), "track_insert_key", i, insert_queue_new[j].first, insert_queue_new[j].second);
+ undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", i, insert_queue_new[j].first);
}
// Undo methods.
@@ -6460,6 +6458,7 @@ void AnimationTrackEditor::_select_all_tracks_for_copy() {
void AnimationTrackEditor::_bind_methods() {
ClassDB::bind_method("_animation_update", &AnimationTrackEditor::_animation_update);
ClassDB::bind_method("_track_grab_focus", &AnimationTrackEditor::_track_grab_focus);
+ ClassDB::bind_method("_redraw_tracks", &AnimationTrackEditor::_redraw_tracks);
ClassDB::bind_method("_clear_selection_for_anim", &AnimationTrackEditor::_clear_selection_for_anim);
ClassDB::bind_method("_select_at_anim", &AnimationTrackEditor::_select_at_anim);
ClassDB::bind_method("_clear_selection", &AnimationTrackEditor::_clear_selection);
@@ -6925,19 +6924,19 @@ AnimationTrackEditor::AnimationTrackEditor() {
track_copy_dialog->set_title(TTR("Select Tracks to Copy"));
track_copy_dialog->set_ok_button_text(TTR("Copy"));
- VBoxContainer *track_vbox = memnew(VBoxContainer);
- track_copy_dialog->add_child(track_vbox);
+ VBoxContainer *track_copy_vbox = memnew(VBoxContainer);
+ track_copy_dialog->add_child(track_copy_vbox);
Button *select_all_button = memnew(Button);
select_all_button->set_text(TTR("Select All/None"));
select_all_button->connect("pressed", callable_mp(this, &AnimationTrackEditor::_select_all_tracks_for_copy));
- track_vbox->add_child(select_all_button);
+ track_copy_vbox->add_child(select_all_button);
track_copy_select = memnew(Tree);
track_copy_select->set_h_size_flags(SIZE_EXPAND_FILL);
track_copy_select->set_v_size_flags(SIZE_EXPAND_FILL);
track_copy_select->set_hide_root(true);
- track_vbox->add_child(track_copy_select);
+ track_copy_vbox->add_child(track_copy_select);
track_copy_dialog->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_edit_menu_pressed).bind(EDIT_COPY_TRACKS_CONFIRM));
}
diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp
index 6499cf8df2..971b671a0c 100644
--- a/editor/animation_track_editor_plugins.cpp
+++ b/editor/animation_track_editor_plugins.cpp
@@ -412,9 +412,9 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
sf->get_animation_list(&animations);
int frame = get_animation()->track_get_key_value(get_track(), p_index);
- String animation;
+ String animation_name;
if (animations.size() == 1) {
- animation = animations.front()->get();
+ animation_name = animations.front()->get();
} else {
// Go through other track to find if animation is set
String animation_path = get_animation()->track_get_path(get_track());
@@ -422,10 +422,10 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
int animation_track = get_animation()->find_track(animation_path, get_animation()->track_get_type(get_track()));
float track_time = get_animation()->track_get_key_time(get_track(), p_index);
int animaiton_index = get_animation()->track_find_key(animation_track, track_time);
- animation = get_animation()->track_get_key_value(animation_track, animaiton_index);
+ animation_name = get_animation()->track_get_key_value(animation_track, animaiton_index);
}
- Ref<Texture2D> texture = sf->get_frame(animation, frame);
+ Ref<Texture2D> texture = sf->get_frame(animation_name, frame);
if (!texture.is_valid()) {
return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec);
}
@@ -504,9 +504,9 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
sf->get_animation_list(&animations);
int frame = get_animation()->track_get_key_value(get_track(), p_index);
- String animation;
+ String animation_name;
if (animations.size() == 1) {
- animation = animations.front()->get();
+ animation_name = animations.front()->get();
} else {
// Go through other track to find if animation is set
String animation_path = get_animation()->track_get_path(get_track());
@@ -514,10 +514,10 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
int animation_track = get_animation()->find_track(animation_path, get_animation()->track_get_type(get_track()));
float track_time = get_animation()->track_get_key_time(get_track(), p_index);
int animaiton_index = get_animation()->track_find_key(animation_track, track_time);
- animation = get_animation()->track_get_key_value(animation_track, animaiton_index);
+ animation_name = get_animation()->track_get_key_value(animation_track, animaiton_index);
}
- texture = sf->get_frame(animation, frame);
+ texture = sf->get_frame(animation_name, frame);
if (!texture.is_valid()) {
AnimationTrackEdit::draw_key(p_index, p_pixels_sec, p_x, p_selected, p_clip_left, p_clip_right);
return;
@@ -670,15 +670,15 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_
Vector<Vector2> lines;
Vector<Color> colorv;
{
- Ref<Animation> animation = ap->get_animation(anim);
+ Ref<Animation> ap_anim = ap->get_animation(anim);
- for (int i = 0; i < animation->get_track_count(); i++) {
- float h = (rect.size.height - 2) / animation->get_track_count();
+ for (int i = 0; i < ap_anim->get_track_count(); i++) {
+ float h = (rect.size.height - 2) / ap_anim->get_track_count();
int y = 2 + h * i + h / 2;
- for (int j = 0; j < animation->track_get_key_count(i); j++) {
- float ofs = animation->track_get_key_time(i, j);
+ for (int j = 0; j < ap_anim->track_get_key_count(i); j++) {
+ float ofs = ap_anim->track_get_key_time(i, j);
int x = p_x + ofs * p_pixels_sec + 2;
if (x < from_x || x >= (to_x - 4)) {
@@ -1244,15 +1244,15 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec,
Vector<Vector2> lines;
Vector<Color> colorv;
{
- Ref<Animation> animation = ap->get_animation(anim);
+ Ref<Animation> ap_anim = ap->get_animation(anim);
- for (int i = 0; i < animation->get_track_count(); i++) {
- float h = (rect.size.height - 2) / animation->get_track_count();
+ for (int i = 0; i < ap_anim->get_track_count(); i++) {
+ float h = (rect.size.height - 2) / ap_anim->get_track_count();
int y = 2 + h * i + h / 2;
- for (int j = 0; j < animation->track_get_key_count(i); j++) {
- float ofs = animation->track_get_key_time(i, j);
+ for (int j = 0; j < ap_anim->track_get_key_count(i); j++) {
+ float ofs = ap_anim->track_get_key_time(i, j);
int x = p_x + ofs * p_pixels_sec + 2;
if (x < from_x || x >= (to_x - 4)) {
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 11a6912aa5..e328f76545 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -55,6 +55,7 @@ void GotoLineDialog::ok_pressed() {
if (get_line() < 1 || get_line() > 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);
hide();
@@ -149,7 +150,7 @@ bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col)
text_editor->unfold_line(pos.y);
text_editor->set_caret_line(pos.y, false);
text_editor->set_caret_column(pos.x + text.length(), false);
- text_editor->center_viewport_to_caret();
+ text_editor->center_viewport_to_caret(0);
text_editor->select(pos.y, pos.x, pos.y, pos.x + text.length());
line_col_changed_for_result = true;
@@ -176,37 +177,37 @@ bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col)
}
void FindReplaceBar::_replace() {
- bool selection_enabled = text_editor->has_selection();
+ bool selection_enabled = text_editor->has_selection(0);
Point2i selection_begin, selection_end;
if (selection_enabled) {
- selection_begin = Point2i(text_editor->get_selection_from_line(), text_editor->get_selection_from_column());
- selection_end = Point2i(text_editor->get_selection_to_line(), text_editor->get_selection_to_column());
+ selection_begin = Point2i(text_editor->get_selection_from_line(0), text_editor->get_selection_from_column(0));
+ selection_end = Point2i(text_editor->get_selection_to_line(0), text_editor->get_selection_to_column(0));
}
- String replace_text = get_replace_text();
+ String repl_text = get_replace_text();
int search_text_len = get_search_text().length();
text_editor->begin_complex_operation();
if (selection_enabled && is_selection_only()) { // To restrict search_current() to selected region
- text_editor->set_caret_line(selection_begin.width);
- text_editor->set_caret_column(selection_begin.height);
+ text_editor->set_caret_line(selection_begin.width, false, true, 0, 0);
+ text_editor->set_caret_column(selection_begin.height, true, 0);
}
if (search_current()) {
text_editor->unfold_line(result_line);
- text_editor->select(result_line, result_col, result_line, result_col + search_text_len);
+ text_editor->select(result_line, result_col, result_line, result_col + search_text_len, 0);
if (selection_enabled && is_selection_only()) {
Point2i match_from(result_line, result_col);
Point2i match_to(result_line, result_col + search_text_len);
if (!(match_from < selection_begin || match_to > selection_end)) {
- text_editor->insert_text_at_caret(replace_text);
+ text_editor->insert_text_at_caret(repl_text, 0);
if (match_to.x == selection_end.x) { // Adjust selection bounds if necessary
- selection_end.y += replace_text.length() - search_text_len;
+ selection_end.y += repl_text.length() - search_text_len;
}
}
} else {
- text_editor->insert_text_at_caret(replace_text);
+ text_editor->insert_text_at_caret(repl_text, 0);
}
}
text_editor->end_complex_operation();
@@ -216,31 +217,36 @@ void FindReplaceBar::_replace() {
if (selection_enabled && is_selection_only()) {
// Reselect in order to keep 'Replace' restricted to selection
- text_editor->select(selection_begin.x, selection_begin.y, selection_end.x, selection_end.y);
+ text_editor->select(selection_begin.x, selection_begin.y, selection_end.x, selection_end.y, 0);
} else {
- text_editor->deselect();
+ text_editor->deselect(0);
}
}
void FindReplaceBar::_replace_all() {
text_editor->disconnect("text_changed", callable_mp(this, &FindReplaceBar::_editor_text_changed));
// Line as x so it gets priority in comparison, column as y.
- Point2i orig_cursor(text_editor->get_caret_line(), text_editor->get_caret_column());
+ Point2i orig_cursor(text_editor->get_caret_line(0), text_editor->get_caret_column(0));
Point2i prev_match = Point2(-1, -1);
- bool selection_enabled = text_editor->has_selection();
+ bool selection_enabled = text_editor->has_selection(0);
+ if (!is_selection_only()) {
+ text_editor->deselect();
+ selection_enabled = false;
+ } else {
+ result_line = -1;
+ result_col = -1;
+ }
+
Point2i selection_begin, selection_end;
if (selection_enabled) {
- selection_begin = Point2i(text_editor->get_selection_from_line(), text_editor->get_selection_from_column());
- selection_end = Point2i(text_editor->get_selection_to_line(), text_editor->get_selection_to_column());
+ selection_begin = Point2i(text_editor->get_selection_from_line(0), text_editor->get_selection_from_column(0));
+ selection_end = Point2i(text_editor->get_selection_to_line(0), text_editor->get_selection_to_column(0));
}
int vsval = text_editor->get_v_scroll();
- text_editor->set_caret_line(0);
- text_editor->set_caret_column(0);
-
- String replace_text = get_replace_text();
+ String repl_text = get_replace_text();
int search_text_len = get_search_text().length();
int rc = 0;
@@ -250,9 +256,13 @@ void FindReplaceBar::_replace_all() {
text_editor->begin_complex_operation();
if (selection_enabled && is_selection_only()) {
- text_editor->set_caret_line(selection_begin.width);
- text_editor->set_caret_column(selection_begin.height);
+ text_editor->set_caret_line(selection_begin.width, false, true, 0, 0);
+ text_editor->set_caret_column(selection_begin.height, true, 0);
+ } else {
+ text_editor->set_caret_line(0, false, true, 0, 0);
+ text_editor->set_caret_column(0, true, 0);
}
+
if (search_current()) {
do {
// replace area
@@ -263,25 +273,25 @@ void FindReplaceBar::_replace_all() {
break; // Done.
}
- prev_match = Point2i(result_line, result_col + replace_text.length());
+ prev_match = Point2i(result_line, result_col + repl_text.length());
text_editor->unfold_line(result_line);
- text_editor->select(result_line, result_col, result_line, match_to.y);
+ text_editor->select(result_line, result_col, result_line, match_to.y, 0);
- if (selection_enabled && is_selection_only()) {
+ if (selection_enabled) {
if (match_from < selection_begin || match_to > selection_end) {
break; // Done.
}
// Replace but adjust selection bounds.
- text_editor->insert_text_at_caret(replace_text);
+ text_editor->insert_text_at_caret(repl_text, 0);
if (match_to.x == selection_end.x) {
- selection_end.y += replace_text.length() - search_text_len;
+ selection_end.y += repl_text.length() - search_text_len;
}
} else {
// Just replace.
- text_editor->insert_text_at_caret(replace_text);
+ text_editor->insert_text_at_caret(repl_text, 0);
}
rc++;
@@ -293,14 +303,12 @@ void FindReplaceBar::_replace_all() {
replace_all_mode = false;
// Restore editor state (selection, cursor, scroll).
- text_editor->set_caret_line(orig_cursor.x);
- text_editor->set_caret_column(orig_cursor.y);
+ text_editor->set_caret_line(orig_cursor.x, false, true, 0, 0);
+ text_editor->set_caret_column(orig_cursor.y, true, 0);
- if (selection_enabled && is_selection_only()) {
+ if (selection_enabled) {
// Reselect.
- text_editor->select(selection_begin.x, selection_begin.y, selection_end.x, selection_end.y);
- } else {
- text_editor->deselect();
+ text_editor->select(selection_begin.x, selection_begin.y, selection_end.x, selection_end.y, 0);
}
text_editor->set_v_scroll(vsval);
@@ -313,21 +321,28 @@ void FindReplaceBar::_replace_all() {
needs_to_count_results = true;
}
-void FindReplaceBar::_get_search_from(int &r_line, int &r_col) {
- r_line = text_editor->get_caret_line();
- r_col = text_editor->get_caret_column();
+void FindReplaceBar::_get_search_from(int &r_line, int &r_col, bool p_is_searching_next) {
+ if (!text_editor->has_selection(0) || is_selection_only()) {
+ r_line = text_editor->get_caret_line(0);
+ r_col = text_editor->get_caret_column(0);
- if (text_editor->has_selection() && is_selection_only()) {
+ if (!p_is_searching_next && r_line == result_line && r_col >= result_col && r_col <= result_col + get_search_text().length()) {
+ r_col = result_col;
+ }
return;
}
- if (r_line == result_line && r_col >= result_col && r_col <= result_col + get_search_text().length()) {
- r_col = result_col;
+ if (p_is_searching_next) {
+ r_line = text_editor->get_selection_to_line();
+ r_col = text_editor->get_selection_to_column();
+ } else {
+ r_line = text_editor->get_selection_from_line();
+ r_col = text_editor->get_selection_from_column();
}
}
void FindReplaceBar::_update_results_count() {
- if (!needs_to_count_results && (result_line != -1)) {
+ if (!needs_to_count_results && (result_line != -1) && results_count_to_current > 0) {
results_count_to_current += (flags & TextEdit::SEARCH_BACKWARDS) ? -1 : 1;
if (results_count_to_current > results_count) {
@@ -339,9 +354,6 @@ void FindReplaceBar::_update_results_count() {
return;
}
- results_count = 0;
- results_count_to_current = 0;
-
String searched = get_search_text();
if (searched.is_empty()) {
return;
@@ -349,6 +361,8 @@ void FindReplaceBar::_update_results_count() {
needs_to_count_results = false;
+ results_count = 0;
+
for (int i = 0; i < text_editor->get_line_count(); i++) {
String line_text = text_editor->get_line(i);
@@ -372,8 +386,13 @@ void FindReplaceBar::_update_results_count() {
results_count++;
- if (i == result_line && col_pos == result_col) {
- results_count_to_current = results_count;
+ if (i == result_line) {
+ if (col_pos == result_col) {
+ results_count_to_current = results_count;
+ } else if (col_pos < result_col && col_pos + searched.length() > result_col) {
+ col_pos = result_col;
+ results_count_to_current = results_count;
+ }
}
col_pos += searched.length();
@@ -391,10 +410,10 @@ void FindReplaceBar::_update_matches_label() {
if (results_count == 0) {
matches_label->set_text("No match");
- } else if (results_count == 1) {
- matches_label->set_text(vformat(TTR("%d match"), results_count));
+ } else if (results_count_to_current == -1) {
+ matches_label->set_text(vformat(TTRN("%d match", "%d matches", results_count), results_count));
} else {
- matches_label->set_text(vformat(TTR("%d of %d matches"), results_count_to_current, results_count));
+ matches_label->set_text(vformat(TTRN("%d of %d match", "%d of %d matches", results_count), results_count_to_current, results_count));
}
}
}
@@ -416,6 +435,10 @@ bool FindReplaceBar::search_current() {
}
bool FindReplaceBar::search_prev() {
+ if (is_selection_only() && !replace_all_mode) {
+ return false;
+ }
+
if (!is_visible()) {
popup_search(true);
}
@@ -434,9 +457,6 @@ bool FindReplaceBar::search_prev() {
int line, col;
_get_search_from(line, col);
- if (text_editor->has_selection()) {
- col--; // Skip currently selected word.
- }
col -= text.length();
if (col < 0) {
@@ -451,17 +471,15 @@ bool FindReplaceBar::search_prev() {
}
bool FindReplaceBar::search_next() {
+ if (is_selection_only() && !replace_all_mode) {
+ return false;
+ }
+
if (!is_visible()) {
popup_search(true);
}
flags = 0;
- String text;
- if (replace_all_mode) {
- text = get_replace_text();
- } else {
- text = get_search_text();
- }
if (is_whole_words()) {
flags |= TextEdit::SEARCH_WHOLE_WORDS;
@@ -471,18 +489,7 @@ bool FindReplaceBar::search_next() {
}
int line, col;
- _get_search_from(line, col);
-
- if (line == result_line && col == result_col) {
- col += text.length();
- if (col > text_editor->get_line(line).length()) {
- line += 1;
- if (line >= text_editor->get_line_count()) {
- line = 0;
- }
- col = 0;
- }
- }
+ _get_search_from(line, col, true);
return _search(flags, line, col);
}
@@ -512,8 +519,10 @@ void FindReplaceBar::_show_search(bool p_focus_replace, bool p_show_only) {
search_text->call_deferred(SNAME("grab_focus"));
}
- if (text_editor->has_selection() && !selection_only->is_pressed()) {
- search_text->set_text(text_editor->get_selected_text());
+ if (text_editor->has_selection(0) && !is_selection_only()) {
+ search_text->set_text(text_editor->get_selected_text(0));
+ result_line = text_editor->get_selection_from_line();
+ result_col = text_editor->get_selection_from_column();
}
if (!get_search_text().is_empty()) {
@@ -537,6 +546,7 @@ void FindReplaceBar::popup_search(bool p_show_only) {
replace_text->hide();
hbc_button_replace->hide();
hbc_option_replace->hide();
+ selection_only->set_pressed(false);
_show_search(false, p_show_only);
}
@@ -548,9 +558,9 @@ void FindReplaceBar::popup_replace() {
hbc_option_replace->show();
}
- selection_only->set_pressed((text_editor->has_selection() && text_editor->get_selection_from_line() < text_editor->get_selection_to_line()));
+ selection_only->set_pressed((text_editor->has_selection(0) && text_editor->get_selection_from_line(0) < text_editor->get_selection_to_line(0)));
- _show_search(is_visible() || text_editor->has_selection());
+ _show_search(is_visible() || text_editor->has_selection(0));
}
void FindReplaceBar::_search_options_changed(bool p_pressed) {
@@ -587,7 +597,7 @@ void FindReplaceBar::_search_text_submitted(const String &p_text) {
}
void FindReplaceBar::_replace_text_submitted(const String &p_text) {
- if (selection_only->is_pressed() && text_editor->has_selection()) {
+ if (selection_only->is_pressed() && text_editor->has_selection(0)) {
_replace_all();
_hide_bar();
} else if (Input::get_singleton()->is_key_pressed(Key::SHIFT)) {
@@ -1091,6 +1101,7 @@ void CodeTextEditor::trim_trailing_whitespace() {
}
if (trimed_whitespace) {
+ text_editor->merge_overlapping_carets();
text_editor->end_complex_operation();
text_editor->queue_redraw();
}
@@ -1122,8 +1133,11 @@ void CodeTextEditor::convert_indent_to_spaces() {
indent += " ";
}
- int cursor_line = text_editor->get_caret_line();
- int cursor_column = text_editor->get_caret_column();
+ Vector<int> cursor_columns;
+ cursor_columns.resize(text_editor->get_caret_count());
+ for (int c = 0; c < text_editor->get_caret_count(); c++) {
+ cursor_columns.write[c] = text_editor->get_caret_column(c);
+ }
bool changed_indentation = false;
for (int i = 0; i < text_editor->get_line_count(); i++) {
@@ -1140,8 +1154,10 @@ void CodeTextEditor::convert_indent_to_spaces() {
text_editor->begin_complex_operation();
changed_indentation = true;
}
- if (cursor_line == i && cursor_column > j) {
- cursor_column += indent_size - 1;
+ for (int c = 0; c < text_editor->get_caret_count(); c++) {
+ if (text_editor->get_caret_line(c) == i && text_editor->get_caret_column(c) > j) {
+ cursor_columns.write[c] += indent_size - 1;
+ }
}
line = line.left(j) + indent + line.substr(j + 1);
}
@@ -1152,7 +1168,10 @@ void CodeTextEditor::convert_indent_to_spaces() {
}
}
if (changed_indentation) {
- text_editor->set_caret_column(cursor_column);
+ for (int c = 0; c < text_editor->get_caret_count(); c++) {
+ text_editor->set_caret_column(cursor_columns[c], c == 0, c);
+ }
+ text_editor->merge_overlapping_carets();
text_editor->end_complex_operation();
text_editor->queue_redraw();
}
@@ -1162,8 +1181,11 @@ void CodeTextEditor::convert_indent_to_tabs() {
int indent_size = EditorSettings::get_singleton()->get("text_editor/behavior/indent/size");
indent_size -= 1;
- int cursor_line = text_editor->get_caret_line();
- int cursor_column = text_editor->get_caret_column();
+ Vector<int> cursor_columns;
+ cursor_columns.resize(text_editor->get_caret_count());
+ for (int c = 0; c < text_editor->get_caret_count(); c++) {
+ cursor_columns.write[c] = text_editor->get_caret_column(c);
+ }
bool changed_indentation = false;
for (int i = 0; i < text_editor->get_line_count(); i++) {
@@ -1184,8 +1206,10 @@ void CodeTextEditor::convert_indent_to_tabs() {
text_editor->begin_complex_operation();
changed_indentation = true;
}
- if (cursor_line == i && cursor_column > j) {
- cursor_column -= indent_size;
+ for (int c = 0; c < text_editor->get_caret_count(); c++) {
+ if (text_editor->get_caret_line(c) == i && text_editor->get_caret_column(c) > j) {
+ cursor_columns.write[c] -= indent_size;
+ }
}
line = line.left(j - indent_size) + "\t" + line.substr(j + 1);
j = 0;
@@ -1201,7 +1225,10 @@ void CodeTextEditor::convert_indent_to_tabs() {
}
}
if (changed_indentation) {
- text_editor->set_caret_column(cursor_column);
+ for (int c = 0; c < text_editor->get_caret_count(); c++) {
+ text_editor->set_caret_column(cursor_columns[c], c == 0, c);
+ }
+ text_editor->merge_overlapping_carets();
text_editor->end_complex_operation();
text_editor->queue_redraw();
}
@@ -1211,59 +1238,128 @@ void CodeTextEditor::convert_case(CaseStyle p_case) {
if (!text_editor->has_selection()) {
return;
}
-
text_editor->begin_complex_operation();
- int begin = text_editor->get_selection_from_line();
- int end = text_editor->get_selection_to_line();
- int begin_col = text_editor->get_selection_from_column();
- int end_col = text_editor->get_selection_to_column();
-
- for (int i = begin; i <= end; i++) {
- int len = text_editor->get_line(i).length();
- if (i == end) {
- len = end_col;
- }
- if (i == begin) {
- len -= begin_col;
+ Vector<int> caret_edit_order = text_editor->get_caret_index_edit_order();
+ for (const int &c : caret_edit_order) {
+ if (!text_editor->has_selection(c)) {
+ continue;
}
- String new_line = text_editor->get_line(i).substr(i == begin ? begin_col : 0, len);
- switch (p_case) {
- case UPPER: {
- new_line = new_line.to_upper();
- } break;
- case LOWER: {
- new_line = new_line.to_lower();
- } break;
- case CAPITALIZE: {
- new_line = new_line.capitalize();
- } break;
- }
+ int begin = text_editor->get_selection_from_line(c);
+ int end = text_editor->get_selection_to_line(c);
+ int begin_col = text_editor->get_selection_from_column(c);
+ int end_col = text_editor->get_selection_to_column(c);
- if (i == begin) {
- new_line = text_editor->get_line(i).left(begin_col) + new_line;
- }
- if (i == end) {
- new_line = new_line + text_editor->get_line(i).substr(end_col);
+ for (int i = begin; i <= end; i++) {
+ int len = text_editor->get_line(i).length();
+ if (i == end) {
+ len = end_col;
+ }
+ if (i == begin) {
+ len -= begin_col;
+ }
+ String new_line = text_editor->get_line(i).substr(i == begin ? begin_col : 0, len);
+
+ switch (p_case) {
+ case UPPER: {
+ new_line = new_line.to_upper();
+ } break;
+ case LOWER: {
+ new_line = new_line.to_lower();
+ } break;
+ case CAPITALIZE: {
+ new_line = new_line.capitalize();
+ } break;
+ }
+
+ if (i == begin) {
+ new_line = text_editor->get_line(i).left(begin_col) + new_line;
+ }
+ if (i == end) {
+ new_line = new_line + text_editor->get_line(i).substr(end_col);
+ }
+ text_editor->set_line(i, new_line);
}
- text_editor->set_line(i, new_line);
}
text_editor->end_complex_operation();
}
void CodeTextEditor::move_lines_up() {
text_editor->begin_complex_operation();
- if (text_editor->has_selection()) {
- int from_line = text_editor->get_selection_from_line();
- int from_col = text_editor->get_selection_from_column();
- int to_line = text_editor->get_selection_to_line();
- int to_column = text_editor->get_selection_to_column();
- int cursor_line = text_editor->get_caret_line();
- for (int i = from_line; i <= to_line; i++) {
- int line_id = i;
- int next_id = i - 1;
+ Vector<int> carets_to_remove;
+
+ Vector<int> caret_edit_order = text_editor->get_caret_index_edit_order();
+ for (int i = 0; i < caret_edit_order.size(); i++) {
+ int c = caret_edit_order[i];
+ int cl = text_editor->get_caret_line(c);
+
+ bool swaped_caret = false;
+ for (int j = i + 1; j < caret_edit_order.size(); j++) {
+ if (text_editor->has_selection(caret_edit_order[j])) {
+ if (text_editor->get_selection_from_line() == cl) {
+ carets_to_remove.push_back(caret_edit_order[j]);
+ continue;
+ }
+
+ if (text_editor->get_selection_to_line() == cl) {
+ if (text_editor->has_selection(c)) {
+ if (text_editor->get_selection_to_line(c) != cl) {
+ text_editor->select(cl + 1, 0, text_editor->get_selection_to_line(c), text_editor->get_selection_to_column(c), c);
+ break;
+ }
+ }
+
+ carets_to_remove.push_back(c);
+ i = j - 1;
+ swaped_caret = true;
+ break;
+ }
+ break;
+ }
+
+ if (text_editor->get_caret_line(caret_edit_order[j]) == cl) {
+ carets_to_remove.push_back(caret_edit_order[j]);
+ i = j;
+ continue;
+ }
+ break;
+ }
+
+ if (swaped_caret) {
+ continue;
+ }
+
+ if (text_editor->has_selection(c)) {
+ int from_line = text_editor->get_selection_from_line(c);
+ int from_col = text_editor->get_selection_from_column(c);
+ int to_line = text_editor->get_selection_to_line(c);
+ int to_column = text_editor->get_selection_to_column(c);
+ int cursor_line = text_editor->get_caret_line(c);
+
+ for (int j = from_line; j <= to_line; j++) {
+ int line_id = j;
+ int next_id = j - 1;
+
+ if (line_id == 0 || next_id < 0) {
+ return;
+ }
+
+ text_editor->unfold_line(line_id);
+ text_editor->unfold_line(next_id);
+
+ text_editor->swap_lines(line_id, next_id);
+ text_editor->set_caret_line(next_id, c == 0, true, 0, c);
+ }
+ int from_line_up = from_line > 0 ? from_line - 1 : from_line;
+ int to_line_up = to_line > 0 ? to_line - 1 : to_line;
+ int cursor_line_up = cursor_line > 0 ? cursor_line - 1 : cursor_line;
+ text_editor->select(from_line_up, from_col, to_line_up, to_column, c);
+ text_editor->set_caret_line(cursor_line_up, c == 0, true, 0, c);
+ } else {
+ int line_id = text_editor->get_caret_line(c);
+ int next_id = line_id - 1;
if (line_id == 0 || next_id < 0) {
return;
@@ -1273,238 +1369,336 @@ void CodeTextEditor::move_lines_up() {
text_editor->unfold_line(next_id);
text_editor->swap_lines(line_id, next_id);
- text_editor->set_caret_line(next_id);
- }
- int from_line_up = from_line > 0 ? from_line - 1 : from_line;
- int to_line_up = to_line > 0 ? to_line - 1 : to_line;
- int cursor_line_up = cursor_line > 0 ? cursor_line - 1 : cursor_line;
- text_editor->select(from_line_up, from_col, to_line_up, to_column);
- text_editor->set_caret_line(cursor_line_up);
- } else {
- int line_id = text_editor->get_caret_line();
- int next_id = line_id - 1;
-
- if (line_id == 0 || next_id < 0) {
- return;
+ text_editor->set_caret_line(next_id, c == 0, true, 0, c);
}
-
- text_editor->unfold_line(line_id);
- text_editor->unfold_line(next_id);
-
- text_editor->swap_lines(line_id, next_id);
- text_editor->set_caret_line(next_id);
}
text_editor->end_complex_operation();
+ text_editor->merge_overlapping_carets();
text_editor->queue_redraw();
}
void CodeTextEditor::move_lines_down() {
text_editor->begin_complex_operation();
- if (text_editor->has_selection()) {
- int from_line = text_editor->get_selection_from_line();
- int from_col = text_editor->get_selection_from_column();
- int to_line = text_editor->get_selection_to_line();
- int to_column = text_editor->get_selection_to_column();
- int cursor_line = text_editor->get_caret_line();
- for (int i = to_line; i >= from_line; i--) {
- int line_id = i;
- int next_id = i + 1;
+ Vector<int> carets_to_remove;
+
+ Vector<int> caret_edit_order = text_editor->get_caret_index_edit_order();
+ for (int i = 0; i < caret_edit_order.size(); i++) {
+ int c = caret_edit_order[i];
+ int cl = text_editor->get_caret_line(c);
+
+ bool swaped_caret = false;
+ for (int j = i + 1; j < caret_edit_order.size(); j++) {
+ if (text_editor->has_selection(caret_edit_order[j])) {
+ if (text_editor->get_selection_from_line() == cl) {
+ carets_to_remove.push_back(caret_edit_order[j]);
+ continue;
+ }
+
+ if (text_editor->get_selection_to_line() == cl) {
+ if (text_editor->has_selection(c)) {
+ if (text_editor->get_selection_to_line(c) != cl) {
+ text_editor->select(cl + 1, 0, text_editor->get_selection_to_line(c), text_editor->get_selection_to_column(c), c);
+ break;
+ }
+ }
+
+ carets_to_remove.push_back(c);
+ i = j - 1;
+ swaped_caret = true;
+ break;
+ }
+ break;
+ }
+
+ if (text_editor->get_caret_line(caret_edit_order[j]) == cl) {
+ carets_to_remove.push_back(caret_edit_order[j]);
+ i = j;
+ continue;
+ }
+ break;
+ }
+
+ if (swaped_caret) {
+ continue;
+ }
+
+ if (text_editor->has_selection(c)) {
+ int from_line = text_editor->get_selection_from_line(c);
+ int from_col = text_editor->get_selection_from_column(c);
+ int to_line = text_editor->get_selection_to_line(c);
+ int to_column = text_editor->get_selection_to_column(c);
+ int cursor_line = text_editor->get_caret_line(c);
+
+ for (int l = to_line; l >= from_line; l--) {
+ int line_id = l;
+ int next_id = l + 1;
+
+ if (line_id == text_editor->get_line_count() - 1 || next_id > text_editor->get_line_count()) {
+ continue;
+ }
+
+ text_editor->unfold_line(line_id);
+ text_editor->unfold_line(next_id);
+
+ text_editor->swap_lines(line_id, next_id);
+ text_editor->set_caret_line(next_id, c == 0, true, 0, c);
+ }
+ int from_line_down = from_line < text_editor->get_line_count() ? from_line + 1 : from_line;
+ int to_line_down = to_line < text_editor->get_line_count() ? to_line + 1 : to_line;
+ int cursor_line_down = cursor_line < text_editor->get_line_count() ? cursor_line + 1 : cursor_line;
+ text_editor->select(from_line_down, from_col, to_line_down, to_column, c);
+ text_editor->set_caret_line(cursor_line_down, c == 0, true, 0, c);
+ } else {
+ int line_id = text_editor->get_caret_line(c);
+ int next_id = line_id + 1;
if (line_id == text_editor->get_line_count() - 1 || next_id > text_editor->get_line_count()) {
- return;
+ continue;
}
text_editor->unfold_line(line_id);
text_editor->unfold_line(next_id);
text_editor->swap_lines(line_id, next_id);
- text_editor->set_caret_line(next_id);
- }
- int from_line_down = from_line < text_editor->get_line_count() ? from_line + 1 : from_line;
- int to_line_down = to_line < text_editor->get_line_count() ? to_line + 1 : to_line;
- int cursor_line_down = cursor_line < text_editor->get_line_count() ? cursor_line + 1 : cursor_line;
- text_editor->select(from_line_down, from_col, to_line_down, to_column);
- text_editor->set_caret_line(cursor_line_down);
- } else {
- int line_id = text_editor->get_caret_line();
- int next_id = line_id + 1;
-
- if (line_id == text_editor->get_line_count() - 1 || next_id > text_editor->get_line_count()) {
- return;
+ text_editor->set_caret_line(next_id, c == 0, true, 0, c);
}
+ }
- text_editor->unfold_line(line_id);
- text_editor->unfold_line(next_id);
-
- text_editor->swap_lines(line_id, next_id);
- text_editor->set_caret_line(next_id);
+ // Sort and remove backwards to preserve indexes.
+ carets_to_remove.sort();
+ for (int i = carets_to_remove.size() - 1; i >= 0; i--) {
+ text_editor->remove_caret(carets_to_remove[i]);
}
+
+ text_editor->merge_overlapping_carets();
text_editor->end_complex_operation();
text_editor->queue_redraw();
}
-void CodeTextEditor::_delete_line(int p_line) {
+void CodeTextEditor::_delete_line(int p_line, int p_caret) {
// this is currently intended to be called within delete_lines()
// so `begin_complex_operation` is omitted here
text_editor->set_line(p_line, "");
if (p_line == 0 && text_editor->get_line_count() > 1) {
- text_editor->set_caret_line(1);
- text_editor->set_caret_column(0);
+ text_editor->set_caret_line(1, p_caret == 0, true, 0, p_caret);
+ text_editor->set_caret_column(0, p_caret == 0, p_caret);
}
- text_editor->backspace();
+ text_editor->backspace(p_caret);
if (p_line < text_editor->get_line_count()) {
text_editor->unfold_line(p_line);
}
- text_editor->set_caret_line(p_line);
+ text_editor->set_caret_line(p_line, p_caret == 0, true, 0, p_caret);
}
void CodeTextEditor::delete_lines() {
text_editor->begin_complex_operation();
- if (text_editor->has_selection()) {
- int to_line = text_editor->get_selection_to_line();
- int from_line = text_editor->get_selection_from_line();
- int count = Math::abs(to_line - from_line) + 1;
- text_editor->set_caret_line(from_line, false);
- text_editor->deselect();
- for (int i = 0; i < count; i++) {
- _delete_line(from_line);
+ Vector<int> carets_to_remove;
+
+ Vector<int> caret_edit_order = text_editor->get_caret_index_edit_order();
+ for (int i = 0; i < caret_edit_order.size(); i++) {
+ int c = caret_edit_order[i];
+ int cl = text_editor->get_caret_line(c);
+
+ bool swaped_caret = false;
+ for (int j = i + 1; j < caret_edit_order.size(); j++) {
+ if (text_editor->has_selection(caret_edit_order[j])) {
+ if (text_editor->get_selection_from_line() == cl) {
+ carets_to_remove.push_back(caret_edit_order[j]);
+ continue;
+ }
+
+ if (text_editor->get_selection_to_line() == cl) {
+ if (text_editor->has_selection(c)) {
+ if (text_editor->get_selection_to_line(c) != cl) {
+ text_editor->select(cl + 1, 0, text_editor->get_selection_to_line(c), text_editor->get_selection_to_column(c), c);
+ break;
+ }
+ }
+
+ carets_to_remove.push_back(c);
+ i = j - 1;
+ swaped_caret = true;
+ break;
+ }
+ break;
+ }
+
+ if (text_editor->get_caret_line(caret_edit_order[j]) == cl) {
+ carets_to_remove.push_back(caret_edit_order[j]);
+ i = j;
+ continue;
+ }
+ break;
}
- } else {
- _delete_line(text_editor->get_caret_line());
+
+ if (swaped_caret) {
+ continue;
+ }
+
+ if (text_editor->has_selection(c)) {
+ int to_line = text_editor->get_selection_to_line(c);
+ int from_line = text_editor->get_selection_from_line(c);
+ int count = Math::abs(to_line - from_line) + 1;
+
+ text_editor->set_caret_line(from_line, false, true, 0, c);
+ text_editor->deselect(c);
+ for (int j = 0; j < count; j++) {
+ _delete_line(from_line, c);
+ }
+ } else {
+ _delete_line(text_editor->get_caret_line(c), c);
+ }
+ }
+
+ // Sort and remove backwards to preserve indexes.
+ carets_to_remove.sort();
+ for (int i = carets_to_remove.size() - 1; i >= 0; i--) {
+ text_editor->remove_caret(carets_to_remove[i]);
}
+ text_editor->merge_overlapping_carets();
text_editor->end_complex_operation();
}
void CodeTextEditor::duplicate_selection() {
- const int cursor_column = text_editor->get_caret_column();
- int from_line = text_editor->get_caret_line();
- int to_line = text_editor->get_caret_line();
- int from_column = 0;
- int to_column = 0;
- int cursor_new_line = to_line + 1;
- int cursor_new_column = text_editor->get_caret_column();
- String new_text = "\n" + text_editor->get_line(from_line);
- bool selection_active = false;
-
- text_editor->set_caret_column(text_editor->get_line(from_line).length());
- if (text_editor->has_selection()) {
- from_column = text_editor->get_selection_from_column();
- to_column = text_editor->get_selection_to_column();
-
- from_line = text_editor->get_selection_from_line();
- to_line = text_editor->get_selection_to_line();
- cursor_new_line = to_line + text_editor->get_caret_line() - from_line;
- cursor_new_column = to_column == cursor_column ? 2 * to_column - from_column : to_column;
- new_text = text_editor->get_selected_text();
- selection_active = true;
-
- text_editor->set_caret_line(to_line);
- text_editor->set_caret_column(to_column);
- }
-
text_editor->begin_complex_operation();
- for (int i = from_line; i <= to_line; i++) {
- text_editor->unfold_line(i);
- }
- text_editor->deselect();
- text_editor->insert_text_at_caret(new_text);
- text_editor->set_caret_line(cursor_new_line);
- text_editor->set_caret_column(cursor_new_column);
- if (selection_active) {
- text_editor->select(to_line, to_column, 2 * to_line - from_line, to_line == from_line ? 2 * to_column - from_column : to_column);
- }
+ Vector<int> caret_edit_order = text_editor->get_caret_index_edit_order();
+ for (const int &c : caret_edit_order) {
+ const int cursor_column = text_editor->get_caret_column(c);
+ int from_line = text_editor->get_caret_line(c);
+ int to_line = text_editor->get_caret_line(c);
+ int from_column = 0;
+ int to_column = 0;
+ int cursor_new_line = to_line + 1;
+ int cursor_new_column = text_editor->get_caret_column(c);
+ String new_text = "\n" + text_editor->get_line(from_line);
+ bool selection_active = false;
+
+ text_editor->set_caret_column(text_editor->get_line(from_line).length(), c == 0, c);
+ if (text_editor->has_selection(c)) {
+ from_column = text_editor->get_selection_from_column(c);
+ to_column = text_editor->get_selection_to_column(c);
+
+ from_line = text_editor->get_selection_from_line(c);
+ to_line = text_editor->get_selection_to_line(c);
+ cursor_new_line = to_line + text_editor->get_caret_line(c) - from_line;
+ cursor_new_column = to_column == cursor_column ? 2 * to_column - from_column : to_column;
+ new_text = text_editor->get_selected_text(c);
+ selection_active = true;
+
+ text_editor->set_caret_line(to_line, c == 0, true, 0, c);
+ text_editor->set_caret_column(to_column, c == 0, c);
+ }
+ for (int i = from_line; i <= to_line; i++) {
+ text_editor->unfold_line(i);
+ }
+ text_editor->deselect(c);
+ text_editor->insert_text_at_caret(new_text, c);
+ text_editor->set_caret_line(cursor_new_line, c == 0, true, 0, c);
+ text_editor->set_caret_column(cursor_new_column, c == 0, c);
+ if (selection_active) {
+ text_editor->select(to_line, to_column, 2 * to_line - from_line, to_line == from_line ? 2 * to_column - from_column : to_column, c);
+ }
+ }
+ text_editor->merge_overlapping_carets();
text_editor->end_complex_operation();
text_editor->queue_redraw();
}
void CodeTextEditor::toggle_inline_comment(const String &delimiter) {
text_editor->begin_complex_operation();
- if (text_editor->has_selection()) {
- int begin = text_editor->get_selection_from_line();
- int end = text_editor->get_selection_to_line();
- // End of selection ends on the first column of the last line, ignore it.
- if (text_editor->get_selection_to_column() == 0) {
- end -= 1;
- }
+ Vector<int> caret_edit_order = text_editor->get_caret_index_edit_order();
+ for (const int &c : caret_edit_order) {
+ if (text_editor->has_selection(c)) {
+ int begin = text_editor->get_selection_from_line(c);
+ int end = text_editor->get_selection_to_line(c);
- int col_to = text_editor->get_selection_to_column();
- int cursor_pos = text_editor->get_caret_column();
+ // End of selection ends on the first column of the last line, ignore it.
+ if (text_editor->get_selection_to_column(c) == 0) {
+ end -= 1;
+ }
- // Check if all lines in the selected block are commented.
- bool is_commented = true;
- for (int i = begin; i <= end; i++) {
- if (!text_editor->get_line(i).begins_with(delimiter)) {
- is_commented = false;
- break;
+ int col_to = text_editor->get_selection_to_column(c);
+ int cursor_pos = text_editor->get_caret_column(c);
+
+ // Check if all lines in the selected block are commented.
+ bool is_commented = true;
+ for (int i = begin; i <= end; i++) {
+ if (!text_editor->get_line(i).begins_with(delimiter)) {
+ is_commented = false;
+ break;
+ }
}
- }
- for (int i = begin; i <= end; i++) {
- String line_text = text_editor->get_line(i);
+ for (int i = begin; i <= end; i++) {
+ String line_text = text_editor->get_line(i);
- if (line_text.strip_edges().is_empty()) {
- line_text = delimiter;
- } else {
- if (is_commented) {
- line_text = line_text.substr(delimiter.length(), line_text.length());
+ if (line_text.strip_edges().is_empty()) {
+ line_text = delimiter;
} else {
- line_text = delimiter + line_text;
+ if (is_commented) {
+ line_text = line_text.substr(delimiter.length(), line_text.length());
+ } else {
+ line_text = delimiter + line_text;
+ }
}
+ text_editor->set_line(i, line_text);
}
- text_editor->set_line(i, line_text);
- }
- // Adjust selection & cursor position.
- int offset = (is_commented ? -1 : 1) * delimiter.length();
- int col_from = text_editor->get_selection_from_column() > 0 ? text_editor->get_selection_from_column() + offset : 0;
+ // Adjust selection & cursor position.
+ int offset = (is_commented ? -1 : 1) * delimiter.length();
+ int col_from = text_editor->get_selection_from_column(c) > 0 ? text_editor->get_selection_from_column(c) + offset : 0;
- if (is_commented && text_editor->get_caret_column() == text_editor->get_line(text_editor->get_caret_line()).length() + 1) {
- cursor_pos += 1;
- }
+ if (is_commented && text_editor->get_caret_column(c) == text_editor->get_line(text_editor->get_caret_line(c)).length() + 1) {
+ cursor_pos += 1;
+ }
- if (text_editor->get_selection_to_column() != 0 && col_to != text_editor->get_line(text_editor->get_selection_to_line()).length() + 1) {
- col_to += offset;
- }
+ if (text_editor->get_selection_to_column(c) != 0 && col_to != text_editor->get_line(text_editor->get_selection_to_line(c)).length() + 1) {
+ col_to += offset;
+ }
- if (text_editor->get_caret_column() != 0) {
- cursor_pos += offset;
- }
+ if (text_editor->get_caret_column(c) != 0) {
+ cursor_pos += offset;
+ }
- text_editor->select(begin, col_from, text_editor->get_selection_to_line(), col_to);
- text_editor->set_caret_column(cursor_pos);
+ text_editor->select(begin, col_from, text_editor->get_selection_to_line(c), col_to, c);
+ text_editor->set_caret_column(cursor_pos, c == 0, c);
- } else {
- int begin = text_editor->get_caret_line();
- String line_text = text_editor->get_line(begin);
- int delimiter_length = delimiter.length();
-
- int col = text_editor->get_caret_column();
- if (line_text.begins_with(delimiter)) {
- line_text = line_text.substr(delimiter_length, line_text.length());
- col -= delimiter_length;
} else {
- line_text = delimiter + line_text;
- col += delimiter_length;
- }
+ int begin = text_editor->get_caret_line(c);
+ String line_text = text_editor->get_line(begin);
+ int delimiter_length = delimiter.length();
+
+ int col = text_editor->get_caret_column(c);
+ if (line_text.begins_with(delimiter)) {
+ line_text = line_text.substr(delimiter_length, line_text.length());
+ col -= delimiter_length;
+ } else {
+ line_text = delimiter + line_text;
+ col += delimiter_length;
+ }
- text_editor->set_line(begin, line_text);
- text_editor->set_caret_column(col);
+ text_editor->set_line(begin, line_text);
+ text_editor->set_caret_column(col, c == 0, c);
+ }
}
+ text_editor->merge_overlapping_carets();
text_editor->end_complex_operation();
text_editor->queue_redraw();
}
void CodeTextEditor::goto_line(int p_line) {
+ text_editor->remove_secondary_carets();
text_editor->deselect();
text_editor->unfold_line(p_line);
text_editor->call_deferred(SNAME("set_caret_line"), p_line);
}
void CodeTextEditor::goto_line_selection(int p_line, int p_begin, int p_end) {
+ text_editor->remove_secondary_carets();
text_editor->unfold_line(p_line);
text_editor->call_deferred(SNAME("set_caret_line"), p_line);
text_editor->call_deferred(SNAME("set_caret_column"), p_begin);
@@ -1526,19 +1720,7 @@ void CodeTextEditor::clear_executing_line() {
Variant CodeTextEditor::get_edit_state() {
Dictionary state;
-
- state["scroll_position"] = text_editor->get_v_scroll();
- state["h_scroll_position"] = text_editor->get_h_scroll();
- state["column"] = text_editor->get_caret_column();
- state["row"] = text_editor->get_caret_line();
-
- state["selection"] = get_text_editor()->has_selection();
- if (get_text_editor()->has_selection()) {
- state["selection_from_line"] = text_editor->get_selection_from_line();
- state["selection_from_column"] = text_editor->get_selection_from_column();
- state["selection_to_line"] = text_editor->get_selection_to_line();
- state["selection_to_column"] = text_editor->get_selection_to_column();
- }
+ state.merge(get_navigation_state());
state["folded_lines"] = text_editor->get_folded_lines();
state["breakpoints"] = text_editor->get_breakpointed_lines();
@@ -1559,8 +1741,10 @@ void CodeTextEditor::set_edit_state(const Variant &p_state) {
text_editor->set_v_scroll(state["scroll_position"]);
text_editor->set_h_scroll(state["h_scroll_position"]);
- if (state.has("selection")) {
+ if (state.get("selection", false)) {
text_editor->select(state["selection_from_line"], state["selection_from_column"], state["selection_to_line"], state["selection_to_column"]);
+ } else {
+ text_editor->deselect();
}
if (state.has("folded_lines")) {
@@ -1585,6 +1769,25 @@ void CodeTextEditor::set_edit_state(const Variant &p_state) {
}
}
+Variant CodeTextEditor::get_navigation_state() {
+ Dictionary state;
+
+ state["scroll_position"] = text_editor->get_v_scroll();
+ state["h_scroll_position"] = text_editor->get_h_scroll();
+ state["column"] = text_editor->get_caret_column();
+ state["row"] = text_editor->get_caret_line();
+
+ state["selection"] = get_text_editor()->has_selection();
+ if (get_text_editor()->has_selection()) {
+ state["selection_from_line"] = text_editor->get_selection_from_line();
+ state["selection_from_column"] = text_editor->get_selection_from_column();
+ state["selection_to_line"] = text_editor->get_selection_to_line();
+ state["selection_to_column"] = text_editor->get_selection_to_column();
+ }
+
+ return state;
+}
+
void CodeTextEditor::set_error(const String &p_error) {
error->set_text(p_error);
if (!p_error.is_empty()) {
@@ -1608,6 +1811,7 @@ void CodeTextEditor::goto_error() {
if (text_editor->get_line_count() != error_line) {
text_editor->unfold_line(error_line);
}
+ text_editor->remove_secondary_carets();
text_editor->set_caret_line(error_line);
text_editor->set_caret_column(error_column);
text_editor->center_viewport_to_caret();
@@ -1784,8 +1988,10 @@ void CodeTextEditor::set_warning_count(int p_warning_count) {
}
void CodeTextEditor::toggle_bookmark() {
- int line = text_editor->get_caret_line();
- text_editor->set_line_as_bookmarked(line, !text_editor->is_line_bookmarked(line));
+ for (int i = 0; i < text_editor->get_caret_count(); i++) {
+ int line = text_editor->get_caret_line(i);
+ text_editor->set_line_as_bookmarked(line, !text_editor->is_line_bookmarked(line));
+ }
}
void CodeTextEditor::goto_next_bookmark() {
@@ -1794,6 +2000,7 @@ void CodeTextEditor::goto_next_bookmark() {
return;
}
+ text_editor->remove_secondary_carets();
int line = text_editor->get_caret_line();
if (line >= (int)bmarks[bmarks.size() - 1]) {
text_editor->unfold_line(bmarks[0]);
@@ -1818,6 +2025,7 @@ void CodeTextEditor::goto_prev_bookmark() {
return;
}
+ text_editor->remove_secondary_carets();
int line = text_editor->get_caret_line();
if (line <= (int)bmarks[0]) {
text_editor->unfold_line(bmarks[bmarks.size() - 1]);
diff --git a/editor/code_editor.h b/editor/code_editor.h
index 49679cc700..ded7518287 100644
--- a/editor/code_editor.h
+++ b/editor/code_editor.h
@@ -92,7 +92,7 @@ class FindReplaceBar : public HBoxContainer {
bool replace_all_mode = false;
bool preserve_cursor = false;
- void _get_search_from(int &r_line, int &r_col);
+ void _get_search_from(int &r_line, int &r_col, bool p_is_searching_next = false);
void _update_results_count();
void _update_matches_label();
@@ -197,7 +197,7 @@ class CodeTextEditor : public VBoxContainer {
void _update_status_bar_theme();
- void _delete_line(int p_line);
+ void _delete_line(int p_line, int p_caret);
void _toggle_scripts_pressed();
protected:
@@ -246,6 +246,7 @@ public:
Variant get_edit_state();
void set_edit_state(const Variant &p_state);
+ Variant get_navigation_state();
void set_error_count(int p_error_count);
void set_warning_count(int p_warning_count);
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index ddeb8643b8..2105a101d8 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -160,6 +160,9 @@ void ConnectDialog::_tree_node_selected() {
}
dst_path = source->get_path_to(current);
+ if (!edit_mode) {
+ set_dst_method(generate_method_callback_name(source, signal, current));
+ }
_update_ok_enabled();
}
@@ -184,8 +187,8 @@ void ConnectDialog::_add_bind() {
Variant::Type type = (Variant::Type)type_list->get_item_id(type_list->get_selected());
Variant value;
- Callable::CallError error;
- Variant::construct(type, value, nullptr, 0, error);
+ Callable::CallError err;
+ Variant::construct(type, value, nullptr, 0, err);
cdbinds->params.push_back(value);
cdbinds->notify_changed();
@@ -205,6 +208,45 @@ void ConnectDialog::_remove_bind() {
cdbinds->params.remove_at(idx);
cdbinds->notify_changed();
}
+/*
+ * Automatically generates a name for the callback method.
+ */
+StringName ConnectDialog::generate_method_callback_name(Node *p_source, String p_signal_name, Node *p_target) {
+ String node_name = p_source->get_name();
+ for (int i = 0; i < node_name.length(); i++) { // TODO: Regex filter may be cleaner.
+ char32_t c = node_name[i];
+ if (!is_ascii_identifier_char(c)) {
+ if (c == ' ') {
+ // Replace spaces with underlines.
+ c = '_';
+ } else {
+ // Remove any other characters.
+ node_name.remove_at(i);
+ i--;
+ continue;
+ }
+ }
+ node_name[i] = c;
+ }
+
+ Dictionary subst;
+ subst["NodeName"] = node_name.to_pascal_case();
+ subst["nodeName"] = node_name.to_camel_case();
+ subst["node_name"] = node_name.to_snake_case();
+
+ subst["SignalName"] = p_signal_name.to_pascal_case();
+ subst["signalName"] = p_signal_name.to_camel_case();
+ subst["signal_name"] = p_signal_name.to_snake_case();
+
+ String dst_method;
+ if (p_source == p_target) {
+ dst_method = String(EDITOR_GET("interface/editors/default_signal_callback_to_self_name")).format(subst);
+ } else {
+ dst_method = String(EDITOR_GET("interface/editors/default_signal_callback_name")).format(subst);
+ }
+
+ return dst_method;
+}
/*
* Enables or disables the connect button. The connect button is enabled if a
@@ -371,6 +413,7 @@ void ConnectDialog::popup_dialog(const String &p_for_signal) {
first_popup = false;
_advanced_pressed();
}
+
popup_centered();
}
@@ -583,19 +626,19 @@ void ConnectionsDock::_make_or_edit_connection() {
// Conditions to add function: must have a script and must not have the method already
// (in the class, the script itself, or inherited).
bool add_script_function = false;
- Ref<Script> script = target->get_script();
- if (!target->get_script().is_null() && !ClassDB::has_method(target->get_class(), cd.method)) {
+ Ref<Script> scr = target->get_script();
+ if (!scr.is_null() && !ClassDB::has_method(target->get_class(), cd.method)) {
// There is a chance that the method is inherited from another script.
bool found_inherited_function = false;
- Ref<Script> inherited_script = script->get_base_script();
- while (!inherited_script.is_null()) {
- int line = inherited_script->get_language()->find_function(cd.method, inherited_script->get_source_code());
+ Ref<Script> inherited_scr = scr->get_base_script();
+ while (!inherited_scr.is_null()) {
+ int line = inherited_scr->get_language()->find_function(cd.method, inherited_scr->get_source_code());
if (line != -1) {
found_inherited_function = true;
break;
}
- inherited_script = inherited_script->get_base_script();
+ inherited_scr = inherited_scr->get_base_script();
}
add_script_function = !found_inherited_function;
@@ -743,43 +786,17 @@ bool ConnectionsDock::_is_item_signal(TreeItem &p_item) {
void ConnectionsDock::_open_connection_dialog(TreeItem &p_item) {
String signal_name = p_item.get_metadata(0).operator Dictionary()["name"];
const String &signal_name_ref = signal_name;
- String node_name = selected_node->get_name();
- for (int i = 0; i < node_name.length(); i++) { // TODO: Regex filter may be cleaner.
- char32_t c = node_name[i];
- if (!is_ascii_identifier_char(c)) {
- if (c == ' ') {
- // Replace spaces with underlines.
- c = '_';
- } else {
- // Remove any other characters.
- node_name.remove_at(i);
- i--;
- continue;
- }
- }
- node_name[i] = c;
- }
Node *dst_node = selected_node->get_owner() ? selected_node->get_owner() : selected_node;
if (!dst_node || dst_node->get_script().is_null()) {
dst_node = _find_first_script(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root());
}
- Dictionary subst;
- subst["NodeName"] = node_name.to_pascal_case();
- subst["nodeName"] = node_name.to_camel_case();
- subst["node_name"] = node_name.to_snake_case();
- subst["SignalName"] = signal_name.to_pascal_case();
- subst["signalName"] = signal_name.to_camel_case();
- subst["signal_name"] = signal_name.to_snake_case();
-
- String dst_method = String(EDITOR_GET("interface/editors/default_signal_callback_name")).format(subst);
-
ConnectDialog::ConnectionData cd;
cd.source = selected_node;
cd.signal = StringName(signal_name_ref);
cd.target = dst_node;
- cd.method = StringName(dst_method);
+ cd.method = ConnectDialog::generate_method_callback_name(cd.source, signal_name, cd.target);
connect_dialog->popup_dialog(signal_name_ref);
connect_dialog->init(cd);
connect_dialog->set_title(TTR("Connect a Signal to a Method"));
@@ -816,13 +833,13 @@ void ConnectionsDock::_go_to_script(TreeItem &p_item) {
return;
}
- Ref<Script> script = cd.target->get_script();
+ Ref<Script> scr = cd.target->get_script();
- if (script.is_null()) {
+ if (scr.is_null()) {
return;
}
- if (script.is_valid() && ScriptEditor::get_singleton()->script_goto_method(script, cd.method)) {
+ if (scr.is_valid() && ScriptEditor::get_singleton()->script_goto_method(scr, cd.method)) {
EditorNode::get_singleton()->editor_select(EditorNode::EDITOR_SCRIPT);
}
}
@@ -1077,10 +1094,10 @@ void ConnectionsDock::update_tree() {
}
// List existing connections.
- List<Object::Connection> connections;
- selected_node->get_signal_connection_list(signal_name, &connections);
+ List<Object::Connection> existing_connections;
+ selected_node->get_signal_connection_list(signal_name, &existing_connections);
- for (const Object::Connection &F : connections) {
+ for (const Object::Connection &F : existing_connections) {
Connection connection = F;
if (!(connection.flags & CONNECT_PERSIST)) {
continue;
@@ -1187,6 +1204,7 @@ ConnectionsDock::ConnectionsDock() {
add_theme_constant_override("separation", 3 * EDSCALE);
EDITOR_DEF("interface/editors/default_signal_callback_name", "_on_{node_name}_{signal_name}");
+ EDITOR_DEF("interface/editors/default_signal_callback_to_self_name", "_on_{signal_name}");
}
ConnectionsDock::~ConnectionsDock() {
diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h
index db2f855617..16a60306aa 100644
--- a/editor/connections_dialog.h
+++ b/editor/connections_dialog.h
@@ -144,6 +144,7 @@ protected:
static void _bind_methods();
public:
+ static StringName generate_method_callback_name(Node *p_source, String p_signal_name, Node *p_target);
Node *get_source() const;
StringName get_signal_name() const;
NodePath get_dst_path() const;
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index 3e72c6211d..7a4e58c6f9 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -126,10 +126,6 @@ bool CreateDialog::_should_hide_type(const String &p_type) const {
return true; // Do not show editor nodes.
}
- if (p_type == base_type && !EditorNode::get_editor_data().get_custom_types().has(p_type)) {
- return true; // Root is already added.
- }
-
if (ClassDB::class_exists(p_type)) {
if (!ClassDB::can_instantiate(p_type) || ClassDB::is_virtual(p_type)) {
return true; // Can't create abstract or virtual class.
@@ -217,18 +213,18 @@ void CreateDialog::_add_type(const String &p_type, const TypeCategory p_type_cat
inherited_type = TypeCategory::CPP_TYPE;
} else if (p_type_category == TypeCategory::PATH_TYPE) {
ERR_FAIL_COND(!ResourceLoader::exists(p_type, "Script"));
- Ref<Script> script = ResourceLoader::load(p_type, "Script");
- ERR_FAIL_COND(script.is_null());
+ Ref<Script> scr = ResourceLoader::load(p_type, "Script");
+ ERR_FAIL_COND(scr.is_null());
- Ref<Script> base = script->get_base_script();
+ Ref<Script> base = scr->get_base_script();
if (base.is_null()) {
String extends;
- script->get_language()->get_global_class_name(script->get_path(), &extends);
+ scr->get_language()->get_global_class_name(scr->get_path(), &extends);
inherits = extends;
inherited_type = TypeCategory::CPP_TYPE;
} else {
- inherits = script->get_language()->get_global_class_name(base->get_path());
+ inherits = scr->get_language()->get_global_class_name(base->get_path());
if (inherits.is_empty()) {
inherits = base->get_path();
inherited_type = TypeCategory::PATH_TYPE;
@@ -236,18 +232,18 @@ void CreateDialog::_add_type(const String &p_type, const TypeCategory p_type_cat
}
} else {
if (ScriptServer::is_global_class(p_type)) {
- Ref<Script> script = EditorNode::get_editor_data().script_class_load_script(p_type);
- ERR_FAIL_COND(script.is_null());
+ Ref<Script> scr = EditorNode::get_editor_data().script_class_load_script(p_type);
+ ERR_FAIL_COND(scr.is_null());
- Ref<Script> base = script->get_base_script();
+ Ref<Script> base = scr->get_base_script();
if (base.is_null()) {
String extends;
- script->get_language()->get_global_class_name(script->get_path(), &extends);
+ scr->get_language()->get_global_class_name(scr->get_path(), &extends);
inherits = extends;
inherited_type = TypeCategory::CPP_TYPE;
} else {
- inherits = script->get_language()->get_global_class_name(base->get_path());
+ inherits = scr->get_language()->get_global_class_name(base->get_path());
if (inherits.is_empty()) {
inherits = base->get_path();
inherited_type = TypeCategory::PATH_TYPE;
@@ -343,6 +339,11 @@ String CreateDialog::_top_result(const Vector<String> p_candidates, const String
}
float CreateDialog::_score_type(const String &p_type, const String &p_search) const {
+ if (p_type == p_search) {
+ // Always favor an exact match (case-sensitive), since clicking a favorite will set the search text to the type.
+ return 1.0f;
+ }
+
float inverse_length = 1.f / float(p_type.length());
// Favor types where search term is a substring close to the start of the type.
@@ -351,13 +352,13 @@ float CreateDialog::_score_type(const String &p_type, const String &p_search) co
float score = (pos > -1) ? 1.0f - w * MIN(1, 3 * pos * inverse_length) : MAX(0.f, .9f - w);
// Favor shorter items: they resemble the search term more.
- w = 0.1f;
- score *= (1 - w) + w * (p_search.length() * inverse_length);
+ w = 0.9f;
+ score *= (1 - w) + w * MIN(1.0f, p_search.length() * inverse_length);
- score *= _is_type_preferred(p_type) ? 1.0f : 0.8f;
+ score *= _is_type_preferred(p_type) ? 1.0f : 0.9f;
// Add score for being a favorite type.
- score *= (favorite_list.find(p_type) > -1) ? 1.0f : 0.7f;
+ score *= (favorite_list.find(p_type) > -1) ? 1.0f : 0.8f;
// Look through at most 5 recent items
bool in_recent = false;
@@ -367,7 +368,7 @@ float CreateDialog::_score_type(const String &p_type, const String &p_search) co
break;
}
}
- score *= in_recent ? 1.0f : 0.8f;
+ score *= in_recent ? 1.0f : 0.9f;
return score;
}
@@ -751,9 +752,7 @@ CreateDialog::CreateDialog() {
favorites->connect("cell_selected", callable_mp(this, &CreateDialog::_favorite_selected));
favorites->connect("item_activated", callable_mp(this, &CreateDialog::_favorite_activated));
favorites->add_theme_constant_override("draw_guides", 1);
-#ifndef _MSC_VER
-#warning cannot forward drag data to a non control, must be fixed
-#endif
+ // Cannot forward drag data to a non control, must be fixed.
//favorites->set_drag_forwarding(this);
fav_vb->add_margin_child(TTR("Favorites:"), favorites, true);
diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp
index 4c445eb766..ae8752eb6d 100644
--- a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp
+++ b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp
@@ -656,7 +656,7 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) {
bool DebugAdapterProtocol::process_message(const String &p_text) {
JSON json;
- ERR_FAIL_COND_V_MSG(json.parse(p_text) != OK, true, "Mal-formed message!");
+ ERR_FAIL_COND_V_MSG(json.parse(p_text) != OK, true, "Malformed message!");
Dictionary params = json.get_data();
bool completed = true;
@@ -921,11 +921,11 @@ void DebugAdapterProtocol::on_debug_stack_frame_vars(const int &p_size) {
ERR_FAIL_COND(!stackframe_list.has(frame));
List<int> scope_ids = stackframe_list.find(frame)->value;
for (List<int>::Element *E = scope_ids.front(); E; E = E->next()) {
- int variable_id = E->get();
- if (variable_list.has(variable_id)) {
- variable_list.find(variable_id)->value.clear();
+ int var_id = E->get();
+ if (variable_list.has(var_id)) {
+ variable_list.find(var_id)->value.clear();
} else {
- variable_list.insert(variable_id, Array());
+ variable_list.insert(var_id, Array());
}
}
}
@@ -941,7 +941,7 @@ void DebugAdapterProtocol::on_debug_stack_frame_var(const Array &p_data) {
List<int> scope_ids = stackframe_list.find(frame)->value;
ERR_FAIL_COND(scope_ids.size() != 3);
ERR_FAIL_INDEX(stack_var.type, 3);
- int variable_id = scope_ids[stack_var.type];
+ int var_id = scope_ids[stack_var.type];
DAP::Variable variable;
@@ -950,7 +950,7 @@ void DebugAdapterProtocol::on_debug_stack_frame_var(const Array &p_data) {
variable.type = Variant::get_type_name(stack_var.value.get_type());
variable.variablesReference = parse_variant(stack_var.value);
- variable_list.find(variable_id)->value.push_back(variable.to_json());
+ variable_list.find(var_id)->value.push_back(variable.to_json());
_remaining_vars--;
}
diff --git a/editor/debugger/debug_adapter/debug_adapter_server.cpp b/editor/debugger/debug_adapter/debug_adapter_server.cpp
index 41e6b1f308..37da64beae 100644
--- a/editor/debugger/debug_adapter/debug_adapter_server.cpp
+++ b/editor/debugger/debug_adapter/debug_adapter_server.cpp
@@ -64,10 +64,10 @@ void DebugAdapterServer::_notification(int p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
protocol._request_timeout = EditorSettings::get_singleton()->get("network/debug_adapter/request_timeout");
protocol._sync_breakpoints = EditorSettings::get_singleton()->get("network/debug_adapter/sync_breakpoints");
- int remote_port = (int)_EDITOR_GET("network/debug_adapter/remote_port");
- if (remote_port != this->remote_port) {
- this->stop();
- this->start();
+ int port = (int)_EDITOR_GET("network/debug_adapter/remote_port");
+ if (port != remote_port) {
+ stop();
+ start();
}
} break;
}
diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp
index 7ea6cedd2b..371aaf8617 100644
--- a/editor/debugger/editor_debugger_inspector.cpp
+++ b/editor/debugger/editor_debugger_inspector.cpp
@@ -166,11 +166,11 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) {
if (pinfo.hint_string == "Script") {
if (debug_obj->get_script() != var) {
debug_obj->set_script(Ref<RefCounted>());
- Ref<Script> script(var);
- if (!script.is_null()) {
- ScriptInstance *script_instance = script->placeholder_instance_create(debug_obj);
- if (script_instance) {
- debug_obj->set_script_and_instance(var, script_instance);
+ Ref<Script> scr(var);
+ if (!scr.is_null()) {
+ ScriptInstance *scr_instance = scr->placeholder_instance_create(debug_obj);
+ if (scr_instance) {
+ debug_obj->set_script_and_instance(var, scr_instance);
}
}
}
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp
index 9fd7fa578f..06b73cf296 100644
--- a/editor/debugger/editor_debugger_node.cpp
+++ b/editor/debugger/editor_debugger_node.cpp
@@ -477,13 +477,10 @@ void EditorDebuggerNode::_menu_option(int p_id) {
}
void EditorDebuggerNode::_update_debug_options() {
- bool keep_debugger_open = EditorSettings::get_singleton()->get_project_metadata("debug_options", "keep_debugger_open", false);
- bool debug_with_external_editor = EditorSettings::get_singleton()->get_project_metadata("debug_options", "debug_with_external_editor", false);
-
- if (keep_debugger_open) {
+ if (EditorSettings::get_singleton()->get_project_metadata("debug_options", "keep_debugger_open", false).operator bool()) {
_menu_option(DEBUG_KEEP_DEBUGGER_OPEN);
}
- if (debug_with_external_editor) {
+ if (EditorSettings::get_singleton()->get_project_metadata("debug_options", "debug_with_external_editor", false).operator bool()) {
_menu_option(DEBUG_WITH_EXTERNAL_EDITOR);
}
}
diff --git a/editor/debugger/editor_performance_profiler.cpp b/editor/debugger/editor_performance_profiler.cpp
index 10b50a81e4..e2fd462f3a 100644
--- a/editor/debugger/editor_performance_profiler.cpp
+++ b/editor/debugger/editor_performance_profiler.cpp
@@ -349,12 +349,12 @@ void EditorPerformanceProfiler::update_monitors(const Vector<StringName> &p_name
void EditorPerformanceProfiler::add_profile_frame(const Vector<float> &p_values) {
for (KeyValue<StringName, Monitor> &E : monitors) {
- float data = 0.0f;
+ float value = 0.0f;
if (E.value.frame_index >= 0 && E.value.frame_index < p_values.size()) {
- data = p_values[E.value.frame_index];
+ value = p_values[E.value.frame_index];
}
- E.value.history.push_front(data);
- E.value.update_value(data);
+ E.value.history.push_front(value);
+ E.value.update_value(value);
}
marker_frame++;
monitor_draw->queue_redraw();
diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp
index 6bc1536cb9..f1fc1019b9 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -747,8 +747,8 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
if (element) {
Callable &c = element->value;
ERR_FAIL_COND_MSG(c.is_null(), "Invalid callable registered: " + cap);
- Variant cmd = p_msg.substr(colon_index + 1), data = p_data;
- const Variant *args[2] = { &cmd, &data };
+ Variant cmd = p_msg.substr(colon_index + 1), cmd_data = p_data;
+ const Variant *args[2] = { &cmd, &cmd_data };
Variant retval;
Callable::CallError err;
c.callp(args, 2, retval, err);
@@ -895,9 +895,9 @@ void ScriptEditorDebugger::_clear_execution() {
}
void ScriptEditorDebugger::_set_breakpoint(const String &p_file, const int &p_line, const bool &p_enabled) {
- Ref<Script> script = ResourceLoader::load(p_file);
- emit_signal(SNAME("set_breakpoint"), script, p_line - 1, p_enabled);
- script.unref();
+ Ref<Script> scr = ResourceLoader::load(p_file);
+ emit_signal(SNAME("set_breakpoint"), scr, p_line - 1, p_enabled);
+ scr.unref();
}
void ScriptEditorDebugger::_clear_breakpoints() {
@@ -979,15 +979,15 @@ void ScriptEditorDebugger::stop() {
}
void ScriptEditorDebugger::_profiler_activate(bool p_enable, int p_type) {
- Array data;
- data.push_back(p_enable);
+ Array msg_data;
+ msg_data.push_back(p_enable);
switch (p_type) {
case PROFILER_NETWORK:
- _put_msg("profiler:multiplayer", data);
- _put_msg("profiler:rpc", data);
+ _put_msg("profiler:multiplayer", msg_data);
+ _put_msg("profiler:rpc", msg_data);
break;
case PROFILER_VISUAL:
- _put_msg("profiler:visual", data);
+ _put_msg("profiler:visual", msg_data);
break;
case PROFILER_SCRIPTS_SERVERS:
if (p_enable) {
@@ -997,9 +997,9 @@ void ScriptEditorDebugger::_profiler_activate(bool p_enable, int p_type) {
Array opts;
int max_funcs = EditorSettings::get_singleton()->get("debugger/profiler_frame_max_functions");
opts.push_back(CLAMP(max_funcs, 16, 512));
- data.push_back(opts);
+ msg_data.push_back(opts);
}
- _put_msg("profiler:servers", data);
+ _put_msg("profiler:servers", msg_data);
break;
default:
ERR_FAIL_MSG("Invalid profiler type");
@@ -1563,8 +1563,22 @@ void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) {
ti = ti->get_parent();
}
- // We only need the first child here (C++ source stack trace).
+ // Find the child with the "C++ Source".
+ // It's not at a fixed position as "C++ Error" may come first.
TreeItem *ci = ti->get_first_child();
+ const String cpp_source = "<" + TTR("C++ Source") + ">";
+ while (ci) {
+ if (ci->get_text(0) == cpp_source) {
+ break;
+ }
+ ci = ci->get_next();
+ }
+
+ if (!ci) {
+ WARN_PRINT_ED("No C++ source reference is available for this error.");
+ return;
+ }
+
// Parse back the `file:line @ method()` string.
const Vector<String> file_line_number = ci->get_text(1).split("@")[0].strip_edges().split(":");
ERR_FAIL_COND_MSG(file_line_number.size() < 2, "Incorrect C++ source stack trace file:line format (please report).");
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index b0ea289bbe..9064329d1f 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -792,14 +792,14 @@ void OrphanResourcesDialog::show() {
popup_centered_ratio(0.4);
}
-void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &paths) {
+void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &r_paths) {
while (p_item) {
if (p_item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK && p_item->is_checked(0)) {
- paths.push_back(p_item->get_metadata(0));
+ r_paths.push_back(p_item->get_metadata(0));
}
if (p_item->get_first_child()) {
- _find_to_delete(p_item->get_first_child(), paths);
+ _find_to_delete(p_item->get_first_child(), r_paths);
}
p_item = p_item->get_next();
diff --git a/editor/dependency_editor.h b/editor/dependency_editor.h
index 6e39015ec3..7a523457ef 100644
--- a/editor/dependency_editor.h
+++ b/editor/dependency_editor.h
@@ -165,7 +165,7 @@ class OrphanResourcesDialog : public ConfirmationDialog {
bool _fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent);
List<String> paths;
- void _find_to_delete(TreeItem *p_item, List<String> &paths);
+ void _find_to_delete(TreeItem *p_item, List<String> &r_paths);
void _delete_confirm();
void _button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp
index aaa5956c17..77697f4de1 100644
--- a/editor/editor_asset_installer.cpp
+++ b/editor/editor_asset_installer.cpp
@@ -183,16 +183,16 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
int pp = path.rfind("/");
- TreeItem *parent;
+ TreeItem *parent_item;
if (pp == -1) {
- parent = root;
+ parent_item = root;
} else {
String ppath = path.substr(0, pp);
ERR_CONTINUE(!dir_map.has(ppath));
- parent = dir_map[ppath];
+ parent_item = dir_map[ppath];
}
- TreeItem *ti = tree->create_item(parent);
+ TreeItem *ti = tree->create_item(parent_item);
ti->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
ti->set_checked(0, true);
ti->set_editable(0, true);
@@ -284,17 +284,17 @@ void EditorAssetInstaller::ok_pressed() {
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
da->make_dir(dirpath);
} else {
- Vector<uint8_t> data;
- data.resize(info.uncompressed_size);
+ Vector<uint8_t> uncomp_data;
+ uncomp_data.resize(info.uncompressed_size);
//read
unzOpenCurrentFile(pkg);
- unzReadCurrentFile(pkg, data.ptrw(), data.size());
+ unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size());
unzCloseCurrentFile(pkg);
Ref<FileAccess> f = FileAccess::open(path, FileAccess::WRITE);
if (f.is_valid()) {
- f->store_buffer(data.ptr(), data.size());
+ f->store_buffer(uncomp_data.ptr(), uncomp_data.size());
} else {
failed_files.push_back(path);
}
diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp
index 09dce869c9..83deff1469 100644
--- a/editor/editor_audio_buses.cpp
+++ b/editor/editor_audio_buses.cpp
@@ -919,10 +919,10 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
effect_options = memnew(PopupMenu);
effect_options->connect("index_pressed", callable_mp(this, &EditorAudioBus::_effect_add));
add_child(effect_options);
- List<StringName> effects;
- ClassDB::get_inheriters_from_class("AudioEffect", &effects);
- effects.sort_custom<StringName::AlphCompare>();
- for (const StringName &E : effects) {
+ List<StringName> effect_list;
+ ClassDB::get_inheriters_from_class("AudioEffect", &effect_list);
+ effect_list.sort_custom<StringName::AlphCompare>();
+ for (const StringName &E : effect_list) {
if (!ClassDB::can_instantiate(E) || ClassDB::is_virtual(E)) {
continue;
}
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index 544b6c7141..98f21bda7a 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -222,15 +222,15 @@ void EditorAutoloadSettings::_autoload_edited() {
name = "autoload/" + name;
int order = ProjectSettings::get_singleton()->get_order(selected_autoload);
- String path = ProjectSettings::get_singleton()->get(selected_autoload);
+ String scr_path = ProjectSettings::get_singleton()->get(selected_autoload);
undo_redo->create_action(TTR("Rename Autoload"));
- undo_redo->add_do_property(ProjectSettings::get_singleton(), name, path);
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), name, scr_path);
undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", name, order);
undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", selected_autoload);
- undo_redo->add_undo_property(ProjectSettings::get_singleton(), selected_autoload, path);
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), selected_autoload, scr_path);
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", selected_autoload, order);
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "clear", name);
@@ -250,20 +250,20 @@ void EditorAutoloadSettings::_autoload_edited() {
String base = "autoload/" + ti->get_text(0);
int order = ProjectSettings::get_singleton()->get_order(base);
- String path = ProjectSettings::get_singleton()->get(base);
+ String scr_path = ProjectSettings::get_singleton()->get(base);
- if (path.begins_with("*")) {
- path = path.substr(1, path.length());
+ if (scr_path.begins_with("*")) {
+ scr_path = scr_path.substr(1, scr_path.length());
}
// Singleton autoloads are represented with a leading "*" in their path.
if (checked) {
- path = "*" + path;
+ scr_path = "*" + scr_path;
}
undo_redo->create_action(TTR("Toggle Autoload Globals"));
- undo_redo->add_do_property(ProjectSettings::get_singleton(), base, path);
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), base, scr_path);
undo_redo->add_undo_property(ProjectSettings::get_singleton(), base, ProjectSettings::get_singleton()->get(base));
undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", base, order);
@@ -404,11 +404,11 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {
ERR_FAIL_COND_V_MSG(res.is_null(), nullptr, "Can't autoload: " + p_path + ".");
Node *n = nullptr;
Ref<PackedScene> scn = res;
- Ref<Script> script = res;
+ Ref<Script> scr = res;
if (scn.is_valid()) {
n = scn->instantiate();
- } else if (script.is_valid()) {
- StringName ibt = script->get_instance_base_type();
+ } else if (scr.is_valid()) {
+ StringName ibt = scr->get_instance_base_type();
bool valid_type = ClassDB::is_parent_class(ibt, "Node");
ERR_FAIL_COND_V_MSG(!valid_type, nullptr, "Script does not inherit from Node: " + p_path + ".");
@@ -417,7 +417,7 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {
ERR_FAIL_COND_V_MSG(!obj, nullptr, "Cannot instance script for Autoload, expected 'Node' inheritance, got: " + String(ibt) + ".");
n = Object::cast_to<Node>(obj);
- n->set_script(script);
+ n->set_script(scr);
}
ERR_FAIL_COND_V_MSG(!n, nullptr, "Path in Autoload not a node or script: " + p_path + ".");
@@ -453,21 +453,21 @@ void EditorAutoloadSettings::update_autoload() {
}
String name = pi.name.get_slice("/", 1);
- String path = ProjectSettings::get_singleton()->get(pi.name);
+ String scr_path = ProjectSettings::get_singleton()->get(pi.name);
if (name.is_empty()) {
continue;
}
AutoloadInfo info;
- info.is_singleton = path.begins_with("*");
+ info.is_singleton = scr_path.begins_with("*");
if (info.is_singleton) {
- path = path.substr(1, path.length());
+ scr_path = scr_path.substr(1, scr_path.length());
}
info.name = name;
- info.path = path;
+ info.path = scr_path;
info.order = ProjectSettings::get_singleton()->get_order(pi.name);
bool need_to_add = true;
@@ -499,7 +499,7 @@ void EditorAutoloadSettings::update_autoload() {
item->set_text(0, name);
item->set_editable(0, true);
- item->set_text(1, path);
+ item->set_text(1, scr_path);
item->set_selectable(1, true);
item->set_cell_mode(2, TreeItem::CELL_MODE_CHECK);
@@ -745,13 +745,12 @@ bool EditorAutoloadSettings::autoload_add(const String &p_name, const String &p_
return false;
}
- const String &path = p_path;
- if (!FileAccess::exists(path)) {
+ if (!FileAccess::exists(p_path)) {
EditorNode::get_singleton()->show_warning(TTR("Can't add Autoload:") + "\n" + vformat(TTR("%s is an invalid path. File does not exist."), path));
return false;
}
- if (!path.begins_with("res://")) {
+ if (!p_path.begins_with("res://")) {
EditorNode::get_singleton()->show_warning(TTR("Can't add Autoload:") + "\n" + vformat(TTR("%s is an invalid path. Not in resource path (res://)."), path));
return false;
}
@@ -762,7 +761,7 @@ bool EditorAutoloadSettings::autoload_add(const String &p_name, const String &p_
undo_redo->create_action(TTR("Add Autoload"));
// Singleton autoloads are represented with a leading "*" in their path.
- undo_redo->add_do_property(ProjectSettings::get_singleton(), name, "*" + path);
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), name, "*" + p_path);
if (ProjectSettings::get_singleton()->has_setting(name)) {
undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, ProjectSettings::get_singleton()->get(name));
@@ -829,21 +828,21 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
}
String name = pi.name.get_slice("/", 1);
- String path = ProjectSettings::get_singleton()->get(pi.name);
+ String scr_path = ProjectSettings::get_singleton()->get(pi.name);
if (name.is_empty()) {
continue;
}
AutoloadInfo info;
- info.is_singleton = path.begins_with("*");
+ info.is_singleton = scr_path.begins_with("*");
if (info.is_singleton) {
- path = path.substr(1, path.length());
+ scr_path = scr_path.substr(1, scr_path.length());
}
info.name = name;
- info.path = path;
+ info.path = scr_path;
info.order = ProjectSettings::get_singleton()->get_order(pi.name);
if (info.is_singleton) {
diff --git a/editor/editor_build_profile.cpp b/editor/editor_build_profile.cpp
index 0f0ab4a339..7fd27692b0 100644
--- a/editor/editor_build_profile.cpp
+++ b/editor/editor_build_profile.cpp
@@ -255,8 +255,7 @@ Error EditorBuildProfile::save_to_file(const String &p_path) {
Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::WRITE);
ERR_FAIL_COND_V_MSG(f.is_null(), ERR_CANT_CREATE, "Cannot create file '" + p_path + "'.");
- JSON json;
- String text = json.stringify(data, "\t");
+ String text = JSON::stringify(data, "\t");
f->store_string(text);
return OK;
}
diff --git a/editor/editor_command_palette.h b/editor/editor_command_palette.h
index b3e84771d0..15200552b4 100644
--- a/editor/editor_command_palette.h
+++ b/editor/editor_command_palette.h
@@ -66,7 +66,11 @@ class EditorCommandPalette : public ConfirmationDialog {
struct CommandHistoryComparator {
_FORCE_INLINE_ bool operator()(const CommandEntry &A, const CommandEntry &B) const {
- return A.last_used > B.last_used;
+ if (A.last_used == B.last_used) {
+ return A.display_name < B.display_name;
+ } else {
+ return A.last_used > B.last_used;
+ }
}
};
diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp
index 9fa08a0adb..ab252a7ff1 100644
--- a/editor/editor_file_dialog.cpp
+++ b/editor/editor_file_dialog.cpp
@@ -1023,10 +1023,10 @@ void EditorFileDialog::set_current_path(const String &p_path) {
if (pos == -1) {
set_current_file(p_path);
} else {
- String dir = p_path.substr(0, pos);
- String file = p_path.substr(pos + 1, p_path.length());
- set_current_dir(dir);
- set_current_file(file);
+ String path_dir = p_path.substr(0, pos);
+ String path_file = p_path.substr(pos + 1, p_path.length());
+ set_current_dir(path_dir);
+ set_current_file(path_file);
}
}
@@ -1614,26 +1614,26 @@ void EditorFileDialog::set_default_display_mode(DisplayMode p_mode) {
}
void EditorFileDialog::_save_to_recent() {
- String dir = get_current_dir();
- Vector<String> recent = EditorSettings::get_singleton()->get_recent_dirs();
+ String cur_dir = get_current_dir();
+ Vector<String> recent_new = EditorSettings::get_singleton()->get_recent_dirs();
const int max = 20;
int count = 0;
- bool res = dir.begins_with("res://");
+ bool res = cur_dir.begins_with("res://");
- for (int i = 0; i < recent.size(); i++) {
- bool cres = recent[i].begins_with("res://");
- if (recent[i] == dir || (res == cres && count > max)) {
- recent.remove_at(i);
+ for (int i = 0; i < recent_new.size(); i++) {
+ bool cres = recent_new[i].begins_with("res://");
+ if (recent_new[i] == cur_dir || (res == cres && count > max)) {
+ recent_new.remove_at(i);
i--;
} else {
count++;
}
}
- recent.insert(0, dir);
+ recent_new.insert(0, cur_dir);
- EditorSettings::get_singleton()->set_recent_dirs(recent);
+ EditorSettings::get_singleton()->set_recent_dirs(recent_new);
}
void EditorFileDialog::set_disable_overwrite_warning(bool p_disable) {
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 9153640115..c28bb18891 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -919,11 +919,11 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, Ref<DirAc
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
ScriptLanguage *lang = ScriptServer::get_language(i);
if (lang->supports_documentation() && fi->type == lang->get_type()) {
- Ref<Script> script = ResourceLoader::load(path);
- if (script == nullptr) {
+ Ref<Script> scr = ResourceLoader::load(path);
+ if (scr == nullptr) {
continue;
}
- Vector<DocData::ClassDoc> docs = script->get_documentation();
+ Vector<DocData::ClassDoc> docs = scr->get_documentation();
for (int j = 0; j < docs.size(); j++) {
EditorHelp::get_doc_data()->add_doc(docs[j]);
}
@@ -1902,8 +1902,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const HashMap<String
List<String> import_variants;
List<String> gen_files;
- Variant metadata;
- Error err = importer->import(p_file, base_path, params, &import_variants, &gen_files, &metadata);
+ Variant meta;
+ Error err = importer->import(p_file, base_path, params, &import_variants, &gen_files, &meta);
if (err != OK) {
ERR_PRINT("Error importing '" + p_file + "'.");
@@ -1955,8 +1955,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const HashMap<String
f->store_line("valid=false");
}
- if (metadata != Variant()) {
- f->store_line("metadata=" + metadata.get_construct_string());
+ if (meta != Variant()) {
+ f->store_line("metadata=" + meta.get_construct_string());
}
f->store_line("");
@@ -2108,11 +2108,11 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
reimport_files.sort();
- bool use_threads = GLOBAL_GET("editor/import/use_multiple_threads");
+ bool use_multiple_threads = GLOBAL_GET("editor/import/use_multiple_threads");
int from = 0;
for (int i = 0; i < reimport_files.size(); i++) {
- if (use_threads && reimport_files[i].threaded) {
+ if (use_multiple_threads && reimport_files[i].threaded) {
if (i + 1 == reimport_files.size() || reimport_files[i + 1].importer != reimport_files[from].importer) {
if (from - i == 0) {
//single file, do not use threads
@@ -2124,16 +2124,16 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
importer->import_threaded_begin();
- ImportThreadData data;
- data.max_index = from;
- data.reimport_from = from;
- data.reimport_files = reimport_files.ptr();
+ ImportThreadData tdata;
+ tdata.max_index = from;
+ tdata.reimport_from = from;
+ tdata.reimport_files = reimport_files.ptr();
- WorkerThreadPool::GroupID group_task = WorkerThreadPool::get_singleton()->add_template_group_task(this, &EditorFileSystem::_reimport_thread, &data, i - from + 1, -1, false, vformat(TTR("Import resources of type: %s"), reimport_files[from].importer));
+ WorkerThreadPool::GroupID group_task = WorkerThreadPool::get_singleton()->add_template_group_task(this, &EditorFileSystem::_reimport_thread, &tdata, i - from + 1, -1, false, vformat(TTR("Import resources of type: %s"), reimport_files[from].importer));
int current_index = from - 1;
do {
- if (current_index < data.max_index) {
- current_index = data.max_index;
+ if (current_index < tdata.max_index) {
+ current_index = tdata.max_index;
pr.step(reimport_files[current_index].path.get_file(), current_index);
}
OS::get_singleton()->delay_usec(1);
@@ -2259,7 +2259,7 @@ void EditorFileSystem::move_group_file(const String &p_path, const String &p_new
ResourceUID::ID EditorFileSystem::_resource_saver_get_resource_id_for_path(const String &p_path, bool p_generate) {
if (!p_path.is_resource_file() || p_path.begins_with(ProjectSettings::get_singleton()->get_project_data_path())) {
- //saved externally (configuration file) or internal file, do not assign an ID.
+ // Saved externally (configuration file) or internal file, do not assign an ID.
return ResourceUID::INVALID_ID;
}
@@ -2267,15 +2267,21 @@ ResourceUID::ID EditorFileSystem::_resource_saver_get_resource_id_for_path(const
int cpos = -1;
if (!singleton->_find_file(p_path, &fs, cpos)) {
+ // Fallback to ResourceLoader if filesystem cache fails (can happen during scanning etc.).
+ ResourceUID::ID fallback = ResourceLoader::get_resource_uid(p_path);
+ if (fallback != ResourceUID::INVALID_ID) {
+ return fallback;
+ }
+
if (p_generate) {
- return ResourceUID::get_singleton()->create_id(); //just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple.
+ return ResourceUID::get_singleton()->create_id(); // Just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple.
} else {
return ResourceUID::INVALID_ID;
}
} else if (fs->files[cpos]->uid != ResourceUID::INVALID_ID) {
return fs->files[cpos]->uid;
} else if (p_generate) {
- return ResourceUID::get_singleton()->create_id(); //just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple.
+ return ResourceUID::get_singleton()->create_id(); // Just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple.
} else {
return ResourceUID::INVALID_ID;
}
@@ -2422,7 +2428,7 @@ EditorFileSystem::EditorFileSystem() {
scan_total = 0;
update_script_classes_queued.clear();
- ResourceUID::get_singleton()->clear(); //will be updated on scan
+ MessageQueue::get_singleton()->push_callable(callable_mp(ResourceUID::get_singleton(), &ResourceUID::clear)); // Will be updated on scan.
ResourceSaver::set_get_resource_id_for_path(_resource_saver_get_resource_id_for_path);
}
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp
index c31d13d122..0262284cdf 100644
--- a/editor/editor_fonts.cpp
+++ b/editor/editor_fonts.cpp
@@ -317,6 +317,24 @@ void editor_register_fonts(Ref<Theme> p_theme) {
mono_other_fc->set_opentype_features(ftrs);
}
+ // Use fake bold/italics to style the editor log's `print_rich()` output.
+ // Use stronger embolden strength to make bold easier to distinguish from regular text.
+ Ref<FontVariation> mono_other_fc_bold = mono_other_fc->duplicate();
+ mono_other_fc_bold->set_variation_embolden(0.8);
+
+ Ref<FontVariation> mono_other_fc_italic = mono_other_fc->duplicate();
+ mono_other_fc_italic->set_variation_transform(Transform2D(1.0, 0.2, 0.0, 1.0, 0.0, 0.0));
+
+ Ref<FontVariation> mono_other_fc_bold_italic = mono_other_fc->duplicate();
+ mono_other_fc_bold_italic->set_variation_embolden(0.8);
+ mono_other_fc_bold_italic->set_variation_transform(Transform2D(1.0, 0.2, 0.0, 1.0, 0.0, 0.0));
+
+ Ref<FontVariation> mono_other_fc_mono = mono_other_fc->duplicate();
+ // Use a different font style to distinguish `[code]` in rich prints.
+ // This emulates the "faint" styling used in ANSI escape codes by using a slightly thinner font.
+ mono_other_fc_mono->set_variation_embolden(-0.25);
+ mono_other_fc_mono->set_variation_transform(Transform2D(1.0, 0.1, 0.0, 1.0, 0.0, 0.0));
+
Ref<FontVariation> italic_fc = default_fc->duplicate();
italic_fc->set_variation_transform(Transform2D(1.0, 0.2, 0.0, 1.0, 0.0, 0.0));
@@ -386,6 +404,10 @@ void editor_register_fonts(Ref<Theme> p_theme) {
p_theme->set_font_size("output_source_size", "EditorFonts", int(EDITOR_GET("run/output/font_size")) * EDSCALE);
p_theme->set_font("output_source", "EditorFonts", mono_other_fc);
+ p_theme->set_font("output_source_bold", "EditorFonts", mono_other_fc_bold);
+ p_theme->set_font("output_source_italic", "EditorFonts", mono_other_fc_italic);
+ p_theme->set_font("output_source_bold_italic", "EditorFonts", mono_other_fc_bold_italic);
+ p_theme->set_font("output_source_mono", "EditorFonts", mono_other_fc_mono);
p_theme->set_font_size("status_source_size", "EditorFonts", default_font_size);
p_theme->set_font("status_source", "EditorFonts", mono_other_fc);
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 745dcdd04c..5192680787 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -184,9 +184,9 @@ void EditorHelp::_class_desc_input(const Ref<InputEvent> &p_input) {
void EditorHelp::_class_desc_resized(bool p_force_update_theme) {
// Add extra horizontal margins for better readability.
// The margins increase as the width of the editor help container increases.
- Ref<Font> doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts"));
+ Ref<Font> font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts"));
int font_size = get_theme_font_size(SNAME("doc_source_size"), SNAME("EditorFonts"));
- real_t char_width = doc_code_font->get_char_size('x', font_size).width;
+ real_t char_width = font->get_char_size('x', font_size).width;
const int new_display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - char_width * 120 * EDSCALE) * 0.5;
if (display_margin != new_display_margin || p_force_update_theme) {
display_margin = new_display_margin;
@@ -412,13 +412,13 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
}
void EditorHelp::_update_method_list(const Vector<DocData::MethodDoc> p_methods, bool &r_method_descrpitons) {
- Ref<Font> doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts"));
+ Ref<Font> font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts"));
class_desc->pop(); // title font size
class_desc->pop(); // title font
class_desc->pop(); // title color
class_desc->add_newline();
- class_desc->push_font(doc_code_font);
+ class_desc->push_font(font);
class_desc->push_indent(1);
class_desc->push_table(2);
class_desc->set_table_column_expand(1, true);
@@ -479,9 +479,8 @@ void EditorHelp::_update_method_list(const Vector<DocData::MethodDoc> p_methods,
}
void EditorHelp::_update_method_descriptions(const DocData::ClassDoc p_classdoc, const Vector<DocData::MethodDoc> p_methods, const String &p_method_type) {
- Ref<Font> doc_font = get_theme_font(SNAME("doc"), SNAME("EditorFonts"));
- Ref<Font> doc_bold_font = get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts"));
- Ref<Font> doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts"));
+ Ref<Font> font = get_theme_font(SNAME("doc"), SNAME("EditorFonts"));
+ Ref<Font> code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts"));
String link_color_text = title_color.to_html(false);
class_desc->pop(); // title font size
class_desc->pop(); // title font
@@ -501,7 +500,7 @@ void EditorHelp::_update_method_descriptions(const DocData::ClassDoc p_classdoc,
}
for (int i = 0; i < methods_filtered.size(); i++) {
- class_desc->push_font(doc_code_font);
+ class_desc->push_font(code_font);
_add_method(methods_filtered[i], false);
class_desc->pop();
@@ -509,7 +508,7 @@ void EditorHelp::_update_method_descriptions(const DocData::ClassDoc p_classdoc,
class_desc->add_newline();
class_desc->push_color(text_color);
- class_desc->push_font(doc_font);
+ class_desc->push_font(font);
class_desc->push_indent(1);
if (methods_filtered[i].errors_returned.size()) {
class_desc->append_text(TTR("Error codes returned:"));
diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp
index 1b8146a0f0..286dcf4b8e 100644
--- a/editor/editor_help_search.cpp
+++ b/editor/editor_help_search.cpp
@@ -320,6 +320,11 @@ bool EditorHelpSearch::Runner::_phase_match_classes_init() {
matched_item = nullptr;
match_highest_score = 0;
+ terms = term.split_spaces();
+ if (terms.is_empty()) {
+ terms.append(term);
+ }
+
return true;
}
@@ -350,62 +355,38 @@ bool EditorHelpSearch::Runner::_phase_match_classes() {
// Make an exception for annotations, since there are not that many of them.
if (term.length() > 1 || term == "@") {
if (search_flags & SEARCH_CONSTRUCTORS) {
- for (int i = 0; i < class_doc.constructors.size(); i++) {
- String method_name = (search_flags & SEARCH_CASE_SENSITIVE) ? class_doc.constructors[i].name : class_doc.constructors[i].name.to_lower();
- if (method_name.find(term) > -1 ||
- (term.begins_with(".") && method_name.begins_with(term.substr(1))) ||
- (term.ends_with("(") && method_name.ends_with(term.left(term.length() - 1).strip_edges())) ||
- (term.begins_with(".") && term.ends_with("(") && method_name == term.substr(1, term.length() - 2).strip_edges())) {
- match.constructors.push_back(const_cast<DocData::MethodDoc *>(&class_doc.constructors[i]));
- }
- }
+ _match_method_name_and_push_back(class_doc.constructors, &match.constructors);
}
if (search_flags & SEARCH_METHODS) {
- for (int i = 0; i < class_doc.methods.size(); i++) {
- String method_name = (search_flags & SEARCH_CASE_SENSITIVE) ? class_doc.methods[i].name : class_doc.methods[i].name.to_lower();
- if (method_name.find(term) > -1 ||
- (term.begins_with(".") && method_name.begins_with(term.substr(1))) ||
- (term.ends_with("(") && method_name.ends_with(term.left(term.length() - 1).strip_edges())) ||
- (term.begins_with(".") && term.ends_with("(") && method_name == term.substr(1, term.length() - 2).strip_edges())) {
- match.methods.push_back(const_cast<DocData::MethodDoc *>(&class_doc.methods[i]));
- }
- }
+ _match_method_name_and_push_back(class_doc.methods, &match.methods);
}
if (search_flags & SEARCH_OPERATORS) {
- for (int i = 0; i < class_doc.operators.size(); i++) {
- String method_name = (search_flags & SEARCH_CASE_SENSITIVE) ? class_doc.operators[i].name : class_doc.operators[i].name.to_lower();
- if (method_name.find(term) > -1 ||
- (term.begins_with(".") && method_name.begins_with(term.substr(1))) ||
- (term.ends_with("(") && method_name.ends_with(term.left(term.length() - 1).strip_edges())) ||
- (term.begins_with(".") && term.ends_with("(") && method_name == term.substr(1, term.length() - 2).strip_edges())) {
- match.operators.push_back(const_cast<DocData::MethodDoc *>(&class_doc.operators[i]));
- }
- }
+ _match_method_name_and_push_back(class_doc.operators, &match.operators);
}
if (search_flags & SEARCH_SIGNALS) {
for (int i = 0; i < class_doc.signals.size(); i++) {
- if (_match_string(term, class_doc.signals[i].name)) {
+ if (_all_terms_in_name(class_doc.signals[i].name)) {
match.signals.push_back(const_cast<DocData::MethodDoc *>(&class_doc.signals[i]));
}
}
}
if (search_flags & SEARCH_CONSTANTS) {
for (int i = 0; i < class_doc.constants.size(); i++) {
- if (_match_string(term, class_doc.constants[i].name)) {
+ if (_all_terms_in_name(class_doc.constants[i].name)) {
match.constants.push_back(const_cast<DocData::ConstantDoc *>(&class_doc.constants[i]));
}
}
}
if (search_flags & SEARCH_PROPERTIES) {
for (int i = 0; i < class_doc.properties.size(); i++) {
- if (_match_string(term, class_doc.properties[i].name) || _match_string(term, class_doc.properties[i].getter) || _match_string(term, class_doc.properties[i].setter)) {
+ if (_all_terms_in_name(class_doc.properties[i].name)) {
match.properties.push_back(const_cast<DocData::PropertyDoc *>(&class_doc.properties[i]));
}
}
}
if (search_flags & SEARCH_THEME_ITEMS) {
for (int i = 0; i < class_doc.theme_properties.size(); i++) {
- if (_match_string(term, class_doc.theme_properties[i].name)) {
+ if (_all_terms_in_name(class_doc.theme_properties[i].name)) {
match.theme_properties.push_back(const_cast<DocData::ThemeItemDoc *>(&class_doc.theme_properties[i]));
}
}
@@ -417,7 +398,6 @@ bool EditorHelpSearch::Runner::_phase_match_classes() {
}
}
}
- matches[class_doc.name] = match;
}
matches[class_doc.name] = match;
}
@@ -470,7 +450,7 @@ bool EditorHelpSearch::Runner::_phase_member_items() {
return false;
}
- TreeItem *parent = (search_flags & SEARCH_SHOW_HIERARCHY) ? class_items[match.doc->name] : root_item;
+ TreeItem *parent_item = (search_flags & SEARCH_SHOW_HIERARCHY) ? class_items[match.doc->name] : root_item;
bool constructor_created = false;
for (int i = 0; i < match.methods.size(); i++) {
String text = match.methods[i]->name;
@@ -484,23 +464,23 @@ bool EditorHelpSearch::Runner::_phase_member_items() {
continue;
}
}
- _create_method_item(parent, match.doc, text, match.methods[i]);
+ _create_method_item(parent_item, match.doc, text, match.methods[i]);
}
for (int i = 0; i < match.signals.size(); i++) {
- _create_signal_item(parent, match.doc, match.signals[i]);
+ _create_signal_item(parent_item, match.doc, match.signals[i]);
}
for (int i = 0; i < match.constants.size(); i++) {
- _create_constant_item(parent, match.doc, match.constants[i]);
+ _create_constant_item(parent_item, match.doc, match.constants[i]);
}
for (int i = 0; i < match.properties.size(); i++) {
- _create_property_item(parent, match.doc, match.properties[i]);
+ _create_property_item(parent_item, match.doc, match.properties[i]);
}
for (int i = 0; i < match.theme_properties.size(); i++) {
- _create_theme_property_item(parent, match.doc, match.theme_properties[i]);
+ _create_theme_property_item(parent_item, match.doc, match.theme_properties[i]);
}
for (int i = 0; i < match.annotations.size(); i++) {
// Hide the redundant leading @ symbol.
- _create_annotation_item(parent, match.doc, match.annotations[i]->name.substr(1), match.annotations[i]);
+ _create_annotation_item(parent_item, match.doc, match.annotations[i]->name.substr(1), match.annotations[i]);
}
++iterator_match;
@@ -514,6 +494,28 @@ bool EditorHelpSearch::Runner::_phase_select_match() {
return true;
}
+void EditorHelpSearch::Runner::_match_method_name_and_push_back(Vector<DocData::MethodDoc> &p_methods, Vector<DocData::MethodDoc *> *r_match_methods) {
+ // Constructors, Methods, Operators...
+ for (int i = 0; i < p_methods.size(); i++) {
+ String method_name = (search_flags & SEARCH_CASE_SENSITIVE) ? p_methods[i].name : p_methods[i].name.to_lower();
+ if (_all_terms_in_name(method_name) ||
+ (term.begins_with(".") && method_name.begins_with(term.substr(1))) ||
+ (term.ends_with("(") && method_name.ends_with(term.left(term.length() - 1).strip_edges())) ||
+ (term.begins_with(".") && term.ends_with("(") && method_name == term.substr(1, term.length() - 2).strip_edges())) {
+ r_match_methods->push_back(const_cast<DocData::MethodDoc *>(&p_methods[i]));
+ }
+ }
+}
+
+bool EditorHelpSearch::Runner::_all_terms_in_name(String name) {
+ for (int i = 0; i < terms.size(); i++) {
+ if (!_match_string(terms[i], name)) {
+ return false;
+ }
+ }
+ return true;
+}
+
bool EditorHelpSearch::Runner::_match_string(const String &p_term, const String &p_string) const {
if (search_flags & SEARCH_CASE_SENSITIVE) {
return p_string.find(p_term) > -1;
@@ -565,19 +567,19 @@ TreeItem *EditorHelpSearch::Runner::_create_class_hierarchy(const ClassMatch &p_
}
// Ensure parent nodes are created first.
- TreeItem *parent = root_item;
+ TreeItem *parent_item = root_item;
if (!p_match.doc->inherits.is_empty()) {
if (class_items.has(p_match.doc->inherits)) {
- parent = class_items[p_match.doc->inherits];
+ parent_item = class_items[p_match.doc->inherits];
} else {
ClassMatch &base_match = matches[p_match.doc->inherits];
if (base_match.doc) {
- parent = _create_class_hierarchy(base_match);
+ parent_item = _create_class_hierarchy(base_match);
}
}
}
- TreeItem *class_item = _create_class_item(parent, p_match.doc, !p_match.name);
+ TreeItem *class_item = _create_class_item(parent_item, p_match.doc, !p_match.name);
class_items[p_match.doc->name] = class_item;
return class_item;
}
diff --git a/editor/editor_help_search.h b/editor/editor_help_search.h
index efd8645cd7..a8bd219b89 100644
--- a/editor/editor_help_search.h
+++ b/editor/editor_help_search.h
@@ -119,6 +119,7 @@ class EditorHelpSearch::Runner : public RefCounted {
Control *ui_service = nullptr;
Tree *results_tree = nullptr;
String term;
+ Vector<String> terms;
int search_flags;
Ref<Texture2D> empty_icon;
@@ -145,6 +146,8 @@ class EditorHelpSearch::Runner : public RefCounted {
String _build_method_tooltip(const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) const;
+ void _match_method_name_and_push_back(Vector<DocData::MethodDoc> &p_methods, Vector<DocData::MethodDoc *> *r_match_methods);
+ bool _all_terms_in_name(String name);
bool _match_string(const String &p_term, const String &p_string) const;
void _match_item(TreeItem *p_item, const String &p_text);
TreeItem *_create_class_hierarchy(const ClassMatch &p_match);
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 65c65a517f..3856423fc4 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -783,9 +783,9 @@ Variant EditorProperty::get_drag_data(const Point2 &p_point) {
dp["property"] = property;
dp["value"] = object->get(property);
- Label *label = memnew(Label);
- label->set_text(property);
- set_drag_preview(label);
+ Label *drag_label = memnew(Label);
+ drag_label->set_text(property);
+ set_drag_preview(drag_label);
return dp;
}
@@ -1061,7 +1061,7 @@ void EditorInspectorPlugin::add_property_editor_for_multiple_properties(const St
}
bool EditorInspectorPlugin::can_handle(Object *p_object) {
- bool success;
+ bool success = false;
if (GDVIRTUAL_CALL(_can_handle, p_object, success)) {
return success;
}
@@ -1081,7 +1081,7 @@ void EditorInspectorPlugin::parse_group(Object *p_object, const String &p_group)
}
bool EditorInspectorPlugin::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide) {
- bool ret;
+ bool ret = false;
if (GDVIRTUAL_CALL(_parse_property, p_object, p_type, p_path, p_hint, p_hint_text, p_usage, p_wide, ret)) {
return ret;
}
@@ -1575,9 +1575,9 @@ int EditorInspectorArray::_get_array_count() {
return _extract_properties_as_array(object_property_list).size();
} else if (mode == MODE_USE_COUNT_PROPERTY) {
bool valid;
- int count = object->get(count_property, &valid);
+ int count_val = object->get(count_property, &valid);
ERR_FAIL_COND_V_MSG(!valid, 0, vformat("%s is not a valid property to be used as array count.", count_property));
- return count;
+ return count_val;
}
return 0;
}
@@ -2768,13 +2768,13 @@ void EditorInspector::update_tree() {
// Set the category icon.
if (!EditorNode::get_editor_data().is_type_recognized(type) && p.hint_string.length() && FileAccess::exists(p.hint_string)) {
// If we have a category inside a script, search for the first script with a valid icon.
- Ref<Script> script = ResourceLoader::load(p.hint_string, "Script");
+ Ref<Script> scr = ResourceLoader::load(p.hint_string, "Script");
StringName base_type;
StringName name;
- if (script.is_valid()) {
- base_type = script->get_instance_base_type();
- name = EditorNode::get_editor_data().script_class_get_name(script->get_path());
- Vector<DocData::ClassDoc> docs = script->get_documentation();
+ if (scr.is_valid()) {
+ base_type = scr->get_instance_base_type();
+ name = EditorNode::get_editor_data().script_class_get_name(scr->get_path());
+ Vector<DocData::ClassDoc> docs = scr->get_documentation();
if (!docs.is_empty()) {
doc_name = docs[0].name;
}
@@ -2782,20 +2782,20 @@ void EditorInspector::update_tree() {
label = name;
}
}
- while (script.is_valid()) {
- name = EditorNode::get_editor_data().script_class_get_name(script->get_path());
+ while (scr.is_valid()) {
+ name = EditorNode::get_editor_data().script_class_get_name(scr->get_path());
String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(name);
if (name != StringName() && !icon_path.is_empty()) {
category->icon = ResourceLoader::load(icon_path, "Texture");
break;
}
- const EditorData::CustomType *ctype = EditorNode::get_editor_data().get_custom_type_by_path(script->get_path());
+ const EditorData::CustomType *ctype = EditorNode::get_editor_data().get_custom_type_by_path(scr->get_path());
if (ctype) {
category->icon = ctype->icon;
break;
}
- script = script->get_base_script();
+ scr = scr->get_base_script();
}
if (category->icon.is_null() && has_theme_icon(base_type, SNAME("EditorIcons"))) {
category->icon = get_theme_icon(base_type, SNAME("EditorIcons"));
diff --git a/editor/editor_locale_dialog.cpp b/editor/editor_locale_dialog.cpp
index 87da67fb05..953358b23e 100644
--- a/editor/editor_locale_dialog.cpp
+++ b/editor/editor_locale_dialog.cpp
@@ -149,7 +149,7 @@ void EditorLocaleDialog::_filter_lang_option_changed() {
void EditorLocaleDialog::_filter_script_option_changed() {
TreeItem *t = script_list->get_edited();
- String script = t->get_metadata(0);
+ String scr_code = t->get_metadata(0);
bool checked = t->is_checked(0);
Variant prev;
@@ -160,11 +160,11 @@ void EditorLocaleDialog::_filter_script_option_changed() {
prev = f_script_all;
}
- int l_idx = f_script_all.find(script);
+ int l_idx = f_script_all.find(scr_code);
if (checked) {
if (l_idx == -1) {
- f_script_all.append(script);
+ f_script_all.append(scr_code);
}
} else {
if (l_idx != -1) {
@@ -298,7 +298,7 @@ void EditorLocaleDialog::_update_tree() {
Vector<String> scripts = TranslationServer::get_singleton()->get_all_scripts();
for (const String &E : scripts) {
if (is_edit_mode || (filter == SHOW_ALL_LOCALES) || f_script_all.has(E) || f_script_all.is_empty()) {
- const String &script = TranslationServer::get_singleton()->get_script_name(E);
+ const String &scr_code = TranslationServer::get_singleton()->get_script_name(E);
TreeItem *t = script_list->create_item(s_root);
if (is_edit_mode) {
t->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
@@ -307,7 +307,7 @@ void EditorLocaleDialog::_update_tree() {
} else if (script_code->get_text() == E) {
t->select(0);
}
- t->set_text(0, vformat("%s [%s]", script, E));
+ t->set_text(0, vformat("%s [%s]", scr_code, E));
t->set_metadata(0, E);
}
}
diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp
index 6e6a898757..0f2543f708 100644
--- a/editor/editor_log.cpp
+++ b/editor/editor_log.cpp
@@ -65,19 +65,34 @@ void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_f
}
void EditorLog::_update_theme() {
- Ref<Font> normal_font = get_theme_font(SNAME("output_source"), SNAME("EditorFonts"));
+ const Ref<Font> normal_font = get_theme_font(SNAME("output_source"), SNAME("EditorFonts"));
if (normal_font.is_valid()) {
log->add_theme_font_override("normal_font", normal_font);
}
- log->add_theme_font_size_override("normal_font_size", get_theme_font_size(SNAME("output_source_size"), SNAME("EditorFonts")));
- log->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4));
-
- Ref<Font> bold_font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
+ const Ref<Font> bold_font = get_theme_font(SNAME("output_source_bold"), SNAME("EditorFonts"));
if (bold_font.is_valid()) {
log->add_theme_font_override("bold_font", bold_font);
}
+ const Ref<Font> italics_font = get_theme_font(SNAME("output_source_italic"), SNAME("EditorFonts"));
+ if (italics_font.is_valid()) {
+ log->add_theme_font_override("italics_font", italics_font);
+ }
+
+ const Ref<Font> bold_italics_font = get_theme_font(SNAME("output_source_bold_italic"), SNAME("EditorFonts"));
+ if (bold_italics_font.is_valid()) {
+ log->add_theme_font_override("bold_italics_font", bold_italics_font);
+ }
+
+ const Ref<Font> mono_font = get_theme_font(SNAME("output_source_mono"), SNAME("EditorFonts"));
+ if (mono_font.is_valid()) {
+ log->add_theme_font_override("mono_font", mono_font);
+ }
+
+ log->add_theme_font_size_override("normal_font_size", get_theme_font_size(SNAME("output_source_size"), SNAME("EditorFonts")));
+ log->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4));
+
type_filter_map[MSG_TYPE_STD]->toggle_button->set_icon(get_theme_icon(SNAME("Popup"), SNAME("EditorIcons")));
type_filter_map[MSG_TYPE_ERROR]->toggle_button->set_icon(get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons")));
type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_icon(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")));
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 6bc281c7e4..bf50efc4f9 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -892,8 +892,8 @@ void EditorNode::_update_update_spinner() {
}
void EditorNode::_on_plugin_ready(Object *p_script, const String &p_activate_name) {
- Ref<Script> script = Object::cast_to<Script>(p_script);
- if (script.is_null()) {
+ Ref<Script> scr = Object::cast_to<Script>(p_script);
+ if (scr.is_null()) {
return;
}
if (p_activate_name.length()) {
@@ -901,7 +901,7 @@ void EditorNode::_on_plugin_ready(Object *p_script, const String &p_activate_nam
}
project_settings_editor->update_plugins();
project_settings_editor->hide();
- push_item(script.operator->());
+ push_item(scr.operator->());
}
void EditorNode::_remove_plugin_from_enabled(const String &p_name) {
@@ -1181,7 +1181,8 @@ void EditorNode::_vp_resized() {
}
void EditorNode::_titlebar_resized() {
- const Size2 &margin = DisplayServer::get_singleton()->window_get_safe_title_margins(DisplayServer::MAIN_WINDOW_ID);
+ DisplayServer::get_singleton()->window_set_window_buttons_offset(Vector2i(menu_hb->get_global_position().y + menu_hb->get_size().y / 2, menu_hb->get_global_position().y + menu_hb->get_size().y / 2), DisplayServer::MAIN_WINDOW_ID);
+ const Vector3i &margin = DisplayServer::get_singleton()->window_get_safe_title_margins(DisplayServer::MAIN_WINDOW_ID);
if (left_menu_spacer) {
int w = (gui_base->is_layout_rtl()) ? margin.y : margin.x;
left_menu_spacer->set_custom_minimum_size(Size2(w, 0));
@@ -1190,6 +1191,9 @@ void EditorNode::_titlebar_resized() {
int w = (gui_base->is_layout_rtl()) ? margin.x : margin.y;
right_menu_spacer->set_custom_minimum_size(Size2(w, 0));
}
+ if (menu_hb) {
+ menu_hb->set_custom_minimum_size(Size2(0, margin.z - menu_hb->get_global_position().y));
+ }
}
void EditorNode::_version_button_pressed() {
@@ -1665,10 +1669,8 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
cache_base = temp_path.path_join("resthumb-" + cache_base);
// Does not have it, try to load a cached thumbnail.
- String file = cache_base + ".png";
-
post_process_preview(img);
- img->save_png(file);
+ img->save_png(cache_base + ".png");
}
}
@@ -2038,8 +2040,8 @@ void EditorNode::_dialog_action(String p_file) {
ERR_FAIL_COND(saving_resource.is_null());
save_resource_in_path(saving_resource, p_file);
saving_resource = Ref<Resource>();
- ObjectID current = editor_history.get_current();
- Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr;
+ ObjectID current_id = editor_history.get_current();
+ Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
ERR_FAIL_COND(!current_obj);
current_obj->notify_property_list_changed();
} break;
@@ -2240,8 +2242,8 @@ static bool overrides_external_editor(Object *p_object) {
}
void EditorNode::_edit_current(bool p_skip_foreign) {
- ObjectID current = editor_history.get_current();
- Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr;
+ ObjectID current_id = editor_history.get_current();
+ Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
Ref<Resource> res = Object::cast_to<Resource>(current_obj);
if (p_skip_foreign && res.is_valid()) {
@@ -2691,9 +2693,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
save_confirmation->set_text(TTR("Save modified resources before closing?"));
}
} else {
- Node *scene_root = editor_data.get_edited_scene_root(tab_closing_idx);
- if (scene_root) {
- String scene_filename = scene_root->get_scene_file_path();
+ Node *ed_scene_root = editor_data.get_edited_scene_root(tab_closing_idx);
+ if (ed_scene_root) {
+ String scene_filename = ed_scene_root->get_scene_file_path();
if (p_option == FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT) {
save_confirmation->set_ok_button_text(TTR("Save & Reload"));
save_confirmation->set_text(vformat(TTR("Save changes to '%s' before reloading?"), !scene_filename.is_empty() ? scene_filename : "unsaved scene"));
@@ -3511,39 +3513,39 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled,
}
String script_path = cf->get_value("plugin", "script");
- Ref<Script> script; // We need to save it for creating "ep" below.
+ Ref<Script> scr; // We need to save it for creating "ep" below.
// Only try to load the script if it has a name. Else, the plugin has no init script.
if (script_path.length() > 0) {
script_path = addon_path.get_base_dir().path_join(script_path);
- script = ResourceLoader::load(script_path);
+ scr = ResourceLoader::load(script_path);
- if (script.is_null()) {
+ if (scr.is_null()) {
show_warning(vformat(TTR("Unable to load addon script from path: '%s'."), script_path));
return;
}
// Errors in the script cause the base_type to be an empty StringName.
- if (script->get_instance_base_type() == StringName()) {
+ if (scr->get_instance_base_type() == StringName()) {
show_warning(vformat(TTR("Unable to load addon script from path: '%s'. This might be due to a code error in that script.\nDisabling the addon at '%s' to prevent further errors."), script_path, addon_path));
_remove_plugin_from_enabled(addon_path);
return;
}
// Plugin init scripts must inherit from EditorPlugin and be tools.
- if (String(script->get_instance_base_type()) != "EditorPlugin") {
+ if (String(scr->get_instance_base_type()) != "EditorPlugin") {
show_warning(vformat(TTR("Unable to load addon script from path: '%s' Base type is not EditorPlugin."), script_path));
return;
}
- if (!script->is_tool()) {
+ if (!scr->is_tool()) {
show_warning(vformat(TTR("Unable to load addon script from path: '%s' Script is not in tool mode."), script_path));
return;
}
}
EditorPlugin *ep = memnew(EditorPlugin);
- ep->set_script(script);
+ ep->set_script(scr);
addon_name_to_plugin[addon_path] = ep;
add_editor_plugin(ep, p_config_changed);
@@ -3641,17 +3643,17 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
changing_scene = false;
- int current = -1;
+ int current_tab = -1;
for (int i = 0; i < editor_table.size(); i++) {
if (editor_plugin_screen == editor_table[i]) {
- current = i;
+ current_tab = i;
break;
}
}
if (p_state.has("editor_index")) {
int index = p_state["editor_index"];
- if (current < 2) { // If currently in spatial/2d, only switch to spatial/2d. If currently in script, stay there.
+ if (current_tab < 2) { // If currently in spatial/2d, only switch to spatial/2d. If currently in script, stay there.
if (index < 2 || !get_edited_scene()) {
editor_select(index);
}
@@ -3659,7 +3661,7 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
}
if (get_edited_scene()) {
- if (current < 2) {
+ if (current_tab < 2) {
// Use heuristic instead.
int n2d = 0, n3d = 0;
_find_node_types(get_edited_scene(), n2d, n3d);
@@ -3772,7 +3774,7 @@ int EditorNode::new_scene() {
if (editor_data.get_edited_scene_count() > 1) {
for (int i = 0; i < editor_data.get_edited_scene_count() - 1; i++) {
bool unsaved = get_undo_redo()->is_history_unsaved(editor_data.get_scene_history_id(i));
- if (!unsaved && editor_data.get_scene_path(i).is_empty()) {
+ if (!unsaved && editor_data.get_scene_path(i).is_empty() && editor_data.get_edited_scene_root(i) == nullptr) {
editor_data.remove_scene(i);
idx--;
}
@@ -3939,9 +3941,9 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
void EditorNode::open_request(const String &p_path) {
if (!opening_prev) {
- List<String>::Element *prev_scene = previous_scenes.find(p_path);
- if (prev_scene != nullptr) {
- prev_scene->erase();
+ List<String>::Element *prev_scene_item = previous_scenes.find(p_path);
+ if (prev_scene_item != nullptr) {
+ prev_scene_item->erase();
}
}
@@ -4192,9 +4194,9 @@ void EditorNode::stop_child_process(OS::ProcessID p_pid) {
Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) const {
ERR_FAIL_COND_V(!p_object, nullptr);
- Ref<Script> script = p_object->get_script();
+ Ref<Script> scr = p_object->get_script();
- if (script.is_valid()) {
+ if (scr.is_valid()) {
// Uncommenting would break things! Consider adding a parameter if you need it.
// StringName name = EditorNode::get_editor_data().script_class_get_name(base_script->get_path());
// if (name != StringName()) {
@@ -4202,18 +4204,18 @@ Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) cons
// }
// TODO: Should probably be deprecated in 4.x
- StringName base = script->get_instance_base_type();
+ StringName base = scr->get_instance_base_type();
if (base != StringName() && EditorNode::get_editor_data().get_custom_types().has(base)) {
const Vector<EditorData::CustomType> &types = EditorNode::get_editor_data().get_custom_types()[base];
- Ref<Script> base_script = script;
- while (base_script.is_valid()) {
+ Ref<Script> base_scr = scr;
+ while (base_scr.is_valid()) {
for (int i = 0; i < types.size(); ++i) {
- if (types[i].script == base_script) {
+ if (types[i].script == base_scr) {
return types[i].script;
}
}
- base_script = base_script->get_base_script();
+ base_scr = base_scr->get_base_script();
}
}
}
@@ -4224,30 +4226,30 @@ Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) cons
StringName EditorNode::get_object_custom_type_name(const Object *p_object) const {
ERR_FAIL_COND_V(!p_object, StringName());
- Ref<Script> script = p_object->get_script();
- if (script.is_null() && Object::cast_to<Script>(p_object)) {
- script = p_object;
+ Ref<Script> scr = p_object->get_script();
+ if (scr.is_null() && Object::cast_to<Script>(p_object)) {
+ scr = p_object;
}
- if (script.is_valid()) {
- Ref<Script> base_script = script;
- while (base_script.is_valid()) {
- StringName name = EditorNode::get_editor_data().script_class_get_name(base_script->get_path());
+ if (scr.is_valid()) {
+ Ref<Script> base_scr = scr;
+ while (base_scr.is_valid()) {
+ StringName name = EditorNode::get_editor_data().script_class_get_name(base_scr->get_path());
if (name != StringName()) {
return name;
}
// TODO: Should probably be deprecated in 4.x.
- StringName base = base_script->get_instance_base_type();
+ StringName base = base_scr->get_instance_base_type();
if (base != StringName() && EditorNode::get_editor_data().get_custom_types().has(base)) {
const Vector<EditorData::CustomType> &types = EditorNode::get_editor_data().get_custom_types()[base];
for (int i = 0; i < types.size(); ++i) {
- if (types[i].script == base_script) {
+ if (types[i].script == base_scr) {
return types[i].name;
}
}
}
- base_script = base_script->get_base_script();
+ base_scr = base_scr->get_base_script();
}
}
@@ -4291,40 +4293,40 @@ void EditorNode::_pick_main_scene_custom_action(const String &p_custom_action_na
Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) {
ERR_FAIL_COND_V(!p_object || !gui_base, nullptr);
- Ref<Script> script = p_object->get_script();
- if (script.is_null() && p_object->is_class("Script")) {
- script = p_object;
+ Ref<Script> scr = p_object->get_script();
+ if (scr.is_null() && p_object->is_class("Script")) {
+ scr = p_object;
}
- if (script.is_valid() && !script_icon_cache.has(script)) {
- Ref<Script> base_script = script;
- while (base_script.is_valid()) {
- StringName name = EditorNode::get_editor_data().script_class_get_name(base_script->get_path());
+ if (scr.is_valid() && !script_icon_cache.has(scr)) {
+ Ref<Script> base_scr = scr;
+ while (base_scr.is_valid()) {
+ StringName name = EditorNode::get_editor_data().script_class_get_name(base_scr->get_path());
String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(name);
Ref<ImageTexture> icon = _load_custom_class_icon(icon_path);
if (icon.is_valid()) {
- script_icon_cache[script] = icon;
+ script_icon_cache[scr] = icon;
return icon;
}
// TODO: should probably be deprecated in 4.x
- StringName base = base_script->get_instance_base_type();
+ StringName base = base_scr->get_instance_base_type();
if (base != StringName() && EditorNode::get_editor_data().get_custom_types().has(base)) {
const Vector<EditorData::CustomType> &types = EditorNode::get_editor_data().get_custom_types()[base];
for (int i = 0; i < types.size(); ++i) {
- if (types[i].script == base_script && types[i].icon.is_valid()) {
- script_icon_cache[script] = types[i].icon;
+ if (types[i].script == base_scr && types[i].icon.is_valid()) {
+ script_icon_cache[scr] = types[i].icon;
return types[i].icon;
}
}
}
- base_script = base_script->get_base_script();
+ base_scr = base_scr->get_base_script();
}
// If no icon found, cache it as null.
- script_icon_cache[script] = Ref<Texture>();
- } else if (script.is_valid() && script_icon_cache.has(script) && script_icon_cache[script].is_valid()) {
- return script_icon_cache[script];
+ script_icon_cache[scr] = Ref<Texture>();
+ } else if (scr.is_valid() && script_icon_cache.has(scr) && script_icon_cache[scr].is_valid()) {
+ return script_icon_cache[scr];
}
// TODO: Should probably be deprecated in 4.x.
@@ -4348,7 +4350,7 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p
if (ScriptServer::is_global_class(p_class)) {
String class_name = p_class;
- Ref<Script> script = EditorNode::get_editor_data().script_class_load_script(class_name);
+ Ref<Script> scr = EditorNode::get_editor_data().script_class_load_script(class_name);
while (true) {
String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(class_name);
@@ -4359,18 +4361,18 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p
// Find next global class along the inheritance chain.
do {
- Ref<Script> base_script = script->get_base_script();
- if (base_script.is_null()) {
+ Ref<Script> base_scr = scr->get_base_script();
+ if (base_scr.is_null()) {
// We've reached a native class, use its icon.
String base_type;
- script->get_language()->get_global_class_name(script->get_path(), &base_type);
+ scr->get_language()->get_global_class_name(scr->get_path(), &base_type);
if (gui_base->has_theme_icon(base_type, "EditorIcons")) {
return gui_base->get_theme_icon(base_type, "EditorIcons");
}
return gui_base->get_theme_icon(p_fallback, "EditorIcons");
}
- script = base_script;
- class_name = EditorNode::get_editor_data().script_class_get_name(script->get_path());
+ scr = base_scr;
+ class_name = EditorNode::get_editor_data().script_class_get_name(scr->get_path());
} while (class_name.is_empty());
}
}
@@ -4675,26 +4677,24 @@ void EditorNode::_dock_move_left() {
if (dock_popup_selected_idx < 0 || dock_popup_selected_idx >= DOCK_SLOT_MAX) {
return;
}
- Control *current = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab());
- Control *prev = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab() - 1);
- if (!current || !prev) {
+ Control *current_ctl = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab());
+ Control *prev_ctl = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab() - 1);
+ if (!current_ctl || !prev_ctl) {
return;
}
- dock_slot[dock_popup_selected_idx]->move_child(current, prev->get_index());
- dock_slot[dock_popup_selected_idx]->set_current_tab(dock_slot[dock_popup_selected_idx]->get_current_tab() - 1);
+ dock_slot[dock_popup_selected_idx]->move_child(current_ctl, prev_ctl->get_index(false));
dock_select->queue_redraw();
_edit_current();
_save_docks();
}
void EditorNode::_dock_move_right() {
- Control *current = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab());
- Control *next = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab() + 1);
- if (!current || !next) {
+ Control *current_ctl = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab());
+ Control *next_ctl = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab() + 1);
+ if (!current_ctl || !next_ctl) {
return;
}
- dock_slot[dock_popup_selected_idx]->move_child(next, current->get_index());
- dock_slot[dock_popup_selected_idx]->set_current_tab(dock_slot[dock_popup_selected_idx]->get_current_tab() + 1);
+ dock_slot[dock_popup_selected_idx]->move_child(next_ctl, current_ctl->get_index(false));
dock_select->queue_redraw();
_edit_current();
_save_docks();
@@ -5283,9 +5283,9 @@ void EditorNode::_layout_menu_option(int p_id) {
}
void EditorNode::_scene_tab_script_edited(int p_tab) {
- Ref<Script> script = editor_data.get_scene_root_script(p_tab);
- if (script.is_valid()) {
- InspectorDock::get_singleton()->edit_resource(script);
+ Ref<Script> scr = editor_data.get_scene_root_script(p_tab);
+ if (scr.is_valid()) {
+ InspectorDock::get_singleton()->edit_resource(scr);
}
}
@@ -5909,7 +5909,7 @@ void EditorNode::_update_renderer_color() {
if (renderer->get_text() == "gl_compatibility") {
renderer->add_theme_color_override("font_color", Color::hex(0x5586a4ff));
} else if (renderer->get_text() == "forward_plus" || renderer->get_text() == "mobile") {
- renderer->add_theme_color_override("font_color", theme_base->get_theme_color(SNAME("vulkan_color"), SNAME("Editor")));
+ renderer->add_theme_color_override("font_color", theme_base->get_theme_color(SNAME("highend_color"), SNAME("Editor")));
}
}
@@ -6181,10 +6181,17 @@ EditorNode::EditorNode() {
// Define a minimum window size to prevent UI elements from overlapping or being cut off.
DisplayServer::get_singleton()->window_set_min_size(Size2(1024, 600) * EDSCALE);
- ResourceLoader::set_abort_on_missing_resources(false);
FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files"));
EditorFileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files"));
EditorFileDialog::set_default_display_mode((EditorFileDialog::DisplayMode)EditorSettings::get_singleton()->get("filesystem/file_dialog/display_mode").operator int());
+
+ int swap_cancel_ok = EDITOR_GET("interface/editor/accept_dialog_cancel_ok_buttons");
+ if (swap_cancel_ok != 0) { // 0 is auto, set in register_scene based on DisplayServer.
+ // Swap on means OK first.
+ AcceptDialog::set_swap_cancel_ok(swap_cancel_ok == 2);
+ }
+
+ ResourceLoader::set_abort_on_missing_resources(false);
ResourceLoader::set_error_notify_func(this, _load_error_notify);
ResourceLoader::set_dependency_error_notify_func(this, _dependency_error_report);
@@ -7564,7 +7571,6 @@ EditorNode::EditorNode() {
// Extend menu bar to window title.
if (can_expand) {
- DisplayServer::get_singleton()->window_set_window_buttons_offset(Vector2i(menu_hb->get_minimum_size().y / 2, menu_hb->get_minimum_size().y / 2), DisplayServer::MAIN_WINDOW_ID);
DisplayServer::get_singleton()->window_set_flag(DisplayServer::WINDOW_FLAG_EXTEND_TO_TITLE, true, DisplayServer::MAIN_WINDOW_ID);
menu_hb->set_can_move_window(true);
}
@@ -7618,7 +7624,7 @@ bool EditorPluginList::forward_gui_input(const Ref<InputEvent> &p_event) {
return discard;
}
-EditorPlugin::AfterGUIInput EditorPluginList::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled) {
+EditorPlugin::AfterGUIInput EditorPluginList::forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled) {
EditorPlugin::AfterGUIInput after = EditorPlugin::AFTER_GUI_INPUT_PASS;
for (int i = 0; i < plugins_list.size(); i++) {
@@ -7626,7 +7632,7 @@ EditorPlugin::AfterGUIInput EditorPluginList::forward_spatial_gui_input(Camera3D
continue;
}
- EditorPlugin::AfterGUIInput current_after = plugins_list[i]->forward_spatial_gui_input(p_camera, p_event);
+ EditorPlugin::AfterGUIInput current_after = plugins_list[i]->forward_3d_gui_input(p_camera, p_event);
if (current_after == EditorPlugin::AFTER_GUI_INPUT_STOP) {
after = EditorPlugin::AFTER_GUI_INPUT_STOP;
}
@@ -7650,15 +7656,15 @@ void EditorPluginList::forward_canvas_force_draw_over_viewport(Control *p_overla
}
}
-void EditorPluginList::forward_spatial_draw_over_viewport(Control *p_overlay) {
+void EditorPluginList::forward_3d_draw_over_viewport(Control *p_overlay) {
for (int i = 0; i < plugins_list.size(); i++) {
- plugins_list[i]->forward_spatial_draw_over_viewport(p_overlay);
+ plugins_list[i]->forward_3d_draw_over_viewport(p_overlay);
}
}
-void EditorPluginList::forward_spatial_force_draw_over_viewport(Control *p_overlay) {
+void EditorPluginList::forward_3d_force_draw_over_viewport(Control *p_overlay) {
for (int i = 0; i < plugins_list.size(); i++) {
- plugins_list[i]->forward_spatial_force_draw_over_viewport(p_overlay);
+ plugins_list[i]->forward_3d_force_draw_over_viewport(p_overlay);
}
}
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 3c236a1301..9452425dc8 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -935,9 +935,9 @@ public:
bool forward_gui_input(const Ref<InputEvent> &p_event);
void forward_canvas_draw_over_viewport(Control *p_overlay);
void forward_canvas_force_draw_over_viewport(Control *p_overlay);
- EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled);
- void forward_spatial_draw_over_viewport(Control *p_overlay);
- void forward_spatial_force_draw_over_viewport(Control *p_overlay);
+ EditorPlugin::AfterGUIInput forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled);
+ void forward_3d_draw_over_viewport(Control *p_overlay);
+ void forward_3d_force_draw_over_viewport(Control *p_overlay);
void add_plugin(EditorPlugin *p_plugin);
void remove_plugin(EditorPlugin *p_plugin);
void clear();
diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp
index d1f41dad84..a8fd9d0eb0 100644
--- a/editor/editor_path.cpp
+++ b/editor/editor_path.cpp
@@ -59,7 +59,7 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) {
continue;
}
- Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj);
+ Ref<Texture2D> obj_icon = EditorNode::get_singleton()->get_object_icon(obj);
String proper_name = "";
Vector<String> name_parts = E.name.split("/");
@@ -72,7 +72,7 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) {
}
int index = sub_objects_menu->get_item_count();
- sub_objects_menu->add_icon_item(icon, proper_name, objects.size());
+ sub_objects_menu->add_icon_item(obj_icon, proper_name, objects.size());
sub_objects_menu->set_item_indent(index, p_depth);
objects.push_back(obj->get_instance_id());
@@ -122,15 +122,15 @@ void EditorPath::update_path() {
continue;
}
- Ref<Texture2D> icon;
+ Ref<Texture2D> obj_icon;
if (Object::cast_to<MultiNodeEdit>(obj)) {
- icon = EditorNode::get_singleton()->get_class_icon(Object::cast_to<MultiNodeEdit>(obj)->get_edited_class_name());
+ obj_icon = EditorNode::get_singleton()->get_class_icon(Object::cast_to<MultiNodeEdit>(obj)->get_edited_class_name());
} else {
- icon = EditorNode::get_singleton()->get_object_icon(obj);
+ obj_icon = EditorNode::get_singleton()->get_object_icon(obj);
}
- if (icon.is_valid()) {
- current_object_icon->set_texture(icon);
+ if (obj_icon.is_valid()) {
+ current_object_icon->set_texture(obj_icon);
}
if (i == history->get_path_size() - 1) {
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index 981dad2d2a..4fdf669121 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -570,7 +570,7 @@ void EditorPlugin::notify_resource_saved(const Ref<Resource> &p_resource) {
}
bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
- bool success;
+ bool success = false;
if (GDVIRTUAL_CALL(_forward_canvas_gui_input, p_event, success)) {
return success;
}
@@ -604,8 +604,8 @@ int EditorPlugin::update_overlays() const {
}
}
-EditorPlugin::AfterGUIInput EditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
- int success;
+EditorPlugin::AfterGUIInput EditorPlugin::forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
+ int success = EditorPlugin::AFTER_GUI_INPUT_PASS;
if (GDVIRTUAL_CALL(_forward_3d_gui_input, p_camera, p_event, success)) {
return static_cast<EditorPlugin::AfterGUIInput>(success);
@@ -614,11 +614,11 @@ EditorPlugin::AfterGUIInput EditorPlugin::forward_spatial_gui_input(Camera3D *p_
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
-void EditorPlugin::forward_spatial_draw_over_viewport(Control *p_overlay) {
+void EditorPlugin::forward_3d_draw_over_viewport(Control *p_overlay) {
GDVIRTUAL_CALL(_forward_3d_draw_over_viewport, p_overlay);
}
-void EditorPlugin::forward_spatial_force_draw_over_viewport(Control *p_overlay) {
+void EditorPlugin::forward_3d_force_draw_over_viewport(Control *p_overlay) {
GDVIRTUAL_CALL(_forward_3d_force_draw_over_viewport, p_overlay);
}
@@ -662,7 +662,7 @@ void EditorPlugin::edit(Object *p_object) {
}
bool EditorPlugin::handles(Object *p_object) const {
- bool success;
+ bool success = false;
if (GDVIRTUAL_CALL(_handles, p_object, success)) {
return success;
}
@@ -753,12 +753,12 @@ void EditorPlugin::remove_export_plugin(const Ref<EditorExportPlugin> &p_exporte
EditorExport::get_singleton()->remove_export_plugin(p_exporter);
}
-void EditorPlugin::add_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) {
+void EditorPlugin::add_node_3d_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) {
ERR_FAIL_COND(!p_gizmo_plugin.is_valid());
Node3DEditor::get_singleton()->add_gizmo_plugin(p_gizmo_plugin);
}
-void EditorPlugin::remove_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) {
+void EditorPlugin::remove_node_3d_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) {
ERR_FAIL_COND(!p_gizmo_plugin.is_valid());
Node3DEditor::get_singleton()->remove_gizmo_plugin(p_gizmo_plugin);
}
@@ -908,8 +908,8 @@ void EditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("remove_scene_post_import_plugin", "scene_import_plugin"), &EditorPlugin::remove_scene_post_import_plugin);
ClassDB::bind_method(D_METHOD("add_export_plugin", "plugin"), &EditorPlugin::add_export_plugin);
ClassDB::bind_method(D_METHOD("remove_export_plugin", "plugin"), &EditorPlugin::remove_export_plugin);
- ClassDB::bind_method(D_METHOD("add_spatial_gizmo_plugin", "plugin"), &EditorPlugin::add_spatial_gizmo_plugin);
- ClassDB::bind_method(D_METHOD("remove_spatial_gizmo_plugin", "plugin"), &EditorPlugin::remove_spatial_gizmo_plugin);
+ ClassDB::bind_method(D_METHOD("add_node_3d_gizmo_plugin", "plugin"), &EditorPlugin::add_node_3d_gizmo_plugin);
+ ClassDB::bind_method(D_METHOD("remove_node_3d_gizmo_plugin", "plugin"), &EditorPlugin::remove_node_3d_gizmo_plugin);
ClassDB::bind_method(D_METHOD("add_inspector_plugin", "plugin"), &EditorPlugin::add_inspector_plugin);
ClassDB::bind_method(D_METHOD("remove_inspector_plugin", "plugin"), &EditorPlugin::remove_inspector_plugin);
ClassDB::bind_method(D_METHOD("set_input_event_forwarding_always_enabled"), &EditorPlugin::set_input_event_forwarding_always_enabled);
diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h
index a048b174e4..1211bcf53c 100644
--- a/editor/editor_plugin.h
+++ b/editor/editor_plugin.h
@@ -237,9 +237,9 @@ public:
virtual void forward_canvas_draw_over_viewport(Control *p_overlay);
virtual void forward_canvas_force_draw_over_viewport(Control *p_overlay);
- virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event);
- virtual void forward_spatial_draw_over_viewport(Control *p_overlay);
- virtual void forward_spatial_force_draw_over_viewport(Control *p_overlay);
+ virtual EditorPlugin::AfterGUIInput forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event);
+ virtual void forward_3d_draw_over_viewport(Control *p_overlay);
+ virtual void forward_3d_force_draw_over_viewport(Control *p_overlay);
virtual String get_name() const;
virtual const Ref<Texture2D> get_icon() const;
@@ -285,8 +285,8 @@ public:
void add_export_plugin(const Ref<EditorExportPlugin> &p_exporter);
void remove_export_plugin(const Ref<EditorExportPlugin> &p_exporter);
- void add_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin);
- void remove_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin);
+ void add_node_3d_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin);
+ void remove_node_3d_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin);
void add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin);
void remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin);
diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp
index bd19df41fe..dd647c944d 100644
--- a/editor/editor_plugin_settings.cpp
+++ b/editor/editor_plugin_settings.cpp
@@ -98,14 +98,14 @@ void EditorPluginSettings::update_plugins() {
String author = cf->get_value("plugin", "author");
String version = cf->get_value("plugin", "version");
String description = cf->get_value("plugin", "description");
- String script = cf->get_value("plugin", "script");
+ String scr = cf->get_value("plugin", "script");
TreeItem *item = plugin_list->create_item(root);
item->set_text(0, name);
- item->set_tooltip_text(0, TTR("Name:") + " " + name + "\n" + TTR("Path:") + " " + path + "\n" + TTR("Main Script:") + " " + script + "\n" + TTR("Description:") + " " + description);
+ item->set_tooltip_text(0, TTR("Name:") + " " + name + "\n" + TTR("Path:") + " " + path + "\n" + TTR("Main Script:") + " " + scr + "\n" + TTR("Description:") + " " + description);
item->set_metadata(0, path);
item->set_text(1, version);
- item->set_metadata(1, script);
+ item->set_metadata(1, scr);
item->set_text(2, author);
item->set_metadata(2, description);
item->set_cell_mode(3, TreeItem::CELL_MODE_CHECK);
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 3b99962435..332e47dc52 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -37,6 +37,7 @@
#include "editor/editor_resource_preview.h"
#include "editor/editor_scale.h"
#include "editor/filesystem_dock.h"
+#include "editor/project_settings_editor.h"
#include "scene/2d/gpu_particles_2d.h"
#include "scene/3d/fog_volume.h"
#include "scene/3d/gpu_particles_3d.h"
@@ -51,9 +52,9 @@ void EditorPropertyNil::update_property() {
}
EditorPropertyNil::EditorPropertyNil() {
- Label *label = memnew(Label);
- label->set_text("<null>");
- add_child(label);
+ Label *prop_label = memnew(Label);
+ prop_label->set_text("<null>");
+ add_child(prop_label);
}
///////////////////// TEXT /////////////////////////
@@ -759,8 +760,13 @@ void EditorPropertyEnum::_option_selected(int p_which) {
}
void EditorPropertyEnum::update_property() {
- int64_t which = get_edited_object()->get(get_edited_property());
+ Variant current = get_edited_object()->get(get_edited_property());
+ if (current.get_type() == Variant::NIL) {
+ options->select(-1);
+ return;
+ }
+ int64_t which = current;
for (int i = 0; i < options->get_item_count(); i++) {
if (which == (int64_t)options->get_item_metadata(i)) {
options->select(i);
@@ -1252,26 +1258,41 @@ void EditorPropertyLayers::setup(LayerType p_layer_type) {
}
void EditorPropertyLayers::set_layer_name(int p_index, const String &p_name) {
- if (ProjectSettings::get_singleton()->has_setting(basename + vformat("/layer_%d", p_index + 1))) {
- ProjectSettings::get_singleton()->set(basename + vformat("/layer_%d", p_index + 1), p_name);
+ const String property_name = basename + vformat("/layer_%d", p_index + 1);
+ if (ProjectSettings::get_singleton()->has_setting(property_name)) {
+ ProjectSettings::get_singleton()->set(property_name, p_name);
ProjectSettings::get_singleton()->save();
}
}
+String EditorPropertyLayers::get_layer_name(int p_index) const {
+ const String property_name = basename + vformat("/layer_%d", p_index + 1);
+ if (ProjectSettings::get_singleton()->has_setting(property_name)) {
+ return ProjectSettings::get_singleton()->get(property_name);
+ }
+ return String();
+}
+
void EditorPropertyLayers::_button_pressed() {
int layer_count = grid->layer_count;
- int layer_group_size = grid->layer_group_size;
-
layers->clear();
for (int i = 0; i < layer_count; i++) {
- if ((i != 0) && ((i % layer_group_size) == 0)) {
- layers->add_separator();
+ const String name = get_layer_name(i);
+ if (name.is_empty()) {
+ continue;
}
- layers->add_check_item(grid->names[i], i);
+ layers->add_check_item(name, i);
int idx = layers->get_item_index(i);
layers->set_item_checked(idx, grid->value & (1 << i));
}
+ if (layers->get_item_count() == 0) {
+ layers->add_item(TTR("No Named Layers"));
+ layers->set_item_disabled(0, true);
+ }
+ layers->add_separator();
+ layers->add_icon_item(get_theme_icon("Edit", "EditorIcons"), TTR("Edit Layer Names"), grid->layer_count);
+
Rect2 gp = button->get_screen_rect();
layers->reset_size();
Vector2 popup_pos = gp.position - Vector2(layers->get_contents_minimum_size().x, 0);
@@ -1280,14 +1301,19 @@ void EditorPropertyLayers::_button_pressed() {
}
void EditorPropertyLayers::_menu_pressed(int p_menu) {
- if (grid->value & (1 << p_menu)) {
- grid->value &= ~(1 << p_menu);
+ if (p_menu == grid->layer_count) {
+ ProjectSettingsEditor::get_singleton()->popup_project_settings();
+ ProjectSettingsEditor::get_singleton()->set_general_page(basename);
} else {
- grid->value |= (1 << p_menu);
+ if (grid->value & (1 << p_menu)) {
+ grid->value &= ~(1 << p_menu);
+ } else {
+ grid->value |= (1 << p_menu);
+ }
+ grid->queue_redraw();
+ layers->set_item_checked(layers->get_item_index(p_menu), grid->value & (1 << p_menu));
+ _grid_changed(grid->value);
}
- grid->queue_redraw();
- layers->set_item_checked(layers->get_item_index(p_menu), grid->value & (1 << p_menu));
- _grid_changed(grid->value);
}
void EditorPropertyLayers::_refresh_names() {
@@ -1489,12 +1515,12 @@ void EditorPropertyFloat::update_property() {
void EditorPropertyFloat::_bind_methods() {
}
-void EditorPropertyFloat::setup(double p_min, double p_max, double p_step, bool p_no_slider, bool p_exp_range, bool p_greater, bool p_lesser, const String &p_suffix, bool p_angle_in_radians) {
+void EditorPropertyFloat::setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_exp_range, bool p_greater, bool p_lesser, const String &p_suffix, bool p_angle_in_radians) {
angle_in_radians = p_angle_in_radians;
spin->set_min(p_min);
spin->set_max(p_max);
spin->set_step(p_step);
- spin->set_hide_slider(p_no_slider);
+ spin->set_hide_slider(p_hide_slider);
spin->set_exp_ratio(p_exp_range);
spin->set_allow_greater(p_greater);
spin->set_allow_lesser(p_lesser);
@@ -1797,12 +1823,12 @@ void EditorPropertyVector2::_notification(int p_what) {
}
}
-void EditorPropertyVector2::setup(double p_min, double p_max, double p_step, bool p_no_slider, bool p_link, const String &p_suffix) {
+void EditorPropertyVector2::setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_link, const String &p_suffix) {
for (int i = 0; i < 2; i++) {
spin[i]->set_min(p_min);
spin[i]->set_max(p_max);
spin[i]->set_step(p_step);
- spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_hide_slider(p_hide_slider);
spin[i]->set_allow_greater(true);
spin[i]->set_allow_lesser(true);
spin[i]->set_suffix(p_suffix);
@@ -1907,12 +1933,12 @@ void EditorPropertyRect2::_notification(int p_what) {
void EditorPropertyRect2::_bind_methods() {
}
-void EditorPropertyRect2::setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix) {
+void EditorPropertyRect2::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) {
for (int i = 0; i < 4; i++) {
spin[i]->set_min(p_min);
spin[i]->set_max(p_max);
spin[i]->set_step(p_step);
- spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_hide_slider(p_hide_slider);
spin[i]->set_allow_greater(true);
spin[i]->set_allow_lesser(true);
spin[i]->set_suffix(p_suffix);
@@ -2078,13 +2104,13 @@ void EditorPropertyVector3::_notification(int p_what) {
void EditorPropertyVector3::_bind_methods() {
}
-void EditorPropertyVector3::setup(double p_min, double p_max, double p_step, bool p_no_slider, bool p_link, const String &p_suffix, bool p_angle_in_radians) {
+void EditorPropertyVector3::setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_link, const String &p_suffix, bool p_angle_in_radians) {
angle_in_radians = p_angle_in_radians;
for (int i = 0; i < 3; i++) {
spin[i]->set_min(p_min);
spin[i]->set_max(p_max);
spin[i]->set_step(p_step);
- spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_hide_slider(p_hide_slider);
spin[i]->set_allow_greater(true);
spin[i]->set_allow_lesser(true);
spin[i]->set_suffix(p_suffix);
@@ -2210,12 +2236,12 @@ void EditorPropertyVector2i::_notification(int p_what) {
}
}
-void EditorPropertyVector2i::setup(int p_min, int p_max, bool p_no_slider, bool p_link, const String &p_suffix) {
+void EditorPropertyVector2i::setup(int p_min, int p_max, bool p_hide_slider, bool p_link, const String &p_suffix) {
for (int i = 0; i < 2; i++) {
spin[i]->set_min(p_min);
spin[i]->set_max(p_max);
spin[i]->set_step(1);
- spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_hide_slider(p_hide_slider);
spin[i]->set_allow_greater(true);
spin[i]->set_allow_lesser(true);
spin[i]->set_suffix(p_suffix);
@@ -2320,12 +2346,12 @@ void EditorPropertyRect2i::_notification(int p_what) {
void EditorPropertyRect2i::_bind_methods() {
}
-void EditorPropertyRect2i::setup(int p_min, int p_max, bool p_no_slider, const String &p_suffix) {
+void EditorPropertyRect2i::setup(int p_min, int p_max, bool p_hide_slider, const String &p_suffix) {
for (int i = 0; i < 4; i++) {
spin[i]->set_min(p_min);
spin[i]->set_max(p_max);
spin[i]->set_step(1);
- spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_hide_slider(p_hide_slider);
spin[i]->set_allow_greater(true);
spin[i]->set_allow_lesser(true);
spin[i]->set_suffix(p_suffix);
@@ -2464,12 +2490,12 @@ void EditorPropertyVector3i::_notification(int p_what) {
void EditorPropertyVector3i::_bind_methods() {
}
-void EditorPropertyVector3i::setup(int p_min, int p_max, bool p_no_slider, bool p_link, const String &p_suffix) {
+void EditorPropertyVector3i::setup(int p_min, int p_max, bool p_hide_slider, bool p_link, const String &p_suffix) {
for (int i = 0; i < 3; i++) {
spin[i]->set_min(p_min);
spin[i]->set_max(p_max);
spin[i]->set_step(1);
- spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_hide_slider(p_hide_slider);
spin[i]->set_allow_greater(true);
spin[i]->set_allow_lesser(true);
spin[i]->set_suffix(p_suffix);
@@ -2573,12 +2599,12 @@ void EditorPropertyPlane::_notification(int p_what) {
void EditorPropertyPlane::_bind_methods() {
}
-void EditorPropertyPlane::setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix) {
+void EditorPropertyPlane::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) {
for (int i = 0; i < 4; i++) {
spin[i]->set_min(p_min);
spin[i]->set_max(p_max);
spin[i]->set_step(p_step);
- spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_hide_slider(p_hide_slider);
spin[i]->set_allow_greater(true);
spin[i]->set_allow_lesser(true);
}
@@ -2734,12 +2760,12 @@ void EditorPropertyQuaternion::_notification(int p_what) {
void EditorPropertyQuaternion::_bind_methods() {
}
-void EditorPropertyQuaternion::setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix, bool p_hide_editor) {
+void EditorPropertyQuaternion::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix, bool p_hide_editor) {
for (int i = 0; i < 4; i++) {
spin[i]->set_min(p_min);
spin[i]->set_max(p_max);
spin[i]->set_step(p_step);
- spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_hide_slider(p_hide_slider);
spin[i]->set_allow_greater(true);
spin[i]->set_allow_lesser(true);
// Quaternion is inherently unitless, however someone may want to use it as
@@ -2882,16 +2908,14 @@ void EditorPropertyVector4::_notification(int p_what) {
void EditorPropertyVector4::_bind_methods() {
}
-void EditorPropertyVector4::setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix) {
+void EditorPropertyVector4::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) {
for (int i = 0; i < 4; i++) {
spin[i]->set_min(p_min);
spin[i]->set_max(p_max);
spin[i]->set_step(p_step);
- spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_hide_slider(p_hide_slider);
spin[i]->set_allow_greater(true);
spin[i]->set_allow_lesser(true);
- // Vector4 is inherently unitless, however someone may want to use it as
- // a generic way to store 4 values, so we'll still respect the suffix.
spin[i]->set_suffix(p_suffix);
}
}
@@ -2974,11 +2998,11 @@ void EditorPropertyVector4i::_notification(int p_what) {
void EditorPropertyVector4i::_bind_methods() {
}
-void EditorPropertyVector4i::setup(double p_min, double p_max, bool p_no_slider, const String &p_suffix) {
+void EditorPropertyVector4i::setup(double p_min, double p_max, bool p_hide_slider, const String &p_suffix) {
for (int i = 0; i < 4; i++) {
spin[i]->set_min(p_min);
spin[i]->set_max(p_max);
- spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_hide_slider(p_hide_slider);
spin[i]->set_allow_greater(true);
spin[i]->set_allow_lesser(true);
spin[i]->set_suffix(p_suffix);
@@ -3069,12 +3093,12 @@ void EditorPropertyAABB::_notification(int p_what) {
void EditorPropertyAABB::_bind_methods() {
}
-void EditorPropertyAABB::setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix) {
+void EditorPropertyAABB::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) {
for (int i = 0; i < 6; i++) {
spin[i]->set_min(p_min);
spin[i]->set_max(p_max);
spin[i]->set_step(p_step);
- spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_hide_slider(p_hide_slider);
spin[i]->set_allow_greater(true);
spin[i]->set_allow_lesser(true);
spin[i]->set_suffix(p_suffix);
@@ -3157,12 +3181,12 @@ void EditorPropertyTransform2D::_notification(int p_what) {
void EditorPropertyTransform2D::_bind_methods() {
}
-void EditorPropertyTransform2D::setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix) {
+void EditorPropertyTransform2D::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) {
for (int i = 0; i < 6; i++) {
spin[i]->set_min(p_min);
spin[i]->set_max(p_max);
spin[i]->set_step(p_step);
- spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_hide_slider(p_hide_slider);
spin[i]->set_allow_greater(true);
spin[i]->set_allow_lesser(true);
if (i % 3 == 2) {
@@ -3249,12 +3273,12 @@ void EditorPropertyBasis::_notification(int p_what) {
void EditorPropertyBasis::_bind_methods() {
}
-void EditorPropertyBasis::setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix) {
+void EditorPropertyBasis::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) {
for (int i = 0; i < 9; i++) {
spin[i]->set_min(p_min);
spin[i]->set_max(p_max);
spin[i]->set_step(p_step);
- spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_hide_slider(p_hide_slider);
spin[i]->set_allow_greater(true);
spin[i]->set_allow_lesser(true);
// Basis is inherently unitless, however someone may want to use it as
@@ -3347,12 +3371,12 @@ void EditorPropertyTransform3D::_notification(int p_what) {
void EditorPropertyTransform3D::_bind_methods() {
}
-void EditorPropertyTransform3D::setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix) {
+void EditorPropertyTransform3D::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) {
for (int i = 0; i < 12; i++) {
spin[i]->set_min(p_min);
spin[i]->set_max(p_max);
spin[i]->set_step(p_step);
- spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_hide_slider(p_hide_slider);
spin[i]->set_allow_greater(true);
spin[i]->set_allow_lesser(true);
if (i % 4 == 3) {
@@ -3393,22 +3417,22 @@ void EditorPropertyProjection::_value_changed(double val, const String &p_name)
}
Projection p;
- p.matrix[0][0] = spin[0]->get_value();
- p.matrix[0][1] = spin[1]->get_value();
- p.matrix[0][2] = spin[2]->get_value();
- p.matrix[0][3] = spin[3]->get_value();
- p.matrix[1][0] = spin[4]->get_value();
- p.matrix[1][1] = spin[5]->get_value();
- p.matrix[1][2] = spin[6]->get_value();
- p.matrix[1][3] = spin[7]->get_value();
- p.matrix[2][0] = spin[8]->get_value();
- p.matrix[2][1] = spin[9]->get_value();
- p.matrix[2][2] = spin[10]->get_value();
- p.matrix[2][3] = spin[11]->get_value();
- p.matrix[3][0] = spin[12]->get_value();
- p.matrix[3][1] = spin[13]->get_value();
- p.matrix[3][2] = spin[14]->get_value();
- p.matrix[3][3] = spin[15]->get_value();
+ p.columns[0][0] = spin[0]->get_value();
+ p.columns[0][1] = spin[1]->get_value();
+ p.columns[0][2] = spin[2]->get_value();
+ p.columns[0][3] = spin[3]->get_value();
+ p.columns[1][0] = spin[4]->get_value();
+ p.columns[1][1] = spin[5]->get_value();
+ p.columns[1][2] = spin[6]->get_value();
+ p.columns[1][3] = spin[7]->get_value();
+ p.columns[2][0] = spin[8]->get_value();
+ p.columns[2][1] = spin[9]->get_value();
+ p.columns[2][2] = spin[10]->get_value();
+ p.columns[2][3] = spin[11]->get_value();
+ p.columns[3][0] = spin[12]->get_value();
+ p.columns[3][1] = spin[13]->get_value();
+ p.columns[3][2] = spin[14]->get_value();
+ p.columns[3][3] = spin[15]->get_value();
emit_changed(get_edited_property(), p, p_name);
}
@@ -3419,22 +3443,22 @@ void EditorPropertyProjection::update_property() {
void EditorPropertyProjection::update_using_transform(Projection p_transform) {
setting = true;
- spin[0]->set_value(p_transform.matrix[0][0]);
- spin[1]->set_value(p_transform.matrix[0][1]);
- spin[2]->set_value(p_transform.matrix[0][2]);
- spin[3]->set_value(p_transform.matrix[0][3]);
- spin[4]->set_value(p_transform.matrix[1][0]);
- spin[5]->set_value(p_transform.matrix[1][1]);
- spin[6]->set_value(p_transform.matrix[1][2]);
- spin[7]->set_value(p_transform.matrix[1][3]);
- spin[8]->set_value(p_transform.matrix[2][0]);
- spin[9]->set_value(p_transform.matrix[2][1]);
- spin[10]->set_value(p_transform.matrix[2][2]);
- spin[11]->set_value(p_transform.matrix[2][3]);
- spin[12]->set_value(p_transform.matrix[3][0]);
- spin[13]->set_value(p_transform.matrix[3][1]);
- spin[14]->set_value(p_transform.matrix[3][2]);
- spin[15]->set_value(p_transform.matrix[3][3]);
+ spin[0]->set_value(p_transform.columns[0][0]);
+ spin[1]->set_value(p_transform.columns[0][1]);
+ spin[2]->set_value(p_transform.columns[0][2]);
+ spin[3]->set_value(p_transform.columns[0][3]);
+ spin[4]->set_value(p_transform.columns[1][0]);
+ spin[5]->set_value(p_transform.columns[1][1]);
+ spin[6]->set_value(p_transform.columns[1][2]);
+ spin[7]->set_value(p_transform.columns[1][3]);
+ spin[8]->set_value(p_transform.columns[2][0]);
+ spin[9]->set_value(p_transform.columns[2][1]);
+ spin[10]->set_value(p_transform.columns[2][2]);
+ spin[11]->set_value(p_transform.columns[2][3]);
+ spin[12]->set_value(p_transform.columns[3][0]);
+ spin[13]->set_value(p_transform.columns[3][1]);
+ spin[14]->set_value(p_transform.columns[3][2]);
+ spin[15]->set_value(p_transform.columns[3][3]);
setting = false;
}
@@ -3453,12 +3477,12 @@ void EditorPropertyProjection::_notification(int p_what) {
void EditorPropertyProjection::_bind_methods() {
}
-void EditorPropertyProjection::setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix) {
+void EditorPropertyProjection::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) {
for (int i = 0; i < 16; i++) {
spin[i]->set_min(p_min);
spin[i]->set_max(p_max);
spin[i]->set_step(p_step);
- spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_hide_slider(p_hide_slider);
spin[i]->set_allow_greater(true);
spin[i]->set_allow_lesser(true);
if (i % 4 == 3) {
@@ -3646,8 +3670,8 @@ bool EditorPropertyNodePath::can_drop_data_fw(const Point2 &p_point, const Varia
void EditorPropertyNodePath::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
ERR_FAIL_COND(!is_drop_valid(p_data));
- Dictionary data = p_data;
- Array nodes = data["nodes"];
+ Dictionary data_dict = p_data;
+ Array nodes = data_dict["nodes"];
Node *node = get_tree()->get_edited_scene_root()->get_node(nodes[0]);
if (node) {
@@ -3975,19 +3999,19 @@ void EditorPropertyResource::_update_preferred_shader() {
if (parent_property) {
EditorShaderPicker *shader_picker = Object::cast_to<EditorShaderPicker>(resource_picker);
- Object *object = parent_property->get_edited_object();
- const StringName &property = parent_property->get_edited_property();
+ Object *ed_object = parent_property->get_edited_object();
+ const StringName &ed_property = parent_property->get_edited_property();
// Set preferred shader based on edited parent type.
- if ((Object::cast_to<GPUParticles2D>(object) || Object::cast_to<GPUParticles3D>(object)) && property == SNAME("process_material")) {
+ if ((Object::cast_to<GPUParticles2D>(ed_object) || Object::cast_to<GPUParticles3D>(ed_object)) && ed_property == SNAME("process_material")) {
shader_picker->set_preferred_mode(Shader::MODE_PARTICLES);
- } else if (Object::cast_to<FogVolume>(object)) {
+ } else if (Object::cast_to<FogVolume>(ed_object)) {
shader_picker->set_preferred_mode(Shader::MODE_FOG);
- } else if (Object::cast_to<CanvasItem>(object)) {
+ } else if (Object::cast_to<CanvasItem>(ed_object)) {
shader_picker->set_preferred_mode(Shader::MODE_CANVAS_ITEM);
- } else if (Object::cast_to<Node3D>(object) || Object::cast_to<Mesh>(object)) {
+ } else if (Object::cast_to<Node3D>(ed_object) || Object::cast_to<Mesh>(ed_object)) {
shader_picker->set_preferred_mode(Shader::MODE_SPATIAL);
- } else if (Object::cast_to<Sky>(object)) {
+ } else if (Object::cast_to<Sky>(ed_object)) {
shader_picker->set_preferred_mode(Shader::MODE_SKY);
}
}
@@ -4218,7 +4242,7 @@ static EditorPropertyRangeHint _parse_range_hint(PropertyHint p_hint, const Stri
hint.or_greater = true;
} else if (slice == "or_less") {
hint.or_less = true;
- } else if (slice == "no_slider") {
+ } else if (slice == "hide_slider") {
hint.hide_slider = true;
} else if (slice == "exp") {
hint.exp_range = true;
diff --git a/editor/editor_properties.h b/editor/editor_properties.h
index d6c9510634..20b130f57f 100644
--- a/editor/editor_properties.h
+++ b/editor/editor_properties.h
@@ -357,6 +357,7 @@ protected:
public:
void setup(LayerType p_layer_type);
void set_layer_name(int p_index, const String &p_name);
+ String get_layer_name(int p_index) const;
virtual void update_property() override;
EditorPropertyLayers();
};
@@ -433,7 +434,7 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_no_slider, bool p_exp_range, bool p_greater, bool p_lesser, const String &p_suffix = String(), bool p_angle_in_radians = false);
+ void setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_exp_range, bool p_greater, bool p_lesser, const String &p_suffix = String(), bool p_angle_in_radians = false);
EditorPropertyFloat();
};
@@ -496,7 +497,7 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_no_slider, bool p_link = false, const String &p_suffix = String());
+ void setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_link = false, const String &p_suffix = String());
EditorPropertyVector2(bool p_force_wide = false);
};
@@ -513,7 +514,7 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
+ void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
EditorPropertyRect2(bool p_force_wide = false);
};
@@ -541,7 +542,7 @@ public:
virtual void update_property() override;
virtual void update_using_vector(Vector3 p_vector);
virtual Vector3 get_vector();
- void setup(double p_min, double p_max, double p_step, bool p_no_slider, bool p_link = false, const String &p_suffix = String(), bool p_angle_in_radians = false);
+ void setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_link = false, const String &p_suffix = String(), bool p_angle_in_radians = false);
EditorPropertyVector3(bool p_force_wide = false);
};
@@ -561,7 +562,7 @@ protected:
public:
virtual void update_property() override;
- void setup(int p_min, int p_max, bool p_no_slider, bool p_link = false, const String &p_suffix = String());
+ void setup(int p_min, int p_max, bool p_hide_slider, bool p_link = false, const String &p_suffix = String());
EditorPropertyVector2i(bool p_force_wide = false);
};
@@ -578,7 +579,7 @@ protected:
public:
virtual void update_property() override;
- void setup(int p_min, int p_max, bool p_no_slider, const String &p_suffix = String());
+ void setup(int p_min, int p_max, bool p_hide_slider, const String &p_suffix = String());
EditorPropertyRect2i(bool p_force_wide = false);
};
@@ -603,7 +604,7 @@ protected:
public:
virtual void update_property() override;
- void setup(int p_min, int p_max, bool p_no_slider, bool p_link = false, const String &p_suffix = String());
+ void setup(int p_min, int p_max, bool p_hide_slider, bool p_link = false, const String &p_suffix = String());
EditorPropertyVector3i(bool p_force_wide = false);
};
@@ -620,7 +621,7 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
+ void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
EditorPropertyPlane(bool p_force_wide = false);
};
@@ -654,7 +655,7 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String(), bool p_hide_editor = false);
+ void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String(), bool p_hide_editor = false);
EditorPropertyQuaternion();
};
@@ -671,7 +672,7 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
+ void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
EditorPropertyVector4();
};
@@ -688,7 +689,7 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, bool p_no_slider, const String &p_suffix = String());
+ void setup(double p_min, double p_max, bool p_hide_slider, const String &p_suffix = String());
EditorPropertyVector4i();
};
@@ -705,7 +706,7 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
+ void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
EditorPropertyAABB();
};
@@ -722,7 +723,7 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
+ void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
EditorPropertyTransform2D(bool p_include_origin = true);
};
@@ -739,7 +740,7 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
+ void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
EditorPropertyBasis();
};
@@ -757,7 +758,7 @@ protected:
public:
virtual void update_property() override;
virtual void update_using_transform(Transform3D p_transform);
- void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
+ void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
EditorPropertyTransform3D();
};
@@ -775,7 +776,7 @@ protected:
public:
virtual void update_property() override;
virtual void update_using_transform(Projection p_transform);
- void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
+ void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
EditorPropertyProjection();
};
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index 728a3b0f80..d98ad117d7 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -260,9 +260,9 @@ void EditorPropertyArray::update_property() {
HBoxContainer *hbox = memnew(HBoxContainer);
vbox->add_child(hbox);
- Label *label = memnew(Label(TTR("Size:")));
- label->set_h_size_flags(SIZE_EXPAND_FILL);
- hbox->add_child(label);
+ Label *size_label = memnew(Label(TTR("Size:")));
+ size_label->set_h_size_flags(SIZE_EXPAND_FILL);
+ hbox->add_child(size_label);
size_slider = memnew(EditorSpinSlider);
size_slider->set_step(1);
@@ -367,17 +367,17 @@ void EditorPropertyArray::update_property() {
bool is_untyped_array = array.get_type() == Variant::ARRAY && subtype == Variant::NIL;
if (is_untyped_array) {
- Button *edit = memnew(Button);
- edit->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
- hbox->add_child(edit);
- edit->set_disabled(is_read_only());
- edit->connect("pressed", callable_mp(this, &EditorPropertyArray::_change_type).bind(edit, i + offset));
+ Button *edit_btn = memnew(Button);
+ edit_btn->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
+ hbox->add_child(edit_btn);
+ edit_btn->set_disabled(is_read_only());
+ edit_btn->connect("pressed", callable_mp(this, &EditorPropertyArray::_change_type).bind(edit_btn, i + offset));
} else {
- Button *remove = memnew(Button);
- remove->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
- remove->set_disabled(is_read_only());
- remove->connect("pressed", callable_mp(this, &EditorPropertyArray::_remove_pressed).bind(i + offset));
- hbox->add_child(remove);
+ Button *remove_btn = memnew(Button);
+ remove_btn->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
+ remove_btn->set_disabled(is_read_only());
+ remove_btn->connect("pressed", callable_mp(this, &EditorPropertyArray::_remove_pressed).bind(i + offset));
+ hbox->add_child(remove_btn);
}
prop->update_property();
@@ -1155,11 +1155,11 @@ void EditorPropertyDictionary::update_property() {
}
hbox->add_child(prop);
prop->set_h_size_flags(SIZE_EXPAND_FILL);
- Button *edit = memnew(Button);
- edit->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
- edit->set_disabled(is_read_only());
- hbox->add_child(edit);
- edit->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_change_type).bind(edit, change_index));
+ Button *edit_btn = memnew(Button);
+ edit_btn->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
+ edit_btn->set_disabled(is_read_only());
+ hbox->add_child(edit_btn);
+ edit_btn->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_change_type).bind(edit_btn, change_index));
prop->update_property();
@@ -1396,10 +1396,10 @@ void EditorPropertyLocalizableString::update_property() {
property_vbox->add_child(hbox);
hbox->add_child(prop);
prop->set_h_size_flags(SIZE_EXPAND_FILL);
- Button *edit = memnew(Button);
- edit->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
- hbox->add_child(edit);
- edit->connect("pressed", callable_mp(this, &EditorPropertyLocalizableString::_remove_item).bind(edit, remove_index));
+ Button *edit_btn = memnew(Button);
+ edit_btn->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
+ hbox->add_child(edit_btn);
+ edit_btn->connect("pressed", callable_mp(this, &EditorPropertyLocalizableString::_remove_item).bind(edit_btn, remove_index));
prop->update_property();
}
diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp
index f89aef4cc3..01816b7205 100644
--- a/editor/editor_resource_picker.cpp
+++ b/editor/editor_resource_picker.cpp
@@ -96,9 +96,9 @@ void EditorResourcePicker::_update_resource_preview(const String &p_path, const
}
if (preview_rect) {
- Ref<Script> script = edited_resource;
- if (script.is_valid()) {
- assign_button->set_text(script->get_path().get_file());
+ Ref<Script> scr = edited_resource;
+ if (scr.is_valid()) {
+ assign_button->set_text(scr->get_path().get_file());
return;
}
@@ -981,8 +981,8 @@ void EditorScriptPicker::set_create_options(Object *p_menu_node) {
menu_node->add_icon_item(get_theme_icon(SNAME("ScriptCreate"), SNAME("EditorIcons")), TTR("New Script"), OBJ_MENU_NEW_SCRIPT);
if (script_owner) {
- Ref<Script> script = script_owner->get_script();
- if (script.is_valid()) {
+ Ref<Script> scr = script_owner->get_script();
+ if (scr.is_valid()) {
menu_node->add_icon_item(get_theme_icon(SNAME("ScriptExtend"), SNAME("EditorIcons")), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT);
}
}
@@ -1040,12 +1040,12 @@ void EditorShaderPicker::set_create_options(Object *p_menu_node) {
}
bool EditorShaderPicker::handle_menu_selected(int p_which) {
- Ref<ShaderMaterial> material = Ref<ShaderMaterial>(get_edited_material());
+ Ref<ShaderMaterial> ed_material = Ref<ShaderMaterial>(get_edited_material());
switch (p_which) {
case OBJ_MENU_NEW_SHADER: {
- if (material.is_valid()) {
- SceneTreeDock::get_singleton()->open_shader_dialog(material, preferred_mode);
+ if (ed_material.is_valid()) {
+ SceneTreeDock::get_singleton()->open_shader_dialog(ed_material, preferred_mode);
return true;
}
} break;
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index 706b77c142..33de63e63d 100644
--- a/editor/editor_resource_preview.cpp
+++ b/editor/editor_resource_preview.cpp
@@ -41,7 +41,7 @@
#include "editor/editor_settings.h"
bool EditorResourcePreviewGenerator::handles(const String &p_type) const {
- bool success;
+ bool success = false;
if (GDVIRTUAL_CALL(_handles, p_type, success)) {
return success;
}
@@ -70,7 +70,7 @@ Ref<Texture2D> EditorResourcePreviewGenerator::generate_from_path(const String &
}
bool EditorResourcePreviewGenerator::generate_small_preview_automatically() const {
- bool success;
+ bool success = false;
if (GDVIRTUAL_CALL(_generate_small_preview_automatically, success)) {
return success;
}
@@ -79,7 +79,7 @@ bool EditorResourcePreviewGenerator::generate_small_preview_automatically() cons
}
bool EditorResourcePreviewGenerator::can_generate_small_preview() const {
- bool success;
+ bool success = false;
if (GDVIRTUAL_CALL(_can_generate_small_preview, success)) {
return success;
}
diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp
index e078bea037..ae47bbe864 100644
--- a/editor/editor_sectioned_inspector.cpp
+++ b/editor/editor_sectioned_inspector.cpp
@@ -151,7 +151,9 @@ void SectionedInspector::_section_selected() {
void SectionedInspector::set_current_section(const String &p_section) {
if (section_map.has(p_section)) {
- section_map[p_section]->select(0);
+ TreeItem *item = section_map[p_section];
+ item->select(0);
+ sections->scroll_to_item(item);
}
}
@@ -226,9 +228,9 @@ void SectionedInspector::update_category_list() {
TreeItem *root = sections->create_item();
section_map[""] = root;
- String filter;
+ String filter_text;
if (search_box) {
- filter = search_box->get_text();
+ filter_text = search_box->get_text();
}
const EditorPropertyNameProcessor::Style name_style = EditorPropertyNameProcessor::get_settings_style();
@@ -245,7 +247,7 @@ void SectionedInspector::update_category_list() {
continue;
}
- if (!filter.is_empty() && !_property_path_matches(pi.name, filter, name_style)) {
+ if (!filter_text.is_empty() && !_property_path_matches(pi.name, filter_text, name_style)) {
continue;
}
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 74445e6caa..5bdfd8d377 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -76,14 +76,14 @@ bool EditorSettings::_set_only(const StringName &p_name, const Variant &p_value)
Array arr = p_value;
for (int i = 0; i < arr.size(); i++) {
Dictionary dict = arr[i];
- String name = dict["name"];
+ String shortcut_name = dict["name"];
Array shortcut_events = dict["shortcuts"];
Ref<Shortcut> sc;
sc.instantiate();
sc->set_events(shortcut_events);
- add_shortcut(name, sc);
+ add_shortcut(shortcut_name, sc);
}
return false;
@@ -92,16 +92,16 @@ bool EditorSettings::_set_only(const StringName &p_name, const Variant &p_value)
for (int i = 0; i < actions_arr.size(); i++) {
Dictionary action_dict = actions_arr[i];
- String name = action_dict["name"];
+ String action_name = action_dict["name"];
Array events = action_dict["events"];
InputMap *im = InputMap::get_singleton();
- im->action_erase_events(name);
+ im->action_erase_events(action_name);
- builtin_action_overrides[name].clear();
+ builtin_action_overrides[action_name].clear();
for (int ev_idx = 0; ev_idx < events.size(); ev_idx++) {
- im->action_add_event(name, events[ev_idx]);
- builtin_action_overrides[name].push_back(events[ev_idx]);
+ im->action_add_event(action_name, events[ev_idx]);
+ builtin_action_overrides[action_name].push_back(events[ev_idx]);
}
}
return false;
@@ -438,6 +438,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
EDITOR_SETTING_USAGE(Variant::BOOL, PROPERTY_HINT_NONE, "interface/editor/single_window_mode", false, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED)
_initial_set("interface/editor/mouse_extra_buttons_navigate_history", true);
_initial_set("interface/editor/save_each_scene_on_quit", true); // Regression
+ EDITOR_SETTING_USAGE(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/accept_dialog_cancel_ok_buttons", 0,
+ vformat("Auto (%s),Cancel First,OK First", DisplayServer::get_singleton()->get_swap_cancel_ok() ? "OK First" : "Cancel First"),
+ PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
#ifdef DEV_ENABLED
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/show_internal_errors_in_toast_notifications", 0, "Auto (Enabled),Enabled,Disabled")
#else
@@ -735,8 +738,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
if (p_extra_config->has_section("init_projects") && p_extra_config->has_section_key("init_projects", "list")) {
Vector<String> list = p_extra_config->get_value("init_projects", "list");
for (int i = 0; i < list.size(); i++) {
- String name = list[i].replace("/", "::");
- set("projects/" + name, list[i]);
+ String proj_name = list[i].replace("/", "::");
+ set("projects/" + proj_name, list[i]);
}
}
diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp
index 2c09543d92..db501aac03 100644
--- a/editor/editor_settings_dialog.cpp
+++ b/editor/editor_settings_dialog.cpp
@@ -41,6 +41,8 @@
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
+#include "editor/event_listener_line_edit.h"
+#include "editor/input_event_configuration_dialog.h"
#include "scene/gui/margin_container.h"
void EditorSettingsDialog::ok_pressed() {
@@ -106,11 +108,16 @@ void EditorSettingsDialog::popup_edit_settings() {
_focus_current_search_box();
}
-void EditorSettingsDialog::_filter_shortcuts(const String &p_filter) {
- shortcut_filter = p_filter;
+void EditorSettingsDialog::_filter_shortcuts(const String &) {
_update_shortcuts();
}
+void EditorSettingsDialog::_filter_shortcuts_by_event(const Ref<InputEvent> &p_event) {
+ if (p_event.is_null() || (p_event->is_pressed() && !p_event->is_echo())) {
+ _update_shortcuts();
+ }
+}
+
void EditorSettingsDialog::_undo_redo_callback(void *p_self, const String &p_name) {
EditorNode::get_log()->add_message(p_name, EditorLog::MSG_TYPE_EDITOR);
}
@@ -326,6 +333,22 @@ void EditorSettingsDialog::_create_shortcut_treeitem(TreeItem *p_parent, const S
}
}
+bool EditorSettingsDialog::_should_display_shortcut(const String &p_name, const Array &p_events) const {
+ const Ref<InputEvent> search_ev = shortcut_search_by_event->get_event();
+ bool event_match = true;
+ if (search_ev.is_valid()) {
+ event_match = false;
+ for (int i = 0; i < p_events.size(); ++i) {
+ const Ref<InputEvent> ev = p_events[i];
+ if (ev.is_valid() && ev->is_match(search_ev, true)) {
+ event_match = true;
+ }
+ }
+ }
+
+ return event_match && shortcut_search_box->get_text().is_subsequence_ofn(p_name);
+}
+
void EditorSettingsDialog::_update_shortcuts() {
// Before clearing the tree, take note of which categories are collapsed so that this state can be maintained when the tree is repopulated.
HashMap<String, bool> collapsed;
@@ -379,32 +402,17 @@ void EditorSettingsDialog::_update_shortcuts() {
const String &action_name = E.key;
const InputMap::Action &action = E.value;
- Array events; // Need to get the list of events into an array so it can be set as metadata on the item.
- Vector<String> event_strings;
-
// Skip non-builtin actions.
if (!InputMap::get_singleton()->get_builtins_with_feature_overrides_applied().has(action_name)) {
continue;
}
const List<Ref<InputEvent>> &all_default_events = InputMap::get_singleton()->get_builtins_with_feature_overrides_applied().find(action_name)->value;
- List<Ref<InputEventKey>> key_default_events;
- // Remove all non-key events from the defaults. Only check keys, since we are in the editor.
- for (const List<Ref<InputEvent>>::Element *I = all_default_events.front(); I; I = I->next()) {
- Ref<InputEventKey> k = I->get();
- if (k.is_valid()) {
- key_default_events.push_back(k);
- }
- }
-
- // Join the text of the events with a delimiter so they can all be displayed in one cell.
- String events_display_string = event_strings.is_empty() ? "None" : String("; ").join(event_strings);
-
- if (!shortcut_filter.is_subsequence_ofn(action_name) && (events_display_string == "None" || !shortcut_filter.is_subsequence_ofn(events_display_string))) {
+ Array action_events = _event_list_to_array_helper(action.inputs);
+ if (!_should_display_shortcut(action_name, action_events)) {
continue;
}
- Array action_events = _event_list_to_array_helper(action.inputs);
Array default_events = _event_list_to_array_helper(all_default_events);
bool same_as_defaults = Shortcut::is_event_array_equal(default_events, action_events);
bool collapse = !collapsed.has(action_name) || (collapsed.has(action_name) && collapsed[action_name]);
@@ -459,8 +467,7 @@ void EditorSettingsDialog::_update_shortcuts() {
String section_name = E.get_slice("/", 0);
TreeItem *section = sections[section_name];
- // Shortcut Item
- if (!shortcut_filter.is_subsequence_ofn(sc->get_name())) {
+ if (!_should_display_shortcut(sc->get_name(), sc->get_events())) {
continue;
}
@@ -749,12 +756,29 @@ EditorSettingsDialog::EditorSettingsDialog() {
tabs->add_child(tab_shortcuts);
tab_shortcuts->set_name(TTR("Shortcuts"));
+ HBoxContainer *top_hbox = memnew(HBoxContainer);
+ top_hbox->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ tab_shortcuts->add_child(top_hbox);
+
shortcut_search_box = memnew(LineEdit);
- shortcut_search_box->set_placeholder(TTR("Filter Shortcuts"));
+ shortcut_search_box->set_placeholder(TTR("Filter by name..."));
shortcut_search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- tab_shortcuts->add_child(shortcut_search_box);
+ top_hbox->add_child(shortcut_search_box);
shortcut_search_box->connect("text_changed", callable_mp(this, &EditorSettingsDialog::_filter_shortcuts));
+ shortcut_search_by_event = memnew(EventListenerLineEdit);
+ shortcut_search_by_event->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ shortcut_search_by_event->set_stretch_ratio(0.75);
+ shortcut_search_by_event->set_allowed_input_types(INPUT_KEY);
+ shortcut_search_by_event->connect("event_changed", callable_mp(this, &EditorSettingsDialog::_filter_shortcuts_by_event));
+ top_hbox->add_child(shortcut_search_by_event);
+
+ Button *clear_all_search = memnew(Button);
+ clear_all_search->set_text(TTR("Clear All"));
+ clear_all_search->connect("pressed", callable_mp(shortcut_search_box, &LineEdit::clear));
+ clear_all_search->connect("pressed", callable_mp(shortcut_search_by_event, &EventListenerLineEdit::clear_event));
+ top_hbox->add_child(clear_all_search);
+
shortcuts = memnew(Tree);
shortcuts->set_v_size_flags(Control::SIZE_EXPAND_FILL);
shortcuts->set_columns(2);
@@ -771,8 +795,7 @@ EditorSettingsDialog::EditorSettingsDialog() {
// Adding event dialog
shortcut_editor = memnew(InputEventConfigurationDialog);
shortcut_editor->connect("confirmed", callable_mp(this, &EditorSettingsDialog::_event_config_confirmed));
- shortcut_editor->set_allowed_input_types(InputEventConfigurationDialog::InputType::INPUT_KEY);
- shortcut_editor->set_close_on_escape(false);
+ shortcut_editor->set_allowed_input_types(INPUT_KEY);
add_child(shortcut_editor);
set_hide_on_ok(true);
diff --git a/editor/editor_settings_dialog.h b/editor/editor_settings_dialog.h
index 87ed6a77eb..05424a64ed 100644
--- a/editor/editor_settings_dialog.h
+++ b/editor/editor_settings_dialog.h
@@ -53,6 +53,7 @@ class EditorSettingsDialog : public AcceptDialog {
LineEdit *search_box = nullptr;
LineEdit *shortcut_search_box = nullptr;
+ EventListenerLineEdit *shortcut_search_by_event = nullptr;
SectionedInspector *inspector = nullptr;
// Shortcuts
@@ -64,7 +65,6 @@ class EditorSettingsDialog : public AcceptDialog {
};
Tree *shortcuts = nullptr;
- String shortcut_filter;
InputEventConfigurationDialog *shortcut_editor = nullptr;
@@ -103,13 +103,13 @@ class EditorSettingsDialog : public AcceptDialog {
void _focus_current_search_box();
void _filter_shortcuts(const String &p_filter);
+ void _filter_shortcuts_by_event(const Ref<InputEvent> &p_event);
+ bool _should_display_shortcut(const String &p_name, const Array &p_events) const;
void _update_shortcuts();
void _shortcut_button_pressed(Object *p_item, int p_column, int p_idx, MouseButton p_button = MouseButton::LEFT);
void _shortcut_cell_double_clicked();
- void _builtin_action_popup_index_pressed(int p_index);
-
static void _undo_redo_callback(void *p_self, const String &p_name);
Label *restart_label = nullptr;
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index 5edb6d877c..1cdfceebc8 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -143,7 +143,7 @@ void EditorSpinSlider::gui_input(const Ref<InputEvent> &p_event) {
}
Ref<InputEventKey> k = p_event;
- if (k.is_valid() && k->is_pressed() && k->is_action("ui_accept")) {
+ if (k.is_valid() && k->is_pressed() && k->is_action("ui_accept", true)) {
_focus_entered();
}
}
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index f4c1f308cc..1d9e320be1 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -564,9 +564,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_color("readonly_color", "Editor", readonly_color);
if (!dark_theme) {
- theme->set_color("vulkan_color", "Editor", Color::hex(0xad1128ff));
+ theme->set_color("highend_color", "Editor", Color::hex(0xad1128ff));
} else {
- theme->set_color("vulkan_color", "Editor", Color(1.0, 0.0, 0.0));
+ theme->set_color("highend_color", "Editor", Color(1.0, 0.0, 0.0));
}
const int thumb_size = EDITOR_GET("filesystem/file_dialog/thumbnail_size");
theme->set_constant("scale", "Editor", EDSCALE);
@@ -1471,6 +1471,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_stylebox("slider", "HSlider", make_flat_stylebox(dark_color_3, 0, default_margin_size / 2, 0, default_margin_size / 2, corner_width));
theme->set_stylebox("grabber_area", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2, corner_width));
theme->set_stylebox("grabber_area_highlight", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2));
+ theme->set_constant("grabber_offset", "HSlider", 0);
// VSlider
theme->set_icon("grabber", "VSlider", theme->get_icon(SNAME("GuiSliderGrabber"), SNAME("EditorIcons")));
@@ -1478,6 +1479,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_stylebox("slider", "VSlider", make_flat_stylebox(dark_color_3, default_margin_size / 2, 0, default_margin_size / 2, 0, corner_width));
theme->set_stylebox("grabber_area", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0, corner_width));
theme->set_stylebox("grabber_area_highlight", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0));
+ theme->set_constant("grabber_offset", "VSlider", 0);
// RichTextLabel
theme->set_color("default_color", "RichTextLabel", font_color);
@@ -1714,6 +1716,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_constant("h_width", "ColorPicker", 30 * EDSCALE);
theme->set_constant("label_width", "ColorPicker", 10 * EDSCALE);
theme->set_icon("screen_picker", "ColorPicker", theme->get_icon(SNAME("ColorPick"), SNAME("EditorIcons")));
+ theme->set_icon("shape_circle", "ColorPicker", theme->get_icon(SNAME("PickerShapeCircle"), SNAME("EditorIcons")));
+ theme->set_icon("shape_rect", "ColorPicker", theme->get_icon(SNAME("PickerShapeRectangle"), SNAME("EditorIcons")));
+ theme->set_icon("shape_rect_wheel", "ColorPicker", theme->get_icon(SNAME("PickerShapeRectangleWheel"), SNAME("EditorIcons")));
theme->set_icon("add_preset", "ColorPicker", theme->get_icon(SNAME("Add"), SNAME("EditorIcons")));
theme->set_icon("sample_bg", "ColorPicker", theme->get_icon(SNAME("GuiMiniCheckerboard"), SNAME("EditorIcons")));
theme->set_icon("overbright_indicator", "ColorPicker", theme->get_icon(SNAME("OverbrightIndicator"), SNAME("EditorIcons")));
diff --git a/editor/editor_toaster.cpp b/editor/editor_toaster.cpp
index 6a5242f0c6..6b2cc99df9 100644
--- a/editor/editor_toaster.cpp
+++ b/editor/editor_toaster.cpp
@@ -78,19 +78,19 @@ void EditorToaster::_notification(int p_what) {
// Change alpha over time.
bool needs_update = false;
for (const KeyValue<Control *, Toast> &element : toasts) {
- Color modulate = element.key->get_modulate();
+ Color modulate_fade = element.key->get_modulate();
// Change alpha over time.
- if (element.value.popped && modulate.a < 1.0) {
- modulate.a += delta * 3;
- element.key->set_modulate(modulate);
- } else if (!element.value.popped && modulate.a > 0.0) {
- modulate.a -= delta * 2;
- element.key->set_modulate(modulate);
+ if (element.value.popped && modulate_fade.a < 1.0) {
+ modulate_fade.a += delta * 3;
+ element.key->set_modulate(modulate_fade);
+ } else if (!element.value.popped && modulate_fade.a > 0.0) {
+ modulate_fade.a -= delta * 2;
+ element.key->set_modulate(modulate_fade);
}
// Hide element if it is not visible anymore.
- if (modulate.a <= 0) {
+ if (modulate_fade.a <= 0) {
if (element.key->is_visible()) {
element.key->hide();
needs_update = true;
@@ -317,7 +317,7 @@ void EditorToaster::_set_notifications_enabled(bool p_enabled) {
void EditorToaster::_repop_old() {
// Repop olds, up to max_temporary_count
bool needs_update = false;
- int visible = 0;
+ int visible_count = 0;
for (int i = vbox_container->get_child_count() - 1; i >= 0; i--) {
Control *control = Object::cast_to<Control>(vbox_container->get_child(i));
if (!control->is_visible()) {
@@ -326,8 +326,8 @@ void EditorToaster::_repop_old() {
toasts[control].popped = true;
needs_update = true;
}
- visible++;
- if (visible >= max_temporary_count) {
+ visible_count++;
+ if (visible_count >= max_temporary_count) {
break;
}
}
diff --git a/editor/editor_zoom_widget.cpp b/editor/editor_zoom_widget.cpp
index 88e99d9b30..8e820f41ee 100644
--- a/editor/editor_zoom_widget.cpp
+++ b/editor/editor_zoom_widget.cpp
@@ -161,13 +161,19 @@ void EditorZoomWidget::_bind_methods() {
ADD_SIGNAL(MethodInfo("zoom_changed", PropertyInfo(Variant::FLOAT, "zoom")));
}
+void EditorZoomWidget::set_shortcut_context(Node *p_node) const {
+ zoom_minus->set_shortcut_context(p_node);
+ zoom_plus->set_shortcut_context(p_node);
+ zoom_reset->set_shortcut_context(p_node);
+}
+
EditorZoomWidget::EditorZoomWidget() {
// Zoom buttons
zoom_minus = memnew(Button);
zoom_minus->set_flat(true);
add_child(zoom_minus);
zoom_minus->connect("pressed", callable_mp(this, &EditorZoomWidget::_button_zoom_minus));
- zoom_minus->set_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_minus", TTR("Zoom Out"), KeyModifierMask::CMD_OR_CTRL | Key::MINUS));
+ zoom_minus->set_shortcut(ED_SHORTCUT_ARRAY("canvas_item_editor/zoom_minus", TTR("Zoom Out"), { int32_t(KeyModifierMask::CMD_OR_CTRL | Key::MINUS), int32_t(KeyModifierMask::CMD_OR_CTRL | Key::KP_SUBTRACT) }));
zoom_minus->set_shortcut_context(this);
zoom_minus->set_focus_mode(FOCUS_NONE);
@@ -189,7 +195,7 @@ EditorZoomWidget::EditorZoomWidget() {
zoom_plus->set_flat(true);
add_child(zoom_plus);
zoom_plus->connect("pressed", callable_mp(this, &EditorZoomWidget::_button_zoom_plus));
- zoom_plus->set_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_plus", TTR("Zoom In"), KeyModifierMask::CMD_OR_CTRL | Key::EQUAL)); // Usually direct access key for PLUS
+ zoom_plus->set_shortcut(ED_SHORTCUT_ARRAY("canvas_item_editor/zoom_plus", TTR("Zoom In"), { int32_t(KeyModifierMask::CMD_OR_CTRL | Key::EQUAL), int32_t(KeyModifierMask::CMD_OR_CTRL | Key::KP_ADD) }));
zoom_plus->set_shortcut_context(this);
zoom_plus->set_focus_mode(FOCUS_NONE);
diff --git a/editor/editor_zoom_widget.h b/editor/editor_zoom_widget.h
index 4690a57a2b..995b9e1808 100644
--- a/editor/editor_zoom_widget.h
+++ b/editor/editor_zoom_widget.h
@@ -57,6 +57,8 @@ public:
float get_zoom();
void set_zoom(float p_zoom);
void set_zoom_by_increments(int p_increment_count, bool p_integer_only = false);
+ // Sets the shortcut context for the zoom buttons. By default their context is this EditorZoomWidget control.
+ void set_shortcut_context(Node *p_node) const;
};
#endif // EDITOR_ZOOM_WIDGET_H
diff --git a/editor/event_listener_line_edit.cpp b/editor/event_listener_line_edit.cpp
new file mode 100644
index 0000000000..14e482432a
--- /dev/null
+++ b/editor/event_listener_line_edit.cpp
@@ -0,0 +1,131 @@
+/*************************************************************************/
+/* event_listener_line_edit.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "editor/event_listener_line_edit.h"
+
+bool EventListenerLineEdit::_is_event_allowed(const Ref<InputEvent> &p_event) const {
+ const Ref<InputEventMouseButton> mb = p_event;
+ const Ref<InputEventKey> k = p_event;
+ const Ref<InputEventJoypadButton> jb = p_event;
+ const Ref<InputEventJoypadMotion> jm = p_event;
+
+ return (mb.is_valid() && (allowed_input_types & INPUT_MOUSE_BUTTON)) ||
+ (k.is_valid() && (allowed_input_types & INPUT_KEY)) ||
+ (jb.is_valid() && (allowed_input_types & INPUT_JOY_BUTTON)) ||
+ (jm.is_valid() && (allowed_input_types & INPUT_JOY_MOTION));
+}
+
+void EventListenerLineEdit::gui_input(const Ref<InputEvent> &p_event) {
+ const Ref<InputEventMouseMotion> mm = p_event;
+ if (mm.is_valid()) {
+ LineEdit::gui_input(p_event);
+ return;
+ }
+
+ // Allow mouse button click on the clear button without being treated as an event.
+ const Ref<InputEventMouseButton> b = p_event;
+ if (b.is_valid() && _is_over_clear_button(b->get_position())) {
+ LineEdit::gui_input(p_event);
+ return;
+ }
+
+ // First event will be an event which is used to focus this control - i.e. a mouse click, or a tab press.
+ // Ignore the first one so that clicking into the LineEdit does not override the current event.
+ // Ignore is reset to true when the control is unfocused.
+ if (ignore) {
+ ignore = false;
+ return;
+ }
+
+ accept_event();
+ if (!p_event->is_pressed() || p_event->is_echo() || p_event->is_match(event) || !_is_event_allowed(p_event)) {
+ return;
+ }
+
+ event = p_event;
+ set_text(event->as_text());
+ emit_signal("event_changed", event);
+}
+
+void EventListenerLineEdit::_on_text_changed(const String &p_text) {
+ if (p_text.is_empty()) {
+ clear_event();
+ }
+}
+
+void EventListenerLineEdit::_on_focus() {
+ set_placeholder(TTR("Listening for input..."));
+}
+
+void EventListenerLineEdit::_on_unfocus() {
+ ignore = true;
+ set_placeholder(TTR("Filter by event..."));
+}
+
+Ref<InputEvent> EventListenerLineEdit::get_event() const {
+ return event;
+}
+
+void EventListenerLineEdit::clear_event() {
+ if (event.is_valid()) {
+ event = Ref<InputEvent>();
+ set_text("");
+ emit_signal("event_changed", event);
+ }
+}
+
+void EventListenerLineEdit::set_allowed_input_types(int input_types) {
+ allowed_input_types = input_types;
+}
+
+int EventListenerLineEdit::get_allowed_input_types() const {
+ return allowed_input_types;
+}
+
+void EventListenerLineEdit::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ connect("text_changed", callable_mp(this, &EventListenerLineEdit::_on_text_changed));
+ connect("focus_entered", callable_mp(this, &EventListenerLineEdit::_on_focus));
+ connect("focus_exited", callable_mp(this, &EventListenerLineEdit::_on_unfocus));
+ set_right_icon(get_theme_icon(SNAME("Keyboard"), SNAME("EditorIcons")));
+ set_clear_button_enabled(true);
+ } break;
+ }
+}
+
+void EventListenerLineEdit::_bind_methods() {
+ ADD_SIGNAL(MethodInfo("event_changed", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
+}
+
+EventListenerLineEdit::EventListenerLineEdit() {
+ set_caret_blink_enabled(false);
+ set_placeholder(TTR("Filter by event..."));
+}
diff --git a/editor/event_listener_line_edit.h b/editor/event_listener_line_edit.h
new file mode 100644
index 0000000000..5b415e8a2d
--- /dev/null
+++ b/editor/event_listener_line_edit.h
@@ -0,0 +1,74 @@
+/*************************************************************************/
+/* event_listener_line_edit.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef EVENT_LISTENER_LINE_EDIT_H
+#define EVENT_LISTENER_LINE_EDIT_H
+
+#include "scene/gui/line_edit.h"
+
+enum InputType {
+ INPUT_KEY = 1,
+ INPUT_MOUSE_BUTTON = 2,
+ INPUT_JOY_BUTTON = 4,
+ INPUT_JOY_MOTION = 8
+};
+
+class EventListenerLineEdit : public LineEdit {
+ GDCLASS(EventListenerLineEdit, LineEdit)
+
+ int allowed_input_types = INPUT_KEY | INPUT_MOUSE_BUTTON | INPUT_JOY_BUTTON | INPUT_JOY_MOTION;
+ bool ignore = true;
+ bool share_keycodes = false;
+ Ref<InputEvent> event;
+
+ bool _is_event_allowed(const Ref<InputEvent> &p_event) const;
+
+ void gui_input(const Ref<InputEvent> &p_event) override;
+ void _on_text_changed(const String &p_text);
+
+ void _on_focus();
+ void _on_unfocus();
+
+protected:
+ void _notification(int p_what);
+ static void _bind_methods();
+
+public:
+ Ref<InputEvent> get_event() const;
+ void clear_event();
+
+ void set_allowed_input_types(int input_types);
+ int get_allowed_input_types() const;
+
+public:
+ EventListenerLineEdit();
+};
+
+#endif // EVENT_LISTENER_LINE_EDIT_H
diff --git a/editor/export/editor_export_platform.h b/editor/export/editor_export_platform.h
index 88dc7bd5cd..5db79b98d1 100644
--- a/editor/export/editor_export_platform.h
+++ b/editor/export/editor_export_platform.h
@@ -144,6 +144,7 @@ public:
};
virtual Ref<EditorExportPreset> create_preset();
+ virtual bool is_executable(const String &p_path) const { return false; }
virtual void clear_messages() { messages.clear(); }
virtual void add_message(ExportMessageType p_type, const String &p_category, const String &p_message) {
diff --git a/editor/export/editor_export_platform_pc.cpp b/editor/export/editor_export_platform_pc.cpp
index 8538414523..c5b61e9b03 100644
--- a/editor/export/editor_export_platform_pc.cpp
+++ b/editor/export/editor_export_platform_pc.cpp
@@ -185,10 +185,12 @@ Error EditorExportPlatformPC::export_project_data(const Ref<EditorExportPreset>
String src_path = ProjectSettings::get_singleton()->globalize_path(so_files[i].path);
String target_path;
if (so_files[i].target.is_empty()) {
- target_path = p_path.get_base_dir().path_join(src_path.get_file());
+ target_path = p_path.get_base_dir();
} else {
- target_path = p_path.get_base_dir().path_join(so_files[i].target).path_join(src_path.get_file());
+ target_path = p_path.get_base_dir().path_join(so_files[i].target);
+ da->make_dir_recursive(target_path);
}
+ target_path = target_path.path_join(src_path.get_file());
if (da->dir_exists(src_path)) {
err = da->make_dir_recursive(target_path);
diff --git a/editor/export/export_template_manager.cpp b/editor/export/export_template_manager.cpp
index ceb5b63293..9ebf4d795a 100644
--- a/editor/export/export_template_manager.cpp
+++ b/editor/export/export_template_manager.cpp
@@ -265,9 +265,9 @@ void ExportTemplateManager::_refresh_mirrors_completed(int p_status, int p_code,
mirrors_available = false;
- Dictionary data = json.get_data();
- if (data.has("mirrors")) {
- Array mirrors = data["mirrors"];
+ Dictionary mirror_data = json.get_data();
+ if (mirror_data.has("mirrors")) {
+ Array mirrors = mirror_data["mirrors"];
for (int i = 0; i < mirrors.size(); i++) {
Dictionary m = mirrors[i];
@@ -401,17 +401,17 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_
String file = String::utf8(fname);
if (file.ends_with("version.txt")) {
- Vector<uint8_t> data;
- data.resize(info.uncompressed_size);
+ Vector<uint8_t> uncomp_data;
+ uncomp_data.resize(info.uncompressed_size);
// Read.
unzOpenCurrentFile(pkg);
- ret = unzReadCurrentFile(pkg, data.ptrw(), data.size());
+ ret = unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size());
ERR_BREAK_MSG(ret < 0, vformat("An error occurred while attempting to read from file: %s. This file will not be used.", file));
unzCloseCurrentFile(pkg);
String data_str;
- data_str.parse_utf8((const char *)data.ptr(), data.size());
+ data_str.parse_utf8((const char *)uncomp_data.ptr(), uncomp_data.size());
data_str = data_str.strip_edges();
// Version number should be of the form major.minor[.patch].status[.module_config]
@@ -473,12 +473,12 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_
continue;
}
- Vector<uint8_t> data;
- data.resize(info.uncompressed_size);
+ Vector<uint8_t> uncomp_data;
+ uncomp_data.resize(info.uncompressed_size);
// Read
unzOpenCurrentFile(pkg);
- ret = unzReadCurrentFile(pkg, data.ptrw(), data.size());
+ ret = unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size());
ERR_BREAK_MSG(ret < 0, vformat("An error occurred while attempting to read from file: %s. This file will not be used.", file));
unzCloseCurrentFile(pkg);
@@ -512,7 +512,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_
ERR_CONTINUE_MSG(true, "Can't open file from path '" + String(to_write) + "'.");
}
- f->store_buffer(data.ptr(), data.size());
+ f->store_buffer(uncomp_data.ptr(), uncomp_data.size());
f.unref(); // close file.
#ifndef WINDOWS_ENABLED
FileAccess::set_unix_permissions(to_write, (info.external_fa >> 16) & 0x01FF);
@@ -714,12 +714,12 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_
String base_dir = path.get_base_dir();
if (!path.ends_with("/")) {
- Vector<uint8_t> data;
- data.resize(info.uncompressed_size);
+ Vector<uint8_t> uncomp_data;
+ uncomp_data.resize(info.uncompressed_size);
// Read.
unzOpenCurrentFile(pkg);
- unzReadCurrentFile(pkg, data.ptrw(), data.size());
+ unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size());
unzCloseCurrentFile(pkg);
if (!dirs_tested.has(base_dir)) {
@@ -730,7 +730,7 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_
String to_write = String("res://android/build").path_join(path);
Ref<FileAccess> f = FileAccess::open(to_write, FileAccess::WRITE);
if (f.is_valid()) {
- f->store_buffer(data.ptr(), data.size());
+ f->store_buffer(uncomp_data.ptr(), uncomp_data.size());
f.unref(); // close file.
#ifndef WINDOWS_ENABLED
FileAccess::set_unix_permissions(to_write, (info.external_fa >> 16) & 0x01FF);
diff --git a/editor/export/project_export.cpp b/editor/export/project_export.cpp
index 43aac5e981..9b5e76bcd7 100644
--- a/editor/export/project_export.cpp
+++ b/editor/export/project_export.cpp
@@ -94,7 +94,7 @@ void ProjectExportDialog::_add_preset(int p_platform) {
Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_platform(p_platform)->create_preset();
ERR_FAIL_COND(!preset.is_valid());
- String name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name();
+ String preset_name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name();
bool make_runnable = true;
int attempt = 1;
while (true) {
@@ -105,7 +105,7 @@ void ProjectExportDialog::_add_preset(int p_platform) {
if (p->get_platform() == preset->get_platform() && p->is_runnable()) {
make_runnable = false;
}
- if (p->get_name() == name) {
+ if (p->get_name() == preset_name) {
valid = false;
break;
}
@@ -116,10 +116,10 @@ void ProjectExportDialog::_add_preset(int p_platform) {
}
attempt++;
- name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name() + " " + itos(attempt);
+ preset_name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name() + " " + itos(attempt);
}
- preset->set_name(name);
+ preset->set_name(preset_name);
if (make_runnable) {
preset->set_runnable(make_runnable);
}
@@ -154,12 +154,12 @@ void ProjectExportDialog::_update_presets() {
current_idx = i;
}
- String name = preset->get_name();
+ String preset_name = preset->get_name();
if (preset->is_runnable()) {
- name += " (" + TTR("Runnable") + ")";
+ preset_name += " (" + TTR("Runnable") + ")";
}
preset->update_files_to_export();
- presets->add_item(name, preset->get_platform()->get_logo());
+ presets->add_item(preset_name, preset->get_platform()->get_logo());
}
if (current_idx != -1) {
@@ -552,7 +552,7 @@ void ProjectExportDialog::_duplicate_preset() {
Ref<EditorExportPreset> preset = current->get_platform()->create_preset();
ERR_FAIL_COND(!preset.is_valid());
- String name = current->get_name() + " (copy)";
+ String preset_name = current->get_name() + " (copy)";
bool make_runnable = true;
while (true) {
bool valid = true;
@@ -562,7 +562,7 @@ void ProjectExportDialog::_duplicate_preset() {
if (p->get_platform() == preset->get_platform() && p->is_runnable()) {
make_runnable = false;
}
- if (p->get_name() == name) {
+ if (p->get_name() == preset_name) {
valid = false;
break;
}
@@ -572,10 +572,10 @@ void ProjectExportDialog::_duplicate_preset() {
break;
}
- name += " (copy)";
+ preset_name += " (copy)";
}
- preset->set_name(name);
+ preset->set_name(preset_name);
if (make_runnable) {
preset->set_runnable(make_runnable);
}
@@ -945,8 +945,8 @@ void ProjectExportDialog::_export_all_dialog_action(const String &p_str) {
}
void ProjectExportDialog::_export_all(bool p_debug) {
- String mode = p_debug ? TTR("Debug") : TTR("Release");
- EditorProgress ep("exportall", TTR("Exporting All") + " " + mode, EditorExport::get_singleton()->get_export_preset_count(), true);
+ String export_target = p_debug ? TTR("Debug") : TTR("Release");
+ EditorProgress ep("exportall", TTR("Exporting All") + " " + export_target, EditorExport::get_singleton()->get_export_preset_count(), true);
bool show_dialog = false;
result_dialog_log->clear();
@@ -1015,9 +1015,7 @@ ProjectExportDialog::ProjectExportDialog() {
preset_vb->add_child(mc);
mc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
presets = memnew(ItemList);
-#ifndef _MSC_VER
-#warning must reimplement drag forward
-#endif
+ // TODO: Must reimplement drag forwarding.
//presets->set_drag_forwarding(this);
mc->add_child(presets);
presets->connect("item_selected", callable_mp(this, &ProjectExportDialog::_edit_preset));
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 424eab2f02..d37f2aab43 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -218,11 +218,11 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo
TreeItem *root = tree->create_item();
// Handles the favorites.
- TreeItem *favorites = tree->create_item(root);
- favorites->set_icon(0, get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons")));
- favorites->set_text(0, TTR("Favorites:"));
- favorites->set_metadata(0, "Favorites");
- favorites->set_collapsed(p_uncollapsed_paths.find("Favorites") < 0);
+ TreeItem *favorites_item = tree->create_item(root);
+ favorites_item->set_icon(0, get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons")));
+ favorites_item->set_text(0, TTR("Favorites:"));
+ favorites_item->set_metadata(0, "Favorites");
+ favorites_item->set_collapsed(p_uncollapsed_paths.find("Favorites") < 0);
Vector<String> favorite_paths = EditorSettings::get_singleton()->get_favorites();
@@ -272,7 +272,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo
}
if (searched_string.length() == 0 || text.to_lower().find(searched_string) >= 0) {
- TreeItem *ti = tree->create_item(favorites);
+ TreeItem *ti = tree->create_item(favorites_item);
ti->set_text(0, text);
ti->set_icon(0, icon);
ti->set_icon_modulate(0, color);
@@ -784,9 +784,8 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
List<FileInfo> file_list;
if (path == "Favorites") {
// Display the favorites.
- Vector<String> favorites = EditorSettings::get_singleton()->get_favorites();
- for (int i = 0; i < favorites.size(); i++) {
- String favorite = favorites[i];
+ Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites();
+ for (const String &favorite : favorites_list) {
String text;
Ref<Texture2D> icon;
if (favorite == "res://") {
@@ -1056,15 +1055,15 @@ void FileSystemDock::_select_file(const String &p_path, bool p_select_in_favorit
void FileSystemDock::_tree_activate_file() {
TreeItem *selected = tree->get_selected();
if (selected) {
- String path = selected->get_metadata(0);
+ String file_path = selected->get_metadata(0);
TreeItem *parent = selected->get_parent();
bool is_favorite = parent != nullptr && parent->get_metadata(0) == "Favorites";
- if ((!is_favorite && path.ends_with("/")) || path == "Favorites") {
+ if ((!is_favorite && file_path.ends_with("/")) || file_path == "Favorites") {
bool collapsed = selected->is_collapsed();
selected->set_collapsed(!collapsed);
} else {
- _select_file(path, is_favorite && !path.ends_with("/"));
+ _select_file(file_path, is_favorite && !file_path.ends_with("/"));
}
}
}
@@ -1169,29 +1168,29 @@ void FileSystemDock::_push_to_history() {
button_hist_next->set_disabled(history_pos == history.size() - 1);
}
-void FileSystemDock::_get_all_items_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files, Vector<String> &folders) const {
- if (efsd == nullptr) {
+void FileSystemDock::_get_all_items_in_dir(EditorFileSystemDirectory *p_efsd, Vector<String> &r_files, Vector<String> &r_folders) const {
+ if (p_efsd == nullptr) {
return;
}
- for (int i = 0; i < efsd->get_subdir_count(); i++) {
- folders.push_back(efsd->get_subdir(i)->get_path());
- _get_all_items_in_dir(efsd->get_subdir(i), files, folders);
+ for (int i = 0; i < p_efsd->get_subdir_count(); i++) {
+ r_folders.push_back(p_efsd->get_subdir(i)->get_path());
+ _get_all_items_in_dir(p_efsd->get_subdir(i), r_files, r_folders);
}
- for (int i = 0; i < efsd->get_file_count(); i++) {
- files.push_back(efsd->get_file_path(i));
+ for (int i = 0; i < p_efsd->get_file_count(); i++) {
+ r_files.push_back(p_efsd->get_file_path(i));
}
}
-void FileSystemDock::_find_remaps(EditorFileSystemDirectory *efsd, const HashMap<String, String> &renames, Vector<String> &to_remaps) const {
- for (int i = 0; i < efsd->get_subdir_count(); i++) {
- _find_remaps(efsd->get_subdir(i), renames, to_remaps);
+void FileSystemDock::_find_remaps(EditorFileSystemDirectory *p_efsd, const HashMap<String, String> &r_renames, Vector<String> &r_to_remaps) const {
+ for (int i = 0; i < p_efsd->get_subdir_count(); i++) {
+ _find_remaps(p_efsd->get_subdir(i), r_renames, r_to_remaps);
}
- for (int i = 0; i < efsd->get_file_count(); i++) {
- Vector<String> deps = efsd->get_file_deps(i);
+ for (int i = 0; i < p_efsd->get_file_count(); i++) {
+ Vector<String> deps = p_efsd->get_file_deps(i);
for (int j = 0; j < deps.size(); j++) {
- if (renames.has(deps[j])) {
- to_remaps.push_back(efsd->get_file_path(i));
+ if (r_renames.has(deps[j])) {
+ r_to_remaps.push_back(p_efsd->get_file_path(i));
break;
}
}
@@ -1345,25 +1344,25 @@ void FileSystemDock::_update_resource_paths_after_move(const HashMap<String, Str
}
for (int i = 0; i < EditorNode::get_editor_data().get_edited_scene_count(); i++) {
- String path;
+ String file_path;
if (i == EditorNode::get_editor_data().get_edited_scene()) {
if (!get_tree()->get_edited_scene_root()) {
continue;
}
- path = get_tree()->get_edited_scene_root()->get_scene_file_path();
+ file_path = get_tree()->get_edited_scene_root()->get_scene_file_path();
} else {
- path = EditorNode::get_editor_data().get_scene_path(i);
+ file_path = EditorNode::get_editor_data().get_scene_path(i);
}
- if (p_renames.has(path)) {
- path = p_renames[path];
+ if (p_renames.has(file_path)) {
+ file_path = p_renames[file_path];
}
if (i == EditorNode::get_editor_data().get_edited_scene()) {
- get_tree()->get_edited_scene_root()->set_scene_file_path(path);
+ get_tree()->get_edited_scene_root()->set_scene_file_path(file_path);
} else {
- EditorNode::get_editor_data().set_scene_path(i, path);
+ EditorNode::get_editor_data().set_scene_path(i, file_path);
}
}
}
@@ -1421,11 +1420,10 @@ void FileSystemDock::_update_project_settings_after_move(const HashMap<String, S
}
void FileSystemDock::_update_favorites_list_after_move(const HashMap<String, String> &p_files_renames, const HashMap<String, String> &p_folders_renames) const {
- Vector<String> favorites = EditorSettings::get_singleton()->get_favorites();
+ Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites();
Vector<String> new_favorites;
- for (int i = 0; i < favorites.size(); i++) {
- String old_path = favorites[i];
+ for (const String &old_path : favorites_list) {
if (p_folders_renames.has(old_path)) {
new_favorites.push_back(p_folders_renames[old_path]);
} else if (p_files_renames.has(old_path)) {
@@ -1836,23 +1834,23 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
case FILE_ADD_FAVORITE: {
// Add the files from favorites.
- Vector<String> favorites = EditorSettings::get_singleton()->get_favorites();
+ Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites();
for (int i = 0; i < p_selected.size(); i++) {
- if (!favorites.has(p_selected[i])) {
- favorites.push_back(p_selected[i]);
+ if (!favorites_list.has(p_selected[i])) {
+ favorites_list.push_back(p_selected[i]);
}
}
- EditorSettings::get_singleton()->set_favorites(favorites);
+ EditorSettings::get_singleton()->set_favorites(favorites_list);
_update_tree(_compute_uncollapsed_paths());
} break;
case FILE_REMOVE_FAVORITE: {
// Remove the files from favorites.
- Vector<String> favorites = EditorSettings::get_singleton()->get_favorites();
+ Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites();
for (int i = 0; i < p_selected.size(); i++) {
- favorites.erase(p_selected[i]);
+ favorites_list.erase(p_selected[i]);
}
- EditorSettings::get_singleton()->set_favorites(favorites);
+ EditorSettings::get_singleton()->set_favorites(favorites_list);
_update_tree(_compute_uncollapsed_paths());
if (path == "Favorites") {
_update_file_list(true);
@@ -2274,7 +2272,7 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
int drop_section = tree->get_drop_section_at_position(p_point);
int drop_position;
- Vector<String> files = drag_data["files"];
+ Vector<String> drag_files = drag_data["files"];
TreeItem *favorites_item = tree->get_root()->get_first_child();
TreeItem *resources_item = favorites_item->get_next();
@@ -2295,8 +2293,8 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
// Remove dragged favorites.
Vector<int> to_remove;
int offset = 0;
- for (int i = 0; i < files.size(); i++) {
- int to_remove_pos = dirs.find(files[i]);
+ for (int i = 0; i < drag_files.size(); i++) {
+ int to_remove_pos = dirs.find(drag_files[i]);
to_remove.push_back(to_remove_pos);
if (to_remove_pos < drop_position) {
offset++;
@@ -2309,8 +2307,8 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
}
// Re-add them at the right position.
- for (int i = 0; i < files.size(); i++) {
- dirs.insert(drop_position, files[i]);
+ for (int i = 0; i < drag_files.size(); i++) {
+ dirs.insert(drop_position, drag_files[i]);
drop_position++;
}
@@ -2379,13 +2377,13 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
} else if (favorite) {
// Add the files from favorites.
Vector<String> fnames = drag_data["files"];
- Vector<String> favorites = EditorSettings::get_singleton()->get_favorites();
+ Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites();
for (int i = 0; i < fnames.size(); i++) {
- if (!favorites.has(fnames[i])) {
- favorites.push_back(fnames[i]);
+ if (!favorites_list.has(fnames[i])) {
+ favorites_list.push_back(fnames[i]);
}
}
- EditorSettings::get_singleton()->set_favorites(favorites);
+ EditorSettings::get_singleton()->set_favorites(favorites_list);
_update_tree(_compute_uncollapsed_paths());
}
}
@@ -2463,7 +2461,7 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str
Vector<String> filenames;
Vector<String> foldernames;
- Vector<String> favorites = EditorSettings::get_singleton()->get_favorites();
+ Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites();
bool all_files = true;
bool all_files_scenes = true;
@@ -2484,8 +2482,8 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str
// Check if in favorites.
bool found = false;
- for (int j = 0; j < favorites.size(); j++) {
- if (favorites[j] == fpath) {
+ for (int j = 0; j < favorites_list.size(); j++) {
+ if (favorites_list[j] == fpath) {
found = true;
break;
}
@@ -2852,10 +2850,10 @@ void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) {
}
}
-void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &files) const {
+void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &r_files) const {
if (!p_path.ends_with("/")) {
if (FileAccess::exists(p_path + ".import")) {
- files.push_back(p_path);
+ r_files.push_back(p_path);
}
return;
}
@@ -2866,7 +2864,7 @@ void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &f
while (!n.is_empty()) {
if (n != "." && n != ".." && !n.ends_with(".import")) {
String npath = p_path + n + (da->current_is_dir() ? "/" : "");
- _get_imported_files(npath, files);
+ _get_imported_files(npath, r_files);
}
n = da->get_next();
}
@@ -2996,7 +2994,7 @@ void FileSystemDock::_bind_methods() {
ADD_SIGNAL(MethodInfo("file_removed", PropertyInfo(Variant::STRING, "file")));
ADD_SIGNAL(MethodInfo("folder_removed", PropertyInfo(Variant::STRING, "folder")));
ADD_SIGNAL(MethodInfo("files_moved", PropertyInfo(Variant::STRING, "old_file"), PropertyInfo(Variant::STRING, "new_file")));
- ADD_SIGNAL(MethodInfo("folder_moved", PropertyInfo(Variant::STRING, "old_folder"), PropertyInfo(Variant::STRING, "new_file")));
+ ADD_SIGNAL(MethodInfo("folder_moved", PropertyInfo(Variant::STRING, "old_folder"), PropertyInfo(Variant::STRING, "new_folder")));
ADD_SIGNAL(MethodInfo("display_mode_changed"));
}
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index c38b3f8a47..f39ca9e74d 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -213,11 +213,11 @@ private:
void _file_multi_selected(int p_index, bool p_selected);
void _tree_multi_selected(Object *p_item, int p_column, bool p_selected);
- void _get_imported_files(const String &p_path, Vector<String> &files) const;
+ void _get_imported_files(const String &p_path, Vector<String> &r_files) const;
void _update_import_dock();
- void _get_all_items_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files, Vector<String> &folders) const;
- void _find_remaps(EditorFileSystemDirectory *efsd, const HashMap<String, String> &renames, Vector<String> &to_remaps) const;
+ void _get_all_items_in_dir(EditorFileSystemDirectory *p_efsd, Vector<String> &r_files, Vector<String> &r_folders) const;
+ void _find_remaps(EditorFileSystemDirectory *p_efsd, const HashMap<String, String> &r_renames, Vector<String> &r_to_remaps) const;
void _try_move_item(const FileOrFolder &p_item, const String &p_new_path, HashMap<String, String> &p_file_renames, HashMap<String, String> &p_folder_renames);
void _try_duplicate_item(const FileOrFolder &p_item, const String &p_new_path) const;
void _update_dependencies_after_move(const HashMap<String, String> &p_renames) const;
diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp
index 16c5003fdc..a0f4ade182 100644
--- a/editor/find_in_files.cpp
+++ b/editor/find_in_files.cpp
@@ -968,8 +968,8 @@ void FindInFilesPanel::update_replace_buttons() {
_replace_all_button->set_disabled(disabled);
}
-void FindInFilesPanel::set_progress_visible(bool visible) {
- _progress_bar->set_self_modulate(Color(1, 1, 1, visible ? 1 : 0));
+void FindInFilesPanel::set_progress_visible(bool p_visible) {
+ _progress_bar->set_self_modulate(Color(1, 1, 1, p_visible ? 1 : 0));
}
void FindInFilesPanel::_bind_methods() {
diff --git a/editor/find_in_files.h b/editor/find_in_files.h
index c57a084779..46ba3842af 100644
--- a/editor/find_in_files.h
+++ b/editor/find_in_files.h
@@ -198,7 +198,7 @@ private:
void draw_result_text(Object *item_obj, Rect2 rect);
- void set_progress_visible(bool visible);
+ void set_progress_visible(bool p_visible);
void clear();
FindInFiles *_finder = nullptr;
diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp
index dac86acae4..f11e328087 100644
--- a/editor/groups_editor.cpp
+++ b/editor/groups_editor.cpp
@@ -39,6 +39,24 @@
#include "scene/gui/label.h"
#include "scene/resources/packed_scene.h"
+static bool can_edit(Node *p_node, String p_group) {
+ Node *n = p_node;
+ bool can_edit = true;
+ while (n) {
+ Ref<SceneState> ss = (n == EditorNode::get_singleton()->get_edited_scene()) ? n->get_scene_inherited_state() : n->get_scene_instance_state();
+ if (ss.is_valid()) {
+ int path = ss->find_node_by_path(n->get_path_to(p_node));
+ if (path != -1) {
+ if (ss->is_node_in_group(path, p_group)) {
+ can_edit = false;
+ }
+ }
+ }
+ n = n->get_owner();
+ }
+ return can_edit;
+}
+
void GroupDialog::_group_selected() {
nodes_to_add->clear();
add_node_root = nodes_to_add->create_item();
@@ -94,7 +112,7 @@ void GroupDialog::_load_nodes(Node *p_current) {
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(p_current, "Node");
node->set_icon(0, icon);
- if (!_can_edit(p_current, selected_group)) {
+ if (!can_edit(p_current, selected_group)) {
node->set_selectable(0, false);
node->set_custom_color(0, groups->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")));
}
@@ -105,24 +123,6 @@ void GroupDialog::_load_nodes(Node *p_current) {
}
}
-bool GroupDialog::_can_edit(Node *p_node, String p_group) {
- Node *n = p_node;
- bool can_edit = true;
- while (n) {
- Ref<SceneState> ss = (n == EditorNode::get_singleton()->get_edited_scene()) ? n->get_scene_inherited_state() : n->get_scene_instance_state();
- if (ss.is_valid()) {
- int path = ss->find_node_by_path(n->get_path_to(p_node));
- if (path != -1) {
- if (ss->is_node_in_group(path, p_group)) {
- can_edit = false;
- }
- }
- }
- n = n->get_owner();
- }
- return can_edit;
-}
-
void GroupDialog::_add_pressed() {
TreeItem *selected = nodes_to_add->get_next_selected(nullptr);
@@ -218,19 +218,14 @@ void GroupDialog::_add_group_text_changed(const String &p_new_text) {
}
void GroupDialog::_group_renamed() {
- TreeItem *renamed_group = groups->get_edited();
+ TreeItem *renamed_group = groups->get_selected();
if (!renamed_group) {
return;
}
const String name = renamed_group->get_text(0).strip_edges();
- for (TreeItem *E = groups_root->get_first_child(); E; E = E->get_next()) {
- if (E != renamed_group && E->get_text(0) == name) {
- renamed_group->set_text(0, selected_group);
- error->set_text(TTR("Group name already exists."));
- error->popup_centered();
- return;
- }
+ if (name == selected_group) {
+ return;
}
if (name.is_empty()) {
@@ -240,6 +235,15 @@ void GroupDialog::_group_renamed() {
return;
}
+ for (TreeItem *E = groups_root->get_first_child(); E; E = E->get_next()) {
+ if (E != renamed_group && E->get_text(0) == name) {
+ renamed_group->set_text(0, selected_group);
+ error->set_text(TTR("Group name already exists."));
+ error->popup_centered();
+ return;
+ }
+ }
+
renamed_group->set_text(0, name); // Spaces trimmed.
undo_redo->create_action(TTR("Rename Group"));
@@ -248,7 +252,7 @@ void GroupDialog::_group_renamed() {
scene_tree->get_nodes_in_group(selected_group, &nodes);
bool removed_all = true;
for (Node *node : nodes) {
- if (_can_edit(node, selected_group)) {
+ if (can_edit(node, selected_group)) {
undo_redo->add_do_method(node, "remove_from_group", selected_group);
undo_redo->add_undo_method(node, "remove_from_group", name);
undo_redo->add_do_method(node, "add_to_group", name, true);
@@ -324,7 +328,7 @@ void GroupDialog::_modify_group_pressed(Object *p_item, int p_column, int p_id,
scene_tree->get_nodes_in_group(name, &nodes);
bool removed_all = true;
for (Node *E : nodes) {
- if (_can_edit(E, name)) {
+ if (can_edit(E, name)) {
undo_redo->add_do_method(E, "remove_from_group", name);
undo_redo->add_undo_method(E, "add_to_group", name, true);
} else {
@@ -571,7 +575,7 @@ GroupDialog::GroupDialog() {
set_title(TTR("Group Editor"));
- error = memnew(ConfirmationDialog);
+ error = memnew(AcceptDialog);
add_child(error);
error->set_ok_button_text(TTR("Close"));
@@ -584,14 +588,12 @@ void GroupsEditor::_add_group(const String &p_group) {
if (!node) {
return;
}
-
const String name = group_name->get_text().strip_edges();
- if (name.is_empty()) {
- return;
- }
group_name->clear();
if (node->is_in_group(name)) {
+ error->set_text(TTR("Group name already exists."));
+ error->popup_centered();
return;
}
@@ -609,6 +611,65 @@ void GroupsEditor::_add_group(const String &p_group) {
undo_redo->commit_action();
}
+void GroupsEditor::_group_selected() {
+ if (!tree->is_anything_selected()) {
+ return;
+ }
+ selected_group = tree->get_selected()->get_text(0);
+}
+
+void GroupsEditor::_group_renamed() {
+ if (!node || !can_edit(node, selected_group)) {
+ return;
+ }
+
+ TreeItem *ti = tree->get_selected();
+ if (!ti) {
+ return;
+ }
+
+ const String name = ti->get_text(0).strip_edges();
+ if (name == selected_group) {
+ return;
+ }
+
+ if (name.is_empty()) {
+ ti->set_text(0, selected_group);
+ error->set_text(TTR("Invalid group name."));
+ error->popup_centered();
+ return;
+ }
+
+ for (TreeItem *E = groups_root->get_first_child(); E; E = E->get_next()) {
+ if (E != ti && E->get_text(0) == name) {
+ ti->set_text(0, selected_group);
+ error->set_text(TTR("Group name already exists."));
+ error->popup_centered();
+ return;
+ }
+ }
+
+ ti->set_text(0, name); // Spaces trimmed.
+
+ undo_redo->create_action(TTR("Rename Group"));
+
+ undo_redo->add_do_method(node, "remove_from_group", selected_group);
+ undo_redo->add_undo_method(node, "remove_from_group", name);
+ undo_redo->add_do_method(node, "add_to_group", name, true);
+ undo_redo->add_undo_method(node, "add_to_group", selected_group, true);
+
+ undo_redo->add_do_method(this, "_group_selected");
+ undo_redo->add_undo_method(this, "_group_selected");
+ undo_redo->add_do_method(this, "update_tree");
+ undo_redo->add_undo_method(this, "update_tree");
+
+ // To force redraw of scene tree.
+ undo_redo->add_do_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree");
+ undo_redo->add_undo_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree");
+
+ undo_redo->commit_action();
+}
+
void GroupsEditor::_modify_group(Object *p_item, int p_column, int p_id, MouseButton p_button) {
if (p_button != MouseButton::LEFT) {
return;
@@ -624,7 +685,7 @@ void GroupsEditor::_modify_group(Object *p_item, int p_column, int p_id, MouseBu
}
switch (p_id) {
case DELETE_GROUP: {
- String name = ti->get_text(0);
+ const String name = ti->get_text(0);
undo_redo->create_action(TTR("Remove from Group"));
undo_redo->add_do_method(node, "remove_from_group", name);
@@ -666,6 +727,7 @@ void GroupsEditor::update_tree() {
groups.sort_custom<_GroupInfoComparator>();
TreeItem *root = tree->create_item();
+ groups_root = root;
for (const GroupInfo &gi : groups) {
if (!gi.persistent) {
@@ -692,6 +754,7 @@ void GroupsEditor::update_tree() {
TreeItem *item = tree->create_item(root);
item->set_text(0, gi.name);
+ item->set_editable(0, true);
if (can_be_deleted) {
item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), DELETE_GROUP);
item->add_button(0, get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), COPY_GROUP);
@@ -717,6 +780,7 @@ void GroupsEditor::_show_group_dialog() {
void GroupsEditor::_bind_methods() {
ClassDB::bind_method("update_tree", &GroupsEditor::update_tree);
+ ClassDB::bind_method("_group_selected", &GroupsEditor::_group_selected);
}
GroupsEditor::GroupsEditor() {
@@ -749,13 +813,21 @@ GroupsEditor::GroupsEditor() {
add->connect("pressed", callable_mp(this, &GroupsEditor::_add_group).bind(String()));
tree = memnew(Tree);
+ vbc->add_child(tree);
tree->set_hide_root(true);
+ tree->set_allow_reselect(true);
+ tree->set_allow_rmb_select(true);
tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- vbc->add_child(tree);
+ tree->connect("item_selected", callable_mp(this, &GroupsEditor::_group_selected));
tree->connect("button_clicked", callable_mp(this, &GroupsEditor::_modify_group));
+ tree->connect("item_edited", callable_mp(this, &GroupsEditor::_group_renamed));
tree->add_theme_constant_override("draw_guides", 1);
add_theme_constant_override("separation", 3 * EDSCALE);
+ error = memnew(AcceptDialog);
+ add_child(error);
+ error->get_ok_button()->set_text(TTR("Close"));
+
_group_name_changed("");
}
diff --git a/editor/groups_editor.h b/editor/groups_editor.h
index 8bbea4e652..5d012a3501 100644
--- a/editor/groups_editor.h
+++ b/editor/groups_editor.h
@@ -44,7 +44,7 @@ class EditorUndoRedoManager;
class GroupDialog : public AcceptDialog {
GDCLASS(GroupDialog, AcceptDialog);
- ConfirmationDialog *error = nullptr;
+ AcceptDialog *error = nullptr;
SceneTree *scene_tree = nullptr;
TreeItem *groups_root = nullptr;
@@ -88,8 +88,6 @@ class GroupDialog : public AcceptDialog {
void _modify_group_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _delete_group_item(const String &p_name);
- bool _can_edit(Node *p_node, String p_group);
-
void _load_groups(Node *p_current);
void _load_nodes(Node *p_current);
@@ -113,8 +111,10 @@ class GroupsEditor : public VBoxContainer {
GDCLASS(GroupsEditor, VBoxContainer);
Node *node = nullptr;
+ TreeItem *groups_root = nullptr;
GroupDialog *group_dialog = nullptr;
+ AcceptDialog *error = nullptr;
LineEdit *group_name = nullptr;
Button *add = nullptr;
@@ -122,11 +122,16 @@ class GroupsEditor : public VBoxContainer {
Ref<EditorUndoRedoManager> undo_redo;
+ String selected_group;
+
void update_tree();
void _add_group(const String &p_group = "");
void _modify_group(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _group_name_changed(const String &p_new_text);
+ void _group_selected();
+ void _group_renamed();
+
void _show_group_dialog();
protected:
diff --git a/editor/icons/BoneMapHumanBody.svg b/editor/icons/BoneMapHumanBody.svg
index 2c2c5db1f6..8674157aaa 100644
--- a/editor/icons/BoneMapHumanBody.svg
+++ b/editor/icons/BoneMapHumanBody.svg
@@ -1 +1,26 @@
-<svg enable-background="new 0 0 1024 1024" height="1024" viewBox="0 0 1024 1024" width="1024" xmlns="http://www.w3.org/2000/svg"><path d="m0 0h1024v1024h-1024z" fill="#3f3f3f"/><path d="m926.5 217.162c-11.5-2-26.03 4.547-37.5 6.5-15.723 2.678-25.238 3.24-33.333 5.167-1.227.292-3.103.763-5.792.958 0 0-.019.16-.052.437-36.819.994-106.823-6.062-138.156-2.062-23.816 3.041-86.334-5.667-105.667-6-13.911-.239-59.292-4.583-71.75-2.5-.667-4.083-1.5-10.75.95-17.468 14.881-7.246 27.229-21.569 35.341-38.467.922 4.424 6.252 4.929 12.459-14.231 5.662-17.478 2.324-22.254-2.313-22.525.172-2.056.279-4.105.313-6.142.788-48.041-15-78.667-69-78.667s-69.787 30.626-69 78.667c.033 2.036.141 4.086.313 6.142-4.637.271-7.975 5.048-2.313 22.525 6.207 19.16 11.537 18.655 12.459 14.231 8.113 16.897 20.461 31.221 35.342 38.467 2.449 6.718 1.617 13.385.949 17.468-12.457-2.083-57.838 2.261-71.75 2.5-19.332.333-81.85 9.041-105.666 6-31.333-4-101.337 3.056-138.156 2.062-.033-.276-.053-.437-.053-.437-2.689-.195-4.564-.666-5.791-.958-8.096-1.927-17.611-2.489-33.334-5.167-11.469-1.953-26-8.5-37.5-6.5-3.367.586 6 9.834 15.5 12.334 13.635 3.588 25.25 10.666 36 13.166-2.25 3.75-15.59 7.063-23 12-5.336 3.557 6.5 6.5 12 5 20.842-5.684 22.973.389 37.514-9.019 30.078 4.078 102.537 20.514 122.154 14.186 12.457-4.018 100.332 7.083 142.332 5.833 6.039-.18 1.656 65.563 2 73.5 3 69-16.842 133.135-18.666 169.667-1.92 38.42-3.42 57.919 7.666 131.333 6.967 46.126-2.521 82.079-2 94 6 137 29 172 4 221-14 27.44 67.449 26.958 65 9-3.012-22.092-12.666-22.333-10.666-46.333 1.896-22.768 16.049-151.298 8.666-206.667-2-15 0-26 2-66 2.355-47.101 7-88 14-123 7 35 11.645 75.899 14 123 2 40 4 51 2 66-7.383 55.369 6.77 183.899 8.667 206.667 2 24-7.654 24.241-10.667 46.333-2.449 17.958 79 18.44 65-9-25-49-2-84 4-221 .522-11.921-8.966-47.874-2-94 11.086-73.414 9.586-92.913 7.667-131.333-1.824-36.532-21.667-100.667-18.667-169.667.345-7.938-4.039-73.68 2-73.5 42 1.25 129.876-9.852 142.333-5.833 19.616 6.328 92.076-10.107 122.153-14.186 14.541 9.407 16.673 3.335 37.514 9.019 5.5 1.5 17.336-1.443 12-5-7.409-4.937-20.75-8.25-23-12 10.75-2.5 22.366-9.578 36.001-13.166 9.5-2.5 18.866-11.748 15.499-12.334z" fill="#b2b2b2"/></svg>
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="レイヤー_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
+ y="0px" width="1024px" height="1024px" viewBox="0 0 1024 1024" enable-background="new 0 0 1024 1024" xml:space="preserve">
+<path fill="#3F3F3F" d="M0,0h1024v1024H0V0z"/>
+<path fill="#B2B2B2" d="M512,536.162c7,35,11.645,66.898,14,114c2,40,4,51,2,66c-7.384,55.369,6.77,183.898,8.666,206.667
+ c2,24-7.653,24.241-10.666,46.333c-2.449,17.958,79,18.439,65-9c-25-49-2-84,4-221c0.521-11.921-8.967-47.874-2-94
+ c11.086-73.414,8.42-107.242,6.5-145.662c-1.245-31.973-1-56.963-9-138.963c-0.976-10.002,5.915-79.268,11.954-79.088
+ c42,1.25,97.313-5.009,118.145-14.68c28.901,3.73,97.81-12.047,127.887-16.126c14.541,9.407,16.673,3.335,37.515,9.019
+ c5.5,1.5,17.336-1.443,12-5c-7.409-4.937-20.75-8.25-23-12c10.75-2.5,22.365-9.578,36-13.166c9.5-2.5,18.866-11.748,15.5-12.334l0,0
+ c-11.5-2-26.03,4.547-37.5,6.5c-15.724,2.678-25.238,3.24-33.334,5.167c-1.227,0.292-3.103,0.763-5.791,0.958
+ c0,0-0.02,0.16-0.053,0.437c-36.818,0.994-80.322-9.724-130.31-5.569c-34.026-3.925-94.181-5.16-113.513-5.493
+ c-13.911-0.239-59.293-2.583-71.75-0.5c-0.668-4.083-1.5-9.75,0.949-16.468c14.881-7.246,19.188-17.796,27.301-34.694
+ c0.922,4.424,6.252,4.929,12.459-14.231c5.661-17.478,2.323-22.254-2.313-22.525c0.172-2.056,0.279-4.105,0.313-6.142
+ C573.746,76.562,566,42.163,512,42.163s-61.746,34.399-60.959,82.44c0.034,2.037,0.142,4.086,0.313,6.142
+ c-4.637,0.271-7.975,5.047-2.313,22.525c6.207,19.16,11.537,18.655,12.459,14.231c8.112,16.898,12.42,27.448,27.301,34.694
+ c2.449,6.718,1.617,12.385,0.949,16.468c-12.457-2.083-57.839,0.261-71.75,0.5c-19.332,0.333-79.486,1.568-113.513,5.493
+ c-49.987-4.155-93.491,6.563-130.31,5.569c-0.033-0.277-0.053-0.437-0.053-0.437c-2.688-0.195-4.564-0.666-5.791-0.958
+ c-8.096-1.927-17.61-2.489-33.334-5.167c-11.47-1.953-26-8.5-37.5-6.5l0,0c-3.366,0.586,6,9.834,15.5,12.334
+ c13.635,3.588,25.25,10.666,36,13.166c-2.25,3.75-15.591,7.063-23,12c-5.336,3.557,6.5,6.5,12,5
+ c20.842-5.684,22.974,0.388,37.515-9.019c30.077,4.079,98.985,19.857,127.887,16.126c20.832,9.671,76.145,15.93,118.145,14.68
+ c6.039-0.18,12.93,69.085,11.954,79.088c-8,82-7.755,106.99-9,138.963c-1.92,38.419-4.586,72.248,6.5,145.662
+ c6.967,46.126-2.521,82.079-2,94c6,137,29,172,4,221c-14,27.439,67.449,26.958,65,9c-3.013-22.092-12.666-22.333-10.666-46.333
+ c1.896-22.769,16.05-151.298,8.666-206.667c-2-15,0-26,2-66C500.356,603.061,505,571.162,512,536.162z"/>
+</svg>
diff --git a/editor/icons/PickerShapeCircle.svg b/editor/icons/PickerShapeCircle.svg
new file mode 100644
index 0000000000..8e7fb7f06e
--- /dev/null
+++ b/editor/icons/PickerShapeCircle.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><clipPath id="a"><path d="m0 0h16v16h-16z"/></clipPath><g clip-path="url(#a)" fill="#eaeaea"><rect height="11" rx="5.5" transform="translate(1 2)" width="11"/><path d="m0 0h2v11h-2z" transform="translate(13 2)"/></g></svg>
diff --git a/editor/icons/PickerShapeRectangle.svg b/editor/icons/PickerShapeRectangle.svg
new file mode 100644
index 0000000000..3c7dd46884
--- /dev/null
+++ b/editor/icons/PickerShapeRectangle.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><clipPath id="a"><path d="m0 0h16v16h-16z"/></clipPath><g clip-path="url(#a)" fill="#eaeaea"><path d="m0 0h11v11h-11z" transform="translate(1 2)"/><path d="m0 0h2v11h-2z" transform="translate(13 2)"/></g></svg>
diff --git a/editor/icons/PickerShapeRectangleWheel.svg b/editor/icons/PickerShapeRectangleWheel.svg
new file mode 100644
index 0000000000..e85665a8f2
--- /dev/null
+++ b/editor/icons/PickerShapeRectangleWheel.svg
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ height="16"
+ viewBox="0 0 16 16"
+ width="16"
+ version="1.1"
+ id="svg11"
+ sodipodi:docname="PickerShapeRectangleWheel.svg"
+ inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg">
+ <defs
+ id="defs15" />
+ <sodipodi:namedview
+ id="namedview13"
+ pagecolor="#505050"
+ bordercolor="#ffffff"
+ borderopacity="1"
+ inkscape:pageshadow="0"
+ inkscape:pageopacity="0"
+ inkscape:pagecheckerboard="1"
+ showgrid="true"
+ inkscape:zoom="16"
+ inkscape:cx="0.53125"
+ inkscape:cy="5.28125"
+ inkscape:window-width="1920"
+ inkscape:window-height="1001"
+ inkscape:window-x="-9"
+ inkscape:window-y="-9"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg11">
+ <inkscape:grid
+ type="xygrid"
+ id="grid944" />
+ </sodipodi:namedview>
+ <clipPath
+ id="a">
+ <path
+ d="m0 0h16v16h-16z"
+ id="path2" />
+ </clipPath>
+ <g
+ clip-path="url(#a)"
+ fill="#eaeaea"
+ id="g9"
+ transform="matrix(0.85714286,0,0,0.85714286,1.1428571,1.1428571)">
+ <path
+ d="M 7,2 A 5,5 0 1 0 12,7 5.006,5.006 0 0 0 7,2 M 7,0 A 7,7 0 1 1 0,7 7,7 0 0 1 7,0 Z"
+ transform="translate(1,1)"
+ id="path5" />
+ <path
+ d="M 0,0 H 7 V 7 H 0 Z"
+ transform="translate(4.5,4.5)"
+ id="path7" />
+ </g>
+</svg>
diff --git a/editor/import/audio_stream_import_settings.cpp b/editor/import/audio_stream_import_settings.cpp
index e3da82a5cb..d94b517003 100644
--- a/editor/import/audio_stream_import_settings.cpp
+++ b/editor/import/audio_stream_import_settings.cpp
@@ -76,7 +76,7 @@ void AudioStreamImportSettings::_notification(int p_what) {
void AudioStreamImportSettings::_draw_preview() {
Rect2 rect = _preview->get_rect();
- Size2 size = rect.size;
+ Size2 rect_size = rect.size;
Ref<AudioStreamPreview> preview = AudioStreamPreviewGenerator::get_singleton()->generate_preview(stream);
float preview_offset = zoom_bar->get_value();
@@ -85,7 +85,7 @@ void AudioStreamImportSettings::_draw_preview() {
Ref<Font> beat_font = get_theme_font(SNAME("main"), SNAME("EditorFonts"));
int main_size = get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"));
Vector<Vector2> lines;
- lines.resize(size.width * 2);
+ lines.resize(rect_size.width * 2);
Color color_active = get_theme_color(SNAME("contrast_color_2"), SNAME("Editor"));
Color color_inactive = color_active;
color_inactive.a *= 0.5;
@@ -107,9 +107,9 @@ void AudioStreamImportSettings::_draw_preview() {
}
}
- for (int i = 0; i < size.width; i++) {
- float ofs = preview_offset + i * preview_len / size.width;
- float ofs_n = preview_offset + (i + 1) * preview_len / size.width;
+ for (int i = 0; i < rect_size.width; i++) {
+ float ofs = preview_offset + i * preview_len / rect_size.width;
+ float ofs_n = preview_offset + (i + 1) * preview_len / rect_size.width;
float max = preview->get_max(ofs, ofs_n) * 0.5 + 0.5;
float min = preview->get_min(ofs, ofs_n) * 0.5 + 0.5;
@@ -139,8 +139,8 @@ void AudioStreamImportSettings::_draw_preview() {
int bar_beats = stream->get_bar_beats();
int last_text_end_x = 0;
- for (int i = 0; i < size.width; i++) {
- float ofs = preview_offset + i * preview_len / size.width;
+ for (int i = 0; i < rect_size.width; i++) {
+ float ofs = preview_offset + i * preview_len / rect_size.width;
int beat = int(ofs / beat_size);
if (beat != prev_beat) {
String text = itos(beat);
diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp
index 5d8e453395..7cf35c519b 100644
--- a/editor/import/collada.cpp
+++ b/editor/import/collada.cpp
@@ -2036,11 +2036,7 @@ void Collada::_merge_skeletons(VisualScene *p_vscene, Node *p_node) {
ERR_CONTINUE(!state.scene_map.has(nodeid)); //weird, it should have it...
-#ifdef NO_SAFE_CAST
- NodeJoint *nj = static_cast<NodeJoint *>(state.scene_map[nodeid]);
-#else
NodeJoint *nj = dynamic_cast<NodeJoint *>(state.scene_map[nodeid]);
-#endif
ERR_CONTINUE(!nj); //broken collada
ERR_CONTINUE(!nj->owner); //weird, node should have a skeleton owner
@@ -2197,11 +2193,7 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, L
String nodeid = ng->skeletons[0];
ERR_FAIL_COND_V(!state.scene_map.has(nodeid), false); //weird, it should have it...
-#ifdef NO_SAFE_CAST
- NodeJoint *nj = static_cast<NodeJoint *>(state.scene_map[nodeid]);
-#else
NodeJoint *nj = dynamic_cast<NodeJoint *>(state.scene_map[nodeid]);
-#endif
ERR_FAIL_COND_V(!nj, false);
ERR_FAIL_COND_V(!nj->owner, false); //weird, node should have a skeleton owner
diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp
index 1e0f45419f..5585c8edd2 100644
--- a/editor/import/dynamic_font_import_settings.cpp
+++ b/editor/import/dynamic_font_import_settings.cpp
@@ -949,11 +949,11 @@ void DynamicFontImportSettings::_re_import() {
void DynamicFontImportSettings::open_settings(const String &p_path) {
// Load base font data.
- Vector<uint8_t> data = FileAccess::get_file_as_array(p_path);
+ Vector<uint8_t> font_data = FileAccess::get_file_as_array(p_path);
// Load font for preview.
font_preview.instantiate();
- font_preview->set_data(data);
+ font_preview->set_data(font_data);
String font_name = vformat("%s (%s)", font_preview->get_font_name(), font_preview->get_font_style_name());
String sample;
@@ -976,7 +976,7 @@ void DynamicFontImportSettings::open_settings(const String &p_path) {
// Load second copy of font with MSDF disabled for the glyph table and metadata extraction.
font_main.instantiate();
- font_main->set_data(data);
+ font_main->set_data(font_data);
font_main->set_multichannel_signed_distance_field(false);
text_edit->add_theme_font_override("font", font_main);
@@ -1036,7 +1036,7 @@ void DynamicFontImportSettings::open_settings(const String &p_path) {
double embolden = preload_config.has("variation_embolden") ? preload_config["variation_embolden"].operator double() : 0;
int face_index = preload_config.has("variation_face_index") ? preload_config["variation_face_index"].operator int() : 0;
Transform2D transform = preload_config.has("variation_transform") ? preload_config["variation_transform"].operator Transform2D() : Transform2D();
- Vector2i size = preload_config.has("size") ? preload_config["size"].operator Vector2i() : Vector2i(16, 0);
+ Vector2i font_size = preload_config.has("size") ? preload_config["size"].operator Vector2i() : Vector2i(16, 0);
String cfg_name = preload_config.has("name") ? preload_config["name"].operator String() : vformat("Configuration %d", i);
TreeItem *vars_item = vars_list->create_item(vars_list_root);
@@ -1061,8 +1061,8 @@ void DynamicFontImportSettings::open_settings(const String &p_path) {
import_variation_data_custom->options = options_variations;
vars_item->set_metadata(0, import_variation_data_custom);
- import_variation_data_custom->set("size", size.x);
- import_variation_data_custom->set("outline_size", size.y);
+ import_variation_data_custom->set("size", font_size.x);
+ import_variation_data_custom->set("outline_size", font_size.y);
import_variation_data_custom->set("variation_opentype", variation);
import_variation_data_custom->set("variation_embolden", embolden);
import_variation_data_custom->set("variation_face_index", face_index);
diff --git a/editor/import/editor_import_plugin.cpp b/editor/import/editor_import_plugin.cpp
index 5211f003c1..5d684fc5db 100644
--- a/editor/import/editor_import_plugin.cpp
+++ b/editor/import/editor_import_plugin.cpp
@@ -154,7 +154,7 @@ bool EditorImportPlugin::get_option_visibility(const String &p_path, const Strin
d[E->key] = E->value;
++E;
}
- bool visible;
+ bool visible = false;
if (GDVIRTUAL_CALL(_get_option_visibility, p_path, p_option, d, visible)) {
return visible;
}
@@ -172,7 +172,7 @@ Error EditorImportPlugin::import(const String &p_source_file, const String &p_sa
++E;
}
- int err;
+ int err = 0;
if (GDVIRTUAL_CALL(_import, p_source_file, p_save_path, options, platform_variants, gen_files, err)) {
Error ret_err = Error(err);
diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp
index ed83535421..9dafa47c1c 100644
--- a/editor/import/resource_importer_layered_texture.cpp
+++ b/editor/import/resource_importer_layered_texture.cpp
@@ -396,12 +396,12 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
texture_import->used_channels = used_channels;
_check_compress_ctex(p_source_file, texture_import);
if (r_metadata) {
- Dictionary metadata;
- metadata["vram_texture"] = compress_mode == COMPRESS_VRAM_COMPRESSED;
+ Dictionary meta;
+ meta["vram_texture"] = compress_mode == COMPRESS_VRAM_COMPRESSED;
if (formats_imported.size()) {
- metadata["imported_formats"] = formats_imported;
+ meta["imported_formats"] = formats_imported;
}
- *r_metadata = metadata;
+ *r_metadata = meta;
}
return OK;
@@ -432,20 +432,20 @@ String ResourceImporterLayeredTexture::get_import_settings_string() const {
bool ResourceImporterLayeredTexture::are_import_settings_valid(const String &p_path) const {
//will become invalid if formats are missing to import
- Dictionary metadata = ResourceFormatImporter::get_singleton()->get_resource_metadata(p_path);
+ Dictionary meta = ResourceFormatImporter::get_singleton()->get_resource_metadata(p_path);
- if (!metadata.has("vram_texture")) {
+ if (!meta.has("vram_texture")) {
return false;
}
- bool vram = metadata["vram_texture"];
+ bool vram = meta["vram_texture"];
if (!vram) {
return true; //do not care about non vram
}
Vector<String> formats_imported;
- if (metadata.has("imported_formats")) {
- formats_imported = metadata["imported_formats"];
+ if (meta.has("imported_formats")) {
+ formats_imported = meta["imported_formats"];
}
int index = 0;
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index b5798a5784..756d61f712 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -953,43 +953,49 @@ Node *ResourceImporterScene::_pre_fix_animations(Node *p_node, Node *p_root, con
if (Object::cast_to<AnimationPlayer>(p_node)) {
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
+ List<StringName> anims;
+ ap->get_animation_list(&anims);
- Array animation_clips;
- {
- int clip_count = node_settings["clips/amount"];
+ for (const StringName &name : anims) {
+ Ref<Animation> anim = ap->get_animation(name);
+ Array animation_slices;
- for (int i = 0; i < clip_count; i++) {
- String name = node_settings["clip_" + itos(i + 1) + "/name"];
- int from_frame = node_settings["clip_" + itos(i + 1) + "/start_frame"];
- int end_frame = node_settings["clip_" + itos(i + 1) + "/end_frame"];
- Animation::LoopMode loop_mode = static_cast<Animation::LoopMode>((int)node_settings["clip_" + itos(i + 1) + "/loop_mode"]);
- bool save_to_file = node_settings["clip_" + itos(i + 1) + "/save_to_file/enabled"];
- bool save_to_path = node_settings["clip_" + itos(i + 1) + "/save_to_file/path"];
- bool save_to_file_keep_custom = node_settings["clip_" + itos(i + 1) + "/save_to_file/keep_custom_tracks"];
+ if (p_animation_data.has(name)) {
+ Dictionary anim_settings = p_animation_data[name];
+ int slices_count = anim_settings["slices/amount"];
+
+ for (int i = 0; i < slices_count; i++) {
+ String slice_name = anim_settings["slice_" + itos(i + 1) + "/name"];
+ int from_frame = anim_settings["slice_" + itos(i + 1) + "/start_frame"];
+ int end_frame = anim_settings["slice_" + itos(i + 1) + "/end_frame"];
+ Animation::LoopMode loop_mode = static_cast<Animation::LoopMode>((int)anim_settings["slice_" + itos(i + 1) + "/loop_mode"]);
+ bool save_to_file = anim_settings["slice_" + itos(i + 1) + "/save_to_file/enabled"];
+ bool save_to_path = anim_settings["slice_" + itos(i + 1) + "/save_to_file/path"];
+ bool save_to_file_keep_custom = anim_settings["slice_" + itos(i + 1) + "/save_to_file/keep_custom_tracks"];
+
+ animation_slices.push_back(slice_name);
+ animation_slices.push_back(from_frame / p_animation_fps);
+ animation_slices.push_back(end_frame / p_animation_fps);
+ animation_slices.push_back(loop_mode);
+ animation_slices.push_back(save_to_file);
+ animation_slices.push_back(save_to_path);
+ animation_slices.push_back(save_to_file_keep_custom);
+ }
+ }
- animation_clips.push_back(name);
- animation_clips.push_back(from_frame / p_animation_fps);
- animation_clips.push_back(end_frame / p_animation_fps);
- animation_clips.push_back(loop_mode);
- animation_clips.push_back(save_to_file);
- animation_clips.push_back(save_to_path);
- animation_clips.push_back(save_to_file_keep_custom);
+ if (animation_slices.size() > 0) {
+ _create_slices(ap, anim, animation_slices, true);
}
}
- if (animation_clips.size()) {
- _create_clips(ap, animation_clips, true);
- } else {
- List<StringName> anims;
- ap->get_animation_list(&anims);
- AnimationImportTracks import_tracks_mode[TRACK_CHANNEL_MAX] = {
- AnimationImportTracks(int(node_settings["import_tracks/position"])),
- AnimationImportTracks(int(node_settings["import_tracks/rotation"])),
- AnimationImportTracks(int(node_settings["import_tracks/scale"]))
- };
- if (anims.size() > 1 && (import_tracks_mode[0] != ANIMATION_IMPORT_TRACKS_IF_PRESENT || import_tracks_mode[1] != ANIMATION_IMPORT_TRACKS_IF_PRESENT || import_tracks_mode[2] != ANIMATION_IMPORT_TRACKS_IF_PRESENT)) {
- _optimize_track_usage(ap, import_tracks_mode);
- }
+ AnimationImportTracks import_tracks_mode[TRACK_CHANNEL_MAX] = {
+ AnimationImportTracks(int(node_settings["import_tracks/position"])),
+ AnimationImportTracks(int(node_settings["import_tracks/rotation"])),
+ AnimationImportTracks(int(node_settings["import_tracks/scale"]))
+ };
+
+ if (anims.size() > 1 && (import_tracks_mode[0] != ANIMATION_IMPORT_TRACKS_IF_PRESENT || import_tracks_mode[1] != ANIMATION_IMPORT_TRACKS_IF_PRESENT || import_tracks_mode[2] != ANIMATION_IMPORT_TRACKS_IF_PRESENT)) {
+ _optimize_track_usage(ap, import_tracks_mode);
}
}
@@ -1408,144 +1414,138 @@ Ref<Animation> ResourceImporterScene::_save_animation_to_file(Ref<Animation> ani
return anim;
}
-void ResourceImporterScene::_create_clips(AnimationPlayer *anim, const Array &p_clips, bool p_bake_all) {
- if (!anim->has_animation("default")) {
- ERR_FAIL_COND_MSG(p_clips.size() > 0, "To create clips, animations must be named \"default\".");
- return;
- }
+void ResourceImporterScene::_create_slices(AnimationPlayer *ap, Ref<Animation> anim, const Array &p_slices, bool p_bake_all) {
+ Ref<AnimationLibrary> al = ap->get_animation_library(ap->find_animation_library(anim));
- Ref<Animation> default_anim = anim->get_animation("default");
- Ref<AnimationLibrary> al = anim->get_animation_library(anim->find_animation(default_anim));
-
- for (int i = 0; i < p_clips.size(); i += 7) {
- String name = p_clips[i];
- float from = p_clips[i + 1];
- float to = p_clips[i + 2];
- Animation::LoopMode loop_mode = static_cast<Animation::LoopMode>((int)p_clips[i + 3]);
- bool save_to_file = p_clips[i + 4];
- String save_to_path = p_clips[i + 5];
- bool keep_current = p_clips[i + 6];
+ for (int i = 0; i < p_slices.size(); i += 7) {
+ String name = p_slices[i];
+ float from = p_slices[i + 1];
+ float to = p_slices[i + 2];
+ Animation::LoopMode loop_mode = static_cast<Animation::LoopMode>((int)p_slices[i + 3]);
+ bool save_to_file = p_slices[i + 4];
+ String save_to_path = p_slices[i + 5];
+ bool keep_current = p_slices[i + 6];
if (from >= to) {
continue;
}
Ref<Animation> new_anim = memnew(Animation);
- for (int j = 0; j < default_anim->get_track_count(); j++) {
+ for (int j = 0; j < anim->get_track_count(); j++) {
List<float> keys;
- int kc = default_anim->track_get_key_count(j);
+ int kc = anim->track_get_key_count(j);
int dtrack = -1;
for (int k = 0; k < kc; k++) {
- float kt = default_anim->track_get_key_time(j, k);
+ float kt = anim->track_get_key_time(j, k);
if (kt >= from && kt < to) {
//found a key within range, so create track
if (dtrack == -1) {
- new_anim->add_track(default_anim->track_get_type(j));
+ new_anim->add_track(anim->track_get_type(j));
dtrack = new_anim->get_track_count() - 1;
- new_anim->track_set_path(dtrack, default_anim->track_get_path(j));
+ new_anim->track_set_path(dtrack, anim->track_get_path(j));
if (kt > (from + 0.01) && k > 0) {
- if (default_anim->track_get_type(j) == Animation::TYPE_POSITION_3D) {
+ if (anim->track_get_type(j) == Animation::TYPE_POSITION_3D) {
Vector3 p;
- default_anim->position_track_interpolate(j, from, &p);
+ anim->position_track_interpolate(j, from, &p);
new_anim->position_track_insert_key(dtrack, 0, p);
- } else if (default_anim->track_get_type(j) == Animation::TYPE_ROTATION_3D) {
+ } else if (anim->track_get_type(j) == Animation::TYPE_ROTATION_3D) {
Quaternion r;
- default_anim->rotation_track_interpolate(j, from, &r);
+ anim->rotation_track_interpolate(j, from, &r);
new_anim->rotation_track_insert_key(dtrack, 0, r);
- } else if (default_anim->track_get_type(j) == Animation::TYPE_SCALE_3D) {
+ } else if (anim->track_get_type(j) == Animation::TYPE_SCALE_3D) {
Vector3 s;
- default_anim->scale_track_interpolate(j, from, &s);
+ anim->scale_track_interpolate(j, from, &s);
new_anim->scale_track_insert_key(dtrack, 0, s);
- } else if (default_anim->track_get_type(j) == Animation::TYPE_VALUE) {
- Variant var = default_anim->value_track_interpolate(j, from);
+ } else if (anim->track_get_type(j) == Animation::TYPE_VALUE) {
+ Variant var = anim->value_track_interpolate(j, from);
new_anim->track_insert_key(dtrack, 0, var);
- } else if (default_anim->track_get_type(j) == Animation::TYPE_BLEND_SHAPE) {
+ } else if (anim->track_get_type(j) == Animation::TYPE_BLEND_SHAPE) {
float interp;
- default_anim->blend_shape_track_interpolate(j, from, &interp);
+ anim->blend_shape_track_interpolate(j, from, &interp);
new_anim->blend_shape_track_insert_key(dtrack, 0, interp);
}
}
}
- if (default_anim->track_get_type(j) == Animation::TYPE_POSITION_3D) {
+ if (anim->track_get_type(j) == Animation::TYPE_POSITION_3D) {
Vector3 p;
- default_anim->position_track_get_key(j, k, &p);
+ anim->position_track_get_key(j, k, &p);
new_anim->position_track_insert_key(dtrack, kt - from, p);
- } else if (default_anim->track_get_type(j) == Animation::TYPE_ROTATION_3D) {
+ } else if (anim->track_get_type(j) == Animation::TYPE_ROTATION_3D) {
Quaternion r;
- default_anim->rotation_track_get_key(j, k, &r);
+ anim->rotation_track_get_key(j, k, &r);
new_anim->rotation_track_insert_key(dtrack, kt - from, r);
- } else if (default_anim->track_get_type(j) == Animation::TYPE_SCALE_3D) {
+ } else if (anim->track_get_type(j) == Animation::TYPE_SCALE_3D) {
Vector3 s;
- default_anim->scale_track_get_key(j, k, &s);
+ anim->scale_track_get_key(j, k, &s);
new_anim->scale_track_insert_key(dtrack, kt - from, s);
- } else if (default_anim->track_get_type(j) == Animation::TYPE_VALUE) {
- Variant var = default_anim->track_get_key_value(j, k);
+ } else if (anim->track_get_type(j) == Animation::TYPE_VALUE) {
+ Variant var = anim->track_get_key_value(j, k);
new_anim->track_insert_key(dtrack, kt - from, var);
- } else if (default_anim->track_get_type(j) == Animation::TYPE_BLEND_SHAPE) {
+ } else if (anim->track_get_type(j) == Animation::TYPE_BLEND_SHAPE) {
float interp;
- default_anim->blend_shape_track_get_key(j, k, &interp);
+ anim->blend_shape_track_get_key(j, k, &interp);
new_anim->blend_shape_track_insert_key(dtrack, kt - from, interp);
}
}
if (dtrack != -1 && kt >= to) {
- if (default_anim->track_get_type(j) == Animation::TYPE_POSITION_3D) {
+ if (anim->track_get_type(j) == Animation::TYPE_POSITION_3D) {
Vector3 p;
- default_anim->position_track_interpolate(j, to, &p);
+ anim->position_track_interpolate(j, to, &p);
new_anim->position_track_insert_key(dtrack, to - from, p);
- } else if (default_anim->track_get_type(j) == Animation::TYPE_ROTATION_3D) {
+ } else if (anim->track_get_type(j) == Animation::TYPE_ROTATION_3D) {
Quaternion r;
- default_anim->rotation_track_interpolate(j, to, &r);
+ anim->rotation_track_interpolate(j, to, &r);
new_anim->rotation_track_insert_key(dtrack, to - from, r);
- } else if (default_anim->track_get_type(j) == Animation::TYPE_SCALE_3D) {
+ } else if (anim->track_get_type(j) == Animation::TYPE_SCALE_3D) {
Vector3 s;
- default_anim->scale_track_interpolate(j, to, &s);
+ anim->scale_track_interpolate(j, to, &s);
new_anim->scale_track_insert_key(dtrack, to - from, s);
- } else if (default_anim->track_get_type(j) == Animation::TYPE_VALUE) {
- Variant var = default_anim->value_track_interpolate(j, to);
+ } else if (anim->track_get_type(j) == Animation::TYPE_VALUE) {
+ Variant var = anim->value_track_interpolate(j, to);
new_anim->track_insert_key(dtrack, to - from, var);
- } else if (default_anim->track_get_type(j) == Animation::TYPE_BLEND_SHAPE) {
+ } else if (anim->track_get_type(j) == Animation::TYPE_BLEND_SHAPE) {
float interp;
- default_anim->blend_shape_track_interpolate(j, to, &interp);
+ anim->blend_shape_track_interpolate(j, to, &interp);
new_anim->blend_shape_track_insert_key(dtrack, to - from, interp);
}
}
}
if (dtrack == -1 && p_bake_all) {
- new_anim->add_track(default_anim->track_get_type(j));
+ new_anim->add_track(anim->track_get_type(j));
dtrack = new_anim->get_track_count() - 1;
- new_anim->track_set_path(dtrack, default_anim->track_get_path(j));
- if (default_anim->track_get_type(j) == Animation::TYPE_POSITION_3D) {
+ new_anim->track_set_path(dtrack, anim->track_get_path(j));
+ if (anim->track_get_type(j) == Animation::TYPE_POSITION_3D) {
Vector3 p;
- default_anim->position_track_interpolate(j, from, &p);
+ anim->position_track_interpolate(j, from, &p);
new_anim->position_track_insert_key(dtrack, 0, p);
- default_anim->position_track_interpolate(j, to, &p);
+ anim->position_track_interpolate(j, to, &p);
new_anim->position_track_insert_key(dtrack, to - from, p);
- } else if (default_anim->track_get_type(j) == Animation::TYPE_ROTATION_3D) {
+ } else if (anim->track_get_type(j) == Animation::TYPE_ROTATION_3D) {
Quaternion r;
- default_anim->rotation_track_interpolate(j, from, &r);
+ anim->rotation_track_interpolate(j, from, &r);
new_anim->rotation_track_insert_key(dtrack, 0, r);
- default_anim->rotation_track_interpolate(j, to, &r);
+ anim->rotation_track_interpolate(j, to, &r);
new_anim->rotation_track_insert_key(dtrack, to - from, r);
- } else if (default_anim->track_get_type(j) == Animation::TYPE_SCALE_3D) {
+ } else if (anim->track_get_type(j) == Animation::TYPE_SCALE_3D) {
Vector3 s;
- default_anim->scale_track_interpolate(j, from, &s);
+ anim->scale_track_interpolate(j, from, &s);
new_anim->scale_track_insert_key(dtrack, 0, s);
- default_anim->scale_track_interpolate(j, to, &s);
+ anim->scale_track_interpolate(j, to, &s);
new_anim->scale_track_insert_key(dtrack, to - from, s);
- } else if (default_anim->track_get_type(j) == Animation::TYPE_VALUE) {
- Variant var = default_anim->value_track_interpolate(j, from);
+ } else if (anim->track_get_type(j) == Animation::TYPE_VALUE) {
+ Variant var = anim->value_track_interpolate(j, from);
new_anim->track_insert_key(dtrack, 0, var);
- Variant to_var = default_anim->value_track_interpolate(j, to);
+ Variant to_var = anim->value_track_interpolate(j, to);
new_anim->track_insert_key(dtrack, to - from, to_var);
- } else if (default_anim->track_get_type(j) == Animation::TYPE_BLEND_SHAPE) {
+ } else if (anim->track_get_type(j) == Animation::TYPE_BLEND_SHAPE) {
float interp;
- default_anim->blend_shape_track_interpolate(j, from, &interp);
+ anim->blend_shape_track_interpolate(j, from, &interp);
new_anim->blend_shape_track_insert_key(dtrack, 0, interp);
- default_anim->blend_shape_track_interpolate(j, to, &interp);
+ anim->blend_shape_track_interpolate(j, to, &interp);
new_anim->blend_shape_track_insert_key(dtrack, to - from, interp);
}
}
@@ -1562,7 +1562,7 @@ void ResourceImporterScene::_create_clips(AnimationPlayer *anim, const Array &p_
}
}
- al->remove_animation("default"); // Remove default (no longer needed).
+ al->remove_animation(ap->find_animation(anim)); // Remove original animation (no longer needed).
}
void ResourceImporterScene::_optimize_animations(AnimationPlayer *anim, float p_max_vel_error, float p_max_ang_error, int p_prc_error) {
@@ -1642,6 +1642,17 @@ void ResourceImporterScene::get_internal_import_options(InternalImportCategory p
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "save_to_file/enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "save_to_file/path", PROPERTY_HINT_SAVE_FILE, "*.res,*.tres"), ""));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "save_to_file/keep_custom_tracks"), ""));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slices/amount", PROPERTY_HINT_RANGE, "0,256,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 0));
+
+ for (int i = 0; i < 256; i++) {
+ r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "slice_" + itos(i + 1) + "/name"), ""));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slice_" + itos(i + 1) + "/start_frame"), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slice_" + itos(i + 1) + "/end_frame"), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slice_" + itos(i + 1) + "/loop_mode", PROPERTY_HINT_ENUM, "None,Linear,Pingpong"), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "slice_" + itos(i + 1) + "/save_to_file/enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "slice_" + itos(i + 1) + "/save_to_file/path", PROPERTY_HINT_SAVE_FILE, ".res,*.tres"), ""));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "slice_" + itos(i + 1) + "/save_to_file/keep_custom_tracks"), false));
+ }
} break;
case INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE: {
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "import/skip_import", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false));
@@ -1654,17 +1665,6 @@ void ResourceImporterScene::get_internal_import_options(InternalImportCategory p
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "import_tracks/position", PROPERTY_HINT_ENUM, "IfPresent,IfPresentForAll,Never"), 1));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "import_tracks/rotation", PROPERTY_HINT_ENUM, "IfPresent,IfPresentForAll,Never"), 1));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "import_tracks/scale", PROPERTY_HINT_ENUM, "IfPresent,IfPresentForAll,Never"), 1));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slices/amount", PROPERTY_HINT_RANGE, "0,256,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 0));
-
- for (int i = 0; i < 256; i++) {
- r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "slice_" + itos(i + 1) + "/name"), ""));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slice_" + itos(i + 1) + "/start_frame"), 0));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slice_" + itos(i + 1) + "/end_frame"), 0));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slice_" + itos(i + 1) + "/loop_mode", PROPERTY_HINT_ENUM, "None,Linear,Pingpong"), 0));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "slice_" + itos(i + 1) + "/save_to_file/enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false));
- r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "slice_" + itos(i + 1) + "/save_to_file/path", PROPERTY_HINT_SAVE_FILE, ".res,*.tres"), ""));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "slice_" + itos(i + 1) + "/save_to_file/keep_custom_tracks"), false));
- }
} break;
case INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE: {
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "import/skip_import", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false));
@@ -1767,6 +1767,13 @@ bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategor
if (p_option == "save_to_file/path" || p_option == "save_to_file/keep_custom_tracks") {
return p_options["save_to_file/enabled"];
}
+ if (p_option.begins_with("slice_")) {
+ int max_slice = p_options["slices/amount"];
+ int slice = p_option.get_slice("_", 1).to_int() - 1;
+ if (slice >= max_slice) {
+ return false;
+ }
+ }
} break;
case INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE: {
if (p_option.begins_with("optimizer/") && p_option != "optimizer/enabled" && !bool(p_options["optimizer/enabled"])) {
@@ -1775,14 +1782,6 @@ bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategor
if (p_option.begins_with("compression/") && p_option != "compression/enabled" && !bool(p_options["compression/enabled"])) {
return false;
}
-
- if (p_option.begins_with("slice_")) {
- int max_slice = p_options["slices/amount"];
- int slice = p_option.get_slice("_", 1).to_int() - 1;
- if (slice >= max_slice) {
- return false;
- }
- }
} break;
case INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE: {
const bool use_retarget = p_options["retarget/bone_map"].get_validated_object() != nullptr;
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index 386519bc59..498e9f2964 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -283,7 +283,7 @@ public:
Node *_post_fix_animations(Node *p_node, Node *p_root, const Dictionary &p_node_data, const Dictionary &p_animation_data, float p_animation_fps);
Ref<Animation> _save_animation_to_file(Ref<Animation> anim, bool p_save_to_file, String p_save_to_path, bool p_keep_custom_tracks);
- void _create_clips(AnimationPlayer *anim, const Array &p_clips, bool p_bake_all);
+ void _create_slices(AnimationPlayer *ap, Ref<Animation> anim, const Array &p_clips, bool p_bake_all);
void _optimize_animations(AnimationPlayer *anim, float p_max_vel_error, float p_max_ang_error, int p_prc_error);
void _compress_animations(AnimationPlayer *anim, int p_page_size_kb);
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp
index c06756ff0b..ed3f1ff489 100644
--- a/editor/import/resource_importer_texture.cpp
+++ b/editor/import/resource_importer_texture.cpp
@@ -233,7 +233,8 @@ void ResourceImporterTexture::get_import_options(const String &p_path, List<Impo
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "process/size_limit", PROPERTY_HINT_RANGE, "0,4096,1"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "detect_3d/compress_to", PROPERTY_HINT_ENUM, "Disabled,VRAM Compressed,Basis Universal"), (p_preset == PRESET_DETECT) ? 1 : 0));
- if (p_path.get_extension() == "svg") {
+ // Do path based customization only if a path was passed.
+ if (p_path.is_empty() || p_path.get_extension() == "svg") {
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "svg/scale", PROPERTY_HINT_RANGE, "0.001,100,0.001"), 1.0));
// Editor use only, applies to SVG.
@@ -669,23 +670,23 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
}
if (r_metadata) {
- Dictionary metadata;
- metadata["vram_texture"] = compress_mode == COMPRESS_VRAM_COMPRESSED;
+ Dictionary meta;
+ meta["vram_texture"] = compress_mode == COMPRESS_VRAM_COMPRESSED;
if (formats_imported.size()) {
- metadata["imported_formats"] = formats_imported;
+ meta["imported_formats"] = formats_imported;
}
if (editor_image.is_valid()) {
- metadata["has_editor_variant"] = true;
+ meta["has_editor_variant"] = true;
if (use_editor_scale) {
- metadata["editor_scale"] = EDSCALE;
+ meta["editor_scale"] = EDSCALE;
}
if (convert_editor_colors) {
- metadata["editor_dark_theme"] = EditorSettings::get_singleton()->is_dark_theme();
+ meta["editor_dark_theme"] = EditorSettings::get_singleton()->is_dark_theme();
}
}
- *r_metadata = metadata;
+ *r_metadata = meta;
}
return OK;
}
@@ -715,29 +716,29 @@ String ResourceImporterTexture::get_import_settings_string() const {
bool ResourceImporterTexture::are_import_settings_valid(const String &p_path) const {
//will become invalid if formats are missing to import
- Dictionary metadata = ResourceFormatImporter::get_singleton()->get_resource_metadata(p_path);
+ Dictionary meta = ResourceFormatImporter::get_singleton()->get_resource_metadata(p_path);
- if (metadata.has("has_editor_variant")) {
- if (metadata.has("editor_scale") && (float)metadata["editor_scale"] != EDSCALE) {
+ if (meta.has("has_editor_variant")) {
+ if (meta.has("editor_scale") && (float)meta["editor_scale"] != EDSCALE) {
return false;
}
- if (metadata.has("editor_dark_theme") && (bool)metadata["editor_dark_theme"] != EditorSettings::get_singleton()->is_dark_theme()) {
+ if (meta.has("editor_dark_theme") && (bool)meta["editor_dark_theme"] != EditorSettings::get_singleton()->is_dark_theme()) {
return false;
}
}
- if (!metadata.has("vram_texture")) {
+ if (!meta.has("vram_texture")) {
return false;
}
- bool vram = metadata["vram_texture"];
+ bool vram = meta["vram_texture"];
if (!vram) {
return true; // Do not care about non-VRAM.
}
Vector<String> formats_imported;
- if (metadata.has("imported_formats")) {
- formats_imported = metadata["imported_formats"];
+ if (meta.has("imported_formats")) {
+ formats_imported = meta["imported_formats"];
}
int index = 0;
diff --git a/editor/input_event_configuration_dialog.cpp b/editor/input_event_configuration_dialog.cpp
new file mode 100644
index 0000000000..ed9a5898fb
--- /dev/null
+++ b/editor/input_event_configuration_dialog.cpp
@@ -0,0 +1,700 @@
+/*************************************************************************/
+/* input_event_configuration_dialog.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "editor/input_event_configuration_dialog.h"
+#include "core/input/input_map.h"
+#include "editor/editor_scale.h"
+#include "editor/event_listener_line_edit.h"
+#include "scene/gui/check_box.h"
+#include "scene/gui/line_edit.h"
+#include "scene/gui/option_button.h"
+#include "scene/gui/separator.h"
+#include "scene/gui/tree.h"
+
+// Maps to 2*axis if value is neg, or 2*axis+1 if value is pos.
+static const char *_joy_axis_descriptions[(size_t)JoyAxis::MAX * 2] = {
+ TTRC("Left Stick Left, Joystick 0 Left"),
+ TTRC("Left Stick Right, Joystick 0 Right"),
+ TTRC("Left Stick Up, Joystick 0 Up"),
+ TTRC("Left Stick Down, Joystick 0 Down"),
+ TTRC("Right Stick Left, Joystick 1 Left"),
+ TTRC("Right Stick Right, Joystick 1 Right"),
+ TTRC("Right Stick Up, Joystick 1 Up"),
+ TTRC("Right Stick Down, Joystick 1 Down"),
+ TTRC("Joystick 2 Left"),
+ TTRC("Left Trigger, Sony L2, Xbox LT, Joystick 2 Right"),
+ TTRC("Joystick 2 Up"),
+ TTRC("Right Trigger, Sony R2, Xbox RT, Joystick 2 Down"),
+ TTRC("Joystick 3 Left"),
+ TTRC("Joystick 3 Right"),
+ TTRC("Joystick 3 Up"),
+ TTRC("Joystick 3 Down"),
+ TTRC("Joystick 4 Left"),
+ TTRC("Joystick 4 Right"),
+ TTRC("Joystick 4 Up"),
+ TTRC("Joystick 4 Down"),
+};
+
+String InputEventConfigurationDialog::get_event_text(const Ref<InputEvent> &p_event, bool p_include_device) const {
+ ERR_FAIL_COND_V_MSG(p_event.is_null(), String(), "Provided event is not a valid instance of InputEvent");
+
+ String text = p_event->as_text();
+
+ Ref<InputEventKey> key = p_event;
+ if (key.is_valid() && key->is_command_or_control_autoremap()) {
+#ifdef MACOS_ENABLED
+ text = text.replace("Command", "Command/Ctrl");
+#else
+ text = text.replace("Ctrl", "Command/Ctrl");
+#endif
+ }
+ Ref<InputEventMouse> mouse = p_event;
+ Ref<InputEventJoypadMotion> jp_motion = p_event;
+ Ref<InputEventJoypadButton> jp_button = p_event;
+ if (jp_motion.is_valid()) {
+ // Joypad motion events will display slightly differently than what the event->as_text() provides. See #43660.
+ String desc = TTR("Unknown Joypad Axis");
+ if (jp_motion->get_axis() < JoyAxis::MAX) {
+ desc = RTR(_joy_axis_descriptions[2 * (size_t)jp_motion->get_axis() + (jp_motion->get_axis_value() < 0 ? 0 : 1)]);
+ }
+
+ text = vformat("Joypad Axis %s %s (%s)", itos((int64_t)jp_motion->get_axis()), jp_motion->get_axis_value() < 0 ? "-" : "+", desc);
+ }
+ if (p_include_device && (mouse.is_valid() || jp_button.is_valid() || jp_motion.is_valid())) {
+ String device_string = _get_device_string(p_event->get_device());
+ text += vformat(" - %s", device_string);
+ }
+
+ return text;
+}
+
+void InputEventConfigurationDialog::_set_event(const Ref<InputEvent> &p_event, bool p_update_input_list_selection) {
+ if (p_event.is_valid()) {
+ event = p_event;
+
+ // If the event is changed to something which is not the same as the listener,
+ // clear out the event from the listener text box to avoid confusion.
+ const Ref<InputEvent> listener_event = event_listener->get_event();
+ if (listener_event.is_valid() && !listener_event->is_match(p_event)) {
+ event_listener->clear_event();
+ }
+
+ // Update Label
+ event_as_text->set_text(get_event_text(event, true));
+
+ Ref<InputEventKey> k = p_event;
+ Ref<InputEventMouseButton> mb = p_event;
+ Ref<InputEventJoypadButton> joyb = p_event;
+ Ref<InputEventJoypadMotion> joym = p_event;
+ Ref<InputEventWithModifiers> mod = p_event;
+
+ // Update option values and visibility
+ bool show_mods = false;
+ bool show_device = false;
+ bool show_phys_key = false;
+
+ if (mod.is_valid()) {
+ show_mods = true;
+ mod_checkboxes[MOD_ALT]->set_pressed(mod->is_alt_pressed());
+ mod_checkboxes[MOD_SHIFT]->set_pressed(mod->is_shift_pressed());
+ mod_checkboxes[MOD_CTRL]->set_pressed(mod->is_ctrl_pressed());
+ mod_checkboxes[MOD_META]->set_pressed(mod->is_meta_pressed());
+
+ autoremap_command_or_control_checkbox->set_pressed(mod->is_command_or_control_autoremap());
+ }
+
+ if (k.is_valid()) {
+ show_phys_key = true;
+ physical_key_checkbox->set_pressed(k->get_physical_keycode() != Key::NONE && k->get_keycode() == Key::NONE);
+
+ } else if (joyb.is_valid() || joym.is_valid() || mb.is_valid()) {
+ show_device = true;
+ _set_current_device(event->get_device());
+ }
+
+ mod_container->set_visible(show_mods);
+ device_container->set_visible(show_device);
+ physical_key_checkbox->set_visible(show_phys_key);
+ additional_options_container->show();
+
+ // Update selected item in input list.
+ if (p_update_input_list_selection && (k.is_valid() || joyb.is_valid() || joym.is_valid() || mb.is_valid())) {
+ TreeItem *category = input_list_tree->get_root()->get_first_child();
+ while (category) {
+ TreeItem *input_item = category->get_first_child();
+
+ if (input_item != nullptr) {
+ // input_type should always be > 0, unless the tree structure has been misconfigured.
+ int input_type = input_item->get_parent()->get_meta("__type", 0);
+ if (input_type == 0) {
+ return;
+ }
+
+ // If event type matches input types of this category.
+ if ((k.is_valid() && input_type == INPUT_KEY) || (joyb.is_valid() && input_type == INPUT_JOY_BUTTON) || (joym.is_valid() && input_type == INPUT_JOY_MOTION) || (mb.is_valid() && input_type == INPUT_MOUSE_BUTTON)) {
+ // Loop through all items of this category until one matches.
+ while (input_item) {
+ bool key_match = k.is_valid() && (Variant(k->get_keycode()) == input_item->get_meta("__keycode") || Variant(k->get_physical_keycode()) == input_item->get_meta("__keycode"));
+ bool joyb_match = joyb.is_valid() && Variant(joyb->get_button_index()) == input_item->get_meta("__index");
+ bool joym_match = joym.is_valid() && Variant(joym->get_axis()) == input_item->get_meta("__axis") && joym->get_axis_value() == (float)input_item->get_meta("__value");
+ bool mb_match = mb.is_valid() && Variant(mb->get_button_index()) == input_item->get_meta("__index");
+ if (key_match || joyb_match || joym_match || mb_match) {
+ category->set_collapsed(false);
+ input_item->select(0);
+ input_list_tree->ensure_cursor_is_visible();
+ return;
+ }
+ input_item = input_item->get_next();
+ }
+ }
+ }
+
+ category->set_collapsed(true); // Event not in this category, so collapse;
+ category = category->get_next();
+ }
+ }
+ } else {
+ // Event is not valid, reset dialog
+ event = p_event;
+ event_listener->clear_event();
+ event_as_text->set_text(TTR("No Event Configured"));
+
+ additional_options_container->hide();
+ input_list_tree->deselect_all();
+ _update_input_list();
+ }
+}
+
+void InputEventConfigurationDialog::_on_listen_input_changed(const Ref<InputEvent> &p_event) {
+ // Ignore if invalid, echo or not pressed
+ if (p_event.is_null() || p_event->is_echo() || !p_event->is_pressed()) {
+ return;
+ }
+
+ // Create an editable reference
+ Ref<InputEvent> received_event = p_event;
+ // Check what the type is and if it is allowed.
+ Ref<InputEventKey> k = received_event;
+ Ref<InputEventJoypadButton> joyb = received_event;
+ Ref<InputEventJoypadMotion> joym = received_event;
+ Ref<InputEventMouseButton> mb = received_event;
+
+ int type = 0;
+ if (k.is_valid()) {
+ type = INPUT_KEY;
+ } else if (joyb.is_valid()) {
+ type = INPUT_JOY_BUTTON;
+ } else if (joym.is_valid()) {
+ type = INPUT_JOY_MOTION;
+ } else if (mb.is_valid()) {
+ type = INPUT_MOUSE_BUTTON;
+ }
+
+ if (!(allowed_input_types & type)) {
+ return;
+ }
+
+ if (joym.is_valid()) {
+ float axis_value = joym->get_axis_value();
+ if (ABS(axis_value) < 0.9) {
+ // Ignore motion below 0.9 magnitude to avoid accidental touches
+ return;
+ } else {
+ // Always make the value 1 or -1 for display consistency
+ joym->set_axis_value(SIGN(axis_value));
+ }
+ }
+
+ if (k.is_valid()) {
+ k->set_pressed(false); // To avoid serialisation of 'pressed' property - doesn't matter for actions anyway.
+ // Maintain physical keycode option state
+ if (physical_key_checkbox->is_pressed()) {
+ k->set_keycode(Key::NONE);
+ } else {
+ k->set_physical_keycode(Key::NONE);
+ }
+ }
+
+ Ref<InputEventWithModifiers> mod = received_event;
+ if (mod.is_valid()) {
+ mod->set_window_id(0);
+ }
+
+ // Maintain device selection.
+ received_event->set_device(_get_current_device());
+
+ _set_event(received_event);
+}
+
+void InputEventConfigurationDialog::_on_listen_focus_changed() {
+ if (event_listener->has_focus()) {
+ set_close_on_escape(false);
+ } else {
+ set_close_on_escape(true);
+ }
+}
+
+void InputEventConfigurationDialog::_search_term_updated(const String &) {
+ _update_input_list();
+}
+
+void InputEventConfigurationDialog::_update_input_list() {
+ input_list_tree->clear();
+
+ TreeItem *root = input_list_tree->create_item();
+ String search_term = input_list_search->get_text();
+
+ bool collapse = input_list_search->get_text().is_empty();
+
+ if (allowed_input_types & INPUT_KEY) {
+ TreeItem *kb_root = input_list_tree->create_item(root);
+ kb_root->set_text(0, TTR("Keyboard Keys"));
+ kb_root->set_icon(0, icon_cache.keyboard);
+ kb_root->set_collapsed(collapse);
+ kb_root->set_meta("__type", INPUT_KEY);
+
+ for (int i = 0; i < keycode_get_count(); i++) {
+ String name = keycode_get_name_by_index(i);
+
+ if (!search_term.is_empty() && name.findn(search_term) == -1) {
+ continue;
+ }
+
+ TreeItem *item = input_list_tree->create_item(kb_root);
+ item->set_text(0, name);
+ item->set_meta("__keycode", keycode_get_value_by_index(i));
+ }
+ }
+
+ if (allowed_input_types & INPUT_MOUSE_BUTTON) {
+ TreeItem *mouse_root = input_list_tree->create_item(root);
+ mouse_root->set_text(0, TTR("Mouse Buttons"));
+ mouse_root->set_icon(0, icon_cache.mouse);
+ mouse_root->set_collapsed(collapse);
+ mouse_root->set_meta("__type", INPUT_MOUSE_BUTTON);
+
+ MouseButton mouse_buttons[9] = { MouseButton::LEFT, MouseButton::RIGHT, MouseButton::MIDDLE, MouseButton::WHEEL_UP, MouseButton::WHEEL_DOWN, MouseButton::WHEEL_LEFT, MouseButton::WHEEL_RIGHT, MouseButton::MB_XBUTTON1, MouseButton::MB_XBUTTON2 };
+ for (int i = 0; i < 9; i++) {
+ Ref<InputEventMouseButton> mb;
+ mb.instantiate();
+ mb->set_button_index(mouse_buttons[i]);
+ String desc = get_event_text(mb, false);
+
+ if (!search_term.is_empty() && desc.findn(search_term) == -1) {
+ continue;
+ }
+
+ TreeItem *item = input_list_tree->create_item(mouse_root);
+ item->set_text(0, desc);
+ item->set_meta("__index", mouse_buttons[i]);
+ }
+ }
+
+ if (allowed_input_types & INPUT_JOY_BUTTON) {
+ TreeItem *joyb_root = input_list_tree->create_item(root);
+ joyb_root->set_text(0, TTR("Joypad Buttons"));
+ joyb_root->set_icon(0, icon_cache.joypad_button);
+ joyb_root->set_collapsed(collapse);
+ joyb_root->set_meta("__type", INPUT_JOY_BUTTON);
+
+ for (int i = 0; i < (int)JoyButton::MAX; i++) {
+ Ref<InputEventJoypadButton> joyb;
+ joyb.instantiate();
+ joyb->set_button_index((JoyButton)i);
+ String desc = get_event_text(joyb, false);
+
+ if (!search_term.is_empty() && desc.findn(search_term) == -1) {
+ continue;
+ }
+
+ TreeItem *item = input_list_tree->create_item(joyb_root);
+ item->set_text(0, desc);
+ item->set_meta("__index", i);
+ }
+ }
+
+ if (allowed_input_types & INPUT_JOY_MOTION) {
+ TreeItem *joya_root = input_list_tree->create_item(root);
+ joya_root->set_text(0, TTR("Joypad Axes"));
+ joya_root->set_icon(0, icon_cache.joypad_axis);
+ joya_root->set_collapsed(collapse);
+ joya_root->set_meta("__type", INPUT_JOY_MOTION);
+
+ for (int i = 0; i < (int)JoyAxis::MAX * 2; i++) {
+ int axis = i / 2;
+ int direction = (i & 1) ? 1 : -1;
+ Ref<InputEventJoypadMotion> joym;
+ joym.instantiate();
+ joym->set_axis((JoyAxis)axis);
+ joym->set_axis_value(direction);
+ String desc = get_event_text(joym, false);
+
+ if (!search_term.is_empty() && desc.findn(search_term) == -1) {
+ continue;
+ }
+
+ TreeItem *item = input_list_tree->create_item(joya_root);
+ item->set_text(0, desc);
+ item->set_meta("__axis", i >> 1);
+ item->set_meta("__value", (i & 1) ? 1 : -1);
+ }
+ }
+}
+
+void InputEventConfigurationDialog::_mod_toggled(bool p_checked, int p_index) {
+ Ref<InputEventWithModifiers> ie = event;
+
+ // Not event with modifiers
+ if (ie.is_null()) {
+ return;
+ }
+
+ if (p_index == 0) {
+ ie->set_alt_pressed(p_checked);
+ } else if (p_index == 1) {
+ ie->set_shift_pressed(p_checked);
+ } else if (p_index == 2) {
+ if (!autoremap_command_or_control_checkbox->is_pressed()) {
+ ie->set_ctrl_pressed(p_checked);
+ }
+ } else if (p_index == 3) {
+ if (!autoremap_command_or_control_checkbox->is_pressed()) {
+ ie->set_meta_pressed(p_checked);
+ }
+ }
+
+ _set_event(ie);
+}
+
+void InputEventConfigurationDialog::_autoremap_command_or_control_toggled(bool p_checked) {
+ Ref<InputEventWithModifiers> ie = event;
+ if (ie.is_valid()) {
+ ie->set_command_or_control_autoremap(p_checked);
+ _set_event(ie);
+ }
+
+ if (p_checked) {
+ mod_checkboxes[MOD_META]->hide();
+ mod_checkboxes[MOD_CTRL]->hide();
+ } else {
+ mod_checkboxes[MOD_META]->show();
+ mod_checkboxes[MOD_CTRL]->show();
+ }
+}
+
+void InputEventConfigurationDialog::_physical_keycode_toggled(bool p_checked) {
+ Ref<InputEventKey> k = event;
+
+ if (k.is_null()) {
+ return;
+ }
+
+ if (p_checked) {
+ k->set_physical_keycode(k->get_keycode());
+ k->set_keycode(Key::NONE);
+ } else {
+ k->set_keycode((Key)k->get_physical_keycode());
+ k->set_physical_keycode(Key::NONE);
+ }
+
+ _set_event(k);
+}
+
+void InputEventConfigurationDialog::_input_list_item_selected() {
+ TreeItem *selected = input_list_tree->get_selected();
+
+ // Invalid tree selection - type only exists on the "category" items, which are not a valid selection.
+ if (selected->has_meta("__type")) {
+ return;
+ }
+
+ InputType input_type = (InputType)(int)selected->get_parent()->get_meta("__type");
+
+ switch (input_type) {
+ case INPUT_KEY: {
+ Key keycode = (Key)(int)selected->get_meta("__keycode");
+ Ref<InputEventKey> k;
+ k.instantiate();
+
+ if (physical_key_checkbox->is_pressed()) {
+ k->set_physical_keycode(keycode);
+ k->set_keycode(Key::NONE);
+ } else {
+ k->set_physical_keycode(Key::NONE);
+ k->set_keycode(keycode);
+ }
+
+ // Maintain modifier state from checkboxes
+ k->set_alt_pressed(mod_checkboxes[MOD_ALT]->is_pressed());
+ k->set_shift_pressed(mod_checkboxes[MOD_SHIFT]->is_pressed());
+ if (autoremap_command_or_control_checkbox->is_pressed()) {
+ k->set_command_or_control_autoremap(true);
+ } else {
+ k->set_ctrl_pressed(mod_checkboxes[MOD_CTRL]->is_pressed());
+ k->set_meta_pressed(mod_checkboxes[MOD_META]->is_pressed());
+ }
+
+ _set_event(k, false);
+ } break;
+ case INPUT_MOUSE_BUTTON: {
+ MouseButton idx = (MouseButton)(int)selected->get_meta("__index");
+ Ref<InputEventMouseButton> mb;
+ mb.instantiate();
+ mb->set_button_index(idx);
+ // Maintain modifier state from checkboxes
+ mb->set_alt_pressed(mod_checkboxes[MOD_ALT]->is_pressed());
+ mb->set_shift_pressed(mod_checkboxes[MOD_SHIFT]->is_pressed());
+ if (autoremap_command_or_control_checkbox->is_pressed()) {
+ mb->set_command_or_control_autoremap(true);
+ } else {
+ mb->set_ctrl_pressed(mod_checkboxes[MOD_CTRL]->is_pressed());
+ mb->set_meta_pressed(mod_checkboxes[MOD_META]->is_pressed());
+ }
+
+ // Maintain selected device
+ mb->set_device(_get_current_device());
+
+ _set_event(mb, false);
+ } break;
+ case INPUT_JOY_BUTTON: {
+ JoyButton idx = (JoyButton)(int)selected->get_meta("__index");
+ Ref<InputEventJoypadButton> jb = InputEventJoypadButton::create_reference(idx);
+
+ // Maintain selected device
+ jb->set_device(_get_current_device());
+
+ _set_event(jb, false);
+ } break;
+ case INPUT_JOY_MOTION: {
+ JoyAxis axis = (JoyAxis)(int)selected->get_meta("__axis");
+ int value = selected->get_meta("__value");
+
+ Ref<InputEventJoypadMotion> jm;
+ jm.instantiate();
+ jm->set_axis(axis);
+ jm->set_axis_value(value);
+
+ // Maintain selected device
+ jm->set_device(_get_current_device());
+
+ _set_event(jm, false);
+ } break;
+ }
+}
+
+void InputEventConfigurationDialog::_device_selection_changed(int p_option_button_index) {
+ // Subtract 1 as option index 0 corresponds to "All Devices" (value of -1)
+ // and option index 1 corresponds to device 0, etc...
+ event->set_device(p_option_button_index - 1);
+ event_as_text->set_text(get_event_text(event, true));
+}
+
+void InputEventConfigurationDialog::_set_current_device(int p_device) {
+ device_id_option->select(p_device + 1);
+}
+
+int InputEventConfigurationDialog::_get_current_device() const {
+ return device_id_option->get_selected() - 1;
+}
+
+String InputEventConfigurationDialog::_get_device_string(int p_device) const {
+ if (p_device == InputMap::ALL_DEVICES) {
+ return TTR("All Devices");
+ }
+ return TTR("Device") + " " + itos(p_device);
+}
+
+void InputEventConfigurationDialog::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ input_list_search->set_right_icon(input_list_search->get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
+
+ physical_key_checkbox->set_icon(get_theme_icon(SNAME("KeyboardPhysical"), SNAME("EditorIcons")));
+
+ icon_cache.keyboard = get_theme_icon(SNAME("Keyboard"), SNAME("EditorIcons"));
+ icon_cache.mouse = get_theme_icon(SNAME("Mouse"), SNAME("EditorIcons"));
+ icon_cache.joypad_button = get_theme_icon(SNAME("JoyButton"), SNAME("EditorIcons"));
+ icon_cache.joypad_axis = get_theme_icon(SNAME("JoyAxis"), SNAME("EditorIcons"));
+
+ _update_input_list();
+ } break;
+ }
+}
+
+void InputEventConfigurationDialog::popup_and_configure(const Ref<InputEvent> &p_event) {
+ if (p_event.is_valid()) {
+ _set_event(p_event);
+ } else {
+ // Clear Event
+ _set_event(p_event);
+
+ // Clear Checkbox Values
+ for (int i = 0; i < MOD_MAX; i++) {
+ mod_checkboxes[i]->set_pressed(false);
+ }
+
+ // Enable the Physical Key checkbox by default to encourage its use.
+ // Physical Key should be used for most game inputs as it allows keys to work
+ // on non-QWERTY layouts out of the box.
+ // This is especially important for WASD movement layouts.
+ physical_key_checkbox->set_pressed(true);
+
+ autoremap_command_or_control_checkbox->set_pressed(false);
+
+ // Select "All Devices" by default.
+ device_id_option->select(0);
+ }
+
+ popup_centered(Size2(0, 400) * EDSCALE);
+}
+
+Ref<InputEvent> InputEventConfigurationDialog::get_event() const {
+ return event;
+}
+
+void InputEventConfigurationDialog::set_allowed_input_types(int p_type_masks) {
+ allowed_input_types = p_type_masks;
+}
+
+InputEventConfigurationDialog::InputEventConfigurationDialog() {
+ allowed_input_types = INPUT_KEY | INPUT_MOUSE_BUTTON | INPUT_JOY_BUTTON | INPUT_JOY_MOTION;
+
+ set_title(TTR("Event Configuration"));
+ set_min_size(Size2i(550 * EDSCALE, 0)); // Min width
+
+ VBoxContainer *main_vbox = memnew(VBoxContainer);
+ add_child(main_vbox);
+
+ event_as_text = memnew(Label);
+ event_as_text->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
+ event_as_text->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
+ event_as_text->add_theme_font_override("font", get_theme_font(SNAME("bold"), SNAME("EditorFonts")));
+ event_as_text->add_theme_font_size_override("font_size", 18 * EDSCALE);
+ main_vbox->add_child(event_as_text);
+
+ event_listener = memnew(EventListenerLineEdit);
+ event_listener->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ event_listener->set_stretch_ratio(0.75);
+ event_listener->connect("event_changed", callable_mp(this, &InputEventConfigurationDialog::_on_listen_input_changed));
+ event_listener->connect("focus_entered", callable_mp(this, &InputEventConfigurationDialog::_on_listen_focus_changed));
+ event_listener->connect("focus_exited", callable_mp(this, &InputEventConfigurationDialog::_on_listen_focus_changed));
+ main_vbox->add_child(event_listener);
+
+ main_vbox->add_child(memnew(HSeparator));
+
+ // List of all input options to manually select from.
+ VBoxContainer *manual_vbox = memnew(VBoxContainer);
+ manual_vbox->set_name(TTR("Manual Selection"));
+ manual_vbox->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ main_vbox->add_child(manual_vbox);
+
+ input_list_search = memnew(LineEdit);
+ input_list_search->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ input_list_search->set_placeholder(TTR("Filter Inputs"));
+ input_list_search->set_clear_button_enabled(true);
+ input_list_search->connect("text_changed", callable_mp(this, &InputEventConfigurationDialog::_search_term_updated));
+ manual_vbox->add_child(input_list_search);
+
+ input_list_tree = memnew(Tree);
+ input_list_tree->set_custom_minimum_size(Size2(0, 100 * EDSCALE)); // Min height for tree
+ input_list_tree->connect("item_selected", callable_mp(this, &InputEventConfigurationDialog::_input_list_item_selected));
+ input_list_tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ manual_vbox->add_child(input_list_tree);
+
+ input_list_tree->set_hide_root(true);
+ input_list_tree->set_columns(1);
+
+ _update_input_list();
+
+ // Additional Options
+ additional_options_container = memnew(VBoxContainer);
+ additional_options_container->hide();
+
+ Label *opts_label = memnew(Label);
+ opts_label->set_theme_type_variation("HeaderSmall");
+ opts_label->set_text(TTR("Additional Options"));
+ additional_options_container->add_child(opts_label);
+
+ // Device Selection
+ device_container = memnew(HBoxContainer);
+ device_container->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+
+ Label *device_label = memnew(Label);
+ device_label->set_theme_type_variation("HeaderSmall");
+ device_label->set_text(TTR("Device:"));
+ device_container->add_child(device_label);
+
+ device_id_option = memnew(OptionButton);
+ device_id_option->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ for (int i = -1; i < 8; i++) {
+ device_id_option->add_item(_get_device_string(i));
+ }
+ device_id_option->connect("item_selected", callable_mp(this, &InputEventConfigurationDialog::_device_selection_changed));
+ _set_current_device(InputMap::ALL_DEVICES);
+ device_container->add_child(device_id_option);
+
+ device_container->hide();
+ additional_options_container->add_child(device_container);
+
+ // Modifier Selection
+ mod_container = memnew(HBoxContainer);
+ for (int i = 0; i < MOD_MAX; i++) {
+ String name = mods[i];
+ mod_checkboxes[i] = memnew(CheckBox);
+ mod_checkboxes[i]->connect("toggled", callable_mp(this, &InputEventConfigurationDialog::_mod_toggled).bind(i));
+ mod_checkboxes[i]->set_text(name);
+ mod_checkboxes[i]->set_tooltip_text(TTR(mods_tip[i]));
+ mod_container->add_child(mod_checkboxes[i]);
+ }
+
+ mod_container->add_child(memnew(VSeparator));
+
+ autoremap_command_or_control_checkbox = memnew(CheckBox);
+ autoremap_command_or_control_checkbox->connect("toggled", callable_mp(this, &InputEventConfigurationDialog::_autoremap_command_or_control_toggled));
+ autoremap_command_or_control_checkbox->set_pressed(false);
+ autoremap_command_or_control_checkbox->set_text(TTR("Command / Control (auto)"));
+ autoremap_command_or_control_checkbox->set_tooltip_text(TTR("Automatically remaps between 'Meta' ('Command') and 'Control' depending on current platform."));
+ mod_container->add_child(autoremap_command_or_control_checkbox);
+
+ mod_container->hide();
+ additional_options_container->add_child(mod_container);
+
+ // Physical Key Checkbox
+
+ physical_key_checkbox = memnew(CheckBox);
+ physical_key_checkbox->set_text(TTR("Use Physical Keycode"));
+ physical_key_checkbox->set_tooltip_text(TTR("Stores the physical position of the key on the keyboard rather than the key's value. Used for compatibility with non-latin layouts.\nThis should generally be enabled for most game shortcuts, but not in non-game applications."));
+ physical_key_checkbox->connect("toggled", callable_mp(this, &InputEventConfigurationDialog::_physical_keycode_toggled));
+ physical_key_checkbox->hide();
+ additional_options_container->add_child(physical_key_checkbox);
+
+ main_vbox->add_child(additional_options_container);
+}
diff --git a/editor/input_event_configuration_dialog.h b/editor/input_event_configuration_dialog.h
new file mode 100644
index 0000000000..fc590cba26
--- /dev/null
+++ b/editor/input_event_configuration_dialog.h
@@ -0,0 +1,124 @@
+/*************************************************************************/
+/* input_event_configuration_dialog.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef INPUT_EVENT_CONFIGURATION_DIALOG_H
+#define INPUT_EVENT_CONFIGURATION_DIALOG_H
+
+#include "scene/gui/dialogs.h"
+
+class OptionButton;
+class Tree;
+class EventListenerLineEdit;
+class CheckBox;
+
+// Confirmation Dialog used when configuring an input event.
+// Separate from ActionMapEditor for code cleanliness and separation of responsibilities.
+class InputEventConfigurationDialog : public ConfirmationDialog {
+ GDCLASS(InputEventConfigurationDialog, ConfirmationDialog)
+private:
+ struct IconCache {
+ Ref<Texture2D> keyboard;
+ Ref<Texture2D> mouse;
+ Ref<Texture2D> joypad_button;
+ Ref<Texture2D> joypad_axis;
+ } icon_cache;
+
+ Ref<InputEvent> event = Ref<InputEvent>();
+
+ // Listening for input
+ EventListenerLineEdit *event_listener = nullptr;
+ Label *event_as_text = nullptr;
+
+ // List of All Key/Mouse/Joypad input options.
+ int allowed_input_types;
+ Tree *input_list_tree = nullptr;
+ LineEdit *input_list_search = nullptr;
+
+ // Additional Options, shown depending on event selected
+ VBoxContainer *additional_options_container = nullptr;
+
+ HBoxContainer *device_container = nullptr;
+ OptionButton *device_id_option = nullptr;
+
+ HBoxContainer *mod_container = nullptr; // Contains the subcontainer and the store command checkbox.
+
+ enum ModCheckbox {
+ MOD_ALT,
+ MOD_SHIFT,
+ MOD_CTRL,
+ MOD_META,
+ MOD_MAX
+ };
+#if defined(MACOS_ENABLED)
+ String mods[MOD_MAX] = { "Option", "Shift", "Ctrl", "Command" };
+#elif defined(WINDOWS_ENABLED)
+ String mods[MOD_MAX] = { "Alt", "Shift", "Ctrl", "Windows" };
+#else
+ String mods[MOD_MAX] = { "Alt", "Shift", "Ctrl", "Meta" };
+#endif
+ String mods_tip[MOD_MAX] = { "Alt or Option key", "Shift key", "Control key", "Meta/Windows or Command key" };
+
+ CheckBox *mod_checkboxes[MOD_MAX];
+ CheckBox *autoremap_command_or_control_checkbox = nullptr;
+
+ CheckBox *physical_key_checkbox = nullptr;
+
+ void _set_event(const Ref<InputEvent> &p_event, bool p_update_input_list_selection = true);
+ void _on_listen_input_changed(const Ref<InputEvent> &p_event);
+ void _on_listen_focus_changed();
+
+ void _search_term_updated(const String &p_term);
+ void _update_input_list();
+ void _input_list_item_selected();
+
+ void _mod_toggled(bool p_checked, int p_index);
+ void _autoremap_command_or_control_toggled(bool p_checked);
+ void _physical_keycode_toggled(bool p_checked);
+
+ void _device_selection_changed(int p_option_button_index);
+ void _set_current_device(int p_device);
+ int _get_current_device() const;
+ String _get_device_string(int p_device) const;
+
+protected:
+ void _notification(int p_what);
+
+public:
+ // Pass an existing event to configure it. Alternatively, pass no event to start with a blank configuration.
+ void popup_and_configure(const Ref<InputEvent> &p_event = Ref<InputEvent>());
+ Ref<InputEvent> get_event() const;
+ String get_event_text(const Ref<InputEvent> &p_event, bool p_include_device) const;
+
+ void set_allowed_input_types(int p_type_masks);
+
+ InputEventConfigurationDialog();
+};
+
+#endif // INPUT_EVENT_CONFIGURATION_DIALOG_H
diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp
index 74fdbdebd7..d8b75db30f 100644
--- a/editor/inspector_dock.cpp
+++ b/editor/inspector_dock.cpp
@@ -255,8 +255,8 @@ void InspectorDock::_resource_file_selected(String p_file) {
}
void InspectorDock::_save_resource(bool save_as) {
- ObjectID current = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
- Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr;
+ ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
+ Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
@@ -270,8 +270,8 @@ void InspectorDock::_save_resource(bool save_as) {
}
void InspectorDock::_unref_resource() {
- ObjectID current = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
- Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr;
+ ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
+ Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
@@ -281,8 +281,8 @@ void InspectorDock::_unref_resource() {
}
void InspectorDock::_copy_resource() {
- ObjectID current = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
- Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr;
+ ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
+ Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
@@ -610,8 +610,8 @@ void InspectorDock::apply_script_properties(Object *p_object) {
}
for (const Pair<StringName, Variant> &E : stored_properties) {
- Variant current;
- if (si->get(E.first, current) && current.get_type() == E.second.get_type()) {
+ Variant current_prop;
+ if (si->get(E.first, current_prop) && current_prop.get_type() == E.second.get_type()) {
si->set(E.first, E.second);
}
}
diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp
index 71ff77e9bc..a7ebf21cd2 100644
--- a/editor/plugin_config_dialog.cpp
+++ b/editor/plugin_config_dialog.cpp
@@ -80,11 +80,11 @@ void PluginConfigDialog::_on_confirmed() {
if (!templates.is_empty()) {
template_content = templates[0].content;
}
- Ref<Script> script = ScriptServer::get_language(lang_idx)->make_template(template_content, class_name, "EditorPlugin");
- script->set_path(script_path, true);
- ResourceSaver::save(script);
+ Ref<Script> scr = ScriptServer::get_language(lang_idx)->make_template(template_content, class_name, "EditorPlugin");
+ scr->set_path(script_path, true);
+ ResourceSaver::save(scr);
- emit_signal(SNAME("plugin_ready"), script.ptr(), active_edit->is_pressed() ? _to_absolute_plugin_path(_get_subfolder()) : "");
+ emit_signal(SNAME("plugin_ready"), scr.ptr(), active_edit->is_pressed() ? _to_absolute_plugin_path(_get_subfolder()) : "");
} else {
EditorNode::get_singleton()->get_project_settings()->update_plugins();
}
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp
index c928b95642..cb07d8cf01 100644
--- a/editor/plugins/abstract_polygon_2d_editor.cpp
+++ b/editor/plugins/abstract_polygon_2d_editor.cpp
@@ -561,8 +561,8 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
const Vector2 p = (vertex == edited_point) ? edited_point.pos : (points[i] + offset);
const Vector2 point = xform.xform(p);
- const Color modulate = vertex == active_point ? Color(0.5, 1, 2) : Color(1, 1, 1);
- p_overlay->draw_texture(handle, point - handle->get_size() * 0.5, modulate);
+ const Color overlay_modulate = vertex == active_point ? Color(0.5, 1, 2) : Color(1, 1, 1);
+ p_overlay->draw_texture(handle, point - handle->get_size() * 0.5, overlay_modulate);
if (vertex == hover_point) {
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp
index f75dcdf2d6..765d85c1ac 100644
--- a/editor/plugins/animation_blend_space_2d_editor.cpp
+++ b/editor/plugins/animation_blend_space_2d_editor.cpp
@@ -406,11 +406,11 @@ void AnimationNodeBlendSpace2DEditor::_tool_switch(int p_tool) {
making_triangle.clear();
if (p_tool == 2) {
- Vector<Vector2> points;
+ Vector<Vector2> bl_points;
for (int i = 0; i < blend_space->get_blend_point_count(); i++) {
- points.push_back(blend_space->get_blend_point_position(i));
+ bl_points.push_back(blend_space->get_blend_point_position(i));
}
- Vector<Delaunay2D::Triangle> tr = Delaunay2D::triangulate(points);
+ Vector<Delaunay2D::Triangle> tr = Delaunay2D::triangulate(bl_points);
for (int i = 0; i < tr.size(); i++) {
blend_space->add_triangle(tr[i].points[0], tr[i].points[1], tr[i].points[2]);
}
@@ -494,8 +494,8 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
//triangles first
for (int i = 0; i < blend_space->get_triangle_count(); i++) {
- Vector<Vector2> points;
- points.resize(3);
+ Vector<Vector2> bl_points;
+ bl_points.resize(3);
for (int j = 0; j < 3; j++) {
int point_idx = blend_space->get_triangle_point(i, j);
@@ -509,11 +509,11 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space());
point *= s;
point.y = s.height - point.y;
- points.write[j] = point;
+ bl_points.write[j] = point;
}
for (int j = 0; j < 3; j++) {
- blend_space_draw->draw_line(points[j], points[(j + 1) % 3], linecolor, Math::round(EDSCALE), true);
+ blend_space_draw->draw_line(bl_points[j], bl_points[(j + 1) % 3], linecolor, Math::round(EDSCALE), true);
}
Color color;
@@ -530,7 +530,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
color,
color
};
- blend_space_draw->draw_primitive(points, colors, Vector<Vector2>());
+ blend_space_draw->draw_primitive(bl_points, colors, Vector<Vector2>());
}
points.clear();
@@ -560,19 +560,19 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
}
if (making_triangle.size()) {
- Vector<Vector2> points;
+ Vector<Vector2> bl_points;
for (int i = 0; i < making_triangle.size(); i++) {
Vector2 point = blend_space->get_blend_point_position(making_triangle[i]);
point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space());
point *= s;
point.y = s.height - point.y;
- points.push_back(point);
+ bl_points.push_back(point);
}
- for (int i = 0; i < points.size() - 1; i++) {
- blend_space_draw->draw_line(points[i], points[i + 1], linecolor, Math::round(2 * EDSCALE), true);
+ for (int i = 0; i < bl_points.size() - 1; i++) {
+ blend_space_draw->draw_line(bl_points[i], bl_points[i + 1], linecolor, Math::round(2 * EDSCALE), true);
}
- blend_space_draw->draw_line(points[points.size() - 1], blend_space_draw->get_local_mouse_position(), linecolor, Math::round(2 * EDSCALE), true);
+ blend_space_draw->draw_line(bl_points[bl_points.size() - 1], blend_space_draw->get_local_mouse_position(), linecolor, Math::round(2 * EDSCALE), true);
}
///draw cursor position
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index ca7b2d0015..067730a87a 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -262,10 +262,10 @@ void AnimationNodeBlendTreeEditor::update_graph() {
node->add_theme_color_override("resizer_color", c);
}
- List<AnimationNodeBlendTree::NodeConnection> connections;
- blend_tree->get_node_connections(&connections);
+ List<AnimationNodeBlendTree::NodeConnection> node_connections;
+ blend_tree->get_node_connections(&node_connections);
- for (const AnimationNodeBlendTree::NodeConnection &E : connections) {
+ for (const AnimationNodeBlendTree::NodeConnection &E : node_connections) {
StringName from = E.output_node;
StringName to = E.input_node;
int to_idx = E.input_index;
@@ -293,9 +293,9 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) {
if (p_idx == MENU_LOAD_FILE) {
open_file->clear_filters();
- List<String> filters;
- ResourceLoader::get_recognized_extensions_for_type("AnimationNode", &filters);
- for (const String &E : filters) {
+ List<String> ext_filters;
+ ResourceLoader::get_recognized_extensions_for_type("AnimationNode", &ext_filters);
+ for (const String &E : ext_filters) {
open_file->add_filter("*." + E);
}
open_file->popup_file_dialog();
@@ -611,10 +611,10 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
HashSet<String> paths;
HashMap<String, RBSet<String>> types;
{
- List<StringName> animations;
- player->get_animation_list(&animations);
+ List<StringName> animation_list;
+ player->get_animation_list(&animation_list);
- for (const StringName &E : animations) {
+ for (const StringName &E : animation_list) {
Ref<Animation> anim = player->get_animation(E);
for (int i = 0; i < anim->get_track_count(); i++) {
String track_path = anim->track_get_path(i);
@@ -970,10 +970,10 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima
//recreate connections
graph->clear_connections();
- List<AnimationNodeBlendTree::NodeConnection> connections;
- blend_tree->get_node_connections(&connections);
+ List<AnimationNodeBlendTree::NodeConnection> node_connections;
+ blend_tree->get_node_connections(&node_connections);
- for (const AnimationNodeBlendTree::NodeConnection &E : connections) {
+ for (const AnimationNodeBlendTree::NodeConnection &E : node_connections) {
StringName from = E.output_node;
StringName to = E.input_node;
int to_idx = E.input_index;
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index e8caac565c..a48990779b 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -302,6 +302,8 @@ void AnimationPlayerEditor::_animation_selected(int p_which) {
AnimationPlayerEditor::get_singleton()->get_track_editor()->update_keying();
_animation_key_editor_seek(timeline_position, false);
+
+ emit_signal("animation_selected", current);
}
void AnimationPlayerEditor::_animation_new() {
@@ -720,7 +722,18 @@ void AnimationPlayerEditor::set_state(const Dictionary &p_state) {
if (p_state.has("player")) {
Node *n = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["player"]);
if (Object::cast_to<AnimationPlayer>(n) && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) {
+ if (player) {
+ if (player->is_connected("animation_libraries_updated", callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated))) {
+ player->disconnect("animation_libraries_updated", callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated));
+ }
+ }
player = Object::cast_to<AnimationPlayer>(n);
+ if (player) {
+ if (!player->is_connected("animation_libraries_updated", callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated))) {
+ player->connect("animation_libraries_updated", callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated));
+ }
+ }
+
_update_player();
EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
set_process(true);
@@ -826,13 +839,13 @@ void AnimationPlayerEditor::_update_player() {
}
// Check if the global library is foreign since we want to disable options for adding/remove/renaming animations if it is.
- Ref<AnimationLibrary> library = player->get_animation_library(K);
+ Ref<AnimationLibrary> anim_library = player->get_animation_library(K);
if (K == "") {
- foreign_global_anim_lib = EditorNode::get_singleton()->is_resource_read_only(library);
+ foreign_global_anim_lib = EditorNode::get_singleton()->is_resource_read_only(anim_library);
}
List<StringName> animlist;
- library->get_animation_list(&animlist);
+ anim_library->get_animation_list(&animlist);
for (const StringName &E : animlist) {
String path = K;
@@ -913,19 +926,19 @@ void AnimationPlayerEditor::_update_player() {
void AnimationPlayerEditor::_update_animation_list_icons() {
for (int i = 0; i < animation->get_item_count(); i++) {
- String name = animation->get_item_text(i);
+ String anim_name = animation->get_item_text(i);
if (animation->is_item_disabled(i) || animation->is_item_separator(i)) {
continue;
}
Ref<Texture2D> icon;
- if (name == player->get_autoplay()) {
- if (name == SceneStringNames::get_singleton()->RESET) {
+ if (anim_name == player->get_autoplay()) {
+ if (anim_name == SceneStringNames::get_singleton()->RESET) {
icon = autoplay_reset_icon;
} else {
icon = autoplay_icon;
}
- } else if (name == SceneStringNames::get_singleton()->RESET) {
+ } else if (anim_name == SceneStringNames::get_singleton()->RESET) {
icon = reset_icon;
}
@@ -982,9 +995,18 @@ void AnimationPlayerEditor::edit(AnimationPlayer *p_player) {
if (player && pin->is_pressed()) {
return; // Ignore, pinned.
}
+
+ if (player) {
+ if (player->is_connected("animation_libraries_updated", callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated))) {
+ player->disconnect("animation_libraries_updated", callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated));
+ }
+ }
player = p_player;
if (player) {
+ if (!player->is_connected("animation_libraries_updated", callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated))) {
+ player->connect("animation_libraries_updated", callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated));
+ }
_update_player();
if (onion.enabled) {
@@ -1151,6 +1173,10 @@ void AnimationPlayerEditor::_animation_player_changed(Object *p_pl) {
}
}
+void AnimationPlayerEditor::_animation_libraries_updated() {
+ _animation_player_changed(player);
+}
+
void AnimationPlayerEditor::_list_changed() {
if (is_visible_in_tree()) {
_update_player();
@@ -1356,8 +1382,8 @@ void AnimationPlayerEditor::_free_onion_layers() {
void AnimationPlayerEditor::_prepare_onion_layers_1() {
// This would be called per viewport and we want to act once only.
- int64_t frame = get_tree()->get_frame();
- if (frame == onion.last_frame) {
+ int64_t cur_frame = get_tree()->get_frame();
+ if (cur_frame == onion.last_frame) {
return;
}
@@ -1366,7 +1392,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_1() {
return;
}
- onion.last_frame = frame;
+ onion.last_frame = cur_frame;
// Refresh viewports with no onion layers overlaid.
onion.can_overlay = false;
@@ -1545,6 +1571,7 @@ void AnimationPlayerEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_animation_edit"), &AnimationPlayerEditor::_animation_edit);
ClassDB::bind_method(D_METHOD("_animation_resource_edit"), &AnimationPlayerEditor::_animation_resource_edit);
ClassDB::bind_method(D_METHOD("_animation_player_changed"), &AnimationPlayerEditor::_animation_player_changed);
+ ClassDB::bind_method(D_METHOD("_animation_libraries_updated"), &AnimationPlayerEditor::_animation_libraries_updated);
ClassDB::bind_method(D_METHOD("_list_changed"), &AnimationPlayerEditor::_list_changed);
ClassDB::bind_method(D_METHOD("_animation_duplicate"), &AnimationPlayerEditor::_animation_duplicate);
@@ -1552,6 +1579,8 @@ void AnimationPlayerEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_prepare_onion_layers_2"), &AnimationPlayerEditor::_prepare_onion_layers_2);
ClassDB::bind_method(D_METHOD("_start_onion_skinning"), &AnimationPlayerEditor::_start_onion_skinning);
ClassDB::bind_method(D_METHOD("_stop_onion_skinning"), &AnimationPlayerEditor::_stop_onion_skinning);
+
+ ADD_SIGNAL(MethodInfo("animation_selected", PropertyInfo(Variant::STRING, "name")));
}
AnimationPlayerEditor *AnimationPlayerEditor::singleton = nullptr;
diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h
index 06fd9455df..ae570e53f3 100644
--- a/editor/plugins/animation_player_editor_plugin.h
+++ b/editor/plugins/animation_player_editor_plugin.h
@@ -195,6 +195,7 @@ class AnimationPlayerEditor : public VBoxContainer {
void _blend_edited();
void _animation_player_changed(Object *p_pl);
+ void _animation_libraries_updated();
void _animation_key_editor_seek(float p_pos, bool p_drag, bool p_timeline_only = false);
void _animation_key_editor_anim_len_changed(float p_len);
@@ -266,7 +267,7 @@ public:
virtual void make_visible(bool p_visible) override;
virtual void forward_canvas_force_draw_over_viewport(Control *p_overlay) override { anim_editor->forward_force_draw_over_viewport(p_overlay); }
- virtual void forward_spatial_force_draw_over_viewport(Control *p_overlay) override { anim_editor->forward_force_draw_over_viewport(p_overlay); }
+ virtual void forward_3d_force_draw_over_viewport(Control *p_overlay) override { anim_editor->forward_force_draw_over_viewport(p_overlay); }
AnimationPlayerEditorPlugin();
~AnimationPlayerEditorPlugin();
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index 3c9486cdaa..2d1f4088a0 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -243,19 +243,19 @@ void EditorAssetLibraryItemDescription::configure(const String &p_title, int p_a
}
void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, const String &p_url) {
- Preview preview;
- preview.id = p_id;
- preview.video_link = p_url;
- preview.is_video = p_video;
- preview.button = memnew(Button);
- preview.button->set_icon(previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons")));
- preview.button->set_toggle_mode(true);
- preview.button->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDescription::_preview_click).bind(p_id));
- preview_hb->add_child(preview.button);
+ Preview new_preview;
+ new_preview.id = p_id;
+ new_preview.video_link = p_url;
+ new_preview.is_video = p_video;
+ new_preview.button = memnew(Button);
+ new_preview.button->set_icon(previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons")));
+ new_preview.button->set_toggle_mode(true);
+ new_preview.button->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDescription::_preview_click).bind(p_id));
+ preview_hb->add_child(new_preview.button);
if (!p_video) {
- preview.image = previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons"));
+ new_preview.image = previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons"));
}
- preview_images.push_back(preview);
+ preview_images.push_back(new_preview);
if (preview_images.size() == 1 && !p_video) {
_preview_click(p_id);
}
diff --git a/editor/plugins/audio_stream_randomizer_editor_plugin.cpp b/editor/plugins/audio_stream_randomizer_editor_plugin.cpp
index d670197c53..e21a50a434 100644
--- a/editor/plugins/audio_stream_randomizer_editor_plugin.cpp
+++ b/editor/plugins/audio_stream_randomizer_editor_plugin.cpp
@@ -44,8 +44,8 @@ void AudioStreamRandomizerEditorPlugin::make_visible(bool p_visible) {
}
void AudioStreamRandomizerEditorPlugin::_move_stream_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) {
- Ref<EditorUndoRedoManager> undo_redo = Object::cast_to<EditorUndoRedoManager>(p_undo_redo);
- ERR_FAIL_COND(undo_redo.is_null());
+ Ref<EditorUndoRedoManager> undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo);
+ ERR_FAIL_COND(undo_redo_man.is_null());
AudioStreamRandomizer *randomizer = Object::cast_to<AudioStreamRandomizer>(p_edited);
if (!randomizer) {
@@ -76,12 +76,12 @@ void AudioStreamRandomizerEditorPlugin::_move_stream_array_element(Object *p_und
end = MIN(MAX(p_from_index, p_to_pos) + 1, end);
}
-#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property));
+#define ADD_UNDO(obj, property) undo_redo_man->add_undo_property(obj, property, obj->get(property));
// Save layers' properties.
if (p_from_index < 0) {
- undo_redo->add_undo_method(randomizer, "remove_stream", p_to_pos < 0 ? randomizer->get_streams_count() : p_to_pos);
+ undo_redo_man->add_undo_method(randomizer, "remove_stream", p_to_pos < 0 ? randomizer->get_streams_count() : p_to_pos);
} else if (p_to_pos < 0) {
- undo_redo->add_undo_method(randomizer, "add_stream", p_from_index);
+ undo_redo_man->add_undo_method(randomizer, "add_stream", p_from_index);
}
List<PropertyInfo> properties;
@@ -107,11 +107,11 @@ void AudioStreamRandomizerEditorPlugin::_move_stream_array_element(Object *p_und
#undef ADD_UNDO
if (p_from_index < 0) {
- undo_redo->add_do_method(randomizer, "add_stream", p_to_pos);
+ undo_redo_man->add_do_method(randomizer, "add_stream", p_to_pos);
} else if (p_to_pos < 0) {
- undo_redo->add_do_method(randomizer, "remove_stream", p_from_index);
+ undo_redo_man->add_do_method(randomizer, "remove_stream", p_from_index);
} else {
- undo_redo->add_do_method(randomizer, "move_stream", p_from_index, p_to_pos);
+ undo_redo_man->add_do_method(randomizer, "move_stream", p_from_index, p_to_pos);
}
}
diff --git a/editor/plugins/bone_map_editor_plugin.h b/editor/plugins/bone_map_editor_plugin.h
index 55261ab477..16e5403978 100644
--- a/editor/plugins/bone_map_editor_plugin.h
+++ b/editor/plugins/bone_map_editor_plugin.h
@@ -206,7 +206,6 @@ class BoneMapEditor : public VBoxContainer {
BoneMapper *bone_mapper = nullptr;
void fetch_objects();
- void clear_editors();
void create_editors();
protected:
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 84b8b4aed8..c59781390a 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -304,7 +304,7 @@ void CanvasItemEditor::_snap_other_nodes(
Point2 &r_current_snap, SnapTarget (&r_current_snap_target)[2],
const SnapTarget p_snap_target, List<const CanvasItem *> p_exceptions,
const Node *p_current) {
- const CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_current);
+ const CanvasItem *ci = Object::cast_to<CanvasItem>(p_current);
// Check if the element is in the exception
bool exception = false;
@@ -315,12 +315,12 @@ void CanvasItemEditor::_snap_other_nodes(
}
};
- if (canvas_item && !exception) {
- Transform2D ci_transform = canvas_item->get_global_transform_with_canvas();
+ if (ci && !exception) {
+ Transform2D ci_transform = ci->get_global_transform_with_canvas();
if (fmod(ci_transform.get_rotation() - p_transform_to_snap.get_rotation(), (real_t)360.0) == 0.0) {
- if (canvas_item->_edit_use_rect()) {
- Point2 begin = ci_transform.xform(canvas_item->_edit_get_rect().get_position());
- Point2 end = ci_transform.xform(canvas_item->_edit_get_rect().get_position() + canvas_item->_edit_get_rect().get_size());
+ if (ci->_edit_use_rect()) {
+ Point2 begin = ci_transform.xform(ci->_edit_get_rect().get_position());
+ Point2 end = ci_transform.xform(ci->_edit_get_rect().get_position() + ci->_edit_get_rect().get_size());
_snap_if_closer_point(p_value, r_current_snap, r_current_snap_target, begin, p_snap_target, ci_transform.get_rotation());
_snap_if_closer_point(p_value, r_current_snap, r_current_snap_target, end, p_snap_target, ci_transform.get_rotation());
@@ -528,14 +528,14 @@ Rect2 CanvasItemEditor::_get_encompassing_rect_from_list(List<CanvasItem *> p_li
ERR_FAIL_COND_V(p_list.is_empty(), Rect2());
// Handles the first element
- CanvasItem *canvas_item = p_list.front()->get();
- Rect2 rect = Rect2(canvas_item->get_global_transform_with_canvas().xform(canvas_item->_edit_get_rect().get_center()), Size2());
+ CanvasItem *ci = p_list.front()->get();
+ Rect2 rect = Rect2(ci->get_global_transform_with_canvas().xform(ci->_edit_get_rect().get_center()), Size2());
// Expand with the other ones
- for (CanvasItem *canvas_item2 : p_list) {
- Transform2D xform = canvas_item2->get_global_transform_with_canvas();
+ for (CanvasItem *ci2 : p_list) {
+ Transform2D xform = ci2->get_global_transform_with_canvas();
- Rect2 current_rect = canvas_item2->_edit_get_rect();
+ Rect2 current_rect = ci2->_edit_get_rect();
rect.expand_to(xform.xform(current_rect.position));
rect.expand_to(xform.xform(current_rect.position + Vector2(current_rect.size.x, 0)));
rect.expand_to(xform.xform(current_rect.position + current_rect.size));
@@ -553,24 +553,24 @@ void CanvasItemEditor::_expand_encompassing_rect_using_children(Rect2 &r_rect, c
return;
}
- const CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
+ const CanvasItem *ci = Object::cast_to<CanvasItem>(p_node);
for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
- if (canvas_item && !canvas_item->is_set_as_top_level()) {
- _expand_encompassing_rect_using_children(r_rect, p_node->get_child(i), r_first, p_parent_xform * canvas_item->get_transform(), p_canvas_xform);
+ if (ci && !ci->is_set_as_top_level()) {
+ _expand_encompassing_rect_using_children(r_rect, p_node->get_child(i), r_first, p_parent_xform * ci->get_transform(), p_canvas_xform);
} else {
- const CanvasLayer *canvas_layer = Object::cast_to<CanvasLayer>(p_node);
- _expand_encompassing_rect_using_children(r_rect, p_node->get_child(i), r_first, Transform2D(), canvas_layer ? canvas_layer->get_transform() : p_canvas_xform);
+ const CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node);
+ _expand_encompassing_rect_using_children(r_rect, p_node->get_child(i), r_first, Transform2D(), cl ? cl->get_transform() : p_canvas_xform);
}
}
- if (canvas_item && canvas_item->is_visible_in_tree() && (include_locked_nodes || !_is_node_locked(canvas_item))) {
+ if (ci && ci->is_visible_in_tree() && (include_locked_nodes || !_is_node_locked(ci))) {
Transform2D xform = p_canvas_xform;
- if (!canvas_item->is_set_as_top_level()) {
+ if (!ci->is_set_as_top_level()) {
xform *= p_parent_xform;
}
- xform *= canvas_item->get_transform();
- Rect2 rect = canvas_item->_edit_get_rect();
+ xform *= ci->get_transform();
+ Rect2 rect = ci->_edit_get_rect();
if (r_first) {
r_rect = Rect2(xform.xform(rect.get_center()), Size2());
r_first = false;
@@ -599,14 +599,14 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no
}
const real_t grab_distance = EDITOR_GET("editors/polygon_editor/point_grab_radius");
- CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
+ CanvasItem *ci = Object::cast_to<CanvasItem>(p_node);
for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
- if (canvas_item) {
- if (!canvas_item->is_set_as_top_level()) {
- _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_parent_xform * canvas_item->get_transform(), p_canvas_xform);
+ if (ci) {
+ if (!ci->is_set_as_top_level()) {
+ _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_parent_xform * ci->get_transform(), p_canvas_xform);
} else {
- _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, canvas_item->get_transform(), p_canvas_xform);
+ _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, ci->get_transform(), p_canvas_xform);
}
} else {
CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node);
@@ -614,18 +614,18 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no
}
}
- if (canvas_item && canvas_item->is_visible_in_tree()) {
+ if (ci && ci->is_visible_in_tree()) {
Transform2D xform = p_canvas_xform;
- if (!canvas_item->is_set_as_top_level()) {
+ if (!ci->is_set_as_top_level()) {
xform *= p_parent_xform;
}
- xform = (xform * canvas_item->get_transform()).affine_inverse();
+ xform = (xform * ci->get_transform()).affine_inverse();
const real_t local_grab_distance = xform.basis_xform(Vector2(grab_distance, 0)).length() / zoom;
- if (canvas_item->_edit_is_selected_on_click(xform.xform(p_pos), local_grab_distance)) {
- Node2D *node = Object::cast_to<Node2D>(canvas_item);
+ if (ci->_edit_is_selected_on_click(xform.xform(p_pos), local_grab_distance)) {
+ Node2D *node = Object::cast_to<Node2D>(ci);
_SelectResult res;
- res.item = canvas_item;
+ res.item = ci;
res.z_index = node ? node->get_z_index() : 0;
res.has_z = node;
r_items.push_back(res);
@@ -647,13 +647,13 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel
node = scene->get_deepest_editable_node(node);
}
- CanvasItem *canvas_item = Object::cast_to<CanvasItem>(node);
+ CanvasItem *ci = Object::cast_to<CanvasItem>(node);
if (!p_allow_locked) {
// Replace the node by the group if grouped
while (node && node != scene->get_parent()) {
- CanvasItem *canvas_item_tmp = Object::cast_to<CanvasItem>(node);
- if (canvas_item_tmp && node->has_meta("_edit_group_")) {
- canvas_item = canvas_item_tmp;
+ CanvasItem *ci_tmp = Object::cast_to<CanvasItem>(node);
+ if (ci_tmp && node->has_meta("_edit_group_")) {
+ ci = ci_tmp;
}
node = node->get_parent();
}
@@ -662,18 +662,18 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel
// Check if the canvas item is already in the list (for groups or scenes)
bool duplicate = false;
for (int j = 0; j < i; j++) {
- if (r_items[j].item == canvas_item) {
+ if (r_items[j].item == ci) {
duplicate = true;
break;
}
}
//Remove the item if invalid
- if (!canvas_item || duplicate || (canvas_item != scene && canvas_item->get_owner() != scene && !scene->is_editable_instance(canvas_item->get_owner())) || (!p_allow_locked && _is_node_locked(canvas_item))) {
+ if (!ci || duplicate || (ci != scene && ci->get_owner() != scene && !scene->is_editable_instance(ci->get_owner())) || (!p_allow_locked && _is_node_locked(ci))) {
r_items.remove_at(i);
i--;
} else {
- r_items.write[i].item = canvas_item;
+ r_items.write[i].item = ci;
}
}
}
@@ -686,7 +686,7 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n
return;
}
- CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
+ CanvasItem *ci = Object::cast_to<CanvasItem>(p_node);
Node *scene = EditorNode::get_singleton()->get_edited_scene();
bool editable = p_node == scene || p_node->get_owner() == scene || p_node == scene->get_deepest_editable_node(p_node);
@@ -695,37 +695,37 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n
if (!lock_children || !editable) {
for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
- if (canvas_item) {
- if (!canvas_item->is_set_as_top_level()) {
- _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, p_parent_xform * canvas_item->get_transform(), p_canvas_xform);
+ if (ci) {
+ if (!ci->is_set_as_top_level()) {
+ _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, p_parent_xform * ci->get_transform(), p_canvas_xform);
} else {
- _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, canvas_item->get_transform(), p_canvas_xform);
+ _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, ci->get_transform(), p_canvas_xform);
}
} else {
- CanvasLayer *canvas_layer = Object::cast_to<CanvasLayer>(p_node);
- _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, Transform2D(), canvas_layer ? canvas_layer->get_transform() : p_canvas_xform);
+ CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node);
+ _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, Transform2D(), cl ? cl->get_transform() : p_canvas_xform);
}
}
}
- if (canvas_item && canvas_item->is_visible_in_tree() && !locked && editable) {
+ if (ci && ci->is_visible_in_tree() && !locked && editable) {
Transform2D xform = p_canvas_xform;
- if (!canvas_item->is_set_as_top_level()) {
+ if (!ci->is_set_as_top_level()) {
xform *= p_parent_xform;
}
- xform *= canvas_item->get_transform();
+ xform *= ci->get_transform();
- if (canvas_item->_edit_use_rect()) {
- Rect2 rect = canvas_item->_edit_get_rect();
+ if (ci->_edit_use_rect()) {
+ Rect2 rect = ci->_edit_get_rect();
if (p_rect.has_point(xform.xform(rect.position)) &&
p_rect.has_point(xform.xform(rect.position + Vector2(rect.size.x, 0))) &&
p_rect.has_point(xform.xform(rect.position + Vector2(rect.size.x, rect.size.y))) &&
p_rect.has_point(xform.xform(rect.position + Vector2(0, rect.size.y)))) {
- r_items->push_back(canvas_item);
+ r_items->push_back(ci);
}
} else {
if (p_rect.has_point(xform.xform(Point2()))) {
- r_items->push_back(canvas_item);
+ r_items->push_back(ci);
}
}
}
@@ -765,11 +765,11 @@ bool CanvasItemEditor::_select_click_on_item(CanvasItem *item, Point2 p_click_po
List<CanvasItem *> CanvasItemEditor::_get_edited_canvas_items(bool retrieve_locked, bool remove_canvas_item_if_parent_in_selection) {
List<CanvasItem *> selection;
for (const KeyValue<Node *, Object *> &E : editor_selection->get_selection()) {
- CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key);
- if (canvas_item && canvas_item->is_visible_in_tree() && canvas_item->get_viewport() == EditorNode::get_singleton()->get_scene_root() && (retrieve_locked || !_is_node_locked(canvas_item))) {
- CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
+ CanvasItem *ci = Object::cast_to<CanvasItem>(E.key);
+ if (ci && ci->is_visible_in_tree() && ci->get_viewport() == EditorNode::get_singleton()->get_scene_root() && (retrieve_locked || !_is_node_locked(ci))) {
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci);
if (se) {
- selection.push_back(canvas_item);
+ selection.push_back(ci);
}
}
}
@@ -819,18 +819,18 @@ void CanvasItemEditor::_save_canvas_item_state(List<CanvasItem *> p_canvas_items
original_transform = Transform2D();
bool transform_stored = false;
- for (CanvasItem *canvas_item : p_canvas_items) {
- CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
+ for (CanvasItem *ci : p_canvas_items) {
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci);
if (se) {
if (!transform_stored) {
- original_transform = canvas_item->get_global_transform();
+ original_transform = ci->get_global_transform();
transform_stored = true;
}
- se->undo_state = canvas_item->_edit_get_state();
- se->pre_drag_xform = canvas_item->get_global_transform_with_canvas();
- if (canvas_item->_edit_use_rect()) {
- se->pre_drag_rect = canvas_item->_edit_get_rect();
+ se->undo_state = ci->_edit_get_state();
+ se->pre_drag_xform = ci->get_global_transform_with_canvas();
+ if (ci->_edit_use_rect()) {
+ se->pre_drag_rect = ci->_edit_get_rect();
} else {
se->pre_drag_rect = Rect2();
}
@@ -839,20 +839,20 @@ void CanvasItemEditor::_save_canvas_item_state(List<CanvasItem *> p_canvas_items
}
void CanvasItemEditor::_restore_canvas_item_state(List<CanvasItem *> p_canvas_items, bool restore_bones) {
- for (CanvasItem *canvas_item : drag_selection) {
- CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
- canvas_item->_edit_set_state(se->undo_state);
+ for (CanvasItem *ci : drag_selection) {
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci);
+ ci->_edit_set_state(se->undo_state);
}
}
void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_items, String action_name, bool commit_bones) {
List<CanvasItem *> modified_canvas_items;
- for (CanvasItem *canvas_item : p_canvas_items) {
- Dictionary old_state = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item)->undo_state;
- Dictionary new_state = canvas_item->_edit_get_state();
+ for (CanvasItem *ci : p_canvas_items) {
+ Dictionary old_state = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci)->undo_state;
+ Dictionary new_state = ci->_edit_get_state();
if (old_state.hash() != new_state.hash()) {
- modified_canvas_items.push_back(canvas_item);
+ modified_canvas_items.push_back(ci);
}
}
@@ -861,16 +861,16 @@ void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_ite
}
undo_redo->create_action(action_name);
- for (CanvasItem *canvas_item : modified_canvas_items) {
- CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
+ for (CanvasItem *ci : modified_canvas_items) {
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci);
if (se) {
- undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state());
- undo_redo->add_undo_method(canvas_item, "_edit_set_state", se->undo_state);
+ undo_redo->add_do_method(ci, "_edit_set_state", ci->_edit_get_state());
+ undo_redo->add_undo_method(ci, "_edit_set_state", se->undo_state);
if (commit_bones) {
for (const Dictionary &F : se->pre_drag_bones_undo_state) {
- canvas_item = Object::cast_to<CanvasItem>(canvas_item->get_parent());
- undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state());
- undo_redo->add_undo_method(canvas_item, "_edit_set_state", F);
+ ci = Object::cast_to<CanvasItem>(ci->get_parent());
+ undo_redo->add_do_method(ci, "_edit_set_state", ci->_edit_get_state());
+ undo_redo->add_undo_method(ci, "_edit_set_state", F);
}
}
}
@@ -1318,9 +1318,9 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) {
// Filters the selection with nodes that allow setting the pivot
drag_selection = List<CanvasItem *>();
- for (CanvasItem *canvas_item : selection) {
- if (canvas_item->_edit_use_pivot()) {
- drag_selection.push_back(canvas_item);
+ for (CanvasItem *ci : selection) {
+ if (ci->_edit_use_pivot()) {
+ drag_selection.push_back(ci);
}
}
@@ -1334,8 +1334,8 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) {
} else {
new_pos = snap_point(drag_from, SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, nullptr, drag_selection);
}
- for (CanvasItem *canvas_item : drag_selection) {
- canvas_item->_edit_set_pivot(canvas_item->get_global_transform_with_canvas().affine_inverse().xform(new_pos));
+ for (CanvasItem *ci : drag_selection) {
+ ci->_edit_set_pivot(ci->get_global_transform_with_canvas().affine_inverse().xform(new_pos));
}
drag_type = DRAG_PIVOT;
@@ -1355,8 +1355,8 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) {
} else {
new_pos = snap_point(drag_to, SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL);
}
- for (CanvasItem *canvas_item : drag_selection) {
- canvas_item->_edit_set_pivot(canvas_item->get_global_transform_with_canvas().affine_inverse().xform(new_pos));
+ for (CanvasItem *ci : drag_selection) {
+ ci->_edit_set_pivot(ci->get_global_transform_with_canvas().affine_inverse().xform(new_pos));
}
return true;
}
@@ -1408,11 +1408,11 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
if (drag_selection.size() > 0) {
drag_type = DRAG_ROTATE;
drag_from = transform.affine_inverse().xform(b->get_position());
- CanvasItem *canvas_item = drag_selection[0];
- if (canvas_item->_edit_use_pivot()) {
- drag_rotation_center = canvas_item->get_global_transform_with_canvas().xform(canvas_item->_edit_get_pivot());
+ CanvasItem *ci = drag_selection[0];
+ if (ci->_edit_use_pivot()) {
+ drag_rotation_center = ci->get_global_transform_with_canvas().xform(ci->_edit_get_pivot());
} else {
- drag_rotation_center = canvas_item->get_global_transform_with_canvas().get_origin();
+ drag_rotation_center = ci->get_global_transform_with_canvas().get_origin();
}
_save_canvas_item_state(drag_selection);
return true;
@@ -1425,11 +1425,11 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
// Rotate the node
if (m.is_valid()) {
_restore_canvas_item_state(drag_selection);
- for (CanvasItem *canvas_item : drag_selection) {
+ for (CanvasItem *ci : drag_selection) {
drag_to = transform.affine_inverse().xform(m->get_position());
//Rotate the opposite way if the canvas item's compounded scale has an uneven number of negative elements
- bool opposite = (canvas_item->get_global_transform().get_scale().sign().dot(canvas_item->get_transform().get_scale().sign()) == 0);
- canvas_item->_edit_set_rotation(snap_angle(canvas_item->_edit_get_rotation() + (opposite ? -1 : 1) * (drag_from - drag_rotation_center).angle_to(drag_to - drag_rotation_center), canvas_item->_edit_get_rotation()));
+ bool opposite = (ci->get_global_transform().get_scale().sign().dot(ci->get_transform().get_scale().sign()) == 0);
+ ci->_edit_set_rotation(snap_angle(ci->_edit_get_rotation() + (opposite ? -1 : 1) * (drag_from - drag_rotation_center).angle_to(drag_to - drag_rotation_center), ci->_edit_get_rotation()));
viewport->queue_redraw();
}
return true;
@@ -1477,9 +1477,9 @@ bool CanvasItemEditor::_gui_input_open_scene_on_double_click(const Ref<InputEven
if (b.is_valid() && b->get_button_index() == MouseButton::LEFT && b->is_pressed() && b->is_double_click() && tool == TOOL_SELECT) {
List<CanvasItem *> selection = _get_edited_canvas_items();
if (selection.size() == 1) {
- CanvasItem *canvas_item = selection[0];
- if (!canvas_item->get_scene_file_path().is_empty() && canvas_item != EditorNode::get_singleton()->get_edited_scene()) {
- EditorNode::get_singleton()->open_request(canvas_item->get_scene_file_path());
+ CanvasItem *ci = selection[0];
+ if (!ci->get_scene_file_path().is_empty() && ci != EditorNode::get_singleton()->get_edited_scene()) {
+ EditorNode::get_singleton()->open_request(ci->get_scene_file_path());
return true;
}
}
@@ -1641,10 +1641,10 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
if (b.is_valid() && b->get_button_index() == MouseButton::LEFT && b->is_pressed() && tool == TOOL_SELECT) {
List<CanvasItem *> selection = _get_edited_canvas_items();
if (selection.size() == 1) {
- CanvasItem *canvas_item = selection[0];
- if (canvas_item->_edit_use_rect() && _is_node_movable(canvas_item)) {
- Rect2 rect = canvas_item->_edit_get_rect();
- Transform2D xform = transform * canvas_item->get_global_transform_with_canvas();
+ CanvasItem *ci = selection[0];
+ if (ci->_edit_use_rect() && _is_node_movable(ci)) {
+ Rect2 rect = ci->_edit_get_rect();
+ Transform2D xform = transform * ci->get_global_transform_with_canvas();
const Vector2 endpoints[4] = {
xform.xform(rect.position),
@@ -1689,7 +1689,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
drag_type = resize_drag;
drag_from = transform.affine_inverse().xform(b->get_position());
drag_selection = List<CanvasItem *>();
- drag_selection.push_back(canvas_item);
+ drag_selection.push_back(ci);
_save_canvas_item_state(drag_selection);
return true;
}
@@ -1702,36 +1702,36 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
drag_type == DRAG_TOP_LEFT || drag_type == DRAG_TOP_RIGHT || drag_type == DRAG_BOTTOM_LEFT || drag_type == DRAG_BOTTOM_RIGHT) {
// Resize the node
if (m.is_valid()) {
- CanvasItem *canvas_item = drag_selection[0];
- CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
+ CanvasItem *ci = drag_selection[0];
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci);
//Reset state
- canvas_item->_edit_set_state(se->undo_state);
+ ci->_edit_set_state(se->undo_state);
bool uniform = m->is_shift_pressed();
bool symmetric = m->is_alt_pressed();
- Rect2 local_rect = canvas_item->_edit_get_rect();
+ Rect2 local_rect = ci->_edit_get_rect();
real_t aspect = local_rect.get_size().y / local_rect.get_size().x;
Point2 current_begin = local_rect.get_position();
Point2 current_end = local_rect.get_position() + local_rect.get_size();
- Point2 max_begin = (symmetric) ? (current_begin + current_end - canvas_item->_edit_get_minimum_size()) / 2.0 : current_end - canvas_item->_edit_get_minimum_size();
- Point2 min_end = (symmetric) ? (current_begin + current_end + canvas_item->_edit_get_minimum_size()) / 2.0 : current_begin + canvas_item->_edit_get_minimum_size();
+ Point2 max_begin = (symmetric) ? (current_begin + current_end - ci->_edit_get_minimum_size()) / 2.0 : current_end - ci->_edit_get_minimum_size();
+ Point2 min_end = (symmetric) ? (current_begin + current_end + ci->_edit_get_minimum_size()) / 2.0 : current_begin + ci->_edit_get_minimum_size();
Point2 center = (current_begin + current_end) / 2.0;
drag_to = transform.affine_inverse().xform(m->get_position());
- Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse();
+ Transform2D xform = ci->get_global_transform_with_canvas().affine_inverse();
Point2 drag_to_snapped_begin;
Point2 drag_to_snapped_end;
// last call decides which snapping lines are drawn
if (drag_type == DRAG_LEFT || drag_type == DRAG_TOP || drag_type == DRAG_TOP_LEFT) {
- drag_to_snapped_end = snap_point(xform.affine_inverse().xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item);
- drag_to_snapped_begin = snap_point(xform.affine_inverse().xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item);
+ drag_to_snapped_end = snap_point(xform.affine_inverse().xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci);
+ drag_to_snapped_begin = snap_point(xform.affine_inverse().xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci);
} else {
- drag_to_snapped_begin = snap_point(xform.affine_inverse().xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item);
- drag_to_snapped_end = snap_point(xform.affine_inverse().xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item);
+ drag_to_snapped_begin = snap_point(xform.affine_inverse().xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci);
+ drag_to_snapped_end = snap_point(xform.affine_inverse().xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci);
}
Point2 drag_begin = xform.xform(drag_to_snapped_begin);
@@ -1787,7 +1787,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
current_begin.y = 2.0 * center.y - current_end.y;
}
}
- canvas_item->_edit_set_rect(Rect2(current_begin, current_end - current_begin));
+ ci->_edit_set_rect(Rect2(current_begin, current_end - current_begin));
return true;
}
@@ -1850,11 +1850,11 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
if (b.is_valid() && b->get_button_index() == MouseButton::LEFT && b->is_pressed() && ((b->is_alt_pressed() && b->is_ctrl_pressed()) || tool == TOOL_SCALE)) {
List<CanvasItem *> selection = _get_edited_canvas_items();
if (selection.size() == 1) {
- CanvasItem *canvas_item = selection[0];
+ CanvasItem *ci = selection[0];
- if (_is_node_movable(canvas_item)) {
- Transform2D xform = transform * canvas_item->get_global_transform_with_canvas();
- Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
+ if (_is_node_movable(ci)) {
+ Transform2D xform = transform * ci->get_global_transform_with_canvas();
+ Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
drag_type = DRAG_SCALE_BOTH;
@@ -1873,7 +1873,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
drag_from = transform.affine_inverse().xform(b->get_position());
drag_selection = List<CanvasItem *>();
- drag_selection.push_back(canvas_item);
+ drag_selection.push_back(ci);
_save_canvas_item_state(drag_selection);
return true;
}
@@ -1885,12 +1885,12 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
// Resize the node
if (m.is_valid()) {
_restore_canvas_item_state(drag_selection);
- CanvasItem *canvas_item = drag_selection[0];
+ CanvasItem *ci = drag_selection[0];
drag_to = transform.affine_inverse().xform(m->get_position());
- Transform2D parent_xform = canvas_item->get_global_transform_with_canvas() * canvas_item->get_transform().affine_inverse();
- Transform2D unscaled_transform = (transform * parent_xform * canvas_item->_edit_get_transform()).orthonormalized();
+ Transform2D parent_xform = ci->get_global_transform_with_canvas() * ci->get_transform().affine_inverse();
+ Transform2D unscaled_transform = (transform * parent_xform * ci->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = (viewport->get_transform() * unscaled_transform).affine_inverse() * transform;
bool uniform = m->is_shift_pressed();
@@ -1900,7 +1900,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
Point2 drag_to_local = simple_xform.xform(drag_to);
Point2 offset = drag_to_local - drag_from_local;
- Size2 scale = canvas_item->_edit_get_scale();
+ Size2 scale = ci->_edit_get_scale();
Size2 original_scale = scale;
real_t ratio = scale.y / scale.x;
if (drag_type == DRAG_SCALE_BOTH) {
@@ -1938,7 +1938,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
}
}
- canvas_item->_edit_set_scale(scale);
+ ci->_edit_set_scale(scale);
return true;
}
@@ -1999,9 +1999,9 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
if (selection.size() > 0) {
drag_type = DRAG_MOVE;
- CanvasItem *canvas_item = selection[0];
- Transform2D parent_xform = canvas_item->get_global_transform_with_canvas() * canvas_item->get_transform().affine_inverse();
- Transform2D unscaled_transform = (transform * parent_xform * canvas_item->_edit_get_transform()).orthonormalized();
+ CanvasItem *ci = selection[0];
+ Transform2D parent_xform = ci->get_global_transform_with_canvas() * ci->get_transform().affine_inverse();
+ Transform2D unscaled_transform = (transform * parent_xform * ci->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
if (show_transformation_gizmos) {
@@ -2058,10 +2058,10 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
}
int index = 0;
- for (CanvasItem *canvas_item : drag_selection) {
- Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform();
+ for (CanvasItem *ci : drag_selection) {
+ Transform2D xform = ci->get_global_transform_with_canvas().affine_inverse() * ci->get_transform();
- canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos));
+ ci->_edit_set_position(ci->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos));
index++;
}
return true;
@@ -2181,10 +2181,10 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
}
int index = 0;
- for (CanvasItem *canvas_item : drag_selection) {
- Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform();
+ for (CanvasItem *ci : drag_selection) {
+ Transform2D xform = ci->get_global_transform_with_canvas().affine_inverse() * ci->get_transform();
- canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos));
+ ci->_edit_set_position(ci->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos));
index++;
}
}
@@ -2263,8 +2263,8 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
Node *node = item;
while (node && node != scene->get_parent()) {
- CanvasItem *canvas_item_tmp = Object::cast_to<CanvasItem>(node);
- if (canvas_item_tmp && node->has_meta("_edit_group_")) {
+ CanvasItem *ci_tmp = Object::cast_to<CanvasItem>(node);
+ if (ci_tmp && node->has_meta("_edit_group_")) {
locked = 2;
}
node = node->get_parent();
@@ -2325,16 +2325,16 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
}
// Find the item to select
- CanvasItem *canvas_item = nullptr;
+ CanvasItem *ci = nullptr;
Vector<_SelectResult> selection = Vector<_SelectResult>();
// Retrieve the canvas items
_get_canvas_items_at_pos(click, selection);
if (!selection.is_empty()) {
- canvas_item = selection[0].item;
+ ci = selection[0].item;
}
- if (!canvas_item) {
+ if (!ci) {
// Start a box selection
if (!b->is_shift_pressed()) {
// Clear the selection if not additive
@@ -2348,7 +2348,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
box_selecting_to = drag_from;
return true;
} else {
- bool still_selected = _select_click_on_item(canvas_item, click, b->is_shift_pressed());
+ bool still_selected = _select_click_on_item(ci, click, b->is_shift_pressed());
// Start dragging
if (still_selected) {
// Drag the node(s) if requested
@@ -2488,16 +2488,16 @@ bool CanvasItemEditor::_gui_input_hover(const Ref<InputEvent> &p_event) {
// Compute the nodes names and icon position
Vector<_HoverResult> hovering_results_tmp;
for (int i = 0; i < hovering_results_items.size(); i++) {
- CanvasItem *canvas_item = hovering_results_items[i].item;
+ CanvasItem *ci = hovering_results_items[i].item;
- if (canvas_item->_edit_use_rect()) {
+ if (ci->_edit_use_rect()) {
continue;
}
_HoverResult hover_result;
- hover_result.position = canvas_item->get_global_transform_with_canvas().get_origin();
- hover_result.icon = EditorNode::get_singleton()->get_object_icon(canvas_item);
- hover_result.name = canvas_item->get_name();
+ hover_result.position = ci->get_global_transform_with_canvas().get_origin();
+ hover_result.icon = EditorNode::get_singleton()->get_object_icon(ci);
+ hover_result.name = ci->get_name();
hovering_results_tmp.push_back(hover_result);
}
@@ -3312,16 +3312,16 @@ void CanvasItemEditor::_draw_selection() {
Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons"));
Ref<Texture2D> previous_position_icon = get_theme_icon(SNAME("EditorPositionPrevious"), SNAME("EditorIcons"));
- RID ci = viewport->get_canvas_item();
+ RID vp_ci = viewport->get_canvas_item();
List<CanvasItem *> selection = _get_edited_canvas_items(true, false);
bool single = selection.size() == 1;
for (CanvasItem *E : selection) {
- CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E);
- CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
+ CanvasItem *ci = Object::cast_to<CanvasItem>(E);
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci);
- bool item_locked = canvas_item->has_meta("_edit_lock_");
+ bool item_locked = ci->has_meta("_edit_lock_");
// Draw the previous position if we are dragging the node
if (show_helpers &&
@@ -3331,7 +3331,7 @@ void CanvasItemEditor::_draw_selection() {
const Transform2D pre_drag_xform = transform * se->pre_drag_xform;
const Color pre_drag_color = Color(0.4, 0.6, 1, 0.7);
- if (canvas_item->_edit_use_rect()) {
+ if (ci->_edit_use_rect()) {
Vector2 pre_drag_endpoints[4] = {
pre_drag_xform.xform(se->pre_drag_rect.position),
pre_drag_xform.xform(se->pre_drag_rect.position + Vector2(se->pre_drag_rect.size.x, 0)),
@@ -3347,11 +3347,11 @@ void CanvasItemEditor::_draw_selection() {
}
}
- Transform2D xform = transform * canvas_item->get_global_transform_with_canvas();
+ Transform2D xform = transform * ci->get_global_transform_with_canvas();
// Draw the selected items position / surrounding boxes
- if (canvas_item->_edit_use_rect()) {
- Rect2 rect = canvas_item->_edit_get_rect();
+ if (ci->_edit_use_rect()) {
+ Rect2 rect = ci->_edit_get_rect();
const Vector2 endpoints[4] = {
xform.xform(rect.position),
xform.xform(rect.position + Vector2(rect.size.x, 0)),
@@ -3369,7 +3369,7 @@ void CanvasItemEditor::_draw_selection() {
viewport->draw_line(endpoints[i], endpoints[(i + 1) % 4], c, Math::round(2 * EDSCALE));
}
} else {
- Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
+ Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
viewport->draw_set_transform_matrix(simple_xform);
viewport->draw_texture(position_icon, -(position_icon->get_size() / 2));
@@ -3378,9 +3378,9 @@ void CanvasItemEditor::_draw_selection() {
if (single && !item_locked && (tool == TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_SCALE || tool == TOOL_ROTATE || tool == TOOL_EDIT_PIVOT)) { //kind of sucks
// Draw the pivot
- if (canvas_item->_edit_use_pivot()) {
+ if (ci->_edit_use_pivot()) {
// Draw the node's pivot
- Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
+ Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
viewport->draw_set_transform_matrix(simple_xform);
@@ -3389,15 +3389,15 @@ void CanvasItemEditor::_draw_selection() {
}
// Draw control-related helpers
- Control *control = Object::cast_to<Control>(canvas_item);
+ Control *control = Object::cast_to<Control>(ci);
if (control && _is_node_movable(control)) {
_draw_control_anchors(control);
_draw_control_helpers(control);
}
// Draw the resize handles
- if (tool == TOOL_SELECT && canvas_item->_edit_use_rect() && _is_node_movable(canvas_item)) {
- Rect2 rect = canvas_item->_edit_get_rect();
+ if (tool == TOOL_SELECT && ci->_edit_use_rect() && _is_node_movable(ci)) {
+ Rect2 rect = ci->_edit_get_rect();
const Vector2 endpoints[4] = {
xform.xform(rect.position),
xform.xform(rect.position + Vector2(rect.size.x, 0)),
@@ -3411,12 +3411,12 @@ void CanvasItemEditor::_draw_selection() {
Vector2 ofs = ((endpoints[i] - endpoints[prev]).normalized() + ((endpoints[i] - endpoints[next]).normalized())).normalized();
ofs *= Math_SQRT2 * (select_handle->get_size().width / 2);
- select_handle->draw(ci, (endpoints[i] + ofs - (select_handle->get_size() / 2)).floor());
+ select_handle->draw(vp_ci, (endpoints[i] + ofs - (select_handle->get_size() / 2)).floor());
ofs = (endpoints[i] + endpoints[next]) / 2;
ofs += (endpoints[next] - endpoints[i]).orthogonal().normalized() * (select_handle->get_size().width / 2);
- select_handle->draw(ci, (ofs - (select_handle->get_size() / 2)).floor());
+ select_handle->draw(vp_ci, (ofs - (select_handle->get_size() / 2)).floor());
}
}
@@ -3424,8 +3424,8 @@ void CanvasItemEditor::_draw_selection() {
bool is_ctrl = Input::get_singleton()->is_key_pressed(Key::CTRL);
bool is_alt = Input::get_singleton()->is_key_pressed(Key::ALT);
if (tool == TOOL_MOVE && show_transformation_gizmos) {
- if (_is_node_movable(canvas_item)) {
- Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
+ if (_is_node_movable(ci)) {
+ Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
Size2 move_factor = Size2(MOVE_HANDLE_DISTANCE, MOVE_HANDLE_DISTANCE);
@@ -3454,8 +3454,8 @@ void CanvasItemEditor::_draw_selection() {
// Draw the rescale handles
if (show_transformation_gizmos && ((is_alt && is_ctrl) || tool == TOOL_SCALE || drag_type == DRAG_SCALE_X || drag_type == DRAG_SCALE_Y)) {
- if (_is_node_movable(canvas_item)) {
- Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
+ if (_is_node_movable(ci)) {
+ Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE);
@@ -3589,16 +3589,16 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans
if (p_node != scene && p_node->get_owner() != scene && !scene->is_editable_instance(p_node->get_owner())) {
return;
}
- CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
- if (canvas_item && !canvas_item->is_visible_in_tree()) {
+ CanvasItem *ci = Object::cast_to<CanvasItem>(p_node);
+ if (ci && !ci->is_visible_in_tree()) {
return;
}
Transform2D parent_xform = p_parent_xform;
Transform2D canvas_xform = p_canvas_xform;
- if (canvas_item && !canvas_item->is_set_as_top_level()) {
- parent_xform = parent_xform * canvas_item->get_transform();
+ if (ci && !ci->is_set_as_top_level()) {
+ parent_xform = parent_xform * ci->get_transform();
} else {
CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node);
parent_xform = Transform2D();
@@ -3609,12 +3609,12 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans
_draw_invisible_nodes_positions(p_node->get_child(i), parent_xform, canvas_xform);
}
- if (canvas_item && !canvas_item->_edit_use_rect() && (!editor_selection->is_selected(canvas_item) || _is_node_locked(canvas_item))) {
+ if (ci && !ci->_edit_use_rect() && (!editor_selection->is_selected(ci) || _is_node_locked(ci))) {
Transform2D xform = transform * canvas_xform * parent_xform;
// Draw the node's position
Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPositionUnselected"), SNAME("EditorIcons"));
- Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
+ Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
viewport->draw_set_transform_matrix(simple_xform);
viewport->draw_texture(position_icon, -position_icon->get_size() / 2, Color(1.0, 1.0, 1.0, 0.5));
@@ -3720,16 +3720,16 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p
if (p_node != scene && p_node->get_owner() != scene && !scene->is_editable_instance(p_node->get_owner())) {
return;
}
- CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
- if (canvas_item && !canvas_item->is_visible_in_tree()) {
+ CanvasItem *ci = Object::cast_to<CanvasItem>(p_node);
+ if (ci && !ci->is_visible_in_tree()) {
return;
}
Transform2D parent_xform = p_parent_xform;
Transform2D canvas_xform = p_canvas_xform;
- if (canvas_item && !canvas_item->is_set_as_top_level()) {
- parent_xform = parent_xform * canvas_item->get_transform();
+ if (ci && !ci->is_set_as_top_level()) {
+ parent_xform = parent_xform * ci->get_transform();
} else {
CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node);
parent_xform = Transform2D();
@@ -3740,19 +3740,19 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p
_draw_locks_and_groups(p_node->get_child(i), parent_xform, canvas_xform);
}
- RID viewport_canvas_item = viewport->get_canvas_item();
- if (canvas_item) {
+ RID viewport_ci = viewport->get_canvas_item();
+ if (ci) {
real_t offset = 0;
Ref<Texture2D> lock = get_theme_icon(SNAME("LockViewport"), SNAME("EditorIcons"));
if (p_node->has_meta("_edit_lock_") && show_edit_locks) {
- lock->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0));
+ lock->draw(viewport_ci, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0));
offset += lock->get_size().x;
}
Ref<Texture2D> group = get_theme_icon(SNAME("GroupViewport"), SNAME("EditorIcons"));
- if (canvas_item->has_meta("_edit_group_") && show_edit_locks) {
- group->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0));
+ if (ci->has_meta("_edit_group_") && show_edit_locks) {
+ group->draw(viewport_ci, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0));
//offset += group->get_size().x;
}
}
@@ -3885,16 +3885,16 @@ void CanvasItemEditor::_notification(int p_what) {
// Update the viewport if the canvas_item changes
List<CanvasItem *> selection = _get_edited_canvas_items(true);
- for (CanvasItem *canvas_item : selection) {
- CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
+ for (CanvasItem *ci : selection) {
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci);
Rect2 rect;
- if (canvas_item->_edit_use_rect()) {
- rect = canvas_item->_edit_get_rect();
+ if (ci->_edit_use_rect()) {
+ rect = ci->_edit_get_rect();
} else {
rect = Rect2();
}
- Transform2D xform = canvas_item->get_transform();
+ Transform2D xform = ci->get_transform();
if (rect != se->prev_rect || xform != se->prev_xform) {
viewport->queue_redraw();
@@ -3902,7 +3902,7 @@ void CanvasItemEditor::_notification(int p_what) {
se->prev_xform = xform;
}
- Control *control = Object::cast_to<Control>(canvas_item);
+ Control *control = Object::cast_to<Control>(ci);
if (control) {
real_t anchors[4];
Vector2 pivot;
@@ -3923,7 +3923,7 @@ void CanvasItemEditor::_notification(int p_what) {
}
}
- if (canvas_item->_edit_use_pivot()) {
+ if (ci->_edit_use_pivot()) {
nb_having_pivot++;
}
}
@@ -4184,17 +4184,17 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation,
AnimationTrackEditor *te = AnimationPlayerEditor::get_singleton()->get_track_editor();
te->make_insert_queue();
for (const KeyValue<Node *, Object *> &E : selection) {
- CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key);
- if (!canvas_item || !canvas_item->is_visible_in_tree()) {
+ CanvasItem *ci = Object::cast_to<CanvasItem>(E.key);
+ if (!ci || !ci->is_visible_in_tree()) {
continue;
}
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
+ if (ci->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
}
- if (Object::cast_to<Node2D>(canvas_item)) {
- Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
+ if (Object::cast_to<Node2D>(ci)) {
+ Node2D *n2d = Object::cast_to<Node2D>(ci);
if (key_pos && p_location) {
te->insert_node_value_key(n2d, "position", n2d->get_position(), p_on_existing);
@@ -4241,8 +4241,8 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation,
}
}
- } else if (Object::cast_to<Control>(canvas_item)) {
- Control *ctrl = Object::cast_to<Control>(canvas_item);
+ } else if (Object::cast_to<Control>(ci)) {
+ Control *ctrl = Object::cast_to<Control>(ci);
if (key_pos) {
te->insert_node_value_key(ctrl, "position", ctrl->get_position(), p_on_existing);
@@ -4390,16 +4390,16 @@ void CanvasItemEditor::_popup_callback(int p_op) {
List<Node *> selection = editor_selection->get_selected_node_list();
for (Node *E : selection) {
- CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E);
- if (!canvas_item || !canvas_item->is_inside_tree()) {
+ CanvasItem *ci = Object::cast_to<CanvasItem>(E);
+ if (!ci || !ci->is_inside_tree()) {
continue;
}
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
+ if (ci->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
}
- undo_redo->add_do_method(canvas_item, "set_meta", "_edit_lock_", true);
- undo_redo->add_undo_method(canvas_item, "remove_meta", "_edit_lock_");
+ undo_redo->add_do_method(ci, "set_meta", "_edit_lock_", true);
+ undo_redo->add_undo_method(ci, "remove_meta", "_edit_lock_");
undo_redo->add_do_method(this, "emit_signal", "item_lock_status_changed");
undo_redo->add_undo_method(this, "emit_signal", "item_lock_status_changed");
}
@@ -4412,16 +4412,16 @@ void CanvasItemEditor::_popup_callback(int p_op) {
List<Node *> selection = editor_selection->get_selected_node_list();
for (Node *E : selection) {
- CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E);
- if (!canvas_item || !canvas_item->is_inside_tree()) {
+ CanvasItem *ci = Object::cast_to<CanvasItem>(E);
+ if (!ci || !ci->is_inside_tree()) {
continue;
}
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
+ if (ci->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
}
- undo_redo->add_do_method(canvas_item, "remove_meta", "_edit_lock_");
- undo_redo->add_undo_method(canvas_item, "set_meta", "_edit_lock_", true);
+ undo_redo->add_do_method(ci, "remove_meta", "_edit_lock_");
+ undo_redo->add_undo_method(ci, "set_meta", "_edit_lock_", true);
undo_redo->add_do_method(this, "emit_signal", "item_lock_status_changed");
undo_redo->add_undo_method(this, "emit_signal", "item_lock_status_changed");
}
@@ -4434,16 +4434,16 @@ void CanvasItemEditor::_popup_callback(int p_op) {
List<Node *> selection = editor_selection->get_selected_node_list();
for (Node *E : selection) {
- CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E);
- if (!canvas_item || !canvas_item->is_inside_tree()) {
+ CanvasItem *ci = Object::cast_to<CanvasItem>(E);
+ if (!ci || !ci->is_inside_tree()) {
continue;
}
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
+ if (ci->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
}
- undo_redo->add_do_method(canvas_item, "set_meta", "_edit_group_", true);
- undo_redo->add_undo_method(canvas_item, "remove_meta", "_edit_group_");
+ undo_redo->add_do_method(ci, "set_meta", "_edit_group_", true);
+ undo_redo->add_undo_method(ci, "remove_meta", "_edit_group_");
undo_redo->add_do_method(this, "emit_signal", "item_group_status_changed");
undo_redo->add_undo_method(this, "emit_signal", "item_group_status_changed");
}
@@ -4456,16 +4456,16 @@ void CanvasItemEditor::_popup_callback(int p_op) {
List<Node *> selection = editor_selection->get_selected_node_list();
for (Node *E : selection) {
- CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E);
- if (!canvas_item || !canvas_item->is_inside_tree()) {
+ CanvasItem *ci = Object::cast_to<CanvasItem>(E);
+ if (!ci || !ci->is_inside_tree()) {
continue;
}
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
+ if (ci->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
}
- undo_redo->add_do_method(canvas_item, "remove_meta", "_edit_group_");
- undo_redo->add_undo_method(canvas_item, "set_meta", "_edit_group_", true);
+ undo_redo->add_do_method(ci, "remove_meta", "_edit_group_");
+ undo_redo->add_undo_method(ci, "set_meta", "_edit_group_", true);
undo_redo->add_do_method(this, "emit_signal", "item_group_status_changed");
undo_redo->add_undo_method(this, "emit_signal", "item_group_status_changed");
}
@@ -4496,17 +4496,17 @@ void CanvasItemEditor::_popup_callback(int p_op) {
const HashMap<Node *, Object *> &selection = editor_selection->get_selection();
for (const KeyValue<Node *, Object *> &E : selection) {
- CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key);
- if (!canvas_item || !canvas_item->is_visible_in_tree()) {
+ CanvasItem *ci = Object::cast_to<CanvasItem>(E.key);
+ if (!ci || !ci->is_visible_in_tree()) {
continue;
}
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
+ if (ci->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
}
- if (Object::cast_to<Node2D>(canvas_item)) {
- Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
+ if (Object::cast_to<Node2D>(ci)) {
+ Node2D *n2d = Object::cast_to<Node2D>(ci);
PoseClipboard pc;
pc.pos = n2d->get_position();
pc.rot = n2d->get_rotation();
@@ -4542,17 +4542,17 @@ void CanvasItemEditor::_popup_callback(int p_op) {
HashMap<Node *, Object *> &selection = editor_selection->get_selection();
for (const KeyValue<Node *, Object *> &E : selection) {
- CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key);
- if (!canvas_item || !canvas_item->is_visible_in_tree()) {
+ CanvasItem *ci = Object::cast_to<CanvasItem>(E.key);
+ if (!ci || !ci->is_visible_in_tree()) {
continue;
}
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
+ if (ci->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
}
- if (Object::cast_to<Node2D>(canvas_item)) {
- Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
+ if (Object::cast_to<Node2D>(ci)) {
+ Node2D *n2d = Object::cast_to<Node2D>(ci);
if (key_pos) {
n2d->set_position(Vector2());
@@ -4563,8 +4563,8 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (key_scale) {
n2d->set_scale(Vector2(1, 1));
}
- } else if (Object::cast_to<Control>(canvas_item)) {
- Control *ctrl = Object::cast_to<Control>(canvas_item);
+ } else if (Object::cast_to<Control>(ci)) {
+ Control *ctrl = Object::cast_to<Control>(ci);
if (key_pos) {
ctrl->set_position(Point2());
@@ -4658,28 +4658,28 @@ void CanvasItemEditor::_focus_selection(int p_op) {
const HashMap<Node *, Object *> &selection = editor_selection->get_selection();
for (const KeyValue<Node *, Object *> &E : selection) {
- CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key);
- if (!canvas_item) {
+ CanvasItem *ci = Object::cast_to<CanvasItem>(E.key);
+ if (!ci) {
continue;
}
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
+ if (ci->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
}
// counting invisible items, for now
- //if (!canvas_item->is_visible_in_tree()) continue;
+ //if (!ci->is_visible_in_tree()) continue;
++count;
Rect2 item_rect;
- if (canvas_item->_edit_use_rect()) {
- item_rect = canvas_item->_edit_get_rect();
+ if (ci->_edit_use_rect()) {
+ item_rect = ci->_edit_get_rect();
} else {
item_rect = Rect2();
}
- Vector2 pos = canvas_item->get_global_transform().get_origin();
- Vector2 scale = canvas_item->get_global_transform().get_scale();
- real_t angle = canvas_item->get_global_transform().get_rotation();
+ Vector2 pos = ci->get_global_transform().get_origin();
+ Vector2 scale = ci->get_global_transform().get_scale();
+ real_t angle = ci->get_global_transform().get_rotation();
Transform2D t(angle, Vector2(0.f, 0.f));
item_rect = t.xform(item_rect);
@@ -5060,6 +5060,7 @@ CanvasItemEditor::CanvasItemEditor() {
zoom_widget = memnew(EditorZoomWidget);
controls_vb->add_child(zoom_widget);
zoom_widget->set_anchors_and_offsets_preset(Control::PRESET_TOP_LEFT, Control::PRESET_MODE_MINSIZE, 2 * EDSCALE);
+ zoom_widget->set_shortcut_context(this);
zoom_widget->connect("zoom_changed", callable_mp(this, &CanvasItemEditor::_update_zoom));
panner.instantiate();
@@ -5316,7 +5317,7 @@ CanvasItemEditor::CanvasItemEditor() {
p->add_shortcut(ED_SHORTCUT("canvas_item_editor/frame_selection", TTR("Frame Selection"), KeyModifierMask::SHIFT | Key::F), VIEW_FRAME_TO_SELECTION);
p->add_shortcut(ED_SHORTCUT("canvas_item_editor/clear_guides", TTR("Clear Guides")), CLEAR_GUIDES);
p->add_separator();
- p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/preview_canvas_scale", TTR("Preview Canvas Scale"), KeyModifierMask::SHIFT | KeyModifierMask::CMD_OR_CTRL | Key::P), PREVIEW_CANVAS_SCALE);
+ p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/preview_canvas_scale", TTR("Preview Canvas Scale")), PREVIEW_CANVAS_SCALE);
main_menu_hbox->add_child(memnew(VSeparator));
diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp
index e56fd5dfe3..a0e6771768 100644
--- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp
+++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp
@@ -110,8 +110,8 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() {
int vpc = 0;
{
- Vector<uint8_t> data = img->get_data();
- const uint8_t *r = data.ptr();
+ Vector<uint8_t> img_data = img->get_data();
+ const uint8_t *r = img_data.ptr();
for (int i = 0; i < s.width; i++) {
for (int j = 0; j < s.height; j++) {
diff --git a/editor/plugins/editor_resource_conversion_plugin.cpp b/editor/plugins/editor_resource_conversion_plugin.cpp
index 91394dbac7..2db860fd07 100644
--- a/editor/plugins/editor_resource_conversion_plugin.cpp
+++ b/editor/plugins/editor_resource_conversion_plugin.cpp
@@ -46,7 +46,7 @@ String EditorResourceConversionPlugin::converts_to() const {
}
bool EditorResourceConversionPlugin::handles(const Ref<Resource> &p_resource) const {
- bool ret;
+ bool ret = false;
if (GDVIRTUAL_CALL(_handles, p_resource, ret)) {
return ret;
}
diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp
index e2d19c34e6..1b2afe2151 100644
--- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp
@@ -207,8 +207,8 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() {
int vpc = 0;
{
- Vector<uint8_t> data = img->get_data();
- const uint8_t *r = data.ptr();
+ Vector<uint8_t> img_data = img->get_data();
+ const uint8_t *r = img_data.ptr();
for (int i = 0; i < s.width; i++) {
for (int j = 0; j < s.height; j++) {
diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp
index d91cbb6571..db3a46d1f1 100644
--- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp
@@ -255,8 +255,8 @@ void GPUParticles3DEditor::_menu_option(int p_option) {
}
} break;
case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE: {
- Ref<ParticleProcessMaterial> material = node->get_process_material();
- if (material.is_null()) {
+ Ref<ParticleProcessMaterial> mat = node->get_process_material();
+ if (mat.is_null()) {
EditorNode::get_singleton()->show_warning(TTR("A processor material of type 'ParticleProcessMaterial' is required."));
return;
}
@@ -366,13 +366,13 @@ void GPUParticles3DEditor::_generate_emission_points() {
Ref<Image> image = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img));
Ref<ImageTexture> tex = ImageTexture::create_from_image(image);
- Ref<ParticleProcessMaterial> material = node->get_process_material();
- ERR_FAIL_COND(material.is_null());
+ Ref<ParticleProcessMaterial> mat = node->get_process_material();
+ ERR_FAIL_COND(mat.is_null());
if (normals.size() > 0) {
- material->set_emission_shape(ParticleProcessMaterial::EMISSION_SHAPE_DIRECTED_POINTS);
- material->set_emission_point_count(point_count);
- material->set_emission_point_texture(tex);
+ mat->set_emission_shape(ParticleProcessMaterial::EMISSION_SHAPE_DIRECTED_POINTS);
+ mat->set_emission_point_count(point_count);
+ mat->set_emission_point_texture(tex);
Vector<uint8_t> point_img2;
point_img2.resize(w * h * 3 * sizeof(float));
@@ -390,11 +390,11 @@ void GPUParticles3DEditor::_generate_emission_points() {
}
Ref<Image> image2 = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img2));
- material->set_emission_normal_texture(ImageTexture::create_from_image(image2));
+ mat->set_emission_normal_texture(ImageTexture::create_from_image(image2));
} else {
- material->set_emission_shape(ParticleProcessMaterial::EMISSION_SHAPE_POINTS);
- material->set_emission_point_count(point_count);
- material->set_emission_point_texture(tex);
+ mat->set_emission_shape(ParticleProcessMaterial::EMISSION_SHAPE_POINTS);
+ mat->set_emission_point_count(point_count);
+ mat->set_emission_point_texture(tex);
}
}
diff --git a/editor/plugins/gradient_editor.cpp b/editor/plugins/gradient_editor.cpp
index c13b162db6..822f303d93 100644
--- a/editor/plugins/gradient_editor.cpp
+++ b/editor/plugins/gradient_editor.cpp
@@ -90,8 +90,8 @@ void GradientEditor::_gradient_changed() {
}
editing = true;
- Vector<Gradient::Point> points = gradient->get_points();
- set_points(points);
+ Vector<Gradient::Point> grad_points = gradient->get_points();
+ set_points(grad_points);
set_interpolation_mode(gradient->get_interpolation_mode());
queue_redraw();
editing = false;
diff --git a/editor/plugins/input_event_editor_plugin.cpp b/editor/plugins/input_event_editor_plugin.cpp
index 153eab32d2..b67f0f6ad2 100644
--- a/editor/plugins/input_event_editor_plugin.cpp
+++ b/editor/plugins/input_event_editor_plugin.cpp
@@ -30,6 +30,9 @@
#include "input_event_editor_plugin.h"
+#include "editor/event_listener_line_edit.h"
+#include "editor/input_event_configuration_dialog.h"
+
void InputEventConfigContainer::_bind_methods() {
}
@@ -63,13 +66,13 @@ void InputEventConfigContainer::set_event(const Ref<InputEvent> &p_event) {
Ref<InputEventJoypadMotion> jm = p_event;
if (k.is_valid()) {
- config_dialog->set_allowed_input_types(InputEventConfigurationDialog::InputType::INPUT_KEY);
+ config_dialog->set_allowed_input_types(INPUT_KEY);
} else if (m.is_valid()) {
- config_dialog->set_allowed_input_types(InputEventConfigurationDialog::InputType::INPUT_MOUSE_BUTTON);
+ config_dialog->set_allowed_input_types(INPUT_MOUSE_BUTTON);
} else if (jb.is_valid()) {
- config_dialog->set_allowed_input_types(InputEventConfigurationDialog::InputType::INPUT_JOY_BUTTON);
+ config_dialog->set_allowed_input_types(INPUT_JOY_BUTTON);
} else if (jm.is_valid()) {
- config_dialog->set_allowed_input_types(InputEventConfigurationDialog::InputType::INPUT_JOY_MOTION);
+ config_dialog->set_allowed_input_types(INPUT_JOY_MOTION);
}
input_event = p_event;
diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp
index 31053f90b8..d73761d770 100644
--- a/editor/plugins/line_2d_editor_plugin.cpp
+++ b/editor/plugins/line_2d_editor_plugin.cpp
@@ -51,9 +51,9 @@ void Line2DEditor::_set_polygon(int p_idx, const Variant &p_polygon) const {
}
void Line2DEditor::_action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon) {
- Node2D *node = _get_node();
- undo_redo->add_do_method(node, "set_points", p_polygon);
- undo_redo->add_undo_method(node, "set_points", p_previous);
+ Node2D *_node = _get_node();
+ undo_redo->add_do_method(_node, "set_points", p_polygon);
+ undo_redo->add_undo_method(_node, "set_points", p_previous);
}
Line2DEditor::Line2DEditor() {}
diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp
index c502d47669..d5cdb70ccf 100644
--- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp
+++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp
@@ -270,6 +270,24 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
case MENU_OPTION_CREATE_OUTLINE_MESH: {
outline_dialog->popup_centered(Vector2(200, 90));
} break;
+ case MENU_OPTION_CREATE_DEBUG_TANGENTS: {
+ Ref<EditorUndoRedoManager> ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action(TTR("Create Debug Tangents"));
+
+ MeshInstance3D *tangents = node->create_debug_tangents_node();
+
+ if (tangents) {
+ Node *owner = get_tree()->get_edited_scene_root();
+
+ ur->add_do_reference(tangents);
+ ur->add_do_method(node, "add_child", tangents, true);
+ ur->add_do_method(tangents, "set_owner", owner);
+
+ ur->add_undo_method(node, "remove_child", tangents);
+ }
+
+ ur->commit_action();
+ } break;
case MENU_OPTION_CREATE_UV2: {
Ref<ArrayMesh> mesh2 = node->get_mesh();
if (!mesh2.is_valid()) {
@@ -511,6 +529,7 @@ MeshInstance3DEditor::MeshInstance3DEditor() {
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Create Outline Mesh..."), MENU_OPTION_CREATE_OUTLINE_MESH);
options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a static outline mesh. The outline mesh will have its normals flipped automatically.\nThis can be used instead of the StandardMaterial Grow property when using that property isn't possible."));
+ options->get_popup()->add_item(TTR("Create Debug Tangents"), MENU_OPTION_CREATE_DEBUG_TANGENTS);
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("View UV1"), MENU_OPTION_DEBUG_UV1);
options->get_popup()->add_item(TTR("View UV2"), MENU_OPTION_DEBUG_UV2);
diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.h b/editor/plugins/mesh_instance_3d_editor_plugin.h
index 7968176744..88800227d1 100644
--- a/editor/plugins/mesh_instance_3d_editor_plugin.h
+++ b/editor/plugins/mesh_instance_3d_editor_plugin.h
@@ -46,6 +46,7 @@ class MeshInstance3DEditor : public Control {
MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES,
MENU_OPTION_CREATE_NAVMESH,
MENU_OPTION_CREATE_OUTLINE_MESH,
+ MENU_OPTION_CREATE_DEBUG_TANGENTS,
MENU_OPTION_CREATE_UV2,
MENU_OPTION_DEBUG_UV1,
MENU_OPTION_DEBUG_UV2,
diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp
index ec6ea7f39b..7194cd9d27 100644
--- a/editor/plugins/node_3d_editor_gizmos.cpp
+++ b/editor/plugins/node_3d_editor_gizmos.cpp
@@ -231,7 +231,7 @@ void EditorNode3DGizmo::commit_subgizmos(const Vector<int> &p_ids, const Vector<
gizmo_plugin->commit_subgizmos(this, p_ids, p_restore, p_cancel);
}
-void EditorNode3DGizmo::set_spatial_node(Node3D *p_node) {
+void EditorNode3DGizmo::set_node_3d(Node3D *p_node) {
ERR_FAIL_NULL(p_node);
spatial_node = p_node;
}
@@ -839,8 +839,8 @@ void EditorNode3DGizmo::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_collision_triangles", "triangles"), &EditorNode3DGizmo::add_collision_triangles);
ClassDB::bind_method(D_METHOD("add_unscaled_billboard", "material", "default_scale", "modulate"), &EditorNode3DGizmo::add_unscaled_billboard, DEFVAL(1), DEFVAL(Color(1, 1, 1)));
ClassDB::bind_method(D_METHOD("add_handles", "handles", "material", "ids", "billboard", "secondary"), &EditorNode3DGizmo::add_handles, DEFVAL(false), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("set_spatial_node", "node"), &EditorNode3DGizmo::_set_spatial_node);
- ClassDB::bind_method(D_METHOD("get_spatial_node"), &EditorNode3DGizmo::get_spatial_node);
+ ClassDB::bind_method(D_METHOD("set_node_3d", "node"), &EditorNode3DGizmo::_set_node_3d);
+ ClassDB::bind_method(D_METHOD("get_node_3d"), &EditorNode3DGizmo::get_node_3d);
ClassDB::bind_method(D_METHOD("get_plugin"), &EditorNode3DGizmo::get_plugin);
ClassDB::bind_method(D_METHOD("clear"), &EditorNode3DGizmo::clear);
ClassDB::bind_method(D_METHOD("set_hidden", "hidden"), &EditorNode3DGizmo::set_hidden);
@@ -1039,7 +1039,7 @@ Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::get_gizmo(Node3D *p_spatial) {
}
ref->set_plugin(this);
- ref->set_spatial_node(p_spatial);
+ ref->set_node_3d(p_spatial);
ref->set_hidden(current_state == HIDDEN);
current_gizmos.push_back(ref.ptr());
@@ -1119,7 +1119,7 @@ void EditorNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
bool EditorNode3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- bool ret;
+ bool ret = false;
if (GDVIRTUAL_CALL(_is_handle_highlighted, Ref<EditorNode3DGizmo>(p_gizmo), p_id, p_secondary, ret)) {
return ret;
}
@@ -1151,7 +1151,7 @@ void EditorNode3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, in
}
int EditorNode3DGizmoPlugin::subgizmos_intersect_ray(const EditorNode3DGizmo *p_gizmo, Camera3D *p_camera, const Vector2 &p_point) const {
- int ret;
+ int ret = -1;
if (GDVIRTUAL_CALL(_subgizmos_intersect_ray, Ref<EditorNode3DGizmo>(p_gizmo), p_camera, p_point, ret)) {
return ret;
}
@@ -1217,7 +1217,7 @@ EditorNode3DGizmoPlugin::EditorNode3DGizmoPlugin() {
EditorNode3DGizmoPlugin::~EditorNode3DGizmoPlugin() {
for (int i = 0; i < current_gizmos.size(); ++i) {
current_gizmos[i]->set_plugin(nullptr);
- current_gizmos[i]->get_spatial_node()->remove_gizmo(current_gizmos[i]);
+ current_gizmos[i]->get_node_3d()->remove_gizmo(current_gizmos[i]);
}
if (Node3DEditor::get_singleton()) {
Node3DEditor::get_singleton()->update_all_gizmos();
@@ -1261,7 +1261,7 @@ String Light3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int
}
Variant Light3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node());
+ Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_node_3d());
if (p_id == 0) {
return light->get_param(Light3D::PARAM_RANGE);
}
@@ -1300,7 +1300,7 @@ static float _find_closest_angle_to_half_pi_arc(const Vector3 &p_from, const Vec
}
void Light3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
- Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node());
+ Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_node_3d());
Transform3D gt = light->get_global_transform();
Transform3D gi = gt.affine_inverse();
@@ -1344,7 +1344,7 @@ void Light3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id,
}
void Light3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
- Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node());
+ Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_node_3d());
if (p_cancel) {
light->set_param(p_id == 0 ? Light3D::PARAM_RANGE : Light3D::PARAM_SPOT_ANGLE, p_restore);
@@ -1364,7 +1364,7 @@ void Light3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_i
}
void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node());
+ Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_node_3d());
Color color = light->get_color().srgb_to_linear() * light->get_correlated_color().srgb_to_linear();
color = color.linear_to_srgb();
@@ -1526,12 +1526,12 @@ String AudioStreamPlayer3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *
}
Variant AudioStreamPlayer3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node());
+ AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_node_3d());
return player->get_emission_angle();
}
void AudioStreamPlayer3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
- AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node());
+ AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_node_3d());
Transform3D gt = player->get_global_transform();
Transform3D gi = gt.affine_inverse();
@@ -1568,7 +1568,7 @@ void AudioStreamPlayer3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo
}
void AudioStreamPlayer3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
- AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node());
+ AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_node_3d());
if (p_cancel) {
player->set_emission_angle(p_restore);
@@ -1583,7 +1583,7 @@ void AudioStreamPlayer3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gi
}
void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- const AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node());
+ const AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -1762,7 +1762,7 @@ int Camera3DGizmoPlugin::get_priority() const {
}
String Camera3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node());
+ Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_node_3d());
if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) {
return "FOV";
@@ -1772,7 +1772,7 @@ String Camera3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, in
}
Variant Camera3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node());
+ Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_node_3d());
if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) {
return camera->get_fov();
@@ -1782,7 +1782,7 @@ Variant Camera3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo,
}
void Camera3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
- Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node());
+ Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_node_3d());
Transform3D gt = camera->get_global_transform();
Transform3D gi = gt.affine_inverse();
@@ -1811,7 +1811,7 @@ void Camera3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id,
}
void Camera3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
- Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node());
+ Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_node_3d());
if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) {
if (p_cancel) {
@@ -1838,7 +1838,7 @@ void Camera3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_
}
void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node());
+ Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -1962,7 +1962,7 @@ bool MeshInstance3DGizmoPlugin::can_be_hidden() const {
}
void MeshInstance3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- MeshInstance3D *mesh = Object::cast_to<MeshInstance3D>(p_gizmo->get_spatial_node());
+ MeshInstance3D *mesh = Object::cast_to<MeshInstance3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -1998,7 +1998,7 @@ int OccluderInstance3DGizmoPlugin::get_priority() const {
}
String OccluderInstance3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- const OccluderInstance3D *cs = Object::cast_to<OccluderInstance3D>(p_gizmo->get_spatial_node());
+ const OccluderInstance3D *cs = Object::cast_to<OccluderInstance3D>(p_gizmo->get_node_3d());
Ref<Occluder3D> o = cs->get_occluder();
if (o.is_null()) {
@@ -2017,7 +2017,7 @@ String OccluderInstance3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p
}
Variant OccluderInstance3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- OccluderInstance3D *oi = Object::cast_to<OccluderInstance3D>(p_gizmo->get_spatial_node());
+ OccluderInstance3D *oi = Object::cast_to<OccluderInstance3D>(p_gizmo->get_node_3d());
Ref<Occluder3D> o = oi->get_occluder();
if (o.is_null()) {
@@ -2043,7 +2043,7 @@ Variant OccluderInstance3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo
}
void OccluderInstance3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
- OccluderInstance3D *oi = Object::cast_to<OccluderInstance3D>(p_gizmo->get_spatial_node());
+ OccluderInstance3D *oi = Object::cast_to<OccluderInstance3D>(p_gizmo->get_node_3d());
Ref<Occluder3D> o = oi->get_occluder();
if (o.is_null()) {
@@ -2130,7 +2130,7 @@ void OccluderInstance3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo,
}
void OccluderInstance3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
- OccluderInstance3D *oi = Object::cast_to<OccluderInstance3D>(p_gizmo->get_spatial_node());
+ OccluderInstance3D *oi = Object::cast_to<OccluderInstance3D>(p_gizmo->get_node_3d());
Ref<Occluder3D> o = oi->get_occluder();
if (o.is_null()) {
@@ -2181,7 +2181,7 @@ void OccluderInstance3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_giz
}
void OccluderInstance3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- OccluderInstance3D *occluder_instance = Object::cast_to<OccluderInstance3D>(p_gizmo->get_spatial_node());
+ OccluderInstance3D *occluder_instance = Object::cast_to<OccluderInstance3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -2250,7 +2250,7 @@ bool Sprite3DGizmoPlugin::can_be_hidden() const {
}
void Sprite3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- Sprite3D *sprite = Object::cast_to<Sprite3D>(p_gizmo->get_spatial_node());
+ Sprite3D *sprite = Object::cast_to<Sprite3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -2282,7 +2282,7 @@ bool Label3DGizmoPlugin::can_be_hidden() const {
}
void Label3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- Label3D *label = Object::cast_to<Label3D>(p_gizmo->get_spatial_node());
+ Label3D *label = Object::cast_to<Label3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -2393,7 +2393,7 @@ int PhysicalBone3DGizmoPlugin::get_priority() const {
void PhysicalBone3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->clear();
- PhysicalBone3D *physical_bone = Object::cast_to<PhysicalBone3D>(p_gizmo->get_spatial_node());
+ PhysicalBone3D *physical_bone = Object::cast_to<PhysicalBone3D>(p_gizmo->get_node_3d());
if (!physical_bone) {
return;
@@ -2528,7 +2528,7 @@ int RayCast3DGizmoPlugin::get_priority() const {
}
void RayCast3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- RayCast3D *raycast = Object::cast_to<RayCast3D>(p_gizmo->get_spatial_node());
+ RayCast3D *raycast = Object::cast_to<RayCast3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -2566,7 +2566,7 @@ int ShapeCast3DGizmoPlugin::get_priority() const {
}
void ShapeCast3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- ShapeCast3D *shapecast = Object::cast_to<ShapeCast3D>(p_gizmo->get_spatial_node());
+ ShapeCast3D *shapecast = Object::cast_to<ShapeCast3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -2584,7 +2584,7 @@ void ShapeCast3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
/////
void SpringArm3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- SpringArm3D *spring_arm = Object::cast_to<SpringArm3D>(p_gizmo->get_spatial_node());
+ SpringArm3D *spring_arm = Object::cast_to<SpringArm3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -2636,7 +2636,7 @@ int VehicleWheel3DGizmoPlugin::get_priority() const {
}
void VehicleWheel3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- VehicleWheel3D *car_wheel = Object::cast_to<VehicleWheel3D>(p_gizmo->get_spatial_node());
+ VehicleWheel3D *car_wheel = Object::cast_to<VehicleWheel3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -2712,7 +2712,7 @@ bool SoftBody3DGizmoPlugin::is_selectable_when_hidden() const {
}
void SoftBody3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node());
+ SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -2753,17 +2753,17 @@ String SoftBody3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo,
}
Variant SoftBody3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node());
+ SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_node_3d());
return Variant(soft_body->is_point_pinned(p_id));
}
void SoftBody3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
- SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node());
+ SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_node_3d());
soft_body->pin_point_toggle(p_id);
}
bool SoftBody3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node());
+ SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_node_3d());
return soft_body->is_point_pinned(p_id);
}
@@ -2809,12 +2809,12 @@ String VisibleOnScreenNotifier3DGizmoPlugin::get_handle_name(const EditorNode3DG
}
Variant VisibleOnScreenNotifier3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- VisibleOnScreenNotifier3D *notifier = Object::cast_to<VisibleOnScreenNotifier3D>(p_gizmo->get_spatial_node());
+ VisibleOnScreenNotifier3D *notifier = Object::cast_to<VisibleOnScreenNotifier3D>(p_gizmo->get_node_3d());
return notifier->get_aabb();
}
void VisibleOnScreenNotifier3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
- VisibleOnScreenNotifier3D *notifier = Object::cast_to<VisibleOnScreenNotifier3D>(p_gizmo->get_spatial_node());
+ VisibleOnScreenNotifier3D *notifier = Object::cast_to<VisibleOnScreenNotifier3D>(p_gizmo->get_node_3d());
Transform3D gt = notifier->get_global_transform();
@@ -2866,7 +2866,7 @@ void VisibleOnScreenNotifier3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p
}
void VisibleOnScreenNotifier3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
- VisibleOnScreenNotifier3D *notifier = Object::cast_to<VisibleOnScreenNotifier3D>(p_gizmo->get_spatial_node());
+ VisibleOnScreenNotifier3D *notifier = Object::cast_to<VisibleOnScreenNotifier3D>(p_gizmo->get_node_3d());
if (p_cancel) {
notifier->set_aabb(p_restore);
@@ -2881,7 +2881,7 @@ void VisibleOnScreenNotifier3DGizmoPlugin::commit_handle(const EditorNode3DGizmo
}
void VisibleOnScreenNotifier3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- VisibleOnScreenNotifier3D *notifier = Object::cast_to<VisibleOnScreenNotifier3D>(p_gizmo->get_spatial_node());
+ VisibleOnScreenNotifier3D *notifier = Object::cast_to<VisibleOnScreenNotifier3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -3001,12 +3001,12 @@ String GPUParticles3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_giz
}
Variant GPUParticles3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node());
+ GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_node_3d());
return particles->get_visibility_aabb();
}
void GPUParticles3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
- GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node());
+ GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_node_3d());
Transform3D gt = particles->get_global_transform();
Transform3D gi = gt.affine_inverse();
@@ -3057,7 +3057,7 @@ void GPUParticles3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int
}
void GPUParticles3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
- GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node());
+ GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_node_3d());
if (p_cancel) {
particles->set_visibility_aabb(p_restore);
@@ -3072,7 +3072,7 @@ void GPUParticles3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo,
}
void GPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node());
+ GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -3148,7 +3148,7 @@ int GPUParticlesCollision3DGizmoPlugin::get_priority() const {
}
String GPUParticlesCollision3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- const Node3D *cs = p_gizmo->get_spatial_node();
+ const Node3D *cs = p_gizmo->get_node_3d();
if (Object::cast_to<GPUParticlesCollisionSphere3D>(cs) || Object::cast_to<GPUParticlesAttractorSphere3D>(cs)) {
return "Radius";
@@ -3162,21 +3162,21 @@ String GPUParticlesCollision3DGizmoPlugin::get_handle_name(const EditorNode3DGiz
}
Variant GPUParticlesCollision3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- const Node3D *cs = p_gizmo->get_spatial_node();
+ const Node3D *cs = p_gizmo->get_node_3d();
if (Object::cast_to<GPUParticlesCollisionSphere3D>(cs) || Object::cast_to<GPUParticlesAttractorSphere3D>(cs)) {
- return p_gizmo->get_spatial_node()->call("get_radius");
+ return p_gizmo->get_node_3d()->call("get_radius");
}
if (Object::cast_to<GPUParticlesCollisionBox3D>(cs) || Object::cast_to<GPUParticlesAttractorBox3D>(cs) || Object::cast_to<GPUParticlesAttractorVectorField3D>(cs) || Object::cast_to<GPUParticlesCollisionSDF3D>(cs) || Object::cast_to<GPUParticlesCollisionHeightField3D>(cs)) {
- return Vector3(p_gizmo->get_spatial_node()->call("get_extents"));
+ return Vector3(p_gizmo->get_node_3d()->call("get_extents"));
}
return Variant();
}
void GPUParticlesCollision3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
- Node3D *sn = p_gizmo->get_spatial_node();
+ Node3D *sn = p_gizmo->get_node_3d();
Transform3D gt = sn->get_global_transform();
Transform3D gi = gt.affine_inverse();
@@ -3222,7 +3222,7 @@ void GPUParticlesCollision3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_g
}
void GPUParticlesCollision3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
- Node3D *sn = p_gizmo->get_spatial_node();
+ Node3D *sn = p_gizmo->get_node_3d();
if (Object::cast_to<GPUParticlesCollisionSphere3D>(sn) || Object::cast_to<GPUParticlesAttractorSphere3D>(sn)) {
if (p_cancel) {
@@ -3252,7 +3252,7 @@ void GPUParticlesCollision3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *
}
void GPUParticlesCollision3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- Node3D *cs = p_gizmo->get_spatial_node();
+ Node3D *cs = p_gizmo->get_node_3d();
p_gizmo->clear();
@@ -3430,12 +3430,12 @@ String ReflectionProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gi
}
Variant ReflectionProbeGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node());
+ ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_node_3d());
return AABB(probe->get_extents(), probe->get_origin_offset());
}
void ReflectionProbeGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
- ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node());
+ ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_node_3d());
Transform3D gt = probe->get_global_transform();
Transform3D gi = gt.affine_inverse();
@@ -3492,7 +3492,7 @@ void ReflectionProbeGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, in
}
void ReflectionProbeGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
- ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node());
+ ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_node_3d());
AABB restore = p_restore;
@@ -3512,7 +3512,7 @@ void ReflectionProbeGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo,
}
void ReflectionProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node());
+ ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -3609,12 +3609,12 @@ String DecalGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p
}
Variant DecalGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node());
+ Decal *decal = Object::cast_to<Decal>(p_gizmo->get_node_3d());
return decal->get_extents();
}
void DecalGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
- Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node());
+ Decal *decal = Object::cast_to<Decal>(p_gizmo->get_node_3d());
Transform3D gt = decal->get_global_transform();
Transform3D gi = gt.affine_inverse();
@@ -3645,7 +3645,7 @@ void DecalGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bo
}
void DecalGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
- Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node());
+ Decal *decal = Object::cast_to<Decal>(p_gizmo->get_node_3d());
Vector3 restore = p_restore;
@@ -3662,7 +3662,7 @@ void DecalGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id,
}
void DecalGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node());
+ Decal *decal = Object::cast_to<Decal>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -3749,12 +3749,12 @@ String VoxelGIGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int
}
Variant VoxelGIGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_spatial_node());
+ VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_node_3d());
return probe->get_extents();
}
void VoxelGIGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
- VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_spatial_node());
+ VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_node_3d());
Transform3D gt = probe->get_global_transform();
Transform3D gi = gt.affine_inverse();
@@ -3785,7 +3785,7 @@ void VoxelGIGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id,
}
void VoxelGIGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
- VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_spatial_node());
+ VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_node_3d());
Vector3 restore = p_restore;
@@ -3802,7 +3802,7 @@ void VoxelGIGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_i
}
void VoxelGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_spatial_node());
+ VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_node_3d());
Ref<Material> material = get_material("voxel_gi_material", p_gizmo);
Ref<Material> icon = get_material("voxel_gi_icon", p_gizmo);
@@ -3913,7 +3913,7 @@ int LightmapGIGizmoPlugin::get_priority() const {
void LightmapGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Ref<Material> icon = get_material("baked_indirect_light_icon", p_gizmo);
- LightmapGI *baker = Object::cast_to<LightmapGI>(p_gizmo->get_spatial_node());
+ LightmapGI *baker = Object::cast_to<LightmapGI>(p_gizmo->get_node_3d());
Ref<LightmapGIData> data = baker->get_light_data();
p_gizmo->add_unscaled_billboard(icon, 0.05);
@@ -4163,13 +4163,13 @@ int CollisionObject3DGizmoPlugin::get_priority() const {
}
void CollisionObject3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_gizmo->get_spatial_node());
+ CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
- List<uint32_t> owners;
- co->get_shape_owners(&owners);
- for (uint32_t &owner_id : owners) {
+ List<uint32_t> owner_ids;
+ co->get_shape_owners(&owner_ids);
+ for (uint32_t &owner_id : owner_ids) {
Transform3D xform = co->shape_owner_get_transform(owner_id);
Object *owner = co->shape_owner_get_owner(owner_id);
// Exclude CollisionShape3D and CollisionPolygon3D as they have their gizmo.
@@ -4214,7 +4214,7 @@ int CollisionShape3DGizmoPlugin::get_priority() const {
}
String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- const CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node());
+ const CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_node_3d());
Ref<Shape3D> s = cs->get_shape();
if (s.is_null()) {
@@ -4245,7 +4245,7 @@ String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_g
}
Variant CollisionShape3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node());
+ CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_node_3d());
Ref<Shape3D> s = cs->get_shape();
if (s.is_null()) {
@@ -4281,7 +4281,7 @@ Variant CollisionShape3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p
}
void CollisionShape3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
- CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node());
+ CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_node_3d());
Ref<Shape3D> s = cs->get_shape();
if (s.is_null()) {
@@ -4395,7 +4395,7 @@ void CollisionShape3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, i
}
void CollisionShape3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
- CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node());
+ CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_node_3d());
Ref<Shape3D> s = cs->get_shape();
if (s.is_null()) {
@@ -4499,7 +4499,7 @@ void CollisionShape3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo
}
void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node());
+ CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -4814,7 +4814,7 @@ int CollisionPolygon3DGizmoPlugin::get_priority() const {
}
void CollisionPolygon3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- CollisionPolygon3D *polygon = Object::cast_to<CollisionPolygon3D>(p_gizmo->get_spatial_node());
+ CollisionPolygon3D *polygon = Object::cast_to<CollisionPolygon3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -4861,7 +4861,7 @@ int NavigationRegion3DGizmoPlugin::get_priority() const {
}
void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- NavigationRegion3D *navigationregion = Object::cast_to<NavigationRegion3D>(p_gizmo->get_spatial_node());
+ NavigationRegion3D *navigationregion = Object::cast_to<NavigationRegion3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
Ref<NavigationMesh> navigationmesh = navigationregion->get_navigation_mesh();
@@ -5021,7 +5021,7 @@ int NavigationLink3DGizmoPlugin::get_priority() const {
}
void NavigationLink3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- NavigationLink3D *link = Object::cast_to<NavigationLink3D>(p_gizmo->get_spatial_node());
+ NavigationLink3D *link = Object::cast_to<NavigationLink3D>(p_gizmo->get_node_3d());
RID nav_map = link->get_world_3d()->get_navigation_map();
real_t search_radius = NavigationServer3D::get_singleton()->map_get_link_connection_radius(nav_map);
@@ -5106,12 +5106,12 @@ String NavigationLink3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_g
}
Variant NavigationLink3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- NavigationLink3D *link = Object::cast_to<NavigationLink3D>(p_gizmo->get_spatial_node());
+ NavigationLink3D *link = Object::cast_to<NavigationLink3D>(p_gizmo->get_node_3d());
return p_id == 0 ? link->get_start_location() : link->get_end_location();
}
void NavigationLink3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
- NavigationLink3D *link = Object::cast_to<NavigationLink3D>(p_gizmo->get_spatial_node());
+ NavigationLink3D *link = Object::cast_to<NavigationLink3D>(p_gizmo->get_node_3d());
Transform3D gt = link->get_global_transform();
Transform3D gi = gt.affine_inverse();
@@ -5144,7 +5144,7 @@ void NavigationLink3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, i
}
void NavigationLink3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
- NavigationLink3D *link = Object::cast_to<NavigationLink3D>(p_gizmo->get_spatial_node());
+ NavigationLink3D *link = Object::cast_to<NavigationLink3D>(p_gizmo->get_node_3d());
if (p_cancel) {
if (p_id == 0) {
@@ -5444,7 +5444,7 @@ int Joint3DGizmoPlugin::get_priority() const {
}
void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- Joint3D *joint = Object::cast_to<Joint3D>(p_gizmo->get_spatial_node());
+ Joint3D *joint = Object::cast_to<Joint3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
@@ -5877,11 +5877,11 @@ String FogVolumeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, i
}
Variant FogVolumeGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- return Vector3(p_gizmo->get_spatial_node()->call("get_extents"));
+ return Vector3(p_gizmo->get_node_3d()->call("get_extents"));
}
void FogVolumeGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
- Node3D *sn = p_gizmo->get_spatial_node();
+ Node3D *sn = p_gizmo->get_node_3d();
Transform3D gt = sn->get_global_transform();
Transform3D gi = gt.affine_inverse();
@@ -5910,7 +5910,7 @@ void FogVolumeGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id
}
void FogVolumeGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
- Node3D *sn = p_gizmo->get_spatial_node();
+ Node3D *sn = p_gizmo->get_node_3d();
if (p_cancel) {
sn->call("set_extents", p_restore);
@@ -5925,11 +5925,11 @@ void FogVolumeGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p
}
void FogVolumeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- Node3D *cs = p_gizmo->get_spatial_node();
+ Node3D *cs = p_gizmo->get_node_3d();
p_gizmo->clear();
- if (RS::FogVolumeShape(int(p_gizmo->get_spatial_node()->call("get_shape"))) != RS::FOG_VOLUME_SHAPE_WORLD) {
+ if (RS::FogVolumeShape(int(p_gizmo->get_node_3d()->call("get_shape"))) != RS::FOG_VOLUME_SHAPE_WORLD) {
const Ref<Material> material =
get_material("shape_material", p_gizmo);
const Ref<Material> material_internal =
diff --git a/editor/plugins/node_3d_editor_gizmos.h b/editor/plugins/node_3d_editor_gizmos.h
index 5924f8571a..b642e1024a 100644
--- a/editor/plugins/node_3d_editor_gizmos.h
+++ b/editor/plugins/node_3d_editor_gizmos.h
@@ -72,7 +72,7 @@ class EditorNode3DGizmo : public Node3DGizmo {
Vector<Instance> instances;
Node3D *spatial_node = nullptr;
- void _set_spatial_node(Node *p_node) { set_spatial_node(Object::cast_to<Node3D>(p_node)); }
+ void _set_node_3d(Node *p_node) { set_node_3d(Object::cast_to<Node3D>(p_node)); }
protected:
static void _bind_methods();
@@ -116,8 +116,8 @@ public:
void set_selected(bool p_selected) { selected = p_selected; }
bool is_selected() const { return selected; }
- void set_spatial_node(Node3D *p_node);
- Node3D *get_spatial_node() const { return spatial_node; }
+ void set_node_3d(Node3D *p_node);
+ Node3D *get_node_3d() const { return spatial_node; }
Ref<EditorNode3DGizmoPlugin> get_plugin() const { return gizmo_plugin; }
bool intersect_frustum(const Camera3D *p_camera, const Vector<Plane> &p_frustum);
void handles_intersect_ray(Camera3D *p_camera, const Vector2 &p_point, bool p_shift_pressed, int &r_id, bool &r_secondary);
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 33aad0ac61..4d3ffdc12b 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -1356,7 +1356,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
EditorNode *en = EditorNode::get_singleton();
EditorPluginList *force_input_forwarding_list = en->get_editor_plugins_force_input_forwarding();
if (!force_input_forwarding_list->is_empty()) {
- EditorPlugin::AfterGUIInput discard = force_input_forwarding_list->forward_spatial_gui_input(camera, p_event, true);
+ EditorPlugin::AfterGUIInput discard = force_input_forwarding_list->forward_3d_gui_input(camera, p_event, true);
if (discard == EditorPlugin::AFTER_GUI_INPUT_STOP) {
return;
}
@@ -1369,7 +1369,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
EditorNode *en = EditorNode::get_singleton();
EditorPluginList *over_plugin_list = en->get_editor_plugins_over();
if (!over_plugin_list->is_empty()) {
- EditorPlugin::AfterGUIInput discard = over_plugin_list->forward_spatial_gui_input(camera, p_event, false);
+ EditorPlugin::AfterGUIInput discard = over_plugin_list->forward_3d_gui_input(camera, p_event, false);
if (discard == EditorPlugin::AFTER_GUI_INPUT_STOP) {
return;
}
@@ -2400,6 +2400,9 @@ void Node3DEditorViewport::_project_settings_changed() {
const bool use_taa = GLOBAL_GET("rendering/anti_aliasing/quality/use_taa");
viewport->set_use_taa(use_taa);
+ const bool transparent_background = GLOBAL_GET("rendering/transparent_background");
+ viewport->set_transparent_background(transparent_background);
+
const bool use_debanding = GLOBAL_GET("rendering/anti_aliasing/quality/use_debanding");
viewport->set_use_debanding(use_debanding);
@@ -2429,11 +2432,11 @@ void Node3DEditorViewport::_notification(int p_what) {
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
- bool visible = is_visible_in_tree();
+ bool vp_visible = is_visible_in_tree();
- set_process(visible);
+ set_process(vp_visible);
- if (visible) {
+ if (vp_visible) {
orthogonal = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL));
_update_name();
_update_camera(0);
@@ -2735,12 +2738,12 @@ static void draw_indicator_bar(Control &p_surface, real_t p_fill, const Ref<Text
void Node3DEditorViewport::_draw() {
EditorPluginList *over_plugin_list = EditorNode::get_singleton()->get_editor_plugins_over();
if (!over_plugin_list->is_empty()) {
- over_plugin_list->forward_spatial_draw_over_viewport(surface);
+ over_plugin_list->forward_3d_draw_over_viewport(surface);
}
EditorPluginList *force_over_plugin_list = EditorNode::get_singleton()->get_editor_plugins_force_over();
if (!force_over_plugin_list->is_empty()) {
- force_over_plugin_list->forward_spatial_force_draw_over_viewport(surface);
+ force_over_plugin_list->forward_3d_force_draw_over_viewport(surface);
}
if (surface->has_focus()) {
@@ -3880,8 +3883,8 @@ bool Node3DEditorViewport::_apply_preview_material(ObjectID p_target, const Poin
Vector3 xform_ray = ai.basis.xform(world_ray).normalized();
Vector3 xform_pos = ai.xform(world_pos);
- for (int surface = 0; surface < surface_count; surface++) {
- Ref<TriangleMesh> surface_mesh = mesh->generate_surface_triangle_mesh(surface);
+ for (int surface_idx = 0; surface_idx < surface_count; surface_idx++) {
+ Ref<TriangleMesh> surface_mesh = mesh->generate_surface_triangle_mesh(surface_idx);
Vector3 rpos, rnorm;
if (surface_mesh->intersect_ray(xform_pos, xform_ray, rpos, rnorm)) {
@@ -3894,7 +3897,7 @@ bool Node3DEditorViewport::_apply_preview_material(ObjectID p_target, const Poin
}
if (dist < closest_dist) {
- closest_surface = surface;
+ closest_surface = surface_idx;
closest_dist = dist;
}
}
@@ -4020,16 +4023,16 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po
Node3D *node3d = Object::cast_to<Node3D>(instantiated_scene);
if (node3d) {
- Transform3D global_transform;
+ Transform3D gl_transform;
Node3D *parent_node3d = Object::cast_to<Node3D>(parent);
if (parent_node3d) {
- global_transform = parent_node3d->get_global_gizmo_transform();
+ gl_transform = parent_node3d->get_global_gizmo_transform();
}
- global_transform.origin = spatial_editor->snap_point(_get_instance_position(p_point));
- global_transform.basis *= node3d->get_transform().basis;
+ gl_transform.origin = spatial_editor->snap_point(_get_instance_position(p_point));
+ gl_transform.basis *= node3d->get_transform().basis;
- editor_data->get_undo_redo()->add_do_method(instantiated_scene, "set_global_transform", global_transform);
+ editor_data->get_undo_redo()->add_do_method(instantiated_scene, "set_global_transform", gl_transform);
}
return true;
@@ -4163,8 +4166,8 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant
}
if (can_instantiate) {
- Transform3D global_transform = Transform3D(Basis(), _get_instance_position(p_point));
- preview_node->set_global_transform(global_transform);
+ Transform3D gl_transform = Transform3D(Basis(), _get_instance_position(p_point));
+ preview_node->set_global_transform(gl_transform);
return true;
}
@@ -4773,10 +4776,9 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p
view_menu->get_popup()->connect("id_pressed", callable_mp(this, &Node3DEditorViewport::_menu_option));
display_submenu->connect("id_pressed", callable_mp(this, &Node3DEditorViewport::_menu_option));
view_menu->set_disable_shortcuts(true);
-#ifndef _MSC_VER
-#warning this needs to be fixed
-#endif
- //if (OS::get_singleton()->get_current_video_driver() == OS::VIDEO_DRIVER_GLES2) {
+
+ // TODO: Re-evaluate with new OpenGL3 renderer, and implement.
+ //if (OS::get_singleton()->get_current_video_driver() == OS::RENDERING_DRIVER_OPENGL3) {
if (false) {
// Alternate display modes only work when using the Vulkan renderer; make this explicit.
const int normal_idx = view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL);
diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp
index adfaf11264..d7953bf4e0 100644
--- a/editor/plugins/path_3d_editor_plugin.cpp
+++ b/editor/plugins/path_3d_editor_plugin.cpp
@@ -264,45 +264,45 @@ void Path3DGizmo::redraw() {
if (Path3DEditorPlugin::singleton->get_edited_path() == path) {
v3p.clear();
- Vector<Vector3> handles;
- Vector<Vector3> sec_handles;
+ Vector<Vector3> handle_points;
+ Vector<Vector3> sec_handle_points;
for (int i = 0; i < c->get_point_count(); i++) {
Vector3 p = c->get_point_position(i);
- handles.push_back(p);
+ handle_points.push_back(p);
// push Out points first so they get selected if the In and Out points are on top of each other.
if (i < c->get_point_count() - 1) {
v3p.push_back(p);
v3p.push_back(p + c->get_point_out(i));
- sec_handles.push_back(p + c->get_point_out(i));
+ sec_handle_points.push_back(p + c->get_point_out(i));
}
if (i > 0) {
v3p.push_back(p);
v3p.push_back(p + c->get_point_in(i));
- sec_handles.push_back(p + c->get_point_in(i));
+ sec_handle_points.push_back(p + c->get_point_in(i));
}
}
if (v3p.size() > 1) {
add_lines(v3p, path_thin_material);
}
- if (handles.size()) {
- add_handles(handles, handles_material);
+ if (handle_points.size()) {
+ add_handles(handle_points, handles_material);
}
- if (sec_handles.size()) {
- add_handles(sec_handles, sec_handles_material, Vector<int>(), false, true);
+ if (sec_handle_points.size()) {
+ add_handles(sec_handle_points, sec_handles_material, Vector<int>(), false, true);
}
}
}
Path3DGizmo::Path3DGizmo(Path3D *p_path) {
path = p_path;
- set_spatial_node(p_path);
+ set_node_3d(p_path);
orig_in_length = 0;
orig_out_length = 0;
}
-EditorPlugin::AfterGUIInput Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
+EditorPlugin::AfterGUIInput Path3DEditorPlugin::forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
if (!path) {
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
diff --git a/editor/plugins/path_3d_editor_plugin.h b/editor/plugins/path_3d_editor_plugin.h
index 53e4e2efa8..11a640b79f 100644
--- a/editor/plugins/path_3d_editor_plugin.h
+++ b/editor/plugins/path_3d_editor_plugin.h
@@ -101,7 +101,7 @@ public:
Path3D *get_edited_path() { return path; }
static Path3DEditorPlugin *singleton;
- virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) override;
+ virtual EditorPlugin::AfterGUIInput forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) override;
virtual String get_name() const override { return "Path3D"; }
bool has_main_screen() const override { return false; }
diff --git a/editor/plugins/polygon_3d_editor_plugin.cpp b/editor/plugins/polygon_3d_editor_plugin.cpp
index 2b3a5c3e23..dc6ae6be96 100644
--- a/editor/plugins/polygon_3d_editor_plugin.cpp
+++ b/editor/plugins/polygon_3d_editor_plugin.cpp
@@ -109,7 +109,7 @@ void Polygon3DEditor::_wip_close() {
undo_redo->commit_action();
}
-EditorPlugin::AfterGUIInput Polygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
+EditorPlugin::AfterGUIInput Polygon3DEditor::forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
if (!node) {
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
diff --git a/editor/plugins/polygon_3d_editor_plugin.h b/editor/plugins/polygon_3d_editor_plugin.h
index 0eb02a39e2..918072b429 100644
--- a/editor/plugins/polygon_3d_editor_plugin.h
+++ b/editor/plugins/polygon_3d_editor_plugin.h
@@ -90,7 +90,7 @@ protected:
static void _bind_methods();
public:
- virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event);
+ virtual EditorPlugin::AfterGUIInput forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event);
void edit(Node *p_node);
Polygon3DEditor();
~Polygon3DEditor();
@@ -102,7 +102,7 @@ class Polygon3DEditorPlugin : public EditorPlugin {
Polygon3DEditor *polygon_editor = nullptr;
public:
- virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) override { return polygon_editor->forward_spatial_gui_input(p_camera, p_event); }
+ virtual EditorPlugin::AfterGUIInput forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) override { return polygon_editor->forward_3d_gui_input(p_camera, p_event); }
virtual String get_name() const override { return "Polygon3DEditor"; }
bool has_main_screen() const override { return false; }
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index f70f0dc0aa..876ef3bae9 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -128,12 +128,12 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
}
}
- const Ref<Script> script = _get_edited_resource();
- if (script.is_valid()) {
+ const Ref<Script> scr = _get_edited_resource();
+ if (scr.is_valid()) {
/* Core types. */
const Color basetype_color = EDITOR_GET("text_editor/theme/highlighting/base_type_color");
List<String> core_types;
- script->get_language()->get_core_type_words(&core_types);
+ scr->get_language()->get_core_type_words(&core_types);
for (const String &E : core_types) {
highlighter->add_keyword_color(E, basetype_color);
}
@@ -142,9 +142,9 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
const Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
const Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color");
List<String> keywords;
- script->get_language()->get_reserved_words(&keywords);
+ scr->get_language()->get_reserved_words(&keywords);
for (const String &E : keywords) {
- if (script->get_language()->is_control_flow_keyword(E)) {
+ if (scr->get_language()->is_control_flow_keyword(E)) {
highlighter->add_keyword_color(E, control_flow_keyword_color);
} else {
highlighter->add_keyword_color(E, keyword_color);
@@ -153,19 +153,19 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
/* Member types. */
const Color member_variable_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color");
- StringName instance_base = script->get_instance_base_type();
+ StringName instance_base = scr->get_instance_base_type();
if (instance_base != StringName()) {
List<PropertyInfo> plist;
ClassDB::get_property_list(instance_base, &plist);
for (const PropertyInfo &E : plist) {
- String name = E.name;
+ String prop_name = E.name;
if (E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP) {
continue;
}
- if (name.contains("/")) {
+ if (prop_name.contains("/")) {
continue;
}
- highlighter->add_member_keyword_color(name, member_variable_color);
+ highlighter->add_member_keyword_color(prop_name, member_variable_color);
}
List<String> clist;
@@ -178,7 +178,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
/* Comments */
const Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
List<String> comments;
- script->get_language()->get_comment_delimiters(&comments);
+ scr->get_language()->get_comment_delimiters(&comments);
for (const String &comment : comments) {
String beg = comment.get_slice(" ", 0);
String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String();
@@ -188,7 +188,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
/* Strings */
const Color string_color = EDITOR_GET("text_editor/theme/highlighting/string_color");
List<String> strings;
- script->get_language()->get_string_delimiters(&strings);
+ scr->get_language()->get_string_delimiters(&strings);
for (const String &string : strings) {
String beg = string.get_slice(" ", 0);
String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String();
@@ -431,8 +431,8 @@ void ScriptEditor::_goto_script_line2(int p_line) {
}
void ScriptEditor::_goto_script_line(Ref<RefCounted> p_script, int p_line) {
- Ref<Script> script = Object::cast_to<Script>(*p_script);
- if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) {
+ Ref<Script> scr = Object::cast_to<Script>(*p_script);
+ if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) {
if (edit(p_script, p_line, 0)) {
EditorNode::get_singleton()->push_item(p_script.ptr());
@@ -447,15 +447,15 @@ void ScriptEditor::_goto_script_line(Ref<RefCounted> p_script, int p_line) {
}
void ScriptEditor::_set_execution(Ref<RefCounted> p_script, int p_line) {
- Ref<Script> script = Object::cast_to<Script>(*p_script);
- if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) {
+ Ref<Script> scr = Object::cast_to<Script>(*p_script);
+ if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) {
for (int i = 0; i < tab_container->get_tab_count(); i++) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
if (!se) {
continue;
}
- if ((script != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) {
+ if ((scr != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == scr->get_path()) {
se->set_executing_line(p_line);
}
}
@@ -463,15 +463,15 @@ void ScriptEditor::_set_execution(Ref<RefCounted> p_script, int p_line) {
}
void ScriptEditor::_clear_execution(Ref<RefCounted> p_script) {
- Ref<Script> script = Object::cast_to<Script>(*p_script);
- if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) {
+ Ref<Script> scr = Object::cast_to<Script>(*p_script);
+ if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) {
for (int i = 0; i < tab_container->get_tab_count(); i++) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
if (!se) {
continue;
}
- if ((script != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) {
+ if ((scr != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == scr->get_path()) {
se->clear_executing_line();
}
}
@@ -479,19 +479,19 @@ void ScriptEditor::_clear_execution(Ref<RefCounted> p_script) {
}
void ScriptEditor::_set_breakpoint(Ref<RefCounted> p_script, int p_line, bool p_enabled) {
- Ref<Script> script = Object::cast_to<Script>(*p_script);
- if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) {
+ Ref<Script> scr = Object::cast_to<Script>(*p_script);
+ if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) {
// Update if open.
for (int i = 0; i < tab_container->get_tab_count(); i++) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
- if (se && se->get_edited_resource()->get_path() == script->get_path()) {
+ if (se && se->get_edited_resource()->get_path() == scr->get_path()) {
se->set_breakpoint(p_line, p_enabled);
return;
}
}
// Handle closed.
- Dictionary state = script_editor_cache->get_value(script->get_path(), "state");
+ Dictionary state = script_editor_cache->get_value(scr->get_path(), "state");
Array breakpoints;
if (state.has("breakpoints")) {
breakpoints = state["breakpoints"];
@@ -505,8 +505,8 @@ void ScriptEditor::_set_breakpoint(Ref<RefCounted> p_script, int p_line, bool p_
breakpoints.push_back(p_line);
}
state["breakpoints"] = breakpoints;
- script_editor_cache->set_value(script->get_path(), "state", state);
- EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), p_line + 1, false);
+ script_editor_cache->set_value(scr->get_path(), "state", state);
+ EditorDebuggerNode::get_singleton()->set_breakpoint(scr->get_path(), p_line + 1, false);
}
}
@@ -566,7 +566,7 @@ void ScriptEditor::_save_history() {
Node *n = tab_container->get_current_tab_control();
if (Object::cast_to<ScriptEditorBase>(n)) {
- history.write[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state();
+ history.write[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_navigation_state();
}
if (Object::cast_to<EditorHelp>(n)) {
history.write[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll();
@@ -601,7 +601,7 @@ void ScriptEditor::_go_to_tab(int p_idx) {
Node *n = tab_container->get_current_tab_control();
if (Object::cast_to<ScriptEditorBase>(n)) {
- history.write[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state();
+ history.write[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_navigation_state();
}
if (Object::cast_to<EditorHelp>(n)) {
history.write[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll();
@@ -627,9 +627,9 @@ void ScriptEditor::_go_to_tab(int p_idx) {
Object::cast_to<ScriptEditorBase>(c)->ensure_focus();
}
- Ref<Script> script = Object::cast_to<ScriptEditorBase>(c)->get_edited_resource();
- if (script != nullptr) {
- notify_script_changed(script);
+ Ref<Script> scr = Object::cast_to<ScriptEditorBase>(c)->get_edited_resource();
+ if (scr != nullptr) {
+ notify_script_changed(scr);
}
Object::cast_to<ScriptEditorBase>(c)->validate();
@@ -705,9 +705,9 @@ void ScriptEditor::_open_recent_script(int p_idx) {
ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
if (extensions.find(path.get_extension())) {
- Ref<Script> script = ResourceLoader::load(path);
- if (script.is_valid()) {
- edit(script, true);
+ Ref<Script> scr = ResourceLoader::load(path);
+ if (scr.is_valid()) {
+ edit(scr, true);
return;
}
}
@@ -729,9 +729,9 @@ void ScriptEditor::_open_recent_script(int p_idx) {
} else {
EditorNode::get_singleton()->load_resource(res_path);
}
- Ref<Script> script = ResourceLoader::load(path);
- if (script.is_valid()) {
- edit(script, true);
+ Ref<Script> scr = ResourceLoader::load(path);
+ if (scr.is_valid()) {
+ edit(scr, true);
return;
}
} else if (!path.is_resource_file()) {
@@ -774,9 +774,9 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
previous_scripts.push_back(file->get_path());
}
- Ref<Script> script = file;
- if (script.is_valid()) {
- notify_script_close(script);
+ Ref<Script> scr = file;
+ if (scr.is_valid()) {
+ notify_script_close(scr);
}
}
}
@@ -851,8 +851,8 @@ void ScriptEditor::_close_docs_tab() {
void ScriptEditor::_copy_script_path() {
ScriptEditorBase *se = _get_current_editor();
if (se) {
- Ref<Resource> script = se->get_edited_resource();
- DisplayServer::get_singleton()->clipboard_set(script->get_path());
+ Ref<Resource> scr = se->get_edited_resource();
+ DisplayServer::get_singleton()->clipboard_set(scr->get_path());
}
}
@@ -908,9 +908,9 @@ void ScriptEditor::_resave_scripts(const String &p_str) {
continue;
}
- Ref<Resource> script = se->get_edited_resource();
+ Ref<Resource> scr = se->get_edited_resource();
- if (script->is_built_in()) {
+ if (scr->is_built_in()) {
continue; //internal script, who cares
}
@@ -928,13 +928,13 @@ void ScriptEditor::_resave_scripts(const String &p_str) {
}
}
- Ref<TextFile> text_file = script;
+ Ref<TextFile> text_file = scr;
if (text_file != nullptr) {
se->apply_code();
_save_text_file(text_file, text_file->get_path());
break;
} else {
- EditorNode::get_singleton()->save_resource(script);
+ EditorNode::get_singleton()->save_resource(scr);
}
se->tag_saved_version();
}
@@ -949,9 +949,9 @@ void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) {
continue;
}
- Ref<Resource> script = se->get_edited_resource();
+ Ref<Resource> scr = se->get_edited_resource();
- if (script == p_res) {
+ if (scr == p_res) {
se->tag_saved_version();
}
}
@@ -1106,8 +1106,8 @@ Ref<Script> ScriptEditor::_get_current_script() {
ScriptEditorBase *current = _get_current_editor();
if (current) {
- Ref<Script> script = current->get_edited_resource();
- return script != nullptr ? script : nullptr;
+ Ref<Script> scr = current->get_edited_resource();
+ return scr != nullptr ? scr : nullptr;
} else {
return nullptr;
}
@@ -1284,7 +1284,7 @@ void ScriptEditor::_menu_option(int p_option) {
Ref<Resource> resource = current->get_edited_resource();
Ref<TextFile> text_file = resource;
- Ref<Script> script = resource;
+ Ref<Script> scr = resource;
if (text_file != nullptr) {
file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
@@ -1301,26 +1301,15 @@ void ScriptEditor::_menu_option(int p_option) {
break;
}
- if (script != nullptr) {
- Vector<DocData::ClassDoc> documentations = script->get_documentation();
- for (int j = 0; j < documentations.size(); j++) {
- const DocData::ClassDoc &doc = documentations.get(j);
- if (EditorHelp::get_doc_data()->has_doc(doc.name)) {
- EditorHelp::get_doc_data()->remove_doc(doc.name);
- }
- }
+ if (scr.is_valid()) {
+ clear_docs_from_script(scr);
}
EditorNode::get_singleton()->push_item(resource.ptr());
EditorNode::get_singleton()->save_resource_as(resource);
- if (script != nullptr) {
- Vector<DocData::ClassDoc> documentations = script->get_documentation();
- for (int j = 0; j < documentations.size(); j++) {
- const DocData::ClassDoc &doc = documentations.get(j);
- EditorHelp::get_doc_data()->add_doc(doc);
- update_doc(doc.name);
- }
+ if (scr.is_valid()) {
+ update_docs_from_script(scr);
}
} break;
@@ -1378,18 +1367,18 @@ void ScriptEditor::_menu_option(int p_option) {
_copy_script_path();
} break;
case SHOW_IN_FILE_SYSTEM: {
- const Ref<Resource> script = current->get_edited_resource();
- String path = script->get_path();
+ const Ref<Resource> scr = current->get_edited_resource();
+ String path = scr->get_path();
if (!path.is_empty()) {
- if (script->is_built_in()) {
+ if (scr->is_built_in()) {
path = path.get_slice("::", 0); // Show the scene instead.
}
FileSystemDock *file_system_dock = FileSystemDock::get_singleton();
file_system_dock->navigate_to_path(path);
// Ensure that the FileSystem dock is visible.
- TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control();
- tab_container->set_current_tab(tab_container->get_tab_idx_from_control(file_system_dock));
+ TabContainer *dock_tab_container = (TabContainer *)file_system_dock->get_parent_control();
+ dock_tab_container->set_current_tab(dock_tab_container->get_tab_idx_from_control(file_system_dock));
}
} break;
case CLOSE_DOCS: {
@@ -1646,12 +1635,12 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
if (se) {
- Ref<Script> script = se->get_edited_resource();
- if (script == nullptr || !script.is_valid()) {
+ Ref<Script> scr = se->get_edited_resource();
+ if (scr == nullptr || !scr.is_valid()) {
continue;
}
- if (script->is_built_in() && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed
+ if (scr->is_built_in() && scr->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed
_close_tab(i, false);
i--;
}
@@ -1679,12 +1668,12 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) {
continue;
}
- Ref<Script> script = se->get_edited_resource();
- if (script == nullptr) {
+ Ref<Script> scr = se->get_edited_resource();
+ if (scr == nullptr) {
continue;
}
- String base = script->get_path();
+ String base = scr->get_path();
loaded_scripts.insert(base);
if (base.begins_with("local://") || base.is_empty()) {
continue;
@@ -2195,20 +2184,20 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col,
return false;
}
- Ref<Script> script = p_resource;
+ Ref<Script> scr = p_resource;
// Don't open dominant script if using an external editor.
bool use_external_editor =
EditorSettings::get_singleton()->get("text_editor/external/use_external_editor") ||
- (script.is_valid() && script->get_language()->overrides_external_editor());
- use_external_editor = use_external_editor && !(script.is_valid() && script->is_built_in()); // Ignore external editor for built-in scripts.
+ (scr.is_valid() && scr->get_language()->overrides_external_editor());
+ use_external_editor = use_external_editor && !(scr.is_valid() && scr->is_built_in()); // Ignore external editor for built-in scripts.
const bool open_dominant = EditorSettings::get_singleton()->get("text_editor/behavior/files/open_dominant_script_on_scene_change");
const bool should_open = (open_dominant && !use_external_editor) || !EditorNode::get_singleton()->is_changing_scene();
- if (script.is_valid() && script->get_language()->overrides_external_editor()) {
+ if (scr.is_valid() && scr->get_language()->overrides_external_editor()) {
if (should_open) {
- Error err = script->get_language()->open_in_external_editor(script, p_line >= 0 ? p_line : 0, p_col);
+ Error err = scr->get_language()->open_in_external_editor(scr, p_line >= 0 ? p_line : 0, p_col);
if (err != OK) {
ERR_PRINT("Couldn't open script in the overridden external text editor");
}
@@ -2282,7 +2271,7 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col,
continue;
}
- if ((script != nullptr && se->get_edited_resource() == p_resource) || se->get_edited_resource()->get_path() == p_resource->get_path()) {
+ if ((scr != nullptr && se->get_edited_resource() == p_resource) || se->get_edited_resource()->get_path() == p_resource->get_path()) {
if (should_open) {
se->enable_editor();
@@ -2327,9 +2316,9 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col,
}
se->add_syntax_highlighter(highlighter);
- if (script != nullptr && !highlighter_set) {
+ if (scr != nullptr && !highlighter_set) {
PackedStringArray languages = highlighter->_get_supported_languages();
- if (languages.has(script->get_language()->get_name())) {
+ if (languages.has(scr->get_language()->get_name())) {
se->set_syntax_highlighter(highlighter);
highlighter_set = true;
}
@@ -2410,7 +2399,7 @@ void ScriptEditor::save_current_script() {
Ref<Resource> resource = current->get_edited_resource();
Ref<TextFile> text_file = resource;
- Ref<Script> script = resource;
+ Ref<Script> scr = resource;
if (text_file != nullptr) {
current->apply_code();
@@ -2418,14 +2407,8 @@ void ScriptEditor::save_current_script() {
return;
}
- if (script != nullptr) {
- Vector<DocData::ClassDoc> documentations = script->get_documentation();
- for (int j = 0; j < documentations.size(); j++) {
- const DocData::ClassDoc &doc = documentations.get(j);
- if (EditorHelp::get_doc_data()->has_doc(doc.name)) {
- EditorHelp::get_doc_data()->remove_doc(doc.name);
- }
- }
+ if (scr.is_valid()) {
+ clear_docs_from_script(scr);
}
if (resource->is_built_in()) {
@@ -2440,13 +2423,8 @@ void ScriptEditor::save_current_script() {
EditorNode::get_singleton()->save_resource(resource);
}
- if (script != nullptr) {
- Vector<DocData::ClassDoc> documentations = script->get_documentation();
- for (int j = 0; j < documentations.size(); j++) {
- const DocData::ClassDoc &doc = documentations.get(j);
- EditorHelp::get_doc_data()->add_doc(doc);
- update_doc(doc.name);
- }
+ if (scr.is_valid()) {
+ update_docs_from_script(scr);
}
}
@@ -2484,32 +2462,21 @@ void ScriptEditor::save_all_scripts() {
if (!edited_res->is_built_in()) {
Ref<TextFile> text_file = edited_res;
- Ref<Script> script = edited_res;
+ Ref<Script> scr = edited_res;
if (text_file != nullptr) {
_save_text_file(text_file, text_file->get_path());
continue;
}
- if (script != nullptr) {
- Vector<DocData::ClassDoc> documentations = script->get_documentation();
- for (int j = 0; j < documentations.size(); j++) {
- const DocData::ClassDoc &doc = documentations.get(j);
- if (EditorHelp::get_doc_data()->has_doc(doc.name)) {
- EditorHelp::get_doc_data()->remove_doc(doc.name);
- }
- }
+ if (scr.is_valid()) {
+ clear_docs_from_script(scr);
}
EditorNode::get_singleton()->save_resource(edited_res); //external script, save it
- if (script != nullptr) {
- Vector<DocData::ClassDoc> documentations = script->get_documentation();
- for (int j = 0; j < documentations.size(); j++) {
- const DocData::ClassDoc &doc = documentations.get(j);
- EditorHelp::get_doc_data()->add_doc(doc);
- update_doc(doc.name);
- }
+ if (scr.is_valid()) {
+ update_docs_from_script(scr);
}
} else {
// For built-in scripts, save their scenes instead.
@@ -2559,13 +2526,13 @@ void ScriptEditor::reload_scripts(bool p_refresh_only) {
continue;
}
- Ref<Script> script = edited_res;
- if (script != nullptr) {
- Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE);
- ERR_CONTINUE(!rel_script.is_valid());
- script->set_source_code(rel_script->get_source_code());
- script->set_last_modified_time(rel_script->get_last_modified_time());
- script->reload(true);
+ Ref<Script> scr = edited_res;
+ if (scr != nullptr) {
+ Ref<Script> rel_scr = ResourceLoader::load(scr->get_path(), scr->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE);
+ ERR_CONTINUE(!rel_scr.is_valid());
+ scr->set_source_code(rel_scr->get_source_code());
+ scr->set_last_modified_time(rel_scr->get_last_modified_time());
+ scr->reload(true);
}
Ref<TextFile> text_file = edited_res;
@@ -2638,17 +2605,17 @@ void ScriptEditor::_editor_stop() {
void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const PackedStringArray &p_args) {
ERR_FAIL_COND(!p_obj);
- Ref<Script> script = p_obj->get_script();
- ERR_FAIL_COND(!script.is_valid());
+ Ref<Script> scr = p_obj->get_script();
+ ERR_FAIL_COND(!scr.is_valid());
- EditorNode::get_singleton()->push_item(script.ptr());
+ EditorNode::get_singleton()->push_item(scr.ptr());
for (int i = 0; i < tab_container->get_tab_count(); i++) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
if (!se) {
continue;
}
- if (se->get_edited_resource() != script) {
+ if (se->get_edited_resource() != scr) {
continue;
}
@@ -2659,7 +2626,7 @@ void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const
script_list->select(script_list->find_metadata(i));
// Save the current script so the changes can be picked up by an external editor.
- if (!script.ptr()->is_built_in()) { // But only if it's not built-in script.
+ if (!scr.ptr()->is_built_in()) { // But only if it's not built-in script.
save_current_script();
}
@@ -3331,6 +3298,29 @@ void ScriptEditor::update_doc(const String &p_name) {
}
}
+void ScriptEditor::clear_docs_from_script(const Ref<Script> &p_script) {
+ ERR_FAIL_COND(p_script.is_null());
+
+ Vector<DocData::ClassDoc> documentations = p_script->get_documentation();
+ for (int j = 0; j < documentations.size(); j++) {
+ const DocData::ClassDoc &doc = documentations.get(j);
+ if (EditorHelp::get_doc_data()->has_doc(doc.name)) {
+ EditorHelp::get_doc_data()->remove_doc(doc.name);
+ }
+ }
+}
+
+void ScriptEditor::update_docs_from_script(const Ref<Script> &p_script) {
+ ERR_FAIL_COND(p_script.is_null());
+
+ Vector<DocData::ClassDoc> documentations = p_script->get_documentation();
+ for (int j = 0; j < documentations.size(); j++) {
+ const DocData::ClassDoc &doc = documentations.get(j);
+ EditorHelp::get_doc_data()->add_doc(doc);
+ update_doc(doc.name);
+ }
+}
+
void ScriptEditor::_update_selected_editor_menu() {
for (int i = 0; i < tab_container->get_tab_count(); i++) {
bool current = tab_container->get_current_tab() == i;
@@ -3370,7 +3360,7 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
Node *n = tab_container->get_current_tab_control();
if (Object::cast_to<ScriptEditorBase>(n)) {
- history.write[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state();
+ history.write[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_navigation_state();
}
if (Object::cast_to<EditorHelp>(n)) {
history.write[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll();
@@ -3381,13 +3371,14 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
n = history[history_pos].control;
- if (Object::cast_to<ScriptEditorBase>(n)) {
- Object::cast_to<ScriptEditorBase>(n)->set_edit_state(history[history_pos].state);
- Object::cast_to<ScriptEditorBase>(n)->ensure_focus();
+ ScriptEditorBase *seb = Object::cast_to<ScriptEditorBase>(n);
+ if (seb) {
+ seb->set_edit_state(history[history_pos].state);
+ seb->ensure_focus();
- Ref<Script> script = Object::cast_to<ScriptEditorBase>(n)->get_edited_resource();
- if (script != nullptr) {
- notify_script_changed(script);
+ Ref<Script> scr = seb->get_edited_resource();
+ if (scr != nullptr) {
+ notify_script_changed(scr);
}
}
@@ -3423,9 +3414,9 @@ Vector<Ref<Script>> ScriptEditor::get_open_scripts() const {
continue;
}
- Ref<Script> script = se->get_edited_resource();
- if (script != nullptr) {
- out_scripts.push_back(script);
+ Ref<Script> scr = se->get_edited_resource();
+ if (scr != nullptr) {
+ out_scripts.push_back(scr);
}
}
@@ -3476,9 +3467,9 @@ void ScriptEditor::_help_search(String p_text) {
}
void ScriptEditor::_open_script_request(const String &p_path) {
- Ref<Script> script = ResourceLoader::load(p_path);
- if (script.is_valid()) {
- script_editor->edit(script, false);
+ Ref<Script> scr = ResourceLoader::load(p_path);
+ if (scr.is_valid()) {
+ script_editor->edit(scr, false);
return;
}
@@ -3543,9 +3534,9 @@ void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_numb
EditorNode::get_singleton()->load_scene(fpath);
return;
} else {
- Ref<Script> script = res;
- if (script.is_valid()) {
- edit(script);
+ Ref<Script> scr = res;
+ if (scr.is_valid()) {
+ edit(scr);
ScriptTextEditor *ste = Object::cast_to<ScriptTextEditor>(_get_current_editor());
if (ste) {
@@ -3815,12 +3806,12 @@ ScriptEditor::ScriptEditor() {
script_search_menu->get_popup()->connect("id_pressed", callable_mp(this, &ScriptEditor::_menu_option));
menu_hb->add_child(script_search_menu);
- MenuButton *debug_menu = memnew(MenuButton);
- menu_hb->add_child(debug_menu);
- debug_menu->hide(); // Handled by EditorDebuggerNode below.
+ MenuButton *debug_menu_btn = memnew(MenuButton);
+ menu_hb->add_child(debug_menu_btn);
+ debug_menu_btn->hide(); // Handled by EditorDebuggerNode below.
EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton();
- debugger->set_script_debug_button(debug_menu);
+ debugger->set_script_debug_button(debug_menu_btn);
debugger->connect("goto_script_line", callable_mp(this, &ScriptEditor::_goto_script_line));
debugger->connect("set_execution", callable_mp(this, &ScriptEditor::_set_execution));
debugger->connect("clear_execution", callable_mp(this, &ScriptEditor::_clear_execution));
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 233baa9bd3..e69b8f8f82 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -146,6 +146,7 @@ public:
virtual bool is_unsaved() = 0;
virtual Variant get_edit_state() = 0;
virtual void set_edit_state(const Variant &p_state) = 0;
+ virtual Variant get_navigation_state() = 0;
virtual void goto_line(int p_line, bool p_with_error = false) = 0;
virtual void set_executing_line(int p_line) = 0;
virtual void clear_executing_line() = 0;
@@ -508,6 +509,8 @@ public:
void goto_help(const String &p_desc) { _help_class_goto(p_desc); }
void update_doc(const String &p_name);
+ void clear_docs_from_script(const Ref<Script> &p_script);
+ void update_docs_from_script(const Ref<Script> &p_script);
bool can_take_away_focus() const;
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index a1d24907e5..58a0160010 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -267,6 +267,7 @@ void ScriptTextEditor::_warning_clicked(Variant p_line) {
void ScriptTextEditor::_error_clicked(Variant p_line) {
if (p_line.get_type() == Variant::INT) {
+ code_editor->get_text_editor()->remove_secondary_carets();
code_editor->get_text_editor()->set_caret_line(p_line.operator int64_t());
}
}
@@ -295,6 +296,7 @@ void ScriptTextEditor::reload_text() {
void ScriptTextEditor::add_callback(const String &p_function, PackedStringArray p_args) {
String code = code_editor->get_text_editor()->get_text();
int pos = script->get_language()->find_function(p_function, code);
+ code_editor->get_text_editor()->remove_secondary_carets();
if (pos == -1) {
//does not exist
code_editor->get_text_editor()->deselect();
@@ -347,6 +349,10 @@ void ScriptTextEditor::set_edit_state(const Variant &p_state) {
}
}
+Variant ScriptTextEditor::get_navigation_state() {
+ return code_editor->get_navigation_state();
+}
+
void ScriptTextEditor::_convert_case(CodeTextEditor::CaseStyle p_case) {
code_editor->convert_case(p_case);
}
@@ -697,25 +703,25 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
}
for (const Ref<Script> &E : scripts) {
- Ref<Script> script = E;
+ Ref<Script> scr = E;
- if (p_for_script.is_valid() && p_for_script != script) {
+ if (p_for_script.is_valid() && p_for_script != scr) {
continue;
}
- if (script->is_built_in()) {
+ if (scr->is_built_in()) {
continue; //internal script, who cares, though weird
}
- uint64_t last_date = script->get_last_modified_time();
- uint64_t date = FileAccess::get_modified_time(script->get_path());
+ uint64_t last_date = scr->get_last_modified_time();
+ uint64_t date = FileAccess::get_modified_time(scr->get_path());
if (last_date != date) {
- Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE);
- ERR_CONTINUE(!rel_script.is_valid());
- script->set_source_code(rel_script->get_source_code());
- script->set_last_modified_time(rel_script->get_last_modified_time());
- script->update_exports();
+ Ref<Script> rel_scr = ResourceLoader::load(scr->get_path(), scr->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE);
+ ERR_CONTINUE(!rel_scr.is_valid());
+ scr->set_source_code(rel_scr->get_source_code());
+ scr->set_last_modified_time(rel_scr->get_last_modified_time());
+ scr->update_exports();
_trigger_live_script_reload();
}
@@ -976,10 +982,10 @@ void ScriptTextEditor::_update_connected_methods() {
Vector<Node *> nodes = _find_all_node_for_script(base, base, script);
HashSet<StringName> methods_found;
for (int i = 0; i < nodes.size(); i++) {
- List<Connection> connections;
- nodes[i]->get_signals_connected_to_this(&connections);
+ List<Connection> signal_connections;
+ nodes[i]->get_signals_connected_to_this(&signal_connections);
- for (const Connection &connection : connections) {
+ for (const Connection &connection : signal_connections) {
if (!(connection.flags & CONNECT_PERSIST)) {
continue;
}
@@ -1363,6 +1369,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
return;
}
+ tx->remove_secondary_carets();
int line = tx->get_caret_line();
// wrap around
@@ -1389,6 +1396,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
return;
}
+ tx->remove_secondary_carets();
int line = tx->get_caret_line();
// wrap around
if (line <= (int)bpoints[0]) {
@@ -1409,21 +1417,21 @@ void ScriptTextEditor::_edit_option(int p_op) {
} break;
case HELP_CONTEXTUAL: {
- String text = tx->get_selected_text();
+ String text = tx->get_selected_text(0);
if (text.is_empty()) {
- text = tx->get_word_under_caret();
+ text = tx->get_word_under_caret(0);
}
if (!text.is_empty()) {
emit_signal(SNAME("request_help"), text);
}
} break;
case LOOKUP_SYMBOL: {
- String text = tx->get_word_under_caret();
+ String text = tx->get_word_under_caret(0);
if (text.is_empty()) {
- text = tx->get_selected_text();
+ text = tx->get_selected_text(0);
}
if (!text.is_empty()) {
- _lookup_symbol(text, tx->get_caret_line(), tx->get_caret_column());
+ _lookup_symbol(text, tx->get_caret_line(0), tx->get_caret_column(0));
}
} break;
}
@@ -1601,6 +1609,7 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
int col = pos.x;
if (d.has("type") && String(d["type"]) == "resource") {
+ te->remove_secondary_carets();
Ref<Resource> res = d["resource"];
if (!res.is_valid()) {
return;
@@ -1618,6 +1627,7 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
}
if (d.has("type") && (String(d["type"]) == "files" || String(d["type"]) == "files_and_dirs")) {
+ te->remove_secondary_carets();
Array files = d["files"];
String text_to_drop;
@@ -1641,6 +1651,7 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
}
if (d.has("type") && String(d["type"]) == "nodes") {
+ te->remove_secondary_carets();
Node *scene_root = get_tree()->get_edited_scene_root();
if (!scene_root) {
EditorNode::get_singleton()->show_warning(TTR("Can't drop nodes without an open scene."));
@@ -1725,6 +1736,7 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
}
if (d.has("type") && String(d["type"]) == "obj_property") {
+ te->remove_secondary_carets();
const String text_to_drop = String(d["property"]).c_escape().quote(quote_style);
te->set_caret_line(row);
@@ -1745,8 +1757,8 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
local_pos = mb->get_global_position() - tx->get_global_position();
create_menu = true;
} else if (k.is_valid() && k->is_action("ui_menu", true)) {
- tx->adjust_viewport_to_caret();
- local_pos = tx->get_caret_draw_pos();
+ tx->adjust_viewport_to_caret(0);
+ local_pos = tx->get_caret_draw_pos(0);
create_menu = true;
}
@@ -1757,6 +1769,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
tx->set_move_caret_on_right_click_enabled(EditorSettings::get_singleton()->get("text_editor/behavior/navigation/move_caret_on_right_click"));
if (tx->is_move_caret_on_right_click_enabled()) {
+ tx->remove_secondary_carets();
if (tx->has_selection()) {
int from_line = tx->get_selection_from_line();
int to_line = tx->get_selection_to_line();
@@ -1776,10 +1789,10 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
String word_at_pos = tx->get_word_at_pos(local_pos);
if (word_at_pos.is_empty()) {
- word_at_pos = tx->get_word_under_caret();
+ word_at_pos = tx->get_word_under_caret(0);
}
if (word_at_pos.is_empty()) {
- word_at_pos = tx->get_selected_text();
+ word_at_pos = tx->get_selected_text(0);
}
bool has_color = (word_at_pos == "Color");
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index 99fafb2192..fb02e5c7c4 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -215,6 +215,7 @@ public:
virtual bool is_unsaved() override;
virtual Variant get_edit_state() override;
virtual void set_edit_state(const Variant &p_state) override;
+ virtual Variant get_navigation_state() override;
virtual void ensure_focus() override;
virtual void trim_trailing_whitespace() override;
virtual void insert_final_newline() override;
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index de1a807721..456c28d887 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -264,6 +264,9 @@ void ShaderEditorPlugin::_menu_item_pressed(int p_index) {
} else {
EditorNode::get_singleton()->save_resource(edited_shaders[index].shader_inc);
}
+ if (edited_shaders[index].shader_editor) {
+ edited_shaders[index].shader_editor->tag_saved_version();
+ }
} break;
case FILE_SAVE_AS: {
int index = shader_tabs->get_current_tab();
@@ -282,6 +285,9 @@ void ShaderEditorPlugin::_menu_item_pressed(int p_index) {
}
EditorNode::get_singleton()->save_resource_as(edited_shaders[index].shader_inc, path);
}
+ if (edited_shaders[index].shader_editor) {
+ edited_shaders[index].shader_editor->tag_saved_version();
+ }
} break;
case FILE_INSPECT: {
int index = shader_tabs->get_current_tab();
diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp
index 2478ac9514..83245366f9 100644
--- a/editor/plugins/skeleton_3d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_3d_editor_plugin.cpp
@@ -587,25 +587,25 @@ void Skeleton3DEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
void Skeleton3DEditor::move_skeleton_bone(NodePath p_skeleton_path, int32_t p_selected_boneidx, int32_t p_target_boneidx) {
Node *node = get_node_or_null(p_skeleton_path);
- Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(node);
- ERR_FAIL_NULL(skeleton);
+ Skeleton3D *skeleton_node = Object::cast_to<Skeleton3D>(node);
+ ERR_FAIL_NULL(skeleton_node);
Ref<EditorUndoRedoManager> &ur = EditorNode::get_undo_redo();
ur->create_action(TTR("Set Bone Parentage"));
// If the target is a child of ourselves, we move only *us* and not our children.
- if (skeleton->is_bone_parent_of(p_target_boneidx, p_selected_boneidx)) {
- const BoneId parent_idx = skeleton->get_bone_parent(p_selected_boneidx);
- const int bone_count = skeleton->get_bone_count();
+ if (skeleton_node->is_bone_parent_of(p_target_boneidx, p_selected_boneidx)) {
+ const BoneId parent_idx = skeleton_node->get_bone_parent(p_selected_boneidx);
+ const int bone_count = skeleton_node->get_bone_count();
for (BoneId i = 0; i < bone_count; ++i) {
- if (skeleton->get_bone_parent(i) == p_selected_boneidx) {
- ur->add_undo_method(skeleton, "set_bone_parent", i, skeleton->get_bone_parent(i));
- ur->add_do_method(skeleton, "set_bone_parent", i, parent_idx);
- skeleton->set_bone_parent(i, parent_idx);
+ if (skeleton_node->get_bone_parent(i) == p_selected_boneidx) {
+ ur->add_undo_method(skeleton_node, "set_bone_parent", i, skeleton_node->get_bone_parent(i));
+ ur->add_do_method(skeleton_node, "set_bone_parent", i, parent_idx);
+ skeleton_node->set_bone_parent(i, parent_idx);
}
}
}
- ur->add_undo_method(skeleton, "set_bone_parent", p_selected_boneidx, skeleton->get_bone_parent(p_selected_boneidx));
- ur->add_do_method(skeleton, "set_bone_parent", p_selected_boneidx, p_target_boneidx);
- skeleton->set_bone_parent(p_selected_boneidx, p_target_boneidx);
+ ur->add_undo_method(skeleton_node, "set_bone_parent", p_selected_boneidx, skeleton_node->get_bone_parent(p_selected_boneidx));
+ ur->add_do_method(skeleton_node, "set_bone_parent", p_selected_boneidx, p_target_boneidx);
+ skeleton_node->set_bone_parent(p_selected_boneidx, p_target_boneidx);
update_joint_tree();
ur->commit_action();
@@ -1128,7 +1128,7 @@ Skeleton3DEditorPlugin::Skeleton3DEditorPlugin() {
Node3DEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin);
}
-EditorPlugin::AfterGUIInput Skeleton3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
+EditorPlugin::AfterGUIInput Skeleton3DEditorPlugin::forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
Skeleton3DEditor *se = Skeleton3DEditor::get_singleton();
Node3DEditor *ne = Node3DEditor::get_singleton();
if (se && se->is_edit_mode()) {
@@ -1234,7 +1234,7 @@ int Skeleton3DGizmoPlugin::get_priority() const {
}
int Skeleton3DGizmoPlugin::subgizmos_intersect_ray(const EditorNode3DGizmo *p_gizmo, Camera3D *p_camera, const Vector2 &p_point) const {
- Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(p_gizmo->get_spatial_node());
+ Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(p_gizmo->get_node_3d());
ERR_FAIL_COND_V(!skeleton, -1);
Skeleton3DEditor *se = Skeleton3DEditor::get_singleton();
@@ -1277,14 +1277,14 @@ int Skeleton3DGizmoPlugin::subgizmos_intersect_ray(const EditorNode3DGizmo *p_gi
}
Transform3D Skeleton3DGizmoPlugin::get_subgizmo_transform(const EditorNode3DGizmo *p_gizmo, int p_id) const {
- Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(p_gizmo->get_spatial_node());
+ Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(p_gizmo->get_node_3d());
ERR_FAIL_COND_V(!skeleton, Transform3D());
return skeleton->get_bone_global_pose(p_id);
}
void Skeleton3DGizmoPlugin::set_subgizmo_transform(const EditorNode3DGizmo *p_gizmo, int p_id, Transform3D p_transform) {
- Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(p_gizmo->get_spatial_node());
+ Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(p_gizmo->get_node_3d());
ERR_FAIL_COND(!skeleton);
// Prepare for global to local.
@@ -1313,7 +1313,7 @@ void Skeleton3DGizmoPlugin::set_subgizmo_transform(const EditorNode3DGizmo *p_gi
}
void Skeleton3DGizmoPlugin::commit_subgizmos(const EditorNode3DGizmo *p_gizmo, const Vector<int> &p_ids, const Vector<Transform3D> &p_restore, bool p_cancel) {
- Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(p_gizmo->get_spatial_node());
+ Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(p_gizmo->get_node_3d());
ERR_FAIL_COND(!skeleton);
Skeleton3DEditor *se = Skeleton3DEditor::get_singleton();
@@ -1346,7 +1346,7 @@ void Skeleton3DGizmoPlugin::commit_subgizmos(const EditorNode3DGizmo *p_gizmo, c
}
void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(p_gizmo->get_spatial_node());
+ Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(p_gizmo->get_node_3d());
p_gizmo->clear();
int selected = -1;
diff --git a/editor/plugins/skeleton_3d_editor_plugin.h b/editor/plugins/skeleton_3d_editor_plugin.h
index 9747ed8374..9f02d144ed 100644
--- a/editor/plugins/skeleton_3d_editor_plugin.h
+++ b/editor/plugins/skeleton_3d_editor_plugin.h
@@ -238,7 +238,7 @@ class Skeleton3DEditorPlugin : public EditorPlugin {
EditorInspectorPluginSkeleton *skeleton_plugin = nullptr;
public:
- virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) override;
+ virtual EditorPlugin::AfterGUIInput forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) override;
bool has_main_screen() const override { return false; }
virtual bool handles(Object *p_object) const override;
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index d0a1ddafa1..5dac66d3e1 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -414,16 +414,16 @@ void SpriteFramesEditor::_notification(int p_what) {
load_sheet->set_icon(get_theme_icon(SNAME("SpriteSheet"), SNAME("EditorIcons")));
copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")));
paste->set_icon(get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons")));
- empty->set_icon(get_theme_icon(SNAME("InsertBefore"), SNAME("EditorIcons")));
- empty2->set_icon(get_theme_icon(SNAME("InsertAfter"), SNAME("EditorIcons")));
+ empty_before->set_icon(get_theme_icon(SNAME("InsertBefore"), SNAME("EditorIcons")));
+ empty_after->set_icon(get_theme_icon(SNAME("InsertAfter"), SNAME("EditorIcons")));
move_up->set_icon(get_theme_icon(SNAME("MoveLeft"), SNAME("EditorIcons")));
move_down->set_icon(get_theme_icon(SNAME("MoveRight"), SNAME("EditorIcons")));
- _delete->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
+ delete_frame->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons")));
zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons")));
zoom_in->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons")));
- new_anim->set_icon(get_theme_icon(SNAME("New"), SNAME("EditorIcons")));
- remove_anim->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
+ add_anim->set_icon(get_theme_icon(SNAME("New"), SNAME("EditorIcons")));
+ delete_anim->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
anim_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
split_sheet_zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons")));
split_sheet_zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons")));
@@ -1016,19 +1016,19 @@ void SpriteFramesEditor::edit(SpriteFrames *p_frames) {
hide();
}
- new_anim->set_disabled(read_only);
- remove_anim->set_disabled(read_only);
+ add_anim->set_disabled(read_only);
+ delete_anim->set_disabled(read_only);
anim_speed->set_editable(!read_only);
anim_loop->set_disabled(read_only);
load->set_disabled(read_only);
load_sheet->set_disabled(read_only);
copy->set_disabled(read_only);
paste->set_disabled(read_only);
- empty->set_disabled(read_only);
- empty2->set_disabled(read_only);
+ empty_before->set_disabled(read_only);
+ empty_after->set_disabled(read_only);
move_up->set_disabled(read_only);
move_down->set_disabled(read_only);
- _delete->set_disabled(read_only);
+ delete_frame->set_disabled(read_only);
}
void SpriteFramesEditor::set_undo_redo(Ref<EditorUndoRedoManager> p_undo_redo) {
@@ -1095,8 +1095,8 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
}
for (int i = 0; i < files.size(); i++) {
- String file = files[i];
- String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
+ String f = files[i];
+ String ftype = EditorFileSystem::get_singleton()->get_file_type(f);
if (!ClassDB::is_parent_class(ftype, "Texture2D")) {
return false;
@@ -1187,18 +1187,16 @@ SpriteFramesEditor::SpriteFramesEditor() {
HBoxContainer *hbc_animlist = memnew(HBoxContainer);
sub_vb->add_child(hbc_animlist);
- new_anim = memnew(Button);
- new_anim->set_flat(true);
- new_anim->set_tooltip_text(TTR("New Animation"));
- hbc_animlist->add_child(new_anim);
- new_anim->connect("pressed", callable_mp(this, &SpriteFramesEditor::_animation_add));
+ add_anim = memnew(Button);
+ add_anim->set_flat(true);
+ hbc_animlist->add_child(add_anim);
+ add_anim->connect("pressed", callable_mp(this, &SpriteFramesEditor::_animation_add));
- remove_anim = memnew(Button);
- remove_anim->set_flat(true);
- remove_anim->set_tooltip_text(TTR("Remove Animation"));
- hbc_animlist->add_child(remove_anim);
- remove_anim->set_disabled(true);
- remove_anim->connect("pressed", callable_mp(this, &SpriteFramesEditor::_animation_remove));
+ delete_anim = memnew(Button);
+ delete_anim->set_flat(true);
+ hbc_animlist->add_child(delete_anim);
+ delete_anim->set_disabled(true);
+ delete_anim->connect("pressed", callable_mp(this, &SpriteFramesEditor::_animation_remove));
anim_search_box = memnew(LineEdit);
hbc_animlist->add_child(anim_search_box);
@@ -1215,6 +1213,11 @@ SpriteFramesEditor::SpriteFramesEditor() {
animations->connect("item_edited", callable_mp(this, &SpriteFramesEditor::_animation_name_edited));
animations->set_allow_reselect(true);
+ add_anim->set_shortcut_context(animations);
+ add_anim->set_shortcut(ED_SHORTCUT("sprite_frames/new_animation", TTR("Add Animation"), KeyModifierMask::CMD_OR_CTRL | Key::N));
+ delete_anim->set_shortcut_context(animations);
+ delete_anim->set_shortcut(ED_SHORTCUT("sprite_frames/delete_animation", TTR("Delete Animation"), Key::KEY_DELETE));
+
HBoxContainer *hbc_anim_speed = memnew(HBoxContainer);
hbc_anim_speed->add_child(memnew(Label(TTR("Speed:"))));
vbc_animlist->add_child(hbc_anim_speed);
@@ -1244,54 +1247,45 @@ SpriteFramesEditor::SpriteFramesEditor() {
load = memnew(Button);
load->set_flat(true);
- load->set_tooltip_text(TTR("Add a Texture from File"));
hbc->add_child(load);
load_sheet = memnew(Button);
load_sheet->set_flat(true);
- load_sheet->set_tooltip_text(TTR("Add Frames from a Sprite Sheet"));
hbc->add_child(load_sheet);
hbc->add_child(memnew(VSeparator));
copy = memnew(Button);
copy->set_flat(true);
- copy->set_tooltip_text(TTR("Copy"));
hbc->add_child(copy);
paste = memnew(Button);
paste->set_flat(true);
- paste->set_tooltip_text(TTR("Paste"));
hbc->add_child(paste);
hbc->add_child(memnew(VSeparator));
- empty = memnew(Button);
- empty->set_flat(true);
- empty->set_tooltip_text(TTR("Insert Empty (Before)"));
- hbc->add_child(empty);
+ empty_before = memnew(Button);
+ empty_before->set_flat(true);
+ hbc->add_child(empty_before);
- empty2 = memnew(Button);
- empty2->set_flat(true);
- empty2->set_tooltip_text(TTR("Insert Empty (After)"));
- hbc->add_child(empty2);
+ empty_after = memnew(Button);
+ empty_after->set_flat(true);
+ hbc->add_child(empty_after);
hbc->add_child(memnew(VSeparator));
move_up = memnew(Button);
move_up->set_flat(true);
- move_up->set_tooltip_text(TTR("Move (Before)"));
hbc->add_child(move_up);
move_down = memnew(Button);
move_down->set_flat(true);
- move_down->set_tooltip_text(TTR("Move (After)"));
hbc->add_child(move_down);
- _delete = memnew(Button);
- _delete->set_flat(true);
- _delete->set_tooltip_text(TTR("Delete"));
- hbc->add_child(_delete);
+ delete_frame = memnew(Button);
+ delete_frame->set_flat(true);
+ hbc->add_child(delete_frame);
hbc->add_spacer();
@@ -1333,13 +1327,40 @@ SpriteFramesEditor::SpriteFramesEditor() {
load->connect("pressed", callable_mp(this, &SpriteFramesEditor::_load_pressed));
load_sheet->connect("pressed", callable_mp(this, &SpriteFramesEditor::_open_sprite_sheet));
- _delete->connect("pressed", callable_mp(this, &SpriteFramesEditor::_delete_pressed));
+ delete_frame->connect("pressed", callable_mp(this, &SpriteFramesEditor::_delete_pressed));
copy->connect("pressed", callable_mp(this, &SpriteFramesEditor::_copy_pressed));
paste->connect("pressed", callable_mp(this, &SpriteFramesEditor::_paste_pressed));
- empty->connect("pressed", callable_mp(this, &SpriteFramesEditor::_empty_pressed));
- empty2->connect("pressed", callable_mp(this, &SpriteFramesEditor::_empty2_pressed));
+ empty_before->connect("pressed", callable_mp(this, &SpriteFramesEditor::_empty_pressed));
+ empty_after->connect("pressed", callable_mp(this, &SpriteFramesEditor::_empty2_pressed));
move_up->connect("pressed", callable_mp(this, &SpriteFramesEditor::_up_pressed));
move_down->connect("pressed", callable_mp(this, &SpriteFramesEditor::_down_pressed));
+
+ load->set_shortcut_context(tree);
+ load->set_shortcut(ED_SHORTCUT("sprite_frames/load_from_file", TTR("Add frame from file"), KeyModifierMask::CMD_OR_CTRL | Key::O));
+ load_sheet->set_shortcut_context(tree);
+ load_sheet->set_shortcut(ED_SHORTCUT("sprite_frames/load_from_sheet", TTR("Add frames from sprite sheet"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::O));
+ delete_frame->set_shortcut_context(tree);
+ delete_frame->set_shortcut(ED_SHORTCUT("sprite_frames/delete", TTR("Delete Frame"), Key::KEY_DELETE));
+ copy->set_shortcut_context(tree);
+ copy->set_shortcut(ED_SHORTCUT("sprite_frames/copy", TTR("Copy Frame"), KeyModifierMask::CMD_OR_CTRL | Key::C));
+ paste->set_shortcut_context(tree);
+ paste->set_shortcut(ED_SHORTCUT("sprite_frames/paste", TTR("Paste Frame"), KeyModifierMask::CMD_OR_CTRL | Key::V));
+ empty_before->set_shortcut_context(tree);
+ empty_before->set_shortcut(ED_SHORTCUT("sprite_frames/empty_before", TTR("Insert Empty (Before Selected)"), KeyModifierMask::ALT | Key::LEFT));
+ empty_after->set_shortcut_context(tree);
+ empty_after->set_shortcut(ED_SHORTCUT("sprite_frames/empty_after", TTR("Insert Empty (After Selected)"), KeyModifierMask::ALT | Key::RIGHT));
+ move_up->set_shortcut_context(tree);
+ move_up->set_shortcut(ED_SHORTCUT("sprite_frames/move_left", TTR("Move Frame Left"), KeyModifierMask::CMD_OR_CTRL | Key::LEFT));
+ move_down->set_shortcut_context(tree);
+ move_down->set_shortcut(ED_SHORTCUT("sprite_frames/move_right", TTR("Move Frame Right"), KeyModifierMask::CMD_OR_CTRL | Key::RIGHT));
+
+ zoom_out->set_shortcut_context(tree);
+ zoom_out->set_shortcut(ED_SHORTCUT_ARRAY("sprite_frames/zoom_out", TTR("Zoom Out"),
+ { int32_t(KeyModifierMask::CMD_OR_CTRL | Key::MINUS), int32_t(KeyModifierMask::CMD_OR_CTRL | Key::KP_SUBTRACT) }));
+ zoom_in->set_shortcut_context(tree);
+ zoom_in->set_shortcut(ED_SHORTCUT_ARRAY("sprite_frames/zoom_in", TTR("Zoom In"),
+ { int32_t(KeyModifierMask::CMD_OR_CTRL | Key::EQUAL), int32_t(KeyModifierMask::CMD_OR_CTRL | Key::KP_ADD) }));
+
file->connect("files_selected", callable_mp(this, &SpriteFramesEditor::_file_load_request).bind(-1));
loading_scene = false;
sel = -1;
diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h
index 092f556c63..5fc3fe4481 100644
--- a/editor/plugins/sprite_frames_editor_plugin.h
+++ b/editor/plugins/sprite_frames_editor_plugin.h
@@ -61,11 +61,11 @@ class SpriteFramesEditor : public HSplitContainer {
Button *load = nullptr;
Button *load_sheet = nullptr;
- Button *_delete = nullptr;
+ Button *delete_frame = nullptr;
Button *copy = nullptr;
Button *paste = nullptr;
- Button *empty = nullptr;
- Button *empty2 = nullptr;
+ Button *empty_before = nullptr;
+ Button *empty_after = nullptr;
Button *move_up = nullptr;
Button *move_down = nullptr;
Button *zoom_out = nullptr;
@@ -75,8 +75,8 @@ class SpriteFramesEditor : public HSplitContainer {
bool loading_scene;
int sel;
- Button *new_anim = nullptr;
- Button *remove_anim = nullptr;
+ Button *add_anim = nullptr;
+ Button *delete_anim = nullptr;
LineEdit *anim_search_box = nullptr;
Tree *animations = nullptr;
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index 9846cd4a84..07f0819c7f 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -222,6 +222,10 @@ void TextEditor::set_edit_state(const Variant &p_state) {
ensure_focus();
}
+Variant TextEditor::get_navigation_state() {
+ return code_editor->get_navigation_state();
+}
+
void TextEditor::trim_trailing_whitespace() {
code_editor->trim_trailing_whitespace();
}
@@ -441,6 +445,7 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
bool is_folded = tx->is_line_folded(row);
if (tx->is_move_caret_on_right_click_enabled()) {
+ tx->remove_secondary_carets();
if (tx->has_selection()) {
int from_line = tx->get_selection_from_line();
int to_line = tx->get_selection_to_line();
@@ -467,9 +472,9 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
Ref<InputEventKey> k = ev;
if (k.is_valid() && k->is_pressed() && k->is_action("ui_menu", true)) {
CodeEdit *tx = code_editor->get_text_editor();
- int line = tx->get_caret_line();
- tx->adjust_viewport_to_caret();
- _make_context_menu(tx->has_selection(), tx->can_fold_line(line), tx->is_line_folded(line), (get_global_transform().inverse() * tx->get_global_transform()).xform(tx->get_caret_draw_pos()));
+ int line = tx->get_caret_line(0);
+ tx->adjust_viewport_to_caret(0);
+ _make_context_menu(tx->has_selection(0), tx->can_fold_line(line), tx->is_line_folded(line), (get_global_transform().inverse() * tx->get_global_transform()).xform(tx->get_caret_draw_pos(0)));
context_menu->grab_focus();
}
}
diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h
index 9ee6a39b2e..a7a640247f 100644
--- a/editor/plugins/text_editor.h
+++ b/editor/plugins/text_editor.h
@@ -117,6 +117,7 @@ public:
virtual bool is_unsaved() override;
virtual Variant get_edit_state() override;
virtual void set_edit_state(const Variant &p_state) override;
+ virtual Variant get_navigation_state() override;
virtual Vector<String> get_functions() override;
virtual PackedInt32Array get_breakpoints() override;
virtual void set_breakpoint(int p_line, bool p_enabled) override{};
diff --git a/editor/plugins/text_shader_editor.cpp b/editor/plugins/text_shader_editor.cpp
index dfd5e76ba6..48086bf235 100644
--- a/editor/plugins/text_shader_editor.cpp
+++ b/editor/plugins/text_shader_editor.cpp
@@ -202,12 +202,12 @@ void ShaderTextEditor::set_warnings_panel(RichTextLabel *p_warnings_panel) {
}
void ShaderTextEditor::_load_theme_settings() {
- CodeEdit *text_editor = get_text_editor();
+ CodeEdit *te = get_text_editor();
Color updated_marked_line_color = EDITOR_GET("text_editor/theme/highlighting/mark_color");
if (updated_marked_line_color != marked_line_color) {
- for (int i = 0; i < text_editor->get_line_count(); i++) {
- if (text_editor->get_line_background_color(i) == marked_line_color) {
- text_editor->set_line_background_color(i, updated_marked_line_color);
+ for (int i = 0; i < te->get_line_count(); i++) {
+ if (te->get_line_background_color(i) == marked_line_color) {
+ te->set_line_background_color(i, updated_marked_line_color);
}
}
marked_line_color = updated_marked_line_color;
@@ -257,14 +257,14 @@ void ShaderTextEditor::_load_theme_settings() {
const Vector<ShaderLanguage::ModeInfo> &modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(i));
for (int j = 0; j < modes.size(); j++) {
- const ShaderLanguage::ModeInfo &info = modes[j];
+ const ShaderLanguage::ModeInfo &mode_info = modes[j];
- if (!info.options.is_empty()) {
- for (int k = 0; k < info.options.size(); k++) {
- built_ins.push_back(String(info.name) + "_" + String(info.options[k]));
+ if (!mode_info.options.is_empty()) {
+ for (int k = 0; k < mode_info.options.size(); k++) {
+ built_ins.push_back(String(mode_info.name) + "_" + String(mode_info.options[k]));
}
} else {
- built_ins.push_back(String(info.name));
+ built_ins.push_back(String(mode_info.name));
}
}
}
@@ -278,14 +278,14 @@ void ShaderTextEditor::_load_theme_settings() {
const Vector<ShaderLanguage::ModeInfo> &modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode()));
for (int i = 0; i < modes.size(); i++) {
- const ShaderLanguage::ModeInfo &info = modes[i];
+ const ShaderLanguage::ModeInfo &mode_info = modes[i];
- if (!info.options.is_empty()) {
- for (int j = 0; j < info.options.size(); j++) {
- built_ins.push_back(String(info.name) + "_" + String(info.options[j]));
+ if (!mode_info.options.is_empty()) {
+ for (int j = 0; j < mode_info.options.size(); j++) {
+ built_ins.push_back(String(mode_info.name) + "_" + String(mode_info.options[j]));
}
} else {
- built_ins.push_back(String(info.name));
+ built_ins.push_back(String(mode_info.name));
}
}
}
@@ -303,12 +303,12 @@ void ShaderTextEditor::_load_theme_settings() {
syntax_highlighter->add_color_region("//", "", comment_color, true);
syntax_highlighter->set_disabled_branch_color(comment_color);
- text_editor->clear_comment_delimiters();
- text_editor->add_comment_delimiter("/*", "*/", false);
- text_editor->add_comment_delimiter("//", "", true);
+ te->clear_comment_delimiters();
+ te->add_comment_delimiter("/*", "*/", false);
+ te->add_comment_delimiter("//", "", true);
- if (!text_editor->has_auto_brace_completion_open_key("/*")) {
- text_editor->add_auto_brace_completion_pair("/*", "*/");
+ if (!te->has_auto_brace_completion_open_key("/*")) {
+ te->add_auto_brace_completion_pair("/*", "*/");
}
// Colorize preprocessor include strings.
@@ -399,22 +399,22 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptLa
ShaderLanguage sl;
String calltip;
- ShaderLanguage::ShaderCompileInfo info;
- info.global_shader_uniform_type_func = _get_global_shader_uniform_type;
+ ShaderLanguage::ShaderCompileInfo comp_info;
+ comp_info.global_shader_uniform_type_func = _get_global_shader_uniform_type;
if (shader.is_null()) {
- info.is_include = true;
+ comp_info.is_include = true;
- sl.complete(code, info, r_options, calltip);
+ sl.complete(code, comp_info, r_options, calltip);
get_text_editor()->set_code_hint(calltip);
return;
}
_check_shader_mode();
- info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode()));
- info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode()));
- info.shader_types = ShaderTypes::get_singleton()->get_types();
+ comp_info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode()));
+ comp_info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode()));
+ comp_info.shader_types = ShaderTypes::get_singleton()->get_types();
- sl.complete(code, info, r_options, calltip);
+ sl.complete(code, comp_info, r_options, calltip);
get_text_editor()->set_code_hint(calltip);
}
@@ -464,22 +464,22 @@ void ShaderTextEditor::_validate_script() {
//preprocessor error
ERR_FAIL_COND(err_positions.size() == 0);
- String error_text = error_pp;
- int error_line = err_positions.front()->get().line;
+ String err_text = error_pp;
+ int err_line = err_positions.front()->get().line;
if (err_positions.size() == 1) {
// Error in main file
- error_text = "error(" + itos(error_line) + "): " + error_text;
+ err_text = "error(" + itos(err_line) + "): " + err_text;
} else {
- error_text = "error(" + itos(error_line) + ") in include " + err_positions.back()->get().file.get_file() + ":" + itos(err_positions.back()->get().line) + ": " + error_text;
+ err_text = "error(" + itos(err_line) + ") in include " + err_positions.back()->get().file.get_file() + ":" + itos(err_positions.back()->get().line) + ": " + err_text;
set_error_count(err_positions.size() - 1);
}
- set_error(error_text);
- set_error_pos(error_line - 1, 0);
+ set_error(err_text);
+ set_error_pos(err_line - 1, 0);
for (int i = 0; i < get_text_editor()->get_line_count(); i++) {
get_text_editor()->set_line_background_color(i, Color(0, 0, 0, 0));
}
- get_text_editor()->set_line_background_color(error_line - 1, marked_line_color);
+ get_text_editor()->set_line_background_color(err_line - 1, marked_line_color);
set_warning_count(0);
@@ -507,39 +507,39 @@ void ShaderTextEditor::_validate_script() {
}
sl.set_warning_flags(flags);
- ShaderLanguage::ShaderCompileInfo info;
- info.global_shader_uniform_type_func = _get_global_shader_uniform_type;
+ ShaderLanguage::ShaderCompileInfo comp_info;
+ comp_info.global_shader_uniform_type_func = _get_global_shader_uniform_type;
if (shader.is_null()) {
- info.is_include = true;
+ comp_info.is_include = true;
} else {
Shader::Mode mode = shader->get_mode();
- info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(mode));
- info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(mode));
- info.shader_types = ShaderTypes::get_singleton()->get_types();
+ comp_info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(mode));
+ comp_info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(mode));
+ comp_info.shader_types = ShaderTypes::get_singleton()->get_types();
}
code = code_pp;
//compiler error
- last_compile_result = sl.compile(code, info);
+ last_compile_result = sl.compile(code, comp_info);
if (last_compile_result != OK) {
- String error_text;
- int error_line;
+ String err_text;
+ int err_line;
Vector<ShaderLanguage::FilePosition> include_positions = sl.get_include_positions();
if (include_positions.size() > 1) {
//error is in an include
- error_line = include_positions[0].line;
- error_text = "error(" + itos(error_line) + ") in include " + include_positions[include_positions.size() - 1].file + ":" + itos(include_positions[include_positions.size() - 1].line) + ": " + sl.get_error_text();
+ err_line = include_positions[0].line;
+ err_text = "error(" + itos(err_line) + ") in include " + include_positions[include_positions.size() - 1].file + ":" + itos(include_positions[include_positions.size() - 1].line) + ": " + sl.get_error_text();
set_error_count(include_positions.size() - 1);
} else {
- error_line = sl.get_error_line();
- error_text = "error(" + itos(error_line) + "): " + sl.get_error_text();
+ err_line = sl.get_error_line();
+ err_text = "error(" + itos(err_line) + "): " + sl.get_error_text();
set_error_count(0);
}
- set_error(error_text);
- set_error_pos(error_line - 1, 0);
- get_text_editor()->set_line_background_color(error_line - 1, marked_line_color);
+ set_error(err_text);
+ set_error_pos(err_line - 1, 0);
+ get_text_editor()->set_line_background_color(err_line - 1, marked_line_color);
} else {
set_error("");
}
@@ -715,7 +715,7 @@ void TextShaderEditor::_notification(int p_what) {
popup->set_item_icon(popup->get_item_index(HELP_DOCS), get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons")));
} break;
- case NOTIFICATION_WM_WINDOW_FOCUS_IN: {
+ case NOTIFICATION_APPLICATION_FOCUS_IN: {
_check_for_external_edit();
} break;
}
@@ -917,6 +917,10 @@ bool TextShaderEditor::is_unsaved() const {
return shader_editor->get_text_editor()->get_saved_version() != shader_editor->get_text_editor()->get_version();
}
+void TextShaderEditor::tag_saved_version() {
+ shader_editor->get_text_editor()->tag_saved_version();
+}
+
void TextShaderEditor::apply_shaders() {
String editor_code = shader_editor->get_text_editor()->get_text();
if (shader.is_valid()) {
@@ -954,6 +958,7 @@ void TextShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
tx->set_move_caret_on_right_click_enabled(EditorSettings::get_singleton()->get("text_editor/behavior/navigation/move_caret_on_right_click"));
if (tx->is_move_caret_on_right_click_enabled()) {
+ tx->remove_secondary_carets();
if (tx->has_selection()) {
int from_line = tx->get_selection_from_line();
int to_line = tx->get_selection_to_line();
diff --git a/editor/plugins/text_shader_editor.h b/editor/plugins/text_shader_editor.h
index abeaff1fff..c2094342ed 100644
--- a/editor/plugins/text_shader_editor.h
+++ b/editor/plugins/text_shader_editor.h
@@ -190,6 +190,7 @@ public:
void save_external_data(const String &p_str = "");
void validate_script();
bool is_unsaved() const;
+ void tag_saved_version();
virtual Size2 get_minimum_size() const override { return Size2(0, 200); }
diff --git a/editor/plugins/tiles/tile_atlas_view.cpp b/editor/plugins/tiles/tile_atlas_view.cpp
index c823487279..502c34459a 100644
--- a/editor/plugins/tiles/tile_atlas_view.cpp
+++ b/editor/plugins/tiles/tile_atlas_view.cpp
@@ -533,11 +533,11 @@ TileAtlasView::TileAtlasView() {
panel->set_v_size_flags(SIZE_EXPAND_FILL);
add_child(panel);
- // Scrollingsc
zoom_widget = memnew(EditorZoomWidget);
add_child(zoom_widget);
zoom_widget->set_anchors_and_offsets_preset(Control::PRESET_TOP_LEFT, Control::PRESET_MODE_MINSIZE, 2 * EDSCALE);
zoom_widget->connect("zoom_changed", callable_mp(this, &TileAtlasView::_zoom_widget_changed).unbind(1));
+ zoom_widget->set_shortcut_context(this);
button_center_view = memnew(Button);
button_center_view->set_icon(get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons")));
diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp
index d0f8e1f32d..17b9035121 100644
--- a/editor/plugins/tiles/tile_data_editors.cpp
+++ b/editor/plugins/tiles/tile_data_editors.cpp
@@ -212,8 +212,8 @@ void GenericTilePolygonEditor::_base_control_draw() {
for (int i = 0; i < (int)polygons.size(); i++) {
const Vector<Vector2> &polygon = polygons[i];
for (int j = 0; j < polygon.size(); j++) {
- const Color modulate = (tinted_polygon_index == i && tinted_point_index == j) ? Color(0.5, 1, 2) : Color(1, 1, 1);
- base_control->draw_texture(handle, xform.xform(polygon[j]) - handle->get_size() / 2, modulate);
+ const Color poly_modulate = (tinted_polygon_index == i && tinted_point_index == j) ? Color(0.5, 1, 2) : Color(1, 1, 1);
+ base_control->draw_texture(handle, xform.xform(polygon[j]) - handle->get_size() / 2, poly_modulate);
}
}
}
@@ -831,6 +831,7 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() {
editor_zoom_widget = memnew(EditorZoomWidget);
editor_zoom_widget->set_position(Vector2(5, 5));
editor_zoom_widget->connect("zoom_changed", callable_mp(this, &GenericTilePolygonEditor::_zoom_changed).unbind(1));
+ editor_zoom_widget->set_shortcut_context(this);
root->add_child(editor_zoom_widget);
button_center_view = memnew(Button);
@@ -2662,27 +2663,27 @@ TileDataTerrainsEditor::~TileDataTerrainsEditor() {
}
Variant TileDataNavigationEditor::_get_painted_value() {
- Ref<NavigationPolygon> navigation_polygon;
- navigation_polygon.instantiate();
+ Ref<NavigationPolygon> nav_polygon;
+ nav_polygon.instantiate();
for (int i = 0; i < polygon_editor->get_polygon_count(); i++) {
Vector<Vector2> polygon = polygon_editor->get_polygon(i);
- navigation_polygon->add_outline(polygon);
+ nav_polygon->add_outline(polygon);
}
- navigation_polygon->make_polygons_from_outlines();
- return navigation_polygon;
+ nav_polygon->make_polygons_from_outlines();
+ return nav_polygon;
}
void TileDataNavigationEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) {
TileData *tile_data = p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile);
ERR_FAIL_COND(!tile_data);
- Ref<NavigationPolygon> navigation_polygon = tile_data->get_navigation_polygon(navigation_layer);
+ Ref<NavigationPolygon> nav_polygon = tile_data->get_navigation_polygon(navigation_layer);
polygon_editor->clear_polygons();
- if (navigation_polygon.is_valid()) {
- for (int i = 0; i < navigation_polygon->get_outline_count(); i++) {
- polygon_editor->add_polygon(navigation_polygon->get_outline(i));
+ if (nav_polygon.is_valid()) {
+ for (int i = 0; i < nav_polygon->get_outline_count(); i++) {
+ polygon_editor->add_polygon(nav_polygon->get_outline(i));
}
}
polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate());
@@ -2691,8 +2692,8 @@ void TileDataNavigationEditor::_set_painted_value(TileSetAtlasSource *p_tile_set
void TileDataNavigationEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) {
TileData *tile_data = p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile);
ERR_FAIL_COND(!tile_data);
- Ref<NavigationPolygon> navigation_polygon = p_value;
- tile_data->set_navigation_polygon(navigation_layer, navigation_polygon);
+ Ref<NavigationPolygon> nav_polygon = p_value;
+ tile_data->set_navigation_polygon(navigation_layer, nav_polygon);
polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate());
}
@@ -2740,9 +2741,9 @@ void TileDataNavigationEditor::draw_over_tile(CanvasItem *p_canvas_item, Transfo
// Draw all shapes.
RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), p_transform);
- Ref<NavigationPolygon> navigation_polygon = tile_data->get_navigation_polygon(navigation_layer);
- if (navigation_polygon.is_valid()) {
- Vector<Vector2> verts = navigation_polygon->get_vertices();
+ Ref<NavigationPolygon> nav_polygon = tile_data->get_navigation_polygon(navigation_layer);
+ if (nav_polygon.is_valid()) {
+ Vector<Vector2> verts = nav_polygon->get_vertices();
if (verts.size() < 3) {
return;
}
@@ -2759,9 +2760,9 @@ void TileDataNavigationEditor::draw_over_tile(CanvasItem *p_canvas_item, Transfo
}
RandomPCG rand;
- for (int i = 0; i < navigation_polygon->get_polygon_count(); i++) {
+ for (int i = 0; i < nav_polygon->get_polygon_count(); i++) {
// An array of vertices for this polygon.
- Vector<int> polygon = navigation_polygon->get_polygon(i);
+ Vector<int> polygon = nav_polygon->get_polygon(i);
Vector<Vector2> vertices;
vertices.resize(polygon.size());
for (int j = 0; j < polygon.size(); j++) {
diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp
index acfa8b3d00..dd16d4ffea 100644
--- a/editor/plugins/tiles/tile_map_editor.cpp
+++ b/editor/plugins/tiles/tile_map_editor.cpp
@@ -2002,6 +2002,7 @@ void TileMapEditorTilesPlugin::_set_source_sort(int p_sort) {
}
TilesEditorPlugin::get_singleton()->set_sorting_option(p_sort);
_update_tile_set_sources_list();
+ EditorSettings::get_singleton()->set_project_metadata("editor_metadata", "tile_source_sort", p_sort);
}
void TileMapEditorTilesPlugin::_bind_methods() {
@@ -3190,10 +3191,10 @@ void TileMapEditorTerrainsPlugin::_update_tiles_list() {
TreeItem *selected_tree_item = terrains_tree->get_selected();
if (selected_tree_item && selected_tree_item->get_metadata(0)) {
Dictionary metadata_dict = selected_tree_item->get_metadata(0);
- int selected_terrain_set = metadata_dict["terrain_set"];
- int selected_terrain_id = metadata_dict["terrain_id"];
- ERR_FAIL_INDEX(selected_terrain_set, tile_set->get_terrain_sets_count());
- ERR_FAIL_INDEX(selected_terrain_id, tile_set->get_terrains_count(selected_terrain_set));
+ int sel_terrain_set = metadata_dict["terrain_set"];
+ int sel_terrain_id = metadata_dict["terrain_id"];
+ ERR_FAIL_INDEX(sel_terrain_set, tile_set->get_terrain_sets_count());
+ ERR_FAIL_INDEX(sel_terrain_id, tile_set->get_terrains_count(sel_terrain_set));
// Add the two first generic modes
int item_index = terrains_tile_list->add_icon_item(main_vbox_container->get_theme_icon(SNAME("TerrainConnect"), SNAME("EditorIcons")));
@@ -3211,13 +3212,13 @@ void TileMapEditorTerrainsPlugin::_update_tiles_list() {
// Sort the items in a map by the number of corresponding terrains.
RBMap<int, RBSet<TileSet::TerrainsPattern>> sorted;
- for (const TileSet::TerrainsPattern &E : per_terrain_terrains_patterns[selected_terrain_set][selected_terrain_id]) {
+ for (const TileSet::TerrainsPattern &E : per_terrain_terrains_patterns[sel_terrain_set][sel_terrain_id]) {
// Count the number of matching sides/terrains.
int count = 0;
for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
- if (tile_set->is_valid_terrain_peering_bit(selected_terrain_set, bit) && E.get_terrain_peering_bit(bit) == selected_terrain_id) {
+ if (tile_set->is_valid_terrain_peering_bit(sel_terrain_set, bit) && E.get_terrain_peering_bit(bit) == sel_terrain_id) {
count++;
}
}
@@ -3234,7 +3235,7 @@ void TileMapEditorTerrainsPlugin::_update_tiles_list() {
bool transpose = false;
double max_probability = -1.0;
- for (const TileMapCell &cell : tile_set->get_tiles_for_terrains_pattern(selected_terrain_set, terrains_pattern)) {
+ for (const TileMapCell &cell : tile_set->get_tiles_for_terrains_pattern(sel_terrain_set, terrains_pattern)) {
Ref<TileSetSource> source = tile_set->get_source(cell.source_id);
Ref<TileSetAtlasSource> atlas_source = source;
@@ -3689,8 +3690,8 @@ void TileMapEditor::_update_layers_selection() {
}
void TileMapEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) {
- Ref<EditorUndoRedoManager> undo_redo = Object::cast_to<EditorUndoRedoManager>(p_undo_redo);
- ERR_FAIL_COND(undo_redo.is_null());
+ Ref<EditorUndoRedoManager> undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo);
+ ERR_FAIL_COND(undo_redo_man.is_null());
TileMap *tile_map = Object::cast_to<TileMap>(p_edited);
if (!tile_map) {
@@ -3721,12 +3722,12 @@ void TileMapEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p_
end = MIN(MAX(p_from_index, p_to_pos) + 1, end);
}
-#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property));
+#define ADD_UNDO(obj, property) undo_redo_man->add_undo_property(obj, property, obj->get(property));
// Save layers' properties.
if (p_from_index < 0) {
- undo_redo->add_undo_method(tile_map, "remove_layer", p_to_pos < 0 ? tile_map->get_layers_count() : p_to_pos);
+ undo_redo_man->add_undo_method(tile_map, "remove_layer", p_to_pos < 0 ? tile_map->get_layers_count() : p_to_pos);
} else if (p_to_pos < 0) {
- undo_redo->add_undo_method(tile_map, "add_layer", p_from_index);
+ undo_redo_man->add_undo_method(tile_map, "add_layer", p_from_index);
}
List<PropertyInfo> properties;
@@ -3752,11 +3753,11 @@ void TileMapEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p_
#undef ADD_UNDO
if (p_from_index < 0) {
- undo_redo->add_do_method(tile_map, "add_layer", p_to_pos);
+ undo_redo_man->add_do_method(tile_map, "add_layer", p_to_pos);
} else if (p_to_pos < 0) {
- undo_redo->add_do_method(tile_map, "remove_layer", p_from_index);
+ undo_redo_man->add_do_method(tile_map, "remove_layer", p_from_index);
} else {
- undo_redo->add_do_method(tile_map, "move_layer", p_from_index, p_to_pos);
+ undo_redo_man->add_do_method(tile_map, "move_layer", p_from_index, p_to_pos);
}
}
diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
index 45b2a5eb14..1857606f00 100644
--- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
+++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
@@ -561,9 +561,9 @@ void TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles() {
void TileSetAtlasSourceEditor::_update_atlas_source_inspector() {
// Update visibility.
- bool visible = tools_button_group->get_pressed_button() == tool_setup_atlas_source_button;
- atlas_source_inspector_label->set_visible(visible);
- atlas_source_inspector->set_visible(visible);
+ bool inspector_visible = tools_button_group->get_pressed_button() == tool_setup_atlas_source_button;
+ atlas_source_inspector_label->set_visible(inspector_visible);
+ atlas_source_inspector->set_visible(inspector_visible);
}
void TileSetAtlasSourceEditor::_update_tile_inspector() {
@@ -2043,6 +2043,13 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_unscaled_draw() {
}
void TileSetAtlasSourceEditor::_tile_set_changed() {
+ if (tile_set->get_source_count() == 0) {
+ // No sources, so nothing to do here anymore.
+ tile_set->disconnect("changed", callable_mp(this, &TileSetAtlasSourceEditor::_tile_set_changed));
+ tile_set = Ref<TileSet>();
+ return;
+ }
+
tile_set_changed_needs_update = true;
}
@@ -2060,14 +2067,14 @@ void TileSetAtlasSourceEditor::_atlas_source_proxy_object_changed(String p_what)
}
void TileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value) {
- Ref<EditorUndoRedoManager> undo_redo = Object::cast_to<EditorUndoRedoManager>(p_undo_redo);
- ERR_FAIL_COND(!undo_redo.is_valid());
+ Ref<EditorUndoRedoManager> undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo);
+ ERR_FAIL_COND(!undo_redo_man.is_valid());
-#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property));
+#define ADD_UNDO(obj, property) undo_redo_man->add_undo_property(obj, property, obj->get(property));
AtlasTileProxyObject *tile_data_proxy = Object::cast_to<AtlasTileProxyObject>(p_edited);
if (tile_data_proxy) {
- UndoRedo *internal_undo_redo = undo_redo->get_history_for_object(tile_data_proxy).undo_redo;
+ UndoRedo *internal_undo_redo = undo_redo_man->get_history_for_object(tile_data_proxy).undo_redo;
internal_undo_redo->start_force_keep_in_merge_ends();
Vector<String> components = String(p_property).split("/", true, 2);
@@ -2100,7 +2107,7 @@ void TileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_redo
TileSetAtlasSource *atlas_source = atlas_source_proxy->get_edited();
ERR_FAIL_COND(!atlas_source);
- UndoRedo *internal_undo_redo = undo_redo->get_history_for_object(atlas_source).undo_redo;
+ UndoRedo *internal_undo_redo = undo_redo_man->get_history_for_object(atlas_source).undo_redo;
internal_undo_redo->start_force_keep_in_merge_ends();
PackedVector2Array arr;
diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp
index 7394288fcd..3b057b7631 100644
--- a/editor/plugins/tiles/tile_set_editor.cpp
+++ b/editor/plugins/tiles/tile_set_editor.cpp
@@ -407,11 +407,11 @@ void TileSetEditor::_tab_changed(int p_tab_changed) {
}
void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) {
- Ref<EditorUndoRedoManager> undo_redo = Object::cast_to<EditorUndoRedoManager>(p_undo_redo);
- ERR_FAIL_COND(undo_redo.is_null());
+ Ref<EditorUndoRedoManager> undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo);
+ ERR_FAIL_COND(undo_redo_man.is_null());
- TileSet *tile_set = Object::cast_to<TileSet>(p_edited);
- if (!tile_set) {
+ TileSet *ed_tile_set = Object::cast_to<TileSet>(p_edited);
+ if (!ed_tile_set) {
return;
}
@@ -421,18 +421,18 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_
int begin = 0;
int end;
if (p_array_prefix == "occlusion_layer_") {
- end = tile_set->get_occlusion_layers_count();
+ end = ed_tile_set->get_occlusion_layers_count();
} else if (p_array_prefix == "physics_layer_") {
- end = tile_set->get_physics_layers_count();
+ end = ed_tile_set->get_physics_layers_count();
} else if (p_array_prefix == "terrain_set_") {
- end = tile_set->get_terrain_sets_count();
+ end = ed_tile_set->get_terrain_sets_count();
} else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrain_") {
int terrain_set = components[0].trim_prefix("terrain_set_").to_int();
- end = tile_set->get_terrains_count(terrain_set);
+ end = ed_tile_set->get_terrains_count(terrain_set);
} else if (p_array_prefix == "navigation_layer_") {
- end = tile_set->get_navigation_layers_count();
+ end = ed_tile_set->get_navigation_layers_count();
} else if (p_array_prefix == "custom_data_layer_") {
- end = tile_set->get_custom_data_layers_count();
+ end = ed_tile_set->get_custom_data_layers_count();
} else {
ERR_FAIL_MSG("Invalid array prefix for TileSet.");
}
@@ -452,10 +452,10 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_
end = MIN(MAX(p_from_index, p_to_pos) + 1, end);
}
-#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property));
+#define ADD_UNDO(obj, property) undo_redo_man->add_undo_property(obj, property, obj->get(property));
// Save layers' properties.
List<PropertyInfo> properties;
- tile_set->get_property_list(&properties);
+ ed_tile_set->get_property_list(&properties);
for (PropertyInfo pi : properties) {
if (pi.name.begins_with(p_array_prefix)) {
String str = pi.name.trim_prefix(p_array_prefix);
@@ -469,17 +469,17 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_
if (to_char_index > 0) {
int array_index = str.left(to_char_index).to_int();
if (array_index >= begin && array_index < end) {
- ADD_UNDO(tile_set, pi.name);
+ ADD_UNDO(ed_tile_set, pi.name);
}
}
}
}
// Save properties for TileSetAtlasSources tile data
- for (int i = 0; i < tile_set->get_source_count(); i++) {
- int source_id = tile_set->get_source_id(i);
+ for (int i = 0; i < ed_tile_set->get_source_count(); i++) {
+ int source_id = ed_tile_set->get_source_id(i);
- Ref<TileSetAtlasSource> tas = tile_set->get_source(source_id);
+ Ref<TileSetAtlasSource> tas = ed_tile_set->get_source(source_id);
if (tas.is_valid()) {
for (int j = 0; j < tas->get_tiles_count(); j++) {
Vector2i tile_id = tas->get_tile_id(j);
@@ -537,68 +537,68 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_
// Add do method.
if (p_array_prefix == "occlusion_layer_") {
if (p_from_index < 0) {
- undo_redo->add_do_method(tile_set, "add_occlusion_layer", p_to_pos);
+ undo_redo_man->add_do_method(ed_tile_set, "add_occlusion_layer", p_to_pos);
} else if (p_to_pos < 0) {
- undo_redo->add_do_method(tile_set, "remove_occlusion_layer", p_from_index);
+ undo_redo_man->add_do_method(ed_tile_set, "remove_occlusion_layer", p_from_index);
} else {
- undo_redo->add_do_method(tile_set, "move_occlusion_layer", p_from_index, p_to_pos);
+ undo_redo_man->add_do_method(ed_tile_set, "move_occlusion_layer", p_from_index, p_to_pos);
}
} else if (p_array_prefix == "physics_layer_") {
if (p_from_index < 0) {
- undo_redo->add_do_method(tile_set, "add_physics_layer", p_to_pos);
+ undo_redo_man->add_do_method(ed_tile_set, "add_physics_layer", p_to_pos);
} else if (p_to_pos < 0) {
- undo_redo->add_do_method(tile_set, "remove_physics_layer", p_from_index);
+ undo_redo_man->add_do_method(ed_tile_set, "remove_physics_layer", p_from_index);
} else {
- undo_redo->add_do_method(tile_set, "move_physics_layer", p_from_index, p_to_pos);
+ undo_redo_man->add_do_method(ed_tile_set, "move_physics_layer", p_from_index, p_to_pos);
}
} else if (p_array_prefix == "terrain_set_") {
if (p_from_index < 0) {
- undo_redo->add_do_method(tile_set, "add_terrain_set", p_to_pos);
+ undo_redo_man->add_do_method(ed_tile_set, "add_terrain_set", p_to_pos);
} else if (p_to_pos < 0) {
- undo_redo->add_do_method(tile_set, "remove_terrain_set", p_from_index);
+ undo_redo_man->add_do_method(ed_tile_set, "remove_terrain_set", p_from_index);
} else {
- undo_redo->add_do_method(tile_set, "move_terrain_set", p_from_index, p_to_pos);
+ undo_redo_man->add_do_method(ed_tile_set, "move_terrain_set", p_from_index, p_to_pos);
}
} else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrain_") {
int terrain_set = components[0].trim_prefix("terrain_set_").to_int();
if (p_from_index < 0) {
- undo_redo->add_do_method(tile_set, "add_terrain", terrain_set, p_to_pos);
+ undo_redo_man->add_do_method(ed_tile_set, "add_terrain", terrain_set, p_to_pos);
} else if (p_to_pos < 0) {
- undo_redo->add_do_method(tile_set, "remove_terrain", terrain_set, p_from_index);
+ undo_redo_man->add_do_method(ed_tile_set, "remove_terrain", terrain_set, p_from_index);
} else {
- undo_redo->add_do_method(tile_set, "move_terrain", terrain_set, p_from_index, p_to_pos);
+ undo_redo_man->add_do_method(ed_tile_set, "move_terrain", terrain_set, p_from_index, p_to_pos);
}
} else if (p_array_prefix == "navigation_layer_") {
if (p_from_index < 0) {
- undo_redo->add_do_method(tile_set, "add_navigation_layer", p_to_pos);
+ undo_redo_man->add_do_method(ed_tile_set, "add_navigation_layer", p_to_pos);
} else if (p_to_pos < 0) {
- undo_redo->add_do_method(tile_set, "remove_navigation_layer", p_from_index);
+ undo_redo_man->add_do_method(ed_tile_set, "remove_navigation_layer", p_from_index);
} else {
- undo_redo->add_do_method(tile_set, "move_navigation_layer", p_from_index, p_to_pos);
+ undo_redo_man->add_do_method(ed_tile_set, "move_navigation_layer", p_from_index, p_to_pos);
}
} else if (p_array_prefix == "custom_data_layer_") {
if (p_from_index < 0) {
- undo_redo->add_do_method(tile_set, "add_custom_data_layer", p_to_pos);
+ undo_redo_man->add_do_method(ed_tile_set, "add_custom_data_layer", p_to_pos);
} else if (p_to_pos < 0) {
- undo_redo->add_do_method(tile_set, "remove_custom_data_layer", p_from_index);
+ undo_redo_man->add_do_method(ed_tile_set, "remove_custom_data_layer", p_from_index);
} else {
- undo_redo->add_do_method(tile_set, "move_custom_data_layer", p_from_index, p_to_pos);
+ undo_redo_man->add_do_method(ed_tile_set, "move_custom_data_layer", p_from_index, p_to_pos);
}
}
}
void TileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value) {
- Ref<EditorUndoRedoManager> undo_redo = Object::cast_to<EditorUndoRedoManager>(p_undo_redo);
- ERR_FAIL_COND(undo_redo.is_null());
+ Ref<EditorUndoRedoManager> undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo);
+ ERR_FAIL_COND(undo_redo_man.is_null());
-#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property));
- TileSet *tile_set = Object::cast_to<TileSet>(p_edited);
- if (tile_set) {
+#define ADD_UNDO(obj, property) undo_redo_man->add_undo_property(obj, property, obj->get(property));
+ TileSet *ed_tile_set = Object::cast_to<TileSet>(p_edited);
+ if (ed_tile_set) {
Vector<String> components = p_property.split("/", true, 3);
- for (int i = 0; i < tile_set->get_source_count(); i++) {
- int source_id = tile_set->get_source_id(i);
+ for (int i = 0; i < ed_tile_set->get_source_count(); i++) {
+ int source_id = ed_tile_set->get_source_id(i);
- Ref<TileSetAtlasSource> tas = tile_set->get_source(source_id);
+ Ref<TileSetAtlasSource> tas = ed_tile_set->get_source(source_id);
if (tas.is_valid()) {
for (int j = 0; j < tas->get_tiles_count(); j++) {
Vector2i tile_id = tas->get_tile_id(j);
diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp
index 17115519e2..364c3b7246 100644
--- a/editor/plugins/tiles/tiles_editor_plugin.cpp
+++ b/editor/plugins/tiles/tiles_editor_plugin.cpp
@@ -264,12 +264,12 @@ void TilesEditorPlugin::set_sorting_option(int p_option) {
source_sort = p_option;
}
-List<int> TilesEditorPlugin::get_sorted_sources(const Ref<TileSet> tile_set) const {
- SourceNameComparator::tile_set = tile_set;
+List<int> TilesEditorPlugin::get_sorted_sources(const Ref<TileSet> p_tile_set) const {
+ SourceNameComparator::tile_set = p_tile_set;
List<int> source_ids;
- for (int i = 0; i < tile_set->get_source_count(); i++) {
- source_ids.push_back(tile_set->get_source_id(i));
+ for (int i = 0; i < p_tile_set->get_source_count(); i++) {
+ source_ids.push_back(p_tile_set->get_source_id(i));
}
switch (source_sort) {
diff --git a/editor/plugins/tiles/tiles_editor_plugin.h b/editor/plugins/tiles/tiles_editor_plugin.h
index b1fe6f8df6..bdada9ec90 100644
--- a/editor/plugins/tiles/tiles_editor_plugin.h
+++ b/editor/plugins/tiles/tiles_editor_plugin.h
@@ -122,7 +122,7 @@ public:
// Sorting.
void set_sorting_option(int p_option);
- List<int> get_sorted_sources(const Ref<TileSet> tile_set) const;
+ List<int> get_sorted_sources(const Ref<TileSet> p_tile_set) const;
virtual void edit(Object *p_object) override;
virtual bool handles(Object *p_object) const override;
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 40993ea168..8355f64fe5 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -86,7 +86,7 @@ void VisualShaderNodePlugin::set_editor(VisualShaderEditor *p_editor) {
}
Control *VisualShaderNodePlugin::create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) {
- Object *ret;
+ Object *ret = nullptr;
if (GDVIRTUAL_CALL(_create_editor, p_parent_resource, p_node, ret)) {
return Object::cast_to<Control>(ret);
}
@@ -1235,11 +1235,11 @@ void VisualShaderEditor::_update_nodes() {
Ref<Resource> res = ResourceLoader::load(script_path);
ERR_FAIL_COND(res.is_null());
ERR_FAIL_COND(!res->is_class("Script"));
- Ref<Script> script = Ref<Script>(res);
+ Ref<Script> scr = Ref<Script>(res);
Ref<VisualShaderNodeCustom> ref;
ref.instantiate();
- ref->set_script(script);
+ ref->set_script(scr);
if (!ref->is_available(visual_shader->get_mode(), visual_shader->get_shader_type())) {
continue;
}
@@ -1278,7 +1278,7 @@ void VisualShaderEditor::_update_nodes() {
Dictionary dict;
dict["name"] = name;
- dict["script"] = script;
+ dict["script"] = scr;
dict["description"] = description;
dict["return_icon_type"] = return_icon_type;
@@ -1705,9 +1705,9 @@ void VisualShaderEditor::_update_graph() {
}
}
- List<VisualShader::Connection> connections;
- visual_shader->get_node_connections(type, &connections);
- graph_plugin->set_connections(connections);
+ List<VisualShader::Connection> node_connections;
+ visual_shader->get_node_connections(type, &node_connections);
+ graph_plugin->set_connections(node_connections);
Vector<int> nodes = visual_shader->get_node_list(type);
@@ -1724,7 +1724,7 @@ void VisualShaderEditor::_update_graph() {
graph_plugin->make_dirty(false);
- for (const VisualShader::Connection &E : connections) {
+ for (const VisualShader::Connection &E : node_connections) {
int from = E.from_node;
int from_idx = E.from_port;
int to = E.to_node;
@@ -1899,45 +1899,45 @@ void VisualShaderEditor::_expand_output_port(int p_node, int p_port, bool p_expa
visual_shader->get_node_connections(type, &conns);
for (const VisualShader::Connection &E : conns) {
- int from_node = E.from_node;
- int from_port = E.from_port;
- int to_node = E.to_node;
- int to_port = E.to_port;
+ int cn_from_node = E.from_node;
+ int cn_from_port = E.from_port;
+ int cn_to_node = E.to_node;
+ int cn_to_port = E.to_port;
- if (from_node == p_node) {
+ if (cn_from_node == p_node) {
if (p_expand) {
- if (from_port > p_port) { // reconnect ports after expanded ports
- undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
- undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port);
+ if (cn_from_port > p_port) { // reconnect ports after expanded ports
+ undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
- undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
- undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port);
+ undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
- undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port + type_size, to_node, to_port);
- undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port + type_size, to_node, to_port);
+ undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port + type_size, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port + type_size, cn_to_node, cn_to_port);
- undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port + type_size, to_node, to_port);
- undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port + type_size, to_node, to_port);
+ undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port + type_size, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port + type_size, cn_to_node, cn_to_port);
}
} else {
- if (from_port > p_port + type_size) { // reconnect ports after expanded ports
- undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
- undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port);
+ if (cn_from_port > p_port + type_size) { // reconnect ports after expanded ports
+ undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
- undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
- undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port);
+ undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
- undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, from_node, from_port - type_size, to_node, to_port);
- undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port - type_size, to_node, to_port);
+ undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, cn_from_node, cn_from_port - type_size, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port - type_size, cn_to_node, cn_to_port);
- undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port - type_size, to_node, to_port);
- undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port - type_size, to_node, to_port);
- } else if (from_port > p_port) { // disconnect component ports
- undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
- undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port);
+ undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port - type_size, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port - type_size, cn_to_node, cn_to_port);
+ } else if (cn_from_port > p_port) { // disconnect component ports
+ undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
- undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
- undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port);
+ undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
}
}
}
@@ -1973,30 +1973,30 @@ void VisualShaderEditor::_remove_input_port(int p_node, int p_port) {
List<VisualShader::Connection> conns;
visual_shader->get_node_connections(type, &conns);
for (const VisualShader::Connection &E : conns) {
- int from_node = E.from_node;
- int from_port = E.from_port;
- int to_node = E.to_node;
- int to_port = E.to_port;
-
- if (to_node == p_node) {
- if (to_port == p_port) {
- undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
- undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port);
-
- undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
- undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port);
- } else if (to_port > p_port) {
- undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
- undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port);
-
- undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
- undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port);
-
- undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port - 1);
- undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port - 1);
-
- undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port - 1);
- undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port - 1);
+ int cn_from_node = E.from_node;
+ int cn_from_port = E.from_port;
+ int cn_to_node = E.to_node;
+ int cn_to_port = E.to_port;
+
+ if (cn_to_node == p_node) {
+ if (cn_to_port == p_port) {
+ undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+
+ undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ } else if (cn_to_port > p_port) {
+ undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+
+ undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+
+ undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port - 1);
+ undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port - 1);
+
+ undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port - 1);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port - 1);
}
}
}
@@ -2022,30 +2022,30 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) {
List<VisualShader::Connection> conns;
visual_shader->get_node_connections(type, &conns);
for (const VisualShader::Connection &E : conns) {
- int from_node = E.from_node;
- int from_port = E.from_port;
- int to_node = E.to_node;
- int to_port = E.to_port;
-
- if (from_node == p_node) {
- if (from_port == p_port) {
- undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
- undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port);
-
- undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
- undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port);
- } else if (from_port > p_port) {
- undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
- undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port);
-
- undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
- undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port);
-
- undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port - 1, to_node, to_port);
- undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port - 1, to_node, to_port);
-
- undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port - 1, to_node, to_port);
- undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port - 1, to_node, to_port);
+ int cn_from_node = E.from_node;
+ int cn_from_port = E.from_port;
+ int cn_to_node = E.to_node;
+ int cn_to_port = E.to_port;
+
+ if (cn_from_node == p_node) {
+ if (cn_from_port == p_port) {
+ undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+
+ undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ } else if (cn_from_port > p_port) {
+ undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+
+ undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+
+ undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port - 1, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port - 1, cn_to_node, cn_to_port);
+
+ undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port - 1, cn_to_node, cn_to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port - 1, cn_to_node, cn_to_port);
}
}
}
@@ -2932,16 +2932,16 @@ void VisualShaderEditor::_add_varying(const String &p_name, VisualShader::Varyin
void VisualShaderEditor::_remove_varying(const String &p_name) {
undo_redo->create_action(vformat(TTR("Remove Varying from Visual Shader: %s"), p_name));
- VisualShader::VaryingMode mode = visual_shader->get_varying_mode(p_name);
+ VisualShader::VaryingMode var_mode = visual_shader->get_varying_mode(p_name);
undo_redo->add_do_method(visual_shader.ptr(), "remove_varying", p_name);
- undo_redo->add_undo_method(visual_shader.ptr(), "add_varying", p_name, mode, visual_shader->get_varying_type(p_name));
+ undo_redo->add_undo_method(visual_shader.ptr(), "add_varying", p_name, var_mode, visual_shader->get_varying_type(p_name));
undo_redo->add_do_method(this, "_update_varyings");
undo_redo->add_undo_method(this, "_update_varyings");
for (int i = 0; i <= VisualShader::TYPE_LIGHT; i++) {
- if (mode == VisualShader::VARYING_MODE_FRAG_TO_LIGHT && i == 0) {
+ if (var_mode == VisualShader::VARYING_MODE_FRAG_TO_LIGHT && i == 0) {
continue;
}
@@ -2967,10 +2967,10 @@ void VisualShaderEditor::_remove_varying(const String &p_name) {
}
}
- List<VisualShader::Connection> connections;
- visual_shader->get_node_connections(type, &connections);
+ List<VisualShader::Connection> node_connections;
+ visual_shader->get_node_connections(type, &node_connections);
- for (VisualShader::Connection &E : connections) {
+ for (VisualShader::Connection &E : node_connections) {
Ref<VisualShaderNodeVaryingGetter> var_getter = Object::cast_to<VisualShaderNodeVaryingGetter>(visual_shader->get_node(type, E.from_node).ptr());
if (var_getter.is_valid() && E.from_port > 0) {
undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
@@ -3707,7 +3707,7 @@ void VisualShaderEditor::_notification(int p_what) {
[[fallthrough]];
}
case NOTIFICATION_THEME_CHANGED: {
- highend_label->set_modulate(get_theme_color(SNAME("vulkan_color"), SNAME("Editor")));
+ highend_label->set_modulate(get_theme_color(SNAME("highend_color"), SNAME("Editor")));
node_filter->set_right_icon(Control::get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
@@ -3847,10 +3847,10 @@ void VisualShaderEditor::_dup_copy_nodes(int p_type, List<CopyItem> &r_items, Li
}
}
- List<VisualShader::Connection> connections;
- visual_shader->get_node_connections(type, &connections);
+ List<VisualShader::Connection> node_connections;
+ visual_shader->get_node_connections(type, &node_connections);
- for (const VisualShader::Connection &E : connections) {
+ for (const VisualShader::Connection &E : node_connections) {
if (nodes.has(E.from_node) && nodes.has(E.to_node)) {
r_connections.push_back(E);
}
@@ -3961,15 +3961,15 @@ void VisualShaderEditor::_duplicate_nodes() {
int type = get_current_shader_type();
List<CopyItem> items;
- List<VisualShader::Connection> connections;
+ List<VisualShader::Connection> node_connections;
- _dup_copy_nodes(type, items, connections);
+ _dup_copy_nodes(type, items, node_connections);
if (items.is_empty()) {
return;
}
- _dup_paste_nodes(type, items, connections, Vector2(10, 10) * EDSCALE, true);
+ _dup_paste_nodes(type, items, node_connections, Vector2(10, 10) * EDSCALE, true);
}
void VisualShaderEditor::_copy_nodes(bool p_cut) {
@@ -4064,11 +4064,11 @@ void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> p_input,
bool type_changed = next_input_type != prev_input_type;
- Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_undo_redo();
- undo_redo->create_action(TTR("Visual Shader Input Type Changed"));
+ Ref<EditorUndoRedoManager> undo_redo_man = EditorNode::get_undo_redo();
+ undo_redo_man->create_action(TTR("Visual Shader Input Type Changed"));
- undo_redo->add_do_method(p_input.ptr(), "set_input_name", p_name);
- undo_redo->add_undo_method(p_input.ptr(), "set_input_name", prev_name);
+ undo_redo_man->add_do_method(p_input.ptr(), "set_input_name", p_name);
+ undo_redo_man->add_undo_method(p_input.ptr(), "set_input_name", prev_name);
if (type_changed) {
for (int type_id = 0; type_id < VisualShader::TYPE_MAX; type_id++) {
@@ -4098,30 +4098,30 @@ void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> p_input,
List<VisualShader::Connection> conns;
visual_shader->get_node_connections(type, &conns);
for (const VisualShader::Connection &E : conns) {
- int from_node = E.from_node;
- int from_port = E.from_port;
- int to_node = E.to_node;
- int to_port = E.to_port;
-
- if (from_node == id) {
- bool is_incompatible_types = !visual_shader->is_port_types_compatible(p_input->get_input_type_by_name(p_name), visual_shader->get_node(type, to_node)->get_input_port_type(to_port));
-
- if (is_incompatible_types || from_port > type_size) {
- undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
- undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port);
- undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
- undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port);
+ int cn_from_node = E.from_node;
+ int cn_from_port = E.from_port;
+ int cn_to_node = E.to_node;
+ int cn_to_port = E.to_port;
+
+ if (cn_from_node == id) {
+ bool is_incompatible_types = !visual_shader->is_port_types_compatible(p_input->get_input_type_by_name(p_name), visual_shader->get_node(type, cn_to_node)->get_input_port_type(cn_to_port));
+
+ if (is_incompatible_types || cn_from_port > type_size) {
+ undo_redo_man->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ undo_redo_man->add_undo_method(visual_shader.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ undo_redo_man->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
+ undo_redo_man->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port);
}
}
}
- undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type_id, id);
- undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id);
+ undo_redo_man->add_do_method(graph_plugin.ptr(), "update_node", type_id, id);
+ undo_redo_man->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id);
}
}
}
- undo_redo->commit_action();
+ undo_redo_man->commit_action();
}
void VisualShaderEditor::_parameter_ref_select_item(Ref<VisualShaderNodeParameterRef> p_parameter_ref, String p_name) {
@@ -4133,11 +4133,11 @@ void VisualShaderEditor::_parameter_ref_select_item(Ref<VisualShaderNodeParamete
bool type_changed = p_parameter_ref->get_parameter_type_by_name(p_name) != p_parameter_ref->get_parameter_type_by_name(prev_name);
- Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_undo_redo();
- undo_redo->create_action(TTR("ParameterRef Name Changed"));
+ Ref<EditorUndoRedoManager> undo_redo_man = EditorNode::get_undo_redo();
+ undo_redo_man->create_action(TTR("ParameterRef Name Changed"));
- undo_redo->add_do_method(p_parameter_ref.ptr(), "set_parameter_name", p_name);
- undo_redo->add_undo_method(p_parameter_ref.ptr(), "set_parameter_name", prev_name);
+ undo_redo_man->add_do_method(p_parameter_ref.ptr(), "set_parameter_name", p_name);
+ undo_redo_man->add_undo_method(p_parameter_ref.ptr(), "set_parameter_name", prev_name);
// update output port
for (int type_id = 0; type_id < VisualShader::TYPE_MAX; type_id++) {
@@ -4152,20 +4152,20 @@ void VisualShaderEditor::_parameter_ref_select_item(Ref<VisualShaderNodeParamete
if (visual_shader->is_port_types_compatible(p_parameter_ref->get_parameter_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) {
continue;
}
- undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
- undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
- undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
- undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
+ undo_redo_man->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
+ undo_redo_man->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
+ undo_redo_man->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
+ undo_redo_man->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
}
}
}
- undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type_id, id);
- undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id);
+ undo_redo_man->add_do_method(graph_plugin.ptr(), "update_node", type_id, id);
+ undo_redo_man->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id);
break;
}
}
- undo_redo->commit_action();
+ undo_redo_man->commit_action();
}
void VisualShaderEditor::_varying_select_item(Ref<VisualShaderNodeVarying> p_varying, String p_name) {
@@ -4177,11 +4177,11 @@ void VisualShaderEditor::_varying_select_item(Ref<VisualShaderNodeVarying> p_var
bool is_getter = Ref<VisualShaderNodeVaryingGetter>(p_varying.ptr()).is_valid();
- Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_undo_redo();
- undo_redo->create_action(TTR("Varying Name Changed"));
+ Ref<EditorUndoRedoManager> undo_redo_man = EditorNode::get_undo_redo();
+ undo_redo_man->create_action(TTR("Varying Name Changed"));
- undo_redo->add_do_method(p_varying.ptr(), "set_varying_name", p_name);
- undo_redo->add_undo_method(p_varying.ptr(), "set_varying_name", prev_name);
+ undo_redo_man->add_do_method(p_varying.ptr(), "set_varying_name", p_name);
+ undo_redo_man->add_undo_method(p_varying.ptr(), "set_varying_name", prev_name);
VisualShader::VaryingType vtype = p_varying->get_varying_type_by_name(p_name);
VisualShader::VaryingType prev_vtype = p_varying->get_varying_type_by_name(prev_name);
@@ -4189,8 +4189,8 @@ void VisualShaderEditor::_varying_select_item(Ref<VisualShaderNodeVarying> p_var
bool type_changed = vtype != prev_vtype;
if (type_changed) {
- undo_redo->add_do_method(p_varying.ptr(), "set_varying_type", vtype);
- undo_redo->add_undo_method(p_varying.ptr(), "set_varying_type", prev_vtype);
+ undo_redo_man->add_do_method(p_varying.ptr(), "set_varying_type", vtype);
+ undo_redo_man->add_undo_method(p_varying.ptr(), "set_varying_type", prev_vtype);
}
// update ports
@@ -4209,32 +4209,32 @@ void VisualShaderEditor::_varying_select_item(Ref<VisualShaderNodeVarying> p_var
if (visual_shader->is_port_types_compatible(p_varying->get_varying_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) {
continue;
}
- undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
- undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
- undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
- undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
+ undo_redo_man->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
+ undo_redo_man->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
+ undo_redo_man->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
+ undo_redo_man->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
}
} else {
if (E.to_node == id) {
if (visual_shader->is_port_types_compatible(p_varying->get_varying_type_by_name(p_name), visual_shader->get_node(type, E.from_node)->get_output_port_type(E.from_port))) {
continue;
}
- undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
- undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
- undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
- undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
+ undo_redo_man->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
+ undo_redo_man->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
+ undo_redo_man->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
+ undo_redo_man->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
}
}
}
}
- undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type_id, id);
- undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id);
+ undo_redo_man->add_do_method(graph_plugin.ptr(), "update_node", type_id, id);
+ undo_redo_man->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id);
break;
}
}
- undo_redo->commit_action();
+ undo_redo_man->commit_action();
}
void VisualShaderEditor::_float_constant_selected(int p_which) {
@@ -4515,8 +4515,8 @@ void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
for (int i = 0; i < arr.size(); i++) {
String type = ResourceLoader::get_resource_type(arr[i]);
if (type == "GDScript") {
- Ref<Script> script = ResourceLoader::load(arr[i]);
- if (script->get_instance_base_type() == "VisualShaderNodeCustom") {
+ Ref<Script> scr = ResourceLoader::load(arr[i]);
+ if (scr->get_instance_base_type() == "VisualShaderNodeCustom") {
saved_node_pos = p_point + Vector2(0, i * 250 * EDSCALE);
saved_node_pos_dirty = true;
@@ -6229,9 +6229,9 @@ void VisualShaderNodePortPreview::_shader_changed() {
}
}
- Ref<ShaderMaterial> material;
- material.instantiate();
- material->set_shader(preview_shader);
+ Ref<ShaderMaterial> mat;
+ mat.instantiate();
+ mat->set_shader(preview_shader);
//find if a material is also being edited and copy parameters to this one
@@ -6252,12 +6252,12 @@ void VisualShaderNodePortPreview::_shader_changed() {
List<PropertyInfo> params;
src_mat->get_shader()->get_shader_uniform_list(&params);
for (const PropertyInfo &E : params) {
- material->set(E.name, src_mat->get(E.name));
+ mat->set(E.name, src_mat->get(E.name));
}
}
}
- set_material(material);
+ set_material(mat);
}
void VisualShaderNodePortPreview::setup(const Ref<VisualShader> &p_shader, VisualShader::Type p_type, int p_node, int p_port) {
diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp
index 0c0151d1a5..78f3b4de0e 100644
--- a/editor/project_converter_3_to_4.cpp
+++ b/editor/project_converter_3_to_4.cpp
@@ -230,6 +230,7 @@ static const char *gdscript_function_renames[][2] = {
{ "add_force", "apply_force" }, //RigidBody2D
{ "add_icon_override", "add_theme_icon_override" }, // Control
{ "add_scene_import_plugin", "add_scene_format_importer_plugin" }, //EditorPlugin
+ { "add_spatial_gizmo_plugin", "add_node_3d_gizmo_plugin" }, // EditorPlugin
{ "add_stylebox_override", "add_theme_stylebox_override" }, // Control
{ "add_torque", "apply_torque" }, //RigidBody2D
{ "agent_set_neighbor_dist", "agent_set_neighbor_distance" }, // NavigationServer2D, NavigationServer3D
@@ -301,6 +302,7 @@ static const char *gdscript_function_renames[][2] = {
{ "get_cull_mask_bit", "get_cull_mask_value" }, // Camera3D
{ "get_cursor_position", "get_caret_column" }, // LineEdit
{ "get_d", "get_distance" }, // LineShape2D
+ { "get_depth_bias_enable", "get_depth_bias_enabled" }, // RDPipelineRasterizationState
{ "get_drag_data", "_get_drag_data" }, // Control
{ "get_drag_data_fw", "_get_drag_data_fw" }, // ScriptEditor
{ "get_editor_viewport", "get_editor_main_screen" }, // EditorPlugin
@@ -309,6 +311,7 @@ static const char *gdscript_function_renames[][2] = {
{ "get_error_string", "get_error_message" }, // JSON
{ "get_filename", "get_scene_file_path" }, // Node, WARNING, this may be used in a lot of other places
{ "get_focus_neighbour", "get_focus_neighbor" }, // Control
+ { "get_follow_smoothing", "get_position_smoothing_speed" }, // Camera2D
{ "get_font_types", "get_font_type_list" }, // Theme
{ "get_frame_color", "get_color" }, // ColorRect
{ "get_global_rate_scale", "get_playback_speed_scale" }, // AudioServer
@@ -357,6 +360,7 @@ static const char *gdscript_function_renames[][2] = {
{ "get_render_targetsize", "get_render_target_size" }, // XRInterface
{ "get_resource_type", "_get_resource_type" }, // ResourceFormatLoader
{ "get_result", "get_data" }, //JSON
+ { "get_reverb_bus", "set_reverb_bus_name" }, // Area3D
{ "get_rpc_sender_id", "get_remote_sender_id" }, // Multiplayer API
{ "get_save_extension", "_get_save_extension" }, // EditorImportPlugin
{ "get_scancode", "get_keycode" }, // InputEventKey
@@ -367,6 +371,7 @@ static const char *gdscript_function_renames[][2] = {
{ "get_slide_count", "get_slide_collision_count" }, // CharacterBody2D, CharacterBody3D
{ "get_slips_on_slope", "get_slide_on_slope" }, // SeparationRayShape2D, SeparationRayShape3D
{ "get_space_override_mode", "get_gravity_space_override_mode" }, // Area2D
+ { "get_spatial_node", "get_node_3d" }, // EditorNode3DGizmo
{ "get_speed", "get_velocity" }, // InputEventMouseMotion
{ "get_stylebox_types", "get_stylebox_type_list" }, // Theme
{ "get_surface_material", "get_surface_override_material" }, // MeshInstance3D broke ImporterMesh
@@ -377,6 +382,7 @@ static const char *gdscript_function_renames[][2] = {
{ "get_theme_item_types", "get_theme_item_type_list" }, // Theme
{ "get_timer_process_mode", "get_timer_process_callback" }, // Timer
{ "get_translation", "get_position" }, // Node3D broke GLTFNode which is used rarely
+ { "get_unit_db", "get_volume_db" }, // AudioStreamPlayer3D
{ "get_unit_offset", "get_progress_ratio" }, // PathFollow2D, PathFollow3D
{ "get_use_in_baked_light", "is_baking_navigation" }, // GridMap
{ "get_used_cells_by_id", "get_used_cells" }, // TileMap
@@ -414,6 +420,7 @@ static const char *gdscript_function_renames[][2] = {
{ "is_commiting_action", "is_committing_action" }, // UndoRedo
{ "is_doubleclick", "is_double_click" }, // InputEventMouseButton
{ "is_draw_red", "is_draw_warning" }, // EditorProperty
+ { "is_follow_smoothing_enabled", "is_position_smoothing_enabled" }, // Camera2D
{ "is_h_drag_enabled", "is_drag_horizontal_enabled" }, // Camera2D
{ "is_handle_highlighted", "_is_handle_highlighted" }, // EditorNode3DGizmo, EditorNode3DGizmoPlugin
{ "is_inverting_faces", "get_flip_faces" }, // CSGPrimitive3D
@@ -466,6 +473,7 @@ static const char *gdscript_function_renames[][2] = {
{ "remove_font_override", "remove_theme_font_override" }, // Control
{ "remove_icon_override", "remove_theme_icon_override" }, // Control
{ "remove_scene_import_plugin", "remove_scene_format_importer_plugin" }, //EditorPlugin
+ { "remove_spatial_gizmo_plugin", "remove_node_3d_gizmo_plugin" }, // EditorPlugin
{ "remove_stylebox_override", "remove_theme_stylebox_override" }, // Control
{ "rename_animation", "rename_animation_library" }, // AnimationPlayer
{ "rename_dependencies", "_rename_dependencies" }, // ResourceFormatLoader
@@ -491,13 +499,16 @@ static const char *gdscript_function_renames[][2] = {
{ "set_cull_mask_bit", "set_cull_mask_value" }, // Camera3D
{ "set_cursor_position", "set_caret_column" }, // LineEdit
{ "set_d", "set_distance" }, // WorldMarginShape2D
+ { "set_depth_bias_enable", "set_depth_bias_enabled" }, // RDPipelineRasterizationState
{ "set_doubleclick", "set_double_click" }, // InputEventMouseButton
{ "set_draw_red", "set_draw_warning" }, // EditorProperty
+ { "set_enable_follow_smoothing", "set_position_smoothing_enabled" }, // Camera2D
{ "set_enabled_focus_mode", "set_focus_mode" }, // BaseButton
{ "set_endian_swap", "set_big_endian" }, // File
{ "set_expand_to_text_length", "set_expand_to_text_length_enabled" }, // LineEdit
{ "set_filename", "set_scene_file_path" }, // Node, WARNING, this may be used in a lot of other places
{ "set_focus_neighbour", "set_focus_neighbor" }, // Control
+ { "set_follow_smoothing", "set_position_smoothing_speed" }, // Camera2D
{ "set_frame_color", "set_color" }, // ColorRect
{ "set_global_rate_scale", "set_playback_speed_scale" }, // AudioServer
{ "set_gravity_distance_scale", "set_gravity_point_distance_scale" }, // Area2D
@@ -521,9 +532,11 @@ static const char *gdscript_function_renames[][2] = {
{ "set_oneshot", "set_one_shot" }, // AnimatedTexture
{ "set_pause_mode", "set_process_mode" }, // Node
{ "set_physical_scancode", "set_physical_keycode" }, // InputEventKey
+ { "set_proximity_fade", "set_proximity_fade_enabled" }, // Material
{ "set_refuse_new_network_connections", "set_refuse_new_connections" }, // Multiplayer API
{ "set_region", "set_region_enabled" }, // Sprite2D, Sprite broke AtlasTexture
{ "set_region_filter_clip", "set_region_filter_clip_enabled" }, // Sprite2D
+ { "set_reverb_bus", "set_reverb_bus_name" }, // Area3D
{ "set_rotate", "set_rotates" }, // PathFollow2D
{ "set_scancode", "set_keycode" }, // InputEventKey
{ "set_shift", "set_shift_pressed" }, // InputEventWithModifiers
@@ -532,6 +545,7 @@ static const char *gdscript_function_renames[][2] = {
{ "set_slips_on_slope", "set_slide_on_slope" }, // SeparationRayShape2D, SeparationRayShape3D
{ "set_sort_enabled", "set_y_sort_enabled" }, // Node2D
{ "set_space_override_mode", "set_gravity_space_override_mode" }, // Area2D
+ { "set_spatial_node", "set_node_3d" }, // EditorNode3DGizmo
{ "set_speed", "set_velocity" }, // InputEventMouseMotion
{ "set_ssao_edge_sharpness", "set_ssao_sharpness" }, // Environment
{ "set_surface_material", "set_surface_override_material" }, // MeshInstance3D broke ImporterMesh
@@ -540,6 +554,7 @@ static const char *gdscript_function_renames[][2] = {
{ "set_text_align", "set_text_alignment" }, // Button
{ "set_timer_process_mode", "set_timer_process_callback" }, // Timer
{ "set_translation", "set_position" }, // Node3D - this broke GLTFNode which is used rarely
+ { "set_unit_db", "set_volume_db" }, // AudioStreamPlayer3D
{ "set_unit_offset", "set_progress_ratio" }, // PathFollow2D, PathFollow3D
{ "set_uv2", "surface_set_uv2" }, // ImmediateMesh broke Surffacetool
{ "set_v_drag_enabled", "set_drag_vertical_enabled" }, // Camera2D
@@ -651,6 +666,7 @@ static const char *csharp_function_renames[][2] = {
// { "SetVOffset", "SetDragVerticalOffset" }, // Camera2D broke Camera3D, PathFollow3D, PathFollow2D
// {"GetPoints","GetPointsId"},// Astar, broke Line2D, Convexpolygonshape
// {"GetVScroll","GetVScrollBar"},//ItemList, broke TextView
+ { "AddSpatialGizmoPlugin", "AddNode3dGizmoPlugin" }, // EditorPlugin
{ "RenderingServer", "GetTabAlignment" }, // Tab
{ "_AboutToShow", "_AboutToPopup" }, // ColorPickerButton
{ "_GetConfigurationWarning", "_GetConfigurationWarnings" }, // Node
@@ -734,12 +750,14 @@ static const char *csharp_function_renames[][2] = {
{ "GetCullMaskBit", "GetCullMaskValue" }, // Camera3D
{ "GetCursorPosition", "GetCaretColumn" }, // LineEdit
{ "GetD", "GetDistance" }, // LineShape2D
+ { "GetDepthBiasEnable", "GetDepthBiasEnabled" }, // RDPipelineRasterizationState
{ "GetDragDataFw", "_GetDragDataFw" }, // ScriptEditor
{ "GetEditorViewport", "GetViewport" }, // EditorPlugin
{ "GetEnabledFocusMode", "GetFocusMode" }, // BaseButton
{ "GetEndianSwap", "IsBigEndian" }, // File
{ "GetErrorString", "GetErrorMessage" }, // JSON
{ "GetFocusNeighbour", "GetFocusNeighbor" }, // Control
+ { "GetFollowSmoothing", "GetFollowSmoothingSpeed" }, // Camera2D
{ "GetFontTypes", "GetFontTypeList" }, // Theme
{ "GetFrameColor", "GetColor" }, // ColorRect
{ "GetGlobalRateScale", "GetPlaybackSpeedScale" }, // AudioServer
@@ -787,6 +805,7 @@ static const char *csharp_function_renames[][2] = {
{ "GetRenderTargetsize", "GetRenderTargetSize" }, // XRInterface
{ "GetResourceType", "_GetResourceType" }, // ResourceFormatLoader
{ "GetResult", "GetData" }, //JSON
+ { "GetReverbBus", "GetReverbBusName" }, // Area3D
{ "GetRpcSenderId", "GetRemoteSenderId" }, // Multiplayer API
{ "GetSaveExtension", "_GetSaveExtension" }, // EditorImportPlugin
{ "GetScancode", "GetKeycode" }, // InputEventKey
@@ -796,6 +815,7 @@ static const char *csharp_function_renames[][2] = {
{ "GetSizeOverride", "GetSize2dOverride" }, // SubViewport
{ "GetSlipsOnSlope", "GetSlideOnSlope" }, // SeparationRayShape2D, SeparationRayShape3D
{ "GetSpaceOverrideMode", "GetGravitySpaceOverrideMode" }, // Area2D
+ { "GetSpatialNode", "GetNode3d" }, // EditorNode3DGizmo
{ "GetSpeed", "GetVelocity" }, // InputEventMouseMotion
{ "GetStyleboxTypes", "GetStyleboxTypeList" }, // Theme
{ "GetSurfaceMaterial", "GetSurfaceOverrideMaterial" }, // MeshInstance3D broke ImporterMesh
@@ -806,6 +826,7 @@ static const char *csharp_function_renames[][2] = {
{ "GetThemeItemTypes", "GetThemeItemTypeList" }, // Theme
{ "GetTimerProcessMode", "GetTimerProcessCallback" }, // Timer
{ "GetTranslation", "GetPosition" }, // Node3D broke GLTFNode which is used rarely
+ { "GetUnitDb", "GetVolumeDb" }, // AudioStreamPlayer3D
{ "GetUnitOffset", "GetProgressRatio" }, // PathFollow2D, PathFollow3D
{ "GetUseInBakedLight", "IsBakingNavigation" }, // GridMap
{ "GetUsedCellsById", "GetUsedCells" }, // TileMap
@@ -842,6 +863,7 @@ static const char *csharp_function_renames[][2] = {
{ "IsAParentOf", "IsAncestorOf" }, // Node
{ "IsCommitingAction", "IsCommittingAction" }, // UndoRedo
{ "IsDoubleclick", "IsDoubleClick" }, // InputEventMouseButton
+ { "IsFollowSmoothingEnabled", "IsPositionSmoothingEnabled" }, // Camera2D
{ "IsHDragEnabled", "IsDragHorizontalEnabled" }, // Camera2D
{ "IsHandleHighlighted", "_IsHandleHighlighted" }, // EditorNode3DGizmo, EditorNode3DGizmoPlugin
{ "IsNetworkMaster", "IsMultiplayerAuthority" }, // Node
@@ -890,6 +912,7 @@ static const char *csharp_function_renames[][2] = {
{ "RemoveConstantOverride", "RemoveThemeConstantOverride" }, // Control
{ "RemoveFontOverride", "RemoveThemeFontOverride" }, // Control
{ "RemoveSceneImportPlugin", "RemoveSceneFormatImporterPlugin" }, //EditorPlugin
+ { "RemoveSpatialGizmoPlugin", "RemoveNode3dGizmoPlugin" }, // EditorPlugin
{ "RemoveStyleboxOverride", "RemoveThemeStyleboxOverride" }, // Control
{ "RenameAnimation", "RenameAnimationLibrary" }, // AnimationPlayer
{ "RenameDependencies", "_RenameDependencies" }, // ResourceFormatLoader
@@ -915,11 +938,14 @@ static const char *csharp_function_renames[][2] = {
{ "SetCullMaskBit", "SetCullMaskValue" }, // Camera3D
{ "SetCursorPosition", "SetCaretColumn" }, // LineEdit
{ "SetD", "SetDistance" }, // WorldMarginShape2D
+ { "SetDepthBiasEnable", "SetDepthBiasEnabled" }, // RDPipelineRasterizationState
{ "SetDoubleclick", "SetDoubleClick" }, // InputEventMouseButton
+ { "SetEnableFollowSmoothing", "SetFollowSmoothingEnabled" }, // Camera2D
{ "SetEnabledFocusMode", "SetFocusMode" }, // BaseButton
{ "SetEndianSwap", "SetBigEndian" }, // File
{ "SetExpandToTextLength", "SetExpandToTextLengthEnabled" }, // LineEdit
{ "SetFocusNeighbour", "SetFocusNeighbor" }, // Control
+ { "SetFollowSmoothing", "SetFollowSmoothingSpeed" }, // Camera2D
{ "SetFrameColor", "SetColor" }, // ColorRect
{ "SetGlobalRateScale", "SetPlaybackSpeedScale" }, // AudioServer
{ "SetGravityDistanceScale", "SetGravityPointDistanceScale" }, // Area2D
@@ -941,9 +967,11 @@ static const char *csharp_function_renames[][2] = {
{ "SetNetworkPeer", "SetMultiplayerPeer" }, // Multiplayer API
{ "SetOneshot", "SetOneShot" }, // AnimatedTexture
{ "SetPhysicalScancode", "SetPhysicalKeycode" }, // InputEventKey
+ { "SetProximityFade", "SetProximityFadeEnabled" }, // Material
{ "SetRefuseNewNetworkConnections", "SetRefuseNewConnections" }, // Multiplayer API
{ "SetRegion", "SetRegionEnabled" }, // Sprite2D, Sprite broke AtlasTexture
{ "SetRegionFilterClip", "SetRegionFilterClipEnabled" }, // Sprite2D
+ { "SetReverbBus", "SetReverbBusName" }, // Area3D
{ "SetRotate", "SetRotates" }, // PathFollow2D
{ "SetScancode", "SetKeycode" }, // InputEventKey
{ "SetShift", "SetShiftPressed" }, // InputEventWithModifiers
@@ -952,6 +980,7 @@ static const char *csharp_function_renames[][2] = {
{ "SetSlipsOnSlope", "SetSlideOnSlope" }, // SeparationRayShape2D, SeparationRayShape3D
{ "SetSortEnabled", "SetYSortEnabled" }, // Node2D
{ "SetSpaceOverrideMode", "SetGravitySpaceOverrideMode" }, // Area2D
+ { "SetSpatialNode", "SetNode3d" }, // EditorNode3DGizmo
{ "SetSpeed", "SetVelocity" }, // InputEventMouseMotion
{ "SetSsaoEdgeSharpness", "SetSsaoSharpness" }, // Environment
{ "SetSurfaceMaterial", "SetSurfaceOverrideMaterial" }, // MeshInstance3D broke ImporterMesh
@@ -961,6 +990,7 @@ static const char *csharp_function_renames[][2] = {
{ "SetTimerProcessMode", "SetTimerProcessCallback" }, // Timer
{ "SetTonemapAutoExposure", "SetTonemapAutoExposureEnabled" }, // Environment
{ "SetTranslation", "SetPosition" }, // Node3D - this broke GLTFNode which is used rarely
+ { "SetUnitDb", "SetVolumeDb" }, // AudioStreamPlayer3D
{ "SetUnitOffset", "SetProgressRatio" }, // PathFollow2D, PathFollow3D
{ "SetUv2", "SurfaceSetUv2" }, // ImmediateMesh broke Surffacetool
{ "SetVDragEnabled", "SetDragVerticalEnabled" }, // Camera2D
@@ -1059,6 +1089,7 @@ static const char *gdscript_properties_renames[][2] = {
{ "close_v_ofs", "close_v_offset" }, // Theme
{ "commentfocus", "comment_focus" }, // Theme
{ "contacts_reported", "max_contacts_reported" }, // RigidBody
+ { "depth_bias_enable", "depth_bias_enabled" }, // RDPipelineRasterizationState
{ "drag_margin_bottom", "drag_bottom_margin" }, // Camera2D
{ "drag_margin_h_enabled", "drag_horizontal_enabled" }, // Camera2D
{ "drag_margin_left", "drag_left_margin" }, // Camera2D
@@ -1101,6 +1132,7 @@ static const char *gdscript_properties_renames[][2] = {
{ "pause_mode", "process_mode" }, // Node
{ "physical_scancode", "physical_keycode" }, // InputEventKey
{ "popup_exclusive", "exclusive" }, // Window
+ { "proximity_fade_enable", "proximity_fade_enabled" }, // Material
{ "rect_position", "position" }, // Control
{ "rect_global_position", "global_position" }, // Control
{ "rect_size", "size" }, // Control
@@ -1111,9 +1143,12 @@ static const char *gdscript_properties_renames[][2] = {
{ "rect_clip_content", "clip_contents" }, // Control
{ "refuse_new_network_connections", "refuse_new_connections" }, // MultiplayerAPI
{ "region_filter_clip", "region_filter_clip_enabled" }, // Sprite2D
+ { "reverb_bus_enable", "reverb_bus_enabled" }, // Area3D
{ "selectedframe", "selected_frame" }, // Theme
{ "size_override_stretch", "size_2d_override_stretch" }, // SubViewport
{ "slips_on_slope", "slide_on_slope" }, // SeparationRayShape2D
+ { "smoothing_enabled", "follow_smoothing_enabled" }, // Camera2D
+ { "smoothing_speed", "position_smoothing_speed" }, // Camera2D
{ "ss_reflections_depth_tolerance", "ssr_depth_tolerance" }, // Environment
{ "ss_reflections_enabled", "ssr_enabled" }, // Environment
{ "ss_reflections_fade_in", "ssr_fade_in" }, // Environment
@@ -1125,6 +1160,7 @@ static const char *gdscript_properties_renames[][2] = {
{ "table_hseparation", "table_h_separation" }, // Theme
{ "table_vseparation", "table_v_separation" }, // Theme
{ "translation", "position" }, // Node3D - broke GLTFNode
+ { "unit_db", "volume_db" }, // AudioStreamPlayer3D
{ "unit_offset", "progress_ratio" }, // PathFollow2D, PathFollow3D
{ "vseparation", "v_separation" }, // Theme
@@ -1164,6 +1200,7 @@ static const char *csharp_properties_renames[][2] = {
{ "CloseHOfs", "CloseHOffset" }, // Theme
{ "CloseVOfs", "CloseVOffset" }, // Theme
{ "Commentfocus", "CommentFocus" }, // Theme
+ { "DepthBiasEnable", "DepthBiasEnabled" }, // RDPipelineRasterizationState
{ "DragMarginBottom", "DragBottomMargin" }, // Camera2D
{ "DragMarginHEnabled", "DragHorizontalEnabled" }, // Camera2D
{ "DragMarginLeft", "DragLeftMargin" }, // Camera2D
@@ -1199,11 +1236,15 @@ static const char *csharp_properties_renames[][2] = {
{ "PauseMode", "ProcessMode" }, // Node
{ "PhysicalScancode", "PhysicalKeycode" }, // InputEventKey
{ "PopupExclusive", "Exclusive" }, // Window
+ { "ProximityFadeEnable", "ProximityFadeEnabled" }, // Material
{ "RefuseNewNetworkConnections", "RefuseNewConnections" }, // MultiplayerAPI
{ "RegionFilterClip", "RegionFilterClipEnabled" }, // Sprite2D
+ { "ReverbBusEnable", "ReverbBusEnabled" }, // Area3D
{ "Selectedframe", "SelectedFrame" }, // Theme
{ "SizeOverrideStretch", "Size2dOverrideStretch" }, // SubViewport
{ "SlipsOnSlope", "SlideOnSlope" }, // SeparationRayShape2D
+ { "SmoothingEnabled", "FollowSmoothingEnabled" }, // Camera2D
+ { "SmoothingSpeed", "FollowSmoothingSpeed" }, // Camera2D
{ "SsReflectionsDepthTolerance", "SsrDepthTolerance" }, // Environment
{ "SsReflectionsEnabled", "SsrEnabled" }, // Environment
{ "SsReflectionsFadeIn", "SsrFadeIn" }, // Environment
@@ -1215,6 +1256,7 @@ static const char *csharp_properties_renames[][2] = {
{ "TableHseparation", "TableHSeparation" }, // Theme
{ "TableVseparation", "TableVSeparation" }, // Theme
{ "Translation", "Position" }, // Node3D - broke GLTFNode
+ { "UnitDb", "VolumeDb" }, // AudioStreamPlayer3D
{ "UnitOffset", "ProgressRatio" }, // PathFollow2D, PathFollow3D
{ "Vseparation", "VSeparation" }, // Theme
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 673da8872d..5a1eedd8a2 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -143,7 +143,11 @@ private:
install_status_rect->set_texture(new_icon);
}
- set_size(Size2(500, 0) * EDSCALE);
+ Size2i window_size = get_size();
+ Size2 contents_min_size = get_contents_minimum_size();
+ if (window_size.x < contents_min_size.x || window_size.y < contents_min_size.y) {
+ set_size(window_size.max(contents_min_size));
+ }
}
String _test_path() {
@@ -563,19 +567,19 @@ private:
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
da->make_dir(dir.path_join(rel_path));
} else {
- Vector<uint8_t> data;
- data.resize(info.uncompressed_size);
+ Vector<uint8_t> uncomp_data;
+ uncomp_data.resize(info.uncompressed_size);
String rel_path = path.substr(zip_root.length());
//read
unzOpenCurrentFile(pkg);
- ret = unzReadCurrentFile(pkg, data.ptrw(), data.size());
+ ret = unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size());
ERR_BREAK_MSG(ret < 0, vformat("An error occurred while attempting to read from file: %s. This file will not be used.", rel_path));
unzCloseCurrentFile(pkg);
Ref<FileAccess> f = FileAccess::open(dir.path_join(rel_path), FileAccess::WRITE);
if (f.is_valid()) {
- f->store_buffer(data.ptr(), data.size());
+ f->store_buffer(uncomp_data.ptr(), uncomp_data.size());
} else {
failed_files.push_back(rel_path);
}
@@ -1490,7 +1494,7 @@ void ProjectList::sort_projects() {
for (int i = 0; i < _projects.size(); ++i) {
Item &item = _projects.write[i];
- bool visible = true;
+ bool item_visible = true;
if (!_search_term.is_empty()) {
String search_path;
if (_search_term.contains("/")) {
@@ -1502,10 +1506,10 @@ void ProjectList::sort_projects() {
}
// When searching, display projects whose name or path contain the search term
- visible = item.project_name.findn(_search_term) != -1 || search_path.findn(_search_term) != -1;
+ item_visible = item.project_name.findn(_search_term) != -1 || search_path.findn(_search_term) != -1;
}
- item.control->set_visible(visible);
+ item.control->set_visible(item_visible);
}
for (int i = 0; i < _projects.size(); ++i) {
@@ -2594,6 +2598,12 @@ ProjectManager::ProjectManager() {
EditorFileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files"));
+ int swap_cancel_ok = EDITOR_GET("interface/editor/accept_dialog_cancel_ok_buttons");
+ if (swap_cancel_ok != 0) { // 0 is auto, set in register_scene based on DisplayServer.
+ // Swap on means OK first.
+ AcceptDialog::set_swap_cancel_ok(swap_cancel_ok == 2);
+ }
+
set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
set_theme(create_custom_theme());
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 2da49f11cc..8175f356c7 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -36,6 +36,7 @@
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
+#include "scene/gui/check_button.h"
#include "servers/movie_writer/movie_writer.h"
ProjectSettingsEditor *ProjectSettingsEditor::singleton = nullptr;
@@ -72,6 +73,11 @@ void ProjectSettingsEditor::set_plugins_page() {
tab_container->set_current_tab(tab_container->get_tab_idx_from_control(plugin_settings));
}
+void ProjectSettingsEditor::set_general_page(const String &p_category) {
+ tab_container->set_current_tab(tab_container->get_tab_idx_from_control(general_editor));
+ general_settings_inspector->set_current_section(p_category);
+}
+
void ProjectSettingsEditor::update_plugins() {
plugin_settings->update_plugins();
}
@@ -356,12 +362,12 @@ void ProjectSettingsEditor::_action_edited(const String &p_name, const Dictionar
} else {
// Events changed
- int event_count = ((Array)p_action["events"]).size();
+ int act_event_count = ((Array)p_action["events"]).size();
int old_event_count = ((Array)old_val["events"]).size();
- if (event_count == old_event_count) {
+ if (act_event_count == old_event_count) {
undo_redo->create_action(TTR("Edit Input Action Event"));
- } else if (event_count > old_event_count) {
+ } else if (act_event_count > old_event_count) {
undo_redo->create_action(TTR("Add Input Action Event"));
} else {
undo_redo->create_action(TTR("Remove Input Action Event"));
@@ -575,7 +581,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
tab_container->set_theme_type_variation("TabContainerOdd");
add_child(tab_container);
- VBoxContainer *general_editor = memnew(VBoxContainer);
+ general_editor = memnew(VBoxContainer);
general_editor->set_name(TTR("General"));
general_editor->set_alignment(BoxContainer::ALIGNMENT_BEGIN);
general_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h
index 040d992e40..ec10c76cb7 100644
--- a/editor/project_settings_editor.h
+++ b/editor/project_settings_editor.h
@@ -53,6 +53,7 @@ class ProjectSettingsEditor : public AcceptDialog {
Timer *timer = nullptr;
TabContainer *tab_container = nullptr;
+ VBoxContainer *general_editor = nullptr;
SectionedInspector *general_settings_inspector = nullptr;
ActionMapEditor *action_map_editor = nullptr;
LocalizationEditor *localization_editor = nullptr;
@@ -116,6 +117,7 @@ public:
static ProjectSettingsEditor *get_singleton() { return singleton; }
void popup_project_settings();
void set_plugins_page();
+ void set_general_page(const String &p_category);
void update_plugins();
EditorAutoloadSettings *get_autoload_settings() { return autoload_settings; }
diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp
index 300a3d0f05..f918570c66 100644
--- a/editor/rename_dialog.cpp
+++ b/editor/rename_dialog.cpp
@@ -652,9 +652,9 @@ void RenameDialog::_features_toggled(bool pressed) {
}
// Adjust to minimum size in y
- Size2i size = get_size();
- size.y = 0;
- set_size(size);
+ Size2i new_size = get_size();
+ new_size.y = 0;
+ set_size(new_size);
}
#endif // MODULE_REGEX_ENABLED
diff --git a/editor/scene_create_dialog.cpp b/editor/scene_create_dialog.cpp
index 4563dbb0f7..5b54a5a229 100644
--- a/editor/scene_create_dialog.cpp
+++ b/editor/scene_create_dialog.cpp
@@ -170,9 +170,9 @@ Node *SceneCreateDialog::create_scene_root() {
root = memnew(Node3D);
break;
case ROOT_USER_INTERFACE: {
- Control *gui = memnew(Control);
- gui->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
- root = gui;
+ Control *gui_ctl = memnew(Control);
+ gui_ctl->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
+ root = gui_ctl;
} break;
case ROOT_OTHER:
root = Object::cast_to<Node>(select_node_dialog->instance_selected());
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index d1dc188be9..ee358a8064 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -330,9 +330,9 @@ bool SceneTreeDock::_track_inherit(const String &p_target_scene_path, Node *p_de
Ref<SceneState> ss = p->get_scene_inherited_state();
if (ss.is_valid()) {
String path = ss->get_path();
- Ref<PackedScene> data = ResourceLoader::load(path);
- if (data.is_valid()) {
- p = data->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ Ref<PackedScene> pack_data = ResourceLoader::load(path);
+ if (pack_data.is_valid()) {
+ p = pack_data->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
if (!p) {
continue;
}
@@ -1147,9 +1147,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
String name = selected_favorite_root.get_slicec(' ', 0);
if (ScriptServer::is_global_class(name)) {
new_node = Object::cast_to<Node>(ClassDB::instantiate(ScriptServer::get_global_class_native_base(name)));
- Ref<Script> script = ResourceLoader::load(ScriptServer::get_global_class_path(name), "Script");
- if (new_node && script.is_valid()) {
- new_node->set_script(script);
+ Ref<Script> scr = ResourceLoader::load(ScriptServer::get_global_class_path(name), "Script");
+ if (new_node && scr.is_valid()) {
+ new_node->set_script(scr);
new_node->set_name(name);
}
} else {
@@ -1187,6 +1187,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
default: {
+ _filter_option_selected(p_tool);
+
if (p_tool >= EDIT_SUBRESOURCE_BASE) {
int idx = p_tool - EDIT_SUBRESOURCE_BASE;
@@ -2174,11 +2176,15 @@ void SceneTreeDock::_selection_changed() {
void SceneTreeDock::_do_create(Node *p_parent) {
Variant c = create_dialog->instance_selected();
-
- ERR_FAIL_COND(!c);
Node *child = Object::cast_to<Node>(c);
ERR_FAIL_COND(!child);
+ String new_name = p_parent->validate_child_name(child);
+ if (GLOBAL_GET("editor/node_naming/name_casing").operator int() != NAME_CASING_PASCAL_CASE) {
+ new_name = adjust_name_casing(new_name);
+ }
+ child->set_name(new_name);
+
editor_data->get_undo_redo()->create_action_for_history(TTR("Create Node"), editor_data->get_current_edited_scene_history_id());
if (edited_scene) {
@@ -2189,7 +2195,6 @@ void SceneTreeDock::_do_create(Node *p_parent) {
editor_data->get_undo_redo()->add_do_reference(child);
editor_data->get_undo_redo()->add_undo_method(p_parent, "remove_child", child);
- String new_name = p_parent->validate_child_name(child);
EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton();
editor_data->get_undo_redo()->add_do_method(ed, "live_debug_create_node", edited_scene->get_path_to(p_parent), child->get_class(), new_name);
editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(p_parent)).path_join(new_name)));
@@ -2883,11 +2888,83 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
void SceneTreeDock::_update_tree_menu() {
PopupMenu *tree_menu = button_tree_menu->get_popup();
- tree_menu->set_item_checked(tree_menu->get_item_idx_from_text(TTR("Auto Expand to Selected")), EditorSettings::get_singleton()->get("docks/scene_tree/auto_expand_to_selected"));
+ tree_menu->clear();
+
+ _append_filter_options_to(tree_menu);
+
+ tree_menu->add_separator();
+ tree_menu->add_check_item(TTR("Auto Expand to Selected"), TOOL_AUTO_EXPAND);
+ tree_menu->set_item_checked(tree_menu->get_item_index(TOOL_AUTO_EXPAND), EditorSettings::get_singleton()->get("docks/scene_tree/auto_expand_to_selected"));
+}
+
+void SceneTreeDock::_update_filter_menu() {
+ _append_filter_options_to(filter->get_menu());
}
void SceneTreeDock::_filter_changed(const String &p_filter) {
scene_tree->set_filter(p_filter);
+
+ String warning = scene_tree->get_filter_term_warning();
+ if (!warning.is_empty()) {
+ filter->add_theme_icon_override(SNAME("clear"), get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")));
+ filter->set_tooltip_text(warning);
+ } else {
+ filter->remove_theme_icon_override(SNAME("clear"));
+ filter->set_tooltip_text("");
+ }
+}
+
+void SceneTreeDock::_filter_gui_input(const Ref<InputEvent> &p_event) {
+ Ref<InputEventMouseButton> mb = p_event;
+ if (mb.is_null()) {
+ return;
+ }
+
+ if (mb->is_pressed() && mb->get_button_index() == MouseButton::MIDDLE) {
+ filter_quick_menu->clear();
+
+ _append_filter_options_to(filter_quick_menu, false);
+ filter_quick_menu->set_position(get_screen_position() + get_local_mouse_position());
+ filter_quick_menu->reset_size();
+ filter_quick_menu->popup();
+ filter_quick_menu->grab_focus();
+ accept_event();
+ }
+}
+
+void SceneTreeDock::_filter_option_selected(int p_option) {
+ String filter_parameter;
+ switch (p_option) {
+ case FILTER_BY_TYPE: {
+ filter_parameter = "type";
+ } break;
+ case FILTER_BY_GROUP: {
+ filter_parameter = "group";
+ } break;
+ }
+
+ if (!filter_parameter.is_empty()) {
+ set_filter((get_filter() + " " + filter_parameter + ":").strip_edges());
+ filter->set_caret_column(filter->get_text().length());
+ filter->grab_focus();
+ }
+}
+
+void SceneTreeDock::_append_filter_options_to(PopupMenu *p_menu, bool p_include_separator) {
+ if (p_include_separator) {
+ p_menu->add_separator();
+
+ p_menu->set_item_text(-1, TTR("Filters"));
+ p_menu->set_item_icon(-1, get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
+ p_menu->set_item_indent(-1, -2);
+ }
+
+ p_menu->add_item(TTR("Filter by Type"), FILTER_BY_TYPE);
+ p_menu->add_item(TTR("Filter by Group"), FILTER_BY_GROUP);
+ p_menu->set_item_icon(p_menu->get_item_index(FILTER_BY_TYPE), get_theme_icon(SNAME("Node"), SNAME("EditorIcons")));
+ p_menu->set_item_icon(p_menu->get_item_index(FILTER_BY_GROUP), get_theme_icon(SNAME("Groups"), SNAME("EditorIcons")));
+ p_menu->set_item_tooltip(p_menu->get_item_index(FILTER_BY_TYPE), TTR("Selects all Nodes of the given type."));
+ p_menu->set_item_tooltip(p_menu->get_item_index(FILTER_BY_GROUP), TTR("Selects all Nodes belonging to the given group.\nIf empty, selects any Node belonging to any group."));
}
String SceneTreeDock::get_filter() {
@@ -3399,14 +3476,22 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec
button_instance->set_tooltip_text(TTR("Instantiate a scene file as a Node. Creates an inherited scene if no root node exists."));
button_instance->set_shortcut(ED_GET_SHORTCUT("scene_tree/instance_scene"));
filter_hbc->add_child(button_instance);
-
vbc->add_child(filter_hbc);
+
+ // The "Filter Nodes" text input above the Scene Tree Editor.
filter = memnew(LineEdit);
filter->set_h_size_flags(SIZE_EXPAND_FILL);
filter->set_placeholder(TTR("Filter Nodes"));
filter_hbc->add_child(filter);
filter->add_theme_constant_override("minimum_character_width", 0);
filter->connect("text_changed", callable_mp(this, &SceneTreeDock::_filter_changed));
+ filter->connect("gui_input", callable_mp(this, &SceneTreeDock::_filter_gui_input));
+ filter->get_menu()->connect("about_to_popup", callable_mp(this, &SceneTreeDock::_update_filter_menu));
+ filter->get_menu()->connect("id_pressed", callable_mp(this, &SceneTreeDock::_filter_option_selected));
+
+ filter_quick_menu = memnew(PopupMenu);
+ filter_quick_menu->connect("id_pressed", callable_mp(this, &SceneTreeDock::_filter_option_selected));
+ filter->add_child(filter_quick_menu);
button_create_script = memnew(Button);
button_create_script->set_flat(true);
@@ -3430,7 +3515,6 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec
filter_hbc->add_child(button_tree_menu);
PopupMenu *tree_menu = button_tree_menu->get_popup();
- tree_menu->add_check_item(TTR("Auto Expand to Selected"), TOOL_AUTO_EXPAND);
tree_menu->connect("id_pressed", callable_mp(this, &SceneTreeDock::_tool_selected).bind(false));
button_hb = memnew(HBoxContainer);
diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h
index e48b518252..04bb4d93e7 100644
--- a/editor/scene_tree_dock.h
+++ b/editor/scene_tree_dock.h
@@ -160,7 +160,13 @@ class SceneTreeDock : public VBoxContainer {
EditorQuickOpen *quick_open = nullptr;
EditorFileDialog *new_scene_from_dialog = nullptr;
+ enum FilterMenuItems {
+ FILTER_BY_TYPE = 64, // Used in the same menus as the Tool enum.
+ FILTER_BY_GROUP,
+ };
+
LineEdit *filter = nullptr;
+ PopupMenu *filter_quick_menu = nullptr;
TextureRect *filter_icon = nullptr;
PopupMenu *menu = nullptr;
@@ -243,8 +249,12 @@ class SceneTreeDock : public VBoxContainer {
void _tree_rmb(const Vector2 &p_menu_pos);
void _update_tree_menu();
+ void _update_filter_menu();
void _filter_changed(const String &p_filter);
+ void _filter_gui_input(const Ref<InputEvent> &p_event);
+ void _filter_option_selected(int option);
+ void _append_filter_options_to(PopupMenu *p_menu, bool p_include_separator = true);
void _perform_instantiate_scenes(const Vector<String> &p_files, Node *parent, int p_pos);
void _replace_with_branch_scene(const String &p_file, Node *base);
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index 7bcc8aa078..da727a127a 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -215,8 +215,8 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
if (connect_to_script_mode) {
Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
- Ref<Script> script = p_node->get_script();
- if (!script.is_null() && EditorNode::get_singleton()->get_object_custom_type_base(p_node) != script) {
+ Ref<Script> scr = p_node->get_script();
+ if (!scr.is_null() && EditorNode::get_singleton()->get_object_custom_type_base(p_node) != scr) {
//has script
item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT);
} else {
@@ -224,7 +224,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
item->set_custom_color(0, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")));
item->set_selectable(0, false);
- if (!script.is_null()) { // make sure to mark the script if a custom type
+ if (!scr.is_null()) { // make sure to mark the script if a custom type
item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT);
item->set_button_disabled(0, item->get_button_count(0) - 1, true);
}
@@ -268,8 +268,8 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
if (can_rename) { //should be can edit..
- String warning = p_node->get_configuration_warnings_as_string();
- if (!warning.is_empty()) {
+ String conf_warning = p_node->get_configuration_warnings_as_string();
+ if (!conf_warning.is_empty()) {
const int num_warnings = p_node->get_configuration_warnings().size();
String warning_icon;
if (num_warnings == 1) {
@@ -284,15 +284,15 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
const String bullet_point = String::utf8("• ");
int next_newline = 0;
while (next_newline != -1) {
- next_newline = warning.find("\n", next_newline + 2);
- if (warning.substr(next_newline + 1, bullet_point.length()) != bullet_point) {
- warning = warning.insert(next_newline + 1, " ");
+ next_newline = conf_warning.find("\n", next_newline + 2);
+ if (conf_warning.substr(next_newline + 1, bullet_point.length()) != bullet_point) {
+ conf_warning = conf_warning.insert(next_newline + 1, " ");
}
}
String newline = (num_warnings == 1 ? "\n" : "\n\n");
- item->add_button(0, get_theme_icon(warning_icon, SNAME("EditorIcons")), BUTTON_WARNING, false, TTR("Node configuration warning:") + newline + warning);
+ item->add_button(0, get_theme_icon(warning_icon, SNAME("EditorIcons")), BUTTON_WARNING, false, TTR("Node configuration warning:") + newline + conf_warning);
}
if (p_node->is_unique_name_in_owner()) {
@@ -385,20 +385,20 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
p_node->connect("script_changed", callable_mp(this, &SceneTreeEditor::_node_script_changed).bind(p_node));
}
- Ref<Script> script = p_node->get_script();
- if (!script.is_null()) {
+ Ref<Script> scr = p_node->get_script();
+ if (!scr.is_null()) {
String additional_notes;
Color button_color = Color(1, 1, 1);
// Can't set tooltip after adding button, need to do it before.
- if (script->is_tool()) {
+ if (scr->is_tool()) {
additional_notes += "\n" + TTR("This script is currently running in the editor.");
button_color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
}
- if (EditorNode::get_singleton()->get_object_custom_type_base(p_node) == script) {
+ if (EditorNode::get_singleton()->get_object_custom_type_base(p_node) == scr) {
additional_notes += "\n" + TTR("This script is a custom type.");
button_color.a = 0.5;
}
- item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path() + additional_notes);
+ item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + scr->get_path() + additional_notes);
item->set_button_color(0, item->get_button_count(0) - 1, button_color);
}
@@ -511,16 +511,16 @@ void SceneTreeEditor::_node_visibility_changed(Node *p_node) {
int idx = item->get_button_by_id(0, BUTTON_VISIBILITY);
ERR_FAIL_COND(idx == -1);
- bool visible = false;
+ bool node_visible = false;
if (p_node->is_class("CanvasItem") || p_node->is_class("CanvasLayer") || p_node->is_class("Window")) {
- visible = p_node->call("is_visible");
+ node_visible = p_node->call("is_visible");
CanvasItemEditor::get_singleton()->get_viewport_control()->queue_redraw();
} else if (p_node->is_class("Node3D")) {
- visible = p_node->call("is_visible");
+ node_visible = p_node->call("is_visible");
}
- if (visible) {
+ if (node_visible) {
item->set_button(0, idx, get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")));
} else {
item->set_button(0, idx, get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons")));
@@ -612,6 +612,7 @@ void SceneTreeEditor::_update_tree(bool p_scroll_to_selected) {
bool SceneTreeEditor::_update_filter(TreeItem *p_parent, bool p_scroll_to_selected) {
if (!p_parent) {
p_parent = tree->get_root();
+ filter_term_warning.clear();
}
if (!p_parent) {
@@ -673,27 +674,37 @@ bool SceneTreeEditor::_item_matches_all_terms(TreeItem *p_item, PackedStringArra
if (parameter == "type" || parameter == "t") {
// Filter by Type.
- String node_type = get_node(p_item->get_metadata(0))->get_class().to_lower();
+ String type = get_node(p_item->get_metadata(0))->get_class();
+ bool term_in_inherited_class = false;
+ // Every Node is is a Node, duh!
+ while (type != "Node") {
+ if (type.to_lower().contains(argument)) {
+ term_in_inherited_class = true;
+ break;
+ }
- if (!node_type.contains(argument)) {
+ type = ClassDB::get_parent_class(type);
+ }
+ if (!term_in_inherited_class) {
return false;
}
} else if (parameter == "group" || parameter == "g") {
// Filter by Group.
Node *node = get_node(p_item->get_metadata(0));
- List<Node::GroupInfo> group_info_list;
- node->get_groups(&group_info_list);
- if (group_info_list.is_empty()) {
- return false;
- }
- // When argument is empty, match all Nodes belonging to any group.
- if (!argument.is_empty()) {
+ if (argument.is_empty()) {
+ // When argument is empty, match all Nodes belonging to any exposed group.
+ if (node->get_persistent_group_count() == 0) {
+ return false;
+ }
+ } else {
+ List<Node::GroupInfo> group_info_list;
+ node->get_groups(&group_info_list);
+
bool term_in_groups = false;
for (int j = 0; j < group_info_list.size(); j++) {
- // Ignore private groups.
- if (String(group_info_list[j].name).begins_with("__")) {
- continue;
+ if (!group_info_list[j].persistent) {
+ continue; // Ignore internal groups.
}
if (String(group_info_list[j].name).to_lower().contains(argument)) {
term_in_groups = true;
@@ -704,8 +715,8 @@ bool SceneTreeEditor::_item_matches_all_terms(TreeItem *p_item, PackedStringArra
return false;
}
}
- } else {
- WARN_PRINT(vformat(TTR("Special Node filter \"%s\" is not recognised. Available filters include \"type\" and \"group\"."), parameter));
+ } else if (filter_term_warning.is_empty()) {
+ filter_term_warning = vformat(TTR("\"%s\" is not a known filter."), parameter);
continue;
}
} else {
@@ -804,6 +815,10 @@ void SceneTreeEditor::_cell_multi_selected(Object *p_object, int p_cell, bool p_
TreeItem *item = Object::cast_to<TreeItem>(p_object);
ERR_FAIL_COND(!item);
+ if (!item->is_visible()) {
+ return;
+ }
+
NodePath np = item->get_metadata(0);
Node *n = get_node(np);
@@ -1025,6 +1040,10 @@ String SceneTreeEditor::get_filter() const {
return filter;
}
+String SceneTreeEditor::get_filter_term_warning() {
+ return filter_term_warning;
+}
+
void SceneTreeEditor::set_undo_redo(Ref<EditorUndoRedoManager> p_undo_redo) {
undo_redo = p_undo_redo;
}
@@ -1119,7 +1138,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from
return Variant(); //dragging from button
}
- Vector<Node *> selected;
+ Vector<Node *> selected_nodes;
Vector<Ref<Texture2D>> icons;
TreeItem *next = tree->get_next_selected(nullptr);
while (next) {
@@ -1129,14 +1148,14 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from
if (n) {
// Only allow selection if not part of an instantiated scene.
if (!n->get_owner() || n->get_owner() == get_scene_node() || n->get_owner()->get_scene_file_path().is_empty()) {
- selected.push_back(n);
+ selected_nodes.push_back(n);
icons.push_back(next->get_icon(0));
}
}
next = tree->get_next_selected(next);
}
- if (selected.is_empty()) {
+ if (selected_nodes.is_empty()) {
return Variant();
}
@@ -1145,20 +1164,20 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from
int list_max = 10;
float opacity_step = 1.0f / list_max;
float opacity_item = 1.0f;
- for (int i = 0; i < selected.size(); i++) {
+ for (int i = 0; i < selected_nodes.size(); i++) {
if (i < list_max) {
HBoxContainer *hb = memnew(HBoxContainer);
TextureRect *tf = memnew(TextureRect);
tf->set_texture(icons[i]);
tf->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
hb->add_child(tf);
- Label *label = memnew(Label(selected[i]->get_name()));
+ Label *label = memnew(Label(selected_nodes[i]->get_name()));
hb->add_child(label);
vb->add_child(hb);
hb->set_modulate(Color(1, 1, 1, opacity_item));
opacity_item -= opacity_step;
}
- NodePath p = selected[i]->get_path();
+ NodePath p = selected_nodes[i]->get_path();
objs.push_back(p);
}
diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h
index 8fbc3ab6d6..dcdfead885 100644
--- a/editor/scene_tree_editor.h
+++ b/editor/scene_tree_editor.h
@@ -62,6 +62,7 @@ class SceneTreeEditor : public Control {
ObjectID instance_node;
String filter;
+ String filter_term_warning;
AcceptDialog *error = nullptr;
AcceptDialog *warning = nullptr;
@@ -142,6 +143,7 @@ public:
void set_filter(const String &p_filter);
String get_filter() const;
+ String get_filter_term_warning();
void set_undo_redo(Ref<EditorUndoRedoManager> p_undo_redo);
void set_display_foreign_nodes(bool p_display);
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index f57dfe4827..cc09c3a432 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -828,9 +828,9 @@ ScriptLanguage::ScriptTemplate ScriptCreateDialog::_get_current_template() const
return ScriptLanguage::ScriptTemplate();
}
-Vector<ScriptLanguage::ScriptTemplate> ScriptCreateDialog::_get_user_templates(const ScriptLanguage *language, const StringName &p_object, const String &p_dir, const ScriptLanguage::TemplateLocation &p_origin) const {
+Vector<ScriptLanguage::ScriptTemplate> ScriptCreateDialog::_get_user_templates(const ScriptLanguage *p_language, const StringName &p_object, const String &p_dir, const ScriptLanguage::TemplateLocation &p_origin) const {
Vector<ScriptLanguage::ScriptTemplate> user_templates;
- String extension = language->get_extension();
+ String extension = p_language->get_extension();
String dir_path = p_dir.path_join(p_object);
@@ -840,7 +840,7 @@ Vector<ScriptLanguage::ScriptTemplate> ScriptCreateDialog::_get_user_templates(c
String file = d->get_next();
while (file != String()) {
if (file.get_extension() == extension) {
- user_templates.append(_parse_template(language, dir_path, file, p_origin, p_object));
+ user_templates.append(_parse_template(p_language, dir_path, file, p_origin, p_object));
}
file = d->get_next();
}
@@ -849,7 +849,7 @@ Vector<ScriptLanguage::ScriptTemplate> ScriptCreateDialog::_get_user_templates(c
return user_templates;
}
-ScriptLanguage::ScriptTemplate ScriptCreateDialog::_parse_template(const ScriptLanguage *language, const String &p_path, const String &p_filename, const ScriptLanguage::TemplateLocation &p_origin, const String &p_inherits) const {
+ScriptLanguage::ScriptTemplate ScriptCreateDialog::_parse_template(const ScriptLanguage *p_language, const String &p_path, const String &p_filename, const ScriptLanguage::TemplateLocation &p_origin, const String &p_inherits) const {
ScriptLanguage::ScriptTemplate script_template = ScriptLanguage::ScriptTemplate();
script_template.origin = p_origin;
script_template.inherit = p_inherits;
@@ -857,7 +857,7 @@ ScriptLanguage::ScriptTemplate ScriptCreateDialog::_parse_template(const ScriptL
// Get meta delimiter
String meta_delimiter = String();
List<String> comment_delimiters;
- language->get_comment_delimiters(&comment_delimiters);
+ p_language->get_comment_delimiters(&comment_delimiters);
for (const String &script_delimiter : comment_delimiters) {
if (!script_delimiter.contains(" ")) {
meta_delimiter = script_delimiter;
diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h
index c7d8cfc38a..fb1a49a1ca 100644
--- a/editor/script_create_dialog.h
+++ b/editor/script_create_dialog.h
@@ -119,8 +119,8 @@ class ScriptCreateDialog : public ConfirmationDialog {
void _update_template_menu();
void _update_dialog();
ScriptLanguage::ScriptTemplate _get_current_template() const;
- Vector<ScriptLanguage::ScriptTemplate> _get_user_templates(const ScriptLanguage *language, const StringName &p_object, const String &p_dir, const ScriptLanguage::TemplateLocation &p_origin) const;
- ScriptLanguage::ScriptTemplate _parse_template(const ScriptLanguage *language, const String &p_path, const String &p_filename, const ScriptLanguage::TemplateLocation &p_origin, const String &p_inherits) const;
+ Vector<ScriptLanguage::ScriptTemplate> _get_user_templates(const ScriptLanguage *p_language, const StringName &p_object, const String &p_dir, const ScriptLanguage::TemplateLocation &p_origin) const;
+ ScriptLanguage::ScriptTemplate _parse_template(const ScriptLanguage *p_language, const String &p_path, const String &p_filename, const ScriptLanguage::TemplateLocation &p_origin, const String &p_inherits) const;
String _get_script_origin_label(const ScriptLanguage::TemplateLocation &p_origin) const;
protected:
diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp
index ae533b5b75..cdbe88b99e 100644
--- a/editor/shader_create_dialog.cpp
+++ b/editor/shader_create_dialog.cpp
@@ -96,20 +96,20 @@ void ShaderCreateDialog::_update_language_info() {
type_data.clear();
for (int i = 0; i < SHADER_TYPE_MAX; i++) {
- ShaderTypeData data;
+ ShaderTypeData shader_type_data;
if (i == int(SHADER_TYPE_TEXT)) {
- data.use_templates = true;
- data.extensions.push_back("gdshader");
- data.default_extension = "gdshader";
+ shader_type_data.use_templates = true;
+ shader_type_data.extensions.push_back("gdshader");
+ shader_type_data.default_extension = "gdshader";
} else if (i == int(SHADER_TYPE_INC)) {
- data.extensions.push_back("gdshaderinc");
- data.default_extension = "gdshaderinc";
+ shader_type_data.extensions.push_back("gdshaderinc");
+ shader_type_data.default_extension = "gdshaderinc";
} else {
- data.default_extension = "tres";
+ shader_type_data.default_extension = "tres";
}
- data.extensions.push_back("res");
- data.extensions.push_back("tres");
- type_data.push_back(data);
+ shader_type_data.extensions.push_back("res");
+ shader_type_data.extensions.push_back("tres");
+ type_data.push_back(shader_type_data);
}
}
@@ -261,9 +261,9 @@ void ShaderCreateDialog::_load_exist() {
void ShaderCreateDialog::_type_changed(int p_language) {
current_type = p_language;
- ShaderTypeData data = type_data[p_language];
+ ShaderTypeData shader_type_data = type_data[p_language];
- String selected_ext = "." + data.default_extension;
+ String selected_ext = "." + shader_type_data.default_extension;
String path = file_path->get_text();
String extension = "";
@@ -284,10 +284,10 @@ void ShaderCreateDialog::_type_changed(int p_language) {
type_menu->set_item_disabled(int(SHADER_TYPE_INC), load_enabled);
mode_menu->set_disabled(p_language == SHADER_TYPE_INC);
- template_menu->set_disabled(!data.use_templates);
+ template_menu->set_disabled(!shader_type_data.use_templates);
template_menu->clear();
- if (data.use_templates) {
+ if (shader_type_data.use_templates) {
int last_template = EditorSettings::get_singleton()->get_project_metadata("shader_setup", "last_selected_template", 0);
template_menu->add_item(TTR("Default"));
@@ -437,8 +437,6 @@ String ShaderCreateDialog::_validate_path(const String &p_path) {
}
}
- ShaderTypeData data = type_data[type_menu->get_selected()];
-
bool found = false;
bool match = false;