OpenTTD Source  12.0-beta2
terraform_gui.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "stdafx.h"
11 #include "core/backup_type.hpp"
12 #include "clear_map.h"
13 #include "company_func.h"
14 #include "company_base.h"
15 #include "gui.h"
16 #include "window_gui.h"
17 #include "window_func.h"
18 #include "viewport_func.h"
19 #include "command_func.h"
20 #include "signs_func.h"
21 #include "sound_func.h"
22 #include "base_station_base.h"
23 #include "textbuf_gui.h"
24 #include "genworld.h"
25 #include "tree_map.h"
26 #include "landscape_type.h"
27 #include "tilehighlight_func.h"
28 #include "strings_func.h"
29 #include "newgrf_object.h"
30 #include "object.h"
31 #include "hotkeys.h"
32 #include "engine_base.h"
33 #include "terraform_gui.h"
34 #include "zoom_func.h"
35 
37 
38 #include "table/strings.h"
39 
40 #include "safeguards.h"
41 
42 void CcTerraform(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
43 {
44  if (result.Succeeded()) {
45  if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
46  } else {
49  }
50 }
51 
52 
54 static void GenerateDesertArea(TileIndex end, TileIndex start)
55 {
56  if (_game_mode != GM_EDITOR) return;
57 
58  Backup<bool> old_generating_world(_generating_world, true, FILE_LINE);
59 
60  TileArea ta(start, end);
61  for (TileIndex tile : ta) {
63  DoCommandP(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
64  MarkTileDirtyByTile(tile);
65  }
66  old_generating_world.Restore();
68 }
69 
71 static void GenerateRockyArea(TileIndex end, TileIndex start)
72 {
73  if (_game_mode != GM_EDITOR) return;
74 
75  bool success = false;
76  TileArea ta(start, end);
77 
78  for (TileIndex tile : ta) {
79  switch (GetTileType(tile)) {
80  case MP_TREES:
81  if (GetTreeGround(tile) == TREE_GROUND_SHORE) continue;
82  FALLTHROUGH;
83 
84  case MP_CLEAR:
85  MakeClear(tile, CLEAR_ROCKS, 3);
86  break;
87 
88  default:
89  continue;
90  }
91  MarkTileDirtyByTile(tile);
92  success = true;
93  }
94 
95  if (success && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, end);
96 }
97 
108 {
110  /* When end_tile is MP_VOID, the error tile will not be visible to the
111  * user. This happens when terraforming at the southern border. */
112  if (TileX(end_tile) == MapMaxX()) end_tile += TileDiffXY(-1, 0);
113  if (TileY(end_tile) == MapMaxY()) end_tile += TileDiffXY(0, -1);
114  }
115 
116  switch (proc) {
117  case DDSP_DEMOLISH_AREA:
118  DoCommandP(end_tile, start_tile, _ctrl_pressed ? 1 : 0, CMD_CLEAR_AREA | CMD_MSG(STR_ERROR_CAN_T_CLEAR_THIS_AREA), CcPlaySound_EXPLOSION);
119  break;
121  DoCommandP(end_tile, start_tile, LM_RAISE << 1 | (_ctrl_pressed ? 1 : 0), CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_RAISE_LAND_HERE), CcTerraform);
122  break;
124  DoCommandP(end_tile, start_tile, LM_LOWER << 1 | (_ctrl_pressed ? 1 : 0), CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LOWER_LAND_HERE), CcTerraform);
125  break;
126  case DDSP_LEVEL_AREA:
127  DoCommandP(end_tile, start_tile, LM_LEVEL << 1 | (_ctrl_pressed ? 1 : 0), CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LEVEL_LAND_HERE), CcTerraform);
128  break;
129  case DDSP_CREATE_ROCKS:
130  GenerateRockyArea(end_tile, start_tile);
131  break;
132  case DDSP_CREATE_DESERT:
133  GenerateDesertArea(end_tile, start_tile);
134  break;
135  default:
136  return false;
137  }
138 
139  return true;
140 }
141 
147 {
149 }
150 
154 
156  {
157  /* This is needed as we like to have the tree available on OnInit. */
158  this->CreateNestedTree();
159  this->FinishInitNested(window_number);
160  this->last_user_action = WIDGET_LIST_END;
161  }
162 
164  {
165  }
166 
167  void OnInit() override
168  {
169  /* Don't show the place object button when there are no objects to place. */
170  NWidgetStacked *show_object = this->GetWidget<NWidgetStacked>(WID_TT_SHOW_PLACE_OBJECT);
171  show_object->SetDisplayedPlane(ObjectClass::GetUIClassCount() != 0 ? 0 : SZSP_NONE);
172  }
173 
174  void OnClick(Point pt, int widget, int click_count) override
175  {
176  if (widget < WID_TT_BUTTONS_START) return;
177 
178  switch (widget) {
179  case WID_TT_LOWER_LAND: // Lower land button
181  this->last_user_action = widget;
182  break;
183 
184  case WID_TT_RAISE_LAND: // Raise land button
186  this->last_user_action = widget;
187  break;
188 
189  case WID_TT_LEVEL_LAND: // Level land button
190  HandlePlacePushButton(this, WID_TT_LEVEL_LAND, SPR_CURSOR_LEVEL_LAND, HT_POINT | HT_DIAGONAL);
191  this->last_user_action = widget;
192  break;
193 
194  case WID_TT_DEMOLISH: // Demolish aka dynamite button
196  this->last_user_action = widget;
197  break;
198 
199  case WID_TT_BUY_LAND: // Buy land button
200  HandlePlacePushButton(this, WID_TT_BUY_LAND, SPR_CURSOR_BUY_LAND, HT_RECT);
201  this->last_user_action = widget;
202  break;
203 
204  case WID_TT_PLANT_TREES: // Plant trees button
205  ShowBuildTreesToolbar();
206  break;
207 
208  case WID_TT_PLACE_SIGN: // Place sign button
209  HandlePlacePushButton(this, WID_TT_PLACE_SIGN, SPR_CURSOR_SIGN, HT_RECT);
210  this->last_user_action = widget;
211  break;
212 
213  case WID_TT_PLACE_OBJECT: // Place object button
215  break;
216 
217  default: NOT_REACHED();
218  }
219  }
220 
221  void OnPlaceObject(Point pt, TileIndex tile) override
222  {
223  switch (this->last_user_action) {
224  case WID_TT_LOWER_LAND: // Lower land button
226  break;
227 
228  case WID_TT_RAISE_LAND: // Raise land button
230  break;
231 
232  case WID_TT_LEVEL_LAND: // Level land button
234  break;
235 
236  case WID_TT_DEMOLISH: // Demolish aka dynamite button
238  break;
239 
240  case WID_TT_BUY_LAND: // Buy land button
241  DoCommandP(tile, OBJECT_OWNED_LAND, 0, CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_PURCHASE_THIS_LAND), CcPlaySound_CONSTRUCTION_RAIL);
242  break;
243 
244  case WID_TT_PLACE_SIGN: // Place sign button
245  PlaceProc_Sign(tile);
246  break;
247 
248  default: NOT_REACHED();
249  }
250  }
251 
252  void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
253  {
254  VpSelectTilesWithMethod(pt.x, pt.y, select_method);
255  }
256 
257  Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
258  {
259  Point pt = GetToolbarAlignedWindowPosition(sm_width);
260  pt.y += sm_height;
261  return pt;
262  }
263 
264  void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
265  {
266  if (pt.x != -1) {
267  switch (select_proc) {
268  default: NOT_REACHED();
269  case DDSP_DEMOLISH_AREA:
272  case DDSP_LEVEL_AREA:
273  GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
274  break;
275  }
276  }
277  }
278 
279  void OnPlaceObjectAbort() override
280  {
281  this->RaiseButtons();
282  }
283 
284  static HotkeyList hotkeys;
285 };
286 
293 {
294  if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED;
295  Window *w = ShowTerraformToolbar(nullptr);
296  if (w == nullptr) return ES_NOT_HANDLED;
297  return w->OnHotkey(hotkey);
298 }
299 
300 static Hotkey terraform_hotkeys[] = {
301  Hotkey('Q' | WKC_GLOBAL_HOTKEY, "lower", WID_TT_LOWER_LAND),
302  Hotkey('W' | WKC_GLOBAL_HOTKEY, "raise", WID_TT_RAISE_LAND),
303  Hotkey('E' | WKC_GLOBAL_HOTKEY, "level", WID_TT_LEVEL_LAND),
304  Hotkey('D' | WKC_GLOBAL_HOTKEY, "dynamite", WID_TT_DEMOLISH),
305  Hotkey('U', "buyland", WID_TT_BUY_LAND),
306  Hotkey('I', "trees", WID_TT_PLANT_TREES),
307  Hotkey('O', "placesign", WID_TT_PLACE_SIGN),
308  Hotkey('P', "placeobject", WID_TT_PLACE_OBJECT),
309  HOTKEY_LIST_END
310 };
311 HotkeyList TerraformToolbarWindow::hotkeys("terraform", terraform_hotkeys, TerraformToolbarGlobalHotkeys);
312 
313 static const NWidgetPart _nested_terraform_widgets[] = {
315  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
316  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_LANDSCAPING_TOOLBAR, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
317  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
318  EndContainer(),
320  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_TT_LOWER_LAND), SetMinimalSize(22, 22),
321  SetFill(0, 1), SetDataTip(SPR_IMG_TERRAFORM_DOWN, STR_LANDSCAPING_TOOLTIP_LOWER_A_CORNER_OF_LAND),
322  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_TT_RAISE_LAND), SetMinimalSize(22, 22),
323  SetFill(0, 1), SetDataTip(SPR_IMG_TERRAFORM_UP, STR_LANDSCAPING_TOOLTIP_RAISE_A_CORNER_OF_LAND),
324  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_TT_LEVEL_LAND), SetMinimalSize(22, 22),
325  SetFill(0, 1), SetDataTip(SPR_IMG_LEVEL_LAND, STR_LANDSCAPING_LEVEL_LAND_TOOLTIP),
326 
327  NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(4, 22), EndContainer(),
328 
329  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_TT_DEMOLISH), SetMinimalSize(22, 22),
330  SetFill(0, 1), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
331  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_TT_BUY_LAND), SetMinimalSize(22, 22),
332  SetFill(0, 1), SetDataTip(SPR_IMG_BUY_LAND, STR_LANDSCAPING_TOOLTIP_PURCHASE_LAND),
333  NWidget(WWT_PUSHIMGBTN, COLOUR_DARK_GREEN, WID_TT_PLANT_TREES), SetMinimalSize(22, 22),
334  SetFill(0, 1), SetDataTip(SPR_IMG_PLANTTREES, STR_SCENEDIT_TOOLBAR_PLANT_TREES),
335  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_TT_PLACE_SIGN), SetMinimalSize(22, 22),
336  SetFill(0, 1), SetDataTip(SPR_IMG_SIGN, STR_SCENEDIT_TOOLBAR_PLACE_SIGN),
338  NWidget(WWT_PUSHIMGBTN, COLOUR_DARK_GREEN, WID_TT_PLACE_OBJECT), SetMinimalSize(22, 22),
339  SetFill(0, 1), SetDataTip(SPR_IMG_TRANSMITTER, STR_SCENEDIT_TOOLBAR_PLACE_OBJECT),
340  EndContainer(),
341  EndContainer(),
342 };
343 
344 static WindowDesc _terraform_desc(
345  WDP_MANUAL, "toolbar_landscape", 0, 0,
348  _nested_terraform_widgets, lengthof(_nested_terraform_widgets),
349  &TerraformToolbarWindow::hotkeys
350 );
351 
358 {
359  if (!Company::IsValidID(_local_company)) return nullptr;
360 
361  Window *w;
362  if (link == nullptr) {
363  w = AllocateWindowDescFront<TerraformToolbarWindow>(&_terraform_desc, 0);
364  return w;
365  }
366 
367  /* Delete the terraform toolbar to place it again. */
369  w = AllocateWindowDescFront<TerraformToolbarWindow>(&_terraform_desc, 0);
370  /* Align the terraform toolbar under the main toolbar. */
371  w->top -= w->height;
372  w->SetDirty();
373  /* Put the linked toolbar to the left / right of it. */
374  link->left = w->left + (_current_text_dir == TD_RTL ? w->width : -link->width);
375  link->top = w->top;
376  link->SetDirty();
377 
378  return w;
379 }
380 
381 static byte _terraform_size = 1;
382 
392 static void CommonRaiseLowerBigLand(TileIndex tile, int mode)
393 {
394  if (_terraform_size == 1) {
395  StringID msg =
396  mode ? STR_ERROR_CAN_T_RAISE_LAND_HERE : STR_ERROR_CAN_T_LOWER_LAND_HERE;
397 
398  DoCommandP(tile, SLOPE_N, (uint32)mode, CMD_TERRAFORM_LAND | CMD_MSG(msg), CcTerraform);
399  } else {
400  assert(_terraform_size != 0);
401  TileArea ta(tile, _terraform_size, _terraform_size);
402  ta.ClampToMap();
403 
404  if (ta.w == 0 || ta.h == 0) return;
405 
406  if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
407 
408  uint h;
409  if (mode != 0) {
410  /* Raise land */
411  h = MAX_TILE_HEIGHT;
412  for (TileIndex tile2 : ta) {
413  h = std::min(h, TileHeight(tile2));
414  }
415  } else {
416  /* Lower land */
417  h = 0;
418  for (TileIndex tile2 : ta) {
419  h = std::max(h, TileHeight(tile2));
420  }
421  }
422 
423  for (TileIndex tile2 : ta) {
424  if (TileHeight(tile2) == h) {
425  DoCommandP(tile2, SLOPE_N, (uint32)mode, CMD_TERRAFORM_LAND);
426  }
427  }
428  }
429 }
430 
431 static const int8 _multi_terraform_coords[][2] = {
432  { 0, -2},
433  { 4, 0}, { -4, 0}, { 0, 2},
434  { -8, 2}, { -4, 4}, { 0, 6}, { 4, 4}, { 8, 2},
435  {-12, 0}, { -8, -2}, { -4, -4}, { 0, -6}, { 4, -4}, { 8, -2}, { 12, 0},
436  {-16, 2}, {-12, 4}, { -8, 6}, { -4, 8}, { 0, 10}, { 4, 8}, { 8, 6}, { 12, 4}, { 16, 2},
437  {-20, 0}, {-16, -2}, {-12, -4}, { -8, -6}, { -4, -8}, { 0,-10}, { 4, -8}, { 8, -6}, { 12, -4}, { 16, -2}, { 20, 0},
438  {-24, 2}, {-20, 4}, {-16, 6}, {-12, 8}, { -8, 10}, { -4, 12}, { 0, 14}, { 4, 12}, { 8, 10}, { 12, 8}, { 16, 6}, { 20, 4}, { 24, 2},
439  {-28, 0}, {-24, -2}, {-20, -4}, {-16, -6}, {-12, -8}, { -8,-10}, { -4,-12}, { 0,-14}, { 4,-12}, { 8,-10}, { 12, -8}, { 16, -6}, { 20, -4}, { 24, -2}, { 28, 0},
440 };
441 
442 static const NWidgetPart _nested_scen_edit_land_gen_widgets[] = {
444  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
445  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_TERRAFORM_TOOLBAR_LAND_GENERATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
446  NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
447  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
448  EndContainer(),
449  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
450  NWidget(NWID_HORIZONTAL), SetPadding(2, 2, 7, 2),
451  NWidget(NWID_SPACER), SetFill(1, 0),
452  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_ETT_DEMOLISH), SetMinimalSize(22, 22),
453  SetFill(0, 1), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
454  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_ETT_LOWER_LAND), SetMinimalSize(22, 22),
455  SetFill(0, 1), SetDataTip(SPR_IMG_TERRAFORM_DOWN, STR_LANDSCAPING_TOOLTIP_LOWER_A_CORNER_OF_LAND),
456  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_ETT_RAISE_LAND), SetMinimalSize(22, 22),
457  SetFill(0, 1), SetDataTip(SPR_IMG_TERRAFORM_UP, STR_LANDSCAPING_TOOLTIP_RAISE_A_CORNER_OF_LAND),
458  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_ETT_LEVEL_LAND), SetMinimalSize(22, 22),
459  SetFill(0, 1), SetDataTip(SPR_IMG_LEVEL_LAND, STR_LANDSCAPING_LEVEL_LAND_TOOLTIP),
460  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_ETT_PLACE_ROCKS), SetMinimalSize(22, 22),
461  SetFill(0, 1), SetDataTip(SPR_IMG_ROCKS, STR_TERRAFORM_TOOLTIP_PLACE_ROCKY_AREAS_ON_LANDSCAPE),
463  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_ETT_PLACE_DESERT), SetMinimalSize(22, 22),
464  SetFill(0, 1), SetDataTip(SPR_IMG_DESERT, STR_TERRAFORM_TOOLTIP_DEFINE_DESERT_AREA),
465  EndContainer(),
467  SetFill(0, 1), SetDataTip(SPR_IMG_TRANSMITTER, STR_SCENEDIT_TOOLBAR_PLACE_OBJECT),
468  NWidget(NWID_SPACER), SetFill(1, 0),
469  EndContainer(),
471  NWidget(NWID_SPACER), SetFill(1, 0),
472  NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_ETT_DOTS), SetMinimalSize(59, 31), SetDataTip(STR_EMPTY, STR_NULL),
473  NWidget(NWID_SPACER), SetFill(1, 0),
475  NWidget(NWID_SPACER), SetFill(0, 1),
476  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_ETT_INCREASE_SIZE), SetMinimalSize(12, 12), SetDataTip(SPR_ARROW_UP, STR_TERRAFORM_TOOLTIP_INCREASE_SIZE_OF_LAND_AREA),
478  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_ETT_DECREASE_SIZE), SetMinimalSize(12, 12), SetDataTip(SPR_ARROW_DOWN, STR_TERRAFORM_TOOLTIP_DECREASE_SIZE_OF_LAND_AREA),
479  NWidget(NWID_SPACER), SetFill(0, 1),
480  EndContainer(),
482  EndContainer(),
484  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_ETT_NEW_SCENARIO), SetMinimalSize(160, 12),
485  SetFill(1, 0), SetDataTip(STR_TERRAFORM_SE_NEW_WORLD, STR_TERRAFORM_TOOLTIP_GENERATE_RANDOM_LAND), SetPadding(0, 2, 0, 2),
487  SetFill(1, 0), SetDataTip(STR_TERRAFORM_RESET_LANDSCAPE, STR_TERRAFORM_RESET_LANDSCAPE_TOOLTIP), SetPadding(1, 2, 2, 2),
488  EndContainer(),
489 };
490 
496 static void ResetLandscapeConfirmationCallback(Window *w, bool confirmed)
497 {
498  if (confirmed) {
499  /* Set generating_world to true to get instant-green grass after removing
500  * company property. */
501  Backup<bool> old_generating_world(_generating_world, true, FILE_LINE);
502 
503  /* Delete all companies */
504  for (Company *c : Company::Iterate()) {
506  delete c;
507  }
508 
509  old_generating_world.Restore();
510 
511  /* Delete all station signs */
512  for (BaseStation *st : BaseStation::Iterate()) {
513  /* There can be buoys, remove them */
514  if (IsBuoyTile(st->xy)) DoCommand(st->xy, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
515  if (!st->IsInUse()) delete st;
516  }
517 
518  /* Now that all vehicles are gone, we can reset the engine pool. Maybe it reduces some NewGRF changing-mess */
520 
522  }
523 }
524 
528 
530  {
531  this->CreateNestedTree();
532  NWidgetStacked *show_desert = this->GetWidget<NWidgetStacked>(WID_ETT_SHOW_PLACE_DESERT);
533  show_desert->SetDisplayedPlane(_settings_game.game_creation.landscape == LT_TROPIC ? 0 : SZSP_NONE);
534  this->FinishInitNested(window_number);
535  this->last_user_action = WIDGET_LIST_END;
536  }
537 
538  void OnPaint() override
539  {
540  this->DrawWidgets();
541 
542  if (this->IsWidgetLowered(WID_ETT_LOWER_LAND) || this->IsWidgetLowered(WID_ETT_RAISE_LAND)) { // change area-size if raise/lower corner is selected
543  SetTileSelectSize(_terraform_size, _terraform_size);
544  }
545  }
546 
547  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
548  {
549  if (widget != WID_ETT_DOTS) return;
550 
551  size->width = std::max<uint>(size->width, ScaleGUITrad(59));
552  size->height = std::max<uint>(size->height, ScaleGUITrad(31));
553  }
554 
555  void DrawWidget(const Rect &r, int widget) const override
556  {
557  if (widget != WID_ETT_DOTS) return;
558 
559  int center_x = RoundDivSU(r.left + r.right, 2);
560  int center_y = RoundDivSU(r.top + r.bottom, 2);
561 
562  int n = _terraform_size * _terraform_size;
563  const int8 *coords = &_multi_terraform_coords[0][0];
564 
565  assert(n != 0);
566  do {
567  DrawSprite(SPR_WHITE_POINT, PAL_NONE, center_x + ScaleGUITrad(coords[0]), center_y + ScaleGUITrad(coords[1]));
568  coords += 2;
569  } while (--n);
570  }
571 
572  void OnClick(Point pt, int widget, int click_count) override
573  {
574  if (widget < WID_ETT_BUTTONS_START) return;
575 
576  switch (widget) {
577  case WID_ETT_DEMOLISH: // Demolish aka dynamite button
579  this->last_user_action = widget;
580  break;
581 
582  case WID_ETT_LOWER_LAND: // Lower land button
584  this->last_user_action = widget;
585  break;
586 
587  case WID_ETT_RAISE_LAND: // Raise land button
589  this->last_user_action = widget;
590  break;
591 
592  case WID_ETT_LEVEL_LAND: // Level land button
593  HandlePlacePushButton(this, WID_ETT_LEVEL_LAND, SPR_CURSOR_LEVEL_LAND, HT_POINT | HT_DIAGONAL);
594  this->last_user_action = widget;
595  break;
596 
597  case WID_ETT_PLACE_ROCKS: // Place rocks button
598  HandlePlacePushButton(this, WID_ETT_PLACE_ROCKS, SPR_CURSOR_ROCKY_AREA, HT_RECT);
599  this->last_user_action = widget;
600  break;
601 
602  case WID_ETT_PLACE_DESERT: // Place desert button (in tropical climate)
603  HandlePlacePushButton(this, WID_ETT_PLACE_DESERT, SPR_CURSOR_DESERT, HT_RECT);
604  this->last_user_action = widget;
605  break;
606 
607  case WID_ETT_PLACE_OBJECT: // Place transmitter button
609  break;
610 
612  case WID_ETT_DECREASE_SIZE: { // Increase/Decrease terraform size
613  int size = (widget == WID_ETT_INCREASE_SIZE) ? 1 : -1;
614  this->HandleButtonClick(widget);
615  size += _terraform_size;
616 
617  if (!IsInsideMM(size, 1, 8 + 1)) return;
618  _terraform_size = size;
619 
621  this->SetDirty();
622  break;
623  }
624 
625  case WID_ETT_NEW_SCENARIO: // gen random land
626  this->HandleButtonClick(widget);
628  break;
629 
630  case WID_ETT_RESET_LANDSCAPE: // Reset landscape
631  ShowQuery(STR_QUERY_RESET_LANDSCAPE_CAPTION, STR_RESET_LANDSCAPE_CONFIRMATION_TEXT, nullptr, ResetLandscapeConfirmationCallback);
632  break;
633 
634  default: NOT_REACHED();
635  }
636  }
637 
638  void OnTimeout() override
639  {
640  for (uint i = WID_ETT_START; i < this->nested_array_size; i++) {
641  if (i == WID_ETT_BUTTONS_START) i = WID_ETT_BUTTONS_END; // skip the buttons
642  if (this->IsWidgetLowered(i)) {
643  this->RaiseWidget(i);
644  this->SetWidgetDirty(i);
645  }
646  }
647  }
648 
649  void OnPlaceObject(Point pt, TileIndex tile) override
650  {
651  switch (this->last_user_action) {
652  case WID_ETT_DEMOLISH: // Demolish aka dynamite button
654  break;
655 
656  case WID_ETT_LOWER_LAND: // Lower land button
657  CommonRaiseLowerBigLand(tile, 0);
658  break;
659 
660  case WID_ETT_RAISE_LAND: // Raise land button
661  CommonRaiseLowerBigLand(tile, 1);
662  break;
663 
664  case WID_ETT_LEVEL_LAND: // Level land button
666  break;
667 
668  case WID_ETT_PLACE_ROCKS: // Place rocks button
670  break;
671 
672  case WID_ETT_PLACE_DESERT: // Place desert button (in tropical climate)
674  break;
675 
676  default: NOT_REACHED();
677  }
678  }
679 
680  void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
681  {
682  VpSelectTilesWithMethod(pt.x, pt.y, select_method);
683  }
684 
685  void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
686  {
687  if (pt.x != -1) {
688  switch (select_proc) {
689  default: NOT_REACHED();
690  case DDSP_CREATE_ROCKS:
691  case DDSP_CREATE_DESERT:
694  case DDSP_LEVEL_AREA:
695  case DDSP_DEMOLISH_AREA:
696  GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
697  break;
698  }
699  }
700  }
701 
702  void OnPlaceObjectAbort() override
703  {
704  this->RaiseButtons();
705  this->SetDirty();
706  }
707 
708  static HotkeyList hotkeys;
709 };
710 
717 {
718  if (_game_mode != GM_EDITOR) return ES_NOT_HANDLED;
720  if (w == nullptr) return ES_NOT_HANDLED;
721  return w->OnHotkey(hotkey);
722 }
723 
724 static Hotkey terraform_editor_hotkeys[] = {
725  Hotkey('D' | WKC_GLOBAL_HOTKEY, "dynamite", WID_ETT_DEMOLISH),
729  Hotkey('R', "rocky", WID_ETT_PLACE_ROCKS),
730  Hotkey('T', "desert", WID_ETT_PLACE_DESERT),
731  Hotkey('O', "object", WID_ETT_PLACE_OBJECT),
732  HOTKEY_LIST_END
733 };
734 
735 HotkeyList ScenarioEditorLandscapeGenerationWindow::hotkeys("terraform_editor", terraform_editor_hotkeys, TerraformToolbarEditorGlobalHotkeys);
736 
737 static WindowDesc _scen_edit_land_gen_desc(
738  WDP_AUTO, "toolbar_landscape_scen", 0, 0,
741  _nested_scen_edit_land_gen_widgets, lengthof(_nested_scen_edit_land_gen_widgets),
742  &ScenarioEditorLandscapeGenerationWindow::hotkeys
743 );
744 
750 {
751  return AllocateWindowDescFront<ScenarioEditorLandscapeGenerationWindow>(&_scen_edit_land_gen_desc, 0);
752 }
SZSP_NONE
@ SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
Definition: widget_type.h:423
MP_CLEAR
@ MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
Definition: tile_type.h:46
SetTileSelectSize
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
Definition: viewport.cpp:2472
DDSP_DEMOLISH_AREA
@ DDSP_DEMOLISH_AREA
Clear area.
Definition: viewport_type.h:116
CommonRaiseLowerBigLand
static void CommonRaiseLowerBigLand(TileIndex tile, int mode)
Raise/Lower a bigger chunk of land at the same time in the editor.
Definition: terraform_gui.cpp:392
CMD_MSG
#define CMD_MSG(x)
Used to combine a StringID with the command.
Definition: command_type.h:372
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:83
TROPICZONE_DESERT
@ TROPICZONE_DESERT
Tile is desert.
Definition: tile_type.h:76
TerraformToolbarWindow::OnInitialPosition
Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
Compute the initial position of the window.
Definition: terraform_gui.cpp:257
sound_func.h
CMD_CLEAR_AREA
@ CMD_CLEAR_AREA
clear an area
Definition: command_type.h:274
EngineOverrideManager::ResetToCurrentNewGRFConfig
static bool ResetToCurrentNewGRFConfig()
Tries to reset the engine mapping to match the current NewGRF configuration.
Definition: engine.cpp:513
ScenarioEditorLandscapeGenerationWindow::last_user_action
int last_user_action
Last started user action.
Definition: terraform_gui.cpp:527
DoCommand
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
Definition: command.cpp:450
HotkeyList
List of hotkeys for a window.
Definition: hotkeys.h:40
landscape_type.h
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
command_func.h
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:64
SetPadding
static NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1139
DDSP_CREATE_ROCKS
@ DDSP_CREATE_ROCKS
Fill area with rocks.
Definition: viewport_type.h:121
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:210
WID_ETT_LOWER_LAND
@ WID_ETT_LOWER_LAND
Lower land button.
Definition: terraform_widget.h:34
GameCreationSettings::landscape
byte landscape
the landscape we're currently in
Definition: settings_type.h:320
Backup
Class to backup a specific variable and restore it later.
Definition: backup_type.hpp:21
company_base.h
ViewportDragDropSelectionProcess
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
Definition: viewport_type.h:115
ANIMCURSOR_RAISELAND
static const CursorID ANIMCURSOR_RAISELAND
696 - 698 - raise land tool
Definition: sprites.h:1500
CLEAR_ROCKS
@ CLEAR_ROCKS
3
Definition: clear_map.h:22
DDSP_LEVEL_AREA
@ DDSP_LEVEL_AREA
Level area.
Definition: viewport_type.h:119
signs_func.h
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:50
ScenarioEditorLandscapeGenerationWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: terraform_gui.cpp:555
WID_ETT_RESET_LANDSCAPE
@ WID_ETT_RESET_LANDSCAPE
Button for removing all company-owned property.
Definition: terraform_widget.h:44
SetRedErrorSquare
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Definition: viewport.cpp:2454
Window::CreateNestedTree
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1760
MakeClear
static void MakeClear(TileIndex t, ClearGround g, uint density)
Make a clear tile.
Definition: clear_map.h:259
TREE_GROUND_SHORE
@ TREE_GROUND_SHORE
shore
Definition: tree_map.h:56
ScenarioEditorLandscapeGenerationWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: terraform_gui.cpp:702
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
ScenarioEditorLandscapeGenerationWindow::OnPlaceDrag
void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
The user is dragging over the map when the tile highlight mode has been set.
Definition: terraform_gui.cpp:680
PlaceProc_DemolishArea
void PlaceProc_DemolishArea(TileIndex tile)
Start a drag for demolishing an area.
Definition: terraform_gui.cpp:146
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:35
SND_15_BEEP
@ SND_15_BEEP
19 == 0x13 GUI button click
Definition: sound_type.h:58
zoom_func.h
Window::RaiseButtons
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition: window.cpp:584
WID_ETT_BUTTONS_START
@ WID_ETT_BUTTONS_START
Start of pushable buttons.
Definition: terraform_widget.h:32
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:52
WID_ETT_PLACE_ROCKS
@ WID_ETT_PLACE_ROCKS
Place rocks button.
Definition: terraform_widget.h:37
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
ANIMCURSOR_DEMOLISH
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Definition: sprites.h:1498
TerraformToolbarWindow::last_user_action
int last_user_action
Last started user action.
Definition: terraform_gui.cpp:153
TileY
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition: map_func.h:215
WindowNumber
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:711
MAX_TILE_HEIGHT
static const uint MAX_TILE_HEIGHT
Maximum allowed tile height.
Definition: tile_type.h:22
clear_map.h
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:96
Window::HandleButtonClick
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
Definition: window.cpp:646
DC_EXEC
@ DC_EXEC
execute the given command
Definition: command_type.h:348
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: window.cpp:621
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:971
TerraformToolbarWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition: terraform_gui.cpp:167
genworld.h
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1107
ScenarioEditorLandscapeGenerationWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: terraform_gui.cpp:538
WID_ETT_BUTTONS_END
@ WID_ETT_BUTTONS_END
End of pushable buttons.
Definition: terraform_widget.h:40
WID_ETT_NEW_SCENARIO
@ WID_ETT_NEW_SCENARIO
Button for generating a new scenario.
Definition: terraform_widget.h:43
LM_LEVEL
@ LM_LEVEL
Level the land.
Definition: map_type.h:82
CommandCost::Succeeded
bool Succeeded() const
Did this command succeed?
Definition: command_type.h:150
textbuf_gui.h
TileX
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition: map_func.h:205
TerraformToolbarWindow::OnPlaceMouseUp
void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
The user has dragged over the map when the tile highlight mode has been set.
Definition: terraform_gui.cpp:264
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:576
IsInsideMM
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
Definition: math_func.hpp:204
TerraformToolbarEditorGlobalHotkeys
static EventState TerraformToolbarEditorGlobalHotkeys(int hotkey)
Handler for global hotkeys of the ScenarioEditorLandscapeGenerationWindow.
Definition: terraform_gui.cpp:716
WindowDesc
High level window description.
Definition: window_gui.h:168
window_gui.h
TerraformToolbarWindow::OnPlaceObject
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
Definition: terraform_gui.cpp:221
WID_ETT_RAISE_LAND
@ WID_ETT_RAISE_LAND
Raise land button.
Definition: terraform_widget.h:35
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:156
GenerateDesertArea
static void GenerateDesertArea(TileIndex end, TileIndex start)
Scenario editor command that generates desert areas.
Definition: terraform_gui.cpp:54
WKC_GLOBAL_HOTKEY
@ WKC_GLOBAL_HOTKEY
Fake keycode bit to indicate global hotkeys.
Definition: gfx_type.h:33
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:317
CommandCost
Common return value for all commands.
Definition: command_type.h:23
SetTropicZone
static void SetTropicZone(TileIndex tile, TropicZone type)
Set the tropic zone.
Definition: tile_map.h:225
ScenarioEditorLandscapeGenerationWindow::OnPlaceMouseUp
void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
The user has dragged over the map when the tile highlight mode has been set.
Definition: terraform_gui.cpp:685
tilehighlight_func.h
TileHeight
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
Definition: tile_map.h:29
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:596
CMD_TERRAFORM_LAND
@ CMD_TERRAFORM_LAND
terraform a tile
Definition: command_type.h:186
DoCommandP
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Definition: command.cpp:541
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:315
VpStartPlaceSizing
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Definition: viewport.cpp:2654
ShowCreateScenario
void ShowCreateScenario()
Show the window to create a scenario.
Definition: genworld_gui.cpp:1268
GenerateRockyArea
static void GenerateRockyArea(TileIndex end, TileIndex start)
Scenario editor command that generates rocky areas.
Definition: terraform_gui.cpp:71
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:993
ScenarioEditorLandscapeGenerationWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: terraform_gui.cpp:547
HT_DIAGONAL
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
Definition: tilehighlight_type.h:28
WID_TT_LOWER_LAND
@ WID_TT_LOWER_LAND
Lower land button.
Definition: terraform_widget.h:17
INVALID_OWNER
@ INVALID_OWNER
An invalid owner.
Definition: company_type.h:29
OrthogonalTileArea::w
uint16 w
The width of the area.
Definition: tilearea_type.h:20
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:719
WID_TT_RAISE_LAND
@ WID_TT_RAISE_LAND
Raise land button.
Definition: terraform_widget.h:18
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition: viewport.cpp:3139
OrthogonalTileArea
Represents the covered area of e.g.
Definition: tilearea_type.h:18
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:53
WID_TT_PLACE_OBJECT
@ WID_TT_PLACE_OBJECT
Place object button.
Definition: terraform_widget.h:24
WID_TT_PLANT_TREES
@ WID_TT_PLANT_TREES
Plant trees button (note: opens separate window, no place-push-button).
Definition: terraform_widget.h:22
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
safeguards.h
ScenarioEditorLandscapeGenerationWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: terraform_gui.cpp:572
GetToolbarAlignedWindowPosition
Point GetToolbarAlignedWindowPosition(int window_width)
Computer the position of the top-left corner of a window to be opened right under the toolbar.
Definition: window.cpp:1664
HandlePlacePushButton
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
Definition: main_gui.cpp:61
Window::left
int left
x position of left edge of the window
Definition: window_gui.h:312
ConstructionSettings::freeform_edges
bool freeform_edges
allow terraforming the tiles at the map edges
Definition: settings_type.h:345
WID_ETT_PLACE_OBJECT
@ WID_ETT_PLACE_OBJECT
Place transmitter button.
Definition: terraform_widget.h:39
WID_ETT_DOTS
@ WID_ETT_DOTS
Invisible widget for rendering the terraform size on.
Definition: terraform_widget.h:31
DrawSprite
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:1041
DDSP_LOWER_AND_LEVEL_AREA
@ DDSP_LOWER_AND_LEVEL_AREA
Lower / level area.
Definition: viewport_type.h:118
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
WID_ETT_SHOW_PLACE_DESERT
@ WID_ETT_SHOW_PLACE_DESERT
Should the place desert button be shown?
Definition: terraform_widget.h:29
stdafx.h
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:307
TerraformToolbarWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: terraform_gui.cpp:174
RoundDivSU
static int RoundDivSU(int a, uint b)
Computes round(a / b) for signed a and unsigned b.
Definition: math_func.hpp:276
WID_TT_SHOW_PLACE_OBJECT
@ WID_TT_SHOW_PLACE_OBJECT
Should the place object button be shown?
Definition: terraform_widget.h:15
DC_BANKRUPT
@ DC_BANKRUPT
company bankrupts, skip money check, skip vehicle on tile check in some cases
Definition: command_type.h:354
LM_RAISE
@ LM_RAISE
Raise the land.
Definition: map_type.h:84
NWidgetStacked::SetDisplayedPlane
void SetDisplayedPlane(int plane)
Select which plane to show (for NWID_SELECTION only).
Definition: widget.cpp:1195
CMD_LEVEL_LAND
@ CMD_LEVEL_LAND
level land
Definition: command_type.h:301
viewport_func.h
terraform_widget.h
NWidgetStacked
Stacked widgets, widgets all occupying the same space in the window.
Definition: widget_type.h:438
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:37
ResetLandscapeConfirmationCallback
static void ResetLandscapeConfirmationCallback(Window *w, bool confirmed)
Callback function for the scenario editor 'reset landscape' confirmation window.
Definition: terraform_gui.cpp:496
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
newgrf_object.h
OrthogonalTileArea::h
uint16 h
The height of the area.
Definition: tilearea_type.h:21
WID_TT_BUTTONS_START
@ WID_TT_BUTTONS_START
Start of pushable buttons.
Definition: terraform_widget.h:16
MP_TREES
@ MP_TREES
Tile got trees.
Definition: tile_type.h:50
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
OBJECT_OWNED_LAND
static const ObjectType OBJECT_OWNED_LAND
Owned land 'flag'.
Definition: object_type.h:19
_generating_world
bool _generating_world
Whether we are generating the map or not.
Definition: genworld.cpp:61
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
WWT_PUSHIMGBTN
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:105
ShowQuery
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
Show a modal confirmation window with standard 'yes' and 'no' buttons The window is aligned to the ce...
Definition: misc_gui.cpp:1267
IsBuoyTile
static bool IsBuoyTile(TileIndex t)
Is tile t a buoy tile?
Definition: station_map.h:316
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:208
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1092
SLOPE_N
@ SLOPE_N
the north corner of the tile is raised
Definition: slope_type.h:53
Pool::PoolItem<&_company_pool >::Iterate
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:386
strings_func.h
TerraformToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: terraform_gui.cpp:279
terraform_gui.h
MapMaxY
static uint MapMaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
Definition: map_func.h:111
WID_ETT_LEVEL_LAND
@ WID_ETT_LEVEL_LAND
Level land button.
Definition: terraform_widget.h:36
_terraform_err_tile
TileIndex _terraform_err_tile
first tile we couldn't terraform
Definition: terraform_cmd.cpp:39
WIDGET_LIST_END
static const int WIDGET_LIST_END
indicate the end of widgets' list for vararg functions
Definition: widget_type.h:20
WID_ETT_START
@ WID_ETT_START
Used for iterations.
Definition: terraform_widget.h:30
Backup::Restore
void Restore()
Restore the variable.
Definition: backup_type.hpp:112
WC_SCEN_LAND_GEN
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
Definition: window_type.h:441
ScaleGUITrad
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Definition: zoom_func.h:76
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1207
TerraformToolbarWindow::OnPlaceDrag
void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
The user is dragging over the map when the tile highlight mode has been set.
Definition: terraform_gui.cpp:252
InvalidateWindowClassesData
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
Definition: window.cpp:3235
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1010
tree_map.h
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
MarkTileDirtyByTile
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
Definition: viewport.cpp:1987
TileDiffXY
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
Definition: map_func.h:179
WID_TT_BUY_LAND
@ WID_TT_BUY_LAND
Buy land button.
Definition: terraform_widget.h:21
Window::IsWidgetLowered
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:487
DDSP_RAISE_AND_LEVEL_AREA
@ DDSP_RAISE_AND_LEVEL_AREA
Raise / level area.
Definition: viewport_type.h:117
EventState
EventState
State of handling an event.
Definition: window_type.h:717
HT_RECT
@ HT_RECT
rectangle (stations, depots, ...)
Definition: tilehighlight_type.h:21
VPM_X_AND_Y
@ VPM_X_AND_Y
area of land in X and Y directions
Definition: viewport_type.h:100
CMD_BUILD_OBJECT
@ CMD_BUILD_OBJECT
build an object
Definition: command_type.h:187
base_station_base.h
PlaceProc_Sign
void PlaceProc_Sign(TileIndex tile)
PlaceProc function, called when someone pressed the button if the sign-tool is selected.
Definition: signs_cmd.cpp:131
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1776
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
BaseStation
Base class for all station-ish types.
Definition: base_station_base.h:52
company_func.h
MapMaxX
static uint MapMaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
Definition: map_func.h:102
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:313
TerraformToolbarGlobalHotkeys
static EventState TerraformToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the TerraformToolbarWindow.
Definition: terraform_gui.cpp:292
GetTreeGround
static TreeGround GetTreeGround(TileIndex t)
Returns the groundtype for tree tiles.
Definition: tree_map.h:88
ScenarioEditorLandscapeGenerationWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: terraform_gui.cpp:638
window_func.h
SoundSettings::click_beep
bool click_beep
Beep on a random selection of buttons.
Definition: settings_type.h:209
WID_TT_DEMOLISH
@ WID_TT_DEMOLISH
Demolish aka dynamite button.
Definition: terraform_widget.h:20
TerraformToolbarWindow
Terra form toolbar managing class.
Definition: terraform_gui.cpp:152
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:378
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:314
ScenarioEditorLandscapeGenerationWindow
Landscape generation window handler in the scenario editor.
Definition: terraform_gui.cpp:526
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition: terraform_gui.cpp:357
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1689
WDP_MANUAL
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
Definition: window_gui.h:155
SND_1F_CONSTRUCTION_OTHER
@ SND_1F_CONSTRUCTION_OTHER
29 == 0x1D Construction: other (non-water, non-rail, non-bridge)
Definition: sound_type.h:68
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1176
engine_base.h
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1076
WC_TOWN_VIEW
@ WC_TOWN_VIEW
Town view; Window numbers:
Definition: window_type.h:325
gui.h
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition: settings_type.h:577
Window
Data structure for an opened window.
Definition: window_gui.h:279
GetTileType
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
Definition: tile_map.h:96
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:326
Window::RaiseWidget
void RaiseWidget(byte widget_index)
Marks a widget as raised.
Definition: window_gui.h:477
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:636
TROPICZONE_NORMAL
@ TROPICZONE_NORMAL
Normal tropiczone.
Definition: tile_type.h:75
ShowBuildObjectPicker
Window * ShowBuildObjectPicker()
Show our object picker.
Definition: object_gui.cpp:712
HT_POINT
@ HT_POINT
point (lower land, raise land, level land, ...)
Definition: tilehighlight_type.h:22
WID_ETT_DECREASE_SIZE
@ WID_ETT_DECREASE_SIZE
Downwards arrow button to decrease terraforming size.
Definition: terraform_widget.h:42
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:78
Window::nested_array_size
uint nested_array_size
Size of the nested array.
Definition: window_gui.h:326
OrthogonalTileArea::ClampToMap
void ClampToMap()
Clamp the tile area to map borders.
Definition: tilearea.cpp:142
Window::SetWidgetDirty
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:608
WID_ETT_PLACE_DESERT
@ WID_ETT_PLACE_DESERT
Place desert button (in tropical climate).
Definition: terraform_widget.h:38
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
Company
Definition: company_base.h:115
ChangeOwnershipOfCompanyItems
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
Change the ownership of all the items of a company.
Definition: economy.cpp:282
WID_TT_LEVEL_LAND
@ WID_TT_LEVEL_LAND
Level land button.
Definition: terraform_widget.h:19
WID_ETT_DEMOLISH
@ WID_ETT_DEMOLISH
Demolish aka dynamite button.
Definition: terraform_widget.h:33
LM_LOWER
@ LM_LOWER
Lower the land.
Definition: map_type.h:83
ScenarioEditorLandscapeGenerationWindow::OnPlaceObject
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
Definition: terraform_gui.cpp:649
TD_RTL
@ TD_RTL
Text is written right-to-left by default.
Definition: strings_type.h:24
_current_text_dir
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:48
WID_TT_PLACE_SIGN
@ WID_TT_PLACE_SIGN
Place sign button.
Definition: terraform_widget.h:23
CMD_LANDSCAPE_CLEAR
@ CMD_LANDSCAPE_CLEAR
demolish a tile
Definition: command_type.h:180
WID_ETT_INCREASE_SIZE
@ WID_ETT_INCREASE_SIZE
Upwards arrow button to increase terraforming size.
Definition: terraform_widget.h:41
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:53
object.h
ShowEditorTerraformToolbar
Window * ShowEditorTerraformToolbar()
Show the toolbar for terraforming in the scenario editor.
Definition: terraform_gui.cpp:749
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:22
hotkeys.h
ANIMCURSOR_LOWERLAND
static const CursorID ANIMCURSOR_LOWERLAND
699 - 701 - lower land tool
Definition: sprites.h:1499
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:62
backup_type.hpp
DDSP_CREATE_DESERT
@ DDSP_CREATE_DESERT
Fill area with desert.
Definition: viewport_type.h:120
GUIPlaceProcDragXY
bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile)
A central place to handle all X_AND_Y dragged GUI functions.
Definition: terraform_gui.cpp:107