Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/classes/EditorNode3DGizmo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<description>
Override this method to return the name of an edited handle (handles must have been previously added by [method add_handles]). Handles can be named for reference to the user when editing.
The [param secondary] argument is [code]true[/code] when the requested handle is secondary (see [method add_handles] for more information).
[b]Note:[/b] By convention, the first word of the name should be capitalized, while the rest should be in lowercase. For example, [code]"Inner radius"[/code].
</description>
</method>
<method name="_get_handle_value" qualifiers="virtual const">
Expand Down
1 change: 1 addition & 0 deletions doc/classes/EditorNode3DGizmoPlugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<param index="2" name="secondary" type="bool" />
<description>
Override this method to provide gizmo's handle names. The [param secondary] argument is [code]true[/code] when the requested handle is secondary (see [method EditorNode3DGizmo.add_handles] for more information). Called for this plugin's active gizmos.
[b]Note:[/b] By convention, the first word of the name should be capitalized, while the rest should be in lowercase. For example, [code]"Inner radius"[/code].
</description>
</method>
<method name="_get_handle_value" qualifiers="virtual const">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int AudioStreamPlayer3DGizmoPlugin::get_priority() const {
}

String AudioStreamPlayer3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
return "Emission Radius";
return TTR("Emission radius");
}

Variant AudioStreamPlayer3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
Expand Down
4 changes: 2 additions & 2 deletions editor/plugins/gizmos/camera_3d_gizmo_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ String Camera3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, in
Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_node_3d());

if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) {
return "FOV";
return TTR("FOV");
} else {
return "Size";
return TTR("Size");
}
}

Expand Down
4 changes: 2 additions & 2 deletions editor/plugins/gizmos/collision_shape_3d_gizmo_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_g
}

if (Object::cast_to<SphereShape3D>(*s)) {
return "Radius";
return TTR("Radius");
}

if (Object::cast_to<BoxShape3D>(*s)) {
Expand All @@ -123,7 +123,7 @@ String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_g
}

if (Object::cast_to<SeparationRayShape3D>(*s)) {
return "Length";
return TTR("Length");
}

return "";
Expand Down
4 changes: 2 additions & 2 deletions editor/plugins/gizmos/light_3d_gizmo_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ int Light3DGizmoPlugin::get_priority() const {

String Light3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
if (p_id == 0) {
return "Radius";
return TTR("Radius");
} else {
return "Aperture";
return TTR("Aperture");
}
}

Expand Down
4 changes: 2 additions & 2 deletions editor/plugins/gizmos/occluder_instance_3d_gizmo_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ String OccluderInstance3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p
}

if (Object::cast_to<SphereOccluder3D>(*o)) {
return "Radius";
return TTR("Radius");
}

if (Object::cast_to<BoxOccluder3D>(*o) || Object::cast_to<QuadOccluder3D>(*o)) {
return "Size";
return TTR("Size");
}

return "";
Expand Down
6 changes: 3 additions & 3 deletions editor/plugins/gizmos/reflection_probe_gizmo_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ String ReflectionProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gi
}
switch (p_id) {
case 6:
return "Origin X";
return TTR("Origin X");
case 7:
return "Origin Y";
return TTR("Origin Y");
case 8:
return "Origin Z";
return TTR("Origin Z");
}
return "";
}
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/gizmos/soft_body_3d_gizmo_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void SoftBody3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}

String SoftBody3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
return "SoftBody3D pin point";
return TTR("SoftBody3D pin point");
}

