diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/animation_editor.cpp | 52 | ||||
-rw-r--r-- | editor/code_editor.cpp | 38 | ||||
-rw-r--r-- | editor/code_editor.h | 3 | ||||
-rw-r--r-- | editor/editor_file_dialog.cpp | 5 | ||||
-rw-r--r-- | editor/editor_help.cpp | 47 | ||||
-rw-r--r-- | editor/editor_node.cpp | 3 | ||||
-rw-r--r-- | editor/filesystem_dock.cpp | 17 | ||||
-rw-r--r-- | editor/plugins/animation_tree_editor_plugin.cpp | 6 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 16 | ||||
-rw-r--r-- | editor/plugins/polygon_2d_editor_plugin.cpp | 13 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 216 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.h | 5 | ||||
-rw-r--r-- | editor/project_settings_editor.cpp | 4 | ||||
-rw-r--r-- | editor/scene_tree_dock.cpp | 2 | ||||
-rw-r--r-- | editor/script_editor_debugger.cpp | 9 | ||||
-rw-r--r-- | editor/settings_config_dialog.cpp | 2 |
16 files changed, 318 insertions, 120 deletions
diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp index 7d877bdb8c..1d70f8ba55 100644 --- a/editor/animation_editor.cpp +++ b/editor/animation_editor.cpp @@ -966,7 +966,9 @@ void AnimationKeyEditor::_cleanup_animation(Ref<Animation> p_animation) { Object *obj = NULL; RES res; - Node *node = root->get_node_and_resource(p_animation->track_get_path(i), res); + Vector<StringName> leftover_path; + + Node *node = root->get_node_and_resource(p_animation->track_get_path(i), res, leftover_path); if (res.is_valid()) { obj = res.ptr(); @@ -975,7 +977,7 @@ void AnimationKeyEditor::_cleanup_animation(Ref<Animation> p_animation) { } if (obj && p_animation->track_get_type(i) == Animation::TYPE_VALUE) { - valid_type = obj->get_static_property_type(p_animation->track_get_path(i).get_property(), &prop_exists); + valid_type = obj->get_static_property_type_indexed(leftover_path, &prop_exists); } if (!obj && cleanup_tracks->is_pressed()) { @@ -1315,7 +1317,9 @@ void AnimationKeyEditor::_track_editor_draw() { Object *obj = NULL; RES res; - Node *node = root ? root->get_node_and_resource(animation->track_get_path(idx), res) : (Node *)NULL; + Vector<StringName> leftover_path; + + Node *node = root ? root->get_node_and_resource(animation->track_get_path(idx), res, leftover_path) : (Node *)NULL; if (res.is_valid()) { obj = res.ptr(); @@ -1324,7 +1328,8 @@ void AnimationKeyEditor::_track_editor_draw() { } if (obj && animation->track_get_type(idx) == Animation::TYPE_VALUE) { - valid_type = obj->get_static_property_type(animation->track_get_path(idx).get_property(), &prop_exists); + // While leftover_path might be still empty, we wouldn't be able to get here anyway + valid_type = obj->get_static_property_type_indexed(leftover_path, &prop_exists); } if (/*mouse_over.over!=MouseOver::OVER_NONE &&*/ idx == mouse_over.track) { @@ -1648,26 +1653,34 @@ PropertyInfo AnimationKeyEditor::_find_hint_for_track(int p_idx, NodePath &r_bas return PropertyInfo(); RES res; - Node *node = root->get_node_and_resource(path, res); + Vector<StringName> leftover_path; + Node *node = root->get_node_and_resource(path, res, leftover_path, true); if (node) { r_base_path = node->get_path(); } - String property = path.get_property(); - if (property == "") + if (leftover_path.empty()) return PropertyInfo(); - List<PropertyInfo> pinfo; + Variant property_info_base; if (res.is_valid()) - res->get_property_list(&pinfo); + property_info_base = res; else if (node) - node->get_property_list(&pinfo); + property_info_base = node; + + for (int i = 0; i < leftover_path.size() - 1; i++) { + property_info_base = property_info_base.get_named(leftover_path[i]); + } + + List<PropertyInfo> pinfo; + property_info_base.get_property_list(&pinfo); for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == property) + if (E->get().name == leftover_path[leftover_path.size() - 1]) { return E->get(); + } } return PropertyInfo(); @@ -2779,7 +2792,8 @@ void AnimationKeyEditor::_track_editor_gui_input(const Ref<InputEvent> &p_input) Object *obj = NULL; RES res; - Node *node = root->get_node_and_resource(animation->track_get_path(idx), res); + Vector<StringName> leftover_path; + Node *node = root->get_node_and_resource(animation->track_get_path(idx), res, leftover_path); if (res.is_valid()) { obj = res.ptr(); @@ -2788,7 +2802,7 @@ void AnimationKeyEditor::_track_editor_gui_input(const Ref<InputEvent> &p_input) } if (obj) { - valid_type = obj->get_static_property_type(animation->track_get_path(idx).get_property(), &prop_exists); + valid_type = obj->get_static_property_type_indexed(leftover_path, &prop_exists); } text += "type: " + Variant::get_type_name(v.get_type()) + "\n"; @@ -2889,6 +2903,18 @@ void AnimationKeyEditor::_track_editor_gui_input(const Ref<InputEvent> &p_input) } } } + + Ref<InputEventMagnifyGesture> magnify_gesture = p_input; + if (magnify_gesture.is_valid()) { + zoom->set_value(zoom->get_value() * magnify_gesture->get_factor()); + } + + Ref<InputEventPanGesture> pan_gesture = p_input; + if (pan_gesture.is_valid()) { + + h_scroll->set_value(h_scroll->get_value() - h_scroll->get_page() * pan_gesture->get_delta().x / 8); + v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() * pan_gesture->get_delta().y / 8); + } } void AnimationKeyEditor::_notification(int p_what) { diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index c7012a0c14..216f2027fb 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -979,6 +979,23 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) { } } + Ref<InputEventMagnifyGesture> magnify_gesture = p_event; + if (magnify_gesture.is_valid()) { + + Ref<DynamicFont> font = text_editor->get_font("font"); + + if (font.is_valid()) { + if (font->get_size() != (int)font_size) { + font_size = font->get_size(); + } + + font_size *= powf(magnify_gesture->get_factor(), 0.25); + + _add_font_size((int)font_size - font->get_size()); + } + return; + } + Ref<InputEventKey> k = p_event; if (k.is_valid()) { @@ -999,14 +1016,15 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) { void CodeTextEditor::_zoom_in() { font_resize_val += EDSCALE; - - if (font_resize_timer->get_time_left() == 0) - font_resize_timer->start(); + _zoom_changed(); } void CodeTextEditor::_zoom_out() { font_resize_val -= EDSCALE; + _zoom_changed(); +} +void CodeTextEditor::_zoom_changed() { if (font_resize_timer->get_time_left() == 0) font_resize_timer->start(); } @@ -1067,16 +1085,25 @@ void CodeTextEditor::_complete_request() { void CodeTextEditor::_font_resize_timeout() { + if (_add_font_size(font_resize_val)) { + font_resize_val = 0; + } +} + +bool CodeTextEditor::_add_font_size(int p_delta) { + Ref<DynamicFont> font = text_editor->get_font("font"); if (font.is_valid()) { - int new_size = CLAMP(font->get_size() + font_resize_val, 8 * EDSCALE, 96 * EDSCALE); + int new_size = CLAMP(font->get_size() + p_delta, 8 * EDSCALE, 96 * EDSCALE); if (new_size != font->get_size()) { EditorSettings::get_singleton()->set("interface/editor/source_font_size", new_size / EDSCALE); font->set_size(new_size); } - font_resize_val = 0; + return true; + } else { + return false; } } @@ -1285,6 +1312,7 @@ CodeTextEditor::CodeTextEditor() { code_complete_timer->connect("timeout", this, "_code_complete_timer_timeout"); font_resize_val = 0; + font_size = -1; font_resize_timer = memnew(Timer); add_child(font_resize_timer); font_resize_timer->set_one_shot(true); diff --git a/editor/code_editor.h b/editor/code_editor.h index 410dd99878..656ea4b47b 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -204,6 +204,7 @@ class CodeTextEditor : public VBoxContainer { Timer *font_resize_timer; int font_resize_val; + real_t font_size; Label *error; @@ -212,10 +213,12 @@ class CodeTextEditor : public VBoxContainer { void _update_font(); void _complete_request(); void _font_resize_timeout(); + bool _add_font_size(int p_delta); void _text_editor_gui_input(const Ref<InputEvent> &p_event); void _zoom_in(); void _zoom_out(); + void _zoom_changed(); void _reset_zoom(); CodeTextEditorCodeCompleteFunc code_complete_func; diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index a0ca9b88e0..f8b9425a4e 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -541,6 +541,9 @@ void EditorFileDialog::update_file_list() { while ((item = dir_access->get_next(&isdir)) != "") { + if (item == ".") + continue; + ishidden = dir_access->current_is_hidden(); if (show_hidden || !ishidden) { @@ -562,7 +565,7 @@ void EditorFileDialog::update_file_list() { while (!dirs.empty()) { const String &dir_name = dirs.front()->get(); - item_list->add_item(dir_name + "/"); + item_list->add_item(dir_name); if (display_mode == DISPLAY_THUMBNAILS) { diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index cc7f1cac43..4b372e7afd 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -564,18 +564,37 @@ void EditorHelp::_class_desc_select(const String &p_select) { emit_signal("go_to_help", "class_name:" + p_select.substr(1, p_select.length())); return; } else if (p_select.begins_with("@")) { + String tag = p_select.substr(1, 6); + String link = p_select.substr(7, p_select.length()); + + String topic; + Map<String, int> *table = NULL; + + if (tag == "method") { + topic = "class_method"; + table = &this->method_line; + } else if (tag == "member") { + topic = "class_property"; + table = &this->property_line; + } else if (tag == "enum ") { + topic = "class_enum"; + table = &this->enum_line; + } else if (tag == "signal") { + topic = "class_signal"; + table = &this->signal_line; + } else { + return; + } - String m = p_select.substr(1, p_select.length()); - - if (m.find(".") != -1) { + if (link.find(".") != -1) { //must go somewhere else - emit_signal("go_to_help", "class_method:" + m.get_slice(".", 0) + ":" + m.get_slice(".", 0)); + emit_signal("go_to_help", topic + ":" + link.get_slice(".", 0) + ":" + link.get_slice(".", 1)); } else { - if (!method_line.has(m)) + if (!table->has(link)) return; - class_desc->scroll_to_line(method_line[m]); + class_desc->scroll_to_line((*table)[link]); } } else if (p_select.begins_with("http")) { OS::get_singleton()->shell_open(p_select); @@ -808,7 +827,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { } class_desc->push_cell(); if (describe) { - class_desc->push_meta("@" + cd.properties[i].name); + class_desc->push_meta("@member" + cd.properties[i].name); } class_desc->push_font(doc_code_font); @@ -881,7 +900,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { if (methods[i].description != "") { method_descr = true; - class_desc->push_meta("@" + methods[i].name); + class_desc->push_meta("@method" + methods[i].name); } class_desc->push_color(headline_color); _add_text(methods[i].name); @@ -1240,7 +1259,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { for (int i = 0; i < cd.properties.size(); i++) { - method_line[cd.properties[i].name] = class_desc->get_line_count() - 2; + property_line[cd.properties[i].name] = class_desc->get_line_count() - 2; class_desc->push_table(2); class_desc->set_table_column_expand(1, 1); @@ -1452,7 +1471,6 @@ void EditorHelp::_help_callback(const String &p_topic) { line = property_line[name]; } else if (what == "class_enum") { - print_line("go to enum:"); if (enum_line.has(name)) line = enum_line[name]; } else if (what == "class_theme_item") { @@ -1535,12 +1553,13 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { p_rt->add_text("["); pos = brk_pos + 1; - } else if (tag.begins_with("method ")) { + } else if (tag.begins_with("method ") || tag.begins_with("member ") || tag.begins_with("signal ") || tag.begins_with("enum ")) { - String m = tag.substr(7, tag.length()); + String link_target = tag.substr(tag.find(" ") + 1, tag.length()); + String link_tag = tag.substr(0, tag.find(" ")).rpad(6); p_rt->push_color(link_color); - p_rt->push_meta("@" + m); - p_rt->add_text(m + "()"); + p_rt->push_meta("@" + link_tag + link_target); + p_rt->add_text(link_target + (tag.begins_with("method ") ? "()" : "")); p_rt->pop(); p_rt->pop(); pos = brk_end + 1; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 109f132d76..a32ade3b71 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -364,7 +364,8 @@ void EditorNode::_notification(int p_what) { dock_tab_move_right->set_icon(theme->get_icon("Forward", "EditorIcons")); update_menu->set_icon(gui_base->get_icon("Progress1", "EditorIcons")); } - if (p_what = Control::NOTIFICATION_RESIZED) { + + if (p_what == Control::NOTIFICATION_RESIZED) { _update_scene_tabs(); } } diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 9c432323f4..2ddfea00e3 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1417,18 +1417,18 @@ void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) { if (all_files_scenes) { file_options->add_item(TTR("Instance"), FILE_INSTANCE); } + file_options->add_separator(); if (filenames.size() == 1) { - file_options->add_separator(); file_options->add_item(TTR("Edit Dependencies.."), FILE_DEPENDENCIES); file_options->add_item(TTR("View Owners.."), FILE_OWNERS); + file_options->add_separator(); } } else if (all_folders && foldernames.size() > 0) { file_options->add_item(TTR("Open"), FILE_OPEN); + file_options->add_separator(); } - file_options->add_separator(); - int num_items = filenames.size() + foldernames.size(); if (num_items >= 1) { if (num_items == 1) { @@ -1448,12 +1448,13 @@ void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) { } void FileSystemDock::_rmb_pressed(const Vector2 &p_pos) { - folder_options->clear(); - folder_options->set_size(Size2(1, 1)); + file_options->clear(); + file_options->set_size(Size2(1, 1)); - folder_options->add_item(TTR("New Folder.."), FOLDER_NEW_FOLDER); - folder_options->set_position(files->get_global_position() + p_pos); - folder_options->popup(); + file_options->add_item(TTR("New Folder.."), FILE_NEW_FOLDER); + file_options->add_item(TTR("Show In File Manager"), FILE_SHOW_IN_EXPLORER); + file_options->set_position(files->get_global_position() + p_pos); + file_options->popup(); } void FileSystemDock::select_file(const String &p_file) { diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index 22d23e1c72..8fe6538653 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -1196,14 +1196,14 @@ void AnimationTreeEditor::_edit_filters() { if (base) { NodePath np = E->get(); - if (np.get_property() != StringName()) { + if (np.get_subname_count() == 1) { Node *n = base->get_node(np); Skeleton *s = Object::cast_to<Skeleton>(n); if (s) { String skelbase = E->get().substr(0, E->get().find(":")); - int bidx = s->find_bone(np.get_property()); + int bidx = s->find_bone(np.get_subname(0)); if (bidx != -1) { int bparent = s->get_bone_parent(bidx); @@ -1213,7 +1213,7 @@ void AnimationTreeEditor::_edit_filters() { String bpn = skelbase + ":" + s->get_bone_name(bparent); if (pm.has(bpn)) { parent = pm[bpn]; - descr = np.get_property(); + descr = np.get_subname(0); } } else { diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 6cb4171f5a..3940dd9044 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1442,6 +1442,22 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { } } + Ref<InputEventMagnifyGesture> magnify_gesture = p_event; + if (magnify_gesture.is_valid()) { + + _zoom_on_position(zoom * magnify_gesture->get_factor(), magnify_gesture->get_position()); + return; + } + + Ref<InputEventPanGesture> pan_gesture = p_event; + if (pan_gesture.is_valid()) { + + const Vector2 delta = (int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom) * pan_gesture->get_delta(); + h_scroll->set_value(h_scroll->get_value() + delta.x); + v_scroll->set_value(v_scroll->get_value() + delta.y); + return; + } + Ref<InputEventMouseButton> b = p_event; if (b.is_valid()) { // Button event diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index a525983c75..ebb5f57e99 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -339,6 +339,19 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { uv_edit_draw->update(); } } + + Ref<InputEventMagnifyGesture> magnify_gesture = p_input; + if (magnify_gesture.is_valid()) { + + uv_zoom->set_value(uv_zoom->get_value() * magnify_gesture->get_factor()); + } + + Ref<InputEventPanGesture> pan_gesture = p_input; + if (pan_gesture.is_valid()) { + + uv_hscroll->set_value(uv_hscroll->get_value() + uv_hscroll->get_page() * pan_gesture->get_delta().x / 8); + uv_vscroll->set_value(uv_vscroll->get_value() + uv_vscroll->get_page() * pan_gesture->get_delta().y / 8); + } } void Polygon2DEditor::_uv_scroll_changed(float) { diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 448daab226..921ba529a2 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -1694,92 +1694,78 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { switch (nav_mode) { case NAVIGATION_PAN: { + _nav_pan(m, _get_warped_mouse_motion(m)); - real_t pan_speed = 1 / 150.0; - int pan_speed_modifier = 10; - if (nav_scheme == NAVIGATION_MAYA && m->get_shift()) - pan_speed *= pan_speed_modifier; + } break; - Point2i relative = _get_warped_mouse_motion(m); + case NAVIGATION_ZOOM: { + _nav_zoom(m, m->get_relative()); - Transform camera_transform; + } break; - camera_transform.translate(cursor.pos); - camera_transform.basis.rotate(Vector3(1, 0, 0), -cursor.x_rot); - camera_transform.basis.rotate(Vector3(0, 1, 0), -cursor.y_rot); - Vector3 translation(-relative.x * pan_speed, relative.y * pan_speed, 0); - translation *= cursor.distance / DISTANCE_DEFAULT; - camera_transform.translate(translation); - cursor.pos = camera_transform.origin; + case NAVIGATION_ORBIT: { + _nav_orbit(m, _get_warped_mouse_motion(m)); + + } break; + + case NAVIGATION_LOOK: { + _nav_look(m, _get_warped_mouse_motion(m)); + + } break; + + default: {} + } + } + + Ref<InputEventMagnifyGesture> magnify_gesture = p_event; + if (magnify_gesture.is_valid()) { + + if (is_freelook_active()) + scale_freelook_speed(magnify_gesture->get_factor()); + else + scale_cursor_distance(1.0 / magnify_gesture->get_factor()); + } + + Ref<InputEventPanGesture> pan_gesture = p_event; + if (pan_gesture.is_valid()) { + + NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int(); + NavigationMode nav_mode = NAVIGATION_NONE; + + if (nav_scheme == NAVIGATION_GODOT) { + + int mod = _get_key_modifier(pan_gesture); + + if (mod == _get_key_modifier_setting("editors/3d/navigation/pan_modifier")) + nav_mode = NAVIGATION_PAN; + else if (mod == _get_key_modifier_setting("editors/3d/navigation/zoom_modifier")) + nav_mode = NAVIGATION_ZOOM; + else if (mod == _get_key_modifier_setting("editors/3d/navigation/orbit_modifier")) + nav_mode = NAVIGATION_ORBIT; + + } else if (nav_scheme == NAVIGATION_MAYA) { + if (pan_gesture->get_alt()) + nav_mode = NAVIGATION_PAN; + } + + switch (nav_mode) { + case NAVIGATION_PAN: { + _nav_pan(m, pan_gesture->get_delta()); } break; case NAVIGATION_ZOOM: { - real_t zoom_speed = 1 / 80.0; - int zoom_speed_modifier = 10; - if (nav_scheme == NAVIGATION_MAYA && m->get_shift()) - zoom_speed *= zoom_speed_modifier; - - NavigationZoomStyle zoom_style = (NavigationZoomStyle)EditorSettings::get_singleton()->get("editors/3d/navigation/zoom_style").operator int(); - if (zoom_style == NAVIGATION_ZOOM_HORIZONTAL) { - if (m->get_relative().x > 0) - scale_cursor_distance(1 - m->get_relative().x * zoom_speed); - else if (m->get_relative().x < 0) - scale_cursor_distance(1.0 / (1 + m->get_relative().x * zoom_speed)); - } else { - if (m->get_relative().y > 0) - scale_cursor_distance(1 + m->get_relative().y * zoom_speed); - else if (m->get_relative().y < 0) - scale_cursor_distance(1.0 / (1 - m->get_relative().y * zoom_speed)); - } + _nav_zoom(m, pan_gesture->get_delta()); } break; case NAVIGATION_ORBIT: { - Point2i relative = _get_warped_mouse_motion(m); - - real_t degrees_per_pixel = EditorSettings::get_singleton()->get("editors/3d/navigation_feel/orbit_sensitivity"); - real_t radians_per_pixel = Math::deg2rad(degrees_per_pixel); - - cursor.x_rot += relative.y * radians_per_pixel; - cursor.y_rot += relative.x * radians_per_pixel; - if (cursor.x_rot > Math_PI / 2.0) - cursor.x_rot = Math_PI / 2.0; - if (cursor.x_rot < -Math_PI / 2.0) - cursor.x_rot = -Math_PI / 2.0; - name = ""; - _update_name(); + _nav_orbit(m, pan_gesture->get_delta()); + } break; case NAVIGATION_LOOK: { - // Freelook only works properly in perspective. - // It technically works too in ortho, but it's awful for a user due to fov being near zero - if (!orthogonal) { - Point2i relative = _get_warped_mouse_motion(m); - - real_t degrees_per_pixel = EditorSettings::get_singleton()->get("editors/3d/navigation_feel/orbit_sensitivity"); - real_t radians_per_pixel = Math::deg2rad(degrees_per_pixel); - - // Note: do NOT assume the camera has the "current" transform, because it is interpolated and may have "lag". - Transform prev_camera_transform = to_camera_transform(cursor); - - cursor.x_rot += relative.y * radians_per_pixel; - cursor.y_rot += relative.x * radians_per_pixel; - if (cursor.x_rot > Math_PI / 2.0) - cursor.x_rot = Math_PI / 2.0; - if (cursor.x_rot < -Math_PI / 2.0) - cursor.x_rot = -Math_PI / 2.0; - - // Look is like the opposite of Orbit: the focus point rotates around the camera - Transform camera_transform = to_camera_transform(cursor); - Vector3 pos = camera_transform.xform(Vector3(0, 0, 0)); - Vector3 prev_pos = prev_camera_transform.xform(Vector3(0, 0, 0)); - Vector3 diff = prev_pos - pos; - cursor.pos += diff; - - name = ""; - _update_name(); - } + _nav_look(m, pan_gesture->get_delta()); } break; @@ -1885,6 +1871,94 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { accept_event(); } +void SpatialEditorViewport::_nav_pan(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) { + + const NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int(); + + real_t pan_speed = 1 / 150.0; + int pan_speed_modifier = 10; + if (nav_scheme == NAVIGATION_MAYA && p_event->get_shift()) + pan_speed *= pan_speed_modifier; + + Transform camera_transform; + + camera_transform.translate(cursor.pos); + camera_transform.basis.rotate(Vector3(1, 0, 0), -cursor.x_rot); + camera_transform.basis.rotate(Vector3(0, 1, 0), -cursor.y_rot); + Vector3 translation(-p_relative.x * pan_speed, p_relative.y * pan_speed, 0); + translation *= cursor.distance / DISTANCE_DEFAULT; + camera_transform.translate(translation); + cursor.pos = camera_transform.origin; +} + +void SpatialEditorViewport::_nav_zoom(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) { + + const NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int(); + + real_t zoom_speed = 1 / 80.0; + int zoom_speed_modifier = 10; + if (nav_scheme == NAVIGATION_MAYA && p_event->get_shift()) + zoom_speed *= zoom_speed_modifier; + + NavigationZoomStyle zoom_style = (NavigationZoomStyle)EditorSettings::get_singleton()->get("editors/3d/navigation/zoom_style").operator int(); + if (zoom_style == NAVIGATION_ZOOM_HORIZONTAL) { + if (p_relative.x > 0) + scale_cursor_distance(1 - p_relative.x * zoom_speed); + else if (p_relative.x < 0) + scale_cursor_distance(1.0 / (1 + p_relative.x * zoom_speed)); + } else { + if (p_relative.y > 0) + scale_cursor_distance(1 + p_relative.y * zoom_speed); + else if (p_relative.y < 0) + scale_cursor_distance(1.0 / (1 - p_relative.y * zoom_speed)); + } +} + +void SpatialEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) { + + real_t degrees_per_pixel = EditorSettings::get_singleton()->get("editors/3d/navigation_feel/orbit_sensitivity"); + real_t radians_per_pixel = Math::deg2rad(degrees_per_pixel); + + cursor.x_rot += p_relative.y * radians_per_pixel; + cursor.y_rot += p_relative.x * radians_per_pixel; + if (cursor.x_rot > Math_PI / 2.0) + cursor.x_rot = Math_PI / 2.0; + if (cursor.x_rot < -Math_PI / 2.0) + cursor.x_rot = -Math_PI / 2.0; + name = ""; + _update_name(); +} + +void SpatialEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) { + + // Freelook only works properly in perspective. + // It technically works too in ortho, but it's awful for a user due to fov being near zero + if (!orthogonal) { + real_t degrees_per_pixel = EditorSettings::get_singleton()->get("editors/3d/navigation_feel/orbit_sensitivity"); + real_t radians_per_pixel = Math::deg2rad(degrees_per_pixel); + + // Note: do NOT assume the camera has the "current" transform, because it is interpolated and may have "lag". + Transform prev_camera_transform = to_camera_transform(cursor); + + cursor.x_rot += p_relative.y * radians_per_pixel; + cursor.y_rot += p_relative.x * radians_per_pixel; + if (cursor.x_rot > Math_PI / 2.0) + cursor.x_rot = Math_PI / 2.0; + if (cursor.x_rot < -Math_PI / 2.0) + cursor.x_rot = -Math_PI / 2.0; + + // Look is like the opposite of Orbit: the focus point rotates around the camera + Transform camera_transform = to_camera_transform(cursor); + Vector3 pos = camera_transform.xform(Vector3(0, 0, 0)); + Vector3 prev_pos = prev_camera_transform.xform(Vector3(0, 0, 0)); + Vector3 diff = prev_pos - pos; + cursor.pos += diff; + + name = ""; + _update_name(); + } +} + void SpatialEditorViewport::set_freelook_active(bool active_now) { if (!freelook_active && active_now) { diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index ad11ec33df..14558fc878 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -170,6 +170,11 @@ private: void _select_region(); bool _gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only = false); + void _nav_pan(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative); + void _nav_zoom(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative); + void _nav_orbit(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative); + void _nav_look(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative); + float get_znear() const; float get_zfar() const; float get_fov() const; diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index b07280a4cd..900f7625bc 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -360,7 +360,7 @@ void ProjectSettingsEditor::_wait_for_key(const Ref<InputEvent> &p_event) { last_wait_for_key = p_event; String str = keycode_get_string(k->get_scancode()).capitalize(); if (k->get_metakey()) - str = TTR("Meta+") + str; + str = vformat("%s+", find_keycode_name(KEY_META)) + str; if (k->get_shift()) str = TTR("Shift+") + str; if (k->get_alt()) @@ -642,7 +642,7 @@ void ProjectSettingsEditor::_update_actions() { String str = keycode_get_string(k->get_scancode()).capitalize(); if (k->get_metakey()) - str = TTR("Meta+") + str; + str = vformat("%s+", find_keycode_name(KEY_META)) + str; if (k->get_shift()) str = TTR("Shift+") + str; if (k->get_alt()) diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 1d2647badc..a97a5630e6 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -986,7 +986,7 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP //will be renamed NodePath rel_path = new_root_path.rel_path_to(E->get().second); - NodePath new_path = NodePath(rel_path.get_names(), track_np.get_subnames(), false, track_np.get_property()); + NodePath new_path = NodePath(rel_path.get_names(), track_np.get_subnames(), false); if (new_path == track_np) continue; //bleh editor_data->get_undo_redo().add_do_method(anim.ptr(), "track_set_path", i, new_path); diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 2a3e47b2a6..ef082f29c3 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -1127,6 +1127,15 @@ void ScriptEditorDebugger::_notification(int p_what) { tabs->add_style_override("tab_bg", editor->get_gui_base()->get_stylebox("DebuggerTabBG", "EditorStyles")); tabs->set_margin(MARGIN_LEFT, -EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT)); tabs->set_margin(MARGIN_RIGHT, EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT)); + + bool enable_rl = EditorSettings::get_singleton()->get("docks/scene_tree/draw_relationship_lines"); + Color rl_color = EditorSettings::get_singleton()->get("docks/scene_tree/relationship_line_color"); + + if (enable_rl) { + inspect_scene_tree->add_constant_override("draw_relationship_lines", 1); + inspect_scene_tree->add_color_override("relationship_line_color", rl_color); + } else + inspect_scene_tree->add_constant_override("draw_relationship_lines", 0); } break; } } diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index c052845be9..853761f689 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -291,7 +291,7 @@ void EditorSettingsDialog::_wait_for_key(const Ref<InputEvent> &p_event) { last_wait_for_key = k; String str = keycode_get_string(k->get_scancode()).capitalize(); if (k->get_metakey()) - str = TTR("Meta+") + str; + str = vformat("%s+", find_keycode_name(KEY_META)) + str; if (k->get_shift()) str = TTR("Shift+") + str; if (k->get_alt()) |