/
Guest.cpp
2133 lines (1864 loc) 路 61.6 KB
/
Guest.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-2019 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 <openrct2-ui/interface/Viewport.h>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Context.h>
#include <openrct2/Game.h>
#include <openrct2/GameState.h>
#include <openrct2/Input.h>
#include <openrct2/actions/GuestSetFlagsAction.hpp>
#include <openrct2/actions/PeepPickupAction.hpp>
#include <openrct2/config/Config.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/management/Marketing.h>
#include <openrct2/network/network.h>
#include <openrct2/peep/Peep.h>
#include <openrct2/peep/Staff.h>
#include <openrct2/ride/RideData.h>
#include <openrct2/ride/ShopItem.h>
#include <openrct2/scenario/Scenario.h>
#include <openrct2/sprites.h>
#include <openrct2/util/Util.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/world/Footpath.h>
#include <openrct2/world/Park.h>
// clang-format off
enum WINDOW_GUEST_PAGE {
WINDOW_GUEST_OVERVIEW,
WINDOW_GUEST_STATS,
WINDOW_GUEST_RIDES,
WINDOW_GUEST_FINANCE,
WINDOW_GUEST_THOUGHTS,
WINDOW_GUEST_INVENTORY,
WINDOW_GUEST_DEBUG
};
enum WINDOW_GUEST_WIDGET_IDX {
WIDX_BACKGROUND,
WIDX_TITLE,
WIDX_CLOSE,
WIDX_PAGE_BACKGROUND,
WIDX_TAB_1,
WIDX_TAB_2,
WIDX_TAB_3,
WIDX_TAB_4,
WIDX_TAB_5,
WIDX_TAB_6,
WIDX_TAB_7,
WIDX_MARQUEE = 11,
WIDX_VIEWPORT,
WIDX_ACTION_LBL,
WIDX_PICKUP,
WIDX_RENAME,
WIDX_LOCATE,
WIDX_TRACK,
WIDX_RIDE_SCROLL = 11
};
validate_global_widx(WC_PEEP, WIDX_PICKUP);
static constexpr int32_t TabWidth = 30;
#define MAIN_GUEST_WIDGETS \
{ WWT_FRAME, 0, 0, 191, 0, 156, 0xFFFFFFFF, STR_NONE }, /* Panel / Background */ \
{ WWT_CAPTION, 0, 1, 190, 1, 14, STR_STRINGID, STR_WINDOW_TITLE_TIP }, /* Title */ \
{ WWT_CLOSEBOX, 0, 179, 189, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, /* Close x button */ \
{ WWT_RESIZE, 1, 0, 191, 43, 156, 0xFFFFFFFF, STR_NONE }, /* Resize */ \
{ WWT_TAB, 1, 3, TabWidth + 3, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_SHOW_GUEST_VIEW_TIP }, /* Tab 1 */ \
{ WWT_TAB, 1, 34, TabWidth + 34, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_SHOW_GUEST_NEEDS_TIP }, /* Tab 2 */ \
{ WWT_TAB, 1, 65, TabWidth + 65, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_SHOW_GUEST_VISITED_RIDES_TIP }, /* Tab 3 */ \
{ WWT_TAB, 1, 96, TabWidth + 96, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_SHOW_GUEST_FINANCE_TIP }, /* Tab 4 */ \
{ WWT_TAB, 1, 127, TabWidth + 127, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_SHOW_GUEST_THOUGHTS_TIP }, /* Tab 5 */ \
{ WWT_TAB, 1, 158, TabWidth + 158, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_SHOW_GUEST_ITEMS_TIP }, /* Tab 6 */ \
{ WWT_TAB, 1, 189, TabWidth + 189, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_DEBUG_TIP } /* Tab 7 */
static rct_widget window_guest_overview_widgets[] = {
MAIN_GUEST_WIDGETS,
{ WWT_LABEL_CENTRED, 1, 3, 166, 45, 56, 0xFFFFFFFF, STR_NONE }, // Label Thought marquee
{ WWT_VIEWPORT, 1, 3, 166, 57, 143, 0xFFFFFFFF, STR_NONE }, // Viewport
{ WWT_LABEL_CENTRED, 1, 3, 166, 144, 154, 0xFFFFFFFF, STR_NONE }, // Label Action
{ WWT_FLATBTN, 1, 167, 190, 45, 68, SPR_PICKUP_BTN, STR_PICKUP_TIP }, // Pickup Button
{ WWT_FLATBTN, 1, 167, 190, 69, 92, SPR_RENAME, STR_NAME_GUEST_TIP }, // Rename Button
{ WWT_FLATBTN, 1, 167, 190, 93, 116, SPR_LOCATE, STR_LOCATE_SUBJECT_TIP }, // Locate Button
{ WWT_FLATBTN, 1, 167, 190, 117, 140, SPR_TRACK_PEEP, STR_TOGGLE_GUEST_TRACKING_TIP }, // Track Button
{ WIDGETS_END },
};
static rct_widget window_guest_stats_widgets[] = {
MAIN_GUEST_WIDGETS,
{ WIDGETS_END },
};
static rct_widget window_guest_rides_widgets[] = {
MAIN_GUEST_WIDGETS,
{ WWT_SCROLL, 1, 3, 188, 57, 143, SCROLL_VERTICAL, STR_NONE },
{ WIDGETS_END },
};
static rct_widget window_guest_finance_widgets[] = {
MAIN_GUEST_WIDGETS,
{ WIDGETS_END },
};
static rct_widget window_guest_thoughts_widgets[] = {
MAIN_GUEST_WIDGETS,
{ WIDGETS_END },
};
static rct_widget window_guest_inventory_widgets[] = {
MAIN_GUEST_WIDGETS,
{ WIDGETS_END },
};
static rct_widget window_guest_debug_widgets[] = {
MAIN_GUEST_WIDGETS,
{ WIDGETS_END },
};
// 0x981D0C
static rct_widget *window_guest_page_widgets[] = {
window_guest_overview_widgets,
window_guest_stats_widgets,
window_guest_rides_widgets,
window_guest_finance_widgets,
window_guest_thoughts_widgets,
window_guest_inventory_widgets,
window_guest_debug_widgets
};
static void window_guest_set_page(rct_window* w, int32_t page);
static void window_guest_disable_widgets(rct_window* w);
static void window_guest_viewport_init(rct_window* w);
static void window_guest_common_resize(rct_window* w);
static void window_guest_common_invalidate(rct_window* w);
static void window_guest_overview_close(rct_window *w);
static void window_guest_overview_resize(rct_window *w);
static void window_guest_overview_mouse_up(rct_window *w, rct_widgetindex widgetIndex);
static void window_guest_overview_paint(rct_window *w, rct_drawpixelinfo *dpi);
static void window_guest_overview_invalidate(rct_window *w);
static void window_guest_overview_viewport_rotate(rct_window *w);
static void window_guest_overview_update(rct_window* w);
static void window_guest_overview_text_input(rct_window *w, rct_widgetindex widgetIndex, char *text);
static void window_guest_overview_tool_update(rct_window* w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords);
static void window_guest_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords);
static void window_guest_overview_tool_abort(rct_window *w, rct_widgetindex widgetIndex);
static void window_guest_mouse_up(rct_window *w, rct_widgetindex widgetIndex);
static void window_guest_stats_update(rct_window *w);
static void window_guest_stats_paint(rct_window *w, rct_drawpixelinfo *dpi);
static void window_guest_rides_update(rct_window *w);
static void window_guest_rides_scroll_get_size(rct_window *w, int32_t scrollIndex, int32_t *width, int32_t *height);
static void window_guest_rides_scroll_mouse_down(rct_window *w, int32_t scrollIndex, ScreenCoordsXY screenCoords);
static void window_guest_rides_scroll_mouse_over(rct_window *w, int32_t scrollIndex, ScreenCoordsXY screenCoords);
static void window_guest_rides_invalidate(rct_window *w);
static void window_guest_rides_paint(rct_window *w, rct_drawpixelinfo *dpi);
static void window_guest_rides_scroll_paint(rct_window *w, rct_drawpixelinfo *dpi, int32_t scrollIndex);
static void window_guest_finance_update(rct_window *w);
static void window_guest_finance_paint(rct_window *w, rct_drawpixelinfo *dpi);
static void window_guest_thoughts_update(rct_window *w);
static void window_guest_thoughts_paint(rct_window *w, rct_drawpixelinfo *dpi);
static void window_guest_inventory_update(rct_window *w);
static void window_guest_inventory_paint(rct_window *w, rct_drawpixelinfo *dpi);
static void window_guest_debug_update(rct_window *w);
static void window_guest_debug_paint(rct_window *w, rct_drawpixelinfo* dpi);
static rct_window_event_list window_guest_overview_events = {
window_guest_overview_close,
window_guest_overview_mouse_up,
window_guest_overview_resize,
nullptr,
nullptr,
nullptr,
window_guest_overview_update,
nullptr,
nullptr,
window_guest_overview_tool_update,
window_guest_overview_tool_down,
nullptr,
nullptr,
window_guest_overview_tool_abort,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
window_guest_overview_text_input,
window_guest_overview_viewport_rotate,
nullptr,
nullptr,
nullptr,
nullptr,
window_guest_overview_invalidate,
window_guest_overview_paint,
nullptr
};
static rct_window_event_list window_guest_stats_events = {
nullptr,
window_guest_mouse_up,
window_guest_common_resize,
nullptr,
nullptr,
nullptr,
window_guest_stats_update,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
window_guest_common_invalidate,
window_guest_stats_paint,
nullptr
};
static rct_window_event_list window_guest_rides_events = {
nullptr,
window_guest_mouse_up,
window_guest_common_resize,
nullptr,
nullptr,
nullptr,
window_guest_rides_update,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
window_guest_rides_scroll_get_size,
window_guest_rides_scroll_mouse_down,
nullptr,
window_guest_rides_scroll_mouse_over,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
window_guest_rides_invalidate,
window_guest_rides_paint,
window_guest_rides_scroll_paint
};
static rct_window_event_list window_guest_finance_events = {
nullptr,
window_guest_mouse_up,
window_guest_common_resize,
nullptr,
nullptr,
nullptr,
window_guest_finance_update,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
window_guest_common_invalidate,
window_guest_finance_paint,
nullptr
};
static rct_window_event_list window_guest_thoughts_events = {
nullptr,
window_guest_mouse_up,
window_guest_common_resize,
nullptr,
nullptr,
nullptr,
window_guest_thoughts_update,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
window_guest_common_invalidate,
window_guest_thoughts_paint,
nullptr
};
static rct_window_event_list window_guest_inventory_events = {
nullptr,
window_guest_mouse_up,
window_guest_common_resize,
nullptr,
nullptr,
nullptr,
window_guest_inventory_update,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
window_guest_common_invalidate,
window_guest_inventory_paint,
nullptr
};
static rct_window_event_list window_guest_debug_events = {
nullptr,
window_guest_mouse_up,
window_guest_common_resize,
nullptr,
nullptr,
nullptr,
window_guest_debug_update,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
window_guest_common_invalidate,
window_guest_debug_paint,
nullptr
};
// 0x981D24
static rct_window_event_list *window_guest_page_events[] = {
&window_guest_overview_events,
&window_guest_stats_events,
&window_guest_rides_events,
&window_guest_finance_events,
&window_guest_thoughts_events,
&window_guest_inventory_events,
&window_guest_debug_events
};
void window_guest_set_colours();
// 0x981D3C
static constexpr const uint32_t window_guest_page_enabled_widgets[] = {
(1 << WIDX_CLOSE) |
(1 << WIDX_TAB_1) |
(1 << WIDX_TAB_2) |
(1 << WIDX_TAB_3) |
(1 << WIDX_TAB_4) |
(1 << WIDX_TAB_5) |
(1 << WIDX_TAB_6) |
(1 << WIDX_TAB_7) |
(1 << WIDX_RENAME)|
(1 << WIDX_PICKUP)|
(1 << WIDX_LOCATE)|
(1 << WIDX_TRACK),
(1 << WIDX_CLOSE) |
(1 << WIDX_TAB_1) |
(1 << WIDX_TAB_2) |
(1 << WIDX_TAB_3) |
(1 << WIDX_TAB_4) |
(1 << WIDX_TAB_5) |
(1 << WIDX_TAB_6) |
(1 << WIDX_TAB_7),
(1 << WIDX_CLOSE) |
(1 << WIDX_TAB_1) |
(1 << WIDX_TAB_2) |
(1 << WIDX_TAB_3) |
(1 << WIDX_TAB_4) |
(1 << WIDX_TAB_5) |
(1 << WIDX_TAB_6) |
(1 << WIDX_TAB_7) |
(1 << WIDX_RIDE_SCROLL),
(1 << WIDX_CLOSE) |
(1 << WIDX_TAB_1) |
(1 << WIDX_TAB_2) |
(1 << WIDX_TAB_3) |
(1 << WIDX_TAB_4) |
(1 << WIDX_TAB_5) |
(1 << WIDX_TAB_6) |
(1 << WIDX_TAB_7),
(1 << WIDX_CLOSE) |
(1 << WIDX_TAB_1) |
(1 << WIDX_TAB_2) |
(1 << WIDX_TAB_3) |
(1 << WIDX_TAB_4) |
(1 << WIDX_TAB_5) |
(1 << WIDX_TAB_6) |
(1 << WIDX_TAB_7),
(1 << WIDX_CLOSE) |
(1 << WIDX_TAB_1) |
(1 << WIDX_TAB_2) |
(1 << WIDX_TAB_3) |
(1 << WIDX_TAB_4) |
(1 << WIDX_TAB_5) |
(1 << WIDX_TAB_6) |
(1 << WIDX_TAB_7),
(1 << WIDX_CLOSE) |
(1 << WIDX_TAB_1) |
(1 << WIDX_TAB_2) |
(1 << WIDX_TAB_3) |
(1 << WIDX_TAB_4) |
(1 << WIDX_TAB_5) |
(1 << WIDX_TAB_6) |
(1 << WIDX_TAB_7)
};
static constexpr const rct_size16 window_guest_page_sizes[][2] = {
{ 192, 159, 500, 450 }, // WINDOW_GUEST_OVERVIEW
{ 192, 180, 192, 180 }, // WINDOW_GUEST_STATS
{ 192, 180, 500, 400 }, // WINDOW_GUEST_RIDES
{ 210, 148, 210, 148 }, // WINDOW_GUEST_FINANCE
{ 192, 159, 500, 450 }, // WINDOW_GUEST_THOUGHTS
{ 192, 159, 500, 450 }, // WINDOW_GUEST_INVENTORY
{ 192, 159, 192, 171 } // WINDOW_GUEST_DEBUG
};
// clang-format on
/**
*
* rct2: 0x006989E9
*
*/
rct_window* window_guest_open(Peep* peep)
{
if (peep->type == PEEP_TYPE_STAFF)
{
return window_staff_open(peep);
}
rct_window* window;
window = window_bring_to_front_by_number(WC_PEEP, peep->sprite_index);
if (window == nullptr)
{
int32_t windowWidth = 192;
if (gConfigGeneral.debugging_tools)
windowWidth += TabWidth;
window = window_create_auto_pos(windowWidth, 157, &window_guest_overview_events, WC_PEEP, WF_RESIZABLE);
window->widgets = window_guest_overview_widgets;
window->enabled_widgets = window_guest_page_enabled_widgets[0];
window->number = peep->sprite_index;
window->page = 0;
window->viewport_focus_coordinates.y = 0;
window->frame_no = 0;
window->list_information_type = 0;
window->picked_peep_frame = 0;
window->highlighted_item = 0;
window_guest_disable_widgets(window);
window->min_width = windowWidth;
window->min_height = 157;
window->max_width = 500;
window->max_height = 450;
window->no_list_items = 0;
window->selected_list_item = -1;
window->viewport_focus_coordinates.y = -1;
}
window->page = 0;
window->Invalidate();
window->widgets = window_guest_page_widgets[WINDOW_GUEST_OVERVIEW];
window->enabled_widgets = window_guest_page_enabled_widgets[WINDOW_GUEST_OVERVIEW];
window->hold_down_widgets = 0;
window->event_handlers = window_guest_page_events[WINDOW_GUEST_OVERVIEW];
window->pressed_widgets = 0;
window_guest_disable_widgets(window);
window_init_scroll_widgets(window);
window_guest_viewport_init(window);
return window;
}
static void window_guest_common_resize(rct_window* w)
{
// Get page specific min and max size
int32_t minWidth = window_guest_page_sizes[w->page][0].width;
int32_t minHeight = window_guest_page_sizes[w->page][0].height;
int32_t maxWidth = window_guest_page_sizes[w->page][1].width;
int32_t maxHeight = window_guest_page_sizes[w->page][1].height;
// Ensure min size is large enough for all tabs to fit
for (int32_t i = WIDX_TAB_1; i <= WIDX_TAB_7; i++)
{
if (!(w->disabled_widgets & (1ULL << i)))
{
minWidth = std::max(minWidth, w->widgets[i].right + 3);
}
}
maxWidth = std::max(minWidth, maxWidth);
window_set_resize(w, minWidth, minHeight, maxWidth, maxHeight);
}
static void window_guest_common_invalidate(rct_window* w)
{
if (window_guest_page_widgets[w->page] != w->widgets)
{
w->widgets = window_guest_page_widgets[w->page];
window_init_scroll_widgets(w);
}
w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1);
auto peep = GET_PEEP(w->number);
peep->FormatNameTo(gCommonFormatArgs);
w->widgets[WIDX_BACKGROUND].right = w->width - 1;
w->widgets[WIDX_BACKGROUND].bottom = w->height - 1;
w->widgets[WIDX_PAGE_BACKGROUND].right = w->width - 1;
w->widgets[WIDX_PAGE_BACKGROUND].bottom = w->height - 1;
w->widgets[WIDX_TITLE].right = w->width - 2;
w->widgets[WIDX_CLOSE].left = w->width - 13;
w->widgets[WIDX_CLOSE].right = w->width - 3;
window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_7);
}
/**
* Disables the finance tab when no money.
* Disables peep pickup when in certain no pickup states.
* rct2: 0x006987A6
*/
void window_guest_disable_widgets(rct_window* w)
{
Peep* peep = &get_sprite(w->number)->peep;
uint64_t disabled_widgets = 0;
if (peep_can_be_picked_up(peep))
{
if (w->disabled_widgets & (1 << WIDX_PICKUP))
w->Invalidate();
}
else
{
disabled_widgets = (1 << WIDX_PICKUP);
if (!(w->disabled_widgets & (1 << WIDX_PICKUP)))
w->Invalidate();
}
if (gParkFlags & PARK_FLAGS_NO_MONEY)
{
disabled_widgets |= (1 << WIDX_TAB_4); // Disable finance tab if no money
}
if (!gConfigGeneral.debugging_tools)
{
disabled_widgets |= (1 << WIDX_TAB_7); // Disable debug tab when debug tools not turned on
}
w->disabled_widgets = disabled_widgets;
}
/**
*
* rct2: 0x00696A75
*/
void window_guest_overview_close(rct_window* w)
{
if (input_test_flag(INPUT_FLAG_TOOL_ACTIVE))
{
if (w->classification == gCurrentToolWidget.window_classification && w->number == gCurrentToolWidget.window_number)
tool_cancel();
}
}
/**
*
* rct2: 0x00696FBE
*/
void window_guest_overview_resize(rct_window* w)
{
window_guest_disable_widgets(w);
window_event_invalidate_call(w);
widget_invalidate(w, WIDX_MARQUEE);
window_guest_common_resize(w);
auto viewport = w->viewport;
if (viewport != nullptr)
{
auto reqViewportWidth = w->width - 30;
auto reqViewportHeight = w->height - 72;
if (viewport->width != reqViewportWidth || viewport->height != reqViewportHeight)
{
uint8_t zoom_amount = 1 << viewport->zoom;
viewport->width = reqViewportWidth;
viewport->height = reqViewportHeight;
viewport->view_width = viewport->width / zoom_amount;
viewport->view_height = viewport->height / zoom_amount;
}
}
window_guest_viewport_init(w);
}
/**
*
* rct2: 0x00696A06
*/
void window_guest_overview_mouse_up(rct_window* w, rct_widgetindex widgetIndex)
{
Peep* peep = GET_PEEP(w->number);
switch (widgetIndex)
{
case WIDX_CLOSE:
window_close(w);
break;
case WIDX_TAB_1:
case WIDX_TAB_2:
case WIDX_TAB_3:
case WIDX_TAB_4:
case WIDX_TAB_5:
case WIDX_TAB_6:
case WIDX_TAB_7:
window_guest_set_page(w, widgetIndex - WIDX_TAB_1);
break;
case WIDX_PICKUP:
{
if (!peep_can_be_picked_up(peep))
{
return;
}
w->picked_peep_old_x = peep->x;
PeepPickupAction pickupAction{ PeepPickupType::Pickup, w->number, {}, network_get_current_player_id() };
pickupAction.SetCallback([peepnum = w->number](const GameAction* ga, const GameActionResult* result) {
if (result->Error != GA_ERROR::OK)
return;
rct_window* wind = window_find_by_number(WC_PEEP, peepnum);
if (wind)
{
tool_set(wind, WC_PEEP__WIDX_PICKUP, TOOL_PICKER);
}
});
GameActions::Execute(&pickupAction);
}
break;
case WIDX_RENAME:
{
auto peepName = peep->GetName();
window_text_input_raw_open(w, widgetIndex, STR_GUEST_RENAME_TITLE, STR_GUEST_RENAME_PROMPT, peepName.c_str(), 32);
break;
}
case WIDX_LOCATE:
w->ScrollToViewport();
break;
case WIDX_TRACK:
{
uint32_t flags = peep->peep_flags ^ PEEP_FLAGS_TRACKING;
auto guestSetFlagsAction = GuestSetFlagsAction(w->number, flags);
GameActions::Execute(&guestSetFlagsAction);
}
break;
}
}
/**
*
* rct2: 0x696AA0
*/
void window_guest_set_page(rct_window* w, int32_t page)
{
if (input_test_flag(INPUT_FLAG_TOOL_ACTIVE))
{
if (w->number == gCurrentToolWidget.window_number && w->classification == gCurrentToolWidget.window_classification)
tool_cancel();
}
int32_t listen = 0;
if (page == WINDOW_GUEST_OVERVIEW && w->page == WINDOW_GUEST_OVERVIEW && w->viewport)
{
if (!(w->viewport->flags & VIEWPORT_FLAG_SOUND_ON))
listen = 1;
}
w->page = page;
w->frame_no = 0;
w->no_list_items = 0;
w->selected_list_item = -1;
rct_viewport* viewport = w->viewport;
w->viewport = nullptr;
if (viewport)
{
viewport->width = 0;
}
w->enabled_widgets = window_guest_page_enabled_widgets[page];
w->hold_down_widgets = 0;
w->event_handlers = window_guest_page_events[page];
w->pressed_widgets = 0;
w->widgets = window_guest_page_widgets[page];
window_guest_disable_widgets(w);
w->Invalidate();
window_event_resize_call(w);
window_event_invalidate_call(w);
window_init_scroll_widgets(w);
w->Invalidate();
if (listen && w->viewport)
w->viewport->flags |= VIEWPORT_FLAG_SOUND_ON;
}
void window_guest_overview_viewport_rotate(rct_window* w)
{
window_guest_viewport_init(w);
}
/**
*
* rct2: 0x0069883C
*/
void window_guest_viewport_init(rct_window* w)
{
if (w->page != WINDOW_GUEST_OVERVIEW)
return;
auto peep = GET_PEEP(w->number);
if (peep != nullptr)
{
auto focus = viewport_update_smart_guest_follow(w, peep);
bool reCreateViewport = false;
uint16_t origViewportFlags{};
if (w->viewport != nullptr)
{
// Check all combos, for now skipping y and rot
if (focus.coordinate.x == w->viewport_focus_coordinates.x
&& (focus.coordinate.y & VIEWPORT_FOCUS_Y_MASK) == w->viewport_focus_coordinates.y
&& focus.coordinate.z == w->viewport_focus_coordinates.z
&& focus.coordinate.rotation == w->viewport_focus_coordinates.rotation)
return;
origViewportFlags = w->viewport->flags;
reCreateViewport = true;
w->viewport->width = 0;
w->viewport = nullptr;
}
window_event_invalidate_call(w);
w->viewport_focus_coordinates.x = focus.coordinate.x;
w->viewport_focus_coordinates.y = focus.coordinate.y;
w->viewport_focus_coordinates.z = focus.coordinate.z;
w->viewport_focus_coordinates.rotation = focus.coordinate.rotation;
if (peep->state != PEEP_STATE_PICKED && w->viewport == nullptr)
{
auto view_widget = &w->widgets[WIDX_VIEWPORT];
int32_t x = view_widget->left + 1 + w->x;
int32_t y = view_widget->top + 1 + w->y;
int32_t width = view_widget->right - view_widget->left - 1;
int32_t height = view_widget->bottom - view_widget->top - 1;
viewport_create(
w, x, y, width, height, 0, focus.coordinate.x, focus.coordinate.y & VIEWPORT_FOCUS_Y_MASK, focus.coordinate.z,
focus.sprite.type & VIEWPORT_FOCUS_TYPE_MASK, focus.sprite.sprite_id);
if (w->viewport != nullptr && reCreateViewport)
{
w->viewport->flags = origViewportFlags;
}
w->flags |= WF_NO_SCROLLING;
w->Invalidate();
}
w->Invalidate();
}
}
/**
*
* rct2: 0x6983dd
* used by window_staff as well
*/
static void window_guest_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
if (w->disabled_widgets & (1 << WIDX_TAB_1))
return;
rct_widget* widget = &w->widgets[WIDX_TAB_1];
int32_t width = widget->right - widget->left - 1;
int32_t height = widget->bottom - widget->top - 1;
int32_t x = widget->left + 1 + w->x;
int32_t y = widget->top + 1 + w->y;
if (w->page == WINDOW_GUEST_OVERVIEW)
height++;
rct_drawpixelinfo clip_dpi;
if (!clip_drawpixelinfo(&clip_dpi, dpi, x, y, width, height))
{
return;
}
x = 14;
y = 20;
Peep* peep = GET_PEEP(w->number);
if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == STAFF_TYPE_ENTERTAINER)
y++;
int32_t ebx = g_peep_animation_entries[peep->sprite_type].sprite_animation->base_image + 1;
int32_t eax = 0;
if (w->page == WINDOW_GUEST_OVERVIEW)
{
eax = w->var_496;
eax &= 0xFFFC;
}
ebx += eax;
int32_t sprite_id = ebx | SPRITE_ID_PALETTE_COLOUR_2(peep->tshirt_colour, peep->trousers_colour);
gfx_draw_sprite(&clip_dpi, sprite_id, x, y, 0);
// If holding a balloon
if (ebx >= 0x2A1D && ebx < 0x2A3D)
{
ebx += 32;
ebx |= SPRITE_ID_PALETTE_COLOUR_1(peep->balloon_colour);
gfx_draw_sprite(&clip_dpi, ebx, x, y, 0);
}
// If holding umbrella
if (ebx >= 0x2BBD && ebx < 0x2BDD)
{
ebx += 32;
ebx |= SPRITE_ID_PALETTE_COLOUR_1(peep->umbrella_colour);
gfx_draw_sprite(&clip_dpi, ebx, x, y, 0);
}
// If wearing hat
if (ebx >= 0x29DD && ebx < 0x29FD)
{
ebx += 32;
ebx |= SPRITE_ID_PALETTE_COLOUR_1(peep->hat_colour);
gfx_draw_sprite(&clip_dpi, ebx, x, y, 0);
}
}
/**
*
* rct2: 0x69869b
*/
static void window_guest_stats_tab_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
if (w->disabled_widgets & (1 << WIDX_TAB_2))
return;
rct_widget* widget = &w->widgets[WIDX_TAB_2];
int32_t x = widget->left + w->x;
int32_t y = widget->top + w->y;
Peep* peep = GET_PEEP(w->number);
int32_t image_id = get_peep_face_sprite_large(peep);
if (w->page == WINDOW_GUEST_STATS)
{
// If currently viewing this tab animate tab
// if it is very sick or angry.
switch (image_id)
{
case SPR_PEEP_LARGE_FACE_VERY_VERY_SICK_0:
image_id += (w->frame_no / 4) & 0xF;
break;
case SPR_PEEP_LARGE_FACE_VERY_SICK_0:
image_id += (w->frame_no / 8) & 0x3;
break;
case SPR_PEEP_LARGE_FACE_ANGRY_0:
image_id += (w->frame_no / 8) & 0x3;
break;
}
}
gfx_draw_sprite(dpi, image_id, x, y, 0);
}
/**
*
* rct2: 0x69861F
*/
static void window_guest_rides_tab_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
if (w->disabled_widgets & (1 << WIDX_TAB_3))
return;
rct_widget* widget = &w->widgets[WIDX_TAB_3];
int32_t x = widget->left + w->x;
int32_t y = widget->top + w->y;
int32_t image_id = SPR_TAB_RIDE_0;
if (w->page == WINDOW_GUEST_RIDES)
{
image_id += (w->frame_no / 4) & 0xF;
}
gfx_draw_sprite(dpi, image_id, x, y, 0);
}
/**
*
* rct2: 0x698597
*/
static void window_guest_finance_tab_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
if (w->disabled_widgets & (1 << WIDX_TAB_4))
return;
rct_widget* widget = &w->widgets[WIDX_TAB_4];
int32_t x = widget->left + w->x;
int32_t y = widget->top + w->y;
int32_t image_id = SPR_TAB_FINANCES_SUMMARY_0;
if (w->page == WINDOW_GUEST_FINANCE)
{
image_id += (w->frame_no / 2) & 0x7;
}
gfx_draw_sprite(dpi, image_id, x, y, 0);
}
/**
*
* rct2: 0x6985D8