diff --git a/cm_changelog.txt b/cm_changelog.txt index d7346c7655..a6807fa4cd 100644 --- a/cm_changelog.txt +++ b/cm_changelog.txt @@ -80,12 +80,13 @@ This is usable for any OpenTTD servers - Add hotkey to toggle minimap - Make hotkey to close news and errors configurable (still defaults to SPACE) - Remove custom hotkey keycodes that were added to vanilla -- Make land info tool work with right click tooltip setting +- Make land info tool work with right click tooltip setting and/or disabled extra tooltip settings. - Make station rating tooltips work with right click tooltip setting - Splilt extra(land) tooltips setting in config into 3 for industries, stations and houses separately. - Add a setting to pause games after loading. - Add a "step" console command to advance the game for n ticks (singleplayer only). - cmexport +- Make modifier key (ctrl/alt/shift) functions configurable. *** 1.10.2 (5 Jun 2020) *** - Add new minimap mode showing industries, height and farms at the same time. diff --git a/projects/openttd_vs140.vcxproj b/projects/openttd_vs140.vcxproj index 7603ffad84..73bb2b745f 100644 --- a/projects/openttd_vs140.vcxproj +++ b/projects/openttd_vs140.vcxproj @@ -1367,6 +1367,8 @@ + + diff --git a/projects/openttd_vs140.vcxproj.filters b/projects/openttd_vs140.vcxproj.filters index 0ef9710acf..712aaa8ac7 100644 --- a/projects/openttd_vs140.vcxproj.filters +++ b/projects/openttd_vs140.vcxproj.filters @@ -3195,6 +3195,12 @@ CityMania + + CityMania + + + CityMania + CityMania diff --git a/projects/openttd_vs141.vcxproj b/projects/openttd_vs141.vcxproj index a3484139f0..7137146c5b 100644 --- a/projects/openttd_vs141.vcxproj +++ b/projects/openttd_vs141.vcxproj @@ -1367,6 +1367,8 @@ + + diff --git a/projects/openttd_vs141.vcxproj.filters b/projects/openttd_vs141.vcxproj.filters index 0ef9710acf..712aaa8ac7 100644 --- a/projects/openttd_vs141.vcxproj.filters +++ b/projects/openttd_vs141.vcxproj.filters @@ -3195,6 +3195,12 @@ CityMania + + CityMania + + + CityMania + CityMania diff --git a/projects/openttd_vs142.vcxproj b/projects/openttd_vs142.vcxproj index 659f7ae872..af577959fa 100644 --- a/projects/openttd_vs142.vcxproj +++ b/projects/openttd_vs142.vcxproj @@ -1367,6 +1367,8 @@ + + diff --git a/projects/openttd_vs142.vcxproj.filters b/projects/openttd_vs142.vcxproj.filters index 0ef9710acf..712aaa8ac7 100644 --- a/projects/openttd_vs142.vcxproj.filters +++ b/projects/openttd_vs142.vcxproj.filters @@ -3195,6 +3195,12 @@ CityMania + + CityMania + + + CityMania + CityMania diff --git a/source.list b/source.list index 1092264b86..1c7a88c72d 100644 --- a/source.list +++ b/source.list @@ -1212,6 +1212,8 @@ citymania/cm_export.hpp citymania/cm_export.cpp citymania/cm_game.hpp citymania/cm_game.cpp +citymania/cm_hotkeys.hpp +citymania/cm_hotkeys.cpp citymania/cm_main.hpp citymania/cm_main.cpp citymania/cm_tooltips.hpp diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 9264924fb7..a5cbbc42f2 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -29,6 +29,7 @@ #include "widgets/airport_widget.h" +#include "citymania/cm_hotkeys.hpp" #include "citymania/station_ui.hpp" #include "safeguards.h" @@ -62,7 +63,7 @@ static void PlaceAirport(TileIndex tile) } if (_selected_airport_index == -1) return; - uint32 p2 = _ctrl_pressed; + uint32 p2 = (citymania::_fn_mod ? 1 : 0); SB(p2, 16, 16, INVALID_STATION); // no station to join uint32 p1 = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->GetIndex(); diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index cb220af38d..d95db55716 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -29,6 +29,8 @@ #include "table/strings.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" /** The type of the last built rail bridge */ @@ -385,7 +387,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo case TRANSPORT_RAIL: last_bridge_type = _last_railbridge_type; break; default: break; // water ways and air routes don't have bridge types } - if (_ctrl_pressed && CheckBridgeAvailability(last_bridge_type, bridge_len).Succeeded()) { + if (citymania::_fn_mod && CheckBridgeAvailability(last_bridge_type, bridge_len).Succeeded()) { DoCommandP(end, start, type | last_bridge_type, CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE), CcBuildBridge); return; } diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 70ec5385a9..beda980691 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -35,6 +35,8 @@ #include "hotkeys.h" #include "table/strings.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" /** @@ -1432,7 +1434,7 @@ struct BuildVehicleWindow : Window { size_t num_items = this->eng_list.size(); this->SelectEngine((i < num_items) ? this->eng_list[i] : INVALID_ENGINE); this->SetDirty(); - if (_ctrl_pressed) { + if (citymania::_fn_mod) { this->OnClick(pt, WID_BV_SHOW_HIDE, 1); } else if (click_count > 1 && !this->listview_mode) { this->OnClick(pt, WID_BV_BUILD, 1); diff --git a/src/citymania/cm_hotkeys.cpp b/src/citymania/cm_hotkeys.cpp new file mode 100644 index 0000000000..396a49e43e --- /dev/null +++ b/src/citymania/cm_hotkeys.cpp @@ -0,0 +1,43 @@ +#include "../stdafx.h" + +#include "cm_hotkeys.hpp" +#include "cm_settings.hpp" + +#include "../settings_type.h" +#include "../window_gui.h" +#include "../window_type.h" + +#include "../safeguards.h" + +namespace citymania { + +bool _fn_mod = false; +bool _remove_mod = false; +bool _estimate_mod = false; + + +void UpdateModKeys(bool shift_pressed, bool ctrl_pressed, bool alt_pressed) { + ModKey key = ModKey::NONE; + if (alt_pressed) key = ModKey::ALT; + if (ctrl_pressed) key = ModKey::CTRL; + if (shift_pressed) key = ModKey::SHIFT; + bool fn_mod_prev = _fn_mod; + bool remove_mod_prev = _remove_mod; + _fn_mod = (_settings_client.gui.cm_fn_mod == key); + _remove_mod = (_settings_client.gui.cm_remove_mod == key); + _estimate_mod = (_settings_client.gui.cm_estimate_mod == key); + + Window *w; + if (fn_mod_prev != _fn_mod) { + FOR_ALL_WINDOWS_FROM_FRONT(w) { + if (w->CM_OnFnModStateChange() == ES_HANDLED) break; + } + } + if (remove_mod_prev != _remove_mod) { + FOR_ALL_WINDOWS_FROM_FRONT(w) { + if (w->CM_OnRemoveModStateChange() == ES_HANDLED) break; + } + } +} + +} // namespace citymania diff --git a/src/citymania/cm_hotkeys.hpp b/src/citymania/cm_hotkeys.hpp new file mode 100644 index 0000000000..8f7d106c7b --- /dev/null +++ b/src/citymania/cm_hotkeys.hpp @@ -0,0 +1,14 @@ +#ifndef CMEXT_HOTKEYS_HPP +#define CMEXT_HOTKEYS_HPP + +namespace citymania { + +extern bool _fn_mod; +extern bool _estimate_mod; +extern bool _remove_mod; + +void UpdateModKeys(bool shift_pressed, bool ctrl_pressed, bool alt_pressed); + +} // namespace citymania + +#endif diff --git a/src/citymania/cm_settings.hpp b/src/citymania/cm_settings.hpp index fafb17bcf7..9f0231a4d8 100644 --- a/src/citymania/cm_settings.hpp +++ b/src/citymania/cm_settings.hpp @@ -4,10 +4,17 @@ #include #include -// #include "types.hpp" +#include "../cargo_type.h" namespace citymania { +enum class ModKey : uint8 { + NONE = 0, + SHIFT = 1, + CTRL = 2, + ALT = 3 +}; + class CBRequirement { public: CargoID cargo_id; diff --git a/src/citymania/copypaste.cpp b/src/citymania/copypaste.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/citymania/copypaste.hpp b/src/citymania/copypaste.hpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/citymania/station_ui.cpp b/src/citymania/station_ui.cpp index 634f2749d0..720e879828 100644 --- a/src/citymania/station_ui.cpp +++ b/src/citymania/station_ui.cpp @@ -2,6 +2,8 @@ #include "station_ui.hpp" +#include "cm_hotkeys.hpp" + #include "../core/math_func.hpp" #include "../command_type.h" #include "../command_func.h" @@ -172,7 +174,7 @@ const Station *CheckClickOnDeadStationSign() { bool CheckStationJoin(TileIndex start_tile, TileIndex end_tile) { // if (_ctrl_pressed && start_tile == end_tile) { - if (_ctrl_pressed) { + if (citymania::_fn_mod) { if (IsTileType (start_tile, MP_STATION)) { citymania::SelectStationToJoin(Station::GetByTile(start_tile)); return true; @@ -188,7 +190,7 @@ bool CheckStationJoin(TileIndex start_tile, TileIndex end_tile) { void JoinAndBuild(CommandContainer cmdcont) { auto join_to = _highlight_station_to_join; - uint32 adj_bit = ((_ctrl_pressed || join_to) ? 1 : 0); + uint32 adj_bit = ((citymania::_fn_mod || join_to) ? 1 : 0); auto cmd = (cmdcont.cmd & CMD_ID_MASK); if (cmd == CMD_BUILD_RAIL_STATION) { SB(cmdcont.p1, 24, 1, adj_bit); @@ -199,7 +201,7 @@ void JoinAndBuild(CommandContainer cmdcont) { } else if (cmd == CMD_BUILD_AIRPORT) { SB(cmdcont.p2, 0, 1, adj_bit); } - if (_ctrl_pressed) SB(cmdcont.p2, 16, 16, NEW_STATION); + if (citymania::_fn_mod) SB(cmdcont.p2, 16, 16, NEW_STATION); else if (join_to) SB(cmdcont.p2, 16, 16, join_to->index); else SB(cmdcont.p2, 16, 16, INVALID_STATION); @@ -251,7 +253,7 @@ void HandleStationPlacement(TileIndex start, TileIndex end) if (_railstation.orientation == AXIS_X) Swap(numtracks, platlength); - uint32 p1 = _cur_railtype | _railstation.orientation << 6 | numtracks << 8 | platlength << 16 | _ctrl_pressed << 24; + uint32 p1 = _cur_railtype | _railstation.orientation << 6 | numtracks << 8 | platlength << 16 | (citymania::_fn_mod ? 1 << 24 : 0); uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16; CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" }; @@ -261,7 +263,7 @@ void HandleStationPlacement(TileIndex start, TileIndex end) void PlaceRail_Station(TileIndex tile) { if (CheckStationJoin(tile, tile)) return; - uint32 p1 = _cur_railtype | _railstation.orientation << 6 | _settings_client.gui.station_numtracks << 8 | _settings_client.gui.station_platlength << 16 | _ctrl_pressed << 24; + uint32 p1 = _cur_railtype | _railstation.orientation << 6 | _settings_client.gui.station_numtracks << 8 | _settings_client.gui.station_platlength << 16 | (citymania::_fn_mod ? 1 << 24 : 0); uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16; int w = _settings_client.gui.station_numtracks; @@ -278,7 +280,7 @@ void PlaceDock(TileIndex tile) { uint32 p2 = (uint32)INVALID_STATION << 16; // no station to join /* tile is always the land tile, so need to evaluate _thd.pos */ - CommandContainer cmdcont = { tile, _ctrl_pressed, p2, CMD_BUILD_DOCK | CMD_MSG(STR_ERROR_CAN_T_BUILD_DOCK_HERE), CcBuildDocks, "" }; + CommandContainer cmdcont = { tile, citymania::_fn_mod, p2, CMD_BUILD_DOCK | CMD_MSG(STR_ERROR_CAN_T_BUILD_DOCK_HERE), CcBuildDocks, "" }; /* Determine the watery part of the dock. */ // DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile)); @@ -292,7 +294,7 @@ void PlaceAirport(TileIndex tile) { if (_selected_airport_index == -1) return; - uint32 p2 = _ctrl_pressed; + uint32 p2 = (citymania::_fn_mod ? 1 : 0); SB(p2, 16, 16, INVALID_STATION); // no station to join uint32 p1 = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->GetIndex(); @@ -331,7 +333,7 @@ static void FindStationsAroundSelection(const TileArea &location) } void CheckRedrawStationCoverage() { - static bool last_ctrl_pressed = false; + // static bool last_ctrl_pressed = false; static TileArea last_location; static bool last_station_mode = false; static bool last_coverage = false; @@ -346,7 +348,7 @@ void CheckRedrawStationCoverage() { // last_location = location; // last_station_mode = station_mode; - if (_ctrl_pressed) { + if (citymania::_fn_mod) { Station *st = nullptr; if (IsTileType(location.tile, MP_STATION) && GetTileOwner(location.tile) == _local_company) st = Station::GetByTile(location.tile); diff --git a/src/command.cpp b/src/command.cpp index 5d2b0545c1..106cd862b0 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -31,6 +31,8 @@ #include "table/strings.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" CommandProc CmdBuildRailroadTrack; @@ -564,7 +566,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac * However, in case of incoming network commands, * map generation or the pause button we do want * to execute. */ - bool estimate_only = _shift_pressed && IsLocalCompany() && + bool estimate_only = citymania::_estimate_mod && IsLocalCompany() && !_generating_world && !(cmd & CMD_NETWORK_COMMAND) && !(GetCommandFlags(cmd) & CMD_NO_EST) && diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 54e3ced643..a312b8c09d 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -39,6 +39,8 @@ #include "widgets/company_widget.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" @@ -437,11 +439,11 @@ struct CompanyFinancesWindow : Window { break; case WID_CF_INCREASE_LOAN: // increase loan - DoCommandP(0, 0, _ctrl_pressed, CMD_INCREASE_LOAN | CMD_MSG(STR_ERROR_CAN_T_BORROW_ANY_MORE_MONEY)); + DoCommandP(0, 0, citymania::_fn_mod, CMD_INCREASE_LOAN | CMD_MSG(STR_ERROR_CAN_T_BORROW_ANY_MORE_MONEY)); break; case WID_CF_REPAY_LOAN: // repay loan - DoCommandP(0, 0, _ctrl_pressed, CMD_DECREASE_LOAN | CMD_MSG(STR_ERROR_CAN_T_REPAY_LOAN)); + DoCommandP(0, 0, citymania::_fn_mod, CMD_DECREASE_LOAN | CMD_MSG(STR_ERROR_CAN_T_REPAY_LOAN)); break; case WID_CF_INFRASTRUCTURE: // show infrastructure details @@ -968,7 +970,7 @@ public: } assert(j < LS_END); - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ToggleBit(this->sel, j); } else { this->sel = 1 << j; @@ -998,7 +1000,7 @@ public: /* Set company colour livery */ for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) { /* Changed colour for the selected scheme, or all visible schemes if CTRL is pressed. */ - if (HasBit(this->sel, scheme) || (_ctrl_pressed && _livery_class[scheme] == this->livery_class && HasBit(_loaded_newgrf_features.used_liveries, scheme))) { + if (HasBit(this->sel, scheme) || (citymania::_fn_mod && _livery_class[scheme] == this->livery_class && HasBit(_loaded_newgrf_features.used_liveries, scheme))) { DoCommandP(0, scheme | (widget == WID_SCL_PRI_COL_DROPDOWN ? 0 : 256), index, CMD_SET_COMPANY_COLOUR); } } @@ -2602,7 +2604,7 @@ struct CompanyWindow : Window case WID_C_VIEW_HQ: { TileIndex tile = Company::Get((CompanyID)this->window_number)->location_of_HQ; - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowExtraViewPortWindow(tile); } else { ScrollMainWindowToTile(tile); @@ -2705,7 +2707,7 @@ struct CompanyWindow : Window void OnPlaceObject(Point pt, TileIndex tile) override { - if (DoCommandP(tile, OBJECT_HQ, 0, CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_BUILD_COMPANY_HEADQUARTERS)) && !_shift_pressed) { + if (DoCommandP(tile, OBJECT_HQ, 0, CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_BUILD_COMPANY_HEADQUARTERS)) && !citymania::_estimate_mod) { ResetObjectToPlace(); this->RaiseButtons(); } diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index e994d2da94..cc8b7795bf 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -31,6 +31,8 @@ #include "table/strings.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" /* @@ -116,7 +118,7 @@ static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Veh if (wagon == v) return; - DoCommandP(v->tile, v->index | (_ctrl_pressed ? 1 : 0) << 20, wagon == nullptr ? INVALID_VEHICLE : wagon->index, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_MOVE_VEHICLE)); + DoCommandP(v->tile, v->index | (citymania::_fn_mod ? 1 : 0) << 20, wagon == nullptr ? INVALID_VEHICLE : wagon->index, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_MOVE_VEHICLE)); } static VehicleCellSize _base_block_sizes_depot[VEH_COMPANY_END]; ///< Cell size for vehicle images in the depot view. @@ -542,7 +544,7 @@ struct DepotWindow : Window { } else if (v != nullptr) { SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this); SetMouseCursorVehicle(v, EIT_IN_DEPOT); - _cursor.vehchain = _ctrl_pressed; + _cursor.vehchain = citymania::_fn_mod; this->sel = v->index; this->SetDirty(); @@ -768,7 +770,7 @@ struct DepotWindow : Window { break; case WID_D_LOCATION: - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowExtraViewPortWindow(this->window_number); } else { ScrollMainWindowToTile(this->window_number); @@ -840,7 +842,7 @@ struct DepotWindow : Window { CargoArray capacity, loaded; /* Display info for single (articulated) vehicle, or for whole chain starting with selected vehicle */ - bool whole_chain = (this->type == VEH_TRAIN && _ctrl_pressed); + bool whole_chain = (this->type == VEH_TRAIN && citymania::_fn_mod); /* loop through vehicle chain and collect cargoes */ uint num = 0; @@ -888,12 +890,12 @@ struct DepotWindow : Window { bool OnVehicleSelect(const Vehicle *v) override { if (_settings_client.gui.cm_open_vehicle_for_shared_clone) { // CM - if (DoCommandP(this->window_number, v->index, _ctrl_pressed ? 1 : 0, CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), CcCloneVehicle)) + if (DoCommandP(this->window_number, v->index, citymania::_fn_mod ? 1 : 0, CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), CcCloneVehicle)) ResetObjectToPlace(); return true; } - if (_ctrl_pressed) { + if (citymania::_fn_mod) { /* Share-clone, do not open new viewport, and keep tool active */ DoCommandP(this->window_number, v->index, 1, CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), nullptr); } else { @@ -991,7 +993,7 @@ struct DepotWindow : Window { GetDepotVehiclePtData gdvp = { nullptr, nullptr }; if (this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, &gdvp) == MODE_DRAG_VEHICLE && sel != INVALID_VEHICLE) { - if (gdvp.wagon != nullptr && gdvp.wagon->index == sel && _ctrl_pressed) { + if (gdvp.wagon != nullptr && gdvp.wagon->index == sel && citymania::_fn_mod) { DoCommandP(Vehicle::Get(sel)->tile, Vehicle::Get(sel)->index, true, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE)); } else if (gdvp.wagon == nullptr || gdvp.wagon->index != sel) { @@ -1017,7 +1019,7 @@ struct DepotWindow : Window { this->sel = INVALID_VEHICLE; this->SetDirty(); - int sell_cmd = (v->type == VEH_TRAIN && (widget == WID_D_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0; + int sell_cmd = (v->type == VEH_TRAIN && (widget == WID_D_SELL_CHAIN || citymania::_fn_mod)) ? 1 : 0; DoCommandP(v->tile, v->index | sell_cmd << 20 | MAKE_ORDER_BACKUP_FLAG, 0, GetCmdSellVeh(v->type)); break; } @@ -1054,10 +1056,10 @@ struct DepotWindow : Window { } } - EventState OnCTRLStateChange() override + EventState CM_OnFnModStateChange() override { if (this->sel != INVALID_VEHICLE) { - _cursor.vehchain = _ctrl_pressed; + _cursor.vehchain = citymania::_fn_mod; this->SetWidgetDirty(WID_D_MATRIX); return ES_HANDLED; } diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 5da5726b65..748451a096 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -31,6 +31,7 @@ #include "table/sprites.h" #include "table/strings.h" +#include "citymania/cm_hotkeys.hpp" #include "citymania/station_ui.hpp" #include "safeguards.h" @@ -191,7 +192,7 @@ struct BuildDocksToolbarWindow : Window { case WID_DT_DEPOT: // Build depot button DoCommandP(tile, _ship_depot_direction, 0, CMD_BUILD_SHIP_DEPOT | CMD_MSG(STR_ERROR_CAN_T_BUILD_SHIP_DEPOT), CcBuildDocks); - if (_ctrl_pressed == _settings_client.gui.persistent_depottools) + if (citymania::_fn_mod == _settings_client.gui.persistent_depottools) ResetObjectToPlace(); break; @@ -205,7 +206,7 @@ struct BuildDocksToolbarWindow : Window { uint32 p2 = (uint32)INVALID_STATION << 16; // no station to join /* tile is always the land tile, so need to evaluate _thd.pos */ - CommandContainer cmdcont = { tile, _ctrl_pressed, p2, CMD_BUILD_DOCK | CMD_MSG(STR_ERROR_CAN_T_BUILD_DOCK_HERE), CcBuildDocks, "" }; + CommandContainer cmdcont = { tile, citymania::_fn_mod, p2, CMD_BUILD_DOCK | CMD_MSG(STR_ERROR_CAN_T_BUILD_DOCK_HERE), CcBuildDocks, "" }; /* Determine the watery part of the dock. */ DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile)); @@ -244,7 +245,7 @@ struct BuildDocksToolbarWindow : Window { GUIPlaceProcDragXY(select_proc, start_tile, end_tile); break; case DDSP_CREATE_WATER: - DoCommandP(end_tile, start_tile, (_game_mode == GM_EDITOR && _ctrl_pressed) ? WATER_CLASS_SEA : WATER_CLASS_CANAL, CMD_BUILD_CANAL | CMD_MSG(STR_ERROR_CAN_T_BUILD_CANALS), CcPlaySound_SPLAT_WATER); + DoCommandP(end_tile, start_tile, (_game_mode == GM_EDITOR && citymania::_fn_mod) ? WATER_CLASS_SEA : WATER_CLASS_CANAL, CMD_BUILD_CANAL | CMD_MSG(STR_ERROR_CAN_T_BUILD_CANALS), CcPlaySound_SPLAT_WATER); break; case DDSP_CREATE_RIVER: DoCommandP(end_tile, start_tile, WATER_CLASS_RIVER, CMD_BUILD_CANAL | CMD_MSG(STR_ERROR_CAN_T_PLACE_RIVERS), CcPlaySound_SPLAT_WATER); diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index b71fa7a6bd..1f72d3ada4 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -28,6 +28,8 @@ #include "table/strings.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" /** @@ -128,7 +130,7 @@ struct EnginePreviewWindow : Window { DoCommandP(0, this->window_number, 0, CMD_WANT_ENGINE_PREVIEW); FALLTHROUGH; case WID_EP_NO: - if (!_shift_pressed) delete this; + if (!citymania::_estimate_mod) delete this; break; } } diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index 4fd0e0189b..9fad484faf 100644 --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -28,6 +28,8 @@ #include "table/strings.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" /** Goal list columns. */ @@ -147,7 +149,7 @@ struct GoalListWindow : public Window { default: NOT_REACHED(); } - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowExtraViewPortWindow(xy); } else { ScrollMainWindowToTile(xy); diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 0bf8589ac5..88a7d785ee 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -29,6 +29,8 @@ #include "table/sprites.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" static const int LEVEL_WIDTH = 10; ///< Indenting width of a sub-group in pixels @@ -734,7 +736,7 @@ public: this->vehicle_sel = v->index; - if (_ctrl_pressed) { + if (citymania::_fn_mod) { this->SelectGroup(v->group_id); } @@ -783,7 +785,7 @@ public: case WID_GL_REPLACE_PROTECTION: { const Group *g = Group::GetIfValid(this->vli.index); if (g != nullptr) { - DoCommandP(0, this->vli.index, (g->replace_protection ? 0 : 1) | (_ctrl_pressed << 1), CMD_SET_GROUP_REPLACE_PROTECTION); + DoCommandP(0, this->vli.index, (g->replace_protection ? 0 : 1) | (citymania::_fn_mod ? 2 : 0), CMD_SET_GROUP_REPLACE_PROTECTION); } break; } @@ -826,7 +828,7 @@ public: { switch (widget) { case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles - DoCommandP(0, DEFAULT_GROUP, this->vehicle_sel | (_ctrl_pressed ? 1 << 31 : 0), CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE)); + DoCommandP(0, DEFAULT_GROUP, this->vehicle_sel | (citymania::_fn_mod ? 1 << 31 : 0), CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE)); this->vehicle_sel = INVALID_VEHICLE; this->group_over = INVALID_GROUP; @@ -843,7 +845,7 @@ public: uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height); GroupID new_g = id_g >= this->groups.size() ? NEW_GROUP : this->groups[id_g]->index; - DoCommandP(0, new_g, vindex | (_ctrl_pressed ? 1 << 31 : 0), CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE), new_g == NEW_GROUP ? CcAddVehicleNewGroup : nullptr); + DoCommandP(0, new_g, vindex | (citymania::_fn_mod ? 1 << 31 : 0), CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE), new_g == NEW_GROUP ? CcAddVehicleNewGroup : nullptr); break; } diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 976578efdf..d90d1ee408 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -43,6 +43,7 @@ #include +#include "citymania/cm_hotkeys.hpp" #include "citymania/highlight.hpp" #include "safeguards.h" @@ -1090,7 +1091,7 @@ public: case WID_IV_GOTO: { Industry *i = Industry::Get(this->window_number); - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowExtraViewPortWindow(i->location.GetCenterTile()); } else { ScrollMainWindowToTile(i->location.GetCenterTile()); @@ -1701,7 +1702,7 @@ public: case WID_ID_INDUSTRY_LIST: { uint p = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_ID_INDUSTRY_LIST, WD_FRAMERECT_TOP); if (p < this->industries.size()) { - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowExtraViewPortWindow(this->industries[p]->location.tile); } else { ScrollMainWindowToTile(this->industries[p]->location.tile); diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index 1fea69ea5b..37b0fa93b2 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -31,6 +31,8 @@ #include "table/strings.h" #include "table/sprites.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" struct SelectGameWindow : public Window { @@ -117,7 +119,7 @@ struct SelectGameWindow : public Window { switch (widget) { case WID_SGI_GENERATE_GAME: - if (_ctrl_pressed) { + if (citymania::_fn_mod) { StartNewGameWithoutGUI(GENERATE_NEW_SEED); } else { ShowGenerateLandscape(); diff --git a/src/lang/english.txt b/src/lang/english.txt index d334132b72..60bc6a3995 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -5526,3 +5526,13 @@ STR_CM_LAND_TOOLTIPS_STATION_CARGO :{WHITE}{STRING} {BLACK}{CARG STR_LAND_AREA_INFORMATION_POP :{BLACK}Population: {LTBLUE}{NUM} +STR_CM_CONFIG_SETTING_MODIFIER_FN : Additional function modifier key: {STRING2} +STR_CM_CONFIG_SETTING_MODIFIER_FN_HELPTEXT : Modifier key for accessing additional functions. +STR_CM_CONFIG_SETTING_MODIFIER_REMOVE : Remove modifier key: {STRING2} +STR_CM_CONFIG_SETTING_MODIFIER_REMOVE_HELPTEXT : Modifier key for removal mode on building tools. +STR_CM_CONFIG_SETTING_MODIFIER_ESTIMATE : Estimate modifier key: {STRING2} +STR_CM_CONFIG_SETTING_MODIFIER_ESTIMATE_HELPTEXT : Modifier key for estimating action cost. +STR_CM_CONFIG_SETTING_MODIFIER_NONE : None +STR_CM_CONFIG_SETTING_MODIFIER_SHIFT : Shift +STR_CM_CONFIG_SETTING_MODIFIER_CTRL : Ctrl +STR_CM_CONFIG_SETTING_MODIFIER_ALT : Alt diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 64d9ddd8a3..513305c9b0 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -41,6 +41,8 @@ #include "../zoom_func.h" #include "../watch_gui.h" +#include "../citymania/cm_hotkeys.hpp" + #include "../safeguards.h" @@ -616,7 +618,7 @@ public: this->SetWidgetDisabledState(WID_NG_JOIN, sel == nullptr || // no Selected Server !sel->online || // Server offline sel->info.clients_on >= sel->info.clients_max || // Server full - (!sel->info.compatible && !_ctrl_pressed)); // Revision mismatch + (!sel->info.compatible && !citymania::_fn_mod)); // Revision mismatch /* 'NewGRF Settings' button invisible if no NewGRF is used */ this->GetWidget(WID_NG_NEWGRF_SEL)->SetDisplayedPlane(sel == nullptr || !sel->online || sel->info.grfconfig == nullptr); @@ -1221,7 +1223,7 @@ struct NetworkStartServerWindow : public Window { case WID_NSS_GENERATE_GAME: // Start game _is_network_server = true; - if (_ctrl_pressed) { + if (citymania::_fn_mod) { StartNewGameWithoutGUI(GENERATE_NEW_SEED); } else { ShowGenerateLandscape(); diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index 130ee306c6..479cdaf110 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -42,6 +42,8 @@ #include "table/strings.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" /** The sprite picker. */ @@ -972,10 +974,10 @@ struct SpriteAlignerWindow : Window { } switch (widget) { /* Move eight units at a time if ctrl is pressed. */ - case WID_SA_UP: spr->y_offs -= _ctrl_pressed ? 8 : 1; break; - case WID_SA_DOWN: spr->y_offs += _ctrl_pressed ? 8 : 1; break; - case WID_SA_LEFT: spr->x_offs -= _ctrl_pressed ? 8 : 1; break; - case WID_SA_RIGHT: spr->x_offs += _ctrl_pressed ? 8 : 1; break; + case WID_SA_UP: spr->y_offs -= citymania::_fn_mod ? 8 : 1; break; + case WID_SA_DOWN: spr->y_offs += citymania::_fn_mod ? 8 : 1; break; + case WID_SA_LEFT: spr->x_offs -= citymania::_fn_mod ? 8 : 1; break; + case WID_SA_RIGHT: spr->x_offs += citymania::_fn_mod ? 8 : 1; break; } /* Of course, we need to redraw the sprite, but where is it used? * Everywhere is a safe bet. */ diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 2fba804010..3d465957bf 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -39,6 +39,8 @@ #include "table/strings.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" const NewsItem *_statusbar_news_item = nullptr; @@ -506,7 +508,7 @@ struct NewsWindow : Window { } else { TileIndex tile1 = GetReferenceTile(this->ni->reftype1, this->ni->ref1); TileIndex tile2 = GetReferenceTile(this->ni->reftype2, this->ni->ref2); - if (_ctrl_pressed) { + if (citymania::_fn_mod) { if (tile1 != INVALID_TILE) ShowExtraViewPortWindow(tile1); if (tile2 != INVALID_TILE) ShowExtraViewPortWindow(tile2); } else { diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 9ef1b6f34b..404a999f04 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -31,6 +31,8 @@ #include "widgets/order_widget.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" @@ -457,7 +459,7 @@ static std::pair GetOrderCmdFromTile(const Vehicle *v, Ti ODTFB_PART_OF_ORDERS, (_settings_client.gui.new_nonstop && v->IsGroundVehicle()) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE); - if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE)); + if (citymania::_fn_mod) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE)); return std::make_pair(order, FeederOrderMod::NONE); } @@ -467,7 +469,7 @@ static std::pair GetOrderCmdFromTile(const Vehicle *v, Ti v->type == VEH_TRAIN && IsTileOwner(tile, _local_company)) { order.MakeGoToWaypoint(GetStationIndex(tile)); - if (_settings_client.gui.new_nonstop != _ctrl_pressed) order.SetNonStopType(ONSF_NO_STOP_AT_ANY_STATION); + if (_settings_client.gui.new_nonstop != citymania::_fn_mod) order.SetNonStopType(ONSF_NO_STOP_AT_ANY_STATION); return std::make_pair(order, FeederOrderMod::NONE); } @@ -820,11 +822,11 @@ private: void OrderClick_Skip() { /* Don't skip when there's nothing to skip */ - if (_ctrl_pressed && this->vehicle->cur_implicit_order_index == this->OrderGetSel()) return; + if (citymania::_fn_mod && this->vehicle->cur_implicit_order_index == this->OrderGetSel()) return; if (this->vehicle->GetNumOrders() <= 1) return; - DoCommandP(this->vehicle->tile, this->vehicle->index, _ctrl_pressed ? this->OrderGetSel() : ((this->vehicle->cur_implicit_order_index + 1) % this->vehicle->GetNumOrders()), - CMD_SKIP_TO_ORDER | CMD_MSG(_ctrl_pressed ? STR_ERROR_CAN_T_SKIP_TO_ORDER : STR_ERROR_CAN_T_SKIP_ORDER)); + DoCommandP(this->vehicle->tile, this->vehicle->index, citymania::_fn_mod ? this->OrderGetSel() : ((this->vehicle->cur_implicit_order_index + 1) % this->vehicle->GetNumOrders()), + CMD_SKIP_TO_ORDER | CMD_MSG(citymania::_fn_mod ? STR_ERROR_CAN_T_SKIP_TO_ORDER : STR_ERROR_CAN_T_SKIP_ORDER)); } /** @@ -852,7 +854,7 @@ private: /* Don't try to stop sharing orders if 'End of Shared Orders' isn't selected. */ if (!this->vehicle->IsOrderListShared() || this->selected_order != this->vehicle->GetNumOrders()) return; /* If Ctrl is pressed, delete the order list as if we clicked the 'Delete' button. */ - if (_ctrl_pressed) { + if (citymania::_fn_mod) { this->OrderClick_Delete(); return; } @@ -873,7 +875,7 @@ private: */ void OrderClick_Refit(int i, bool auto_refit) { - if (_ctrl_pressed) { + if (citymania::_fn_mod) { /* Cancel refitting */ DoCommandP(this->vehicle->tile, this->vehicle->index, (this->OrderGetSel() << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, CMD_ORDER_REFIT); } else { @@ -1309,7 +1311,7 @@ public: VehicleOrderID sel = this->GetOrderFromPt(pt.y); - if (_ctrl_pressed && sel < this->vehicle->GetNumOrders()) { + if (citymania::_fn_mod && sel < this->vehicle->GetNumOrders()) { TileIndex xy = this->vehicle->GetOrder(sel)->GetLocation(this->vehicle); if (xy != INVALID_TILE) ScrollMainWindowToTile(xy); return; @@ -1616,7 +1618,7 @@ public: * ourself as it easily copies orders of vehicles within a station when we mean the station. * Obviously if you press CTRL on a non-empty orders vehicle you know what you are doing * TODO: give a warning message */ - 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 (DoCommandP(this->vehicle->tile, this->vehicle->index | (share_order ? CO_SHARE : CO_COPY) << 30, v->index, diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index dbf8400344..c2ec78e636 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -38,6 +38,7 @@ #include "widgets/rail_widget.h" +#include "citymania/cm_hotkeys.hpp" #include "citymania/station_ui.hpp" #include "safeguards.h" @@ -210,7 +211,7 @@ static void PlaceRail_Station(TileIndex tile) citymania::PlaceRail_Station(tile); return; } - uint32 p1 = _cur_railtype | _railstation.orientation << 6 | _settings_client.gui.station_numtracks << 8 | _settings_client.gui.station_platlength << 16 | _ctrl_pressed << 24; + uint32 p1 = _cur_railtype | _railstation.orientation << 6 | _settings_client.gui.station_numtracks << 8 | _settings_client.gui.station_platlength << 16 | citymania::_fn_mod << 24; uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16; int w = _settings_client.gui.station_numtracks; @@ -254,13 +255,13 @@ static void GenericPlaceSignals(TileIndex tile) if (w != nullptr) { /* signal GUI is used */ - SB(p1, 3, 1, _ctrl_pressed); + SB(p1, 3, 1, citymania::_fn_mod); SB(p1, 4, 1, _cur_signal_variant); SB(p1, 5, 3, _cur_signal_type); SB(p1, 8, 1, _convert_signal_button); SB(p1, 9, 6, cycle_bounds[_settings_client.gui.cycle_signal_types]); } else { - SB(p1, 3, 1, _ctrl_pressed); + SB(p1, 3, 1, citymania::_fn_mod); SB(p1, 4, 1, (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC)); SB(p1, 5, 3, _default_signal_type[_settings_client.gui.default_signal_type]); SB(p1, 8, 1, 0); @@ -399,7 +400,7 @@ static void HandleAutodirPlacement() * snap point over the last overbuilt track piece. In such case we don't * wan't to show any errors to the user. Don't execute the command right * away, first check if overbuilding. */ - if (_shift_pressed || !(_thd.place_mode & HT_POLY) || + if (citymania::_estimate_mod || !(_thd.place_mode & HT_POLY) || DoCommand(&cmd, DC_AUTO | DC_NO_WATER).GetErrorMessage() != STR_ERROR_ALREADY_BUILT || _rail_track_endtile == INVALID_TILE) { /* Execute. */ @@ -408,7 +409,7 @@ static void HandleAutodirPlacement() /* Save new snap points for the polyline tool, no matter if the command * succeeded, the snapping will be extended over overbuilt track pieces. */ - if (!_shift_pressed && _rail_track_endtile != INVALID_TILE) { + if (!citymania::_estimate_mod && _rail_track_endtile != INVALID_TILE) { StoreRailPlacementEndpoints(start_tile, _rail_track_endtile, track, true); } } @@ -434,14 +435,14 @@ static void HandleAutoSignalPlacement() /* signal GUI is used */ SB(p2, 3, 1, 0); SB(p2, 4, 1, _cur_signal_variant); - SB(p2, 6, 1, _ctrl_pressed); + SB(p2, 6, 1, citymania::_fn_mod); SB(p2, 7, 3, _cur_signal_type); SB(p2, 24, 8, _settings_client.gui.drag_signals_density); SB(p2, 10, 1, !_settings_client.gui.drag_signals_fixed_distance); } else { SB(p2, 3, 1, 0); SB(p2, 4, 1, (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC)); - SB(p2, 6, 1, _ctrl_pressed); + SB(p2, 6, 1, citymania::_fn_mod); SB(p2, 7, 3, _default_signal_type[_settings_client.gui.default_signal_type]); SB(p2, 24, 8, _settings_client.gui.drag_signals_density); SB(p2, 10, 1, !_settings_client.gui.drag_signals_fixed_distance); @@ -689,7 +690,7 @@ struct BuildRailToolbarWindow : Window { } else if (this->last_user_action == HOTKEY_NEW_POLYRAIL) { do_snap = false; do_open = !was_open || was_snap; - } else if (_ctrl_pressed) { + } else if (citymania::_fn_mod) { do_snap = !was_open || !was_snap; do_open = true; } else { @@ -752,7 +753,7 @@ struct BuildRailToolbarWindow : Window { case WID_RAT_BUILD_SIGNALS: { this->last_user_action = widget; bool started = HandlePlacePushButton(this, WID_RAT_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, HT_RECT); - if (started && _settings_client.gui.enable_signal_gui != _ctrl_pressed) { + if (started && _settings_client.gui.enable_signal_gui != citymania::_fn_mod) { ShowSignalBuilder(this); } break; @@ -780,7 +781,7 @@ struct BuildRailToolbarWindow : Window { default: NOT_REACHED(); } this->UpdateRemoveWidgetStatus(widget); - if (_ctrl_pressed && remove_on_ctrl) RailToolbar_CtrlChanged(this); + if (citymania::_remove_mod && remove_on_ctrl) RailToolbar_CtrlChanged(this); } EventState OnHotkey(int hotkey) override @@ -842,7 +843,7 @@ struct BuildRailToolbarWindow : Window { DoCommandP(tile, _cur_railtype, ddir, CMD_BUILD_TRAIN_DEPOT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_DEPOT), CcRailDepot); - if (_ctrl_pressed == _settings_client.gui.persistent_depottools) + if (citymania::_fn_mod == _settings_client.gui.persistent_depottools) ResetObjectToPlace(); break; @@ -905,7 +906,7 @@ struct BuildRailToolbarWindow : Window { break; case DDSP_CONVERT_RAIL: - DoCommandP(end_tile, start_tile, _cur_railtype | (_ctrl_pressed ? 1 << 6 : 0), CMD_CONVERT_RAIL | CMD_MSG(STR_ERROR_CAN_T_CONVERT_RAIL), CcPlaySound_SPLAT_RAIL); + DoCommandP(end_tile, start_tile, _cur_railtype | (citymania::_fn_mod ? 1 << 6 : 0), CMD_CONVERT_RAIL | CMD_MSG(STR_ERROR_CAN_T_CONVERT_RAIL), CcPlaySound_SPLAT_RAIL); break; case DDSP_REMOVE_STATION: @@ -913,17 +914,17 @@ struct BuildRailToolbarWindow : Window { if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) { /* Station */ if (_remove_button_clicked) { - DoCommandP(end_tile, start_tile, _ctrl_pressed ? 0 : 1, CMD_REMOVE_FROM_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_REMOVE_PART_OF_STATION), CcPlaySound_SPLAT_RAIL); + DoCommandP(end_tile, start_tile, citymania::_fn_mod ? 0 : 1, CMD_REMOVE_FROM_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_REMOVE_PART_OF_STATION), CcPlaySound_SPLAT_RAIL); } else { HandleStationPlacement(start_tile, end_tile); } } else { /* Waypoint */ if (_remove_button_clicked) { - DoCommandP(end_tile, start_tile, _ctrl_pressed ? 0 : 1, CMD_REMOVE_FROM_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT), CcPlaySound_SPLAT_RAIL); + DoCommandP(end_tile, start_tile, citymania::_fn_mod ? 0 : 1, CMD_REMOVE_FROM_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT), CcPlaySound_SPLAT_RAIL); } else { TileArea ta(start_tile, end_tile); - uint32 p1 = _cur_railtype | (select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y) << 6 | ta.w << 8 | ta.h << 16 | _ctrl_pressed << 24; + uint32 p1 = _cur_railtype | (select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y) << 6 | ta.w << 8 | ta.h << 16 | citymania::_fn_mod << 24; uint32 p2 = STAT_CLASS_WAYP | _cur_waypoint_type << 8 | INVALID_STATION << 16; CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT), CcPlaySound_SPLAT_RAIL, "" }; @@ -959,7 +960,7 @@ struct BuildRailToolbarWindow : Window { VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile); } - EventState OnCTRLStateChange() override + EventState CM_OnRemoveModStateChange() override { /* do not toggle Remove button by Ctrl when placing station */ if (!this->IsWidgetLowered(WID_RAT_BUILD_STATION) && !this->IsWidgetLowered(WID_RAT_BUILD_WAYPOINT) && RailToolbar_CtrlChanged(this)) return ES_HANDLED; @@ -1097,7 +1098,7 @@ static void HandleStationPlacement(TileIndex start, TileIndex end) if (_railstation.orientation == AXIS_X) Swap(numtracks, platlength); - uint32 p1 = _cur_railtype | _railstation.orientation << 6 | numtracks << 8 | platlength << 16 | _ctrl_pressed << 24; + uint32 p1 = _cur_railtype | _railstation.orientation << 6 | numtracks << 8 | platlength << 16 | citymania::_fn_mod << 24; uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16; CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" }; diff --git a/src/road_gui.cpp b/src/road_gui.cpp index e60c20f3df..805dfcd0c0 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -39,6 +39,7 @@ #include "table/strings.h" +#include "citymania/cm_hotkeys.hpp" #include "citymania/station_ui.hpp" #include "safeguards.h" @@ -618,7 +619,7 @@ struct BuildRoadToolbarWindow : Window { default: NOT_REACHED(); } this->UpdateOptionWidgetStatus((RoadToolbarWidgets)widget); - if (_ctrl_pressed) RoadToolbar_CtrlChanged(this); + if (citymania::_remove_mod) RoadToolbar_CtrlChanged(this); } EventState OnHotkey(int hotkey) override @@ -663,7 +664,7 @@ struct BuildRoadToolbarWindow : Window { } DoCommandP(tile, _cur_roadtype << 2 | ddir, 0, CMD_BUILD_ROAD_DEPOT | CMD_MSG(this->rti->strings.err_depot), CcRoadDepot); - if (_ctrl_pressed == _settings_client.gui.persistent_depottools) + if (citymania::_fn_mod == _settings_client.gui.persistent_depottools) ResetObjectToPlace(); break; @@ -809,9 +810,9 @@ struct BuildRoadToolbarWindow : Window { if (this->IsWidgetLowered(WID_ROT_BUS_STATION)) { if (_remove_button_clicked) { TileArea ta(start_tile, end_tile); - DoCommandP(ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_BUS, CMD_REMOVE_ROAD_STOP | CMD_MSG(this->rti->strings.err_remove_station[ROADSTOP_BUS]), CcPlaySound_SPLAT_OTHER); + DoCommandP(ta.tile, ta.w | ta.h << 8, (citymania::_fn_mod ? 2 : 0) | ROADSTOP_BUS, CMD_REMOVE_ROAD_STOP | CMD_MSG(this->rti->strings.err_remove_station[ROADSTOP_BUS]), CcPlaySound_SPLAT_OTHER); } else { - PlaceRoadStop(start_tile, end_tile, _cur_roadtype << 5 | (_ctrl_pressed << 2) | ROADSTOP_BUS, CMD_BUILD_ROAD_STOP | CMD_MSG(this->rti->strings.err_build_station[ROADSTOP_BUS])); + PlaceRoadStop(start_tile, end_tile, _cur_roadtype << 5 | (citymania::_fn_mod << 2) | ROADSTOP_BUS, CMD_BUILD_ROAD_STOP | CMD_MSG(this->rti->strings.err_build_station[ROADSTOP_BUS])); } } break; @@ -821,9 +822,9 @@ struct BuildRoadToolbarWindow : Window { if (this->IsWidgetLowered(WID_ROT_TRUCK_STATION)) { if (_remove_button_clicked) { TileArea ta(start_tile, end_tile); - DoCommandP(ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_TRUCK, CMD_REMOVE_ROAD_STOP | CMD_MSG(this->rti->strings.err_remove_station[ROADSTOP_TRUCK]), CcPlaySound_SPLAT_OTHER); + DoCommandP(ta.tile, ta.w | ta.h << 8, (citymania::_fn_mod << 1) | ROADSTOP_TRUCK, CMD_REMOVE_ROAD_STOP | CMD_MSG(this->rti->strings.err_remove_station[ROADSTOP_TRUCK]), CcPlaySound_SPLAT_OTHER); } else { - PlaceRoadStop(start_tile, end_tile, _cur_roadtype << 5 | (_ctrl_pressed << 2) | ROADSTOP_TRUCK, CMD_BUILD_ROAD_STOP | CMD_MSG(this->rti->strings.err_build_station[ROADSTOP_TRUCK])); + PlaceRoadStop(start_tile, end_tile, _cur_roadtype << 5 | (citymania::_fn_mod << 2) | ROADSTOP_TRUCK, CMD_BUILD_ROAD_STOP | CMD_MSG(this->rti->strings.err_build_station[ROADSTOP_TRUCK])); } } break; @@ -841,7 +842,7 @@ struct BuildRoadToolbarWindow : Window { VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile); } - EventState OnCTRLStateChange() override + EventState CM_OnRemoveModStateChange() override { if (RoadToolbar_CtrlChanged(this)) return ES_HANDLED; return ES_NOT_HANDLED; diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 6067708c50..ca78535422 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1543,6 +1543,9 @@ static SettingsContainer &GetSettingsTree() general->Add(new SettingEntry("gui.window_soft_limit")); general->Add(new SettingEntry("gui.right_mouse_wnd_close")); general->Add(new SettingEntry("gui.pause_after_load")); + general->Add(new SettingEntry("gui.cm_fn_mod")); + general->Add(new SettingEntry("gui.cm_remove_mod")); + general->Add(new SettingEntry("gui.cm_estimate_mod")); } SettingsPage *viewports = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_VIEWPORTS)); diff --git a/src/settings_type.h b/src/settings_type.h index eea0d40f52..7f8f79008d 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -195,6 +195,10 @@ struct GUISettings { bool cm_land_tooltips_for_stations; bool cm_land_tooltips_for_houses; + citymania::ModKey cm_fn_mod; + citymania::ModKey cm_remove_mod; + citymania::ModKey cm_estimate_mod; + /** * Returns true when the user has sufficient privileges to edit newgrfs on a running game * @return whether the user has sufficient privileges to edit newgrfs in an existing game diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index ea3de70085..ae1f28b80f 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -31,6 +31,8 @@ #include "table/strings.h" #include "table/sprites.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" struct SignList { @@ -555,7 +557,7 @@ static WindowDesc _query_sign_edit_desc( */ void HandleClickOnSign(const Sign *si) { - if (_ctrl_pressed && (si->owner == _local_company || (si->owner == OWNER_DEITY && _game_mode == GM_EDITOR))) { + if (citymania::_fn_mod && (si->owner == _local_company || (si->owner == OWNER_DEITY && _game_mode == GM_EDITOR))) { RenameSign(si->index, nullptr); return; } diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index a1ac788ffa..b1444c823e 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -29,6 +29,7 @@ #include +#include "citymania/cm_hotkeys.hpp" #include "citymania/minimap.hpp" #include "safeguards.h" @@ -1377,7 +1378,7 @@ inline uint SmallMapWindow::GetNumberRowsLegend(uint columns) const */ void SmallMapWindow::SelectLegendItem(int click_pos, LegendAndColour *legend, int end_legend_item, int begin_legend_item) { - 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 c0d98f6e86..4234408a13 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -40,6 +40,7 @@ #include #include "citymania/station_ui.hpp" +#include "citymania/cm_hotkeys.hpp" #include "citymania/cm_tooltips.hpp" #include "safeguards.h" @@ -105,7 +106,7 @@ int DrawStationAuthorityText(int left, int right, int top) { static void FindStationsAroundSelection() { /* With distant join we don't know which station will be selected, so don't show any */ - if (_ctrl_pressed) { + if (citymania::_fn_mod) { SetViewportCatchmentStation(nullptr, true); return; } @@ -150,10 +151,10 @@ void CheckRedrawStationCoverage(const Window *w) return; } /* Test if ctrl state changed */ - static bool _last_ctrl_pressed; - if (_ctrl_pressed != _last_ctrl_pressed) { + static bool _last_fn_pressed; + if (citymania::_fn_mod != _last_fn_pressed) { _thd.dirty = 0xff; - _last_ctrl_pressed = _ctrl_pressed; + _last_fn_pressed = citymania::_fn_mod; } if (_thd.dirty & 1) { @@ -560,7 +561,7 @@ public: /* do not check HasStationInUse - it is slow and may be invalid */ assert(st->owner == (Owner)this->window_number || st->owner == OWNER_NONE); - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowExtraViewPortWindow(st->xy); } else { ScrollMainWindowToTile(st->xy); @@ -573,7 +574,7 @@ public: case WID_STL_BUS: case WID_STL_AIRPLANE: case WID_STL_SHIP: - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ToggleBit(this->facilities, widget - WID_STL_TRAIN); this->ToggleWidgetLoweredState(widget); } else { @@ -621,7 +622,7 @@ public: break; case WID_STL_NOCARGOWAITING: - if (_ctrl_pressed) { + if (citymania::_fn_mod) { this->include_empty = !this->include_empty; this->ToggleWidgetLoweredState(WID_STL_NOCARGOWAITING); } else { @@ -643,7 +644,7 @@ public: /* Determine the selected cargo type */ const CargoSpec *cs = _sorted_cargo_specs[widget - WID_STL_CARGOSTART]; - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ToggleBit(this->cargo_filter, cs->Index()); this->ToggleWidgetLoweredState(widget); } else { @@ -1919,7 +1920,7 @@ struct StationViewWindow : public Window { void HandleCargoWaitingClick(int row) { if (row < 0 || (uint)row >= this->displayed_rows.size()) return; - if (_ctrl_pressed) { + if (citymania::_fn_mod) { this->scroll_to_row = row; } else { RowDisplay &display = this->displayed_rows[row]; @@ -1944,7 +1945,7 @@ struct StationViewWindow : public Window { break; case WID_SV_LOCATION: - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowExtraViewPortWindow(Station::Get(this->window_number)->xy); } else { ScrollMainWindowToTile(Station::Get(this->window_number)->xy); @@ -2475,7 +2476,7 @@ static bool StationJoinerNeeded(const CommandContainer &cmd, TileArea ta) } /* only show the popup, if we press ctrl */ - if (!_ctrl_pressed) return false; + if (!citymania::_fn_mod) return false; /* Now check if we could build there */ if (DoCommand(&cmd, CommandFlagsToDCFlags(GetCommandFlags(cmd.cmd))).Failed()) return false; diff --git a/src/story_gui.cpp b/src/story_gui.cpp index 677d88bba8..cc96265464 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -29,6 +29,8 @@ #include "table/strings.h" #include "table/sprites.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" typedef GUIList GUIStoryPageList; @@ -385,7 +387,7 @@ protected: break; case SPET_LOCATION: - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowExtraViewPortWindow((TileIndex)pe.referenced_id); } else { ScrollMainWindowToTile((TileIndex)pe.referenced_id); diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index f9a17f7b72..8766c7bcbc 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -23,6 +23,8 @@ #include "table/strings.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" struct SubsidyListWindow : Window { @@ -82,8 +84,8 @@ struct SubsidyListWindow : Window { default: NOT_REACHED(); } - if (_ctrl_pressed || !ScrollMainWindowToTile(xy)) { - if (_ctrl_pressed) ShowExtraViewPortWindow(xy); + if (citymania::_fn_mod || !ScrollMainWindowToTile(xy)) { + if (citymania::_fn_mod) ShowExtraViewPortWindow(xy); /* otherwise determine dst coordinate for subsidy and scroll to it */ switch (s->dst_type) { @@ -92,7 +94,7 @@ struct SubsidyListWindow : Window { default: NOT_REACHED(); } - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowExtraViewPortWindow(xy); } else { ScrollMainWindowToTile(xy); diff --git a/src/table/settings.ini b/src/table/settings.ini index fa77ff90b8..39df248bc2 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -4232,5 +4232,44 @@ interval = 10 str = STR_CONFIG_SETTING_POWERFUND_HOUSES strval = STR_JUST_COMMA +[SDTC_VAR] +var = gui.cm_fn_mod +type = SLE_UINT8 +flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +guiflags = SGF_MULTISTRING +def = 2 +min = 0 +max = 3 +str = STR_CM_CONFIG_SETTING_MODIFIER_FN +strhelp = STR_CM_CONFIG_SETTING_MODIFIER_FN_HELPTEXT +strval = STR_CM_CONFIG_SETTING_MODIFIER_NONE +cat = SC_ADVANCED + +[SDTC_VAR] +var = gui.cm_remove_mod +type = SLE_UINT8 +flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +guiflags = SGF_MULTISTRING +def = 2 +min = 0 +max = 3 +str = STR_CM_CONFIG_SETTING_MODIFIER_REMOVE +strhelp = STR_CM_CONFIG_SETTING_MODIFIER_REMOVE_HELPTEXT +strval = STR_CM_CONFIG_SETTING_MODIFIER_NONE +cat = SC_ADVANCED + +[SDTC_VAR] +var = gui.cm_estimate_mod +type = SLE_UINT8 +flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +guiflags = SGF_MULTISTRING +def = 1 +min = 0 +max = 3 +str = STR_CM_CONFIG_SETTING_MODIFIER_ESTIMATE +strhelp = STR_CM_CONFIG_SETTING_MODIFIER_ESTIMATE_HELPTEXT +strval = STR_CM_CONFIG_SETTING_MODIFIER_NONE +cat = SC_ADVANCED + [SDT_END] diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index a9cc18c0d8..3d277394fc 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -36,6 +36,8 @@ #include "table/strings.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" void CcTerraform(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd) @@ -58,7 +60,7 @@ static void GenerateDesertArea(TileIndex end, TileIndex start) TileArea ta(start, end); TILE_AREA_LOOP(tile, ta) { - SetTropicZone(tile, (_ctrl_pressed) ? TROPICZONE_NORMAL : TROPICZONE_DESERT); + SetTropicZone(tile, citymania::_fn_mod ? TROPICZONE_NORMAL : TROPICZONE_DESERT); DoCommandP(tile, 0, 0, CMD_LANDSCAPE_CLEAR); MarkTileDirtyByTile(tile); } @@ -114,14 +116,14 @@ bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_t switch (proc) { case DDSP_DEMOLISH_AREA: - DoCommandP(end_tile, start_tile, _ctrl_pressed ? 1 : 0, CMD_CLEAR_AREA | CMD_MSG(STR_ERROR_CAN_T_CLEAR_THIS_AREA), CcPlaySound_EXPLOSION); + DoCommandP(end_tile, start_tile, citymania::_fn_mod ? 1 : 0, CMD_CLEAR_AREA | CMD_MSG(STR_ERROR_CAN_T_CLEAR_THIS_AREA), CcPlaySound_EXPLOSION); break; case DDSP_DEMOLISH_TREES: // loop through every tile and send a demolish command for each tree // orthogonal area TileIndex tree_start_tile, tree_recent_tile, prev_tile; tree_start_tile = tree_recent_tile = prev_tile = 0; - if (!_ctrl_pressed) { + if (!citymania::_fn_mod) { OrthogonalTileArea square_area = OrthogonalTileArea(start_tile, end_tile); TILE_AREA_LOOP(curr_tile, square_area) { // if we're on a non-consecutive tile or we've hit a black-marked tile @@ -174,13 +176,13 @@ bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_t } break; case DDSP_RAISE_AND_LEVEL_AREA: - DoCommandP(end_tile, start_tile, LM_RAISE << 1 | (_ctrl_pressed ? 1 : 0), CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_RAISE_LAND_HERE), CcTerraform); + DoCommandP(end_tile, start_tile, LM_RAISE << 1 | (citymania::_fn_mod ? 1 : 0), CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_RAISE_LAND_HERE), CcTerraform); break; case DDSP_LOWER_AND_LEVEL_AREA: - DoCommandP(end_tile, start_tile, LM_LOWER << 1 | (_ctrl_pressed ? 1 : 0), CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LOWER_LAND_HERE), CcTerraform); + DoCommandP(end_tile, start_tile, LM_LOWER << 1 | (citymania::_fn_mod ? 1 : 0), CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LOWER_LAND_HERE), CcTerraform); break; case DDSP_LEVEL_AREA: - DoCommandP(end_tile, start_tile, LM_LEVEL << 1 | (_ctrl_pressed ? 1 : 0), CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LEVEL_LAND_HERE), CcTerraform); + DoCommandP(end_tile, start_tile, LM_LEVEL << 1 | (citymania::_fn_mod ? 1 : 0), CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LEVEL_LAND_HERE), CcTerraform); break; case DDSP_CREATE_ROCKS: GenerateRockyArea(end_tile, start_tile); diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 9e23ebabc9..ab13a340ce 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -28,6 +28,8 @@ #include "table/sprites.h" #include "table/strings.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" /** Container for the arrival/departure dates of a vehicle */ @@ -529,7 +531,7 @@ struct TimetableWindow : Window { } case WID_VT_START_DATE: // Change the date that the timetable starts. - ShowSetDateWindow(this, v->index | (v->orders.list->IsCompleteTimetable() && _ctrl_pressed ? 1U << 20 : 0), _date, _cur_year, _cur_year + 15, ChangeTimetableStartCallback); + ShowSetDateWindow(this, v->index | (v->orders.list->IsCompleteTimetable() && citymania::_fn_mod ? 1U << 20 : 0), _date, _cur_year, _cur_year + 15, ChangeTimetableStartCallback); break; case WID_VT_CHANGE_TIME: { // "Wait For" button. @@ -595,7 +597,7 @@ struct TimetableWindow : Window { case WID_VT_AUTOFILL: { // Autofill the timetable. uint32 p2 = 0; if (!HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)) SetBit(p2, 0); - if (_ctrl_pressed) SetBit(p2, 1); + if (citymania::_fn_mod) SetBit(p2, 1); DoCommandP(0, v->index, p2, CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE)); break; } diff --git a/src/town_gui.cpp b/src/town_gui.cpp index cfc967b12f..e006191525 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -44,6 +44,8 @@ #include #include "console_func.h" +#include "citymania/cm_hotkeys.hpp" + struct CargoX { int id; int from; @@ -504,7 +506,7 @@ public: { switch (widget) { case WID_TV_CENTER_VIEW: // scroll to location - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowExtraViewPortWindow(this->town->xy); } else { ScrollMainWindowToTile(this->town->xy); @@ -1037,7 +1039,7 @@ public: const Town *t = this->towns[id_v]; assert(t != nullptr); - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowExtraViewPortWindow(t->xy); } else { ScrollMainWindowToTile(t->xy); @@ -1298,7 +1300,7 @@ public: townnameparts, CMD_FOUND_TOWN | CMD_MSG(errstr), cc, name); /* Rerandomise name, if success and no cost-estimation. */ - if (success && !_shift_pressed) this->RandomTownName(); + if (success && !citymania::_estimate_mod) this->RandomTownName(); } void OnClick(Point pt, int widget, int click_count) override @@ -1461,7 +1463,7 @@ public: switch (widget) { case WID_CB_LOCATION: case WID_CB_CENTER_VIEW: // scroll to location - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowExtraViewPortWindow(this->town->xy); } else { diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index 153dcb5d03..b527dffe46 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -18,6 +18,8 @@ #include "table/sprites.h" #include "table/strings.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" TransparencyOptionBits _transparency_opt; ///< The bits that should be transparent. @@ -70,7 +72,7 @@ public: void OnClick(Point pt, int widget, int click_count) override { if (widget >= WID_TT_BEGIN && widget < WID_TT_END) { - if (_ctrl_pressed) { + if (citymania::_fn_mod) { /* toggle the bit of the transparencies lock variable */ ToggleTransparencyLock((TransparencyOption)(widget - WID_TT_BEGIN)); this->SetDirty(); diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 1c4e1fc257..47976f2b17 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -38,6 +38,8 @@ #include "zoom_func.h" #include "hotkeys.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" @@ -899,7 +901,7 @@ struct RefitWindow : public Window { /* If the selection is not correct, clear it. */ if (this->num_vehicles != 0) { - if (_ctrl_pressed) this->num_vehicles = UINT8_MAX; + if (citymania::_fn_mod) this->num_vehicles = UINT8_MAX; break; } FALLTHROUGH; @@ -922,7 +924,7 @@ struct RefitWindow : public Window { this->click_x = GetClickPosition(pt.x - nwi->pos_x); this->SetSelectedVehicles(pt.x - nwi->pos_x); this->SetWidgetDirty(WID_VR_VEHICLE_PANEL_DISPLAY); - if (!_ctrl_pressed) { + if (!citymania::_fn_mod) { SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this); } else { /* The vehicle selection has changed. */ @@ -1627,7 +1629,7 @@ public: const Vehicle *v = this->vehicles[id_v]; if (!VehicleClicked(v)) { - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowCompanyGroupForVehicle(v); } else { ShowVehicleViewWindow(v); @@ -1748,10 +1750,10 @@ void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type) { /* If _settings_client.gui.advanced_vehicle_list > 1, display the Advanced list * if _settings_client.gui.advanced_vehicle_list == 1, display Advanced list only for local company - * if _ctrl_pressed, do the opposite action (Advanced list x Normal list) + * if citymania::_fn_mod, do the opposite action (Advanced list x Normal list) */ - if ((_settings_client.gui.advanced_vehicle_list > (uint)(company != _local_company)) != _ctrl_pressed) { + if ((_settings_client.gui.advanced_vehicle_list > (uint)(company != _local_company)) != citymania::_fn_mod) { ShowCompanyGroup(company, vehicle_type); } else { ShowVehicleListWindowLocal(company, VL_STANDARD, vehicle_type, company); @@ -2173,7 +2175,7 @@ struct VehicleDetailsWindow : Window { case WID_VD_INCREASE_SERVICING_INTERVAL: // increase int case WID_VD_DECREASE_SERVICING_INTERVAL: { // decrease int - int mod = _ctrl_pressed ? 5 : 10; + int mod = citymania::_fn_mod ? 5 : 10; const Vehicle *v = Vehicle::Get(this->window_number); mod = (widget == WID_VD_DECREASE_SERVICING_INTERVAL) ? -mod : mod; @@ -2665,7 +2667,7 @@ public: switch (widget) { case WID_VV_START_STOP: // start stop - if (_ctrl_pressed) { + if (citymania::_fn_mod) { /* Scroll to current order destination */ TileIndex tile = v->current_order.GetLocation(v); if (tile != INVALID_TILE) ScrollMainWindowToTile(tile); @@ -2677,7 +2679,7 @@ public: case WID_VV_CENTER_MAIN_VIEW: {// center main view const Window *mainwindow = FindWindowById(WC_MAIN_WINDOW, 0); /* code to allow the main window to 'follow' the vehicle if the ctrl key is pressed */ - if (_ctrl_pressed && mainwindow->viewport->zoom <= ZOOM_LVL_OUT_4X) { + if (citymania::_fn_mod && mainwindow->viewport->zoom <= ZOOM_LVL_OUT_4X) { mainwindow->viewport->follow_vehicle = v->index; } else { ScrollMainWindowTo(v->x_pos, v->y_pos, v->z_pos); @@ -2686,20 +2688,20 @@ public: } case WID_VV_GOTO_DEPOT: // goto hangar - DoCommandP(v->tile, v->index | (_ctrl_pressed ? DEPOT_SERVICE : 0U), 0, GetCmdSendToDepot(v)); + DoCommandP(v->tile, v->index | (citymania::_fn_mod ? DEPOT_SERVICE : 0U), 0, GetCmdSendToDepot(v)); break; case WID_VV_REFIT: // refit ShowVehicleRefitWindow(v, INVALID_VEH_ORDER_ID, this); break; case WID_VV_SHOW_ORDERS: // show orders - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowTimetableWindow(v); } else { ShowOrdersWindow(v); } break; case WID_VV_SHOW_DETAILS: // show details - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowCompanyGroupForVehicle(v); } else { ShowVehicleDetailsWindow(v); @@ -2710,7 +2712,7 @@ public: * There is no point to it except for starting the vehicle. * For starting the vehicle the player has to open the depot GUI, which is * most likely already open, but is also visible in the vehicle viewport. */ - DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, + DoCommandP(v->tile, v->index, citymania::_fn_mod ? 1 : 0, _vehicle_command_translation_table[VCT_CMD_CLONE_VEH][v->type], CcCloneVehicleWithOrderIndex); break; diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp index 88e5c528ff..6d910d9a8e 100644 --- a/src/video/allegro_v.cpp +++ b/src/video/allegro_v.cpp @@ -28,6 +28,8 @@ #include #include +#include "../../citymania/cm_hotkeys.hpp" + #include "../safeguards.h" #ifdef _DEBUG @@ -508,7 +510,8 @@ void VideoDriver_Allegro::MainLoop() (key[KEY_RIGHT] ? 4 : 0) | (key[KEY_DOWN] ? 8 : 0); - if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); + // CM if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); + citymania::UpdateModKeys(_shift_pressed, _ctrl_pressed, _alt_pressed); GameLoop(); diff --git a/src/video/cocoa/event.mm b/src/video/cocoa/event.mm index f45c3e971f..193de584c1 100644 --- a/src/video/cocoa/event.mm +++ b/src/video/cocoa/event.mm @@ -37,6 +37,8 @@ #include "../../window_func.h" #include "../../thread.h" +#include "../../citymania/cm_hotkeys.hpp" + #import /* gettimeofday */ /** @@ -697,7 +699,8 @@ void QZ_GameLoop() _ctrl_pressed = !!(_current_mods & ( _settings_client.gui.right_mouse_btn_emulation != RMBE_CONTROL ? NSControlKeyMask : NSCommandKeyMask)); _shift_pressed = !!(_current_mods & NSShiftKeyMask); - if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); + // CM if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); + citymania::UpdateModKeys(_shift_pressed, _ctrl_pressed, _alt_pressed); GameLoop(); diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp index 928112890f..234fd6c968 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -28,6 +28,8 @@ #include #include +#include "../citymania/cm_hotkeys.hpp" + #include "../safeguards.h" static FVideoDriver_SDL iFVideoDriver_SDL; @@ -752,7 +754,8 @@ void VideoDriver_SDL::MainLoop() (keys[SDL_SCANCODE_UP] ? 2 : 0) | (keys[SDL_SCANCODE_RIGHT] ? 4 : 0) | (keys[SDL_SCANCODE_DOWN] ? 8 : 0); - if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); + // CM if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); + citymania::UpdateModKeys(_shift_pressed, _ctrl_pressed, _alt_pressed); /* The gameloop is the part that can run asynchronously. The rest * except sleeping can't. */ diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index da369664e1..50ff5ff101 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -27,6 +27,8 @@ #include #include +#include "../../citymania/cm_hotkeys.hpp" + #include "../safeguards.h" static FVideoDriver_SDL iFVideoDriver_SDL; @@ -748,7 +750,8 @@ void VideoDriver_SDL::MainLoop() (keys[SDLK_RIGHT] ? 4 : 0) | (keys[SDLK_DOWN] ? 8 : 0); #endif - if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); + // CM if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); + citymania::UpdateModKeys(_shift_pressed, _ctrl_pressed, _alt_pressed); /* The gameloop is the part that can run asynchronously. The rest * except sleeping can't. */ diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index ae3f48b2a1..c4b30b5c65 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -29,6 +29,8 @@ #include #include +#include "../../citymania/cm_hotkeys.hpp" + #include "../safeguards.h" /* Missing define in MinGW headers. */ @@ -1253,7 +1255,8 @@ void VideoDriver_Win32::MainLoop() _dirkeys = 0; } - if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); + // CM if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); + citymania::UpdateModKeys(_shift_pressed, _ctrl_pressed, _alt_pressed); /* Flush GDI buffer to ensure we don't conflict with the drawing thread. */ GdiFlush(); diff --git a/src/viewport.cpp b/src/viewport.cpp index 1d65756130..7d43164501 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -102,6 +102,7 @@ #include "industry_type.h" #include "citymania/highlight.hpp" +#include "citymania/cm_hotkeys.hpp" #include "safeguards.h" @@ -2270,7 +2271,7 @@ static bool CheckClickOnViewportSign(const ViewPort *vp, int x, int y) } return true; } else if (last_t != nullptr) { - if (_ctrl_pressed) TownExecuteAction(last_t, 4); //CM build statue + if (citymania::_fn_mod) TownExecuteAction(last_t, 4); //CM build statue else ShowTownViewWindow(last_t->index); return true; } else if (last_si != nullptr) { @@ -2440,7 +2441,7 @@ bool HandleViewportClicked(const ViewPort *vp, int x, int y, bool double_click) DEBUG(misc, 2, "Vehicle %d (index %d) at %p", v->unitnumber, v->index, v); if (IsCompanyBuildableVehicleType(v)) { v = v->First(); - if (_ctrl_pressed && v->owner == _local_company) { + if (citymania::_fn_mod && v->owner == _local_company) { if (_settings_client.gui.enable_ctrl_click_start_stop) StartStopVehicle(v, true); } else { @@ -2583,7 +2584,7 @@ void TileHighlightData::Reset() */ bool TileHighlightData::IsDraggingDiagonal() { - return (this->place_mode & HT_DIAGONAL) != 0 && _ctrl_pressed && _left_button_down; + return (this->place_mode & HT_DIAGONAL) != 0 && citymania::_fn_mod && _left_button_down; } /** diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp index 64ef0eb251..191e818d99 100644 --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -25,6 +25,8 @@ #include "table/strings.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" /** GUI for accessing waypoints and buoys. */ @@ -88,7 +90,7 @@ public: { switch (widget) { case WID_W_CENTER_VIEW: // scroll to location - if (_ctrl_pressed) { + if (citymania::_fn_mod) { ShowExtraViewPortWindow(this->GetCenterTile()); } else { ScrollMainWindowToTile(this->GetCenterTile()); diff --git a/src/window.cpp b/src/window.cpp index 06e11d1924..c0cd326e86 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -41,6 +41,8 @@ #include "guitimer_func.h" #include "news_func.h" +#include "citymania/cm_hotkeys.hpp" + #include "safeguards.h" /** Values for _settings_client.gui.auto_scrolling */ @@ -724,7 +726,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count) return; case WWT_DEFSIZEBOX: { - if (_ctrl_pressed) { + if (citymania::_fn_mod) { w->window_desc->pref_width = w->width; w->window_desc->pref_height = w->height; } else { @@ -758,7 +760,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count) case WWT_STICKYBOX: w->flags ^= WF_STICKY; nw->SetDirty(w); - if (_ctrl_pressed) w->window_desc->pref_sticky = (w->flags & WF_STICKY) != 0; + if (citymania::_fn_mod) w->window_desc->pref_sticky = (w->flags & WF_STICKY) != 0; return; default: @@ -2732,14 +2734,15 @@ void HandleKeypress(uint keycode, WChar key) /** * State of CONTROL key has changed */ -void HandleCtrlChanged() -{ - /* Call the event, start with the uppermost window. */ - Window *w; - FOR_ALL_WINDOWS_FROM_FRONT(w) { - if (w->OnCTRLStateChange() == ES_HANDLED) return; - } -} +// Use CityMania modifier key handling +// void HandleCtrlChanged() +// { +// /* Call the event, start with the uppermost window. */ +// Window *w; +// FOR_ALL_WINDOWS_FROM_FRONT(w) { +// if (w->OnCTRLStateChange() == ES_HANDLED) return; +// } +// } /** * Insert a text string at the cursor position into the edit box widget. diff --git a/src/window_gui.h b/src/window_gui.h index 633c45f2ec..8ae9965943 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -611,8 +611,9 @@ public: * @return #ES_HANDLED if the change has been handled and no other * window should receive the event. */ - virtual EventState OnCTRLStateChange() { return ES_NOT_HANDLED; } - + // CM virtual EventState OnCTRLStateChange() { return ES_NOT_HANDLED; } + virtual EventState CM_OnFnModStateChange() { return ES_NOT_HANDLED; } + virtual EventState CM_OnRemoveModStateChange() { return ES_NOT_HANDLED; } /** * A click with the left mouse button has been made on the window.