1
0
Fork 0

Change: Refactor modifier key handling, split Ctrl into function and remove

pull/10006/head
dP 2022-09-06 20:29:53 +03:00
parent acaceb45ba
commit aea866a42f
51 changed files with 227 additions and 204 deletions

View File

@ -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

View File

@ -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) {

View File

@ -582,7 +582,7 @@ public:
case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: {
const Group *g = Group::GetIfValid(this->sel_group);
if (g != nullptr) {
Command<CMD_SET_GROUP_FLAG>::Post(this->sel_group, GroupFlags::GF_REPLACE_WAGON_REMOVAL, !HasBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL), _ctrl_pressed);
Command<CMD_SET_GROUP_FLAG>::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<CMD_CHANGE_COMPANY_SETTING>::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<CMD_SET_AUTOREPLACE>::Post(this->sel_group, veh_from, INVALID_ENGINE, false);

View File

@ -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<CMD_BUILD_BRIDGE>::Post(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE, CcBuildBridge, end, start, transport_type, last_bridge_type, road_rail_type);
return;
}

View File

@ -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);

View File

@ -226,7 +226,7 @@ std::tuple<bool, bool, bool> 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'. */

View File

@ -497,11 +497,11 @@ struct CompanyFinancesWindow : Window {
break;
case WID_CF_INCREASE_LOAN: // increase loan
Command<CMD_INCREASE_LOAN>::Post(STR_ERROR_CAN_T_BORROW_ANY_MORE_MONEY, _ctrl_pressed ? LoanCommand::Max : LoanCommand::Interval, 0);
Command<CMD_INCREASE_LOAN>::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<CMD_DECREASE_LOAN>::Post(STR_ERROR_CAN_T_REPAY_LOAN, _ctrl_pressed ? LoanCommand::Max : LoanCommand::Interval, 0);
Command<CMD_DECREASE_LOAN>::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<CMD_SET_COMPANY_COLOUR>::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<CMD_BUILD_OBJECT>::Post(STR_ERROR_CAN_T_BUILD_COMPANY_HEADQUARTERS, tile, OBJECT_HQ, 0) && !_shift_pressed) {
if (Command<CMD_BUILD_OBJECT>::Post(STR_ERROR_CAN_T_BUILD_COMPANY_HEADQUARTERS, tile, OBJECT_HQ, 0) && !_estimate_pressed) {
ResetObjectToPlace();
this->RaiseButtons();
}

View File

@ -144,7 +144,7 @@ static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Veh
if (wagon == v) return;
Command<CMD_MOVE_RAIL_VEHICLE>::Post(STR_ERROR_CAN_T_MOVE_VEHICLE, v->tile, v->index, wagon == nullptr ? INVALID_VEHICLE : wagon->index, _ctrl_pressed);
Command<CMD_MOVE_RAIL_VEHICLE>::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<CMD_CLONE_VEHICLE>::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<CMD_REVERSE_TRAIN_DIRECTION>::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<CMD_SELL_VEHICLE>::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;
}

View File

@ -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<CMD_BUILD_DOCK>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_DOCK>()), 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<CMD_BUILD_CANAL>::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<CMD_BUILD_CANAL>::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<CMD_BUILD_CANAL>::Post(STR_ERROR_CAN_T_PLACE_RIVERS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WATER_CLASS_RIVER, _ctrl_pressed);
Command<CMD_BUILD_CANAL>::Post(STR_ERROR_CAN_T_PLACE_RIVERS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WATER_CLASS_RIVER, _fn_pressed);
break;
default: break;

View File

@ -130,7 +130,7 @@ struct EnginePreviewWindow : Window {
Command<CMD_WANT_ENGINE_PREVIEW>::Post(this->window_number);
FALLTHROUGH;
case WID_EP_NO:
if (!_shift_pressed) this->Close();
if (!_estimate_pressed) this->Close();
break;
}
}

View File

@ -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:

View File

@ -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 _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?

View File

@ -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 _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);

View File

@ -143,7 +143,7 @@ struct GoalListWindow : public Window {
default: NOT_REACHED();
}
if (_ctrl_pressed) {
if (_fn_pressed) {
ShowExtraViewportWindow(xy);
} else {
ScrollMainWindowToTile(xy);

View File

@ -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<CMD_SET_GROUP_FLAG>::Post(this->vli.index, GroupFlags::GF_REPLACE_PROTECTION, !HasBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION), _ctrl_pressed);
Command<CMD_SET_GROUP_FLAG>::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<CMD_ADD_VEHICLE_GROUP>::Post(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE, DEFAULT_GROUP, this->vehicle_sel, _ctrl_pressed || this->grouping == GB_SHARED_ORDERS, VehicleListIdentifier{});
Command<CMD_ADD_VEHICLE_GROUP>::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<CMD_ADD_VEHICLE_GROUP>::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<CMD_ADD_VEHICLE_GROUP>::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;
}

View File

@ -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);

View File

@ -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();

View File

