summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.cpp263
1 files changed, 114 insertions, 149 deletions
diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp
index 8d72178f23..201ff30f40 100644
--- a/tools/editor/plugins/spatial_editor_plugin.cpp
+++ b/tools/editor/plugins/spatial_editor_plugin.cpp
@@ -1658,136 +1658,89 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
default: {}
}
} break;
-
case InputEvent::KEY: {
-
const InputEventKey &k = p_event.key;
if (!k.pressed)
break;
- switch(k.scancode) {
-
- case KEY_S: {
-
- if (_edit.mode!=TRANSFORM_NONE) {
-
- _edit.snap=true;
- }
- } break;
- case KEY_7:
- case KEY_KP_7: {
- bool emulate_numpad = EditorSettings::get_singleton()->get("3d_editor/emulate_numpad");
- if (!emulate_numpad && k.scancode==KEY_7)
- return;
- cursor.y_rot=0;
- if (k.mod.shift) {
- cursor.x_rot=-Math_PI/2.0;
- set_message(TTR("Bottom View."),2);
- name=TTR("Bottom");
- _update_name();
-
- } else {
- cursor.x_rot=Math_PI/2.0;
- set_message(TTR("Top View."),2);
- name=TTR("Top");
- _update_name();
- }
- } break;
- case KEY_1:
- case KEY_KP_1: {
- bool emulate_numpad = EditorSettings::get_singleton()->get("3d_editor/emulate_numpad");
- if (!emulate_numpad && k.scancode==KEY_1)
- return;
- cursor.x_rot=0;
- if (k.mod.shift) {
- cursor.y_rot=Math_PI;
- set_message(TTR("Rear View."),2);
- name=TTR("Rear");
- _update_name();
-
- } else {
- cursor.y_rot=0;
- set_message(TTR("Front View."),2);
- name=TTR("Front");
- _update_name();
- }
-
- } break;
- case KEY_3:
- case KEY_KP_3: {
- bool emulate_numpad = EditorSettings::get_singleton()->get("3d_editor/emulate_numpad");
- if (!emulate_numpad && k.scancode==KEY_3)
- return;
- cursor.x_rot=0;
- if (k.mod.shift) {
- cursor.y_rot=Math_PI/2.0;
- set_message(TTR("Left View."),2);
- name=TTR("Left");
- _update_name();
- } else {
- cursor.y_rot=-Math_PI/2.0;
- set_message(TTR("Right View."),2);
- name=TTR("Right");
- _update_name();
- }
-
- } break;
- case KEY_5:
- case KEY_KP_5: {
- bool emulate_numpad = EditorSettings::get_singleton()->get("3d_editor/emulate_numpad");
- if (!emulate_numpad && k.scancode==KEY_5)
- return;
-
- //orthogonal = !orthogonal;
- _menu_option(orthogonal?VIEW_PERSPECTIVE:VIEW_ORTHOGONAL);
- _update_name();
-
-
- } break;
- case KEY_K: {
-
- if (!get_selected_count() || _edit.mode!=TRANSFORM_NONE)
- break;
-
- if (!AnimationPlayerEditor::singleton->get_key_editor()->has_keying()) {
- set_message(TTR("Keying is disabled (no key inserted)."));
- break;
- }
-
- List<Node*> &selection = editor_selection->get_selected_node_list();
-
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
-
- Spatial *sp = E->get()->cast_to<Spatial>();
- if (!sp)
- continue;
-
- emit_signal("transform_key_request",sp,"",sp->get_transform());
- }
-
-
- set_message(TTR("Animation Key Inserted."));
+ if (ED_IS_SHORTCUT("spatial_editor/snap", p_event)) {
+ if (_edit.mode != TRANSFORM_NONE) {
+ _edit.snap=true;
+ }
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/bottom_view", p_event)) {
+ cursor.y_rot = 0;
+ cursor.x_rot = -Math_PI/2.0;
+ set_message(TTR("Bottom View."),2);
+ name = TTR("Bottom");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/top_view", p_event)) {
+ cursor.y_rot = 0;
+ cursor.x_rot = Math_PI/2.0;
+ set_message(TTR("Top View."),2);
+ name = TTR("Top");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/rear_view", p_event)) {
+ cursor.x_rot = 0;
+ cursor.y_rot = Math_PI;
+ set_message(TTR("Rear View."),2);
+ name = TTR("Rear");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/front_view", p_event)) {
+ cursor.x_rot = 0;
+ cursor.y_rot=0;
+ set_message(TTR("Front View."),2);
+ name=TTR("Front");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/left_view", p_event)) {
+ cursor.x_rot=0;
+ cursor.y_rot = Math_PI/2.0;
+ set_message(TTR("Left View."),2);
+ name = TTR("Left");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/right_view", p_event)) {
+ cursor.x_rot=0;
+ cursor.y_rot = -Math_PI/2.0;
+ set_message(TTR("Right View."),2);
+ name = TTR("Right");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/switch_perspective_orthogonal", p_event)) {
+ _menu_option(orthogonal?VIEW_PERSPECTIVE:VIEW_ORTHOGONAL);
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/insert_anim_key", p_event)) {
+ if (!get_selected_count() || _edit.mode!=TRANSFORM_NONE)
+ break;
+ if (!AnimationPlayerEditor::singleton->get_key_editor()->has_keying()) {
+ set_message(TTR("Keying is disabled (no key inserted)."));
+ break;
+ }
- } break;
+ List<Node*> &selection = editor_selection->get_selected_node_list();
- case KEY_F: {
+ for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
- if (k.pressed && k.mod.shift && k.mod.control) {
- _menu_option(VIEW_ALIGN_SELECTION_WITH_VIEW);
- } else if (k.pressed) {
- _menu_option(VIEW_CENTER_TO_SELECTION);
- }
+ Spatial *sp = E->get()->cast_to<Spatial>();
+ if (!sp)
+ continue;
- } break;
+ emit_signal("transform_key_request",sp,"",sp->get_transform());
+ }
- case KEY_SPACE: {
- if (!k.pressed)
- emit_signal("toggle_maximize_view", this);
- } break;
+ set_message(TTR("Animation Key Inserted."));
}
+ if (k.scancode == KEY_SPACE) {
+ if (!k.pressed) emit_signal("toggle_maximize_view", this);
+ }
} break;
@@ -2470,29 +2423,28 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
surface->add_child(view_menu);
view_menu->set_pos( Point2(4,4));
view_menu->set_self_opacity(0.5);
-
- view_menu->get_popup()->add_item(TTR("Top (Num7)"),VIEW_TOP);
- view_menu->get_popup()->add_item(TTR("Bottom (Shift+Num7)"),VIEW_BOTTOM);
- view_menu->get_popup()->add_item(TTR("Left (Num3)"),VIEW_LEFT);
- view_menu->get_popup()->add_item(TTR("Right (Shift+Num3)"),VIEW_RIGHT);
- view_menu->get_popup()->add_item(TTR("Front (Num1)"),VIEW_FRONT);
- view_menu->get_popup()->add_item(TTR("Rear (Shift+Num1)"),VIEW_REAR);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/top_view"), VIEW_TOP);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/bottom_view"), VIEW_BOTTOM);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/left_view"), VIEW_LEFT);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/right_view"), VIEW_RIGHT);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/front_view"), VIEW_FRONT);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/rear_view"), VIEW_REAR);
view_menu->get_popup()->add_separator();
- view_menu->get_popup()->add_check_item(TTR("Perspective (Num5)"),VIEW_PERSPECTIVE);
- view_menu->get_popup()->add_check_item(TTR("Orthogonal (Num5)"),VIEW_ORTHOGONAL);
+ view_menu->get_popup()->add_check_item(TTR("Perspective") + " (" + ED_GET_SHORTCUT("spatial_editor/switch_perspective_orthogonal")->get_as_text() + ")", VIEW_PERSPECTIVE);
+ view_menu->get_popup()->add_check_item(TTR("Orthogonal") + " (" + ED_GET_SHORTCUT("spatial_editor/switch_perspective_orthogonal")->get_as_text() + ")", VIEW_ORTHOGONAL);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_PERSPECTIVE),true);
view_menu->get_popup()->add_separator();
- view_menu->get_popup()->add_check_item(TTR("Environment"),VIEW_ENVIRONMENT);
+ view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_environment", TTR("Environment")), VIEW_ENVIRONMENT);
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT),true);
view_menu->get_popup()->add_separator();
- view_menu->get_popup()->add_check_item(TTR("Audio Listener"),VIEW_AUDIO_LISTENER);
+ view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_audio_listener", TTR("Audio Listener")), VIEW_AUDIO_LISTENER);
view_menu->get_popup()->add_separator();
- view_menu->get_popup()->add_check_item(TTR("Gizmos"),VIEW_GIZMOS);
+ view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_gizmos", TTR("Gizmos")),VIEW_GIZMOS);
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_GIZMOS),true);
view_menu->get_popup()->add_separator();
- view_menu->get_popup()->add_item(TTR("Selection (F)"),VIEW_CENTER_TO_SELECTION);
- view_menu->get_popup()->add_item(TTR("Align with view (Ctrl+Shift+F)"),VIEW_ALIGN_SELECTION_WITH_VIEW);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/focus_selection"), VIEW_CENTER_TO_SELECTION);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_selection_with_view"), VIEW_ALIGN_SELECTION_WITH_VIEW);
view_menu->get_popup()->connect("item_pressed",this,"_menu_option");
preview_camera = memnew( Button );
@@ -3951,6 +3903,19 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
hbc_menu->add_child(vs);
+ ED_SHORTCUT("spatial_editor/bottom_view", TTR("Bottom View"), KEY_MASK_ALT+KEY_KP_7);
+ ED_SHORTCUT("spatial_editor/top_view", TTR("Top View"), KEY_KP_7);
+ ED_SHORTCUT("spatial_editor/rear_view", TTR("Rear View"), KEY_MASK_ALT+KEY_KP_1);
+ ED_SHORTCUT("spatial_editor/front_view", TTR("Front View"), KEY_KP_1);
+ ED_SHORTCUT("spatial_editor/left_view", TTR("Left View"), KEY_MASK_ALT+KEY_KP_3);
+ ED_SHORTCUT("spatial_editor/right_view", TTR("Right View"), KEY_KP_3);
+ ED_SHORTCUT("spatial_editor/switch_perspective_orthogonal", TTR("Switch Perspective/Orthogonal view"), KEY_KP_5);
+ ED_SHORTCUT("spatial_editor/snap", TTR("Snap"), KEY_S);
+ ED_SHORTCUT("spatial_editor/insert_anim_key", TTR("Insert Animation Key"), KEY_K);
+ ED_SHORTCUT("spatial_editor/focus_selection", TTR("Focus Selection"), KEY_F);
+ ED_SHORTCUT("spatial_editor/align_selection_with_view", TTR("Align Selection With View"), KEY_MASK_ALT+KEY_MASK_CMD+KEY_F);
+
+
PopupMenu *p;
transform_menu = memnew( MenuButton );
@@ -3958,13 +3923,13 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
hbc_menu->add_child( transform_menu );
p = transform_menu->get_popup();
- p->add_check_item(TTR("Use Snap"),MENU_TRANSFORM_USE_SNAP);
- p->add_item(TTR("Configure Snap.."),MENU_TRANSFORM_CONFIGURE_SNAP);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/use_snap", TTR("Use Snap")), MENU_TRANSFORM_USE_SNAP);
+ p->add_shortcut(ED_SHORTCUT("spatial_editor/configure_snap", TTR("Configure Snap..")), MENU_TRANSFORM_CONFIGURE_SNAP);
p->add_separator();
- p->add_check_item(TTR("Local Coords"),MENU_TRANSFORM_LOCAL_COORDS);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/local_coords", TTR("Local Coords")), MENU_TRANSFORM_LOCAL_COORDS);
//p->set_item_checked(p->get_item_count()-1,true);
p->add_separator();
- p->add_item(TTR("Transform Dialog.."),MENU_TRANSFORM_DIALOG);
+ p->add_shortcut(ED_SHORTCUT("spatial_editor/transform_dialog", TTR("Transform Dialog..")), MENU_TRANSFORM_DIALOG);
p->connect("item_pressed", this,"_menu_item_pressed");
@@ -3975,27 +3940,27 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
p = view_menu->get_popup();
- p->add_check_item(TTR("Use Default Light"),MENU_VIEW_USE_DEFAULT_LIGHT);
- p->add_check_item(TTR("Use Default sRGB"),MENU_VIEW_USE_DEFAULT_SRGB);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/use_default_light", TTR("Use Default Light")), MENU_VIEW_USE_DEFAULT_LIGHT);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/use_default_srgb", TTR("Use Default sRGB")), MENU_VIEW_USE_DEFAULT_SRGB);
p->add_separator();
- p->add_check_item(TTR("1 Viewport"),MENU_VIEW_USE_1_VIEWPORT,KEY_MASK_CMD+KEY_1);
- p->add_check_item(TTR("2 Viewports"),MENU_VIEW_USE_2_VIEWPORTS,KEY_MASK_CMD+KEY_2);
- p->add_check_item(TTR("2 Viewports (Alt)"),MENU_VIEW_USE_2_VIEWPORTS_ALT,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_2);
- p->add_check_item(TTR("3 Viewports"),MENU_VIEW_USE_3_VIEWPORTS,KEY_MASK_CMD+KEY_3);
- p->add_check_item(TTR("3 Viewports (Alt)"),MENU_VIEW_USE_3_VIEWPORTS_ALT,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_3);
- p->add_check_item(TTR("4 Viewports"),MENU_VIEW_USE_4_VIEWPORTS,KEY_MASK_CMD+KEY_4);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/1_viewport", TTR("1 Viewport"), KEY_MASK_CMD+KEY_1), MENU_VIEW_USE_1_VIEWPORT);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports", TTR("2 Viewports"), KEY_MASK_CMD+KEY_2), MENU_VIEW_USE_2_VIEWPORTS);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports_alt", TTR("2 Viewports (Alt)"), KEY_MASK_ALT+KEY_MASK_CMD+KEY_2), MENU_VIEW_USE_2_VIEWPORTS_ALT);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/3_viewports", TTR("3 Viewports"),KEY_MASK_CMD+KEY_3), MENU_VIEW_USE_3_VIEWPORTS);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/3_viewports_alt", TTR("3 Viewports (Alt)"), KEY_MASK_ALT+KEY_MASK_CMD+KEY_3), MENU_VIEW_USE_3_VIEWPORTS_ALT);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/4_viewports", TTR("4 Viewports"), KEY_MASK_CMD+KEY_4), MENU_VIEW_USE_4_VIEWPORTS);
p->add_separator();
- p->add_check_item(TTR("Display Normal"),MENU_VIEW_DISPLAY_NORMAL);
- p->add_check_item(TTR("Display Wireframe"),MENU_VIEW_DISPLAY_WIREFRAME);
- p->add_check_item(TTR("Display Overdraw"),MENU_VIEW_DISPLAY_OVERDRAW);
- p->add_check_item(TTR("Display Shadeless"),MENU_VIEW_DISPLAY_SHADELESS);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/display_normal", TTR("Display Normal")), MENU_VIEW_DISPLAY_NORMAL);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/display_wireframe", TTR("Display Wireframe")), MENU_VIEW_DISPLAY_WIREFRAME);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/display_overdraw", TTR("Display Overdraw")), MENU_VIEW_DISPLAY_OVERDRAW);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/display_shadeless", TTR("Display Shadeless")), MENU_VIEW_DISPLAY_SHADELESS);
p->add_separator();
- p->add_check_item(TTR("View Origin"),MENU_VIEW_ORIGIN);
- p->add_check_item(TTR("View Grid"),MENU_VIEW_GRID);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_origin", TTR("View Origin")), MENU_VIEW_ORIGIN);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_grid", TTR("View Grid")), MENU_VIEW_GRID);
p->add_separator();
- p->add_item(TTR("Settings"),MENU_VIEW_CAMERA_SETTINGS);
+ p->add_shortcut(ED_SHORTCUT("spatial_editor/settings", TTR("Settings")), MENU_VIEW_CAMERA_SETTINGS);
p->set_item_checked( p->get_item_index(MENU_VIEW_USE_DEFAULT_LIGHT), true );