summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorstormcone <48624099+stormcone@users.noreply.github.com>2019-11-23 21:52:33 +0100
committerCharles Pigott <charlespigott@googlemail.com>2020-01-05 20:52:17 +0000
commit808253c29c5b0f855a1d4cb230783cc2adb1451d (patch)
tree702b5ff1fe51bbebbb55860bba46407716453264 /src
parent70f9c3c655363bd8814f4a7d95e4dd94a85afd00 (diff)
downloadopenttd-808253c29c5b0f855a1d4cb230783cc2adb1451d.tar.xz
Change: Move the filtered cargo to the first place in the industry directory window's cargo lists
Diffstat (limited to 'src')
-rw-r--r--src/industry_gui.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index d6a0d7aa4..c93dc5573 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -1475,6 +1475,18 @@ protected:
return std::get<3>(a) > std::get<3>(b);
});
+ /* If the produced cargo filter is active then move the filtered cargo to the beginning of the list,
+ * because this is the one the player interested in, and that way it is not hidden in the 'n' more cargos */
+ const CargoID cid = this->cargo_filter[this->produced_cargo_filter_criteria];
+ if (cid != CF_ANY && cid != CF_NONE) {
+ auto filtered_ci = std::find_if(cargos.begin(), cargos.end(), [cid](const CargoInfo& ci) -> bool {
+ return std::get<0>(ci) == cid;
+ });
+ if (filtered_ci != cargos.end()) {
+ std::rotate(cargos.begin(), filtered_ci, filtered_ci + 1);
+ }
+ }
+
/* Display first 3 cargos */
for (size_t j = 0; j < min<size_t>(3, cargos.size()); j++) {
CargoInfo ci = cargos[j];