From aea866a42f3ca37e47b7f86f871f6e234f30a893 Mon Sep 17 00:00:00 2001 From: dP Date: Tue, 6 Sep 2022 20:29:53 +0300 Subject: [PATCH] Change: Refactor modifier key handling, split Ctrl into function and remove --- src/ai/ai_gui.cpp | 4 ++-- src/airport_gui.cpp | 2 +- src/autoreplace_gui.cpp | 6 +++--- src/bridge_gui.cpp | 2 +- src/build_vehicle_gui.cpp | 2 +- src/command.cpp | 2 +- src/company_gui.cpp | 12 ++++++------ src/depot_gui.cpp | 24 +++++++++++------------ src/dock_gui.cpp | 6 +++--- src/engine_gui.cpp | 2 +- src/game/game_gui.cpp | 4 ++-- src/gfx.cpp | 6 ++++-- src/gfx_func.h | 8 +++++--- src/goal_gui.cpp | 2 +- src/group_gui.cpp | 10 +++++----- src/industry_gui.cpp | 4 ++-- src/intro_gui.cpp | 2 +- src/league_gui.cpp | 2 +- src/misc_gui.cpp | 2 +- src/network/network_gui.cpp | 2 +- src/newgrf_debug_gui.cpp | 2 +- src/news_gui.cpp | 2 +- src/object_gui.cpp | 2 +- src/order_gui.cpp | 38 ++++++++++++++++++------------------- src/rail_cmd.cpp | 12 ++++++------ src/rail_cmd.h | 2 +- src/rail_gui.cpp | 34 ++++++++++++++++----------------- src/road_gui.cpp | 18 +++++++++--------- src/script/script_gui.cpp | 4 ++-- src/settings_gui.cpp | 2 +- src/signs_gui.cpp | 4 ++-- src/smallmap_gui.cpp | 2 +- src/station_gui.cpp | 31 +++++++++++++++--------------- src/story_gui.cpp | 2 +- src/subsidy_gui.cpp | 6 +++--- src/terraform_gui.cpp | 12 ++++++------ src/timetable_gui.cpp | 20 +++++++++---------- src/toolbar_gui.cpp | 2 +- src/town_gui.cpp | 6 +++--- src/transparency_gui.cpp | 2 +- src/tree_gui.cpp | 2 +- src/vehicle_gui.cpp | 30 ++++++++++++++--------------- src/video/allegro_v.cpp | 8 +++----- src/video/cocoa/cocoa_v.mm | 8 +++----- src/video/sdl2_v.cpp | 8 +++----- src/video/sdl_v.cpp | 8 +++----- src/video/win32_v.cpp | 8 +++----- src/viewport.cpp | 4 ++-- src/waypoint_gui.cpp | 2 +- src/window.cpp | 36 ++++++++++++++++++++++++++++------- src/window_gui.h | 10 ++++++++-- 51 files changed, 227 insertions(+), 204 deletions(-) diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 4469974c63..555d1a48da 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -229,7 +229,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 && this->selected_slot != INVALID_COMPANY) ShowScriptListWindow((CompanyID)this->selected_slot, _ctrl_pressed); + if (click_count > 1 && this->selected_slot != INVALID_COMPANY) ShowScriptListWindow((CompanyID)this->selected_slot, _fn_pressed); break; } @@ -259,7 +259,7 @@ struct AIConfigWindow : public Window { } case WID_AIC_CHANGE: // choose other AI - ShowScriptListWindow((CompanyID)this->selected_slot, _ctrl_pressed); + ShowScriptListWindow((CompanyID)this->selected_slot, _fn_pressed); break; case WID_AIC_CONFIGURE: // change the settings for an AI diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index aa2069c425..c5d631529b 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -65,7 +65,7 @@ static void PlaceAirport(TileIndex tile) byte airport_type = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->GetIndex(); byte layout = _selected_airport_layout; - bool adjacent = _ctrl_pressed; + bool adjacent = _fn_pressed; auto proc = [=](bool test, StationID to_join) -> bool { if (test) { diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 64707259d3..db8d60e60a 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -582,7 +582,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), _fn_pressed); } else { // toggle renew_keep_length Command::Post("company.renew_keep_length", Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1); @@ -634,9 +634,9 @@ public: if ((item.flags & EngineDisplayFlags::Shaded) == EngineDisplayFlags::None) e = item.engine_id; } - /* If Ctrl is pressed on the left side and we don't have any engines of the selected type, stop autoreplacing. + /* If Fn modifier 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 && _fn_pressed && 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/bridge_gui.cpp b/src/bridge_gui.cpp index fec724bb4c..52f9fbcca7 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -376,7 +376,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 (_fn_pressed && CheckBridgeAvailability(last_bridge_type, bridge_len).Succeeded()) { Command::Post(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE, CcBuildBridge, end, start, transport_type, last_bridge_type, road_rail_type); return; } diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 02e86115e2..f4b9b1576f 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -1620,7 +1620,7 @@ struct BuildVehicleWindow : Window { } this->SelectEngine(e); this->SetDirty(); - if (_ctrl_pressed) { + if (_fn_pressed) { 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/command.cpp b/src/command.cpp index 51ec446e77..2cf95315a6 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -226,7 +226,7 @@ std::tuple CommandHelperBase::InternalPostBefore(Commands cmd, * However, in case of incoming network commands, * map generation or the pause button we do want * to execute. */ - bool estimate_only = _shift_pressed && IsLocalCompany() && !_generating_world && !network_command && !(flags & CMD_NO_EST); + bool estimate_only = _estimate_pressed && IsLocalCompany() && !_generating_world && !network_command && !(flags & CMD_NO_EST); /* We're only sending the command, so don't do * fancy things for 'success'. */ diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 6d354d86bd..4b865925c5 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -497,11 +497,11 @@ struct CompanyFinancesWindow : Window { break; case WID_CF_INCREASE_LOAN: // increase loan - Command::Post(STR_ERROR_CAN_T_BORROW_ANY_MORE_MONEY, _ctrl_pressed ? LoanCommand::Max : LoanCommand::Interval, 0); + Command::Post(STR_ERROR_CAN_T_BORROW_ANY_MORE_MONEY, _fn_pressed ? LoanCommand::Max : LoanCommand::Interval, 0); break; case WID_CF_REPAY_LOAN: // repay loan - Command::Post(STR_ERROR_CAN_T_REPAY_LOAN, _ctrl_pressed ? LoanCommand::Max : LoanCommand::Interval, 0); + Command::Post(STR_ERROR_CAN_T_REPAY_LOAN, _fn_pressed ? LoanCommand::Max : LoanCommand::Interval, 0); break; case WID_CF_INFRASTRUCTURE: // show infrastructure details @@ -1017,7 +1017,7 @@ public: } assert(j < LS_END); - if (_ctrl_pressed) { + if (_fn_pressed) { ToggleBit(this->sel, j); } else { this->sel = 1 << j; @@ -1048,7 +1048,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) || (_fn_pressed && _livery_class[scheme] == this->livery_class && HasBit(_loaded_newgrf_features.used_liveries, scheme))) { Command::Post(scheme, widget == WID_SCL_PRI_COL_DROPDOWN, colour); } } @@ -2510,7 +2510,7 @@ struct CompanyWindow : Window case WID_C_VIEW_HQ: { TileIndex tile = Company::Get((CompanyID)this->window_number)->location_of_HQ; - if (_ctrl_pressed) { + if (_fn_pressed) { ShowExtraViewportWindow(tile); } else { ScrollMainWindowToTile(tile); @@ -2585,7 +2585,7 @@ struct CompanyWindow : Window void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override { - if (Command::Post(STR_ERROR_CAN_T_BUILD_COMPANY_HEADQUARTERS, tile, OBJECT_HQ, 0) && !_shift_pressed) { + if (Command::Post(STR_ERROR_CAN_T_BUILD_COMPANY_HEADQUARTERS, tile, OBJECT_HQ, 0) && !_estimate_pressed) { ResetObjectToPlace(); this->RaiseButtons(); } diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index f523825b85..fa8aec4148 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -144,7 +144,7 @@ static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Veh if (wagon == v) return; - Command::Post(STR_ERROR_CAN_T_MOVE_VEHICLE, v->tile, v->index, wagon == nullptr ? INVALID_VEHICLE : wagon->index, _ctrl_pressed); + Command::Post(STR_ERROR_CAN_T_MOVE_VEHICLE, v->tile, v->index, wagon == nullptr ? INVALID_VEHICLE : wagon->index, _fn_pressed); } static VehicleCellSize _base_block_sizes_depot[VEH_COMPANY_END]; ///< Cell size for vehicle images in the depot view. @@ -560,7 +560,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 = _fn_pressed; this->sel = v->index; this->SetDirty(); @@ -786,7 +786,7 @@ struct DepotWindow : Window { break; case WID_D_LOCATION: - if (_ctrl_pressed) { + if (_fn_pressed) { ShowExtraViewportWindow(this->window_number); } else { ScrollMainWindowToTile(this->window_number); @@ -854,7 +854,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 && _fn_pressed); /* loop through vehicle chain and collect cargoes */ uint num = 0; @@ -900,7 +900,7 @@ struct DepotWindow : Window { */ bool OnVehicleSelect(const Vehicle *v) override { - if (_ctrl_pressed) { + if (_fn_pressed) { /* Share-clone, do not open new viewport, and keep tool active */ Command::Post(STR_ERROR_CAN_T_BUY_TRAIN + v->type, this->window_number, v->index, true); } else { @@ -921,8 +921,8 @@ struct DepotWindow : Window { */ bool OnVehicleSelect(VehicleList::const_iterator begin, VehicleList::const_iterator end) override { - if (!_ctrl_pressed) { - /* If CTRL is not pressed: If all the vehicles in this list have the same orders, then copy orders */ + if (!_fn_pressed) { + /* If Fn 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); })) { @@ -937,7 +937,7 @@ struct DepotWindow : Window { ShowErrorMessage(STR_ERROR_CAN_T_BUY_TRAIN + (*begin)->type, STR_ERROR_CAN_T_CLONE_VEHICLE_LIST, WL_INFO); } } else { - /* If CTRL is pressed: If all the vehicles in this list share orders, then copy orders */ + /* If Fn is pressed: If all the vehicles in this list share orders, then copy orders */ if (AllEqual(begin, end, [](const Vehicle *v1, const Vehicle *v2) { return VehiclesHaveSameEngineList(v1, v2); })) { @@ -1039,7 +1039,7 @@ struct DepotWindow : Window { GetDepotVehiclePtData gdvp = { nullptr, nullptr }; if (this->GetVehicleFromDepotWndPt(pt.x, pt.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 && _fn_pressed) { Command::Post(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE, Vehicle::Get(sel)->tile, Vehicle::Get(sel)->index, true); } else if (gdvp.wagon == nullptr || gdvp.wagon->index != sel) { this->vehicle_over = INVALID_VEHICLE; @@ -1064,7 +1064,7 @@ struct DepotWindow : Window { this->sel = INVALID_VEHICLE; this->SetDirty(); - bool sell_cmd = (v->type == VEH_TRAIN && (widget == WID_D_SELL_CHAIN || _ctrl_pressed)); + bool sell_cmd = (v->type == VEH_TRAIN && (widget == WID_D_SELL_CHAIN || _fn_pressed)); Command::Post(GetCmdSellVehMsg(v->type), v->tile, v->index, sell_cmd, true, INVALID_CLIENT_ID); break; } @@ -1101,10 +1101,10 @@ struct DepotWindow : Window { } } - EventState OnCTRLStateChange() override + EventState OnFnStateChange() override { if (this->sel != INVALID_VEHICLE) { - _cursor.vehchain = _ctrl_pressed; + _cursor.vehchain = _fn_pressed; this->SetWidgetDirty(WID_D_MATRIX); return ES_HANDLED; } diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 76a778622a..21009c69c0 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -213,7 +213,7 @@ struct BuildDocksToolbarWindow : Window { DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile)); TileIndex tile_to = (dir != INVALID_DIAGDIR ? TileAddByDiagDir(tile, ReverseDiagDir(dir)) : tile); - bool adjacent = _ctrl_pressed; + bool adjacent = _fn_pressed; auto proc = [=](bool test, StationID to_join) -> bool { if (test) { return Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), tile, INVALID_STATION, adjacent).Succeeded(); @@ -255,10 +255,10 @@ struct BuildDocksToolbarWindow : Window { GUIPlaceProcDragXY(select_proc, start_tile, end_tile); break; case DDSP_CREATE_WATER: - Command::Post(STR_ERROR_CAN_T_BUILD_CANALS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, (_game_mode == GM_EDITOR && _ctrl_pressed) ? WATER_CLASS_SEA : WATER_CLASS_CANAL, false); + Command::Post(STR_ERROR_CAN_T_BUILD_CANALS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, (_game_mode == GM_EDITOR && _fn_pressed) ? WATER_CLASS_SEA : WATER_CLASS_CANAL, false); break; case DDSP_CREATE_RIVER: - Command::Post(STR_ERROR_CAN_T_PLACE_RIVERS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WATER_CLASS_RIVER, _ctrl_pressed); + Command::Post(STR_ERROR_CAN_T_PLACE_RIVERS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WATER_CLASS_RIVER, _fn_pressed); break; default: break; diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index 908c856199..ee5bb0c44e 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -130,7 +130,7 @@ struct EnginePreviewWindow : Window { Command::Post(this->window_number); FALLTHROUGH; case WID_EP_NO: - if (!_shift_pressed) this->Close(); + if (!_estimate_pressed) this->Close(); break; } } diff --git a/src/game/game_gui.cpp b/src/game/game_gui.cpp index debc06af13..620c4ab0e5 100644 --- a/src/game/game_gui.cpp +++ b/src/game/game_gui.cpp @@ -255,12 +255,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, _fn_pressed); break; } case WID_GSC_CHANGE: // choose other Game Script - ShowScriptListWindow((CompanyID)OWNER_DEITY, _ctrl_pressed); + ShowScriptListWindow((CompanyID)OWNER_DEITY, _fn_pressed); break; case WID_GSC_CONTENT_DOWNLOAD: diff --git a/src/gfx.cpp b/src/gfx.cpp index 1cf74769e6..1ba7185309 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -34,8 +34,10 @@ byte _dirkeys; ///< 1 = left, 2 = up, 4 = right, 8 = down bool _fullscreen; byte _support8bpp; CursorVars _cursor; -bool _ctrl_pressed; ///< Is Ctrl pressed? -bool _shift_pressed; ///< Is Shift pressed? +bool _shift_pressed; ///< Is Shift pressed? +bool _fn_pressed; ///< Is function modifier pressed? +bool _remove_pressed; ///< Is remove modifier pressed? +bool _estimate_pressed; ///< Is estimate modifier pressed? uint16_t _game_speed = 100; ///< Current game-speed; 100 is 1x, 0 is infinite. bool _left_button_down; ///< Is left mouse button pressed? bool _left_button_clicked; ///< Is left mouse button clicked? diff --git a/src/gfx_func.h b/src/gfx_func.h index 9681158768..96c58a517c 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -52,8 +52,10 @@ extern byte _dirkeys; ///< 1 = left, 2 = up, 4 = right, 8 = down extern bool _fullscreen; extern byte _support8bpp; extern CursorVars _cursor; -extern bool _ctrl_pressed; ///< Is Ctrl pressed? -extern bool _shift_pressed; ///< Is Shift pressed? +extern bool _shift_pressed; ///< Is Shift pressed? +extern bool _fn_pressed; ///< Is function modifier pressed? +extern bool _remove_pressed; ///< Is remove modifier pressed? +extern bool _estimate_pressed; ///< Is esitame modifier pressed? extern uint16_t _game_speed; extern bool _left_button_down; @@ -71,7 +73,7 @@ extern Palette _cur_palette; ///< Current palette void HandleToolbarHotkey(int hotkey); void HandleKeypress(uint keycode, char32_t key); void HandleTextInput(const char *str, bool marked = false, const char *caret = nullptr, const char *insert_location = nullptr, const char *replacement_end = nullptr); -void HandleCtrlChanged(); +void HandleModifierKeys(bool shift_pressed, bool ctrl_pressed); void HandleMouseEvents(); void UpdateWindows(); void ChangeGameSpeed(bool enable_fast_forward); diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index d8be74d358..44bf11ebf0 100644 --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -143,7 +143,7 @@ struct GoalListWindow : public Window { default: NOT_REACHED(); } - if (_ctrl_pressed) { + if (_fn_pressed) { ShowExtraViewportWindow(xy); } else { ScrollMainWindowToTile(xy); diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 50e6990fe8..1ede6a3e02 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -757,12 +757,12 @@ public: NOT_REACHED(); } if (v) { - if (_ctrl_pressed && this->grouping == GB_SHARED_ORDERS) { + if (_fn_pressed && this->grouping == GB_SHARED_ORDERS) { ShowOrdersWindow(v); } else { this->vehicle_sel = v->index; - if (_ctrl_pressed && this->grouping == GB_NONE) { + if (_fn_pressed && this->grouping == GB_NONE) { /* * It only makes sense to select a group if not using shared orders * since two vehicles sharing orders can be from different groups. @@ -818,7 +818,7 @@ public: case WID_GL_REPLACE_PROTECTION: { const Group *g = Group::GetIfValid(this->vli.index); if (g != nullptr) { - Command::Post(this->vli.index, GroupFlags::GF_REPLACE_PROTECTION, !HasBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION), _ctrl_pressed); + Command::Post(this->vli.index, GroupFlags::GF_REPLACE_PROTECTION, !HasBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION), _fn_pressed); } break; } @@ -861,7 +861,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, _fn_pressed || this->grouping == GB_SHARED_ORDERS, VehicleListIdentifier{}); this->vehicle_sel = INVALID_VEHICLE; this->group_over = INVALID_GROUP; @@ -878,7 +878,7 @@ public: auto it = this->group_sb->GetScrolledItemFromWidget(this->groups, pt.y, this, WID_GL_LIST_GROUP); GroupID new_g = it == this->groups.end() ? NEW_GROUP : (*it)->index; - Command::Post(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE, new_g == NEW_GROUP ? CcAddVehicleNewGroup : nullptr, new_g, vindex, _ctrl_pressed || this->grouping == GB_SHARED_ORDERS, VehicleListIdentifier{}); + Command::Post(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE, new_g == NEW_GROUP ? CcAddVehicleNewGroup : nullptr, new_g, vindex, _fn_pressed || this->grouping == GB_SHARED_ORDERS, VehicleListIdentifier{}); break; } diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index d3127ef1ae..2ec615c73c 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -1080,7 +1080,7 @@ public: case WID_IV_GOTO: { Industry *i = Industry::Get(this->window_number); - if (_ctrl_pressed) { + if (_fn_pressed) { ShowExtraViewportWindow(i->location.GetCenterTile()); } else { ScrollMainWindowToTile(i->location.GetCenterTile()); @@ -1778,7 +1778,7 @@ public: case WID_ID_INDUSTRY_LIST: { auto it = this->vscroll->GetScrolledItemFromWidget(this->industries, pt.y, this, WID_ID_INDUSTRY_LIST, WidgetDimensions::scaled.framerect.top); if (it != this->industries.end()) { - if (_ctrl_pressed) { + if (_fn_pressed) { ShowExtraViewportWindow((*it)->location.tile); } else { ScrollMainWindowToTile((*it)->location.tile); diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index 2ffe2d4097..e08023a219 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -333,7 +333,7 @@ struct SelectGameWindow : public Window { switch (widget) { case WID_SGI_GENERATE_GAME: - if (_ctrl_pressed) { + if (_fn_pressed) { StartNewGameWithoutGUI(GENERATE_NEW_SEED); } else { ShowGenerateLandscape(); diff --git a/src/league_gui.cpp b/src/league_gui.cpp index de02cfe8c2..f8d2148998 100644 --- a/src/league_gui.cpp +++ b/src/league_gui.cpp @@ -244,7 +244,7 @@ static void HandleLinkClick(Link link) default: NOT_REACHED(); } - if (_ctrl_pressed) { + if (_fn_pressed) { ShowExtraViewportWindow(xy); } else { ScrollMainWindowToTile(xy); diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 64e1d02840..6cc74d93ee 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -344,7 +344,7 @@ public: { switch (widget) { case WID_LI_LOCATION: - if (_ctrl_pressed) { + if (_fn_pressed) { ShowExtraViewportWindow(this->tile); } else { ScrollMainWindowToTile(this->tile); diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index a228bedb82..68c9e458f8 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -1082,7 +1082,7 @@ struct NetworkStartServerWindow : public Window { case WID_NSS_GENERATE_GAME: // Start game if (!CheckServerName()) return; _is_network_server = true; - if (_ctrl_pressed) { + if (_fn_pressed) { StartNewGameWithoutGUI(GENERATE_NEW_SEED); } else { ShowGenerateLandscape(); diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index 6bb16255bb..4841ca34b2 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -1007,7 +1007,7 @@ struct SpriteAlignerWindow : Window { if (this->offs_start_map.count(this->current_sprite) == 0) { this->offs_start_map[this->current_sprite] = XyOffs(spr->x_offs, spr->y_offs); } - int amt = ScaleByZoom(_ctrl_pressed ? 8 : 1, SpriteAlignerWindow::zoom); + int amt = ScaleByZoom(_fn_pressed ? 8 : 1, SpriteAlignerWindow::zoom); switch (widget) { /* Move eight units at a time if ctrl is pressed. */ case WID_SA_UP: spr->y_offs -= amt; break; diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 01479f1872..7309dad7c4 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -510,7 +510,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 (_fn_pressed) { if (tile1 != INVALID_TILE) ShowExtraViewportWindow(tile1); if (tile2 != INVALID_TILE) ShowExtraViewportWindow(tile2); } else { diff --git a/src/object_gui.cpp b/src/object_gui.cpp index a72edbe4ff..0ee70b7df6 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -553,7 +553,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, (_fn_pressed ? true : false)); } void OnPlaceObjectAbort() override diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 62780c4850..a914d27623 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -388,7 +388,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) 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 (_fn_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE)); return order; } @@ -398,7 +398,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) 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 != _fn_pressed) order.SetNonStopType(ONSF_NO_STOP_AT_ANY_STATION); return order; } @@ -429,7 +429,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) } if (st->facilities & facil) { order.MakeGoToStation(st->index); - if (_ctrl_pressed) order.SetLoadType(OLF_FULL_LOAD_ANY); + if (_fn_pressed) order.SetLoadType(OLF_FULL_LOAD_ANY); if (_settings_client.gui.new_nonstop && v->IsGroundVehicle()) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS); order.SetStopLocation(v->type == VEH_TRAIN ? (OrderStopLocation)(_settings_client.gui.stop_location) : OSL_PLATFORM_FAR_END); return order; @@ -689,16 +689,16 @@ private: /** * Handle the click on the skip button. - * If ctrl is pressed, skip to selected order, else skip to current order + 1 + * If Fn is pressed, skip to selected order, else skip to current order + 1 */ 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 (_fn_pressed && this->vehicle->cur_implicit_order_index == this->OrderGetSel()) return; if (this->vehicle->GetNumOrders() <= 1) return; - Command::Post(_ctrl_pressed ? STR_ERROR_CAN_T_SKIP_TO_ORDER : STR_ERROR_CAN_T_SKIP_ORDER, - this->vehicle->tile, this->vehicle->index, _ctrl_pressed ? this->OrderGetSel() : ((this->vehicle->cur_implicit_order_index + 1) % this->vehicle->GetNumOrders())); + Command::Post(_fn_pressed ? STR_ERROR_CAN_T_SKIP_TO_ORDER : STR_ERROR_CAN_T_SKIP_ORDER, + this->vehicle->tile, this->vehicle->index, _fn_pressed ? this->OrderGetSel() : ((this->vehicle->cur_implicit_order_index + 1) % this->vehicle->GetNumOrders())); } /** @@ -717,7 +717,7 @@ private: /** * Handle the click on the 'stop sharing' button. - * If 'End of Shared Orders' isn't selected, do nothing. If Ctrl is pressed, call OrderClick_Delete and exit. + * If 'End of Shared Orders' isn't selected, do nothing. If Fn is pressed, call OrderClick_Delete and exit. * To stop sharing this vehicle order list, we copy the orders of a vehicle that share this order list. That way we * exit the group of shared vehicles while keeping the same order list. */ @@ -725,8 +725,8 @@ 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 Fn is pressed, delete the order list as if we clicked the 'Delete' button. */ + if (_fn_pressed) { this->OrderClick_Delete(); return; } @@ -741,13 +741,13 @@ private: /** * Handle the click on the refit button. - * If ctrl is pressed, cancel refitting, else show the refit window. + * If Fn is pressed, cancel refitting, else show the refit window. * @param i Selected refit command. * @param auto_refit Select refit for auto-refitting. */ void OrderClick_Refit(int i, bool auto_refit) { - if (_ctrl_pressed) { + if (_fn_pressed) { /* Cancel refitting */ Command::Post(this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), CARGO_NO_REFIT); } else { @@ -1023,7 +1023,7 @@ public: this->SetWidgetLoweredState(WID_O_NON_STOP, order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS); } /* Disable refit button if the order is no 'always go' order. - * However, keep the service button enabled for refit-orders to allow clearing refits (without knowing about ctrl). */ + * However, keep the service button enabled for refit-orders to allow clearing refits (without knowing about Fn). */ this->SetWidgetDisabledState(WID_O_REFIT, (order->GetDepotOrderType() & ODTFB_SERVICE) || (order->GetDepotActionType() & ODATFB_HALT) || (!this->can_do_refit && !order->IsRefit())); @@ -1178,7 +1178,7 @@ public: VehicleOrderID sel = this->GetOrderFromPt(pt.y); - if (_ctrl_pressed && sel < this->vehicle->GetNumOrders()) { + if (_fn_pressed && sel < this->vehicle->GetNumOrders()) { TileIndex xy = this->vehicle->GetOrder(sel)->GetLocation(this->vehicle); if (xy != INVALID_TILE) ScrollMainWindowToTile(xy); return; @@ -1463,9 +1463,9 @@ public: /* v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet. * We disallow copying orders of other vehicles if we already have at least one order entry * 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 + * Obviously if you press Fn 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 = _fn_pressed || this->goto_type == OPOS_SHARE; if (this->vehicle->GetNumOrders() != 0 && !share_order) return false; if (Command::Post(share_order ? STR_ERROR_CAN_T_SHARE_ORDER_LIST : STR_ERROR_CAN_T_COPY_ORDER_LIST, @@ -1484,11 +1484,11 @@ 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 = _fn_pressed || this->goto_type == OPOS_SHARE; if (this->vehicle->GetNumOrders() != 0 && !share_order) return false; if (!share_order) { - /* If CTRL is not pressed: If all the vehicles in this list have the same orders, then copy orders */ + /* If Fn 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 VehiclesHaveSameOrderList(v1, v2); })) { @@ -1497,7 +1497,7 @@ public: ShowErrorMessage(STR_ERROR_CAN_T_COPY_ORDER_LIST, STR_ERROR_CAN_T_COPY_ORDER_VEHICLE_LIST, WL_INFO); } } else { - /* If CTRL is pressed: If all the vehicles in this list share orders, then copy orders */ + /* If Fn is pressed: If all the vehicles in this list share orders, then copy orders */ if (AllEqual(begin, end, [](const Vehicle *v1, const Vehicle *v2) { return v1->FirstShared() == v2->FirstShared(); })) { diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 190716bd83..fe83536a63 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1039,7 +1039,7 @@ CommandCost CmdBuildTrainDepot(DoCommandFlag flags, TileIndex tile, RailType rai * @param track track-orientation * @param sigtype type of the signal * @param sigvar variant of signal type (normal/semaphore) - * @param ctrl_pressed true = override signal/semaphore, or pre/exit/combo signal or toggle variant (CTRL-toggle) + * @param fn_pressed true = override signal/semaphore, or pre/exit/combo signal or toggle variant (Fn-toggle) * @param convert_signal convert the present signal type and variant * @param cycle_start start cycle from this signal type * @param cycle_stop wrap around after this signal type @@ -1049,12 +1049,12 @@ CommandCost CmdBuildTrainDepot(DoCommandFlag flags, TileIndex tile, RailType rai * @return the cost of this operation or an error * @todo p2 should be replaced by two bits for "along" and "against" the track. */ -CommandCost CmdBuildSingleSignal(DoCommandFlag flags, TileIndex tile, Track track, SignalType sigtype, SignalVariant sigvar, bool convert_signal, bool skip_existing_signals, bool ctrl_pressed, SignalType cycle_start, SignalType cycle_stop, uint8_t num_dir_cycle, byte signals_copy) +CommandCost CmdBuildSingleSignal(DoCommandFlag flags, TileIndex tile, Track track, SignalType sigtype, SignalVariant sigvar, bool convert_signal, bool skip_existing_signals, bool fn_pressed, SignalType cycle_start, SignalType cycle_stop, uint8_t num_dir_cycle, byte signals_copy) { if (sigtype > SIGTYPE_LAST || sigvar > SIG_SEMAPHORE) return CMD_ERROR; if (cycle_start > cycle_stop || cycle_stop > SIGTYPE_LAST) return CMD_ERROR; - if (ctrl_pressed) sigvar = (SignalVariant)(sigvar ^ SIG_SEMAPHORE); + if (fn_pressed) sigvar = (SignalVariant)(sigvar ^ SIG_SEMAPHORE); /* You can only build signals on plain rail tiles, and the selected track must exist */ if (!ValParamTrackOrientation(track) || !IsPlainRailTile(tile) || @@ -1087,7 +1087,7 @@ CommandCost CmdBuildSingleSignal(DoCommandFlag flags, TileIndex tile, Track trac } else if (convert_signal) { /* convert button pressed */ - if (ctrl_pressed || GetSignalVariant(tile, track) != sigvar) { + if (fn_pressed || GetSignalVariant(tile, track) != sigvar) { /* it costs money to change signal variant (light or semaphore) */ cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_SIGNALS] + _price[PR_CLEAR_SIGNALS]); } else { @@ -1133,7 +1133,7 @@ CommandCost CmdBuildSingleSignal(DoCommandFlag flags, TileIndex tile, Track trac } else { if (convert_signal) { /* convert signal button pressed */ - if (ctrl_pressed) { + if (fn_pressed) { /* toggle the present signal variant: SIG_ELECTRIC <-> SIG_SEMAPHORE */ SetSignalVariant(tile, track, (GetSignalVariant(tile, track) == SIG_ELECTRIC) ? SIG_SEMAPHORE : SIG_ELECTRIC); /* Query current signal type so the check for PBS signals below works. */ @@ -1147,7 +1147,7 @@ CommandCost CmdBuildSingleSignal(DoCommandFlag flags, TileIndex tile, Track trac } } - } else if (ctrl_pressed) { + } else if (fn_pressed) { /* cycle between cycle_start and cycle_end */ sigtype = (SignalType)(GetSignalType(tile, track) + 1); diff --git a/src/rail_cmd.h b/src/rail_cmd.h index 38a5e5c30a..5230f5285a 100644 --- a/src/rail_cmd.h +++ b/src/rail_cmd.h @@ -20,7 +20,7 @@ CommandCost CmdRemoveRailroadTrack(DoCommandFlag flags, TileIndex end_tile, Tile CommandCost CmdBuildSingleRail(DoCommandFlag flags, TileIndex tile, RailType railtype, Track track, bool auto_remove_signals); CommandCost CmdRemoveSingleRail(DoCommandFlag flags, TileIndex tile, Track track); CommandCost CmdBuildTrainDepot(DoCommandFlag flags, TileIndex tile, RailType railtype, DiagDirection dir); -CommandCost CmdBuildSingleSignal(DoCommandFlag flags, TileIndex tile, Track track, SignalType sigtype, SignalVariant sigvar, bool convert_signal, bool skip_existing_signals, bool ctrl_pressed, SignalType cycle_start, SignalType cycle_stop, uint8_t num_dir_cycle, byte signals_copy); +CommandCost CmdBuildSingleSignal(DoCommandFlag flags, TileIndex tile, Track track, SignalType sigtype, SignalVariant sigvar, bool convert_signal, bool skip_existing_signals, bool fn_pressed, SignalType cycle_start, SignalType cycle_stop, uint8_t num_dir_cycle, byte signals_copy); CommandCost CmdRemoveSingleSignal(DoCommandFlag flags, TileIndex tile, Track track); CommandCost CmdConvertRail(DoCommandFlag flags, TileIndex tile, TileIndex area_start, RailType totype, bool diagonal); CommandCost CmdBuildSignalTrack(DoCommandFlag flags, TileIndex tile, TileIndex end_tile, Track track, SignalType sigtype, SignalVariant sigvar, bool mode, bool autofill, bool minimise_gaps, byte signal_density); diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 05a641fa81..ad8a3613a1 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -204,7 +204,7 @@ static void PlaceRail_Station(TileIndex tile) RailType rt = _cur_railtype; byte numtracks = _settings_client.gui.station_numtracks; byte platlength = _settings_client.gui.station_platlength; - bool adjacent = _ctrl_pressed; + bool adjacent = _fn_pressed; auto proc = [=](bool test, StationID to_join) -> bool { if (test) { @@ -246,11 +246,11 @@ static void GenericPlaceSignals(TileIndex tile) if (FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr) { /* signal GUI is used */ Command::Post(_convert_signal_button ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL, - tile, track, _cur_signal_type, _cur_signal_variant, _convert_signal_button, false, _ctrl_pressed, cycle_start, SIGTYPE_LAST, 0, 0); + tile, track, _cur_signal_type, _cur_signal_variant, _convert_signal_button, false, _fn_pressed, cycle_start, SIGTYPE_LAST, 0, 0); } else { SignalVariant sigvar = TimerGameCalendar::year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC; Command::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL, - tile, track, _settings_client.gui.default_signal_type, sigvar, false, false, _ctrl_pressed, cycle_start, SIGTYPE_LAST, 0, 0); + tile, track, _settings_client.gui.default_signal_type, sigvar, false, false, _fn_pressed, cycle_start, SIGTYPE_LAST, 0, 0); } } @@ -297,11 +297,11 @@ static void ToggleRailButton_Remove(Window *w) } /** - * Updates the Remove button because of Ctrl state change + * Updates the Remove button because of remove modifer state change * @param w window the button belongs to * @return true iff the remove button was changed */ -static bool RailToolbar_CtrlChanged(Window *w) +static bool RailToolbar_RemoveChanged(Window *w) { if (w->IsWidgetDisabled(WID_RAT_REMOVE)) return false; @@ -393,13 +393,13 @@ static void HandleAutoSignalPlacement() * in a network game can specify their own signal density */ if (_remove_button_clicked) { 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, _fn_pressed); } 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, _fn_pressed, !_settings_client.gui.drag_signals_fixed_distance, _settings_client.gui.drag_signals_density); } } @@ -596,7 +596,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 != _ctrl_pressed) { + if (started != _fn_pressed) { ShowSignalBuilder(this); } break; @@ -624,7 +624,7 @@ struct BuildRailToolbarWindow : Window { default: NOT_REACHED(); } this->UpdateRemoveWidgetStatus(widget); - if (_ctrl_pressed) RailToolbar_CtrlChanged(this); + if (_remove_pressed) RailToolbar_RemoveChanged(this); } EventState OnHotkey(int hotkey) override @@ -723,7 +723,7 @@ struct BuildRailToolbarWindow : Window { break; case DDSP_CONVERT_RAIL: - Command::Post(STR_ERROR_CAN_T_CONVERT_RAIL, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, _cur_railtype, _ctrl_pressed); + Command::Post(STR_ERROR_CAN_T_CONVERT_RAIL, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, _cur_railtype, _fn_pressed); break; case DDSP_REMOVE_STATION: @@ -731,7 +731,7 @@ struct BuildRailToolbarWindow : Window { if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) { /* Station */ if (_remove_button_clicked) { - bool keep_rail = !_ctrl_pressed; + bool keep_rail = !_fn_pressed; Command::Post(STR_ERROR_CAN_T_REMOVE_PART_OF_STATION, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, keep_rail); } else { HandleStationPlacement(start_tile, end_tile); @@ -739,12 +739,12 @@ struct BuildRailToolbarWindow : Window { } else { /* Waypoint */ if (_remove_button_clicked) { - bool keep_rail = !_ctrl_pressed; + bool keep_rail = !_fn_pressed; Command::Post(STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, keep_rail); } else { TileArea ta(start_tile, end_tile); Axis axis = select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y; - bool adjacent = _ctrl_pressed; + bool adjacent = _fn_pressed; uint16_t waypoint_type = _cur_waypoint_type; auto proc = [=](bool test, StationID to_join) -> bool { @@ -786,10 +786,10 @@ struct BuildRailToolbarWindow : Window { VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile); } - EventState OnCTRLStateChange() override + EventState OnRemoveStateChange() 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; + /* do not toggle Remove button by remove modifier when placing station */ + if (!this->IsWidgetLowered(WID_RAT_BUILD_STATION) && !this->IsWidgetLowered(WID_RAT_BUILD_WAYPOINT) && RailToolbar_RemoveChanged(this)) return ES_HANDLED; return ES_NOT_HANDLED; } @@ -912,7 +912,7 @@ static void HandleStationPlacement(TileIndex start, TileIndex end) RailStationGUISettings params = _railstation; RailType rt = _cur_railtype; - bool adjacent = _ctrl_pressed; + bool adjacent = _fn_pressed; auto proc = [=](bool test, StationID to_join) -> bool { if (test) { diff --git a/src/road_gui.cpp b/src/road_gui.cpp index adb88f33e6..220966f19e 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -285,11 +285,11 @@ static void ToggleRoadButton_Remove(Window *w) } /** - * Updates the Remove button because of Ctrl state change + * Updates the Remove button because of remove modifer state change * @param w window the button belongs to * @return true iff the remove button was changed */ -static bool RoadToolbar_CtrlChanged(Window *w) +static bool RoadToolbar_RemoveChanged(Window *w) { if (w->IsWidgetDisabled(WID_ROT_REMOVE)) return false; @@ -549,7 +549,7 @@ struct BuildRoadToolbarWindow : Window { default: NOT_REACHED(); } this->UpdateOptionWidgetStatus((RoadToolbarWidgets)widget); - if (_ctrl_pressed) RoadToolbar_CtrlChanged(this); + if (_remove_pressed) RoadToolbar_RemoveChanged(this); } EventState OnHotkey(int hotkey) override @@ -709,9 +709,9 @@ struct BuildRoadToolbarWindow : Window { if (this->IsWidgetLowered(WID_ROT_BUS_STATION) && GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), ROADSTOP_BUS, _cur_roadtype)) { if (_remove_button_clicked) { TileArea ta(start_tile, end_tile); - Command::Post(this->rti->strings.err_remove_station[ROADSTOP_BUS], CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, ROADSTOP_BUS, _ctrl_pressed); + Command::Post(this->rti->strings.err_remove_station[ROADSTOP_BUS], CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, ROADSTOP_BUS, _fn_pressed); } else { - PlaceRoadStop(start_tile, end_tile, ROADSTOP_BUS, _ctrl_pressed, _cur_roadtype, this->rti->strings.err_build_station[ROADSTOP_BUS]); + PlaceRoadStop(start_tile, end_tile, ROADSTOP_BUS, _fn_pressed, _cur_roadtype, this->rti->strings.err_build_station[ROADSTOP_BUS]); } } break; @@ -721,9 +721,9 @@ struct BuildRoadToolbarWindow : Window { if (this->IsWidgetLowered(WID_ROT_TRUCK_STATION) && GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), ROADSTOP_TRUCK, _cur_roadtype)) { if (_remove_button_clicked) { TileArea ta(start_tile, end_tile); - Command::Post(this->rti->strings.err_remove_station[ROADSTOP_TRUCK], CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, ROADSTOP_TRUCK, _ctrl_pressed); + Command::Post(this->rti->strings.err_remove_station[ROADSTOP_TRUCK], CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, ROADSTOP_TRUCK, _fn_pressed); } else { - PlaceRoadStop(start_tile, end_tile, ROADSTOP_TRUCK, _ctrl_pressed, _cur_roadtype, this->rti->strings.err_build_station[ROADSTOP_TRUCK]); + PlaceRoadStop(start_tile, end_tile, ROADSTOP_TRUCK, _fn_pressed, _cur_roadtype, this->rti->strings.err_build_station[ROADSTOP_TRUCK]); } } break; @@ -741,9 +741,9 @@ struct BuildRoadToolbarWindow : Window { VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile); } - EventState OnCTRLStateChange() override + EventState OnRemoveStateChange() override { - if (RoadToolbar_CtrlChanged(this)) return ES_HANDLED; + if (RoadToolbar_RemoveChanged(this)) return ES_HANDLED; return ES_NOT_HANDLED; } diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index 6f2d15da49..e83a3616b9 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -1042,12 +1042,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), _fn_pressed); } switch (widget) { case WID_SCRD_SCRIPT_GAME: - ChangeToScript(OWNER_DEITY, _ctrl_pressed); + ChangeToScript(OWNER_DEITY, _fn_pressed); break; case WID_SCRD_RELOAD_TOGGLE: diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index f335d10a18..bfd59e43bb 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -785,7 +785,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 (!_fn_pressed) 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 848cb8e529..a029454cec 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -489,7 +489,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 (_fn_pressed) { ShowExtraViewportWindow(tile); } else { ScrollMainWindowToTile(tile); @@ -565,7 +565,7 @@ void HandleClickOnSign(const Sign *si) /* If we can't rename the sign, don't even open the rename GUI. */ if (!CompanyCanRenameSign(si)) return; - if (_ctrl_pressed && (si->owner == _local_company || (si->owner == OWNER_DEITY && _game_mode == GM_EDITOR))) { + if (_fn_pressed && (si->owner == _local_company || (si->owner == OWNER_DEITY && _game_mode == GM_EDITOR))) { RenameSign(si->index, ""); return; } diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 3df7ab6e14..23d1e2cec5 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -792,7 +792,7 @@ protected: */ void SelectLegendItem(int click_pos, LegendAndColour *legend, int end_legend_item, int begin_legend_item = 0) { - if (_ctrl_pressed) { + if (_fn_pressed) { /* 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 07553fbcd7..d104d90147 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -84,7 +84,7 @@ template void FindStationsAroundSelection() { /* With distant join we don't know which station will be selected, so don't show any */ - if (_ctrl_pressed) { + if (_fn_pressed) { SetViewportCatchmentSpecializedStation(nullptr, true); return; } @@ -125,11 +125,11 @@ void FindStationsAroundSelection() */ void CheckRedrawStationCoverage(const Window *w) { - /* Test if ctrl state changed */ - static bool _last_ctrl_pressed; - if (_ctrl_pressed != _last_ctrl_pressed) { + /* Test if fn modifer state changed */ + static bool _last_fn_pressed; + if (_fn_pressed != _last_fn_pressed) { _thd.dirty = 0xff; - _last_ctrl_pressed = _ctrl_pressed; + _last_fn_pressed = _fn_pressed; } if (_thd.dirty & 1) { @@ -145,10 +145,10 @@ void CheckRedrawStationCoverage(const Window *w) void CheckRedrawWaypointCoverage(const Window *) { /* Test if ctrl state changed */ - static bool _last_ctrl_pressed; - if (_ctrl_pressed != _last_ctrl_pressed) { + static bool _last_fn_pressed; + if (_fn_pressed != _last_fn_pressed) { _thd.dirty = 0xff; - _last_ctrl_pressed = _ctrl_pressed; + _last_fn_pressed = _fn_pressed; } if (_thd.dirty & 1) { @@ -544,7 +544,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 (_fn_pressed) { ShowExtraViewportWindow(st->xy); } else { ScrollMainWindowToTile(st->xy); @@ -557,7 +557,7 @@ public: case WID_STL_BUS: case WID_STL_AIRPLANE: case WID_STL_SHIP: - if (_ctrl_pressed) { + if (_fn_pressed) { ToggleBit(this->filter.facilities, widget - WID_STL_TRAIN); this->ToggleWidgetLoweredState(widget); } else { @@ -604,7 +604,7 @@ public: break; case WID_STL_NOCARGOWAITING: - if (_ctrl_pressed) { + if (_fn_pressed) { this->filter.include_empty = !this->filter.include_empty; this->ToggleWidgetLoweredState(WID_STL_NOCARGOWAITING); } else { @@ -626,8 +626,9 @@ public: /* Determine the selected cargo type */ const CargoSpec *cs = _sorted_cargo_specs[widget - WID_STL_CARGOSTART]; - if (_ctrl_pressed) { + if (_fn_pressed) { ToggleBit(this->filter.cargoes, cs->Index()); + this->ToggleWidgetLoweredState(widget); } else { for (uint i = 0; i < _sorted_standard_cargo_specs.size(); i++) { @@ -1901,7 +1902,7 @@ struct StationViewWindow : public Window { void HandleCargoWaitingClick(int row) { if (row < 0 || (uint)row >= this->displayed_rows.size()) return; - if (_ctrl_pressed) { + if (_fn_pressed) { this->scroll_to_row = row; } else { RowDisplay &display = this->displayed_rows[row]; @@ -1926,7 +1927,7 @@ struct StationViewWindow : public Window { break; case WID_SV_LOCATION: - if (_ctrl_pressed) { + if (_fn_pressed) { ShowExtraViewportWindow(Station::Get(this->window_number)->xy); } else { ScrollMainWindowToTile(Station::Get(this->window_number)->xy); @@ -2423,7 +2424,7 @@ static bool StationJoinerNeeded(TileArea ta, const StationPickerCmdProc &proc) } /* only show the popup, if we press ctrl */ - if (!_ctrl_pressed) return false; + if (!_fn_pressed) return false; /* Now check if we could build there */ if (!proc(true, INVALID_STATION)) return false; diff --git a/src/story_gui.cpp b/src/story_gui.cpp index c986042cb7..14490e0a53 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -542,7 +542,7 @@ protected: break; case SPET_LOCATION: - if (_ctrl_pressed) { + if (_fn_pressed) { ShowExtraViewportWindow((TileIndex)pe.referenced_id); } else { ScrollMainWindowToTile((TileIndex)pe.referenced_id); diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index 9e72fe203e..7db7c4d53e 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -82,8 +82,8 @@ struct SubsidyListWindow : Window { default: NOT_REACHED(); } - if (_ctrl_pressed || !ScrollMainWindowToTile(xy)) { - if (_ctrl_pressed) ShowExtraViewportWindow(xy); + if (_fn_pressed || !ScrollMainWindowToTile(xy)) { + if (_fn_pressed) ShowExtraViewportWindow(xy); /* otherwise determine dst coordinate for subsidy and scroll to it */ switch (s->dst_type) { @@ -92,7 +92,7 @@ struct SubsidyListWindow : Window { default: NOT_REACHED(); } - if (_ctrl_pressed) { + if (_fn_pressed) { ShowExtraViewportWindow(xy); } else { ScrollMainWindowToTile(xy); diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index e589c4f20e..d7b149142b 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -63,7 +63,7 @@ static void GenerateDesertArea(TileIndex end, TileIndex start) TileArea ta(start, end); for (TileIndex tile : ta) { - SetTropicZone(tile, (_ctrl_pressed) ? TROPICZONE_NORMAL : TROPICZONE_DESERT); + SetTropicZone(tile, (_remove_pressed) ? TROPICZONE_NORMAL : TROPICZONE_DESERT); Command::Post(tile); MarkTileDirtyByTile(tile); } @@ -119,16 +119,16 @@ bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_t switch (proc) { case DDSP_DEMOLISH_AREA: - Command::Post(STR_ERROR_CAN_T_CLEAR_THIS_AREA, CcPlaySound_EXPLOSION, end_tile, start_tile, _ctrl_pressed); + Command::Post(STR_ERROR_CAN_T_CLEAR_THIS_AREA, CcPlaySound_EXPLOSION, end_tile, start_tile, _fn_pressed); break; case DDSP_RAISE_AND_LEVEL_AREA: - Command::Post(STR_ERROR_CAN_T_RAISE_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LM_RAISE); + Command::Post(STR_ERROR_CAN_T_RAISE_LAND_HERE, CcTerraform, end_tile, start_tile, _fn_pressed, LM_RAISE); break; case DDSP_LOWER_AND_LEVEL_AREA: - Command::Post(STR_ERROR_CAN_T_LOWER_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LM_LOWER); + Command::Post(STR_ERROR_CAN_T_LOWER_LAND_HERE, CcTerraform, end_tile, start_tile, _fn_pressed, LM_LOWER); break; case DDSP_LEVEL_AREA: - Command::Post(STR_ERROR_CAN_T_LEVEL_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LM_LEVEL); + Command::Post(STR_ERROR_CAN_T_LEVEL_LAND_HERE, CcTerraform, end_tile, start_tile, _fn_pressed, LM_LEVEL); break; case DDSP_CREATE_ROCKS: GenerateRockyArea(end_tile, start_tile); @@ -284,7 +284,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, (_fn_pressed ? true : false)); break; } } diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 961e25eda2..c715c2ce01 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -204,8 +204,8 @@ struct TimetableWindow : Window { const Vehicle *vehicle; ///< Vehicle monitored by the window. bool show_expected; ///< Whether we show expected arrival or scheduled. Scrollbar *vscroll; ///< The scrollbar. - bool set_start_date_all; ///< Set start date using minutes text entry for all timetable entries (ctrl-click) action. - bool change_timetable_all; ///< Set wait time or speed for all timetable entries (ctrl-click) action. + bool set_start_date_all; ///< Set start date using minutes text entry for all timetable entries (Fn-click) action. + bool change_timetable_all; ///< Set wait time or speed for all timetable entries (Fn-click) action. TimetableWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc), @@ -646,10 +646,10 @@ struct TimetableWindow : Window { case WID_VT_START_DATE: // Change the date that the timetable starts. if (_settings_client.gui.timetable_mode == TimetableMode::Seconds) { this->query_widget = WID_VT_START_DATE; - this->change_timetable_all = _ctrl_pressed; + this->change_timetable_all = _fn_pressed; ShowQueryString(STR_EMPTY, STR_TIMETABLE_START_SECONDS_QUERY, 6, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED); } else { - ShowSetDateWindow(this, v->index, TimerGameEconomy::date, TimerGameEconomy::year, TimerGameEconomy::year + MAX_TIMETABLE_START_YEARS, ChangeTimetableStartCallback, reinterpret_cast(static_cast(_ctrl_pressed))); + ShowSetDateWindow(this, v->index, TimerGameEconomy::date, TimerGameEconomy::year, TimerGameEconomy::year + MAX_TIMETABLE_START_YEARS, ChangeTimetableStartCallback, reinterpret_cast(static_cast(_fn_pressed))); } break; @@ -673,7 +673,7 @@ struct TimetableWindow : Window { } } - this->change_timetable_all = _ctrl_pressed && (order != nullptr); + this->change_timetable_all = _fn_pressed && (order != nullptr); ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME, 31, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED); break; } @@ -694,14 +694,14 @@ struct TimetableWindow : Window { } } - this->change_timetable_all = _ctrl_pressed && (order != nullptr); + this->change_timetable_all = _fn_pressed && (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 (_fn_pressed) { 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); @@ -711,7 +711,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 (_fn_pressed) { 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); @@ -720,11 +720,11 @@ 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, _fn_pressed); break; case WID_VT_AUTOFILL: { // Autofill the timetable. - Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, !HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE), _ctrl_pressed); + Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, !HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE), _fn_pressed); break; } diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index f1be2f9c7a..9355fa3a38 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -1133,7 +1133,7 @@ static CallBackFunction MenuClickHelp(int index) case 0: return PlaceLandBlockInfo(); case 1: ShowHelpWindow(); break; case 2: IConsoleSwitch(); break; - case 3: ShowScriptDebugWindow(INVALID_COMPANY, _ctrl_pressed); break; + case 3: ShowScriptDebugWindow(INVALID_COMPANY, _fn_pressed); break; case 4: ShowScreenshotWindow(); break; case 5: ShowFramerateWindow(); break; case 6: ShowAboutWindow(); break; diff --git a/src/town_gui.cpp b/src/town_gui.cpp index d3d1244a9e..18371d2946 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -493,7 +493,7 @@ public: { switch (widget) { case WID_TV_CENTER_VIEW: // scroll to location - if (_ctrl_pressed) { + if (_fn_pressed) { ShowExtraViewportWindow(this->town->xy); } else { ScrollMainWindowToTile(this->town->xy); @@ -958,7 +958,7 @@ public: const Town *t = *it; assert(t != nullptr); - if (_ctrl_pressed) { + if (_fn_pressed) { ShowExtraViewportWindow(t->xy); } else { ScrollMainWindowToTile(t->xy); @@ -1217,7 +1217,7 @@ public: tile, this->town_size, this->city, this->town_layout, random, townnameparts, name); /* Rerandomise name, if success and no cost-estimation. */ - if (success && !_shift_pressed) this->RandomTownName(); + if (success && !_estimate_pressed) this->RandomTownName(); } void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index d0379ad801..bcb81fe18d 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -72,7 +72,7 @@ public: void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget >= WID_TT_BEGIN && widget < WID_TT_END) { - if (_ctrl_pressed) { + if (_fn_pressed) { /* toggle the bit of the transparencies lock variable */ ToggleTransparencyLock((TransparencyOption)(widget - WID_TT_BEGIN)); this->SetDirty(); diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index 4a91853289..b3684263b2 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -239,7 +239,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, _fn_pressed); } } diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index de0a11f11d..86a454571a 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1155,7 +1155,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 (_fn_pressed) this->num_vehicles = UINT8_MAX; break; } FALLTHROUGH; @@ -1178,7 +1178,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 (!_fn_pressed) { SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this); } else { /* The vehicle selection has changed. */ @@ -2074,7 +2074,7 @@ public: case GB_NONE: { const Vehicle *v = vehgroup.GetSingleVehicle(); if (!VehicleClicked(v)) { - if (_ctrl_pressed) { + if (_fn_pressed) { ShowCompanyGroupForVehicle(v); } else { ShowVehicleViewWindow(v); @@ -2087,7 +2087,7 @@ public: assert(vehgroup.NumVehicles() > 0); if (!VehicleClicked(vehgroup)) { const Vehicle *v = vehgroup.vehicles_begin[0]; - if (_ctrl_pressed) { + if (_fn_pressed) { ShowOrdersWindow(v); } else { if (vehgroup.NumVehicles() == 1) { @@ -2232,10 +2232,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 _fn_pressed, 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)) != _fn_pressed) { ShowCompanyGroup(company, vehicle_type); } else { ShowVehicleListWindowLocal(company, VL_STANDARD, vehicle_type, company); @@ -2687,9 +2687,9 @@ struct VehicleDetailsWindow : Window { const Vehicle *v = Vehicle::Get(this->window_number); int mod; if (!v->ServiceIntervalIsPercent() && TimerGameEconomy::UsingWallclockUnits()) { - mod = _ctrl_pressed ? 1 : 5; + mod = _fn_pressed ? 1 : 5; } else { - mod = _ctrl_pressed ? 5 : 10; + mod = _fn_pressed ? 5 : 10; } mod = (widget == WID_VD_DECREASE_SERVICING_INTERVAL) ? -mod : mod; @@ -3209,7 +3209,7 @@ public: TileIndex tile = v->current_order.GetLocation(v); if (tile == INVALID_TILE) break; - if (_ctrl_pressed) { + if (_fn_pressed) { ShowExtraViewportWindow(tile); } else { ScrollMainWindowToTile(tile); @@ -3218,7 +3218,7 @@ public: } case WID_VV_LOCATION: // center main view - if (_ctrl_pressed) { + if (_fn_pressed) { ShowExtraViewportWindow(TileVirtXY(v->x_pos, v->y_pos)); } else { const Window *mainwindow = GetMainWindow(); @@ -3232,20 +3232,20 @@ public: break; case WID_VV_GOTO_DEPOT: // goto hangar - Command::Post(GetCmdSendToDepotMsg(v), v->index, _ctrl_pressed ? DepotCommand::Service : DepotCommand::None, {}); + Command::Post(GetCmdSendToDepotMsg(v), v->index, _fn_pressed ? DepotCommand::Service : DepotCommand::None, {}); 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 (_fn_pressed) { ShowTimetableWindow(v); } else { ShowOrdersWindow(v); } break; case WID_VV_SHOW_DETAILS: // show details - if (_ctrl_pressed) { + if (_fn_pressed) { ShowCompanyGroupForVehicle(v); } else { ShowVehicleDetailsWindow(v); @@ -3257,8 +3257,8 @@ public: * 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. */ Command::Post(_vehicle_msg_translation_table[VCT_CMD_CLONE_VEH][v->type], - _ctrl_pressed ? nullptr : CcCloneVehicle, - v->tile, v->index, _ctrl_pressed); + _fn_pressed ? nullptr : CcCloneVehicle, + v->tile, v->index, _fn_pressed); break; case WID_VV_TURN_AROUND: // turn around assert(v->IsGroundVehicle()); diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp index a2ac32c117..7ad6b01602 100644 --- a/src/video/allegro_v.cpp +++ b/src/video/allegro_v.cpp @@ -461,10 +461,8 @@ void VideoDriver_Allegro::Stop() void VideoDriver_Allegro::InputLoop() { - bool old_ctrl_pressed = _ctrl_pressed; - - _ctrl_pressed = !!(key_shifts & KB_CTRL_FLAG); - _shift_pressed = !!(key_shifts & KB_SHIFT_FLAG); + bool ctrl_pressed = !!(key_shifts & KB_CTRL_FLAG); + bool shift_pressed = !!(key_shifts & KB_SHIFT_FLAG); /* Speedup when pressing tab, except when using ALT+TAB * to switch to another application. */ @@ -477,7 +475,7 @@ void VideoDriver_Allegro::InputLoop() (key[KEY_RIGHT] ? 4 : 0) | (key[KEY_DOWN] ? 8 : 0); - if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); + HandleModifierKeys(shift_pressed, ctrl_pressed); } void VideoDriver_Allegro::MainLoop() diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm index 23979b4ef4..33a6640f30 100644 --- a/src/video/cocoa/cocoa_v.mm +++ b/src/video/cocoa/cocoa_v.mm @@ -472,14 +472,12 @@ void VideoDriver_Cocoa::InputLoop() { NSUInteger cur_mods = [ NSEvent modifierFlags ]; - bool old_ctrl_pressed = _ctrl_pressed; - - _ctrl_pressed = (cur_mods & ( _settings_client.gui.right_mouse_btn_emulation != RMBE_CONTROL ? NSEventModifierFlagControl : NSEventModifierFlagCommand)) != 0; - _shift_pressed = (cur_mods & NSEventModifierFlagShift) != 0; + bool ctrl_pressed = (cur_mods & ( _settings_client.gui.right_mouse_btn_emulation != RMBE_CONTROL ? NSEventModifierFlagControl : NSEventModifierFlagCommand)) != 0; + bool shift_pressed = (cur_mods & NSEventModifierFlagShift) != 0; this->fast_forward_key_pressed = _tab_is_down; - if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); + HandleModifierKeys(shift_pressed, ctrl_pressed); } /** Main game loop. */ diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp index 2bb381f5ec..e53a345230 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -575,10 +575,8 @@ void VideoDriver_SDL_Base::InputLoop() uint32_t mod = SDL_GetModState(); const Uint8 *keys = SDL_GetKeyboardState(nullptr); - bool old_ctrl_pressed = _ctrl_pressed; - - _ctrl_pressed = !!(mod & KMOD_CTRL); - _shift_pressed = !!(mod & KMOD_SHIFT); + bool ctrl_pressed = !!(mod & KMOD_CTRL); + bool shift_pressed = !!(mod & KMOD_SHIFT); /* Speedup when pressing tab, except when using ALT+TAB * to switch to another application. */ @@ -591,7 +589,7 @@ void VideoDriver_SDL_Base::InputLoop() (keys[SDL_SCANCODE_RIGHT] ? 4 : 0) | (keys[SDL_SCANCODE_DOWN] ? 8 : 0); - if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); + HandleModifierKeys(shift_pressed, ctrl_pressed); } void VideoDriver_SDL_Base::LoopOnce() diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index 54819eb9e3..c54de0eecf 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -631,10 +631,8 @@ void VideoDriver_SDL::InputLoop() int numkeys; Uint8 *keys = SDL_GetKeyState(&numkeys); - bool old_ctrl_pressed = _ctrl_pressed; - - _ctrl_pressed = !!(mod & KMOD_CTRL); - _shift_pressed = !!(mod & KMOD_SHIFT); + bool ctrl_pressed = !!(mod & KMOD_CTRL); + bool shift_pressed = !!(mod & KMOD_SHIFT); /* Speedup when pressing tab, except when using ALT+TAB * to switch to another application. */ @@ -647,7 +645,7 @@ void VideoDriver_SDL::InputLoop() (keys[SDLK_RIGHT] ? 4 : 0) | (keys[SDLK_DOWN] ? 8 : 0); - if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); + HandleModifierKeys(shift_pressed, ctrl_pressed); } void VideoDriver_SDL::MainLoop() diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index a2710186a2..ab3bb1bed6 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -848,10 +848,8 @@ void VideoDriver_Win32Base::CheckPaletteAnim() void VideoDriver_Win32Base::InputLoop() { - bool old_ctrl_pressed = _ctrl_pressed; - - _ctrl_pressed = this->has_focus && GetAsyncKeyState(VK_CONTROL) < 0; - _shift_pressed = this->has_focus && GetAsyncKeyState(VK_SHIFT) < 0; + bool ctrl_pressed = this->has_focus && GetAsyncKeyState(VK_CONTROL) < 0; + bool shift_pressed = this->has_focus && GetAsyncKeyState(VK_SHIFT) < 0; /* Speedup when pressing tab, except when using ALT+TAB * to switch to another application. */ @@ -868,7 +866,7 @@ void VideoDriver_Win32Base::InputLoop() _dirkeys = 0; } - if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); + HandleModifierKeys(shift_pressed, ctrl_pressed); } bool VideoDriver_Win32Base::PollEvent() diff --git a/src/viewport.cpp b/src/viewport.cpp index 77e93cb2ff..3be3ae22be 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -2430,7 +2430,7 @@ bool HandleViewportClicked(const Viewport *vp, int x, int y) Debug(misc, 2, "Vehicle {} (index {}) at {}", v->unitnumber, v->index, fmt::ptr(v)); if (IsCompanyBuildableVehicleType(v)) { v = v->First(); - if (_ctrl_pressed && v->owner == _local_company) { + if (_fn_pressed && v->owner == _local_company) { StartStopVehicle(v, true); } else { ShowVehicleViewWindow(v); @@ -2572,7 +2572,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 && _fn_pressed && _left_button_down; } /** diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp index 725f8f91d8..130cf8584a 100644 --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -101,7 +101,7 @@ public: { switch (widget) { case WID_W_CENTER_VIEW: // scroll to location - if (_ctrl_pressed) { + if (_fn_pressed) { ShowExtraViewportWindow(this->GetCenterTile()); } else { ScrollMainWindowToTile(this->GetCenterTile()); diff --git a/src/window.cpp b/src/window.cpp index a33c3c0177..1585a8451a 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -680,7 +680,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count) return; case WWT_DEFSIZEBOX: { - if (_ctrl_pressed) { + if (_fn_pressed) { w->window_desc->pref_width = w->width; w->window_desc->pref_height = w->height; } else { @@ -714,7 +714,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 (_fn_pressed) w->window_desc->pref_sticky = (w->flags & WF_STICKY) != 0; return; default: @@ -2614,14 +2614,36 @@ void HandleKeypress(uint keycode, char32_t key) } /** - * State of CONTROL key has changed + * Handle the modifier key state changes. */ -void HandleCtrlChanged() +void HandleModifierKeys(bool shift_pressed, bool ctrl_pressed, bool alt_pressed) { - /* Call the event, start with the uppermost window. */ - for (Window *w : Window::IterateFromFront()) { - if (w->OnCTRLStateChange() == ES_HANDLED) return; + bool old_fn_pressed = _fn_pressed; + bool old_remove_pressed = _remove_pressed; + + _shift_pressed = shift_pressed; + + /* Hardwire modifiers leaving remove inaccessible for now. */ + _fn_pressed = ctrl_pressed; + _remove_pressed = false; + _estimate_pressed = shift_pressed; + + if (old_fn_pressed != _fn_pressed) { + /* Call the event, start with the uppermost window. */ + for (Window *w : Window::IterateFromFront()) { + if (w->OnFnStateChange() == ES_HANDLED) return; + } } + + if (old_remove_pressed != _remove_pressed) { + /* Call the event, start with the uppermost window. */ + for (Window *w : Window::IterateFromFront()) { + if (w->OnRemoveStateChange() == ES_HANDLED) return; + } + } + + old_fn_pressed = _fn_pressed; + old_remove_pressed = _remove_pressed; } /** diff --git a/src/window_gui.h b/src/window_gui.h index d4171070cf..ac227a037c 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -647,12 +647,18 @@ public: virtual EventState OnHotkey(int hotkey); /** - * The state of the control key has changed + * The state of the function modifier key has changed * @return #ES_HANDLED if the change has been handled and no other * window should receive the event. */ - virtual EventState OnCTRLStateChange() { return ES_NOT_HANDLED; } + virtual EventState OnFnStateChange() { return ES_NOT_HANDLED; } + /** + * The state of the remove modifier key has changed + * @return #ES_HANDLED if the change has been handled and no other + * window should receive the event. + */ + virtual EventState OnRemoveStateChange() { return ES_NOT_HANDLED; } /** * A click with the left mouse button has been made on the window.