OpenTTD Source 20260911-master-gee2b2ac12a
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
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 "house.h"
16#include "gui.h"
17#include "window_gui.h"
18#include "window_func.h"
19#include "viewport_func.h"
20#include "command_func.h"
21#include "signs_func.h"
22#include "sound_func.h"
23#include "base_station_base.h"
24#include "textbuf_gui.h"
25#include "genworld.h"
26#include "tree_map.h"
27#include "landscape_type.h"
28#include "tilehighlight_func.h"
29#include "strings_func.h"
30#include "newgrf_object.h"
31#include "object.h"
32#include "hotkeys.h"
33#include "engine_base.h"
34#include "terraform_gui.h"
35#include "terraform_cmd.h"
36#include "zoom_func.h"
37#include "rail_cmd.h"
38#include "landscape_cmd.h"
39#include "terraform_cmd.h"
40#include "object_cmd.h"
41
43
44#include "table/strings.h"
45
46#include "safeguards.h"
47
48void CcTerraform(Commands, const CommandCost &result, Money, TileIndex tile)
49{
50 if (result.Succeeded()) {
51 if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
52 } else {
54 }
55}
56
57
63static void GenerateDesertArea(TileIndex end, TileIndex start)
64{
65 if (_game_mode != GameMode::Editor) return;
66
67 Backup<bool> old_generating_world(_generating_world, true);
68
69 TileArea ta(start, end);
70 for (TileIndex tile : ta) {
72 Command<Commands::LandscapeClear>::Post(tile);
74 }
75 old_generating_world.Restore();
76 InvalidateWindowClassesData(WindowClass::TownView, 0);
77}
78
85static void PlaceRockyArea(TileIndex end, TileIndex start, bool remove)
86{
87 if (_game_mode != GameMode::Editor) return;
88
89 bool success = false;
90 TileArea ta(start, end);
91
92 for (TileIndex tile : ta) {
93 switch (GetTileType(tile)) {
94 case TileType::Trees:
95 if (GetTreeGround(tile) == TreeGround::Shore) continue;
96 if (!remove) {
98 }
99 break;
100
101 case TileType::Clear:
102 if (remove) {
103 if (GetClearGround(tile) == ClearGround::Rocks) {
105 }
106 } else {
108 }
109 break;
110
111 case TileType::Water:
112 if (remove) {
113 switch (GetWaterTileType(tile)) {
116 default: continue;
117 }
118 } else {
119 switch (GetWaterTileType(tile)) {
121 if (GetTileSlope(tile) != SLOPE_FLAT) continue;
123 break;
124
126 default: continue;
127 }
128 }
129 break;
130
131 default:
132 continue;
133 }
135 success = true;
136 }
137
138 if (success && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, end);
139}
140
147static void PlaceRoughGround(TileIndex end, TileIndex start, bool remove)
148{
149 if (_game_mode != GameMode::Editor) return;
150
151 bool success = false;
152 TileArea ta(start, end);
153
154 for (TileIndex tile : ta) {
155 switch (GetTileType(tile)) {
156 case TileType::Trees: {
157 /* Preserve snowline density underneath trees, so the tile loop
158 * doesn't have to come back and fix it later. */
159 uint density = GetTreeDensity(tile);
160 if (remove) {
161 switch (GetTreeGround(tile)) {
164 break;
167 break;
168 default:
169 continue;
170 }
171 } else {
172 switch (GetTreeGround(tile)) {
175 break;
178 break;
179 default:
180 continue;
181 }
182 }
183 break;
184 }
185
186 case TileType::Clear:
187 if (remove) {
188 if (GetClearGround(tile) == ClearGround::Rough) {
190 } else {
191 continue;
192 }
193 } else {
195 }
196 break;
197
198 default:
199 continue;
200 }
202 success = true;
203 }
204
205 if (success && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, end);
206}
207
218{
219 if (!_settings_game.construction.freeform_edges) {
220 /* When end_tile is TileType::Void, the error tile will not be visible to the
221 * user. This happens when terraforming at the southern border. */
222 if (TileX(end_tile) == Map::MaxX()) end_tile += TileDiffXY(-1, 0);
223 if (TileY(end_tile) == Map::MaxY()) end_tile += TileDiffXY(0, -1);
224 }
225
226 switch (proc) {
228 Command<Commands::ClearArea>::Post(STR_ERROR_CAN_T_CLEAR_THIS_AREA, CcPlaySound_EXPLOSION, end_tile, start_tile, _ctrl_pressed);
229 break;
231 Command<Commands::LevelLand>::Post(STR_ERROR_CAN_T_RAISE_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LevelMode::Raise);
232 break;
234 Command<Commands::LevelLand>::Post(STR_ERROR_CAN_T_LOWER_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LevelMode::Lower);
235 break;
236 case DDSP_LEVEL_AREA:
237 Command<Commands::LevelLand>::Post(STR_ERROR_CAN_T_LEVEL_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LevelMode::Level);
238 break;
240 PlaceRockyArea(end_tile, start_tile, _ctrl_pressed);
241 break;
243 PlaceRoughGround(end_tile, start_tile, _ctrl_pressed);
244 break;
246 GenerateDesertArea(end_tile, start_tile);
247 break;
248 default:
249 return false;
250 }
251
252 return true;
253}
254
263
265struct TerraformToolbarWindow : Window {
267
268 TerraformToolbarWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc)
269 {
270 /* This is needed as we like to have the tree available on OnInit. */
271 this->CreateNestedTree();
272 this->FinishInitNested(window_number);
273 }
274
275 void OnInit() override
276 {
277 /* Don't show the place object button when there are no objects to place. */
280 }
281
282 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
283 {
284 if (widget < WID_TT_BUTTONS_START) return;
285
286 switch (widget) {
287 case WID_TT_LOWER_LAND: // Lower land button
289 this->last_user_action = widget;
290 break;
291
292 case WID_TT_RAISE_LAND: // Raise land button
294 this->last_user_action = widget;
295 break;
296
297 case WID_TT_LEVEL_LAND: // Level land button
299 this->last_user_action = widget;
300 break;
301
302 case WID_TT_DEMOLISH: // Demolish aka dynamite button
304 this->last_user_action = widget;
305 break;
306
307 case WID_TT_BUY_LAND: // Buy land button
309 this->last_user_action = widget;
310 break;
311
312 case WID_TT_PLANT_TREES: // Plant trees button
313 ShowBuildTreesToolbar();
314 break;
315
316 case WID_TT_PLACE_SIGN: // Place sign button
318 this->last_user_action = widget;
319 break;
320
321 case WID_TT_PLACE_OBJECT: // Place object button
323 break;
324
325 default: NOT_REACHED();
326 }
327 }
328
329 void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
330 {
331 switch (this->last_user_action) {
332 case WID_TT_LOWER_LAND: // Lower land button
334 break;
335
336 case WID_TT_RAISE_LAND: // Raise land button
338 break;
339
340 case WID_TT_LEVEL_LAND: // Level land button
342 break;
343
344 case WID_TT_DEMOLISH: // Demolish aka dynamite button
346 break;
347
348 case WID_TT_BUY_LAND: // Buy land button
350 break;
351
352 case WID_TT_PLACE_SIGN: // Place sign button
353 PlaceProc_Sign(tile);
354 break;
355
356 default: NOT_REACHED();
357 }
358 }
359
360 void OnPlaceDrag(ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt) override
361 {
362 VpSelectTilesWithMethod(pt.x, pt.y, select_method);
363 }
364
365 Point OnInitialPosition([[maybe_unused]] int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]] int window_number) override
366 {
368 if (FindWindowByClass(WindowClass::BuildToolbar) != nullptr && !_settings_client.gui.link_terraform_toolbar) pt.y += sm_height;
369
370 return pt;
371 }
372
373 void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, TileIndex start_tile, TileIndex end_tile) override
374 {
375 if (pt.x != -1) {
376 switch (select_proc) {
377 default: NOT_REACHED();
381 case DDSP_LEVEL_AREA:
382 GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
383 break;
385 if (!_settings_game.construction.freeform_edges) {
386 /* When end_tile is TileType::Void, the error tile will not be visible to the
387 * user. This happens when terraforming at the southern border. */
388 if (TileX(end_tile) == Map::MaxX()) end_tile += TileDiffXY(-1, 0);
389 if (TileY(end_tile) == Map::MaxY()) end_tile += TileDiffXY(0, -1);
390 }
391 Command<Commands::BuildObjectArea>::Post(STR_ERROR_CAN_T_PURCHASE_THIS_LAND, CcPlaySound_CONSTRUCTION_RAIL,
392 end_tile, start_tile, OBJECT_OWNED_LAND, 0, _ctrl_pressed);
393 break;
394 }
395 }
396 }
397
398 void OnPlaceObjectAbort() override
399 {
400 this->RaiseButtons();
401 }
402
409 {
410 if (_game_mode != GameMode::Normal) return EventState::NotHandled;
411 Window *w = ShowTerraformToolbar(nullptr);
412 if (w == nullptr) return EventState::NotHandled;
413 return w->OnHotkey(hotkey);
414 }
415
416 static inline HotkeyList hotkeys{"terraform", {
420 Hotkey('D' | WKC_GLOBAL_HOTKEY, "dynamite", WID_TT_DEMOLISH),
421 Hotkey('U', "buyland", WID_TT_BUY_LAND),
422 Hotkey('I', "trees", WID_TT_PLANT_TREES),
423 Hotkey('O', "placesign", WID_TT_PLACE_SIGN),
424 Hotkey('P', "placeobject", WID_TT_PLACE_OBJECT),
426};
427
428static constexpr std::initializer_list<NWidgetPart> _nested_terraform_widgets = {
431 NWidget(WWT_CAPTION, Colours::DarkGreen), SetStringTip(STR_LANDSCAPING_TOOLBAR, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
433 EndContainer(),
436 SetFill(0, 1), SetSpriteTip(SPR_IMG_TERRAFORM_DOWN, STR_LANDSCAPING_TOOLTIP_LOWER_A_CORNER_OF_LAND),
438 SetFill(0, 1), SetSpriteTip(SPR_IMG_TERRAFORM_UP, STR_LANDSCAPING_TOOLTIP_RAISE_A_CORNER_OF_LAND),
440 SetFill(0, 1), SetSpriteTip(SPR_IMG_LEVEL_LAND, STR_LANDSCAPING_LEVEL_LAND_TOOLTIP),
441
443
445 SetFill(0, 1), SetSpriteTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
447 SetFill(0, 1), SetSpriteTip(SPR_IMG_BUY_LAND, STR_LANDSCAPING_TOOLTIP_PURCHASE_LAND),
449 SetFill(0, 1), SetSpriteTip(SPR_IMG_PLANTTREES, STR_SCENEDIT_TOOLBAR_PLANT_TREES_TOOLTIP),
451 SetFill(0, 1), SetSpriteTip(SPR_IMG_SIGN, STR_SCENEDIT_TOOLBAR_PLACE_SIGN_TOOLTIP),
454 SetFill(0, 1), SetSpriteTip(SPR_IMG_TRANSMITTER, STR_SCENEDIT_TOOLBAR_PLACE_OBJECT_TOOLTIP),
455 EndContainer(),
456 EndContainer(),
457};
458
461 WindowPosition::Manual, "toolbar_landscape", 0, 0,
462 WindowClass::ScenarioGenerateLandscape, WindowClass::None,
464 _nested_terraform_widgets,
465 &TerraformToolbarWindow::hotkeys
466);
467
474{
475 if (!Company::IsValidID(_local_company)) return nullptr;
476
477 /* Delete the terraform toolbar to place it again. */
478 CloseWindowById(WindowClass::ScenarioGenerateLandscape, 0, true);
479
481
483 /* Put the linked toolbar to the left / right of the main toolbar. */
484 link->left = w->left + (_current_text_dir == TD_RTL ? w->width : -link->width);
485 link->top = w->top;
486 link->SetDirty();
487
488 return w;
489}
490
491static uint8_t _terraform_size = 1;
492
502static void CommonRaiseLowerBigLand(TileIndex tile, bool mode)
503{
504 if (_terraform_size == 1) {
505 StringID msg =
506 mode ? STR_ERROR_CAN_T_RAISE_LAND_HERE : STR_ERROR_CAN_T_LOWER_LAND_HERE;
507
508 Command<Commands::TerraformLand>::Post(msg, CcTerraform, tile, SLOPE_N, mode);
509 } else {
510 assert(_terraform_size != 0);
511 TileArea ta(tile, _terraform_size, _terraform_size);
512 ta.ClampToMap();
513
514 if (ta.w == 0 || ta.h == 0) return;
515
516 if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
517
518 uint h;
519 if (mode != 0) {
520 /* Raise land */
521 h = MAX_TILE_HEIGHT;
522 for (TileIndex tile2 : ta) {
523 h = std::min(h, TileHeight(tile2));
524 }
525 } else {
526 /* Lower land */
527 h = 0;
528 for (TileIndex tile2 : ta) {
529 h = std::max(h, TileHeight(tile2));
530 }
531 }
532
533 for (TileIndex tile2 : ta) {
534 if (TileHeight(tile2) == h) {
535 Command<Commands::TerraformLand>::Post(tile2, SLOPE_N, mode);
536 }
537 }
538 }
539}
540
541static const int8_t _multi_terraform_coords[][2] = {
542 { 0, -2},
543 { 4, 0}, { -4, 0}, { 0, 2},
544 { -8, 2}, { -4, 4}, { 0, 6}, { 4, 4}, { 8, 2},
545 {-12, 0}, { -8, -2}, { -4, -4}, { 0, -6}, { 4, -4}, { 8, -2}, { 12, 0},
546 {-16, 2}, {-12, 4}, { -8, 6}, { -4, 8}, { 0, 10}, { 4, 8}, { 8, 6}, { 12, 4}, { 16, 2},
547 {-20, 0}, {-16, -2}, {-12, -4}, { -8, -6}, { -4, -8}, { 0,-10}, { 4, -8}, { 8, -6}, { 12, -4}, { 16, -2}, { 20, 0},
548 {-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},
549 {-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},
550};
551
552static constexpr std::initializer_list<NWidgetPart> _nested_scen_edit_land_gen_widgets = {
555 NWidget(WWT_CAPTION, Colours::DarkGreen), SetStringTip(STR_TERRAFORM_TOOLBAR_LAND_GENERATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
558 EndContainer(),
560 NWidget(NWID_HORIZONTAL), SetPadding(2, 2, 7, 2),
563 SetFill(0, 1), SetSpriteTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
565 SetFill(0, 1), SetSpriteTip(SPR_IMG_TERRAFORM_DOWN, STR_TERRAFORM_TOOLTIP_LOWER_A_CORNER_OF_LAND),
567 SetFill(0, 1), SetSpriteTip(SPR_IMG_TERRAFORM_UP, STR_TERRAFORM_TOOLTIP_RAISE_A_CORNER_OF_LAND),
569 SetFill(0, 1), SetSpriteTip(SPR_IMG_LEVEL_LAND, STR_LANDSCAPING_LEVEL_LAND_TOOLTIP),
571 SetFill(0, 1), SetSpriteTip(SPR_IMG_ROCKS, STR_TERRAFORM_TOOLTIP_PLACE_ROCKY_AREAS_ON_LANDSCAPE),
573 SetFill(0, 1), SetSpriteTip(SPR_IMG_SHOW_COUNTOURS, STR_TERRAFORM_TOOLTIP_PLACE_ROUGH_AREAS_ON_LANDSCAPE),
576 SetFill(0, 1), SetSpriteTip(SPR_IMG_DESERT, STR_TERRAFORM_TOOLTIP_DEFINE_DESERT_AREA),
577 EndContainer(),
579 SetFill(0, 1), SetSpriteTip(SPR_IMG_TRANSMITTER, STR_SCENEDIT_TOOLBAR_PLACE_OBJECT_TOOLTIP),
581 EndContainer(),
588 NWidget(WWT_IMGBTN, Colours::Grey, WID_ETT_INCREASE_SIZE), SetMinimalSize(12, 12), SetSpriteTip(SPR_ARROW_UP, STR_TERRAFORM_TOOLTIP_INCREASE_SIZE_OF_LAND_AREA),
590 NWidget(WWT_IMGBTN, Colours::Grey, WID_ETT_DECREASE_SIZE), SetMinimalSize(12, 12), SetSpriteTip(SPR_ARROW_DOWN, STR_TERRAFORM_TOOLTIP_DECREASE_SIZE_OF_LAND_AREA),
592 EndContainer(),
594 EndContainer(),
597 SetFill(1, 0), SetStringTip(STR_TERRAFORM_SE_NEW_WORLD, STR_TERRAFORM_TOOLTIP_GENERATE_RANDOM_LAND), SetPadding(0, 2, 0, 2),
599 SetFill(1, 0), SetStringTip(STR_TERRAFORM_RESET_LANDSCAPE, STR_TERRAFORM_RESET_LANDSCAPE_TOOLTIP), SetPadding(1, 2, 2, 2),
600 EndContainer(),
601};
602
607static void ResetLandscapeConfirmationCallback(Window *, bool confirmed)
608{
609 if (confirmed) {
610 /* Set generating_world to true to get instant-green grass after removing
611 * company property. */
612 Backup<bool> old_generating_world(_generating_world, true);
613
614 /* Delete all companies */
615 for (Company *c : Company::Iterate()) {
617 delete c;
618 }
619
620 old_generating_world.Restore();
621
622 /* Delete all station signs */
623 for (BaseStation *st : BaseStation::Iterate()) {
624 /* There can be buoys, remove them */
625 if (IsBuoyTile(st->xy)) Command<Commands::LandscapeClear>::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, st->xy);
626 if (!st->IsInUse()) delete st;
627 }
628
629 /* Now that all vehicles are gone, we can reset the engine pool. Maybe it reduces some NewGRF changing-mess */
631
633 }
634}
635
637struct ScenarioEditorLandscapeGenerationWindow : Window {
639
640 ScenarioEditorLandscapeGenerationWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc)
641 {
642 this->CreateNestedTree();
644 show_desert->SetDisplayedPlane(_settings_game.game_creation.landscape == LandscapeType::Tropic ? 0 : SZSP_NONE);
645 this->FinishInitNested(window_number);
646 }
647
648 void OnPaint() override
649 {
650 this->DrawWidgets();
651
652 if (this->IsWidgetLowered(WID_ETT_LOWER_LAND) || this->IsWidgetLowered(WID_ETT_RAISE_LAND)) { // change area-size if raise/lower corner is selected
653 SetTileSelectSize(_terraform_size, _terraform_size);
654 }
655 }
656
657 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
658 {
659 if (widget != WID_ETT_DOTS) return;
660
661 size.width = std::max<uint>(size.width, ScaleGUITrad(59));
662 size.height = std::max<uint>(size.height, ScaleGUITrad(31));
663 }
664
665 void DrawWidget(const Rect &r, WidgetID widget) const override
666 {
667 if (widget != WID_ETT_DOTS) return;
668
669 int center_x = RoundDivSU(r.left + r.right, 2);
670 int center_y = RoundDivSU(r.top + r.bottom, 2);
671
672 int n = _terraform_size * _terraform_size;
673 const int8_t *coords = &_multi_terraform_coords[0][0];
674
675 assert(n != 0);
676 do {
677 DrawSprite(SPR_WHITE_POINT, PAL_NONE, center_x + ScaleGUITrad(coords[0]), center_y + ScaleGUITrad(coords[1]));
678 coords += 2;
679 } while (--n);
680 }
681
682 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
683 {
684 if (widget < WID_ETT_BUTTONS_START) return;
685
686 switch (widget) {
687 case WID_ETT_DEMOLISH: // Demolish aka dynamite button
689 this->last_user_action = widget;
690 break;
691
692 case WID_ETT_LOWER_LAND: // Lower land button
694 this->last_user_action = widget;
695 break;
696
697 case WID_ETT_RAISE_LAND: // Raise land button
699 this->last_user_action = widget;
700 break;
701
702 case WID_ETT_LEVEL_LAND: // Level land button
704 this->last_user_action = widget;
705 break;
706
707 case WID_ETT_PLACE_ROCKS: // Place rocks button
709 this->last_user_action = widget;
710 break;
711
712 case WID_ETT_PLACE_ROUGH: // Place rough land button
714 this->last_user_action = widget;
715 break;
716
717 case WID_ETT_PLACE_DESERT: // Place desert button (in tropical climate)
719 this->last_user_action = widget;
720 break;
721
722 case WID_ETT_PLACE_OBJECT: // Place transmitter button
724 break;
725
727 case WID_ETT_DECREASE_SIZE: { // Increase/Decrease terraform size
728 int size = (widget == WID_ETT_INCREASE_SIZE) ? 1 : -1;
729 this->HandleButtonClick(widget);
730 size += _terraform_size;
731
732 if (!IsInsideMM(size, 1, 8 + 1)) return;
733 _terraform_size = size;
734
735 this->SetDirty();
736 break;
737 }
738
739 case WID_ETT_NEW_SCENARIO: // gen random land
740 this->HandleButtonClick(widget);
742 break;
743
744 case WID_ETT_RESET_LANDSCAPE: // Reset landscape
745 ShowQuery(
746 GetEncodedString(STR_QUERY_RESET_LANDSCAPE_CAPTION),
747 GetEncodedString(STR_RESET_LANDSCAPE_CONFIRMATION_TEXT),
749 break;
750
751 default: NOT_REACHED();
752 }
753 }
754
755 void OnTimeout() override
756 {
757 for (const auto &pair : this->widget_lookup) {
758 if (pair.first < WID_ETT_START || (pair.first >= WID_ETT_BUTTONS_START && pair.first < WID_ETT_BUTTONS_END)) continue; // skip the buttons
759 this->RaiseWidgetWhenLowered(pair.first);
760 }
761 }
762
763 void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
764 {
765 switch (this->last_user_action) {
766 case WID_ETT_DEMOLISH: // Demolish aka dynamite button
768 break;
769
770 case WID_ETT_LOWER_LAND: // Lower land button
771 if (_terraform_size == 1) {
773 } else {
774 CommonRaiseLowerBigLand(tile, false);
775 }
776 break;
777
778 case WID_ETT_RAISE_LAND: // Raise land button
779 if (_terraform_size == 1) {
781 } else {
782 CommonRaiseLowerBigLand(tile, true);
783 }
784 break;
785
786 case WID_ETT_LEVEL_LAND: // Level land button
788 break;
789
790 case WID_ETT_PLACE_ROCKS: // Place rocks button
792 break;
793
794 case WID_ETT_PLACE_ROUGH: // Place rough land button
796 break;
797
798 case WID_ETT_PLACE_DESERT: // Place desert button (in tropical climate)
800 break;
801
802 default: NOT_REACHED();
803 }
804 }
805
806 void OnPlaceDrag(ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt) override
807 {
808 VpSelectTilesWithMethod(pt.x, pt.y, select_method);
809 }
810
811 void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, TileIndex start_tile, TileIndex end_tile) override
812 {
813 if (pt.x != -1) {
814 switch (select_proc) {
815 default: NOT_REACHED();
821 case DDSP_LEVEL_AREA:
823 GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
824 break;
825 }
826 }
827 }
828
830 {
831 switch (this->last_user_action) {
835 if (this->IsWidgetLowered(this->last_user_action)) {
836 SetSelectionRed(_ctrl_pressed);
837 return EventState::Handled;
838 }
839 break;
840 }
842 }
843
844 void OnPlaceObjectAbort() override
845 {
846 this->RaiseButtons();
847 this->SetDirty();
848 }
849
856 {
857 if (_game_mode != GameMode::Editor) return EventState::NotHandled;
859 if (w == nullptr) return EventState::NotHandled;
860 return w->OnHotkey(hotkey);
861 }
862
863 static inline HotkeyList hotkeys{"terraform_editor", {
864 Hotkey('D' | WKC_GLOBAL_HOTKEY, "dynamite", WID_ETT_DEMOLISH),
868 Hotkey('R', "rocky", WID_ETT_PLACE_ROCKS),
869 Hotkey('T', "desert", WID_ETT_PLACE_DESERT),
870 Hotkey('O', "object", WID_ETT_PLACE_OBJECT),
872};
873
876 WindowPosition::Automatic, "toolbar_landscape_scen", 0, 0,
877 WindowClass::ScenarioGenerateLandscape, WindowClass::None,
879 _nested_scen_edit_land_gen_widgets,
880 &ScenarioEditorLandscapeGenerationWindow::hotkeys
881);
882
Class for backupping variables and making sure they are restored later.
Base classes/functions for base stations.
Common return value for all commands.
bool Succeeded() const
Did this command succeed?
Stacked widgets, widgets all occupying the same space in the window.
bool SetDisplayedPlane(int plane)
Select which plane to show (for NWID_SELECTION only).
Definition widget.cpp:1458
Map accessors for 'clear' tiles.
@ Rocks
Rocks with snow transition (0-3).
Definition clear_map.h:24
@ Grass
Plain grass with dirt transition (0-3).
Definition clear_map.h:22
@ Rough
Rough mounds (3).
Definition clear_map.h:23
void MakeClear(Tile t, ClearGround g, uint density)
Make a clear tile.
Definition clear_map.h:253
ClearGround GetClearGround(Tile t)
Get the type of clear tile.
Definition clear_map.h:52
void SetClearGroundDensity(Tile t, ClearGround type, uint density)
Sets ground type and density in one go, also sets the counter to 0.
Definition clear_map.h:152
Functions related to commands.
@ Execute
execute the given command
@ Bankrupt
company bankrupts, skip money check, skip vehicle on tile check in some cases
Commands
List of commands.
Definition of stuff that is very close to a company, like the company struct itself.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Functions related to companies.
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
Change the ownership of all the items of a company.
Definition economy.cpp:323
static constexpr Owner INVALID_OWNER
An invalid owner.
Base class for engines.
bool _generating_world
Whether we are generating the map or not.
Definition genworld.cpp:74
Functions related to world/map generation.
void ShowCreateScenario()
Show the window to create a scenario.
bool _ctrl_pressed
Is Ctrl pressed?
Definition gfx.cpp:39
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:1037
@ Invalid
Invalid marker.
Definition gfx_type.h:302
@ Grey
Grey.
Definition gfx_type.h:299
@ DarkGreen
Dark green.
Definition gfx_type.h:292
@ WKC_GLOBAL_HOTKEY
Fake keycode bit to indicate global hotkeys.
Definition gfx_type.h:35
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
constexpr NWidgetPart SetSpriteTip(SpriteID sprite, StringID tip={})
Widget part function for setting the sprite and tooltip.
constexpr NWidgetPart SetToolbarMinimalSize(int width)
Widget part function to setting the minimal size for a toolbar button.
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
constexpr NWidgetPart SetStringTip(StringID string, StringID tip={})
Widget part function for setting the string and tooltip.
constexpr NWidgetPart SetToolbarSpacerMinimalSize()
Widget part function to setting the minimal size for a toolbar spacer.
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=INVALID_WIDGET)
Widget part function for starting a new 'real' widget.
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Definition sprites.h:1694
static const CursorID ANIMCURSOR_LOWERLAND
699 - 701 - lower land tool
Definition sprites.h:1695
static const CursorID ANIMCURSOR_RAISELAND
696 - 698 - raise land tool
Definition sprites.h:1696
static const CursorID SPR_CURSOR_LEVEL_LAND
Definition sprites.h:1578
static const CursorID SPR_CURSOR_SIGN
Definition sprites.h:1574
static const CursorID SPR_CURSOR_ROCKY_AREA
Definition sprites.h:1582
static const CursorID SPR_CURSOR_DESERT
Definition sprites.h:1583
static const CursorID SPR_CURSOR_BUY_LAND
Definition sprites.h:1577
void SetDirty() const
Mark entire window as dirty (in need of re-paint).
Definition window.cpp:975
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition gfx.cpp:1553
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
GUI functions that shouldn't be here.
Hotkey related functions.
Definition of HouseSpec and accessors.
Command definitions related to landscape (slopes etc.).
Types related to the landscape.
@ Tropic
Landscape with distinct rainforests and deserts,.
#define Point
Macro that prevents name conflicts between included headers.
bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
Definition main_gui.cpp:63
TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
Definition map_func.h:392
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition map_func.h:429
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition map_func.h:419
@ Raise
Raise the land.
Definition map_type.h:46
@ Level
Level the land.
Definition map_type.h:44
@ Lower
Lower the land.
Definition map_type.h:45
constexpr bool IsInsideMM(const size_t x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
constexpr int RoundDivSU(int a, uint b)
Computes round(a / b) for signed a and unsigned b.
void ShowQuery(EncodedString &&caption, EncodedString &&message, Window *parent, QueryCallbackProc *callback, bool focus)
Show a confirmation window with standard 'yes' and 'no' buttons The window is aligned to the centre o...
Functions related to NewGRF objects.
Functions related to objects.
Window * ShowBuildObjectPicker()
Show our object picker.
Command definitions related to objects.
static const ObjectType OBJECT_OWNED_LAND
Owned land 'flag'.
Definition object_type.h:21
@ Editor
In the scenario editor.
Definition openttd.h:21
@ Normal
Playing a game.
Definition openttd.h:20
Command definitions for rail.
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:61
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
void PlaceProc_Sign(TileIndex tile)
PlaceProc function, called when someone pressed the button if the sign-tool is selected.
Functions related to signs.
@ SLOPE_N
the north corner of the tile is raised
Definition slope_type.h:58
@ SLOPE_FLAT
a flat tile
Definition slope_type.h:54
Functions related to sound.
@ SND_1F_CONSTRUCTION_OTHER
29 == 0x1D Construction: other (non-water, non-rail, non-bridge)
Definition sound_type.h:77
static const SpriteID SPR_IMG_PLANTTREES
Definition sprites.h:1260
static const SpriteID SPR_IMG_DYNAMITE
Definition sprites.h:1236
static const SpriteID SPR_IMG_SIGN
Definition sprites.h:1276
static const SpriteID SPR_IMG_TRANSMITTER
Definition sprites.h:1239
static const SpriteID SPR_IMG_BUY_LAND
Definition sprites.h:1277
static const SpriteID SPR_IMG_ROCKS
Definition sprites.h:1237
static const SpriteID SPR_IMG_SHOW_COUNTOURS
Definition sprites.h:1256
static const SpriteID SPR_IMG_TERRAFORM_UP
Definition sprites.h:1234
static const SpriteID SPR_IMG_LEVEL_LAND
Definition sprites.h:1240
static const SpriteID SPR_ARROW_DOWN
Definition sprites.h:85
static const SpriteID SPR_IMG_DESERT
Definition sprites.h:1238
static const SpriteID SPR_ARROW_UP
Definition sprites.h:86
static const SpriteID SPR_IMG_TERRAFORM_DOWN
Definition sprites.h:1235
bool IsBuoyTile(Tile t)
Is tile t a buoy tile?
Definition of base types and functions in a cross-platform compatible way.
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
Definition strings.cpp:90
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition strings.cpp:56
Functions related to OTTD's strings.
StrongType::Typedef< uint32_t, struct StringIDTag, StrongType::Compare, StrongType::Integer > StringID
Numeric value that represents a string, independent of the selected language.
@ TD_RTL
Text is written right-to-left by default.
Class to backup a specific variable and restore it later.
void Restore()
Restore the variable.
Base class for all station-ish types.
T y
Y coordinate.
Dimensions (a width and height) of a rectangle in 2D.
static bool ResetToCurrentNewGRFConfig()
Tries to reset the engine mapping to match the current NewGRF configuration.
Definition engine.cpp:620
List of hotkeys for a window.
Definition hotkeys.h:46
All data for a single hotkey.
Definition hotkeys.h:22
static uint MaxY()
Gets the maximum Y coordinate within the map, including TileType::Void.
Definition map_func.h:298
static uint MaxX()
Gets the maximum X coordinate within the map, including TileType::Void.
Definition map_func.h:289
void ClampToMap()
Clamp the tile area to map borders.
Definition tilearea.cpp:142
uint16_t w
The width of the area.
uint16_t h
The height of the area.
static Pool::IterateWrapper< Company > Iterate(size_t from=0)
Specification of a rectangle with absolute coordinates of all edges.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
void OnPaint() override
The window must be repainted.
WidgetID last_user_action
Last started user action.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
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.
EventState OnCTRLStateChange() override
The state of the control key has changed.
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.
void OnTimeout() override
Called when this window's timeout has been reached.
static EventState TerraformToolbarEditorGlobalHotkeys(int hotkey)
Handler for global hotkeys of the ScenarioEditorLandscapeGenerationWindow.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
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.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
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.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void OnInit() override
Notification that the nested widget tree gets initialized.
Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override
Compute the initial position of the window.
static EventState TerraformToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the TerraformToolbarWindow.
WidgetID last_user_action
Last started user action.
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
High level window description.
Definition window_gui.h:172
Number to differentiate different windows of the same class.
Data structure for an opened window.
Definition window_gui.h:273
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition window.cpp:1817
void DrawWidgets() const
Paint all widgets of a window.
Definition widget.cpp:792
void RaiseWidgetWhenLowered(WidgetID widget_index)
Marks a widget as raised and dirty (redraw), when it is marked as lowered.
Definition window_gui.h:478
ResizeInfo resize
Resize information.
Definition window_gui.h:314
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition window.cpp:1807
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
Definition window_gui.h:491
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition window.cpp:539
int left
x position of left edge of the window
Definition window_gui.h:309
int top
y position of top edge of the window
Definition window_gui.h:310
WidgetLookup widget_lookup
Indexed access to the nested widget tree. Do not access directly, use Window::GetWidget() instead.
Definition window_gui.h:322
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition window.cpp:1841
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
Definition window_gui.h:989
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
Definition window.cpp:604
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition window.cpp:579
int width
width of the window (number of pixels to the right in x direction)
Definition window_gui.h:311
WindowNumber window_number
Window number within the window class.
Definition window_gui.h:302
Command definitions related to terraforming.
static void PlaceRockyArea(TileIndex end, TileIndex start, bool remove)
Scenario editor command that generates rocky areas.
bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile)
A central place to handle all X_AND_Y dragged GUI functions.
static WindowDesc _scen_edit_land_gen_desc(WindowPosition::Automatic, "toolbar_landscape_scen", 0, 0, WindowClass::ScenarioGenerateLandscape, WindowClass::None, WindowDefaultFlag::Construction, _nested_scen_edit_land_gen_widgets, &ScenarioEditorLandscapeGenerationWindow::hotkeys)
Window definition for the landscaping toolbar for he scenario editor.
static void ResetLandscapeConfirmationCallback(Window *, bool confirmed)
Callback function for the scenario editor 'reset landscape' confirmation window.
void PlaceProc_DemolishArea(TileIndex tile)
Start a drag for demolishing an area.
static WindowDesc _terraform_desc(WindowPosition::Manual, "toolbar_landscape", 0, 0, WindowClass::ScenarioGenerateLandscape, WindowClass::None, WindowDefaultFlag::Construction, _nested_terraform_widgets, &TerraformToolbarWindow::hotkeys)
Window definition for the landscaping toolbar.
Window * ShowEditorTerraformToolbar()
Show the toolbar for terraforming in the scenario editor.
static void PlaceRoughGround(TileIndex end, TileIndex start, bool remove)
Scenario editor command that generates rough land areas.
static void CommonRaiseLowerBigLand(TileIndex tile, bool mode)
Raise/Lower a bigger chunk of land at the same time in the editor.
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
static void GenerateDesertArea(TileIndex end, TileIndex start)
Scenario editor command that generates desert areas.
GUI stuff related to terraforming.
Types related to the terraform widgets.
@ WID_ETT_INCREASE_SIZE
Upwards arrow button to increase terraforming size.
@ WID_ETT_PLACE_ROCKS
Place rocks button.
@ WID_ETT_DOTS
Invisible widget for rendering the terraform size on.
@ WID_ETT_PLACE_ROUGH
Place rough land button.
@ WID_ETT_DECREASE_SIZE
Downwards arrow button to decrease terraforming size.
@ WID_ETT_SHOW_PLACE_DESERT
Should the place desert button be shown?
@ WID_ETT_PLACE_OBJECT
Place transmitter button.
@ WID_ETT_PLACE_DESERT
Place desert button (in tropical climate).
@ WID_ETT_NEW_SCENARIO
Button for generating a new scenario.
@ WID_ETT_RESET_LANDSCAPE
Button for removing all company-owned property.
@ WID_ETT_BUTTONS_START
Start of pushable buttons.
@ WID_ETT_LEVEL_LAND
Level land button.
@ WID_ETT_LOWER_LAND
Lower land button.
@ WID_ETT_START
Used for iterations.
@ WID_ETT_RAISE_LAND
Raise land button.
@ WID_ETT_BUTTONS_END
End of pushable buttons.
@ WID_ETT_DEMOLISH
Demolish aka dynamite button.
@ WID_TT_LEVEL_LAND
Level land button.
@ WID_TT_DEMOLISH
Demolish aka dynamite button.
@ WID_TT_SHOW_PLACE_OBJECT
Should the place object button be shown?
@ WID_TT_RAISE_LAND
Raise land button.
@ WID_TT_PLACE_OBJECT
Place object button.
@ WID_TT_PLANT_TREES
Plant trees button (note: opens separate window, no place-push-button).
@ WID_TT_PLACE_SIGN
Place sign button.
@ WID_TT_BUY_LAND
Buy land button.
@ WID_TT_BUTTONS_START
Start of pushable buttons.
@ WID_TT_LOWER_LAND
Lower land button.
Stuff related to the text buffer GUI.
static uint TileHeight(Tile tile)
Returns the height of a tile.
Definition tile_map.h:29
Slope GetTileSlope(TileIndex tile)
Return the slope of a given tile inside the map.
Definition tile_map.h:279
void SetTropicZone(Tile tile, TropicZone type)
Set the tropic zone.
Definition tile_map.h:225
static TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
Definition tile_map.h:96
static constexpr uint MAX_TILE_HEIGHT
Maximum allowed tile height.
Definition tile_type.h:24
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
Definition tile_type.h:92
@ Desert
Tile is desert.
Definition tile_type.h:83
@ Normal
Normal tropiczone.
Definition tile_type.h:82
@ Water
Water tile.
Definition tile_type.h:55
@ Trees
Tile with one or more trees.
Definition tile_type.h:53
@ Clear
A tile without any structures, i.e. grass, rocks, farm fields etc.
Definition tile_type.h:49
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Functions related to tile highlights.
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
Prepare state for highlighting tiles while dragging with the mouse.
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
@ HT_POINT
point (lower land, raise land, level land, ...)
@ HT_RECT
rectangle (stations, depots, ...)
Map accessors for tree tiles.
TreeGround GetTreeGround(Tile t)
Returns the groundtype for tree tiles.
Definition tree_map.h:102
@ SnowOrDesert
Snow or desert, depending on landscape.
Definition tree_map.h:55
@ Shore
Shore.
Definition tree_map.h:56
@ RoughSnow
A snow tile that is rough underneath.
Definition tree_map.h:57
@ Grass
Normal grass.
Definition tree_map.h:53
@ Rough
Rough land.
Definition tree_map.h:54
void SetTreeGroundDensity(Tile t, TreeGround g, uint d)
Set the density and ground type of a tile with trees.
Definition tree_map.h:145
uint GetTreeDensity(Tile t)
Returns the 'density' of a tile with trees.
Definition tree_map.h:128
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Functions related to (drawing on) viewports.
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects).
@ VPM_X_AND_Y
area of land in X and Y directions
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
@ DDSP_CREATE_DESERT
Fill area with desert.
@ DDSP_CREATE_ROUGH
Fill area with rough land.
@ DDSP_LOWER_AND_LEVEL_AREA
Lower / level area.
@ DDSP_DEMOLISH_AREA
Clear area.
@ DDSP_CREATE_ROCKS
Fill area with rocks.
@ DDSP_RAISE_AND_LEVEL_AREA
Raise / level area.
@ DDSP_LEVEL_AREA
Level area.
@ DDSP_BUILD_OBJECT
Build an object.
WaterTileType GetWaterTileType(Tile t)
Get the water tile type of a tile.
Definition water_map.h:82
void SetWaterTileType(Tile t, WaterTileType type)
Set the water tile type of a tile.
Definition water_map.h:93
@ ClearRocks
Rocks on water.
Definition water_map.h:36
@ Coast
Coast.
Definition water_map.h:33
@ CoastRocks
Rocks on coast.
Definition water_map.h:37
@ Clear
Plain water.
Definition water_map.h:32
static RectPadding ScaleGUITrad(const RectPadding &r)
Scale a RectPadding to GUI zoom level.
Definition widget.cpp:49
@ WWT_IMGBTN
(Toggle) Button with image
Definition widget_type.h:41
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
@ NWID_SPACER
Invisible widget that takes some space.
Definition widget_type.h:70
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:66
@ WWT_TEXTBTN
(Toggle) Button with text
Definition widget_type.h:44
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:39
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX).
Definition widget_type.h:57
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX).
Definition widget_type.h:55
@ WWT_CAPTION
Window caption (window title between closebox and stickybox).
Definition widget_type.h:52
@ NWID_VERTICAL
Vertical container.
Definition widget_type.h:68
@ WWT_CLOSEBOX
Close box (at top-left of a window).
Definition widget_type.h:60
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition widget_type.h:37
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition widget_type.h:71
@ SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Definition window.cpp:1204
Window * FindWindowByClass(WindowClass cls)
Find any window by its class.
Definition window.cpp:1176
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:1694
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:3352
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
@ Construction
This window is used for construction; close it whenever changing company.
Definition window_gui.h:155
Twindow * AllocateWindowDescFront(WindowDesc &desc, WindowNumber window_number, Targs... extra_arguments)
Open a new window.
@ Automatic
Find a place automatically.
Definition window_gui.h:146
@ Manual
Manually align the window (so no automatic location finding).
Definition window_gui.h:145
int WidgetID
Widget ID.
Definition window_type.h:21
EventState
State of handling an event.
@ Handled
The passed event is handled.
@ NotHandled
The passed event is not handled.
static constexpr WidgetID INVALID_WIDGET
An invalid widget index.
Definition window_type.h:24
Functions related to zooming.