-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathConsoles_App.cpp
More file actions
10236 lines (9013 loc) · 307 KB
/
Consoles_App.cpp
File metadata and controls
10236 lines (9013 loc) · 307 KB
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
#include "stdafx.h"
#include "..\..\Minecraft.World\net.minecraft.world.entity.item.h"
#include "..\..\Minecraft.World\net.minecraft.world.entity.player.h"
#include "..\..\Minecraft.World\net.minecraft.world.level.tile.entity.h"
#include "..\..\Minecraft.World\net.minecraft.world.phys.h"
#include "..\..\Minecraft.World\InputOutputStream.h"
#include "..\..\Minecraft.World\compression.h"
#include "..\Options.h"
#include "..\MinecraftServer.h"
#include "..\MultiPlayerLevel.h"
#include "..\GameRenderer.h"
#include "..\ProgressRenderer.h"
#include "..\LevelRenderer.h"
#include "..\MobSkinMemTextureProcessor.h"
#include "..\Minecraft.h"
#include "..\ClientConnection.h"
#include "..\MultiPlayerLocalPlayer.h"
#include "..\LocalPlayer.h"
#include "..\..\Minecraft.World\Player.h"
#include "..\..\Minecraft.World\Inventory.h"
#include "..\..\Minecraft.World\Level.h"
#include "..\..\Minecraft.World\FurnaceTileEntity.h"
#include "..\..\Minecraft.World\Container.h"
#include "..\..\Minecraft.World\DispenserTileEntity.h"
#include "..\..\Minecraft.World\SignTileEntity.h"
#include "..\StatsCounter.h"
#include "..\GameMode.h"
#include "..\Xbox\Social\SocialManager.h"
#include "Tutorial\TutorialMode.h"
#if defined _XBOX || defined _WINDOWS64
#include "..\Xbox\XML\ATGXmlParser.h"
#include "..\Xbox\XML\xmlFilesCallback.h"
#endif
#include "Minecraft_Macros.h"
#include "..\PlayerList.h"
#include "..\ServerPlayer.h"
#include "GameRules\ConsoleGameRules.h"
#include "GameRules\ConsoleSchematicFile.h"
#include "..\User.h"
#include "..\..\Minecraft.World\LevelData.h"
#include "..\..\Minecraft.World\net.minecraft.world.entity.player.h"
#include "..\EntityRenderDispatcher.h"
#include "..\..\Minecraft.World\compression.h"
#include "..\TexturePackRepository.h"
#include "..\DLCTexturePack.h"
#include "DLC\DLCPack.h"
#include "..\StringTable.h"
#ifndef _XBOX
#include "..\ArchiveFile.h"
#endif
#include "..\Minecraft.h"
#ifdef _XBOX
#include "..\Xbox\GameConfig\Minecraft.spa.h"
#include "..\Xbox\Network\NetworkPlayerXbox.h"
#include "XUI\XUI_TextEntry.h"
#include "XUI\XUI_XZP_Icons.h"
#include "XUI\XUI_PauseMenu.h"
#else
#include "UI\UI.h"
#include "UI\UIScene_PauseMenu.h"
#endif
#ifdef __PS3__
#include <sys/tty.h>
#endif
#ifdef __ORBIS__
#include <save_data_dialog.h>
#endif
#include "..\Common\Leaderboards\LeaderboardManager.h"
//CMinecraftApp app;
unsigned int CMinecraftApp::m_uiLastSignInData = 0;
const float CMinecraftApp::fSafeZoneX = 64.0f; // 5% of 1280
const float CMinecraftApp::fSafeZoneY = 36.0f; // 5% of 720
int CMinecraftApp::s_iHTMLFontSizesA[eHTMLSize_COUNT] =
{
#ifdef _XBOX
14,12,14,24
#else
//20,15,20,24
20,13,20,26
#endif
};
CMinecraftApp::CMinecraftApp()
{
if(GAME_SETTINGS_PROFILE_DATA_BYTES != sizeof(GAME_SETTINGS))
{
// 4J Stu - See comment for GAME_SETTINGS_PROFILE_DATA_BYTES in Xbox_App.h
DebugPrintf("WARNING: The size of the profile GAME_SETTINGS struct has changed, so all stat data is likely incorrect. Is: %d, Should be: %d\n",sizeof(GAME_SETTINGS),GAME_SETTINGS_PROFILE_DATA_BYTES);
#ifndef _CONTENT_PACKAGE
__debugbreak();
#endif
}
for(int i=0;i<XUSER_MAX_COUNT;i++)
{
m_eTMSAction[i]=eTMSAction_Idle;
m_eXuiAction[i]=eAppAction_Idle;
m_eXuiActionParam[i] = nullptr;
//m_dwAdditionalModelParts[i] = 0;
if(FAILED(XUserGetSigninInfo(i,XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY ,&m_currentSigninInfo[i])))
{
m_currentSigninInfo[i].xuid = INVALID_XUID;
m_currentSigninInfo[i].dwGuestNumber = 0;
}
DebugPrintf("Player at index %d has guest number %d\n", i,m_currentSigninInfo[i].dwGuestNumber );
m_bRead_BannedListA[i]=false;
SetBanListCheck(i,false);
m_uiOpacityCountDown[i]=0;
}
m_eGlobalXuiAction=eAppAction_Idle;
m_eGlobalXuiServerAction=eXuiServerAction_Idle;
m_bResourcesLoaded=false;
m_bGameStarted=false;
m_bIsAppPaused=false;
//m_bSplitScreenEnabled = false;
m_bIntroRunning=false;
m_eGameMode=eMode_Singleplayer;
m_bLoadSavesFromFolderEnabled = false;
m_bWriteSavesToFolderEnabled = false;
//m_bInterfaceRenderingOff = false;
//m_bHandRenderingOff = false;
m_bTutorialMode = false;
m_disconnectReason = DisconnectPacket::eDisconnect_None;
m_bLiveLinkRequired = false;
m_bChangingSessionType = false;
m_bReallyChangingSessionType = false;
#ifdef _DEBUG_MENUS_ENABLED
#ifdef _CONTENT_PACKAGE
m_bDebugOptions=false; // make them off by default in a content package build
#else
m_bDebugOptions=true;
#endif
#else
m_bDebugOptions=false;
#endif
//ZeroMemory(m_PreviewBuffer,sizeof(XSOCIAL_PREVIEWIMAGE)*XUSER_MAX_COUNT);
m_xuidNotch = INVALID_XUID;
ZeroMemory(&m_InviteData,sizeof(JoinFromInviteData) );
// m_bRead_TMS_XUIDS_XML=false;
// m_bRead_TMS_DLCINFO_XML=false;
m_pDLCFileBuffer=nullptr;
m_dwDLCFileSize=0;
m_pBannedListFileBuffer=nullptr;
m_dwBannedListFileSize=0;
m_bDefaultCapeInstallAttempted=false;
m_bDLCInstallProcessCompleted=false;
m_bDLCInstallPending=false;
m_iTotalDLC = 0;
m_iTotalDLCInstalled = 0;
mfTrialPausedTime=0.0f;
m_uiAutosaveTimer=0;
ZeroMemory(m_pszUniqueMapName,14);
m_bNewDLCAvailable=false;
m_bSeenNewDLCTip=false;
m_uiGameHostSettings=0;
#ifdef _LARGE_WORLDS
m_GameNewWorldSize = 0;
m_bGameNewWorldSizeUseMoat = false;
m_GameNewHellScale = 0;
#endif
ZeroMemory(m_playerColours,MINECRAFT_NET_MAX_PLAYERS);
m_iDLCOfferC=0;
m_bAllDLCContentRetrieved=true;
InitializeCriticalSection(&csDLCDownloadQueue);
m_bAllTMSContentRetrieved=true;
m_bTickTMSDLCFiles=true;
InitializeCriticalSection(&csTMSPPDownloadQueue);
InitializeCriticalSection(&csAdditionalModelParts);
InitializeCriticalSection(&csAdditionalSkinBoxes);
InitializeCriticalSection(&csAnimOverrideBitmask);
InitializeCriticalSection(&csMemFilesLock);
InitializeCriticalSection(&csMemTPDLock);
InitializeCriticalSection(&m_saveNotificationCriticalSection);
m_saveNotificationDepth = 0;
m_dwRequiredTexturePackID=0;
m_bResetNether=false;
#ifdef _XBOX
// m_bTransferSavesToXboxOne=false;
// m_uiTransferSlotC=5;
#endif
#if (defined _CONTENT_PACAKGE) || (defined _XBOX)
m_bUseDPadForDebug = false;
#else
m_bUseDPadForDebug = true;
#endif
#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__)
for(int i=0;i<XUSER_MAX_COUNT;i++)
{
m_eOptionsStatusA[i]=C4JStorage::eOptions_Callback_Idle;
}
#endif
for(int i=0;i<XUSER_MAX_COUNT;i++)
{
m_vBannedListA[i] = new vector<PBANNEDLISTDATA>;
}
LocaleAndLanguageInit();
#ifdef _XBOX_ONE
m_hasReachedMainMenu = false;
#endif
}
void CMinecraftApp::DebugPrintf(const char *szFormat, ...)
{
#ifndef _FINAL_BUILD
char buf[1024];
va_list ap;
va_start(ap, szFormat);
vsnprintf(buf, sizeof(buf), szFormat, ap);
va_end(ap);
OutputDebugStringA(buf);
#endif
}
void CMinecraftApp::DebugPrintf(int user, const char *szFormat, ...)
{
#ifndef _FINAL_BUILD
if(user == USER_NONE)
return;
char buf[1024];
va_list ap;
va_start(ap, szFormat);
vsnprintf(buf, sizeof(buf), szFormat, ap);
va_end(ap);
#ifdef __PS3__
unsigned int writelen;
sys_tty_write(SYS_TTYP_USER1 + ( user - 1 ), buf, strlen(buf), &writelen );
#elif defined __PSVITA__
switch(user)
{
case 0:
{
SceUID tty2 = sceIoOpen("tty2:", SCE_O_WRONLY, 0);
if(tty2>=0)
{
std::string string1(buf);
sceIoWrite(tty2, string1.c_str(), string1.length());
sceIoClose(tty2);
}
}
break;
case 1:
{
SceUID tty3 = sceIoOpen("tty3:", SCE_O_WRONLY, 0);
if(tty3>=0)
{
std::string string1(buf);
sceIoWrite(tty3, string1.c_str(), string1.length());
sceIoClose(tty3);
}
}
break;
default:
OutputDebugStringA(buf);
break;
}
#else
OutputDebugStringA(buf);
#endif
#ifndef _XBOX
if(user == USER_UI)
{
ui.logDebugString(buf);
}
#endif
#endif
}
LPCWSTR CMinecraftApp::GetString(int iID)
{
//return L"Değişiklikler ve Yenilikler";
//return L"ÕÕÕÕÖÖÖÖ";
return app.m_stringTable->getString(iID);
}
void CMinecraftApp::SetAction(int iPad, eXuiAction action, LPVOID param)
{
if( ( m_eXuiAction[iPad] == eAppAction_ReloadTexturePack ) && ( action == eAppAction_EthernetDisconnected ) )
{
app.DebugPrintf("Invalid change of App action for pad %d from %d to %d, ignoring\n", iPad, m_eXuiAction[iPad], action);
}
else if( ( m_eXuiAction[iPad] == eAppAction_ReloadTexturePack ) && ( action == eAppAction_ExitWorld ) )
{
app.DebugPrintf("Invalid change of App action for pad %d from %d to %d, ignoring\n", iPad, m_eXuiAction[iPad], action);
}
else if(m_eXuiAction[iPad] == eAppAction_ExitWorldCapturedThumbnail && action != eAppAction_Idle)
{
app.DebugPrintf("Invalid change of App action for pad %d from %d to %d, ignoring\n", iPad, m_eXuiAction[iPad], action);
}
else
{
app.DebugPrintf("Changing App action for pad %d from %d to %d\n", iPad, m_eXuiAction[iPad], action);
m_eXuiAction[iPad]=action;
m_eXuiActionParam[iPad] = param;
}
}
bool CMinecraftApp::IsAppPaused()
{
#if defined(_XBOX_ONE) || defined(__ORBIS__)
bool paused = m_bIsAppPaused;
EnterCriticalSection(&m_saveNotificationCriticalSection);
if( g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 )
{
paused |= m_saveNotificationDepth > 0;
}
LeaveCriticalSection(&m_saveNotificationCriticalSection);
return paused;
#else
return m_bIsAppPaused;
#endif
}
void CMinecraftApp::SetAppPaused(bool val)
{
m_bIsAppPaused = val;
}
void CMinecraftApp::HandleButtonPresses()
{
for(int i=0;i<4;i++)
{
HandleButtonPresses(i);
}
}
void CMinecraftApp::HandleButtonPresses(int iPad)
{
// // test an update of the profile data
// void *pData=ProfileManager.GetGameDefinedProfileData(iPad);
//
// unsigned char *pchData= (unsigned char *)pData;
// int iCount=0;
// for(int i=0;i<GAME_DEFINED_PROFILE_DATA_BYTES;i++)
// {
// pchData[i]=0xBC;
// //if(iCount==255) iCount = 0;
// }
// ProfileManager.WriteToProfile(iPad,true);
}
bool CMinecraftApp::LoadInventoryMenu(int iPad,shared_ptr<LocalPlayer> player,bool bNavigateBack)
{
bool success = true;
InventoryScreenInput* initData = new InventoryScreenInput();
initData->player = player;
initData->bNavigateBack=bNavigateBack;
initData->iPad = iPad;
if(app.GetLocalPlayerCount()>1)
{
initData->bSplitscreen=true;
success = ui.NavigateToScene(iPad,eUIScene_InventoryMenu,initData);
}
else
{
initData->bSplitscreen=false;
success = ui.NavigateToScene(iPad,eUIScene_InventoryMenu,initData);
}
return success;
}
bool CMinecraftApp::LoadCreativeMenu(int iPad,shared_ptr<LocalPlayer> player,bool bNavigateBack)
{
bool success = true;
InventoryScreenInput* initData = new InventoryScreenInput();
initData->player = player;
initData->bNavigateBack=bNavigateBack;
initData->iPad = iPad;
if(app.GetLocalPlayerCount()>1)
{
initData->bSplitscreen=true;
success = ui.NavigateToScene(iPad,eUIScene_CreativeMenu,initData);
}
else
{
initData->bSplitscreen=false;
success = ui.NavigateToScene(iPad,eUIScene_CreativeMenu,initData);
}
return success;
}
bool CMinecraftApp::LoadCrafting2x2Menu(int iPad,shared_ptr<LocalPlayer> player)
{
bool success = true;
CraftingPanelScreenInput* initData = new CraftingPanelScreenInput();
initData->player = player;
initData->iContainerType=RECIPE_TYPE_2x2;
initData->iPad = iPad;
initData->x = 0;
initData->y = 0;
initData->z = 0;
if(app.GetLocalPlayerCount()>1)
{
initData->bSplitscreen=true;
success = ui.NavigateToScene(iPad,eUIScene_Crafting2x2Menu, initData);
}
else
{
initData->bSplitscreen=false;
success = ui.NavigateToScene(iPad,eUIScene_Crafting2x2Menu, initData);
}
return success;
}
bool CMinecraftApp::LoadCrafting3x3Menu(int iPad,shared_ptr<LocalPlayer> player, int x, int y, int z)
{
bool success = true;
CraftingPanelScreenInput* initData = new CraftingPanelScreenInput();
initData->player = player;
initData->iContainerType=RECIPE_TYPE_3x3;
initData->iPad = iPad;
initData->x = x;
initData->y = y;
initData->z = z;
if(app.GetLocalPlayerCount()>1)
{
initData->bSplitscreen=true;
success = ui.NavigateToScene(iPad,eUIScene_Crafting3x3Menu, initData);
}
else
{
initData->bSplitscreen=false;
success = ui.NavigateToScene(iPad,eUIScene_Crafting3x3Menu, initData);
}
return success;
}
bool CMinecraftApp::LoadFireworksMenu(int iPad,shared_ptr<LocalPlayer> player, int x, int y, int z)
{
bool success = true;
FireworksScreenInput* initData = new FireworksScreenInput();
initData->player = player;
initData->iPad = iPad;
initData->x = x;
initData->y = y;
initData->z = z;
if(app.GetLocalPlayerCount()>1)
{
initData->bSplitscreen=true;
success = ui.NavigateToScene(iPad,eUIScene_FireworksMenu, initData);
}
else
{
initData->bSplitscreen=false;
success = ui.NavigateToScene(iPad,eUIScene_FireworksMenu, initData);
}
return success;
}
bool CMinecraftApp::LoadEnchantingMenu(int iPad,shared_ptr<Inventory> inventory, int x, int y, int z, Level *level, const wstring &name)
{
bool success = true;
EnchantingScreenInput* initData = new EnchantingScreenInput();
initData->inventory = inventory;
initData->level = level;
initData->x = x;
initData->y = y;
initData->z = z;
initData->iPad = iPad;
initData->name = name;
if(app.GetLocalPlayerCount()>1)
{
initData->bSplitscreen=true;
success = ui.NavigateToScene(iPad,eUIScene_EnchantingMenu, initData);
}
else
{
initData->bSplitscreen=false;
success = ui.NavigateToScene(iPad,eUIScene_EnchantingMenu, initData);
}
return success;
}
bool CMinecraftApp::LoadFurnaceMenu(int iPad,shared_ptr<Inventory> inventory, shared_ptr<FurnaceTileEntity> furnace)
{
bool success = true;
FurnaceScreenInput* initData = new FurnaceScreenInput();
initData->furnace = furnace;
initData->inventory = inventory;
initData->iPad = iPad;
// Load the scene.
if(app.GetLocalPlayerCount()>1)
{
initData->bSplitscreen=true;
success = ui.NavigateToScene(iPad,eUIScene_FurnaceMenu, initData);
}
else
{
initData->bSplitscreen=false;
success = ui.NavigateToScene(iPad,eUIScene_FurnaceMenu, initData);
}
return success;
}
bool CMinecraftApp::LoadBrewingStandMenu(int iPad,shared_ptr<Inventory> inventory, shared_ptr<BrewingStandTileEntity> brewingStand)
{
bool success = true;
BrewingScreenInput* initData = new BrewingScreenInput();
initData->brewingStand = brewingStand;
initData->inventory = inventory;
initData->iPad = iPad;
// Load the scene.
if(app.GetLocalPlayerCount()>1)
{
initData->bSplitscreen=true;
success = ui.NavigateToScene(iPad,eUIScene_BrewingStandMenu, initData);
}
else
{
initData->bSplitscreen=false;
success = ui.NavigateToScene(iPad,eUIScene_BrewingStandMenu, initData);
}
return success;
}
bool CMinecraftApp::LoadContainerMenu(int iPad,shared_ptr<Container> inventory, shared_ptr<Container> container)
{
bool success = true;
ContainerScreenInput* initData = new ContainerScreenInput();
initData->inventory = inventory;
initData->container = container;
initData->iPad = iPad;
// Load the scene.
if(app.GetLocalPlayerCount()>1)
{
initData->bSplitscreen=true;
bool bLargeChest = (initData->container->getContainerSize() > 3*9)?true:false;
if(bLargeChest)
{
success = ui.NavigateToScene(iPad,eUIScene_LargeContainerMenu,initData);
}
else
{
success = ui.NavigateToScene(iPad,eUIScene_ContainerMenu,initData);
}
}
else
{
initData->bSplitscreen=false;
success = ui.NavigateToScene(iPad,eUIScene_ContainerMenu,initData);
}
return success;
}
bool CMinecraftApp::LoadTrapMenu(int iPad,shared_ptr<Container> inventory, shared_ptr<DispenserTileEntity> trap)
{
bool success = true;
TrapScreenInput* initData = new TrapScreenInput();
initData->inventory = inventory;
initData->trap = trap;
initData->iPad = iPad;
// Load the scene.
if(app.GetLocalPlayerCount()>1)
{
initData->bSplitscreen=true;
success = ui.NavigateToScene(iPad,eUIScene_DispenserMenu, initData);
}
else
{
initData->bSplitscreen=false;
success = ui.NavigateToScene(iPad,eUIScene_DispenserMenu, initData);
}
return success;
}
bool CMinecraftApp::LoadSignEntryMenu(int iPad,shared_ptr<SignTileEntity> sign)
{
bool success = true;
SignEntryScreenInput* initData = new SignEntryScreenInput();
initData->sign = sign;
initData->iPad = iPad;
success = ui.NavigateToScene(iPad,eUIScene_SignEntryMenu, initData);
delete initData;
return success;
}
bool CMinecraftApp::LoadRepairingMenu(int iPad,shared_ptr<Inventory> inventory, Level *level, int x, int y, int z)
{
bool success = true;
AnvilScreenInput *initData = new AnvilScreenInput();
initData->inventory = inventory;
initData->level = level;
initData->x = x;
initData->y = y;
initData->z = z;
initData->iPad = iPad;
if(app.GetLocalPlayerCount()>1) initData->bSplitscreen=true;
else initData->bSplitscreen=false;
success = ui.NavigateToScene(iPad,eUIScene_AnvilMenu, initData);
return success;
}
bool CMinecraftApp::LoadTradingMenu(int iPad, shared_ptr<Inventory> inventory, shared_ptr<Merchant> trader, Level *level, const wstring &name)
{
bool success = true;
TradingScreenInput *initData = new TradingScreenInput();
initData->inventory = inventory;
initData->trader = trader;
initData->level = level;
initData->iPad = iPad;
if(app.GetLocalPlayerCount()>1) initData->bSplitscreen=true;
else initData->bSplitscreen=false;
success = ui.NavigateToScene(iPad,eUIScene_TradingMenu, initData);
return success;
}
bool CMinecraftApp::LoadHopperMenu(int iPad ,shared_ptr<Inventory> inventory, shared_ptr<HopperTileEntity> hopper)
{
bool success = true;
HopperScreenInput *initData = new HopperScreenInput();
initData->inventory = inventory;
initData->hopper = hopper;
initData->iPad = iPad;
if(app.GetLocalPlayerCount()>1) initData->bSplitscreen=true;
else initData->bSplitscreen=false;
success = ui.NavigateToScene(iPad,eUIScene_HopperMenu, initData);
return success;
}
bool CMinecraftApp::LoadHopperMenu(int iPad ,shared_ptr<Inventory> inventory, shared_ptr<MinecartHopper> hopper)
{
bool success = true;
HopperScreenInput *initData = new HopperScreenInput();
initData->inventory = inventory;
initData->hopper = dynamic_pointer_cast<Container>(hopper);
initData->iPad = iPad;
if(app.GetLocalPlayerCount()>1) initData->bSplitscreen=true;
else initData->bSplitscreen=false;
success = ui.NavigateToScene(iPad,eUIScene_HopperMenu, initData);
return success;
}
bool CMinecraftApp::LoadHorseMenu(int iPad ,shared_ptr<Inventory> inventory, shared_ptr<Container> container, shared_ptr<EntityHorse> horse)
{
bool success = true;
HorseScreenInput *initData = new HorseScreenInput();
initData->inventory = inventory;
initData->container = container;
initData->horse = horse;
initData->iPad = iPad;
if(app.GetLocalPlayerCount()>1) initData->bSplitscreen=true;
else initData->bSplitscreen=false;
success = ui.NavigateToScene(iPad,eUIScene_HorseMenu, initData);
return success;
}
bool CMinecraftApp::LoadBeaconMenu(int iPad ,shared_ptr<Inventory> inventory, shared_ptr<BeaconTileEntity> beacon)
{
bool success = true;
BeaconScreenInput *initData = new BeaconScreenInput();
initData->inventory = inventory;
initData->beacon = beacon;
initData->iPad = iPad;
if(app.GetLocalPlayerCount()>1) initData->bSplitscreen=true;
else initData->bSplitscreen=false;
success = ui.NavigateToScene(iPad,eUIScene_BeaconMenu, initData);
return success;
}
//////////////////////////////////////////////
// GAME SETTINGS
//////////////////////////////////////////////
#ifdef _WINDOWS64
static void Win64_GetSettingsPath(char *outPath, DWORD size)
{
GetModuleFileNameA(nullptr, outPath, size);
char *lastSlash = strrchr(outPath, '\\');
if (lastSlash) *(lastSlash + 1) = '\0';
strncat_s(outPath, size, "settings.dat", _TRUNCATE);
}
static void Win64_SaveSettings(GAME_SETTINGS *gs)
{
if (!gs) return;
char filePath[MAX_PATH] = {};
Win64_GetSettingsPath(filePath, MAX_PATH);
FILE *f = nullptr;
if (fopen_s(&f, filePath, "wb") == 0 && f)
{
fwrite(gs, sizeof(GAME_SETTINGS), 1, f);
fclose(f);
}
}
static void Win64_LoadSettings(GAME_SETTINGS *gs)
{
if (!gs) return;
char filePath[MAX_PATH] = {};
Win64_GetSettingsPath(filePath, MAX_PATH);
FILE *f = nullptr;
if (fopen_s(&f, filePath, "rb") == 0 && f)
{
GAME_SETTINGS temp = {};
if (fread(&temp, sizeof(GAME_SETTINGS), 1, f) == 1)
memcpy(gs, &temp, sizeof(GAME_SETTINGS));
fclose(f);
}
}
#endif
void CMinecraftApp::InitGameSettings()
{
for(int i=0;i<XUSER_MAX_COUNT;i++)
{
#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__)
GameSettingsA[i]=(GAME_SETTINGS *)StorageManager.GetGameDefinedProfileData(i);
#else
GameSettingsA[i]=static_cast<GAME_SETTINGS *>(ProfileManager.GetGameDefinedProfileData(i));
#endif
// clear the flag to say the settings have changed
GameSettingsA[i]->bSettingsChanged=false;
//SetDefaultGameSettings(i); - done on a callback from the profile manager
// 4J-PB - adding in for Windows & PS3 to set the defaults for the joypad
#if defined _WINDOWS64// || defined __PSVITA__
C_4JProfile::PROFILESETTINGS *pProfileSettings=ProfileManager.GetDashboardProfileSettings(i);
// clear this for now - it will come from reading the system values
memset(pProfileSettings,0,sizeof(C_4JProfile::PROFILESETTINGS));
SetDefaultOptions(pProfileSettings,i);
Win64_LoadSettings(GameSettingsA[i]);
ApplyGameSettingsChanged(i);
#elif defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__
C4JStorage::PROFILESETTINGS *pProfileSettings=StorageManager.GetDashboardProfileSettings(i);
// 4J-PB - don't cause an options write to happen here
SetDefaultOptions(pProfileSettings,i,false);
#endif
}
}
#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__)
int CMinecraftApp::SetDefaultOptions(C4JStorage::PROFILESETTINGS *pSettings,const int iPad,bool bWriteProfile)
#else
int CMinecraftApp::SetDefaultOptions(C_4JProfile::PROFILESETTINGS *pSettings,const int iPad)
#endif
{
SetGameSettings(iPad,eGameSetting_MusicVolume,DEFAULT_VOLUME_LEVEL);
SetGameSettings(iPad,eGameSetting_SoundFXVolume,DEFAULT_VOLUME_LEVEL);
SetGameSettings(iPad,eGameSetting_RenderDistance,16);
SetGameSettings(iPad,eGameSetting_Gamma,50);
SetGameSettings(iPad,eGameSetting_FOV,0);
SetGameSettings(iPad,eGameSetting_GraphicsMode,1);
// 4J-PB - Don't reset the difficult level if we're in-game
if(Minecraft::GetInstance()->level==nullptr)
{
app.DebugPrintf("SetDefaultOptions - Difficulty = 1\n");
SetGameSettings(iPad,eGameSetting_Difficulty,1);
}
SetGameSettings(iPad,eGameSetting_Sensitivity_InGame,100);
SetGameSettings(iPad,eGameSetting_ViewBob,1);
SetGameSettings(iPad,eGameSetting_ControlScheme,0);
SetGameSettings(iPad,eGameSetting_ControlInvertLook,(pSettings->iYAxisInversion!=0)?1:0);
SetGameSettings(iPad,eGameSetting_ControlSouthPaw,pSettings->bSwapSticks?1:0);
SetGameSettings(iPad,eGameSetting_SplitScreenVertical,0);
SetGameSettings(iPad,eGameSetting_GamertagsVisible,1);
// Interim TU 1.6.6
SetGameSettings(iPad,eGameSetting_Sensitivity_InMenu,100);
SetGameSettings(iPad,eGameSetting_DisplaySplitscreenGamertags,1);
SetGameSettings(iPad,eGameSetting_Hints,1);
SetGameSettings(iPad,eGameSetting_Autosave,2);
SetGameSettings(iPad,eGameSetting_Tooltips,1);
SetGameSettings(iPad,eGameSetting_InterfaceOpacity,80);
// TU 5
SetGameSettings(iPad,eGameSetting_Clouds,1);
SetGameSettings(iPad,eGameSetting_Online,1);
SetGameSettings(iPad,eGameSetting_InviteOnly,0);
SetGameSettings(iPad,eGameSetting_FriendsOfFriends,1);
// default the update changes message to zero
// 4J-PB - We'll only display the message if the profile is pre-TU5
//SetGameSettings(iPad,eGameSetting_DisplayUpdateMessage,0);
// TU 6
SetGameSettings(iPad,eGameSetting_BedrockFog,0);
SetGameSettings(iPad,eGameSetting_DisplayHUD,1);
SetGameSettings(iPad,eGameSetting_DisplayHand,1);
// TU 7
SetGameSettings(iPad,eGameSetting_CustomSkinAnim,1);
// TU 9
SetGameSettings(iPad,eGameSetting_DeathMessages,1);
SetGameSettings(iPad,eGameSetting_UISize,1);
SetGameSettings(iPad,eGameSetting_UISizeSplitscreen,2);
SetGameSettings(iPad,eGameSetting_AnimatedCharacter,1);
// TU 12
GameSettingsA[iPad]->ucCurrentFavoriteSkinPos=0;
for(int i=0;i<MAX_FAVORITE_SKINS;i++)
{
GameSettingsA[iPad]->uiFavoriteSkinA[i]=0xFFFFFFFF;
}
// TU 13
GameSettingsA[iPad]->uiMashUpPackWorldsDisplay=0xFFFFFFFF;
// 1.6.4
app.SetGameHostOption(eGameHostOption_MobGriefing, 1);
app.SetGameHostOption(eGameHostOption_KeepInventory, 0);
app.SetGameHostOption(eGameHostOption_DoMobSpawning, 1 );
app.SetGameHostOption(eGameHostOption_DoMobLoot, 1 );
app.SetGameHostOption(eGameHostOption_DoTileDrops, 1 );
app.SetGameHostOption(eGameHostOption_NaturalRegeneration, 1 );
app.SetGameHostOption(eGameHostOption_DoDaylightCycle, 1 );
// 4J-PB - leave these in, or remove from everywhere they are referenced!
// Although probably best to leave in unless we split the profile settings into platform specific classes - having different meaning per platform for the same bitmask could get confusing
//#ifdef __PS3__
// PS3DEC13
SetGameSettings(iPad,eGameSetting_PS3_EULA_Read,0); // EULA not read
// PS3 1.05 - added Greek
// 4J-JEV: We cannot change these in-game, as they could affect localised strings and font.
// XB1: Fix for #172947 - Content: Gameplay: While playing in language different form system default one and resetting options to their defaults in active gameplay causes in-game language to change and HUD to disappear
if (!app.GetGameStarted())
{
GameSettingsA[iPad]->ucLanguage = MINECRAFT_LANGUAGE_DEFAULT; // use the system language
GameSettingsA[iPad]->ucLocale = MINECRAFT_LANGUAGE_DEFAULT; // use the system locale
}
//#endif
#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__)
GameSettingsA[iPad]->bSettingsChanged=bWriteProfile;
#endif
return 0;
}
#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__)
int CMinecraftApp::DefaultOptionsCallback(LPVOID pParam,C4JStorage::PROFILESETTINGS *pSettings, const int iPad)
#else
int CMinecraftApp::DefaultOptionsCallback(LPVOID pParam,C_4JProfile::PROFILESETTINGS *pSettings, const int iPad)
#endif
{
CMinecraftApp *pApp=static_cast<CMinecraftApp *>(pParam);
// flag the default options to be set
pApp->DebugPrintf("Setting default options for player %d", iPad);
pApp->SetAction(iPad,eAppAction_SetDefaultOptions, (LPVOID)pSettings);
//pApp->SetDefaultOptions(pSettings,iPad);
// if the profile data has been changed, then force a profile write
// It seems we're allowed to break the 5 minute rule if it's the result of a user action
//pApp->CheckGameSettingsChanged();
return 0;
}
#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__)
wstring CMinecraftApp::toStringOptionsStatus(const C4JStorage::eOptionsCallback &eStatus)
{
#ifndef _CONTENT_PACKAGE
switch(eStatus)
{
case C4JStorage::eOptions_Callback_Idle: return L"Idle";
case C4JStorage::eOptions_Callback_Write: return L"Write";
case C4JStorage::eOptions_Callback_Write_Fail_NoSpace: return L"Write_Fail_NoSpace";
case C4JStorage::eOptions_Callback_Write_Fail: return L"Write_Fail";
case C4JStorage::eOptions_Callback_Read: return L"Read";
case C4JStorage::eOptions_Callback_Read_Fail: return L"Read_Fail";
case C4JStorage::eOptions_Callback_Read_FileNotFound: return L"Read_FileNotFound";
case C4JStorage::eOptions_Callback_Read_Corrupt: return L"Read_Corrupt";
case C4JStorage::eOptions_Callback_Read_CorruptDeletePending: return L"Read_CorruptDeletePending";
case C4JStorage::eOptions_Callback_Read_CorruptDeleted: return L"Read_CorruptDeleted";
default: return L"[UNRECOGNISED_OPTIONS_STATUS]";
}
#else
return L"";
#endif
}
#ifdef __ORBIS__
int CMinecraftApp::OptionsDataCallback(LPVOID pParam,int iPad,unsigned short usVersion,C4JStorage::eOptionsCallback eStatus,int iBlocksRequired)
{
CMinecraftApp *pApp=(CMinecraftApp *)pParam;
pApp->m_eOptionsStatusA[iPad]=eStatus;
pApp->m_eOptionsBlocksRequiredA[iPad]=iBlocksRequired;
return 0;
}
int CMinecraftApp::GetOptionsBlocksRequired(int iPad)
{
return m_eOptionsBlocksRequiredA[iPad];
}
#else
int CMinecraftApp::OptionsDataCallback(LPVOID pParam,int iPad,unsigned short usVersion,C4JStorage::eOptionsCallback eStatus)
{
CMinecraftApp *pApp=(CMinecraftApp *)pParam;
#ifndef _CONTENT_PACKAGE
pApp->DebugPrintf("[OptionsDataCallback] Pad_%i: new status == %ls(%i).\n", iPad, pApp->toStringOptionsStatus(eStatus).c_str(), (int) eStatus);
#endif