diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 0cd83ea8b3..f9c81a6d9f 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -23,6 +23,8 @@ #include "../script/script_gui.h" #include "table/strings.h" +#include "../citymania/cm_hotkeys.hpp" + #include "../safeguards.h" @@ -242,7 +244,7 @@ struct AIConfigWindow : public Window { case WID_AIC_LIST: { // Select a slot this->selected_slot = (CompanyID)this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget); this->InvalidateData(); - if (click_count > 1 && IsEditable(this->selected_slot)) ShowScriptListWindow((CompanyID)this->selected_slot, _ctrl_pressed); + if (click_count > 1 && IsEditable(this->selected_slot)) ShowScriptListWindow((CompanyID)this->selected_slot, citymania::_fn_mod); break; } @@ -272,7 +274,7 @@ struct AIConfigWindow : public Window { } case WID_AIC_CHANGE: // choose other AI - if (IsEditable(this->selected_slot)) ShowScriptListWindow((CompanyID)this->selected_slot, _ctrl_pressed); + if (IsEditable(this->selected_slot)) ShowScriptListWindow((CompanyID)this->selected_slot, citymania::_fn_mod); break; case WID_AIC_CONFIGURE: // change the settings for an AI diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 64707259d3..fa19ba4541 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -31,6 +31,8 @@ #include "widgets/autoreplace_widget.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_list, uint16_t min, uint16_t max, EngineID selected_id, bool show_count, GroupID selected_group); @@ -582,7 +584,7 @@ public: case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: { const Group *g = Group::GetIfValid(this->sel_group); if (g != nullptr) { - Command::Post(this->sel_group, GroupFlags::GF_REPLACE_WAGON_REMOVAL, !HasBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL), _ctrl_pressed); + Command::Post(this->sel_group, GroupFlags::GF_REPLACE_WAGON_REMOVAL, !HasBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL), citymania::_fn_mod); } else { // toggle renew_keep_length Command::Post("company.renew_keep_length", Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1); @@ -636,7 +638,7 @@ public: /* If Ctrl is pressed on the left side and we don't have any engines of the selected type, stop autoreplacing. * This is most common when we have finished autoreplacing the engine and want to remove it from the list. */ - if (click_side == 0 && _ctrl_pressed && e != INVALID_ENGINE && + if (click_side == 0 && citymania::_fn_mod && e != INVALID_ENGINE && (GetGroupNumEngines(_local_company, sel_group, e) == 0 || GetGroupNumEngines(_local_company, ALL_GROUP, e) == 0)) { EngineID veh_from = e; Command::Post(this->sel_group, veh_from, INVALID_ENGINE, false); diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index b4600fb360..dc8e387d39 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -909,7 +909,7 @@ struct DepotWindow : Window { */ bool OnVehicleSelect(VehicleList::const_iterator begin, VehicleList::const_iterator end) override { - if (!_ctrl_pressed) { + if (!citymania::_fn_mod) { /* If CTRL is not pressed: If all the vehicles in this list have the same orders, then copy orders */ if (AllEqual(begin, end, [](const Vehicle *v1, const Vehicle *v2) { return VehiclesHaveSameEngineList(v1, v2); diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 659135602c..f8552e5e44 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -223,7 +223,7 @@ struct BuildDocksToolbarWindow : Window { break; } - bool adjacent = _ctrl_pressed; + bool adjacent = citymania::_fn_mod; auto proc = [=](bool test, StationID to_join) -> bool { if (test) { return Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), tile, INVALID_STATION, adjacent).Succeeded(); diff --git a/src/game/game_gui.cpp b/src/game/game_gui.cpp index 879428c0c4..d29e9a28a1 100644 --- a/src/game/game_gui.cpp +++ b/src/game/game_gui.cpp @@ -26,6 +26,8 @@ #include "../script_config.hpp" #include "../table/strings.h" +#include "../citymania/cm_hotkeys.hpp" + #include "../safeguards.h" @@ -286,12 +288,12 @@ struct GSConfigWindow : public Window { switch (widget) { case WID_GSC_GSLIST: { this->InvalidateData(); - if (click_count > 1 && _game_mode != GM_NORMAL) ShowScriptListWindow((CompanyID)OWNER_DEITY, _ctrl_pressed); + if (click_count > 1 && _game_mode != GM_NORMAL) ShowScriptListWindow((CompanyID)OWNER_DEITY, citymania::_fn_mod); break; } case WID_GSC_CHANGE: // choose other Game Script - ShowScriptListWindow((CompanyID)OWNER_DEITY, _ctrl_pressed); + ShowScriptListWindow((CompanyID)OWNER_DEITY, citymania::_fn_mod); break; case WID_GSC_CONTENT_DOWNLOAD: diff --git a/src/group_gui.cpp b/src/group_gui.cpp index e7989c4b88..bbae6489c5 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -863,7 +863,7 @@ public: { switch (widget) { case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles - Command::Post(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE, DEFAULT_GROUP, this->vehicle_sel, _ctrl_pressed || this->grouping == GB_SHARED_ORDERS, VehicleListIdentifier{}); + Command::Post(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE, DEFAULT_GROUP, this->vehicle_sel, citymania::_fn_mod || this->grouping == GB_SHARED_ORDERS, VehicleListIdentifier{}); this->vehicle_sel = INVALID_VEHICLE; this->group_over = INVALID_GROUP; diff --git a/src/league_gui.cpp b/src/league_gui.cpp index 696d0fe14c..dc8b956b5a 100644 --- a/src/league_gui.cpp +++ b/src/league_gui.cpp @@ -26,6 +26,8 @@ #include "table/strings.h" #include "table/sprites.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" @@ -246,7 +248,7 @@ static void HandleLinkClick(Link link) default: NOT_REACHED(); } - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowExtraViewportWindow(xy); } else { ScrollMainWindowToTile(xy); diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index e2d8606bae..902a87c8e6 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -44,8 +44,9 @@ #include "viewport_func.h" #include "industry.h" -#include "citymania/cm_tooltips.hpp" +#include "citymania/cm_hotkeys.hpp" #include "citymania/cm_misc_gui.hpp" +#include "citymania/cm_tooltips.hpp" #include "safeguards.h" @@ -377,7 +378,7 @@ public: { switch (widget) { case WID_LI_LOCATION: - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowExtraViewportWindow(this->tile); } else { ScrollMainWindowToTile(this->tile); diff --git a/src/object_gui.cpp b/src/object_gui.cpp index cb490d814b..1080b7105e 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -32,6 +32,8 @@ #include "table/strings.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" static ObjectClassID _selected_object_class; ///< Currently selected available object class. @@ -553,7 +555,7 @@ public: } const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index); Command::Post(STR_ERROR_CAN_T_BUILD_OBJECT, CcPlaySound_CONSTRUCTION_OTHER, - end_tile, start_tile, spec->Index(), _selected_object_view, (_ctrl_pressed ? true : false)); + end_tile, start_tile, spec->Index(), _selected_object_view, (citymania::_fn_mod ? true : false)); } void OnPlaceObjectAbort() override diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 7cfa9f7b6a..4eaab44540 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -496,12 +496,12 @@ static std::pair GetOrderCmdFromTile(const Vehicle *v, Ti ShowErrorMessage(STR_ERROR_CAN_T_INSERT_NEW_ORDER, STR_ERROR_UNBUNCHING_ONLY_ONE_ALLOWED, WL_ERROR); /* Return an empty order to bail out. */ order.Free(); - return order; + return {order, FeederOrderMod::NONE}; } else { order.SetDepotActionType(ODATFB_UNBUNCH); } } - return order; + return {order, FeederOrderMod::NONE}; } /* check rail waypoint */ @@ -1689,7 +1689,7 @@ public: */ bool OnVehicleSelect(VehicleList::const_iterator begin, VehicleList::const_iterator end) override { - bool share_order = _ctrl_pressed || this->goto_type == OPOS_SHARE; + bool share_order = citymania::_fn_mod || this->goto_type == OPOS_SHARE; if (this->vehicle->GetNumOrders() != 0 && !share_order) return false; if (!share_order) { diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index f9c96a56c3..c2f6b96e76 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -407,13 +407,13 @@ static void HandleAutoSignalPlacement() if (_remove_button_clicked) { // TODO invert ctrl option Command::Post(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM, CcPlaySound_CONSTRUCTION_RAIL, - TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), track, _ctrl_pressed); + TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), track, citymania::_fn_mod); } else { bool sig_gui = FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr; SignalType sigtype = sig_gui ? _cur_signal_type : _settings_client.gui.default_signal_type; SignalVariant sigvar = sig_gui ? _cur_signal_variant : (TimerGameCalendar::year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC); Command::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL, - TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), track, sigtype, sigvar, false, _ctrl_pressed, !_settings_client.gui.drag_signals_fixed_distance, _settings_client.gui.drag_signals_density); + TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), track, sigtype, sigvar, false, citymania::_fn_mod, !_settings_client.gui.drag_signals_fixed_distance, _settings_client.gui.drag_signals_density); } } diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index 21bee4ac2b..27dbe4f7f7 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -38,6 +38,8 @@ #include "../game/game_instance.hpp" #include "table/strings.h" +#include "../citymania/cm_hotkeys.hpp" + #include "../safeguards.h" @@ -1072,12 +1074,12 @@ struct ScriptDebugWindow : public Window { /* Check which button is clicked */ if (IsInsideMM(widget, WID_SCRD_COMPANY_BUTTON_START, WID_SCRD_COMPANY_BUTTON_END + 1)) { - ChangeToScript((CompanyID)(widget - WID_SCRD_COMPANY_BUTTON_START), _ctrl_pressed); + ChangeToScript((CompanyID)(widget - WID_SCRD_COMPANY_BUTTON_START), citymania::_fn_mod); } switch (widget) { case WID_SCRD_SCRIPT_GAME: - ChangeToScript(OWNER_DEITY, _ctrl_pressed); + ChangeToScript(OWNER_DEITY, citymania::_fn_mod); break; case WID_SCRD_RELOAD_TOGGLE: diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 6d5474186d..45e410ac87 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -49,6 +49,8 @@ #include "video/video_driver.hpp" #include "social_integration.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" @@ -787,7 +789,7 @@ struct GameOptionsWindow : Window { case WID_GO_GUI_SCALE: if (ClickSliderWidget(this->GetWidget(widget)->GetCurrentRect(), pt, MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE, this->gui_scale)) { - if (!_ctrl_pressed) this->gui_scale = ((this->gui_scale + 12) / 25) * 25; + if (!citymania::_fn_mod) this->gui_scale = ((this->gui_scale + 12) / 25) * 25; this->SetWidgetDirty(widget); } diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index 1122f220ad..fbe6cfd005 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -491,7 +491,7 @@ struct SignWindow : Window, SignList { case WID_QES_LOCATION: { const Sign *si = Sign::Get(this->cur_sign); TileIndex tile = TileVirtXY(si->x, si->y); - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowExtraViewportWindow(tile); } else { ScrollMainWindowToTile(tile); diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 59f00ae52b..f75b104b08 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -835,7 +835,7 @@ protected: */ void SelectLegendItem(int click_pos, LegendAndColour *legend, int end_legend_item, int begin_legend_item = 0) { - if (_ctrl_pressed) { + if (citymania::_fn_mod) { /* Disable all, except the clicked one */ bool changes = false; for (int i = begin_legend_item; i != end_legend_item; i++) { diff --git a/src/station_gui.cpp b/src/station_gui.cpp index cff835eddf..df74f5fab9 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -181,9 +181,9 @@ void CheckRedrawWaypointCoverage(const Window *) { /* Test if ctrl state changed */ static bool _last_ctrl_pressed; - if (_ctrl_pressed != _last_ctrl_pressed) { + if (citymania::_fn_mod != _last_ctrl_pressed) { _thd.dirty = 0xff; - _last_ctrl_pressed = _ctrl_pressed; + _last_ctrl_pressed = citymania::_fn_mod; } if (_thd.dirty & 1) { diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 68a1b4e13e..c8d6285aaf 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -378,7 +378,7 @@ struct TerraformToolbarWindow : Window { if (TileY(end_tile) == Map::MaxY()) end_tile += TileDiffXY(0, -1); } Command::Post(STR_ERROR_CAN_T_PURCHASE_THIS_LAND, CcPlaySound_CONSTRUCTION_RAIL, - end_tile, start_tile, OBJECT_OWNED_LAND, 0, (_ctrl_pressed ? true : false)); + end_tile, start_tile, OBJECT_OWNED_LAND, 0, (citymania::_fn_mod ? true : false)); break; } } diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 29e3dd1210..5a40716fe8 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -675,7 +675,7 @@ struct TimetableWindow : Window { } } - this->change_timetable_all = _ctrl_pressed && (order != nullptr); + this->change_timetable_all = citymania::_fn_mod && (order != nullptr); ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME, 31, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED); break; } @@ -696,14 +696,14 @@ struct TimetableWindow : Window { } } - this->change_timetable_all = _ctrl_pressed && (order != nullptr); + this->change_timetable_all = citymania::_fn_mod && (order != nullptr); ShowQueryString(current, STR_TIMETABLE_CHANGE_SPEED, 31, this, CS_NUMERAL, QSF_NONE); break; } case WID_VT_CLEAR_TIME: { // Clear waiting time. auto [order_id, mtf] = PackTimetableArgs(v, this->sel_index, false); - if (_ctrl_pressed) { + if (citymania::_fn_mod) { Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, mtf, 0); } else { Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, order_id, mtf, 0); @@ -713,7 +713,7 @@ struct TimetableWindow : Window { case WID_VT_CLEAR_SPEED: { // Clear max speed button. auto [order_id, mtf] = PackTimetableArgs(v, this->sel_index, true); - if (_ctrl_pressed) { + if (citymania::_fn_mod) { Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, mtf, UINT16_MAX); } else { Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, order_id, mtf, UINT16_MAX); @@ -722,7 +722,7 @@ struct TimetableWindow : Window { } case WID_VT_RESET_LATENESS: // Reset the vehicle's late counter. - Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, _ctrl_pressed); + Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, citymania::_fn_mod); break; case WID_VT_AUTOFILL: { // Autofill the timetable. diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index a21b396f67..d49845ff12 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -68,6 +68,7 @@ #include "citymania/cm_cargo_table_gui.hpp" #include "citymania/cm_commands.hpp" #include "citymania/cm_commands_gui.hpp" +#include "citymania/cm_hotkeys.hpp" #include "citymania/cm_locations.hpp" #include "citymania/cm_main.hpp" #include "citymania/cm_minimap.hpp" @@ -1205,7 +1206,7 @@ static CallBackFunction MenuClickHelp(int index) case 1: citymania::ShowLoginWindow(); break; case 2: ShowHelpWindow(); break; case 3: IConsoleSwitch(); break; - case 4: ShowScriptDebugWindow(INVALID_COMPANY, _ctrl_pressed); break; + case 4: ShowScriptDebugWindow(INVALID_COMPANY, citymania::_fn_mod); break; case 5: ShowScreenshotWindow(); break; case 6: ShowFramerateWindow(); break; case 7: ShowAboutWindow(); break; diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index d1f4df1c38..368feefd88 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -27,6 +27,8 @@ #include "table/strings.h" #include "table/tree_land.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" void PlaceTreesRandomly(); @@ -239,7 +241,7 @@ public: void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, TileIndex start_tile, TileIndex end_tile) override { if (_game_mode != GM_EDITOR && this->mode == PM_NORMAL && pt.x != -1 && select_proc == DDSP_PLANT_TREES) { - Command::Post(STR_ERROR_CAN_T_PLANT_TREE_HERE, end_tile, start_tile, this->tree_to_plant, _ctrl_pressed); + Command::Post(STR_ERROR_CAN_T_PLANT_TREE_HERE, end_tile, start_tile, this->tree_to_plant, citymania::_fn_mod); } } diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index ac0853591c..5d13485ee9 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -2091,7 +2091,7 @@ public: assert(vehgroup.NumVehicles() > 0); if (!VehicleClicked(vehgroup)) { const Vehicle *v = vehgroup.vehicles_begin[0]; - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowOrdersWindow(v); } else { if (vehgroup.NumVehicles() == 1) {