diff options
Diffstat (limited to 'editor/plugins/node_3d_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 90 |
1 files changed, 69 insertions, 21 deletions
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index e9a67491aa..a48b6a090b 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -809,18 +809,66 @@ void Node3DEditorViewport::_select_region() { } void Node3DEditorViewport::_update_name() { - String view_mode = orthogonal ? TTR("Orthogonal") : TTR("Perspective"); + String name; - if (auto_orthogonal) { - view_mode += " [auto]"; + switch (view_type) { + case VIEW_TYPE_USER: { + if (orthogonal) { + name = TTR("Orthogonal"); + } else { + name = TTR("Perspective"); + } + } break; + case VIEW_TYPE_TOP: { + if (orthogonal) { + name = TTR("Top Orthogonal"); + } else { + name = TTR("Top Perspective"); + } + } break; + case VIEW_TYPE_BOTTOM: { + if (orthogonal) { + name = TTR("Bottom Orthogonal"); + } else { + name = TTR("Bottom Perspective"); + } + } break; + case VIEW_TYPE_LEFT: { + if (orthogonal) { + name = TTR("Left Orthogonal"); + } else { + name = TTR("Right Perspective"); + } + } break; + case VIEW_TYPE_RIGHT: { + if (orthogonal) { + name = TTR("Right Orthogonal"); + } else { + name = TTR("Right Perspective"); + } + } break; + case VIEW_TYPE_FRONT: { + if (orthogonal) { + name = TTR("Front Orthogonal"); + } else { + name = TTR("Front Perspective"); + } + } break; + case VIEW_TYPE_REAR: { + if (orthogonal) { + name = TTR("Rear Orthogonal"); + } else { + name = TTR("Rear Perspective"); + } + } break; } - if (name != "") { - view_menu->set_text(name + " " + view_mode); - } else { - view_menu->set_text(view_mode); + if (auto_orthogonal) { + // TRANSLATORS: This will be appended to the view name when Auto Orthogonal is enabled. + name += TTR(" [auto]"); } + view_menu->set_text(name); view_menu->set_size(Vector2(0, 0)); // resets the button size } @@ -1384,7 +1432,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { case TRANSFORM_VIEW: { _edit.plane = TRANSFORM_X_AXIS; set_message(TTR("X-Axis Transform."), 2); - name = ""; + view_type = VIEW_TYPE_USER; _update_name(); } break; case TRANSFORM_X_AXIS: { @@ -2325,7 +2373,7 @@ void Node3DEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, cons } else { cursor.y_rot += p_relative.x * radians_per_pixel; } - name = ""; + view_type = VIEW_TYPE_USER; _update_name(); } @@ -2363,7 +2411,7 @@ void Node3DEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const Vector3 diff = prev_pos - pos; cursor.pos += diff; - name = ""; + view_type = VIEW_TYPE_USER; _update_name(); } @@ -3008,7 +3056,7 @@ void Node3DEditorViewport::_menu_option(int p_option) { cursor.y_rot = 0; cursor.x_rot = Math_PI / 2.0; set_message(TTR("Top View."), 2); - name = TTR("Top"); + view_type = VIEW_TYPE_TOP; _set_auto_orthogonal(); _update_name(); @@ -3017,7 +3065,7 @@ void Node3DEditorViewport::_menu_option(int p_option) { cursor.y_rot = 0; cursor.x_rot = -Math_PI / 2.0; set_message(TTR("Bottom View."), 2); - name = TTR("Bottom"); + view_type = VIEW_TYPE_BOTTOM; _set_auto_orthogonal(); _update_name(); @@ -3026,7 +3074,7 @@ void Node3DEditorViewport::_menu_option(int p_option) { cursor.x_rot = 0; cursor.y_rot = Math_PI / 2.0; set_message(TTR("Left View."), 2); - name = TTR("Left"); + view_type = VIEW_TYPE_LEFT; _set_auto_orthogonal(); _update_name(); @@ -3035,7 +3083,7 @@ void Node3DEditorViewport::_menu_option(int p_option) { cursor.x_rot = 0; cursor.y_rot = -Math_PI / 2.0; set_message(TTR("Right View."), 2); - name = TTR("Right"); + view_type = VIEW_TYPE_RIGHT; _set_auto_orthogonal(); _update_name(); @@ -3044,7 +3092,7 @@ void Node3DEditorViewport::_menu_option(int p_option) { cursor.x_rot = 0; cursor.y_rot = Math_PI; set_message(TTR("Front View."), 2); - name = TTR("Front"); + view_type = VIEW_TYPE_FRONT; _set_auto_orthogonal(); _update_name(); @@ -3053,7 +3101,7 @@ void Node3DEditorViewport::_menu_option(int p_option) { cursor.x_rot = 0; cursor.y_rot = 0; set_message(TTR("Rear View."), 2); - name = TTR("Rear"); + view_type = VIEW_TYPE_REAR; _set_auto_orthogonal(); _update_name(); @@ -3597,8 +3645,8 @@ void Node3DEditorViewport::set_state(const Dictionary &p_state) { _menu_option(VIEW_PERSPECTIVE); } } - if (p_state.has("view_name")) { - name = p_state["view_name"]; + if (p_state.has("view_type")) { + view_type = ViewType(p_state["view_type"].operator int()); _update_name(); } if (p_state.has("auto_orthogonal")) { @@ -3706,7 +3754,7 @@ Dictionary Node3DEditorViewport::get_state() const { d["distance"] = cursor.distance; d["use_environment"] = camera->get_environment().is_valid(); d["use_orthogonal"] = camera->get_projection() == Camera3D::PROJECTION_ORTHOGONAL; - d["view_name"] = name; + d["view_type"] = view_type; d["auto_orthogonal"] = auto_orthogonal; d["auto_orthogonal_enabled"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUTO_ORTHOGONAL)); if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL))) { @@ -3751,7 +3799,7 @@ void Node3DEditorViewport::reset() { message_time = 0; message = ""; last_message = ""; - name = ""; + view_type = VIEW_TYPE_USER; cursor = Cursor(); _update_name(); @@ -4366,7 +4414,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito viewport->set_as_audio_listener_3d(true); } - name = ""; + view_type = VIEW_TYPE_USER; _update_name(); EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &Node3DEditorViewport::update_transform_gizmo_view)); |