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
+12 -11
View File
@@ -40,6 +40,7 @@
#include <vector>
#include "citymania/station_ui.hpp"
#include "citymania/cm_hotkeys.hpp"
#include "citymania/cm_tooltips.hpp"
#include "safeguards.h"
@@ -105,7 +106,7 @@ int DrawStationAuthorityText(int left, int right, int top) {
static void FindStationsAroundSelection()
{
/* With distant join we don't know which station will be selected, so don't show any */
if (_ctrl_pressed) {
if (citymania::_fn_mod) {
SetViewportCatchmentStation(nullptr, true);
return;
}
@@ -150,10 +151,10 @@ void CheckRedrawStationCoverage(const Window *w)
return;
}
/* Test if ctrl state changed */
static bool _last_ctrl_pressed;
if (_ctrl_pressed != _last_ctrl_pressed) {
static bool _last_fn_pressed;
if (citymania::_fn_mod != _last_fn_pressed) {
_thd.dirty = 0xff;
_last_ctrl_pressed = _ctrl_pressed;
_last_fn_pressed = citymania::_fn_mod;
}
if (_thd.dirty & 1) {
@@ -560,7 +561,7 @@ public:
/* do not check HasStationInUse - it is slow and may be invalid */
assert(st->owner == (Owner)this->window_number || st->owner == OWNER_NONE);
if (_ctrl_pressed) {
if (citymania::_fn_mod) {
ShowExtraViewPortWindow(st->xy);
} else {
ScrollMainWindowToTile(st->xy);
@@ -573,7 +574,7 @@ public:
case WID_STL_BUS:
case WID_STL_AIRPLANE:
case WID_STL_SHIP:
if (_ctrl_pressed) {
if (citymania::_fn_mod) {
ToggleBit(this->facilities, widget - WID_STL_TRAIN);
this->ToggleWidgetLoweredState(widget);
} else {
@@ -621,7 +622,7 @@ public:
break;
case WID_STL_NOCARGOWAITING:
if (_ctrl_pressed) {
if (citymania::_fn_mod) {
this->include_empty = !this->include_empty;
this->ToggleWidgetLoweredState(WID_STL_NOCARGOWAITING);
} else {
@@ -643,7 +644,7 @@ public:
/* Determine the selected cargo type */
const CargoSpec *cs = _sorted_cargo_specs[widget - WID_STL_CARGOSTART];
if (_ctrl_pressed) {
if (citymania::_fn_mod) {
ToggleBit(this->cargo_filter, cs->Index());
this->ToggleWidgetLoweredState(widget);
} else {
@@ -1919,7 +1920,7 @@ struct StationViewWindow : public Window {
void HandleCargoWaitingClick(int row)
{
if (row < 0 || (uint)row >= this->displayed_rows.size()) return;
if (_ctrl_pressed) {
if (citymania::_fn_mod) {
this->scroll_to_row = row;
} else {
RowDisplay &display = this->displayed_rows[row];
@@ -1944,7 +1945,7 @@ struct StationViewWindow : public Window {
break;
case WID_SV_LOCATION:
if (_ctrl_pressed) {
if (citymania::_fn_mod) {
ShowExtraViewPortWindow(Station::Get(this->window_number)->xy);
} else {
ScrollMainWindowToTile(Station::Get(this->window_number)->xy);
@@ -2475,7 +2476,7 @@ static bool StationJoinerNeeded(const CommandContainer &cmd, TileArea ta)
}
/* only show the popup, if we press ctrl */
if (!_ctrl_pressed) return false;
if (!citymania::_fn_mod) return false;
/* Now check if we could build there */
if (DoCommand(&cmd, CommandFlagsToDCFlags(GetCommandFlags(cmd.cmd))).Failed()) return false;