-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
TileInspector.cpp
2370 lines (2104 loc) 路 119 KB
/
TileInspector.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*****************************************************************************
* Copyright (c) 2014-2023 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include <algorithm>
#include <iterator>
#include <openrct2-ui/interface/Dropdown.h>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Game.h>
#include <openrct2/Input.h>
#include <openrct2/actions/TileModifyAction.h>
#include <openrct2/common.h>
#include <openrct2/core/Guard.hpp>
#include <openrct2/localisation/Formatter.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/localisation/StringIds.h>
#include <openrct2/object/FootpathItemEntry.h>
#include <openrct2/object/FootpathObject.h>
#include <openrct2/object/FootpathRailingsObject.h>
#include <openrct2/object/FootpathSurfaceObject.h>
#include <openrct2/object/LargeSceneryEntry.h>
#include <openrct2/object/ObjectEntryManager.h>
#include <openrct2/object/SmallSceneryEntry.h>
#include <openrct2/object/TerrainEdgeObject.h>
#include <openrct2/object/TerrainSurfaceObject.h>
#include <openrct2/object/WallSceneryEntry.h>
#include <openrct2/ride/RideData.h>
#include <openrct2/ride/Track.h>
#include <openrct2/sprites.h>
#include <openrct2/windows/TileInspectorGlobals.h>
#include <openrct2/world/Banner.h>
#include <openrct2/world/Footpath.h>
#include <openrct2/world/Park.h>
#include <openrct2/world/Scenery.h>
#include <openrct2/world/Surface.h>
#include <openrct2/world/TileInspector.h>
static constexpr const StringId EntranceTypeStringIds[] = {
STR_TILE_INSPECTOR_ENTRANCE_TYPE_RIDE_ENTRANCE,
STR_TILE_INSPECTOR_ENTRANCE_TYPE_RIDE_EXIT,
STR_TILE_INSPECTOR_ENTRANCE_TYPE_PARK_ENTRANC,
};
static constexpr const StringId ParkEntrancePartStringIds[] = {
STR_TILE_INSPECTOR_ENTRANCE_MIDDLE,
STR_TILE_INSPECTOR_ENTRANCE_LEFT,
STR_TILE_INSPECTOR_ENTRANCE_RIGHT,
};
static constexpr const StringId WallSlopeStringIds[] = {
STR_TILE_INSPECTOR_WALL_FLAT,
STR_TILE_INSPECTOR_WALL_SLOPED_LEFT,
STR_TILE_INSPECTOR_WALL_SLOPED_RIGHT,
STR_TILE_INSPECTOR_WALL_ANIMATION_FRAME,
};
enum WindowTileInspectorWidgetIdx
{
WIDX_BACKGROUND,
WIDX_TITLE,
WIDX_CLOSE,
WIDX_LIST,
WIDX_SPINNER_X,
WIDX_SPINNER_X_INCREASE,
WIDX_SPINNER_X_DECREASE,
WIDX_SPINNER_Y,
WIDX_SPINNER_Y_INCREASE,
WIDX_SPINNER_Y_DECREASE,
WIDX_BUTTON_REMOVE,
WIDX_BUTTON_MOVE_UP,
WIDX_BUTTON_MOVE_DOWN,
WIDX_BUTTON_ROTATE,
WIDX_BUTTON_SORT,
WIDX_BUTTON_PASTE,
WIDX_BUTTON_COPY,
WIDX_COLUMN_INVISIBLE,
WIDX_COLUMN_TYPE,
WIDX_COLUMN_BASEHEIGHT,
WIDX_COLUMN_CLEARANCEHEIGHT,
WIDX_COLUMN_DIRECTION,
WIDX_COLUMN_GHOSTFLAG,
WIDX_COLUMN_LASTFLAG,
WIDX_GROUPBOX_DETAILS,
WIDX_GROUPBOX_PROPERTIES,
PAGE_WIDGETS,
// Surface
WIDX_SURFACE_SPINNER_HEIGHT = PAGE_WIDGETS,
WIDX_SURFACE_SPINNER_HEIGHT_INCREASE,
WIDX_SURFACE_SPINNER_HEIGHT_DECREASE,
WIDX_SURFACE_BUTTON_REMOVE_FENCES,
WIDX_SURFACE_BUTTON_RESTORE_FENCES,
WIDX_SURFACE_CHECK_CORNER_N,
WIDX_SURFACE_CHECK_CORNER_E,
WIDX_SURFACE_CHECK_CORNER_S,
WIDX_SURFACE_CHECK_CORNER_W,
WIDX_SURFACE_CHECK_DIAGONAL,
// Path
WIDX_PATH_SPINNER_HEIGHT = PAGE_WIDGETS,
WIDX_PATH_SPINNER_HEIGHT_INCREASE,
WIDX_PATH_SPINNER_HEIGHT_DECREASE,
WIDX_PATH_CHECK_BROKEN,
WIDX_PATH_CHECK_SLOPED,
WIDX_PATH_CHECK_JUNCTION_RAILINGS,
WIDX_PATH_CHECK_EDGE_NE, // Note: This is NOT named after the world orientation, but after the way
WIDX_PATH_CHECK_EDGE_E, // it looks in the window (top corner is north). Their order is important,
WIDX_PATH_CHECK_EDGE_SE, // as this is the same order paths use for their corners / edges.
WIDX_PATH_CHECK_EDGE_S, // N
WIDX_PATH_CHECK_EDGE_SW, // NW-------NE
WIDX_PATH_CHECK_EDGE_W, // W ------------- E
WIDX_PATH_CHECK_EDGE_NW, // SW-------SE
WIDX_PATH_CHECK_EDGE_N, // S
// Track
WIDX_TRACK_CHECK_APPLY_TO_ALL = PAGE_WIDGETS,
WIDX_TRACK_SPINNER_HEIGHT,
WIDX_TRACK_SPINNER_HEIGHT_INCREASE,
WIDX_TRACK_SPINNER_HEIGHT_DECREASE,
WIDX_TRACK_CHECK_CHAIN_LIFT,
WIDX_TRACK_CHECK_BRAKE_CLOSED,
WIDX_TRACK_CHECK_IS_INDESTRUCTIBLE,
// Scenery
WIDX_SCENERY_SPINNER_HEIGHT = PAGE_WIDGETS,
WIDX_SCENERY_SPINNER_HEIGHT_INCREASE,
WIDX_SCENERY_SPINNER_HEIGHT_DECREASE,
WIDX_SCENERY_CHECK_QUARTER_N,
WIDX_SCENERY_CHECK_QUARTER_E,
WIDX_SCENERY_CHECK_QUARTER_S,
WIDX_SCENERY_CHECK_QUARTER_W,
WIDX_SCENERY_CHECK_COLLISION_N,
WIDX_SCENERY_CHECK_COLLISION_E,
WIDX_SCENERY_CHECK_COLLISION_S,
WIDX_SCENERY_CHECK_COLLISION_W,
// Entrance
WIDX_ENTRANCE_SPINNER_HEIGHT = PAGE_WIDGETS,
WIDX_ENTRANCE_SPINNER_HEIGHT_INCREASE,
WIDX_ENTRANCE_SPINNER_HEIGHT_DECREASE,
WIDX_ENTRANCE_BUTTON_MAKE_USABLE,
// Wall
WIDX_WALL_SPINNER_HEIGHT = PAGE_WIDGETS,
WIDX_WALL_SPINNER_HEIGHT_INCREASE,
WIDX_WALL_SPINNER_HEIGHT_DECREASE,
WIDX_WALL_DROPDOWN_SLOPE,
WIDX_WALL_DROPDOWN_SLOPE_BUTTON,
WIDX_WALL_SPINNER_ANIMATION_FRAME,
WIDX_WALL_SPINNER_ANIMATION_FRAME_INCREASE,
WIDX_WALL_SPINNER_ANIMATION_FRAME_DECREASE,
// Large
WIDX_LARGE_SCENERY_SPINNER_HEIGHT = PAGE_WIDGETS,
WIDX_LARGE_SCENERY_SPINNER_HEIGHT_INCREASE,
WIDX_LARGE_SCENERY_SPINNER_HEIGHT_DECREASE,
// Banner
WIDX_BANNER_SPINNER_HEIGHT = PAGE_WIDGETS,
WIDX_BANNER_SPINNER_HEIGHT_INCREASE,
WIDX_BANNER_SPINNER_HEIGHT_DECREASE,
WIDX_BANNER_CHECK_BLOCK_NE,
WIDX_BANNER_CHECK_BLOCK_SE,
WIDX_BANNER_CHECK_BLOCK_SW,
WIDX_BANNER_CHECK_BLOCK_NW,
};
static_assert(WC_TILE_INSPECTOR__WIDX_BUTTON_ROTATE == WIDX_BUTTON_ROTATE);
static_assert(WC_TILE_INSPECTOR__WIDX_BUTTON_COPY == WIDX_BUTTON_COPY);
static_assert(WC_TILE_INSPECTOR__WIDX_BUTTON_PASTE == WIDX_BUTTON_PASTE);
static_assert(WC_TILE_INSPECTOR__WIDX_BUTTON_REMOVE == WIDX_BUTTON_REMOVE);
static_assert(WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_UP == WIDX_BUTTON_MOVE_UP);
static_assert(WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_DOWN == WIDX_BUTTON_MOVE_DOWN);
static_assert(WC_TILE_INSPECTOR__WIDX_SPINNER_X_INCREASE == WIDX_SPINNER_X_INCREASE);
static_assert(WC_TILE_INSPECTOR__WIDX_SPINNER_X_DECREASE == WIDX_SPINNER_X_DECREASE);
static_assert(WC_TILE_INSPECTOR__WIDX_SPINNER_Y_INCREASE == WIDX_SPINNER_Y_INCREASE);
static_assert(WC_TILE_INSPECTOR__WIDX_SPINNER_Y_DECREASE == WIDX_SPINNER_Y_DECREASE);
#pragma region MEASUREMENTS
static constexpr const StringId WINDOW_TITLE = STR_TILE_INSPECTOR_TITLE;
// Window sizes
static constexpr const int32_t WW = 400;
static constexpr const int32_t WH = 170;
constexpr int32_t MIN_WW = WW;
constexpr int32_t MAX_WW = WW;
constexpr int32_t MIN_WH = 130;
constexpr int32_t MAX_WH = 800;
// Button space for top buttons
constexpr auto ToolbarButtonAnchor = ScreenCoordsXY{ WW - 27, 17 };
constexpr auto ToolbarButtonSize = ScreenSize{ 24, 24 };
constexpr auto ToolbarButtonHalfSize = ScreenSize{ 24, 12 };
constexpr auto ToolbarButtonOffsetX = ScreenSize{ -24, 0 };
// List's column offsets
constexpr auto InvisibleFlagColumnXY = ScreenCoordsXY{ 3, 42 };
constexpr auto InvisibleFlagColumnSize = ScreenSize{ 20, 14 };
constexpr auto TypeColumnXY = InvisibleFlagColumnXY + ScreenSize{ InvisibleFlagColumnSize.width, 0 };
constexpr auto TypeColumnSize = ScreenSize{ 252, 14 };
constexpr auto BaseHeightColumnXY = TypeColumnXY + ScreenSize{ TypeColumnSize.width, 0 };
constexpr auto BaseHeightColumnSize = ScreenSize{ 30, 14 };
constexpr auto ClearanceHeightColumnXY = BaseHeightColumnXY + ScreenCoordsXY{ BaseHeightColumnSize.width, 0 };
constexpr auto ClearanceHeightColumnSize = ScreenSize{ 30, 14 };
constexpr auto DirectionColumnXY = ClearanceHeightColumnXY + ScreenCoordsXY{ ClearanceHeightColumnSize.width, 0 };
constexpr auto DirectionColumnSize = ScreenSize{ 15, 14 };
constexpr auto GhostFlagColumnXY = DirectionColumnXY + ScreenCoordsXY{ DirectionColumnSize.width, 0 };
constexpr auto GhostFlagColumnSize = ScreenSize{ 15, 14 };
constexpr auto LastFlagColumnXY = GhostFlagColumnXY + ScreenCoordsXY{ GhostFlagColumnSize.width, 0 };
constexpr auto LastFlagColumnSize = ScreenSize{ 32, 14 };
constexpr int32_t PADDING_BOTTOM = 15;
constexpr int32_t GROUPBOX_PADDING = 6;
constexpr int32_t HORIZONTAL_GROUPBOX_PADDING = 5;
constexpr int32_t VERTICAL_GROUPBOX_PADDING = 4;
constexpr auto PropertyButtonSize = ScreenSize{ 130, 18 };
constexpr auto PropertyFullWidth = ScreenSize{ 370, 18 };
#pragma endregion
constexpr ScreenCoordsXY PropertyRowCol(ScreenCoordsXY anchor, int32_t row, int32_t column)
{
return anchor
+ ScreenCoordsXY{ column * (PropertyButtonSize.width + HORIZONTAL_GROUPBOX_PADDING),
row * (PropertyButtonSize.height + VERTICAL_GROUPBOX_PADDING) };
}
constexpr ScreenCoordsXY CheckboxGroupOffset(
ScreenCoordsXY anchorPoint, int16_t horizontalMultiplier, int16_t verticalMultiplier)
{
return anchorPoint + ScreenCoordsXY{ 14 * horizontalMultiplier, 7 * verticalMultiplier };
}
// clang-format off
// Macros for easily obtaining the top and bottom of a widget inside a properties group box
#define GBBT(GROUPTOP, row) ((GROUPTOP) + 14 + row * (PropertyButtonSize.height + VERTICAL_GROUPBOX_PADDING))
#define GBBB(GROUPTOP, row) (GBBT((GROUPTOP), row) + PropertyButtonSize.height)
#define MAIN_TILE_INSPECTOR_WIDGETS \
WINDOW_SHIM(WINDOW_TITLE, WW, WH), \
MakeWidget({3, 57}, {WW - 6, WH - PADDING_BOTTOM - 58}, WindowWidgetType::Scroll, WindowColour::Secondary, SCROLL_VERTICAL), /* Element list */ \
/* X and Y spinners */ \
MakeSpinnerWidgets({20, 23}, {51, 12}, WindowWidgetType::Spinner, WindowColour::Secondary), /* Spinner X (3 widgets) */ \
MakeSpinnerWidgets({90, 23}, {51, 12}, WindowWidgetType::Spinner, WindowColour::Secondary), /* Spinner Y (3 widgets) */ \
/* Top buttons */ \
MakeWidget(ToolbarButtonAnchor + ToolbarButtonOffsetX * 0, ToolbarButtonSize, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_DEMOLISH), STR_REMOVE_SELECTED_ELEMENT_TIP ), /* Remove button */ \
MakeWidget(ToolbarButtonAnchor + ToolbarButtonOffsetX * 1, ToolbarButtonHalfSize, WindowWidgetType::Button, WindowColour::Secondary, STR_UP, STR_MOVE_SELECTED_ELEMENT_UP_TIP), /* Move up */ \
MakeWidget(ToolbarButtonAnchor + ToolbarButtonOffsetX * 1 + ScreenSize{0, 12}, ToolbarButtonHalfSize, WindowWidgetType::Button, WindowColour::Secondary, STR_DOWN, STR_MOVE_SELECTED_ELEMENT_DOWN_TIP), /* Move down */ \
MakeWidget(ToolbarButtonAnchor + ToolbarButtonOffsetX * 2, ToolbarButtonSize, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_ROTATE_ARROW), STR_ROTATE_SELECTED_ELEMENT_TIP), /* Rotate button */ \
MakeWidget(ToolbarButtonAnchor + ToolbarButtonOffsetX * 3, ToolbarButtonSize, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_G2_SORT), STR_TILE_INSPECTOR_SORT_TIP), /* Sort button */ \
MakeWidget(ToolbarButtonAnchor + ToolbarButtonOffsetX * 4, ToolbarButtonSize, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_G2_PASTE), STR_TILE_INSPECTOR_PASTE_TIP), /* Paste button */ \
MakeWidget(ToolbarButtonAnchor + ToolbarButtonOffsetX * 5, ToolbarButtonSize, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_G2_COPY), STR_TILE_INSPECTOR_COPY_TIP), /* Copy button */ \
/* Column headers */ \
MakeWidget(InvisibleFlagColumnXY, InvisibleFlagColumnSize, WindowWidgetType::TableHeader, WindowColour::Secondary, STR_TILE_INSPECTOR_INVISIBLE_SHORT, STR_TILE_INSPECTOR_FLAG_INVISIBLE), /* Invisible flag */ \
MakeWidget(TypeColumnXY, TypeColumnSize, WindowWidgetType::TableHeader, WindowColour::Secondary, STR_TILE_INSPECTOR_ELEMENT_TYPE), /* Type */ \
MakeWidget(BaseHeightColumnXY, BaseHeightColumnSize, WindowWidgetType::TableHeader, WindowColour::Secondary, STR_TILE_INSPECTOR_BASE_HEIGHT_SHORT, STR_TILE_INSPECTOR_BASE_HEIGHT), /* Base height */ \
MakeWidget(ClearanceHeightColumnXY, ClearanceHeightColumnSize, WindowWidgetType::TableHeader, WindowColour::Secondary, STR_TILE_INSPECTOR_CLEARANGE_HEIGHT_SHORT, STR_TILE_INSPECTOR_CLEARANCE_HEIGHT), /* Clearance height */ \
MakeWidget(DirectionColumnXY, DirectionColumnSize, WindowWidgetType::TableHeader, WindowColour::Secondary, STR_TILE_INSPECTOR_DIRECTION_SHORT, STR_TILE_INSPECTOR_DIRECTION), /* Direction */ \
MakeWidget(GhostFlagColumnXY, GhostFlagColumnSize, WindowWidgetType::TableHeader, WindowColour::Secondary, STR_TILE_INSPECTOR_FLAG_GHOST_SHORT, STR_TILE_INSPECTOR_FLAG_GHOST), /* Ghost flag */ \
MakeWidget(LastFlagColumnXY, LastFlagColumnSize, WindowWidgetType::TableHeader, WindowColour::Secondary, STR_TILE_INSPECTOR_FLAG_LAST_SHORT, STR_TILE_INSPECTOR_FLAG_LAST), /* Last of tile flag */ \
/* Group boxes */ \
MakeWidget({6, 0}, {WW - 12, 0}, WindowWidgetType::Groupbox, WindowColour::Secondary, STR_NONE, STR_NONE ), /* Details group box */ \
MakeWidget({6, 0}, {WW - 12, 0}, WindowWidgetType::Groupbox, WindowColour::Secondary, STR_TILE_INSPECTOR_GROUPBOX_PROPERTIES, STR_NONE ) /* Properties group box */
static Widget DefaultWidgets[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
WIDGETS_END,
};
constexpr int32_t NumSurfaceProperties = 4;
constexpr int32_t NumSurfaceDetails = 4;
constexpr int32_t SurfacePropertiesHeight = 16 + NumSurfaceProperties * 21;
constexpr int32_t SurfaceDetailsHeight = 20 + NumSurfaceDetails * 11;
static Widget SurfaceWidgets[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
MakeSpinnerWidgets(PropertyRowCol({ 12, 0 }, 0, 1), PropertyButtonSize, WindowWidgetType::Spinner, WindowColour::Secondary), // WIDX_SURFACE_SPINNER_HEIGHT{,_INCREASE,_DECREASE}
MakeWidget(PropertyRowCol({ 12, 0 }, 1, 0), PropertyButtonSize, WindowWidgetType::Button, WindowColour::Secondary, STR_TILE_INSPECTOR_SURFACE_REMOVE_FENCES), // WIDX_SURFACE_BUTTON_REMOVE_FENCES
MakeWidget(PropertyRowCol({ 12, 0 }, 1, 1), PropertyButtonSize, WindowWidgetType::Button, WindowColour::Secondary, STR_TILE_INSPECTOR_SURFACE_RESTORE_FENCES), // WIDX_SURFACE_BUTTON_RESTORE_FENCES
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 3, 1), 1, 0), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_SURFACE_CHECK_CORNER_N
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 3, 1), 2, 1), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_SURFACE_CHECK_CORNER_E
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 3, 1), 1, 2), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_SURFACE_CHECK_CORNER_S
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 3, 1), 0, 1), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_SURFACE_CHECK_CORNER_W
MakeWidget(PropertyRowCol({ 12, 0 }, 4, 0), PropertyFullWidth, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_TILE_INSPECTOR_SURFACE_DIAGONAL), // WIDX_SURFACE_CHECK_DIAGONAL
WIDGETS_END,
};
constexpr int32_t NumPathProperties = 6;
constexpr int32_t NumPathDetails = 3;
constexpr int32_t PathPropertiesHeight = 16 + NumPathProperties * 21;
constexpr int32_t PathDetailsHeight = 20 + NumPathDetails * 11;
static Widget PathWidgets[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
MakeSpinnerWidgets(PropertyRowCol({ 12, 0 }, 0, 1), PropertyButtonSize, WindowWidgetType::Spinner, WindowColour::Secondary), // WIDX_PATH_SPINNER_HEIGHT{,_INCREASE,_DECREASE}
MakeWidget(PropertyRowCol({ 12, 0 }, 1, 0), PropertyFullWidth, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_TILE_INSPECTOR_PATH_BROKEN), // WIDX_PATH_CHECK_BROKEN
MakeWidget(PropertyRowCol({ 12, 0 }, 2, 0), PropertyFullWidth, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_TILE_INSPECTOR_PATH_SLOPED), // WIDX_PATH_CHECK_SLOPED
MakeWidget(PropertyRowCol({ 12, 0 }, 3, 0), PropertyFullWidth, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_TILE_INSPECTOR_PATH_JUNCTION_RAILINGS), // WIDX_PATH_CHECK_JUNCTION_RAILINGS
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 4, 1), 3, 1), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_PATH_CHECK_EDGE_NE
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 4, 1), 4, 2), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_PATH_CHECK_EDGE_E
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 4, 1), 3, 3), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_PATH_CHECK_EDGE_SE
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 4, 1), 2, 4), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_PATH_CHECK_EDGE_S
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 4, 1), 1, 3), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_PATH_CHECK_EDGE_SW
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 4, 1), 0, 2), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_PATH_CHECK_EDGE_W
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 4, 1), 1, 1), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_PATH_CHECK_EDGE_NW
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 4, 1), 2, 0), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_PATH_CHECK_EDGE_N
WIDGETS_END,
};
constexpr int32_t NumTrackProperties = 5;
constexpr int32_t NumTrackDetails = 7;
constexpr int32_t TrackPropertiesHeight = 16 + NumTrackProperties * 21;
constexpr int32_t TrackDetailsHeight = 20 + NumTrackDetails * 11;
static Widget TrackWidgets[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
MakeWidget(PropertyRowCol({ 12, 0}, 0, 0), PropertyFullWidth, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_TILE_INSPECTOR_TRACK_ENTIRE_TRACK_PIECE), // WIDX_TRACK_CHECK_APPLY_TO_ALL
MakeSpinnerWidgets(PropertyRowCol({ 12, 0 }, 1, 1), PropertyButtonSize, WindowWidgetType::Spinner, WindowColour::Secondary), // WIDX_TRACK_SPINNER_HEIGHT{,_INCREASE,_DECREASE}
MakeWidget(PropertyRowCol({ 12, 0}, 2, 0), PropertyFullWidth, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_TILE_INSPECTOR_TRACK_CHAIN_LIFT), // WIDX_TRACK_CHECK_CHAIN_LIFT
MakeWidget(PropertyRowCol({ 12, 0}, 3, 0), PropertyFullWidth, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_TILE_INSPECTOR_TRACK_BRAKE_CLOSED), // WIDX_TRACK_CHECK_BRAKE_CLOSED
MakeWidget(PropertyRowCol({ 12, 0}, 4, 0), PropertyFullWidth, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_TILE_INSPECTOR_TRACK_IS_INDESTRUCTIBLE), // WIDX_TRACK_CHECK_IS_INDESTRUCTIBLE
WIDGETS_END,
};
constexpr int32_t NumSceneryProperties = 4; // The checkbox groups both count for 2 rows
constexpr int32_t NumSceneryDetails = 4;
constexpr int32_t SceneryPropertiesHeight = 16 + NumSceneryProperties * 21;
constexpr int32_t SceneryDetailsHeight = 20 + NumSceneryDetails * 11;
static Widget SceneryWidgets[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
MakeSpinnerWidgets(PropertyRowCol({ 12, 0 }, 0, 1), PropertyButtonSize, WindowWidgetType::Spinner, WindowColour::Secondary), // WIDX_SCENERY_SPINNER_HEIGHT{,_INCREASE,_DECREASE}
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 1, 1), 1, 0), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_SCENERY_CHECK_QUARTER_N
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 1, 1), 2, 1), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_SCENERY_CHECK_QUARTER_E
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 1, 1), 1, 2), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_SCENERY_CHECK_QUARTER_S
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 1, 1), 0, 1), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_SCENERY_CHECK_QUARTER_W
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 2, 1), 1, 0), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_SCENERY_CHECK_COLLISION_N
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 2, 1), 2, 1), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_SCENERY_CHECK_COLLISION_E
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 2, 1), 1, 2), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_SCENERY_CHECK_COLLISION_S
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 2, 1), 0, 1), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_SCENERY_CHECK_COLLISION_W
WIDGETS_END,
};
constexpr int32_t NumEntranceProperties = 2;
constexpr int32_t NumEntranceDetails = 4;
constexpr int32_t EntrancePropertiesHeight = 16 + NumEntranceProperties * 21;
constexpr int32_t EntranceDetailsHeight = 20 + NumEntranceDetails * 11;
static Widget EntranceWidgets[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
MakeSpinnerWidgets(PropertyRowCol({ 12, 0 }, 0, 1), PropertyButtonSize, WindowWidgetType::Spinner, WindowColour::Secondary), // WIDX_ENTRANCE_SPINNER_HEIGHT{,_INCREASE,_DECREASE}
MakeWidget(PropertyRowCol({ 12, 0 }, 1, 0), PropertyButtonSize, WindowWidgetType::Button, WindowColour::Secondary, STR_TILE_INSPECTOR_ENTRANCE_MAKE_USABLE, STR_TILE_INSPECTOR_ENTRANCE_MAKE_USABLE_TIP), // WIDX_ENTRANCE_BUTTON_MAKE_USABLE
WIDGETS_END,
};
constexpr int32_t NumWallProperties = 3;
constexpr int32_t NumWallDetails = 2;
constexpr int32_t WallPropertiesHeight = 16 + NumWallProperties * 21;
constexpr int32_t WallDetailsHeight = 20 + NumWallDetails * 11;
static Widget WallWidgets[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
MakeSpinnerWidgets(PropertyRowCol({ 12, 0 }, 0, 1), PropertyButtonSize, WindowWidgetType::Spinner, WindowColour::Secondary), // WIDX_WALL_SPINNER_HEIGHT{,_INCREASE,_DECREASE}
MakeWidget(PropertyRowCol({ 12, 0 }, 1, 1), PropertyButtonSize, WindowWidgetType::DropdownMenu, WindowColour::Secondary), // WIDX_WALL_DROPDOWN_SLOPE
MakeWidget(PropertyRowCol({ 12 + PropertyButtonSize.width - 12, 0 }, 1, 1), { 11, 12}, WindowWidgetType::Button, WindowColour::Secondary, STR_DROPDOWN_GLYPH), // WIDX_WALL_DROPDOWN_SLOPE_BUTTON
MakeSpinnerWidgets(PropertyRowCol({ 12, 0 }, 2, 1), PropertyButtonSize, WindowWidgetType::Spinner, WindowColour::Secondary), // WIDX_WALL_SPINNER_ANIMATION_FRAME{,_INCREASE,_DECREASE}
WIDGETS_END,
};
constexpr int32_t NumLargeSceneryProperties = 1;
constexpr int32_t NumLargeSceneryDetails = 3;
constexpr int32_t LargeSceneryPropertiesHeight = 16 + NumLargeSceneryProperties * 21;
constexpr int32_t LargeSceneryDetailsHeight = 20 + NumLargeSceneryDetails * 11;
static Widget LargeSceneryWidgets[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
MakeSpinnerWidgets(PropertyRowCol({ 12, 0 }, 0, 1), PropertyButtonSize, WindowWidgetType::Spinner, WindowColour::Secondary), // WIDX_LARGE_SCENERY_SPINNER_HEIGHT{,_INCREASE,_DECREASE}
WIDGETS_END,
};
constexpr int32_t NumBannerProperties = 3;
constexpr int32_t NumBannerDetails = 1;
constexpr int32_t BannerPropertiesHeight = 16 + NumBannerProperties * 21;
constexpr int32_t BannerDetailsHeight = 20 + NumBannerDetails * 11;
static Widget BannerWidgets[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
MakeSpinnerWidgets(PropertyRowCol({ 12, 0 }, 0, 1), PropertyButtonSize, WindowWidgetType::Spinner, WindowColour::Secondary), // WIDX_BANNER_SPINNER_HEIGHT{,_INCREASE,_DECREASE}
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 1, 1), 3, 1), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_BANNER_CHECK_BLOCK_NE
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 1, 1), 3, 3), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_BANNER_CHECK_BLOCK_SE
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 1, 1), 1, 3), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_BANNER_CHECK_BLOCK_SW
MakeWidget(CheckboxGroupOffset(PropertyRowCol({ 12, 0 }, 1, 1), 1, 1), { 12, 12 }, WindowWidgetType::Checkbox, WindowColour::Secondary), // WIDX_BANNER_CHECK_BLOCK_NW
WIDGETS_END,
};
static Widget *PageWidgets[] = {
DefaultWidgets,
SurfaceWidgets,
PathWidgets,
TrackWidgets,
SceneryWidgets,
EntranceWidgets,
WallWidgets,
LargeSceneryWidgets,
BannerWidgets,
};
// clang-format on
struct TileInspectorGroupboxSettings
{
// Offsets from the bottom of the window
int16_t details_top_offset, details_bottom_offset;
int16_t properties_top_offset, properties_bottom_offset;
// String to be displayed in the details groupbox
StringId string_id;
};
static constexpr TileInspectorGroupboxSettings MakeGroupboxSettings(
int16_t detailsHeight, int16_t propertiesHeight, StringId stringId)
{
TileInspectorGroupboxSettings settings{};
decltype(settings.properties_bottom_offset) offsetSum = 0;
settings.properties_bottom_offset = (offsetSum += PADDING_BOTTOM);
settings.properties_top_offset = (offsetSum += propertiesHeight);
settings.details_bottom_offset = (offsetSum += GROUPBOX_PADDING);
settings.details_top_offset = (offsetSum += detailsHeight);
settings.string_id = stringId;
return settings;
}
static constexpr TileInspectorGroupboxSettings PageGroupBoxSettings[] = {
MakeGroupboxSettings(SurfaceDetailsHeight, SurfacePropertiesHeight, STR_TILE_INSPECTOR_GROUPBOX_SURFACE_INFO),
MakeGroupboxSettings(PathDetailsHeight, PathPropertiesHeight, STR_TILE_INSPECTOR_GROUPBOX_PATH_INFO),
MakeGroupboxSettings(TrackDetailsHeight, TrackPropertiesHeight, STR_TILE_INSPECTOR_GROUPBOX_TRACK_INFO),
MakeGroupboxSettings(SceneryDetailsHeight, SceneryPropertiesHeight, STR_TILE_INSPECTOR_GROUPBOX_SCENERY_INFO),
MakeGroupboxSettings(EntranceDetailsHeight, EntrancePropertiesHeight, STR_TILE_INSPECTOR_GROUPBOX_ENTRANCE_INFO),
MakeGroupboxSettings(WallDetailsHeight, WallPropertiesHeight, STR_TILE_INSPECTOR_GROUPBOX_WALL_INFO),
MakeGroupboxSettings(LargeSceneryDetailsHeight, LargeSceneryPropertiesHeight, STR_TILE_INSPECTOR_GROUPBOX_BANNER_INFO),
MakeGroupboxSettings(BannerDetailsHeight, BannerPropertiesHeight, STR_TILE_INSPECTOR_GROUPBOX_BANNER_INFO),
};
static constexpr int32_t ViewportInteractionFlags = EnumsToFlags(
ViewportInteractionItem::Terrain, ViewportInteractionItem::Entity, ViewportInteractionItem::Ride,
ViewportInteractionItem::Scenery, ViewportInteractionItem::Footpath, ViewportInteractionItem::FootpathItem,
ViewportInteractionItem::ParkEntrance, ViewportInteractionItem::Wall, ViewportInteractionItem::LargeScenery,
ViewportInteractionItem::Banner);
// clang-format off
static uint64_t PageHoldDownWidgets[] = {
(1uLL << WIDX_SPINNER_X_INCREASE) | (1uLL << WIDX_SPINNER_X_DECREASE) | (1uLL << WIDX_SPINNER_Y_INCREASE) | (1uLL << WIDX_SPINNER_Y_DECREASE),
(1uLL << WIDX_SPINNER_X_INCREASE) | (1uLL << WIDX_SPINNER_X_DECREASE) | (1uLL << WIDX_SPINNER_Y_INCREASE) | (1uLL << WIDX_SPINNER_Y_DECREASE) | (1uLL << WIDX_SURFACE_SPINNER_HEIGHT_INCREASE) | (1uLL << WIDX_SURFACE_SPINNER_HEIGHT_DECREASE),
(1uLL << WIDX_SPINNER_X_INCREASE) | (1uLL << WIDX_SPINNER_X_DECREASE) | (1uLL << WIDX_SPINNER_Y_INCREASE) | (1uLL << WIDX_SPINNER_Y_DECREASE) | (1uLL << WIDX_PATH_SPINNER_HEIGHT_INCREASE) | (1uLL << WIDX_PATH_SPINNER_HEIGHT_DECREASE),
(1uLL << WIDX_SPINNER_X_INCREASE) | (1uLL << WIDX_SPINNER_X_DECREASE) | (1uLL << WIDX_SPINNER_Y_INCREASE) | (1uLL << WIDX_SPINNER_Y_DECREASE) | (1uLL << WIDX_TRACK_SPINNER_HEIGHT_INCREASE) | (1uLL << WIDX_TRACK_SPINNER_HEIGHT_DECREASE),
(1uLL << WIDX_SPINNER_X_INCREASE) | (1uLL << WIDX_SPINNER_X_DECREASE) | (1uLL << WIDX_SPINNER_Y_INCREASE) | (1uLL << WIDX_SPINNER_Y_DECREASE) | (1uLL << WIDX_SCENERY_SPINNER_HEIGHT_INCREASE) | (1uLL << WIDX_SCENERY_SPINNER_HEIGHT_DECREASE),
(1uLL << WIDX_SPINNER_X_INCREASE) | (1uLL << WIDX_SPINNER_X_DECREASE) | (1uLL << WIDX_SPINNER_Y_INCREASE) | (1uLL << WIDX_SPINNER_Y_DECREASE) | (1uLL << WIDX_ENTRANCE_SPINNER_HEIGHT_INCREASE) | (1uLL << WIDX_ENTRANCE_SPINNER_HEIGHT_DECREASE),
(1uLL << WIDX_SPINNER_X_INCREASE) | (1uLL << WIDX_SPINNER_X_DECREASE) | (1uLL << WIDX_SPINNER_Y_INCREASE) | (1uLL << WIDX_SPINNER_Y_DECREASE) | (1uLL << WIDX_WALL_SPINNER_HEIGHT_INCREASE) | (1uLL << WIDX_WALL_SPINNER_HEIGHT_DECREASE) | (1uLL << WIDX_WALL_SPINNER_ANIMATION_FRAME_INCREASE) | (1uLL << WIDX_WALL_SPINNER_ANIMATION_FRAME_DECREASE),
(1uLL << WIDX_SPINNER_X_INCREASE) | (1uLL << WIDX_SPINNER_X_DECREASE) | (1uLL << WIDX_SPINNER_Y_INCREASE) | (1uLL << WIDX_SPINNER_Y_DECREASE) | (1uLL << WIDX_LARGE_SCENERY_SPINNER_HEIGHT_INCREASE) | (1uLL << WIDX_LARGE_SCENERY_SPINNER_HEIGHT_DECREASE),
(1uLL << WIDX_SPINNER_X_INCREASE) | (1uLL << WIDX_SPINNER_X_DECREASE) | (1uLL << WIDX_SPINNER_Y_INCREASE) | (1uLL << WIDX_SPINNER_Y_DECREASE) | (1uLL << WIDX_BANNER_SPINNER_HEIGHT_INCREASE) | (1uLL << WIDX_BANNER_SPINNER_HEIGHT_DECREASE),
};
static uint64_t PageDisabledWidgets[] = {
(1uLL << WIDX_BUTTON_MOVE_UP) | (1uLL << WIDX_BUTTON_MOVE_DOWN) | (1uLL << WIDX_BUTTON_REMOVE) | (1uLL << WIDX_BUTTON_ROTATE) | (1uLL << WIDX_BUTTON_COPY),
0,
0,
0,
0,
0,
0,
(1uLL << WIDX_BUTTON_ROTATE),
0,
};
// clang-format on
class TileInspector final : public Window
{
private:
int16_t _highlightedIndex = -1;
bool _tileSelected = false;
int32_t _toolMouseX = 0;
int32_t _toolMouseY = 0;
bool _toolCtrlDown = false;
CoordsXY _toolMap = {};
bool _applyToAll = false;
bool _elementCopied = false;
TileElement _copiedElement;
public:
void OnOpen() override
{
min_width = MIN_WW;
min_height = MIN_WH;
max_width = MAX_WW;
max_height = MAX_WH;
windowTileInspectorSelectedIndex = -1;
SetPage(TileInspectorPage::Default);
WindowInitScrollWidgets(*this);
_tileSelected = false;
ToolSet(*this, WIDX_BACKGROUND, Tool::Crosshair);
}
void OnUpdate() override
{
// Check if the mouse is hovering over the list
if (!WidgetIsHighlighted(*this, WIDX_LIST))
{
_highlightedIndex = -1;
InvalidateWidget(WIDX_LIST);
}
if (gCurrentToolWidget.window_classification != WindowClass::TileInspector)
Close();
}
void OnMouseUp(WidgetIndex widgetIndex) override
{
switch (widgetIndex)
{
case WIDX_CLOSE:
ToolCancel();
Close();
return;
case WIDX_BUTTON_REMOVE:
{
int32_t nextItemToSelect = windowTileInspectorSelectedIndex - 1;
RemoveElement(windowTileInspectorSelectedIndex);
SelectElementFromList(nextItemToSelect);
break;
}
case WIDX_BUTTON_ROTATE:
RotateElement(windowTileInspectorSelectedIndex);
break;
case WIDX_BUTTON_SORT:
SortElements();
break;
case WIDX_BUTTON_COPY:
CopyElement();
break;
case WIDX_BUTTON_PASTE:
PasteElement();
break;
case WIDX_BUTTON_MOVE_UP:
SwapElements(windowTileInspectorSelectedIndex, windowTileInspectorSelectedIndex + 1);
break;
case WIDX_BUTTON_MOVE_DOWN:
SwapElements(windowTileInspectorSelectedIndex - 1, windowTileInspectorSelectedIndex);
break;
}
// Only element-specific widgets from now on
if (tileInspectorPage == TileInspectorPage::Default || windowTileInspectorSelectedIndex == -1)
return;
TileElement* const tileElement = GetSelectedElement();
// Update selection, can be nullptr.
OpenRCT2::TileInspector::SetSelectedElement(tileElement);
if (tileElement == nullptr)
return;
// Page widgets
switch (tileElement->GetType())
{
case TileElementType::Surface:
switch (widgetIndex)
{
case WIDX_SURFACE_BUTTON_REMOVE_FENCES:
SurfaceShowParkFences(false);
break;
case WIDX_SURFACE_BUTTON_RESTORE_FENCES:
SurfaceShowParkFences(true);
break;
case WIDX_SURFACE_CHECK_CORNER_N:
case WIDX_SURFACE_CHECK_CORNER_E:
case WIDX_SURFACE_CHECK_CORNER_S:
case WIDX_SURFACE_CHECK_CORNER_W:
SurfaceToggleCorner(((widgetIndex - WIDX_SURFACE_CHECK_CORNER_N) + 2 - GetCurrentRotation()) & 3);
break;
case WIDX_SURFACE_CHECK_DIAGONAL:
SurfaceToggleDiagonal();
break;
} // switch widgetindex
break;
case TileElementType::Path:
switch (widgetIndex)
{
case WIDX_PATH_CHECK_SLOPED:
PathSetSloped(windowTileInspectorSelectedIndex, !tileElement->AsPath()->IsSloped());
break;
case WIDX_PATH_CHECK_JUNCTION_RAILINGS:
PathSetJunctionRailings(
windowTileInspectorSelectedIndex, !tileElement->AsPath()->HasJunctionRailings());
break;
case WIDX_PATH_CHECK_BROKEN:
PathSetBroken(windowTileInspectorSelectedIndex, !tileElement->AsPath()->IsBroken());
break;
case WIDX_PATH_CHECK_EDGE_E:
case WIDX_PATH_CHECK_EDGE_S:
case WIDX_PATH_CHECK_EDGE_W:
case WIDX_PATH_CHECK_EDGE_N:
{
// 0 = east/right, 1 = south/bottom, 2 = west/left, 3 = north/top
const int32_t eswn = (widgetIndex - WIDX_PATH_CHECK_EDGE_E) / 2;
// Transform to world orientation
const int32_t index = (eswn - GetCurrentRotation()) & 3;
PathToggleEdge(
windowTileInspectorSelectedIndex,
index + 4); // The corners are stored in the 4 most significant bits, hence the + 4
break;
}
case WIDX_PATH_CHECK_EDGE_NE:
case WIDX_PATH_CHECK_EDGE_SE:
case WIDX_PATH_CHECK_EDGE_SW:
case WIDX_PATH_CHECK_EDGE_NW:
{
// 0 = NE, 1 = SE, 2 = SW, 3 = NW
const int32_t neseswnw = (widgetIndex - WIDX_PATH_CHECK_EDGE_NE) / 2;
// Transform to world orientation
const int32_t index = (neseswnw - GetCurrentRotation()) & 3;
PathToggleEdge(windowTileInspectorSelectedIndex, index);
break;
}
} // switch widget index
break;
case TileElementType::Track:
switch (widgetIndex)
{
case WIDX_TRACK_CHECK_APPLY_TO_ALL:
_applyToAll ^= 1;
InvalidateWidget(widgetIndex);
break;
case WIDX_TRACK_CHECK_CHAIN_LIFT:
{
bool entireTrackBlock = IsWidgetPressed(WIDX_TRACK_CHECK_APPLY_TO_ALL);
bool newLift = !tileElement->AsTrack()->HasChain();
TrackBlockSetLift(windowTileInspectorSelectedIndex, entireTrackBlock, newLift);
break;
}
case WIDX_TRACK_CHECK_BRAKE_CLOSED:
TrackSetBrakeClosed(windowTileInspectorSelectedIndex, !tileElement->AsTrack()->IsBrakeClosed());
break;
case WIDX_TRACK_CHECK_IS_INDESTRUCTIBLE:
TrackSetIndestructible(windowTileInspectorSelectedIndex, !tileElement->AsTrack()->IsIndestructible());
break;
} // switch widget index
break;
case TileElementType::SmallScenery:
switch (widgetIndex)
{
case WIDX_SCENERY_CHECK_QUARTER_N:
case WIDX_SCENERY_CHECK_QUARTER_E:
case WIDX_SCENERY_CHECK_QUARTER_S:
case WIDX_SCENERY_CHECK_QUARTER_W:
QuarterTileSet(windowTileInspectorSelectedIndex, widgetIndex - WIDX_SCENERY_CHECK_QUARTER_N);
break;
case WIDX_SCENERY_CHECK_COLLISION_N:
case WIDX_SCENERY_CHECK_COLLISION_E:
case WIDX_SCENERY_CHECK_COLLISION_S:
case WIDX_SCENERY_CHECK_COLLISION_W:
ToggleQuadrantCollosion(windowTileInspectorSelectedIndex, widgetIndex - WIDX_SCENERY_CHECK_COLLISION_N);
break;
} // switch widget index
break;
case TileElementType::Entrance:
switch (widgetIndex)
{
case WIDX_ENTRANCE_BUTTON_MAKE_USABLE:
EntranceMakeUsable(windowTileInspectorSelectedIndex);
break;
} // switch widget index
break;
case TileElementType::Banner:
switch (widgetIndex)
{
case WIDX_BANNER_CHECK_BLOCK_NE:
case WIDX_BANNER_CHECK_BLOCK_SE:
case WIDX_BANNER_CHECK_BLOCK_SW:
case WIDX_BANNER_CHECK_BLOCK_NW:
BannerToggleBlock(windowTileInspectorSelectedIndex, widgetIndex - WIDX_BANNER_CHECK_BLOCK_NE);
break;
} // switch widget index
break;
case TileElementType::LargeScenery:
case TileElementType::Wall:
default:
break;
}
}
void OnClose() override
{
OpenRCT2::TileInspector::SetSelectedElement(nullptr);
}
void OnResize() override
{
if (width < min_width)
{
Invalidate();
width = min_width;
}
if (height < min_height)
{
Invalidate();
height = min_height;
}
}
void OnMouseDown(WidgetIndex widgetIndex) override
{
switch (widgetIndex)
{
case WIDX_SPINNER_X_INCREASE:
windowTileInspectorTile.x = std::min<int32_t>(windowTileInspectorTile.x + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1);
_toolMap.x = std::min<int32_t>(_toolMap.x + 32, MAXIMUM_TILE_START_XY);
LoadTile(nullptr);
break;
case WIDX_SPINNER_X_DECREASE:
windowTileInspectorTile.x = std::max<int32_t>(windowTileInspectorTile.x - 1, 0);
_toolMap.x = std::max<int32_t>(_toolMap.x - 32, 0);
LoadTile(nullptr);
break;
case WIDX_SPINNER_Y_INCREASE:
windowTileInspectorTile.y = std::min<int32_t>(windowTileInspectorTile.y + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1);
_toolMap.y = std::min<int32_t>(_toolMap.y + 32, MAXIMUM_TILE_START_XY);
LoadTile(nullptr);
break;
case WIDX_SPINNER_Y_DECREASE:
windowTileInspectorTile.y = std::max<int32_t>(windowTileInspectorTile.y - 1, 0);
_toolMap.y = std::max<int32_t>(_toolMap.y - 32, 0);
LoadTile(nullptr);
break;
} // switch widget index
// Only element-specific widgets from now on
if (tileInspectorPage == TileInspectorPage::Default || windowTileInspectorSelectedIndex == -1)
return;
const TileElement* tileElement = GetSelectedElement();
if (tileElement == nullptr)
return;
switch (tileElement->GetType())
{
case TileElementType::Surface:
switch (widgetIndex)
{
case WIDX_SURFACE_SPINNER_HEIGHT_INCREASE:
BaseHeightOffset(windowTileInspectorSelectedIndex, 1);
break;
case WIDX_SURFACE_SPINNER_HEIGHT_DECREASE:
BaseHeightOffset(windowTileInspectorSelectedIndex, -1);
break;
} // switch widget index
break;
case TileElementType::Path:
switch (widgetIndex)
{
case WIDX_PATH_SPINNER_HEIGHT_INCREASE:
BaseHeightOffset(windowTileInspectorSelectedIndex, 1);
break;
case WIDX_PATH_SPINNER_HEIGHT_DECREASE:
BaseHeightOffset(windowTileInspectorSelectedIndex, -1);
break;
} // switch widget index
break;
case TileElementType::Track:
switch (widgetIndex)
{
case WIDX_TRACK_SPINNER_HEIGHT_INCREASE:
if (IsWidgetPressed(WIDX_TRACK_CHECK_APPLY_TO_ALL))
TrackBlockHeightOffset(windowTileInspectorSelectedIndex, 1);
else
BaseHeightOffset(windowTileInspectorSelectedIndex, 1);
break;
case WIDX_TRACK_SPINNER_HEIGHT_DECREASE:
if (IsWidgetPressed(WIDX_TRACK_CHECK_APPLY_TO_ALL))
TrackBlockHeightOffset(windowTileInspectorSelectedIndex, -1);
else
BaseHeightOffset(windowTileInspectorSelectedIndex, -1);
break;
} // switch widget index
break;
case TileElementType::SmallScenery:
switch (widgetIndex)
{
case WIDX_SCENERY_SPINNER_HEIGHT_INCREASE:
BaseHeightOffset(windowTileInspectorSelectedIndex, 1);
break;
case WIDX_SCENERY_SPINNER_HEIGHT_DECREASE:
BaseHeightOffset(windowTileInspectorSelectedIndex, -1);
break;
} // switch widget index
break;
case TileElementType::Entrance:
switch (widgetIndex)
{
case WIDX_ENTRANCE_SPINNER_HEIGHT_INCREASE:
BaseHeightOffset(windowTileInspectorSelectedIndex, 1);
break;
case WIDX_ENTRANCE_SPINNER_HEIGHT_DECREASE:
BaseHeightOffset(windowTileInspectorSelectedIndex, -1);
break;
case WIDX_ENTRANCE_BUTTON_MAKE_USABLE:
EntranceMakeUsable(windowTileInspectorSelectedIndex);
break;
} // switch widget index
break;
case TileElementType::Wall:
switch (widgetIndex)
{
case WIDX_WALL_SPINNER_HEIGHT_INCREASE:
BaseHeightOffset(windowTileInspectorSelectedIndex, 1);
break;
case WIDX_WALL_SPINNER_HEIGHT_DECREASE:
BaseHeightOffset(windowTileInspectorSelectedIndex, -1);
break;
case WIDX_WALL_DROPDOWN_SLOPE_BUTTON:
{
Widget* widget = &widgets[widgetIndex];
// Use dropdown instead of dropdown button
widget--;
// Fill dropdown list
gDropdownItems[0].Format = STR_DROPDOWN_MENU_LABEL;
gDropdownItems[1].Format = STR_DROPDOWN_MENU_LABEL;
gDropdownItems[2].Format = STR_DROPDOWN_MENU_LABEL;
gDropdownItems[0].Args = STR_TILE_INSPECTOR_WALL_FLAT;
gDropdownItems[1].Args = STR_TILE_INSPECTOR_WALL_SLOPED_LEFT;
gDropdownItems[2].Args = STR_TILE_INSPECTOR_WALL_SLOPED_RIGHT;
WindowDropdownShowTextCustomWidth(
{ windowPos.x + widget->left, windowPos.y + widget->top }, widget->height() + 1, colours[1], 0,
Dropdown::Flag::StayOpen, 3, widget->width() - 3);
// Set current value as checked
Dropdown::SetChecked(tileElement->AsWall()->GetSlope(), true);
break;
}
case WIDX_WALL_SPINNER_ANIMATION_FRAME_INCREASE:
WallAnimationFrameOffset(windowTileInspectorSelectedIndex, 1);
break;
case WIDX_WALL_SPINNER_ANIMATION_FRAME_DECREASE:
WallAnimationFrameOffset(windowTileInspectorSelectedIndex, -1);
break;
} // switch widget index
break;
case TileElementType::LargeScenery:
switch (widgetIndex)
{
case WIDX_LARGE_SCENERY_SPINNER_HEIGHT_INCREASE:
BaseHeightOffset(windowTileInspectorSelectedIndex, 1);
break;
case WIDX_LARGE_SCENERY_SPINNER_HEIGHT_DECREASE:
BaseHeightOffset(windowTileInspectorSelectedIndex, -1);
break;
} // switch widget index
break;
case TileElementType::Banner:
switch (widgetIndex)
{
case WIDX_BANNER_SPINNER_HEIGHT_INCREASE:
BaseHeightOffset(windowTileInspectorSelectedIndex, 1);
break;
case WIDX_BANNER_SPINNER_HEIGHT_DECREASE:
BaseHeightOffset(windowTileInspectorSelectedIndex, -1);
break;
} // switch widget index
break;
default:
break;
}
}
void OnDropdown(WidgetIndex widgetIndex, int32_t dropdownIndex) override
{
if (dropdownIndex == -1)
return;
// Get selected element
TileElement* const tileElement = GetSelectedElement();
if (tileInspectorPage == TileInspectorPage::Wall)
{
openrct2_assert(tileElement->GetType() == TileElementType::Wall, "Element is not a wall");
if (widgetIndex == WIDX_WALL_DROPDOWN_SLOPE_BUTTON)
WallSetSlope(windowTileInspectorSelectedIndex, dropdownIndex);
}
}
void OnToolUpdate(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
{
MapInvalidateSelectionRect();
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
CoordsXY mapCoords;
TileElement* clickedElement = nullptr;
bool mouseOnViewport = false;
if (InputTestPlaceObjectModifier(PLACE_OBJECT_MODIFIER_COPY_Z))
{
auto info = GetMapCoordinatesFromPos(screenCoords, ViewportInteractionFlags);
clickedElement = info.Element;
mapCoords = info.Loc;
}
// Even if Ctrl was pressed, fall back to normal selection when there was nothing under the cursor
if (clickedElement == nullptr)
{
auto mouseCoords = ScreenPosToMapPos(screenCoords, nullptr);
if (mouseCoords.has_value())
{
mouseOnViewport = true;
mapCoords = mouseCoords.value();
}
}
if (mouseOnViewport)
gMapSelectPositionA = gMapSelectPositionB = mapCoords;
else if (_tileSelected)
gMapSelectPositionA = gMapSelectPositionB = _toolMap;
else
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectType = MAP_SELECT_TYPE_FULL;
MapInvalidateSelectionRect();
}
void OnToolDown(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
{
UpdateSelectedTile(screenCoords);
}
void OnToolDrag(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
{
UpdateSelectedTile(screenCoords);
}
ScreenSize OnScrollGetSize(int32_t scrollIndex) override
{
return ScreenSize(WW - 30, windowTileInspectorElementCount * SCROLLABLE_ROW_HEIGHT);
}
void OnScrollMouseDown(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
{
// There is nothing to interact with when no tile is selected
if (!_tileSelected)
return;
// Because the list items are displayed in reverse order, subtract the calculated index from the amount of elements
const int16_t index = windowTileInspectorElementCount - (screenCoords.y - 1) / SCROLLABLE_ROW_HEIGHT - 1;
const ScreenRect checkboxColumnRect{ { 2, 0 }, { 15, screenCoords.y } };
if (index >= 0 && checkboxColumnRect.Contains(screenCoords))
{ // Checkbox was clicked
ToggleInvisibility(index);
}
else
{
SelectElementFromList(index);
}
}