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

Method OnClick

src/tree_gui.cpp:174–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172 }
173
174 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
175 {
176 switch (widget) {
177 case WID_BT_TYPE_RANDOM: // tree of random type.
178 this->tree_to_plant = this->tree_to_plant == TREE_INVALID ? -1 : TREE_INVALID;
179 this->UpdateMode();
180 break;
181
182 case WID_BT_MANY_RANDOM: // place trees randomly over the landscape
183 SndConfirmBeep();
184 PlaceTreesRandomly();
185 MarkWholeScreenDirty();
186 break;
187
188 case WID_BT_MODE_NORMAL:
189 this->mode = PM_NORMAL;
190 this->UpdateMode();
191 break;
192
193 case WID_BT_MODE_FOREST_SM:
194 assert(_game_mode == GM_EDITOR);
195 this->mode = PM_FOREST_SM;
196 this->UpdateMode();
197 break;
198
199 case WID_BT_MODE_FOREST_LG:
200 assert(_game_mode == GM_EDITOR);
201 this->mode = PM_FOREST_LG;
202 this->UpdateMode();
203 break;
204
205 default:
206 if (widget >= WID_BT_TYPE_BUTTON_FIRST) {
207 const int index = widget - WID_BT_TYPE_BUTTON_FIRST;
208 this->tree_to_plant = this->tree_to_plant == index ? -1 : index;
209 this->UpdateMode();
210 }
211 break;
212 }
213 }
214
215 void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
216 {

Callers

nothing calls this directly

Calls 4

UpdateModeMethod · 0.95
SndConfirmBeepFunction · 0.85
PlaceTreesRandomlyFunction · 0.85
MarkWholeScreenDirtyFunction · 0.85

Tested by

no test coverage detected