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
|
#include "stdafx.h"
#include <xuiresource.h>
#include <xuiapp.h>
#include <assert.h>
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\Common\Tutorial\TutorialMode.h"
#include "..\..\..\Minecraft.World\ConsoleSaveFileIO.h"
#include "..\..\LocalPlayer.h"
#include "..\..\Minecraft.h"
#include "..\..\ProgressRenderer.h"
#include "..\..\..\Minecraft.World\AABB.h"
#include "..\..\..\Minecraft.World\Vec3.h"
#include "..\..\..\Minecraft.World\ArrayWithLength.h"
#include "..\..\..\Minecraft.World\File.h"
#include "..\..\..\Minecraft.World\InputOutputStream.h"
#include "XUI_Ctrl_4JList.h"
#include "XUI_Ctrl_4JIcon.h"
#include "XUI_LoadSettings.h"
#include "XUI_MultiGameInfo.h"
#include "XUI_MultiGameJoinLoad.h"
#include "XUI_MultiGameCreate.h"
#include "..\..\MinecraftServer.h"
#include "..\..\Options.h"
#include "..\GameRules\LevelGenerationOptions.h"
#include "..\..\TexturePackRepository.h"
#include "..\..\TexturePack.h"
#include "..\..\..\Minecraft.World\LevelSettings.h"
#define CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID 3
#define CHECKFORAVAILABLETEXTUREPACKS_TIMER_TIME 100
//----------------------------------------------------------------------------------
// Performs initialization tasks - retrieves controls.
//----------------------------------------------------------------------------------
HRESULT CScene_MultiGameJoinLoad::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
m_iPad=*static_cast<int *>(pInitData->pvInitData);
m_bReady=false;
MapChildControls();
m_iTexturePacksNotInstalled=0;
m_iConfigA=nullptr;
XuiControlSetText(m_LabelNoGames,app.GetString(IDS_NO_GAMES_FOUND));
XuiControlSetText(m_GamesList,app.GetString(IDS_JOIN_GAME));
XuiControlSetText(m_SavesList,app.GetString(IDS_START_GAME));
const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string
WCHAR szResourceLocator[ LOCATOR_SIZE ];
const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr);
swprintf(szResourceLocator, LOCATOR_SIZE ,L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/Graphics/TexturePackIcon.png");
m_DefaultMinecraftIconSize = 0;
HRESULT hr = XuiResourceLoadAllNoLoc(szResourceLocator, &m_DefaultMinecraftIconData, &m_DefaultMinecraftIconSize);
m_localPlayers = 1;
m_bKillSaveInfoEnumerate=false;
m_bShowingPartyGamesOnly = false;
m_bRetrievingSaveInfo=false;
m_bSaveTransferInProgress=false;
// check for a default custom cloak in the global storage
// 4J-PB - changed to a config file
// if(ProfileManager.IsSignedInLive( m_iPad ))
// {
// app.InstallDefaultCape();
// }
m_initData= new JoinMenuInitData();
m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
XPARTY_USER_LIST partyList;
if((XPartyGetUserList( &partyList ) != XPARTY_E_NOT_IN_PARTY ) && (partyList.dwUserCount>1))
{
m_bInParty=true;
}
else
{
m_bInParty=false;
}
int iLB = -1;
if(m_bInParty) iLB = IDS_TOOLTIPS_PARTY_GAMES;
XuiSetTimer(m_hObj,JOIN_LOAD_ONLINE_TIMER_ID,JOIN_LOAD_ONLINE_TIMER_TIME);
m_iSaveInfoC=0;
VOID *pObj;
XuiObjectFromHandle( m_SavesList, &pObj );
m_pSavesList = static_cast<CXuiCtrl4JList *>(pObj);
XuiObjectFromHandle( m_GamesList, &pObj );
m_pGamesList = static_cast<CXuiCtrl4JList *>(pObj);
// block input if we're waiting for DLC to install, and wipe the saves list. The end of dlc mounting custom message will fill the list again
if(app.StartInstallDLCProcess(m_iPad)==true)
{
// not doing a mount, so enable input
m_bIgnoreInput=true;
}
else
{
// if we're waiting for DLC to mount, don't fill the save list. The custom message on end of dlc mounting will do that
m_bIgnoreInput=false;
m_iChangingSaveGameInfoIndex = 0;
m_generators = app.getLevelGenerators();
m_iDefaultButtonsC = 0;
m_iMashUpButtonsC=0;
// check if we're in the trial version
if(ProfileManager.IsFullVersion()==false)
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK, -1, -1, -1, -1,iLB);
AddDefaultButtons();
m_pSavesList->SetCurSelVisible(0);
}
else if(StorageManager.GetSaveDisabled())
{
if(StorageManager.GetSaveDeviceSelected(m_iPad))
{
// saving is disabled, but we should still be able to load from a selected save device
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK,IDS_TOOLTIPS_CHANGEDEVICE,-1,-1,-1,iLB,IDS_TOOLTIPS_DELETESAVE);
GetSaveInfo();
}
else
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK,IDS_TOOLTIPS_SELECTDEVICE,-1,-1,-1,iLB);
AddDefaultButtons();
m_SavesListTimer.SetShow( FALSE );
m_pSavesList->SetCurSelVisible(0);
}
}
else
{
// 4J-PB - we need to check that there is enough space left to create a copy of the save (for a rename)
bool bCanRename = StorageManager.EnoughSpaceForAMinSaveGame();
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK,IDS_TOOLTIPS_CHANGEDEVICE,-1,-1,-1,-1,bCanRename?IDS_TOOLTIPS_SAVEOPTIONS:IDS_TOOLTIPS_DELETESAVE);
GetSaveInfo();
}
}
//XuiElementSetDisableFocusRecursion( m_pGamesList->m_hObj, TRUE);
UpdateGamesList();
g_NetworkManager.SetSessionsUpdatedCallback( &CScene_MultiGameJoinLoad::UpdateGamesListCallback, this );
// 4J Stu - Fix for #12530 -TCR 001 BAS Game Stability: Title will crash if the player disconnects while starting a new world and then opts to play the tutorial once they have been returned to the Main Menu.
MinecraftServer::resetFlags();
// If we're not ignoring input, then we aren't still waiting for the DLC to mount, and can now check for corrupt dlc. Otherwise this will happen when the dlc has finished mounting.
if( !m_bIgnoreInput)
{
app.m_dlcManager.checkForCorruptDLCAndAlert();
}
// 4J-PB - Load up any texture pack data we have locally in the XZP
for(int i=0;i<TMS_COUNT;i++)
{
if(app.TMSFileA[i].eTMSType==eTMSFileType_TexturePack)
{
app.LoadLocalTMSFile(app.TMSFileA[i].wchFilename,app.TMSFileA[i].eEXT);
app.AddMemoryTPDFile(app.TMSFileA[i].iConfig, app.TMSFileA[i].pbData,app.TMSFileA[i].uiSize);
}
}
// 4J-PB - there may be texture packs we don't have, so use the info from TMS for this
DLC_INFO *pDLCInfo=nullptr;
// first pass - look to see if there are any that are not in the list
bool bTexturePackAlreadyListed;
bool bNeedToGetTPD=false;
Minecraft *pMinecraft = Minecraft::GetInstance();
int texturePacksCount = pMinecraft->skins->getTexturePackCount();
//CXuiCtrl4JList::LIST_ITEM_INFO ListInfo;
//HRESULT hr;
for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i)
{
bTexturePackAlreadyListed=false;
ULONGLONG ull=app.GetDLCInfoTexturesFullOffer(i);
pDLCInfo=app.GetDLCInfoForFullOfferID(ull);
for(unsigned int i = 0; i < texturePacksCount; ++i)
{
TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i);
if(pDLCInfo->iConfig==tp->getDLCParentPackId())
{
bTexturePackAlreadyListed=true;
}
}
if(bTexturePackAlreadyListed==false)
{
// some missing
bNeedToGetTPD=true;
m_iTexturePacksNotInstalled++;
}
}
if(bNeedToGetTPD==true)
{
// add a TMS request for them
app.DebugPrintf("+++ Adding TMSPP request for texture pack data\n");
app.AddTMSPPFileTypeRequest(e_DLC_TexturePackData);
m_iConfigA= new int [m_iTexturePacksNotInstalled];
m_iTexturePacksNotInstalled=0;
for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i)
{
bTexturePackAlreadyListed=false;
ULONGLONG ull=app.GetDLCInfoTexturesFullOffer(i);
pDLCInfo=app.GetDLCInfoForFullOfferID(ull);
for(unsigned int i = 0; i < texturePacksCount; ++i)
{
TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i);
if(pDLCInfo->iConfig==tp->getDLCParentPackId())
{
bTexturePackAlreadyListed=true;
}
}
if(bTexturePackAlreadyListed==false)
{
m_iConfigA[m_iTexturePacksNotInstalled++]=pDLCInfo->iConfig;
}
}
}
XuiSetTimer(m_hObj,CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID,CHECKFORAVAILABLETEXTUREPACKS_TIMER_TIME);
return S_OK;
}
void CScene_MultiGameJoinLoad::AddDefaultButtons()
{
CXuiCtrl4JList::LIST_ITEM_INFO ListInfo;
// Add two for New Game and Tutorial
ZeroMemory(&ListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO));
ListInfo.pwszText = app.GetString(IDS_CREATE_NEW_WORLD);
ListInfo.fEnabled = TRUE;
ListInfo.iData = -1;
m_pSavesList->AddData(ListInfo);
int iSavesListIndex = 0;
int iGeneratorIndex = 0;
m_iMashUpButtonsC=0;
for (LevelGenerationOptions *levelGen : *m_generators )
{
ListInfo.pwszText = levelGen->getWorldName();
ListInfo.fEnabled = TRUE;
ListInfo.iData = iGeneratorIndex++; // used to index into the list of generators
// need to check if the user has disabled this pack in the save display list
unsigned int uiTexturePackID=levelGen->getRequiredTexturePackId();
if(uiTexturePackID!=0)
{
unsigned int uiMashUpWorldsBitmask=app.GetMashupPackWorlds(m_iPad);
if((uiMashUpWorldsBitmask & (1<<(uiTexturePackID-1024)))==0)
{
// this world is hidden, so skip
continue;
}
}
m_pSavesList->AddData(ListInfo);
// retrieve the save icon from the texture pack, if there is one
if(uiTexturePackID!=0)
{
// increment the count of the mash-up pack worlds in the save list
m_iMashUpButtonsC++;
TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackById(levelGen->getRequiredTexturePackId());
DWORD dwImageBytes;
PBYTE pbImageData = tp->getPackIcon(dwImageBytes);
HXUIBRUSH hXuiBrush;
if(dwImageBytes > 0 && pbImageData)
{
XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&hXuiBrush);
// the index inside the list item for this will be i+1 because they start at m_vListData.size(), so the first etry (tutorial) is 1
m_pSavesList->UpdateGraphic(iSavesListIndex+1,hXuiBrush);
}
}
++iSavesListIndex;
}
m_iDefaultButtonsC = iSavesListIndex + 1;
}
HRESULT CScene_MultiGameJoinLoad::GetSaveInfo( )
{
unsigned int uiSaveC=0;
// This will return with the number retrieved in uiSaveC
if(app.DebugSettingsOn() && app.GetLoadSavesFromFolderEnabled())
{
uiSaveC = 0;
File savesDir(L"GAME:\\Saves");
if( savesDir.exists() )
{
m_saves = savesDir.listFiles();
uiSaveC = static_cast<unsigned int>(m_saves->size());
}
// add the New Game and Tutorial after the saves list is retrieved, if there are any saves
// Add two for New Game and Tutorial
unsigned int listItems = uiSaveC;
CXuiCtrl4JList::LIST_ITEM_INFO ListInfo;
ZeroMemory(&ListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO));
AddDefaultButtons();
for(unsigned int i=0;i<listItems;i++)
{
wstring wName = m_saves->at(i)->getName();
wchar_t *name = new wchar_t[wName.size()+1];
for(unsigned int j = 0; j < wName.size(); ++j)
{
name[j] = wName[j];
}
name[wName.size()] = 0;
ListInfo.pwszText = name;
ListInfo.fEnabled=TRUE;
ListInfo.iData = -1;
m_pSavesList->AddData(ListInfo);
}
m_pSavesList->SetCurSelVisible(0);
}
else
{
m_bRetrievingSaveInfo=true; // we're blocking the exit from this scene until complete
// clear the saves list
m_pSavesList->RemoveAllData();
m_iSaveInfoC=0;
#ifdef _XBOX
C4JStorage::ESGIStatus eSGIStatus=StorageManager.GetSavesInfo(ProfileManager.GetPrimaryPad(),&CScene_MultiGameJoinLoad::GetSavesInfoCallback,this,"savegame.dat");
if(eSGIStatus==C4JStorage::ESGIStatus_NoSaves)
{
uiSaveC=0;
m_SavesListTimer.SetShow( FALSE );
m_SavesList.SetEnable(TRUE);
}
#else
//C4JStorage::ESaveGameState eStatus=StorageManager.GetSavesInfo(ProfileManager.GetPrimaryPad(),&CScene_MultiGameJoinLoad::GetSavesInfoCallback,this,"savegame.dat");
#endif
}
return S_OK;
}
HRESULT CScene_MultiGameJoinLoad::OnDestroy()
{
g_NetworkManager.SetSessionsUpdatedCallback( nullptr, nullptr );
for (auto& it : currentSessions )
{
delete it;
}
if(m_bSaveTransferInProgress)
{
CancelSaveUploadCallback(this);
}
// Reset the background downloading, in case we changed it by attempting to download a texture pack
XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_AUTO);
// clear out the texture pack data
for(int i=0;i<TMS_COUNT;i++)
{
if(app.TMSFileA[i].eTMSType==eTMSFileType_TexturePack)
{
app.RemoveMemoryTPDFile(app.TMSFileA[i].iConfig);
}
}
app.FreeLocalTMSFiles(eTMSFileType_TexturePack);
return S_OK;
}
int CScene_MultiGameJoinLoad::DeviceRemovedDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(pParam);
// results switched for this dialog
if(result==C4JStorage::EMessage_ResultDecline)
{
StorageManager.SetSaveDisabled(true);
StorageManager.SetSaveDeviceSelected(ProfileManager.GetPrimaryPad(),false);
// use the device select returned function to wipe the saves list and change the tooltip
CScene_MultiGameJoinLoad::DeviceSelectReturned(pClass,true);
}
else // continue without saving
{
// Change device
StorageManager.SetSaveDevice(&CScene_MultiGameJoinLoad::DeviceSelectReturned,pClass,true);
}
pClass->m_bIgnoreInput=false;
return 0;
}
//----------------------------------------------------------------------------------
// Handler for the button press message.
//----------------------------------------------------------------------------------
HRESULT CScene_MultiGameJoinLoad::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
{
if(m_bIgnoreInput) return S_OK;
// if we're retrieving save info, ignore key presses
if(m_bRetrievingSaveInfo)
{
return S_OK;
}
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
if ( hObjPressed == m_GamesList )
{
m_bIgnoreInput=true;
DWORD nIndex = m_pGamesList->GetCurSel();
if( m_pGamesList->GetItemCount() > 0 && nIndex < currentSessions.size() )
{
//CScene_MultiGameInfo::JoinMenuInitData *initData = new CScene_MultiGameInfo::JoinMenuInitData();
m_initData->iPad = m_iPad;
m_initData->selectedSession = currentSessions.at( nIndex );
// check that we have the texture pack available
// If it's not the default texture pack
if(m_initData->selectedSession->data.texturePackParentId!=0)
{
int texturePacksCount = Minecraft::GetInstance()->skins->getTexturePackCount();
bool bHasTexturePackInstalled=false;
for(int i=0;i<texturePacksCount;i++)
{
TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackByIndex(i);
if(tp->getDLCParentPackId()==m_initData->selectedSession->data.texturePackParentId)
{
bHasTexturePackInstalled=true;
break;
}
}
if(bHasTexturePackInstalled==false)
{
// upsell the texture pack
// tell sentient about the upsell of the full version of the skin pack
ULONGLONG ullOfferID_Full;
app.GetDLCFullOfferIDForPackID(m_initData->selectedSession->data.texturePackParentId,&ullOfferID_Full);
TelemetryManager->RecordUpsellPresented(pNotifyPressData->UserIndex, eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF);
UINT uiIDA[3];
// Need to check if the texture pack has both Full and Trial versions - we may do some as free ones, so only Full
DLC_INFO *pDLCInfo=app.GetDLCInfoForFullOfferID(ullOfferID_Full);
if(pDLCInfo->ullOfferID_Trial!=0LL)
{
uiIDA[0]=IDS_TEXTUREPACK_FULLVERSION;
uiIDA[1]=IDS_TEXTURE_PACK_TRIALVERSION;
uiIDA[2]=IDS_CONFIRM_CANCEL;
// Give the player a warning about the texture pack missing
StorageManager.RequestMessageBox(IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 3, ProfileManager.GetPrimaryPad(),&CScene_MultiGameJoinLoad::TexturePackDialogReturned,this,app.GetStringTable());
}
else
{
uiIDA[0]=IDS_TEXTUREPACK_FULLVERSION;
uiIDA[1]=IDS_CONFIRM_CANCEL;
// Give the player a warning about the texture pack missing
StorageManager.RequestMessageBox(IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CScene_MultiGameJoinLoad::TexturePackDialogReturned,this,app.GetStringTable());
}
return S_OK;
}
}
m_NetGamesListTimer.SetShow( FALSE );
// Reset the background downloading, in case we changed it by attempting to download a texture pack
XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_AUTO);
// kill the texture pack check timer
XuiKillTimer(m_hObj,CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID);
app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_JoinMenu,m_initData);
}
}
else if(hObjPressed==m_SavesList)
{
m_bIgnoreInput=true;
CXuiControl pItem;
int iIndex;
// get the selected item
iIndex=m_SavesList.GetCurSel(&pItem);
CXuiCtrl4JList::LIST_ITEM_INFO info = m_pSavesList->GetData(iIndex);
if(iIndex == JOIN_LOAD_CREATE_BUTTON_INDEX)
{
app.SetTutorialMode( false );
m_NetGamesListTimer.SetShow( FALSE );
app.SetCorruptSaveDeleted(false);
CreateWorldMenuInitData *params = new CreateWorldMenuInitData();
params->iPad = m_iPad;
app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_CreateWorldMenu,static_cast<void *>(params));
}
else if(info.iData >= 0)
{
LevelGenerationOptions *levelGen = m_generators->at(info.iData);
app.SetTutorialMode( levelGen->isTutorial() );
// Reset the autosave time
app.SetAutosaveTimerTime();
if(levelGen->isTutorial())
{
LoadLevelGen(levelGen);
}
else
{
LoadMenuInitData *params = new LoadMenuInitData();
params->iPad = m_iPad;
// need to get the iIndex from the list item, since the position in the list doesn't correspond to the GetSaveGameInfo list because of sorting
params->iSaveGameInfoIndex=-1;
//params->pbSaveRenamed=&m_bSaveRenamed;
params->levelGen = levelGen;
// navigate to the settings scene
app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_LoadMenu, params);
}
}
else
{
// check if this is a damaged save
if(m_pSavesList->GetData(iIndex).bIsDamaged)
{
// give the option to delete the save
UINT uiIDA[2];
uiIDA[0]=IDS_CONFIRM_CANCEL;
uiIDA[1]=IDS_CONFIRM_OK;
StorageManager.RequestMessageBox(IDS_CORRUPT_OR_DAMAGED_SAVE_TITLE, IDS_CORRUPT_OR_DAMAGED_SAVE_TEXT, uiIDA, 2, pNotifyPressData->UserIndex,&CScene_MultiGameJoinLoad::DeleteSaveDialogReturned,this, app.GetStringTable());
}
else
{
app.SetTutorialMode( false );
if(app.DebugSettingsOn() && app.GetLoadSavesFromFolderEnabled())
{
LoadSaveFromDisk(m_saves->at(iIndex-m_iDefaultButtonsC));
}
else
{
LoadMenuInitData *params = new LoadMenuInitData();
params->iPad = m_iPad;
// need to get the iIndex from the list item, since the position in the list doesn't correspond to the GetSaveGameInfo list because of sorting
params->iSaveGameInfoIndex=m_pSavesList->GetData(iIndex).iIndex-m_iDefaultButtonsC;
//params->pbSaveRenamed=&m_bSaveRenamed;
params->levelGen = nullptr;
// kill the texture pack timer
XuiKillTimer(m_hObj,CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID);
// navigate to the settings scene
app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_LoadMenu, params);
}
}
}
}
return S_OK;
}
HRESULT CScene_MultiGameJoinLoad::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
if(m_bIgnoreInput) return S_OK;
// if we're retrieving save info, ignore key presses
if(m_bRetrievingSaveInfo)
{
return S_OK;
}
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
HRESULT hr = S_OK;
// Explicitly handle B button presses
switch(pInputData->dwKeyCode)
{
case VK_PAD_B:
case VK_ESCAPE:
m_NetGamesListTimer.SetShow( FALSE );
app.NavigateBack(XUSER_INDEX_ANY);
rfHandled = TRUE;
break;
case VK_PAD_X:
// Change device
// Fix for #12531 - TCR 001: BAS Game Stability: When a player selects to change a storage
// device, and repeatedly backs out of the SD screen, disconnects from LIVE, and then selects a SD, the title crashes.
m_bIgnoreInput=true;
StorageManager.SetSaveDevice(&CScene_MultiGameJoinLoad::DeviceSelectReturned,this,true);
CXuiSceneBase::PlayUISFX(eSFX_Press);
break;
case VK_PAD_Y:
if(m_pGamesList->TreeHasFocus() && m_pGamesList->GetItemCount() > 0)
{
DWORD nIndex = m_pGamesList->GetCurSel();
FriendSessionInfo *pSelectedSession = currentSessions.at( nIndex );
PlayerUID xuid = pSelectedSession->data.hostPlayerUID;
if( xuid != INVALID_XUID )
hr = XShowGamerCardUI(ProfileManager.GetLockedProfile(), xuid);
CXuiSceneBase::PlayUISFX(eSFX_Press);
}
else if(DoesSavesListHaveFocus())
{
// save transfer - make sure they want to overwrite a save that is up there
if(ProfileManager.IsSignedInLive( m_iPad ))
{
// 4J-PB - required for a delete of the save if it's found to be a corrupted save
DWORD nIndex = m_pSavesList->GetCurSel();
m_iChangingSaveGameInfoIndex=m_pSavesList->GetData(nIndex).iIndex;
UINT uiIDA[2];
uiIDA[0]=IDS_UPLOAD_SAVE;
uiIDA[1]=IDS_CONFIRM_CANCEL;
ui.RequestMessageBox(IDS_SAVE_TRANSFER_TITLE, IDS_SAVE_TRANSFER_TEXT, uiIDA, 2, pInputData->UserIndex,&CScene_MultiGameJoinLoad::SaveTransferDialogReturned,this, app.GetStringTable());
}
}
break;
case VK_PAD_RSHOULDER:
if(DoesSavesListHaveFocus())
{
m_bIgnoreInput = true;
int iIndex=m_SavesList.GetCurSel();
m_iChangingSaveGameInfoIndex=m_pSavesList->GetData(iIndex).iIndex;
// Could be delete save or Save Options
if(StorageManager.GetSaveDisabled())
{
// delete the save game
// Have to ask the player if they are sure they want to delete this game
UINT uiIDA[2];
uiIDA[0]=IDS_CONFIRM_CANCEL;
uiIDA[1]=IDS_CONFIRM_OK;
StorageManager.RequestMessageBox(IDS_TOOLTIPS_DELETESAVE, IDS_TEXT_DELETE_SAVE, uiIDA, 2, pInputData->UserIndex,&CScene_MultiGameJoinLoad::DeleteSaveDialogReturned,this, app.GetStringTable());
}
else
{
if(StorageManager.EnoughSpaceForAMinSaveGame())
{
UINT uiIDA[3];
uiIDA[0]=IDS_CONFIRM_CANCEL;
uiIDA[1]=IDS_TITLE_RENAMESAVE;
uiIDA[2]=IDS_TOOLTIPS_DELETESAVE;
StorageManager.RequestMessageBox(IDS_TOOLTIPS_SAVEOPTIONS, IDS_TEXT_SAVEOPTIONS, uiIDA, 3, pInputData->UserIndex,&CScene_MultiGameJoinLoad::SaveOptionsDialogReturned,this, app.GetStringTable());
}
else
{
// delete the save game
// Have to ask the player if they are sure they want to delete this game
UINT uiIDA[2];
uiIDA[0]=IDS_CONFIRM_CANCEL;
uiIDA[1]=IDS_CONFIRM_OK;
StorageManager.RequestMessageBox(IDS_TOOLTIPS_DELETESAVE, IDS_TEXT_DELETE_SAVE, uiIDA, 2, pInputData->UserIndex,&CScene_MultiGameJoinLoad::DeleteSaveDialogReturned,this, app.GetStringTable());
}
}
CXuiSceneBase::PlayUISFX(eSFX_Press);
}
else if(DoesMashUpWorldHaveFocus())
{
// hiding a mash-up world
// get the mash-up pack id
CXuiControl pItem;
int iIndex;
iIndex=m_SavesList.GetCurSel(&pItem);
CXuiCtrl4JList::LIST_ITEM_INFO info = m_pSavesList->GetData(iIndex);
if((iIndex != JOIN_LOAD_CREATE_BUTTON_INDEX) && (info.iData >= 0))
{
LevelGenerationOptions *levelGen = m_generators->at(info.iData);
if(!levelGen->isTutorial())
{
if(levelGen->requiresTexturePack())
{
unsigned int uiPackID=levelGen->getRequiredTexturePackId();
m_bIgnoreInput = true;
app.HideMashupPackWorld(m_iPad,uiPackID);
// update the saves list
m_pSavesList->RemoveAllData();
m_iSaveInfoC=0;
GetSaveInfo();
m_bIgnoreInput = false;
}
}
}
CXuiSceneBase::PlayUISFX(eSFX_Press);
}
break;
case VK_PAD_LSHOULDER:
if( m_bInParty )
{
m_bShowingPartyGamesOnly = !m_bShowingPartyGamesOnly;
UpdateGamesList();
CXuiSceneBase::PlayUISFX(eSFX_Press);
}
break;
}
return hr;
}
HRESULT CScene_MultiGameJoinLoad::OnNavReturn(HXUIOBJ hSceneFrom,BOOL& rfHandled)
{
CXuiSceneBase::ShowLogo( DEFAULT_XUI_MENU_USER, TRUE );
// start the texture pack timer again
XuiSetTimer(m_hObj,CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID,CHECKFORAVAILABLETEXTUREPACKS_TIMER_TIME);
m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
// re-enable button presses
m_bIgnoreInput=false;
if( m_bMultiplayerAllowed )
{
HXUICLASS hClassFullscreenProgress = XuiFindClass( L"CScene_FullscreenProgress" );
HXUICLASS hClassConnectingProgress = XuiFindClass( L"CScene_ConnectingProgress" );
// If we are navigating back from a full screen progress scene, then that means a connection attempt failed
if( XuiIsInstanceOf( hSceneFrom, hClassFullscreenProgress ) || XuiIsInstanceOf( hSceneFrom, hClassConnectingProgress ) )
{
UpdateGamesList();
}
}
else
{
m_pGamesList->RemoveAllData();
//m_GamesList.DeleteItems(0, m_GamesList.GetItemCount() );
m_pGamesList->SetEnable(FALSE);
//XuiElementSetDisableFocusRecursion( m_pGamesList->m_hObj, TRUE);
m_NetGamesListTimer.SetShow( TRUE );
m_LabelNoGames.SetShow( FALSE );
m_SavesList.InitFocus(m_iPad);
}
// are we back here because of a delete of a corrupt save?
if(app.GetCorruptSaveDeleted())
{
// need to re-get the saves list and update the display
// clear the saves list
m_pSavesList->RemoveAllData();
m_iSaveInfoC=0;
GetSaveInfo();
app.SetCorruptSaveDeleted(false);
}
int iY = -1;
int iRB=-1;
if( DoesGamesListHaveFocus() )
{
iY = IDS_TOOLTIPS_VIEW_GAMERCARD;
}
else if(DoesSavesListHaveFocus())
{
if(ProfileManager.IsSignedInLive( m_iPad ))
{
iY=IDS_TOOLTIPS_UPLOAD_SAVE_FOR_XBOXONE;
}
if(StorageManager.GetSaveDisabled())
{
iRB=IDS_TOOLTIPS_DELETESAVE;
}
else
{
// 4J-PB - we need to check that there is enough space left to create a copy of the save (for a rename)
if(StorageManager.EnoughSpaceForAMinSaveGame())
{
iRB=IDS_TOOLTIPS_SAVEOPTIONS;
}
else
{
iRB=IDS_TOOLTIPS_DELETESAVE;
}
}
}
else if(DoesMashUpWorldHaveFocus())
{
// If it's a mash-up pack world, give the Hide option
iRB=IDS_TOOLTIPS_HIDE;
}
int iLB = -1;
if(m_bInParty)
{
if( m_bShowingPartyGamesOnly ) iLB = IDS_TOOLTIPS_ALL_GAMES;
else iLB = IDS_TOOLTIPS_PARTY_GAMES;
}
if(ProfileManager.IsFullVersion()==false )
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK, -1, -1,-1,-1,iLB);
}
else if(StorageManager.GetSaveDisabled())
{
// clear out the saves list, since the disable save may have happened in the load screen because of a device removal
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK,IDS_TOOLTIPS_SELECTDEVICE,iY,-1,-1,iLB,iRB);
}
else
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK, IDS_TOOLTIPS_CHANGEDEVICE, iY,-1,-1,iLB,iRB);
}
return S_OK;
}
HRESULT CScene_MultiGameJoinLoad::OnNotifySelChanged(HXUIOBJ hObjSource, XUINotifySelChanged *pNotifySelChangedData, BOOL& bHandled)
{
if(m_bReady)
{
CXuiSceneBase::PlayUISFX(eSFX_Focus);
}
return S_OK;
}
HRESULT CScene_MultiGameJoinLoad::OnTransitionStart( XUIMessageTransition *pTransition, BOOL& bHandled )
{
//if(pTransition->dwTransAction==XUI_TRANSITION_ACTION_DESTROY ) return S_OK;
if(pTransition->dwTransAction==XUI_TRANSITION_ACTION_DESTROY ||
pTransition->dwTransType == XUI_TRANSITION_FROM || pTransition->dwTransType == XUI_TRANSITION_BACKFROM)
{
// 4J Stu - We may have had to unload our font renderer in this scene if one of the save files
// uses characters not in our font (eg asian chars) so restore our font renderer
// This will not do anything if our font renderer is already loaded
app.OverrideFontRenderer(true,true);
KillTimer(JOIN_LOAD_ONLINE_TIMER_ID);
}
else if(pTransition->dwTransType == XUI_TRANSITION_TO || pTransition->dwTransType == XUI_TRANSITION_BACKTO)
{
SetTimer(JOIN_LOAD_ONLINE_TIMER_ID,JOIN_LOAD_ONLINE_TIMER_TIME);
// 4J-PB - Need to check for installed DLC, which might have happened while you were on the info scene
if(pTransition->dwTransType == XUI_TRANSITION_BACKTO)
{
// Can't call this here because if you back out of the load info screen and then go back in and load a game, it will attempt to use the dlc as it's running a mount of the dlc
// block input if we're waiting for DLC to install, and wipe the saves list. The end of dlc mounting custom message will fill the list again
if(app.StartInstallDLCProcess(m_iPad)==false)
{
// not doing a mount, so re-enable input
m_bIgnoreInput=false;
}
else
{
m_bIgnoreInput=true;
m_pSavesList->RemoveAllData();
m_SavesListTimer.SetShow( TRUE );
}
}
}
return S_OK;
}
HRESULT CScene_MultiGameJoinLoad::OnFontRendererChange()
{
// update the tooltips
// if the saves list has focus, then we should show the Delete Save tooltip
// if the games list has focus, then we should the the View Gamercard tooltip
int iRB=-1;
int iY = -1;
if( DoesGamesListHaveFocus() )
{
iY = IDS_TOOLTIPS_VIEW_GAMERCARD;
}
else if(DoesSavesListHaveFocus())
{
if(ProfileManager.IsSignedInLive( m_iPad ))
{
iY=IDS_TOOLTIPS_UPLOAD_SAVE_FOR_XBOXONE;
}
if(StorageManager.GetSaveDisabled())
{
iRB=IDS_TOOLTIPS_DELETESAVE;
}
else
{
if(StorageManager.EnoughSpaceForAMinSaveGame())
{
iRB=IDS_TOOLTIPS_SAVEOPTIONS;
}
else
{
iRB=IDS_TOOLTIPS_DELETESAVE;
}
}
}
else if(DoesMashUpWorldHaveFocus())
{
// If it's a mash-up pack world, give the Hide option
iRB=IDS_TOOLTIPS_HIDE;
}
int iLB = -1;
if(m_bInParty)
{
if( m_bShowingPartyGamesOnly ) iLB = IDS_TOOLTIPS_ALL_GAMES;
else iLB = IDS_TOOLTIPS_PARTY_GAMES;
}
if(ProfileManager.IsFullVersion()==false )
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK, -1, iY,-1,-1,iLB,-1,-1,true);
}
else if(StorageManager.GetSaveDisabled())
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK,IDS_TOOLTIPS_SELECTDEVICE,iY,-1,-1,iLB,iRB,-1,true);
}
else
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK, IDS_TOOLTIPS_CHANGEDEVICE, iY,-1,-1,iLB,iRB,-1,true);
}
return S_OK;
}
HRESULT CScene_MultiGameJoinLoad::OnNotifySetFocus(HXUIOBJ hObjSource, XUINotifyFocus *pNotifyFocusData, BOOL& bHandled)
{
// update the tooltips
// if the saves list has focus, then we should show the Delete Save tooltip
// if the games list has focus, then we should the the View Gamercard tooltip
int iRB=-1;
int iY = -1;
if( DoesGamesListHaveFocus() )
{
iY = IDS_TOOLTIPS_VIEW_GAMERCARD;
}
else if(DoesSavesListHaveFocus())
{
if(ProfileManager.IsSignedInLive( m_iPad ))
{
iY=IDS_TOOLTIPS_UPLOAD_SAVE_FOR_XBOXONE;
}
if(StorageManager.GetSaveDisabled())
{
iRB=IDS_TOOLTIPS_DELETESAVE;
}
else
{
if(StorageManager.EnoughSpaceForAMinSaveGame())
{
iRB=IDS_TOOLTIPS_SAVEOPTIONS;
}
else
{
iRB=IDS_TOOLTIPS_DELETESAVE;
}
}
}
else if(DoesMashUpWorldHaveFocus())
{
// If it's a mash-up pack world, give the Hide option
iRB=IDS_TOOLTIPS_HIDE;
}
int iLB = -1;
if(m_bInParty)
{
if( m_bShowingPartyGamesOnly ) iLB = IDS_TOOLTIPS_ALL_GAMES;
else iLB = IDS_TOOLTIPS_PARTY_GAMES;
}
if(ProfileManager.IsFullVersion()==false )
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK, -1, iY,-1,-1,iLB,-1);
}
else if(StorageManager.GetSaveDisabled())
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK,IDS_TOOLTIPS_SELECTDEVICE,iY,-1,-1,iLB,iRB);
}
else
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK, IDS_TOOLTIPS_CHANGEDEVICE, iY,-1,-1,iLB,iRB);
}
return S_OK;
}
HRESULT CScene_MultiGameJoinLoad::OnNotifyKillFocus(HXUIOBJ hObjSource, XUINotifyFocus *pNotifyFocusData, BOOL& bHandled)
{
return S_OK;
}
bool CScene_MultiGameJoinLoad::DoesSavesListHaveFocus()
{
HXUIOBJ hParentObj,hObj=TreeGetFocus();
if(hObj!=nullptr)
{
// get the parent and see if it's the saves list
XuiElementGetParent(hObj,&hParentObj);
if(hParentObj==m_SavesList.m_hObj)
{
// check it's not the first or second element (new world or tutorial)
if(m_SavesList.GetCurSel()>(m_iDefaultButtonsC-1))
{
return true;
}
}
}
return false;
}
bool CScene_MultiGameJoinLoad::DoesMashUpWorldHaveFocus()
{
HXUIOBJ hParentObj,hObj=TreeGetFocus();
if(hObj!=nullptr)
{
// get the parent and see if it's the saves list
XuiElementGetParent(hObj,&hParentObj);
if(hParentObj==m_SavesList.m_hObj)
{
// check it's not the first or second element (new world or tutorial)
if(m_SavesList.GetCurSel()>(m_iDefaultButtonsC-1))
{
return false;
}
if(m_SavesList.GetCurSel()>(m_iDefaultButtonsC - 1 - m_iMashUpButtonsC))
{
return true;
}
else return false;
}
else return false;
}
return false;
}
bool CScene_MultiGameJoinLoad::DoesGamesListHaveFocus()
{
HXUIOBJ hParentObj,hObj=TreeGetFocus();
if(hObj!=nullptr)
{
// get the parent and see if it's the saves list
XuiElementGetParent(hObj,&hParentObj);
if(hParentObj==m_pGamesList->m_hObj)
{
return true;
}
}
return false;
}
void CScene_MultiGameJoinLoad::UpdateGamesListCallback(LPVOID lpParam)
{
if(lpParam != nullptr)
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(lpParam);
// check this there's no save transfer in progress
if(!pClass->m_bSaveTransferInProgress)
{
pClass->UpdateGamesList();
}
}
}
void CScene_MultiGameJoinLoad::UpdateGamesList()
{
if( m_bIgnoreInput ) return;
// if we're retrieving save info, don't show the list yet as we will be ignoring press events
if(m_bRetrievingSaveInfo)
{
return;
}
DWORD nIndex = -1;
FriendSessionInfo *pSelectedSession = nullptr;
if(m_pGamesList->TreeHasFocus() && m_pGamesList->GetItemCount() > 0)
{
nIndex = m_pGamesList->GetCurSel();
pSelectedSession = currentSessions.at( nIndex );
}
SessionID selectedSessionId;
if( pSelectedSession != nullptr )selectedSessionId = pSelectedSession->sessionId;
pSelectedSession = nullptr;
for (auto& it : currentSessions )
{
delete it;
}
currentSessions.clear();
m_NetGamesListTimer.SetShow( FALSE );
// if the saves list has focus, then we should show the Delete Save tooltip
// if the games list has focus, then we should show the View Gamercard tooltip
int iRB=-1;
int iY = -1;
if( DoesGamesListHaveFocus() )
{
iY = IDS_TOOLTIPS_VIEW_GAMERCARD;
}
else if(DoesSavesListHaveFocus())
{
if(ProfileManager.IsSignedInLive( m_iPad ))
{
iY=IDS_TOOLTIPS_UPLOAD_SAVE_FOR_XBOXONE;
}
if(StorageManager.GetSaveDisabled())
{
iRB=IDS_TOOLTIPS_DELETESAVE;
}
else
{
if(StorageManager.EnoughSpaceForAMinSaveGame())
{
iRB=IDS_TOOLTIPS_SAVEOPTIONS;
}
else
{
iRB=IDS_TOOLTIPS_DELETESAVE;
}
}
}
else if(DoesMashUpWorldHaveFocus())
{
// If it's a mash-up pack world, give the Hide option
iRB=IDS_TOOLTIPS_HIDE;
}
int iLB = -1;
if(m_bInParty)
{
if( m_bShowingPartyGamesOnly ) iLB = IDS_TOOLTIPS_ALL_GAMES;
else iLB = IDS_TOOLTIPS_PARTY_GAMES;
}
if(ProfileManager.IsFullVersion()==false )
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK, -1, iY,-1,-1,iLB,-1);
}
else if(StorageManager.GetSaveDisabled())
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK,IDS_TOOLTIPS_SELECTDEVICE,iY,-1,-1,iLB,iRB);
}
else
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK, IDS_TOOLTIPS_CHANGEDEVICE, iY,-1,-1,iLB,iRB);
}
currentSessions = *g_NetworkManager.GetSessionList( m_iPad, m_localPlayers, m_bShowingPartyGamesOnly );
// Update the xui list displayed
unsigned int xuiListSize = m_pGamesList->GetItemCount();
unsigned int filteredListSize = static_cast<unsigned int>(currentSessions.size());
BOOL gamesListHasFocus = m_pGamesList->TreeHasFocus();
if(filteredListSize > 0)
{
if( !m_pGamesList->IsEnabled() )
{
m_pGamesList->SetEnable(TRUE);
//XuiElementSetDisableFocusRecursion( m_pGamesList->m_hObj, FALSE);
m_pGamesList->SetCurSel( 0 );
}
m_LabelNoGames.SetShow( FALSE );
m_NetGamesListTimer.SetShow( FALSE );
}
else
{
m_pGamesList->SetEnable(FALSE);
//XuiElementSetDisableFocusRecursion(m_pGamesList->m_hObj, TRUE);
m_NetGamesListTimer.SetShow( FALSE );
m_LabelNoGames.SetShow( TRUE );
if( gamesListHasFocus ) m_pGamesList->InitFocus(m_iPad);
}
// clear out the games list and re-fill
m_pGamesList->RemoveAllData();
if( filteredListSize > 0 )
{
// Reset the focus to the selected session if it still exists
unsigned int sessionIndex = 0;
m_pGamesList->SetCurSel(0);
for ( FriendSessionInfo *sessionInfo : currentSessions )
{
HXUIBRUSH hXuiBrush;
CXuiCtrl4JList::LIST_ITEM_INFO ListInfo;
ZeroMemory(&ListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO));
ListInfo.pwszText = sessionInfo->displayLabel;
ListInfo.fEnabled = TRUE;
ListInfo.iData = sessionIndex;
m_pGamesList->AddData(ListInfo);
// display an icon too
// Is this a default game or a texture pack game?
if(sessionInfo->data.texturePackParentId!=0)
{
// Do we have the texture pack
Minecraft *pMinecraft = Minecraft::GetInstance();
TexturePack *tp = pMinecraft->skins->getTexturePackById(sessionInfo->data.texturePackParentId);
HRESULT hr;
DWORD dwImageBytes=0;
PBYTE pbImageData=nullptr;
if(tp==nullptr)
{
DWORD dwBytes=0;
PBYTE pbData=nullptr;
app.GetTPD(sessionInfo->data.texturePackParentId,&pbData,&dwBytes);
// is it in the tpd data ?
app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbImageData,&dwImageBytes );
if(dwImageBytes > 0 && pbImageData)
{
hr=XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&hXuiBrush);
m_pGamesList->UpdateGraphic(sessionIndex,hXuiBrush);
}
}
else
{
pbImageData = tp->getPackIcon(dwImageBytes);
if(dwImageBytes > 0 && pbImageData)
{
hr=XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&hXuiBrush);
m_pGamesList->UpdateGraphic(sessionIndex,hXuiBrush);
}
}
}
else
{
// default texture pack
XuiCreateTextureBrushFromMemory(m_DefaultMinecraftIconData,m_DefaultMinecraftIconSize,&hXuiBrush);
m_pGamesList->UpdateGraphic(sessionIndex,hXuiBrush);
}
if(memcmp( &selectedSessionId, &sessionInfo->sessionId, sizeof(SessionID) ) == 0)
{
m_pGamesList->SetCurSel(sessionIndex);
break;
}
++sessionIndex;
}
}
}
void CScene_MultiGameJoinLoad::UpdateGamesList(DWORD dwNumResults, IQNetGameSearch *pGameSearch)
{
// We don't use the QNet callback, but could resurrect this if we ever do normal matchmaking, but updated to work as the function above
#if 0
const XSESSION_SEARCHRESULT *pSearchResult;
const XNQOSINFO * pxnqi;
if(m_searches>0)
--m_searches;
if(m_searches==0)
{
m_NetGamesListTimer.SetShow( FALSE );
// if the saves list has focus, then we should show the Delete Save tooltip
// if the games list has focus, then we should show the View Gamercard tooltip
int iRB=-1;
int iY = -1;
if( DoesGamesListHaveFocus() )
{
iY = IDS_TOOLTIPS_VIEW_GAMERCARD;
}
else if(DoesSavesListHaveFocus())
{
iRB=IDS_TOOLTIPS_DELETESAVE;
}
int iLB = -1;
if(m_bInParty)
{
if( m_bShowingPartyGamesOnly ) iLB = IDS_TOOLTIPS_ALL_GAMES
else iLB = IDS_TOOLTIPS_PARTY_GAMES;
}
if(ProfileManager.IsFullVersion()==false )
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK, -1, iY,-1,-1,iLB,iRB);
}
else if(StorageManager.GetSaveDisabled())
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK,IDS_TOOLTIPS_SELECTDEVICE,iY,-1,-1,iLB,iRB);
}
else
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK, IDS_TOOLTIPS_CHANGEDEVICE, iY,-1,-1,iLB,iRB);
}
}
if( dwNumResults == 0 )
{
if(m_searches==0 && m_GamesList.GetItemCount() == 0)
{
m_LabelNoGames.SetShow( TRUE );
}
return;
}
unsigned int startOffset = m_GamesList.GetItemCount();
//m_GamesList.InsertItems(startOffset,dwNumResults);
//m_GamesList.SetEnable(TRUE);
//XuiElementSetDisableFocusRecursion( m_GamesList.m_hObj, FALSE);
// Loop through all the results.
for( DWORD dwResult = 0; dwResult < pGameSearch->GetNumResults(); dwResult++ )
{
pSearchResult = pGameSearch->GetSearchResultAtIndex( dwResult );
// No room for us, so ignore it
if(pSearchResult->dwOpenPublicSlots < m_localPlayers)
continue;
FriendSessionInfo *sessionInfo = nullptr;
bool foundSession = false;
for( auto it = friendsSessions.begin(); it != friendsSessions.end(); ++it)
{
sessionInfo = *it;
if(memcmp( &pSearchResult->info.sessionID, &sessionInfo->sessionId, sizeof(SessionID) ) == 0)
{
sessionInfo->searchResult = *pSearchResult;
sessionInfo->displayLabel = new wchar_t[100];
foundSession = true;
break;
}
}
// We received a search result for a session no longer in our list of friends sessions
if(!foundSession)
continue;
// Print some info about this result.
//printf( "Search result %u:\n", dwResult );
//printf( " public slots open = %u, filled = %u\n", pSearchResult->dwOpenPublicSlots, pSearchResult->dwFilledPublicSlots );
//printf( " private slots open = %u, filled = %u\n", pSearchResult->dwOpenPrivateSlots, pSearchResult->dwFilledPrivateSlots );
// See if this result was contacted successfully via QoS probes.
pxnqi = pGameSearch->GetQosInfoAtIndex( dwResult );
if( pxnqi->bFlags & XNET_XNQOSINFO_TARGET_CONTACTED )
{
// Print the round trip time and the rough estimation of
// bandwidth.
app.DebugPrintf( " RTT min = %u, med = %u\n", pxnqi->wRttMinInMsecs, pxnqi->wRttMedInMsecs );
app.DebugPrintf( " bps up = %u, down = %u\n", pxnqi->dwUpBitsPerSec, pxnqi->dwDnBitsPerSec );
if(pxnqi->cbData > 0)
{
sessionInfo->data = *(GameSessionData *)pxnqi->pbData;
wstring gamerName = convStringToWstring(sessionInfo->data.hostName);
swprintf(sessionInfo->displayLabel,L"%ls's Game", gamerName.c_str() );
}
else
{
swprintf(sessionInfo->displayLabel,L"Unknown host Game");
}
// If this host wasn't disabled use this one.
if( !( pxnqi->bFlags & XNET_XNQOSINFO_TARGET_DISABLED ) && sessionInfo->data.netVersion == MINECRAFT_NET_VERSION )
{
//printf("This game is valid\n");
filteredResults.push_back(sessionInfo);
m_GamesList.InsertItems(startOffset,1);
m_GamesList.SetText(startOffset,sessionInfo->displayLabel);
startOffset++;
}
#ifndef _CONTENT_PACKAGE
if( sessionInfo->data.netVersion != MINECRAFT_NET_VERSION )
{
wprintf(L"%ls version of %d does not match our version of %d\n", sessionInfo->displayLabel, sessionInfo->data.netVersion, MINECRAFT_NET_VERSION);
}
#endif
}
}
if( m_GamesList.GetItemCount() == 0)
{
m_LabelNoGames.SetShow( TRUE );
}
else
{
m_GamesList.SetEnable(TRUE);
XuiElementSetDisableFocusRecursion( m_GamesList.m_hObj, FALSE);
if( DoesGamesListHaveFocus() )
{
m_GamesList.SetCurSel(0);
}
}
#endif
}
/*void CScene_MultiGameJoinLoad::UpdateGamesListLabels()
{
for( unsigned int i = 0; i < currentSessions.size(); ++i )
{
FriendSessionInfo *sessionInfo = currentSessions.at(i);
m_GamesList.SetText(i,sessionInfo->displayLabel);
HXUIBRUSH hBrush;
CXuiCtrl4JList::LIST_ITEM_INFO info = m_pGamesList->GetData(i);
// display an icon too
XuiCreateTextureBrushFromMemory(m_DefaultMinecraftIconData,m_DefaultMinecraftIconSize,&hBrush);
m_pGamesList->UpdateGraphic(i,hBrush);
}
#if 0
XUIRect xuiRect;
HXUIOBJ item = XuiListGetItemControl(m_GamesList,0);
HXUIOBJ hObj=nullptr;
HXUIOBJ hTextPres=nullptr;
HRESULT hr=XuiControlGetVisual(item,&hObj);
hr=XuiElementGetChildById(hObj,L"text_Label",&hTextPres);
unsigned char displayLabelViewableStartIndex = 0;
for( unsigned int i = 0; i < currentSessions.size(); ++i )
{
FriendSessionInfo *sessionInfo = currentSessions.at(i);
if(hTextPres != nullptr )
{
hr=XuiTextPresenterMeasureText(hTextPres, sessionInfo->displayLabel, &xuiRect);
float fWidth, fHeight;
XuiElementGetBounds(hTextPres,&fWidth,&fHeight);
int characters = (fWidth/xuiRect.right) * sessionInfo->displayLabelLength;
if( characters < sessionInfo->displayLabelLength )
{
static wchar_t temp[100];
ZeroMemory(temp, (100)*sizeof(wchar_t));
wcsncpy_s( temp, sessionInfo->displayLabel+sessionInfo->displayLabelViewableStartIndex, characters );
m_GamesList.SetText(i,temp);
sessionInfo->displayLabelViewableStartIndex++;
if( sessionInfo->displayLabelViewableStartIndex >= sessionInfo->displayLabelLength ) sessionInfo->displayLabelViewableStartIndex = 0;
}
}
}
#endif
}*/
void CScene_MultiGameJoinLoad::SearchForGameCallback(void *param, DWORD dwNumResults, IQNetGameSearch *pGameSearch)
{
#if 0
HXUIOBJ hObj = (HXUIOBJ)param;
void *pObj;
XuiObjectFromHandle( hObj, &pObj);
CScene_MultiGameJoinLoad *MultiGameJoinLoad = (CScene_MultiGameJoinLoad *)pObj;
MultiGameJoinLoad->UpdateGamesList(dwNumResults, pGameSearch);
#endif
}
int CScene_MultiGameJoinLoad::DeviceSelectReturned(void *pParam,bool bContinue)
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(pParam);
//HRESULT hr;
if(bContinue==true)
{
// if the saves list has focus, then we should show the Delete Save tooltip
// if the games list has focus, then we should show the View Gamercard tooltip
int iRB=-1;
int iY = -1;
if( pClass->DoesGamesListHaveFocus() )
{
iY = IDS_TOOLTIPS_VIEW_GAMERCARD;
}
else if(pClass->DoesSavesListHaveFocus())
{
if(ProfileManager.IsSignedInLive( pClass->m_iPad ))
{
iY=IDS_TOOLTIPS_UPLOAD_SAVE_FOR_XBOXONE;
}
if(StorageManager.GetSaveDisabled())
{
iRB=IDS_TOOLTIPS_DELETESAVE;
}
else
{
if(StorageManager.EnoughSpaceForAMinSaveGame())
{
iRB=IDS_TOOLTIPS_SAVEOPTIONS;
}
else
{
iRB=IDS_TOOLTIPS_DELETESAVE;
}
}
}
else if(pClass->DoesMashUpWorldHaveFocus())
{
// If it's a mash-up pack world, give the Hide option
iRB=IDS_TOOLTIPS_HIDE;
}
int iLB = -1;
if(pClass->m_bInParty)
{
if( pClass->m_bShowingPartyGamesOnly ) iLB = IDS_TOOLTIPS_ALL_GAMES;
else iLB = IDS_TOOLTIPS_PARTY_GAMES;
}
//BOOL bOnlineGame=pClass->m_CheckboxOnline.IsChecked();
// refresh the saves list (if there is a device selected)
// clear out the list first
if(StorageManager.GetSaveDisabled())
{
if(StorageManager.GetSaveDeviceSelected(pClass->m_iPad))
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK,IDS_TOOLTIPS_CHANGEDEVICE,iY,-1,-1,iLB,iRB);
// saving is disabled, but we should still be able to load from a selected save device
pClass->GetSaveInfo();
}
else
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK,IDS_TOOLTIPS_SELECTDEVICE,iY,-1,-1,iLB,iRB);
// clear the saves list
pClass->m_pSavesList->RemoveAllData();
pClass->m_iSaveInfoC=0;
//pClass->m_iThumbnailsLoadedC=0;
pClass->AddDefaultButtons();
pClass->m_SavesListTimer.SetShow( FALSE );
pClass->m_pSavesList->SetCurSelVisible(0);
}
}
else
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK,IDS_TOOLTIPS_CHANGEDEVICE,iY,-1,-1,iLB,iRB);
pClass->GetSaveInfo();
}
}
// enable input again
pClass->m_bIgnoreInput=false;
return 0;
}
HRESULT CScene_MultiGameJoinLoad::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled )
{
// 4J-PB - TODO - Don't think we can do this - if a 2nd player signs in here with an offline profile, the signed in LIVE player gets re-logged in, and bMultiplayerAllowed is false briefly
switch(pTimer->nId)
{
case JOIN_LOAD_ONLINE_TIMER_ID:
{
XPARTY_USER_LIST partyList;
if((XPartyGetUserList( &partyList ) != XPARTY_E_NOT_IN_PARTY ) && (partyList.dwUserCount>1))
{
m_bInParty=true;
}
else
{
m_bInParty=false;
}
bool bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
if(bMultiplayerAllowed != m_bMultiplayerAllowed)
{
if( bMultiplayerAllowed )
{
// m_CheckboxOnline.SetEnable(TRUE);
// m_CheckboxPrivate.SetEnable(TRUE);
}
else
{
m_bInParty = false;
m_pGamesList->RemoveAllData();
//m_GamesList.DeleteItems(0, m_GamesList.GetItemCount() );
m_pGamesList->SetEnable(FALSE);
//XuiElementSetDisableFocusRecursion( m_pGamesList->m_hObj, TRUE);
m_NetGamesListTimer.SetShow( TRUE );
m_LabelNoGames.SetShow( FALSE );
}
int iLB = -1;
if(m_bInParty)
{
if( m_bShowingPartyGamesOnly ) iLB = IDS_TOOLTIPS_ALL_GAMES;
else iLB = IDS_TOOLTIPS_PARTY_GAMES;
}
int iRB=-1;
int iY=-1;
if( DoesGamesListHaveFocus() )
{
}
else if(DoesSavesListHaveFocus())
{
if(ProfileManager.IsSignedInLive( m_iPad ))
{
iY=IDS_TOOLTIPS_UPLOAD_SAVE_FOR_XBOXONE;
}
if(StorageManager.GetSaveDisabled())
{
iRB=IDS_TOOLTIPS_DELETESAVE;
}
else
{
if(StorageManager.EnoughSpaceForAMinSaveGame())
{
iRB=IDS_TOOLTIPS_SAVEOPTIONS;
}
else
{
iRB=IDS_TOOLTIPS_DELETESAVE;
}
}
}
else if(DoesMashUpWorldHaveFocus())
{
// If it's a mash-up pack world, give the Hide option
iRB=IDS_TOOLTIPS_HIDE;
}
if(ProfileManager.IsFullVersion()==false )
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK, -1, -1,-1,-1,iLB);
}
else if(StorageManager.GetSaveDisabled())
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK,IDS_TOOLTIPS_SELECTDEVICE,-1,-1,-1,iLB,iRB);
}
else
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK, IDS_TOOLTIPS_CHANGEDEVICE,iY,-1,-1,iLB,iRB);
}
m_bMultiplayerAllowed = bMultiplayerAllowed;
}
}
break;
case JOIN_LOAD_SEARCH_MINIMUM_TIMER_ID:
{
XuiKillTimer( m_hObj, JOIN_LOAD_SEARCH_MINIMUM_TIMER_ID );
m_NetGamesListTimer.SetShow( FALSE );
m_LabelNoGames.SetShow( TRUE );
}
break;
case JOIN_LOAD_SCROLL_GAME_NAMES_TIMER_ID:
{
// This is called by the gameslist callback function, so isn't needed on a timer
//UpdateGamesListLabels();
}
break;
case CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID:
{
// also check for any new texture packs info being available
// for each item in the mem list, check it's in the data list
//CXuiCtrl4JList::LIST_ITEM_INFO ListInfo;
// for each iConfig, check if the data is available, and add it to the List, then remove it from the viConfig
for(int i=0;i<m_iTexturePacksNotInstalled;i++)
{
if(m_iConfigA[i]!=-1)
{
DWORD dwBytes=0;
PBYTE pbData=nullptr;
//app.DebugPrintf("Retrieving iConfig %d from TPD\n",m_iConfigA[i]);
app.GetTPD(m_iConfigA[i],&pbData,&dwBytes);
if(dwBytes > 0 && pbData)
{
//update the games list
UpdateGamesList();
m_iConfigA[i]=-1;
}
}
}
bool bAllDone=true;
for(int i=0;i<m_iTexturePacksNotInstalled;i++)
{
if(m_iConfigA[i]!=-1)
{
bAllDone = false;
}
}
if(bAllDone)
{
// kill this timer
XuiKillTimer(m_hObj,CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID);
}
}
break;
}
return S_OK;
}
/*
int CScene_MultiGameJoinLoad::LoadSaveDataReturned(void *pParam,bool bContinue)
{
CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad*)pParam;
if(bContinue==true)
{
bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad());
// 4J Stu - If we only have one controller connected, then don't show the sign-in UI again
DWORD connectedControllers = 0;
for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i)
{
if( InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i) ) ++connectedControllers;
}
if(!isClientSide || connectedControllers == 1 || !RenderManager.IsHiDef())
{
DWORD dwLocalUsersMask = CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad());
// No guest problems so we don't need to force a sign-in of players here
StartGameFromSave(pClass, dwLocalUsersMask);
}
else
{
ProfileManager.RequestSignInUI(false, false, false, true, false,&CScene_MultiGameJoinLoad::StartGame_SignInReturned, pParam,ProfileManager.GetPrimaryPad());
}
}
else
{
pClass->m_bIgnoreInput=false;
}
return 0;
}
*/
int CScene_MultiGameJoinLoad::StartGame_SignInReturned(void *pParam,bool bContinue, int iPad)
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(pParam);
if(bContinue==true)
{
// It's possible that the player has not signed in - they can back out
if(ProfileManager.IsSignedIn(iPad))
{
DWORD dwLocalUsersMask = 0;
for(unsigned int index = 0; index < XUSER_MAX_COUNT; ++index)
{
if(ProfileManager.IsSignedIn(index) )
{
dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(index);
}
}
StartGameFromSave(pClass, dwLocalUsersMask);
}
}
else
{
pClass->m_bIgnoreInput=false;
}
return 0;
}
// 4J Stu - Shared functionality that is the same whether we needed a quadrant sign-in or not
void CScene_MultiGameJoinLoad::StartGameFromSave(CScene_MultiGameJoinLoad* pClass, DWORD dwLocalUsersMask)
{
/*bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pClass->m_CheckboxOnline.IsChecked() == TRUE;
//bool isPrivate = pClass->m_CheckboxPrivate.IsChecked() == TRUE;
SenStatGameEvent(ProfileManager.GetPrimaryPad(),eTelemetryGameEvent_Load,Minecraft::GetInstance()->options->difficulty, isClientSide, ProfileManager.IsFullVersion(), 1,0 );
g_NetworkManager.HostGame(dwLocalUsersMask,isClientSide,isPrivate,MINECRAFT_NET_MAX_PLAYERS,0);
LoadingInputParams *loadingParams = new LoadingInputParams();
loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc;
loadingParams->lpParam = nullptr;
UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData();
completionData->bShowBackground=TRUE;
completionData->bShowLogo=TRUE;
completionData->type = e_ProgressCompletion_CloseAllPlayersUIScenes;
completionData->iPad = DEFAULT_XUI_MENU_USER;
loadingParams->completionData = completionData;
app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams);*/
}
int CScene_MultiGameJoinLoad::DeleteSaveDataReturned(void *pParam,bool bSuccess)
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(pParam);
if(bSuccess==true)
{
// need to re-get the saves list and update the display
// clear the saves list
pClass->m_pSavesList->RemoveAllData();
pClass->m_iSaveInfoC=0;
pClass->GetSaveInfo();
}
pClass->m_bIgnoreInput=false;
return 0;
}
void CScene_MultiGameJoinLoad::LoadLevelGen(LevelGenerationOptions *levelGen)
{
// Load data from disc
//File saveFile( L"Tutorial\\Tutorial" );
//LoadSaveFromDisk(&saveFile);
// clear out the app's terrain features list
app.ClearTerrainFeaturePosition();
StorageManager.ResetSaveData();
// Make our next save default to the name of the level
StorageManager.SetSaveTitle(levelGen->getDefaultSaveName().c_str());
bool isClientSide = false;
bool isPrivate = false;
int maxPlayers = MINECRAFT_NET_MAX_PLAYERS;
if( app.GetTutorialMode() )
{
isClientSide = false;
maxPlayers = 4;
}
g_NetworkManager.HostGame(0,isClientSide,isPrivate,maxPlayers,0);
NetworkGameInitData *param = new NetworkGameInitData();
param->seed = 0;
param->saveData = nullptr;
param->settings = app.GetGameHostOption( eGameHostOption_Tutorial );
param->levelGen = levelGen;
if(levelGen->requiresTexturePack())
{
param->texturePackId = levelGen->getRequiredTexturePackId();
Minecraft *pMinecraft = Minecraft::GetInstance();
pMinecraft->skins->selectTexturePackById(param->texturePackId);
//pMinecraft->skins->updateUI();
}
LoadingInputParams *loadingParams = new LoadingInputParams();
loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc;
loadingParams->lpParam = static_cast<LPVOID>(param);
UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData();
completionData->bShowBackground=TRUE;
completionData->bShowLogo=TRUE;
completionData->type = e_ProgressCompletion_CloseAllPlayersUIScenes;
completionData->iPad = DEFAULT_XUI_MENU_USER;
loadingParams->completionData = completionData;
app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams);
}
void CScene_MultiGameJoinLoad::LoadSaveFromDisk(File *saveFile)
{
// we'll only be coming in here when the tutorial is loaded now
StorageManager.ResetSaveData();
// Make our next save default to the name of the level
StorageManager.SetSaveTitle(saveFile->getName().c_str());
int64_t fileSize = saveFile->length();
FileInputStream fis(*saveFile);
byteArray ba(fileSize);
fis.read(ba);
fis.close();
bool isClientSide = false;
bool isPrivate = false;
int maxPlayers = MINECRAFT_NET_MAX_PLAYERS;
if( app.GetTutorialMode() )
{
isClientSide = false;
maxPlayers = 4;
}
app.SetGameHostOption(eGameHostOption_GameType,GameType::CREATIVE->getId());
g_NetworkManager.HostGame(0,isClientSide,isPrivate,maxPlayers,0);
LoadSaveDataThreadParam *saveData = new LoadSaveDataThreadParam(ba.data, ba.length, saveFile->getName());
NetworkGameInitData *param = new NetworkGameInitData();
param->seed = 0;
param->saveData = saveData;
param->settings = app.GetGameHostOption( eGameHostOption_All );
LoadingInputParams *loadingParams = new LoadingInputParams();
loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc;
loadingParams->lpParam = static_cast<LPVOID>(param);
UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData();
completionData->bShowBackground=TRUE;
completionData->bShowLogo=TRUE;
completionData->type = e_ProgressCompletion_CloseAllPlayersUIScenes;
completionData->iPad = DEFAULT_XUI_MENU_USER;
loadingParams->completionData = completionData;
app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams);
}
int CScene_MultiGameJoinLoad::DeleteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(pParam);
// results switched for this dialog
if(result==C4JStorage::EMessage_ResultDecline)
{
if(app.DebugSettingsOn() && app.GetLoadSavesFromFolderEnabled())
{
pClass->m_bIgnoreInput=false;
}
else
{
XCONTENT_DATA XContentData;
StorageManager.GetSaveCacheFileInfo(pClass->m_iChangingSaveGameInfoIndex-pClass->m_iDefaultButtonsC,XContentData);
StorageManager.DeleteSaveData(&XContentData,CScene_MultiGameJoinLoad::DeleteSaveDataReturned,pClass);
pClass->m_SavesListTimer.SetShow( TRUE );
}
}
else
{
pClass->m_bIgnoreInput=false;
}
return 0;
}
int CScene_MultiGameJoinLoad::SaveTransferDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(pParam);
// results switched for this dialog
if(result==C4JStorage::EMessage_ResultAccept)
{
// upload the save
// first load the save
int iIndex=pClass->m_pSavesList->GetData(pClass->m_pSavesList->GetCurSel()).iIndex-pClass->m_iDefaultButtonsC;
XCONTENT_DATA ContentData;
// 4J-PB - ensure we've switched to the right title group id for uploading to
app.TMSPP_SetTitleGroupID(SAVETRANSFER_GROUP_ID);
StorageManager.GetSaveCacheFileInfo(iIndex,ContentData);
C4JStorage::ELoadGameStatus eLoadStatus=StorageManager.LoadSaveData(&ContentData,CScene_MultiGameJoinLoad::LoadSaveDataReturned,pClass);
pClass->m_bIgnoreInput=false;
}
else
{
pClass->m_bIgnoreInput=false;
}
return 0;
}
int CScene_MultiGameJoinLoad::UploadSaveForXboxOneThreadProc( LPVOID lpParameter )
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(lpParameter);
Minecraft *pMinecraft = Minecraft::GetInstance();
pMinecraft->progressRenderer->progressStart(IDS_SAVE_TRANSFER_TITLE);
pMinecraft->progressRenderer->progressStage( IDS_SAVE_TRANSFER_UPLOADING );
// Delete the marker file
DeleteFile(pClass, "completemarker");
if(!WaitForTransferComplete(pClass)) return 0;
// Upload the save data
{
unsigned int uiSaveBytes;
uiSaveBytes=StorageManager.GetSaveSize();
pClass->m_pbSaveTransferData=new BYTE [uiSaveBytes];
StorageManager.GetSaveData(pClass->m_pbSaveTransferData,&uiSaveBytes);
app.DebugPrintf("Uploading save data (%d bytes)\n", uiSaveBytes);
UploadFile(pClass, "savedata", pClass->m_pbSaveTransferData, uiSaveBytes);
}
if(!WaitForTransferComplete(pClass)) return 0;
if(pClass->m_bTransferFail)
{
// something went wrong, user has been informed
pMinecraft->progressRenderer->progressStage( IDS_SAVE_TRANSFER_UPLOADFAILED );
return 0;
}
// Upload the metadata and thumbnail
{
ByteArrayOutputStream baos;
DataOutputStream dos(&baos);
LPCWSTR title = StorageManager.GetSaveTitle();
dos.writeUTF(title);
char szUniqueMapName[14];
StorageManager.GetSaveUniqueFilename(szUniqueMapName);
dos.writeUTF(convStringToWstring(szUniqueMapName));
{
// set the save icon
PBYTE pbImageData=nullptr;
DWORD dwImageBytes=0;
XCONTENT_DATA XContentData;
int iIndex=pClass->m_pSavesList->GetData(pClass->m_pSavesList->GetCurSel()).iIndex-pClass->m_iDefaultButtonsC;
StorageManager.GetSaveCacheFileInfo(iIndex,XContentData);
StorageManager.GetSaveCacheFileInfo(iIndex,&pbImageData,&dwImageBytes);
// if there is no thumbnail, retrieve the default one from the file.
// Don't delete the image data after creating the xuibrush, since we'll use it in the rename of the save
if(pbImageData==nullptr)
{
DWORD dwResult=XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&XContentData,nullptr,&dwImageBytes,nullptr);
if(dwResult==ERROR_SUCCESS)
{
pClass->m_pbSaveTransferData = new BYTE[dwImageBytes];
pbImageData = pClass->m_pbSaveTransferData; // Copy pointer so that we can use the same name as the library owned one, but m_pbSaveTransferData will get deleted when done
XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&XContentData,pbImageData,&dwImageBytes,nullptr);
}
}
dos.writeInt(dwImageBytes);
byteArray ba(pbImageData, dwImageBytes);
dos.write(ba);
}
pClass->m_pbSaveTransferData=new BYTE [baos.size()];
memcpy(pClass->m_pbSaveTransferData,baos.buf.data,baos.size());
app.DebugPrintf("Uploading meta data (%d bytes)\n", baos.size());
UploadFile(pClass, "metadata", pClass->m_pbSaveTransferData, baos.size());
}
// Wait for metadata and thumbnail
if(!WaitForTransferComplete(pClass)) return 0;
if(pClass->m_bTransferFail)
{
// something went wrong, user has been informed
pMinecraft->progressRenderer->progressStage( IDS_SAVE_TRANSFER_UPLOADFAILED );
return 0;
}
// Upload the marker file
{
char singleByteData[1] = {1};
app.DebugPrintf("Uploading marker (%d bytes)\n", 1);
UploadFile(pClass, "completemarker", &singleByteData, 1);
}
// Wait for marker
if(!WaitForTransferComplete(pClass)) return 0;
if(pClass->m_bTransferFail)
{
// something went wrong, user has been informed
pMinecraft->progressRenderer->progressStage( IDS_SAVE_TRANSFER_UPLOADFAILED );
return 0;
}
// change text for completion confirmation
pMinecraft->progressRenderer->progressStage( IDS_SAVE_TRANSFER_UPLOADCOMPLETE );
// done
return 0;
}
void CScene_MultiGameJoinLoad::DeleteFile(CScene_MultiGameJoinLoad *pClass, char *filename)
{
pClass->m_fProgress=0.0f;
pClass->m_bTransferComplete=false;
C4JStorage::ETMSStatus result = StorageManager.TMSPP_DeleteFile(
ProfileManager.GetPrimaryPad(),
filename,
C4JStorage::TMS_FILETYPE_BINARY,
&CScene_MultiGameJoinLoad::DeleteComplete,
pClass,
nullptr);
if(result != C4JStorage::ETMSStatus_DeleteInProgress)
{
DeleteComplete(pClass,ProfileManager.GetPrimaryPad(), -1);
}
}
void CScene_MultiGameJoinLoad::UploadFile(CScene_MultiGameJoinLoad *pClass, char *filename, LPVOID data, DWORD size)
{
pClass->m_fProgress=0.0f;
pClass->m_bTransferComplete=false;
C4JStorage::ETMSStatus result = StorageManager.TMSPP_WriteFileWithProgress(
ProfileManager.GetPrimaryPad(),
C4JStorage::eGlobalStorage_TitleUser,
C4JStorage::TMS_FILETYPE_BINARY,
C4JStorage::TMS_UGCTYPE_NONE,
filename,
static_cast<CHAR *>(data),
size,
&CScene_MultiGameJoinLoad::TransferComplete,pClass, 0,
&CScene_MultiGameJoinLoad::Progress,pClass);
#ifdef _DEBUG_MENUS_ENABLED
if(app.GetWriteSavesToFolderEnabled())
{
File targetFileDir(L"GAME:\\FakeTMSPP");
if(!targetFileDir.exists()) targetFileDir.mkdir();
string path = string( wstringtofilename( targetFileDir.getPath() ) ).append("\\").append(filename);
HANDLE hSaveFile = CreateFile( path.c_str(), GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, nullptr);
DWORD numberOfBytesWritten = 0;
WriteFile( hSaveFile,data,size,&numberOfBytesWritten,nullptr);
assert(numberOfBytesWritten == size);
CloseHandle(hSaveFile);
}
#endif
if(result != C4JStorage::ETMSStatus_WriteInProgress)
{
TransferComplete(pClass,ProfileManager.GetPrimaryPad(), -1);
}
}
bool CScene_MultiGameJoinLoad::WaitForTransferComplete( CScene_MultiGameJoinLoad *pClass )
{
Minecraft *pMinecraft = Minecraft::GetInstance();
// loop until complete
while(pClass->m_bTransferComplete==false)
{
// check for a cancel
if(pClass->m_bSaveTransferInProgress==false)
{
// cancelled
return false;
}
Sleep(50);
// update the progress
pMinecraft->progressRenderer->progressStagePercentage(static_cast<unsigned int>(pClass->m_fProgress * 100.0f));
}
// was there a transfer error?
return true;
}
int CScene_MultiGameJoinLoad::SaveOptionsDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(pParam);
// results switched for this dialog
// EMessage_ResultAccept means cancel
if(result==C4JStorage::EMessage_ResultDecline || result==C4JStorage::EMessage_ResultThirdOption)
{
if(result==C4JStorage::EMessage_ResultDecline) // rename
{
ZeroMemory(pClass->m_wchNewName,sizeof(WCHAR)*XCONTENT_MAX_DISPLAYNAME_LENGTH);
// bring up a keyboard
InputManager.RequestKeyboard(IDS_RENAME_WORLD_TITLE,L"",IDS_RENAME_WORLD_TEXT,iPad,pClass->m_wchNewName,XCONTENT_MAX_DISPLAYNAME_LENGTH,&CScene_MultiGameJoinLoad::KeyboardReturned,pClass,C_4JInput::EKeyboardMode_Default,app.GetStringTable());
}
else // delete
{
// delete the save game
// Have to ask the player if they are sure they want to delete this game
UINT uiIDA[2];
uiIDA[0]=IDS_CONFIRM_CANCEL;
uiIDA[1]=IDS_CONFIRM_OK;
StorageManager.RequestMessageBox(IDS_TOOLTIPS_DELETESAVE, IDS_TEXT_DELETE_SAVE, uiIDA, 2, iPad,&CScene_MultiGameJoinLoad::DeleteSaveDialogReturned,pClass, app.GetStringTable());
//pClass->m_bIgnoreInput=false;
}
}
else
{
pClass->m_bIgnoreInput=false;
}
return 0;
}
int CScene_MultiGameJoinLoad::LoadSaveDataReturned(void *pParam,bool bContinue)
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(pParam);
if(bContinue==true)
{
pClass->m_bSaveTransferInProgress=true;
LoadingInputParams *loadingParams = new LoadingInputParams();
loadingParams->func = &CScene_MultiGameJoinLoad::UploadSaveForXboxOneThreadProc;
loadingParams->lpParam = (LPVOID)pParam;
UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData();
completionData->bShowBackground=TRUE;
completionData->bShowLogo=TRUE;
completionData->type = e_ProgressCompletion_NavigateBack;
completionData->iPad = DEFAULT_XUI_MENU_USER;
completionData->bRequiresUserAction=TRUE;
loadingParams->completionData = completionData;
loadingParams->cancelFunc=&CScene_MultiGameJoinLoad::CancelSaveUploadCallback;
loadingParams->completeFunc=&CScene_MultiGameJoinLoad::SaveUploadCompleteCallback;
loadingParams->m_cancelFuncParam=pClass;
loadingParams->m_completeFuncParam=pClass;
loadingParams->cancelText=IDS_TOOLTIPS_CANCEL;
app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams);
}
else
{
// switch back to the normal title group id
app.TMSPP_SetTitleGroupID(GROUP_ID);
// the save is corrupt!
pClass->SetShow( TRUE );
pClass->m_bIgnoreInput=false;
// give the option to delete the save
UINT uiIDA[2];
uiIDA[0]=IDS_CONFIRM_CANCEL;
uiIDA[1]=IDS_CONFIRM_OK;
StorageManager.RequestMessageBox(IDS_CORRUPT_OR_DAMAGED_SAVE_TITLE, IDS_CORRUPT_OR_DAMAGED_SAVE_TEXT, uiIDA, 2,
pClass->m_iPad,&CScene_MultiGameJoinLoad::DeleteSaveDialogReturned,pClass, app.GetStringTable());
}
return 0;
}
int CScene_MultiGameJoinLoad::Progress(void *pParam,float fProgress)
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(pParam);
app.DebugPrintf("Progress - %f\n",fProgress);
pClass->m_fProgress=fProgress;
return 0;
}
int CScene_MultiGameJoinLoad::TransferComplete(void *pParam,int iPad, int iResult)
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(pParam);
delete [] pClass->m_pbSaveTransferData;
pClass->m_pbSaveTransferData = nullptr;
if(iResult!=0)
{
// There was a transfer fail
// Display a dialog
UINT uiIDA[1];
uiIDA[0]=IDS_CONFIRM_OK;
StorageManager.RequestMessageBox(IDS_SAVE_TRANSFER_TITLE, IDS_SAVE_TRANSFER_UPLOADFAILED, uiIDA, 1, ProfileManager.GetPrimaryPad(),nullptr,nullptr,app.GetStringTable());
pClass->m_bTransferFail=true;
}
else
{
pClass->m_bTransferFail=false;
}
pClass->m_bTransferComplete=true;
//pClass->m_bSaveTransferInProgress=false;
return 0;
}
int CScene_MultiGameJoinLoad::DeleteComplete(void *pParam,int iPad, int iResult)
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(pParam);
pClass->m_bTransferComplete=true;
return 0;
}
int CScene_MultiGameJoinLoad::KeyboardReturned(void *pParam,bool bSet)
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(pParam);
HRESULT hr = S_OK;
// if the user has left the name empty, treat this as backing out
if((pClass->m_wchNewName[0]!=0) && bSet)
{
#ifdef _XBOX
XCONTENT_DATA XContentData;
StorageManager.GetSaveCacheFileInfo(pClass->m_iChangingSaveGameInfoIndex-pClass->m_iDefaultButtonsC,XContentData);
C4JStorage::ELoadGameStatus eLoadStatus=StorageManager.LoadSaveData(&XContentData,CScene_MultiGameJoinLoad::LoadSaveDataForRenameReturned,pClass);
if(eLoadStatus==C4JStorage::ELoadGame_DeviceRemoved)
{
// disable saving
StorageManager.SetSaveDisabled(true);
StorageManager.SetSaveDeviceSelected(ProfileManager.GetPrimaryPad(),false);
UINT uiIDA[1];
uiIDA[0]=IDS_OK;
StorageManager.RequestMessageBox(IDS_STORAGEDEVICEPROBLEM_TITLE, IDS_FAILED_TO_LOADSAVE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad(),&CScene_MultiGameJoinLoad::DeviceRemovedDialogReturned,pClass);
}
#else
// rename the save
#endif
}
else
{
pClass->m_bIgnoreInput=false;
}
return hr;
}
int CScene_MultiGameJoinLoad::LoadSaveDataForRenameReturned(void *pParam,bool bContinue)
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(pParam);
#ifdef _XBOX
if(bContinue==true)
{
// set the save icon
PBYTE pbImageData=nullptr;
DWORD dwImageBytes=0;
HXUIBRUSH hXuiBrush;
XCONTENT_DATA XContentData;
StorageManager.GetSaveCacheFileInfo(pClass->m_iChangingSaveGameInfoIndex-pClass->m_iDefaultButtonsC,XContentData);
StorageManager.GetSaveCacheFileInfo(pClass->m_iChangingSaveGameInfoIndex-pClass->m_iDefaultButtonsC,&pbImageData,&dwImageBytes);
// if there is no thumbnail, retrieve the default one from the file.
// Don't delete the image data after creating the xuibrush, since we'll use it in the rename of the save
if(pbImageData==nullptr)
{
DWORD dwResult=XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&XContentData,nullptr,&dwImageBytes,nullptr);
if(dwResult==ERROR_SUCCESS)
{
pbImageData = new BYTE[dwImageBytes];
XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&XContentData,pbImageData,&dwImageBytes,nullptr);
XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&hXuiBrush);
}
}
else
{
XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&hXuiBrush);
}
// save the data with this icon
StorageManager.CopySaveDataToNewSave( pbImageData,dwImageBytes,pClass->m_wchNewName,&CScene_MultiGameJoinLoad::CopySaveReturned,pClass);
}
else
#endif
{
//pClass->SetShow( TRUE );
pClass->m_bIgnoreInput=false;
}
return 0;
}
int CScene_MultiGameJoinLoad::CopySaveReturned(void *pParam,bool bResult)
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(pParam);
#ifdef _XBOX
if(bResult)
{
// and delete the old save
XCONTENT_DATA XContentData;
StorageManager.GetSaveCacheFileInfo(pClass->m_iChangingSaveGameInfoIndex-pClass->m_iDefaultButtonsC,XContentData);
StorageManager.DeleteSaveData(&XContentData,CScene_MultiGameJoinLoad::DeleteSaveDataReturned,pClass);
pClass->m_SavesListTimer.SetShow( TRUE );
}
else
#endif
{
//pClass->SetShow( TRUE );
pClass->m_bIgnoreInput=false;
}
return 0;
}
int CScene_MultiGameJoinLoad::TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
CScene_MultiGameJoinLoad *pClass = static_cast<CScene_MultiGameJoinLoad *>(pParam);
// Exit with or without saving
// Decline means install full version of the texture pack in this dialog
if(result==C4JStorage::EMessage_ResultDecline || result==C4JStorage::EMessage_ResultAccept)
{
// we need to enable background downloading for the DLC
XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW);
ULONGLONG ullOfferID_Full;
ULONGLONG ullIndexA[1];
app.GetDLCFullOfferIDForPackID(pClass->m_initData->selectedSession->data.texturePackParentId,&ullOfferID_Full);
if( result==C4JStorage::EMessage_ResultAccept ) // Full version
{
ullIndexA[0]=ullOfferID_Full;
StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr);
}
else // trial version
{
// if there is no trial version, this is a Cancel
DLC_INFO *pDLCInfo=app.GetDLCInfoForFullOfferID(ullOfferID_Full);
if(pDLCInfo->ullOfferID_Trial!=0LL)
{
ullIndexA[0]=pDLCInfo->ullOfferID_Trial;
StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr);
}
}
}
pClass->m_bIgnoreInput=false;
return 0;
}
HRESULT CScene_MultiGameJoinLoad::OnCustomMessage_DLCInstalled()
{
// mounted DLC may have changed
if(app.StartInstallDLCProcess(m_iPad)==false)
{
// not doing a mount, so re-enable input
m_bIgnoreInput=false;
}
else
{
m_bIgnoreInput=true;
// clear out the saves list and re-fill
m_pSavesList->RemoveAllData();
m_SavesListTimer.SetShow( TRUE );
}
// this will send a CustomMessage_DLCMountingComplete when done
return S_OK;
}
HRESULT CScene_MultiGameJoinLoad::OnCustomMessage_DLCMountingComplete()
{
VOID *pObj;
XuiObjectFromHandle( m_SavesList, &pObj );
m_pSavesList = static_cast<CXuiCtrl4JList *>(pObj);
m_iChangingSaveGameInfoIndex = 0;
m_generators = app.getLevelGenerators();
m_iDefaultButtonsC = 0;
m_iMashUpButtonsC = 0;
XPARTY_USER_LIST partyList;
if((XPartyGetUserList( &partyList ) != XPARTY_E_NOT_IN_PARTY ) && (partyList.dwUserCount>1))
{
m_bInParty=true;
}
else
{
m_bInParty=false;
}
int iLB = -1;
int iY=-1;
if(DoesSavesListHaveFocus())
{
if(ProfileManager.IsSignedInLive( m_iPad ))
{
iY=IDS_TOOLTIPS_UPLOAD_SAVE_FOR_XBOXONE;
}
}
if(m_bInParty) iLB = IDS_TOOLTIPS_PARTY_GAMES;
// check if we're in the trial version
if(ProfileManager.IsFullVersion()==false)
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK, -1, -1, -1, -1,iLB);
AddDefaultButtons();
m_pSavesList->SetCurSelVisible(0);
}
else if(StorageManager.GetSaveDisabled())
{
if(StorageManager.GetSaveDeviceSelected(m_iPad))
{
// saving is disabled, but we should still be able to load from a selected save device
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK,IDS_TOOLTIPS_CHANGEDEVICE,iY,-1,-1,iLB,IDS_TOOLTIPS_DELETESAVE);
GetSaveInfo();
}
else
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK,IDS_TOOLTIPS_SELECTDEVICE,iY,-1,-1,iLB);
AddDefaultButtons();
m_SavesListTimer.SetShow( FALSE );
m_pSavesList->SetCurSelVisible(0);
}
}
else
{
// 4J-PB - we need to check that there is enough space left to create a copy of the save (for a rename)
bool bCanRename = StorageManager.EnoughSpaceForAMinSaveGame();
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK,IDS_TOOLTIPS_CHANGEDEVICE,iY,-1,-1,-1,bCanRename?IDS_TOOLTIPS_SAVEOPTIONS:IDS_TOOLTIPS_DELETESAVE);
GetSaveInfo();
}
m_bIgnoreInput=false;
app.m_dlcManager.checkForCorruptDLCAndAlert();
return S_OK;
}
/*
void CScene_MultiGameJoinLoad::UpdateTooltips()
{
int iA=IDS_TOOLTIPS_SELECT;
int iB=IDS_TOOLTIPS_BACK;
int iX=-1;
int iY=-1
int iLB = -1;
XPARTY_USER_LIST partyList;
if((XPartyGetUserList( &partyList ) != XPARTY_E_NOT_IN_PARTY ) && (partyList.dwUserCount>1))
{
m_bInParty=true;
}
else
{
m_bInParty=false;
}
if(m_bInParty) iLB = IDS_TOOLTIPS_PARTY_GAMES;
if(ProfileManager.IsFullVersion()==false)
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK, -1, -1, -1, -1,iLB);
}
else if(StorageManager.GetSaveDisabled())
{
if(StorageManager.GetSaveDeviceSelected(m_iPad))
{
// saving is disabled, but we should still be able to load from a selected save device
iX=IDS_TOOLTIPS_CHANGEDEVICE;
iRB=IDS_TOOLTIPS_DELETESAVE;
}
else
{
iX=IDS_TOOLTIPS_SELECTDEVICE;
}
}
else
{
// 4J-PB - we need to check that there is enough space left to create a copy of the save (for a rename)
bool bCanRename = StorageManager.EnoughSpaceForAMinSaveGame();
if(bCanRename)
{
iRB=IDS_TOOLTIPS_SAVEOPTIONS;
}
else
{
iRB=IDS_TOOLTIPS_DELETESAVE;
}
}
ui.SetTooltips( DEFAULT_XUI_MENU_USER, iA,iB, iX, iY, iLT, iRT,iLB, iRB);
}
*/
#ifdef _XBOX
bool CScene_MultiGameJoinLoad::GetSavesInfoCallback(LPVOID pParam,int iTotalSaveInfoC, C4JStorage::CACHEINFOSTRUCT *InfoA, int iPad, HRESULT hResult)
{
CScene_MultiGameJoinLoad *pClass=(CScene_MultiGameJoinLoad *)pParam;
CXuiCtrl4JList::LIST_ITEM_INFO ListInfo;
PBYTE pbImageData=(PBYTE)InfoA;
PBYTE pbCurrentImagePtr;
HXUIBRUSH hXuiBrush;
HRESULT hr;
// move the image data pointer to the right place
if(iTotalSaveInfoC!=0)
{
pbImageData+=sizeof(C4JStorage::CACHEINFOSTRUCT)*iTotalSaveInfoC;
}
pClass->m_SavesListTimer.SetShow( FALSE );
pClass->m_SavesList.SetEnable(TRUE);
pClass->AddDefaultButtons();
for(int i=0;i<iTotalSaveInfoC;i++)
{
ZeroMemory(&ListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO));
// Add these to the save list
if(!(app.DebugSettingsOn() && app.GetLoadSavesFromFolderEnabled()))
{
// if the save is corrupt, display this instead of the title
if(InfoA[i].dwImageBytes==0)
{
ListInfo.pwszText=app.GetString(IDS_CORRUPT_OR_DAMAGED_SAVE_TITLE);
ListInfo.bIsDamaged=true;
}
else
{
ListInfo.pwszText=InfoA[i].wchDisplayName;
ListInfo.bIsDamaged=false;
}
ListInfo.fEnabled=TRUE;
ListInfo.iData = -1;
pClass->m_pSavesList->AddData(ListInfo,-1);
// update the graphic on the list item
// if there is no thumbnail, this is a corrupt file
if(InfoA[i].dwImageBytes!=0)
{
pbCurrentImagePtr=pbImageData+InfoA[i].dwImageOffset;
hr=XuiCreateTextureBrushFromMemory(pbCurrentImagePtr,InfoA[i].dwImageBytes,&hXuiBrush);
pClass->m_pSavesList->UpdateGraphic(i+pClass->m_iDefaultButtonsC,hXuiBrush );
}
else
{
// we could put in a damaged save icon here
const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string
WCHAR szResourceLocator[ LOCATOR_SIZE ];
const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr);
swprintf(szResourceLocator, LOCATOR_SIZE, L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/Graphics/MinecraftBrokenIcon.png");
XuiCreateTextureBrush(szResourceLocator,&hXuiBrush);
pClass->m_pSavesList->UpdateGraphic(i+pClass->m_iDefaultButtonsC,hXuiBrush );
}
}
}
pClass->m_iSaveInfoC=iTotalSaveInfoC;
// If there are some saves, then set the focus to be on the most recent one, which will be the first one after the create and tutorial
if(iTotalSaveInfoC>0)
{
pClass->m_pSavesList->SetCurSelVisible(pClass->m_iDefaultButtonsC);
pClass->m_bReady=true;
}
pClass->m_bRetrievingSaveInfo=false;
// It's possible that the games list is updated but we haven't displayed it yet as we were still waiting on saves list to load
// This is to fix a bug where joining a game before the saves list has loaded causes a crash when this callback is called
// as the scene no longer exists
pClass->UpdateGamesList();
// Fix for #45154 - Frontend: DLC: Content can only be downloaded from the frontend if you have not joined/exited multiplayer
XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_AUTO);
return false;
}
#else
int CScene_MultiGameJoinLoad::GetSavesInfoCallback(LPVOID lpParam,const bool)
{
return true;
}
#endif
void CScene_MultiGameJoinLoad::CancelSaveUploadCallback(LPVOID lpParam)
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(lpParam);
StorageManager.TMSPP_CancelWriteFileWithProgress(pClass->m_iPad);
pClass->m_bSaveTransferInProgress=false;
// change back to the normal title group id
app.TMSPP_SetTitleGroupID(GROUP_ID);
// app.getRemoteStorage()->abort();
// pClass->m_eSaveUploadState = eSaveUpload_Idle;
UINT uiIDA[1] = { IDS_CONFIRM_OK };
ui.RequestMessageBox(IDS_XBONE_CANCEL_UPLOAD_TITLE, IDS_XBONE_CANCEL_UPLOAD_TEXT, uiIDA, 1, pClass->m_iPad, nullptr, nullptr, app.GetStringTable());
}
void CScene_MultiGameJoinLoad::SaveUploadCompleteCallback(LPVOID lpParam)
{
CScene_MultiGameJoinLoad* pClass = static_cast<CScene_MultiGameJoinLoad *>(lpParam);
pClass->m_bSaveTransferInProgress=false;
// change back to the normal title group id
app.TMSPP_SetTitleGroupID(GROUP_ID);
// app.getRemoteStorage()->abort();
// pClass->m_eSaveUploadState = eSaveUpload_Idle;
}
|