summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-05-08 17:33:04 +0000
committerfrosch <frosch@openttd.org>2010-05-08 17:33:04 +0000
commit9ff8032c94298eb53a9609a30045bede0db9c177 (patch)
treea27c99d698e47d04815ea70f505b78b3662c0d58 /src
parent5b77a63ecfabe3537e10e681fac765fc5c46be10 (diff)
downloadopenttd-9ff8032c94298eb53a9609a30045bede0db9c177.tar.xz
(svn r19770) -Feature: Hide all other industries when ctrl+clicking an industry type in smallmap legend.
Diffstat (limited to 'src')
-rw-r--r--src/smallmap_gui.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 9bea2a542..68a9a056c 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -1212,7 +1212,25 @@ public:
/* Check if click is on industry label*/
int industry_pos = (column * number_of_rows) + line;
if (industry_pos < _smallmap_industry_count) {
- _legend_from_industries[industry_pos].show_on_map = !_legend_from_industries[industry_pos].show_on_map;
+ if (_ctrl_pressed) {
+ /* Disable all, except the clicked one */
+ bool changes = false;
+ for (int i = 0; i != _smallmap_industry_count; i++) {
+ bool new_state = i == industry_pos;
+ if (_legend_from_industries[i].show_on_map != new_state) {
+ changes = true;
+ _legend_from_industries[i].show_on_map = new_state;
+ }
+ }
+ if (!changes) {
+ /* Nothing changed? Then show all (again). */
+ for (int i = 0; i != _smallmap_industry_count; i++) {
+ _legend_from_industries[i].show_on_map = true;
+ }
+ }
+ } else {
+ _legend_from_industries[industry_pos].show_on_map = !_legend_from_industries[industry_pos].show_on_map;
+ }
}
this->SetDirty();
}