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
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
* Handles the inventory and conversation windows.
*
* And the save/load game windows. Some of this will be platform
* specific - I'll try to separate this ASAP.
*
* And there's still a bit of tidying and commenting to do yet.
*/
//#define USE_3FLAGS 1
#include "tinsel/actors.h"
#include "tinsel/anim.h"
#include "tinsel/background.h"
#include "tinsel/config.h"
#include "tinsel/cursor.h"
#include "tinsel/drives.h"
#include "tinsel/dw.h"
#include "tinsel/film.h"
#include "tinsel/font.h"
#include "tinsel/graphics.h"
#include "tinsel/handle.h"
#include "tinsel/heapmem.h"
#include "tinsel/dialogs.h"
#include "tinsel/multiobj.h"
#include "tinsel/music.h"
#include "tinsel/palette.h"
#include "tinsel/pcode.h"
#include "tinsel/pid.h"
#include "tinsel/polygons.h"
#include "tinsel/savescn.h"
#include "tinsel/sched.h"
#include "tinsel/serializer.h"
#include "tinsel/sound.h"
#include "tinsel/strres.h"
#include "tinsel/sysvar.h"
#include "tinsel/text.h"
#include "tinsel/timers.h" // For ONE_SECOND constant
#include "tinsel/tinlib.h"
#include "tinsel/tinsel.h" // For engine access
#include "tinsel/token.h"
namespace Tinsel {
//----------------- EXTERNAL GLOBAL DATA --------------------
// In DOS_DW.C
extern bool bRestart; // restart flag - set to restart the game
#ifdef MAC_OPTIONS
// In MAC_SOUND.C
extern int volMaster;
#endif
//----------------- EXTERNAL FUNCTIONS ---------------------
// Tag functions in PDISPLAY.C
extern void EnableTags(void);
extern void DisableTags(void);
extern void DisablePointing(CORO_PARAM);
extern void EnablePointing(void);
//----------------- LOCAL DEFINES --------------------
#define INV_PICKUP PLR_SLEFT // Local names
#define INV_LOOK PLR_SRIGHT // for button events
#define INV_ACTION PLR_DLEFT //
// For SlideSlider() and similar
enum SSFN {
S_START, S_SLIDE, S_END, S_TIMEUP, S_TIMEDN
};
/** attribute values - may become bit field if further attributes are added */
enum {
IO_ONLYINV1 = 0x01,
IO_ONLYINV2 = 0x02,
IO_DROPCODE = 0x04
};
//-----------------------
// Moveable window translucent rectangle position limits
enum {
MAXLEFT = 315, //
MINRIGHT = 3, // These values keep 2 pixcells
MINTOP = -13, // of header on the screen.
MAXTOP = 195 //
};
//-----------------------
// Indices into hWinParts's reels
enum PARTS_INDEX {
IX_SLIDE = 0, // Slider
IX_V26 = 1,
IX_V52 = 2,
IX_V78 = 3,
IX_V104 = 4,
IX_V130 = 5,
IX_H26 = 6,
IX_H52 = 7,
IX_H78 = 8,
IX_H104 = 9,
IX_H130 = 10,
IX_H156 = 11,
IX_H182 = 12,
IX_H208 = 13,
IX_H234 = 14,
IX_TL = 15, // Top left corner
IX_TR = 16, // Top right corner
IX_BL = 17, // Bottom left corner
IX_BR = 18, // Bottom right corner
IX1_H25 = 19,
IX1_V11 = 20,
IX1_RTL = 21, // Re-sizing top left corner
IX1_RTR = 22, // Re-sizing top right corner
IX1_RBR = 23, // Re-sizing bottom right corner
IX1_CURLR = 24, // }
IX1_CURUD = 25, // }
IX1_CURDU = 26, // } Custom cursors
IX1_CURDD = 27, // }
IX1_CURUP = 28, // }
IX1_CURDOWN = 29, // }
IX1_MDGROOVE = 30, // 'Mixing desk' slider background
IX1_MDSLIDER= 34, // 'Mixing desk' slider
IX1_BLANK1 = 35, //
IX1_BLANK2 = 36, //
IX1_BLANK3 = 37, //
IX1_CIRCLE1 = 38, //
IX1_CIRCLE2 = 39, //
IX1_CROSS1 = 40, //
IX1_CROSS2 = 41, //
IX1_CROSS3 = 42, //
IX1_QUIT1 = 43, //
IX1_QUIT2 = 44, //
IX1_QUIT3 = 45, //
IX1_TICK1 = 46, //
IX1_TICK2 = 47, //
IX1_TICK3 = 48, //
IX1_NTR = 49, // New top right corner
IX2_RTL = 19, // Re-sizing top left corner
IX2_RTR = 20, // Re-sizing top right corner
IX2_RBR = 21, // Re-sizing bottom right corner
IX2_CURLR = 22, // }
IX2_CURUD = 23, // }
IX2_CURDU = 24, // } Custom cursors
IX2_CURDD = 25, // }
IX2_MDGROOVE = 26, // 'Mixing desk' slider background
IX2_MDSLIDER = 27, // 'Mixing desk' slider
IX2_CIRCLE1 = 28, //
IX2_CIRCLE2 = 29, //
IX2_CROSS1 = 30, //
IX2_CROSS2 = 31, //
IX2_CROSS3 = 32, //
IX2_TICK1 = 33, //
IX2_TICK2 = 34, //
IX2_TICK3 = 35, //
IX2_NTR = 36, // New top right corner
IX2_TR4 = 37,
IX2_LEFT1 = 38,
IX2_LEFT2 = 39,
IX2_RIGHT1 = 40,
IX2_RIGHT2 = 41,
T1_HOPEDFORREELS = 50,
T2_HOPEDFORREELS = 42
};
// The following defines select the correct constant depending on Tinsel version
#define IX_CROSS1 (TinselV2 ? IX2_CROSS1 : IX1_CROSS1)
#define IX_CURDD (TinselV2 ? IX2_CURDD : IX1_CURDD)
#define IX_CURDU (TinselV2 ? IX2_CURDU : IX1_CURDU)
#define IX_CURLR (TinselV2 ? IX2_CURLR : IX1_CURLR)
#define IX_CURUD (TinselV2 ? IX2_CURUD : IX1_CURUD)
#define IX_CURUL (TinselV2 ? IX2_CURUL : IX1_CURUL)
#define IX_MDGROOVE (TinselV2 ? IX2_MDGROOVE : IX1_MDGROOVE)
#define IX_MDSLIDER (TinselV2 ? IX2_MDSLIDER : IX1_MDSLIDER)
#define IX_NTR (TinselV2 ? IX2_NTR : IX1_NTR)
#define IX_RBR (TinselV2 ? IX2_RBR : IX1_RBR)
#define IX_RTL (TinselV2 ? IX2_RTL : IX1_RTL)
#define IX_RTR (TinselV2 ? IX2_RTR : IX1_RTR)
#define IX_TICK1 (TinselV2 ? IX2_TICK1 : IX1_TICK1)
#define NORMGRAPH 0
#define DOWNGRAPH 1
#define HIGRAPH 2
//-----------------------
#define FIX_UK 0
#define FIX_FR 1
#define FIX_GR 2
#define FIX_IT 3
#define FIX_SP 4
#define FIX_USA 5
#define HOPEDFORFREELS 6 // Expected flag reels
//-----------------------
#define MAX_ININV (TinselV2 ? 160 : 150) // Max in an inventory
#define MAX_ININV_TOT 160
#define MAX_PERMICONS 10 // Max permanent conversation icons
#define MAXHICONS 10 // Max dimensions of
#define MAXVICONS 6 // an inventory window
#define ITEM_WIDTH (TinselV2 ? 50 : 25) // Dimensions of an icon
#define ITEM_HEIGHT (TinselV2 ? 50 : 25) //
#define I_SEPARATION (TinselV2 ? 2 : 1) // Item separation
#define NM_TOFF 11 // Title text Y offset from top
#define NM_TBT (TinselV2 ? 4 : 0) // Y, title box top
#define NM_TBB 33
#define NM_LSX (TinselV2 ? 4 : 0) // X, left side
#define NM_BSY (TinselV2 ? -9 : - M_TH + 1)
#define NM_RSX (TinselV2 ? -9 : - M_SW + 1)
#define NM_SBL (-27)
#define NM_SLH (TinselV2 ? 11 : 5) // Slider height
#define NM_SLX (-11) // Slider X offset (from right)
#define NM_BG_POS_X (TinselV2 ? 9 : 1) // }
#define NM_BG_POS_Y (TinselV2 ? 9 : 1) // } Offset of translucent rectangle
#define NM_BG_SIZ_X (TinselV2 ? -18 : -3) // }
#define NM_BG_SIZ_Y (TinselV2 ? -18 : -3) // } How much larger it is than edges
#define NM_RS_T_INSET 3
#define NM_RS_B_INSET 4
#define NM_RS_L_INSET 3
#define NM_RS_R_INSET 4
#define NM_RS_THICKNESS 5
#define NM_MOVE_AREA_B_Y 30
#define NM_SLIDE_INSET (TinselV2 ? 18 : 15) // X offset (from right) of left of scroll region
#define NM_SLIDE_THICKNESS (TinselV2 ? 13 : 4) // thickness of scroll region
#define NM_UP_ARROW_TOP 34 // Y offset of top of up arrow
#define NM_UP_ARROW_BOTTOM 49 // Y offset of bottom of up arrow
#define NM_DN_ARROW_TOP 22 // Y offset (from bottom) of top of down arrow
#define NM_DN_ARROW_BOTTOM 5 // Y offset (from bottom) of bottom of down arrow
#define MD_YBUTTOP (TinselV2 ? 2 : 9)
#define MD_YBUTBOT (TinselV2 ? 16 : 0)
#define MD_XLBUTL (TinselV2 ? 4 : 1)
#define MD_XLBUTR (TinselV2 ? 26 : 10)
#define MD_XRBUTL (TinselV2 ? 173 : 105)
#define MD_XRBUTR (TinselV2 ? 195 : 114)
#define ROTX1 60 // Rotate button's offsets from the centre
// Number of objects that makes up an empty window
#define MAX_WCOMP 21 // 4 corners + (3+3) sides + (2+2) extra sides
// + Bground + title + slider
// + more Needed for save game window
#define MAX_ICONS MAXHICONS*MAXVICONS
#define MAX_NAME_RIGHT (TinselV2 ? 417 : 213)
#define SLIDE_RANGE (TinselV2 ? 120 : 81)
#define SLIDE_MINX (TinselV2 ? 25 : 8)
#define SLIDE_MAXX (TinselV2 ? 25 + 120 : 8 + 81)
#define MDTEXT_YOFF (TinselV2 ? -1 : 6)
#define MDTEXT_XOFF -4
#define TOG2_YOFF -22
#define ROT_YOFF 48
#define TYOFF (TinselV2 ? 4 : 0)
#define FLAGX (-5)
#define FLAGY 4
//----------------- LOCAL GLOBAL DATA --------------------
//----- Permanent data (compiled in) -----
// Save game name editing cursor
#define CURSOR_CHAR '_'
char sCursor[2] = { CURSOR_CHAR, 0 };
static const int hFillers[MAXHICONS] = {
IX_H26, // 2 icons wide
IX_H52, // 3
IX_H78, // 4
IX_H104, // 5
IX_H130, // 6
IX_H156, // 7
IX_H182, // 8
IX_H208, // 9
IX_H234 // 10 icons wide
};
static const int vFillers[MAXVICONS] = {
IX_V26, // 2 icons high
IX_V52, // 3
IX_V78, // 4
IX_V104, // 5
IX_V130 // 6 icons high
};
//----- Permanent data (set once) -----
static SCNHANDLE hWinParts = 0; // Window members and cursors' graphic data
static SCNHANDLE flagFilm = 0; // Window members and cursors' graphic data
static SCNHANDLE configStrings[20];
static INV_OBJECT *invObjects = NULL; // Inventory objects' data
static int numObjects = 0; // Number of inventory objects
static SCNHANDLE *invFilms = NULL;
static bool bNoLanguage = false;
static DIRECTION initialDirection;
//----- Permanent data (updated, valid while inventory closed) -----
static enum {NO_INV, IDLE_INV, ACTIVE_INV, BOGUS_INV} InventoryState;
static int HeldItem = INV_NOICON; // Current held item
static SCNHANDLE heldFilm;
struct INV_DEF {
int MinHicons; // }
int MinVicons; // } Dimension limits
int MaxHicons; // }
int MaxVicons; // }
int NoofHicons; // }
int NoofVicons; // } Current dimentsions
int contents[160]; // Contained items
int NoofItems; // Current number of held items
int FirstDisp; // Index to first item currently displayed
int inventoryX; // } Display position
int inventoryY; // }
int otherX; // } Display position
int otherY; // }
int MaxInvObj; // Max. allowed contents
SCNHANDLE hInvTitle; // Window heading
bool resizable; // Re-sizable window?
bool bMoveable; // Moveable window?
int sNoofHicons; // }
int sNoofVicons; // } Current dimensions
bool bMax; // Maximised last time open?
};
static INV_DEF InvD[NUM_INV]; // Conversation + 2 inventories + ...
// Permanent contents of conversation inventory
static int permIcons[MAX_PERMICONS]; // Basic items i.e. permanent contents
static int numPermIcons = 0; // - copy to conv. inventory at pop-up time
static int numEndIcons = 0;
//----- Data pertinant to current active inventory -----
static int ino = 0; // Which inventory is currently active
static bool InventoryHidden = false;
static bool InventoryMaximised = false;
static enum { ID_NONE, ID_MOVE, ID_SLIDE,
ID_BOTTOM, ID_TOP, ID_LEFT, ID_RIGHT,
ID_TLEFT, ID_TRIGHT, ID_BLEFT, ID_BRIGHT,
ID_CSLIDE, ID_MDCONT } InvDragging;
static int SuppH = 0; // 'Linear' element of
static int SuppV = 0; // dimensions during re-sizing
static int Ychange = 0; //
static int Ycompensate = 0; // All to do with re-sizing.
static int Xchange = 0; //
static int Xcompensate = 0; //
static bool ItemsChanged = 0; // When set, causes items to be re-drawn
static bool bReOpenMenu = 0;
static int TL = 0, TR = 0, BL = 0, BR = 0; // Used during window construction
static int TLwidth = 0, TLheight = 0; //
static int TRwidth = 0; //
static int BLheight = 0; //
static LANGUAGE displayedLanguage;
static OBJECT *objArray[MAX_WCOMP]; // Current display objects (window)
static OBJECT *iconArray[MAX_ICONS]; // Current display objects (icons)
static ANIM iconAnims[MAX_ICONS];
static OBJECT *DobjArray[MAX_WCOMP]; // Current display objects (re-sizing window)
static OBJECT *RectObject = 0, *SlideObject = 0; // Current display objects, for reference
// objects are in objArray.
static int sliderYpos = 0; // For positioning the slider
static int sliderYmax = 0, sliderYmin = 0; //
#define sliderRange (sliderYmax - sliderYmin)
// Also to do with the slider
static struct { int n; int y; } slideStuff[MAX_ININV_TOT+1];
#define MAXSLIDES 4
struct MDSLIDES {
int num;
OBJECT *obj;
int min, max;
};
static MDSLIDES mdSlides[MAXSLIDES];
static int numMdSlides = 0;
static int GlitterIndex = 0;
// Icon clicked on to cause an event
// - Passed to conversation polygon or actor code via Topic()
// - (sometimes) Passed to inventory icon code via OtherObject()
static int thisIcon = 0;
static CONV_PARAM thisConvFn; // Top, 'Middle' or Bottom
static HPOLYGON thisConvPoly = 0; // Conversation code is in a polygon code block
static int thisConvActor; // ...or an actor's code block.
static int pointedIcon = INV_NOICON; // used by InvLabels - icon pointed to on last call
static volatile int PointedWaitCount = 0; // used by ObjectProcess - fix the 'repeated pressing bug'
static int sX = 0; // used by SlideMSlider() - current x-coordinate
static int lX = 0; // used by SlideMSlider() - last x-coordinate
static bool bMoveOnUnHide; // Set before start of conversation
// - causes conversation to be started in a sensible place
//----- Data pertinant to configure (incl. load/save game) -----
#define COL_MAINBOX TBLUE1 // Base blue colour
#define COL_BOX TBLUE1
#define COL_HILIGHT TBLUE4
#ifdef JAPAN
#define BOX_HEIGHT 17
#define EDIT_BOX1_WIDTH 149
#else
#define BOX_HEIGHT 13
#define EDIT_BOX1_WIDTH 145
#endif
#define EDIT_BOX2_WIDTH 166
#define T2_EDIT_BOX1_WIDTH 290
#define T2_EDIT_BOX2_WIDTH 322
#define T2_BOX_HEIGHT 26
//----- Data pertinant to scene hoppers ------------------------
#include "common/pack-start.h" // START STRUCT PACKING
struct HOPPER {
uint32 hScene;
SCNHANDLE hSceneDesc;
uint32 numEntries;
uint32 entryIndex;
} PACKED_STRUCT;
typedef HOPPER *PHOPPER;
struct HOPENTRY {
uint32 eNumber; // entrance number
SCNHANDLE hDesc; // handle to entrance description
uint32 flags;
} PACKED_STRUCT;
typedef HOPENTRY *PHOPENTRY;
#include "common/pack-end.h" // END STRUCT PACKING
static PHOPPER pHopper;
static PHOPENTRY pEntries;
static int numScenes;
static int numEntries;
static PHOPPER pChosenScene = NULL;
static int lastChosenScene;
static bool bRemember;
//--------------------------------------------------------------
enum BTYPE {
RGROUP, //!< Radio button group - 1 is selectable at a time. Action on double click
ARSBUT, //!< Action if a radio button is selected
AABUT, //!< Action always
AATBUT, //!< Action always, text box
ARSGBUT,
AAGBUT, //!< Action always, graphic button
SLIDER, //!< Not a button at all
TOGGLE, //!< Discworld 1 toggle
TOGGLE1, //!< Discworld 2 toggle type 1
TOGGLE2, //!< Discworld 2 toggle type 2
DCTEST,
FLIP,
FRGROUP,
ROTATE,
NOTHING
};
enum BFUNC {
NOFUNC,
SAVEGAME,
LOADGAME,
IQUITGAME,
CLOSEWIN,
OPENLOAD,
OPENSAVE,
OPENREST,
OPENSOUND,
OPENCONT,
#ifndef JAPAN
OPENSUBT,
#endif
OPENQUIT,
INITGAME,
MUSICVOL,
HOPPER2, // Call up Scene Hopper 2
BF_CHANGESCENE,
CLANG,
RLANG
#ifdef MAC_OPTIONS
, MASTERVOL, SAMPVOL
#endif
};
#define NO_HEADING ((SCNHANDLE)-1)
#define USE_POINTER (-1)
#define SIX_LOAD_OPTION 0
#define SIX_SAVE_OPTION 1
#define SIX_RESTART_OPTION 2
#define SIX_SOUND_OPTION 3
#define SIX_CONTROL_OPTION 4
#ifndef JAPAN
#define SIX_SUBTITLES_OPTION 5
#endif
#define SIX_QUIT_OPTION 6
#define SIX_RESUME_OPTION 7
#define SIX_LOAD_HEADING 8
#define SIX_SAVE_HEADING 9
#define SIX_RESTART_HEADING 10
#define SIX_MVOL_SLIDER 11
#define SIX_SVOL_SLIDER 12
#define SIX_VVOL_SLIDER 13
#define SIX_DCLICK_SLIDER 14
#define SIX_DCLICK_TEST 15
#define SIX_SWAP_TOGGLE 16
#define SIX_TSPEED_SLIDER 17
#define SIX_STITLE_TOGGLE 18
#define SIX_QUIT_HEADING 19
enum TM {TM_POINTER, TM_INDEX, TM_STRINGNUM, TM_NONE};
struct CONFBOX {
BTYPE boxType;
BFUNC boxFunc;
TM textMethod;
char *boxText;
int ixText;
int xpos;
int ypos;
int w; // Doubles as max value for SLIDERs
int h; // Doubles as iteration size for SLIDERs
int *ival;
int bi; // Base index for AAGBUTs
};
struct CONFINIT {
int h;
int v;
int x;
int y;
bool bExtraWin;
CONFBOX *Box;
int NumBoxes;
uint32 ixHeading;
};
#define BW 44 // Width of crosses and ticks etc. buttons
#define BH 41 // Height of crosses and ticks etc. buttons
/*-------------------------------------------------------------*\
| This is the main menu (that comes up when you hit F1 on a PC) |
\*-------------------------------------------------------------*/
#ifdef JAPAN
#define FBY 11 // y-offset of first button
#define FBX 13 // x-offset of first button
#else
#define FBY 20 // y-offset of first button
#define FBX 15 // x-offset of first button
#endif
#define OPTX 33
#define OPTY 30
#define BOX_V_SEP 7
#define BOXX 56 // X-position of text boxes
#define BOXY 50 // Y-position of text boxes
#define T2_OPTX 33
#define T2_OPTY 36
#define T2_BOX_V_SEP 12
#define T2_BOX_V2_SEP 6
CONFBOX t1OptionBox[] = {
{ AATBUT, OPENLOAD, TM_NONE, NULL, SIX_LOAD_OPTION, FBX, FBY, EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 },
{ AATBUT, OPENSAVE, TM_NONE, NULL, SIX_SAVE_OPTION, FBX, FBY + (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 },
{ AATBUT, OPENREST, TM_NONE, NULL, SIX_RESTART_OPTION, FBX, FBY + 2*(BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 },
{ AATBUT, OPENSOUND, TM_NONE, NULL, SIX_SOUND_OPTION, FBX, FBY + 3*(BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 },
{ AATBUT, OPENCONT, TM_NONE, NULL, SIX_CONTROL_OPTION, FBX, FBY + 4*(BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 },
#ifdef JAPAN
// TODO: If in JAPAN mode, simply disable the subtitles button?
{ AATBUT, OPENQUIT, NULL, SIX_QUIT_OPTION, FBX, FBY + 5*(BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 },
{ AATBUT, CLOSEWIN, NULL, SIX_RESUME_OPTION, FBX, FBY + 6*(BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 }
#else
{ AATBUT, OPENSUBT, TM_NONE, NULL, SIX_SUBTITLES_OPTION,FBX, FBY + 5*(BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 },
{ AATBUT, OPENQUIT, TM_NONE, NULL, SIX_QUIT_OPTION, FBX, FBY + 6*(BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 },
{ AATBUT, CLOSEWIN, TM_NONE, NULL, SIX_RESUME_OPTION, FBX, FBY + 7*(BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0 }
#endif
};
CONFINIT t1ciOption = { 6, 5, 72, 23, false, t1OptionBox, ARRAYSIZE(t1OptionBox), NO_HEADING };
CONFBOX t2OptionBox[] = {
{ AATBUT, OPENLOAD, TM_INDEX, NULL, SS_LOAD_OPTION, T2_OPTX, T2_OPTY, T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ AATBUT, OPENSAVE, TM_INDEX, NULL, SS_SAVE_OPTION, T2_OPTX, T2_OPTY + (T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ AATBUT, OPENREST, TM_INDEX, NULL, SS_RESTART_OPTION, T2_OPTX, T2_OPTY + 2*(T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ AATBUT, OPENSOUND, TM_INDEX, NULL, SS_SOUND_OPTION, T2_OPTX, T2_OPTY + 3*(T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ AATBUT, OPENQUIT, TM_INDEX, NULL, SS_QUIT_OPTION, T2_OPTX, T2_OPTY + 4*(T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0 }
};
CONFINIT t2ciOption = { 6, 4, 144, 60, false, t2OptionBox, sizeof(t2OptionBox)/sizeof(CONFBOX), NO_HEADING };
#define ciOption (TinselV2 ? t2ciOption : t1ciOption)
#define optionBox (TinselV2 ? t2OptionBox : t1OptionBox)
/*-------------------------------------------------------------*\
| These are the load and save game menus. |
\*-------------------------------------------------------------*/
#define NUM_RGROUP_BOXES 9
#ifdef JAPAN
#define NUM_RGROUP_BOXES 7 // number of visible slots
#define SY 32 // y-position of first slot
#else
#define NUM_RGROUP_BOXES 9 // number of visible slots
#define SY 31 // y-position of first slot
#endif
CONFBOX t1LoadBox[NUM_RGROUP_BOXES+2] = {
{ RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY, EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
{ RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
{ RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 2*(BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
{ RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 3*(BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
{ RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 4*(BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
{ RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 5*(BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
{ RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 6*(BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
#ifndef JAPAN
{ RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 7*(BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
{ RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 8*(BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
#endif
{ ARSGBUT, LOADGAME, TM_NONE, NULL, USE_POINTER, 230, 44, 23, 19, NULL, IX1_TICK1 },
{ AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 230, 44+47, 23, 19, NULL, IX1_CROSS1 }
};
CONFBOX t2LoadBox[] = {
{ RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 2*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 3*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 4*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 5*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 6*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 7*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 8*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ ARSGBUT, LOADGAME, TM_NONE, NULL, 0, 460, 100, BW, BH, NULL, IX2_TICK1 },
{ AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100+100, BW, BH, NULL, IX2_CROSS1 }
};
CONFINIT t1ciLoad = { 10, 6, 20, 16, true, t1LoadBox, ARRAYSIZE(t1LoadBox), SIX_LOAD_HEADING };
CONFINIT t2ciLoad = { 10, 6, 40, 16, true, t2LoadBox, sizeof(t2LoadBox)/sizeof(CONFBOX), SS_LOAD_HEADING };
CONFBOX t1SaveBox[NUM_RGROUP_BOXES+2] = {
{ RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY, EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
{ RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
{ RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 2*(BOX_HEIGHT + 2),EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
{ RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 3*(BOX_HEIGHT + 2),EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
{ RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 4*(BOX_HEIGHT + 2),EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
{ RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 5*(BOX_HEIGHT + 2),EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
{ RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 6*(BOX_HEIGHT + 2),EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
#ifndef JAPAN
{ RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 7*(BOX_HEIGHT + 2),EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
{ RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 8*(BOX_HEIGHT + 2),EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0 },
#endif
{ ARSGBUT, SAVEGAME, TM_NONE, NULL,USE_POINTER, 230, 44, 23, 19, NULL, IX1_TICK1 },
{ AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 230, 44+47, 23, 19, NULL, IX1_CROSS1 }
};
CONFBOX t2SaveBox[] = {
{ RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 2*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 3*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 4*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 5*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 6*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 7*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 8*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ ARSGBUT, SAVEGAME, TM_NONE, NULL, 0, 460, 100, BW, BH, NULL, IX2_TICK1 },
{ AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100+100, BW, BH, NULL, IX2_CROSS1 }
};
CONFINIT t1ciSave = { 10, 6, 20, 16, true, t1SaveBox, ARRAYSIZE(t1SaveBox), SIX_SAVE_HEADING };
CONFINIT t2ciSave = { 10, 6, 40, 16, true, t2SaveBox, sizeof(t2SaveBox)/sizeof(CONFBOX), SS_SAVE_HEADING };
#define ciLoad (TinselV2 ? t2ciLoad : t1ciLoad)
#define loadBox (TinselV2 ? t2LoadBox : t1LoadBox)
#define ciSave (TinselV2 ? t2ciSave : t1ciSave)
#define saveBox (TinselV2 ? t2SaveBox : t1SaveBox)
/*-------------------------------------------------------------*\
| This is the restart confirmation 'menu'. |
\*-------------------------------------------------------------*/
CONFBOX t1RestartBox[] = {
#ifdef JAPAN
{ AAGBUT, INITGAME, TM_NONE, NULL, USE_POINTER, 96, 44, 23, 19, NULL, IX_TICK1 },
{ AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 56, 44, 23, 19, NULL, IX_CROSS1 }
#else
{ AAGBUT, INITGAME, TM_NONE, NULL, USE_POINTER, 70, 28, 23, 19, NULL, IX1_TICK1 },
{ AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 30, 28, 23, 19, NULL, IX1_CROSS1 }
#endif
};
CONFBOX t2RestartBox[] = {
{ AAGBUT, INITGAME, TM_NONE, NULL, 0, 140, 78, BW, BH, NULL, IX2_TICK1 },
{ AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 60, 78, BW, BH, NULL, IX2_CROSS1 }
};
#ifdef JAPAN
CONFINIT t1ciRestart = { 6, 2, 72, 53, false, t1RestartBox, ARRAYSIZE(t1RestartBox), SIX_RESTART_HEADING };
#else
CONFINIT t1ciRestart = { 4, 2, 98, 53, false, t1RestartBox, ARRAYSIZE(t1RestartBox), SIX_RESTART_HEADING };
#endif
CONFINIT t2ciRestart = { 4, 2, 196, 53, false, t2RestartBox, sizeof(t2RestartBox)/sizeof(CONFBOX), SS_RESTART_HEADING };
#define ciRestart (TinselV2 ? t2ciRestart : t1ciRestart)
#define restartBox (TinselV2 ? t2RestartBox : t1RestartBox)
/*-------------------------------------------------------------*\
| This is the sound control 'menu'. In Discworld 2, it also |
| contains the subtitles and language selection. |
\*-------------------------------------------------------------*/
CONFBOX t1SoundBox[] = {
{ SLIDER, MUSICVOL, TM_NONE, NULL, SIX_MVOL_SLIDER, 142, 25, Audio::Mixer::kMaxChannelVolume, 2, &volMusic, 0 },
{ SLIDER, NOFUNC, TM_NONE, NULL, SIX_SVOL_SLIDER, 142, 25+40, Audio::Mixer::kMaxChannelVolume, 2, &volSound, 0 },
{ SLIDER, NOFUNC, TM_NONE, NULL, SIX_VVOL_SLIDER, 142, 25+2*40, Audio::Mixer::kMaxChannelVolume, 2, &volVoice, 0 }
};
CONFBOX t2SoundBox[] = {
{ SLIDER, MUSICVOL, TM_INDEX, NULL, SS_MVOL_SLIDER, 280, 50, Audio::Mixer::kMaxChannelVolume, 2, &volMusic, 0 },
{ SLIDER, NOFUNC, TM_INDEX, NULL, SS_SVOL_SLIDER, 280, 50+30, Audio::Mixer::kMaxChannelVolume, 2, &volSound, 0 },
{ SLIDER, NOFUNC, TM_INDEX, NULL, SS_VVOL_SLIDER, 280, 50+2*30, Audio::Mixer::kMaxChannelVolume, 2, &volVoice, 0 },
{ SLIDER, NOFUNC, TM_INDEX, NULL, SS_TSPEED_SLIDER, 280, 160, 100, 2, &speedText, 0 },
{ TOGGLE2, NOFUNC, TM_INDEX, NULL, SS_STITLE_TOGGLE, 100, 220, BW, BH, &bSubtitles, 0 },
{ ROTATE, NOFUNC, TM_INDEX, NULL, SS_LANGUAGE_SELECT, 320,220, BW, BH, NULL, 0 }
};
CONFINIT t1ciSound = { 10, 5, 20, 16, false, t1SoundBox, ARRAYSIZE(t1SoundBox), NO_HEADING };
CONFINIT t2ciSound = { 10, 5, 40, 16, false, t2SoundBox, sizeof(t2SoundBox)/sizeof(CONFBOX), SS_SOUND_HEADING };
#define ciSound (TinselV2 ? t2ciSound : t1ciSound)
#define soundBox (TinselV2 ? t2SoundBox : t1SoundBox)
/*-------------------------------------------------------------*\
| This is the (mouse) control 'menu'. |
\*-------------------------------------------------------------*/
int bFlipped; // looks like this is just so the code has something to alter!
CONFBOX controlBox[] = {
{ SLIDER, NOFUNC, TM_NONE, NULL, SIX_DCLICK_SLIDER, 142, 25, 3*DOUBLE_CLICK_TIME, 1, &dclickSpeed, 0 },
{ FLIP, NOFUNC, TM_NONE, NULL, SIX_DCLICK_TEST, 142, 25+30, 23, 19, &bFlipped, IX1_CIRCLE1 },
#ifdef JAPAN
{ TOGGLE, NOFUNC, TM_NONE, NULL, SIX_SWAP_TOGGLE, 205, 25+70, 23, 19, &bSwapButtons, 0 }
#else
{ TOGGLE, NOFUNC, TM_NONE, NULL, SIX_SWAP_TOGGLE, 155, 25+70, 23, 19, &bSwapButtons, 0 }
#endif
};
CONFINIT ciControl = { 10, 5, 20, 16, false, controlBox, ARRAYSIZE(controlBox), NO_HEADING };
/*-------------------------------------------------------------*\
| This is the subtitles 'menu'. |
\*-------------------------------------------------------------*/
CONFBOX subtitlesBox[] = {
{ SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, &speedText, 0 },
{ TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20+40, 23, 19, &bSubtitles, 0 },
};
CONFBOX subtitlesBox3Flags[] = {
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 15, 118, 56, 32, NULL, FIX_FR },
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 85, 118, 56, 32, NULL, FIX_GR },
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 155, 118, 56, 32, NULL, FIX_SP },
{ SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, &speedText, 0 },
{ TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20+40, 23, 19, &bSubtitles, 0 },
{ ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1 },
{ AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1 }
};
CONFBOX subtitlesBox4Flags[] = {
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 20, 100, 56, 32, NULL, FIX_FR },
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 108, 100, 56, 32, NULL, FIX_GR },
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 64, 137, 56, 32, NULL, FIX_IT },
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 152, 137, 56, 32, NULL, FIX_SP },
{ SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, &speedText, 0 },
{ TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20+40, 23, 19, &bSubtitles, 0 },
{ ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1 },
{ AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1 }
};
CONFBOX subtitlesBox5Flags[] = {
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 15, 100, 56, 32, NULL, FIX_UK },
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 85, 100, 56, 32, NULL, FIX_FR },
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 155, 100, 56, 32, NULL, FIX_GR },
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 50, 137, 56, 32, NULL, FIX_IT },
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 120, 137, 56, 32, NULL, FIX_SP },
{ SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, &speedText, 0 },
{ TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20+40, 23, 19, &bSubtitles, 0 },
{ ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1 },
{ AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1 }
};
/*-------------------------------------------------------------*\
| This is the quit confirmation 'menu'. |
\*-------------------------------------------------------------*/
CONFBOX t1QuitBox[] = {
#ifdef JAPAN
{ AAGBUT, IQUITGAME, TM_NONE, NULL, USE_POINTER,70, 44, 23, 19, NULL, IX_TICK1 },
{ AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 30, 44, 23, 19, NULL, IX_CROSS1 }
#else
{ AAGBUT, IQUITGAME, TM_NONE, NULL, USE_POINTER,70, 28, 23, 19, NULL, IX1_TICK1 },
{ AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 30, 28, 23, 19, NULL, IX1_CROSS1 }
#endif
};
CONFBOX t2QuitBox[] = {
{ AAGBUT, IQUITGAME, TM_NONE, NULL, 0,140, 78, BW, BH, NULL, IX2_TICK1 },
{ AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 60, 78, BW, BH, NULL, IX2_CROSS1 }
};
CONFINIT t1ciQuit = { 4, 2, 98, 53, false, t1QuitBox, ARRAYSIZE(t1QuitBox), SIX_QUIT_HEADING };
CONFINIT t2ciQuit = { 4, 2, 196, 53, false, t2QuitBox, sizeof(t2QuitBox)/sizeof(CONFBOX), SS_QUIT_HEADING };
#define quitBox (TinselV2 ? t2QuitBox : t1QuitBox)
#define ciQuit (TinselV2 ? t2ciQuit : t1ciQuit)
/***************************************************************************\
|************************ Startup and shutdown ***********************|
\***************************************************************************/
CONFBOX hopperBox1[] = {
{ RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 2*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 3*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 4*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 5*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 6*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 7*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 8*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ ARSGBUT, HOPPER2, TM_NONE, NULL, 0, 460, 100, BW, BH, NULL, IX2_TICK1 },
{ AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100 + 100, BW, BH, NULL, IX2_CROSS1 }
};
CONFINIT ciHopper1 = { 10, 6, 40, 16, true, hopperBox1, sizeof(hopperBox1) / sizeof(CONFBOX), SS_HOPPER1 };
CONFBOX hopperBox2[] = {
{ RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 2*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 3*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 4*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 5*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 6*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 7*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 8*(T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0 },
{ ARSGBUT, BF_CHANGESCENE, TM_NONE, NULL, 0, 460, 50, BW, BH, NULL, IX2_TICK1 },
{ AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 200, BW, BH, NULL, IX2_CROSS1 }
};
CONFINIT ciHopper2 = { 10, 6, 40, 16, true, hopperBox2, sizeof(hopperBox2)/sizeof(CONFBOX), NO_HEADING };
/***************************************************************************\
|**************************** Top Window *****************************|
\***************************************************************************/
CONFBOX topwinBox[] = {
{ NOTHING, NOFUNC, TM_NONE, NULL, USE_POINTER, 0, 0, 0, 0, NULL, 0 }
};
CONFINIT ciSubtitles = { 10, 3, 20, 16, false, subtitlesBox, ARRAYSIZE(subtitlesBox), NO_HEADING };
CONFINIT ciTopWin = { 6, 5, 72, 23, false, topwinBox, 0, NO_HEADING };
#define NOBOX (-1)
// Conf window globals
static struct {
CONFBOX *box;
int NumBoxes;
bool bExtraWin;
uint32 ixHeading;
bool editableRgroup;
int selBox;
int pointBox; // Box pointed to on last call
int modifier;
int extraBase;
int numSaved;
} cd = {
NULL, 0, false, 0, false,
NOBOX, NOBOX, 0, 0, 0
};
// For editing save game names
char sedit[SG_DESC_LEN+2];
#define HL1 0 // Hilight that moves with the cursor
#define HL2 1 // Hilight on selected RGROUP box
#define HL3 2 // Text on selected RGROUP box
#define NUMHL 3
// Data for button press/toggle effects
static struct {
bool bButAnim;
CONFBOX *box;
bool press; // true = button press; false = button toggle
} g_buttonEffect = { false, 0, false };
//----- LOCAL FORWARD REFERENCES -----
enum {
IB_NONE = -1, //
IB_UP = -2, // negative numbers returned
IB_DOWN = -3, // by WhichMenuBox()
IB_SLIDE = -4, //
IB_SLIDE_UP = -5, //
IB_SLIDE_DOWN = -6 //
};
enum {
HI_BIT = ((uint)MIN_INT >> 1), // The next to top bit
IS_LEFT = HI_BIT,
IS_SLIDER = (IS_LEFT >> 1),
IS_RIGHT = (IS_SLIDER >> 1),
IS_MASK = (IS_LEFT | IS_SLIDER | IS_RIGHT)
};
static int WhichMenuBox(int curX, int curY, bool bSlides);
static void SlideMSlider(int x, SSFN fn);
static OBJECT *AddObject(const FREEL *pfreel, int num);
static void AddBoxes(bool posnSlide);
static void ConfActionSpecial(int i);
/*-------------------------------------------------------------------------*/
/*** Magic numbers ***/
#define M_SW 5 // Side width
#define M_TH 5 // Top height
#ifdef JAPAN
#define M_TOFF 6 // Title text Y offset from top
#define M_TBB 20 // Title box bottom Y offset
#else
#define M_TOFF 4 // Title text Y offset from top
#define M_TBB 14 // Title box bottom Y offset
#endif
#define M_SBL 26 // Scroll bar left X offset
#define M_SH 5 // Slider height (*)
#define M_SW 5 // Slider width (*)
#define M_SXOFF 9 // Slider X offset from right-hand side
#ifdef JAPAN
#define M_IUT 22 // Y offset of top of up arrow
#define M_IUB 30 // Y offset of bottom of up arrow
#else
#define M_IUT 16 // Y offset of top of up arrow
#define M_IUB 24 // Y offset of bottom of up arrow
#endif
#define M_IDT 10 // Y offset (from bottom) of top of down arrow
#define M_IDB 3 // Y offset (from bottom) of bottom of down arrow
#define START_ICONX (TinselV2 ? 12 : (M_SW+1)) // } Relative offset of first icon
#define START_ICONY (TinselV2 ? 40 : (M_TBB+M_TH+1)) // } within the inventory window
/*-------------------------------------------------------------------------*/
bool LanguageChange(void) {
LANGUAGE nLang = g_language;
if (_vm->getFeatures() & GF_USE_3FLAGS) {
// VERY quick dodgy bodge
if (cd.selBox == 0)
nLang = TXT_FRENCH; // = 1
else if (cd.selBox == 1)
nLang = TXT_GERMAN; // = 2
else
nLang = TXT_SPANISH; // = 4
} else if (_vm->getFeatures() & GF_USE_4FLAGS) {
nLang = (LANGUAGE)(cd.selBox + 1);
} else if (_vm->getFeatures() & GF_USE_5FLAGS) {
nLang = (LANGUAGE)cd.selBox;
}
if (nLang != g_language) {
KillInventory();
ChangeLanguage(nLang);
g_language = nLang;
return true;
} else
return false;
}
/**************************************************************************/
/***************************** Scene Hopper ******************************/
/**************************************************************************/
/**
* Read in the scene hopper data file and set the
* pointers to the data and scene count.
*/
static void PrimeSceneHopper(void) {
Common::File f;
char *pBuffer;
uint32 vSize;
// Open the file (it's on the CD)
CdCD(nullContext);
if (!f.open(HOPPER_FILENAME))
error(CANNOT_FIND_FILE, HOPPER_FILENAME);
// Read in header
if (f.readUint32LE() != CHUNK_SCENE_HOPPER)
error(FILE_IS_CORRUPT, HOPPER_FILENAME);
vSize = f.readUint32LE();
// allocate a buffer for it all
assert(pHopper == NULL);
uint32 size = f.size() - 8;
// make sure memory allocated
pBuffer = (char *)malloc(size);
if (pBuffer == NULL)
// cannot alloc buffer for index
error(NO_MEM, "Scene hopper data\n");
// load data
if (f.read(pBuffer, size) != size)
// file must be corrupt if we get to here
error(FILE_IS_CORRUPT, HOPPER_FILENAME);
// Set data pointers
pHopper = (PHOPPER)pBuffer;
pEntries = (PHOPENTRY)(pBuffer + vSize);
numScenes = vSize / sizeof(HOPPER);
// close the file
f.close();
}
/**
* Free the scene hopper data file
*/
static void FreeSceneHopper() {
free(pHopper);
pHopper = NULL;
}
static void FirstScene(int first) {
int i;
assert(numScenes && pHopper);
if (bRemember) {
assert(first == 0);
first = lastChosenScene;
bRemember = false;
}
// Force it to a sensible value
if (first > numScenes - NUM_RGROUP_BOXES)
first = numScenes - NUM_RGROUP_BOXES;
if (first < 0)
first = 0;
// Fill in the rest
for (i = 0; i < NUM_RGROUP_BOXES && i + first < numScenes; i++) {
cd.box[i].textMethod = TM_STRINGNUM;
cd.box[i].ixText = FROM_LE_32(pHopper[i + first].hSceneDesc);
}
// Blank out the spare ones (if any)
while (i < NUM_RGROUP_BOXES) {
cd.box[i].textMethod = TM_NONE;
cd.box[i++].ixText = 0;
}
cd.extraBase = first;
}
static void RememberChosenScene(void) {
bRemember = true;
}
static void SetChosenScene(void) {
lastChosenScene = cd.selBox + cd.extraBase;
pChosenScene = &pHopper[cd.selBox + cd.extraBase];
}
static void FirstEntry(int first) {
int i;
InvD[INV_MENU].hInvTitle = FROM_LE_32(pChosenScene->hSceneDesc);
// get number of entrances
numEntries = FROM_LE_32(pChosenScene->numEntries);
// Force first to a sensible value
if (first > numEntries-NUM_RGROUP_BOXES)
first = numEntries-NUM_RGROUP_BOXES;
if (first < 0)
first = 0;
for (i = 0; i < NUM_RGROUP_BOXES && i < numEntries; i++) {
cd.box[i].textMethod = TM_STRINGNUM;
cd.box[i].ixText = FROM_LE_32(pEntries[FROM_LE_32(pChosenScene->entryIndex) + i + first].hDesc);
}
// Blank out the spare ones (if any)
while (i < NUM_RGROUP_BOXES) {
cd.box[i].textMethod = TM_NONE;
cd.box[i++].ixText = 0;
}
cd.extraBase = first;
}
void HopAction(void) {
PHOPENTRY pEntry = pEntries + FROM_LE_32(pChosenScene->entryIndex) + cd.selBox + cd.extraBase;
uint32 hScene = FROM_LE_32(pChosenScene->hScene);
uint32 eNumber = FROM_LE_32(pEntry->eNumber);
debugC(DEBUG_BASIC, kTinselDebugAnimations, "Scene hopper chose scene %xh,%d\n", hScene, eNumber);
if (FROM_LE_32(pEntry->flags) & fCall) {
SaveScene(nullContext);
NewScene(nullContext, pChosenScene->hScene, pEntry->eNumber, TRANS_FADE);
}
else if (FROM_LE_32(pEntry->flags) & fHook)
HookScene(hScene, eNumber, TRANS_FADE);
else
NewScene(nullContext, hScene, eNumber, TRANS_CUT);
}
/**************************************************************************/
/******************** Some miscellaneous functions ************************/
/**************************************************************************/
/**
* Delete all the objects in iconArray[]
*/
static void DumpIconArray(void) {
for (int i = 0; i < MAX_ICONS; i++) {
if (iconArray[i] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[i]);
iconArray[i] = NULL;
}
}
}
/**
* Delete all the objects in DobjArray[]
*/
static void DumpDobjArray(void) {
for (int i = 0; i < MAX_WCOMP; i++) {
if (DobjArray[i] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), DobjArray[i]);
DobjArray[i] = NULL;
}
}
}
/**
* Delete all the objects in objArray[]
*/
static void DumpObjArray(void) {
for (int i = 0; i < MAX_WCOMP; i++) {
if (objArray[i] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), objArray[i]);
objArray[i] = NULL;
}
}
}
/**
* Convert item ID number to pointer to item's compiled data
* i.e. Image data and Glitter code.
*/
INV_OBJECT *GetInvObject(int num) {
INV_OBJECT *retval = invObjects;
for (int i = 0; i < numObjects; i++, retval++) {
if (retval->id == num)
return retval;
}
error("Trying to manipulate undefined inventory icon");
}
/**
* Convert item ID number to index.
*/
int GetObjectIndex(int id) {
int i; // Loop counter
INV_OBJECT *pObject;
for (i = 0, pObject = invObjects; i < numObjects; i++, pObject++) {
if (pObject->id == id)
break;
}
assert(i < numObjects);
return i;
}
/**
* Returns position of an item in one of the inventories.
* The actual position is not important for the uses that this is put to.
*/
int InventoryPos(int num) {
int i;
for (i = 0; i < InvD[INV_1].NoofItems; i++) // First inventory
if (InvD[INV_1].contents[i] == num)
return i;
for (i = 0; i < InvD[INV_2].NoofItems; i++) // Second inventory
if (InvD[INV_2].contents[i] == num)
return i;
if (HeldItem == num)
return INV_HELDNOTIN; // Held, but not in either inventory
return INV_NOICON; // Not held, not in either inventory
}
bool IsInInventory(int object, int invnum) {
assert(invnum == INV_1 || invnum == INV_2);
for (int i = 0; i < InvD[invnum].NoofItems; i++) // First inventory
if (InvD[invnum].contents[i] == object)
return true;
return false;
}
/**
* Returns which item is held (INV_NOICON (-1) if none)
*/
int WhichItemHeld(void) {
return HeldItem;
}
/**
* Called from the cursor module when it re-initialises (at the start of
* a new scene). For if we are holding something at scene-change time.
*/
void InventoryIconCursor(bool bNewItem) {
if (HeldItem != INV_NOICON) {
if (TinselV2) {
if (bNewItem) {
int objIndex = GetObjectIndex(HeldItem);
heldFilm = invFilms[objIndex];
}
SetAuxCursor(heldFilm);
} else {
INV_OBJECT *invObj = GetInvObject(HeldItem);
SetAuxCursor(invObj->hIconFilm);
}
}
}
/**
* Returns true if the inventory is active.
*/
bool InventoryActive(void) {
return (InventoryState == ACTIVE_INV);
}
int WhichInventoryOpen(void) {
if (InventoryState != ACTIVE_INV)
return 0;
else
return ino;
}
/**************************************************************************/
/************** Running inventory item's Glitter code *********************/
/**************************************************************************/
struct OP_INIT {
INV_OBJECT *pinvo;
TINSEL_EVENT event;
PLR_EVENT bev;
int myEscape;
};
/**
* Run inventory item's Glitter code
*/
static void ObjectProcess(CORO_PARAM, const void *param) {
// COROUTINE
CORO_BEGIN_CONTEXT;
INT_CONTEXT *pic;
int ThisPointedWait; // Fix the 'repeated pressing bug'
CORO_END_CONTEXT(_ctx);
// get the stuff copied to process when it was created
const OP_INIT *to = (const OP_INIT *)param;
CORO_BEGIN_CODE(_ctx);
if (!TinselV2)
CORO_INVOKE_1(AllowDclick, to->bev);
_ctx->pic = InitInterpretContext(GS_INVENTORY, to->pinvo->hScript, to->event, NOPOLY, 0, to->pinvo,
to->myEscape);
CORO_INVOKE_1(Interpret, _ctx->pic);
if (to->event == POINTED) {
_ctx->ThisPointedWait = ++PointedWaitCount;
while (1) {
CORO_SLEEP(1);
int x, y;
GetCursorXY(&x, &y, false);
if (InvItemId(x, y) != to->pinvo->id)
break;
// Fix the 'repeated pressing bug'
if (_ctx->ThisPointedWait != PointedWaitCount)
CORO_KILL_SELF();
}
_ctx->pic = InitInterpretContext(GS_INVENTORY, to->pinvo->hScript, UNPOINT, NOPOLY, 0, to->pinvo);
CORO_INVOKE_1(Interpret, _ctx->pic);
}
CORO_END_CODE;
}
/**
* Run inventory item's Glitter code
*/
void InvTinselEvent(INV_OBJECT *pinvo, TINSEL_EVENT event, PLR_EVENT be, int index) {
OP_INIT to = { pinvo, event, be, 0 };
if (InventoryHidden || (TinselV2 && !pinvo->hScript))
return;
GlitterIndex = index;
g_scheduler->createProcess(PID_TCODE, ObjectProcess, &to, sizeof(to));
}
void ObjectEvent(CORO_PARAM, int objId, TINSEL_EVENT event, bool bWait, int myEscape, bool *result) {
// COROUTINE
CORO_BEGIN_CONTEXT;
PROCESS *pProc;
INV_OBJECT *pInvo;
OP_INIT op;
CORO_END_CONTEXT(_ctx);
CORO_BEGIN_CODE(_ctx);
if (result) *result = false;
_ctx->pInvo = GetInvObject(objId);
if (!_ctx->pInvo->hScript)
return;
_ctx->op.pinvo = _ctx->pInvo;
_ctx->op.event = event;
_ctx->op.myEscape = myEscape;
g_scheduler->createProcess(PID_TCODE, ObjectProcess, &_ctx->op, sizeof(_ctx->op));
if (bWait)
CORO_INVOKE_2(WaitInterpret, _ctx->pProc, result);
else
// FIXME: Essential to ensure created ObjectProcess coroutine has a chance to start
// up, for the scene restore when returning from looking at the AshkEnte instructions
// to work. Really need to trace operation of original to see at what point the scene
// save is done, and when control was first yielded to the ObjectProcess coroutine
CORO_SLEEP(1);
CORO_END_CODE;
}
/**************************************************************************/
/****************** Load/Save game specific functions *********************/
/**************************************************************************/
/**
* Set first load/save file entry displayed.
* Point Box[] text pointers to appropriate file descriptions.
*/
void FirstFile(int first) {
int i, j;
i = getList();
cd.numSaved = i;
if (first < 0)
first = 0;
else if (first > MAX_SAVED_FILES - NUM_RGROUP_BOXES)
first = MAX_SAVED_FILES - NUM_RGROUP_BOXES;
if (first == 0 && i < MAX_SAVED_FILES && cd.box == saveBox) {
// Blank first entry for new save
cd.box[0].boxText = NULL;
cd.modifier = j = 1;
} else {
cd.modifier = j = 0;
}
for (i = first; j < NUM_RGROUP_BOXES; j++, i++) {
cd.box[j].boxText = ListEntry(i, LE_DESC);
}
cd.extraBase = first;
}
/**
* Save the game using filename from selected slot & current description.
*/
void InvSaveGame(void) {
if (cd.selBox != NOBOX) {
#ifndef JAPAN
sedit[strlen(sedit)-1] = 0; // Don't include the cursor!
#endif
SaveGame(ListEntry(cd.selBox-cd.modifier+cd.extraBase, LE_NAME), sedit);
}
}
/**
* Load the selected saved game.
*/
void InvLoadGame(void) {
int rGame;
if (cd.selBox != NOBOX && (cd.selBox+cd.extraBase < cd.numSaved)) {
rGame = cd.selBox;
cd.selBox = NOBOX;
if (iconArray[HL3] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL3]);
iconArray[HL3] = NULL;
}
if (iconArray[HL2] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL2]);
iconArray[HL2] = NULL;
}
if (iconArray[HL1] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
iconArray[HL1] = NULL;
}
RestoreGame(rGame+cd.extraBase);
}
}
/**
* Edit the string in sedit[]
* Returns true if the string was altered.
*/
#ifndef JAPAN
bool UpdateString(const Common::KeyState &kbd) {
int cpos;
if (!cd.editableRgroup)
return false;
cpos = strlen(sedit)-1;
if (kbd.ascii == 0)
return false;
if (kbd.keycode == Common::KEYCODE_BACKSPACE) {
if (!cpos)
return false;
sedit[cpos] = 0;
cpos--;
sedit[cpos] = CURSOR_CHAR;
return true;
// } else if (isalnum(c) || c == ',' || c == '.' || c == '\'' || (c == ' ' && cpos != 0)) {
} else if (IsCharImage(GetTagFontHandle(), kbd.ascii) || (kbd.ascii == ' ' && cpos != 0)) {
if (cpos == SG_DESC_LEN)
return false;
sedit[cpos] = kbd.ascii;
cpos++;
sedit[cpos] = CURSOR_CHAR;
sedit[cpos+1] = 0;
return true;
}
return false;
}
#endif
/**
* Keystrokes get sent here when load/save screen is up.
*/
bool InvKeyIn(const Common::KeyState &kbd) {
if (kbd.keycode == Common::KEYCODE_PAGEUP ||
kbd.keycode == Common::KEYCODE_PAGEDOWN ||
kbd.keycode == Common::KEYCODE_HOME ||
kbd.keycode == Common::KEYCODE_END)
return true; // Key needs processing
if (kbd.keycode == 0 && kbd.ascii == 0) {
;
} else if (kbd.keycode == Common::KEYCODE_RETURN) {
return true; // Key needs processing
} else if (kbd.keycode == Common::KEYCODE_ESCAPE) {
return true; // Key needs processing
} else {
#ifndef JAPAN
if (UpdateString(kbd)) {
/*
* Delete display of text currently being edited,
* and replace it with freshly edited text.
*/
if (iconArray[HL3] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL3]);
iconArray[HL3] = NULL;
}
iconArray[HL3] = ObjectTextOut(nullContext,
GetPlayfieldList(FIELD_STATUS), sedit, 0,
InvD[ino].inventoryX + cd.box[cd.selBox].xpos + 2,
InvD[ino].inventoryY + cd.box[cd.selBox].ypos + TYOFF,
GetTagFontHandle(), 0);
if (MultiRightmost(iconArray[HL3]) > MAX_NAME_RIGHT) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL3]);
UpdateString(Common::KeyState(Common::KEYCODE_BACKSPACE));
iconArray[HL3] = ObjectTextOut(nullContext,
GetPlayfieldList(FIELD_STATUS), sedit, 0,
InvD[ino].inventoryX + cd.box[cd.selBox].xpos + 2,
InvD[ino].inventoryY + cd.box[cd.selBox].ypos + TYOFF,
GetTagFontHandle(), 0);
}
MultiSetZPosition(iconArray[HL3], Z_INV_ITEXT + 2);
}
#endif
}
return false;
}
/**
* Highlights selected box.
* If it's editable (save game), copy existing description and add a cursor.
*/
void Select(int i, bool force) {
#ifdef JAPAN
time_t secs_now;
struct tm *time_now;
#endif
i &= ~IS_MASK;
if (cd.selBox == i && !force)
return;
cd.selBox = i;
// Clear previous selected highlight and text
if (iconArray[HL2] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL2]);
iconArray[HL2] = NULL;
}
if (iconArray[HL3] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL3]);
iconArray[HL3] = NULL;
}
// New highlight box
switch (cd.box[i].boxType) {
case RGROUP:
iconArray[HL2] = RectangleObject(BgPal(),
(TinselV2 ? HighlightColour() : COL_HILIGHT), cd.box[i].w, cd.box[i].h);
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL2]);
MultiSetAniXY(iconArray[HL2],
InvD[ino].inventoryX + cd.box[i].xpos,
InvD[ino].inventoryY + cd.box[i].ypos);
// Z-position of box, and add edit text if appropriate
if (cd.editableRgroup) {
MultiSetZPosition(iconArray[HL2], Z_INV_ITEXT+1);
if (TinselV2) {
assert(cd.box[i].textMethod == TM_POINTER);
} else {
assert(cd.box[i].ixText == USE_POINTER);
}
#ifdef JAPAN
// Current date and time
time(&secs_now);
time_now = localtime(&secs_now);
strftime(sedit, SG_DESC_LEN, "%D %H:%M", time_now);
#else
// Current description with cursor appended
if (cd.box[i].boxText != NULL) {
strcpy(sedit, cd.box[i].boxText);
strcat(sedit, sCursor);
} else {
strcpy(sedit, sCursor);
}
#endif
iconArray[HL3] = ObjectTextOut(nullContext,
GetPlayfieldList(FIELD_STATUS), sedit, 0,
InvD[ino].inventoryX + cd.box[i].xpos + 2,
#ifdef JAPAN
InvD[ino].inventoryY + cd.box[i].ypos + 2,
#else
InvD[ino].inventoryY + cd.box[i].ypos + TYOFF,
#endif
GetTagFontHandle(), 0);
MultiSetZPosition(iconArray[HL3], Z_INV_ITEXT + 2);
} else {
MultiSetZPosition(iconArray[HL2], Z_INV_ICONS + 1);
}
_vm->divertKeyInput(InvKeyIn);
break;
#if defined(USE_3FLAGS) || defined(USE_4FLAGS) || defined(USE_5FLAGS)
case FRGROUP:
iconArray[HL2] = RectangleObject(BgPal(), COL_HILIGHT, cd.box[i].w+6, cd.box[i].h+6);
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL2]);
MultiSetAniXY(iconArray[HL2],
InvD[ino].inventoryX + cd.box[i].xpos - 2,
InvD[ino].inventoryY + cd.box[i].ypos - 2);
MultiSetZPosition(iconArray[HL2], Z_INV_BRECT+1);
break;
#endif
default:
break;
}
}
/**************************************************************************/
/***/
/**************************************************************************/
/**
* Stop holding an item.
*/
void DropItem(int item) {
if (HeldItem == item) {
HeldItem = INV_NOICON; // Item not held
DelAuxCursor(); // no longer aux cursor
}
// Redraw contents - held item was not displayed as a content.
ItemsChanged = true;
}
/**
* Clears the specified inventory
*/
void ClearInventory(int invno) {
assert(invno == INV_1 || invno == INV_2);
InvD[invno].NoofItems = 0;
memset(InvD[invno].contents, 0, sizeof(InvD[invno].contents));
}
/**
* Stick the item into an inventory list (contents[]), and hold the
* item if requested.
*/
void AddToInventory(int invno, int icon, bool hold) {
int i;
bool bOpen;
INV_OBJECT *invObj;
// Validate trying to add to a legal inventory
assert(invno == INV_1 || invno == INV_2 || invno == INV_CONV
|| invno == INV_OPEN || (invno == INV_DEFAULT && TinselV2));
if (invno == INV_OPEN) {
assert(InventoryState == ACTIVE_INV && (ino == INV_1 || ino == INV_2)); // addopeninv() with inventry not open
invno = ino;
bOpen = true;
// Make sure it doesn't get in both!
RemFromInventory(ino == INV_1 ? INV_2 : INV_1, icon);
} else {
bOpen = false;
if (TinselV2 && invno == INV_DEFAULT) {
invObj = GetInvObject(icon);
if (invObj->attribute & DEFINV2)
invno = INV_2;
else if (invObj->attribute & DEFINV1)
invno = INV_1;
else
invno = SysVar(SV_DEFAULT_INV);
}
}
if (invno == INV_1)
RemFromInventory(INV_2, icon);
else if (invno == INV_2)
RemFromInventory(INV_1, icon);
// See if it's already there
for (i = 0; i < InvD[invno].NoofItems; i++) {
if (InvD[invno].contents[i] == icon)
break;
}
// Add it if it isn't already there
if (i == InvD[invno].NoofItems) {
if (!bOpen) {
if (invno == INV_CONV) {
if (TinselV2) {
int nei;
// Count how many current contents have end attribute
for (i = 0, nei = 0; i < InvD[INV_CONV].NoofItems; i++) {
invObj = GetInvObject(InvD[INV_CONV].contents[i]);
if (invObj->attribute & CONVENDITEM)
nei++;
}
// For conversation, insert before end icons
memmove(&InvD[INV_CONV].contents[i-nei+1],
&InvD[INV_CONV].contents[i-nei], nei * sizeof(int));
InvD[INV_CONV].contents[i - nei] = icon;
InvD[INV_CONV].NoofItems++;
InvD[INV_CONV].NoofHicons = InvD[INV_CONV].NoofItems;
// Get the window to re-position
bMoveOnUnHide = true;
} else {
// For conversation, insert before last icon
// which will always be the goodbye icon
InvD[invno].contents[InvD[invno].NoofItems] = InvD[invno].contents[InvD[invno].NoofItems-1];
InvD[invno].contents[InvD[invno].NoofItems-1] = icon;
InvD[invno].NoofItems++;
}
} else {
InvD[invno].contents[InvD[invno].NoofItems++] = icon;
}
ItemsChanged = true;
} else {
// It could be that the index is beyond what you'd expect
// as delinv may well have been called
if (GlitterIndex < InvD[invno].NoofItems) {
memmove(&InvD[invno].contents[GlitterIndex + 1],
&InvD[invno].contents[GlitterIndex],
(InvD[invno].NoofItems - GlitterIndex) * sizeof(int));
InvD[invno].contents[GlitterIndex] = icon;
} else {
InvD[invno].contents[InvD[invno].NoofItems] = icon;
}
InvD[invno].NoofItems++;
}
// Move here after bug on Japenese DW1
ItemsChanged = true;
}
// Hold it if requested
if (hold)
HoldItem(icon);
}
/**
* Take the item from the inventory list (contents[]).
* Return FALSE if item wasn't present, true if it was.
*/
bool RemFromInventory(int invno, int icon) {
int i;
assert(invno == INV_1 || invno == INV_2 || invno == INV_CONV); // Trying to delete from illegal inventory
// See if it's there
for (i = 0; i < InvD[invno].NoofItems; i++) {
if (InvD[invno].contents[i] == icon)
break;
}
if (i == InvD[invno].NoofItems)
return false; // Item wasn't there
else {
memmove(&InvD[invno].contents[i], &InvD[invno].contents[i+1], (InvD[invno].NoofItems-i)*sizeof(int));
InvD[invno].NoofItems--;
if (TinselV2 && invno == INV_CONV) {
InvD[INV_CONV].NoofHicons = InvD[invno].NoofItems;
// Get the window to re-position
bMoveOnUnHide = true;
}
ItemsChanged = true;
return true; // Item removed
}
}
/**
* If the item is not already held, hold it.
*/
void HoldItem(int item, bool bKeepFilm) {
INV_OBJECT *invObj;
if (HeldItem != item) {
if (TinselV2 && (HeldItem != NOOBJECT)) {
// No longer holding previous item
DelAuxCursor(); // no longer aux cursor
// If old held object is not in an inventory, and
// has a default, stick it in its default inventory.
if (!IsInInventory(HeldItem, INV_1) && !IsInInventory(HeldItem, INV_2)) {
invObj = GetInvObject(HeldItem);
if (invObj->attribute & DEFINV1)
AddToInventory(INV_1, HeldItem);
else if (invObj->attribute & DEFINV2)
AddToInventory(INV_2, HeldItem);
else
// Hook for definable default inventory
AddToInventory(INV_1, HeldItem);
}
} else if (!TinselV2) {
if (item == INV_NOICON && HeldItem != INV_NOICON)
DelAuxCursor(); // no longer aux cursor
if (item != INV_NOICON) {
invObj = GetInvObject(item);
SetAuxCursor(invObj->hIconFilm); // and is aux. cursor
}
}
HeldItem = item; // Item held
if (TinselV2) {
InventoryIconCursor(!bKeepFilm);
// Redraw contents - held item not displayed as a content.
ItemsChanged = true;
}
}
if (!TinselV2)
// Redraw contents - held item not displayed as a content.
ItemsChanged = true;
}
/**************************************************************************/
/***/
/**************************************************************************/
enum { I_NOTIN, I_HEADER, I_BODY,
I_TLEFT, I_TRIGHT, I_BLEFT, I_BRIGHT,
I_TOP, I_BOTTOM, I_LEFT, I_RIGHT,
I_UP, I_SLIDE_UP, I_SLIDE, I_SLIDE_DOWN, I_DOWN,
I_ENDCHANGE
};
#define EXTRA 1 // This was introduced when we decided to increase
// the active area of the borders for re-sizing.
/*---------------------------------*/
#define LeftX InvD[ino].inventoryX
#define TopY InvD[ino].inventoryY
/*---------------------------------*/
/**
* Work out which area of the inventory window the cursor is in.
*
* This used to be worked out with appropriately defined magic numbers.
* Then the graphic changed and I got it right again. Then the graphic
* changed and I got fed up of faffing about. It's probably easier just
* to rework all this.
*/
int InvArea(int x, int y) {
if (TinselV2) {
int RightX = MultiRightmost(RectObject) - NM_BG_SIZ_X - NM_BG_POS_X - NM_RS_R_INSET;
int BottomY = MultiLowest(RectObject) - NM_BG_SIZ_Y - NM_BG_POS_Y - NM_RS_B_INSET;
// Outside the whole rectangle?
if (x <= LeftX || x > RightX || y <= TopY || y > BottomY)
return I_NOTIN;
// The bottom line
if (y > BottomY - NM_RS_THICKNESS) {
// Below top of bottom line?
if (x <= LeftX + NM_RS_THICKNESS)
return I_BLEFT; // Bottom left corner
else if (x > RightX - NM_RS_THICKNESS)
return I_BRIGHT; // Bottom right corner
else
return I_BOTTOM; // Just plain bottom
}
// The top line
if (y <= TopY + NM_RS_THICKNESS) {
// Above bottom of top line?
if (x <= LeftX + NM_RS_THICKNESS)
return I_TLEFT; // Top left corner
else if (x > RightX - NM_RS_THICKNESS)
return I_TRIGHT; // Top right corner
else
return I_TOP; // Just plain top
}
// Sides
if (x <= LeftX + NM_RS_THICKNESS) // Left of right of left side?
return I_LEFT;
else if (x > RightX - NM_RS_THICKNESS) // Right of left of right side?
return I_RIGHT;
// In the move area?
if (y < TopY + NM_MOVE_AREA_B_Y)
return I_HEADER;
// Scroll bits
if (!(ino == INV_MENU && cd.bExtraWin)) {
if (x > RightX - NM_SLIDE_INSET && x <= RightX - NM_SLIDE_INSET + NM_SLIDE_THICKNESS) {
if (y > TopY + NM_UP_ARROW_TOP && y < TopY + NM_UP_ARROW_BOTTOM)
return I_UP;
if (y > BottomY - NM_DN_ARROW_TOP && y <= BottomY - NM_DN_ARROW_BOTTOM)
return I_DOWN;
/* '3' is a magic adjustment with no apparent sense */
if (y >= TopY + sliderYmin - 3 && y < TopY + sliderYmax + NM_SLH) {
if (y < TopY + sliderYpos - 3)
return I_SLIDE_UP;
if (y < TopY + sliderYpos + NM_SLH - 3)
return I_SLIDE;
else
return I_SLIDE_DOWN;
}
}
}
} else {
int RightX = MultiRightmost(RectObject) + 1;
int BottomY = MultiLowest(RectObject) + 1;
// Outside the whole rectangle?
if (x <= LeftX - EXTRA || x > RightX + EXTRA
|| y <= TopY - EXTRA || y > BottomY + EXTRA)
return I_NOTIN;
// The bottom line
if (y > BottomY - 2 - EXTRA) { // Below top of bottom line?
if (x <= LeftX + 2 + EXTRA)
return I_BLEFT; // Bottom left corner
else if (x > RightX - 2 - EXTRA)
return I_BRIGHT; // Bottom right corner
else
return I_BOTTOM; // Just plain bottom
}
// The top line
if (y <= TopY + 2 + EXTRA) { // Above bottom of top line?
if (x <= LeftX + 2 + EXTRA)
return I_TLEFT; // Top left corner
else if (x > RightX - 2 - EXTRA)
return I_TRIGHT; // Top right corner
else
return I_TOP; // Just plain top
}
// Sides
if (x <= LeftX + 2 + EXTRA) // Left of right of left side?
return I_LEFT;
else if (x > RightX - 2 - EXTRA) // Right of left of right side?
return I_RIGHT;
// From here down still needs fixing up properly
/*
* In the move area?
*/
if (ino != INV_CONF
&& x >= LeftX + M_SW - 2 && x <= RightX - M_SW + 3 &&
y >= TopY + M_TH - 2 && y < TopY + M_TBB + 2)
return I_HEADER;
/*
* Scroll bits
*/
if (!(ino == INV_CONF && cd.bExtraWin)) {
if (x > RightX - NM_SLIDE_INSET && x <= RightX - NM_SLIDE_INSET + NM_SLIDE_THICKNESS) {
if (y > TopY + M_IUT + 1 && y < TopY + M_IUB - 1)
return I_UP;
if (y > BottomY - M_IDT + 4 && y <= BottomY - M_IDB + 1)
return I_DOWN;
if (y >= TopY + sliderYmin && y < TopY + sliderYmax + M_SH) {
if (y < TopY + sliderYpos)
return I_SLIDE_UP;
if (y < TopY + sliderYpos + M_SH)
return I_SLIDE;
else
return I_SLIDE_DOWN;
}
}
}
}
return I_BODY;
}
/**
* Returns the id of the icon displayed under the given position.
* Also return co-ordinates of items tag display position, if requested.
*/
int InvItem(int *x, int *y, bool update) {
int itop, ileft;
int row, col;
int item;
int IconsX;
itop = InvD[ino].inventoryY + START_ICONY;
IconsX = InvD[ino].inventoryX + START_ICONX;
for (item = InvD[ino].FirstDisp, row = 0; row < InvD[ino].NoofVicons; row++) {
ileft = IconsX;
for (col = 0; col < InvD[ino].NoofHicons; col++, item++) {
if (*x >= ileft && *x < ileft + ITEM_WIDTH &&
*y >= itop && *y < itop + ITEM_HEIGHT) {
if (update) {
*x = ileft + ITEM_WIDTH/2;
*y = itop /*+ ITEM_HEIGHT/4*/;
}
return item;
}
ileft += ITEM_WIDTH + 1;
}
itop += ITEM_HEIGHT + 1;
}
return INV_NOICON;
}
int InvItem(Common::Point &coOrds, bool update) {
int x = coOrds.x;
int y = coOrds.y;
return InvItem(&x, &y, update);
coOrds.x = x;
coOrds.y = y;
}
/**
* Returns the id of the icon displayed under the given position.
*/
int InvItemId(int x, int y) {
int itop, ileft;
int row, col;
int item;
if (InventoryHidden || InventoryState == IDLE_INV)
return INV_NOICON;
itop = InvD[ino].inventoryY + START_ICONY;
int IconsX = InvD[ino].inventoryX + START_ICONX;
for (item = InvD[ino].FirstDisp, row = 0; row < InvD[ino].NoofVicons; row++) {
ileft = IconsX;
for (col = 0; col < InvD[ino].NoofHicons; col++, item++) {
if (x >= ileft && x < ileft + ITEM_WIDTH &&
y >= itop && y < itop + ITEM_HEIGHT) {
return InvD[ino].contents[item];
}
ileft += ITEM_WIDTH + 1;
}
itop += ITEM_HEIGHT + 1;
}
return INV_NOICON;
}
/**
* Finds which box the cursor is in.
*/
static int WhichMenuBox(int curX, int curY, bool bSlides) {
if (bSlides) {
for (int i = 0; i < numMdSlides; i++) {
if (curY > MultiHighest(mdSlides[i].obj) && curY < MultiLowest(mdSlides[i].obj)
&& curX > MultiLeftmost(mdSlides[i].obj) && curX < MultiRightmost(mdSlides[i].obj))
return mdSlides[i].num | IS_SLIDER;
}
}
curX -= InvD[ino].inventoryX;
curY -= InvD[ino].inventoryY;
for (int i = 0; i < cd.NumBoxes; i++) {
switch (cd.box[i].boxType) {
case SLIDER:
if (bSlides) {
if (curY >= cd.box[i].ypos+MD_YBUTTOP && curY < cd.box[i].ypos+MD_YBUTBOT) {
if (curX >= cd.box[i].xpos+MD_XLBUTL && curX < cd.box[i].xpos+MD_XLBUTR)
return i | IS_LEFT;
if (curX >= cd.box[i].xpos+MD_XRBUTL && curX < cd.box[i].xpos+MD_XRBUTR)
return i | IS_RIGHT;
}
}
break;
case AAGBUT:
case ARSGBUT:
case TOGGLE:
case TOGGLE1:
case TOGGLE2:
case FLIP:
if (curY > cd.box[i].ypos && curY < cd.box[i].ypos + cd.box[i].h
&& curX > cd.box[i].xpos && curX < cd.box[i].xpos + cd.box[i].w)
return i;
break;
case ROTATE:
if (bNoLanguage)
break;
if (curY > cd.box[i].ypos && curY < cd.box[i].ypos + cd.box[i].h) {
// Left one?
if (curX > cd.box[i].xpos-ROTX1 && curX < cd.box[i].xpos-ROTX1 + cd.box[i].w) {
cd.box[i].bi = IX2_LEFT1;
return i;
}
// Right one?
if (curX > cd.box[i].xpos+ROTX1 && curX < cd.box[i].xpos+ROTX1 + cd.box[i].w) {
cd.box[i].bi = IX2_RIGHT1;
return i;
}
}
break;
default:
// 'Normal' box
if (curY >= cd.box[i].ypos && curY < cd.box[i].ypos + cd.box[i].h
&& curX >= cd.box[i].xpos && curX < cd.box[i].xpos + cd.box[i].w)
return i;
break;
}
}
// Slider on extra window
if (cd.bExtraWin) {
const Common::Rect &r = TinselV2 ?
Common::Rect(411, 46, 425, 339) :
Common::Rect(20 + 181, 24 + 2, 20 + 181 + 8, 24 + 139 + 5);
if (r.contains(curX, curY)) {
if (curY < (r.top + (TinselV2 ? 18 : 5)))
return IB_UP;
else if (curY > (r.bottom - (TinselV2 ? 18 : 5)))
return IB_DOWN;
else if (curY + InvD[ino].inventoryY < sliderYpos)
return IB_SLIDE_UP;
else if (curY + InvD[ino].inventoryY >= sliderYpos + NM_SLH)
return IB_SLIDE_DOWN;
else
return IB_SLIDE;
}
}
return IB_NONE;
}
/**************************************************************************/
/***/
/**************************************************************************/
#define ROTX1 60 // Rotate button's offsets from the centre
/**
* InvBoxes
*/
void InvBoxes(bool InBody, int curX, int curY) {
static int rotateIndex = -1;
int index; // Box pointed to on this call
const FILM *pfilm;
// Find out which icon is currently pointed to
if (!InBody)
index = -1;
else {
index = WhichMenuBox(curX, curY, false);
}
// If no icon pointed to, or points to (logical position of)
// currently held icon, then no icon is pointed to!
if (index < 0) {
// unhigh-light box (if one was)
cd.pointBox = NOBOX;
if (iconArray[HL1] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
iconArray[HL1] = NULL;
}
} else if (index != cd.pointBox) {
cd.pointBox = index;
// A new box is pointed to - high-light it
if (iconArray[HL1] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
iconArray[HL1] = NULL;
}
if ((cd.box[cd.pointBox].boxType == ARSBUT && cd.selBox != NOBOX) ||
///* I don't agree */ cd.box[cd.pointBox].boxType == RGROUP ||
cd.box[cd.pointBox].boxType == AATBUT ||
cd.box[cd.pointBox].boxType == AABUT) {
iconArray[HL1] = RectangleObject(BgPal(),
(TinselV2 ? HighlightColour() : COL_HILIGHT),
cd.box[cd.pointBox].w, cd.box[cd.pointBox].h);
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
MultiSetAniXY(iconArray[HL1],
InvD[ino].inventoryX + cd.box[cd.pointBox].xpos,
InvD[ino].inventoryY + cd.box[cd.pointBox].ypos);
MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1);
}
else if (cd.box[cd.pointBox].boxType == AAGBUT ||
cd.box[cd.pointBox].boxType == ARSGBUT ||
cd.box[cd.pointBox].boxType == TOGGLE ||
cd.box[cd.pointBox].boxType == TOGGLE1 ||
cd.box[cd.pointBox].boxType == TOGGLE2) {
pfilm = (const FILM *)LockMem(hWinParts);
iconArray[HL1] = AddObject(&pfilm->reels[cd.box[cd.pointBox].bi+HIGRAPH], -1);
MultiSetAniXY(iconArray[HL1],
InvD[ino].inventoryX + cd.box[cd.pointBox].xpos,
InvD[ino].inventoryY + cd.box[cd.pointBox].ypos);
MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1);
}
else if (cd.box[cd.pointBox].boxType == ROTATE) {
if (bNoLanguage)
return;
pfilm = (const FILM *)LockMem(hWinParts);
rotateIndex = cd.box[cd.pointBox].bi;
if (rotateIndex == IX2_LEFT1) {
iconArray[HL1] = AddObject(&pfilm->reels[IX2_LEFT2], -1 );
MultiSetAniXY(iconArray[HL1],
InvD[ino].inventoryX + cd.box[cd.pointBox].xpos - ROTX1,
InvD[ino].inventoryY + cd.box[cd.pointBox].ypos);
MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1);
} else if (rotateIndex == IX2_RIGHT1) {
iconArray[HL1] = AddObject(&pfilm->reels[IX2_RIGHT2], -1);
MultiSetAniXY(iconArray[HL1],
InvD[ino].inventoryX + cd.box[cd.pointBox].xpos + ROTX1,
InvD[ino].inventoryY + cd.box[cd.pointBox].ypos);
MultiSetZPosition(iconArray[HL1], Z_INV_ICONS + 1);
}
}
}
}
static void ButtonPress(CORO_PARAM, CONFBOX *box) {
CORO_BEGIN_CONTEXT;
CORO_END_CONTEXT(_ctx);
CORO_BEGIN_CODE(_ctx);
const FILM *pfilm;
assert(box->boxType == AAGBUT || box->boxType == ARSGBUT);
// Replace highlight image with normal image
pfilm = (const FILM *)LockMem(hWinParts);
if (iconArray[HL1] != NULL)
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
pfilm = (const FILM *)LockMem(hWinParts);
iconArray[HL1] = AddObject(&pfilm->reels[box->bi+NORMGRAPH], -1);
MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos);
MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1);
// Hold normal image for 1 frame
CORO_SLEEP(1);
if (iconArray[HL1] == NULL)
return;
// Replace normal image with depresses image
pfilm = (const FILM *)LockMem(hWinParts);
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1);
MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos);
MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1);
// Hold depressed image for 2 frames
CORO_SLEEP(2);
if (iconArray[HL1] == NULL)
return;
// Replace depressed image with normal image
pfilm = (const FILM *)LockMem(hWinParts);
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
iconArray[HL1] = AddObject(&pfilm->reels[box->bi+NORMGRAPH], -1);
MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos);
MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1);
CORO_SLEEP(1);
CORO_END_CODE;
}
static void ButtonToggle(CORO_PARAM, CONFBOX *box) {
CORO_BEGIN_CONTEXT;
CORO_END_CONTEXT(_ctx);
CORO_BEGIN_CODE(_ctx);
const FILM *pfilm;
assert((box->boxType == TOGGLE) || (box->boxType == TOGGLE1)
|| (box->boxType == TOGGLE2));
// Remove hilight image
if (iconArray[HL1] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
iconArray[HL1] = NULL;
}
// Hold normal image for 1 frame
CORO_SLEEP(1);
if (InventoryState != ACTIVE_INV)
return;
// Add depressed image
pfilm = (const FILM *)LockMem(hWinParts);
iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1);
MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos);
MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1);
// Hold depressed image for 1 frame
CORO_SLEEP(1);
if (iconArray[HL1] == NULL)
return;
// Toggle state
(*box->ival) = *(box->ival) ^ 1; // XOR with true
box->bi = *(box->ival) ? IX_TICK1 : IX_CROSS1;
AddBoxes(false);
// Keep highlight (e.g. flag)
if (cd.selBox != NOBOX)
Select(cd.selBox, true);
// New state, depressed image
pfilm = (const FILM *)LockMem(hWinParts);
if (iconArray[HL1] != NULL)
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1);
MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos);
MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1);
// Hold new depressed image for 1 frame
CORO_SLEEP(1);
if (iconArray[HL1] == NULL)
return;
// New state, normal
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
iconArray[HL1] = NULL;
// Hold normal image for 1 frame
CORO_SLEEP(1);
if (InventoryState != ACTIVE_INV)
return;
// New state, highlighted
pfilm = (const FILM *)LockMem(hWinParts);
if (iconArray[HL1] != NULL)
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]);
iconArray[HL1] = AddObject(&pfilm->reels[box->bi+HIGRAPH], -1);
MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos);
MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1);
CORO_END_CODE;
}
/**
* Monitors for POINTED event for inventory icons.
*/
void InvLabels(bool InBody, int aniX, int aniY) {
int index; // Icon pointed to on this call
INV_OBJECT *invObj;
// Find out which icon is currently pointed to
if (!InBody)
index = INV_NOICON;
else {
index = InvItem(&aniX, &aniY, false);
if (index != INV_NOICON) {
if (index >= InvD[ino].NoofItems)
index = INV_NOICON;
else
index = InvD[ino].contents[index];
}
}
// If no icon pointed to, or points to (logical position of)
// currently held icon, then no icon is pointed to!
if (index == INV_NOICON || index == HeldItem) {
pointedIcon = INV_NOICON;
} else if (index != pointedIcon) {
// A new icon is pointed to - run its script with POINTED event
invObj = GetInvObject(index);
if (invObj->hScript)
InvTinselEvent(invObj, POINTED, PLR_NOEVENT, index);
pointedIcon = index;
}
}
/**************************************************************************/
/***/
/**************************************************************************/
/**
* All to do with the slider.
* I can't remember how it works - or, indeed, what it does.
* It seems to set up slideStuff[], an array of possible first-displayed
* icons set against the matching y-positions of the slider.
*/
void AdjustTop(void) {
int tMissing, bMissing, nMissing;
int nsliderYpos;
int rowsWanted;
int slideRange;
int n, i;
// Only do this if there's a slider
if (!SlideObject)
return;
rowsWanted = (InvD[ino].NoofItems - InvD[ino].FirstDisp + InvD[ino].NoofHicons-1) / InvD[ino].NoofHicons;
while (rowsWanted < InvD[ino].NoofVicons) {
if (InvD[ino].FirstDisp) {
InvD[ino].FirstDisp -= InvD[ino].NoofHicons;
if (InvD[ino].FirstDisp < 0)
InvD[ino].FirstDisp = 0;
rowsWanted++;
} else
break;
}
tMissing = InvD[ino].FirstDisp ? (InvD[ino].FirstDisp + InvD[ino].NoofHicons-1)/InvD[ino].NoofHicons : 0;
bMissing = (rowsWanted > InvD[ino].NoofVicons) ? rowsWanted - InvD[ino].NoofVicons : 0;
nMissing = tMissing + bMissing;
slideRange = sliderYmax - sliderYmin;
if (!tMissing)
nsliderYpos = sliderYmin;
else if (!bMissing)
nsliderYpos = sliderYmax;
else {
nsliderYpos = tMissing*slideRange/nMissing;
nsliderYpos += sliderYmin;
}
if (nMissing) {
n = InvD[ino].FirstDisp - tMissing*InvD[ino].NoofHicons;
for (i = 0; i <= nMissing; i++, n += InvD[ino].NoofHicons) {
slideStuff[i].n = n;
slideStuff[i].y = (i*slideRange/nMissing) + sliderYmin;
}
if (slideStuff[0].n < 0)
slideStuff[0].n = 0;
assert(i < MAX_ININV + 1);
slideStuff[i].n = -1;
} else {
slideStuff[0].n = 0;
slideStuff[0].y = sliderYmin;
slideStuff[1].n = -1;
}
if (nsliderYpos != sliderYpos) {
MultiMoveRelXY(SlideObject, 0, nsliderYpos - sliderYpos);
sliderYpos = nsliderYpos;
}
}
/**
* Insert an inventory icon object onto the display list.
*/
OBJECT *AddInvObject(int num, const FREEL **pfreel, const FILM **pfilm) {
INV_OBJECT *invObj; // Icon data
const MULTI_INIT *pmi; // Its INIT structure - from the reel
IMAGE *pim; // ... you get the picture
OBJECT *pPlayObj; // The object we insert
invObj = GetInvObject(num);
// Get pointer to image
pim = GetImageFromFilm(invObj->hIconFilm, 0, pfreel, &pmi, pfilm);
// Poke in the background palette
pim->hImgPal = TO_LE_32(BgPal());
// Set up the multi-object
pPlayObj = MultiInitObject(pmi);
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), pPlayObj);
return pPlayObj;
}
/**
* Create display objects for the displayed icons in an inventory window.
*/
void FillInInventory(void) {
int Index; // Index into contents[]
int n = 0; // index into iconArray[]
int xpos, ypos;
int row, col;
const FREEL *pfr;
const FILM *pfilm;
DumpIconArray();
if (InvDragging != ID_SLIDE)
AdjustTop(); // Set up slideStuff[]
Index = InvD[ino].FirstDisp; // Start from first displayed object
n = 0;
ypos = START_ICONY; // Y-offset of first display row
for (row = 0; row < InvD[ino].NoofVicons; row++, ypos += ITEM_HEIGHT + 1) {
xpos = START_ICONX; // X-offset of first display column
for (col = 0; col < InvD[ino].NoofHicons; col++) {
if (Index >= InvD[ino].NoofItems)
break;
else if (InvD[ino].contents[Index] != HeldItem) {
// Create a display object and position it
iconArray[n] = AddInvObject(InvD[ino].contents[Index], &pfr, &pfilm);
MultiSetAniXY(iconArray[n], InvD[ino].inventoryX + xpos , InvD[ino].inventoryY + ypos);
MultiSetZPosition(iconArray[n], Z_INV_ICONS);
InitStepAnimScript(&iconAnims[n], iconArray[n], FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pfilm->frate));
n++;
}
Index++;
xpos += ITEM_WIDTH + 1; // X-offset of next display column
}
}
}
enum {FROM_HANDLE, FROM_STRING};
/**
* Set up a rectangle as the background to the inventory window.
* Additionally, sticks the window title up.
*/
static void AddBackground(OBJECT **rect, OBJECT **title, int extraH, int extraV, int textFrom) {
// Why not 2 ????
int width = TLwidth + extraH + TRwidth + NM_BG_SIZ_X;
int height = TLheight + extraV + BLheight + NM_BG_SIZ_Y;
// Create a rectangle object
RectObject = *rect = TranslucentObject(width, height);
// add it to display list and position it
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), *rect);
MultiSetAniXY(*rect, InvD[ino].inventoryX + NM_BG_POS_X,
InvD[ino].inventoryY + NM_BG_POS_Y);
MultiSetZPosition(*rect, Z_INV_BRECT);
if (title == NULL)
return;
// Create text object using title string
CoroContext dummyCoro;
if (textFrom == FROM_HANDLE) {
LoadStringRes(InvD[ino].hInvTitle, TextBufferAddr(), TBUFSZ);
*title = ObjectTextOut(dummyCoro, GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0,
InvD[ino].inventoryX + width/2, InvD[ino].inventoryY + M_TOFF,
GetTagFontHandle(), TXT_CENTRE);
assert(*title); // Inventory title string produced NULL text
MultiSetZPosition(*title, Z_INV_HTEXT);
} else if (textFrom == FROM_STRING && cd.ixHeading != NO_HEADING) {
LoadStringRes(configStrings[cd.ixHeading], TextBufferAddr(), TBUFSZ);
*title = ObjectTextOut(dummyCoro, GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0,
InvD[ino].inventoryX + width/2, InvD[ino].inventoryY + M_TOFF,
GetTagFontHandle(), TXT_CENTRE);
assert(*title); // Inventory title string produced NULL text
MultiSetZPosition(*title, Z_INV_HTEXT);
}
}
/**
* Set up a rectangle as the background to the inventory window.
*/
static void AddBackground(OBJECT **rect, int extraH, int extraV) {
AddBackground(rect, NULL, extraH, extraV, 0);
}
/**
* Adds a title for a dialog
*/
static void AddTitle(POBJECT *title, int extraH) {
int width = TLwidth + extraH + TRwidth + NM_BG_SIZ_X;
// Create text object using title string
if (InvD[ino].hInvTitle != (SCNHANDLE)NO_HEADING) {
LoadStringRes(InvD[ino].hInvTitle, TextBufferAddr(), TBUFSZ);
*title = ObjectTextOut(nullContext, GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0,
InvD[ino].inventoryX + (width/2)+NM_BG_POS_X, InvD[ino].inventoryY + NM_TOFF,
GetTagFontHandle(), TXT_CENTRE, 0);
assert(*title);
MultiSetZPosition(*title, Z_INV_HTEXT);
}
}
/**
* Insert a part of the inventory window frame onto the display list.
*/
static OBJECT *AddObject(const FREEL *pfreel, int num) {
const MULTI_INIT *pmi; // Get the MULTI_INIT structure
IMAGE *pim;
OBJECT *pPlayObj;
// Get pointer to image
pim = GetImageFromReel(pfreel, &pmi);
// Poke in the background palette
pim->hImgPal = TO_LE_32(BgPal());
// Horrible bodge involving global variables to save
// width and/or height of some window frame components
if (num == TL) {
TLwidth = FROM_LE_16(pim->imgWidth);
TLheight = FROM_LE_16(pim->imgHeight) & ~C16_FLAG_MASK;
} else if (num == TR) {
TRwidth = FROM_LE_16(pim->imgWidth);
} else if (num == BL) {
BLheight = FROM_LE_16(pim->imgHeight) & ~C16_FLAG_MASK;
}
// Set up and insert the multi-object
pPlayObj = MultiInitObject(pmi);
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), pPlayObj);
return pPlayObj;
}
/**
* Display the scroll bar slider.
*/
void AddSlider(OBJECT **slide, const FILM *pfilm) {
SlideObject = *slide = AddObject(&pfilm->reels[IX_SLIDE], -1);
MultiSetAniXY(*slide, MultiRightmost(RectObject) + (TinselV2 ? NM_SLX : -M_SXOFF + 2) - 1,
InvD[ino].inventoryY + sliderYpos);
MultiSetZPosition(*slide, Z_INV_MFRAME);
}
/**
* Display a box with some text in it.
*/
void AddBox(int *pi, int i) {
int x = InvD[ino].inventoryX + cd.box[i].xpos;
int y = InvD[ino].inventoryY + cd.box[i].ypos;
int *pival = cd.box[i].ival;
int xdisp;
const FILM *pFilm;
switch (cd.box[i].boxType) {
default:
// Ignore if it's a blank scene hopper box
if (TinselV2 && (cd.box[i].textMethod == TM_NONE))
break;
// Give us a box
iconArray[*pi] = RectangleObject(BgPal(), TinselV2 ? BoxColour() : COL_BOX,
cd.box[i].w, cd.box[i].h);
MultiInsertObject(GetPlayfieldList(FIELD_STATUS), iconArray[*pi]);
MultiSetAniXY(iconArray[*pi], x, y);
MultiSetZPosition(iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1;
// Stick in the text
if ((cd.box[i].textMethod == TM_POINTER) ||
(!TinselV2 && (cd.box[i].ixText == USE_POINTER))) {
if (cd.box[i].boxText != NULL) {
if (cd.box[i].boxType == RGROUP) {
iconArray[*pi] = ObjectTextOut(nullContext, GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0,
#ifdef JAPAN
x + 2, y+2, GetTagFontHandle(), 0);
#else
x + 2, y + TYOFF, GetTagFontHandle(), 0);
#endif
} else {
iconArray[*pi] = ObjectTextOut(nullContext, GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0,
#ifdef JAPAN
// Note: it never seems to go here!
x + cd.box[i].w/2, y+2, GetTagFontHandle(), TXT_CENTRE);
#else
x + cd.box[i].w / 2, y + TYOFF, GetTagFontHandle(), TXT_CENTRE);
#endif
}
MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
}
} else {
if (TinselV2) {
if (cd.box[i].textMethod == TM_INDEX)
LoadStringRes(SysString(cd.box[i].ixText), TextBufferAddr(), TBUFSZ);
else {
assert(cd.box[i].textMethod == TM_STRINGNUM);
LoadStringRes(cd.box[i].ixText, TextBufferAddr(), TBUFSZ);
}
} else {
LoadStringRes(configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ);
assert(cd.box[i].boxType != RGROUP); // You'll need to add some code!
}
if (TinselV2 && (cd.box[i].boxType == RGROUP))
iconArray[*pi] = ObjectTextOut(nullContext, GetPlayfieldList(FIELD_STATUS), TextBufferAddr(),
0, x + 2, y + TYOFF, GetTagFontHandle(), 0, 0);
else
iconArray[*pi] = ObjectTextOut(nullContext, GetPlayfieldList(FIELD_STATUS),
TextBufferAddr(), 0,
#ifdef JAPAN
x + cd.box[i].w/2, y+2, GetTagFontHandle(), TXT_CENTRE);
#else
x + cd.box[i].w / 2, y + TYOFF, GetTagFontHandle(), TXT_CENTRE);
#endif
MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
}
break;
case AAGBUT:
case ARSGBUT:
pFilm = (const FILM *)LockMem(hWinParts);
iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + NORMGRAPH], -1);
MultiSetAniXY(iconArray[*pi], x, y);
MultiSetZPosition(iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1;
break;
#if defined(USE_3FLAGS) || defined(USE_4FLAGS) || defined(USE_5FLAGS)
case FRGROUP:
assert(flagFilm != 0); // Language flags not declared!
pFilm = (const FILM *)LockMem(flagFilm);
if (bAmerica && cd.box[i].bi == FIX_UK)
cd.box[i].bi = FIX_USA;
iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi], -1);
MultiSetAniXY(iconArray[*pi], x, y);
MultiSetZPosition(iconArray[*pi], Z_INV_BRECT+2);
*pi += 1;
break;
#endif
case FLIP:
pFilm = (const FILM *)LockMem(hWinParts);
if (*(cd.box[i].ival))
iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi], -1);
else
iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi+1], -1);
MultiSetAniXY(iconArray[*pi], x, y);
MultiSetZPosition(iconArray[*pi], Z_INV_BRECT+1);
*pi += 1;
// Stick in the text
if (TinselV2) {
assert(cd.box[i].textMethod == TM_INDEX);
LoadStringRes(SysString(cd.box[i].ixText), TextBufferAddr(), TBUFSZ);
} else {
assert(cd.box[i].ixText != USE_POINTER);
LoadStringRes(configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ);
}
iconArray[*pi] = ObjectTextOut(nullContext, GetPlayfieldList(FIELD_STATUS),
TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF, GetTagFontHandle(), TXT_RIGHT);
MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
break;
case TOGGLE:
case TOGGLE1:
case TOGGLE2:
pFilm = (const FILM *)LockMem(hWinParts);
cd.box[i].bi = *(cd.box[i].ival) ? IX_TICK1 : IX_CROSS1;
iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + NORMGRAPH], -1);
MultiSetAniXY(iconArray[*pi], x, y);
MultiSetZPosition(iconArray[*pi], Z_INV_BRECT+1);
*pi += 1;
// Stick in the text
if (TinselV2) {
assert(cd.box[i].textMethod == TM_INDEX);
LoadStringRes(SysString(cd.box[i].ixText), TextBufferAddr(), TBUFSZ);
} else {
assert(cd.box[i].ixText != USE_POINTER);
LoadStringRes(configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ);
}
if (cd.box[i].boxType == TOGGLE2) {
iconArray[*pi] = ObjectTextOut(nullContext, GetPlayfieldList(FIELD_STATUS),
TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF,
GetTagFontHandle(), TXT_CENTRE, 0);
} else {
iconArray[*pi] = ObjectTextOut(nullContext, GetPlayfieldList(FIELD_STATUS),
TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF,
GetTagFontHandle(), TXT_RIGHT, 0);
}
MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
break;
case SLIDER:
pFilm = (const FILM *)LockMem(hWinParts);
xdisp = SLIDE_RANGE*(*pival)/cd.box[i].w;
iconArray[*pi] = AddObject(&pFilm->reels[IX_MDGROOVE], -1);
MultiSetAniXY(iconArray[*pi], x, y);
MultiSetZPosition(iconArray[*pi], Z_MDGROOVE);
*pi += 1;
iconArray[*pi] = AddObject(&pFilm->reels[IX_MDSLIDER], -1);
MultiSetAniXY(iconArray[*pi], x+SLIDE_MINX+xdisp, y);
MultiSetZPosition(iconArray[*pi], Z_MDSLIDER);
assert(numMdSlides < MAXSLIDES);
mdSlides[numMdSlides].num = i;
mdSlides[numMdSlides].min = x + SLIDE_MINX;
mdSlides[numMdSlides].max = x + SLIDE_MAXX;
mdSlides[numMdSlides++].obj = iconArray[*pi];
*pi += 1;
// Stick in the text
if (TinselV2) {
assert(cd.box[i].textMethod == TM_INDEX);
LoadStringRes(SysString(cd.box[i].ixText), TextBufferAddr(), TBUFSZ);
} else {
assert(cd.box[i].ixText != USE_POINTER);
LoadStringRes(configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ);
}
iconArray[*pi] = ObjectTextOut(nullContext, GetPlayfieldList(FIELD_STATUS),
TextBufferAddr(), 0, x+MDTEXT_XOFF, y+MDTEXT_YOFF, GetTagFontHandle(), TXT_RIGHT);
MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
break;
case ROTATE:
pFilm = (const FILM *)LockMem(hWinParts);
// Left one
if (!bNoLanguage) {
iconArray[*pi] = AddObject(&pFilm->reels[IX2_LEFT1], -1);
MultiSetAniXY(iconArray[*pi], x-ROTX1, y);
MultiSetZPosition(iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1;
// Right one
iconArray[*pi] = AddObject( &pFilm->reels[IX2_RIGHT1], -1);
MultiSetAniXY(iconArray[*pi], x + ROTX1, y);
MultiSetZPosition(iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1;
// Stick in the text
assert(cd.box[i].textMethod == TM_INDEX);
LoadStringRes(SysString(cd.box[i].ixText), TextBufferAddr(), TBUFSZ);
iconArray[*pi] = ObjectTextOut(nullContext, GetPlayfieldList(FIELD_STATUS),
TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF,
GetTagFontHandle(), TXT_CENTRE, 0);
MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
}
// Current language's text
if (LanguageDesc(displayedLanguage) == 0)
break;
LoadStringRes(LanguageDesc(displayedLanguage), TextBufferAddr(), TBUFSZ);
iconArray[*pi] = ObjectTextOut(nullContext, GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0,
x + cd.box[i].w / 2, y + ROT_YOFF, GetTagFontHandle(), TXT_CENTRE, 0);
MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT);
*pi += 1;
// Current language's flag
pFilm = (const FILM *)LockMem(LanguageFlag(displayedLanguage));
iconArray[*pi] = AddObject(&pFilm->reels[0], -1);
MultiSetAniXY(iconArray[*pi], x + FLAGX, y + FLAGY);
MultiSetZPosition(iconArray[*pi], Z_INV_BRECT + 1);
*pi += 1;
break;
}
}
/**
* Display some boxes.
*/
static void AddBoxes(bool bPosnSlide) {
int objCount = NUMHL; // Object count - allow for HL1, HL2 etc.
DumpIconArray();
numMdSlides = 0;
for (int i = 0; i < cd.NumBoxes; i++) {
AddBox(&objCount, i);
}
if (cd.bExtraWin) {
if (bPosnSlide && !TinselV2)
sliderYpos = sliderYmin + (cd.extraBase*(sliderYmax-sliderYmin))/(MAX_SAVED_FILES-NUM_RGROUP_BOXES);
else if (bPosnSlide) {
// Tinsel 2 bPosnSlide code
int lastY = sliderYpos;
if (cd.box == loadBox || cd.box == saveBox)
sliderYpos = sliderYmin + (cd.extraBase * (sliderRange)) /
(MAX_SAVED_FILES - NUM_RGROUP_BOXES);
else if (cd.box == hopperBox1) {
if (numScenes <= NUM_RGROUP_BOXES)
sliderYpos = sliderYmin;
else
sliderYpos = sliderYmin + (cd.extraBase*(sliderRange))/(numScenes-NUM_RGROUP_BOXES);
} else if (cd.box == hopperBox2) {
if (numEntries <= NUM_RGROUP_BOXES)
sliderYpos = sliderYmin;
else
sliderYpos = sliderYmin + (cd.extraBase * (sliderRange)) /
(numEntries-NUM_RGROUP_BOXES);
}
MultiMoveRelXY(SlideObject, 0, sliderYpos - lastY);
}
if (!TinselV2)
MultiSetAniXY(SlideObject, InvD[ino].inventoryX + 24 + 179, sliderYpos);
}
assert(objCount < MAX_ICONS); // added too many icons
}
/**
* Display the scroll bar slider.
*/
void AddEWSlider(OBJECT **slide, const FILM *pfilm) {
SlideObject = *slide = AddObject(&pfilm->reels[IX_SLIDE], -1);
MultiSetAniXY(*slide, InvD[ino].inventoryX + 24 + 127, sliderYpos);
MultiSetZPosition(*slide, Z_INV_MFRAME);
}
/**
* AddExtraWindow
*/
int AddExtraWindow(int x, int y, OBJECT **retObj) {
int n = 0;
const FILM *pfilm;
// Get the frame's data
pfilm = (const FILM *)LockMem(hWinParts);
x += TinselV2 ? 30 : 20;
y += TinselV2 ? 38 : 24;
// Draw the four corners
retObj[n] = AddObject(&pfilm->reels[IX_RTL], -1); // Top left
MultiSetAniXY(retObj[n], x, y);
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
retObj[n] = AddObject(&pfilm->reels[IX_NTR], -1); // Top right
MultiSetAniXY(retObj[n], x + (TinselV2 ? TLwidth + 312 : 152), y);
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
retObj[n] = AddObject(&pfilm->reels[IX_BL], -1); // Bottom left
MultiSetAniXY(retObj[n], x, y + (TinselV2 ? TLheight + 208 : 124));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
retObj[n] = AddObject(&pfilm->reels[IX_BR], -1); // Bottom right
MultiSetAniXY(retObj[n], x + (TinselV2 ? TLwidth + 312 : 152),
y + (TinselV2 ? TLheight + 208 : 124));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
// Draw the edges
retObj[n] = AddObject(&pfilm->reels[IX_H156], -1); // Top
MultiSetAniXY(retObj[n], x + (TinselV2 ? TLwidth : 6), y + NM_TBT);
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
retObj[n] = AddObject(&pfilm->reels[IX_H156], -1); // Bottom
MultiSetAniXY(retObj[n], x + (TinselV2 ? TLwidth : 6), y +
(TinselV2 ? TLheight + 208 + BLheight + NM_BSY : 143));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
retObj[n] = AddObject(&pfilm->reels[IX_V104], -1); // Left
MultiSetAniXY(retObj[n], x + NM_LSX, y + (TinselV2 ? TLheight : 20));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
retObj[n] = AddObject(&pfilm->reels[IX_V104], -1); // Right 1
MultiSetAniXY(retObj[n], x + (TinselV2 ? TLwidth + 312 + TRwidth + NM_RSX : 179),
y + (TinselV2 ? TLheight : 20));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
retObj[n] = AddObject(&pfilm->reels[IX_V104], -1); // Right 2
MultiSetAniXY(retObj[n], x + (TinselV2 ? TLwidth + 312 + TRwidth + NM_SBL : 188),
y + (TinselV2 ? TLheight : 20));
MultiSetZPosition(retObj[n], Z_INV_MFRAME);
n++;
if (TinselV2) {
sliderYpos = sliderYmin = y + 27;
sliderYmax = y + 273;
retObj[n++] = SlideObject = AddObject( &pfilm->reels[IX_SLIDE], -1);
MultiSetAniXY(SlideObject,
x + TLwidth + 320 + TRwidth - NM_BG_POS_X + NM_BG_SIZ_X - 2,
sliderYpos);
MultiSetZPosition(SlideObject, Z_INV_MFRAME);
} else {
sliderYpos = sliderYmin = y + 9;
sliderYmax = y + 134;
AddEWSlider(&retObj[n++], pfilm);
}
return n;
}
enum InventoryType { EMPTY, FULL, CONF };
/**
* Construct an inventory window - either a standard one, with
* background, slider and icons, or a re-sizing window.
*/
void ConstructInventory(InventoryType filling) {
int eH, eV; // Extra width and height
int n = 0; // Index into object array
int zpos; // Z-position of frame
int invX = InvD[ino].inventoryX;
int invY = InvD[ino].inventoryY;
OBJECT **retObj;
const FILM *pfilm;
extern bool RePosition(void); // Forward reference
// Select the object array to use
if (filling == FULL || filling == CONF) {
retObj = objArray; // Standard window
zpos = Z_INV_MFRAME;
} else {
retObj = DobjArray; // Re-sizing window
zpos = Z_INV_RFRAME;
}
// Dispose of anything it may be replacing
for (int i = 0; i < MAX_WCOMP; i++) {
if (retObj[i] != NULL) {
MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), retObj[i]);
retObj[i] = NULL;
}
}
// Get the frame's data
pfilm = (const FILM *)LockMem(hWinParts);
// Standard window is of granular dimensions
if (filling == FULL) {
// Round-up/down to nearest number of icons
if (SuppH > ITEM_WIDTH / 2)
InvD[ino].NoofHicons++;
if (SuppV > ITEM_HEIGHT / 2)
InvD[ino].NoofVicons++;
SuppH = SuppV = 0;
}
// Extra width and height
eH = (InvD[ino].NoofHicons - 1) * (ITEM_WIDTH+I_SEPARATION) + SuppH;
eV = (InvD[ino].NoofVicons - 1) * (ITEM_HEIGHT+I_SEPARATION) + SuppV;
// Which window frame corners to use
if (TinselV2 && (ino == INV_CONV)) {
TL = IX_TL;
TR = IX2_TR4;
BL = IX_BL;
BR = IX_RBR;
} else if ((filling == FULL) && (ino != INV_CONV)) {
TL = IX_TL;
TR = IX_TR;
BL = IX_BL;
BR = IX_BR;
} else {
TL = IX_RTL;
TR = IX_RTR;
BL = IX_BL;
BR = IX_RBR;
}
// Draw the four corners
retObj[n] = AddObject(&pfilm->reels[TL], TL);
MultiSetAniXY(retObj[n], invX, invY);
MultiSetZPosition(retObj[n], zpos);
n++;
retObj[n] = AddObject(&pfilm->reels[TR], TR);
MultiSetAniXY(retObj[n], invX + TLwidth + eH, invY);
MultiSetZPosition(retObj[n], zpos);
n++;
retObj[n] = AddObject(&pfilm->reels[BL], BL);
MultiSetAniXY(retObj[n], invX, invY + TLheight + eV);
MultiSetZPosition(retObj[n], zpos);
n++;
retObj[n] = AddObject(&pfilm->reels[BR], BR);
MultiSetAniXY(retObj[n], invX + TLwidth + eH, invY + TLheight + eV);
MultiSetZPosition(retObj[n], zpos);
n++;
// Draw extra Top and bottom parts
if (InvD[ino].NoofHicons > 1) {
// Top side
retObj[n] = AddObject(&pfilm->reels[hFillers[InvD[ino].NoofHicons-2]], -1);
MultiSetAniXY(retObj[n], invX + TLwidth, invY + NM_TBT);
MultiSetZPosition(retObj[n], zpos);
n++;
// Bottom of header box
if (filling == FULL) {
if (TinselV2) {
retObj[n] = AddObject(&pfilm->reels[hFillers[InvD[ino].NoofHicons-2]], -1);
MultiSetAniXY(retObj[n], invX + TLwidth, invY + NM_TBB);
MultiSetZPosition(retObj[n], zpos);
n++;
} else {
retObj[n] = AddObject(&pfilm->reels[hFillers[InvD[ino].NoofHicons-2]], -1);
MultiSetAniXY(retObj[n], invX + TLwidth, invY + M_TBB + 1);
MultiSetZPosition(retObj[n], zpos);
n++;
// Extra bits for conversation - hopefully temporary
if (ino == INV_CONV) {
retObj[n] = AddObject(&pfilm->reels[IX_H26], -1);
MultiSetAniXY(retObj[n], invX + TLwidth - 2, invY + M_TBB + 1);
MultiSetZPosition(retObj[n], zpos);
n++;
retObj[n] = AddObject(&pfilm->reels[IX_H52], -1);
MultiSetAniXY(retObj[n], invX + eH - 10, invY + M_TBB + 1);
MultiSetZPosition(retObj[n], zpos);
n++;
}
}
}
// Bottom side
retObj[n] = AddObject(&pfilm->reels[hFillers[InvD[ino].NoofHicons-2]], -1);
MultiSetAniXY(retObj[n], invX + TLwidth, invY + TLheight + eV + BLheight + NM_BSY);
MultiSetZPosition(retObj[n], zpos);
n++;
}
if (SuppH) {
int offx = TLwidth + eH - (TinselV2 ? ITEM_WIDTH + I_SEPARATION : 26);
if (offx < TLwidth) // Not too far!
offx = TLwidth;
// Top side extra
retObj[n] = AddObject(&pfilm->reels[IX_H26], -1);
MultiSetAniXY(retObj[n], invX + offx, invY + NM_TBT);
MultiSetZPosition(retObj[n], zpos);
n++;
// Bottom side extra
retObj[n] = AddObject(&pfilm->reels[IX_H26], -1);
MultiSetAniXY(retObj[n], invX + offx, invY + TLheight + eV + BLheight + NM_BSY);
MultiSetZPosition(retObj[n], zpos);
n++;
}
// Draw extra side parts
if (InvD[ino].NoofVicons > 1) {
// Left side
retObj[n] = AddObject(&pfilm->reels[vFillers[InvD[ino].NoofVicons-2]], -1);
MultiSetAniXY(retObj[n], invX + NM_LSX, invY + TLheight);
MultiSetZPosition(retObj[n], zpos);
n++;
// Left side of scroll bar
if (filling == FULL && ino != INV_CONV) {
retObj[n] = AddObject(&pfilm->reels[vFillers[InvD[ino].NoofVicons-2]], -1);
if (TinselV2)
MultiSetAniXY(retObj[n], invX + TLwidth + eH + TRwidth + NM_SBL, invY + TLheight);
else
MultiSetAniXY(retObj[n], invX + TLwidth + eH + M_SBL + 1, invY + TLheight);
MultiSetZPosition(retObj[n], zpos);
n++;
}
// Right side
retObj[n] = AddObject(&pfilm->reels[vFillers[InvD[ino].NoofVicons-2]], -1);
MultiSetAniXY(retObj[n], invX + TLwidth + eH + TRwidth + NM_RSX, invY + TLheight);
MultiSetZPosition(retObj[n], zpos);
n++;
}
if (SuppV) {
int offy = TLheight + eV - (TinselV2 ? ITEM_HEIGHT + I_SEPARATION : 26);
int minAmount = TinselV2 ? 20 : 5;
if (offy < minAmount)
offy = minAmount;
// Left side extra
retObj[n] = AddObject(&pfilm->reels[IX_V26], -1);
MultiSetAniXY(retObj[n], invX + NM_LSX, invY + offy);
MultiSetZPosition(retObj[n], zpos);
n++;
// Right side extra
retObj[n] = AddObject(&pfilm->reels[IX_V26], -1);
MultiSetAniXY(retObj[n], invX + TLwidth + eH + TRwidth + NM_RSX, invY + offy);
MultiSetZPosition(retObj[n], zpos);
n++;
}
OBJECT **rect, **title;
// Draw background, slider and icons
if (TinselV2 && (filling != EMPTY)) {
AddBackground(&retObj[n++], eH, eV);
AddTitle(&retObj[n++], eH);
}
if (filling == FULL) {
if (!TinselV2) {
rect = &retObj[n++];
title = &retObj[n++];
AddBackground(rect, title, eH, eV, FROM_HANDLE);
}
if (ino == INV_CONV) {
SlideObject = NULL;
if (TinselV2) {
// !!!!! MAGIC NUMBER ALERT !!!!!
// Make sure it's big enough for the heading
if (MultiLeftmost(retObj[n-1]) < InvD[INV_CONV].inventoryX + 10) {
InvD[INV_CONV].NoofHicons++;
ConstructInventory(FULL);
}
}
} else if (InvD[ino].NoofItems > InvD[ino].NoofHicons*InvD[ino].NoofVicons) {
sliderYmin = TLheight - (TinselV2 ? 2 : 1);
sliderYmax = TLheight + eV + (TinselV2 ? 12 : 10);
AddSlider(&retObj[n++], pfilm);
}
FillInInventory();
}
else if (filling == CONF) {
if (!TinselV2) {
rect = &retObj[n++];
title = &retObj[n++];
AddBackground(rect, title, eH, eV, FROM_STRING);
if (cd.bExtraWin)
n += AddExtraWindow(invX, invY, &retObj[n]);
} else {
if (cd.bExtraWin)
AddExtraWindow(invX, invY, &retObj[n]);
}
AddBoxes(true);
}
assert(n < MAX_WCOMP); // added more parts than we can handle!
// Reposition returns true if needs to move
if (InvD[ino].bMoveable && filling == FULL && RePosition()) {
ConstructInventory(FULL);
}
}
/**
* Call this when drawing a 'FULL', movable inventory. Checks that the
* position of the Translucent object is within limits. If it isn't,
* adjusts the x/y position of the current inventory and returns true.
*/
bool RePosition(void) {
int p;
bool bMoveitMoveit = false;
assert(RectObject); // no recangle object!
// Test for off-screen horizontally
p = MultiLeftmost(RectObject);
if (p > MAXLEFT) {
// Too far to the right
InvD[ino].inventoryX += MAXLEFT - p;
bMoveitMoveit = true; // I like to....
} else {
// Too far to the left?
p = MultiRightmost(RectObject);
if (p < MINRIGHT) {
InvD[ino].inventoryX += MINRIGHT - p;
bMoveitMoveit = true; // I like to....
}
}
// Test for off-screen vertically
p = MultiHighest(RectObject);
if (p < MINTOP) {
// Too high
InvD[ino].inventoryY += MINTOP - p;
bMoveitMoveit = true; // I like to....
} else if (p > MAXTOP) {
// Too low
InvD[ino].inventoryY += MAXTOP - p;
bMoveitMoveit = true; // I like to....
}
return bMoveitMoveit;
}
/**************************************************************************/
/***/
/**************************************************************************/
/**
* Get the cursor's reel, poke in the background palette,
* and customise the cursor.
*/
void AlterCursor(int num) {
const FREEL *pfreel;
IMAGE *pim;
// Get pointer to image
pim = GetImageFromFilm(hWinParts, num, &pfreel);
// Poke in the background palette
pim->hImgPal = TO_LE_32(BgPal());
SetTempCursor(FROM_LE_32(pfreel->script));
}
enum InvCursorFN {IC_AREA, IC_DROP};
/**
* InvCursor
*/
void InvCursor(InvCursorFN fn, int CurX, int CurY) {
static enum { IC_NORMAL, IC_DR, IC_UR, IC_TB, IC_LR,
IC_INV, IC_UP, IC_DN } ICursor = IC_NORMAL; // FIXME: local static var
int area; // The part of the window the cursor is over
bool restoreMain = false;
// If currently dragging, don't be messing about with the cursor shape
if (InvDragging != ID_NONE)
return;
switch (fn) {
case IC_DROP:
ICursor = IC_NORMAL;
InvCursor(IC_AREA, CurX, CurY);
break;
case IC_AREA:
area = InvArea(CurX, CurY);
// Check for POINTED events
if (ino == INV_CONF)
InvBoxes(area == I_BODY, CurX, CurY);
else
InvLabels(area == I_BODY, CurX, CurY);
// No cursor trails while within inventory window
if (area == I_NOTIN)
UnHideCursorTrails();
else
HideCursorTrails();
switch (area) {
case I_NOTIN:
restoreMain = true;
break;
case I_TLEFT:
case I_BRIGHT:
if (!InvD[ino].resizable)
restoreMain = true;
else if (ICursor != IC_DR) {
AlterCursor(IX_CURDD);
ICursor = IC_DR;
}
break;
case I_TRIGHT:
case I_BLEFT:
if (!InvD[ino].resizable)
restoreMain = true;
else if (ICursor != IC_UR) {
AlterCursor(IX_CURDU);
ICursor = IC_UR;
}
break;
case I_TOP:
case I_BOTTOM:
if (!InvD[ino].resizable) {
restoreMain = true;
break;
}
if (ICursor != IC_TB) {
AlterCursor(IX_CURUD);
ICursor = IC_TB;
}
break;
case I_LEFT:
case I_RIGHT:
if (!InvD[ino].resizable)
restoreMain = true;
else if (ICursor != IC_LR) {
AlterCursor(IX_CURLR);
ICursor = IC_LR;
}
break;
case I_UP:
case I_SLIDE_UP:
case I_DOWN:
case I_SLIDE_DOWN:
case I_SLIDE:
case I_HEADER:
case I_BODY:
restoreMain = true;
break;
}
break;
}
if (restoreMain && ICursor != IC_NORMAL) {
RestoreMainCursor();
ICursor = IC_NORMAL;
}
}
/*-------------------------------------------------------------------------*/
/**************************************************************************/
/******************** Conversation specific functions *********************/
/**************************************************************************/
void ConvAction(int index) {
assert(ino == INV_CONV); // not conv. window!
PMOVER pMover = TinselV2 ? GetMover(GetLeadId()) : NULL;
switch (index) {
case INV_NOICON:
return;
case INV_CLOSEICON:
thisIcon = -1; // Postamble
break;
case INV_OPENICON:
// Store the direction the lead character is facing in when the conversation starts
if (TinselV2)
initialDirection = GetMoverDirection(pMover);
thisIcon = -2; // Preamble
break;
default:
thisIcon = InvD[ino].contents[index];
break;
}
if (!TinselV2)
RunPolyTinselCode(thisConvPoly, CONVERSE, PLR_NOEVENT, true);
else {
// If the lead's direction has changed for any reason (such as having broken the
// fourth wall and talked to the screen), reset back to the original direction
DIRECTION currDirection = GetMoverDirection(pMover);
if (currDirection != initialDirection) {
SetMoverDirection(pMover, initialDirection);
SetMoverStanding(pMover);
}
if (thisConvPoly != NOPOLY)
PolygonEvent(nullContext, thisConvPoly, CONVERSE, 0, false, 0);
else
ActorEvent(nullContext, thisConvActor, CONVERSE, false, 0);
}
}
/**
* Called to specify whether conversation window is going to
* appear at the top or bottom of the screen.
* Also to specify which polygon or actor is opening the conversation.
*
* Note: ano may (will probably) be set when it's a polygon.
*/
void SetConvDetails(CONV_PARAM fn, HPOLYGON hPoly, int ano) {
thisConvFn = fn;
thisConvPoly = hPoly;
thisConvActor = ano;
bMoveOnUnHide = true;
// Get the Actor Tag's or Tagged Actor's label for the conversation window title
if (hPoly != NOPOLY) {
int x, y;
GetTagTag(hPoly, &InvD[INV_CONV].hInvTitle, &x, &y);
} else {
InvD[INV_CONV].hInvTitle = GetActorTagHandle(ano);
}
}
/*-------------------------------------------------------------------------*/
/**
* Add an icon to the permanent conversation list.
*/
void PermaConvIcon(int icon, bool bEnd) {
int i;
// See if it's already there
for (i = 0; i < numPermIcons; i++) {
if (permIcons[i] == icon)
break;
}
// Add it if it isn't already there
if (i == numPermIcons) {
assert(numPermIcons < MAX_PERMICONS);
if (bEnd || !numEndIcons) {
// Add it at the end
permIcons[numPermIcons++] = icon;
if (bEnd)
numEndIcons++;
} else {
// Insert before end icons
memmove(&permIcons[numPermIcons-numEndIcons+1],
&permIcons[numPermIcons-numEndIcons],
numEndIcons * sizeof(int));
permIcons[numPermIcons-numEndIcons] = icon;
numPermIcons++;
}
}
}
/*-------------------------------------------------------------------------*/
void convPos(int fn) {
if (fn == CONV_DEF)
InvD[INV_CONV].inventoryY = 8;
else if (fn == CONV_BOTTOM)
InvD[INV_CONV].inventoryY = 150;
}
void ConvPoly(HPOLYGON hPoly) {
thisConvPoly = hPoly;
}
int GetIcon(void) {
return thisIcon;
}
void CloseDownConv(void) {
if (InventoryState == ACTIVE_INV && ino == INV_CONV) {
KillInventory();
}
}
void HideConversation(bool bHide) {
int aniX, aniY;
int i;
if (InventoryState == ACTIVE_INV && ino == INV_CONV) {
if (bHide) {
// Move all the window and icons off-screen
for (i = 0; objArray[i] && i < MAX_WCOMP; i++) {
MultiAdjustXY(objArray[i], 2 * SCREEN_WIDTH, 0);
}
for (i = 0; iconArray[i] && i < MAX_ICONS; i++) {
MultiAdjustXY(iconArray[i], 2 * SCREEN_WIDTH, 0);
}
// Window is hidden
InventoryHidden = true;
// Remove any labels
InvLabels(false, 0, 0);
} else {
// Window is not hidden
InventoryHidden = false;
if (TinselV2 && ItemsChanged)
// Just rebuild the whole thing
ConstructInventory(FULL);
else {
// Move it all back on-screen
for (i = 0; objArray[i] && i < MAX_WCOMP; i++) {
MultiAdjustXY(objArray[i], -2 * SCREEN_WIDTH, 0);
}
// Don't flash if items changed. If they have, will be redrawn anyway.
if (TinselV2 || !ItemsChanged) {
for (i = 0; iconArray[i] && i < MAX_ICONS; i++) {
MultiAdjustXY(iconArray[i], -2*SCREEN_WIDTH, 0);
}
}
}
if (TinselV2 && bMoveOnUnHide) {
/*
* First time, position it appropriately
*/
int left, centre;
int x, y, deltay;
// Only do it once per conversation
bMoveOnUnHide = false;
// Current centre of the window
left = MultiLeftmost(RectObject);
centre = (MultiRightmost(RectObject) + left) / 2;
// Get the x-offset for the conversation window
if (thisConvActor) {
int Loffset, Toffset;
GetActorMidTop(thisConvActor, &x, &y);
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
x -= Loffset;
y -= Toffset;
} else {
x = SCREEN_WIDTH / 2;
y = SCREEN_BOX_HEIGHT2 / 2;
}
// Save old y-position
deltay = InvD[INV_CONV].inventoryY;
switch (thisConvFn) {
case CONV_TOP:
InvD[INV_CONV].inventoryY = SysVar(SV_CONV_TOPY);
break;
case CONV_BOTTOM:
InvD[INV_CONV].inventoryY = SysVar(SV_CONV_BOTY);
break;
case CONV_DEF:
InvD[INV_CONV].inventoryY = y - SysVar(SV_CONV_ABOVE_Y);
break;
default:
break;
}
// Calculate y change
deltay = InvD[INV_CONV].inventoryY - deltay;
// Move it all
for (i = 0; objArray[i] && i < MAX_WCOMP; i++) {
MultiMoveRelXY(objArray[i], x - centre, deltay);
}
for (i = 0; iconArray[i] && i < MAX_ICONS; i++) {
MultiMoveRelXY(iconArray[i], x - centre, deltay);
}
InvD[INV_CONV].inventoryX += x - centre;
/*
* Now positioned as worked out
* - but it must be in a sensible place
*/
if (MultiLeftmost(RectObject) < SysVar(SV_CONV_MINX))
x = SysVar(SV_CONV_MINX) - MultiLeftmost(RectObject);
else if (MultiRightmost(RectObject) > SCREEN_WIDTH - SysVar(SV_CONV_MINX))
x = SCREEN_WIDTH - SysVar(SV_CONV_MINX) - MultiRightmost(RectObject);
else
x = 0;
if (thisConvFn == CONV_DEF && MultiHighest(RectObject) < SysVar(SV_CONV_MINY)
&& thisConvActor) {
int Loffset, Toffset;
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
y = GetActorBottom(thisConvActor) - MultiHighest(RectObject) +
SysVar(SV_CONV_BELOW_Y);
y -= Toffset;
}
else
y = 0;
if (x || y) {
for (i = 0; objArray[i] && i < MAX_WCOMP; i++) {
MultiMoveRelXY(objArray[i], x, y);
}
for (i = 0; iconArray[i] && i < MAX_ICONS; i++) {
MultiMoveRelXY(iconArray[i], x, y);
}
InvD[INV_CONV].inventoryX += x;
InvD[INV_CONV].inventoryY += y;
}
/*
* Oh shit! We might have gone off the bottom
*/
if (MultiLowest(RectObject) > SCREEN_BOX_HEIGHT2 - SysVar(SV_CONV_MINY)) {
y = (SCREEN_BOX_HEIGHT2 - SysVar(SV_CONV_MINY)) - MultiLowest(RectObject);
for (i = 0; objArray[i] && i < MAX_WCOMP; i++) {
MultiMoveRelXY(objArray[i], 0, y);
}
for (i = 0; iconArray[i] && i < MAX_ICONS; i++) {
MultiMoveRelXY(iconArray[i], 0, y);
}
InvD[INV_CONV].inventoryY += y;
}
}
GetCursorXY(&aniX, &aniY, false);
InvLabels(true, aniX, aniY);
}
}
}
bool ConvIsHidden(void) {
return InventoryHidden;
}
/**************************************************************************/
/******************* Open and closing functions ***************************/
/**************************************************************************/
/**
* Start up an inventory window.
*/
void PopUpInventory(int invno) {
assert(invno == INV_1 || invno == INV_2 || invno == INV_CONV
|| invno == INV_CONF || invno == INV_MENU); // Trying to open illegal inventory
if (InventoryState == IDLE_INV) {
bReOpenMenu = false; // Better safe than sorry...
DisableTags(); // Tags disabled during inventory
if (TinselV2)
DisablePointing(nullContext); // Pointing disabled during inventory
if (invno == INV_CONV) { // Conversation window?
if (TinselV2)
// Quiet please..
_vm->_pcmMusic->dim(false);
// Start conversation with permanent contents
memset(InvD[INV_CONV].contents, 0, MAX_ININV*sizeof(int));
memcpy(InvD[INV_CONV].contents, permIcons, numPermIcons*sizeof(int));
InvD[INV_CONV].NoofItems = numPermIcons;
if (TinselV2)
InvD[INV_CONV].NoofHicons = numPermIcons;
else
thisIcon = 0;
} else if (invno == INV_CONF) { // Configuration window?
cd.selBox = NOBOX;
cd.pointBox = NOBOX;
}
ino = invno; // The open inventory
ItemsChanged = false; // Nothing changed
InvDragging = ID_NONE; // Not dragging
InventoryState = ACTIVE_INV; // Inventory actiive
InventoryHidden = false; // Not hidden
InventoryMaximised = InvD[ino].bMax;
if (invno != INV_CONF) // Configuration window?
ConstructInventory(FULL); // Draw it up
else {
ConstructInventory(CONF); // Draw it up
}
}
}
void SetMenuGlobals(CONFINIT *ci) {
InvD[INV_CONF].MinHicons = InvD[INV_CONF].MaxHicons = InvD[INV_CONF].NoofHicons = ci->h;
InvD[INV_CONF].MaxVicons = InvD[INV_CONF].MinVicons = InvD[INV_CONF].NoofVicons = ci->v;
InvD[INV_CONF].inventoryX = ci->x;
InvD[INV_CONF].inventoryY = ci->y;
cd.bExtraWin = ci->bExtraWin;
cd.box = ci->Box;
cd.NumBoxes = ci->NumBoxes;
cd.ixHeading = ci->ixHeading;
if (TinselV2) {
if ((ci->ixHeading != NO_HEADING) && SysString(ci->ixHeading))
InvD[INV_MENU].hInvTitle = SysString(ci->ixHeading);
else
InvD[INV_MENU].hInvTitle = NO_HEADING;
}
}
/**
* PopupConf
*/
void OpenMenu(CONFTYPE menuType) {
int curX, curY;
if (InventoryState != IDLE_INV)
return;
InvD[INV_CONF].resizable = false;
InvD[INV_CONF].bMoveable = false;
switch (menuType) {
case MAIN_MENU:
SetMenuGlobals(&ciOption);
break;
case SAVE_MENU:
if (!TinselV2)
SetCursorScreenXY(262, 91);
SetMenuGlobals(&ciSave);
cd.editableRgroup = true;
FirstFile(0);
break;
case LOAD_MENU:
SetMenuGlobals(&ciLoad);
cd.editableRgroup = false;
FirstFile(0);
break;
case RESTART_MENU:
if (TinselV2)
SetCursorScreenXY(360, 153);
else if (_vm->getLanguage() == Common::JA_JPN)
SetCursorScreenXY(180, 106);
else
SetCursorScreenXY(180, 90);
SetMenuGlobals(&ciRestart);
break;
case SOUND_MENU:
if (TinselV2)
displayedLanguage = TextLanguage();
SetMenuGlobals(&ciSound);
break;
case CONTROLS_MENU:
SetMenuGlobals(&ciControl);
break;
case QUIT_MENU:
if (TinselV2)
SetCursorScreenXY(360, 153);
else if (_vm->getLanguage() == Common::JA_JPN)
SetCursorScreenXY(180, 106);
else
SetCursorScreenXY(180, 90);
SetMenuGlobals(&ciQuit);
break;
case HOPPER_MENU1:
PrimeSceneHopper();
SetMenuGlobals(&ciHopper1);
cd.editableRgroup = false;
RememberChosenScene();
FirstScene(0);
break;
case HOPPER_MENU2:
SetMenuGlobals(&ciHopper2);
cd.editableRgroup = false;
SetChosenScene();
FirstEntry(0);
break;
case SUBTITLES_MENU:
if (_vm->getFeatures() & GF_USE_3FLAGS) {
ciSubtitles.v = 6;
ciSubtitles.Box = subtitlesBox3Flags;
ciSubtitles.NumBoxes = ARRAYSIZE(subtitlesBox3Flags);
} else if (_vm->getFeatures() & GF_USE_4FLAGS) {
ciSubtitles.v = 6;
ciSubtitles.Box = subtitlesBox4Flags;
ciSubtitles.NumBoxes = ARRAYSIZE(subtitlesBox4Flags);
} else if (_vm->getFeatures() & GF_USE_5FLAGS) {
ciSubtitles.v = 6;
ciSubtitles.Box = subtitlesBox4Flags;
ciSubtitles.NumBoxes = ARRAYSIZE(subtitlesBox4Flags);
} else {
ciSubtitles.v = 3;
ciSubtitles.Box = subtitlesBox;
ciSubtitles.NumBoxes = ARRAYSIZE(subtitlesBox);
}
SetMenuGlobals(&ciSubtitles);
break;
case TOP_WINDOW:
SetMenuGlobals(&ciTopWin);
ino = INV_CONF;
ConstructInventory(CONF); // Draw it up
InventoryState = BOGUS_INV;
return;
default:
return;
}
if (HeldItem != INV_NOICON)
DelAuxCursor(); // no longer aux cursor
PopUpInventory(INV_CONF);
// Make initial box selections if appropriate
if (menuType == SAVE_MENU || menuType == LOAD_MENU
|| menuType == HOPPER_MENU1 || menuType == HOPPER_MENU2)
Select(0, false);
else if (menuType == SUBTITLES_MENU) {
if (_vm->getFeatures() & GF_USE_3FLAGS) {
// VERY quick dirty bodges
if (g_language == TXT_FRENCH)
Select(0, false);
else if (g_language == TXT_GERMAN)
Select(1, false);
else
Select(2, false);
} else if (_vm->getFeatures() & GF_USE_4FLAGS) {
Select(g_language-1, false);
} else if (_vm->getFeatures() & GF_USE_5FLAGS) {
Select(g_language, false);
}
}
GetCursorXY(&curX, &curY, false);
InvCursor(IC_AREA, curX, curY);
}
/**
* Close down an inventory window.
*/
void KillInventory(void) {
if (objArray[0] != NULL) {
DumpObjArray();
DumpDobjArray();
DumpIconArray();
}
if (InventoryState == ACTIVE_INV) {
EnableTags();
if (TinselV2)
EnablePointing();
InvD[ino].bMax = InventoryMaximised;
UnHideCursorTrails();
_vm->divertKeyInput(NULL);
}
InventoryState = IDLE_INV;
if (bReOpenMenu) {
bReOpenMenu = false;
OpenMenu(MAIN_MENU);
// Write config changes
WriteConfig();
} else if (ino == INV_CONF)
InventoryIconCursor(false);
if (TinselV2)
// Pump up the volume
if (ino == INV_CONV)
_vm->_pcmMusic->unDim(false);
}
void CloseInventory(void) {
// If not active, ignore this
if (InventoryState != ACTIVE_INV)
return;
// If hidden, a conversation action is still underway - ignore this
if (InventoryHidden)
return;
// If conversation, this is a closeing event
if (ino == INV_CONV)
ConvAction(INV_CLOSEICON);
KillInventory();
RestoreMainCursor();
}
/**************************************************************************/
/************************ The inventory process ***************************/
/**************************************************************************/
/**
* Redraws the icons if appropriate. Also handle button press/toggle effects
*/
void InventoryProcess(CORO_PARAM, const void *) {
// COROUTINE
CORO_BEGIN_CONTEXT;
CORO_END_CONTEXT(_ctx);
CORO_BEGIN_CODE(_ctx);
if (NumberOfLanguages() <= 1)
bNoLanguage = true;
while (1) {
CORO_SLEEP(1); // allow scheduling
if (objArray[0] != NULL) {
if (ItemsChanged && ino != INV_CONF && !InventoryHidden) {
FillInInventory();
// Needed when clicking on scroll bar.
int curX, curY;
GetCursorXY(&curX, &curY, false);
InvCursor(IC_AREA, curX, curY);
ItemsChanged = false;
}
if (ino != INV_CONF) {
for (int i = 0; i < MAX_ICONS; i++) {
if (iconArray[i] != NULL)
StepAnimScript(&iconAnims[i]);
}
}
if (InvDragging == ID_MDCONT) {
// Mixing desk control
int sval, index, *pival;
index = cd.selBox & ~IS_MASK;
pival = cd.box[index].ival;
sval = *pival;
if (cd.selBox & IS_LEFT) {
*pival -= cd.box[index].h;
if (*pival < 0)
*pival = 0;
} else if (cd.selBox & IS_RIGHT) {
*pival += cd.box[index].h;
if (*pival > cd.box[index].w)
*pival = cd.box[index].w;
}
if (sval != *pival) {
SlideMSlider(0, (cd.selBox & IS_RIGHT) ? S_TIMEUP : S_TIMEDN);
}
}
}
if (g_buttonEffect.bButAnim) {
assert(g_buttonEffect.box);
if (g_buttonEffect.press) {
if (g_buttonEffect.box->boxType == AAGBUT || g_buttonEffect.box->boxType == ARSGBUT)
CORO_INVOKE_1(ButtonPress, g_buttonEffect.box);
switch (g_buttonEffect.box->boxFunc) {
case SAVEGAME:
KillInventory();
InvSaveGame();
break;
case LOADGAME:
KillInventory();
InvLoadGame();
break;
case IQUITGAME:
_vm->quitGame();
break;
case CLOSEWIN:
KillInventory();
if ((cd.box == hopperBox1) || (cd.box == hopperBox2))
FreeSceneHopper();
break;
case OPENLOAD:
KillInventory();
OpenMenu(LOAD_MENU);
break;
case OPENSAVE:
KillInventory();
OpenMenu(SAVE_MENU);
break;
case OPENREST:
KillInventory();
OpenMenu(RESTART_MENU);
break;
case OPENSOUND:
KillInventory();
OpenMenu(SOUND_MENU);
break;
case OPENCONT:
KillInventory();
OpenMenu(CONTROLS_MENU);
break;
#ifndef JAPAN
case OPENSUBT:
KillInventory();
OpenMenu(SUBTITLES_MENU);
break;
#endif
case OPENQUIT:
KillInventory();
OpenMenu(QUIT_MENU);
break;
case INITGAME:
KillInventory();
bRestart = true;
break;
#if defined(USE_3FLAGS) || defined(USE_4FLAGS) || defined(USE_5FLAGS)
case CLANG:
if (!LanguageChange())
KillInventory();
break;
case RLANG:
KillInventory();
break;
#endif
case HOPPER2:
KillInventory();
OpenMenu(HOPPER_MENU2);
break;
case BF_CHANGESCENE:
KillInventory();
HopAction();
FreeSceneHopper();
break;
default:
break;
}
} else
CORO_INVOKE_1(ButtonToggle, g_buttonEffect.box);
g_buttonEffect.bButAnim = false;
}
}
CORO_END_CODE;
}
/**************************************************************************/
/*************** Drag stuff - Resizing and moving window ******************/
/**************************************************************************/
/**
* Appears to find the nearest entry in slideStuff[] to the supplied
* y-coordinate.
*/
int NearestSlideY(int fity) {
int nearDist = 1000;
int thisDist;
int nearI = 0; // Index of nearest fit
int i = 0;
do {
thisDist = ABS(slideStuff[i].y - fity);
if (thisDist < nearDist) {
nearDist = thisDist;
nearI = i;
}
} while (slideStuff[++i].n != -1);
return nearI;
}
/**
* Gets called at the start and end of a drag on the slider, and upon
* y-movement during such a drag.
*/
void SlideSlider(int y, SSFN fn) {
static int newY = 0, lasti = 0; // FIXME: local static var
int gotoY, ati;
// Only do this if there's a slider
if (!SlideObject)
return;
switch (fn) {
case S_START: // Start of a drag on the slider
newY = sliderYpos;
lasti = NearestSlideY(sliderYpos);
break;
case S_SLIDE: // Y-movement during drag
newY = newY + y; // New y-position
if (newY < sliderYmin)
gotoY = sliderYmin; // Above top limit
else if (newY > sliderYmax)
gotoY = sliderYmax; // Below bottom limit
else
gotoY = newY; // Hunky-Dory
// Move slider to new position
MultiMoveRelXY(SlideObject, 0, gotoY - sliderYpos);
sliderYpos = gotoY;
// Re-draw icons if necessary
ati = NearestSlideY(sliderYpos);
if (ati != lasti) {
InvD[ino].FirstDisp = slideStuff[ati].n;
assert(InvD[ino].FirstDisp >= 0); // negative first displayed
ItemsChanged = true;
lasti = ati;
}
break;
case S_END: // End of a drag on the slider
// Draw icons from new start icon
ati = NearestSlideY(sliderYpos);
InvD[ino].FirstDisp = slideStuff[ati].n;
ItemsChanged = true;
break;
default:
break;
}
}
/**
* Gets called at the start and end of a drag on the slider, and upon
* y-movement during such a drag.
*/
void SlideCSlider(int y, SSFN fn) {
static int newY = 0; // FIXME: local static var
int gotoY;
int fc;
// Only do this if there's a slider
if (!SlideObject)
return;
switch (fn) {
case S_START: // Start of a drag on the slider
newY = sliderYpos;
break;
case S_SLIDE: // Y-movement during drag
newY = newY + y; // New y-position
if (newY < sliderYmin)
gotoY = sliderYmin; // Above top limit
else if (newY > sliderYmax)
gotoY = sliderYmax; // Below bottom limit
else
gotoY = newY; // Hunky-Dory
// Move slider to new position
if (TinselV2)
MultiMoveRelXY(SlideObject, 0, gotoY - sliderYpos);
sliderYpos = gotoY;
fc = cd.extraBase;
if ((cd.box == saveBox || cd.box == loadBox))
FirstFile((sliderYpos - sliderYmin) * (MAX_SAVED_FILES - NUM_RGROUP_BOXES) /
(sliderYmax - sliderYmin));
else if (cd.box == hopperBox1)
FirstScene((sliderYpos - sliderYmin) * (numScenes - NUM_RGROUP_BOXES) / sliderRange);
else if (cd.box == hopperBox2)
FirstEntry((sliderYpos - sliderYmin) * (numEntries - NUM_RGROUP_BOXES) / sliderRange);
// If extraBase has changed...
if (fc != cd.extraBase) {
AddBoxes(false);
fc -= cd.extraBase;
cd.selBox += fc;
// Ensure within legal limits
if (cd.selBox < 0)
cd.selBox = 0;
else if (cd.selBox >= NUM_RGROUP_BOXES)
cd.selBox = NUM_RGROUP_BOXES-1;
Select(cd.selBox, true);
}
break;
case S_END: // End of a drag on the slider
break;
default:
break;
}
}
/**
* Gets called at the start and end of a drag on a mixing desk slider,
* and upon x-movement during such a drag.
*/
static void SlideMSlider(int x, SSFN fn) {
static int newX = 0; // FIXME: local static var
int gotoX;
int index, i;
if (fn == S_END || fn == S_TIMEUP || fn == S_TIMEDN)
;
else if (!(cd.selBox & IS_SLIDER))
return;
// Work out the indices
index = cd.selBox & ~IS_MASK;
for (i = 0; i < numMdSlides; i++)
if (mdSlides[i].num == index)
break;
assert(i < numMdSlides);
switch (fn) {
case S_START: // Start of a drag on the slider
// can use index as a throw-away value
GetAniPosition(mdSlides[i].obj, &newX, &index);
lX = sX = newX;
break;
case S_SLIDE: // X-movement during drag
if (x == 0)
return;
newX = newX + x; // New x-position
if (newX < mdSlides[i].min)
gotoX = mdSlides[i].min; // Below bottom limit
else if (newX > mdSlides[i].max)
gotoX = mdSlides[i].max; // Above top limit
else
gotoX = newX; // Hunky-Dory
// Move slider to new position
MultiMoveRelXY(mdSlides[i].obj, gotoX - sX, 0);
sX = gotoX;
if (lX != sX) {
*cd.box[index].ival = (sX - mdSlides[i].min)*cd.box[index].w/SLIDE_RANGE;
if (cd.box[index].boxFunc == MUSICVOL)
SetMidiVolume(*cd.box[index].ival);
#ifdef MAC_OPTIONS
if (cd.box[index].boxFunc == MASTERVOL)
SetSystemVolume(*cd.box[index].ival);
if (cd.box[index].boxFunc == SAMPVOL)
SetSampleVolume(*cd.box[index].ival);
#endif
lX = sX;
}
break;
case S_TIMEUP:
case S_TIMEDN:
gotoX = SLIDE_RANGE*(*cd.box[index].ival)/cd.box[index].w;
MultiSetAniX(mdSlides[i].obj, mdSlides[i].min+gotoX);
if (cd.box[index].boxFunc == MUSICVOL)
SetMidiVolume(*cd.box[index].ival);
#ifdef MAC_OPTIONS
if (cd.box[index].boxFunc == MASTERVOL)
SetSystemVolume(*cd.box[index].ival);
if (cd.box[index].boxFunc == SAMPVOL)
SetSampleVolume(*cd.box[index].ival);
#endif
break;
case S_END: // End of a drag on the slider
AddBoxes(false); // Might change position slightly
if (ino == INV_CONF && cd.box == subtitlesBox)
Select(g_language, false);
break;
}
}
/**
* Called from ChangeingSize() during re-sizing.
*/
void GettingTaller(void) {
if (SuppV) {
Ychange += SuppV;
if (Ycompensate == 'T')
InvD[ino].inventoryY += SuppV;
SuppV = 0;
}
while (Ychange > (ITEM_HEIGHT+1) && InvD[ino].NoofVicons < InvD[ino].MaxVicons) {
Ychange -= (ITEM_HEIGHT+1);
InvD[ino].NoofVicons++;
if (Ycompensate == 'T')
InvD[ino].inventoryY -= (ITEM_HEIGHT+1);
}
if (InvD[ino].NoofVicons < InvD[ino].MaxVicons) {
SuppV = Ychange;
Ychange = 0;
if (Ycompensate == 'T')
InvD[ino].inventoryY -= SuppV;
}
}
/**
* Called from ChangeingSize() during re-sizing.
*/
void GettingShorter(void) {
int StartNvi = InvD[ino].NoofVicons;
int StartUv = SuppV;
if (SuppV) {
Ychange += (SuppV - (ITEM_HEIGHT+1));
InvD[ino].NoofVicons++;
SuppV = 0;
}
while (Ychange < -(ITEM_HEIGHT+1) && InvD[ino].NoofVicons > InvD[ino].MinVicons) {
Ychange += (ITEM_HEIGHT+1);
InvD[ino].NoofVicons--;
}
if (InvD[ino].NoofVicons > InvD[ino].MinVicons && Ychange) {
SuppV = (ITEM_HEIGHT+1) + Ychange;
InvD[ino].NoofVicons--;
Ychange = 0;
}
if (Ycompensate == 'T')
InvD[ino].inventoryY += (ITEM_HEIGHT+1)*(StartNvi - InvD[ino].NoofVicons) - (SuppV - StartUv);
}
/**
* Called from ChangeingSize() during re-sizing.
*/
void GettingWider(void) {
int StartNhi = InvD[ino].NoofHicons;
int StartUh = SuppH;
if (SuppH) {
Xchange += SuppH;
SuppH = 0;
}
while (Xchange > (ITEM_WIDTH+1) && InvD[ino].NoofHicons < InvD[ino].MaxHicons) {
Xchange -= (ITEM_WIDTH+1);
InvD[ino].NoofHicons++;
}
if (InvD[ino].NoofHicons < InvD[ino].MaxHicons) {
SuppH = Xchange;
Xchange = 0;
}
if (Xcompensate == 'L')
InvD[ino].inventoryX += (ITEM_WIDTH+1)*(StartNhi - InvD[ino].NoofHicons) - (SuppH - StartUh);
}
/**
* Called from ChangeingSize() during re-sizing.
*/
void GettingNarrower(void) {
int StartNhi = InvD[ino].NoofHicons;
int StartUh = SuppH;
if (SuppH) {
Xchange += (SuppH - (ITEM_WIDTH+1));
InvD[ino].NoofHicons++;
SuppH = 0;
}
while (Xchange < -(ITEM_WIDTH+1) && InvD[ino].NoofHicons > InvD[ino].MinHicons) {
Xchange += (ITEM_WIDTH+1);
InvD[ino].NoofHicons--;
}
if (InvD[ino].NoofHicons > InvD[ino].MinHicons && Xchange) {
SuppH = (ITEM_WIDTH+1) + Xchange;
InvD[ino].NoofHicons--;
Xchange = 0;
}
if (Xcompensate == 'L')
InvD[ino].inventoryX += (ITEM_WIDTH+1)*(StartNhi - InvD[ino].NoofHicons) - (SuppH - StartUh);
}
/**
* Called from Xmovement()/Ymovement() during re-sizing.
*/
void ChangeingSize(void) {
/* Make it taller or shorter if necessary. */
if (Ychange > 0)
GettingTaller();
else if (Ychange < 0)
GettingShorter();
/* Make it wider or narrower if necessary. */
if (Xchange > 0)
GettingWider();
else if (Xchange < 0)
GettingNarrower();
ConstructInventory(EMPTY);
}
/**
* Called from cursor module when cursor moves while inventory is up.
*/
void Xmovement(int x) {
int aniX, aniY;
int i;
if (x && objArray[0] != NULL) {
switch (InvDragging) {
case ID_MOVE:
GetAniPosition(objArray[0], &InvD[ino].inventoryX, &aniY);
InvD[ino].inventoryX +=x;
MultiSetAniX(objArray[0], InvD[ino].inventoryX);
for (i = 1; objArray[i] && i < MAX_WCOMP; i++)
MultiMoveRelXY(objArray[i], x, 0);
for (i = 0; iconArray[i] && i < MAX_ICONS; i++)
MultiMoveRelXY(iconArray[i], x, 0);
break;
case ID_LEFT:
case ID_TLEFT:
case ID_BLEFT:
Xchange -= x;
ChangeingSize();
break;
case ID_RIGHT:
case ID_TRIGHT:
case ID_BRIGHT:
Xchange += x;
ChangeingSize();
break;
case ID_NONE:
GetCursorXY(&aniX, &aniY, false);
InvCursor(IC_AREA, aniX, aniY);
break;
case ID_MDCONT:
SlideMSlider(x, S_SLIDE);
break;
default:
break;
}
}
}
/**
* Called from cursor module when cursor moves while inventory is up.
*/
void Ymovement(int y) {
int aniX, aniY;
int i;
if (y && objArray[0] != NULL) {
switch (InvDragging) {
case ID_MOVE:
GetAniPosition(objArray[0], &aniX, &InvD[ino].inventoryY);
InvD[ino].inventoryY +=y;
MultiSetAniY(objArray[0], InvD[ino].inventoryY);
for (i = 1; objArray[i] && i < MAX_WCOMP; i++)
MultiMoveRelXY(objArray[i], 0, y);
for (i = 0; iconArray[i] && i < MAX_ICONS; i++)
MultiMoveRelXY(iconArray[i], 0, y);
break;
case ID_SLIDE:
SlideSlider(y, S_SLIDE);
break;
case ID_CSLIDE:
SlideCSlider(y, S_SLIDE);
break;
case ID_BOTTOM:
case ID_BLEFT:
case ID_BRIGHT:
Ychange += y;
ChangeingSize();
break;
case ID_TOP:
case ID_TLEFT:
case ID_TRIGHT:
Ychange -= y;
ChangeingSize();
break;
case ID_NONE:
GetCursorXY(&aniX, &aniY, false);
InvCursor(IC_AREA, aniX, aniY);
break;
default:
break;
}
}
}
/**
* Called when a drag is commencing.
*/
void InvDragStart(void) {
int curX, curY; // cursor's animation position
GetCursorXY(&curX, &curY, false);
/*
* Do something different for Save/Restore screens
*/
if (ino == INV_CONF) {
int whichbox;
whichbox = WhichMenuBox(curX, curY, true);
if (whichbox == IB_SLIDE) {
InvDragging = ID_CSLIDE;
SlideCSlider(0, S_START);
} else if (whichbox > 0 && (whichbox & IS_MASK)) {
InvDragging = ID_MDCONT; // Mixing desk control
cd.selBox = whichbox;
SlideMSlider(0, S_START);
}
return;
}
/*
* Normal operation
*/
switch (InvArea(curX, curY)) {
case I_HEADER:
if (InvD[ino].bMoveable) {
InvDragging = ID_MOVE;
}
break;
case I_SLIDE:
InvDragging = ID_SLIDE;
SlideSlider(0, S_START);
break;
case I_BOTTOM:
if (InvD[ino].resizable) {
Ychange = 0;
InvDragging = ID_BOTTOM;
Ycompensate = 'B';
}
break;
case I_TOP:
if (InvD[ino].resizable) {
Ychange = 0;
InvDragging = ID_TOP;
Ycompensate = 'T';
}
break;
case I_LEFT:
if (InvD[ino].resizable) {
Xchange = 0;
InvDragging = ID_LEFT;
Xcompensate = 'L';
}
break;
case I_RIGHT:
if (InvD[ino].resizable) {
Xchange = 0;
InvDragging = ID_RIGHT;
Xcompensate = 'R';
}
break;
case I_TLEFT:
if (InvD[ino].resizable) {
Ychange = 0;
Ycompensate = 'T';
Xchange = 0;
Xcompensate = 'L';
InvDragging = ID_TLEFT;
}
break;
case I_TRIGHT:
if (InvD[ino].resizable) {
Ychange = 0;
Ycompensate = 'T';
Xchange = 0;
Xcompensate = 'R';
InvDragging = ID_TRIGHT;
}
break;
case I_BLEFT:
if (InvD[ino].resizable) {
Ychange = 0;
Ycompensate = 'B';
Xchange = 0;
Xcompensate = 'L';
InvDragging = ID_BLEFT;
}
break;
case I_BRIGHT:
if (InvD[ino].resizable) {
Ychange = 0;
Ycompensate = 'B';
Xchange = 0;
Xcompensate = 'R';
InvDragging = ID_BRIGHT;
}
break;
}
}
/**
* Called when a drag is over.
*/
void InvDragEnd(void) {
int curX, curY; // cursor's animation position
GetCursorXY(&curX, &curY, false);
if (InvDragging != ID_NONE) {
if (InvDragging == ID_SLIDE) {
SlideSlider(0, S_END);
} else if (InvDragging == ID_CSLIDE) {
; // No action
} else if (InvDragging == ID_MDCONT) {
SlideMSlider(0, S_END);
} else if (InvDragging == ID_MOVE) {
; // No action
} else {
// Were re-sizing. Redraw the whole thing.
DumpDobjArray();
DumpObjArray();
ConstructInventory(FULL);
// If this was the maximised, it no longer is!
if (InventoryMaximised) {
InventoryMaximised = false;
InvD[ino].otherX = InvD[ino].inventoryX;
InvD[ino].otherY = InvD[ino].inventoryY;
}
}
InvDragging = ID_NONE;
ProcessedProvisional();
}
// Cursor could well now be inappropriate
InvCursor(IC_AREA, curX, curY);
Xchange = Ychange = 0; // Probably no need, but does no harm!
}
static void MenuPageDown(void) {
if (cd.box == loadBox || cd.box == saveBox) {
if (cd.extraBase < MAX_SAVED_FILES-NUM_RGROUP_BOXES) {
FirstFile(cd.extraBase+(NUM_RGROUP_BOXES - 1));
AddBoxes(true);
cd.selBox = NUM_RGROUP_BOXES - 1;
Select(cd.selBox, true);
}
} else if (cd.box == hopperBox1) {
if (cd.extraBase < numScenes - NUM_RGROUP_BOXES)
{
FirstScene(cd.extraBase + (NUM_RGROUP_BOXES - 1));
AddBoxes(true);
if (cd.selBox)
cd.selBox = NUM_RGROUP_BOXES - 1;
Select(cd.selBox, true);
}
} else if (cd.box == hopperBox2) {
if (cd.extraBase < numEntries - NUM_RGROUP_BOXES)
{
FirstEntry(cd.extraBase+(NUM_RGROUP_BOXES - 1));
AddBoxes(true);
if (cd.selBox)
cd.selBox = NUM_RGROUP_BOXES - 1;
Select(cd.selBox, true);
}
}
}
static void MenuPageUp(void) {
if (cd.extraBase > 0) {
if (cd.box == loadBox || cd.box == saveBox)
FirstFile(cd.extraBase-(NUM_RGROUP_BOXES - 1));
else if (cd.box == hopperBox1)
FirstScene(cd.extraBase-(NUM_RGROUP_BOXES - 1));
else if (cd.box == hopperBox2)
FirstEntry(cd.extraBase-(NUM_RGROUP_BOXES - 1));
else
return;
AddBoxes(true);
cd.selBox = 0;
Select(cd.selBox, true);
}
}
/**************************************************************************/
/************** Incoming events - further processing **********************/
/**************************************************************************/
/**
* MenuAction
*/
void MenuAction(int i, bool dbl) {
if (i >= 0) {
switch (cd.box[i].boxType) {
case FLIP:
if (dbl) {
*(cd.box[i].ival) ^= 1; // XOR with true
AddBoxes(false);
}
break;
case TOGGLE:
case TOGGLE1:
case TOGGLE2:
if (!g_buttonEffect.bButAnim) {
g_buttonEffect.bButAnim = true;
g_buttonEffect.box = &cd.box[i];
g_buttonEffect.press = false;
}
break;
case RGROUP:
if (dbl) {
// Already highlighted
switch (cd.box[i].boxFunc) {
case SAVEGAME:
KillInventory();
InvSaveGame();
break;
case LOADGAME:
KillInventory();
InvLoadGame();
break;
case HOPPER2:
KillInventory();
OpenMenu(HOPPER_MENU2);
break;
case BF_CHANGESCENE:
KillInventory();
HopAction();
FreeSceneHopper();
break;
default:
break;
}
} else {
Select(i, false);
}
break;
#if defined(USE_3FLAGS) || defined(USE_4FLAGS) || defined(USE_5FLAGS)
case FRGROUP:
if (dbl) {
Select(i, false);
LanguageChange();
} else {
Select(i, false);
}
break;
#endif
case AAGBUT:
case ARSGBUT:
case ARSBUT:
case AABUT:
case AATBUT:
if (g_buttonEffect.bButAnim)
break;
g_buttonEffect.bButAnim = true;
g_buttonEffect.box = &cd.box[i];
g_buttonEffect.press = true;
break;
default:
break;
}
} else {
ConfActionSpecial(i);
}
}
static void ConfActionSpecial(int i) {
switch (i) {
case IB_NONE:
break;
case IB_UP: // Scroll up
if (cd.extraBase > 0) {
if ((cd.box == loadBox) || (cd.box == saveBox))
FirstFile(cd.extraBase - 1);
else if (cd.box == hopperBox1)
FirstScene(cd.extraBase - 1);
else if (cd.box == hopperBox2)
FirstEntry(cd.extraBase - 1);
AddBoxes(true);
if (cd.selBox < NUM_RGROUP_BOXES - 1)
cd.selBox += 1;
Select(cd.selBox, true);
}
break;
case IB_DOWN: // Scroll down
if ((cd.box == loadBox) || (cd.box == saveBox)) {
if (cd.extraBase < MAX_SAVED_FILES - NUM_RGROUP_BOXES) {
FirstFile(cd.extraBase + 1);
AddBoxes(true);
if (cd.selBox)
cd.selBox -= 1;
Select(cd.selBox, true);
}
} else if (cd.box == hopperBox1) {
if (cd.extraBase < numScenes - NUM_RGROUP_BOXES) {
FirstScene(cd.extraBase + 1);
AddBoxes(true);
if (cd.selBox)
cd.selBox -= 1;
Select(cd.selBox, true);
}
} else if (cd.box == hopperBox2) {
if (cd.extraBase < numEntries - NUM_RGROUP_BOXES) {
FirstEntry(cd.extraBase + 1);
AddBoxes(true);
if (cd.selBox)
cd.selBox -= 1;
Select(cd.selBox, true);
}
}
break;
case IB_SLIDE_UP:
MenuPageUp();
break;
case IB_SLIDE_DOWN:
MenuPageDown();
break;
}
}
// SLIDE_UP and SLIDE_DOWN on d click??????
void InvPutDown(int index) {
int aniX, aniY;
// index is the drop position
int hiIndex; // Current position of held item (if in)
// Find where the held item is positioned in this inventory (if it is)
for (hiIndex = 0; hiIndex < InvD[ino].NoofItems; hiIndex++)
if (InvD[ino].contents[hiIndex] == HeldItem)
break;
// If drop position would leave a gap, move it up
if (index >= InvD[ino].NoofItems) {
if (hiIndex == InvD[ino].NoofItems) // Not in, add it
index = InvD[ino].NoofItems;
else
index = InvD[ino].NoofItems - 1;
}
if (hiIndex == InvD[ino].NoofItems) { // Not in, add it
if (InvD[ino].NoofItems < InvD[ino].MaxInvObj) {
InvD[ino].NoofItems++;
// Don't leave it in the other inventory!
if (InventoryPos(HeldItem) != INV_HELDNOTIN)
RemFromInventory(ino == INV_1 ? INV_2 : INV_1, HeldItem);
} else {
// No room at the inn!
return;
}
}
// Position it in the inventory
if (index < hiIndex) {
memmove(&InvD[ino].contents[index + 1], &InvD[ino].contents[index], (hiIndex-index)*sizeof(int));
InvD[ino].contents[index] = HeldItem;
} else if (index > hiIndex) {
memmove(&InvD[ino].contents[hiIndex], &InvD[ino].contents[hiIndex+1], (index-hiIndex)*sizeof(int));
InvD[ino].contents[index] = HeldItem;
} else {
InvD[ino].contents[index] = HeldItem;
}
HeldItem = INV_NOICON;
ItemsChanged = true;
DelAuxCursor();
RestoreMainCursor();
GetCursorXY(&aniX, &aniY, false);
InvCursor(IC_DROP, aniX, aniY);
}
void InvPdProcess(CORO_PARAM, const void *param) {
// COROUTINE
CORO_BEGIN_CONTEXT;
CORO_END_CONTEXT(_ctx);
CORO_BEGIN_CODE(_ctx);
GetToken(TOKEN_LEFT_BUT);
CORO_SLEEP(dclickSpeed+1);
FreeToken(TOKEN_LEFT_BUT);
// get the stuff copied to process when it was created
const int *pindex = (const int *)param;
InvPutDown(*pindex);
CORO_END_CODE;
}
void InvPickup(int index) {
INV_OBJECT *invObj;
// Do nothing if not clicked on anything
if (index == NOOBJECT)
return;
// If not holding anything
if (HeldItem == INV_NOICON && InvD[ino].contents[index] &&
(!TinselV2 || InvD[ino].contents[index] != HeldItem)) {
// Pick-up
invObj = GetInvObject(InvD[ino].contents[index]);
thisIcon = InvD[ino].contents[index];
if (TinselV2)
InvTinselEvent(invObj, PICKUP, INV_PICKUP, index);
else if (invObj->hScript)
InvTinselEvent(invObj, WALKTO, INV_PICKUP, index);
} else if (HeldItem != INV_NOICON) {
// Put-down
invObj = GetInvObject(HeldItem);
// If DROPCODE set, send event, otherwise it's a putdown
if (invObj->attribute & IO_DROPCODE && invObj->hScript)
InvTinselEvent(invObj, PUTDOWN, INV_PICKUP, index);
else if (!(invObj->attribute & IO_ONLYINV1 && ino != INV_1)
&& !(invObj->attribute & IO_ONLYINV2 && ino != INV_2)) {
if (TinselV2)
InvPutDown(index);
else
g_scheduler->createProcess(PID_TCODE, InvPdProcess, &index, sizeof(index));
}
}
}
/**
* Handle WALKTO event (Pick up/put down event)
*/
static void InvWalkTo(const Common::Point &coOrds) {
int i;
switch (InvArea(coOrds.x, coOrds.y)) {
case I_NOTIN:
if (ino == INV_CONV)
ConvAction(INV_CLOSEICON);
if ((cd.box == hopperBox1) || (cd.box == hopperBox2))
FreeSceneHopper();
KillInventory();
break;
case I_SLIDE_UP:
if (InvD[ino].NoofVicons == 1)
InvD[ino].FirstDisp -= InvD[ino].NoofHicons;
for (i = 1; i < InvD[ino].NoofVicons; i++)
InvD[ino].FirstDisp -= InvD[ino].NoofHicons;
if (InvD[ino].FirstDisp < 0)
InvD[ino].FirstDisp = 0;
ItemsChanged = true;
break;
case I_UP:
InvD[ino].FirstDisp -= InvD[ino].NoofHicons;
if (InvD[ino].FirstDisp < 0)
InvD[ino].FirstDisp = 0;
ItemsChanged = true;
break;
case I_SLIDE_DOWN:
if (InvD[ino].NoofVicons == 1)
if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems)
InvD[ino].FirstDisp += InvD[ino].NoofHicons;
for (i = 1; i < InvD[ino].NoofVicons; i++) {
if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems)
InvD[ino].FirstDisp += InvD[ino].NoofHicons;
}
ItemsChanged = true;
break;
case I_DOWN:
if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems) {
InvD[ino].FirstDisp += InvD[ino].NoofHicons;
ItemsChanged = true;
}
break;
case I_BODY:
if (ino == INV_CONF) {
if (!InventoryHidden)
MenuAction(WhichMenuBox(coOrds.x, coOrds.y, false), false);
} else {
Common::Point pt = coOrds;
i = InvItem(pt, false);
// To cater for drop in dead space between icons,
// look 1 pixel right, then 1 down, then 1 right and down.
if (i == INV_NOICON && HeldItem != INV_NOICON &&
(ino == INV_1 || ino == INV_2)) {
pt.x += 1; // 1 to the right
i = InvItem(pt, false);
if (i == INV_NOICON) {
pt.x -= 1; // 1 down
pt.y += 1;
i = InvItem(pt, false);
if (i == INV_NOICON) {
pt.x += 1; // 1 down-right
i = InvItem(pt, false);
}
}
}
if (ino == INV_CONV) {
ConvAction(i);
} else
InvPickup(i);
}
break;
}
}
void InvAction(void) {
int index;
INV_OBJECT *invObj;
int aniX, aniY;
int i;
GetCursorXY(&aniX, &aniY, false);
switch (InvArea(aniX, aniY)) {
case I_BODY:
if (ino == INV_CONF) {
if (!InventoryHidden)
MenuAction(WhichMenuBox(aniX, aniY, false), true);
} else if (ino == INV_CONV) {
index = InvItem(&aniX, &aniY, false);
ConvAction(index);
} else {
index = InvItem(&aniX, &aniY, false);
if (index != INV_NOICON) {
if (InvD[ino].contents[index] && InvD[ino].contents[index] != HeldItem) {
invObj = GetInvObject(InvD[ino].contents[index]);
if (TinselV2)
thisIcon = InvD[ino].contents[index];
if (TinselV2 || (invObj->hScript))
InvTinselEvent(invObj, ACTION, INV_ACTION, index);
}
}
}
break;
case I_HEADER: // Maximise/unmaximise inventory
if (!InvD[ino].resizable)
break;
if (!InventoryMaximised) {
InvD[ino].sNoofHicons = InvD[ino].NoofHicons;
InvD[ino].sNoofVicons = InvD[ino].NoofVicons;
InvD[ino].NoofHicons = InvD[ino].MaxHicons;
InvD[ino].NoofVicons = InvD[ino].MaxVicons;
InventoryMaximised = true;
i = InvD[ino].inventoryX;
InvD[ino].inventoryX = InvD[ino].otherX;
InvD[ino].otherX = i;
i = InvD[ino].inventoryY;
InvD[ino].inventoryY = InvD[ino].otherY;
InvD[ino].otherY = i;
} else {
InvD[ino].NoofHicons = InvD[ino].sNoofHicons;
InvD[ino].NoofVicons = InvD[ino].sNoofVicons;
InventoryMaximised = false;
i = InvD[ino].inventoryX;
InvD[ino].inventoryX = InvD[ino].otherX;
InvD[ino].otherX = i;
i = InvD[ino].inventoryY;
InvD[ino].inventoryY = InvD[ino].otherY;
InvD[ino].otherY = i;
}
// Delete current, and re-draw
DumpDobjArray();
DumpObjArray();
ConstructInventory(FULL);
break;
case I_UP:
InvD[ino].FirstDisp -= InvD[ino].NoofHicons;
if (InvD[ino].FirstDisp < 0)
InvD[ino].FirstDisp = 0;
ItemsChanged = true;
break;
case I_DOWN:
if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems) {
InvD[ino].FirstDisp += InvD[ino].NoofHicons;
ItemsChanged = true;
}
break;
}
}
static void InvLook(const Common::Point &coOrds) {
int index;
INV_OBJECT *invObj;
Common::Point pt = coOrds;
switch (InvArea(pt.x, pt.y)) {
case I_BODY:
index = InvItem(pt, false);
if (index != INV_NOICON) {
if (InvD[ino].contents[index] && InvD[ino].contents[index] != HeldItem) {
invObj = GetInvObject(InvD[ino].contents[index]);
if (invObj->hScript)
InvTinselEvent(invObj, LOOK, INV_LOOK, index);
}
}
break;
case I_NOTIN:
if (ino == INV_CONV)
ConvAction(INV_CLOSEICON);
KillInventory();
break;
}
}
/**************************************************************************/
/********************* Incoming events ************************************/
/**************************************************************************/
void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
if (InventoryHidden)
return;
switch (pEvent) {
case PLR_PROV_WALKTO:
if (MenuActive()) {
ProcessedProvisional();
InvWalkTo(coOrds);
}
break;
case PLR_WALKTO: // PLR_SLEFT
InvWalkTo(coOrds);
break;
case INV_LOOK: // PLR_SRIGHT
if (MenuActive())
InvWalkTo(coOrds);
else
InvLook(coOrds);
break;
case PLR_ACTION: // PLR_DLEFT
if (InvDragging != ID_MDCONT)
InvDragEnd();
InvAction();
break;
case PLR_DRAG1_START: // Left drag start
InvDragStart();
break;
case PLR_DRAG1_END: // Left drag end
InvDragEnd();
break;
case PLR_ESCAPE:
if (MenuActive()) {
if (cd.box != optionBox && cd.box != hopperBox1 && cd.box != hopperBox2)
bReOpenMenu = true;
if ((cd.box == hopperBox1) || (cd.box == hopperBox2))
FreeSceneHopper();
}
CloseInventory();
break;
case PLR_PGDN:
if (ino == INV_MENU) {
// Only act if load or save screen
MenuPageDown();
} else {
// This code is a copy of SLClick on IB_SLIDE_DOWN
// TODO: So share this duplicate code
if (InvD[ino].NoofVicons == 1)
if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems)
InvD[ino].FirstDisp += InvD[ino].NoofHicons;
for (int i = 1; i < InvD[ino].NoofVicons; i++) {
if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems)
InvD[ino].FirstDisp += InvD[ino].NoofHicons;
}
ItemsChanged = true;
}
break;
case PLR_PGUP:
if (ino == INV_MENU) {
// Only act if load or save screen
MenuPageUp();
} else {
// This code is a copy of SLClick on I_SLIDE_UP
// TODO: So share this duplicate code
if (InvD[ino].NoofVicons == 1)
InvD[ino].FirstDisp -= InvD[ino].NoofHicons;
for (int i = 1; i < InvD[ino].NoofVicons; i++)
InvD[ino].FirstDisp -= InvD[ino].NoofHicons;
if (InvD[ino].FirstDisp < 0)
InvD[ino].FirstDisp = 0;
ItemsChanged = true;
}
break;
case PLR_HOME:
if (ino == INV_MENU) {
// Only act if load or save screen
if (cd.box == loadBox || cd.box == saveBox)
FirstFile(0);
else if (cd.box == hopperBox1)
FirstScene(0);
else if (cd.box == hopperBox2)
FirstEntry(0);
else
break;
AddBoxes(true);
cd.selBox = 0;
Select(cd.selBox, true);
} else {
InvD[ino].FirstDisp = 0;
ItemsChanged = true;
}
break;
case PLR_END:
if (ino == INV_MENU) {
if (cd.box == loadBox || cd.box == saveBox)
FirstFile(MAX_SAVED_FILES); // Will get reduced to appropriate value
else if (cd.box == hopperBox1)
FirstScene(numScenes); // Will get reduced to appropriate value
else if (cd.box == hopperBox2)
FirstEntry(numEntries); // Will get reduced to appropriate value
else
break;
AddBoxes(true);
cd.selBox = 0;
Select(cd.selBox, true);
} else {
InvD[ino].FirstDisp = InvD[ino].NoofItems - InvD[ino].NoofHicons*InvD[ino].NoofVicons;
if (InvD[ino].FirstDisp < 0)
InvD[ino].FirstDisp = 0;
ItemsChanged = true;
}
break;
default:
break;
}
}
/**************************************************************************/
/************************* Odds and Ends **********************************/
/**************************************************************************/
/**
* Called from Glitter function invdepict()
* Changes (permanently) the animation film for that object.
*/
void SetObjectFilm(int object, SCNHANDLE hFilm) {
INV_OBJECT *invObj;
invObj = GetInvObject(object);
invObj->hIconFilm = hFilm;
if (HeldItem != object)
ItemsChanged = true;
}
/**
* (Un)serialize the inventory data for save/restore game.
*/
void syncInvInfo(Serializer &s) {
for (int i = 0; i < NUM_INV; i++) {
s.syncAsSint32LE(InvD[i].MinHicons);
s.syncAsSint32LE(InvD[i].MinVicons);
s.syncAsSint32LE(InvD[i].MaxHicons);
s.syncAsSint32LE(InvD[i].MaxVicons);
s.syncAsSint32LE(InvD[i].NoofHicons);
s.syncAsSint32LE(InvD[i].NoofVicons);
for (int j = 0; j < MAX_ININV; j++) {
s.syncAsSint32LE(InvD[i].contents[j]);
}
s.syncAsSint32LE(InvD[i].NoofItems);
s.syncAsSint32LE(InvD[i].FirstDisp);
s.syncAsSint32LE(InvD[i].inventoryX);
s.syncAsSint32LE(InvD[i].inventoryY);
s.syncAsSint32LE(InvD[i].otherX);
s.syncAsSint32LE(InvD[i].otherY);
s.syncAsSint32LE(InvD[i].MaxInvObj);
s.syncAsSint32LE(InvD[i].hInvTitle);
s.syncAsSint32LE(InvD[i].resizable);
s.syncAsSint32LE(InvD[i].bMoveable);
s.syncAsSint32LE(InvD[i].sNoofHicons);
s.syncAsSint32LE(InvD[i].sNoofVicons);
s.syncAsSint32LE(InvD[i].bMax);
}
if (TinselV2) {
for (int i = 0; i < numObjects; ++i)
s.syncAsUint32LE(invFilms[i]);
s.syncAsUint32LE(heldFilm);
}
}
/**************************************************************************/
/************************ Initialisation stuff ****************************/
/**************************************************************************/
/**
* Called from PlayGame(), stores handle to inventory objects' data -
* its id, animation film and Glitter script.
*/
// Note: the SCHANDLE type here has been changed to a void*
void RegisterIcons(void *cptr, int num) {
numObjects = num;
invObjects = (INV_OBJECT *) cptr;
if (TinselV2) {
if (invFilms == NULL)
// First time - allocate memory
invFilms = (SCNHANDLE *)MemoryAlloc(DWM_FIXED | DWM_ZEROINIT, numObjects * sizeof(SCNHANDLE));
if (invFilms == NULL)
error(NO_MEM, "inventory scripts");
// Add defined permanent conversation icons
// and store all the films separately
int i;
INV_OBJECT *pio;
for (i = 0, pio = invObjects; i < numObjects; i++, pio++) {
if (pio->attribute & PERMACONV)
PermaConvIcon(pio->id, pio->attribute & CONVENDITEM);
invFilms[i] = pio->hIconFilm;
}
}
}
/**
* Called from Glitter function 'dec_invw()' - Declare the bits that the
* inventory windows are constructed from, and special cursors.
*/
void setInvWinParts(SCNHANDLE hf) {
#ifdef DEBUG
const FILM *pfilm;
#endif
hWinParts = hf;
#ifdef DEBUG
pfilm = (const FILM *)LockMem(hf);
assert(FROM_LE_32(pfilm->numreels) >= HOPEDFORREELS); // not as many reels as expected
#endif
}
/**
* Called from Glitter function 'dec_flags()' - Declare the language
* flag films
*/
void setFlagFilms(SCNHANDLE hf) {
#ifdef DEBUG
const FILM *pfilm;
#endif
flagFilm = hf;
#ifdef DEBUG
pfilm = (const FILM *)LockMem(hf);
assert(FROM_LE_32(pfilm->numreels) >= HOPEDFORFREELS); // not as many reels as expected
#endif
}
void setConfigStrings(SCNHANDLE *tp) {
memcpy(configStrings, tp, sizeof(configStrings));
}
/**
* Called from Glitter functions: dec_convw()/dec_inv1()/dec_inv2()
* - Declare the heading text and dimensions etc.
*/
void idec_inv(int num, SCNHANDLE text, int MaxContents,
int MinWidth, int MinHeight,
int StartWidth, int StartHeight,
int MaxWidth, int MaxHeight,
int startx, int starty, bool moveable) {
if (MaxWidth > MAXHICONS)
MaxWidth = MAXHICONS; // Max window width
if (MaxHeight > MAXVICONS)
MaxHeight = MAXVICONS; // Max window height
if (MaxContents > MAX_ININV)
MaxContents = MAX_ININV; // Max contents
if (StartWidth > MaxWidth)
StartWidth = MaxWidth;
if (StartHeight > MaxHeight)
StartHeight = MaxHeight;
InventoryState = IDLE_INV;
InvD[num].MaxHicons = MaxWidth;
InvD[num].MinHicons = MinWidth;
InvD[num].MaxVicons = MaxHeight;
InvD[num].MinVicons = MinHeight;
InvD[num].NoofHicons = StartWidth;
InvD[num].NoofVicons = StartHeight;
memset(InvD[num].contents, 0, sizeof(InvD[num].contents));
InvD[num].NoofItems = 0;
InvD[num].FirstDisp = 0;
InvD[num].inventoryX = startx;
InvD[num].inventoryY = starty;
InvD[num].otherX = 21;
InvD[num].otherY = 15;
InvD[num].MaxInvObj = MaxContents;
InvD[num].hInvTitle = text;
if (MaxWidth != MinWidth && MaxHeight != MinHeight)
InvD[num].resizable = true;
InvD[num].bMoveable = moveable;
InvD[num].bMax = false;
}
/**
* Called from Glitter functions: dec_convw()/dec_inv1()/dec_inv2()
* - Declare the heading text and dimensions etc.
*/
void idec_convw(SCNHANDLE text, int MaxContents,
int MinWidth, int MinHeight,
int StartWidth, int StartHeight,
int MaxWidth, int MaxHeight) {
idec_inv(INV_CONV, text, MaxContents, MinWidth, MinHeight,
StartWidth, StartHeight, MaxWidth, MaxHeight,
20, 8, true);
}
/**
* Called from Glitter functions: dec_convw()/dec_inv1()/dec_inv2()
* - Declare the heading text and dimensions etc.
*/
void idec_inv1(SCNHANDLE text, int MaxContents,
int MinWidth, int MinHeight,
int StartWidth, int StartHeight,
int MaxWidth, int MaxHeight) {
idec_inv(INV_1, text, MaxContents, MinWidth, MinHeight,
StartWidth, StartHeight, MaxWidth, MaxHeight,
100, 100, true);
}
/**
* Called from Glitter functions: dec_convw()/dec_inv1()/dec_inv2()
* - Declare the heading text and dimensions etc.
*/
void idec_inv2(SCNHANDLE text, int MaxContents,
int MinWidth, int MinHeight,
int StartWidth, int StartHeight,
int MaxWidth, int MaxHeight) {
idec_inv(INV_2, text, MaxContents, MinWidth, MinHeight,
StartWidth, StartHeight, MaxWidth, MaxHeight,
100, 100, true);
}
int InvGetLimit(int invno) {
assert(invno == INV_1 || invno == INV_2); // only INV_1 and INV_2 supported
return InvD[invno].MaxInvObj;
}
void InvSetLimit(int invno, int MaxContents) {
assert(invno == INV_1 || invno == INV_2); // only INV_1 and INV_2 supported
assert(MaxContents >= InvD[invno].NoofItems); // can't reduce maximum contents below current contents
if (MaxContents > MAX_ININV)
MaxContents = MAX_ININV; // Max contents
InvD[invno].MaxInvObj = MaxContents;
}
void InvSetSize(int invno, int MinWidth, int MinHeight,
int StartWidth, int StartHeight, int MaxWidth, int MaxHeight) {
assert(invno == INV_1 || invno == INV_2); // only INV_1 and INV_2 supported
if (StartWidth > MaxWidth)
StartWidth = MaxWidth;
if (StartHeight > MaxHeight)
StartHeight = MaxHeight;
InvD[invno].MaxHicons = MaxWidth;
InvD[invno].MinHicons = MinWidth;
InvD[invno].MaxVicons = MaxHeight;
InvD[invno].MinVicons = MinHeight;
InvD[invno].NoofHicons = StartWidth;
InvD[invno].NoofVicons = StartHeight;
if (MaxWidth != MinWidth && MaxHeight != MinHeight)
InvD[invno].resizable = true;
else
InvD[invno].resizable = false;
InvD[invno].bMax = false;
}
/**************************************************************************/
bool IsTopWindow(void) {
return (InventoryState == BOGUS_INV);
}
bool MenuActive(void) {
return (InventoryState == ACTIVE_INV && ino == INV_CONF);
}
bool IsConvWindow(void) {
return (InventoryState == ACTIVE_INV && ino == INV_CONV);
}
} // end of namespace Tinsel
|