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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
|
// For licensing and usage information, read docs/winui_license.txt
// MASTER
//****************************************************************************
/***************************************************************************
Properties.cpp
Properties Popup and Misc UI support routines.
Created 8/29/98 by Mike Haaland (mhaaland@hypertech.com)
***************************************************************************/
/***************************************************************************
MSH - 20070809
--
Notes on properties and ini files, reset and reset to default.
----------------------------------------------------------------------------
Each ini contains a complete option set.
Priority order for option sets (Lowest to Highest):
built-in defaults
program ini (executable root filename ini)
debug ini (if running a debug build)
driver ini (source code root filename in which this driver is found)
game ini (where game is the driver name for this game)
To determine which option set to use, start at the top level (lowest
priority), and overlay all higher priority ini's until the desired level
is reached.
The 'default' option set is the next priority higher up the list from
the desired level. For the default (program.ini) level, it is also the
default.
When MAME is run, the desired level is game ini.
Expected Code behavior:
----------------------------------------------------------------------------
This approach requires 3 option sets, 'current', 'original' and 'default'.
'current': used to populate the property pages, and to initialize the
'original' set.
'original': used to evaluate if the 'Reset' button is enabled.
If 'current' matches 'original', the 'Reset' button is disabled,
otherwise it is enabled.
'default': used to evaluate if the 'Restore to Defaults' button is enabled.
If 'current' matches 'default', the 'Restore to Defaults' button is disabled,
otherwise it is enabled.
When editing any option set, the desired level is set to the one being
edited, the default set for that level, is the next lower priority set found.
Upon entering the properties dialog:
a) 'current' is initialized
b) 'original' is initialized by 'current'
c) 'default' is initialized
d) Populate Property pages with 'current'
e) 'Reset' and 'Restore to Defaults' buttons are evaluated.
After any change:
a) 'current' is updated
b) 'Reset' and 'Restore to Defaults' buttons are re-evaluated.
Reset:
a) 'current' is reinitialized to 'original'
b) Re-populate Property pages with 'current'
c) 'Reset' and 'Restore to Defaults' buttons are re-evaluated.
Restore to Defaults:
a) 'current' is reinitialized to 'default'
b) Re-populate Property pages with 'current'
b) 'Reset' and 'Restore to Defaults' buttons are re-evaluated.
Apply:
a) 'original' is reinitialized to 'current'
b) 'Reset' and 'Restore to defaults' are re-evaluated.
c) If they 'current' matches 'default', remove the ini from disk.
Otherwise, write the ini to disk.
Cancel:
a) Exit the dialog.
OK:
a) If they 'current' matches 'default', remove the ini from disk.
Otherwise, write the ini to disk.
b) Exit the dialog.
***************************************************************************/
// standard windows headers
#include <windows.h>
#include <windowsx.h>
// standard C headers
#include <tchar.h>
#include <sys/stat.h> // for S_IFDIR
// MAME/MAMEUI headers
#include "emu.h"
#include "screen.h"
#include "mui_audit.h"
#include "mui_opts.h"
#include "resource.h"
#include "dijoystick.h" /* For DIJoystick availability. */
#include "mui_util.h"
#include "datamap.h"
#include "help.h"
#include "winui.h"
#include "strconv.h"
#include "winutf8.h"
#include "directories.h"
#include "sound/samples.h"
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
#include "newuires.h"
#ifdef UI_DIRECTDRAW
#include "directdraw.h" /* has to be after samples.h */
#endif
#include "properties.h"
#include "drivenum.h"
#include "machine/ram.h"
#include <shlwapi.h>
#if defined(__GNUC__)
/* fix warning: cast does not match function type */
#undef PropSheet_GetTabControl
#define PropSheet_GetTabControl(d) (HWND)(LRESULT)(int)SendMessage((d),PSM_GETTABCONTROL,0,0)
#endif /* defined(__GNUC__) */
/* Enable this if MAME supports multiple versions of D3D */
//#define D3DVERSION
/***************************************************************
* Imported function prototypes
***************************************************************/
/**************************************************************
* Local function prototypes
**************************************************************/
static void SetSamplesEnabled(HWND hWnd, int nIndex, BOOL bSoundEnabled);
static void InitializeOptions(HWND hDlg);
static void InitializeMisc(HWND hDlg);
static void OptOnHScroll(HWND hWnd, HWND hwndCtl, UINT code, int pos);
static void NumScreensSelectionChange(HWND hwnd);
static void RefreshSelectionChange(HWND hWnd, HWND hWndCtrl);
static void InitializeSoundUI(HWND hwnd);
static void InitializeSkippingUI(HWND hwnd);
static void InitializeRotateUI(HWND hwnd);
static void UpdateSelectScreenUI(HWND hwnd);
static void InitializeSelectScreenUI(HWND hwnd);
#ifdef D3DVERSION
static void InitializeD3DVersionUI(HWND hwnd);
#endif
static void InitializeVideoUI(HWND hwnd);
static void InitializeBIOSUI(HWND hwnd);
static void InitializeControllerMappingUI(HWND hwnd);
static void InitializeLanguageUI(HWND hWnd);
static void InitializePluginsUI(HWND hWnd);
//static void InitializeGLSLFilterUI(HWND hWnd);
static void UpdateOptions(HWND hDlg, datamap *map, windows_options &opts);
static void UpdateProperties(HWND hDlg, datamap *map, windows_options &opts);
static void PropToOptions(HWND hWnd, windows_options &o);
static void OptionsToProp(HWND hWnd, windows_options &o);
static void SetPropEnabledControls(HWND hWnd);
static bool SelectLUAScript(HWND hWnd);
static bool ResetLUAScript(HWND hWnd);
static bool SelectPlugins(HWND hWnd);
static bool ResetPlugins(HWND hWnd);
//static bool SelectBGFXChains(HWND hWnd);
//static bool ResetBGFXChains(HWND hWnd);
static BOOL SelectEffect(HWND hWnd);
static BOOL ResetEffect(HWND hWnd);
static BOOL SelectJoystickMap(HWND hWnd);
static BOOL ResetJoystickMap(HWND hWnd);
static BOOL SelectDebugscript(HWND hWnd);
static BOOL ResetDebugscript(HWND hWnd);
static void BuildDataMap(void);
static void ResetDataMap(HWND hWnd);
static void UpdateBackgroundBrush(HWND hwndTab);
static HBRUSH hBkBrush;
#ifdef MESS
static BOOL DirListReadControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name);
static BOOL DirListPopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name);
static BOOL RamPopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name);
extern BOOL BrowseForDirectory(HWND hwnd, LPCTSTR pStartDir, TCHAR* pResult);
//static BOOL g_bModifiedSoftwarePaths = false;
#endif
/**************************************************************
* Local private variables
**************************************************************/
/* No longer used by the core, but we need it to predefine configurable screens for all games. */
#ifndef MAX_SCREENS
/* maximum number of screens for one game */
#define MAX_SCREENS 4
#endif
static windows_options pOrigOpts, pDefaultOpts, pCurrentOpts;
static datamap *properties_datamap;
static int g_nGame = 0;
static int g_nFolder = 0;
static int g_nFolderGame = 0;
static OPTIONS_TYPE g_nPropertyMode = OPTIONS_GAME;
static BOOL g_bAutoAspect[MAX_SCREENS] = {false, false, false, false};
static BOOL g_bAutoSnapSize = false;
static HICON g_hIcon = NULL;
std::vector<string> plugin_names(32);
/* Property sheets */
#define HIGHLIGHT_COLOR RGB(0,196,0)
static HBRUSH highlight_brush = NULL;
static HBRUSH background_brush = NULL;
#define ORIENTATION_COLOR RGB( 190, 128, 0) //LIGHT BROWN
#define VECTOR_COLOR RGB( 190, 0, 0) //DARK RED
#define FOLDER_COLOR RGB( 0, 128, 0 ) // DARK GREEN
#define PARENT_COLOR RGB( 190, 128, 192 ) // PURPLE
#define GAME_COLOR RGB( 0, 128, 192 ) // DARK BLUE
BOOL PropSheetFilter_Vector(const machine_config *drv, const game_driver *gamedrv)
{
return isDriverVector(drv);
}
/* Help IDs - moved to auto-generated helpids.c */
extern const DWORD dwHelpIDs[];
typedef struct
{
const TCHAR* m_pText;
const char* m_pData;
}
DUALCOMBOSTR;
typedef struct
{
const TCHAR* m_pText;
const int m_pData;
}
DUALCOMBOINT;
const DUALCOMBOSTR g_ComboBoxVideo[] =
{
{ TEXT("Auto"), "auto" },
{ TEXT("GDI"), "gdi" },
#ifdef UI_DIRECTDRAW
{ TEXT("DirectDraw"), "ddraw" }, // removed 20160217
#endif
{ TEXT("Direct3D"), "d3d" },
{ TEXT("BGFX"), "bgfx" },
{ TEXT("OpenGL"), "opengl" },
};
#define NUMVIDEO (sizeof(g_ComboBoxVideo) / sizeof(g_ComboBoxVideo[0]))
const DUALCOMBOSTR g_ComboBoxSound[] =
{
{ TEXT("None"), "none" },
{ TEXT("Auto"), "auto" },
{ TEXT("DirectSound"), "dsound" },
{ TEXT("PortAudio"), "portaudio" },
// { TEXT("XAudio2"), "xaudio2" }, // invalid option
};
#define NUMSOUND (sizeof(g_ComboBoxSound) / sizeof(g_ComboBoxSound[0]))
#ifdef D3DVERSION
const DUALCOMBOINT g_ComboBoxD3DVersion[] =
{
{ TEXT("Version 9"), 9 },
// { TEXT("Version 8"), 8 },
};
#define NUMD3DVERSIONS (sizeof(g_ComboBoxD3DVersion) / sizeof(g_ComboBoxD3DVersion[0]))
#define WINOPTION_D3DVERSION "9"
#endif
const DUALCOMBOINT g_ComboBoxSelectScreen[] =
{
{ TEXT("Screen 0"), 0 },
{ TEXT("Screen 1"), 1 },
{ TEXT("Screen 2"), 2 },
{ TEXT("Screen 3"), 3 },
};
#define NUMSELECTSCREEN (sizeof(g_ComboBoxSelectScreen) / sizeof(g_ComboBoxSelectScreen[0]))
const DUALCOMBOSTR g_ComboBoxView[] =
{
{ TEXT("Auto"), "auto" },
{ TEXT("Standard"), "standard" },
{ TEXT("Pixel Aspect"), "pixel" },
{ TEXT("Cocktail"), "cocktail" },
};
#define NUMVIEW (sizeof(g_ComboBoxView) / sizeof(g_ComboBoxView[0]))
const DUALCOMBOSTR g_ComboBoxDevice[] =
{
{ TEXT("None"), "none" },
{ TEXT("Keyboard"), "keyboard" },
{ TEXT("Mouse"), "mouse" },
{ TEXT("Joystick"), "joystick" },
{ TEXT("Lightgun"), "lightgun" },
};
#define NUMDEVICES (sizeof(g_ComboBoxDevice) / sizeof(g_ComboBoxDevice[0]))
const DUALCOMBOSTR g_ComboBoxSnapView[] =
{
{ TEXT("Internal"), "internal" },
{ TEXT("Auto"), "auto" },
{ TEXT("Standard"), "standard" },
{ TEXT("Pixel Aspect"), "pixel" },
{ TEXT("Cocktail"), "cocktail" },
};
#define NUMSNAPVIEW (sizeof(g_ComboBoxSnapView) / sizeof(g_ComboBoxSnapView[0]))
/***************************************************************
* Public functions
***************************************************************/
int PropertiesCurrentGame(HWND hDlg)
{
return g_nGame;
}
DWORD_PTR GetHelpIDs(void)
{
return (DWORD_PTR)dwHelpIDs;
}
static int GetSelectedScreen(HWND hWnd)
{
int nSelectedScreen = 0;
HWND hCtrl = GetDlgItem(hWnd, IDC_SCREENSELECT);
if (hCtrl)
nSelectedScreen = ComboBox_GetCurSel(hCtrl);
if ((nSelectedScreen < 0) || (nSelectedScreen >= NUMSELECTSCREEN))
nSelectedScreen = 0;
return nSelectedScreen;
}
static PROPSHEETPAGE *CreatePropSheetPages(HINSTANCE hInst, BOOL bOnlyDefault,
// const game_driver *gamedrv, UINT *pnMaxPropSheets, BOOL isGame )
int nGame, UINT *pnMaxPropSheets, BOOL isGame )
{
PROPSHEETPAGE *pspages;
int maxPropSheets = 0;
int possiblePropSheets;
int i = ( isGame ) ? 0 : 2;
for (; g_propSheets[i].pfnDlgProc; i++)
;
possiblePropSheets = (isGame) ? i + 1 : i - 1;
pspages = (PROPSHEETPAGE *)malloc(sizeof(PROPSHEETPAGE) * possiblePropSheets);
if (!pspages)
return NULL;
memset(pspages, 0, sizeof(PROPSHEETPAGE) * possiblePropSheets);
i = ( isGame ) ? 0 : 2;
for (; g_propSheets[i].pfnDlgProc; i++)
{
if (nGame < 0)
{
if (g_propSheets[i].bOnDefaultPage)
{
pspages[maxPropSheets].dwSize = sizeof(PROPSHEETPAGE);
pspages[maxPropSheets].dwFlags = 0;
pspages[maxPropSheets].hInstance = hInst;
pspages[maxPropSheets].pszTemplate = MAKEINTRESOURCE(g_propSheets[i].dwDlgID);
pspages[maxPropSheets].pfnCallback = NULL;
pspages[maxPropSheets].lParam = 0;
pspages[maxPropSheets].pfnDlgProc = g_propSheets[i].pfnDlgProc;
maxPropSheets++;
}
}
else
if ((nGame >= 0) || g_propSheets[i].bOnDefaultPage)
{
//machine_config config(*gamedrv,pCurrentOpts);
// if (!gamedrv || !g_propSheets[i].pfnFilterProc || g_propSheets[i].pfnFilterProc(&config, gamedrv))
if (nGame < 0 || !g_propSheets[i].pfnFilterProc || g_propSheets[i].pfnFilterProc(nGame))
{
pspages[maxPropSheets].dwSize = sizeof(PROPSHEETPAGE);
pspages[maxPropSheets].dwFlags = 0;
pspages[maxPropSheets].hInstance = hInst;
pspages[maxPropSheets].pszTemplate = MAKEINTRESOURCE(g_propSheets[i].dwDlgID);
pspages[maxPropSheets].pfnCallback = NULL;
pspages[maxPropSheets].lParam = 0;
pspages[maxPropSheets].pfnDlgProc = g_propSheets[i].pfnDlgProc;
maxPropSheets++;
}
}
}
if (pnMaxPropSheets)
*pnMaxPropSheets = maxPropSheets;
return pspages;
}
// This is for the DEFAULT property-page options only
void InitDefaultPropertyPage(HINSTANCE hInst, HWND hWnd)
{
// clear globals
g_nGame = GLOBAL_OPTIONS;
windows_options dummy;
OptionsCopy(dummy,pDefaultOpts);
OptionsCopy(dummy,pOrigOpts);
OptionsCopy(dummy,pCurrentOpts);
/* Get default options to populate property sheets */
load_options(pCurrentOpts, OPTIONS_GLOBAL, g_nGame, 0);
load_options(pOrigOpts, OPTIONS_GLOBAL, g_nGame, 0);
load_options(pDefaultOpts, OPTIONS_GLOBAL, -2, 0);
g_nPropertyMode = OPTIONS_GLOBAL;
BuildDataMap();
PROPSHEETHEADER pshead;
ZeroMemory(&pshead, sizeof(pshead));
PROPSHEETPAGE *pspage;
pspage = CreatePropSheetPages(hInst, true, -1, &pshead.nPages, false);
if (!pspage)
return;
/* Fill in the property sheet header */
pshead.hwndParent = hWnd;
pshead.dwSize = sizeof(PROPSHEETHEADER);
pshead.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_PROPTITLE;
pshead.hInstance = hInst;
pshead.pszCaption = TEXT("Default Game");
pshead.nStartPage = 0;
pshead.pszIcon = MAKEINTRESOURCE(IDI_MAMEUI_ICON);
pshead.ppsp = pspage;
/* Create the Property sheet and display it */
if (PropertySheet(&pshead) == -1)
{
char temp[100];
DWORD dwError = GetLastError();
sprintf(temp, "Property Sheet Error %d %X", (int)dwError, (int)dwError);
win_message_box_utf8(0, temp, "Error", IDOK);
}
free(pspage);
}
/* Initialize the property pages for anything but the Default option set */
void InitPropertyPage(HINSTANCE hInst, HWND hWnd, HICON hIcon, OPTIONS_TYPE opt_type, int folder_id, int game_num)
{
InitPropertyPageToPage(hInst, hWnd, hIcon, opt_type, folder_id, game_num, PROPERTIES_PAGE);
}
void InitPropertyPageToPage(HINSTANCE hInst, HWND hWnd, HICON hIcon, OPTIONS_TYPE opt_type, int folder_id, int game_num, int start_page )
{
if (highlight_brush == NULL)
highlight_brush = CreateSolidBrush(HIGHLIGHT_COLOR);
if (background_brush == NULL)
background_brush = CreateSolidBrush(GetSysColor(COLOR_3DFACE));
// Initialize the options
windows_options dummy;
OptionsCopy(dummy,pDefaultOpts);
OptionsCopy(dummy,pOrigOpts);
OptionsCopy(dummy,pCurrentOpts);
load_options(pCurrentOpts, opt_type, game_num, 1);
load_options(pOrigOpts, opt_type, game_num, 1);
if (game_num == GLOBAL_OPTIONS)
load_options(pDefaultOpts, OPTIONS_GLOBAL, -2, 0); // base opts is the backup for global
else
load_options(pDefaultOpts, OPTIONS_GLOBAL, -1, 0); // global is the backup for games
// Copy icon to use for the property pages
g_hIcon = CopyIcon(hIcon);
// These MUST be valid, they are used as indicies
g_nGame = game_num;
g_nFolder = folder_id;
// Keep track of OPTIONS_TYPE that was passed in.
g_nPropertyMode = opt_type;
BuildDataMap();
PROPSHEETHEADER pshead;
ZeroMemory(&pshead, sizeof(PROPSHEETHEADER));
// Set the game to audit to this game
// Create the property sheets
PROPSHEETPAGE *pspage;
if( OPTIONS_GAME == opt_type )
{
InitGameAudit(game_num);
pspage = CreatePropSheetPages(hInst, false, game_num, &pshead.nPages, true);
}
else
pspage = CreatePropSheetPages(hInst, false, -1, &pshead.nPages, false);
if (!pspage)
return;
// Get the description use as the dialog caption.
TCHAR* t_description = 0;
switch( opt_type )
{
case OPTIONS_GAME:
t_description = ui_wstring_from_utf8(ModifyThe(driver_list::driver(g_nGame).type.fullname()));
break;
case OPTIONS_SOURCE:
t_description = ui_wstring_from_utf8(GetDriverFilename(g_nGame));
break;
case OPTIONS_GLOBAL:
t_description = ui_wstring_from_utf8("Default Settings");
break;
default:
return;
}
// If we have no description, return.
if( !t_description )
return;
/* Fill in the property sheet header */
pshead.pszCaption = t_description;
pshead.hwndParent = hWnd;
pshead.dwSize = sizeof(PROPSHEETHEADER);
pshead.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_PROPTITLE;
pshead.hInstance = hInst;
pshead.nStartPage = start_page;
pshead.pszIcon = MAKEINTRESOURCE(IDI_MAMEUI_ICON);
pshead.ppsp = pspage;
/* Create the Property sheet and display it */
if (PropertySheet(&pshead) == -1)
{
char temp[100];
DWORD dwError = GetLastError();
sprintf(temp, "Property Sheet Error %d %X", (int)dwError, (int)dwError);
win_message_box_utf8(0, temp, "Error", IDOK);
}
free(t_description);
free(pspage);
}
/*********************************************************************
* Local Functions
*********************************************************************/
#define WINUI_ARRAY_LENGTH(x) (sizeof(x) / sizeof(x[0]))
/* Build CPU info string */
static char *GameInfoCPU(int nIndex)
{
machine_config config(driver_list::driver(nIndex), MameUIGlobal());
execute_interface_iterator cpuiter(config.root_device());
std::unordered_set<std::string> exectags;
static char buffer[1024];
memset(&buffer, 0, sizeof(buffer));
for (device_execute_interface &exec : cpuiter)
{
if (!exectags.insert(exec.device().tag()).second)
continue;
char temp[300];
int count = 1;
int clock = exec.device().clock();
const char *name = exec.device().name();
for (device_execute_interface &scan : cpuiter)
{
if (exec.device().type() == scan.device().type() && strcmp(name, scan.device().name()) == 0 && clock == scan.device().clock())
if (exectags.insert(scan.device().tag()).second)
count++;
}
if (count > 1)
{
snprintf(temp, WINUI_ARRAY_LENGTH(temp), "%d x ", count);
strcat(buffer, temp);
}
if (clock >= 1000000)
snprintf(temp, WINUI_ARRAY_LENGTH(temp), "%s %d.%06d MHz\r\n", name, clock / 1000000, clock % 1000000);
else
snprintf(temp, WINUI_ARRAY_LENGTH(temp), "%s %d.%03d kHz\r\n", name, clock / 1000, clock % 1000);
strcat(buffer, temp);
}
return buffer;
}
/* Build Sound system info string */
static char *GameInfoSound(int nIndex)
{
machine_config config(driver_list::driver(nIndex), MameUIGlobal());
sound_interface_iterator sounditer(config.root_device());
std::unordered_set<std::string> soundtags;
static char buffer[1024];
memset(&buffer, 0, sizeof(buffer));
for (device_sound_interface &sound : sounditer)
{
if (!soundtags.insert(sound.device().tag()).second)
continue;
char temp[300];
int count = 1;
int clock = sound.device().clock();
const char *name = sound.device().name();
for (device_sound_interface &scan : sounditer)
{
if (sound.device().type() == scan.device().type() && strcmp(name, scan.device().name()) == 0 && clock == scan.device().clock())
if (soundtags.insert(scan.device().tag()).second)
count++;
}
if (count > 1)
{
snprintf(temp, WINUI_ARRAY_LENGTH(temp), "%d x ", count);
strcat(buffer, temp);
}
strcat(buffer, name);
if (clock)
{
if (clock >= 1000000)
snprintf(temp, WINUI_ARRAY_LENGTH(temp), " %d.%06d MHz", clock / 1000000, clock % 1000000);
else
snprintf(temp, WINUI_ARRAY_LENGTH(temp), " %d.%03d kHz", clock / 1000, clock % 1000);
strcat(buffer, temp);
}
strcat(buffer, "\r\n");
}
return buffer;
}
/* Build Display info string */
static char *GameInfoScreen(UINT nIndex)
{
static char buf[2048];
machine_config config(driver_list::driver(nIndex),pCurrentOpts);
memset(buf, '\0', 2048);
if (isDriverVector(&config))
strcpy(buf, "Vector Game");
else
{
screen_device_iterator iter(config.root_device());
const screen_device *screen = iter.first();
if (screen == NULL)
strcpy(buf, "Screenless Game");
else
{
for (screen_device &screen : screen_device_iterator(config.root_device()))
{
char tmpbuf[2048];
const rectangle &visarea = screen.visible_area();
if (BIT(GetDriverCacheLower(nIndex), 2)) //ORIENTATION_SWAP_XY
{
sprintf(tmpbuf,"%d x %d (V) %f Hz\n",
visarea.max_y - visarea.min_y + 1,
visarea.max_x - visarea.min_x + 1,
ATTOSECONDS_TO_HZ(screen.refresh_attoseconds()));
}
else
{
sprintf(tmpbuf,"%d x %d (H) %f Hz\n",
visarea.max_x - visarea.min_x + 1,
visarea.max_y - visarea.min_y + 1,
ATTOSECONDS_TO_HZ(screen.refresh_attoseconds()));
}
strcat(buf, tmpbuf);
}
}
}
return buf;
}
/* Build game status string */
const char *GameInfoStatus(int driver_index, BOOL bRomStatus)
{
static char buffer[2048];
memset(buffer,0,sizeof(char)*2048);
if (driver_index < 0)
return buffer;
int audit_result = GetRomAuditResults(driver_index);
uint32_t cache = GetDriverCacheLower(driver_index);
if ( bRomStatus )
{
if (IsAuditResultKnown(audit_result) == false)
strcpy(buffer, "Unknown");
else
if (IsAuditResultYes(audit_result))
{
if (DriverIsBroken(driver_index))
{
strcpy(buffer, "Not working");
if (BIT(cache, 22))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Game protection isn't fully emulated");
}
if (BIT(cache, 21))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Colors are completely wrong");
}
if (BIT(cache, 20))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Colors aren't 100% accurate");
}
if (BIT(cache, 18))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Video emulation isn't 100% accurate");
}
if (BIT(cache, 17))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Game lacks sound");
}
if (BIT(cache, 16))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Sound emulation isn't 100% accurate");
}
if (BIT(cache, 8))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Screen flipping is not supported");
}
if (BIT(cache, 10))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Game requires artwork");
}
}
else
{
strcpy(buffer, "Working");
if (BIT(cache, 22))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Game protection isn't fully emulated");
}
if (BIT(cache, 21))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Colors are completely wrong");
}
if (BIT(cache, 20))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Colors aren't 100% accurate");
}
if (BIT(cache, 18))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Video emulation isn't 100% accurate");
}
if (BIT(cache, 17))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Game lacks sound");
}
if (BIT(cache, 16))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Sound emulation isn't 100% accurate");
}
if (BIT(cache, 8))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Screen flipping is not supported");
}
if (BIT(cache, 10))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Game requires artwork");
}
}
}
else
// audit result is no
strcpy(buffer, "BIOS missing");
}
else
{
//Just show the emulation flags
if (DriverIsBroken(driver_index))
strcpy(buffer, "Not working");
else
strcpy(buffer, "Working");
if (BIT(cache, 22))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Game protection isn't fully emulated");
}
if (BIT(cache, 21))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Colors are completely wrong");
}
if (BIT(cache, 20))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Colors aren't 100% accurate");
}
if (BIT(cache, 18))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Video emulation isn't 100% accurate");
}
if (BIT(cache, 17))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Game lacks sound");
}
if (BIT(cache, 16))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Sound emulation isn't 100% accurate");
}
if (BIT(cache, 8))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Screen flipping is not supported");
}
if (BIT(cache, 10))
{
if (*buffer != '\0')
strcat(buffer, "\r\n");
strcat(buffer, "Game requires artwork");
}
}
return buffer;
}
/* Build game manufacturer string */
static char *GameInfoManufactured(UINT nIndex)
{
static char buffer[1024];
snprintf(buffer,sizeof(buffer),"%s %s",driver_list::driver(nIndex).year,driver_list::driver(nIndex).manufacturer);
return buffer;
}
/* Build Game title string */
char *GameInfoTitle(OPTIONS_TYPE opt_type, UINT nIndex)
{
static char buf[1024];
if (OPTIONS_GLOBAL == opt_type)
strcpy(buf, "Global game options\nDefault options used by all games");
else
if (OPTIONS_SOURCE == opt_type)
strcpy(buf, "Options used by all games in the source");
else
if (OPTIONS_VECTOR == opt_type)
strcpy(buf, "Global vector options");
else
if (OPTIONS_GAME == opt_type)
sprintf(buf, "%s\n\"%s\"", ModifyThe(driver_list::driver(nIndex).type.fullname()), driver_list::driver(nIndex).name);
return buf;
}
/* Build game clone information string */
static char *GameInfoCloneOf(UINT nIndex)
{
static char buf[1024];
int nParentIndex= -1;
buf[0] = '\0';
if (DriverIsClone(nIndex))
{
nParentIndex = GetParentIndex(&driver_list::driver(nIndex));
sprintf(buf, "%s - \"%s\"",
ConvertAmpersandString(ModifyThe(driver_list::driver(nParentIndex).type.fullname())),
driver_list::driver(nParentIndex).name);
}
return buf;
}
static const char * GameInfoSource(UINT nIndex)
{
return GetDriverFilename(nIndex);
}
/* Handle the information property page */
INT_PTR CALLBACK GamePropertiesDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
HWND hWnd;
switch (Msg)
{
case WM_INITDIALOG:
if (g_hIcon)
SendDlgItemMessage(hDlg, IDC_GAME_ICON, STM_SETICON, (WPARAM) g_hIcon, 0);
#if defined(USE_SINGLELINE_TABCONTROL)
{
HWND hWnd = PropSheet_GetTabControl(GetParent(hDlg));
DWORD tabStyle = (GetWindowLong(hWnd,GWL_STYLE) & ~TCS_MULTILINE);
SetWindowLong(hWnd,GWL_STYLE,tabStyle | TCS_SINGLELINE);
}
#endif
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_TITLE), GameInfoTitle(g_nPropertyMode, g_nGame));
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_MANUFACTURED), GameInfoManufactured(g_nGame));
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_STATUS), GameInfoStatus(g_nGame, false));
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_CPU), GameInfoCPU(g_nGame));
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_SOUND), GameInfoSound(g_nGame));
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_SCREEN), GameInfoScreen(g_nGame));
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_CLONEOF), GameInfoCloneOf(g_nGame));
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_SOURCE), GameInfoSource(g_nGame));
if (DriverIsClone(g_nGame))
ShowWindow(GetDlgItem(hDlg, IDC_PROP_CLONEOF_TEXT), SW_SHOW);
else
ShowWindow(GetDlgItem(hDlg, IDC_PROP_CLONEOF_TEXT), SW_HIDE);
hWnd = PropSheet_GetTabControl(GetParent(hDlg));
UpdateBackgroundBrush(hWnd);
ShowWindow(hDlg, SW_SHOW);
return 1;
}
return 0;
}
/* Handle all options property pages */
INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
BOOL g_bUseDefaults = false, g_bReset = false;
switch (Msg)
{
case WM_INITDIALOG:
/* Fill in the Game info at the top of the sheet */
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_TITLE), GameInfoTitle(g_nPropertyMode, g_nGame));
InitializeOptions(hDlg);
InitializeMisc(hDlg);
UpdateProperties(hDlg, properties_datamap, pCurrentOpts);
g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts) ? false : true;
g_bReset = AreOptionsEqual(pCurrentOpts, pOrigOpts) ? false : true;
// Default button doesn't exist on Default settings
// if (g_nGame == GLOBAL_OPTIONS)
// ShowWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), SW_HIDE);
// else
EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), g_bUseDefaults);
// Setup Reset button
EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset);
ShowWindow(hDlg, SW_SHOW);
return 1;
case WM_HSCROLL:
/* slider changed */
HANDLE_WM_HSCROLL(hDlg, wParam, lParam, OptOnHScroll);
EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), true);
// Enable Apply button
PropSheet_Changed(GetParent(hDlg), hDlg);
// make sure everything's copied over, to determine what's changed
UpdateOptions(hDlg, properties_datamap, pCurrentOpts);
// redraw it, it might be a new color now
InvalidateRect((HWND)lParam,NULL,true);
break;
case WM_COMMAND:
{
/* Below, 'changed' is used to signify the 'Apply' button should be enabled. */
WORD wID = GET_WM_COMMAND_ID(wParam, lParam);
HWND hWndCtrl = GET_WM_COMMAND_HWND(wParam, lParam);
WORD wNotifyCode = GET_WM_COMMAND_CMD(wParam, lParam);
BOOL changed = false;
int nCurSelection = 0;
TCHAR szClass[256];
switch (wID)
{
case IDC_REFRESH:
if (wNotifyCode == LBN_SELCHANGE)
{
RefreshSelectionChange(hDlg, hWndCtrl);
changed = true;
}
break;
case IDC_ASPECT:
nCurSelection = Button_GetCheck( GetDlgItem(hDlg, IDC_ASPECT));
if( g_bAutoAspect[GetSelectedScreen(hDlg)] != nCurSelection )
{
changed = true;
g_bAutoAspect[GetSelectedScreen(hDlg)] = nCurSelection;
}
break;
case IDC_SNAPSIZE:
nCurSelection = Button_GetCheck( GetDlgItem(hDlg, IDC_SNAPSIZE));
if( g_bAutoSnapSize != nCurSelection )
{
changed = true;
g_bAutoSnapSize = nCurSelection;
}
break;
case IDC_SELECT_EFFECT:
changed = SelectEffect(hDlg);
break;
case IDC_RESET_EFFECT:
changed = ResetEffect(hDlg);
break;
case IDC_SELECT_JOYSTICKMAP:
changed = SelectJoystickMap(hDlg);
break;
case IDC_RESET_JOYSTICKMAP:
changed = ResetJoystickMap(hDlg);
break;
case IDC_SELECT_DEBUGSCRIPT:
changed = SelectDebugscript(hDlg);
break;
case IDC_RESET_DEBUGSCRIPT:
changed = ResetDebugscript(hDlg);
break;
case IDC_SELECT_LUASCRIPT:
changed = SelectLUAScript(hDlg);
break;
case IDC_RESET_LUASCRIPT:
changed = ResetLUAScript(hDlg);
break;
case IDC_SELECT_PLUGIN:
changed = SelectPlugins(hDlg);
break;
case IDC_RESET_PLUGIN:
changed = ResetPlugins(hDlg);
break;
case IDC_PROP_RESET:
// RESET Button - Only do it if mouse-clicked
if (wNotifyCode != BN_CLICKED)
break;
// Change settings in property sheets back to original
UpdateProperties(hDlg, properties_datamap, pOrigOpts);
// The original options become the current options.
UpdateOptions(hDlg, properties_datamap, pCurrentOpts);
g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts) ? false : true;
g_bReset = AreOptionsEqual(pCurrentOpts, pOrigOpts) ? false : true;
// Turn off Apply
PropSheet_UnChanged(GetParent(hDlg), hDlg);
EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), g_bUseDefaults);
EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset);
break;
case IDC_USE_DEFAULT:
// DEFAULT Button - Only do it if mouse-clicked
if (wNotifyCode != BN_CLICKED)
break;
// Change settings to be the same as mame.ini
UpdateProperties(hDlg, properties_datamap, pDefaultOpts);
// The original options become the current options.
UpdateOptions(hDlg, properties_datamap, pCurrentOpts);
g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts) ? false : true;
g_bReset = AreOptionsEqual(pCurrentOpts, pOrigOpts) ? false : true;
// Enable/Disable the Reset to Defaults button
EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), g_bUseDefaults);
EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset);
// Tell the dialog to enable/disable the apply button.
if (g_nGame != GLOBAL_OPTIONS)
{
if (g_bReset)
PropSheet_Changed(GetParent(hDlg), hDlg);
else
PropSheet_UnChanged(GetParent(hDlg), hDlg);
}
break;
// MSH 20070813 - Update all related controls
case IDC_SCREENSELECT:
case IDC_SCREEN:
// NPW 3-Apr-2007: Ugh I'm only perpetuating the vile hacks in this code
if ((wNotifyCode == CBN_SELCHANGE) || (wNotifyCode == CBN_SELENDOK))
{
changed = datamap_read_control(properties_datamap, hDlg, pCurrentOpts, wID);
datamap_populate_control(properties_datamap, hDlg, pCurrentOpts, IDC_SIZES);
//MSH 20070814 - Hate to do this, but its either this, or update each individual
// control on the SCREEN tab.
UpdateProperties(hDlg, properties_datamap, pCurrentOpts);
changed = true;
/* NOT USED *************
datamap_populate_control(properties_datamap, hDlg, pCurrentOpts, IDC_SCREENSELECT);
datamap_populate_control(properties_datamap, hDlg, pCurrentOpts, IDC_SCREEN);
datamap_populate_control(properties_datamap, hDlg, pCurrentOpts, IDC_REFRESH);
datamap_populate_control(properties_datamap, hDlg, pCurrentOpts, IDC_SIZES);
datamap_populate_control(properties_datamap, hDlg, pCurrentOpts, IDC_VIEW);
datamap_populate_control(properties_datamap, hDlg, pCurrentOpts, IDC_SWITCHRES);
if (strcmp(options_get_string(pCurrentOpts, "screen0"), options_get_string(pOrigOpts, "screen0")!=0) ||
strcmp(options_get_string(pCurrentOpts, "screen1"), options_get_string(pOrigOpts, "screen1")!=0) ||
strcmp(options_get_string(pCurrentOpts, "screen2"), options_get_string(pOrigOpts, "screen2")!=0) ||
strcmp(options_get_string(pCurrentOpts, "screen3"), options_get_string(pOrigOpts, "screen3")!=0))
changed = true;
************************************* */
}
break;
default:
#ifdef MESS
if (MessPropertiesCommand(hDlg, wNotifyCode, wID, &changed))
// To Do: add a hook to MessReadMountedSoftware(drvindex); so the software will update itself when the folder is configured
break;
#endif
// use default behavior; try to get the result out of the datamap if
// appropriate
GetClassName(hWndCtrl, szClass, ARRAY_LENGTH(szClass));
if (!_tcscmp(szClass, WC_COMBOBOX))
{
// combo box
if ((wNotifyCode == CBN_SELCHANGE) || (wNotifyCode == CBN_SELENDOK))
changed = datamap_read_control(properties_datamap, hDlg, pCurrentOpts, wID);
}
else if (!_tcscmp(szClass, WC_BUTTON) && (GetWindowLong(hWndCtrl, GWL_STYLE) & BS_CHECKBOX))
{
// check box
changed = datamap_read_control(properties_datamap, hDlg, pCurrentOpts, wID);
}
break;
}
if (changed == true)
{
// make sure everything's copied over, to determine what's changed
UpdateOptions(hDlg, properties_datamap, pCurrentOpts);
// enable the apply button
PropSheet_Changed(GetParent(hDlg), hDlg);
g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts) ? false : true;
g_bReset = AreOptionsEqual(pCurrentOpts, pOrigOpts) ? false : true;
EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), g_bUseDefaults);
EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset);
}
}
break;
case WM_NOTIFY:
{
// Set to true if we are exiting the properties dialog
//BOOL bClosing = ((LPPSHNOTIFY) lParam)->lParam; // indicates OK was clicked rather than APPLY
switch (((NMHDR *) lParam)->code)
{
//We'll need to use a CheckState Table
//Because this one gets called for all kinds of other things too, and not only if a check is set
case PSN_SETACTIVE:
/* Initialize the controls. */
UpdateProperties(hDlg, properties_datamap, pCurrentOpts);
g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts) ? false : true;
g_bReset = AreOptionsEqual(pCurrentOpts, pOrigOpts) ? false : true;
EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), g_bUseDefaults);
EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset);
break;
case PSN_APPLY:
// Handle more than one PSN_APPLY, since this proc handles more than one
// property sheet and can be called multiple times when it's time to exit,
// and we may have already freed the windows_options.
//if (bClosing)
//{
//if (NULL == pCurrentOpts)
//return true;
//}
// Read the datamap
UpdateOptions(hDlg, properties_datamap, pCurrentOpts);
// The current options become the original options.
UpdateOptions(hDlg, properties_datamap, pOrigOpts);
// Repopulate the controls? WTF? We just read them, they should be fine.
UpdateProperties(hDlg, properties_datamap, pCurrentOpts);
g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts) ? false : true;
g_bReset = AreOptionsEqual(pCurrentOpts, pOrigOpts) ? false : true;
EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), g_bUseDefaults);
EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset);
// Save the current options
save_options(pCurrentOpts, g_nPropertyMode, g_nGame);
// Disable apply button
PropSheet_UnChanged(GetParent(hDlg), hDlg);
SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
return true;
case PSN_KILLACTIVE:
/* Save Changes to the options here. */
UpdateOptions(hDlg, properties_datamap, pCurrentOpts);
// Determine button states.
g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts) ? false : true;
g_bReset = AreOptionsEqual(pCurrentOpts, pOrigOpts) ? false : true;
EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), g_bUseDefaults);
EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset);
ResetDataMap(hDlg);
SetWindowLongPtr(hDlg, DWLP_MSGRESULT, false);
return 1;
case PSN_RESET:
// Reset to the original values. Disregard changes
//pCurrentOpts = pOrigOpts;
g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts) ? false : true;
g_bReset = AreOptionsEqual(pCurrentOpts, pOrigOpts) ? false : true;
EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), g_bUseDefaults);
EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset);
SetWindowLongPtr(hDlg, DWLP_MSGRESULT, false);
break;
case PSN_HELP:
// User wants help for this property page
break;
}
}
break;
case WM_HELP:
/* User clicked the ? from the upper right on a control */
HelpFunction((HWND)((LPHELPINFO)lParam)->hItemHandle, MAMEUICONTEXTHELP, HH_TP_HELP_WM_HELP, GetHelpIDs());
break;
case WM_CONTEXTMENU:
HelpFunction((HWND)wParam, MAMEUICONTEXTHELP, HH_TP_HELP_CONTEXTMENU, GetHelpIDs());
break;
}
return 0;
}
/* Read controls that are not handled in the DataMap */
static void PropToOptions(HWND hWnd, windows_options &o)
{
HWND hCtrl;
HWND hCtrl2;
HWND hCtrl3;
/* aspect ratio */
hCtrl = GetDlgItem(hWnd, IDC_ASPECTRATION);
hCtrl2 = GetDlgItem(hWnd, IDC_ASPECTRATIOD);
hCtrl3 = GetDlgItem(hWnd, IDC_ASPECT);
if (hCtrl && hCtrl2 && hCtrl3)
{
char aspect_option[32];
snprintf(aspect_option, ARRAY_LENGTH(aspect_option), "aspect%d", GetSelectedScreen(hWnd));
if (Button_GetCheck(hCtrl3))
{
o.set_value(aspect_option, "auto", OPTION_PRIORITY_CMDLINE);
}
else
{
int n = 0;
int d = 0;
TCHAR buffer[200];
char buffer2[200];
Edit_GetText(hCtrl, buffer, ARRAY_LENGTH(buffer));
_stscanf(buffer,TEXT("%d"),&n);
Edit_GetText(hCtrl2, buffer, ARRAY_LENGTH(buffer));
_stscanf(buffer,TEXT("%d"),&d);
if (n == 0 || d == 0)
{
n = 4;
d = 3;
}
snprintf(buffer2, sizeof(buffer2), "%d:%d", n, d);
o.set_value(aspect_option, buffer2, OPTION_PRIORITY_CMDLINE);
}
}
/* aspect ratio */
hCtrl = GetDlgItem(hWnd, IDC_SNAPSIZEWIDTH);
hCtrl2 = GetDlgItem(hWnd, IDC_SNAPSIZEHEIGHT);
hCtrl3 = GetDlgItem(hWnd, IDC_SNAPSIZE);
if (hCtrl && hCtrl2 && hCtrl3)
{
if (Button_GetCheck(hCtrl3))
{
o.set_value(OPTION_SNAPSIZE, "auto", OPTION_PRIORITY_CMDLINE);
}
else
{
int width = 0;
int height = 0;
TCHAR buffer[200];
char buffer2[200];
Edit_GetText(hCtrl, buffer, ARRAY_LENGTH(buffer));
_stscanf(buffer, TEXT("%d"), &width);
Edit_GetText(hCtrl2, buffer, ARRAY_LENGTH(buffer));
_stscanf(buffer, TEXT("%d"), &height);
if (width == 0 || height == 0)
{
width = 640;
height = 480;
}
snprintf(buffer2, sizeof(buffer2), "%dx%d", width, height);
o.set_value(OPTION_SNAPSIZE, buffer2, OPTION_PRIORITY_CMDLINE);
}
}
}
/* Update options from the dialog */
static void UpdateOptions(HWND hDlg, datamap *map, windows_options &opts)
{
/* These are always called together, so make one convenient function. */
datamap_read_all_controls(map, hDlg, opts);
PropToOptions(hDlg, opts);
}
/* Update the dialog from the options */
static void UpdateProperties(HWND hDlg, datamap *map, windows_options &opts)
{
/* These are always called together, so make one convenient function. */
datamap_populate_all_controls(map, hDlg, opts);
OptionsToProp(hDlg, opts);
SetPropEnabledControls(hDlg);
}
/* Populate controls that are not handled in the DataMap */
static void OptionsToProp(HWND hWnd, windows_options& o)
{
HWND hCtrl2;
TCHAR buf[1024];
int n = 0;
int d = 0;
int width = 0;
int height = 0;
int res = 0;
/* video */
/* Setup refresh list based on depth. */
datamap_update_control(properties_datamap, hWnd, pCurrentOpts, IDC_REFRESH);
/* Setup Select screen*/
UpdateSelectScreenUI(hWnd );
HWND hCtrl = GetDlgItem(hWnd, IDC_ASPECT);
if (hCtrl)
Button_SetCheck(hCtrl, g_bAutoAspect[GetSelectedScreen(hWnd)] );
hCtrl = GetDlgItem(hWnd, IDC_SNAPSIZE);
if (hCtrl)
Button_SetCheck(hCtrl, g_bAutoSnapSize );
/* Bios select list */
hCtrl = GetDlgItem(hWnd, IDC_BIOS);
if (hCtrl)
{
const char* cBuffer;
for( uint8_t i = 0; i < ComboBox_GetCount( hCtrl ); i++ )
{
cBuffer = (const char*)ComboBox_GetItemData( hCtrl, i );
if (strcmp(cBuffer, pCurrentOpts.value(OPTION_BIOS) ) == 0)
{
res = ComboBox_SetCurSel(hCtrl, i);
break;
}
}
}
hCtrl = GetDlgItem(hWnd, IDC_ASPECT);
if (hCtrl)
{
char aspect_option[32];
snprintf(aspect_option, ARRAY_LENGTH(aspect_option), "aspect%d", GetSelectedScreen(hWnd));
if( strcmp(o.value(aspect_option), "auto") == 0)
{
Button_SetCheck(hCtrl, true);
g_bAutoAspect[GetSelectedScreen(hWnd)] = true;
}
else
{
Button_SetCheck(hCtrl, false);
g_bAutoAspect[GetSelectedScreen(hWnd)] = false;
}
}
/* aspect ratio */
hCtrl = GetDlgItem(hWnd, IDC_ASPECTRATION);
hCtrl2 = GetDlgItem(hWnd, IDC_ASPECTRATIOD);
if (hCtrl && hCtrl2)
{
char aspect_option[32];
snprintf(aspect_option, ARRAY_LENGTH(aspect_option), "aspect%d", GetSelectedScreen(hWnd));
n = 0;
d = 0;
if (o.value(aspect_option))
{
if (sscanf(o.value(aspect_option), "%d:%d", &n, &d) == 2 && n != 0 && d != 0)
{
_stprintf(buf, TEXT("%d"), n);
Edit_SetText(hCtrl, buf);
_stprintf(buf, TEXT("%d"), d);
Edit_SetText(hCtrl2, buf);
}
else
{
Edit_SetText(hCtrl, TEXT("4"));
Edit_SetText(hCtrl2, TEXT("3"));
}
}
else
{
Edit_SetText(hCtrl, TEXT("4"));
Edit_SetText(hCtrl2, TEXT("3"));
}
}
hCtrl = GetDlgItem(hWnd, IDC_EFFECT);
if (hCtrl) {
const char* effect = o.value(OPTION_EFFECT);
if (effect == NULL) {
effect = "none";
o.set_value(OPTION_EFFECT, effect, OPTION_PRIORITY_CMDLINE);
}
win_set_window_text_utf8(hCtrl, effect);
}
hCtrl = GetDlgItem(hWnd, IDC_SNAPSIZE);
if (hCtrl)
{
if( strcmp(o.value(OPTION_SNAPSIZE), "auto") == 0)
{
Button_SetCheck(hCtrl, true);
g_bAutoSnapSize = true;
}
else
{
Button_SetCheck(hCtrl, false);
g_bAutoSnapSize = false;
}
}
#if 0
for (int i = 0; i < 5; i++)
{
UpdateMameShader(hWnd, i, opts);
UpdateScreenShader(hWnd, i, opts);
}
hCtrl = GetDlgItem(hWnd, IDC_CHEATFILE);
if (hCtrl)
{
const char* cheatfile = opts.value(OPTION_CHEATPATH);
if (strcmp(cheatfile, "cheat") == 0)
winui_set_window_text_utf8(hCtrl, "Default");
else
{
char *cheatname = strrchr(cheatfile, '\\');
if (cheatname != NULL)
{
strcpy(buffer, cheatname + 1);
winui_set_window_text_utf8(hCtrl, buffer);
}
else
winui_set_window_text_utf8(hCtrl, cheatfile);
}
}
#endif
hCtrl = GetDlgItem(hWnd, IDC_JOYSTICKMAP);
if (hCtrl)
{
const char* joymap = o.value(OPTION_JOYSTICK_MAP);
win_set_window_text_utf8(hCtrl, joymap);
}
hCtrl = GetDlgItem(hWnd, IDC_LUASCRIPT);
if (hCtrl)
{
const char* script = o.value(OPTION_AUTOBOOT_SCRIPT);
if (strcmp(script, "") == 0)
win_set_window_text_utf8(hCtrl, "None");
else
{
char buffer[260];
wchar_t *t_filename = ui_wstring_from_utf8(script);
wchar_t *tempname = PathFindFileName(t_filename);
PathRemoveExtension(tempname);
char *optname = ui_utf8_from_wstring(tempname);
strcpy(buffer, optname);
free(t_filename);
free(optname);
win_set_window_text_utf8(hCtrl, buffer);
}
}
hCtrl = GetDlgItem(hWnd, IDC_PLUGIN);
if (hCtrl)
{
string t1 = GetPlugins();
const char* plugin = t1.c_str();
if (strlen(plugin) == 0)
//if (strcmp(plugin, "") == 0)
win_set_window_text_utf8(hCtrl, "None");
else
win_set_window_text_utf8(hCtrl, plugin);
}
#if 0
hCtrl = GetDlgItem(hWnd, IDC_BGFX_CHAINS);
if (hCtrl)
{
const char* chains = o.value(OSDOPTION_BGFX_SCREEN_CHAINS);
if (strcmp(chains, "default") == 0)
winui_set_window_text_utf8(hCtrl, "Default");
else
winui_set_window_text_utf8(hCtrl, chains);
}
#endif
/* snapshot size */
hCtrl = GetDlgItem(hWnd, IDC_SNAPSIZEWIDTH);
hCtrl2 = GetDlgItem(hWnd, IDC_SNAPSIZEHEIGHT);
if (hCtrl && hCtrl2)
{
n = 0;
d = 0;
if (o.value(OPTION_SNAPSIZE))
{
if (sscanf(o.value(OPTION_SNAPSIZE), "%dx%d", &width, &height) == 2 && width && height)
{
_stprintf(buf, TEXT("%d"), width);
Edit_SetText(hCtrl, buf);
_stprintf(buf, TEXT("%d"), height);
Edit_SetText(hCtrl2, buf);
}
else
{
Edit_SetText(hCtrl, TEXT("640"));
Edit_SetText(hCtrl2, TEXT("480"));
}
}
else
{
Edit_SetText(hCtrl, TEXT("640"));
Edit_SetText(hCtrl2, TEXT("480"));
}
}
res++;
}
/* Adjust controls - tune them to the currently selected game */
static void SetPropEnabledControls(HWND hWnd)
{
bool useart = true;
BOOL joystick_attached = false;
bool in_window = false;
int nIndex = g_nGame;
// auto is a reserved word
bool autov = (core_stricmp(pCurrentOpts.value(OSDOPTION_VIDEO), "auto")==0);
bool d3d = (core_stricmp(pCurrentOpts.value(OSDOPTION_VIDEO), "d3d")==0) | autov;
#ifdef UI_DIRECTDRAW
bool ddraw = (core_stricmp(pCurrentOpts.value(OSDOPTION_VIDEO), "ddraw")==0) | autov;
#else
bool ddraw = false;
#endif
in_window = pCurrentOpts.bool_value(OSDOPTION_WINDOW);
Button_SetCheck(GetDlgItem(hWnd, IDC_ASPECT), g_bAutoAspect[GetSelectedScreen(hWnd)] );
EnableWindow(GetDlgItem(hWnd, IDC_WAITVSYNC), d3d|ddraw);
EnableWindow(GetDlgItem(hWnd, IDC_TRIPLE_BUFFER), d3d|ddraw);
EnableWindow(GetDlgItem(hWnd, IDC_PRESCALE), d3d|ddraw);
EnableWindow(GetDlgItem(hWnd, IDC_PRESCALEDISP), d3d|ddraw);
EnableWindow(GetDlgItem(hWnd, IDC_PRESCALETEXT), d3d|ddraw);
#ifdef UI_DIRECTDRAW
EnableWindow(GetDlgItem(hWnd, IDC_HWSTRETCH), ddraw && DirectDraw_HasHWStretch());
#else
EnableWindow(GetDlgItem(hWnd, IDC_HWSTRETCH), false);
#endif
EnableWindow(GetDlgItem(hWnd, IDC_SWITCHRES), true);
EnableWindow(GetDlgItem(hWnd, IDC_SYNCREFRESH), true);
EnableWindow(GetDlgItem(hWnd, IDC_REFRESH), !in_window);
EnableWindow(GetDlgItem(hWnd, IDC_REFRESHTEXT), !in_window);
EnableWindow(GetDlgItem(hWnd, IDC_FSGAMMA), !in_window);
EnableWindow(GetDlgItem(hWnd, IDC_FSGAMMATEXT), !in_window);
EnableWindow(GetDlgItem(hWnd, IDC_FSGAMMADISP), !in_window);
EnableWindow(GetDlgItem(hWnd, IDC_FSBRIGHTNESS), !in_window);
EnableWindow(GetDlgItem(hWnd, IDC_FSBRIGHTNESSTEXT), !in_window);
EnableWindow(GetDlgItem(hWnd, IDC_FSBRIGHTNESSDISP), !in_window);
EnableWindow(GetDlgItem(hWnd, IDC_FSCONTRAST), !in_window);
EnableWindow(GetDlgItem(hWnd, IDC_FSCONTRASTTEXT), !in_window);
EnableWindow(GetDlgItem(hWnd, IDC_FSCONTRASTDISP), !in_window);
EnableWindow(GetDlgItem(hWnd, IDC_ASPECTRATIOTEXT), !g_bAutoAspect[GetSelectedScreen(hWnd)]);
EnableWindow(GetDlgItem(hWnd, IDC_ASPECTRATION), !g_bAutoAspect[GetSelectedScreen(hWnd)]);
EnableWindow(GetDlgItem(hWnd, IDC_ASPECTRATIOD), !g_bAutoAspect[GetSelectedScreen(hWnd)]);
EnableWindow(GetDlgItem(hWnd, IDC_SNAPSIZETEXT), !g_bAutoSnapSize);
EnableWindow(GetDlgItem(hWnd, IDC_SNAPSIZEHEIGHT), !g_bAutoSnapSize);
EnableWindow(GetDlgItem(hWnd, IDC_SNAPSIZEWIDTH), !g_bAutoSnapSize);
EnableWindow(GetDlgItem(hWnd, IDC_SNAPSIZEX), !g_bAutoSnapSize);
EnableWindow(GetDlgItem(hWnd, IDC_D3D_FILTER),d3d);
#ifdef D3DVERSION
EnableWindow(GetDlgItem(hWnd, IDC_D3D_VERSION),(NUMD3DVERSIONS>1) & d3d);
#endif
//Switchres and D3D or ddraw enable the per screen parameters
EnableWindow(GetDlgItem(hWnd, IDC_NUMSCREENS), ddraw | d3d);
EnableWindow(GetDlgItem(hWnd, IDC_NUMSCREENSDISP), ddraw | d3d);
EnableWindow(GetDlgItem(hWnd, IDC_SCREENSELECT), ddraw | d3d);
EnableWindow(GetDlgItem(hWnd, IDC_SCREENSELECTTEXT), ddraw | d3d);
EnableWindow(GetDlgItem(hWnd, IDC_ARTWORK_CROP), useart);
EnableWindow(GetDlgItem(hWnd, IDC_BACKDROPS), useart);
EnableWindow(GetDlgItem(hWnd, IDC_BEZELS), useart);
EnableWindow(GetDlgItem(hWnd, IDC_OVERLAYS), useart);
EnableWindow(GetDlgItem(hWnd, IDC_CPANELS), useart);
EnableWindow(GetDlgItem(hWnd, IDC_MARQUEES), useart);
EnableWindow(GetDlgItem(hWnd, IDC_ARTMISCTEXT), useart);
/* Joystick options */
joystick_attached = DIJoystick.Available();
Button_Enable(GetDlgItem(hWnd,IDC_JOYSTICK), joystick_attached);
EnableWindow(GetDlgItem(hWnd, IDC_JDZTEXT), joystick_attached);
EnableWindow(GetDlgItem(hWnd, IDC_JDZDISP), joystick_attached);
EnableWindow(GetDlgItem(hWnd, IDC_JDZ), joystick_attached);
EnableWindow(GetDlgItem(hWnd, IDC_JSATTEXT), joystick_attached);
EnableWindow(GetDlgItem(hWnd, IDC_JSATDISP), joystick_attached);
EnableWindow(GetDlgItem(hWnd, IDC_JSAT), joystick_attached);
/* Trackball / Mouse options */
if (nIndex <= -1 || DriverUsesTrackball(nIndex) || DriverUsesLightGun(nIndex))
Button_Enable(GetDlgItem(hWnd,IDC_USE_MOUSE),true);
else
Button_Enable(GetDlgItem(hWnd,IDC_USE_MOUSE),false);
if (!in_window && (nIndex <= -1 || DriverUsesLightGun(nIndex)))
{
// on WinXP the Lightgun and Dual Lightgun switches are no longer supported use mouse instead
OSVERSIONINFOEX osvi;
BOOL bOsVersionInfoEx;
// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
// If that fails, try using the OSVERSIONINFO structure.
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
{
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
bOsVersionInfoEx = GetVersionEx ( (OSVERSIONINFO *) &osvi);
}
// if( bOsVersionInfoEx && (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) && (osvi.dwMajorVersion >= 5) )
// {
BOOL use_lightgun;
//XP and above...
Button_Enable(GetDlgItem(hWnd,IDC_LIGHTGUN),false);
use_lightgun = Button_GetCheck(GetDlgItem(hWnd,IDC_USE_MOUSE));
Button_Enable(GetDlgItem(hWnd,IDC_DUAL_LIGHTGUN),false);
Button_Enable(GetDlgItem(hWnd,IDC_RELOAD),use_lightgun);
// }
// else
// {
// BOOL use_lightgun;
// Older than XP
// Button_Enable(GetDlgItem(hWnd,IDC_LIGHTGUN),true);
// use_lightgun = Button_GetCheck(GetDlgItem(hWnd,IDC_LIGHTGUN));
// Button_Enable(GetDlgItem(hWnd,IDC_DUAL_LIGHTGUN),use_lightgun);
// Button_Enable(GetDlgItem(hWnd,IDC_RELOAD),use_lightgun);
// }
}
else
{
Button_Enable(GetDlgItem(hWnd,IDC_LIGHTGUN),false);
Button_Enable(GetDlgItem(hWnd,IDC_DUAL_LIGHTGUN),false);
Button_Enable(GetDlgItem(hWnd,IDC_RELOAD),false);
}
/* Sound options */
bool sound = (core_stricmp(pCurrentOpts.value(OSDOPTION_SOUND), "none")!=0);
ComboBox_Enable(GetDlgItem(hWnd, IDC_SAMPLERATE), sound);
EnableWindow(GetDlgItem(hWnd,IDC_VOLUME),sound);
EnableWindow(GetDlgItem(hWnd,IDC_RATETEXT),sound);
EnableWindow(GetDlgItem(hWnd,IDC_VOLUMEDISP),sound);
EnableWindow(GetDlgItem(hWnd,IDC_VOLUMETEXT),sound);
EnableWindow(GetDlgItem(hWnd,IDC_AUDIO_LATENCY),sound);
EnableWindow(GetDlgItem(hWnd,IDC_AUDIO_LATENCY_DISP),sound);
EnableWindow(GetDlgItem(hWnd,IDC_AUDIO_LATENCY_TEXT),sound);
SetSamplesEnabled(hWnd, nIndex, sound);
if (Button_GetCheck(GetDlgItem(hWnd, IDC_AUTOFRAMESKIP)))
EnableWindow(GetDlgItem(hWnd, IDC_FRAMESKIP), false);
else
EnableWindow(GetDlgItem(hWnd, IDC_FRAMESKIP), 1);
if (nIndex <= -1 || DriverHasOptionalBIOS(nIndex))
EnableWindow(GetDlgItem(hWnd,IDC_BIOS),true);
else
EnableWindow(GetDlgItem(hWnd,IDC_BIOS),false);
}
//============================================================
// CONTROL HELPER FUNCTIONS FOR DATA EXCHANGE
//============================================================
static BOOL RotateReadControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
int selected_index = ComboBox_GetCurSel(control);
int original_selection = 0;
// Figure out what the original selection value is
if (opts->bool_value(OPTION_ROR) && !opts->bool_value(OPTION_ROL))
original_selection = 1;
else if (!opts->bool_value(OPTION_ROR) && opts->bool_value(OPTION_ROL))
original_selection = 2;
else if (!opts->bool_value(OPTION_ROTATE))
original_selection = 3;
else if (opts->bool_value(OPTION_AUTOROR))
original_selection = 4;
else if (opts->bool_value(OPTION_AUTOROL))
original_selection = 5;
// Any work to do? If so, make the changes and return true.
if (selected_index != original_selection)
{
// Set the options based on the new selection.
opts->set_value(OPTION_ROR, selected_index == 1, OPTION_PRIORITY_CMDLINE);
opts->set_value(OPTION_ROL, selected_index == 2, OPTION_PRIORITY_CMDLINE);
opts->set_value(OPTION_ROTATE, selected_index != 3, OPTION_PRIORITY_CMDLINE);
opts->set_value(OPTION_AUTOROR, selected_index == 4, OPTION_PRIORITY_CMDLINE);
opts->set_value(OPTION_AUTOROL, selected_index == 5, OPTION_PRIORITY_CMDLINE);
return true;
}
// No changes
return false;
}
static BOOL RotatePopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
int res, selected_index = 0;
if (opts->bool_value(OPTION_ROR) && !opts->bool_value(OPTION_ROL))
selected_index = 1;
else if (!opts->bool_value(OPTION_ROR) && opts->bool_value(OPTION_ROL))
selected_index = 2;
else if (!opts->bool_value(OPTION_ROTATE))
selected_index = 3;
else if (opts->bool_value(OPTION_AUTOROR))
selected_index = 4;
else if (opts->bool_value(OPTION_AUTOROL))
selected_index = 5;
res = ComboBox_SetCurSel(control, selected_index);
res++;
return false;
}
static BOOL ScreenReadControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
char screen_option_name[32];
int selected_screen = GetSelectedScreen(dialog);
int screen_option_index = ComboBox_GetCurSel(control);
TCHAR *screen_option_value = (TCHAR*) ComboBox_GetItemData(control, screen_option_index);
snprintf(screen_option_name, ARRAY_LENGTH(screen_option_name), "screen%d", selected_screen);
char *op_val = ui_utf8_from_wstring(screen_option_value);
opts->set_value(screen_option_name, op_val, OPTION_PRIORITY_CMDLINE);
free(op_val);
return false;
}
static BOOL ScreenPopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
//int iMonitors;
DISPLAY_DEVICE dd;
int res, i = 0;
int nSelection = 0;
TCHAR* t_option = 0;
/* Remove all items in the list. */
res = ComboBox_ResetContent(control);
res = ComboBox_InsertString(control, 0, TEXT("Auto"));
res = ComboBox_SetItemData(control, 0, (void*)ui_wstring_from_utf8("auto"));
//Dynamically populate it, by enumerating the Monitors
//iMonitors = GetSystemMetrics(SM_CMONITORS); // this gets the count of monitors attached
ZeroMemory(&dd, sizeof(dd));
dd.cb = sizeof(dd);
for(i=0; EnumDisplayDevices(NULL, i, &dd, 0); i++)
{
if( !(dd.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) )
{
char screen_option[32];
//we have to add 1 to account for the "auto" entry
res = ComboBox_InsertString(control, i+1, win_tstring_strdup(dd.DeviceName));
res = ComboBox_SetItemData(control, i+1, (void*)win_tstring_strdup(dd.DeviceName));
snprintf(screen_option, ARRAY_LENGTH(screen_option), "screen%d", GetSelectedScreen(dialog));
t_option = ui_wstring_from_utf8(opts->value(screen_option));
if( !t_option )
return false;
if (_tcscmp(t_option, dd.DeviceName) == 0)
nSelection = i+1;
free(t_option);
}
}
res = ComboBox_SetCurSel(control, nSelection);
res++;
return false;
}
static void ViewSetOptionName(datamap *map, HWND dialog, HWND control, char *buffer, size_t buffer_size)
{
snprintf(buffer, buffer_size, "view%d", GetSelectedScreen(dialog));
}
static BOOL ViewPopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
int selected_index = 0;
char view_option[32];
// determine the view option value
snprintf(view_option, ARRAY_LENGTH(view_option), "view%d", GetSelectedScreen(dialog));
const char *view = opts->value(view_option);
int res = ComboBox_ResetContent(control);
for (int i = 0; i < NUMVIEW; i++)
{
res = ComboBox_InsertString(control, i, g_ComboBoxView[i].m_pText);
res = ComboBox_SetItemData(control, i, g_ComboBoxView[i].m_pData);
if (strcmp(view, g_ComboBoxView[i].m_pData)==0)
selected_index = i;
}
res = ComboBox_SetCurSel(control, selected_index);
res++;
return false;
}
static BOOL SnapViewPopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
int selected_index = 0;
// determine the snapview option value
const char *snapview = opts->value(OPTION_SNAPVIEW);
int res = ComboBox_ResetContent(control);
for (int i = 0; i < NUMSNAPVIEW; i++)
{
res = ComboBox_InsertString(control, i, g_ComboBoxSnapView[i].m_pText);
res = ComboBox_SetItemData(control, i, g_ComboBoxSnapView[i].m_pData);
if (strcmp(snapview, g_ComboBoxSnapView[i].m_pData)==0)
selected_index = i;
}
res = ComboBox_SetCurSel(control, selected_index);
res++;
return false;
}
static BOOL DefaultInputReadControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
int input_option_index = ComboBox_GetCurSel(control);
TCHAR *input_option_value = (TCHAR*) ComboBox_GetItemData(control, input_option_index);
char *op_val = ui_utf8_from_wstring(input_option_value);
opts->set_value(OPTION_CTRLR, input_option_index ? op_val : "", OPTION_PRIORITY_CMDLINE);
free(op_val);
return false;
}
wchar_t *win_wstring_from_utf8(const char *utf8string)
{
// convert MAME string (UTF-8) to UTF-16
int char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, nullptr, 0);
wchar_t *result = (wchar_t *)malloc(char_count * sizeof(*result));
if (result != nullptr)
MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, result, char_count);
return result;
}
char *win_utf8_from_wstring(const wchar_t *wstring)
{
// convert UTF-16 to MAME string (UTF-8)
int char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, nullptr, 0, nullptr, nullptr);
char *result = (char *)malloc(char_count * sizeof(*result));
if (result != nullptr)
WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, nullptr, nullptr);
return result;
}
HANDLE winui_find_first_file_utf8(const char* filename, WIN32_FIND_DATA *findfiledata)
{
wchar_t *t_filename = win_wstring_from_utf8(filename);
if (!t_filename)
return NULL;
HANDLE result = FindFirstFile(t_filename, findfiledata);
free(t_filename);
return result;
}
static BOOL DefaultInputPopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
WIN32_FIND_DATA FindFileData;
char path[MAX_PATH];
int selected = 0;
int index = 0;
// determine the ctrlr option
const char *ctrlr_option = opts->value(OPTION_CTRLR);
// reset the controllers dropdown
(void)ComboBox_ResetContent(control);
(void)ComboBox_InsertString(control, index, TEXT("Default"));
(void)ComboBox_SetItemData(control, index, "");
index++;
snprintf(path, WINUI_ARRAY_LENGTH(path), "%s\\*.*", GetCtrlrDir().c_str());
HANDLE hFind = winui_find_first_file_utf8(path, &FindFileData);
if (hFind != INVALID_HANDLE_VALUE)
{
while (FindNextFile (hFind, &FindFileData) != 0)
{
// copy the filename
const char *root = win_utf8_from_wstring(FindFileData.cFileName);
// find the extension
char *ext = strrchr(root, '.');
if (ext)
{
// check if it's a cfg file
if (strcmp (ext, ".cfg") == 0)
{
// and strip off the extension
*ext = 0;
// set the option?
if (!strcmp(root, ctrlr_option))
selected = index;
// add it as an option
wchar_t *t_root = win_wstring_from_utf8(root);
(void)ComboBox_InsertString(control, index, t_root);
(void)ComboBox_SetItemData(control, index, root);
free(t_root);
root = NULL;
index++;
}
}
}
FindClose (hFind);
}
(void)ComboBox_SetCurSel(control, selected);
return false;
}
static void ResolutionSetOptionName(datamap *map, HWND dialog, HWND control, char *buffer, size_t buffer_size)
{
snprintf(buffer, buffer_size, "resolution%d", GetSelectedScreen(dialog));
}
static BOOL ResolutionReadControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
HWND refresh_control = GetDlgItem(dialog, IDC_REFRESH);
HWND sizes_control = GetDlgItem(dialog, IDC_SIZES);
int res = 0, width = 0, height = 0;
char option_value[256];
if (refresh_control && sizes_control)
{
TCHAR buffer[256];
res = ComboBox_GetText(sizes_control, buffer, ARRAY_LENGTH(buffer) - 1);
if (_stscanf(buffer, TEXT("%d x %d"), &width, &height) == 2)
{
int refresh_index = ComboBox_GetCurSel(refresh_control);
int refresh_value = ComboBox_GetItemData(refresh_control, refresh_index);
snprintf(option_value, ARRAY_LENGTH(option_value), "%dx%d@%d", width, height, refresh_value);
}
else
snprintf(option_value, ARRAY_LENGTH(option_value), "auto");
opts->set_value(option_name, option_value, OPTION_PRIORITY_CMDLINE);
}
res++;
return false;
}
static BOOL ResolutionPopulateControl(datamap *map, HWND dialog, HWND control_, windows_options *opts, const char *option_name)
{
HWND sizes_control = GetDlgItem(dialog, IDC_SIZES);
HWND refresh_control = GetDlgItem(dialog, IDC_REFRESH);
int width, height, refresh;
const char *option_value;
int sizes_index = 0;
int refresh_index = 0;
int sizes_selection = 0;
int refresh_selection = 0;
char screen_option[32];
const char *screen;
LPTSTR t_screen;
TCHAR buf[16];
int res = 0, i;
DEVMODE devmode;
if (sizes_control && refresh_control)
{
// determine the resolution
option_value = opts->value(option_name);
if (sscanf(option_value, "%dx%d@%d", &width, &height, &refresh) != 3)
{
width = 0;
height = 0;
refresh = 0;
}
// reset sizes control
res = ComboBox_ResetContent(sizes_control);
res = ComboBox_InsertString(sizes_control, sizes_index, TEXT("Auto"));
res = ComboBox_SetItemData(sizes_control, sizes_index, 0);
sizes_index++;
// reset refresh control
res = ComboBox_ResetContent(refresh_control);
res = ComboBox_InsertString(refresh_control, refresh_index, TEXT("Auto"));
res = ComboBox_SetItemData(refresh_control, refresh_index, 0);
refresh_index++;
// determine which screen we're using
snprintf(screen_option, ARRAY_LENGTH(screen_option), "screen%d", GetSelectedScreen(dialog));
screen = opts->value(screen_option);
t_screen = ui_wstring_from_utf8(screen);
// retrieve screen information
devmode.dmSize = sizeof(devmode);
for (i = 0; EnumDisplaySettings(t_screen, i, &devmode); i++)
{
if ((devmode.dmBitsPerPel == 32 ) // Only 32 bit depth supported by core
&&(devmode.dmDisplayFrequency == refresh || refresh == 0))
{
_sntprintf(buf, ARRAY_LENGTH(buf), TEXT("%li x %li"),
devmode.dmPelsWidth, devmode.dmPelsHeight);
if (ComboBox_FindString(sizes_control, 0, buf) == CB_ERR)
{
res = ComboBox_InsertString(sizes_control, sizes_index, buf);
if ((width == devmode.dmPelsWidth) && (height == devmode.dmPelsHeight))
sizes_selection = sizes_index;
sizes_index++;
}
}
if (devmode.dmDisplayFrequency >= 10 )
{
// I have some devmode "vga" which specifes 1 Hz, which is probably bogus, so we filter it out
_sntprintf(buf, ARRAY_LENGTH(buf), TEXT("%li Hz"), devmode.dmDisplayFrequency);
if (ComboBox_FindString(refresh_control, 0, buf) == CB_ERR)
{
res = ComboBox_InsertString(refresh_control, refresh_index, buf);
res = ComboBox_SetItemData(refresh_control, refresh_index, devmode.dmDisplayFrequency);
if (refresh == devmode.dmDisplayFrequency)
refresh_selection = refresh_index;
refresh_index++;
}
}
}
free(t_screen);
res = ComboBox_SetCurSel(sizes_control, sizes_selection);
res = ComboBox_SetCurSel(refresh_control, refresh_selection);
}
res++;
return false;
}
/************************************************************
* DataMap initializers
************************************************************/
/* Initialize local helper variables */
static void ResetDataMap(HWND hWnd)
{
char screen_option[32];
snprintf(screen_option, ARRAY_LENGTH(screen_option), "screen%d", GetSelectedScreen(hWnd));
if (pCurrentOpts.value(screen_option) == NULL
|| (core_stricmp(pCurrentOpts.value(screen_option), "") == 0 )
|| (core_stricmp(pCurrentOpts.value(screen_option), "auto") == 0 ) )
{
pCurrentOpts.set_value(screen_option, "auto", OPTION_PRIORITY_CMDLINE);
}
}
/* Build the control mapping by adding all needed information to the DataMap */
static void BuildDataMap(void)
{
properties_datamap = datamap_create();
// core state options
datamap_add(properties_datamap, IDC_ENABLE_AUTOSAVE, DM_BOOL, OPTION_AUTOSAVE);
datamap_add(properties_datamap, IDC_SNAPVIEW, DM_STRING, OPTION_SNAPVIEW);
datamap_add(properties_datamap, IDC_SNAPSIZEWIDTH, DM_STRING, NULL);
datamap_add(properties_datamap, IDC_SNAPSIZEHEIGHT, DM_STRING, NULL);
// core performance options
datamap_add(properties_datamap, IDC_AUTOFRAMESKIP, DM_BOOL, OPTION_AUTOFRAMESKIP);
datamap_add(properties_datamap, IDC_FRAMESKIP, DM_INT, OPTION_FRAMESKIP);
datamap_add(properties_datamap, IDC_SECONDSTORUN, DM_INT, OPTION_SECONDS_TO_RUN);
datamap_add(properties_datamap, IDC_SECONDSTORUNDISP, DM_INT, OPTION_SECONDS_TO_RUN);
datamap_add(properties_datamap, IDC_THROTTLE, DM_BOOL, OPTION_THROTTLE);
datamap_add(properties_datamap, IDC_SLEEP, DM_BOOL, OPTION_SLEEP);
datamap_add(properties_datamap, IDC_SPEED, DM_FLOAT, OPTION_SPEED);
datamap_add(properties_datamap, IDC_SPEEDDISP, DM_FLOAT, OPTION_SPEED);
datamap_add(properties_datamap, IDC_REFRESHSPEED, DM_BOOL, OPTION_REFRESHSPEED);
// core retation options
datamap_add(properties_datamap, IDC_ROTATE, DM_INT, NULL);
// ror, rol, autoror, autorol handled by callback
datamap_add(properties_datamap, IDC_FLIPX, DM_BOOL, OPTION_FLIPX);
datamap_add(properties_datamap, IDC_FLIPY, DM_BOOL, OPTION_FLIPY);
// core artwork options
datamap_add(properties_datamap, IDC_ARTWORK_CROP, DM_BOOL, OPTION_ARTWORK_CROP);
datamap_add(properties_datamap, IDC_BACKDROPS, DM_BOOL, OPTION_USE_BACKDROPS);
datamap_add(properties_datamap, IDC_OVERLAYS, DM_BOOL, OPTION_USE_OVERLAYS);
datamap_add(properties_datamap, IDC_BEZELS, DM_BOOL, OPTION_USE_BEZELS);
datamap_add(properties_datamap, IDC_CPANELS, DM_BOOL, OPTION_USE_CPANELS);
datamap_add(properties_datamap, IDC_MARQUEES, DM_BOOL, OPTION_USE_MARQUEES);
// core screen options
datamap_add(properties_datamap, IDC_BRIGHTCORRECT, DM_FLOAT, OPTION_BRIGHTNESS);
datamap_add(properties_datamap, IDC_BRIGHTCORRECTDISP, DM_FLOAT, OPTION_BRIGHTNESS);
datamap_add(properties_datamap, IDC_CONTRAST, DM_FLOAT, OPTION_CONTRAST);
datamap_add(properties_datamap, IDC_CONTRASTDISP, DM_FLOAT, OPTION_CONTRAST);
datamap_add(properties_datamap, IDC_GAMMA, DM_FLOAT, OPTION_GAMMA);
datamap_add(properties_datamap, IDC_GAMMADISP, DM_FLOAT, OPTION_GAMMA);
datamap_add(properties_datamap, IDC_PAUSEBRIGHT, DM_FLOAT, OPTION_PAUSE_BRIGHTNESS);
datamap_add(properties_datamap, IDC_PAUSEBRIGHTDISP, DM_FLOAT, OPTION_PAUSE_BRIGHTNESS);
datamap_add(properties_datamap, IDC_BURNIN, DM_BOOL, OPTION_BURNIN);
datamap_add(properties_datamap, IDC_SNAPBILINEAR, DM_BOOL, OPTION_SNAPBILINEAR);
// core vector options
datamap_add(properties_datamap, IDC_BEAM_MIN, DM_FLOAT, OPTION_BEAM_WIDTH_MIN);
datamap_add(properties_datamap, IDC_BEAM_MINDISP, DM_FLOAT, OPTION_BEAM_WIDTH_MIN);
datamap_add(properties_datamap, IDC_BEAM_MAX, DM_FLOAT, OPTION_BEAM_WIDTH_MAX);
datamap_add(properties_datamap, IDC_BEAM_MAXDISP, DM_FLOAT, OPTION_BEAM_WIDTH_MAX);
datamap_add(properties_datamap, IDC_BEAM_INTEN, DM_FLOAT, OPTION_BEAM_INTENSITY_WEIGHT);
datamap_add(properties_datamap, IDC_BEAM_INTENDISP, DM_FLOAT, OPTION_BEAM_INTENSITY_WEIGHT);
datamap_add(properties_datamap, IDC_FLICKER, DM_FLOAT, OPTION_FLICKER);
datamap_add(properties_datamap, IDC_FLICKERDISP, DM_FLOAT, OPTION_FLICKER);
// core sound options
datamap_add(properties_datamap, IDC_SAMPLERATE, DM_INT, OPTION_SAMPLERATE);
datamap_add(properties_datamap, IDC_SAMPLES, DM_BOOL, OPTION_SAMPLES);
datamap_add(properties_datamap, IDC_SOUND_MODE, DM_STRING, OSDOPTION_SOUND);
datamap_add(properties_datamap, IDC_VOLUME, DM_INT, OPTION_VOLUME);
datamap_add(properties_datamap, IDC_VOLUMEDISP, DM_INT, OPTION_VOLUME);
// core input options
datamap_add(properties_datamap, IDC_COINLOCKOUT, DM_BOOL, OPTION_COIN_LOCKOUT);
datamap_add(properties_datamap, IDC_DEFAULT_INPUT, DM_STRING, OPTION_CTRLR);
datamap_add(properties_datamap, IDC_USE_MOUSE, DM_BOOL, OPTION_MOUSE);
datamap_add(properties_datamap, IDC_JOYSTICK, DM_BOOL, OPTION_JOYSTICK);
datamap_add(properties_datamap, IDC_LIGHTGUN, DM_BOOL, OPTION_LIGHTGUN);
datamap_add(properties_datamap, IDC_STEADYKEY, DM_BOOL, OPTION_STEADYKEY);
datamap_add(properties_datamap, IDC_MULTIKEYBOARD, DM_BOOL, OPTION_MULTIKEYBOARD);
datamap_add(properties_datamap, IDC_MULTIMOUSE, DM_BOOL, OPTION_MULTIMOUSE);
datamap_add(properties_datamap, IDC_RELOAD, DM_BOOL, OPTION_OFFSCREEN_RELOAD);
datamap_add(properties_datamap, IDC_JDZ, DM_FLOAT, OPTION_JOYSTICK_DEADZONE);
datamap_add(properties_datamap, IDC_JDZDISP, DM_FLOAT, OPTION_JOYSTICK_DEADZONE);
datamap_add(properties_datamap, IDC_JSAT, DM_FLOAT, OPTION_JOYSTICK_SATURATION);
datamap_add(properties_datamap, IDC_JSATDISP, DM_FLOAT, OPTION_JOYSTICK_SATURATION);
datamap_add(properties_datamap, IDC_JOYSTICKMAP, DM_STRING, OPTION_JOYSTICK_MAP);
// core input automatic enable options
datamap_add(properties_datamap, IDC_PADDLE, DM_STRING, OPTION_PADDLE_DEVICE);
datamap_add(properties_datamap, IDC_ADSTICK, DM_STRING, OPTION_ADSTICK_DEVICE);
datamap_add(properties_datamap, IDC_PEDAL, DM_STRING, OPTION_PEDAL_DEVICE);
datamap_add(properties_datamap, IDC_DIAL, DM_STRING, OPTION_DIAL_DEVICE);
datamap_add(properties_datamap, IDC_TRACKBALL, DM_STRING, OPTION_TRACKBALL_DEVICE);
datamap_add(properties_datamap, IDC_LIGHTGUNDEVICE, DM_STRING, OPTION_LIGHTGUN_DEVICE);
datamap_add(properties_datamap, IDC_POSITIONAL, DM_STRING, OPTION_POSITIONAL_DEVICE);
datamap_add(properties_datamap, IDC_MOUSE, DM_STRING, OPTION_MOUSE_DEVICE);
// core debugging options
datamap_add(properties_datamap, IDC_LOG, DM_BOOL, OPTION_LOG);
datamap_add(properties_datamap, IDC_DEBUG, DM_BOOL, OPTION_DEBUG);
datamap_add(properties_datamap, IDC_VERBOSE, DM_BOOL, OPTION_VERBOSE);
datamap_add(properties_datamap, IDC_UPDATEINPAUSE, DM_BOOL, OPTION_UPDATEINPAUSE);
datamap_add(properties_datamap, IDC_DEBUGSCRIPT, DM_STRING, OPTION_DEBUGSCRIPT);
// core misc options
datamap_add(properties_datamap, IDC_BIOS, DM_STRING, OPTION_BIOS);
datamap_add(properties_datamap, IDC_CHEAT, DM_BOOL, OPTION_CHEAT);
datamap_add(properties_datamap, IDC_SKIP_GAME_INFO, DM_BOOL, OPTION_SKIP_GAMEINFO);
datamap_add(properties_datamap, IDC_LANGUAGE, DM_STRING, OPTION_LANGUAGE);
datamap_add(properties_datamap, IDC_LUASCRIPT, DM_STRING, OPTION_AUTOBOOT_SCRIPT);
datamap_add(properties_datamap, IDC_BOOTDELAY, DM_INT, OPTION_AUTOBOOT_DELAY);
datamap_add(properties_datamap, IDC_BOOTDELAYDISP, DM_INT, OPTION_AUTOBOOT_DELAY);
datamap_add(properties_datamap, IDC_PLUGINS, DM_BOOL, OPTION_PLUGINS);
datamap_add(properties_datamap, IDC_PLUGIN, DM_STRING, OPTION_PLUGIN);
datamap_add(properties_datamap, IDC_NVRAM_SAVE, DM_BOOL, OPTION_NVRAM_SAVE);
datamap_add(properties_datamap, IDC_REWIND, DM_BOOL, OPTION_REWIND);
// windows debugging options
datamap_add(properties_datamap, IDC_OSLOG, DM_BOOL, OPTION_OSLOG);
// windows performance options
datamap_add(properties_datamap, IDC_HIGH_PRIORITY, DM_INT, WINOPTION_PRIORITY);
datamap_add(properties_datamap, IDC_HIGH_PRIORITYTXT, DM_INT, WINOPTION_PRIORITY);
// windows video options
datamap_add(properties_datamap, IDC_VIDEO_MODE, DM_STRING, OSDOPTION_VIDEO);
datamap_add(properties_datamap, IDC_NUMSCREENS, DM_INT, OSDOPTION_NUMSCREENS);
datamap_add(properties_datamap, IDC_NUMSCREENSDISP, DM_INT, OSDOPTION_NUMSCREENS);
datamap_add(properties_datamap, IDC_WINDOWED, DM_BOOL, OSDOPTION_WINDOW);
datamap_add(properties_datamap, IDC_MAXIMIZE, DM_BOOL, OSDOPTION_MAXIMIZE);
datamap_add(properties_datamap, IDC_KEEPASPECT, DM_BOOL, OPTION_KEEPASPECT);
datamap_add(properties_datamap, IDC_PRESCALE, DM_INT, OSDOPTION_PRESCALE);
datamap_add(properties_datamap, IDC_PRESCALEDISP, DM_INT, OSDOPTION_PRESCALE);
datamap_add(properties_datamap, IDC_EFFECT, DM_STRING, OPTION_EFFECT);
datamap_add(properties_datamap, IDC_WAITVSYNC, DM_BOOL, OSDOPTION_WAITVSYNC);
datamap_add(properties_datamap, IDC_SYNCREFRESH, DM_BOOL, OSDOPTION_SYNCREFRESH);
// Direct3D specific options
#ifdef D3DVERSION
datamap_add(properties_datamap, IDC_D3D_VERSION, DM_INT, WINOPTION_D3DVERSION);
#endif
datamap_add(properties_datamap, IDC_D3D_FILTER, DM_BOOL, OSDOPTION_FILTER);
// per window video options
datamap_add(properties_datamap, IDC_SCREEN, DM_STRING, NULL);
datamap_add(properties_datamap, IDC_SCREENSELECT, DM_STRING, NULL);
datamap_add(properties_datamap, IDC_VIEW, DM_STRING, NULL);
datamap_add(properties_datamap, IDC_ASPECTRATIOD, DM_STRING, NULL);
datamap_add(properties_datamap, IDC_ASPECTRATION, DM_STRING, NULL);
datamap_add(properties_datamap, IDC_REFRESH, DM_STRING, NULL);
datamap_add(properties_datamap, IDC_SIZES, DM_STRING, NULL);
// full screen options
datamap_add(properties_datamap, IDC_TRIPLE_BUFFER, DM_BOOL, WINOPTION_TRIPLEBUFFER);
datamap_add(properties_datamap, IDC_SWITCHRES, DM_BOOL, OSDOPTION_SWITCHRES);
datamap_add(properties_datamap, IDC_FSBRIGHTNESS, DM_FLOAT, WINOPTION_FULLSCREENBRIGHTNESS);
datamap_add(properties_datamap, IDC_FSBRIGHTNESSDISP, DM_FLOAT, WINOPTION_FULLSCREENBRIGHTNESS);
datamap_add(properties_datamap, IDC_FSCONTRAST, DM_FLOAT, WINOPTION_FULLSCREENCONTRAST);
datamap_add(properties_datamap, IDC_FSCONTRASTDISP, DM_FLOAT, WINOPTION_FULLSCREENCONTRAST);
datamap_add(properties_datamap, IDC_FSGAMMA, DM_FLOAT, WINOPTION_FULLSCREENGAMMA);
datamap_add(properties_datamap, IDC_FSGAMMADISP, DM_FLOAT, WINOPTION_FULLSCREENGAMMA);
// windows sound options
datamap_add(properties_datamap, IDC_AUDIO_LATENCY, DM_INT, OSDOPTION_AUDIO_LATENCY);
datamap_add(properties_datamap, IDC_AUDIO_LATENCY_DISP, DM_INT, OSDOPTION_AUDIO_LATENCY);
// input device options
datamap_add(properties_datamap, IDC_DUAL_LIGHTGUN, DM_BOOL, WINOPTION_DUAL_LIGHTGUN);
// show menu
datamap_add(properties_datamap, IDC_SHOW_MENU, DM_BOOL, WINOPTION_MENU);
// set up callbacks
datamap_set_callback(properties_datamap, IDC_ROTATE, DCT_READ_CONTROL, RotateReadControl);
datamap_set_callback(properties_datamap, IDC_ROTATE, DCT_POPULATE_CONTROL, RotatePopulateControl);
datamap_set_callback(properties_datamap, IDC_SCREEN, DCT_READ_CONTROL, ScreenReadControl);
datamap_set_callback(properties_datamap, IDC_SCREEN, DCT_POPULATE_CONTROL, ScreenPopulateControl);
datamap_set_callback(properties_datamap, IDC_VIEW, DCT_POPULATE_CONTROL, ViewPopulateControl);
datamap_set_callback(properties_datamap, IDC_REFRESH, DCT_READ_CONTROL, ResolutionReadControl);
datamap_set_callback(properties_datamap, IDC_REFRESH, DCT_POPULATE_CONTROL, ResolutionPopulateControl);
datamap_set_callback(properties_datamap, IDC_SIZES, DCT_READ_CONTROL, ResolutionReadControl);
datamap_set_callback(properties_datamap, IDC_SIZES, DCT_POPULATE_CONTROL, ResolutionPopulateControl);
datamap_set_callback(properties_datamap, IDC_DEFAULT_INPUT, DCT_READ_CONTROL, DefaultInputReadControl);
datamap_set_callback(properties_datamap, IDC_DEFAULT_INPUT, DCT_POPULATE_CONTROL, DefaultInputPopulateControl);
datamap_set_callback(properties_datamap, IDC_SNAPVIEW, DCT_POPULATE_CONTROL, SnapViewPopulateControl);
datamap_set_option_name_callback(properties_datamap, IDC_VIEW, ViewSetOptionName);
//missing population of views with per game defined additional views
datamap_set_option_name_callback(properties_datamap, IDC_REFRESH, ResolutionSetOptionName);
datamap_set_option_name_callback(properties_datamap, IDC_SIZES, ResolutionSetOptionName);
// formats
datamap_set_int_format(properties_datamap, IDC_VOLUMEDISP, "%ddB");
datamap_set_int_format(properties_datamap, IDC_AUDIO_LATENCY_DISP, "%d/5");
datamap_set_float_format(properties_datamap, IDC_BEAM_MINDISP, "%3.2f");
datamap_set_float_format(properties_datamap, IDC_BEAM_MAXDISP, "%3.2f");
datamap_set_float_format(properties_datamap, IDC_BEAM_INTENDISP, "%3.2f");
datamap_set_float_format(properties_datamap, IDC_FLICKERDISP, "%3.2f");
datamap_set_float_format(properties_datamap, IDC_GAMMADISP, "%03.2f");
datamap_set_float_format(properties_datamap, IDC_BRIGHTCORRECTDISP, "%03.2f");
datamap_set_float_format(properties_datamap, IDC_CONTRASTDISP, "%03.2f");
datamap_set_float_format(properties_datamap, IDC_PAUSEBRIGHTDISP, "%03.2f");
datamap_set_float_format(properties_datamap, IDC_FSGAMMADISP, "%03.2f");
datamap_set_float_format(properties_datamap, IDC_FSBRIGHTNESSDISP, "%03.2f");
datamap_set_float_format(properties_datamap, IDC_FSCONTRASTDISP, "%03.2f");
datamap_set_float_format(properties_datamap, IDC_JDZDISP, "%03.2f");
datamap_set_float_format(properties_datamap, IDC_JSATDISP, "%03.2f");
datamap_set_float_format(properties_datamap, IDC_SPEEDDISP, "%03.2f");
// trackbar ranges - slider-name,start,end,step
datamap_set_trackbar_range(properties_datamap, IDC_JDZ, 0.00, 1.00, (float)0.05);
datamap_set_trackbar_range(properties_datamap, IDC_JSAT, 0.00, 1.00, (float)0.05);
datamap_set_trackbar_range(properties_datamap, IDC_SPEED, 0.00, 3.00, (float)0.01);
datamap_set_trackbar_range(properties_datamap, IDC_BEAM_MIN, 0.00, 1.00, (float)0.01);
datamap_set_trackbar_range(properties_datamap, IDC_BEAM_MAX, 1.00, 10.00, (float)0.01);
datamap_set_trackbar_range(properties_datamap, IDC_BEAM_INTEN, -10.00, 10.00, (float)0.01);
datamap_set_trackbar_range(properties_datamap, IDC_FLICKER, 0.00, 1.00, (float)0.01);
datamap_set_trackbar_range(properties_datamap, IDC_AUDIO_LATENCY, 1, 5, 1);
datamap_set_trackbar_range(properties_datamap, IDC_VOLUME, -32, 0, 1);
datamap_set_trackbar_range(properties_datamap, IDC_SECONDSTORUN, 0, 60, 1);
datamap_set_trackbar_range(properties_datamap, IDC_NUMSCREENS, 1, 4, 1);
datamap_set_trackbar_range(properties_datamap, IDC_PRESCALE, 1, 3, 1);
datamap_set_trackbar_range(properties_datamap, IDC_FSGAMMA, 0.0, 3.0, (float)0.1);
datamap_set_trackbar_range(properties_datamap, IDC_FSBRIGHTNESS, 0.00, 2.0, (float)0.1);
datamap_set_trackbar_range(properties_datamap, IDC_FSCONTRAST, 0.0, 2.0, (float)0.1);
datamap_set_trackbar_range(properties_datamap, IDC_GAMMA, 0.0, 3.0, (float)0.1);
datamap_set_trackbar_range(properties_datamap, IDC_BRIGHTCORRECT, 0.00, 2.0, (float)0.1);
datamap_set_trackbar_range(properties_datamap, IDC_CONTRAST, 0.0, 2.0, (float)0.1);
datamap_set_trackbar_range(properties_datamap, IDC_PAUSEBRIGHT, 0.00, 1.00, (float)0.05);
datamap_set_trackbar_range(properties_datamap, IDC_BOOTDELAY, 0, 5, 1);
#ifdef MESS
// MESS specific stuff
datamap_add(properties_datamap, IDC_DIR_LIST, DM_STRING, NULL);
datamap_add(properties_datamap, IDC_RAM_COMBOBOX, DM_INT, OPTION_RAMSIZE);
// set up callbacks
datamap_set_callback(properties_datamap, IDC_DIR_LIST, DCT_READ_CONTROL, DirListReadControl);
datamap_set_callback(properties_datamap, IDC_DIR_LIST, DCT_POPULATE_CONTROL, DirListPopulateControl);
datamap_set_callback(properties_datamap, IDC_RAM_COMBOBOX, DCT_POPULATE_CONTROL, RamPopulateControl);
#endif
}
static void SetSamplesEnabled(HWND hWnd, int nIndex, BOOL bSoundEnabled)
{
BOOL enabled = false;
HWND hCtrl = GetDlgItem(hWnd, IDC_SAMPLES);
if (hCtrl)
{
if ( nIndex > -1 )
{
machine_config config(driver_list::driver(nIndex),pCurrentOpts);
for (device_sound_interface &sound : sound_interface_iterator(config.root_device()))
if (sound.device().type() == SAMPLES)
enabled = true;
}
enabled = enabled && bSoundEnabled;
EnableWindow(hCtrl, enabled);
}
}
/* Moved here cause it's called in a few places */
static void InitializeOptions(HWND hDlg)
{
// from FX
// InitializeSampleRateUI(hDlg);
InitializeSoundUI(hDlg);
// InitializeSoundModeUI(hDlg);
InitializeSkippingUI(hDlg);
InitializeRotateUI(hDlg);
InitializeSelectScreenUI(hDlg);
InitializeBIOSUI(hDlg);
InitializeControllerMappingUI(hDlg);
InitializeVideoUI(hDlg);
// InitializeSnapViewUI(hDlg);
// InitializeSnapNameUI(hDlg);
InitializeLanguageUI(hDlg);
InitializePluginsUI(hDlg);
// InitializeGLSLFilterUI(hDlg);
#ifdef D3DVERSION
InitializeD3DVersionUI(hDlg);
#endif
}
/* Moved here because it is called in several places */
static void InitializeMisc(HWND hDlg)
{
Button_Enable(GetDlgItem(hDlg, IDC_JOYSTICK), DIJoystick.Available());
}
static void OptOnHScroll(HWND hwnd, HWND hwndCtl, UINT code, int pos)
{
if (hwndCtl == GetDlgItem(hwnd, IDC_NUMSCREENS))
NumScreensSelectionChange(hwnd);
}
/* Handle changes to the Numscreens slider */
static void NumScreensSelectionChange(HWND hwnd)
{
//Also Update the ScreenSelect Combo with the new number of screens
UpdateSelectScreenUI(hwnd );
}
/* Handle changes to the Refresh drop down */
static void RefreshSelectionChange(HWND hWnd, HWND hWndCtrl)
{
int nCurSelection = ComboBox_GetCurSel(hWndCtrl);
if (nCurSelection != CB_ERR)
{
datamap_read_control(properties_datamap, hWnd, pCurrentOpts, IDC_SIZES);
datamap_populate_control(properties_datamap, hWnd, pCurrentOpts, IDC_SIZES);
}
}
/* Initialize the sound options */
static void InitializeSoundUI(HWND hwnd)
{
int res = 0, i;
HWND hCtrl = GetDlgItem(hwnd, IDC_SOUND_MODE);
if (hCtrl)
{
for (i = 0; i < NUMSOUND; i++)
{
res = ComboBox_InsertString(hCtrl, i, g_ComboBoxSound[i].m_pText);
res = ComboBox_SetItemData( hCtrl, i, g_ComboBoxSound[i].m_pData);
}
}
i = 0;
hCtrl = GetDlgItem(hwnd, IDC_SAMPLERATE);
if (hCtrl)
{
res = ComboBox_AddString(hCtrl, TEXT("11025"));
res = ComboBox_SetItemData(hCtrl, i++, 11025);
res = ComboBox_AddString(hCtrl, TEXT("22050"));
res = ComboBox_SetItemData(hCtrl, i++, 22050);
res = ComboBox_AddString(hCtrl, TEXT("44100"));
res = ComboBox_SetItemData(hCtrl, i++, 44100);
res = ComboBox_AddString(hCtrl, TEXT("48000"));
res = ComboBox_SetItemData(hCtrl, i++, 48000);
res = ComboBox_SetCurSel(hCtrl, 1);
}
res++;
}
/* Populate the Frame Skipping drop down */
static void InitializeSkippingUI(HWND hwnd)
{
HWND hCtrl = GetDlgItem(hwnd, IDC_FRAMESKIP);
int res = 0, i = 0;
if (hCtrl)
{
res = ComboBox_AddString(hCtrl, TEXT("Draw every frame"));
res = ComboBox_SetItemData(hCtrl, i++, 0);
res = ComboBox_AddString(hCtrl, TEXT("Skip 1 frame"));
res = ComboBox_SetItemData(hCtrl, i++, 1);
res = ComboBox_AddString(hCtrl, TEXT("Skip 2 frames"));
res = ComboBox_SetItemData(hCtrl, i++, 2);
res = ComboBox_AddString(hCtrl, TEXT("Skip 3 frames"));
res = ComboBox_SetItemData(hCtrl, i++, 3);
res = ComboBox_AddString(hCtrl, TEXT("Skip 4 frames"));
res = ComboBox_SetItemData(hCtrl, i++, 4);
res = ComboBox_AddString(hCtrl, TEXT("Skip 5 frames"));
res = ComboBox_SetItemData(hCtrl, i++, 5);
res = ComboBox_AddString(hCtrl, TEXT("Skip 6 frames"));
res = ComboBox_SetItemData(hCtrl, i++, 6);
res = ComboBox_AddString(hCtrl, TEXT("Skip 7 frames"));
res = ComboBox_SetItemData(hCtrl, i++, 7);
res = ComboBox_AddString(hCtrl, TEXT("Skip 8 frames"));
res = ComboBox_SetItemData(hCtrl, i++, 8);
res = ComboBox_AddString(hCtrl, TEXT("Skip 9 frames"));
res = ComboBox_SetItemData(hCtrl, i++, 9);
res = ComboBox_AddString(hCtrl, TEXT("Skip 10 frames"));
res = ComboBox_SetItemData(hCtrl, i++, 10);
}
res++;
}
/* Populate the Rotate drop down */
static void InitializeRotateUI(HWND hwnd)
{
HWND hCtrl = GetDlgItem(hwnd, IDC_ROTATE);
int res = 0;
if (hCtrl)
{
res = ComboBox_AddString(hCtrl, TEXT("Default")); // 0
res = ComboBox_AddString(hCtrl, TEXT("Clockwise")); // 1
res = ComboBox_AddString(hCtrl, TEXT("Anti-clockwise")); // 2
res = ComboBox_AddString(hCtrl, TEXT("None")); // 3
res = ComboBox_AddString(hCtrl, TEXT("Auto clockwise")); // 4
res = ComboBox_AddString(hCtrl, TEXT("Auto anti-clockwise")); // 5
}
res++;
}
/* Populate the Video Mode drop down */
static void InitializeVideoUI(HWND hwnd)
{
int res = 0;
HWND hCtrl = GetDlgItem(hwnd, IDC_VIDEO_MODE);
if (hCtrl)
{
for (int i = 0; i < NUMVIDEO; i++)
{
res = ComboBox_InsertString(hCtrl, i, g_ComboBoxVideo[i].m_pText);
res = ComboBox_SetItemData( hCtrl, i, g_ComboBoxVideo[i].m_pData);
}
}
res++;
}
#ifdef D3DVERSION
/* Populate the D3D Version drop down */
static void InitializeD3DVersionUI(HWND hwnd)
{
HWND hCtrl = GetDlgItem(hwnd, IDC_D3D_VERSION);
int res = 0;
if (hCtrl)
{
for (int i = 0; i < NUMD3DVERSIONS; i++)
{
res = ComboBox_InsertString(hCtrl, i, g_ComboBoxD3DVersion[i].m_pText);
res = ComboBox_SetItemData( hCtrl, i, g_ComboBoxD3DVersion[i].m_pData);
}
}
res++;
}
#endif
static void UpdateSelectScreenUI(HWND hwnd)
{
int res = 0, i, curSel;
HWND hCtrl = GetDlgItem(hwnd, IDC_SCREENSELECT);
if (hCtrl)
{
curSel = ComboBox_GetCurSel(hCtrl);
if ((curSel < 0) || (curSel >= NUMSELECTSCREEN))
curSel = 0;
res = ComboBox_ResetContent(hCtrl);
for (i = 0; i < NUMSELECTSCREEN && i < pCurrentOpts.int_value(OSDOPTION_NUMSCREENS) ; i++)
{
res = ComboBox_InsertString(hCtrl, i, g_ComboBoxSelectScreen[i].m_pText);
res = ComboBox_SetItemData( hCtrl, i, g_ComboBoxSelectScreen[i].m_pData);
}
// Smaller Amount of screens was selected, so use 0
if( i < curSel )
res = ComboBox_SetCurSel(hCtrl, 0);
else
res = ComboBox_SetCurSel(hCtrl, curSel);
}
res++;
}
/* Populate the Select Screen drop down */
static void InitializeSelectScreenUI(HWND hwnd)
{
UpdateSelectScreenUI(hwnd);
}
static void InitializeControllerMappingUI(HWND hwnd)
{
int res = 0;
HWND hCtrl = GetDlgItem(hwnd,IDC_PADDLE);
HWND hCtrl1 = GetDlgItem(hwnd,IDC_ADSTICK);
HWND hCtrl2 = GetDlgItem(hwnd,IDC_PEDAL);
HWND hCtrl3 = GetDlgItem(hwnd,IDC_MOUSE);
HWND hCtrl4 = GetDlgItem(hwnd,IDC_DIAL);
HWND hCtrl5 = GetDlgItem(hwnd,IDC_TRACKBALL);
HWND hCtrl6 = GetDlgItem(hwnd,IDC_LIGHTGUNDEVICE);
HWND hCtrl7 = GetDlgItem(hwnd,IDC_POSITIONAL);
for (int i = 0; i < NUMDEVICES; i++)
{
if (hCtrl)
{
res = ComboBox_InsertString(hCtrl, i, g_ComboBoxDevice[i].m_pText);
res = ComboBox_SetItemData( hCtrl, i, g_ComboBoxDevice[i].m_pData);
}
if (hCtrl1)
{
res = ComboBox_InsertString(hCtrl1, i, g_ComboBoxDevice[i].m_pText);
res = ComboBox_SetItemData( hCtrl1, i, g_ComboBoxDevice[i].m_pData);
}
if (hCtrl2)
{
res = ComboBox_InsertString(hCtrl2, i, g_ComboBoxDevice[i].m_pText);
res = ComboBox_SetItemData( hCtrl2, i, g_ComboBoxDevice[i].m_pData);
}
if (hCtrl3)
{
res = ComboBox_InsertString(hCtrl3, i, g_ComboBoxDevice[i].m_pText);
res = ComboBox_SetItemData( hCtrl3, i, g_ComboBoxDevice[i].m_pData);
}
if (hCtrl4)
{
res = ComboBox_InsertString(hCtrl4, i, g_ComboBoxDevice[i].m_pText);
res = ComboBox_SetItemData( hCtrl4, i, g_ComboBoxDevice[i].m_pData);
}
if (hCtrl5)
{
res = ComboBox_InsertString(hCtrl5, i, g_ComboBoxDevice[i].m_pText);
res = ComboBox_SetItemData( hCtrl5, i, g_ComboBoxDevice[i].m_pData);
}
if (hCtrl6)
{
res = ComboBox_InsertString(hCtrl6, i, g_ComboBoxDevice[i].m_pText);
res = ComboBox_SetItemData( hCtrl6, i, g_ComboBoxDevice[i].m_pData);
}
if (hCtrl7)
{
res = ComboBox_InsertString(hCtrl7, i, g_ComboBoxDevice[i].m_pText);
res = ComboBox_SetItemData( hCtrl7, i, g_ComboBoxDevice[i].m_pData);
}
}
res++;
}
static void InitializeBIOSUI(HWND hwnd)
{
HWND hCtrl = GetDlgItem(hwnd,IDC_BIOS);
int res = 0, i = 0;
TCHAR* t_s;
if (hCtrl)
{
const game_driver *gamedrv = &driver_list::driver(g_nGame);
const rom_entry *rom;
if (g_nGame == GLOBAL_OPTIONS)
{
res = ComboBox_InsertString(hCtrl, i, TEXT("None"));
res = ComboBox_SetItemData( hCtrl, i++, "");
return;
}
if (g_nGame == LOCAL_OPTIONS) //Folder Options: This is the only place that LOCAL_OPTIONS is used, is this code ever executed?
{
gamedrv = &driver_list::driver(g_nFolderGame);
if (DriverHasOptionalBIOS(g_nFolderGame) == false)
{
res = ComboBox_InsertString(hCtrl, i, TEXT("None"));
res = ComboBox_SetItemData( hCtrl, i++, "");
return;
}
res = ComboBox_InsertString(hCtrl, i, TEXT("Default"));
res = ComboBox_SetItemData( hCtrl, i++, "");
if (gamedrv->rom)
{
auto rom_entries = rom_build_entries(gamedrv->rom);
for (rom = rom_entries.data(); !ROMENTRY_ISEND(rom); rom++)
{
if (ROMENTRY_ISSYSTEM_BIOS(rom))
{
const char *name = ROM_GETHASHDATA(rom);
const char *biosname = ROM_GETNAME(rom);
t_s = ui_wstring_from_utf8(name);
if( !t_s )
return;
res = ComboBox_InsertString(hCtrl, i, win_tstring_strdup(t_s));
res = ComboBox_SetItemData( hCtrl, i++, biosname);
free(t_s);
}
}
}
return;
}
if (DriverHasOptionalBIOS(g_nGame) == false)
{
res = ComboBox_InsertString(hCtrl, i, TEXT("None"));
res = ComboBox_SetItemData( hCtrl, i++, "");
return;
}
res = ComboBox_InsertString(hCtrl, i, TEXT("Default"));
res = ComboBox_SetItemData( hCtrl, i++, "");
if (gamedrv->rom)
{
auto rom_entries = rom_build_entries(gamedrv->rom);
for (rom = rom_entries.data(); !ROMENTRY_ISEND(rom); rom++)
{
if (ROMENTRY_ISSYSTEM_BIOS(rom))
{
const char *name = ROM_GETHASHDATA(rom);
const char *biosname = ROM_GETNAME(rom);
t_s = ui_wstring_from_utf8(name);
if( !t_s )
return;
res = ComboBox_InsertString(hCtrl, i, win_tstring_strdup(t_s));
res = ComboBox_SetItemData( hCtrl, i++, biosname);
free(t_s);
}
}
}
}
res++;
}
static void InitializeLanguageUI(HWND hWnd)
{
HWND hCtrl = GetDlgItem(hWnd, IDC_LANGUAGE);
if (hCtrl)
{
int count = 0;
string t1 = GetLangDir();
const char* t2 = t1.c_str();
osd::directory::ptr directory = osd::directory::open(t2);
if (directory == nullptr)
return;
for (const osd::directory::entry *entry = directory->read(); entry; entry = directory->read())
{
if (entry->type == osd::directory::entry::entry_type::DIR)
{
string name = entry->name;
if (!(name == "." || name == ".."))
{
char *value = strdup(entry->name);
wchar_t *text = ui_wstring_from_utf8(entry->name);
(void)ComboBox_InsertString(hCtrl, count, text);
(void)ComboBox_SetItemData(hCtrl, count, value);
count++;
free(text);
free(value);
}
}
}
directory.reset();
}
}
static void InitializePluginsUI(HWND hWnd)
{
HWND hCtrl = GetDlgItem(hWnd, IDC_SELECT_PLUGIN);
if (hCtrl)
{
string t1 = GetPluginsDir();
const char* t2 = t1.c_str();
osd::directory::ptr directory = osd::directory::open(t2);
if (directory == nullptr)
return;
TCHAR* t_s;
int count = 0;
for (const osd::directory::entry *entry = directory->read(); entry; entry = directory->read())
{
if (entry->type == osd::directory::entry::entry_type::DIR)
{
string name = entry->name;
if (!(name == "." || name == ".." || name == "json"))
{
plugin_names[count] = name;
const char* label = name.c_str();
t_s = ui_wstring_from_utf8(label);
label = 0;
if( !t_s )
return;
if (ComboBox_InsertString(hCtrl, count++, win_tstring_strdup(t_s)) == CB_ERR)
return;
free(t_s);
}
}
}
directory.reset();
}
(void)ComboBox_SetCurSel(hCtrl, -1);
(void)ComboBox_SetCueBannerText(hCtrl, TEXT("Select a plugin"));
}
#if 0
static void InitializeGLSLFilterUI(HWND hWnd)
{
HWND hCtrl = GetDlgItem(hWnd, IDC_GLSLFILTER);
if (hCtrl)
{
for (int i = 0; i < NUMGLSLFILTER; i++)
{
(void)ComboBox_InsertString(hCtrl, i, g_ComboBoxGLSLFilter[i].m_pText);
(void)ComboBox_SetItemData(hCtrl, i, g_ComboBoxGLSLFilter[i].m_pData);
}
}
}
#endif
static BOOL SelectEffect(HWND hWnd)
{
char filename[MAX_PATH];
BOOL changed = false;
*filename = 0;
if (CommonFileDialog(GetOpenFileName, filename, FILETYPE_EFFECT_FILES))
{
//strip Path and extension
char buff[MAX_PATH];
int i, j = 0, k = 0, l = 0;
for(i=0; i<strlen(filename); i++ )
{
if( filename[i] == '\\' )
j = i;
if( filename[i] == '.' )
k = i;
}
for(i=j+1; i<k; i++)
buff[l++] = filename[i];
buff[l] = '\0';
if (strcmp(buff, pCurrentOpts.value(OPTION_EFFECT))!=0)
{
HWND control = GetDlgItem(hWnd, IDC_EFFECT);
pCurrentOpts.set_value(OPTION_EFFECT, buff, OPTION_PRIORITY_CMDLINE);
win_set_window_text_utf8(control, buff);
// datamap_populate_control(properties_datamap, hWnd, pCurrentOpts, IDC_EFFECT);
changed = true;
}
}
return changed;
}
static BOOL ResetEffect(HWND hWnd)
{
BOOL changed = false;
const char *new_value = "none";
if (strcmp(new_value, pCurrentOpts.value(OPTION_EFFECT))!=0)
{
HWND control = GetDlgItem(hWnd, IDC_EFFECT);
pCurrentOpts.set_value(OPTION_EFFECT, new_value, OPTION_PRIORITY_CMDLINE);
win_set_window_text_utf8(control, new_value);
// datamap_populate_control(properties_datamap, hWnd, pCurrentOpts, IDC_EFFECT);
changed = true;
}
return changed;
}
static BOOL SelectJoystickMap(HWND hWnd)
{
char filename[MAX_PATH];
BOOL changed = false;
*filename = 0;
if (CommonFileDialog(GetOpenFileName, filename, FILETYPE_JOYMAP_FILES))
{
if (strcmp(filename, pCurrentOpts.value(OPTION_JOYSTICK_MAP))!=0)
{
HWND control = GetDlgItem(hWnd, IDC_JOYSTICKMAP);
pCurrentOpts.set_value(OPTION_JOYSTICK_MAP, filename, OPTION_PRIORITY_CMDLINE);
win_set_window_text_utf8(control, filename);
changed = true;
}
}
return changed;
}
static BOOL ResetJoystickMap(HWND hWnd)
{
BOOL changed = false;
const char *new_value = "auto";
if (strcmp(new_value, pCurrentOpts.value(OPTION_JOYSTICK_MAP))!=0)
{
HWND control = GetDlgItem(hWnd, IDC_JOYSTICKMAP);
pCurrentOpts.set_value(OPTION_JOYSTICK_MAP, new_value, OPTION_PRIORITY_CMDLINE);
win_set_window_text_utf8(control, new_value);
changed = true;
}
return changed;
}
static bool SelectLUAScript(HWND hWnd)
{
char filename[MAX_PATH];
bool changed = false;
*filename = 0;
if (CommonFileDialog(GetOpenFileName, filename, FILETYPE_LUASCRIPT_FILES))
{
char option[MAX_PATH];
char script[MAX_PATH];
wchar_t *t_filename = ui_wstring_from_utf8(filename);
wchar_t *tempname = PathFindFileName(t_filename);
char *optvalue = ui_utf8_from_wstring(tempname);
strcpy(script, optvalue);
PathRemoveExtension(tempname);
char *optname = ui_utf8_from_wstring(tempname);
strcpy(option, optname);
free(t_filename);
free(optname);
free(optvalue);
if (strcmp(script, pCurrentOpts.value(OPTION_AUTOBOOT_SCRIPT)))
{
pCurrentOpts.set_value(OPTION_AUTOBOOT_SCRIPT, script, OPTION_PRIORITY_CMDLINE);
win_set_window_text_utf8(GetDlgItem(hWnd, IDC_LUASCRIPT), option);
changed = true;
}
}
return changed;
}
static bool ResetLUAScript(HWND hWnd)
{
bool changed = false;
const char *new_value = "";
if (strcmp(new_value, pCurrentOpts.value(OPTION_AUTOBOOT_SCRIPT)))
{
pCurrentOpts.set_value(OPTION_AUTOBOOT_SCRIPT, new_value, OPTION_PRIORITY_CMDLINE);
win_set_window_text_utf8(GetDlgItem(hWnd, IDC_LUASCRIPT), "None");
changed = true;
}
return changed;
}
static bool SelectPlugins(HWND hWnd)
{
bool changed = false;
bool already_enabled = false;
HWND hcontrol = GetDlgItem(hWnd, IDC_SELECT_PLUGIN);
if (!hcontrol)
return changed;
int index = ComboBox_GetCurSel(hcontrol);
if (index == CB_ERR)
return changed;
const char *new_value = plugin_names[index].c_str();
string t1 = GetPlugins();
const char* value = t1.c_str();
char *token = NULL;
char buffer[990]; // hold all plugins
char plugins[24][32]; // number of possible plugins, max length of name
int num_plugins = 0;
strcpy(buffer, value);
token = strtok(buffer, ",");
if (token == NULL)
{
strcpy(plugins[num_plugins], buffer);
}
else
{
while (token != NULL)
{
strcpy(plugins[num_plugins], token);
num_plugins++;
token = strtok(NULL, ",");
}
}
if (strcmp(value, "") == 0)
{
pCurrentOpts.set_value(OPTION_PLUGIN, new_value, OPTION_PRIORITY_CMDLINE);
win_set_window_text_utf8(GetDlgItem(hWnd, IDC_PLUGIN), new_value);
changed = true;
(void)ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_SELECT_PLUGIN), -1);
return changed;
}
for (int i = 0; i < num_plugins; i++)
{
if (strcmp(new_value, plugins[i]) == 0)
{
already_enabled = true;
break;
}
}
if (!already_enabled)
{
char new_option[256];
snprintf(new_option, WINUI_ARRAY_LENGTH(new_option), "%s,%s", value, new_value);
pCurrentOpts.set_value(OPTION_PLUGIN, new_option, OPTION_PRIORITY_CMDLINE);
win_set_window_text_utf8(GetDlgItem(hWnd, IDC_PLUGIN), new_option);
changed = true;
}
(void)ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_SELECT_PLUGIN), -1);
return changed;
}
static bool ResetPlugins(HWND hWnd)
{
bool changed = false;
pCurrentOpts.set_value(OPTION_PLUGIN, "", OPTION_PRIORITY_CMDLINE);
win_set_window_text_utf8(GetDlgItem(hWnd, IDC_PLUGIN), "None");
changed = true;
(void)ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_SELECT_PLUGIN), -1);
return changed;
}
static BOOL SelectDebugscript(HWND hWnd)
{
char filename[MAX_PATH];
BOOL changed = false;
*filename = 0;
if (CommonFileDialog(GetOpenFileName, filename, FILETYPE_DEBUGSCRIPT_FILES))
{
if (strcmp(filename, pCurrentOpts.value(OPTION_DEBUGSCRIPT))!=0)
{
HWND control = GetDlgItem(hWnd, IDC_DEBUGSCRIPT);
pCurrentOpts.set_value(OPTION_DEBUGSCRIPT, filename, OPTION_PRIORITY_CMDLINE);
win_set_window_text_utf8(control, filename);
changed = true;
}
}
return changed;
}
static BOOL ResetDebugscript(HWND hWnd)
{
BOOL changed = false;
const char *new_value = "";
if (strcmp(new_value, pCurrentOpts.value(OPTION_DEBUGSCRIPT))!=0)
{
HWND control = GetDlgItem(hWnd, IDC_DEBUGSCRIPT);
pCurrentOpts.set_value(OPTION_DEBUGSCRIPT, new_value, OPTION_PRIORITY_CMDLINE);
win_set_window_text_utf8(control, new_value);
changed = true;
}
return changed;
}
void UpdateBackgroundBrush(HWND hwndTab)
{
// Destroy old brush
if (hBkBrush)
DeleteBrush(hBkBrush);
hBkBrush = NULL;
// Only do this if the theme is active
if (SafeIsAppThemed())
{
// Get tab control dimensions
RECT rc;
GetWindowRect( hwndTab, &rc);
// Get the tab control DC
HDC hDC = GetDC(hwndTab);
// Create a compatible DC
HDC hDCMem = CreateCompatibleDC(hDC);
HBITMAP hBmp = CreateCompatibleBitmap(hDC, rc.right - rc.left, rc.bottom - rc.top);
HBITMAP hBmpOld = (HBITMAP)(SelectObject(hDCMem, hBmp));
// Tell the tab control to paint in our DC
SendMessage(hwndTab, WM_PRINTCLIENT, (WPARAM)(hDCMem), (LPARAM)(PRF_ERASEBKGND | PRF_CLIENT | PRF_NONCLIENT));
// Create a pattern brush from the bitmap selected in our DC
hBkBrush = CreatePatternBrush(hBmp);
// Restore the bitmap
SelectObject(hDCMem, hBmpOld);
// Cleanup
DeleteBitmap(hBmp);
DeleteDC(hDCMem);
ReleaseDC(hwndTab, hDC);
}
}
// from propertiesms.cpp (MESSUI)
//============================================================
#ifdef MESS
//============================================================
// DATAMAP HANDLERS FOR MESS
//============================================================
static void AppendList(HWND hList, LPCTSTR lpItem, int nItem)
{
LV_ITEM Item;
memset(&Item, 0, sizeof(LV_ITEM));
Item.mask = LVIF_TEXT;
Item.pszText = (LPTSTR) lpItem;
Item.iItem = nItem;
HRESULT res = ListView_InsertItem(hList, &Item);
res++;
}
static BOOL DirListReadControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
int directory_count;
LV_ITEM lvi;
TCHAR buffer[2048];
int pos = 0;
BOOL res;
// determine the directory count; note that one item is the "< >" entry
directory_count = ListView_GetItemCount(control);
if (directory_count > 0)
directory_count--;
buffer[0] = '\0';
for (int i = 0; i < directory_count; i++)
{
// append a semicolon, if we're past the first entry
if (i > 0)
pos += _sntprintf(&buffer[pos], ARRAY_LENGTH(buffer) - pos, TEXT(";"));
// retrieve the next entry
memset(&lvi, '\0', sizeof(lvi));
lvi.mask = LVIF_TEXT;
lvi.iItem = i;
lvi.pszText = &buffer[pos];
lvi.cchTextMax = ARRAY_LENGTH(buffer) - pos;
res = ListView_GetItem(control, &lvi);
// advance the position
pos += _tcslen(&buffer[pos]);
}
char* paths = ui_utf8_from_wstring(buffer);
if ((buffer[1] == 0x3A) || (buffer[0] == 0)) // must be a folder or null
pCurrentOpts.set_value(OPTION_SWPATH, paths, OPTION_PRIORITY_CMDLINE);
free (paths);
res++;
return true;
}
static BOOL DirListPopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
int new_pos = 0;
// access the directory list, and convert to TCHARs
int driver_index = PropertiesCurrentGame(dialog);
windows_options o;
load_options(o, OPTIONS_GAME, driver_index, 0);
const char* paths = o.value(OPTION_SWPATH);
TCHAR* t_dir_list = ui_wstring_from_utf8(paths);
paths = 0;
if (!t_dir_list)
return false;
// delete all items in the list control
BOOL b_res = ListView_DeleteAllItems(control);
// add the column
RECT r;
GetClientRect(control, &r);
LV_COLUMN lvc;
memset(&lvc, 0, sizeof(LVCOLUMN));
lvc.mask = LVCF_WIDTH;
lvc.cx = r.right - r.left - GetSystemMetrics(SM_CXHSCROLL);
HRESULT res = ListView_InsertColumn(control, 0, &lvc);
// add each of the directories
int pos = 0;
int current_item = 0;
while(t_dir_list[pos] != '\0')
{
// parse off this item
TCHAR *s = _tcschr(&t_dir_list[pos], ';');
if (s)
{
*s = '\0';
new_pos = s - t_dir_list + 1;
}
else
new_pos = pos + _tcslen(&t_dir_list[pos]);
// append this item
AppendList(control, &t_dir_list[pos], current_item);
// advance to next item
pos = new_pos;
current_item++;
}
// finish up
AppendList(control, TEXT(DIRLIST_NEWENTRYTEXT), current_item);
ListView_SetItemState(control, 0, LVIS_SELECTED, LVIS_SELECTED);
free(t_dir_list);
res++;
b_res++;
return true;
}
static const char *messram_string(char *buffer, UINT32 ram)
{
const char *suffix;
if ((ram % (1024*1024)) == 0)
{
ram /= 1024*1024;
suffix = "MB";
}
else if ((ram % 1024) == 0)
{
ram /= 1024;
suffix = "KB";
}
else
suffix = "";
sprintf(buffer, "%u%s", ram, suffix);
return buffer;
}
//-------------------------------------------------
// parse_string - convert a ram string to an
// integer value
//-------------------------------------------------
static uint32_t parse_string(const char *s)
{
static const struct
{
const char *suffix;
unsigned multiple;
} s_suffixes[] =
{
{ "", 1 },
{ "k", 1024 },
{ "kb", 1024 },
{ "kib", 1024 },
{ "m", 1024 * 1024 },
{ "mb", 1024 * 1024 },
{ "mib", 1024 * 1024 }
};
// parse the string
unsigned ram = 0;
char suffix[8] = { 0, };
sscanf(s, "%u%7s", &ram, suffix);
// perform the lookup
auto iter = std::find_if(std::begin(s_suffixes), std::end(s_suffixes), [&suffix](const auto &potential_suffix)
{ return !core_stricmp(suffix, potential_suffix.suffix); } );
// identify the multiplier (or 0 if not recognized, signalling a parse failure)
unsigned multiple = iter != std::end(s_suffixes) ? iter->multiple : 0;
// return the result
return ram * multiple;
}
static BOOL RamPopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
int i = 0, current_index = 0;
// identify the driver
int driver_index = PropertiesCurrentGame(dialog);
const game_driver *gamedrv = &driver_list::driver(driver_index);
// clear out the combo box
int res = ComboBox_ResetContent(control);
// allocate the machine config
machine_config cfg(*gamedrv,*opts);
// identify how many options that we have
ram_device_iterator iter(cfg.root_device());
ram_device *device = iter.first();
EnableWindow(control, (device != NULL));
// we can only do something meaningful if there is more than one option
if (device)
{
const ram_device *ramdev = dynamic_cast<const ram_device *>(device);
// identify the current amount of RAM
const char *this_ram_string = opts->value(OPTION_RAMSIZE);
uint32_t current_ram = (this_ram_string) ? parse_string(this_ram_string) : 0;
uint32_t ram = ramdev->default_size();
if (current_ram == 0)
current_ram = ram;
char ramtext[20];
messram_string(ramtext, ram);
TCHAR *t_ramstring = ui_wstring_from_utf8(ramtext);
if( !t_ramstring )
return false;
res = ComboBox_InsertString(control, i, win_tstring_strdup(t_ramstring));
res = ComboBox_SetItemData(control, i, ram);
if (!ramdev->extra_options().empty())
{
/* try to parse each option */
for (ram_device::extra_option const &option : ramdev->extra_options())
{
// identify this option
t_ramstring = ui_wstring_from_utf8(option.first.c_str());
if( t_ramstring )
{
i++;
// add this option to the combo box
res = ComboBox_InsertString(control, i, win_tstring_strdup(t_ramstring));
res = ComboBox_SetItemData(control, i, option.second);
// is this the current option? record the index if so
if (option.second == current_ram)
current_index = i;
}
}
}
if (t_ramstring)
free (t_ramstring);
// set the combo box
res = ComboBox_SetCurSel(control, current_index);
}
res++;
return true;
}
static void MarkChanged(HWND hDlg)
{
/* fake a CBN_SELCHANGE event from IDC_SIZES to force it to be changed */
HWND hCtrl = GetDlgItem(hDlg, IDC_SIZES);
PostMessage(hDlg, WM_COMMAND, (CBN_SELCHANGE << 16) | IDC_SIZES, (LPARAM) hCtrl);
}
static BOOL SoftwareDirectories_OnInsertBrowse(HWND hDlg, BOOL bBrowse, LPCTSTR lpItem)
{
TCHAR inbuf[MAX_PATH];
TCHAR outbuf[MAX_PATH];
LPTSTR lpIn;
BOOL res = false;
g_bModifiedSoftwarePaths = true;
HWND hList = GetDlgItem(hDlg, IDC_DIR_LIST);
int nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED);
if (nItem == -1)
return false;
/* Last item is placeholder for append */
if (nItem == ListView_GetItemCount(hList) - 1)
bBrowse = false;
if (!lpItem)
{
if (bBrowse)
{
ListView_GetItemText(hList, nItem, 0, inbuf, ARRAY_LENGTH(inbuf));
lpIn = inbuf;
}
else
lpIn = NULL;
if (!BrowseForDirectory(hDlg, lpIn, outbuf))
return false;
lpItem = outbuf;
}
AppendList(hList, lpItem, nItem);
if (bBrowse)
res = ListView_DeleteItem(hList, nItem+1);
MarkChanged(hDlg);
res++;
return true;
}
static BOOL SoftwareDirectories_OnDelete(HWND hDlg)
{
int nSelect = 0;
HWND hList = GetDlgItem(hDlg, IDC_DIR_LIST);
g_bModifiedSoftwarePaths = true;
int nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED | LVNI_ALL);
if (nItem == -1)
return false;
/* Don't delete "Append" placeholder. */
if (nItem == ListView_GetItemCount(hList) - 1)
return false;
BOOL res = ListView_DeleteItem(hList, nItem);
int nCount = ListView_GetItemCount(hList);
if (nCount <= 1)
return false;
/* If the last item was removed, select the item above. */
if (nItem == nCount - 1)
nSelect = nCount - 2;
else
nSelect = nItem;
ListView_SetItemState(hList, nSelect, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
MarkChanged(hDlg);
res++;
return true;
}
static BOOL SoftwareDirectories_OnBeginLabelEdit(HWND hDlg, NMHDR* pNMHDR)
{
BOOL bResult = false;
NMLVDISPINFO* pDispInfo = (NMLVDISPINFO*)pNMHDR;
LVITEM* pItem = &pDispInfo->item;
HWND hList = GetDlgItem(hDlg, IDC_DIR_LIST);
/* Last item is placeholder for append */
if (pItem->iItem == ListView_GetItemCount(hList) - 1)
{
HWND hEdit = (HWND) (uintptr_t) SendMessage(hList, LVM_GETEDITCONTROL, 0, 0);
win_set_window_text_utf8(hEdit, "");
}
return bResult;
}
static BOOL SoftwareDirectories_OnEndLabelEdit(HWND hDlg, NMHDR* pNMHDR)
{
BOOL bResult = false;
NMLVDISPINFO* pDispInfo = (NMLVDISPINFO*)pNMHDR;
LVITEM* pItem = &pDispInfo->item;
if (pItem->pszText)
{
struct _stat file_stat;
/* Don't allow empty entries. */
if (!_tcscmp(pItem->pszText, TEXT("")))
return false;
/* Check validity of edited directory. */
if ((_tstat(pItem->pszText, &file_stat) == 0) && (file_stat.st_mode & S_IFDIR))
bResult = true;
else
if (win_message_box_utf8(NULL, "Folder does not exist, continue anyway?", MAMEUINAME, MB_OKCANCEL) == IDOK)
bResult = true;
}
if (bResult == true)
SoftwareDirectories_OnInsertBrowse(hDlg, true, pItem->pszText);
return bResult;
}
static BOOL DriverHasDevice(const game_driver *gamedrv, iodevice_t type)
{
BOOL b = false;
// allocate the machine config
machine_config config(*gamedrv,MameUIGlobal());
for (device_image_interface &dev : image_interface_iterator(config.root_device()))
{
if (!dev.user_loadable())
continue;
if (dev.image_type() == type)
{
b = true;
break;
}
}
return b;
}
BOOL PropSheetFilter_Config(const machine_config *drv, const game_driver *gamedrv)
{
ram_device_iterator iter(drv->root_device());
return (iter.first()) || DriverHasDevice(gamedrv, IO_PRINTER);
}
INT_PTR CALLBACK GameMessOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
INT_PTR rc = 0;
BOOL bHandled = false;
switch (Msg)
{
case WM_NOTIFY:
switch (((NMHDR *) lParam)->code)
{
case LVN_ENDLABELEDIT:
rc = SoftwareDirectories_OnEndLabelEdit(hDlg, (NMHDR *) lParam);
bHandled = true;
break;
case LVN_BEGINLABELEDIT:
rc = SoftwareDirectories_OnBeginLabelEdit(hDlg, (NMHDR *) lParam);
bHandled = true;
break;
}
}
if (!bHandled)
rc = GameOptionsProc(hDlg, Msg, wParam, lParam);
return rc;
}
BOOL MessPropertiesCommand(HWND hWnd, WORD wNotifyCode, WORD wID, BOOL *changed)
{
BOOL handled = true;
switch(wID)
{
case IDC_DIR_BROWSE:
if (wNotifyCode == BN_CLICKED)
*changed = SoftwareDirectories_OnInsertBrowse(hWnd, true, NULL);
break;
case IDC_DIR_INSERT:
if (wNotifyCode == BN_CLICKED)
*changed = SoftwareDirectories_OnInsertBrowse(hWnd, false, NULL);
break;
case IDC_DIR_DELETE:
if (wNotifyCode == BN_CLICKED)
*changed = SoftwareDirectories_OnDelete(hWnd);
break;
default:
handled = false;
break;
}
return handled;
}
#endif
|