the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 1838 lines 60 kB view raw
1#include "stdafx.h" 2#include "UI.h" 3#include "UIScene_LoadMenu.h" 4#include "..\..\Minecraft.h" 5#include "..\..\TexturePackRepository.h" 6#include "..\..\Options.h" 7#include "..\..\MinecraftServer.h" 8#include "..\..\..\Minecraft.World\LevelSettings.h" 9#include "..\..\..\Minecraft.World\StringHelpers.h" 10#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) 11#include "Common\Network\Sony\SonyHttp.h" 12#endif 13#include "..\..\DLCTexturePack.h" 14#if defined(__ORBIS__) || defined(__PSVITA__) 15#include <ces.h> 16#endif 17 18#define GAME_CREATE_ONLINE_TIMER_ID 0 19#define GAME_CREATE_ONLINE_TIMER_TIME 100 20// 4J-PB - Only Xbox will not have trial DLC patched into the game 21#ifdef _XBOX 22#define CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID 1 23#define CHECKFORAVAILABLETEXTUREPACKS_TIMER_TIME 50 24#endif 25 26int UIScene_LoadMenu::m_iDifficultyTitleSettingA[4]= 27{ 28 IDS_DIFFICULTY_TITLE_PEACEFUL, 29 IDS_DIFFICULTY_TITLE_EASY, 30 IDS_DIFFICULTY_TITLE_NORMAL, 31 IDS_DIFFICULTY_TITLE_HARD 32}; 33 34int UIScene_LoadMenu::LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes) 35{ 36 UIScene_LoadMenu *pClass= (UIScene_LoadMenu *)ui.GetSceneFromCallbackId((size_t)lpParam); 37 38 if(pClass) 39 { 40 app.DebugPrintf("Received data for a thumbnail\n"); 41 42 if(pbThumbnail && dwThumbnailBytes) 43 { 44 pClass->registerSubstitutionTexture(pClass->m_thumbnailName,pbThumbnail,dwThumbnailBytes); 45 46 pClass->m_pbThumbnailData = pbThumbnail; 47 pClass->m_uiThumbnailSize = dwThumbnailBytes; 48 pClass->m_bSaveThumbnailReady = true; 49 } 50 else 51 { 52 app.DebugPrintf("Thumbnail data is NULL, or has size 0\n"); 53 pClass->m_bThumbnailGetFailed = true; 54 } 55 pClass->m_bRetrievingSaveThumbnail = false; 56 } 57 58 return 0; 59} 60 61UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void *initData, UILayer *parentLayer) : IUIScene_StartGame(iPad, parentLayer) 62{ 63 // Setup all the Iggy references we need for this scene 64 initialiseMovie(); 65 66 LoadMenuInitData *params = (LoadMenuInitData *)initData; 67 68 m_labelGameName.init(app.GetString(IDS_WORLD_NAME)); 69 m_labelSeed.init(L""); 70 m_labelCreatedMode.init(app.GetString(IDS_CREATED_IN_SURVIVAL)); 71 72 m_buttonGamemode.init(app.GetString(IDS_GAMEMODE_SURVIVAL),eControl_GameMode); 73 m_buttonMoreOptions.init(app.GetString(IDS_MORE_OPTIONS),eControl_MoreOptions); 74 m_buttonLoadWorld.init(app.GetString(IDS_LOAD),eControl_LoadWorld); 75 m_texturePackList.init(app.GetString(IDS_DLC_MENU_TEXTUREPACKS), eControl_TexturePackList); 76 77 m_labelTexturePackName.init(L""); 78 m_labelTexturePackDescription.init(L""); 79 80 m_CurrentDifficulty=app.GetGameSettings(m_iPad,eGameSetting_Difficulty); 81 WCHAR TempString[256]; 82 swprintf( (WCHAR *)TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[app.GetGameSettings(m_iPad,eGameSetting_Difficulty)])); 83 m_sliderDifficulty.init(TempString,eControl_Difficulty,0,3,app.GetGameSettings(m_iPad,eGameSetting_Difficulty)); 84 85 m_MoreOptionsParams.bGenerateOptions=FALSE; 86 m_MoreOptionsParams.bPVP = TRUE; 87 m_MoreOptionsParams.bTrust = TRUE; 88 m_MoreOptionsParams.bFireSpreads = TRUE; 89 m_MoreOptionsParams.bHostPrivileges = FALSE; 90 m_MoreOptionsParams.bTNT = TRUE; 91 m_MoreOptionsParams.iPad = iPad; 92 93 m_iSaveGameInfoIndex=params->iSaveGameInfoIndex; 94 m_levelGen = params->levelGen; 95 96 m_bGameModeCreative = false; 97 m_iGameModeId = GameType::SURVIVAL->getId(); 98 m_bHasBeenInCreative = false; 99 m_bIsSaveOwner = true; 100 101 m_bSaveThumbnailReady = false; 102 m_bRetrievingSaveThumbnail = true; 103 m_bShowTimer = false; 104 m_pDLCPack = NULL; 105 m_bAvailableTexturePacksChecked=false; 106 m_bRequestQuadrantSignin = false; 107 m_iTexturePacksNotInstalled=0; 108 m_bRebuildTouchBoxes = false; 109 m_bThumbnailGetFailed = false; 110 m_seed = 0; 111 m_bIsCorrupt = false; 112 113 m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad); 114 // 4J-PB - read the settings for the online flag. We'll only save this setting if the user changed it. 115 bool bGameSetting_Online=(app.GetGameSettings(m_iPad,eGameSetting_Online)!=0); 116 m_MoreOptionsParams.bOnlineSettingChangedBySystem=false; 117 118 // Set the text for friends of friends, and default to on 119 if( m_bMultiplayerAllowed) 120 { 121 m_MoreOptionsParams.bOnlineGame = bGameSetting_Online?TRUE:FALSE; 122 if(bGameSetting_Online) 123 { 124 m_MoreOptionsParams.bInviteOnly = (app.GetGameSettings(m_iPad,eGameSetting_InviteOnly)!=0)?TRUE:FALSE; 125 m_MoreOptionsParams.bAllowFriendsOfFriends = (app.GetGameSettings(m_iPad,eGameSetting_FriendsOfFriends)!=0)?TRUE:FALSE; 126 } 127 else 128 { 129 m_MoreOptionsParams.bInviteOnly = FALSE; 130 m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; 131 } 132 } 133 else 134 { 135 m_MoreOptionsParams.bOnlineGame = FALSE; 136 m_MoreOptionsParams.bInviteOnly = FALSE; 137 m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; 138 if(bGameSetting_Online) 139 { 140 // The profile settings say Online, but either the player is offline, or they are not allowed to play online 141 m_MoreOptionsParams.bOnlineSettingChangedBySystem=true; 142 } 143 } 144 145 // Set up online game checkbox 146 bool bOnlineGame = m_MoreOptionsParams.bOnlineGame; 147 m_checkboxOnline.SetEnable(true); 148 149 // 4J-PB - to stop an offline game being able to select the online flag 150 if(ProfileManager.IsSignedInLive(m_iPad) == false) 151 { 152 m_checkboxOnline.SetEnable(false); 153 } 154 155 if(m_MoreOptionsParams.bOnlineSettingChangedBySystem) 156 { 157 m_checkboxOnline.SetEnable(false); 158 bOnlineGame = false; 159 } 160 161 m_checkboxOnline.init(app.GetString(IDS_ONLINE_GAME), eControl_OnlineGame, bOnlineGame); 162 163 // Level gen 164 if(m_levelGen) 165 { 166 m_labelGameName.init(m_levelGen->getDisplayName()); 167 if(m_levelGen->requiresTexturePack()) 168 { 169 m_MoreOptionsParams.dwTexturePack = m_levelGen->getRequiredTexturePackId(); 170 171 m_texturePackList.setEnabled(false); 172 173 174 // retrieve the save icon from the texture pack, if there is one 175 TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack); 176 DWORD dwImageBytes; 177 PBYTE pbImageData = tp->getPackIcon(dwImageBytes); 178 179 if(dwImageBytes > 0 && pbImageData) 180 { 181 wchar_t textureName[64]; 182 swprintf(textureName,64,L"loadsave"); 183 registerSubstitutionTexture(textureName,pbImageData,dwImageBytes); 184 m_bitmapIcon.setTextureName( textureName ); 185 } 186 } 187 // Set this level as created in creative mode, so that people can't use the themed worlds as an easy way to get achievements 188 m_bHasBeenInCreative = m_levelGen->getLevelHasBeenInCreative(); 189 if(m_bHasBeenInCreative) 190 { 191 m_labelCreatedMode.setLabel( app.GetString(IDS_CREATED_IN_CREATIVE) ); 192 } 193 else 194 { 195 m_labelCreatedMode.setLabel( app.GetString(IDS_CREATED_IN_SURVIVAL) ); 196 } 197 } 198 else 199 { 200 201#if defined(__PS3__) || defined(__ORBIS__)|| defined(_DURANGO) || defined (__PSVITA__) 202 // convert to utf16 203 uint16_t u16Message[MAX_SAVEFILENAME_LENGTH]; 204 size_t srclen,dstlen; 205 srclen=MAX_SAVEFILENAME_LENGTH; 206 dstlen=MAX_SAVEFILENAME_LENGTH; 207#ifdef __PS3__ 208 L10nResult lres= UTF8stoUTF16s((uint8_t *)params->saveDetails->UTF8SaveFilename,&srclen,u16Message,&dstlen); 209#elif defined(_DURANGO) 210 // Already utf16 on durango 211 memcpy(u16Message,params->saveDetails->UTF16SaveFilename, MAX_SAVEFILENAME_LENGTH); 212#else // __ORBIS__ 213 { 214 SceCesUcsContext Context; 215 sceCesUcsContextInit( &Context ); 216 uint32_t utf8Len, utf16Len; 217 sceCesUtf8StrToUtf16Str(&Context, (uint8_t *)params->saveDetails->UTF8SaveFilename, srclen, &utf8Len, u16Message, dstlen, &utf16Len); 218 } 219#endif 220 m_thumbnailName = (wchar_t *)u16Message; 221 if(params->saveDetails->pbThumbnailData) 222 { 223 m_pbThumbnailData = params->saveDetails->pbThumbnailData; 224 m_uiThumbnailSize = params->saveDetails->dwThumbnailSize; 225 m_bSaveThumbnailReady = true; 226 } 227 else 228 { 229 app.DebugPrintf("Requesting the save thumbnail\n"); 230 // set the save to load 231 PSAVE_DETAILS pSaveDetails=StorageManager.ReturnSavesInfo(); 232#ifdef _DURANGO 233 // On Durango, we have an extra flag possible with LoadSaveDataThumbnail, which if true will force the loading of this thumbnail even if the save data isn't sync'd from 234 // the cloud at this stage. This could mean that there could be a pretty large delay before the callback happens, in this case. 235 C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveDataThumbnail(&pSaveDetails->SaveInfoA[(int)m_iSaveGameInfoIndex],&LoadSaveDataThumbnailReturned,(LPVOID)GetCallbackUniqueId(),true); 236#else 237 C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveDataThumbnail(&pSaveDetails->SaveInfoA[(int)m_iSaveGameInfoIndex],&LoadSaveDataThumbnailReturned,(LPVOID)GetCallbackUniqueId()); 238#endif 239 m_bShowTimer = true; 240 } 241#if defined(_DURANGO) 242 m_labelGameName.init(params->saveDetails->UTF16SaveName); 243#else 244 wchar_t wSaveName[128]; 245 ZeroMemory(wSaveName, 128 * sizeof(wchar_t) ); 246 mbstowcs(wSaveName, params->saveDetails->UTF8SaveName, strlen(params->saveDetails->UTF8SaveName)+1); // plus null 247 m_labelGameName.init(wSaveName); 248#endif 249#endif 250 } 251 252 TelemetryManager->RecordMenuShown(m_iPad, eUIScene_LoadMenu, 0); 253 m_iTexturePacksNotInstalled=0; 254 255 // 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 256 if(app.StartInstallDLCProcess(m_iPad)==true) 257 { 258 // not doing a mount, so enable input 259 m_bIgnoreInput=true; 260 } 261 else 262 { 263 m_bIgnoreInput = false; 264 265 Minecraft *pMinecraft = Minecraft::GetInstance(); 266 int texturePacksCount = pMinecraft->skins->getTexturePackCount(); 267 for(unsigned int i = 0; i < texturePacksCount; ++i) 268 { 269 TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i); 270 271 DWORD dwImageBytes; 272 PBYTE pbImageData = tp->getPackIcon(dwImageBytes); 273 274 if(dwImageBytes > 0 && pbImageData) 275 { 276 wchar_t imageName[64]; 277 swprintf(imageName,64,L"tpack%08x",tp->getId()); 278 registerSubstitutionTexture(imageName, pbImageData, dwImageBytes); 279 m_texturePackList.addPack(i,imageName); 280 } 281 } 282 m_currentTexturePackIndex = pMinecraft->skins->getTexturePackIndex(m_MoreOptionsParams.dwTexturePack); 283 UpdateTexturePackDescription(m_currentTexturePackIndex); 284 m_texturePackList.selectSlot(m_currentTexturePackIndex); 285 286 // 4J-PB - Only Xbox will not have trial DLC patched into the game 287#ifdef _XBOX 288 // 4J-PB - there may be texture packs we don't have, so use the info from TMS for this 289 290 // 4J-PB - Any texture packs available that we don't have installed? 291#if defined(__PS3__) || defined(__ORBIS__) 292 if(!m_bAvailableTexturePacksChecked && app.GetCommerceProductListRetrieved()&& app.GetCommerceProductListInfoRetrieved()) 293#else 294 if(!m_bAvailableTexturePacksChecked) 295#endif 296 { 297 DLC_INFO *pDLCInfo=NULL; 298 299 // first pass - look to see if there are any that are not in the list 300 bool bTexturePackAlreadyListed; 301 bool bNeedToGetTPD=false; 302 303 for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i) 304 { 305 bTexturePackAlreadyListed=false; 306#if defined(__PS3__) || defined(__ORBIS__) 307 char *pchName=app.GetDLCInfoTextures(i); 308 pDLCInfo=app.GetDLCInfo(pchName); 309#else 310 ULONGLONG ull=app.GetDLCInfoTexturesFullOffer(i); 311 pDLCInfo=app.GetDLCInfoForFullOfferID(ull); 312#endif 313 314 for(unsigned int i = 0; i < texturePacksCount; ++i) 315 { 316 TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i); 317 if(pDLCInfo && pDLCInfo->iConfig==tp->getDLCParentPackId()) 318 { 319 bTexturePackAlreadyListed=true; 320 } 321 } 322 if(bTexturePackAlreadyListed==false) 323 { 324 // some missing 325 bNeedToGetTPD=true; 326 327 m_iTexturePacksNotInstalled++; 328 } 329 } 330 331 if(bNeedToGetTPD==true) 332 { 333 // add a TMS request for them 334 app.DebugPrintf("+++ Adding TMSPP request for texture pack data\n"); 335 app.AddTMSPPFileTypeRequest(e_DLC_TexturePackData); 336 m_iConfigA= new int [m_iTexturePacksNotInstalled]; 337 m_iTexturePacksNotInstalled=0; 338 339 for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i) 340 { 341 bTexturePackAlreadyListed=false; 342#if defined(__PS3__) || defined(__ORBIS__) 343 char *pchName=app.GetDLCInfoTextures(i); 344 pDLCInfo=app.GetDLCInfo(pchName); 345#else 346 ULONGLONG ull=app.GetDLCInfoTexturesFullOffer(i); 347 pDLCInfo=app.GetDLCInfoForFullOfferID(ull); 348#endif 349 350 if(pDLCInfo) 351 { 352 for(unsigned int i = 0; i < texturePacksCount; ++i) 353 { 354 TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i); 355 if(pDLCInfo && pDLCInfo->iConfig==tp->getDLCParentPackId()) 356 { 357 bTexturePackAlreadyListed=true; 358 } 359 } 360 if(bTexturePackAlreadyListed==false) 361 { 362 m_iConfigA[m_iTexturePacksNotInstalled++]=pDLCInfo->iConfig; 363 } 364 } 365 } 366 } 367 } 368#endif 369 } 370 371#ifdef _XBOX 372 addTimer(CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID,CHECKFORAVAILABLETEXTUREPACKS_TIMER_TIME); 373#endif 374 375 if(params) delete params; 376 addTimer(GAME_CREATE_ONLINE_TIMER_ID,GAME_CREATE_ONLINE_TIMER_TIME); 377} 378 379void UIScene_LoadMenu::updateTooltips() 380{ 381 ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK, -1, -1); 382} 383 384void UIScene_LoadMenu::updateComponents() 385{ 386 m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,true); 387 388 if(RenderManager.IsWidescreen()) 389 { 390 m_parentLayer->showComponent(m_iPad,eUIComponent_Logo,true); 391 } 392 else 393 { 394 m_parentLayer->showComponent(m_iPad,eUIComponent_Logo,false); 395 } 396} 397 398wstring UIScene_LoadMenu::getMoviePath() 399{ 400 return L"LoadMenu"; 401} 402 403UIControl* UIScene_LoadMenu::GetMainPanel() 404{ 405 return &m_controlMainPanel; 406} 407 408void UIScene_LoadMenu::tick() 409{ 410 if(m_bShowTimer) 411 { 412 m_bShowTimer = false; 413 ui.NavigateToScene(m_iPad, eUIScene_Timer); 414 } 415 416 if( m_bThumbnailGetFailed ) 417 { 418 // On Durango, this can happen if a save is still not been synchronised (user cancelled, or some error). Return back to give them a choice to pick another save. 419 ui.NavigateBack(m_iPad, false, eUIScene_LoadOrJoinMenu); 420 return; 421 } 422 423 if( m_bSaveThumbnailReady ) 424 { 425 m_bSaveThumbnailReady = false; 426 427 m_bitmapIcon.setTextureName( m_thumbnailName.c_str() ); 428 429 // retrieve the seed value from the image metadata 430 bool bHostOptionsRead = false; 431 unsigned int uiHostOptions = 0; 432 433 char szSeed[50]; 434 ZeroMemory(szSeed,50); 435 app.GetImageTextData(m_pbThumbnailData,m_uiThumbnailSize,(unsigned char *)&szSeed,uiHostOptions,bHostOptionsRead,m_MoreOptionsParams.dwTexturePack); 436 437#if defined(_XBOX_ONE) || defined(__ORBIS__) 438 sscanf_s(szSeed, "%I64d", &m_seed); 439#endif 440 441 // #ifdef _DEBUG 442 // // dump out the thumbnail 443 // HANDLE hThumbnail = CreateFile("GAME:\\thumbnail.png", GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, NULL); 444 // DWORD dwBytes; 445 // WriteFile(hThumbnail,pbImageData,dwImageBytes,&dwBytes,NULL); 446 // XCloseHandle(hThumbnail); 447 // #endif 448 449 if(szSeed[0]!=0) 450 { 451 WCHAR TempString[256]; 452 swprintf( (WCHAR *)TempString, 256, L"%ls: %hs", app.GetString( IDS_SEED ),szSeed); 453 m_labelSeed.setLabel(TempString); 454 } 455 else 456 { 457 m_labelSeed.setLabel(L""); 458 } 459 460 // Setup all the text and checkboxes to match what the game was saved with on 461 if(bHostOptionsRead) 462 { 463 m_MoreOptionsParams.bPVP = app.GetGameHostOption(uiHostOptions,eGameHostOption_PvP)>0?TRUE:FALSE; 464 m_MoreOptionsParams.bTrust = app.GetGameHostOption(uiHostOptions,eGameHostOption_TrustPlayers)>0?TRUE:FALSE; 465 m_MoreOptionsParams.bFireSpreads = app.GetGameHostOption(uiHostOptions,eGameHostOption_FireSpreads)>0?TRUE:FALSE; 466 m_MoreOptionsParams.bTNT = app.GetGameHostOption(uiHostOptions,eGameHostOption_TNT)>0?TRUE:FALSE; 467 m_MoreOptionsParams.bHostPrivileges = app.GetGameHostOption(uiHostOptions,eGameHostOption_CheatsEnabled)>0?TRUE:FALSE; 468 m_MoreOptionsParams.bDisableSaving = app.GetGameHostOption(uiHostOptions,eGameHostOption_DisableSaving)>0?TRUE:FALSE; 469 m_MoreOptionsParams.currentWorldSize = (EGameHostOptionWorldSize)app.GetGameHostOption(uiHostOptions,eGameHostOption_WorldSize); 470 m_MoreOptionsParams.newWorldSize = m_MoreOptionsParams.currentWorldSize; 471 472 m_MoreOptionsParams.bMobGriefing = app.GetGameHostOption(uiHostOptions, eGameHostOption_MobGriefing); 473 m_MoreOptionsParams.bKeepInventory = app.GetGameHostOption(uiHostOptions, eGameHostOption_KeepInventory); 474 m_MoreOptionsParams.bDoMobSpawning = app.GetGameHostOption(uiHostOptions, eGameHostOption_DoMobSpawning); 475 m_MoreOptionsParams.bDoMobLoot = app.GetGameHostOption(uiHostOptions, eGameHostOption_DoMobLoot); 476 m_MoreOptionsParams.bDoTileDrops = app.GetGameHostOption(uiHostOptions, eGameHostOption_DoTileDrops); 477 m_MoreOptionsParams.bNaturalRegeneration = app.GetGameHostOption(uiHostOptions, eGameHostOption_NaturalRegeneration); 478 m_MoreOptionsParams.bDoDaylightCycle = app.GetGameHostOption(uiHostOptions, eGameHostOption_DoDaylightCycle); 479 480 bool cheatsOn = m_MoreOptionsParams.bHostPrivileges; 481 if (!cheatsOn) 482 { 483 // Set defaults 484 m_MoreOptionsParams.bMobGriefing = true; 485 m_MoreOptionsParams.bKeepInventory = false; 486 m_MoreOptionsParams.bDoMobSpawning = true; 487 m_MoreOptionsParams.bDoDaylightCycle = true; 488 } 489 490 // turn off creative mode on the save 491 // #ifdef _DEBUG 492 // uiHostOptions&=~GAME_HOST_OPTION_BITMASK_BEENINCREATIVE; 493 // app.SetGameHostOption(eGameHostOption_HasBeenInCreative, 0); 494 // #endif 495 496 if(app.GetGameHostOption(uiHostOptions,eGameHostOption_WasntSaveOwner)>0) 497 { 498 m_bIsSaveOwner = false; 499 } 500 501 m_bHasBeenInCreative = app.GetGameHostOption(uiHostOptions,eGameHostOption_HasBeenInCreative)>0; 502 if(app.GetGameHostOption(uiHostOptions,eGameHostOption_HasBeenInCreative)>0) 503 { 504 m_labelCreatedMode.setLabel( app.GetString(IDS_CREATED_IN_CREATIVE) ); 505 } 506 else 507 { 508 m_labelCreatedMode.setLabel( app.GetString(IDS_CREATED_IN_SURVIVAL) ); 509 } 510 511 switch(app.GetGameHostOption(uiHostOptions,eGameHostOption_GameType)) 512 { 513 case 1: // Creative 514 m_buttonGamemode.setLabel(app.GetString(IDS_GAMEMODE_CREATIVE)); 515 m_bGameModeCreative=true; 516 m_iGameModeId = GameType::CREATIVE->getId(); 517 break; 518#ifdef _ADVENTURE_MODE_ENABLED 519 case 2: // Adventure 520 m_buttonGamemode.setLabel(app.GetString(IDS_GAMEMODE_ADVENTURE)); 521 m_bGameModeCreative=false; 522 m_iGameModeId = GameType::ADVENTURE->getId(); 523 break; 524#endif 525 case 0: // Survival 526 default: 527 m_buttonGamemode.setLabel(app.GetString(IDS_GAMEMODE_SURVIVAL)); 528 m_bGameModeCreative=false; 529 m_iGameModeId = GameType::SURVIVAL->getId(); 530 break; 531 }; 532 533 bool bGameSetting_Online=(app.GetGameSettings(m_iPad,eGameSetting_Online)!=0); 534 if(app.GetGameHostOption(uiHostOptions,eGameHostOption_FriendsOfFriends) && !(m_bMultiplayerAllowed && bGameSetting_Online)) 535 { 536 m_MoreOptionsParams.bAllowFriendsOfFriends = TRUE; 537 } 538 } 539 540 Minecraft *pMinecraft = Minecraft::GetInstance(); 541 m_currentTexturePackIndex = pMinecraft->skins->getTexturePackIndex(m_MoreOptionsParams.dwTexturePack); 542 543 UpdateTexturePackDescription(m_currentTexturePackIndex); 544 545 m_texturePackList.selectSlot(m_currentTexturePackIndex); 546 547 //m_labelGameName.setLabel(m_XContentData.szDisplayName); 548 549 ui.NavigateBack(m_iPad, false, getSceneType() ); 550 } 551 552 if(m_iSetTexturePackDescription >= 0 ) 553 { 554 UpdateTexturePackDescription( m_iSetTexturePackDescription ); 555 m_iSetTexturePackDescription = -1; 556 } 557 if(m_bShowTexturePackDescription) 558 { 559 slideLeft(); 560 m_texturePackDescDisplayed = true; 561 562 m_bShowTexturePackDescription = false; 563 } 564 565 if(m_bRequestQuadrantSignin) 566 { 567 m_bRequestQuadrantSignin = false; 568 SignInInfo info; 569 info.Func = &UIScene_LoadMenu::StartGame_SignInReturned; 570 info.lpParam = this; 571 info.requireOnline = m_MoreOptionsParams.bOnlineGame; 572 ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_QuadrantSignin,&info); 573 } 574 575#ifdef __ORBIS__ 576 // check the status of the PSPlus common dialog 577 switch (sceNpCommerceDialogUpdateStatus()) 578 { 579 case SCE_COMMON_DIALOG_STATUS_FINISHED: 580 { 581 SceNpCommerceDialogResult Result; 582 sceNpCommerceDialogGetResult(&Result); 583 sceNpCommerceDialogTerminate(); 584 585 if(Result.authorized) 586 { 587 ProfileManager.PsPlusUpdate(ProfileManager.GetPrimaryPad(), &Result); 588 // they just became a PSPlus member 589 LoadDataComplete(this); 590 } 591 else 592 { 593 // continue offline? 594 UINT uiIDA[1]; 595 uiIDA[0]=IDS_PRO_NOTONLINE_DECLINE; 596 597 // Give the player a warning about the texture pack missing 598 ui.RequestAlertMessage(IDS_PLAY_OFFLINE,IDS_NO_PLAYSTATIONPLUS, uiIDA, 1, ProfileManager.GetPrimaryPad(),&UIScene_LoadMenu::ContinueOffline,this); 599 } 600 } 601 break; 602 default: 603 break; 604 } 605#endif 606 607 UIScene::tick(); 608} 609 610#ifdef __ORBIS__ 611int UIScene_LoadMenu::ContinueOffline(void *pParam,int iPad,C4JStorage::EMessageResult result) 612{ 613 UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; 614 615 // results switched for this dialog 616 if(result==C4JStorage::EMessage_ResultAccept) 617 { 618 pClass->m_MoreOptionsParams.bOnlineGame=false; 619 pClass->LoadDataComplete(pClass); 620 } 621 return 0; 622} 623 624#endif 625 626void UIScene_LoadMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) 627{ 628 if(m_bIgnoreInput) return; 629 630 ui.AnimateKeyPress(m_iPad, key, repeat, pressed, released); 631 632 switch(key) 633 { 634 case ACTION_MENU_CANCEL: 635 if(pressed) 636 { 637 app.SetCorruptSaveDeleted(false); 638 navigateBack(); 639 handled = true; 640 } 641 break; 642 case ACTION_MENU_OK: 643#ifdef __ORBIS__ 644 case ACTION_MENU_TOUCHPAD_PRESS: 645#endif 646 647 // 4J-JEV: Inform user why their game must be offline. 648#if defined _XBOX_ONE 649 if ( pressed && controlHasFocus(m_checkboxOnline.getId()) && !m_checkboxOnline.IsEnabled() ) 650 { 651 UINT uiIDA[1] = { IDS_CONFIRM_OK }; 652 ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, iPad); 653 } 654#endif 655 656 case ACTION_MENU_UP: 657 case ACTION_MENU_DOWN: 658 case ACTION_MENU_LEFT: 659 case ACTION_MENU_RIGHT: 660 case ACTION_MENU_OTHER_STICK_UP: 661 case ACTION_MENU_OTHER_STICK_DOWN: 662 sendInputToMovie(key, repeat, pressed, released); 663 664 bool bOnlineGame = m_checkboxOnline.IsChecked(); 665 if (m_MoreOptionsParams.bOnlineGame != bOnlineGame) 666 { 667 m_MoreOptionsParams.bOnlineGame = bOnlineGame; 668 669 if (!m_MoreOptionsParams.bOnlineGame) 670 { 671 m_MoreOptionsParams.bInviteOnly = false; 672 m_MoreOptionsParams.bAllowFriendsOfFriends = false; 673 } 674 } 675 676 handled = true; 677 break; 678 } 679} 680 681void UIScene_LoadMenu::handlePress(F64 controlId, F64 childId) 682{ 683 if(m_bIgnoreInput) return; 684 685 //CD - Added for audio 686 ui.PlayUISFX(eSFX_Press); 687 688 switch((int)controlId) 689 { 690 case eControl_GameMode: 691 switch(m_iGameModeId) 692 { 693 case 0: // Survival 694 m_buttonGamemode.setLabel(app.GetString(IDS_GAMEMODE_CREATIVE)); 695 m_iGameModeId = GameType::CREATIVE->getId(); 696 m_bGameModeCreative = true; 697 break; 698 case 1: // Creative 699#ifdef _ADVENTURE_MODE_ENABLED 700 m_buttonGamemode.setLabel(app.GetString(IDS_GAMEMODE_ADVENTURE)); 701 m_iGameModeId = GameType::ADVENTURE->getId(); 702 m_bGameModeCreative = false; 703 break; 704 case 2: // Adventure 705#endif 706 m_buttonGamemode.setLabel(app.GetString(IDS_GAMEMODE_SURVIVAL)); 707 m_iGameModeId = GameType::SURVIVAL->getId(); 708 m_bGameModeCreative = false; 709 break; 710 }; 711 break; 712 case eControl_MoreOptions: 713 ui.NavigateToScene(m_iPad, eUIScene_LaunchMoreOptionsMenu, &m_MoreOptionsParams); 714 break; 715 case eControl_TexturePackList: 716 { 717 UpdateCurrentTexturePack((int)childId); 718 } 719 break; 720 case eControl_LoadWorld: 721 { 722#ifdef _DURANGO 723 if(m_MoreOptionsParams.bOnlineGame) 724 { 725 m_bIgnoreInput = true; 726 ProfileManager.CheckMultiplayerPrivileges(m_iPad, true, &checkPrivilegeCallback, this); 727 } 728 else 729#endif 730 { 731 StartSharedLaunchFlow(); 732 } 733 } 734 break; 735 }; 736} 737 738#ifdef _DURANGO 739void UIScene_LoadMenu::checkPrivilegeCallback(LPVOID lpParam, bool hasPrivilege, int iPad) 740{ 741 UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)lpParam; 742 743 if(hasPrivilege) 744 { 745 pClass->StartSharedLaunchFlow(); 746 } 747 else 748 { 749 pClass->m_bIgnoreInput = false; 750 } 751} 752#endif 753 754void UIScene_LoadMenu::StartSharedLaunchFlow() 755{ 756 Minecraft *pMinecraft=Minecraft::GetInstance(); 757 // Check if we need to upsell the texture pack 758 if(m_MoreOptionsParams.dwTexturePack!=0) 759 { 760 // texture pack hasn't been set yet, so check what it will be 761 TexturePack *pTexturePack = pMinecraft->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack); 762 763 if(pTexturePack==NULL) 764 { 765#if TO_BE_IMPLEMENTED 766 // They've selected a texture pack they don't have yet 767 // upsell 768 CXuiCtrl4JList::LIST_ITEM_INFO ListItem; 769 // get the current index of the list, and then get the data 770 ListItem=m_pTexturePacksList->GetData(m_currentTexturePackIndex); 771 772 773 // upsell the texture pack 774 // tell sentient about the upsell of the full version of the skin pack 775 ULONGLONG ullOfferID_Full; 776 app.GetDLCFullOfferIDForPackID(m_MoreOptionsParams.dwTexturePack,&ullOfferID_Full); 777 778 TelemetryManager->RecordUpsellPresented(ProfileManager.GetPrimaryPad(), eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF); 779#endif 780 781 UINT uiIDA[2]; 782 783 uiIDA[0]=IDS_TEXTUREPACK_FULLVERSION; 784 //uiIDA[1]=IDS_TEXTURE_PACK_TRIALVERSION; 785 uiIDA[1]=IDS_CONFIRM_CANCEL; 786 787 // Give the player a warning about the texture pack missing 788 ui.RequestAlertMessage(IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&TexturePackDialogReturned,this); 789 return; 790 } 791 } 792 m_bIgnoreInput = true; 793 794 // if the profile data has been changed, then force a profile write (we save the online/invite/friends of friends settings) 795 // It seems we're allowed to break the 5 minute rule if it's the result of a user action 796 // check the checkboxes 797 798 // Only save the online setting if the user changed it - we may change it because we're offline, but don't want that saved 799 if(!m_MoreOptionsParams.bOnlineSettingChangedBySystem) 800 { 801 app.SetGameSettings(m_iPad,eGameSetting_Online,m_MoreOptionsParams.bOnlineGame?1:0); 802 } 803 app.SetGameSettings(m_iPad,eGameSetting_InviteOnly,m_MoreOptionsParams.bInviteOnly?1:0); 804 app.SetGameSettings(m_iPad,eGameSetting_FriendsOfFriends,m_MoreOptionsParams.bAllowFriendsOfFriends?1:0); 805 806 app.CheckGameSettingsChanged(true,m_iPad); 807 808 // Check that we have the rights to use a texture pack we have selected. 809 if(m_MoreOptionsParams.dwTexturePack!=0) 810 { 811 // texture pack hasn't been set yet, so check what it will be 812 TexturePack *pTexturePack = pMinecraft->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack); 813 DLCTexturePack *pDLCTexPack=(DLCTexturePack *)pTexturePack; 814 m_pDLCPack=pDLCTexPack->getDLCInfoParentPack(); 815 816 // do we have a license? 817 if(m_pDLCPack && !m_pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" )) 818 { 819 // no 820 821 // We need to allow people to use a trial texture pack if they are offline - we only need them online if they want to buy it. 822 823 /* 824 UINT uiIDA[1]; 825 uiIDA[0]=IDS_OK; 826 827 if(!ProfileManager.IsSignedInLive(m_iPad)) 828 { 829 // need to be signed in to live 830 ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1); 831 m_bIgnoreInput = false; 832 return; 833 } 834 else */ 835 { 836 // upsell 837#ifdef _XBOX 838 DLC_INFO *pDLCInfo = app.GetDLCInfoForTrialOfferID(m_pDLCPack->getPurchaseOfferId()); 839 ULONGLONG ullOfferID_Full; 840 841 if(pDLCInfo!=NULL) 842 { 843 ullOfferID_Full=pDLCInfo->ullOfferID_Full; 844 } 845 else 846 { 847 ullOfferID_Full=pTexturePack->getDLCPack()->getPurchaseOfferId(); 848 } 849 850 // tell sentient about the upsell of the full version of the texture pack 851 TelemetryManager->RecordUpsellPresented(m_iPad, eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF); 852#endif 853 854#if defined(_WINDOWS64) || defined(_DURANGO) 855 // trial pack warning 856 UINT uiIDA[1]; 857 uiIDA[0]=IDS_CONFIRM_OK; 858 ui.RequestAlertMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_USING_TRIAL_TEXUREPACK_WARNING, uiIDA, 1, m_iPad,&TrialTexturePackWarningReturned,this); 859#elif defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) 860 // trial pack warning 861 UINT uiIDA[2]; 862 uiIDA[0]=IDS_CONFIRM_OK; 863 uiIDA[1]=IDS_CONFIRM_CANCEL; 864 ui.RequestAlertMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_USING_TRIAL_TEXUREPACK_WARNING, uiIDA, 2, m_iPad,&TrialTexturePackWarningReturned,this); 865#endif 866 867#if defined _XBOX_ONE || defined __ORBIS__ 868 StorageManager.SetSaveDisabled(true); 869#endif 870 return; 871 } 872 } 873 } 874 app.SetGameHostOption(eGameHostOption_WasntSaveOwner, (!m_bIsSaveOwner)); 875 876#if defined _XBOX_ONE || defined __ORBIS__ 877 app.SetGameHostOption(eGameHostOption_DisableSaving, m_MoreOptionsParams.bDisableSaving?1:0); 878 StorageManager.SetSaveDisabled(m_MoreOptionsParams.bDisableSaving); 879 880 int newWorldSize = 0; 881 int newHellScale = 0; 882 switch(m_MoreOptionsParams.newWorldSize) 883 { 884 case e_worldSize_Unknown: 885 newWorldSize = 0; 886 newHellScale = 0; 887 break; 888 case e_worldSize_Classic: 889 newWorldSize = LEVEL_WIDTH_CLASSIC; 890 newHellScale = HELL_LEVEL_SCALE_CLASSIC; 891 break; 892 case e_worldSize_Small: 893 newWorldSize = LEVEL_WIDTH_SMALL; 894 newHellScale = HELL_LEVEL_SCALE_SMALL; 895 break; 896 case e_worldSize_Medium: 897 newWorldSize = LEVEL_WIDTH_MEDIUM; 898 newHellScale = HELL_LEVEL_SCALE_MEDIUM; 899 break; 900 case e_worldSize_Large: 901 newWorldSize = LEVEL_WIDTH_LARGE; 902 newHellScale = HELL_LEVEL_SCALE_LARGE; 903 break; 904 default: 905 assert(0); 906 break; 907 } 908 bool bUseMoat = !m_MoreOptionsParams.newWorldSizeOverwriteEdges; 909 app.SetGameNewWorldSize(newWorldSize, bUseMoat); 910 app.SetGameNewHellScale(newHellScale); 911 app.SetGameHostOption(eGameHostOption_WorldSize, m_MoreOptionsParams.newWorldSize); 912 913#endif 914 915#if TO_BE_IMPLEMENTED 916 // Reset the background downloading, in case we changed it by attempting to download a texture pack 917 XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_AUTO); 918#endif 919 920 // Check if they have the Reset Nether flag set, and confirm they want to do this 921 if(m_MoreOptionsParams.bResetNether==TRUE) 922 { 923 UINT uiIDA[2]; 924 uiIDA[0]=IDS_DONT_RESET_NETHER; 925 uiIDA[1]=IDS_RESET_NETHER; 926 927 ui.RequestAlertMessage(IDS_RESETNETHER_TITLE, IDS_RESETNETHER_TEXT, uiIDA, 2, m_iPad,&UIScene_LoadMenu::CheckResetNetherReturned,this); 928 } 929 else 930 { 931 LaunchGame(); 932 } 933} 934 935void UIScene_LoadMenu::handleSliderMove(F64 sliderId, F64 currentValue) 936{ 937 WCHAR TempString[256]; 938 int value = (int)currentValue; 939 switch((int)sliderId) 940 { 941 case eControl_Difficulty: 942 m_sliderDifficulty.handleSliderMove(value); 943 944 app.SetGameSettings(m_iPad,eGameSetting_Difficulty,value); 945 swprintf( (WCHAR *)TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[value])); 946 m_sliderDifficulty.setLabel(TempString); 947 break; 948 } 949} 950 951void UIScene_LoadMenu::handleTouchBoxRebuild() 952{ 953 m_bRebuildTouchBoxes = true; 954} 955 956 957void UIScene_LoadMenu::handleTimerComplete(int id) 958{ 959#ifdef __PSVITA__ 960 // we cannot rebuild touch boxes in an iggy callback because it requires further iggy calls 961 if(m_bRebuildTouchBoxes) 962 { 963 GetMainPanel()->UpdateControl(); 964 ui.TouchBoxRebuild(this); 965 m_bRebuildTouchBoxes = false; 966 } 967#endif 968 969 switch(id) 970 { 971 case GAME_CREATE_ONLINE_TIMER_ID: 972 { 973 bool bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad); 974 975 if(bMultiplayerAllowed != m_bMultiplayerAllowed) 976 { 977 if( bMultiplayerAllowed ) 978 { 979 bool bGameSetting_Online=(app.GetGameSettings(m_iPad,eGameSetting_Online)!=0); 980 m_MoreOptionsParams.bOnlineGame = bGameSetting_Online?TRUE:FALSE; 981 if(bGameSetting_Online) 982 { 983 m_MoreOptionsParams.bInviteOnly = (app.GetGameSettings(m_iPad,eGameSetting_InviteOnly)!=0)?TRUE:FALSE; 984 m_MoreOptionsParams.bAllowFriendsOfFriends = (app.GetGameSettings(m_iPad,eGameSetting_FriendsOfFriends)!=0)?TRUE:FALSE; 985 } 986 else 987 { 988 m_MoreOptionsParams.bInviteOnly = FALSE; 989 m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; 990 } 991 } 992 else 993 { 994 m_MoreOptionsParams.bOnlineGame = FALSE; 995 m_MoreOptionsParams.bInviteOnly = FALSE; 996 m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; 997 } 998 999 m_checkboxOnline.SetEnable(bMultiplayerAllowed); 1000 m_checkboxOnline.setChecked(m_MoreOptionsParams.bOnlineGame); 1001 1002 m_bMultiplayerAllowed = bMultiplayerAllowed; 1003 } 1004 } 1005 break; 1006 // 4J-PB - Only Xbox will not have trial DLC patched into the game 1007#ifdef _XBOX 1008 case CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID: 1009 { 1010 1011#if defined(__PS3__) || defined(__ORBIS__) 1012 for(int i=0;i<m_iTexturePacksNotInstalled;i++) 1013 { 1014 if(m_iConfigA[i]!=-1) 1015 { 1016 DLC_INFO *pDLCInfo=app.GetDLCInfoFromTPackID(m_iConfigA[i]); 1017 1018 if(pDLCInfo) 1019 { 1020 // retrieve the image - if we haven't already 1021 wstring textureName = filenametowstring(pDLCInfo->chImageURL); 1022 1023 if(hasRegisteredSubstitutionTexture(textureName)==false) 1024 { 1025 PBYTE pbImageData; 1026 int iImageDataBytes=0; 1027 SonyHttp::getDataFromURL(pDLCInfo->chImageURL,(void **)&pbImageData,&iImageDataBytes); 1028 1029 if(iImageDataBytes!=0) 1030 { 1031 // set the image 1032 registerSubstitutionTexture(textureName,pbImageData,iImageDataBytes,true); 1033 // add an item in 1034 m_texturePackList.addPack(m_iConfigA[i],textureName); 1035 m_iConfigA[i]=-1; 1036 } 1037 } 1038 else 1039 { 1040 // already have the image, so add an item in 1041 m_texturePackList.addPack(m_iConfigA[i],textureName); 1042 m_iConfigA[i]=-1; 1043 } 1044 } 1045 } 1046 } 1047 1048 bool bAllDone=true; 1049 for(int i=0;i<m_iTexturePacksNotInstalled;i++) 1050 { 1051 if(m_iConfigA[i]!=-1) 1052 { 1053 bAllDone = false; 1054 } 1055 } 1056 1057 if(bAllDone) 1058 { 1059 // kill this timer 1060 killTimer(CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID); 1061 } 1062#endif 1063 1064 } 1065 break; 1066#endif 1067 } 1068} 1069 1070void UIScene_LoadMenu::LaunchGame(void) 1071{ 1072 // stop the timer running that causes a check for new texture packs in TMS but not installed, since this will run all through the load game, and will crash if it tries to create an hbrush 1073#ifdef _XBOX 1074 killTimer(CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID); 1075#endif 1076 1077 if( (m_bGameModeCreative == true || m_bHasBeenInCreative) || m_MoreOptionsParams.bHostPrivileges == TRUE) 1078 { 1079 UINT uiIDA[2]; 1080 uiIDA[0]=IDS_CONFIRM_OK; 1081 uiIDA[1]=IDS_CONFIRM_CANCEL; 1082 if(m_bGameModeCreative == true || m_bHasBeenInCreative) 1083 { 1084 // 4J-PB - Need different text for Survival mode with a level that has been saved in Creative 1085 if(!m_bGameModeCreative) 1086 { 1087 ui.RequestAlertMessage(IDS_TITLE_START_GAME, IDS_CONFIRM_START_SAVEDINCREATIVE, uiIDA, 2, m_iPad,&UIScene_LoadMenu::ConfirmLoadReturned,this); 1088 } 1089 else // it's creative mode 1090 { 1091 // has it previously been saved in creative? 1092 if(m_bHasBeenInCreative) 1093 { 1094 // 4J-PB - We don't really need to tell the user this will have achievements disabled, since they already saved it in creative 1095 // and they got the warning then 1096 // inform them that leaderboard writes and achievements will be disabled 1097 //ui.RequestMessageBox(IDS_TITLE_START_GAME, IDS_CONFIRM_START_SAVEDINCREATIVE_CONTINUE, uiIDA, 1, m_iPad,&CScene_LoadGameSettings::ConfirmLoadReturned,this,app.GetStringTable()); 1098 1099 if(m_levelGen != NULL) 1100 { 1101 m_bIsCorrupt = false; 1102 LoadDataComplete(this); 1103 } 1104 else 1105 { 1106 1107 // set the save to load 1108 PSAVE_DETAILS pSaveDetails=StorageManager.ReturnSavesInfo(); 1109#ifndef _DURANGO 1110 app.DebugPrintf("Loading save s [%s]\n",pSaveDetails->SaveInfoA[(int)m_iSaveGameInfoIndex].UTF8SaveTitle,pSaveDetails->SaveInfoA[(int)m_iSaveGameInfoIndex].UTF8SaveFilename); 1111#endif 1112 C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveData(&pSaveDetails->SaveInfoA[(int)m_iSaveGameInfoIndex],&LoadSaveDataReturned,this); 1113 1114#if TO_BE_IMPLEMENTED 1115 if(eLoadStatus==C4JStorage::ELoadGame_DeviceRemoved) 1116 { 1117 // disable saving 1118 StorageManager.SetSaveDisabled(true); 1119 StorageManager.SetSaveDeviceSelected(m_iPad,false); 1120 UINT uiIDA[1]; 1121 uiIDA[0]=IDS_OK; 1122 ui.RequestErrorMessage(IDS_STORAGEDEVICEPROBLEM_TITLE, IDS_FAILED_TO_LOADSAVE_TEXT, uiIDA, 1, m_iPad,&CScene_LoadGameSettings::DeviceRemovedDialogReturned,this); 1123 1124 } 1125#endif 1126 } 1127 } 1128 else 1129 { 1130 // ask if they're sure they want to turn this into a creative map 1131 ui.RequestAlertMessage(IDS_TITLE_START_GAME, IDS_CONFIRM_START_CREATIVE, uiIDA, 2, m_iPad,&UIScene_LoadMenu::ConfirmLoadReturned,this); 1132 } 1133 } 1134 } 1135 else 1136 { 1137 ui.RequestAlertMessage(IDS_TITLE_START_GAME, IDS_CONFIRM_START_HOST_PRIVILEGES, uiIDA, 2, m_iPad,&UIScene_LoadMenu::ConfirmLoadReturned,this); 1138 } 1139 } 1140 else 1141 { 1142 if(m_levelGen != NULL) 1143 { 1144 m_bIsCorrupt = false; 1145 LoadDataComplete(this); 1146 } 1147 else 1148 { 1149 // set the save to load 1150 PSAVE_DETAILS pSaveDetails=StorageManager.ReturnSavesInfo(); 1151#ifndef _DURANGO 1152 app.DebugPrintf("Loading save %s [%s]\n",pSaveDetails->SaveInfoA[(int)m_iSaveGameInfoIndex].UTF8SaveTitle,pSaveDetails->SaveInfoA[(int)m_iSaveGameInfoIndex].UTF8SaveFilename); 1153#endif 1154 C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveData(&pSaveDetails->SaveInfoA[(int)m_iSaveGameInfoIndex],&LoadSaveDataReturned,this); 1155 1156#if TO_BE_IMPLEMENTED 1157 if(eLoadStatus==C4JStorage::ELoadGame_DeviceRemoved) 1158 { 1159 // disable saving 1160 StorageManager.SetSaveDisabled(true); 1161 StorageManager.SetSaveDeviceSelected(m_iPad,false); 1162 UINT uiIDA[1]; 1163 uiIDA[0]=IDS_OK; 1164 ui.RequestErrorMessage(IDS_STORAGEDEVICEPROBLEM_TITLE, IDS_FAILED_TO_LOADSAVE_TEXT, uiIDA, 1, m_iPad,&CScene_LoadGameSettings::DeviceRemovedDialogReturned,this); 1165 } 1166#endif 1167 } 1168 } 1169 //return 0; 1170} 1171 1172int UIScene_LoadMenu::CheckResetNetherReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 1173{ 1174 UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; 1175 1176 // results switched for this dialog 1177 if(result==C4JStorage::EMessage_ResultDecline) 1178 { 1179 // continue and reset the nether 1180 pClass->LaunchGame(); 1181 } 1182 else if(result==C4JStorage::EMessage_ResultAccept) 1183 { 1184 // turn off the reset nether and continue 1185 pClass->m_MoreOptionsParams.bResetNether=FALSE; 1186 pClass->LaunchGame(); 1187 } 1188 else 1189 { 1190 // else they chose cancel 1191 pClass->m_bIgnoreInput=false; 1192 } 1193 return 0; 1194} 1195 1196int UIScene_LoadMenu::ConfirmLoadReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 1197{ 1198 UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; 1199 1200 if(result==C4JStorage::EMessage_ResultAccept) 1201 { 1202 if(pClass->m_levelGen != NULL) 1203 { 1204 pClass->m_bIsCorrupt = false; 1205 pClass->LoadDataComplete(pClass); 1206 } 1207 else 1208 { 1209 // set the save to load 1210 PSAVE_DETAILS pSaveDetails=StorageManager.ReturnSavesInfo(); 1211#ifndef _DURANGO 1212 app.DebugPrintf("Loading save %s [%s]\n",pSaveDetails->SaveInfoA[(int)pClass->m_iSaveGameInfoIndex].UTF8SaveTitle,pSaveDetails->SaveInfoA[(int)pClass->m_iSaveGameInfoIndex].UTF8SaveFilename); 1213#endif 1214 C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveData(&pSaveDetails->SaveInfoA[(int)pClass->m_iSaveGameInfoIndex],&LoadSaveDataReturned,pClass); 1215 1216#if TO_BE_IMPLEMENTED 1217 if(eLoadStatus==C4JStorage::ELoadGame_DeviceRemoved) 1218 { 1219 // disable saving 1220 StorageManager.SetSaveDisabled(true); 1221 StorageManager.SetSaveDeviceSelected(m_iPad,false); 1222 UINT uiIDA[1]; 1223 uiIDA[0]=IDS_OK; 1224 ui.RequestErrorMessage(IDS_STORAGEDEVICEPROBLEM_TITLE, IDS_FAILED_TO_LOADSAVE_TEXT, uiIDA, 1, m_iPad,&CScene_LoadGameSettings::DeviceRemovedDialogReturned,this); 1225 } 1226#endif 1227 } 1228 } 1229 else 1230 { 1231 pClass->m_bIgnoreInput=false; 1232 } 1233 return 0; 1234} 1235 1236int UIScene_LoadMenu::LoadDataComplete(void *pParam) 1237{ 1238 UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; 1239 1240 if(!pClass->m_bIsCorrupt) 1241 { 1242 int iPrimaryPad = ProfileManager.GetPrimaryPad(); 1243 bool isSignedInLive = true; 1244 bool isOnlineGame = pClass->m_MoreOptionsParams.bOnlineGame; 1245 int iPadNotSignedInLive = -1; 1246 bool isLocalMultiplayerAvailable = app.IsLocalMultiplayerAvailable(); 1247 1248 for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) 1249 { 1250 if (ProfileManager.IsSignedIn(i) && ((i == iPrimaryPad) || isLocalMultiplayerAvailable)) 1251 { 1252 if (isSignedInLive && !ProfileManager.IsSignedInLive(i)) 1253 { 1254 // Record the first non signed in live pad 1255 iPadNotSignedInLive = i; 1256 } 1257 1258 isSignedInLive = isSignedInLive && ProfileManager.IsSignedInLive(i); 1259 } 1260 } 1261 1262 // If this is an online game but not all players are signed in to Live, stop! 1263 if (isOnlineGame && !isSignedInLive) 1264 { 1265#ifdef __ORBIS__ 1266 assert(iPadNotSignedInLive != -1); 1267 // Check if PSN is unavailable because of age restriction 1268 int npAvailability = ProfileManager.getNPAvailability(iPadNotSignedInLive); 1269 if (npAvailability == SCE_NP_ERROR_AGE_RESTRICTION) 1270 { 1271 pClass->m_bIgnoreInput = false; 1272 // 4J Stu - This is a bit messy and is due to the library incorrectly returning false for IsSignedInLive if the npAvailability isn't SCE_OK 1273 UINT uiIDA[1]; 1274 uiIDA[0]=IDS_OK; 1275 ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, iPadNotSignedInLive); 1276 } 1277 else 1278 { 1279 pClass->m_bIgnoreInput=true; 1280 UINT uiIDA[2]; 1281 uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; 1282 uiIDA[1] = IDS_CANCEL; 1283 ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, iPadNotSignedInLive, &UIScene_LoadMenu::MustSignInReturnedPSN, pClass); 1284 } 1285 return 0; 1286#else 1287 pClass->m_bIgnoreInput=false; 1288 UINT uiIDA[1]; 1289 uiIDA[0]=IDS_CONFIRM_OK; 1290 ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad()); 1291 return 0; 1292#endif 1293 } 1294 1295 // Check if user-created content is allowed, as we cannot play multiplayer if it's not 1296 bool noUGC = false; 1297 BOOL pccAllowed = TRUE; 1298 BOOL pccFriendsAllowed = TRUE; 1299 bool bContentRestricted = false; 1300 ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); 1301#if defined(__PS3__) || defined(__PSVITA__) 1302 if(isOnlineGame) 1303 { 1304 ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,NULL,&bContentRestricted,NULL); 1305 } 1306#endif 1307 1308#ifdef __ORBIS__ 1309 bool bPlayStationPlus=true; 1310 int iPadWithNoPlaystationPlus=0; 1311 for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) 1312 { 1313 if(ProfileManager.IsSignedIn(i) && ((i == iPrimaryPad) || isLocalMultiplayerAvailable)) 1314 { 1315 if(!ProfileManager.HasPlayStationPlus(i)) 1316 { 1317 bPlayStationPlus=false; 1318 iPadWithNoPlaystationPlus=i; 1319 break; 1320 } 1321 } 1322 } 1323#endif 1324 noUGC = !pccAllowed && !pccFriendsAllowed; 1325 1326 if(!isOnlineGame || !isLocalMultiplayerAvailable) 1327 { 1328 if(isOnlineGame && noUGC ) 1329 { 1330 pClass->setVisible( true ); 1331 1332 ui.RequestUGCMessageBox(); 1333 1334 pClass->m_bIgnoreInput=false; 1335 } 1336 else if(isOnlineGame && bContentRestricted ) 1337 { 1338 pClass->setVisible( true ); 1339 1340 ui.RequestContentRestrictedMessageBox(); 1341 pClass->m_bIgnoreInput=false; 1342 } 1343#ifdef __ORBIS__ 1344 else if(isOnlineGame && (bPlayStationPlus==false)) 1345 { 1346 pClass->setVisible( true ); 1347 pClass->m_bIgnoreInput=false; 1348 1349 if(ProfileManager.RequestingPlaystationPlus(iPadWithNoPlaystationPlus)) 1350 { 1351 // MGH - added this so we don't try and upsell when we don't know if the player has PS Plus yet (if it can't connect to the PS Plus server). 1352 UINT uiIDA[1]; 1353 uiIDA[0]=IDS_OK; 1354 ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL); 1355 return 0; 1356 } 1357 1358 // 4J-PB - we're not allowed to show the text Playstation Plus - have to call the upsell all the time! 1359 // upsell psplus 1360 int32_t iResult=sceNpCommerceDialogInitialize(); 1361 1362 SceNpCommerceDialogParam param; 1363 sceNpCommerceDialogParamInitialize(&param); 1364 param.mode=SCE_NP_COMMERCE_DIALOG_MODE_PLUS; 1365 param.features = SCE_NP_PLUS_FEATURE_REALTIME_MULTIPLAY; 1366 param.userId = ProfileManager.getUserID(iPadWithNoPlaystationPlus); 1367 1368 iResult=sceNpCommerceDialogOpen(&param); 1369 1370// UINT uiIDA[2]; 1371// uiIDA[0]=IDS_PLAY_OFFLINE; 1372// uiIDA[1]=IDS_PLAYSTATIONPLUS_SIGNUP; 1373// ui.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA,2,ProfileManager.GetPrimaryPad(),&UIScene_LoadMenu::PSPlusReturned,pClass, app.GetStringTable(),NULL,0,false); 1374 } 1375 1376#endif 1377 else 1378 { 1379 1380#if defined(__ORBIS__) || defined(__PSVITA__) 1381 if(isOnlineGame) 1382 { 1383 bool chatRestricted = false; 1384 ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,NULL,NULL); 1385 if(chatRestricted) 1386 { 1387 ProfileManager.DisplaySystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_PSN_CHAT_RESTRICTION, ProfileManager.GetPrimaryPad() ); 1388 } 1389 } 1390#endif 1391 DWORD dwLocalUsersMask = CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad()); 1392 1393 // No guest problems so we don't need to force a sign-in of players here 1394 StartGameFromSave(pClass, dwLocalUsersMask); 1395 } 1396 } 1397 else 1398 { 1399 // 4J-PB not sure why we aren't checking the content restriction for the main player here when multiple controllers are connected - adding now 1400 if(isOnlineGame && noUGC ) 1401 { 1402 pClass->setVisible( true ); 1403 ui.RequestUGCMessageBox(); 1404 pClass->m_bIgnoreInput=false; 1405 } 1406 else if(isOnlineGame && bContentRestricted ) 1407 { 1408 pClass->setVisible( true ); 1409 ui.RequestContentRestrictedMessageBox(); 1410 pClass->m_bIgnoreInput=false; 1411 } 1412#ifdef __ORBIS__ 1413 else if(bPlayStationPlus==false) 1414 { 1415 pClass->setVisible( true ); 1416 pClass->m_bIgnoreInput=false; 1417 1418 if(ProfileManager.RequestingPlaystationPlus(iPadWithNoPlaystationPlus)) 1419 { 1420 // MGH - added this so we don't try and upsell when we don't know if the player has PS Plus yet (if it can't connect to the PS Plus server). 1421 UINT uiIDA[1]; 1422 uiIDA[0]=IDS_OK; 1423 ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL); 1424 return 0; 1425 } 1426 1427 // 4J-PB - we're not allowed to show the text Playstation Plus - have to call the upsell all the time! 1428 // upsell psplus 1429 int32_t iResult=sceNpCommerceDialogInitialize(); 1430 1431 SceNpCommerceDialogParam param; 1432 sceNpCommerceDialogParamInitialize(&param); 1433 param.mode=SCE_NP_COMMERCE_DIALOG_MODE_PLUS; 1434 param.features = SCE_NP_PLUS_FEATURE_REALTIME_MULTIPLAY; 1435 param.userId = ProfileManager.getUserID(iPadWithNoPlaystationPlus); 1436 1437 iResult=sceNpCommerceDialogOpen(&param); 1438 1439// UINT uiIDA[2]; 1440// uiIDA[0]=IDS_PLAY_OFFLINE; 1441// uiIDA[1]=IDS_PLAYSTATIONPLUS_SIGNUP; 1442// ui.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA,2,ProfileManager.GetPrimaryPad(),&UIScene_LoadMenu::PSPlusReturned,pClass, app.GetStringTable(),NULL,0,false); 1443 } 1444#endif 1445 else 1446 { 1447#ifdef _WINDOWS64 1448 // On Windows64, IsSignedInLive() returns true as a stub but Xbox Live is 1449 // not available. Skip QuadrantSignin and proceed directly with local play. 1450 DWORD dwLocalUsersMask = CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad()); 1451 StartGameFromSave(pClass, dwLocalUsersMask); 1452#else 1453 pClass->m_bRequestQuadrantSignin = true; 1454#endif 1455 } 1456 } 1457 } 1458 else 1459 { 1460 // the save is corrupt! 1461 pClass->m_bIgnoreInput=false; 1462 1463 // give the option to delete the save 1464 UINT uiIDA[2]; 1465 uiIDA[0]=IDS_CONFIRM_CANCEL; 1466 uiIDA[1]=IDS_CONFIRM_OK; 1467 ui.RequestAlertMessage(IDS_CORRUPT_OR_DAMAGED_SAVE_TITLE, IDS_CORRUPT_OR_DAMAGED_SAVE_TEXT, uiIDA, 2, pClass->m_iPad,&UIScene_LoadMenu::DeleteSaveDialogReturned,pClass); 1468 1469 } 1470 1471 return 0; 1472} 1473 1474int UIScene_LoadMenu::LoadSaveDataReturned(void *pParam,bool bIsCorrupt, bool bIsOwner) 1475{ 1476 UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; 1477 1478 pClass->m_bIsCorrupt=bIsCorrupt; 1479 1480#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) 1481 if(app.GetGameHostOption(eGameHostOption_WasntSaveOwner)) 1482 { 1483 bIsOwner = false; 1484 } 1485#endif 1486 1487 if(bIsOwner) 1488 { 1489 LoadDataComplete(pClass); 1490 } 1491 else 1492 { 1493 // messagebox 1494 pClass->m_bIgnoreInput=false; 1495 1496#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) 1497 // show the message that trophies are disabled 1498 UINT uiIDA[1]; 1499 uiIDA[0]=IDS_CONFIRM_OK; 1500 ui.RequestErrorMessage(IDS_SAVEDATA_COPIED_TITLE, IDS_SAVEDATA_COPIED_TEXT, uiIDA, 1, 1501 pClass->m_iPad,&UIScene_LoadMenu::TrophyDialogReturned,pClass); 1502 app.SetGameHostOption(eGameHostOption_WasntSaveOwner, true); 1503#endif 1504 } 1505 1506 1507 return 0; 1508} 1509 1510int UIScene_LoadMenu::TrophyDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 1511{ 1512 UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; 1513 return LoadDataComplete(pClass); 1514} 1515 1516int UIScene_LoadMenu::DeleteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 1517{ 1518 UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; 1519 1520 // results switched for this dialog 1521 if(result==C4JStorage::EMessage_ResultDecline) 1522 { 1523 PSAVE_DETAILS pSaveDetails=StorageManager.ReturnSavesInfo(); 1524 StorageManager.DeleteSaveData(&pSaveDetails->SaveInfoA[(int)pClass->m_iSaveGameInfoIndex],UIScene_LoadMenu::DeleteSaveDataReturned,pClass); 1525 } 1526 else 1527 { 1528 pClass->m_bIgnoreInput=false; 1529 } 1530 return 0; 1531} 1532 1533int UIScene_LoadMenu::DeleteSaveDataReturned(void *pParam,bool bSuccess) 1534{ 1535 UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; 1536 1537 app.SetCorruptSaveDeleted(true); 1538 pClass->navigateBack(); 1539 1540 return 0; 1541} 1542 1543// 4J Stu - Shared functionality that is the same whether we needed a quadrant sign-in or not 1544void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, DWORD dwLocalUsersMask) 1545{ 1546 if(pClass->m_levelGen == NULL) 1547 { 1548 INT saveOrCheckpointId = 0; 1549 bool validSave = StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); 1550 TelemetryManager->RecordLevelResume(pClass->m_iPad, eSen_FriendOrMatch_Playing_With_Invited_Friends, eSen_CompeteOrCoop_Coop_and_Competitive, app.GetGameSettings(pClass->m_iPad,eGameSetting_Difficulty), app.GetLocalPlayerCount(), g_NetworkManager.GetOnlinePlayerCount(), saveOrCheckpointId); 1551 } 1552 else 1553 { 1554 StorageManager.ResetSaveData(); 1555 // Make our next save default to the name of the level 1556 StorageManager.SetSaveTitle(pClass->m_levelGen->getDefaultSaveName().c_str()); 1557 } 1558 1559 bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pClass->m_MoreOptionsParams.bOnlineGame; 1560#ifdef __PSVITA__ 1561 if(CGameNetworkManager::usingAdhocMode()) 1562 { 1563 if(SQRNetworkManager_AdHoc_Vita::GetAdhocStatus())// && pClass->m_MoreOptionsParams.bOnlineGame) 1564 isClientSide = true; 1565 } 1566#endif // __PSVITA__ 1567 1568 bool isPrivate = (app.GetGameSettings(pClass->m_iPad,eGameSetting_InviteOnly)>0)?true:false; 1569 1570 PSAVE_DETAILS pSaveDetails=StorageManager.ReturnSavesInfo(); 1571 1572 NetworkGameInitData *param = new NetworkGameInitData(); 1573 param->seed = pClass->m_seed; 1574 param->saveData = NULL; 1575 param->levelGen = pClass->m_levelGen; 1576 param->texturePackId = pClass->m_MoreOptionsParams.dwTexturePack; 1577 1578 Minecraft *pMinecraft = Minecraft::GetInstance(); 1579 pMinecraft->skins->selectTexturePackById(pClass->m_MoreOptionsParams.dwTexturePack); 1580 //pMinecraft->skins->updateUI(); 1581 1582 app.SetGameHostOption(eGameHostOption_Difficulty,Minecraft::GetInstance()->options->difficulty); 1583 app.SetGameHostOption(eGameHostOption_FriendsOfFriends,app.GetGameSettings(pClass->m_iPad,eGameSetting_FriendsOfFriends)); 1584 app.SetGameHostOption(eGameHostOption_Gamertags,app.GetGameSettings(pClass->m_iPad,eGameSetting_GamertagsVisible)); 1585 1586 app.SetGameHostOption(eGameHostOption_BedrockFog,app.GetGameSettings(pClass->m_iPad,eGameSetting_BedrockFog)?1:0); 1587 1588 app.SetGameHostOption(eGameHostOption_PvP,pClass->m_MoreOptionsParams.bPVP); 1589 app.SetGameHostOption(eGameHostOption_TrustPlayers,pClass->m_MoreOptionsParams.bTrust ); 1590 app.SetGameHostOption(eGameHostOption_FireSpreads,pClass->m_MoreOptionsParams.bFireSpreads ); 1591 app.SetGameHostOption(eGameHostOption_TNT,pClass->m_MoreOptionsParams.bTNT ); 1592 app.SetGameHostOption(eGameHostOption_HostCanFly,pClass->m_MoreOptionsParams.bHostPrivileges); 1593 app.SetGameHostOption(eGameHostOption_HostCanChangeHunger,pClass->m_MoreOptionsParams.bHostPrivileges); 1594 app.SetGameHostOption(eGameHostOption_HostCanBeInvisible,pClass->m_MoreOptionsParams.bHostPrivileges ); 1595 1596 app.SetGameHostOption(eGameHostOption_MobGriefing, pClass->m_MoreOptionsParams.bMobGriefing); 1597 app.SetGameHostOption(eGameHostOption_KeepInventory, pClass->m_MoreOptionsParams.bKeepInventory); 1598 app.SetGameHostOption(eGameHostOption_DoMobSpawning, pClass->m_MoreOptionsParams.bDoMobSpawning); 1599 app.SetGameHostOption(eGameHostOption_DoMobLoot, pClass->m_MoreOptionsParams.bDoMobLoot); 1600 app.SetGameHostOption(eGameHostOption_DoTileDrops, pClass->m_MoreOptionsParams.bDoTileDrops); 1601 app.SetGameHostOption(eGameHostOption_NaturalRegeneration, pClass->m_MoreOptionsParams.bNaturalRegeneration); 1602 app.SetGameHostOption(eGameHostOption_DoDaylightCycle, pClass->m_MoreOptionsParams.bDoDaylightCycle); 1603 1604#ifdef _LARGE_WORLDS 1605 app.SetGameHostOption(eGameHostOption_WorldSize, pClass->m_MoreOptionsParams.worldSize+1 ); // 0 is GAME_HOST_OPTION_WORLDSIZE_UNKNOWN 1606#endif 1607// app.SetGameNewWorldSize(64, true ); 1608// app.SetGameNewWorldSize(0, false ); 1609 1610 // flag if the user wants to reset the Nether to force a Fortress with netherwart etc. 1611 app.SetResetNether((pClass->m_MoreOptionsParams.bResetNether==TRUE)?true:false); 1612 // clear out the app's terrain features list 1613 app.ClearTerrainFeaturePosition(); 1614 1615 app.SetGameHostOption(eGameHostOption_GameType,pClass->m_iGameModeId ); 1616 1617 g_NetworkManager.HostGame(dwLocalUsersMask,isClientSide,isPrivate,MINECRAFT_NET_MAX_PLAYERS,0); 1618 1619 param->settings = app.GetGameHostOption( eGameHostOption_All ); 1620 1621#ifndef _XBOX 1622 g_NetworkManager.FakeLocalPlayerJoined(); 1623#endif 1624 1625 LoadingInputParams *loadingParams = new LoadingInputParams(); 1626 loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; 1627 loadingParams->lpParam = (LPVOID)param; 1628 1629 // Reset the autosave time 1630 app.SetAutosaveTimerTime(); 1631 1632 UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); 1633 completionData->bShowBackground=TRUE; 1634 completionData->bShowLogo=TRUE; 1635 completionData->type = e_ProgressCompletion_CloseAllPlayersUIScenes; 1636 completionData->iPad = DEFAULT_XUI_MENU_USER; 1637 loadingParams->completionData = completionData; 1638 1639 ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams); 1640} 1641 1642void UIScene_LoadMenu::checkStateAndStartGame() 1643{ 1644 // Check if they have the Reset Nether flag set, and confirm they want to do this 1645 if(m_MoreOptionsParams.bResetNether==TRUE) 1646 { 1647 UINT uiIDA[2]; 1648 uiIDA[0]=IDS_DONT_RESET_NETHER; 1649 uiIDA[1]=IDS_RESET_NETHER; 1650 1651 ui.RequestAlertMessage(IDS_RESETNETHER_TITLE, IDS_RESETNETHER_TEXT, uiIDA, 2, m_iPad,&UIScene_LoadMenu::CheckResetNetherReturned,this); 1652 } 1653 else 1654 { 1655 LaunchGame(); 1656 } 1657} 1658 1659int UIScene_LoadMenu::StartGame_SignInReturned(void *pParam,bool bContinue, int iPad) 1660{ 1661 UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; 1662 1663 if(bContinue==true) 1664 { 1665 // It's possible that the player has not signed in - they can back out 1666 if(ProfileManager.IsSignedIn(pClass->m_iPad)) 1667 { 1668 int primaryPad = ProfileManager.GetPrimaryPad(); 1669 bool noPrivileges = false; 1670 DWORD dwLocalUsersMask = 0; 1671 bool isSignedInLive = ProfileManager.IsSignedInLive(primaryPad); 1672 bool isOnlineGame = pClass->m_MoreOptionsParams.bOnlineGame; 1673 int iPadNotSignedInLive = -1; 1674 bool isLocalMultiplayerAvailable = app.IsLocalMultiplayerAvailable(); 1675 1676 for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) 1677 { 1678 if (ProfileManager.IsSignedIn(i) && ((i == primaryPad) || isLocalMultiplayerAvailable)) 1679 { 1680 if (isSignedInLive && !ProfileManager.IsSignedInLive(i)) 1681 { 1682 // Record the first non signed in live pad 1683 iPadNotSignedInLive = i; 1684 } 1685 1686 if( !ProfileManager.AllowedToPlayMultiplayer(i) ) noPrivileges = true; 1687 dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(i); 1688 isSignedInLive = isSignedInLive && ProfileManager.IsSignedInLive(i); 1689 } 1690 } 1691 1692 // If this is an online game but not all players are signed in to Live, stop! 1693 if (isOnlineGame && !isSignedInLive) 1694 { 1695#ifdef __ORBIS__ 1696 assert(iPadNotSignedInLive != -1); 1697 1698 // Check if PSN is unavailable because of age restriction 1699 int npAvailability = ProfileManager.getNPAvailability(iPadNotSignedInLive); 1700 if (npAvailability == SCE_NP_ERROR_AGE_RESTRICTION) 1701 { 1702 pClass->m_bIgnoreInput = false; 1703 // 4J Stu - This is a bit messy and is due to the library incorrectly returning false for IsSignedInLive if the npAvailability isn't SCE_OK 1704 UINT uiIDA[1]; 1705 uiIDA[0]=IDS_OK; 1706 ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, iPadNotSignedInLive); 1707 } 1708 else 1709 { 1710 pClass->m_bIgnoreInput=true; 1711 UINT uiIDA[2]; 1712 uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; 1713 uiIDA[1] = IDS_CANCEL; 1714 ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, iPadNotSignedInLive, &UIScene_LoadMenu::MustSignInReturnedPSN, pClass); 1715 } 1716 return 0; 1717#else 1718 pClass->m_bIgnoreInput=false; 1719 UINT uiIDA[1]; 1720 uiIDA[0]=IDS_CONFIRM_OK; 1721 ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad()); 1722 return 0; 1723#endif 1724 } 1725 1726 // Check if user-created content is allowed, as we cannot play multiplayer if it's not 1727 bool noUGC = false; 1728 BOOL pccAllowed = TRUE; 1729 BOOL pccFriendsAllowed = TRUE; 1730 1731 ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); 1732 if(!pccAllowed && !pccFriendsAllowed) noUGC = true; 1733 1734 if(isSignedInLive && isOnlineGame && (noPrivileges || noUGC) ) 1735 { 1736 if( noUGC ) 1737 { 1738 pClass->m_bIgnoreInput = false; 1739 pClass->setVisible( true ); 1740 UINT uiIDA[1]; 1741 uiIDA[0]=IDS_CONFIRM_OK; 1742 ui.RequestAlertMessage( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad()); 1743 } 1744 else 1745 { 1746 pClass->m_bIgnoreInput = false; 1747 pClass->setVisible( true ); 1748 UINT uiIDA[1]; 1749 uiIDA[0]=IDS_CONFIRM_OK; 1750 ui.RequestAlertMessage( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_HOST_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad()); 1751 } 1752 } 1753 else 1754 { 1755#if defined( __ORBIS__) || defined(__PSVITA__) 1756 if(isOnlineGame) 1757 { 1758 // show the chat restriction message for all users that it applies to 1759 for(unsigned int i = 0; i < XUSER_MAX_COUNT; i++) 1760 { 1761 if(ProfileManager.IsSignedInLive(i)) 1762 { 1763 bool chatRestricted = false; 1764 ProfileManager.GetChatAndContentRestrictions(i,false,&chatRestricted,NULL,NULL); 1765 if(chatRestricted) 1766 { 1767 ProfileManager.DisplaySystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_PSN_CHAT_RESTRICTION, i ); 1768 } 1769 } 1770 } 1771 } 1772#endif 1773 // This is NOT called from a storage manager thread, and is in fact called from the main thread in the Profile library tick. Therefore we use the main threads IntCache. 1774 StartGameFromSave(pClass, dwLocalUsersMask); 1775 } 1776 } 1777 } 1778 else 1779 { 1780 pClass->m_bIgnoreInput=false; 1781 } 1782 1783 return 0; 1784} 1785 1786void UIScene_LoadMenu::handleGainFocus(bool navBack) 1787{ 1788 if(navBack) 1789 { 1790 m_checkboxOnline.setChecked(m_MoreOptionsParams.bOnlineGame == TRUE); 1791 } 1792} 1793 1794#ifdef __ORBIS__ 1795int UIScene_LoadMenu::MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::EMessageResult result) 1796{ 1797 UIScene_LoadMenu* pClass = (UIScene_LoadMenu *)pParam; 1798 pClass->m_bIgnoreInput = false; 1799 1800 if(result==C4JStorage::EMessage_ResultAccept) 1801 { 1802 SQRNetworkManager_Orbis::AttemptPSNSignIn(&UIScene_LoadMenu::StartGame_SignInReturned, pClass, false, iPad); 1803 } 1804 1805 return 0; 1806} 1807 1808// int UIScene_LoadMenu::PSPlusReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 1809// { 1810// int32_t iResult; 1811// UIScene_LoadMenu *pClass = (UIScene_LoadMenu *)pParam; 1812// 1813// // continue offline, or upsell PS Plus? 1814// if(result==C4JStorage::EMessage_ResultDecline) 1815// { 1816// // upsell psplus 1817// iResult=sceNpCommerceDialogInitialize(); 1818// 1819// SceNpCommerceDialogParam param; 1820// sceNpCommerceDialogParamInitialize(&param); 1821// param.mode=SCE_NP_COMMERCE_DIALOG_MODE_PLUS; 1822// param.features = SCE_NP_PLUS_FEATURE_REALTIME_MULTIPLAY; 1823// param.userId = ProfileManager.getUserID(pClass->m_iPad); 1824// 1825// 1826// iResult=sceNpCommerceDialogOpen(&param); 1827// } 1828// else if(result==C4JStorage::EMessage_ResultAccept) 1829// { 1830// // continue offline 1831// pClass->m_MoreOptionsParams.bOnlineGame=false; 1832// pClass->LoadDataComplete(pClass); 1833// } 1834// 1835// pClass->m_bIgnoreInput=false; 1836// return 0; 1837// } 1838#endif