Variant SoftBody3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ int VisibleOnScreenNotifier3DGizmoPlugin::get_priority() const {
String VisibleOnScreenNotifier3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
switch (p_id) {
case 0:
return "Size X";
return TTR("Size X");
case 1:
return "Size Y";
return TTR("Size Y");
case 2:
return "Size Z";
return TTR("Size Z");
case 3:
return "Pos X";
return TTR("Position X");
case 4:
return "Pos Y";
return TTR("Position Y");
case 5:
return "Pos Z";
return TTR("Position Z");
}

return "";
Expand Down
79 changes: 46 additions & 33 deletions editor/plugins/node_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ void Node3DEditorViewport::cancel_transform() {

collision_reposition = false;
finish_transform();
set_message(TTR("Transform Aborted."), 3);
set_message(TTR("Transform aborted"), 3);
}

void Node3DEditorViewport::_update_shrink() {
Expand Down Expand Up @@ -1794,24 +1794,24 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
switch (_edit.plane) {
case TRANSFORM_VIEW: {
_edit.plane = TRANSFORM_X_AXIS;
set_message(TTR("X-Axis Transform."), 2);
set_message(TTR("X axis transform"), 2);
view_type = VIEW_TYPE_USER;
_update_name();
} break;
case TRANSFORM_X_AXIS: {
_edit.plane = TRANSFORM_Y_AXIS;
set_message(TTR("Y-Axis Transform."), 2);
set_message(TTR("Y axis transform"), 2);

} break;
case TRANSFORM_Y_AXIS: {
_edit.plane = TRANSFORM_Z_AXIS;
set_message(TTR("Z-Axis Transform."), 2);
set_message(TTR("Z axis transform"), 2);

} break;
case TRANSFORM_Z_AXIS: {
_edit.plane = TRANSFORM_VIEW;
// TRANSLATORS: This refers to the transform of the view plane.
set_message(TTR("View Plane Transform."), 2);
set_message(TTR("View plane transform"), 2);

} break;
case TRANSFORM_YZ:
Expand Down Expand Up @@ -2112,7 +2112,10 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
_edit.gizmo->set_handle(_edit.gizmo_handle, _edit.gizmo_handle_secondary, camera, m->get_position());
Variant v = _edit.gizmo->get_handle_value(_edit.gizmo_handle, _edit.gizmo_handle_secondary);
String n = _edit.gizmo->get_handle_name(_edit.gizmo_handle, _edit.gizmo_handle_secondary);
set_message(n + ": " + String(v));
if (v.get_type() == Variant::VECTOR3 || v.get_type() == Variant::VECTOR3I) {
v = _get_coordinates_string(v, "m");
}
set_message(n + " " + String(v));

} else if (m->get_button_mask().has_flag(MouseButtonMask::LEFT)) {
NavigationMode change_nav_from_shortcut = _get_nav_mode_from_shortcut_check(NAVIGATION_LEFT_MOUSE, shortcut_check_sets, false);
Expand Down Expand Up @@ -2430,7 +2433,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}

if (!AnimationPlayerEditor::get_singleton()->get_track_editor()->has_keying()) {
set_message(TTR("Keying is disabled (no key inserted)."));
set_message(TTR("Keying is disabled (no key inserted)"));
return;
}

Expand All @@ -2445,7 +2448,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
spatial_editor->emit_signal(SNAME("transform_key_request"), sp, "", sp->get_transform());
}

set_message(TTR("Animation Key Inserted."));
set_message(TTR("Animation key inserted"));
}
if (ED_IS_SHORTCUT("spatial_editor/cancel_transform", p_event) && _edit.mode != TRANSFORM_NONE) {
cancel_transform();
Expand Down Expand Up @@ -2841,6 +2844,16 @@ void Node3DEditorViewport::set_message(const String &p_message, float p_time) {
message_time = p_time;
}

// Returns a string designed for fixed-width fonts (more readable than
// `vformat()`'s `%v` for this purpose, with no parentheses surrounding the coordinates).
String Node3DEditorViewport::_get_coordinates_string(Vector3 p_coords, String p_suffix, int p_digits) const {
// Add a space of additional padding for positive numbers, so that the `-`
// sign can display without reflowing numbers.
return "X: " + String(p_coords.x >= 0.0 ? " " : "") + rtos(p_coords.x).pad_decimals(p_digits) + " " + p_suffix +
"\t\t Y: " + String(p_coords.y >= 0.0 ? " " : "") + rtos(p_coords.y).pad_decimals(p_digits) + " " + p_suffix +
"\t\t Z: " + String(p_coords.z >= 0.0 ? " " : "") + rtos(p_coords.z).pad_decimals(p_digits) + " " + p_suffix;
}

void Node3DEditorPlugin::edited_scene_changed() {
for (uint32_t i = 0; i < Node3DEditor::VIEWPORTS_COUNT; i++) {
Node3DEditorViewport *viewport = Node3DEditor::get_singleton()->get_editor_viewport(i);
Expand Down Expand Up @@ -3188,8 +3201,7 @@ void Node3DEditorViewport::_notification(int p_what) {
if (!ruler->is_inside_tree()) {
double snap = EDITOR_GET("interface/inspector/default_float_step");
int snap_step_decimals = Math::range_step_decimals(snap);
set_message(TTR("Translating:") + " (" + String::num(selected_node->get_global_position().x, snap_step_decimals) + ", " +
String::num(selected_node->get_global_position().y, snap_step_decimals) + ", " + String::num(selected_node->get_global_position().z, snap_step_decimals) + ")");
set_message(TTR("Translating") + " " + _get_coordinates_string(selected_node->get_global_position(), "m", snap_step_decimals));
}

selected_node->set_global_position(spatial_editor->snap_point(_get_instance_position(_edit.mouse_pos, selected_node)));
Expand All @@ -3210,8 +3222,7 @@ void Node3DEditorViewport::_notification(int p_what) {
preview_node_pos = spatial_editor->snap_point(_get_instance_position(preview_node_viewport_pos, preview_node));
double snap = EDITOR_GET("interface/inspector/default_float_step");
int snap_step_decimals = Math::range_step_decimals(snap);
set_message(TTR("Instantiating:") + " (" + String::num(preview_node_pos.x, snap_step_decimals) + ", " +
String::num(preview_node_pos.y, snap_step_decimals) + ", " + String::num(preview_node_pos.z, snap_step_decimals) + ")");
set_message(TTR("Instantiating") + " " + _get_coordinates_string(preview_node_pos, "m", snap_step_decimals));
Transform3D preview_gl_transform = Transform3D(Basis(), preview_node_pos);
preview_node->set_global_transform(preview_gl_transform);
if (!preview_node->is_visible()) {
Expand Down Expand Up @@ -3374,12 +3385,11 @@ void Node3DEditorViewport::_draw() {
RID ci = surface->get_canvas_item();

if (message_time > 0) {
Ref<Font> font = get_theme_font(SceneStringName(font), SNAME("Label"));
int font_size = get_theme_font_size(SceneStringName(font_size), SNAME("Label"));
Point2 msgpos = Point2(10 * EDSCALE, get_size().y - 14 * EDSCALE);
font->draw_string(ci, msgpos + Point2(1, 1), message, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(0, 0, 0, 0.8));
font->draw_string(ci, msgpos + Point2(-1, -1), message, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(0, 0, 0, 0.8));
font->draw_string(ci, msgpos, message, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1, 1));
const Ref<Font> &font = get_theme_font("expression", EditorStringName(EditorFonts));
const int font_size = get_theme_font_size(SceneStringName(font_size), SNAME("Label"));
const Point2 msgpos = Point2(10 * EDSCALE, get_size().y - 14 * EDSCALE);
font->draw_string_outline(ci, msgpos, message, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Math::round(6 * EDSCALE), Color(0, 0, 0, 0.5));
font->draw_string(ci, msgpos, message, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1));
}

if (_edit.mode == TRANSFORM_ROTATE && _edit.show_rotation_line) {
Expand Down Expand Up @@ -3515,7 +3525,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
case VIEW_TOP: {
cursor.y_rot = 0;
cursor.x_rot = Math::PI / 2.0;
set_message(TTR("Top View."), 2);
set_message(TTR("Top view"), 2);
view_type = VIEW_TYPE_TOP;
_set_auto_orthogonal();
_update_name();
Expand All @@ -3524,7 +3534,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
case VIEW_BOTTOM: {
cursor.y_rot = 0;
cursor.x_rot = -Math::PI / 2.0;
set_message(TTR("Bottom View."), 2);
set_message(TTR("Bottom view"), 2);
view_type = VIEW_TYPE_BOTTOM;
_set_auto_orthogonal();
_update_name();
Expand All @@ -3533,7 +3543,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
case VIEW_LEFT: {
cursor.x_rot = 0;
cursor.y_rot = Math::PI / 2.0;
set_message(TTR("Left View."), 2);
set_message(TTR("Left view"), 2);
view_type = VIEW_TYPE_LEFT;
_set_auto_orthogonal();
_update_name();
Expand All @@ -3542,7 +3552,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
case VIEW_RIGHT: {
cursor.x_rot = 0;
cursor.y_rot = -Math::PI / 2.0;
set_message(TTR("Right View."), 2);
set_message(TTR("Right view"), 2);
view_type = VIEW_TYPE_RIGHT;
_set_auto_orthogonal();
_update_name();
Expand All @@ -3551,7 +3561,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
case VIEW_FRONT: {
cursor.x_rot = 0;
cursor.y_rot = 0;
set_message(TTR("Front View."), 2);
set_message(TTR("Front view"), 2);
view_type = VIEW_TYPE_FRONT;
_set_auto_orthogonal();
_update_name();
Expand All @@ -3560,7 +3570,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
case VIEW_REAR: {
cursor.x_rot = 0;
cursor.y_rot = Math::PI;
set_message(TTR("Rear View."), 2);
set_message(TTR("Rear view"), 2);
view_type = VIEW_TYPE_REAR;
_set_auto_orthogonal();
_update_name();
Expand Down Expand Up @@ -5011,7 +5021,7 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant
}

if (is_cyclical_dep) {
set_message(vformat(TTR("Can't instantiate: %s."), vformat(TTR("Circular dependency found at %s"), error_file)));
set_message(vformat(TTR("Can't instantiate: %s"), vformat(TTR("Circular dependency found at %s"), error_file)));
return false;
}

Expand Down Expand Up @@ -5247,8 +5257,7 @@ void Node3DEditorViewport::update_transform(bool p_shift) {
motion_snapped.snapf(snap);
// This might not be necessary anymore after issue #288 is solved (in 4.0?).
// TRANSLATORS: Refers to changing the scale of a node in the 3D editor.
set_message(TTR("Scaling:") + " (" + String::num(motion_snapped.x, snap_step_decimals) + ", " +
String::num(motion_snapped.y, snap_step_decimals) + ", " + String::num(motion_snapped.z, snap_step_decimals) + ")");
set_message(TTR("Scaling") + " " + _get_coordinates_string(motion_snapped, "", snap_step_decimals));
if (local_coords) {
// TODO: needed?
motion = _edit.original.basis.inverse().xform(motion);
Expand Down Expand Up @@ -5318,8 +5327,8 @@ void Node3DEditorViewport::update_transform(bool p_shift) {
Vector3 motion_snapped = motion;
motion_snapped.snapf(snap);
// TRANSLATORS: Refers to changing the position of a node in the 3D editor.
set_message(TTR("Translating:") + " (" + String::num(motion_snapped.x, snap_step_decimals) + ", " +
String::num(motion_snapped.y, snap_step_decimals) + ", " + String::num(motion_snapped.z, snap_step_decimals) + ")");
set_message(TTR("Translating") + " " + _get_coordinates_string(motion_snapped, "m", snap_step_decimals) +
"\t\t (" + rtos(motion_snapped.length()).pad_decimals(snap_step_decimals) + " m)");
if (local_coords) {
motion = spatial_editor->get_gizmo_transform().basis.inverse().xform(motion);
}
Expand Down Expand Up @@ -5397,7 +5406,9 @@ void Node3DEditorViewport::update_transform(bool p_shift) {
snap = spatial_editor->get_rotate_snap();
}
angle = Math::snapped(Math::rad_to_deg(angle), snap);
set_message(vformat(TTR("Rotating %s degrees."), String::num(angle, snap_step_decimals)));
// Add a space of additional padding for positive numbers, so that
// the `-` sign can display without reflowing numbers.
set_message(vformat(TTR(U"Rotating %s%.2f°"), angle >= 0.0 ? " " : "", angle));
angle = Math::deg_to_rad(angle);

bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); // Disable local transformation for TRANSFORM_VIEW
Expand Down Expand Up @@ -5454,17 +5465,19 @@ void Node3DEditorViewport::update_transform_numeric() {
switch (_edit.mode) {
case TRANSFORM_TRANSLATE:
motion *= value;
set_message(vformat(TTR("Translating %s."), motion));
set_message(vformat(TTR("Translating %s (%.3f m)"), _get_coordinates_string(motion, "m"), motion.length()));
break;
case TRANSFORM_ROTATE:
extra = Math::deg_to_rad(value);
set_message(vformat(TTR("Rotating %f degrees."), value));
// Add a space of additional padding for positive numbers, so that
// the `-` sign can display without reflowing numbers.
set_message(vformat(TTR(U"Rotating %s%.2f°"), value >= 0.0 ? " " : "", value));
break;
case TRANSFORM_SCALE:
// To halve the size of an object in Blender, you scale it by 0.5.
// Doing the same in Godot is considered scaling it by -0.5.
motion *= (value - 1.0);
set_message(vformat(TTR("Scaling %s."), motion));
set_message(vformat(TTR("Scaling %s"), _get_coordinates_string(motion)));
break;
case TRANSFORM_NONE:
ERR_FAIL_MSG("_edit.mode cannot be TRANSFORM_NONE in update_transform_numeric.");
Expand Down
1 change: 1 addition & 0 deletions editor/plugins/node_3d_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ class Node3DEditorViewport : public Control {
double message_time;

void set_message(const String &p_message, float p_time = 5);
String _get_coordinates_string(Vector3 p_coords, String p_suffix = "", int p_digits = 3) const;

void _view_settings_confirmed(real_t p_interp_delta);
void _update_camera(real_t p_interp_delta);
Expand Down
Loading