* Select and toggle a legend item. When CTRL is pressed, disable all other * items in the group defined by begin_legend_item and end_legend_item and * keep the clicked one enabled even if it was already enabled before. If * the other items in the group are all disabled already and CTRL is pressed * enable them instead. * @param click_pos the index of the item being selected * @param le
| 792 | * @param begin_legend_item index of the first item in the group to be inverted |
| 793 | */ |
| 794 | void SelectLegendItem(int click_pos, LegendAndColour *legend, int end_legend_item, int begin_legend_item = 0) |
| 795 | { |
| 796 | if (_ctrl_pressed) { |
| 797 | /* Disable all, except the clicked one */ |
| 798 | bool changes = false; |
| 799 | for (int i = begin_legend_item; i != end_legend_item; i++) { |
| 800 | bool new_state = (i == click_pos); |
| 801 | if (legend[i].show_on_map != new_state) { |
| 802 | changes = true; |
| 803 | legend[i].show_on_map = new_state; |
| 804 | } |
| 805 | } |
| 806 | if (!changes) { |
| 807 | /* Nothing changed? Then show all (again). */ |
| 808 | for (int i = begin_legend_item; i != end_legend_item; i++) { |
| 809 | legend[i].show_on_map = true; |
| 810 | } |
| 811 | } |
| 812 | } else { |
| 813 | legend[click_pos].show_on_map = !legend[click_pos].show_on_map; |
| 814 | } |
| 815 | |
| 816 | if (this->map_type == SMT_INDUSTRY) this->BreakIndustryChainLink(); |
| 817 | } |
| 818 | |
| 819 | /** |
| 820 | * Select a new map type. |
no test coverage detected