MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / UpdateMode

Method UpdateMode

src/tree_gui.cpp:97–127  ·  view source on GitHub ↗

* Update the GUI and enable/disable planting to reflect selected options. */

Source from the content-addressed store, hash-verified

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 {

Callers 2

OnClickMethod · 0.95
OnPlaceObjectAbortMethod · 0.95

Calls 7

SndConfirmBeepFunction · 0.85
SetObjectToPlaceFunction · 0.85
ResetObjectToPlaceFunction · 0.85
NOT_REACHEDFunction · 0.85
RaiseButtonsMethod · 0.80
LowerWidgetMethod · 0.80
SetDirtyMethod · 0.45

Tested by

no test coverage detected