@ -244,7 +244,7 @@ static void HandleLinkClick(Link link)
default: NOT_REACHED();
}
if (_ctrl_pressed) {
if (_fn_pressed) {
ShowExtraViewportWindow(xy);
} else {
ScrollMainWindowToTile(xy);

View File

@ -344,7 +344,7 @@ public:
{
switch (widget) {
case WID_LI_LOCATION:
if (_ctrl_pressed) {
if (_fn_pressed) {
ShowExtraViewportWindow(this->tile);
} else {
ScrollMainWindowToTile(this->tile);

View File

@ -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();

View File

@ -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;

View File

@ -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 {

View File

@ -553,7 +553,7 @@ public:
}
const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index);
Command<CMD_BUILD_OBJECT_AREA>::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

View File

@ -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<CMD_SKIP_TO_ORDER>::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<CMD_SKIP_TO_ORDER>::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<CMD_ORDER_REFIT>::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<CMD_CLONE_ORDER>::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();
})) {

View File

@ -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);

View File

@ -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);

View File

@ -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<CMD_BUILD_SINGLE_SIGNAL>::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<CMD_BUILD_SINGLE_SIGNAL>::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<CMD_REMOVE_SIGNAL_TRACK>::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<CMD_BUILD_SIGNAL_TRACK>::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<CMD_CONVERT_RAIL>::Post(STR_ERROR_CAN_T_CONVERT_RAIL, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, _cur_railtype, _ctrl_pressed);
Command<CMD_CONVERT_RAIL>::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<CMD_REMOVE_FROM_RAIL_STATION>::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<CMD_REMOVE_FROM_RAIL_WAYPOINT>::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) {

View File

@ -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<CMD_REMOVE_ROAD_STOP>::Post(this->rti->strings.err_remove_station[ROADSTOP_BUS], CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, ROADSTOP_BUS, _ctrl_pressed);
Command<CMD_REMOVE_ROAD_STOP>::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<CMD_REMOVE_ROAD_STOP>::Post(this->rti->strings.err_remove_station[ROADSTOP_TRUCK], CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, ROADSTOP_TRUCK, _ctrl_pressed);
Command<CMD_REMOVE_ROAD_STOP>::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;
}

View File

@ -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:

View File

@ -785,7 +785,7 @@ struct GameOptionsWindow : Window {
case WID_GO_GUI_SCALE:
if (ClickSliderWidget(this->GetWidget<NWidgetBase>(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);
}

View File

@ -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;
}

View File

@ -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++) {

View File

@ -84,7 +84,7 @@ template <typename T>
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<T>(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;

View File

@ -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);

View File

@ -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);

View File

@ -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<CMD_LANDSCAPE_CLEAR>::Post(tile);
MarkTileDirtyByTile(tile);
}
@ -119,16 +119,16 @@ bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_t
switch (proc) {
case DDSP_DEMOLISH_AREA:
Command<CMD_CLEAR_AREA>::Post(STR_ERROR_CAN_T_CLEAR_THIS_AREA, CcPlaySound_EXPLOSION, end_tile, start_tile, _ctrl_pressed);
Command<CMD_CLEAR_AREA>::Post(STR_ERROR_CAN_T_CLEAR_THIS_AREA, CcPlaySound_EXPLOSION, end_tile, start_tile, _fn_pressed);
break;
case DDSP_RAISE_AND_LEVEL_AREA:
Command<CMD_LEVEL_LAND>::Post(STR_ERROR_CAN_T_RAISE_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LM_RAISE);
Command<CMD_LEVEL_LAND>::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<CMD_LEVEL_LAND>::Post(STR_ERROR_CAN_T_LOWER_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LM_LOWER);
Command<CMD_LEVEL_LAND>::Post(STR_ERROR_CAN_T_LOWER_LAND_HERE, CcTerraform, end_tile, start_tile, _fn_pressed, LM_LOWER);
break;
case DDSP_LEVEL_AREA:
Command<CMD_LEVEL_LAND>::Post(STR_ERROR_CAN_T_LEVEL_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LM_LEVEL);
Command<CMD_LEVEL_LAND>::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<CMD_BUILD_OBJECT_AREA>::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;
}
}

View File

@ -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<void*>(static_cast<uintptr_t>(_ctrl_pressed)));
ShowSetDateWindow(this, v->index, TimerGameEconomy::date, TimerGameEconomy::year, TimerGameEconomy::year + MAX_TIMETABLE_START_YEARS, ChangeTimetableStartCallback, reinterpret_cast<void*>(static_cast<uintptr_t>(_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<CMD_BULK_CHANGE_TIMETABLE>::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, mtf, 0);
} else {
Command<CMD_CHANGE_TIMETABLE>::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<CMD_BULK_CHANGE_TIMETABLE>::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, mtf, UINT16_MAX);
} else {
Command<CMD_CHANGE_TIMETABLE>::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<CMD_SET_VEHICLE_ON_TIME>::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, _ctrl_pressed);
Command<CMD_SET_VEHICLE_ON_TIME>::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, _fn_pressed);
break;
case WID_VT_AUTOFILL: { // Autofill the timetable.
Command<CMD_AUTOFILL_TIMETABLE>::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, !HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE), _ctrl_pressed);
Command<CMD_AUTOFILL_TIMETABLE>::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, !HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE), _fn_pressed);
break;
}

View File

@ -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;

View File

@ -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

View File

@ -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();

View File

@ -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<CMD_PLANT_TREE>::Post(STR_ERROR_CAN_T_PLANT_TREE_HERE, end_tile, start_tile, this->tree_to_plant, _ctrl_pressed);
Command<CMD_PLANT_TREE>::Post(STR_ERROR_CAN_T_PLANT_TREE_HERE, end_tile, start_tile, this->tree_to_plant, _fn_pressed);
}
}

View File

@ -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<CMD_SEND_VEHICLE_TO_DEPOT>::Post(GetCmdSendToDepotMsg(v), v->index, _ctrl_pressed ? DepotCommand::Service : DepotCommand::None, {});
Command<CMD_SEND_VEHICLE_TO_DEPOT>::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<CMD_CLONE_VEHICLE>::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());

View File

@ -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()

View File

@ -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. */

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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;
}
/**

View File

@ -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());

View File

@ -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)
{
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->OnCTRLStateChange() == ES_HANDLED) return;
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;
}
/**

View File

@ -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.