summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Trahan <tyler@tylertrahan.com>2021-11-07 13:53:54 -0500
committerGitHub <noreply@github.com>2021-11-07 19:53:54 +0100
commitb4bd7b367e3b2ab0e82319e04adb9f302a9f222f (patch)
treef8418975a31d671831a12277506976bc6d3c57b5
parent08cb5ba2cd69406e34cb4a439d477142e80cef57 (diff)
downloadopenttd-b4bd7b367e3b2ab0e82319e04adb9f302a9f222f.tar.xz
Feature: Ctrl-click to remove fully autoreplaced vehicles from list (#9639)
-rw-r--r--src/autoreplace_gui.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index 9f2deaf10..898b4e750 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -578,6 +578,16 @@ public:
size_t engine_count = this->engines[click_side].size();
EngineID e = engine_count > i ? this->engines[click_side][i] : INVALID_ENGINE;
+
+ /* If Ctrl 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 &&
+ (GetGroupNumEngines(_local_company, sel_group, e) == 0 || GetGroupNumEngines(_local_company, ALL_GROUP, e) == 0)) {
+ EngineID veh_from = e;
+ DoCommandP(0, this->sel_group << 16, veh_from + (INVALID_ENGINE << 16), CMD_SET_AUTOREPLACE);
+ break;
+ }
+
if (e == this->sel_engine[click_side]) break; // we clicked the one we already selected
this->sel_engine[click_side] = e;
if (click_side == 0) {