-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
tile_inspector.c
2135 lines (1909 loc) 路 95.4 KB
/
tile_inspector.c
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
#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers
/*****************************************************************************
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 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, either version 3 of the License, or
* (at your option) any later version.
*
* A full copy of the GNU General Public License can be found in licence.txt
*****************************************************************************/
#pragma endregion
#include "dropdown.h"
#include "../input.h"
#include "../interface/themes.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../ride/track.h"
#include "../sprites.h"
#include "../world/footpath.h"
#include "../world/map.h"
#include "../world/scenery.h"
static const rct_string_id terrainTypeStringIds[] = {
STR_TILE_INSPECTOR_TERRAIN_GRASS,
STR_TILE_INSPECTOR_TERRAIN_SAND,
STR_TILE_INSPECTOR_TERRAIN_DIRT,
STR_TILE_INSPECTOR_TERRAIN_ROCK,
STR_TILE_INSPECTOR_TERRAIN_MARTIAN,
STR_TILE_INSPECTOR_TERRAIN_CHECKERBOARD,
STR_TILE_INSPECTOR_TERRAIN_GRASS_CLUMPS,
STR_TILE_INSPECTOR_TERRAIN_ICE,
STR_TILE_INSPECTOR_TERRAIN_GRID_RED,
STR_TILE_INSPECTOR_TERRAIN_GRID_YELLOW,
STR_TILE_INSPECTOR_TERRAIN_GRID_BLUE,
STR_TILE_INSPECTOR_TERRAIN_GRID_GREEN,
STR_TILE_INSPECTOR_TERRAIN_SAND_DARK,
STR_TILE_INSPECTOR_TERRAIN_SAND_LIGHT,
STR_TILE_INSPECTOR_TERRAIN_CHECKERBOARD_INVERTED,
STR_TILE_INSPECTOR_TERRAIN_UNDERGROUND_VIEW,
};
static const rct_string_id terrainEdgeTypeStringIds[] = {
STR_TILE_INSPECTOR_TERRAIN_EDGE_ROCK,
STR_TILE_INSPECTOR_TERRAIN_EDGE_WOOD_RED,
STR_TILE_INSPECTOR_TERRAIN_EDGE_WOOD_BLACK,
STR_TILE_INSPECTOR_TERRAIN_EDGE_ICE,
};
static const rct_string_id entranceTypeStringIds[] = {
STR_TILE_INSPECTOR_ENTRANCE_TYPE_RIDE_ENTRANCE,
STR_TILE_INSPECTOR_ENTRANCE_TYPE_RIDE_EXIT,
STR_TILE_INSPECTOR_ENTRANCE_TYPE_PARK_ENTRANC,
};
static const rct_string_id parkEntrancePartStringIds[] = {
STR_TILE_INSPECTOR_ENTRANCE_MIDDLE,
STR_TILE_INSPECTOR_ENTRANCE_LEFT,
STR_TILE_INSPECTOR_ENTRANCE_RIGHT
};
static const rct_string_id fenceSlopeStringIds[] = {
STR_TILE_INSPECTOR_FENCE_FLAT,
STR_TILE_INSPECTOR_FENCE_SLOPED_LEFT,
STR_TILE_INSPECTOR_FENCE_SLOPED_RIGHT
};
enum WINDOW_TILE_INSPECTOR_PAGES {
PAGE_DEFAULT,
PAGE_SURFACE,
PAGE_PATH,
PAGE_TRACK,
PAGE_SCENERY,
PAGE_ENTRANCE,
PAGE_FENCE,
PAGE_LARGE_SCENERY,
PAGE_BANNER,
PAGE_CORRUPT
};
enum WINDOW_TILE_INSPECTOR_WIDGET_IDX {
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_CORRUPT,
WIDX_BUTTON_REMOVE,
WIDX_BUTTON_MOVE_DOWN,
WIDX_BUTTON_MOVE_UP,
WIDX_BUTTON_ROTATE,
WIDX_BUTTON_SORT,
WIDX_COLUMN_TYPE,
WIDX_COLUMN_BASEHEIGHT,
WIDX_COLUMN_CLEARANCEHEIGHT,
WIDX_COLUMN_GHOSTFLAG,
WIDX_COLUMN_BROKENFLAG,
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_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,
// 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,
// Fence
WIDX_FENCE_SPINNER_HEIGHT = PAGE_WIDGETS,
WIDX_FENCE_SPINNER_HEIGHT_INCREASE,
WIDX_FENCE_SPINNER_HEIGHT_DECREASE,
WIDX_FENCE_DROPDOWN_SLOPE,
WIDX_FENCE_DROPDOWN_SLOPE_BUTTON,
// 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,
// Corrupt
WIDX_CORRUPT_SPINNER_HEIGHT = PAGE_WIDGETS,
WIDX_CORRUPT_SPINNER_HEIGHT_INCREASE,
WIDX_CORRUPT_SPINNER_HEIGHT_DECREASE,
WIDX_CORRUPT_BUTTON_CLAMP,
};
// Window sizes
#define WW 400
#define WH 280
#define MIN_WW WW
#define MAX_WW WW
#define MIN_WH 240
#define MAX_WH 800
// Button space for top buttons
#define BW (WW - 5) // Button's right side
#define BX (BW - 23) // Button's left side
#define BY 17 // Button's Top
#define BH (BY + 23) // Button's Bottom
#define BS 24
// Column offsets for the table headers
#define COL_X_TYPE 3 // Type
#define COL_X_BH (COL_X_TYPE + 300) // Base height
#define COL_X_CH (COL_X_BH + 20) // Clearance height
#define COL_X_GF (COL_X_CH + 20) // Ghost flag
#define COL_X_BF (COL_X_GF + 12) // Broken flag
#define COL_X_LF (COL_X_BF + 12) // Last for tile flag
#define PADDING_BOTTOM 15
#define GROUPBOX_PADDING 6
#define HORIZONTAL_GROUPBOX_PADDING 5
#define VERTICAL_GROUPBOX_PADDING 4
#define LIST_ITEM_HEIGHT 11
#define BUTTONW 130
#define BUTTONH 17
// Calculates the .left, .right, .top and .bottom for buttons in a group box.
// Buttons are used as reference points for all other widgets in the group boxes.
#define GBBL(col) (12 + col * (BUTTONW + HORIZONTAL_GROUPBOX_PADDING))
#define GBBR(col) (GBBL(col) + BUTTONW)
#define GBBT(GROUPTOP, row) ((GROUPTOP) + 14 + row * (BUTTONH + VERTICAL_GROUPBOX_PADDING))
#define GBBB(GROUPTOP, row) (GBBT((GROUPTOP), row) + BUTTONH)
#define GBB(GROUPTOP, col, row) GBBL(col), GBBR(col), GBBT((GROUPTOP), row), GBBB((GROUPTOP), row)
#define GBBF(GROUPTOP, col, row)GBBL(col), WW - 10, GBBT((GROUPTOP), row), GBBB((GROUPTOP), row) // Full width
// Spinners and dropdowns use the buttons as a reference
#define GBS(GBT, col, row) GBBL(col), GBBR(col), GBBT(GBT, row) + 3, GBBB(GBT, row) - 3 // Group box spinner / dropdown field
#define GBSI(GBT, col, row) GBBR(col) - 11, GBBR(col) - 1, GBBT(GBT, row) + 4, GBBT(GBT, row) + 8 // Group box spinner increase
#define GBSD(GBT, col, row) GBBR(col) - 11, GBBR(col) - 1, GBBB(GBT, row) - 8, GBBB(GBT, row) - 4 // Group box spinner decrease
#define GBDB(GBT, col, row) GBBR(col) - 11, GBBR(col) - 1, GBBT(GBT, row) + 4, GBBB(GBT, row) - 4 // Group box dropdown button
// Checkbox - given topleft corner
#define CHK(x, y) x, x + 13, y + 2, y + 15
#define MAIN_TILE_INSPECTOR_WIDGETS \
{ WWT_FRAME, 0, 0, WW - 1, 0, WH - 1, 0xFFFFFFFF, STR_NONE }, /* panel / background */ \
{ WWT_CAPTION, 0, 1, WW - 2, 1, 14, STR_TILE_INSPECTOR_TITLE, STR_WINDOW_TITLE_TIP }, /* title bar */ \
{ WWT_CLOSEBOX, 0, WW - 13, WW - 3, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, /* close x button */ \
{ WWT_SCROLL, 1, 3, WW - 4, 57, WH - PADDING_BOTTOM, 2, STR_NONE }, /* Element list */ \
{ WWT_SPINNER, 1, 20, 61, 23, 34, STR_NONE, STR_NONE }, /* Spinner for X */ \
{ WWT_DROPDOWN_BUTTON, 1, 51, 60, 24, 28, STR_NUMERIC_UP, STR_NONE }, /* increase X */ \
{ WWT_DROPDOWN_BUTTON, 1, 51, 60, 29, 33, STR_NUMERIC_DOWN, STR_NONE }, /* decrease X */ \
{ WWT_SPINNER, 1, 77, 118, 23, 34, STR_NONE, STR_NONE }, /* Spinner for Y */ \
{ WWT_DROPDOWN_BUTTON, 1, 108, 117, 24, 28, STR_NUMERIC_UP, STR_NONE }, /* increase Y */ \
{ WWT_DROPDOWN_BUTTON, 1, 108, 117, 29, 33, STR_NUMERIC_DOWN, STR_NONE }, /* decrease Y */ \
/* Buttons */ \
{ WWT_FLATBTN, 1, BX, BW, BY, BH, SPR_MAP, STR_INSERT_CORRUPT_TIP }, /* Insert corrupt button */ \
{ WWT_FLATBTN, 1, BX - BS * 1, BW - BS * 1, BY, BH, SPR_DEMOLISH, STR_REMOVE_SELECTED_ELEMENT_TIP }, /* Remove button */ \
{ WWT_CLOSEBOX, 1, BX - BS * 2, BW - BS * 2, BY, BY + 11, STR_UP, STR_MOVE_SELECTED_ELEMENT_UP_TIP }, /* Move down */ \
{ WWT_CLOSEBOX, 1, BX - BS * 2, BW - BS * 2, BH - 11, BH, STR_DOWN, STR_MOVE_SELECTED_ELEMENT_DOWN_TIP }, /* Move up */ \
{ WWT_FLATBTN, 1, BX - BS * 3, BW - BS * 3, BY, BH, SPR_ROTATE_ARROW, STR_ROTATE_SELECTED_ELEMENT_TIP }, /* Rotate button */ \
{ WWT_FLATBTN, 1, BX - BS * 4, BW - BS * 4, BY, BH, SPR_G2_SORT, STR_TILE_INSPECTOR_SORT_TIP }, /* Sort button */ \
/* Column headers */ \
{ WWT_13, 1, COL_X_TYPE, COL_X_BH - 1, 42, 42 + 13, STR_NONE, STR_NONE }, /* Type */ \
{ WWT_13, 1, COL_X_BH, COL_X_CH - 1, 42, 42 + 13, STR_NONE, STR_TILE_INSPECTOR_BASE_HEIGHT }, /* Base height */ \
{ WWT_13, 1, COL_X_CH, COL_X_GF - 1, 42, 42 + 13, STR_NONE, STR_TILE_INSPECTOR_CLEARANCE_HEIGHT }, /* Clearance height */ \
{ WWT_13, 1, COL_X_GF, COL_X_BF - 1, 42, 42 + 13, STR_NONE, STR_TILE_INSPECTOR_FLAG_GHOST }, /* Ghost flag */ \
{ WWT_13, 1, COL_X_BF, COL_X_LF - 1, 42, 42 + 13, STR_NONE, STR_TILE_INSPECTOR_FLAG_BROKEN }, /* Broken flag */ \
{ WWT_13, 1, COL_X_LF, WW - 3, 42, 42 + 13, STR_NONE, STR_TILE_INSPECTOR_FLAG_LAST }, /* Last of tile flag */ \
{ WWT_GROUPBOX, 1, 6, WW - 6, -1, -1, STR_NONE, STR_NONE }, /* Details group box */ \
{ WWT_GROUPBOX, 1, 6, WW - 6, -1, -1, STR_TILE_INSPECTOR_GROUPBOX_PROPERTIES, STR_NONE } /* Properties group box */
static rct_widget windowTileInspectorWidgets[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
{ WIDGETS_END },
};
// Group boxes .top and .bottom for a given window height offsets from the bottom
#define SUR_GBPB PADDING_BOTTOM // Surface group box properties bottom
#define SUR_GBPT (SUR_GBPB + 16 + 4 * 21) // Surface group box properties top
#define SUR_GBDB (SUR_GBPT + GROUPBOX_PADDING) // Surface group box details bottom
#define SUR_GBDT (SUR_GBDB + 20 + 4 * 11) // Surface group box details top
static rct_widget windowTileInspectorWidgetsSurface[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
{ WWT_SPINNER, 1, GBS(WH - SUR_GBPT, 1, 0), STR_NONE, STR_NONE }, // WIDX_SURFACE_SPINNER_HEIGHT
{ WWT_DROPDOWN_BUTTON, 1, GBSI(WH - SUR_GBPT, 1, 0), STR_NUMERIC_UP, STR_NONE }, // WIDX_SURFACE_SPINNER_HEIGHT_INCREASE
{ WWT_DROPDOWN_BUTTON, 1, GBSD(WH - SUR_GBPT, 1, 0), STR_NUMERIC_DOWN, STR_NONE }, // WIDX_SURFACE_SPINNER_HEIGHT_DECREASE
{ WWT_CLOSEBOX, 1, GBB(WH - SUR_GBPT, 0, 1), STR_TILE_INSPECTOR_SURFACE_REMOVE_FENCES, STR_NONE }, // WIDX_SURFACE_BUTTON_REMOVE_FENCES
{ WWT_CLOSEBOX, 1, GBB(WH - SUR_GBPT, 1, 1), STR_TILE_INSPECTOR_SURFACE_RESTORE_FENCES, STR_NONE }, // WIDX_SURFACE_BUTTON_RESTORE_FENCES
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 1, GBBT(WH - SUR_GBPT, 2) + 7 * 0), STR_NONE, STR_NONE }, // WIDX_SURFACE_CHECK_CORNER_N
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 2, GBBT(WH - SUR_GBPT, 2) + 7 * 1), STR_NONE, STR_NONE }, // WIDX_SURFACE_CHECK_CORNER_E
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 1, GBBT(WH - SUR_GBPT, 2) + 7 * 2), STR_NONE, STR_NONE }, // WIDX_SURFACE_CHECK_CORNER_S
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 0, GBBT(WH - SUR_GBPT, 2) + 7 * 1), STR_NONE, STR_NONE }, // WIDX_SURFACE_CHECK_CORNER_W
{ WWT_CHECKBOX, 1, GBBF(WH - SUR_GBPT, 0, 4), STR_TILE_INSPECTOR_SURFACE_DIAGONAL, STR_NONE }, // WIDX_SURFACE_CHECK_DIAGONAL
{ WIDGETS_END },
};
#define PAT_GBPB PADDING_BOTTOM // Path group box properties bottom
#define PAT_GBPT (PAT_GBPB + 16 + 3 * 21) // Path group box properties top
#define PAT_GBDB (PAT_GBPT + GROUPBOX_PADDING) // Path group box info bottom
#define PAT_GBDT (PAT_GBDB + 20 + 2 * 11) // Path group box info top
static rct_widget windowTileInspectorWidgetsPath[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
{ WWT_SPINNER, 1, GBS(WH - PAT_GBPT, 1, 0), STR_NONE, STR_NONE }, // WIDX_PATH_SPINNER_HEIGHT
{ WWT_DROPDOWN_BUTTON, 1, GBSI(WH - PAT_GBPT, 1, 0), STR_NUMERIC_UP, STR_NONE }, // WIDX_PATH_SPINNER_HEIGHT_INCREASE
{ WWT_DROPDOWN_BUTTON, 1, GBSD(WH - PAT_GBPT, 1, 0), STR_NUMERIC_DOWN, STR_NONE }, // WIDX_PATH_SPINNER_HEIGHT_DECREASE
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 3, GBBT(WH - PAT_GBPT, 1) + 7 * 1), STR_NONE, STR_NONE }, // WIDX_PATH_CHECK_EDGE_NE
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 4, GBBT(WH - PAT_GBPT, 1) + 7 * 2), STR_NONE, STR_NONE }, // WIDX_PATH_CHECK_EDGE_E
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 3, GBBT(WH - PAT_GBPT, 1) + 7 * 3), STR_NONE, STR_NONE }, // WIDX_PATH_CHECK_EDGE_SE
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 2, GBBT(WH - PAT_GBPT, 1) + 7 * 4), STR_NONE, STR_NONE }, // WIDX_PATH_CHECK_EDGE_S
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 1, GBBT(WH - PAT_GBPT, 1) + 7 * 3), STR_NONE, STR_NONE }, // WIDX_PATH_CHECK_EDGE_SW
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 0, GBBT(WH - PAT_GBPT, 1) + 7 * 2), STR_NONE, STR_NONE }, // WIDX_PATH_CHECK_EDGE_W
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 1, GBBT(WH - PAT_GBPT, 1) + 7 * 1), STR_NONE, STR_NONE }, // WIDX_PATH_CHECK_EDGE_NW
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 2, GBBT(WH - PAT_GBPT, 1) + 7 * 0), STR_NONE, STR_NONE }, // WIDX_PATH_CHECK_EDGE_N
{ WIDGETS_END },
};
#define TRA_GBPB PADDING_BOTTOM // Track group box properties bottom
#define TRA_GBPT (TRA_GBPB + 16 + 3 * 21) // Track group box properties top
#define TRA_GBDB (TRA_GBPT + GROUPBOX_PADDING) // Track group box info bottom
#define TRA_GBDT (TRA_GBDB + 20 + 5 * 11) // Track group box info top
static rct_widget windowTileInspectorWidgetsTrack[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
{ WWT_CHECKBOX, 1, GBBF(WH - TRA_GBPT, 0, 0), STR_TILE_INSPECTOR_TRACK_ENTIRE_TRACK_PIECE, STR_NONE }, // WIDX_TRACK_CHECK_APPLY_TO_ALL
{ WWT_SPINNER, 1, GBS(WH - TRA_GBPT, 1, 1), STR_NONE, STR_NONE }, // WIDX_TRACK_SPINNER_HEIGHT
{ WWT_DROPDOWN_BUTTON, 1, GBSI(WH - TRA_GBPT, 1, 1), STR_NUMERIC_UP, STR_NONE }, // WIDX_TRACK_SPINNER_HEIGHT_INCREASE
{ WWT_DROPDOWN_BUTTON, 1, GBSD(WH - TRA_GBPT, 1, 1), STR_NUMERIC_DOWN, STR_NONE }, // WIDX_TRACK_SPINNER_HEIGHT_DECREASE
{ WWT_CHECKBOX, 1, GBBF(WH - TRA_GBPT, 0, 2), STR_TILE_INSPECTOR_TRACK_CHAIN_LIFT, STR_NONE }, // WIDX_TRACK_CHECK_CHAIN_LIFT
{ WIDGETS_END },
};
#define SCE_GBPB PADDING_BOTTOM // Scenery group box properties bottom
#define SCE_GBPT (SCE_GBPB + 16 + 4 * 21) // Scenery group box properties top
#define SCE_GBDB (SCE_GBPT + GROUPBOX_PADDING) // Scenery group box info bottom
#define SCE_GBDT (SCE_GBDB + 20 + 3 * 11) // Scenery group box info top
static rct_widget windowTileInspectorWidgetsScenery[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
{ WWT_SPINNER, 1, GBS(WH - SCE_GBPT, 1, 0), STR_NONE, STR_NONE }, // WIDX_SCENERY_SPINNER_HEIGHT
{ WWT_DROPDOWN_BUTTON, 1, GBSI(WH - SCE_GBPT, 1, 0), STR_NUMERIC_UP, STR_NONE }, // WIDX_SCENERY_SPINNER_HEIGHT_INCREASE
{ WWT_DROPDOWN_BUTTON, 1, GBSD(WH - SCE_GBPT, 1, 0), STR_NUMERIC_DOWN, STR_NONE }, // WIDX_SCENERY_SPINNER_HEIGHT_DECREASE
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 1, GBBT(WH - SCE_GBPT, 1) + 7 * 0), STR_NONE, STR_NONE }, // WIDX_SCENERY_CHECK_QUARTER_N
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 2, GBBT(WH - SCE_GBPT, 1) + 7 * 1), STR_NONE, STR_NONE }, // WIDX_SCENERY_CHECK_QUARTER_E
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 1, GBBT(WH - SCE_GBPT, 1) + 7 * 2), STR_NONE, STR_NONE }, // WIDX_SCENERY_CHECK_QUARTER_S
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 0, GBBT(WH - SCE_GBPT, 1) + 7 * 1), STR_NONE, STR_NONE }, // WIDX_SCENERY_CHECK_QUARTER_W
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 1, GBBT(WH - SCE_GBPT, 2) + 7 * 0), STR_NONE, STR_NONE }, // WIDX_SCENERY_CHECK_COLLISION_N
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 2, GBBT(WH - SCE_GBPT, 2) + 7 * 1), STR_NONE, STR_NONE }, // WIDX_SCENERY_CHECK_COLLISION_E
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 1, GBBT(WH - SCE_GBPT, 2) + 7 * 2), STR_NONE, STR_NONE }, // WIDX_SCENERY_CHECK_COLLISION_S
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 0, GBBT(WH - SCE_GBPT, 2) + 7 * 1), STR_NONE, STR_NONE }, // WIDX_SCENERY_CHECK_COLLISION_W
{ WIDGETS_END },
};
#define ENT_GBPB PADDING_BOTTOM // Entrance group box properties bottom
#define ENT_GBPT (ENT_GBPB + 16 + 1 * 21) // Entrance group box properties top
#define ENT_GBDB (ENT_GBPT + GROUPBOX_PADDING) // Entrance group box info bottom
#define ENT_GBDT (ENT_GBDB + 20 + 3 * 11) // Entrance group box info top
static rct_widget windowTileInspectorWidgetsEntrance[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
{ WWT_SPINNER, 1, GBS(WH - ENT_GBPT, 1, 0), STR_NONE, STR_NONE }, // WIDX_ENTRANCE_SPINNER_HEIGHT
{ WWT_DROPDOWN_BUTTON, 1, GBSI(WH - ENT_GBPT, 1, 0), STR_NUMERIC_UP, STR_NONE }, // WIDX_ENTRANCE_SPINNER_HEIGHT_INCREASE
{ WWT_DROPDOWN_BUTTON, 1, GBSD(WH - ENT_GBPT, 1, 0), STR_NUMERIC_DOWN, STR_NONE }, // WIDX_ENTRANCE_SPINNER_HEIGHT_DECREASE
{ WIDGETS_END },
};
#define FEN_GBPB PADDING_BOTTOM // Fence group box properties bottom
#define FEN_GBPT (FEN_GBPB + 16 + 2 * 21) // Fence group box properties top
#define FEN_GBDB (FEN_GBPT + GROUPBOX_PADDING) // Fence group box info bottom
#define FEN_GBDT (FEN_GBDB + 20 + 2 * 11) // Fence group box info top
static rct_widget windowTileInspectorWidgetsFence[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
{ WWT_SPINNER, 1, GBS(WH - FEN_GBPT, 1, 0), STR_NONE, STR_NONE }, // WIDX_FENCE_SPINNER_HEIGHT
{ WWT_DROPDOWN_BUTTON, 1, GBSI(WH - FEN_GBPT, 1, 0), STR_NUMERIC_UP, STR_NONE }, // WIDX_FENCE_SPINNER_HEIGHT_INCREASE
{ WWT_DROPDOWN_BUTTON, 1, GBSD(WH - FEN_GBPT, 1, 0), STR_NUMERIC_DOWN, STR_NONE }, // WIDX_FENCE_SPINNER_HEIGHT_DECREASE
{ WWT_DROPDOWN, 1, GBS(WH - FEN_GBPT, 1, 1), STR_NONE, STR_NONE }, // WIDX_FENCE_DROPDOWN_SLOPE
{ WWT_DROPDOWN_BUTTON, 1, GBDB(WH - FEN_GBPT, 1, 1), STR_DROPDOWN_GLYPH, STR_NONE }, // WIDX_FENCE_DROPDOWN_SLOPE_BUTTON
{ WIDGETS_END },
};
#define LAR_GBPB PADDING_BOTTOM // Large scenery group box properties bottom
#define LAR_GBPT (LAR_GBPB + 16 + 1 * 21) // Large scenery group box properties top
#define LAR_GBDB (LAR_GBPT + GROUPBOX_PADDING) // Large scenery group box info bottom
#define LAR_GBDT (LAR_GBDB + 20 + 3 * 11) // Large scenery group box info top
static rct_widget windowTileInspectorWidgetsLargeScenery[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
{ WWT_SPINNER, 1, GBS(WH - LAR_GBPT, 1, 0), STR_NONE, STR_NONE }, // WIDX_LARGE_SCENERY_SPINNER_HEIGHT
{ WWT_DROPDOWN_BUTTON, 1, GBSI(WH - LAR_GBPT, 1, 0), STR_NUMERIC_UP, STR_NONE }, // WIDX_LARGE_SCENERY_SPINNER_HEIGHT_INCREASE
{ WWT_DROPDOWN_BUTTON, 1, GBSD(WH - LAR_GBPT, 1, 0), STR_NUMERIC_DOWN, STR_NONE }, // WIDX_LARGE_SCENERY_SPINNER_HEIGHT_DECREASE
{ WIDGETS_END },
};
#define BAN_GBPB PADDING_BOTTOM // Banner group box properties bottom
#define BAN_GBPT (BAN_GBPB + 16 + 3 * 21) // Banner group box properties top
#define BAN_GBDB (BAN_GBPT + GROUPBOX_PADDING) // Banner group box info bottom
#define BAN_GBDT (BAN_GBDB + 20 + 1 * 11) // Banner group box info top
static rct_widget windowTileInspectorWidgetsBanner[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
{ WWT_SPINNER, 1, GBS(WH - BAN_GBPT, 1, 0), STR_NONE, STR_NONE }, // WIDX_BANNER_SPINNER_HEIGHT
{ WWT_DROPDOWN_BUTTON, 1, GBSI(WH - BAN_GBPT, 1, 0), STR_NUMERIC_UP, STR_NONE }, // WIDX_BANNER_SPINNER_HEIGHT_INCREASE
{ WWT_DROPDOWN_BUTTON, 1, GBSD(WH - BAN_GBPT, 1, 0), STR_NUMERIC_DOWN, STR_NONE }, // WIDX_BANNER_SPINNER_HEIGHT_DECREASE
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 3, GBBT(WH - BAN_GBPT, 1) + 7 * 1), STR_NONE, STR_NONE }, // WIDX_BANNER_CHECK_BLOCK_NE
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 3, GBBT(WH - BAN_GBPT, 1) + 7 * 3), STR_NONE, STR_NONE }, // WIDX_BANNER_CHECK_BLOCK_SE
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 1, GBBT(WH - BAN_GBPT, 1) + 7 * 3), STR_NONE, STR_NONE }, // WIDX_BANNER_CHECK_BLOCK_SW
{ WWT_CHECKBOX, 1, CHK(GBBL(1) + 14 * 1, GBBT(WH - BAN_GBPT, 1) + 7 * 1), STR_NONE, STR_NONE }, // WIDX_BANNER_CHECK_BLOCK_NW
{ WIDGETS_END },
};
#define COR_GBPB PADDING_BOTTOM // Corrupt element group box properties bottom
#define COR_GBPT (COR_GBPB + 16 + 2 * 21) // Corrupt element group box properties top
#define COR_GBDB (COR_GBPT + GROUPBOX_PADDING) // Corrupt element group box info bottom
#define COR_GBDT (COR_GBDB + 20 + 0 * 11) // Corrupt element group box info top
static rct_widget windowTileInspectorWidgetsCorrupt[] = {
MAIN_TILE_INSPECTOR_WIDGETS,
{ WWT_SPINNER, 1, GBS(WH - COR_GBPT, 1, 0), STR_NONE, STR_NONE }, // WIDX_CORRUPT_SPINNER_HEIGHT
{ WWT_DROPDOWN_BUTTON, 1, GBSI(WH - COR_GBPT, 1, 0), STR_NUMERIC_UP, STR_NONE }, // WIDX_CORRUPT_SPINNER_HEIGHT_INCREASE
{ WWT_DROPDOWN_BUTTON, 1, GBSD(WH - COR_GBPT, 1, 0), STR_NUMERIC_DOWN, STR_NONE }, // WIDX_CORRUPT_SPINNER_HEIGHT_DECREASE
{ WWT_CLOSEBOX, 1, GBB(WH - SUR_GBPT, 0, 1), STR_TILE_INSPECTOR_CLAMP_TO_NEXT, STR_TILE_INSPECTOR_CLAMP_TO_NEXT_TIP }, // WIDX_CORRUPT_BUTTON_CLAMP
{ WIDGETS_END },
};
static rct_widget *tileInspectorWidgets[] = {
windowTileInspectorWidgets,
windowTileInspectorWidgetsSurface,
windowTileInspectorWidgetsPath,
windowTileInspectorWidgetsTrack,
windowTileInspectorWidgetsScenery,
windowTileInspectorWidgetsEntrance,
windowTileInspectorWidgetsFence,
windowTileInspectorWidgetsLargeScenery,
windowTileInspectorWidgetsBanner,
windowTileInspectorWidgetsCorrupt,
};
static struct {
// Offsets from the bottom of the window
sint16 detailsTopOffset, detailsBottomOffset;
sint16 properties_top_offset, properties_bottom_offset;
// String to be displayed in the details groupbox
rct_string_id string_idx;
} pageGroupBoxSettings[] = {
{ SUR_GBDT, SUR_GBDB, SUR_GBPT, SUR_GBPB, STR_TILE_INSPECTOR_GROUPBOX_SURFACE_INFO },
{ PAT_GBDT, PAT_GBDB, PAT_GBPT, PAT_GBPB, STR_TILE_INSPECTOR_GROUPBOX_PATH_INFO },
{ TRA_GBDT, TRA_GBDB, TRA_GBPT, TRA_GBPB, STR_TILE_INSPECTOR_GROUPBOX_TRACK_INFO },
{ SCE_GBDT, SCE_GBDB, SCE_GBPT, SCE_GBPB, STR_TILE_INSPECTOR_GROUPBOX_SCENERY_INFO },
{ ENT_GBDT, ENT_GBDB, ENT_GBPT, ENT_GBPB, STR_TILE_INSPECTOR_GROUPBOX_ENTRANCE_INFO },
{ FEN_GBDT, FEN_GBDB, FEN_GBPT, FEN_GBPB, STR_TILE_INSPECTOR_GROUPBOX_FENCE_INFO },
{ LAR_GBDT, LAR_GBDB, LAR_GBPT, LAR_GBPB, STR_TILE_INSPECTOR_GROUPBOX_LARGE_SCENERY_INFO },
{ BAN_GBDT, BAN_GBDB, BAN_GBPT, BAN_GBPB, STR_TILE_INSPECTOR_GROUPBOX_BANNER_INFO },
{ COR_GBDT, COR_GBDB, COR_GBPT, COR_GBPB, STR_TILE_INSPECTOR_GROUPBOX_CORRUPT_INFO }
};
static sint16 windowTileInspectorHighlightedIndex = -1;
static unsigned int windowTileInspectorTileX;
static unsigned int windowTileInspectorTileY;
static bool windowTileInspectorTileSelected = false;
static int windowTileInspectorElementCount = 0;
static bool windowTileInspectorApplyToAll = false;
static rct_map_element* window_tile_inspector_get_selected_element(rct_window *w);
static void window_tile_inspector_load_tile(rct_window* w);
static void window_tile_inspector_insert_corrupt_element(rct_window *w);
static void window_tile_inspector_swap_elements(sint16 first, sint16 second);
static void window_tile_inspector_remove_element(int index);
static void window_tile_inspector_rotate_element(int index);
static void window_tile_inspector_sort_elements(rct_window *w);
static void window_tile_inspector_surface_toggle_corner(rct_map_element *mapElement, int cornerIndex);
static void window_tile_inspector_track_block_height_offset(rct_map_element *mapElement, uint8 offset);
static void window_tile_inspector_track_block_set_lift(rct_map_element *mapElement, bool chain);
static void window_tile_inspector_quarter_tile_set(rct_map_element *const mapElement, const int index);
static void window_tile_inspector_mouseup(rct_window *w, int widgetIndex);
static void window_tile_inspector_resize(rct_window *w);
static void window_tile_inspector_mousedown(int widgetIndex, rct_window *w, rct_widget* widget);
static void window_tile_inspector_update(rct_window *w);
static void window_tile_inspector_dropdown(rct_window *w, int widgetIndex, int dropdownIndex);
static void window_tile_inspector_tool_update(rct_window* w, int widgetIndex, int x, int y);
static void window_tile_inspector_tool_down(rct_window* w, int widgetIndex, int x, int y);
static void window_tile_inspector_scrollgetsize(rct_window *w, int scrollIndex, int *width, int *height);
static void window_tile_inspector_scrollmousedown(rct_window *w, int scrollIndex, int x, int y);
static void window_tile_inspector_scrollmouseover(rct_window *w, int scrollIndex, int x, int y);
static void window_tile_inspector_invalidate(rct_window *w);
static void window_tile_inspector_paint(rct_window *w, rct_drawpixelinfo *dpi);
static void window_tile_inspector_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrollIndex);
static void window_tile_inspector_set_page(rct_window *w, const int page);
static void window_tile_inspector_auto_set_buttons(rct_window *w);
static rct_window_event_list windowTileInspectorEvents = {
NULL,
window_tile_inspector_mouseup,
window_tile_inspector_resize,
window_tile_inspector_mousedown,
window_tile_inspector_dropdown,
NULL,
window_tile_inspector_update,
NULL,
NULL,
window_tile_inspector_tool_update,
window_tile_inspector_tool_down,
NULL,
NULL,
NULL,
NULL,
window_tile_inspector_scrollgetsize,
window_tile_inspector_scrollmousedown,
NULL,
window_tile_inspector_scrollmouseover,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
window_tile_inspector_invalidate,
window_tile_inspector_paint,
window_tile_inspector_scrollpaint
};
static uint64 windowTileInspectorEnabledWidgets[] = {
(1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT),
(1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_BUTTON_ROTATE) | (1ULL << WIDX_SURFACE_SPINNER_HEIGHT_INCREASE) | (1ULL << WIDX_SURFACE_SPINNER_HEIGHT_DECREASE) | (1ULL << WIDX_SURFACE_BUTTON_REMOVE_FENCES) | (1ULL << WIDX_SURFACE_BUTTON_RESTORE_FENCES) | (1ULL << WIDX_SURFACE_CHECK_CORNER_N) | (1ULL << WIDX_SURFACE_CHECK_CORNER_E) | (1ULL << WIDX_SURFACE_CHECK_CORNER_S) | (1ULL << WIDX_SURFACE_CHECK_CORNER_W) | (1ULL << WIDX_SURFACE_CHECK_DIAGONAL),
(1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_BUTTON_ROTATE) | (1ULL << WIDX_PATH_SPINNER_HEIGHT_INCREASE) | (1ULL << WIDX_PATH_SPINNER_HEIGHT_DECREASE) | (1ULL << WIDX_PATH_CHECK_EDGE_N) | (1ULL << WIDX_PATH_CHECK_EDGE_NE) | (1ULL << WIDX_PATH_CHECK_EDGE_E) | (1ULL << WIDX_PATH_CHECK_EDGE_SE) | (1ULL << WIDX_PATH_CHECK_EDGE_S) | (1ULL << WIDX_PATH_CHECK_EDGE_SW) | (1ULL << WIDX_PATH_CHECK_EDGE_W) | (1ULL << WIDX_PATH_CHECK_EDGE_NW),
(1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_BUTTON_ROTATE) | (1ULL << WIDX_TRACK_CHECK_APPLY_TO_ALL) | (1ULL << WIDX_TRACK_SPINNER_HEIGHT_INCREASE) | (1ULL << WIDX_TRACK_SPINNER_HEIGHT_DECREASE) | (1ULL << WIDX_TRACK_CHECK_CHAIN_LIFT),
(1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_BUTTON_ROTATE) | (1ULL << WIDX_SCENERY_SPINNER_HEIGHT_INCREASE) | (1ULL << WIDX_SCENERY_SPINNER_HEIGHT_DECREASE) | (1ULL << WIDX_SCENERY_CHECK_QUARTER_N) | (1ULL << WIDX_SCENERY_CHECK_QUARTER_E) | (1ULL << WIDX_SCENERY_CHECK_QUARTER_S) | (1ULL << WIDX_SCENERY_CHECK_QUARTER_W) | (1ULL << WIDX_SCENERY_CHECK_COLLISION_N) | (1ULL << WIDX_SCENERY_CHECK_COLLISION_E) | (1ULL << WIDX_SCENERY_CHECK_COLLISION_S) | (1ULL << WIDX_SCENERY_CHECK_COLLISION_W),
(1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_BUTTON_ROTATE) | (1ULL << WIDX_ENTRANCE_SPINNER_HEIGHT_INCREASE) | (1ULL << WIDX_ENTRANCE_SPINNER_HEIGHT_DECREASE),
(1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_BUTTON_ROTATE) | (1ULL << WIDX_FENCE_SPINNER_HEIGHT_INCREASE) | (1ULL << WIDX_FENCE_SPINNER_HEIGHT_DECREASE) | (1ULL << WIDX_FENCE_DROPDOWN_SLOPE) | (1ULL << WIDX_FENCE_DROPDOWN_SLOPE_BUTTON),
(1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_LARGE_SCENERY_SPINNER_HEIGHT) | (1ULL << WIDX_LARGE_SCENERY_SPINNER_HEIGHT_INCREASE) | (1ULL << WIDX_LARGE_SCENERY_SPINNER_HEIGHT_DECREASE),
(1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_BUTTON_ROTATE) | (1ULL << WIDX_BANNER_SPINNER_HEIGHT) | (1ULL << WIDX_BANNER_SPINNER_HEIGHT_INCREASE) | (1ULL << WIDX_BANNER_SPINNER_HEIGHT_DECREASE) | (1ULL << WIDX_BANNER_CHECK_BLOCK_NE) | (1ULL << WIDX_BANNER_CHECK_BLOCK_SE) | (1ULL << WIDX_BANNER_CHECK_BLOCK_SW) | (1ULL << WIDX_BANNER_CHECK_BLOCK_NW),
(1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_CORRUPT_SPINNER_HEIGHT) | (1ULL << WIDX_CORRUPT_SPINNER_HEIGHT_INCREASE) | (1ULL << WIDX_CORRUPT_SPINNER_HEIGHT_DECREASE) | (1ULL << WIDX_CORRUPT_BUTTON_CLAMP),
};
static uint64 windowTileInspectorDisabledWidgets[] = {
(1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_MOVE_UP) | (1ULL << WIDX_BUTTON_MOVE_DOWN) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_BUTTON_ROTATE),
0,
0,
0,
0,
0,
0,
(1ULL << WIDX_BUTTON_ROTATE),
0,
(1ULL << WIDX_BUTTON_ROTATE),
};
void window_tile_inspector_open() {
rct_window* window;
// Check if window is already open
window = window_bring_to_front_by_class(WC_TILE_INSPECTOR);
if (window != NULL)
return;
window = window_create(
0,
29,
WW,
WH,
&windowTileInspectorEvents,
WC_TILE_INSPECTOR,
WF_RESIZABLE
);
window_tile_inspector_set_page(window, PAGE_DEFAULT);
window_init_scroll_widgets(window);
window->min_width = MIN_WW;
window->min_height = MIN_WH;
window->max_width = MAX_WW;
window->max_height = MAX_WH;
window->selected_list_item = -1;
windowTileInspectorTileSelected = false;
tool_set(window, WIDX_BACKGROUND, 12);
window_tile_inspector_auto_set_buttons(window);
}
static rct_map_element* window_tile_inspector_get_selected_element(rct_window *w) {
assert(w->selected_list_item >= 0 && w->selected_list_item < windowTileInspectorElementCount);
return map_get_first_element_at(windowTileInspectorTileX, windowTileInspectorTileY) + w->selected_list_item;
}
static void window_tile_inspector_load_tile(rct_window* w) {
rct_map_element *element = map_get_first_element_at(windowTileInspectorTileX, windowTileInspectorTileY);
int numItems = 0;
do {
numItems++;
} while (!map_element_is_last_for_tile(element++));
windowTileInspectorElementCount = numItems;
// Set default page
window_tile_inspector_set_page(w, PAGE_DEFAULT);
// undo selection and buttons affecting it
w->selected_list_item = -1;
window_tile_inspector_auto_set_buttons(w);
w->scrolls[0].v_top = 0;
window_invalidate(w);
}
static void window_tile_inspector_insert_corrupt_element(rct_window *w) {
// Create new corrupt element
rct_map_element *curruptElement = map_element_insert(windowTileInspectorTileX, windowTileInspectorTileY, -1, 0); // Ugly hack: -1 guarantees this to be placed first
windowTileInspectorElementCount++;
assert(curruptElement != NULL);
curruptElement->type = MAP_ELEMENT_TYPE_CORRUPT;
// Set the base height to be the same as the selected element
rct_map_element *const selectedElement = window_tile_inspector_get_selected_element(w);
curruptElement->base_height = curruptElement->clearance_height = selectedElement->base_height;
// Move the corrupt element up until the selected list item is reached
// this way it's placed under the selected element, even when there are multiple elements with the same base height
for (int i = 0; i < w->selected_list_item; i++) {
window_tile_inspector_swap_elements(i, i + 1);
}
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
}
static void window_tile_inspector_remove_element(int index) {
assert(index < windowTileInspectorElementCount);
rct_map_element *const mapElement = map_get_first_element_at(windowTileInspectorTileX, windowTileInspectorTileY) + index;
map_element_remove(mapElement);
windowTileInspectorElementCount--;
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
}
static void window_tile_inspector_rotate_element(int index) {
uint8 newRotation, pathEdges, pathCorners;
assert(index < windowTileInspectorElementCount);
rct_map_element *const mapElement = map_get_first_element_at(windowTileInspectorTileX, windowTileInspectorTileY) + index;
switch (map_element_get_type(mapElement)) {
case MAP_ELEMENT_TYPE_PATH:
if (footpath_element_is_sloped(mapElement)) {
newRotation = (footpath_element_get_slope_direction(mapElement) + 1) & MAP_ELEMENT_DIRECTION_MASK;
mapElement->properties.path.type &= ~MAP_ELEMENT_DIRECTION_MASK;
mapElement->properties.path.type |= newRotation;
}
pathEdges = mapElement->properties.path.edges & 0x0F;
pathCorners = mapElement->properties.path.edges & 0xF0;
mapElement->properties.path.edges = 0;
mapElement->properties.path.edges |= ((pathEdges << 1) | (pathEdges >> 3)) & 0x0F;
mapElement->properties.path.edges |= ((pathCorners << 1) | (pathCorners >> 3)) & 0xF0;
break;
case MAP_ELEMENT_TYPE_TRACK:
case MAP_ELEMENT_TYPE_SCENERY:
case MAP_ELEMENT_TYPE_ENTRANCE:
case MAP_ELEMENT_TYPE_FENCE:
newRotation = (mapElement->type + 1) & MAP_ELEMENT_DIRECTION_MASK;
mapElement->type &= ~MAP_ELEMENT_DIRECTION_MASK;
mapElement->type |= newRotation;
break;
case MAP_ELEMENT_TYPE_BANNER:
mapElement->properties.banner.flags ^= 1 << mapElement->properties.banner.position;
mapElement->properties.banner.position++;
mapElement->properties.banner.position &= 3;
mapElement->properties.banner.flags ^= 1 << mapElement->properties.banner.position;
break;
}
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
}
// Swap element with its parent
static void window_tile_inspector_swap_elements(sint16 first, sint16 second) {
rct_map_element *mapElement = map_get_first_element_at(windowTileInspectorTileX, windowTileInspectorTileY);
rct_map_element *const firstElement = mapElement + first;
rct_map_element *const secondElement = mapElement + second;
// swap_elements shouldn't be called when there is only one element on the tile
assert(!map_element_is_last_for_tile(mapElement));
// Make sure both elements are actually on the current tile
sint16 elementCount = 0;
do {
elementCount++;
} while (!map_element_is_last_for_tile(mapElement++));
assert(elementCount > max(first, second));
// Swap their memory
rct_map_element temp = *firstElement;
*firstElement = *secondElement;
*secondElement = temp;
// Swap the 'last map element for tile' flag if either one of them was last
if (map_element_is_last_for_tile(firstElement) || map_element_is_last_for_tile(secondElement)) {
firstElement->flags ^= MAP_ELEMENT_FLAG_LAST_TILE;
secondElement->flags ^= MAP_ELEMENT_FLAG_LAST_TILE;
}
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
}
static void window_tile_inspector_sort_elements(rct_window *w) {
const rct_map_element *const firstElement = map_get_first_element_at(windowTileInspectorTileX, windowTileInspectorTileY);
// Bubble sort
for (int loopStart = 1; loopStart < windowTileInspectorElementCount; loopStart++) {
int currentId = loopStart;
const rct_map_element *currentElement = firstElement + currentId;
const rct_map_element *otherElement = currentElement - 1;
// While current element's base height is lower, or (when their baseheight is the same) the other map element's clearance height is lower...
while (currentId > 0 && (otherElement->base_height > currentElement->base_height || (otherElement->base_height == currentElement->base_height && otherElement->clearance_height > currentElement->clearance_height))) {
window_tile_inspector_swap_elements(currentId - 1, currentId);
currentId--;
currentElement--;
otherElement--;
}
}
}
static void window_tile_inspector_surface_toggle_corner(rct_map_element *mapElement, int cornerIndex) {
const uint8 originalSlope = mapElement->properties.surface.slope;
const bool diagonal = (originalSlope & 0x10) >> 4;
mapElement->properties.surface.slope ^= 1 << cornerIndex;
if (mapElement->properties.surface.slope & 0x0F) {
mapElement->clearance_height = mapElement->base_height + 2;
}
else {
mapElement->clearance_height = mapElement->base_height;
}
// All corners are raised
if ((mapElement->properties.surface.slope & 0x0F) == 0x0F) {
mapElement->properties.surface.slope &= ~0x1F;
if (diagonal) {
switch (originalSlope & 0x0F) {
case 0b1011: mapElement->properties.surface.slope |= (1 << 0); break;
case 0b0111: mapElement->properties.surface.slope |= (1 << 1); break;
case 0b1110: mapElement->properties.surface.slope |= (1 << 2); break;
case 0b1101: mapElement->properties.surface.slope |= (1 << 3); break;
}
}
// Update base and clearance heights
mapElement->base_height += 2;
mapElement->clearance_height = mapElement->base_height + (diagonal ? 2 : 0);
}
}
// Copied from track.c (track_remove), and modified for raising/lowering
// Not sure if this should be in this file, track.c, or maybe another one
static void window_tile_inspector_track_block_height_offset(rct_map_element *mapElement, uint8 offset) {
uint8 type = mapElement->properties.track.type;
sint16 originX = windowTileInspectorTileX << 5;
sint16 originY = windowTileInspectorTileY << 5;
sint16 originZ = mapElement->base_height * 8;
uint8 rotation = map_element_get_direction(mapElement);
uint8 rideIndex = mapElement->properties.track.ride_index;
rct_ride* ride = get_ride(rideIndex);
const rct_preview_track* trackBlock = get_track_def_from_ride(ride, type);
trackBlock += mapElement->properties.track.sequence & 0x0F;
uint8 originDirection = map_element_get_direction(mapElement);
switch (originDirection) {
case 0:
originX -= trackBlock->x;
originY -= trackBlock->y;
break;
case 1:
originX -= trackBlock->y;
originY += trackBlock->x;
break;
case 2:
originX += trackBlock->x;
originY += trackBlock->y;
break;
case 3:
originX += trackBlock->y;
originY -= trackBlock->x;
break;
}
originZ -= trackBlock->z;
trackBlock = get_track_def_from_ride(ride, type);
for (; trackBlock->index != 255; trackBlock++) {
sint16 x = originX, y = originY, z = originZ;
switch (originDirection) {
case 0:
x += trackBlock->x;
y += trackBlock->y;
break;
case 1:
x += trackBlock->y;
y -= trackBlock->x;
break;
case 2:
x -= trackBlock->x;
y -= trackBlock->y;
break;
case 3:
x -= trackBlock->y;
y += trackBlock->x;
break;
}
z += trackBlock->z;
map_invalidate_tile_full(x, y);
bool found = false;
mapElement = map_get_first_element_at(x >> 5, y >> 5);
do {
if (mapElement->base_height != z / 8)
continue;
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK)
continue;
if ((mapElement->type & MAP_ELEMENT_DIRECTION_MASK) != rotation)
continue;
if ((mapElement->properties.track.sequence & 0x0F) != trackBlock->index)
continue;
if (mapElement->properties.track.type != type)
continue;
found = true;
break;
} while (!map_element_is_last_for_tile(mapElement++));
if (!found) {
log_error("Track map element part not found!");
return;
}
// track_remove returns here on failure, not sure when this would ever be hit. Only thing I can think of is for when you decrease the map size.
assert(map_get_surface_element_at(x >> 5, y >> 5) != NULL);
// Keep?
//invalidate_test_results(ride_index);
mapElement->base_height += offset;
mapElement->clearance_height += offset;
}
}
// Sets chainlift for entire block
// Basically a copy of the above function, with just two different lines... should probably be combined somehow
static void window_tile_inspector_track_block_set_lift(rct_map_element *mapElement, bool chain) {
uint8 type = mapElement->properties.track.type;
sint16 originX = windowTileInspectorTileX << 5;
sint16 originY = windowTileInspectorTileY << 5;
sint16 originZ = mapElement->base_height * 8;
uint8 rotation = map_element_get_direction(mapElement);
uint8 rideIndex = mapElement->properties.track.ride_index;
rct_ride* ride = get_ride(rideIndex);
const rct_preview_track* trackBlock = get_track_def_from_ride(ride, type);
trackBlock += mapElement->properties.track.sequence & 0x0F;
uint8 originDirection = map_element_get_direction(mapElement);
switch (originDirection) {
case 0:
originX -= trackBlock->x;
originY -= trackBlock->y;
break;
case 1:
originX -= trackBlock->y;
originY += trackBlock->x;
break;
case 2:
originX += trackBlock->x;
originY += trackBlock->y;
break;
case 3:
originX += trackBlock->y;
originY -= trackBlock->x;
break;
}
originZ -= trackBlock->z;
trackBlock = get_track_def_from_ride(ride, type);
for (; trackBlock->index != 255; trackBlock++) {
sint16 x = originX, y = originY, z = originZ;
switch (originDirection) {
case 0:
x += trackBlock->x;
y += trackBlock->y;
break;
case 1:
x += trackBlock->y;
y -= trackBlock->x;
break;
case 2:
x -= trackBlock->x;
y -= trackBlock->y;
break;
case 3:
x -= trackBlock->y;
y += trackBlock->x;
break;
}
z += trackBlock->z;
map_invalidate_tile_full(x, y);
bool found = false;
mapElement = map_get_first_element_at(x >> 5, y >> 5);
do {
if (mapElement->base_height != z / 8)
continue;
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK)
continue;
if ((mapElement->type & MAP_ELEMENT_DIRECTION_MASK) != rotation)
continue;
if ((mapElement->properties.track.sequence & 0x0F) != trackBlock->index)
continue;
if (mapElement->properties.track.type != type)
continue;
found = true;
break;
} while (!map_element_is_last_for_tile(mapElement++));
if (!found) {
log_error("Track map element part not found!");
return;
}
// track_remove returns here on failure, not sure when this would ever be hit. Only thing I can think of is for when you decrease the map size.
assert(map_get_surface_element_at(x >> 5, y >> 5) != NULL);
// Keep?
//invalidate_test_results(ride_index);
if (track_element_is_lift_hill(mapElement) != chain) {
mapElement->type ^= TRACK_ELEMENT_FLAG_CHAIN_LIFT;
}
}
}
static void window_tile_inspector_quarter_tile_set(rct_map_element *const mapElement, const int index) {
// index is widget index relative to WIDX_SCENERY_CHECK_QUARTER_N, so a value from 0-3
assert(index >= 0 && index < 4);
const int clickedDirection = (index - get_current_rotation()) & 3;
// Set quadrant index
mapElement->type &= ~MAP_ELEMENT_QUADRANT_MASK;
mapElement->type |= clickedDirection << 6;
// Update collision
mapElement->flags &= 0xF0;
mapElement->flags |= 1 << ((index + 6 - get_current_rotation()) & 3);
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
}
static void window_tile_inspector_mouseup(rct_window *w, int widgetIndex) {
switch (widgetIndex) {
case WIDX_CLOSE:
tool_cancel();
window_close(w);
break;
case WIDX_SPINNER_X_INCREASE:
windowTileInspectorTileX = min(windowTileInspectorTileX + 1, 255);
window_tile_inspector_load_tile(w);
window_tile_inspector_auto_set_buttons(w);
break;
case WIDX_SPINNER_X_DECREASE:
windowTileInspectorTileX = max(windowTileInspectorTileX - 1, 0);
window_tile_inspector_load_tile(w);
window_tile_inspector_auto_set_buttons(w);
break;
case WIDX_SPINNER_Y_INCREASE:
windowTileInspectorTileY = min(windowTileInspectorTileY + 1, 255);
window_tile_inspector_load_tile(w);
window_tile_inspector_auto_set_buttons(w);
break;
case WIDX_SPINNER_Y_DECREASE:
windowTileInspectorTileY = max(windowTileInspectorTileY - 1, 0);
window_tile_inspector_load_tile(w);
window_tile_inspector_auto_set_buttons(w);
break;
case WIDX_BUTTON_CORRUPT:
window_tile_inspector_insert_corrupt_element(w);
window_tile_inspector_set_page(w, PAGE_CORRUPT);
window_tile_inspector_auto_set_buttons(w);
window_invalidate(w);
break;
case WIDX_BUTTON_REMOVE:
window_tile_inspector_remove_element(w->selected_list_item);
window_tile_inspector_set_page(w, PAGE_DEFAULT);
w->selected_list_item = -1;
window_tile_inspector_set_page(w, PAGE_DEFAULT);
window_tile_inspector_auto_set_buttons(w);
window_invalidate(w);
break;