Make modifier key functions configurable

This commit is contained in:
dP
2020-07-13 01:35:07 +03:00
parent 4af1a255df
commit 7441767ed8
55 changed files with 366 additions and 146 deletions

View File

@@ -31,6 +31,8 @@
#include "widgets/order_widget.h"
#include "citymania/cm_hotkeys.hpp"
#include "safeguards.h"
@@ -457,7 +459,7 @@ static std::pair<Order, FeederOrderMod> GetOrderCmdFromTile(const Vehicle *v, Ti
ODTFB_PART_OF_ORDERS,
(_settings_client.gui.new_nonstop && v->IsGroundVehicle()) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
if (citymania::_fn_mod) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
return std::make_pair(order, FeederOrderMod::NONE);
}
@@ -467,7 +469,7 @@ static std::pair<Order, FeederOrderMod> GetOrderCmdFromTile(const Vehicle *v, Ti
v->type == VEH_TRAIN &&
IsTileOwner(tile, _local_company)) {
order.MakeGoToWaypoint(GetStationIndex(tile));
if (_settings_client.gui.new_nonstop != _ctrl_pressed) order.SetNonStopType(ONSF_NO_STOP_AT_ANY_STATION);
if (_settings_client.gui.new_nonstop != citymania::_fn_mod) order.SetNonStopType(ONSF_NO_STOP_AT_ANY_STATION);
return std::make_pair(order, FeederOrderMod::NONE);
}
@@ -820,11 +822,11 @@ private:
void OrderClick_Skip()
{
/* Don't skip when there's nothing to skip */
if (_ctrl_pressed && this->vehicle->cur_implicit_order_index == this->OrderGetSel()) return;
if (citymania::_fn_mod && this->vehicle->cur_implicit_order_index == this->OrderGetSel()) return;
if (this->vehicle->GetNumOrders() <= 1) return;
DoCommandP(this->vehicle->tile, this->vehicle->index, _ctrl_pressed ? this->OrderGetSel() : ((this->vehicle->cur_implicit_order_index + 1) % this->vehicle->GetNumOrders()),
CMD_SKIP_TO_ORDER | CMD_MSG(_ctrl_pressed ? STR_ERROR_CAN_T_SKIP_TO_ORDER : STR_ERROR_CAN_T_SKIP_ORDER));
DoCommandP(this->vehicle->tile, this->vehicle->index, citymania::_fn_mod ? this->OrderGetSel() : ((this->vehicle->cur_implicit_order_index + 1) % this->vehicle->GetNumOrders()),
CMD_SKIP_TO_ORDER | CMD_MSG(citymania::_fn_mod ? STR_ERROR_CAN_T_SKIP_TO_ORDER : STR_ERROR_CAN_T_SKIP_ORDER));
}
/**
@@ -852,7 +854,7 @@ private:
/* Don't try to stop sharing orders if 'End of Shared Orders' isn't selected. */
if (!this->vehicle->IsOrderListShared() || this->selected_order != this->vehicle->GetNumOrders()) return;
/* If Ctrl is pressed, delete the order list as if we clicked the 'Delete' button. */
if (_ctrl_pressed) {
if (citymania::_fn_mod) {
this->OrderClick_Delete();
return;
}
@@ -873,7 +875,7 @@ private:
*/
void OrderClick_Refit(int i, bool auto_refit)
{
if (_ctrl_pressed) {
if (citymania::_fn_mod) {
/* Cancel refitting */
DoCommandP(this->vehicle->tile, this->vehicle->index, (this->OrderGetSel() << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, CMD_ORDER_REFIT);
} else {
@@ -1309,7 +1311,7 @@ public:
VehicleOrderID sel = this->GetOrderFromPt(pt.y);
if (_ctrl_pressed && sel < this->vehicle->GetNumOrders()) {
if (citymania::_fn_mod && sel < this->vehicle->GetNumOrders()) {
TileIndex xy = this->vehicle->GetOrder(sel)->GetLocation(this->vehicle);
if (xy != INVALID_TILE) ScrollMainWindowToTile(xy);
return;
@@ -1616,7 +1618,7 @@ public:
* ourself as it easily copies orders of vehicles within a station when we mean the station.
* Obviously if you press CTRL on a non-empty orders vehicle you know what you are doing
* TODO: give a warning message */
bool share_order = _ctrl_pressed || this->goto_type == OPOS_SHARE;
bool share_order = citymania::_fn_mod || this->goto_type == OPOS_SHARE;
if (this->vehicle->GetNumOrders() != 0 && !share_order) return false;
if (DoCommandP(this->vehicle->tile, this->vehicle->index | (share_order ? CO_SHARE : CO_COPY) << 30, v->index,