1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

Merge pull request #5166 from djrm/shortcuts

Added customizable shortcuts for tile map editor
This commit is contained in:
Rémi Verschelde
2016-06-19 12:50:35 +02:00
committed by GitHub
3 changed files with 64 additions and 54 deletions

View File

@@ -5556,8 +5556,8 @@ EditorNode::EditorNode() {
p->add_submenu_item(TTR("Convert To.."),"Export"); p->add_submenu_item(TTR("Convert To.."),"Export");
pm_export->add_item(TTR("Translatable Strings.."),FILE_DUMP_STRINGS); pm_export->add_item(TTR("Translatable Strings.."),FILE_DUMP_STRINGS);
pm_export->add_separator(); pm_export->add_separator();
pm_export->add_item(TTR("MeshLibrary.."),FILE_EXPORT_MESH_LIBRARY); pm_export->add_shortcut(ED_SHORTCUT("editor/convert_to_MeshLibrary", TTR("MeshLibrary..")), FILE_EXPORT_MESH_LIBRARY);
pm_export->add_item(TTR("TileSet.."),FILE_EXPORT_TILESET); pm_export->add_shortcut(ED_SHORTCUT("editor/convert_to_TileSet", TTR("TileSet..")), FILE_EXPORT_TILESET);
pm_export->connect("item_pressed",this,"_menu_option"); pm_export->connect("item_pressed",this,"_menu_option");
p->add_separator(); p->add_separator();

View File

@@ -1356,19 +1356,23 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
add_anim = memnew( ToolButton ); add_anim = memnew( ToolButton );
ED_SHORTCUT("animation_player_editor/add_animation", TTR("Create new animation in player."));
add_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/add_animation"));
add_anim->set_tooltip(TTR("Create new animation in player.")); add_anim->set_tooltip(TTR("Create new animation in player."));
hb->add_child(add_anim); hb->add_child(add_anim);
load_anim = memnew( ToolButton ); load_anim = memnew( ToolButton );
ED_SHORTCUT("animation_player_editor/load_from_disk", TTR("Load animation from disk."));
add_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/load_from_disk"));
load_anim->set_tooltip(TTR("Load an animation from disk.")); load_anim->set_tooltip(TTR("Load an animation from disk."));
hb->add_child(load_anim); hb->add_child(load_anim);
save_anim = memnew(MenuButton); save_anim = memnew(MenuButton);
save_anim->set_tooltip(TTR("Save the current animation")); save_anim->set_tooltip(TTR("Save the current animation"));
save_anim->get_popup()->add_item(TTR("Save"), ANIM_SAVE); save_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/save", TTR("Save")), ANIM_SAVE);
save_anim->get_popup()->add_item(TTR("Save As.."), ANIM_SAVE_AS); save_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/save_as", TTR("Save As")), ANIM_SAVE_AS);
save_anim->set_focus_mode(Control::FOCUS_NONE); save_anim->set_focus_mode(Control::FOCUS_NONE);
hb->add_child(save_anim); hb->add_child(save_anim);
@@ -1378,15 +1382,21 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
duplicate_anim = memnew( ToolButton ); duplicate_anim = memnew( ToolButton );
hb->add_child(duplicate_anim); hb->add_child(duplicate_anim);
ED_SHORTCUT("animation_player_editor/duplicate_animation", TTR("Duplicate Animation"));
duplicate_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/duplicate_animation"));
duplicate_anim->set_tooltip(TTR("Duplicate Animation")); duplicate_anim->set_tooltip(TTR("Duplicate Animation"));
rename_anim = memnew( ToolButton ); rename_anim = memnew( ToolButton );
hb->add_child(rename_anim); hb->add_child(rename_anim);
ED_SHORTCUT("animation_player_editor/rename_animation", TTR("Rename Animation"));
rename_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/rename_animation"));
rename_anim->set_tooltip(TTR("Rename Animation")); rename_anim->set_tooltip(TTR("Rename Animation"));
remove_anim = memnew( ToolButton ); remove_anim = memnew( ToolButton );
hb->add_child(remove_anim); hb->add_child(remove_anim);
ED_SHORTCUT("animation_player_editor/remove_animation", TTR("Remove Animation"));
remove_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/remove_animation"));
remove_anim->set_tooltip(TTR("Remove Animation")); remove_anim->set_tooltip(TTR("Remove Animation"));
@@ -1408,8 +1418,8 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
tool_anim = memnew( MenuButton); tool_anim = memnew( MenuButton);
//tool_anim->set_flat(false); //tool_anim->set_flat(false);
tool_anim->set_tooltip(TTR("Animation Tools")); tool_anim->set_tooltip(TTR("Animation Tools"));
tool_anim->get_popup()->add_item(TTR("Copy Animation"),TOOL_COPY_ANIM); tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/copy_animation", TTR("Copy Animation")),TOOL_COPY_ANIM);
tool_anim->get_popup()->add_item(TTR("Paste Animation"),TOOL_PASTE_ANIM); tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/paste_animation", TTR("Paste Animation")),TOOL_PASTE_ANIM);
//tool_anim->get_popup()->add_separator(); //tool_anim->get_popup()->add_separator();
//tool_anim->get_popup()->add_item("Edit Anim Resource",TOOL_PASTE_ANIM); //tool_anim->get_popup()->add_item("Edit Anim Resource",TOOL_PASTE_ANIM);
hb->add_child(tool_anim); hb->add_child(tool_anim);

View File

@@ -893,24 +893,12 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) {
if (tool!=TOOL_NONE || !mouse_over) if (tool!=TOOL_NONE || !mouse_over)
return false; return false;
if (k.scancode==KEY_DELETE) { if (ED_IS_SHORTCUT("tile_map_editor/erase_selection", p_event)) {
_menu_option(OPTION_ERASE_SELECTION); _menu_option(OPTION_ERASE_SELECTION);
return true; return true;
} }
if (ED_IS_SHORTCUT("tile_map_editor/select", p_event)) {
if (k.mod.command) {
if (k.scancode==KEY_F) {
search_box->select_all();
search_box->grab_focus();
return true;
}
if (k.scancode==KEY_B) {
tool=TOOL_SELECTING; tool=TOOL_SELECTING;
selection_active=false; selection_active=false;
@@ -918,8 +906,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) {
return true; return true;
} }
if (k.scancode==KEY_D) { if (ED_IS_SHORTCUT("tile_map_editor/duplicate_selection", p_event)) {
_update_copydata(); _update_copydata();
if (selection_active) { if (selection_active) {
@@ -930,22 +917,29 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) {
return true; return true;
} }
} }
} else { if (ED_IS_SHORTCUT("tile_map_editor/find_tile", p_event)) {
search_box->select_all();
if (k.scancode==KEY_A) { search_box->grab_focus();
return true;
}
if (ED_IS_SHORTCUT("tile_map_editor/mirror_x", p_event)) {
flip_h=!flip_h; flip_h=!flip_h;
mirror_x->set_pressed(flip_h); mirror_x->set_pressed(flip_h);
canvas_item_editor->update(); canvas_item_editor->update();
return true; return true;
} }
if (k.scancode==KEY_S) { if (ED_IS_SHORTCUT("tile_map_editor/mirror_y", p_event)) {
flip_v=!flip_v; flip_v=!flip_v;
mirror_y->set_pressed(flip_v); mirror_y->set_pressed(flip_v);
canvas_item_editor->update(); canvas_item_editor->update();
return true; return true;
} }
if (ED_IS_SHORTCUT("tile_map_editor/transpose", p_event)) {
transpose = !transpose;
transp->set_pressed(transpose);
canvas_item_editor->update();
return true;
} }
} break; } break;
} }
@@ -1308,6 +1302,12 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
flip_v=false; flip_v=false;
transpose=false; transpose=false;
ED_SHORTCUT("tile_map_editor/erase_selection", TTR("Erase selection"), KEY_DELETE);
ED_SHORTCUT("tile_map_editor/find_tile", TTR("Find tile"), KEY_MASK_CMD+KEY_F);
ED_SHORTCUT("tile_map_editor/transpose", TTR("Transpose"));
ED_SHORTCUT("tile_map_editor/mirror_x", TTR("Mirror X"), KEY_A);
ED_SHORTCUT("tile_map_editor/mirror_y", TTR("Mirror Y"), KEY_S);
search_box = memnew( LineEdit ); search_box = memnew( LineEdit );
search_box->set_h_size_flags(SIZE_EXPAND_FILL); search_box->set_h_size_flags(SIZE_EXPAND_FILL);
search_box->connect("text_entered", this, "_text_entered"); search_box->connect("text_entered", this, "_text_entered");
@@ -1349,9 +1349,9 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
p->add_separator(); p->add_separator();
p->add_item(TTR("Pick Tile"), OPTION_PICK_TILE, KEY_CONTROL); p->add_item(TTR("Pick Tile"), OPTION_PICK_TILE, KEY_CONTROL);
p->add_separator(); p->add_separator();
p->add_item(TTR("Select"), OPTION_SELECT, KEY_MASK_CMD+KEY_B); p->add_shortcut(ED_SHORTCUT("tile_map_editor/select", TTR("Select"), KEY_MASK_CMD+KEY_B), OPTION_SELECT);
p->add_item(TTR("Duplicate Selection"), OPTION_DUPLICATE, KEY_MASK_CMD+KEY_D); p->add_shortcut(ED_SHORTCUT("tile_map_editor/duplicate_selection", TTR("Duplicate Selection"), KEY_MASK_CMD+KEY_D), OPTION_DUPLICATE);
p->add_item(TTR("Erase Selection"), OPTION_ERASE_SELECTION, KEY_DELETE); p->add_shortcut(ED_GET_SHORTCUT("tile_map_editor/erase_selection"), OPTION_ERASE_SELECTION);
p->connect("item_pressed", this, "_menu_option"); p->connect("item_pressed", this, "_menu_option");
@@ -1361,19 +1361,19 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
transp = memnew( ToolButton ); transp = memnew( ToolButton );
transp->set_toggle_mode(true); transp->set_toggle_mode(true);
transp->set_tooltip(TTR("Transpose")); transp->set_tooltip(TTR("Transpose") + " ("+ED_GET_SHORTCUT("tile_map_editor/transpose")->get_as_text()+")");
transp->set_focus_mode(FOCUS_NONE); transp->set_focus_mode(FOCUS_NONE);
transp->connect("pressed", this, "_update_transform_buttons", make_binds(transp)); transp->connect("pressed", this, "_update_transform_buttons", make_binds(transp));
toolbar->add_child(transp); toolbar->add_child(transp);
mirror_x = memnew( ToolButton ); mirror_x = memnew( ToolButton );
mirror_x->set_toggle_mode(true); mirror_x->set_toggle_mode(true);
mirror_x->set_tooltip(TTR("Mirror X (A)")); mirror_x->set_tooltip(TTR("Mirror X") + " ("+ED_GET_SHORTCUT("tile_map_editor/mirror_x")->get_as_text()+")");
mirror_x->set_focus_mode(FOCUS_NONE); mirror_x->set_focus_mode(FOCUS_NONE);
mirror_x->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_x)); mirror_x->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_x));
toolbar->add_child(mirror_x); toolbar->add_child(mirror_x);
mirror_y = memnew( ToolButton ); mirror_y = memnew( ToolButton );
mirror_y->set_toggle_mode(true); mirror_y->set_toggle_mode(true);
mirror_y->set_tooltip(TTR("Mirror Y (S)")); mirror_y->set_tooltip(TTR("Mirror Y") + " ("+ED_GET_SHORTCUT("tile_map_editor/mirror_y")->get_as_text()+")");
mirror_y->set_focus_mode(FOCUS_NONE); mirror_y->set_focus_mode(FOCUS_NONE);
mirror_y->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_y)); mirror_y->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_y));
toolbar->add_child(mirror_y); toolbar->add_child(mirror_y);