-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
ui.cpp
2307 lines (1896 loc) · 82.5 KB
/
ui.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
// license:BSD-3-Clause
// copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods
/*********************************************************************
ui.cpp
Functions used to handle MAME's user interface.
*********************************************************************/
#include "emu.h"
#include "mame.h"
#include "emuopts.h"
#include "mameopts.h"
#include "video/vector.h"
#include "machine/laserdsc.h"
#include "drivenum.h"
#include "natkeyboard.h"
#include "render.h"
#include "luaengine.h"
#include "cheat.h"
#include "rendfont.h"
#include "uiinput.h"
#include "ui/ui.h"
#include "ui/info.h"
#include "ui/menu.h"
#include "ui/mainmenu.h"
#include "ui/filemngr.h"
#include "ui/sliders.h"
#include "ui/viewgfx.h"
#include "imagedev/cassette.h"
/***************************************************************************
CONSTANTS
***************************************************************************/
enum
{
LOADSAVE_NONE,
LOADSAVE_LOAD,
LOADSAVE_SAVE
};
#define MAX_SAVED_STATE_JOYSTICK 4
/***************************************************************************
LOCAL VARIABLES
***************************************************************************/
// list of natural keyboard keys that are not associated with UI_EVENT_CHARs
static const input_item_id non_char_keys[] =
{
ITEM_ID_ESC,
ITEM_ID_F1,
ITEM_ID_F2,
ITEM_ID_F3,
ITEM_ID_F4,
ITEM_ID_F5,
ITEM_ID_F6,
ITEM_ID_F7,
ITEM_ID_F8,
ITEM_ID_F9,
ITEM_ID_F10,
ITEM_ID_F11,
ITEM_ID_F12,
ITEM_ID_NUMLOCK,
ITEM_ID_0_PAD,
ITEM_ID_1_PAD,
ITEM_ID_2_PAD,
ITEM_ID_3_PAD,
ITEM_ID_4_PAD,
ITEM_ID_5_PAD,
ITEM_ID_6_PAD,
ITEM_ID_7_PAD,
ITEM_ID_8_PAD,
ITEM_ID_9_PAD,
ITEM_ID_DEL_PAD,
ITEM_ID_PLUS_PAD,
ITEM_ID_MINUS_PAD,
ITEM_ID_INSERT,
ITEM_ID_DEL,
ITEM_ID_HOME,
ITEM_ID_END,
ITEM_ID_PGUP,
ITEM_ID_PGDN,
ITEM_ID_UP,
ITEM_ID_DOWN,
ITEM_ID_LEFT,
ITEM_ID_RIGHT,
ITEM_ID_PAUSE,
ITEM_ID_CANCEL
};
static const char *s_color_list[] = {
OPTION_UI_BORDER_COLOR,
OPTION_UI_BACKGROUND_COLOR,
OPTION_UI_GFXVIEWER_BG_COLOR,
OPTION_UI_UNAVAILABLE_COLOR,
OPTION_UI_TEXT_COLOR,
OPTION_UI_TEXT_BG_COLOR,
OPTION_UI_SUBITEM_COLOR,
OPTION_UI_CLONE_COLOR,
OPTION_UI_SELECTED_COLOR,
OPTION_UI_SELECTED_BG_COLOR,
OPTION_UI_MOUSEOVER_COLOR,
OPTION_UI_MOUSEOVER_BG_COLOR,
OPTION_UI_MOUSEDOWN_COLOR,
OPTION_UI_MOUSEDOWN_BG_COLOR,
OPTION_UI_DIPSW_COLOR,
OPTION_UI_SLIDER_COLOR
};
/***************************************************************************
GLOBAL VARIABLES
***************************************************************************/
// messagebox buffer
std::string mame_ui_manager::messagebox_text;
std::string mame_ui_manager::messagebox_poptext;
rgb_t mame_ui_manager::messagebox_backcolor;
// slider info
std::vector<ui::menu_item> mame_ui_manager::slider_list;
slider_state *mame_ui_manager::slider_current;
/***************************************************************************
CORE IMPLEMENTATION
***************************************************************************/
static const uint32_t mouse_bitmap[32*32] =
{
0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x09a46f30,0x81ac7c43,0x24af8049,0x00ad7d45,0x00a8753a,0x00a46f30,0x009f6725,0x009b611c,0x00985b14,0x0095560d,0x00935308,0x00915004,0x00904e02,0x008f4e01,0x008f4d00,0x008f4d00,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x00a16a29,0xa2aa783d,0xffbb864a,0xc0b0824c,0x5aaf7f48,0x09ac7b42,0x00a9773c,0x00a67134,0x00a26b2b,0x009e6522,0x009a5e19,0x00965911,0x0094550b,0x00925207,0x00915004,0x008f4e01,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x009a5e18,0x39a06827,0xffb97c34,0xffe8993c,0xffc88940,0xedac7c43,0x93ad7c44,0x2dac7c43,0x00ab793f,0x00a87438,0x00a46f30,0x00a06827,0x009c611d,0x00985c15,0x0095570e,0x00935309,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x00935308,0x00965810,0xcc9a5e19,0xffe78a21,0xfffb9929,0xfff49931,0xffd88e39,0xffb9813f,0xc9ac7c43,0x66ad7c44,0x0cac7a41,0x00a9773c,0x00a67134,0x00a26b2b,0x009e6522,0x009a5e19,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4e01,0x00904e02,0x60925106,0xffba670a,0xfff88b11,0xfff98f19,0xfff99422,0xfff9982b,0xffe89434,0xffc9883c,0xf3ac7a41,0x9cad7c44,0x39ac7c43,0x00ab7a40,0x00a87539,0x00a56f31,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008e4d00,0x008e4d00,0x098e4d00,0xea8f4d00,0xffee7f03,0xfff68407,0xfff6870d,0xfff78b15,0xfff78f1d,0xfff79426,0xfff49730,0xffd98d38,0xffbc823f,0xd2ac7c43,0x6fad7c44,0x12ac7b42,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008e4d00,0x008e4d00,0x008e4c00,0x8a8e4c00,0xffc46800,0xfff37e00,0xfff37f02,0xfff38106,0xfff3830a,0xfff48711,0xfff48b19,0xfff58f21,0xfff5942b,0xffe79134,0xffcb863b,0xf9ac7a41,0xa5ac7c43,0x3fac7c43,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008e4d00,0x008e4d00,0x008e4c00,0x218d4c00,0xfc8e4c00,0xffee7a00,0xfff07c00,0xfff17c00,0xfff17d02,0xfff17e04,0xfff18008,0xfff2830d,0xfff28614,0xfff38a1c,0xfff38f25,0xfff2932e,0xffd98b37,0xffbc813e,0xdbac7c43,0x78ad7c44,0x15ac7b42,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008e4d00,0x008e4d00,0x008e4d00,0x008e4c00,0xb18d4c00,0xffcf6b00,0xffed7900,0xffed7900,0xffee7900,0xffee7a01,0xffee7a01,0xffee7b03,0xffee7c06,0xffef7e0a,0xffef8110,0xfff08618,0xfff08a20,0xfff18f2a,0xffe78f33,0xffcc863b,0xfcab7a40,0xaeac7c43,0x4bac7c43,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008e4d00,0x008e4d00,0x008e4c00,0x488d4c00,0xffa85800,0xffe97500,0xffea7600,0xffea7600,0xffeb7600,0xffeb7600,0xffeb7600,0xffeb7701,0xffeb7702,0xffeb7804,0xffec7a07,0xffec7d0d,0xffec8013,0xffed851c,0xffee8a25,0xffee8f2e,0xffd98937,0xffbe813d,0xe4ab7a40,0x81ab7a40,0x1ba9763b,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008e4d00,0x008e4d00,0x008e4c00,0x008d4c00,0xdb8d4c00,0xffd86c00,0xffe77300,0xffe77300,0xffe87300,0xffe87300,0xffe87300,0xffe87300,0xffe87300,0xffe87401,0xffe87401,0xffe87503,0xffe97606,0xffe9780a,0xffe97c10,0xffea7f16,0xffeb831d,0xffeb8623,0xffe48426,0xffc67725,0xffa5661f,0xb7985c15,0x54935309,0x038e4d00,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008e4d00,0x008e4d00,0x008e4d00,0x008e4c00,0x6f8d4c00,0xffb25b00,0xffe36f00,0xffe47000,0xffe47000,0xffe57000,0xffe57000,0xffe57000,0xffe57000,0xffe57000,0xffe57000,0xffe57000,0xffe57000,0xffe57101,0xffe57000,0xffe47000,0xffe16e00,0xffde6c00,0xffd86900,0xffd06600,0xffc76200,0xffaa5500,0xff8a4800,0xea743f00,0x5a7a4200,0x00ffffff,0x00ffffff,
0x008f4d00,0x008f4d00,0x008e4d00,0x008e4d00,0x008e4c00,0x0f8d4c00,0xf38d4c00,0xffdc6a00,0xffe16d00,0xffe16d00,0xffe26d00,0xffe26d00,0xffe26d00,0xffe26d00,0xffe26d00,0xffe16d00,0xffe06c00,0xffde6b00,0xffd96900,0xffd16500,0xffc76000,0xffb95900,0xffab5200,0xff9c4b00,0xff894300,0xff6b3600,0xf9512c00,0xa5542d00,0x3c5e3200,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008f4d00,0x008e4d00,0x008e4d00,0x008e4c00,0x008d4c00,0x968d4c00,0xffbc5d00,0xffde6a00,0xffde6a00,0xffde6a00,0xffdf6a00,0xffdf6a00,0xffdf6a00,0xffde6a00,0xffdc6800,0xffd66600,0xffcc6100,0xffbf5b00,0xffaf5300,0xff9d4a00,0xff8a4200,0xff6d3500,0xff502900,0xe7402300,0x7b3f2200,0x15442500,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008f4d00,0x008f4d00,0x008e4d00,0x008e4d00,0x008e4c00,0x2a8d4c00,0xff9b5000,0xffda6600,0xffdb6700,0xffdb6700,0xffdc6700,0xffdc6700,0xffdb6700,0xffd96500,0xffd16200,0xffc25b00,0xffad5100,0xff974700,0xff7f3c00,0xff602f00,0xff472500,0xbd3d2100,0x513d2100,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008f4d00,0x008f4d00,0x008e4d00,0x008e4d00,0x008e4c00,0x008e4c00,0xc08d4c00,0xffc35c00,0xffd76300,0xffd76300,0xffd86300,0xffd86300,0xffd76300,0xffd06000,0xffc05800,0xffa54c00,0xff7f3b00,0xff582c00,0xf03f2200,0x903c2000,0x2a3e2100,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008e4d00,0x008e4d00,0x008e4c00,0x548d4c00,0xffa55200,0xffd35f00,0xffd46000,0xffd46000,0xffd46000,0xffd25e00,0xffc65900,0xffac4e00,0xff833c00,0xe7472600,0x693c2000,0x0c3d2100,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008e4d00,0x008e4d00,0x008e4c00,0x038d4c00,0xe48d4c00,0xffc95a00,0xffd15d00,0xffd15d00,0xffd15d00,0xffcb5a00,0xffb95200,0xff984300,0xff5f2e00,0x723f2200,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008e4d00,0x008e4d00,0x008e4d00,0x008e4c00,0x7b8d4c00,0xffad5200,0xffce5a00,0xffce5a00,0xffcd5900,0xffc35500,0xffaa4a00,0xff853a00,0xf9472600,0x15432400,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008e4d00,0x008e4d00,0x008e4c00,0x188d4c00,0xf98e4c00,0xffc95600,0xffcb5700,0xffc75500,0xffb94f00,0xff9b4200,0xff6c3100,0xab442500,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008e4d00,0x008e4d00,0x008e4d00,0x008e4c00,0xa58d4c00,0xffb35000,0xffc75300,0xffc05000,0xffac4800,0xff8b3a00,0xff542a00,0x45462500,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008e4d00,0x008e4d00,0x008e4c00,0x398d4c00,0xff994d00,0xffc24f00,0xffb74b00,0xff9e4000,0xff763200,0xde472600,0x03492800,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008e4d00,0x008e4d00,0x008e4c00,0x008e4c00,0xcf8d4c00,0xffb24b00,0xffab4500,0xff8d3900,0xff5e2b00,0x7e452500,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008e4d00,0x008e4d00,0x008e4d00,0x008e4c00,0x638d4c00,0xff984800,0xffa03f00,0xff7e3200,0xfc492800,0x1b472600,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008e4d00,0x008e4d00,0x008e4c00,0x098b4b00,0xed824600,0xff903800,0xff692c00,0xb4462600,0x004c2900,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008e4d00,0x008e4d00,0x008e4c00,0x008a4a00,0x8a7e4400,0xff793500,0xff572900,0x51472600,0x00542d00,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008e4d00,0x008d4c00,0x00884900,0x247a4200,0xfc633500,0xe74f2a00,0x034d2900,0x005e3300,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008e4d00,0x008d4c00,0x00884900,0x00794100,0xb4643600,0x87552e00,0x00593000,0x006b3900,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008f4d00,0x008d4c00,0x00884900,0x007c4300,0x486d3b00,0x24643600,0x00693800,0x00774000,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,
0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff,0x00ffffff
};
//-------------------------------------------------
// ctor - set up the user interface
//-------------------------------------------------
mame_ui_manager::mame_ui_manager(running_machine &machine)
: ui_manager(machine),
m_font(nullptr),
m_handler_callback(nullptr),
m_handler_param(0),
m_single_step(false),
m_showfps(false),
m_showfps_end(0),
m_show_profiler(false),
m_popup_text_end(0),
m_mouse_arrow_texture(nullptr),
m_mouse_show(false),
m_load_save_hold(false)
{
}
mame_ui_manager::~mame_ui_manager()
{
}
void mame_ui_manager::init()
{
load_ui_options();
// initialize the other UI bits
ui::menu::init(machine(), options());
ui_gfx_init(machine());
get_font_rows(&machine());
decode_ui_color(0, &machine());
// more initialization
using namespace std::placeholders;
set_handler(ui_callback_type::GENERAL, std::bind(&mame_ui_manager::handler_messagebox, this, _1));
m_non_char_keys_down = std::make_unique<uint8_t[]>((ARRAY_LENGTH(non_char_keys) + 7) / 8);
m_mouse_show = machine().system().flags & MACHINE_CLICKABLE_ARTWORK ? true : false;
// request a callback upon exiting
machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(&mame_ui_manager::exit, this));
// create mouse bitmap
bitmap_argb32 *ui_mouse_bitmap = auto_alloc(machine(), bitmap_argb32(32, 32));
uint32_t *dst = &ui_mouse_bitmap->pix32(0);
memcpy(dst,mouse_bitmap,32*32*sizeof(uint32_t));
m_mouse_arrow_texture = machine().render().texture_alloc();
m_mouse_arrow_texture->set_bitmap(*ui_mouse_bitmap, ui_mouse_bitmap->cliprect(), TEXFORMAT_ARGB32);
}
//-------------------------------------------------
// exit - clean up ourselves on exit
//-------------------------------------------------
void mame_ui_manager::exit()
{
// free the mouse texture
machine().render().texture_free(m_mouse_arrow_texture);
m_mouse_arrow_texture = nullptr;
// free the font
if (m_font != nullptr)
{
machine().render().font_free(m_font);
m_font = nullptr;
}
}
//-------------------------------------------------
// initialize - initialize ui lists
//-------------------------------------------------
void mame_ui_manager::initialize(running_machine &machine)
{
m_machine_info = std::make_unique<ui::machine_info>(machine);
// initialize the on-screen display system
slider_list = slider_init(machine);
if (slider_list.size() > 0)
{
slider_current = reinterpret_cast<slider_state *>(slider_list[0].ref);
}
else
{
slider_current = nullptr;
}
}
//-------------------------------------------------
// set_handler - set a callback/parameter
// pair for the current UI handler
//-------------------------------------------------
void mame_ui_manager::set_handler(ui_callback_type callback_type, const std::function<uint32_t (render_container &)> &&callback)
{
m_handler_callback = std::move(callback);
m_handler_callback_type = callback_type;
}
//-------------------------------------------------
// display_startup_screens - display the
// various startup screens
//-------------------------------------------------
void mame_ui_manager::display_startup_screens(bool first_time)
{
const int maxstate = 3;
int str = machine().options().seconds_to_run();
bool show_gameinfo = !machine().options().skip_gameinfo();
bool show_warnings = true, show_mandatory_fileman = true;
int state;
// disable everything if we are using -str for 300 or fewer seconds, or if we're the empty driver,
// or if we are debugging
if (!first_time || (str > 0 && str < 60*5) || &machine().system() == &GAME_NAME(___empty) || (machine().debug_flags & DEBUG_FLAG_ENABLED) != 0)
show_gameinfo = show_warnings = show_mandatory_fileman = false;
#if defined(EMSCRIPTEN)
// also disable for the JavaScript port since the startup screens do not run asynchronously
show_gameinfo = show_warnings = false;
#endif
// loop over states
using namespace std::placeholders;
set_handler(ui_callback_type::GENERAL, std::bind(&mame_ui_manager::handler_ingame, this, _1));
for (state = 0; state < maxstate && !machine().scheduled_event_pending() && !ui::menu::stack_has_special_main_menu(machine()); state++)
{
// default to standard colors
messagebox_backcolor = UI_BACKGROUND_COLOR;
messagebox_text.clear();
// pick the next state
switch (state)
{
case 0:
if (show_warnings)
messagebox_text = machine_info().warnings_string();
if (!messagebox_text.empty())
{
set_handler(ui_callback_type::MODAL, std::bind(&mame_ui_manager::handler_messagebox_anykey, this, _1));
// TODO: don't think BTANB should be marked yellow? Also move this snippet to specific getter
if (machine().system().flags & (MACHINE_WARNING_FLAGS|MACHINE_BTANB_FLAGS))
messagebox_backcolor = UI_YELLOW_COLOR;
if (machine().system().flags & (MACHINE_FATAL_FLAGS))
messagebox_backcolor = UI_RED_COLOR;
}
break;
case 1:
if (show_gameinfo)
messagebox_text = machine_info().game_info_string();
if (!messagebox_text.empty())
set_handler(ui_callback_type::MODAL, std::bind(&mame_ui_manager::handler_messagebox_anykey, this, _1));
break;
case 2:
if (show_mandatory_fileman)
messagebox_text = machine_info().mandatory_images();
if (!messagebox_text.empty())
{
std::string warning;
warning.assign(_("This driver requires images to be loaded in the following device(s): ")).append(messagebox_text.substr(0, messagebox_text.length() - 2));
ui::menu_file_manager::force_file_manager(*this, machine().render().ui_container(), warning.c_str());
}
break;
}
// clear the input memory
machine().input().reset_polling();
while (machine().input().poll_switches() != INPUT_CODE_INVALID) { }
// loop while we have a handler
while (m_handler_callback_type == ui_callback_type::MODAL && !machine().scheduled_event_pending() && !ui::menu::stack_has_special_main_menu(machine()))
{
machine().video().frame_update();
}
// clear the handler and force an update
set_handler(ui_callback_type::GENERAL, std::bind(&mame_ui_manager::handler_ingame, this, _1));
machine().video().frame_update();
}
// if we're the empty driver, force the menus on
if (ui::menu::stack_has_special_main_menu(machine()))
show_menu();
}
//-------------------------------------------------
// set_startup_text - set the text to display
// at startup
//-------------------------------------------------
void mame_ui_manager::set_startup_text(const char *text, bool force)
{
static osd_ticks_t lastupdatetime = 0;
osd_ticks_t curtime = osd_ticks();
// copy in the new text
messagebox_text.assign(text);
messagebox_backcolor = UI_BACKGROUND_COLOR;
// don't update more than 4 times/second
if (force || (curtime - lastupdatetime) > osd_ticks_per_second() / 4)
{
lastupdatetime = curtime;
machine().video().frame_update();
}
}
//-------------------------------------------------
// update_and_render - update the UI and
// render it; called by video.c
//-------------------------------------------------
void mame_ui_manager::update_and_render(render_container &container)
{
// always start clean
container.empty();
// if we're paused, dim the whole screen
if (machine().phase() >= MACHINE_PHASE_RESET && (single_step() || machine().paused()))
{
int alpha = (1.0f - machine().options().pause_brightness()) * 255.0f;
if (ui::menu::stack_has_special_main_menu(machine()))
alpha = 255;
if (alpha > 255)
alpha = 255;
if (alpha >= 0)
container.add_rect(0.0f, 0.0f, 1.0f, 1.0f, rgb_t(alpha,0x00,0x00,0x00), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
// render any cheat stuff at the bottom
if (machine().phase() >= MACHINE_PHASE_RESET)
mame_machine_manager::instance()->cheat().render_text(*this, container);
// call the current UI handler
m_handler_param = m_handler_callback(container);
// display any popup messages
if (osd_ticks() < m_popup_text_end)
draw_text_box(container, messagebox_poptext.c_str(), ui::text_layout::CENTER, 0.5f, 0.9f, messagebox_backcolor);
else
m_popup_text_end = 0;
// display the internal mouse cursor
if (m_mouse_show || (is_menu_active() && machine().options().ui_mouse()))
{
int32_t mouse_target_x, mouse_target_y;
bool mouse_button;
render_target *mouse_target = machine().ui_input().find_mouse(&mouse_target_x, &mouse_target_y, &mouse_button);
if (mouse_target != nullptr)
{
float mouse_y=-1,mouse_x=-1;
if (mouse_target->map_point_container(mouse_target_x, mouse_target_y, container, mouse_x, mouse_y))
{
const float cursor_size = 0.6 * get_line_height();
container.add_quad(mouse_x, mouse_y, mouse_x + cursor_size * container.manager().ui_aspect(&container), mouse_y + cursor_size, UI_TEXT_COLOR, m_mouse_arrow_texture, PRIMFLAG_ANTIALIAS(1) | PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
}
}
// cancel takes us back to the ingame handler
if (m_handler_param == UI_HANDLER_CANCEL)
{
using namespace std::placeholders;
set_handler(ui_callback_type::GENERAL, std::bind(&mame_ui_manager::handler_ingame, this, _1));
}
}
//-------------------------------------------------
// get_font - return the UI font
//-------------------------------------------------
render_font *mame_ui_manager::get_font()
{
// allocate the font and messagebox string
if (m_font == nullptr)
m_font = machine().render().font_alloc(machine().options().ui_font());
return m_font;
}
//-------------------------------------------------
// get_line_height - return the current height
// of a line
//-------------------------------------------------
float mame_ui_manager::get_line_height()
{
int32_t raw_font_pixel_height = get_font()->pixel_height();
render_target &ui_target = machine().render().ui_target();
int32_t target_pixel_height = ui_target.height();
float one_to_one_line_height;
float scale_factor;
// compute the font pixel height at the nominal size
one_to_one_line_height = (float)raw_font_pixel_height / (float)target_pixel_height;
// determine the scale factor
scale_factor = UI_TARGET_FONT_HEIGHT / one_to_one_line_height;
// if our font is small-ish, do integral scaling
if (raw_font_pixel_height < 24)
{
// do we want to scale smaller? only do so if we exceed the threshold
if (scale_factor <= 1.0f)
{
if (one_to_one_line_height < UI_MAX_FONT_HEIGHT || raw_font_pixel_height < 12)
scale_factor = 1.0f;
}
// otherwise, just ensure an integral scale factor
else
scale_factor = floor(scale_factor);
}
// otherwise, just make sure we hit an even number of pixels
else
{
int32_t height = scale_factor * one_to_one_line_height * (float)target_pixel_height;
scale_factor = (float)height / (one_to_one_line_height * (float)target_pixel_height);
}
return scale_factor * one_to_one_line_height;
}
//-------------------------------------------------
// get_char_width - return the width of a
// single character
//-------------------------------------------------
float mame_ui_manager::get_char_width(char32_t ch)
{
return get_font()->char_width(get_line_height(), machine().render().ui_aspect(), ch);
}
//-------------------------------------------------
// get_string_width - return the width of a
// character string
//-------------------------------------------------
float mame_ui_manager::get_string_width(const char *s, float text_size)
{
return get_font()->utf8string_width(get_line_height() * text_size, machine().render().ui_aspect(), s);
}
//-------------------------------------------------
// draw_outlined_box - add primitives to draw
// an outlined box with the given background
// color
//-------------------------------------------------
void mame_ui_manager::draw_outlined_box(render_container &container, float x0, float y0, float x1, float y1, rgb_t backcolor)
{
draw_outlined_box(container, x0, y0, x1, y1, UI_BORDER_COLOR, backcolor);
}
//-------------------------------------------------
// draw_outlined_box - add primitives to draw
// an outlined box with the given background
// color
//-------------------------------------------------
void mame_ui_manager::draw_outlined_box(render_container &container, float x0, float y0, float x1, float y1, rgb_t fgcolor, rgb_t bgcolor)
{
container.add_rect(x0, y0, x1, y1, bgcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
container.add_line(x0, y0, x1, y0, UI_LINE_WIDTH, fgcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
container.add_line(x1, y0, x1, y1, UI_LINE_WIDTH, fgcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
container.add_line(x1, y1, x0, y1, UI_LINE_WIDTH, fgcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
container.add_line(x0, y1, x0, y0, UI_LINE_WIDTH, fgcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
//-------------------------------------------------
// draw_text - simple text renderer
//-------------------------------------------------
void mame_ui_manager::draw_text(render_container &container, const char *buf, float x, float y)
{
draw_text_full(container, buf, x, y, 1.0f - x, ui::text_layout::LEFT, ui::text_layout::WORD, mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
}
//-------------------------------------------------
// draw_text_full - full featured text
// renderer with word wrapping, justification,
// and full size computation
//-------------------------------------------------
void mame_ui_manager::draw_text_full(render_container &container, const char *origs, float x, float y, float origwrapwidth, ui::text_layout::text_justify justify, ui::text_layout::word_wrapping wrap, draw_mode draw, rgb_t fgcolor, rgb_t bgcolor, float *totalwidth, float *totalheight, float text_size)
{
// create the layout
auto layout = create_layout(container, origwrapwidth, justify, wrap);
// append text to it
layout.add_text(
origs,
fgcolor,
draw == OPAQUE_ ? bgcolor : rgb_t::transparent(),
text_size);
// and emit it (if we are asked to do so)
if (draw != NONE)
layout.emit(container, x, y);
// return width/height
if (totalwidth)
*totalwidth = layout.actual_width();
if (totalheight)
*totalheight = layout.actual_height();
}
//-------------------------------------------------
// draw_text_box - draw a multiline text
// message with a box around it
//-------------------------------------------------
void mame_ui_manager::draw_text_box(render_container &container, const char *text, ui::text_layout::text_justify justify, float xpos, float ypos, rgb_t backcolor)
{
// cap the maximum width
float maximum_width = 1.0f - UI_BOX_LR_BORDER * 2;
// create a layout
ui::text_layout layout = create_layout(container, maximum_width, justify);
// add text to it
layout.add_text(text);
// and draw the result
draw_text_box(container, layout, xpos, ypos, backcolor);
}
//-------------------------------------------------
// draw_text_box - draw a multiline text
// message with a box around it
//-------------------------------------------------
void mame_ui_manager::draw_text_box(render_container &container, ui::text_layout &layout, float xpos, float ypos, rgb_t backcolor)
{
// xpos and ypos are where we want to "pin" the layout, but we need to adjust for the actual size of the payload
auto actual_left = layout.actual_left();
auto actual_width = layout.actual_width();
auto actual_height = layout.actual_height();
auto x = std::min(std::max(xpos - actual_width / 2, UI_BOX_LR_BORDER), 1.0f - actual_width - UI_BOX_LR_BORDER);
auto y = std::min(std::max(ypos - actual_height / 2, UI_BOX_TB_BORDER), 1.0f - actual_height - UI_BOX_TB_BORDER);
// add a box around that
draw_outlined_box(container,
x - UI_BOX_LR_BORDER,
y - UI_BOX_TB_BORDER,
x + actual_width + UI_BOX_LR_BORDER,
y + actual_height + UI_BOX_TB_BORDER, backcolor);
// emit the text
layout.emit(container, x - actual_left, y);
}
//-------------------------------------------------
// draw_message_window - draw a multiline text
// message with a box around it
//-------------------------------------------------
void mame_ui_manager::draw_message_window(render_container &container, const char *text)
{
draw_text_box(container, text, ui::text_layout::text_justify::LEFT, 0.5f, 0.5f, UI_BACKGROUND_COLOR);
}
//-------------------------------------------------
// show_fps_temp - show the FPS counter for
// a specific period of time
//-------------------------------------------------
void mame_ui_manager::show_fps_temp(double seconds)
{
if (!m_showfps)
m_showfps_end = osd_ticks() + seconds * osd_ticks_per_second();
}
//-------------------------------------------------
// set_show_fps - show/hide the FPS counter
//-------------------------------------------------
void mame_ui_manager::set_show_fps(bool show)
{
m_showfps = show;
if (!show)
{
m_showfps = 0;
m_showfps_end = 0;
}
}
//-------------------------------------------------
// show_fps - return the current FPS
// counter visibility state
//-------------------------------------------------
bool mame_ui_manager::show_fps() const
{
return m_showfps || (m_showfps_end != 0);
}
//-------------------------------------------------
// show_fps_counter
//-------------------------------------------------
bool mame_ui_manager::show_fps_counter()
{
bool result = m_showfps || osd_ticks() < m_showfps_end;
if (!result)
m_showfps_end = 0;
return result;
}
//-------------------------------------------------
// set_show_profiler - show/hide the profiler
//-------------------------------------------------
void mame_ui_manager::set_show_profiler(bool show)
{
m_show_profiler = show;
g_profiler.enable(show);
}
//-------------------------------------------------
// show_profiler - return the current
// profiler visibility state
//-------------------------------------------------
bool mame_ui_manager::show_profiler() const
{
return m_show_profiler;
}
//-------------------------------------------------
// show_menu - show the menus
//-------------------------------------------------
void mame_ui_manager::show_menu()
{
using namespace std::placeholders;
set_handler(ui_callback_type::MENU, std::bind(&ui::menu::ui_handler, _1, std::ref(*this)));
}
//-------------------------------------------------
// show_mouse - change mouse status
//-------------------------------------------------
void mame_ui_manager::show_mouse(bool status)
{
m_mouse_show = status;
}
//-------------------------------------------------
// is_menu_active - return true if the menu
// UI handler is active
//-------------------------------------------------
bool mame_ui_manager::is_menu_active(void)
{
return m_handler_callback_type == ui_callback_type::MENU
|| m_handler_callback_type == ui_callback_type::VIEWER;
}
/***************************************************************************
UI HANDLERS
***************************************************************************/
//-------------------------------------------------
// handler_messagebox - displays the current
// messagebox_text string but handles no input
//-------------------------------------------------
uint32_t mame_ui_manager::handler_messagebox(render_container &container)
{
draw_text_box(container, messagebox_text.c_str(), ui::text_layout::LEFT, 0.5f, 0.5f, messagebox_backcolor);
return 0;
}
//-------------------------------------------------
// handler_messagebox_anykey - displays the
// current messagebox_text string and waits for
// any keypress
//-------------------------------------------------
uint32_t mame_ui_manager::handler_messagebox_anykey(render_container &container)
{
uint32_t state = 0;
// draw a standard message window
draw_text_box(container, messagebox_text.c_str(), ui::text_layout::LEFT, 0.5f, 0.5f, messagebox_backcolor);
// if the user cancels, exit out completely
if (machine().ui_input().pressed(IPT_UI_CANCEL))
{
machine().schedule_exit();
state = UI_HANDLER_CANCEL;
}
// if any key is pressed, just exit
else if (machine().input().poll_switches() != INPUT_CODE_INVALID)
state = UI_HANDLER_CANCEL;
return state;
}
//-------------------------------------------------
// process_natural_keyboard - processes any
// natural keyboard input
//-------------------------------------------------
void mame_ui_manager::process_natural_keyboard()
{
ui_event event;
int i, pressed;
input_item_id itemid;
input_code code;
uint8_t *key_down_ptr;
uint8_t key_down_mask;
// loop while we have interesting events
while (machine().ui_input().pop_event(&event))
{
// if this was a UI_EVENT_CHAR event, post it
if (event.event_type == UI_EVENT_CHAR)
machine().ioport().natkeyboard().post(event.ch);
}
// process natural keyboard keys that don't get UI_EVENT_CHARs
for (i = 0; i < ARRAY_LENGTH(non_char_keys); i++)
{
// identify this keycode
itemid = non_char_keys[i];
code = machine().input().code_from_itemid(itemid);
// ...and determine if it is pressed
pressed = machine().input().code_pressed(code);
// figure out whey we are in the key_down map
key_down_ptr = &m_non_char_keys_down[i / 8];
key_down_mask = 1 << (i % 8);
if (pressed && !(*key_down_ptr & key_down_mask))
{
// this key is now down
*key_down_ptr |= key_down_mask;
// post the key
machine().ioport().natkeyboard().post(UCHAR_MAMEKEY_BEGIN + code.item_id());
}
else if (!pressed && (*key_down_ptr & key_down_mask))
{
// this key is now up
*key_down_ptr &= ~key_down_mask;
}
}
}
//-------------------------------------------------
// increase_frameskip
//-------------------------------------------------
void mame_ui_manager::increase_frameskip()
{
// get the current value and increment it
int newframeskip = machine().video().frameskip() + 1;
if (newframeskip > MAX_FRAMESKIP)
newframeskip = -1;
machine().video().set_frameskip(newframeskip);
// display the FPS counter for 2 seconds
show_fps_temp(2.0);
}
//-------------------------------------------------
// decrease_frameskip
//-------------------------------------------------
void mame_ui_manager::decrease_frameskip()
{
// get the current value and decrement it
int newframeskip = machine().video().frameskip() - 1;
if (newframeskip < -1)
newframeskip = MAX_FRAMESKIP;
machine().video().set_frameskip(newframeskip);
// display the FPS counter for 2 seconds
show_fps_temp(2.0);
}
//-------------------------------------------------
// can_paste
//-------------------------------------------------
bool mame_ui_manager::can_paste()
{
// retrieve the clipboard text
char *text = osd_get_clipboard_text();
// free the string if allocated
if (text != nullptr)
free(text);
// did we have text?
return text != nullptr;
}
//-------------------------------------------------
// paste - does a paste from the keyboard
//-------------------------------------------------
void mame_ui_manager::paste()
{
// retrieve the clipboard text
char *text = osd_get_clipboard_text();
// was a result returned?
if (text != nullptr)
{
// post the text
machine().ioport().natkeyboard().post_utf8(text);
// free the string
free(text);
}
}
//-------------------------------------------------
// draw_fps_counter
//-------------------------------------------------
void mame_ui_manager::draw_fps_counter(render_container &container)
{
draw_text_full(container, machine().video().speed_text().c_str(), 0.0f, 0.0f, 1.0f,
ui::text_layout::RIGHT, ui::text_layout::WORD, OPAQUE_, rgb_t::white(), rgb_t::black(), nullptr, nullptr);
}
//-------------------------------------------------
// draw_timecode_counter
//-------------------------------------------------
void mame_ui_manager::draw_timecode_counter(render_container &container)
{
std::string tempstring;
draw_text_full(container, machine().video().timecode_text(tempstring).c_str(), 0.0f, 0.0f, 1.0f,
ui::text_layout::RIGHT, ui::text_layout::WORD, OPAQUE_, rgb_t(0xf0, 0xf0, 0x10, 0x10), rgb_t::black(), nullptr, nullptr);
}
//-------------------------------------------------
// draw_timecode_total
//-------------------------------------------------
void mame_ui_manager::draw_timecode_total(render_container &container)
{
std::string tempstring;
draw_text_full(container, machine().video().timecode_total_text(tempstring).c_str(), 0.0f, 0.0f, 1.0f,
ui::text_layout::LEFT, ui::text_layout::WORD, OPAQUE_, rgb_t(0xf0, 0x10, 0xf0, 0x10), rgb_t::black(), nullptr, nullptr);
}
//-------------------------------------------------
// draw_profiler
//-------------------------------------------------
void mame_ui_manager::draw_profiler(render_container &container)
{
const char *text = g_profiler.text(machine());
draw_text_full(container, text, 0.0f, 0.0f, 1.0f, ui::text_layout::LEFT, ui::text_layout::WORD, OPAQUE_, rgb_t::white(), rgb_t::black(), nullptr, nullptr);
}
//-------------------------------------------------
// start_save_state
//-------------------------------------------------
void mame_ui_manager::start_save_state()
{
machine().pause();
m_load_save_hold = true;
using namespace std::placeholders;
set_handler(ui_callback_type::GENERAL, std::bind(&mame_ui_manager::handler_load_save, this, _1, uint32_t(LOADSAVE_SAVE)));
}
//-------------------------------------------------
// start_load_state
//-------------------------------------------------
void mame_ui_manager::start_load_state()
{
machine().pause();
m_load_save_hold = true;
using namespace std::placeholders;
set_handler(ui_callback_type::GENERAL, std::bind(&mame_ui_manager::handler_load_save, this, _1, uint32_t(LOADSAVE_LOAD)));
}