diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2021-04-09 08:52:10 -0400 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2021-04-09 11:21:09 -0400 |
commit | b8f66d58b6d03274788e31cd67f22b9d15c8632c (patch) | |
tree | 7ac653ef51d8b59714002b876388bbf7b683cb14 | |
parent | 6297a53db489924180e9c54d4e49e9ebef82d6b0 (diff) |
Show a message when trying to zoom farther than the limit
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 17 | ||||
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.h | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 0db57b1d9d..25fb637fb8 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -2215,6 +2215,12 @@ void Node3DEditorViewport::scale_cursor_distance(real_t scale) { cursor.distance = CLAMP(cursor.distance * scale, min_distance, max_distance); } + if (cursor.distance == max_distance || cursor.distance == min_distance) { + zoom_failed_attempts_count++; + } else { + zoom_failed_attempts_count = 0; + } + zoom_indicator_delay = ZOOM_FREELOOK_INDICATOR_DELAY_S; surface->update(); } @@ -2396,6 +2402,7 @@ void Node3DEditorViewport::_notification(int p_what) { zoom_indicator_delay -= delta; if (zoom_indicator_delay <= 0) { surface->update(); + zoom_limit_label->hide(); } } @@ -2775,6 +2782,7 @@ void Node3DEditorViewport::_draw() { } else { // Show zoom + zoom_limit_label->set_visible(zoom_failed_attempts_count > 15); real_t min_distance = MAX(camera->get_near() * 4, ZOOM_FREELOOK_MIN); real_t max_distance = MIN(camera->get_far() / 4, ZOOM_FREELOOK_MAX); @@ -4137,6 +4145,15 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito locked_label->set_text(TTR("View Rotation Locked")); locked_label->hide(); + zoom_limit_label = memnew(Label); + zoom_limit_label->set_anchors_and_offsets_preset(LayoutPreset::PRESET_BOTTOM_LEFT); + zoom_limit_label->set_offset(Side::SIDE_TOP, -28 * EDSCALE); + zoom_limit_label->set_text(TTR("To zoom further, change the camera's clipping planes (View -> Settings...)")); + zoom_limit_label->set_name("ZoomLimitMessageLabel"); + zoom_limit_label->add_theme_color_override("font_color", Color(1, 1, 1, 1)); + zoom_limit_label->hide(); + surface->add_child(zoom_limit_label); + frame_time_gradient = memnew(Gradient); // The color is set when the theme changes. frame_time_gradient->add_point(0.5, Color()); diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index ff4a941b06..70329f90c7 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -295,6 +295,7 @@ private: Label *info_label; Label *cinema_label; Label *locked_label; + Label *zoom_limit_label; VBoxContainer *top_right_vbox; ViewportRotationControl *rotation_control; @@ -418,6 +419,7 @@ private: void scale_freelook_speed(real_t scale); real_t zoom_indicator_delay; + int zoom_failed_attempts_count = 0; RID move_gizmo_instance[3], move_plane_gizmo_instance[3], rotate_gizmo_instance[4], scale_gizmo_instance[3], scale_plane_gizmo_instance[3]; |