Editor: Make "open 2d/3d/script editor" shortcuts configurable.

Also adds shortcuts for opening the AssetLib and for switching to the next/prev editor.

(cherry picked from commit 3be8a94868)
This commit is contained in:
Andreas Haas 2017-05-16 21:26:32 +02:00 committed by Rémi Verschelde
parent 06ca73c6f8
commit 1033250001
3 changed files with 52 additions and 23 deletions

View File

@ -193,28 +193,20 @@ void EditorNode::_unhandled_input(const InputEvent &p_event) {
filesystem_dock->focus_on_filter();
}
switch (p_event.key.scancode) {
/*case KEY_F1:
if (!p_event.key.mod.shift && !p_event.key.mod.command)
_editor_select(EDITOR_SCRIPT);
break;*/
case KEY_F1:
if (!p_event.key.mod.shift && !p_event.key.mod.command)
_editor_select(EDITOR_2D);
break;
case KEY_F2:
if (!p_event.key.mod.shift && !p_event.key.mod.command)
_editor_select(EDITOR_3D);
break;
case KEY_F3:
if (!p_event.key.mod.shift && !p_event.key.mod.command)
_editor_select(EDITOR_SCRIPT);
break;
/* case KEY_F5: _menu_option_confirm((p_event.key.mod.control&&p_event.key.mod.shift)?RUN_PLAY_CUSTOM_SCENE:RUN_PLAY,true); break;
case KEY_F6: _menu_option_confirm(RUN_PLAY_SCENE,true); break;
//case KEY_F7: _menu_option_confirm(RUN_PAUSE,true); break;
case KEY_F8: _menu_option_confirm(RUN_STOP,true); break;*/
if (ED_IS_SHORTCUT("editor/editor_2d", p_event)) {
_editor_select(EDITOR_2D);
} else if (ED_IS_SHORTCUT("editor/editor_3d", p_event)) {
_editor_select(EDITOR_3D);
} else if (ED_IS_SHORTCUT("editor/editor_script", p_event)) {
_editor_select(EDITOR_SCRIPT);
} else if (ED_IS_SHORTCUT("editor/editor_help", p_event)) {
emit_signal("request_help_search", "");
} else if (ED_IS_SHORTCUT("editor/editor_assetlib", p_event)) {
_editor_select(EDITOR_ASSETLIB);
} else if (ED_IS_SHORTCUT("editor/editor_next", p_event)) {
_editor_select_next();
} else if (ED_IS_SHORTCUT("editor/editor_prev", p_event)) {
_editor_select_prev();
}
}
}
@ -495,6 +487,30 @@ void EditorNode::_node_renamed() {
property_editor->update_tree();
}
void EditorNode::_editor_select_next() {
int editor = _get_current_main_editor();
if (editor == editor_table.size() - 1) {
editor = 0;
} else {
editor++;
}
_editor_select(editor);
}
void EditorNode::_editor_select_prev() {
int editor = _get_current_main_editor();
if (editor == 0) {
editor = editor_table.size() - 1;
} else {
editor--;
}
_editor_select(editor);
}
Error EditorNode::load_resource(const String &p_scene) {
RES res = ResourceLoader::load(p_scene);
@ -5051,6 +5067,7 @@ void EditorNode::_bind_methods() {
ADD_SIGNAL(MethodInfo("pause_pressed"));
ADD_SIGNAL(MethodInfo("stop_pressed"));
ADD_SIGNAL(MethodInfo("request_help"));
ADD_SIGNAL(MethodInfo("request_help_search"));
ADD_SIGNAL(MethodInfo("script_add_function_request", PropertyInfo(Variant::OBJECT, "obj"), PropertyInfo(Variant::STRING, "function"), PropertyInfo(Variant::STRING_ARRAY, "args")));
ADD_SIGNAL(MethodInfo("resource_saved", PropertyInfo(Variant::OBJECT, "obj")));
}
@ -6327,6 +6344,14 @@ EditorNode::EditorNode() {
_load_docks();
FileAccess::set_file_close_fail_notify_callback(_file_access_close_error_notify);
ED_SHORTCUT("editor/editor_2d", TTR("Open 2D Editor"), KEY_F2);
ED_SHORTCUT("editor/editor_3d", TTR("Open 3D Editor"), KEY_F3);
ED_SHORTCUT("editor/editor_script", TTR("Open Script Editor"), KEY_F4);
ED_SHORTCUT("editor/editor_help", TTR("Search Help"), KEY_F1);
ED_SHORTCUT("editor/editor_assetlib", TTR("Open Asset Library"));
ED_SHORTCUT("editor/editor_next", TTR("Open the next Editor"));
ED_SHORTCUT("editor/editor_prev", TTR("Open the previous Editor"));
}
EditorNode::~EditorNode() {

View File

@ -434,6 +434,8 @@ private:
void _imported(Node *p_node);
void _node_renamed();
void _editor_select_next();
void _editor_select_prev();
void _editor_select(int p_which);
void _set_scene_metadata(const String &p_file, int p_idx = -1);
void _get_scene_metadata(const String &p_file);
@ -576,7 +578,8 @@ public:
enum EditorTable {
EDITOR_2D = 0,
EDITOR_3D,
EDITOR_SCRIPT
EDITOR_SCRIPT,
EDITOR_ASSETLIB
};
void set_visible_editor(EditorTable p_table) { _editor_select(p_table); }

View File

@ -1615,6 +1615,7 @@ void ScriptEditor::_notification(int p_what) {
get_tree()->connect("tree_changed", this, "_tree_changed");
editor->connect("request_help", this, "_request_help");
editor->connect("request_help_search", this, "_help_search");
}
if (p_what == NOTIFICATION_EXIT_TREE) {