You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
fix numpad emulation in 3d navigation shortcuts
This commit is contained in:
@@ -2455,10 +2455,13 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
||||
}
|
||||
}
|
||||
|
||||
Ref<InputEvent> event_mod = p_event;
|
||||
if (EDITOR_GET("editors/3d/navigation/emulate_numpad")) {
|
||||
const Key code = k->get_physical_keycode();
|
||||
if (code >= Key::KEY_0 && code <= Key::KEY_9) {
|
||||
k->set_keycode(code - Key::KEY_0 + Key::KP_0);
|
||||
event_mod = p_event->duplicate();
|
||||
Ref<InputEventKey> k_mod = event_mod;
|
||||
k_mod->set_keycode(code - Key::KEY_0 + Key::KP_0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2480,18 +2483,18 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
||||
} else {
|
||||
// We're actively transforming, handle keys specially
|
||||
TransformPlane new_plane = TRANSFORM_VIEW;
|
||||
if (ED_IS_SHORTCUT("spatial_editor/lock_transform_x", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/lock_transform_x", event_mod)) {
|
||||
new_plane = TRANSFORM_X_AXIS;
|
||||
} else if (ED_IS_SHORTCUT("spatial_editor/lock_transform_y", p_event)) {
|
||||
} else if (ED_IS_SHORTCUT("spatial_editor/lock_transform_y", event_mod)) {
|
||||
new_plane = TRANSFORM_Y_AXIS;
|
||||
} else if (ED_IS_SHORTCUT("spatial_editor/lock_transform_z", p_event)) {
|
||||
} else if (ED_IS_SHORTCUT("spatial_editor/lock_transform_z", event_mod)) {
|
||||
new_plane = TRANSFORM_Z_AXIS;
|
||||
} else if (_edit.mode != TRANSFORM_ROTATE) { // rotating on a plane doesn't make sense
|
||||
if (ED_IS_SHORTCUT("spatial_editor/lock_transform_yz", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/lock_transform_yz", event_mod)) {
|
||||
new_plane = TRANSFORM_YZ;
|
||||
} else if (ED_IS_SHORTCUT("spatial_editor/lock_transform_xz", p_event)) {
|
||||
} else if (ED_IS_SHORTCUT("spatial_editor/lock_transform_xz", event_mod)) {
|
||||
new_plane = TRANSFORM_XZ;
|
||||
} else if (ED_IS_SHORTCUT("spatial_editor/lock_transform_xy", p_event)) {
|
||||
} else if (ED_IS_SHORTCUT("spatial_editor/lock_transform_xy", event_mod)) {
|
||||
new_plane = TRANSFORM_XY;
|
||||
}
|
||||
}
|
||||
@@ -2518,74 +2521,74 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/snap", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/snap", event_mod)) {
|
||||
if (_edit.mode != TRANSFORM_NONE) {
|
||||
_edit.snap = !_edit.snap;
|
||||
}
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/bottom_view", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/bottom_view", event_mod)) {
|
||||
_menu_option(VIEW_BOTTOM);
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/top_view", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/top_view", event_mod)) {
|
||||
_menu_option(VIEW_TOP);
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/rear_view", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/rear_view", event_mod)) {
|
||||
_menu_option(VIEW_REAR);
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/front_view", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/front_view", event_mod)) {
|
||||
_menu_option(VIEW_FRONT);
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/left_view", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/left_view", event_mod)) {
|
||||
_menu_option(VIEW_LEFT);
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/right_view", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/right_view", event_mod)) {
|
||||
_menu_option(VIEW_RIGHT);
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/orbit_view_down", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/orbit_view_down", event_mod)) {
|
||||
// Clamp rotation to roughly -90..90 degrees so the user can't look upside-down and end up disoriented.
|
||||
cursor.x_rot = CLAMP(cursor.x_rot - Math::PI / 12.0, -1.57, 1.57);
|
||||
cursor.unsnapped_x_rot = cursor.x_rot;
|
||||
view_type = VIEW_TYPE_USER;
|
||||
_update_name();
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/orbit_view_up", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/orbit_view_up", event_mod)) {
|
||||
// Clamp rotation to roughly -90..90 degrees so the user can't look upside-down and end up disoriented.
|
||||
cursor.x_rot = CLAMP(cursor.x_rot + Math::PI / 12.0, -1.57, 1.57);
|
||||
cursor.unsnapped_x_rot = cursor.x_rot;
|
||||
view_type = VIEW_TYPE_USER;
|
||||
_update_name();
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/orbit_view_right", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/orbit_view_right", event_mod)) {
|
||||
cursor.y_rot -= Math::PI / 12.0;
|
||||
cursor.unsnapped_y_rot = cursor.y_rot;
|
||||
view_type = VIEW_TYPE_USER;
|
||||
_update_name();
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/orbit_view_left", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/orbit_view_left", event_mod)) {
|
||||
cursor.y_rot += Math::PI / 12.0;
|
||||
cursor.unsnapped_y_rot = cursor.y_rot;
|
||||
view_type = VIEW_TYPE_USER;
|
||||
_update_name();
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/orbit_view_180", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/orbit_view_180", event_mod)) {
|
||||
cursor.y_rot += Math::PI;
|
||||
cursor.unsnapped_y_rot = cursor.y_rot;
|
||||
view_type = VIEW_TYPE_USER;
|
||||
_update_name();
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/focus_origin", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/focus_origin", event_mod)) {
|
||||
_menu_option(VIEW_CENTER_TO_ORIGIN);
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/focus_selection", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/focus_selection", event_mod)) {
|
||||
_menu_option(VIEW_CENTER_TO_SELECTION);
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/align_transform_with_view", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/align_transform_with_view", event_mod)) {
|
||||
_menu_option(VIEW_ALIGN_TRANSFORM_WITH_VIEW);
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/align_rotation_with_view", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/align_rotation_with_view", event_mod)) {
|
||||
_menu_option(VIEW_ALIGN_ROTATION_WITH_VIEW);
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/insert_anim_key", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/insert_anim_key", event_mod)) {
|
||||
if (!get_selected_count() || _edit.mode != TRANSFORM_NONE) {
|
||||
return;
|
||||
}
|
||||
@@ -2608,20 +2611,20 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
||||
|
||||
set_message(TTR("Animation Key Inserted."));
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/cancel_transform", p_event) && _edit.mode != TRANSFORM_NONE) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/cancel_transform", event_mod) && _edit.mode != TRANSFORM_NONE) {
|
||||
cancel_transform();
|
||||
}
|
||||
if (!is_freelook_active() && !k->is_echo()) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/reset_transform_position", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/reset_transform_position", event_mod)) {
|
||||
_reset_transform(TransformType::POSITION);
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/reset_transform_rotation", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/reset_transform_rotation", event_mod)) {
|
||||
_reset_transform(TransformType::ROTATION);
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/reset_transform_scale", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/reset_transform_scale", event_mod)) {
|
||||
_reset_transform(TransformType::SCALE);
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/instant_translate", p_event) && (_edit.mode != TRANSFORM_TRANSLATE || collision_reposition)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/instant_translate", event_mod) && (_edit.mode != TRANSFORM_TRANSLATE || collision_reposition)) {
|
||||
if (_edit.mode == TRANSFORM_NONE) {
|
||||
begin_transform(TRANSFORM_TRANSLATE, true);
|
||||
} else if (_edit.instant || collision_reposition) {
|
||||
@@ -2629,7 +2632,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
||||
begin_transform(TRANSFORM_TRANSLATE, true);
|
||||
}
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/instant_rotate", p_event) && _edit.mode != TRANSFORM_ROTATE) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/instant_rotate", event_mod) && _edit.mode != TRANSFORM_ROTATE) {
|
||||
if (_edit.mode == TRANSFORM_NONE) {
|
||||
begin_transform(TRANSFORM_ROTATE, true);
|
||||
} else if (_edit.instant || collision_reposition) {
|
||||
@@ -2637,7 +2640,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
||||
begin_transform(TRANSFORM_ROTATE, true);
|
||||
}
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/instant_scale", p_event) && _edit.mode != TRANSFORM_SCALE) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/instant_scale", event_mod) && _edit.mode != TRANSFORM_SCALE) {
|
||||
if (_edit.mode == TRANSFORM_NONE) {
|
||||
begin_transform(TRANSFORM_SCALE, true);
|
||||
} else if (_edit.instant || collision_reposition) {
|
||||
@@ -2645,7 +2648,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
||||
begin_transform(TRANSFORM_SCALE, true);
|
||||
}
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/collision_reposition", p_event) && editor_selection->get_top_selected_node_list().size() == 1 && !collision_reposition) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/collision_reposition", event_mod) && editor_selection->get_top_selected_node_list().size() == 1 && !collision_reposition) {
|
||||
if (_edit.mode == TRANSFORM_NONE || _edit.instant) {
|
||||
if (_edit.mode == TRANSFORM_NONE) {
|
||||
_compute_edit(_edit.mouse_pos);
|
||||
@@ -2660,7 +2663,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
||||
}
|
||||
|
||||
// Freelook doesn't work in orthogonal mode.
|
||||
if (!orthogonal && ED_IS_SHORTCUT("spatial_editor/freelook_toggle", p_event)) {
|
||||
if (!orthogonal && ED_IS_SHORTCUT("spatial_editor/freelook_toggle", event_mod)) {
|
||||
set_freelook_active(!is_freelook_active());
|
||||
|
||||
} else if (k->get_keycode() == Key::ESCAPE) {
|
||||
@@ -2673,15 +2676,15 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
||||
}
|
||||
}
|
||||
|
||||
if (ED_IS_SHORTCUT("spatial_editor/decrease_fov", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/decrease_fov", event_mod)) {
|
||||
scale_fov(-0.05);
|
||||
}
|
||||
|
||||
if (ED_IS_SHORTCUT("spatial_editor/increase_fov", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/increase_fov", event_mod)) {
|
||||
scale_fov(0.05);
|
||||
}
|
||||
|
||||
if (ED_IS_SHORTCUT("spatial_editor/reset_fov", p_event)) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/reset_fov", event_mod)) {
|
||||
reset_fov();
|
||||
}
|
||||
}
|
||||
@@ -9842,12 +9845,12 @@ Node3DEditor::Node3DEditor() {
|
||||
accept = memnew(AcceptDialog);
|
||||
EditorNode::get_singleton()->get_gui_base()->add_child(accept);
|
||||
|
||||
p->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/1_viewport", TTRC("1 Viewport"), KeyModifierMask::CMD_OR_CTRL + Key::KEY_1), MENU_VIEW_USE_1_VIEWPORT);
|
||||
p->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports", TTRC("2 Viewports"), KeyModifierMask::CMD_OR_CTRL + Key::KEY_2), MENU_VIEW_USE_2_VIEWPORTS);
|
||||
p->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports_alt", TTRC("2 Viewports (Alt)"), KeyModifierMask::ALT + KeyModifierMask::CMD_OR_CTRL + Key::KEY_2), MENU_VIEW_USE_2_VIEWPORTS_ALT);
|
||||
p->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/3_viewports", TTRC("3 Viewports"), KeyModifierMask::CMD_OR_CTRL + Key::KEY_3), MENU_VIEW_USE_3_VIEWPORTS);
|
||||
p->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/3_viewports_alt", TTRC("3 Viewports (Alt)"), KeyModifierMask::ALT + KeyModifierMask::CMD_OR_CTRL + Key::KEY_3), MENU_VIEW_USE_3_VIEWPORTS_ALT);
|
||||
p->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/4_viewports", TTRC("4 Viewports"), KeyModifierMask::CMD_OR_CTRL + Key::KEY_4), MENU_VIEW_USE_4_VIEWPORTS);
|
||||
p->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/1_viewport", TTRC("1 Viewport"), KeyModifierMask::CMD_OR_CTRL + Key::KEY_1, true), MENU_VIEW_USE_1_VIEWPORT);
|
||||
p->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports", TTRC("2 Viewports"), KeyModifierMask::CMD_OR_CTRL + Key::KEY_2, true), MENU_VIEW_USE_2_VIEWPORTS);
|
||||
p->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports_alt", TTRC("2 Viewports (Alt)"), KeyModifierMask::ALT + KeyModifierMask::CMD_OR_CTRL + Key::KEY_2, true), MENU_VIEW_USE_2_VIEWPORTS_ALT);
|
||||
p->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/3_viewports", TTRC("3 Viewports"), KeyModifierMask::CMD_OR_CTRL + Key::KEY_3, true), MENU_VIEW_USE_3_VIEWPORTS);
|
||||
p->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/3_viewports_alt", TTRC("3 Viewports (Alt)"), KeyModifierMask::ALT + KeyModifierMask::CMD_OR_CTRL + Key::KEY_3, true), MENU_VIEW_USE_3_VIEWPORTS_ALT);
|
||||
p->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/4_viewports", TTRC("4 Viewports"), KeyModifierMask::CMD_OR_CTRL + Key::KEY_4, true), MENU_VIEW_USE_4_VIEWPORTS);
|
||||
p->add_separator();
|
||||
|
||||
gizmos_menu = memnew(PopupMenu);
|
||||
|
||||
Reference in New Issue
Block a user