Shortcut keys for map editor
This commit is contained in:
Subhraman Sarkar 2024-01-21 07:02:31 +05:30 committed by GitHub
parent 255a99782e
commit 18086e78ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 122 additions and 1 deletions

View file

@ -0,0 +1,3 @@
### Hotkeys
Added hotkeys for various menu items and ThemeWML buttons in Map Editor
Added shortcut Ctrl+G for 'I'm Ready' button in mp_staging dialog (Addresses issue #8250)

View file

@ -408,6 +408,13 @@
shift=yes
[/hotkey]
[hotkey]
command="editor-scenario-save-as"
key="s"
{IF_APPLE_CMD_ELSE_CTRL}
alt=yes
[/hotkey]
[hotkey]
command="editor-map-save-all"
key="s"
@ -420,12 +427,32 @@
{IF_APPLE_CMD_ELSE_CTRL}
[/hotkey]
[hotkey]
command="editor-scenario-new"
key="n"
shift=yes
{IF_APPLE_CMD_ELSE_CTRL}
[/hotkey]
[hotkey]
command="editor-map-load"
key="o"
{IF_APPLE_CMD_ELSE_CTRL}
[/hotkey]
[hotkey]
command="mapscreenshot"
key="s"
alt=yes
shift=yes
[/hotkey]
[hotkey]
command="editor-close-map"
key="w"
alt=yes
[/hotkey]
[hotkey]
command="editor-terrain-palette-swap"
key="x"
@ -474,6 +501,59 @@
{IF_APPLE_CMD_ELSE_CTRL}
[/hotkey]
[hotkey]
command="editor-selection-fill"
key="f"
shift=yes
[/hotkey]
[hotkey]
command="editor-selection-randomize"
key="r"
shift=yes
[/hotkey]
[hotkey]
command="editor-map-resize"
key="r"
alt=yes
[/hotkey]
[hotkey]
command="editor-map-generate"
key="g"
alt=yes
[/hotkey]
[hotkey]
command="editor-map-apply-mask"
key="a"
alt=yes
[/hotkey]
[hotkey]
command="editor-map-create-mask-to"
key="c"
alt=yes
[/hotkey]
[hotkey]
command="editor-refresh-image-cache"
key="f"
alt=yes
[/hotkey]
[hotkey]
command="editor-pbl"
key="a"
[/hotkey]
[hotkey]
command="editor-addon-id"
key="i"
alt=yes
[/hotkey]
[hotkey]
command="editor-tool-next"
key="n"
@ -525,6 +605,12 @@
key="i"
[/hotkey]
[hotkey]
command="editor-draw-num-of-bitmaps"
key="t"
alt=yes
[/hotkey]
[hotkey]
command="title_screen__editor"
key="e"

View file

@ -61,7 +61,7 @@
title= _ "File"
type=turbo
font_size=9
items=editor-scenario-edit,statustable,unitlist,editor-map-new,editor-scenario-new,editor-map-load,menu-editor-recent,editor-map-revert,editor-map-save,editor-map-save-as,mapscreenshot,editor-scenario-save-as,editor-map-save-all,preferences,help,editor-close-map,quit,quit-to-desktop
items=editor-scenario-edit,statustable,unitlist,editor-map-new,editor-scenario-new,editor-map-load,menu-editor-recent,editor-map-revert,editor-map-save,editor-map-save-as,editor-scenario-save-as,mapscreenshot,editor-map-save-all,preferences,help,editor-close-map,quit,quit-to-desktop
ref=top-panel
rect="=,=+1,+100,+20"
xanchor=fixed

View file

@ -76,6 +76,10 @@ void mp_staging::pre_show(window& window)
window.set_enter_disabled(true);
window.set_escape_disabled(true);
// Ctrl+G triggers 'I'm Ready' (ok) button's functionality
connect_signal<event::SDL_KEY_DOWN>(std::bind(
&mp_staging::signal_handler_sdl_key_down, this, std::placeholders::_2, std::placeholders::_3, std::placeholders::_5, std::placeholders::_6));
//
// Set title and status widget states
//
@ -569,6 +573,28 @@ void mp_staging::network_handler()
state_changed_ = false;
}
void mp_staging::signal_handler_sdl_key_down(const event::ui_event /*event*/,
bool& handled,
const SDL_Keycode key,
SDL_Keymod modifier)
{
handled = true;
#ifdef __APPLE__
// Idiomatic modifier key in macOS computers.
const SDL_Keycode modifier_key = KMOD_GUI;
#else
// Idiomatic modifier key in Microsoft desktop environments. Common in
// GNU/Linux as well, to some extent.
const SDL_Keycode modifier_key = KMOD_CTRL;
#endif
if ((key == SDLK_g) && (modifier & modifier_key)) {
get_window()->set_retval(retval::OK);
return;
}
}
void mp_staging::post_show(window& window)
{
if(update_timer_ != 0) {

View file

@ -85,6 +85,12 @@ private:
state_changed_ = true;
}
/** for Ctrl+G handling */
void signal_handler_sdl_key_down(const event::ui_event /*event*/,
bool& handled,
const SDL_Keycode key,
SDL_Keymod modifier);
ng::connect_engine& connect_engine_;
std::vector<ai::description*> ai_algorithms_;