diff --git a/src/citymania/cm_hotkeys.cpp b/src/citymania/cm_hotkeys.cpp index c0a696d7..4f976af1 100644 --- a/src/citymania/cm_hotkeys.cpp +++ b/src/citymania/cm_hotkeys.cpp @@ -78,11 +78,12 @@ bool HasSeparateRemoveMod() { return (_settings_client.gui.cm_fn_mod != _settings_client.gui.cm_remove_mod); } -void UpdateModKeys(bool shift_pressed, bool ctrl_pressed, bool alt_pressed) { +void UpdateModKeys(bool shift_pressed, bool ctrl_pressed, bool alt_pressed, bool command_pressed) { bool mod_pressed[(size_t)ModKey::END] = {false}; if (shift_pressed) mod_pressed[(size_t)ModKey::SHIFT] = true; if (ctrl_pressed) mod_pressed[(size_t)ModKey::CTRL] = true; if (alt_pressed) mod_pressed[(size_t)ModKey::ALT] = true; + if (command_pressed) mod_pressed[(size_t)ModKey::COMMAND] = true; bool fn_mod_prev = _fn_mod; bool remove_mod_prev = _remove_mod; _fn_mod = mod_pressed[(size_t)_settings_client.gui.cm_fn_mod]; diff --git a/src/citymania/cm_hotkeys.hpp b/src/citymania/cm_hotkeys.hpp index 4b266772..53f39dd6 100644 --- a/src/citymania/cm_hotkeys.hpp +++ b/src/citymania/cm_hotkeys.hpp @@ -16,7 +16,7 @@ enum class ToolRemoveMode : uint8 { MOD = 2, }; -void UpdateModKeys(bool shift_pressed, bool ctrl_pressed, bool alt_pressed); +void UpdateModKeys(bool shift_pressed, bool ctrl_pressed, bool alt_pressed, bool command_pressed); bool RailToolbar_IsRemoveInverted(int widget); void RailToolbar_UpdateRemoveWidgetStatus(Window *w, int widged, bool remove_active); diff --git a/src/citymania/cm_settings.hpp b/src/citymania/cm_settings.hpp index 9a9a98b9..6d586672 100644 --- a/src/citymania/cm_settings.hpp +++ b/src/citymania/cm_settings.hpp @@ -16,6 +16,7 @@ enum class ModKey : uint8 { SHIFT = 1, CTRL = 2, ALT = 3, + COMMAND = 4, END, }; diff --git a/src/lang/english.txt b/src/lang/english.txt index 82be9cae..b7b5e558 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -6171,6 +6171,7 @@ CM_STR_CONFIG_SETTING_MODIFIER_NONE :None CM_STR_CONFIG_SETTING_MODIFIER_SHIFT :Shift CM_STR_CONFIG_SETTING_MODIFIER_CTRL :Ctrl CM_STR_CONFIG_SETTING_MODIFIER_ALT :Alt +CM_STR_CONFIG_SETTING_MODIFIER_COMMAND :Command (on MacOS) CM_STR_CONFIG_SETTING_SHADED_TREES :Shaded trees: {STRING2} CM_STR_CONFIG_SETTING_SHADED_TREES_HELPTEXT :Change tree brightness depending on a slope. Enhances visual appeal of mountainous forests. diff --git a/src/table/settings/cmclient_settings.ini b/src/table/settings/cmclient_settings.ini index 617a07bd..c18b108b 100644 --- a/src/table/settings/cmclient_settings.ini +++ b/src/table/settings/cmclient_settings.ini @@ -3,7 +3,7 @@ static void cm_v_RedrawStatusBar(int32 new_value); static void cm_v_RedrawGraphs(int32 new_value); static std::initializer_list _order_mod_actions{"nothing", "full_load", "transfer", "unload_all", "feeder_load", "feeder_unload", "no_load"}; -static std::initializer_list _mod_keys{"none", "shift", "ctrl", "alt"}; +static std::initializer_list _mod_keys{"none", "shift", "ctrl", "alt", "command"}; static std::initializer_list _shaded_tree_options{"always_off", "always_on", "as_server"}; static std::initializer_list _graph_background_options{"black", "grey"}; @@ -182,7 +182,7 @@ flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_GUI_DROPDOWN | CM_SF_CITYMAN full = _mod_keys def = 2 min = 0 -max = 3 +max = 4 str = CM_STR_CONFIG_SETTING_MODIFIER_FN strhelp = CM_STR_CONFIG_SETTING_MODIFIER_FN_HELPTEXT strval = CM_STR_CONFIG_SETTING_MODIFIER_NONE @@ -195,7 +195,7 @@ flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_GUI_DROPDOWN | CM_SF_CITYMAN full = _mod_keys def = 2 min = 0 -max = 3 +max = 4 str = CM_STR_CONFIG_SETTING_MODIFIER_REMOVE strhelp = CM_STR_CONFIG_SETTING_MODIFIER_REMOVE_HELPTEXT strval = CM_STR_CONFIG_SETTING_MODIFIER_NONE @@ -208,7 +208,7 @@ flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_GUI_DROPDOWN | CM_SF_CITYMAN full = _mod_keys def = 1 min = 0 -max = 3 +max = 4 str = CM_STR_CONFIG_SETTING_MODIFIER_ESTIMATE strhelp = CM_STR_CONFIG_SETTING_MODIFIER_ESTIMATE_HELPTEXT strval = CM_STR_CONFIG_SETTING_MODIFIER_NONE diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp index 9894943f..a5a7f104 100644 --- a/src/video/allegro_v.cpp +++ b/src/video/allegro_v.cpp @@ -481,7 +481,7 @@ void VideoDriver_Allegro::InputLoop() (key[KEY_DOWN] ? 8 : 0); // CM if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); - citymania::UpdateModKeys(_shift_pressed, _ctrl_pressed, _alt_pressed); + citymania::UpdateModKeys(_shift_pressed, _ctrl_pressed, _alt_pressed, false); } void VideoDriver_Allegro::MainLoop() diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm index 40ca04cd..e50f4cfe 100644 --- a/src/video/cocoa/cocoa_v.mm +++ b/src/video/cocoa/cocoa_v.mm @@ -477,14 +477,16 @@ bool old_ctrl_pressed = _ctrl_pressed; - _ctrl_pressed = (cur_mods & ( _settings_client.gui.right_mouse_btn_emulation != RMBE_CONTROL ? NSEventModifierFlagControl : NSEventModifierFlagCommand)) != 0; + // _ctrl_pressed = (cur_mods & ( _settings_client.gui.right_mouse_btn_emulation != RMBE_CONTROL ? NSEventModifierFlagControl : NSEventModifierFlagCommand)) != 0; + bool command_pressed = (cur_mods & NSEventModifierFlagCommand) != 0; + _ctrl_pressed = (cur_mods & NSEventModifierFlagControl) != 0; _alt_pressed = (cur_mods & NSEventModifierFlagOption) != 0; _shift_pressed = (cur_mods & NSEventModifierFlagShift) != 0; this->fast_forward_key_pressed = _tab_is_down; // if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); - citymania::UpdateModKeys(_shift_pressed, _ctrl_pressed, _alt_pressed); + citymania::UpdateModKeys(_shift_pressed, _ctrl_pressed, _alt_pressed, command_pressed); } /** Main game loop. */ diff --git a/src/video/cocoa/event.mm b/src/video/cocoa/event.mm index 3ef8f8a4..e8572af4 100644 --- a/src/video/cocoa/event.mm +++ b/src/video/cocoa/event.mm @@ -692,11 +692,12 @@ static bool QZ_PollEvent() bool old_ctrl_pressed = _ctrl_pressed; - _ctrl_pressed = !!(_current_mods & ( _settings_client.gui.right_mouse_btn_emulation != RMBE_CONTROL ? NSControlKeyMask : NSCommandKeyMask)); + _ctrl_pressed = !!(_current_mods & NSControlKeyMask); + bool command_pressed = !!(_current_mods & NSCommandKeyMask); _shift_pressed = !!(_current_mods & NSShiftKeyMask); // CM if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); - citymania::UpdateModKeys(_shift_pressed, _ctrl_pressed, _alt_pressed); + citymania::UpdateModKeys(_shift_pressed, _ctrl_pressed, _alt_pressed, command_pressed); ::GameLoop(); diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp index 4ca5a4e4..41dd2046 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -606,7 +606,7 @@ void VideoDriver_SDL_Base::InputLoop() (keys[SDL_SCANCODE_DOWN] ? 8 : 0); // CM if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); - citymania::UpdateModKeys(_shift_pressed, _ctrl_pressed, _alt_pressed); + citymania::UpdateModKeys(_shift_pressed, _ctrl_pressed, _alt_pressed, false); } void VideoDriver_SDL_Base::LoopOnce() diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index 59bf2a2a..a318eefc 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -670,7 +670,7 @@ void VideoDriver_SDL::InputLoop() (keys[SDLK_DOWN] ? 8 : 0); // CM if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); - citymania::UpdateModKeys(_shift_pressed, _ctrl_pressed, _alt_pressed); + citymania::UpdateModKeys(_shift_pressed, _ctrl_pressed, _alt_pressed, false); } void VideoDriver_SDL::MainLoop() diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 630d172c..0c283c68 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -888,7 +888,7 @@ void VideoDriver_Win32Base::InputLoop() } // CM if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); - citymania::UpdateModKeys(_shift_pressed, _ctrl_pressed, _alt_pressed); + citymania::UpdateModKeys(_shift_pressed, _ctrl_pressed, _alt_pressed, false); } bool VideoDriver_Win32Base::PollEvent()