the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 1281 lines 37 kB view raw
1 2#include "stdafx.h" 3#include "..\Common\Consoles_App.h" 4#include "..\User.h" 5#include "..\..\Minecraft.Client\Minecraft.h" 6#include "..\..\Minecraft.Client\MinecraftServer.h" 7#include "..\..\Minecraft.Client\PlayerList.h" 8#include "..\..\Minecraft.Client\ServerPlayer.h" 9#include "..\..\Minecraft.World\Level.h" 10#include "..\..\Minecraft.World\LevelSettings.h" 11#include "..\..\Minecraft.World\BiomeSource.h" 12#include "..\..\Minecraft.World\LevelType.h" 13#include "..\..\Orbis\Network\SonyCommerce_Orbis.h" 14#include "..\..\Minecraft.World\StringHelpers.h" 15#include "Network/Orbis_NPToolkit.h" 16#include "Orbis\Network\SonyRemoteStorage_Orbis.h" 17 18#include <system_service.h> 19#include "..\..\Common\Network\Sony\SonyRemoteStorage.h" 20#include <save_data_dialog.h> 21#include <error_dialog.h> 22 23#define ORBIS_COMMERCE_ENABLED 24CConsoleMinecraftApp app; 25 26 27 28CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp() 29{ 30 memset(&m_ThumbnailBuffer,0,sizeof(ImageFileBuffer)); 31 memset(&m_SaveImageBuffer,0,sizeof(ImageFileBuffer)); 32// memset(&m_ScreenshotBuffer,0,sizeof(ImageFileBuffer)); 33 34 memset(&ProductCodes,0,sizeof(PRODUCTCODES)); 35 36 m_bVoiceChatAndUGCRestricted=false; 37 m_bDisplayFullVersionPurchase=false; 38 // #ifdef _DEBUG_MENUS_ENABLED 39 // debugOverlayCreated = false; 40 // #endif 41 42 m_ProductListA=NULL; 43 44 m_pRemoteStorage = new SonyRemoteStorage_Orbis; 45 46 m_bSaveDataDialogRunning = false; 47 m_bOptionsSaveDataDialogRunning=false; 48 m_bPatchAvailableDialogRunning = false; 49} 50 51void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId) 52{ 53 ProfileManager.SetRichPresenceContextValue(iPad,CONTEXT_GAME_STATE,contextId); 54} 55 56char *CConsoleMinecraftApp::GetProductCode() 57{ 58 return ProductCodes.chProductCode; 59} 60char *CConsoleMinecraftApp::GetSaveFolderPrefix() 61{ 62 return ProductCodes.chSaveFolderPrefix; 63} 64char *CConsoleMinecraftApp::GetCommerceCategory() 65{ 66 return ProductCodes.chCommerceCategory; 67} 68char *CConsoleMinecraftApp::GetTexturePacksCategoryID() 69{ 70 return ProductCodes.chTexturePackID; 71} 72char *CConsoleMinecraftApp::GetUpgradeKey() 73{ 74 return ProductCodes.chUpgradeKey; 75} 76EProductSKU CConsoleMinecraftApp::GetProductSKU() 77{ 78 return ProductCodes.eProductSKU; 79} 80bool CConsoleMinecraftApp::IsJapaneseSKU() 81{ 82 return ProductCodes.eProductSKU == e_sku_SCEJ; 83 84} 85bool CConsoleMinecraftApp::IsEuropeanSKU() 86{ 87 return ProductCodes.eProductSKU == e_sku_SCEE; 88 89} 90bool CConsoleMinecraftApp::IsAmericanSKU() 91{ 92 return ProductCodes.eProductSKU == e_sku_SCEA; 93 94} 95// char *CConsoleMinecraftApp::GetSKUPostfix() 96// { 97// return ProductCodes.chSkuPostfix; 98// } 99 100SONYDLC *CConsoleMinecraftApp::GetSONYDLCInfo(char *pchTitle) 101{ 102 wstring wstrTemp=convStringToWstring(pchTitle); 103 104 AUTO_VAR(it, m_SONYDLCMap.find(wstrTemp)); 105 if(it == m_SONYDLCMap.end()) 106 { 107 app.DebugPrintf("Couldn't find DLC info for %s\n", pchTitle); 108 assert(0); 109 return NULL; 110 } 111 return it->second; 112} 113 114SONYDLC *CConsoleMinecraftApp::GetSONYDLCInfoFromKeyname(char *pchKeyName) 115{ 116 117 for(AUTO_VAR(it, m_SONYDLCMap.begin()); it != m_SONYDLCMap.end(); ++it) 118 { 119 SONYDLC *pDLCInfo=(*it).second; 120 121 if(strcmp(pDLCInfo->chDLCKeyname,pchKeyName)==0) 122 { 123 return pDLCInfo; 124 } 125 } 126 127 return NULL; 128} 129 130#define WRAPPED_READFILE(hFile,lpBuffer,nNumberOfBytesToRead,lpNumberOfBytesRead,lpOverlapped) {if(ReadFile(hFile,lpBuffer,nNumberOfBytesToRead,lpNumberOfBytesRead,lpOverlapped)==FALSE) { return FALSE;}} 131BOOL CConsoleMinecraftApp::ReadProductCodes() 132{ 133 char chDLCTitle[64]; 134 135 // 4J-PB - Read the file containing the product codes. This will be different for the SCEE/SCEA/SCEJ builds 136 //HANDLE file = CreateFile("orbis/DLCImages/TP01_360x360.png", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 137 HANDLE file = CreateFile("orbis/PS4ProductCodes.bin", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 138 if( file == INVALID_HANDLE_VALUE ) 139 { 140 DWORD error = GetLastError(); 141 app.DebugPrintf("Failed to open ProductCodes.bin with error code %d (%x)\n", error, error); 142 return FALSE; 143 } 144 145 DWORD dwHigh=0; 146 DWORD dwFileSize = GetFileSize(file,&dwHigh); 147 148 if(dwFileSize!=0) 149 { 150 DWORD bytesRead; 151 152 WRAPPED_READFILE(file,ProductCodes.chProductCode,PRODUCT_CODE_SIZE,&bytesRead,NULL); 153 WRAPPED_READFILE(file,ProductCodes.chSaveFolderPrefix,SAVEFOLDERPREFIX_SIZE,&bytesRead,NULL); 154 WRAPPED_READFILE(file,ProductCodes.chCommerceCategory,COMMERCE_CATEGORY_SIZE,&bytesRead,NULL); 155 WRAPPED_READFILE(file,ProductCodes.chTexturePackID,SCE_NP_COMMERCE2_CATEGORY_ID_LEN,&bytesRead,NULL); 156 WRAPPED_READFILE(file,ProductCodes.chUpgradeKey,UPGRADE_KEY_SIZE,&bytesRead,NULL); 157 WRAPPED_READFILE(file,ProductCodes.chSkuPostfix,SKU_POSTFIX_SIZE,&bytesRead,NULL); 158 159 app.DebugPrintf("ProductCodes.chProductCode %s\n",ProductCodes.chProductCode); 160 app.DebugPrintf("ProductCodes.chSaveFolderPrefix %s\n",ProductCodes.chSaveFolderPrefix); 161 app.DebugPrintf("ProductCodes.chCommerceCategory %s\n",ProductCodes.chCommerceCategory); 162 app.DebugPrintf("ProductCodes.chTexturePackID %s\n",ProductCodes.chTexturePackID); 163 app.DebugPrintf("ProductCodes.chUpgradeKey %s\n",ProductCodes.chUpgradeKey); 164 app.DebugPrintf("ProductCodes.chSkuPostfix %s\n",ProductCodes.chSkuPostfix); 165 166 // DLC 167 unsigned int uiDLC; 168 WRAPPED_READFILE(file,&uiDLC,sizeof(int),&bytesRead,NULL); 169 170 for(unsigned int i=0;i<uiDLC;i++) 171 { 172 SONYDLC *pDLCInfo= new SONYDLC; 173 memset(pDLCInfo,0,sizeof(SONYDLC)); 174 memset(chDLCTitle,0,64); 175 176 unsigned int uiVal; 177 WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,NULL); 178 WRAPPED_READFILE(file,pDLCInfo->chDLCKeyname,sizeof(char)*uiVal,&bytesRead,NULL); 179 180 WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,NULL); 181 WRAPPED_READFILE(file,chDLCTitle,sizeof(char)*uiVal,&bytesRead,NULL); 182 app.DebugPrintf("DLC title %s\n",chDLCTitle); 183 184 WRAPPED_READFILE(file,&pDLCInfo->eDLCType,sizeof(int),&bytesRead,NULL); 185 186 WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,NULL); 187 WRAPPED_READFILE(file,pDLCInfo->chDLCPicname,sizeof(char)*uiVal,&bytesRead,NULL); 188 189 WRAPPED_READFILE(file,&pDLCInfo->iFirstSkin,sizeof(int),&bytesRead,NULL); 190 WRAPPED_READFILE(file,&pDLCInfo->iConfig,sizeof(int),&bytesRead,NULL); 191 192 // push this into a vector 193 194 wstring wstrTemp=convStringToWstring(chDLCTitle); 195 m_SONYDLCMap[wstrTemp]=pDLCInfo; 196 } 197 CloseHandle(file); 198 } 199 200 if(strcmp(ProductCodes.chProductCode, "CUSA00265") == 0) 201 ProductCodes.eProductSKU = e_sku_SCEE; 202 else if(strcmp(ProductCodes.chProductCode, "CUSA00744") == 0) 203 ProductCodes.eProductSKU = e_sku_SCEA; 204 else if(strcmp(ProductCodes.chProductCode, "CUSA00283") == 0) 205 ProductCodes.eProductSKU = e_sku_SCEJ; 206 else 207 { 208 // unknown product ID 209 assert(0); 210 } 211 212 return TRUE; 213} 214 215void CConsoleMinecraftApp::StoreLaunchData() 216{ 217} 218void CConsoleMinecraftApp::ExitGame() 219{ 220} 221void CConsoleMinecraftApp::FatalLoadError() 222{ 223 assert(0); 224} 225 226void CConsoleMinecraftApp::CaptureSaveThumbnail() 227{ 228 RenderManager.CaptureThumbnail(&m_ThumbnailBuffer,&m_SaveImageBuffer); 229} 230void CConsoleMinecraftApp::GetSaveThumbnail(PBYTE *ppbThumbnailData,DWORD *pdwThumbnailSize,PBYTE *ppbDataImage,DWORD *pdwSizeImage) 231{ 232 // on a save caused by a create world, the thumbnail capture won't have happened 233 if(m_ThumbnailBuffer.Allocated()) 234 { 235 if( ppbThumbnailData ) 236 { 237 *ppbThumbnailData= new BYTE [m_ThumbnailBuffer.GetBufferSize()]; 238 *pdwThumbnailSize=m_ThumbnailBuffer.GetBufferSize(); 239 memcpy(*ppbThumbnailData,m_ThumbnailBuffer.GetBufferPointer(),*pdwThumbnailSize); 240 } 241 m_ThumbnailBuffer.Release(); 242 } 243 else 244 { 245 if( ppbThumbnailData ) 246 { 247 // use the default image 248 StorageManager.GetDefaultSaveThumbnail(ppbThumbnailData,pdwThumbnailSize); 249 } 250 } 251 252 if(m_SaveImageBuffer.Allocated()) 253 { 254 if( ppbDataImage ) 255 { 256 *ppbDataImage= new BYTE [m_SaveImageBuffer.GetBufferSize()]; 257 *pdwSizeImage=m_SaveImageBuffer.GetBufferSize(); 258 memcpy(*ppbDataImage,m_SaveImageBuffer.GetBufferPointer(),*pdwSizeImage); 259 } 260 m_SaveImageBuffer.Release(); 261 } 262 else 263 { 264 if( ppbDataImage ) 265 { 266 // use the default image 267 StorageManager.GetDefaultSaveImage(ppbDataImage,pdwSizeImage); 268 } 269 } 270} 271 272void CConsoleMinecraftApp::ReleaseSaveThumbnail() 273{ 274 275} 276 277void CConsoleMinecraftApp::GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize) 278{ 279 280} 281 282int CConsoleMinecraftApp::GetLocalTMSFileIndex(WCHAR *wchTMSFile,bool bFilenameIncludesExtension,eFileExtensionType eEXT) 283{ 284 return -1; 285} 286 287 288int CConsoleMinecraftApp::LoadLocalDLCImages() 289{ 290 // 4J-PB - Any local graphic files for the Minecraft Store? 291 unordered_map<wstring, SONYDLC *>*pDLCInfoA=app.GetSonyDLCMap(); 292 for( AUTO_VAR(it, pDLCInfoA->begin()); it != pDLCInfoA->end(); it++ ) 293 { 294 SONYDLC * pDLCInfo=(*it).second; 295 296 LoadLocalDLCImage(pDLCInfo); 297 } 298 return 0; 299} 300 301void CConsoleMinecraftApp::FreeLocalDLCImages() 302{ 303 // 4J-PB - Any local graphic files for the Minecraft Store? 304 unordered_map<wstring, SONYDLC *>*pDLCInfoA=app.GetSonyDLCMap(); 305 for( AUTO_VAR(it, pDLCInfoA->begin()); it != pDLCInfoA->end(); it++ ) 306 { 307 SONYDLC * pDLCInfo=(*it).second; 308 309 if(pDLCInfo->dwImageBytes!=0) 310 { 311 free(pDLCInfo->pbImageData); 312 pDLCInfo->dwImageBytes=0; 313 pDLCInfo->pbImageData=NULL; 314 } 315 } 316} 317 318 319int CConsoleMinecraftApp::LoadLocalDLCImage(SONYDLC *pDLCInfo) 320{ 321 // load the local file 322 char pchFilename[64]; 323 324 sprintf(pchFilename,"orbis/DLCImages/%s_360x360.png",pDLCInfo->chDLCPicname); 325 // 4J-PB - Read the file containing the product codes. This will be different for the SCEE/SCEA/SCEJ builds 326 HANDLE hFile = CreateFile(pchFilename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 327 328 if( hFile == INVALID_HANDLE_VALUE ) 329 { 330 app.DebugPrintf("Failed to open %s\n", pchFilename); 331 return FALSE; 332 } 333 334 DWORD dwHigh=0; 335 pDLCInfo->dwImageBytes = GetFileSize(hFile,&dwHigh); 336 337 if(pDLCInfo->dwImageBytes!=0) 338 { 339 DWORD dwBytesRead; 340 pDLCInfo->pbImageData=(PBYTE)malloc(pDLCInfo->dwImageBytes); 341 342 if(ReadFile(hFile,pDLCInfo->pbImageData,pDLCInfo->dwImageBytes,&dwBytesRead,NULL)==FALSE) 343 { 344 // failed 345 free(pDLCInfo->pbImageData); 346 pDLCInfo->dwImageBytes=0; 347 } 348 } 349 350 CloseHandle(hFile); 351 352 return 0; 353} 354 355int CConsoleMinecraftApp::LoadLocalTMSFile(char *chTMSFile) 356{ 357 return -1; 358} 359int CConsoleMinecraftApp::LoadLocalTMSFile(WCHAR *wchTMSFile) 360{ 361 return -1; 362} 363 364int CConsoleMinecraftApp::LoadLocalTMSFile(WCHAR *wchTMSFile, eFileExtensionType eExt) 365{ 366 return -1; 367} 368 369void CConsoleMinecraftApp::FreeLocalTMSFiles(eTMSFileType eType) 370{ 371 372} 373 374void CConsoleMinecraftApp::TemporaryCreateGameStart() 375{ 376 ////////////////////////////////////////////////////////////////////////////////////////////// From CScene_Main::OnInit 377 378 app.setLevelGenerationOptions(NULL); 379 380 // From CScene_Main::RunPlayGame 381 Minecraft *pMinecraft=Minecraft::GetInstance(); 382 app.ReleaseSaveThumbnail(); 383 ProfileManager.SetLockedProfile(0); 384 pMinecraft->user->name = L"Orbis"; 385 app.ApplyGameSettingsChanged(0); 386 387 ////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameJoinLoad::OnInit 388 MinecraftServer::resetFlags(); 389 390 // From CScene_MultiGameJoinLoad::OnNotifyPressEx 391 app.SetTutorialMode( false ); 392 app.SetCorruptSaveDeleted(false); 393 394 ////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameCreate::CreateGame 395 396 app.ClearTerrainFeaturePosition(); 397 wstring wWorldName = L"TestWorld"; 398 399 StorageManager.ResetSaveData(); 400 StorageManager.SetSaveTitle(wWorldName.c_str()); 401 402 bool isFlat = false; 403 __int64 seedValue = BiomeSource::findSeed(isFlat?LevelType::lvl_flat:LevelType::lvl_normal); // 4J - was (new Random())->nextLong() - now trying to actually find a seed to suit our requirements 404 405 NetworkGameInitData *param = new NetworkGameInitData(); 406 param->seed = seedValue; 407 param->saveData = NULL; 408 409 app.SetGameHostOption(eGameHostOption_Difficulty,0); 410 app.SetGameHostOption(eGameHostOption_FriendsOfFriends,0); 411 app.SetGameHostOption(eGameHostOption_Gamertags,1); 412 app.SetGameHostOption(eGameHostOption_BedrockFog,1); 413 414 app.SetGameHostOption(eGameHostOption_GameType,GameType::SURVIVAL->getId()); 415 app.SetGameHostOption(eGameHostOption_LevelType, 0 ); 416 app.SetGameHostOption(eGameHostOption_Structures, 1 ); 417 app.SetGameHostOption(eGameHostOption_BonusChest, 0 ); 418 419 app.SetGameHostOption(eGameHostOption_PvP, 1); 420 app.SetGameHostOption(eGameHostOption_TrustPlayers, 1 ); 421 app.SetGameHostOption(eGameHostOption_FireSpreads, 1 ); 422 app.SetGameHostOption(eGameHostOption_TNT, 1 ); 423 app.SetGameHostOption(eGameHostOption_HostCanFly, 1); 424 app.SetGameHostOption(eGameHostOption_HostCanChangeHunger, 1); 425 app.SetGameHostOption(eGameHostOption_HostCanBeInvisible, 1 ); 426 427 param->settings = app.GetGameHostOption( eGameHostOption_All ); 428 429 g_NetworkManager.FakeLocalPlayerJoined(); 430 431 LoadingInputParams *loadingParams = new LoadingInputParams(); 432 loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; 433 loadingParams->lpParam = (LPVOID)param; 434 435 // Reset the autosave time 436 app.SetAutosaveTimerTime(); 437 438 C4JThread* thread = new C4JThread(loadingParams->func, loadingParams->lpParam, "RunNetworkGame"); 439 thread->Run(); 440} 441 442 443 444 445 446// COMMERCE / DLC 447 448void CConsoleMinecraftApp::CommerceInit() 449{ 450 m_bCommerceCategoriesRetrieved=false; 451 m_bCommerceProductListRetrieved=false; 452 m_bCommerceInitialised=false; 453 m_bProductListAdditionalDetailsRetrieved=false; 454#ifdef ORBIS_COMMERCE_ENABLED 455 m_pCommerce= new SonyCommerce_Orbis; 456#endif 457 m_eCommerce_State=eCommerce_State_Offline; // can only init when we have a PSN user 458 m_ProductListRetrievedC=0; 459 m_ProductListAdditionalDetailsC=0; 460 m_ProductListCategoriesC=0; 461 m_iCurrentCategory=0; 462 m_iCurrentProduct=0; 463 memset(m_pchSkuID,0,48); 464} 465 466void CConsoleMinecraftApp::CommerceTick() 467{ 468#ifdef ORBIS_COMMERCE_ENABLED 469 // only tick this if the primary user is signed in to the PSN 470 if(ProfileManager.IsSignedInLive(0)) 471 { 472 switch(m_eCommerce_State) 473 { 474 case eCommerce_State_Offline: 475 m_eCommerce_State=eCommerce_State_Init; 476 break; 477 case eCommerce_State_Init: 478 m_eCommerce_State=eCommerce_State_Init_Pending; 479 m_pCommerce->CreateSession(&CConsoleMinecraftApp::CommerceInitCallback, this); 480 break; 481 case eCommerce_State_GetCategories: 482 m_eCommerce_State=eCommerce_State_GetCategories_Pending; 483 // get all categories for this product 484 m_pCommerce->GetCategoryInfo(&CConsoleMinecraftApp::CommerceGetCategoriesCallback, this, &m_CategoryInfo,app.GetCommerceCategory()); 485 486 break; 487 case eCommerce_State_GetProductList: 488 { 489 m_eCommerce_State=eCommerce_State_GetProductList_Pending; 490 SonyCommerce::CategoryInfo *pCategories=app.GetCategoryInfo(); 491 std::list<SonyCommerce::CategoryInfoSub>::iterator iter = pCategories->subCategories.begin(); 492 493 for(int i=0;i<m_ProductListRetrievedC;i++) 494 { 495 iter++; 496 } 497 SonyCommerce::CategoryInfoSub category = (SonyCommerce::CategoryInfoSub)(*iter); 498 499 m_pCommerce->GetProductList(&CConsoleMinecraftApp::CommerceGetProductListCallback, this, &m_ProductListA[m_ProductListRetrievedC],category.categoryId); 500 } 501 502 break; 503 case eCommerce_State_AddProductInfoDetailed: 504 { 505 m_eCommerce_State=eCommerce_State_AddProductInfoDetailed_Pending; 506 507 // for each of the products in the categories, get the detailed info. We really only need the long description and price info. 508 SonyCommerce::CategoryInfo *pCategories=app.GetCategoryInfo(); 509 std::list<SonyCommerce::CategoryInfoSub>::iterator iter = pCategories->subCategories.begin(); 510 for(int i=0;i<m_iCurrentCategory;i++) 511 { 512 iter++; 513 } 514 515 SonyCommerce::CategoryInfoSub category = (SonyCommerce::CategoryInfoSub)(*iter); 516 std::vector<SonyCommerce::ProductInfo>*pvProductList=&m_ProductListA[m_iCurrentCategory]; 517 518 // 4J-PB - there may be no products in the category 519 if(pvProductList->size()==0) 520 { 521 CConsoleMinecraftApp::CommerceAddDetailedProductInfoCallback(this,0); 522 } 523 else 524 { 525 assert(pvProductList->size() > m_iCurrentProduct); 526 SonyCommerce::ProductInfo *pProductInfo=&(pvProductList->at(m_iCurrentProduct)); 527 m_pCommerce->AddDetailedProductInfo(&CConsoleMinecraftApp::CommerceAddDetailedProductInfoCallback, this, pProductInfo,pProductInfo->productId,category.categoryId); 528 } 529 } 530 break; 531 case eCommerce_State_Checkout: 532 m_pCommerce->CreateSession(&CConsoleMinecraftApp::CheckoutSessionStartedCallback, this); 533 m_eCommerce_State=eCommerce_State_Checkout_WaitingForSession; 534 break; 535 case eCommerce_State_Checkout_SessionStarted: 536 m_eCommerce_State=eCommerce_State_Checkout_Pending; 537 m_pCommerce->Checkout(&CConsoleMinecraftApp::CommerceCheckoutCallback, this,m_pchSkuID); 538 break; 539 540 case eCommerce_State_RegisterDLC: 541 { 542 m_eCommerce_State=eCommerce_State_Online; 543 // register the DLC info 544 SonyCommerce::CategoryInfo *pCategories=app.GetCategoryInfo(); 545 std::list<SonyCommerce::CategoryInfoSub>::iterator iter = pCategories->subCategories.begin(); 546 for(int i=0;i<m_iCurrentCategory;i++) 547 { 548 std::vector<SonyCommerce::ProductInfo>*pvProductList=&m_ProductListA[i]; 549 for(int j=0;j<pvProductList->size();j++) 550 { 551 SonyCommerce::ProductInfo *pProductInfo=&(pvProductList->at(j)); 552 // just want the final 16 characters of the product id 553 RegisterDLCData(&pProductInfo->productId[20],0,pProductInfo->imageUrl); 554 } 555 iter++; 556 } 557 } 558 break; 559 560 case eCommerce_State_DownloadAlreadyPurchased: 561 m_pCommerce->CreateSession(&CConsoleMinecraftApp::DownloadAlreadyPurchasedSessionStartedCallback, this); 562 m_eCommerce_State=eCommerce_State_DownloadAlreadyPurchased_WaitingForSession; 563 break; 564 case eCommerce_State_DownloadAlreadyPurchased_SessionStarted: 565 m_eCommerce_State=eCommerce_State_DownloadAlreadyPurchased_Pending; 566 m_pCommerce->DownloadAlreadyPurchased(&CConsoleMinecraftApp::CommerceCheckoutCallback, this,m_pchSkuID); 567 break; 568 569 570 case eCommerce_State_UpgradeTrial: 571 m_pCommerce->CreateSession(&CConsoleMinecraftApp::UpgradeTrialSessionStartedCallback, this); 572 m_eCommerce_State=eCommerce_State_UpgradeTrial_WaitingForSession; 573 break; 574 case eCommerce_State_UpgradeTrial_SessionStarted: 575 m_pCommerce->UpgradeTrial(&CConsoleMinecraftApp::CommerceCheckoutCallback, this); 576 m_eCommerce_State=eCommerce_State_UpgradeTrial_Pending; 577 break; 578 } 579 580 // 4J-PB - bit of a hack to display the full version purchase after signing in during a trial trophy popup 581 if(m_bDisplayFullVersionPurchase && ((m_eCommerce_State==eCommerce_State_Online) || (m_eCommerce_State==eCommerce_State_Error))) 582 { 583 m_bDisplayFullVersionPurchase=false; 584 ProfileManager.DisplayFullVersionPurchase(false,ProfileManager.GetPrimaryPad(),eSen_UpsellID_Full_Version_Of_Game); 585 } 586 } 587 else 588 { 589 // was the primary player signed in and is now signed out? 590 if(m_eCommerce_State!=eCommerce_State_Offline) 591 { 592 m_eCommerce_State=eCommerce_State_Offline; 593 594 // clear out all the product info 595 ClearCommerceDetails(); 596 597 m_pCommerce->CloseSession(); 598 } 599 } 600#endif // ORBIS_COMMERCE_ENABLED 601} 602 603bool CConsoleMinecraftApp::GetCommerceCategoriesRetrieved() 604{ 605 return m_bCommerceCategoriesRetrieved; 606} 607 608bool CConsoleMinecraftApp::GetCommerceProductListRetrieved() 609{ 610 return m_bCommerceProductListRetrieved; 611} 612 613bool CConsoleMinecraftApp::GetCommerceProductListInfoRetrieved() 614{ 615 return m_bProductListAdditionalDetailsRetrieved; 616} 617 618#ifdef ORBIS_COMMERCE_ENABLED 619SonyCommerce::CategoryInfo *CConsoleMinecraftApp::GetCategoryInfo() 620{ 621 if(m_bCommerceCategoriesRetrieved==false) 622 { 623 return NULL; 624 } 625 626 return &m_CategoryInfo; 627} 628#endif 629 630void CConsoleMinecraftApp::ClearCommerceDetails() 631{ 632#ifdef ORBIS_COMMERCE_ENABLED 633 for(int i=0;i<m_ProductListCategoriesC;i++) 634 { 635 std::vector<SonyCommerce::ProductInfo>* pProductList=&m_ProductListA[i]; 636 pProductList->clear(); 637 } 638 639 if(m_ProductListA!=NULL) 640 { 641 delete [] m_ProductListA; 642 m_ProductListA=NULL; 643 } 644 645 m_ProductListRetrievedC=0; 646 m_ProductListAdditionalDetailsC=0; 647 m_ProductListCategoriesC=0; 648 m_iCurrentCategory=0; 649 m_iCurrentProduct=0; 650 m_bCommerceCategoriesRetrieved=false; 651 m_bCommerceInitialised=false; 652 m_bCommerceProductListRetrieved=false; 653 m_bProductListAdditionalDetailsRetrieved=false; 654 655 m_CategoryInfo.subCategories.clear(); 656#endif // #ifdef ORBIS_COMMERCE_ENABLED 657 658} 659 660 661void CConsoleMinecraftApp::GetDLCSkuIDFromProductList(char * pchDLCProductID, char *pchSkuID) 662{ 663#ifdef ORBIS_COMMERCE_ENABLED 664 665 // find the DLC 666 for(int i=0;i<m_ProductListCategoriesC;i++) 667 { 668 for(int j=0;j<m_ProductListA[i].size();j++) 669 { 670 std::vector<SonyCommerce::ProductInfo>* pProductList=&m_ProductListA[i]; 671 AUTO_VAR(itEnd, pProductList->end()); 672 673 for (AUTO_VAR(it, pProductList->begin()); it != itEnd; it++) 674 { 675 SonyCommerce::ProductInfo Info=*it; 676 if(strcmp(pchDLCProductID,Info.productId)==0) 677 { 678 memcpy(pchSkuID,Info.skuId,SCE_NP_COMMERCE2_SKU_ID_LEN); 679 return; 680 } 681 } 682 } 683 } 684 return; 685#endif // #ifdef ORBIS_COMMERCE_ENABLED 686 687} 688 689void CConsoleMinecraftApp::Checkout(char *pchSkuID) 690{ 691 if(m_eCommerce_State==eCommerce_State_Online) 692 { 693 strcpy(m_pchSkuID,pchSkuID); 694 m_eCommerce_State=eCommerce_State_Checkout; 695 } 696} 697 698void CConsoleMinecraftApp::DownloadAlreadyPurchased(char *pchSkuID) 699{ 700 if(m_eCommerce_State==eCommerce_State_Online) 701 { 702 strcpy(m_pchSkuID,pchSkuID); 703 m_eCommerce_State=eCommerce_State_DownloadAlreadyPurchased; 704 } 705} 706 707bool CConsoleMinecraftApp::UpgradeTrial() 708{ 709 if(m_eCommerce_State==eCommerce_State_Online) 710 { 711 m_eCommerce_State=eCommerce_State_UpgradeTrial; 712 return true; 713 } 714 else if(m_eCommerce_State==eCommerce_State_Error) 715 { 716 UINT uiIDA[1]; 717 uiIDA[0]=IDS_CONFIRM_OK; 718 C4JStorage::EMessageResult result = ui.RequestMessageBox( IDS_PRO_UNLOCKGAME_TITLE, IDS_NO_DLCOFFERS, uiIDA,1,ProfileManager.GetPrimaryPad()); 719 return true; 720 } 721 else 722 { 723 // commerce is busy 724 return false; 725 } 726} 727 728#ifdef ORBIS_COMMERCE_ENABLED 729std::vector<SonyCommerce::ProductInfo>* CConsoleMinecraftApp::GetProductList(int iIndex) 730{ 731 if((m_bCommerceProductListRetrieved==false) || (m_bProductListAdditionalDetailsRetrieved==false) ) 732 { 733 return NULL; 734 } 735 736 return &m_ProductListA[iIndex]; 737} 738#endif // #ifdef ORBIS_COMMERCE_ENABLED 739 740bool CConsoleMinecraftApp::DLCAlreadyPurchased(char *pchTitle) 741{ 742#ifdef ORBIS_COMMERCE_ENABLED 743 // purchasability flag is not return on PS4 744 return false; 745 // find the DLC 746// for(int i=0;i<m_ProductListCategoriesC;i++) 747// { 748// for(int j=0;j<m_ProductListA[i].size();j++) 749// { 750// std::vector<SonyCommerce::ProductInfo>* pProductList=&m_ProductListA[i]; 751// AUTO_VAR(itEnd, pProductList->end()); 752// 753// for (AUTO_VAR(it, pProductList->begin()); it != itEnd; it++) 754// { 755// SonyCommerce::ProductInfo Info=*it; 756// if(strcmp(pchTitle,Info.skuId)==0) 757// { 758// ORBIS_STUBBED; 759// SCE_NP_COMMERCE2_SKU_PURCHASABILITY_FLAG_OFF 760// // if(Info.purchasabilityFlag==SCE_NP_COMMERCE2_SKU_PURCHASABILITY_FLAG_OFF) 761// // { 762// // return true; 763// // } 764// // else 765// // { 766// // return false; 767// // } 768// } 769// } 770// } 771// } 772#endif // #ifdef ORBIS_COMMERCE_ENABLED 773 774 return false; 775} 776 777 778 779//////////////////// 780// Commerce callbacks 781///////////////////// 782void CConsoleMinecraftApp::CommerceInitCallback(LPVOID lpParam,int err) 783{ 784 CConsoleMinecraftApp *pClass=(CConsoleMinecraftApp *)lpParam; 785 786 if(err==0) 787 { 788 pClass->m_eCommerce_State=eCommerce_State_GetCategories; 789 } 790 else 791 { 792 pClass->m_eCommerce_State=eCommerce_State_Error; 793 pClass->m_ProductListCategoriesC=0; 794 pClass->m_bCommerceCategoriesRetrieved=true; 795 } 796} 797 798 799void CConsoleMinecraftApp::CommerceGetCategoriesCallback(LPVOID lpParam,int err) 800{ 801#ifdef ORBIS_COMMERCE_ENABLED 802 CConsoleMinecraftApp *pClass=(CConsoleMinecraftApp *)lpParam; 803 804 if(err==0) 805 { 806 pClass->m_ProductListCategoriesC=pClass->m_CategoryInfo.countOfSubCategories; 807 // allocate the memory for the product info for each categories 808 if(pClass->m_CategoryInfo.countOfSubCategories>0) 809 { 810 pClass->m_ProductListA = (std::vector<SonyCommerce::ProductInfo> *) new std::vector<SonyCommerce::ProductInfo> [pClass->m_CategoryInfo.countOfSubCategories]; 811 pClass->m_eCommerce_State=eCommerce_State_GetProductList; 812 } 813 else 814 { 815 pClass->m_eCommerce_State=eCommerce_State_Online; 816 } 817 } 818 else 819 { 820 pClass->m_ProductListCategoriesC=0; 821 pClass->m_eCommerce_State=eCommerce_State_Error; 822 } 823 824 pClass->m_bCommerceCategoriesRetrieved=true; 825#endif // #ifdef ORBIS_COMMERCE_ENABLED 826 827} 828 829void CConsoleMinecraftApp::CommerceGetProductListCallback(LPVOID lpParam,int err) 830{ 831 CConsoleMinecraftApp *pClass=(CConsoleMinecraftApp *)lpParam; 832 833 if(err==0) 834 { 835 pClass->m_ProductListRetrievedC++; 836 // if we have more info to get, keep going with the next call 837 if(pClass->m_ProductListRetrievedC==pClass->m_CategoryInfo.countOfSubCategories) 838 { 839 // we're done, so now retrieve the additional product details for each product 840 pClass->m_eCommerce_State=eCommerce_State_AddProductInfoDetailed; 841 pClass->m_bCommerceProductListRetrieved=true; 842 } 843 else 844 { 845 pClass->m_eCommerce_State=eCommerce_State_GetProductList; 846 } 847 } 848 else 849 { 850 pClass->m_eCommerce_State=eCommerce_State_Error; 851 pClass->m_bCommerceProductListRetrieved=true; 852 } 853} 854 855// void CConsoleMinecraftApp::CommerceGetDetailedProductInfoCallback(LPVOID lpParam,int err) 856// { 857// CConsoleMinecraftApp *pScene=(CConsoleMinecraftApp *)lpParam; 858// 859// if(err==0) 860// { 861// pScene->m_eCommerce_State=eCommerce_State_Idle; 862// //pScene->m_bCommerceProductListRetrieved=true; 863// } 864// //printf("Callback hit, error 0x%08x\n", err); 865// 866// } 867 868void CConsoleMinecraftApp::CommerceAddDetailedProductInfoCallback(LPVOID lpParam,int err) 869{ 870#ifdef ORBIS_COMMERCE_ENABLED 871 CConsoleMinecraftApp *pClass=(CConsoleMinecraftApp *)lpParam; 872 873 if(err==0) 874 { 875 // increment the current product counter. When this gets to the end of the products, move to the next category 876 pClass->m_iCurrentProduct++; 877 878 std::vector<SonyCommerce::ProductInfo>*pvProductList=&pClass->m_ProductListA[pClass->m_iCurrentCategory]; 879 880 // if there are no more products in this category, move to the next category (there may be no products in the category) 881 if(pClass->m_iCurrentProduct>=pvProductList->size()) 882 { 883 // MGH - change this to a while loop so we can skip empty categories. 884 do 885 { 886 pClass->m_iCurrentCategory++; 887 }while(pClass->m_ProductListA[pClass->m_iCurrentCategory].size() == 0 && pClass->m_iCurrentCategory<pClass->m_ProductListCategoriesC); 888 889 pClass->m_iCurrentProduct=0; 890 if(pClass->m_iCurrentCategory==pClass->m_ProductListCategoriesC) 891 { 892 // there are no more categories, so we're done 893 pClass->m_eCommerce_State=eCommerce_State_RegisterDLC; 894 pClass->m_bProductListAdditionalDetailsRetrieved=true; 895 } 896 else 897 { 898 // continue with the next category 899 pClass->m_eCommerce_State=eCommerce_State_AddProductInfoDetailed; 900 } 901 } 902 else 903 { 904 // continue with the next product 905 pClass->m_eCommerce_State=eCommerce_State_AddProductInfoDetailed; 906 } 907 } 908 else 909 { 910 pClass->m_eCommerce_State=eCommerce_State_Error; 911 pClass->m_bProductListAdditionalDetailsRetrieved=true; 912 pClass->m_iCurrentProduct=0; 913 pClass->m_iCurrentCategory=0; 914 } 915 916#endif //#ifdef ORBIS_COMMERCE_ENABLED 917 918} 919 920void CConsoleMinecraftApp::CommerceCheckoutCallback(LPVOID lpParam,int err) 921{ 922 CConsoleMinecraftApp *pClass=(CConsoleMinecraftApp *)lpParam; 923 924 if(err==0) 925 { 926 } 927 pClass->m_eCommerce_State=eCommerce_State_Online; 928} 929 930void CConsoleMinecraftApp::CheckoutSessionStartedCallback(LPVOID lpParam,int err) 931{ 932 CConsoleMinecraftApp *pClass=(CConsoleMinecraftApp *)lpParam; 933 if(err==0) 934 pClass->m_eCommerce_State=eCommerce_State_Checkout_SessionStarted; 935 else 936 pClass->m_eCommerce_State=eCommerce_State_Error; 937} 938 939void CConsoleMinecraftApp::DownloadAlreadyPurchasedSessionStartedCallback(LPVOID lpParam,int err) 940{ 941 CConsoleMinecraftApp *pClass=(CConsoleMinecraftApp *)lpParam; 942 if(err==0) 943 pClass->m_eCommerce_State=eCommerce_State_DownloadAlreadyPurchased_SessionStarted; 944 else 945 pClass->m_eCommerce_State=eCommerce_State_Error; 946} 947 948void CConsoleMinecraftApp::UpgradeTrialSessionStartedCallback(LPVOID lpParam,int err) 949{ 950 CConsoleMinecraftApp *pClass=(CConsoleMinecraftApp *)lpParam; 951 if(err==0) 952 pClass->m_eCommerce_State=eCommerce_State_UpgradeTrial_SessionStarted; 953 else 954 pClass->m_eCommerce_State=eCommerce_State_Error; 955} 956 957 958bool CConsoleMinecraftApp::GetTrialFromName(char *pchDLCName) 959{ 960 if(pchDLCName[0]=='T') 961 { 962 return true; 963 } 964 965 return false; 966} 967 968eDLCContentType CConsoleMinecraftApp::GetDLCTypeFromName(char *pchDLCName) 969{ 970 char chDLCType[3]; 971 972 chDLCType[0]=pchDLCName[1]; 973 chDLCType[1]=pchDLCName[2]; 974 chDLCType[2]=0; 975 976 app.DebugPrintf(6,"DLC - %s\n",pchDLCName); 977 978 if(strcmp(chDLCType,"SP")==0) 979 { 980 return e_DLC_SkinPack; 981 } 982 else if(strcmp(chDLCType,"GP")==0) 983 { 984 return e_DLC_Gamerpics; 985 } 986 else if(strcmp(chDLCType,"TH")==0) 987 { 988 return e_DLC_Themes; 989 } 990 else if(strcmp(chDLCType,"AV")==0) 991 { 992 return e_DLC_AvatarItems; 993 } 994 else if(strcmp(chDLCType,"MP")==0) 995 { 996 return e_DLC_MashupPacks; 997 } 998 else if(strcmp(chDLCType,"TP")==0) 999 { 1000 return e_DLC_TexturePacks; 1001 } 1002 else 1003 { 1004 return e_DLC_NotDefined; 1005 } 1006} 1007 1008int CConsoleMinecraftApp::GetiConfigFromName(char *pchName) 1009{ 1010 char pchiConfig[5]; 1011 int iStrlen=strlen(pchName); 1012 // last four character of DLC product name are the iConfig value 1013 pchiConfig[0]=pchName[iStrlen-4]; 1014 pchiConfig[1]=pchName[iStrlen-3]; 1015 pchiConfig[2]=pchName[iStrlen-2]; 1016 pchiConfig[3]=pchName[iStrlen-1]; 1017 pchiConfig[4]=0; 1018 1019 return atoi(pchiConfig); 1020} 1021 1022int CConsoleMinecraftApp::GetiFirstSkinFromName(char *pchName) 1023{ 1024 char pchiFirstSkin[5]; 1025 int iStrlen=strlen(pchName); 1026 // last four character of DLC product name are the iConfig value 1027 // four before that are the first skin id 1028 pchiFirstSkin[0]=pchName[iStrlen-8]; 1029 pchiFirstSkin[1]=pchName[iStrlen-7]; 1030 pchiFirstSkin[2]=pchName[iStrlen-6]; 1031 pchiFirstSkin[3]=pchName[iStrlen-5]; 1032 pchiFirstSkin[4]=0; 1033 1034 return atoi(pchiFirstSkin); 1035} 1036 1037// void CConsoleMinecraftApp::SetVoiceChatAndUGCRestricted(bool bRestricted) 1038//{ 1039// m_bVoiceChatAndUGCRestricted=bRestricted; 1040//} 1041 1042// bool CConsoleMinecraftApp::GetVoiceChatAndUGCRestricted(void) 1043//{ 1044// return m_bVoiceChatAndUGCRestricted; 1045//} 1046 1047 1048int CConsoleMinecraftApp::GetCommerceState() 1049{ 1050 return m_eCommerce_State; 1051} 1052 1053 1054void CConsoleMinecraftApp::SystemServiceTick() 1055{ 1056 SceSystemServiceStatus status; 1057 SceSystemServiceEvent event; 1058 1059 int ret = sceSystemServiceGetStatus(&status); 1060 if ((ret == SCE_OK) && (status.eventNum > 0)) 1061 { 1062 for (int i = 0; i < status.eventNum; i++) 1063 { 1064 ret = sceSystemServiceReceiveEvent(&event); 1065 if (ret == SCE_OK) 1066 { 1067 switch(event.eventType) 1068 { 1069 case SCE_SYSTEM_SERVICE_EVENT_GAME_CUSTOM_DATA: 1070 { 1071 OrbisNPToolkit::getMessageData((SceNpGameCustomDataEventParam*)event.data.param); 1072 // Processing after invitation 1073 //SceNpSessionInvitationEventParam* pInvite = (SceNpSessionInvitationEventParam*)event.data.param; 1074 //SQRNetworkManager_Orbis::GetInviteDataAndProcess(pInvite); 1075 break; 1076 } 1077 case SCE_SYSTEM_SERVICE_EVENT_ON_RESUME: 1078 // Resume means that the user signed out (but came back), sensible thing to do is exit to main menu 1079 app.SetAction(0, eAppAction_ExitWorld); 1080 break; 1081 case SCE_SYSTEM_SERVICE_EVENT_SESSION_INVITATION: 1082 case SCE_SYSTEM_SERVICE_EVENT_GAME_LIVE_STREAMING_STATUS_UPDATE: 1083 break; 1084 case SCE_SYSTEM_SERVICE_EVENT_ENTITLEMENT_UPDATE: 1085 app.GetCommerce()->CheckForTrialUpgradeKey(); 1086 // clear the DLC installed and check again 1087 app.ClearDLCInstalled(); 1088 ui.HandleDLCInstalled(0); 1089 break; 1090 case SCE_SYSTEM_SERVICE_EVENT_DISPLAY_SAFE_AREA_UPDATE: 1091 case SCE_SYSTEM_SERVICE_EVENT_URL_OPEN: 1092 case SCE_SYSTEM_SERVICE_EVENT_LAUNCH_APP: 1093 default: 1094 break; 1095 1096 } 1097 } 1098 } 1099 } 1100} 1101 1102void CConsoleMinecraftApp::SaveDataDialogTick() 1103{ 1104 if(m_bOptionsSaveDataDialogRunning) 1105 { 1106 SceCommonDialogStatus status = sceSaveDataDialogUpdateStatus(); 1107 if( status == SCE_COMMON_DIALOG_STATUS_FINISHED ) 1108 { 1109 SceSaveDataDialogResult result; 1110 memset(&result, 0, sizeof(result)); 1111 int ret = sceSaveDataDialogGetResult(&result); 1112 m_bOptionsSaveDataDialogRunning = false; 1113 ret = sceSaveDataDialogTerminate(); 1114 1115 // R4099 doesn't say we need give the user a delete dialog to create space, so we won't 1116 } 1117 } 1118 else if( m_bSaveDataDialogRunning ) 1119 { 1120 SceCommonDialogStatus status = sceSaveDataDialogUpdateStatus(); 1121 if( status == SCE_COMMON_DIALOG_STATUS_FINISHED || status == SCE_COMMON_DIALOG_STATUS_NONE ) 1122 { 1123 SceSaveDataDialogResult result; 1124 memset(&result, 0, sizeof(result)); 1125 int ret = sceSaveDataDialogGetResult(&result); 1126 m_bSaveDataDialogRunning = false; 1127 ret = sceSaveDataDialogTerminate(); 1128 1129 UINT uiIDA[3]; 1130 uiIDA[0]=IDS_SAVE_INCOMPLETE_RETRY_SAVING; 1131 uiIDA[1]=IDS_SAVE_INCOMPLETE_DISABLE_SAVING; 1132 uiIDA[2]=IDS_SAVE_INCOMPLETE_DELETE_SAVES; 1133 1134 int message; 1135 if( m_eSaveIncompleteType == C4JStorage::ESaveIncomplete_OutOfQuota ) 1136 { 1137 message = IDS_SAVE_INCOMPLETE_EXPLANATION_QUOTA; 1138 } 1139 else 1140 { 1141 message = IDS_SAVE_INCOMPLETE_EXPLANATION_LOCAL_STORAGE; 1142 } 1143 1144 if( ui.RequestMessageBox( IDS_SAVE_INCOMPLETE_TITLE, message, uiIDA,3,XUSER_INDEX_ANY,Callback_SaveGameIncompleteMessageBoxReturned,this, app.GetStringTable()) == C4JStorage::EMessage_Busy) 1145 { 1146 // If this failed to display, continue as if we cancelled. This isn't ideal, but the user should already have had some system notification of being out of memory, 1147 // and if we instantly retry then they may not be able to navigate whatever other error is blocking this from appearing 1148 Callback_SaveGameIncompleteMessageBoxReturned(this, 0, C4JStorage::EMessage_Cancelled); 1149 } 1150 } 1151 } 1152} 1153 1154 1155void CConsoleMinecraftApp::Callback_SaveGameIncomplete(void *pParam, C4JStorage::ESaveIncompleteType saveIncompleteType, int blocksRequired) 1156{ 1157 CConsoleMinecraftApp* pClass = (CConsoleMinecraftApp*)pParam; 1158 1159 SceSaveDataDialogParam param; 1160 SceSaveDataDialogSystemMessageParam sysParam; 1161 SceSaveDataDialogItems items; 1162 SceSaveDataDirName dirName; 1163 1164 sceSaveDataDialogParamInitialize(&param); 1165 param.mode = SCE_SAVE_DATA_DIALOG_MODE_SYSTEM_MSG; 1166 param.dispType = SCE_SAVE_DATA_DIALOG_TYPE_SAVE; 1167 memset(&sysParam,0,sizeof(sysParam)); 1168 param.sysMsgParam = &sysParam; 1169 param.sysMsgParam->sysMsgType = SCE_SAVE_DATA_DIALOG_SYSMSG_TYPE_NOSPACE_CONTINUABLE; 1170 param.sysMsgParam->value = blocksRequired; 1171 memset(&items, 0, sizeof(items)); 1172 param.items = &items; 1173 1174 SceUserServiceUserId userId; 1175 int ret = sceUserServiceGetInitialUser(&userId); 1176 1177 param.items->userId = userId; 1178 1179 ret = sceSaveDataDialogInitialize(); 1180 ret = sceSaveDataDialogOpen(&param); 1181 1182 pClass->m_bSaveDataDialogRunning = true; 1183 pClass->m_eSaveIncompleteType = saveIncompleteType; 1184 1185 StorageManager.SetSaveDisabled(true); 1186 pClass->EnterSaveNotificationSection(); 1187} 1188 1189int CConsoleMinecraftApp::Callback_SaveGameIncompleteMessageBoxReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 1190{ 1191 CConsoleMinecraftApp* pClass = (CConsoleMinecraftApp*)pParam; 1192 1193 switch(result) 1194 { 1195 case C4JStorage::EMessage_ResultAccept: 1196 pClass->LeaveSaveNotificationSection(); 1197 StorageManager.SetSaveDisabled(false); 1198 StorageManager.ContinueIncompleteOperation(); 1199 break; 1200 case C4JStorage::EMessage_ResultDecline: 1201 case C4JStorage::EMessage_Cancelled: 1202 pClass->LeaveSaveNotificationSection(); 1203 // Set the global flag, so that we don't disable saving again once the message box is complete 1204 app.SetGameHostOption(eGameHostOption_DisableSaving, 1); 1205 StorageManager.CancelIncompleteOperation(); 1206 break; 1207 case C4JStorage::EMessage_ResultThirdOption: 1208 ui.NavigateToScene(iPad, eUIScene_InGameSaveManagementMenu, NULL, eUILayer_Error, eUIGroup_Fullscreen); 1209 break; 1210 } 1211 return 0; 1212} 1213 1214bool CConsoleMinecraftApp::CheckForEmptyStore(int iPad) 1215{ 1216 SonyCommerce::CategoryInfo *pCategories=app.GetCategoryInfo(); 1217 1218 bool bEmptyStore=true; 1219 if(pCategories!=NULL) 1220 { 1221 if(pCategories->countOfProducts>0) 1222 { 1223 bEmptyStore=false; 1224 } 1225 else 1226 { 1227 for(int i=0;i<pCategories->countOfSubCategories;i++) 1228 { 1229 std::vector<SonyCommerce::ProductInfo>*pvProductInfo=app.GetProductList(i); 1230 if(pvProductInfo->size()>0) 1231 { 1232 bEmptyStore=false; 1233 break; 1234 } 1235 } 1236 } 1237 } 1238 1239 if(bEmptyStore) 1240 { 1241 ProfileManager.DisplaySystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_EMPTY_STORE, iPad ); 1242 } 1243 1244 return bEmptyStore; 1245} 1246 1247void CConsoleMinecraftApp::ShowPatchAvailableError() 1248{ 1249 int32_t ret=sceErrorDialogInitialize(); 1250 if ( ret==SCE_OK ) 1251 { 1252 m_bPatchAvailableDialogRunning = true; 1253 1254 SceErrorDialogParam param; 1255 sceErrorDialogParamInitialize( &param ); 1256 // 4J-PB - We want to display the option to get the patch now 1257 param.errorCode = SCE_NP_ERROR_LATEST_PATCH_PKG_DOWNLOADED; 1258 ret = sceUserServiceGetInitialUser( &param.userId ); 1259 if ( ret == SCE_OK ) 1260 { 1261 ret=sceErrorDialogOpen( &param ); 1262 } 1263 } 1264} 1265 1266void CConsoleMinecraftApp::PatchAvailableDialogTick() 1267{ 1268 if(m_bPatchAvailableDialogRunning) 1269 { 1270 SceErrorDialogStatus stat = sceErrorDialogUpdateStatus(); 1271 if( stat == SCE_ERROR_DIALOG_STATUS_FINISHED ) 1272 { 1273 sceErrorDialogTerminate(); 1274 1275 UINT uiIDA[1]; 1276 uiIDA[0]=IDS_PRO_NOTONLINE_DECLINE; 1277 ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION_PATCH_AVAILABLE, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL, app.GetStringTable()); 1278 m_bPatchAvailableDialogRunning=false; 1279 } 1280 } 1281}