* Update the GUI and enable/disable planting to reflect selected options. */
| 95 | * Update the GUI and enable/disable planting to reflect selected options. |
| 96 | */ |
| 97 | void UpdateMode() |
| 98 | { |
| 99 | this->RaiseButtons(); |
| 100 | |
| 101 | const int current_tree = this->tree_to_plant; |
| 102 | |
| 103 | if (this->tree_to_plant >= 0) { |
| 104 | /* Activate placement */ |
| 105 | SndConfirmBeep(); |
| 106 | SetObjectToPlace(SPR_CURSOR_TREE, PAL_NONE, HT_RECT | HT_DIAGONAL, this->window_class, this->window_number); |
| 107 | this->tree_to_plant = current_tree; // SetObjectToPlace may call ResetObjectToPlace which may reset tree_to_plant to -1 |
| 108 | } else { |
| 109 | /* Deactivate placement */ |
| 110 | ResetObjectToPlace(); |
| 111 | } |
| 112 | |
| 113 | if (this->tree_to_plant == TREE_INVALID) { |
| 114 | this->LowerWidget(WID_BT_TYPE_RANDOM); |
| 115 | } else if (this->tree_to_plant >= 0) { |
| 116 | this->LowerWidget(WID_BT_TYPE_BUTTON_FIRST + this->tree_to_plant); |
| 117 | } |
| 118 | |
| 119 | switch (this->mode) { |
| 120 | case PM_NORMAL: this->LowerWidget(WID_BT_MODE_NORMAL); break; |
| 121 | case PM_FOREST_SM: this->LowerWidget(WID_BT_MODE_FOREST_SM); break; |
| 122 | case PM_FOREST_LG: this->LowerWidget(WID_BT_MODE_FOREST_LG); break; |
| 123 | default: NOT_REACHED(); |
| 124 | } |
| 125 | |
| 126 | this->SetDirty(); |
| 127 | } |
| 128 | |
| 129 | void DoPlantForest(TileIndex tile) |
| 130 | { |
no test coverage detected