Fix i18n of 3D view name
Make the full view name translatable as a whole instead of combining from sub-strings.
This commit is contained in:
parent
632844e464
commit
afea754e97
2 changed files with 83 additions and 24 deletions
|
@ -727,22 +727,71 @@ void SpatialEditorViewport::_select_region() {
|
|||
}
|
||||
|
||||
void SpatialEditorViewport::_update_name() {
|
||||
String view_mode = orthogonal ? TTR("Orthogonal") : TTR("Perspective");
|
||||
String name;
|
||||
|
||||
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 (auto_orthogonal) {
|
||||
view_mode += " [auto]";
|
||||
// TRANSLATORS: This will be appended to the view name when Auto Orthogonal is enabled.
|
||||
name += TTR(" [auto]");
|
||||
}
|
||||
|
||||
if (RoomManager::static_rooms_get_active_and_loaded()) {
|
||||
view_mode += " [portals active]";
|
||||
}
|
||||
|
||||
if (name != "") {
|
||||
view_menu->set_text(name + " " + view_mode);
|
||||
} else {
|
||||
view_menu->set_text(view_mode);
|
||||
// TRANSLATORS: This will be appended to the view name when Portal Occulusion is enabled.
|
||||
name += TTR(" [portals active]");
|
||||
}
|
||||
|
||||
view_menu->set_text(name);
|
||||
view_menu->set_size(Vector2(0, 0)); // resets the button size
|
||||
}
|
||||
|
||||
|
@ -1180,7 +1229,7 @@ void SpatialEditorViewport::_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: {
|
||||
|
@ -2117,7 +2166,7 @@ void SpatialEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, con
|
|||
} else {
|
||||
cursor.y_rot += p_relative.x * radians_per_pixel;
|
||||
}
|
||||
name = "";
|
||||
view_type = VIEW_TYPE_USER;
|
||||
_update_name();
|
||||
}
|
||||
|
||||
|
@ -2155,7 +2204,7 @@ void SpatialEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, cons
|
|||
Vector3 diff = prev_pos - pos;
|
||||
cursor.pos += diff;
|
||||
|
||||
name = "";
|
||||
view_type = VIEW_TYPE_USER;
|
||||
_update_name();
|
||||
}
|
||||
|
||||
|
@ -2741,7 +2790,7 @@ void SpatialEditorViewport::_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();
|
||||
|
||||
|
@ -2750,7 +2799,7 @@ void SpatialEditorViewport::_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();
|
||||
|
||||
|
@ -2759,7 +2808,7 @@ void SpatialEditorViewport::_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();
|
||||
|
||||
|
@ -2768,7 +2817,7 @@ void SpatialEditorViewport::_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();
|
||||
|
||||
|
@ -2777,7 +2826,7 @@ void SpatialEditorViewport::_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();
|
||||
|
||||
|
@ -2786,7 +2835,7 @@ void SpatialEditorViewport::_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();
|
||||
|
||||
|
@ -3254,8 +3303,8 @@ void SpatialEditorViewport::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")) {
|
||||
|
@ -3363,7 +3412,7 @@ Dictionary SpatialEditorViewport::get_state() const {
|
|||
d["distance"] = cursor.distance;
|
||||
d["use_environment"] = camera->get_environment().is_valid();
|
||||
d["use_orthogonal"] = camera->get_projection() == Camera::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))) {
|
||||
|
@ -3421,7 +3470,7 @@ void SpatialEditorViewport::reset() {
|
|||
message_time = 0;
|
||||
message = "";
|
||||
last_message = "";
|
||||
name = "";
|
||||
view_type = VIEW_TYPE_USER;
|
||||
|
||||
cursor = Cursor();
|
||||
_update_name();
|
||||
|
@ -3973,7 +4022,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
|
|||
viewport->set_as_audio_listener(true);
|
||||
}
|
||||
|
||||
name = "";
|
||||
view_type = VIEW_TYPE_USER;
|
||||
_update_name();
|
||||
|
||||
EditorSettings::get_singleton()->connect("settings_changed", this, "update_transform_gizmo_view");
|
||||
|
|
|
@ -211,6 +211,16 @@ class SpatialEditorViewport : public Control {
|
|||
VIEW_PORTAL_CULLING,
|
||||
};
|
||||
|
||||
enum ViewType {
|
||||
VIEW_TYPE_USER,
|
||||
VIEW_TYPE_TOP,
|
||||
VIEW_TYPE_BOTTOM,
|
||||
VIEW_TYPE_LEFT,
|
||||
VIEW_TYPE_RIGHT,
|
||||
VIEW_TYPE_FRONT,
|
||||
VIEW_TYPE_REAR,
|
||||
};
|
||||
|
||||
public:
|
||||
enum {
|
||||
GIZMO_BASE_LAYER = 27,
|
||||
|
@ -233,7 +243,7 @@ public:
|
|||
|
||||
private:
|
||||
int index;
|
||||
String name;
|
||||
ViewType view_type;
|
||||
void _menu_option(int p_option);
|
||||
void _set_auto_orthogonal();
|
||||
Spatial *preview_node;
|
||||
|
|
Loading…
Reference in a new issue