the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 1455 lines 48 kB view raw
1#include "stdafx.h" 2#include "UI.h" 3#include "UIScene_CreateWorldMenu.h" 4#include "..\..\MinecraftServer.h" 5#include "..\..\Minecraft.h" 6#include "..\..\Options.h" 7#include "..\..\TexturePackRepository.h" 8#include "..\..\TexturePack.h" 9#include "..\..\..\Minecraft.World\LevelSettings.h" 10#include "..\..\..\Minecraft.World\StringHelpers.h" 11#include "..\..\..\Minecraft.World\BiomeSource.h" 12#include "..\..\..\Minecraft.World\IntCache.h" 13#include "..\..\..\Minecraft.World\LevelType.h" 14#include "..\..\DLCTexturePack.h" 15 16#ifdef __PSVITA__ 17#include "PSVita\Network\SQRNetworkManager_AdHoc_Vita.h" 18#endif 19 20#ifdef _WINDOWS64 21 22#include <windows.h> 23#include "Xbox\Resource.h" 24#endif 25 26#define GAME_CREATE_ONLINE_TIMER_ID 0 27#define GAME_CREATE_ONLINE_TIMER_TIME 100 28 29int UIScene_CreateWorldMenu::m_iDifficultyTitleSettingA[4]= 30{ 31 IDS_DIFFICULTY_TITLE_PEACEFUL, 32 IDS_DIFFICULTY_TITLE_EASY, 33 IDS_DIFFICULTY_TITLE_NORMAL, 34 IDS_DIFFICULTY_TITLE_HARD 35}; 36 37UIScene_CreateWorldMenu::UIScene_CreateWorldMenu(int iPad, void *initData, UILayer *parentLayer) : IUIScene_StartGame(iPad, parentLayer) 38{ 39 // Setup all the Iggy references we need for this scene 40 initialiseMovie(); 41 42 m_worldName = app.GetString(IDS_DEFAULT_WORLD_NAME); 43 m_seed = L""; 44 45 m_iPad=iPad; 46 47 m_labelWorldName.init(app.GetString(IDS_WORLD_NAME)); 48 49 m_editWorldName.init(m_worldName, eControl_EditWorldName); 50 51 m_buttonGamemode.init(app.GetString(IDS_GAMEMODE_SURVIVAL),eControl_GameModeToggle); 52 m_buttonMoreOptions.init(app.GetString(IDS_MORE_OPTIONS),eControl_MoreOptions); 53 m_buttonCreateWorld.init(app.GetString(IDS_CREATE_NEW_WORLD),eControl_NewWorld); 54 55 m_texturePackList.init(app.GetString(IDS_DLC_MENU_TEXTUREPACKS), eControl_TexturePackList); 56 57 m_labelTexturePackName.init(L""); 58 m_labelTexturePackDescription.init(L""); 59 60 WCHAR TempString[256]; 61 swprintf( (WCHAR *)TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[app.GetGameSettings(m_iPad,eGameSetting_Difficulty)])); 62 m_sliderDifficulty.init(TempString,eControl_Difficulty,0,3,app.GetGameSettings(m_iPad,eGameSetting_Difficulty)); 63 64 m_MoreOptionsParams.bGenerateOptions=TRUE; 65 m_MoreOptionsParams.bStructures=TRUE; 66 m_MoreOptionsParams.bFlatWorld=FALSE; 67 m_MoreOptionsParams.bBonusChest=FALSE; 68 m_MoreOptionsParams.bPVP = TRUE; 69 m_MoreOptionsParams.bTrust = TRUE; 70 m_MoreOptionsParams.bFireSpreads = TRUE; 71 m_MoreOptionsParams.bHostPrivileges = FALSE; 72 m_MoreOptionsParams.bTNT = TRUE; 73 m_MoreOptionsParams.iPad = iPad; 74 75 m_MoreOptionsParams.bMobGriefing = true; 76 m_MoreOptionsParams.bKeepInventory = false; 77 m_MoreOptionsParams.bDoMobSpawning = true; 78 m_MoreOptionsParams.bDoMobLoot = true; 79 m_MoreOptionsParams.bDoTileDrops = true; 80 m_MoreOptionsParams.bNaturalRegeneration = true; 81 m_MoreOptionsParams.bDoDaylightCycle = true; 82 83 m_bGameModeCreative = false; 84 m_iGameModeId = GameType::SURVIVAL->getId(); 85 m_pDLCPack = NULL; 86 m_bRebuildTouchBoxes = false; 87 88 m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad); 89 // 4J-PB - read the settings for the online flag. We'll only save this setting if the user changed it. 90 bool bGameSetting_Online=(app.GetGameSettings(m_iPad,eGameSetting_Online)!=0); 91 m_MoreOptionsParams.bOnlineSettingChangedBySystem=false; 92 93 // 4J-PB - Removing this so that we can attempt to create an online game on PS3 when we are a restricted child account 94 // It'll fail when we choose create, but this matches the behaviour of load game, and lets the player know why they can't play online, 95 // instead of just greying out the online setting in the More Options 96 // #ifdef __PS3__ 97 // if(ProfileManager.IsSignedInLive( m_iPad )) 98 // { 99 // ProfileManager.GetChatAndContentRestrictions(m_iPad,true,&bChatRestricted,&bContentRestricted,NULL); 100 // } 101 // #endif 102 103 // Set the text for friends of friends, and default to on 104 if( m_bMultiplayerAllowed ) 105 { 106 m_MoreOptionsParams.bOnlineGame = bGameSetting_Online?TRUE:FALSE; 107 if(bGameSetting_Online) 108 { 109 m_MoreOptionsParams.bInviteOnly = (app.GetGameSettings(m_iPad,eGameSetting_InviteOnly)!=0)?TRUE:FALSE; 110 m_MoreOptionsParams.bAllowFriendsOfFriends = (app.GetGameSettings(m_iPad,eGameSetting_FriendsOfFriends)!=0)?TRUE:FALSE; 111 } 112 else 113 { 114 m_MoreOptionsParams.bInviteOnly = FALSE; 115 m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; 116 } 117 } 118 else 119 { 120 m_MoreOptionsParams.bOnlineGame = FALSE; 121 m_MoreOptionsParams.bInviteOnly = FALSE; 122 m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; 123 if(bGameSetting_Online) 124 { 125 // The profile settings say Online, but either the player is offline, or they are not allowed to play online 126 m_MoreOptionsParams.bOnlineSettingChangedBySystem=true; 127 } 128 } 129 130 // Set up online game checkbox 131 bool bOnlineGame = m_MoreOptionsParams.bOnlineGame; 132 m_checkboxOnline.SetEnable(true); 133 134 // 4J-PB - to stop an offline game being able to select the online flag 135 if(ProfileManager.IsSignedInLive(m_iPad) == false) 136 { 137 m_checkboxOnline.SetEnable(false); 138 } 139 140 if(m_MoreOptionsParams.bOnlineSettingChangedBySystem) 141 { 142 m_checkboxOnline.SetEnable(false); 143 bOnlineGame = false; 144 } 145 146 m_checkboxOnline.init(app.GetString(IDS_ONLINE_GAME), eControl_OnlineGame, bOnlineGame); 147 148 addTimer( GAME_CREATE_ONLINE_TIMER_ID,GAME_CREATE_ONLINE_TIMER_TIME ); 149#if TO_BE_IMPLEMENTED 150 XuiSetTimer(m_hObj,CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID,CHECKFORAVAILABLETEXTUREPACKS_TIMER_TIME); 151#endif 152 153 TelemetryManager->RecordMenuShown(m_iPad, eUIScene_CreateWorldMenu, 0); 154 155 // 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 156 if(app.StartInstallDLCProcess(m_iPad)==true) 157 { 158 // not doing a mount, so enable input 159 m_bIgnoreInput=true; 160 } 161 else 162 { 163 m_bIgnoreInput = false; 164 165 Minecraft *pMinecraft = Minecraft::GetInstance(); 166 int texturePacksCount = pMinecraft->skins->getTexturePackCount(); 167 for(unsigned int i = 0; i < texturePacksCount; ++i) 168 { 169 TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i); 170 171 DWORD dwImageBytes; 172 PBYTE pbImageData = tp->getPackIcon(dwImageBytes); 173 174 if(dwImageBytes > 0 && pbImageData) 175 { 176 wchar_t imageName[64]; 177 swprintf(imageName,64,L"tpack%08x",tp->getId()); 178 registerSubstitutionTexture(imageName, pbImageData, dwImageBytes); 179 m_texturePackList.addPack(i,imageName); 180 app.DebugPrintf("Adding texture pack %ls at %d\n",imageName,i); 181 } 182 } 183 184#if TO_BE_IMPLEMENTED 185 // 4J-PB - there may be texture packs we don't have, so use the info from TMS for this 186 187 DLC_INFO *pDLCInfo=NULL; 188 189 // first pass - look to see if there are any that are not in the list 190 bool bTexturePackAlreadyListed; 191 bool bNeedToGetTPD=false; 192 193 for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i) 194 { 195 bTexturePackAlreadyListed=false; 196 ULONGLONG ull=app.GetDLCInfoTexturesFullOffer(i); 197 pDLCInfo=app.GetDLCInfoForFullOfferID(ull); 198 for(unsigned int i = 0; i < texturePacksCount; ++i) 199 { 200 TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i); 201 if(pDLCInfo->iConfig==tp->getDLCParentPackId()) 202 { 203 bTexturePackAlreadyListed=true; 204 } 205 } 206 if(bTexturePackAlreadyListed==false) 207 { 208 // some missing 209 bNeedToGetTPD=true; 210 211 m_iTexturePacksNotInstalled++; 212 } 213 } 214 215 if(bNeedToGetTPD==true) 216 { 217 // add a TMS request for them 218 app.DebugPrintf("+++ Adding TMSPP request for texture pack data\n"); 219 app.AddTMSPPFileTypeRequest(e_DLC_TexturePackData); 220 m_iConfigA= new int [m_iTexturePacksNotInstalled]; 221 m_iTexturePacksNotInstalled=0; 222 223 for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i) 224 { 225 bTexturePackAlreadyListed=false; 226 ULONGLONG ull=app.GetDLCInfoTexturesFullOffer(i); 227 pDLCInfo=app.GetDLCInfoForFullOfferID(ull); 228 for(unsigned int i = 0; i < texturePacksCount; ++i) 229 { 230 TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i); 231 if(pDLCInfo->iConfig==tp->getDLCParentPackId()) 232 { 233 bTexturePackAlreadyListed=true; 234 } 235 } 236 if(bTexturePackAlreadyListed==false) 237 { 238 m_iConfigA[m_iTexturePacksNotInstalled++]=pDLCInfo->iConfig; 239 } 240 } 241 } 242#endif 243 244 UpdateTexturePackDescription(m_currentTexturePackIndex); 245 246 247 m_texturePackList.selectSlot(m_currentTexturePackIndex); 248 } 249} 250 251UIScene_CreateWorldMenu::~UIScene_CreateWorldMenu() 252{ 253} 254 255void UIScene_CreateWorldMenu::updateTooltips() 256{ 257 ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); 258} 259 260void UIScene_CreateWorldMenu::updateComponents() 261{ 262 m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,true); 263 m_parentLayer->showComponent(m_iPad,eUIComponent_Logo,false); 264} 265 266wstring UIScene_CreateWorldMenu::getMoviePath() 267{ 268 return L"CreateWorldMenu"; 269} 270 271UIControl* UIScene_CreateWorldMenu::GetMainPanel() 272{ 273 return &m_controlMainPanel; 274} 275 276void UIScene_CreateWorldMenu::handleDestroy() 277{ 278#ifdef __PSVITA__ 279 app.DebugPrintf("missing InputManager.DestroyKeyboard on Vita !!!!!!\n"); 280#endif 281 282 // shut down the keyboard if it is displayed 283#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO) 284 InputManager.DestroyKeyboard(); 285#endif 286} 287 288void UIScene_CreateWorldMenu::tick() 289{ 290 UIScene::tick(); 291 292 if(m_iSetTexturePackDescription >= 0 ) 293 { 294 UpdateTexturePackDescription( m_iSetTexturePackDescription ); 295 m_iSetTexturePackDescription = -1; 296 } 297 if(m_bShowTexturePackDescription) 298 { 299 slideLeft(); 300 m_texturePackDescDisplayed = true; 301 302 m_bShowTexturePackDescription = false; 303 } 304 305#ifdef __ORBIS__ 306 // check the status of the PSPlus common dialog 307 switch (sceNpCommerceDialogUpdateStatus()) 308 { 309 case SCE_COMMON_DIALOG_STATUS_FINISHED: 310 { 311 SceNpCommerceDialogResult Result; 312 sceNpCommerceDialogGetResult(&Result); 313 sceNpCommerceDialogTerminate(); 314 315 if(Result.authorized) 316 { 317 ProfileManager.PsPlusUpdate(ProfileManager.GetPrimaryPad(), &Result); 318 // they just became a PSPlus member 319 checkStateAndStartGame(); 320 } 321 else 322 { 323 // continue offline? 324 UINT uiIDA[1]; 325 uiIDA[0]=IDS_PRO_NOTONLINE_DECLINE; 326 327 // Give the player a warning about the texture pack missing 328 ui.RequestAlertMessage(IDS_PLAY_OFFLINE,IDS_NO_PLAYSTATIONPLUS, uiIDA, 1, ProfileManager.GetPrimaryPad(),&UIScene_CreateWorldMenu::ContinueOffline,dynamic_cast<UIScene_CreateWorldMenu*>(this)); 329 } 330 } 331 break; 332 default: 333 break; 334 } 335#endif 336} 337 338#ifdef __ORBIS__ 339int UIScene_CreateWorldMenu::ContinueOffline(void *pParam,int iPad,C4JStorage::EMessageResult result) 340{ 341 UIScene_CreateWorldMenu* pClass = (UIScene_CreateWorldMenu*)pParam; 342 343 // results switched for this dialog 344 if(result==C4JStorage::EMessage_ResultAccept) 345 { 346 pClass->m_MoreOptionsParams.bOnlineGame=false; 347 pClass->checkStateAndStartGame(); 348 } 349 return 0; 350} 351 352#endif 353 354void UIScene_CreateWorldMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) 355{ 356 if(m_bIgnoreInput) return; 357 358 ui.AnimateKeyPress(m_iPad, key, repeat, pressed, released); 359 360 switch(key) 361 { 362 case ACTION_MENU_CANCEL: 363 if(pressed) 364 { 365 navigateBack(); 366 handled = true; 367 } 368 break; 369 case ACTION_MENU_OK: 370#ifdef __ORBIS__ 371 case ACTION_MENU_TOUCHPAD_PRESS: 372#endif 373 374 // 4J-JEV: Inform user why their game must be offline. 375#if defined _XBOX_ONE 376 if ( pressed && controlHasFocus(m_checkboxOnline.getId()) && !m_checkboxOnline.IsEnabled() ) 377 { 378 UINT uiIDA[1] = { IDS_CONFIRM_OK }; 379 ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, iPad); 380 } 381#endif 382 383 case ACTION_MENU_UP: 384 case ACTION_MENU_DOWN: 385 case ACTION_MENU_LEFT: 386 case ACTION_MENU_RIGHT: 387 case ACTION_MENU_OTHER_STICK_UP: 388 case ACTION_MENU_OTHER_STICK_DOWN: 389 sendInputToMovie(key, repeat, pressed, released); 390 391 bool bOnlineGame = m_checkboxOnline.IsChecked(); 392 if (m_MoreOptionsParams.bOnlineGame != bOnlineGame) 393 { 394 m_MoreOptionsParams.bOnlineGame = bOnlineGame; 395 396 if (!m_MoreOptionsParams.bOnlineGame) 397 { 398 m_MoreOptionsParams.bInviteOnly = false; 399 m_MoreOptionsParams.bAllowFriendsOfFriends = false; 400 } 401 } 402 403 handled = true; 404 break; 405 } 406} 407 408void UIScene_CreateWorldMenu::handlePress(F64 controlId, F64 childId) 409{ 410 if(m_bIgnoreInput) return; 411 412 //CD - Added for audio 413 ui.PlayUISFX(eSFX_Press); 414 415 switch((int)controlId) 416 { 417 case eControl_EditWorldName: 418 { 419 m_bIgnoreInput=true; 420 InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD),m_editWorldName.getLabel(),(DWORD)0,25,&UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback,this,C_4JInput::EKeyboardMode_Default); 421 } 422 break; 423 case eControl_GameModeToggle: 424 switch(m_iGameModeId) 425 { 426 case 0: // Survival 427 m_buttonGamemode.setLabel(app.GetString(IDS_GAMEMODE_CREATIVE)); 428 m_iGameModeId = GameType::CREATIVE->getId(); 429 m_bGameModeCreative = true; 430 break; 431 case 1: // Creative 432 m_buttonGamemode.setLabel(app.GetString(IDS_GAMEMODE_SURVIVAL)); 433 m_iGameModeId = GameType::SURVIVAL->getId(); 434 m_bGameModeCreative = false; 435 break; 436 }; 437 break; 438 case eControl_MoreOptions: 439 ui.NavigateToScene(m_iPad, eUIScene_LaunchMoreOptionsMenu, &m_MoreOptionsParams); 440 break; 441 case eControl_TexturePackList: 442 { 443 UpdateCurrentTexturePack((int)childId); 444 } 445 break; 446 case eControl_NewWorld: 447 { 448#ifdef _DURANGO 449 if(m_MoreOptionsParams.bOnlineGame) 450 { 451 m_bIgnoreInput = true; 452 ProfileManager.CheckMultiplayerPrivileges(m_iPad, true, &checkPrivilegeCallback, this); 453 } 454 else 455#endif 456 { 457 StartSharedLaunchFlow(); 458 } 459 break; 460 } 461 } 462} 463 464#ifdef _DURANGO 465void UIScene_CreateWorldMenu::checkPrivilegeCallback(LPVOID lpParam, bool hasPrivilege, int iPad) 466{ 467 UIScene_CreateWorldMenu* pClass = (UIScene_CreateWorldMenu*)lpParam; 468 469 if(hasPrivilege) 470 { 471 pClass->StartSharedLaunchFlow(); 472 } 473 else 474 { 475 pClass->m_bIgnoreInput = false; 476 } 477} 478#endif 479 480void UIScene_CreateWorldMenu::StartSharedLaunchFlow() 481{ 482 Minecraft *pMinecraft=Minecraft::GetInstance(); 483 // Check if we need to upsell the texture pack 484 if(m_MoreOptionsParams.dwTexturePack!=0) 485 { 486 // texture pack hasn't been set yet, so check what it will be 487 TexturePack *pTexturePack = pMinecraft->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack); 488 489 if(pTexturePack==NULL) 490 { 491#if TO_BE_IMPLEMENTED 492 // They've selected a texture pack they don't have yet 493 // upsell 494 CXuiCtrl4JList::LIST_ITEM_INFO ListItem; 495 // get the current index of the list, and then get the data 496 ListItem=m_pTexturePacksList->GetData(m_currentTexturePackIndex); 497 498 499 // upsell the texture pack 500 // tell sentient about the upsell of the full version of the skin pack 501 ULONGLONG ullOfferID_Full; 502 app.GetDLCFullOfferIDForPackID(m_MoreOptionsParams.dwTexturePack,&ullOfferID_Full); 503 504 TelemetryManager->RecordUpsellPresented(ProfileManager.GetPrimaryPad(), eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF); 505#endif 506 507 UINT uiIDA[2]; 508 509 uiIDA[0]=IDS_TEXTUREPACK_FULLVERSION; 510 //uiIDA[1]=IDS_TEXTURE_PACK_TRIALVERSION; 511 uiIDA[1]=IDS_CONFIRM_CANCEL; 512 513 // Give the player a warning about the texture pack missing 514 ui.RequestAlertMessage(IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&TexturePackDialogReturned,this); 515 return; 516 } 517 } 518 m_bIgnoreInput = true; 519 520 // if the profile data has been changed, then force a profile write (we save the online/invite/friends of friends settings) 521 // It seems we're allowed to break the 5 minute rule if it's the result of a user action 522 // check the checkboxes 523 524 // Only save the online setting if the user changed it - we may change it because we're offline, but don't want that saved 525 if(!m_MoreOptionsParams.bOnlineSettingChangedBySystem) 526 { 527 app.SetGameSettings(m_iPad,eGameSetting_Online,m_MoreOptionsParams.bOnlineGame?1:0); 528 } 529 app.SetGameSettings(m_iPad,eGameSetting_InviteOnly,m_MoreOptionsParams.bInviteOnly?1:0); 530 app.SetGameSettings(m_iPad,eGameSetting_FriendsOfFriends,m_MoreOptionsParams.bAllowFriendsOfFriends?1:0); 531 532 app.CheckGameSettingsChanged(true,m_iPad); 533 534 // Check that we have the rights to use a texture pack we have selected. 535 if(m_MoreOptionsParams.dwTexturePack!=0) 536 { 537 // texture pack hasn't been set yet, so check what it will be 538 TexturePack *pTexturePack = pMinecraft->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack); 539 DLCTexturePack *pDLCTexPack=(DLCTexturePack *)pTexturePack; 540 m_pDLCPack=pDLCTexPack->getDLCInfoParentPack(); 541 542 // do we have a license? 543 if(m_pDLCPack && !m_pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" )) 544 { 545 // no 546 547 // 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. 548 549 /* 550 UINT uiIDA[1]; 551 uiIDA[0]=IDS_OK; 552 553 if(!ProfileManager.IsSignedInLive(m_iPad)) 554 { 555 // need to be signed in to live 556 ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1); 557 m_bIgnoreInput = false; 558 return; 559 } 560 else */ 561 { 562 // upsell 563#ifdef _XBOX 564 DLC_INFO *pDLCInfo = app.GetDLCInfoForTrialOfferID(m_pDLCPack->getPurchaseOfferId()); 565 ULONGLONG ullOfferID_Full; 566 567 if(pDLCInfo!=NULL) 568 { 569 ullOfferID_Full=pDLCInfo->ullOfferID_Full; 570 } 571 else 572 { 573 ullOfferID_Full=pTexturePack->getDLCPack()->getPurchaseOfferId(); 574 } 575 576 // tell sentient about the upsell of the full version of the texture pack 577 TelemetryManager->RecordUpsellPresented(m_iPad, eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF); 578#endif 579 580#if defined(_DURANGO) || defined(_WINDOWS64) 581 // trial pack warning 582 UINT uiIDA[1]; 583 uiIDA[0]=IDS_CONFIRM_OK; 584 ui.RequestAlertMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_USING_TRIAL_TEXUREPACK_WARNING, uiIDA, 1, m_iPad,&TrialTexturePackWarningReturned,this); 585#elif defined __PS3__ || defined __ORBIS__ || defined(__PSVITA__) 586 // trial pack warning 587 UINT uiIDA[2]; 588 uiIDA[0]=IDS_CONFIRM_OK; 589 uiIDA[1]=IDS_CONFIRM_CANCEL; 590 ui.RequestAlertMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_USING_TRIAL_TEXUREPACK_WARNING, uiIDA, 2, m_iPad,&TrialTexturePackWarningReturned,this); 591#endif 592 593#if defined _XBOX_ONE || defined __ORBIS__ 594 StorageManager.SetSaveDisabled(true); 595#endif 596 return; 597 } 598 } 599 } 600#if defined _XBOX_ONE || defined __ORBIS__ 601 app.SetGameHostOption(eGameHostOption_DisableSaving, m_MoreOptionsParams.bDisableSaving?1:0); 602 StorageManager.SetSaveDisabled(m_MoreOptionsParams.bDisableSaving); 603#endif 604 checkStateAndStartGame(); 605} 606 607void UIScene_CreateWorldMenu::handleSliderMove(F64 sliderId, F64 currentValue) 608{ 609 WCHAR TempString[256]; 610 int value = (int)currentValue; 611 switch((int)sliderId) 612 { 613 case eControl_Difficulty: 614 m_sliderDifficulty.handleSliderMove(value); 615 616 app.SetGameSettings(m_iPad,eGameSetting_Difficulty,value); 617 swprintf( (WCHAR *)TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[value])); 618 m_sliderDifficulty.setLabel(TempString); 619 break; 620 } 621} 622 623void UIScene_CreateWorldMenu::handleTimerComplete(int id) 624{ 625#ifdef __PSVITA__ 626 // we cannot rebuild touch boxes in an iggy callback because it requires further iggy calls 627 if(m_bRebuildTouchBoxes) 628 { 629 GetMainPanel()->UpdateControl(); 630 ui.TouchBoxRebuild(this); 631 m_bRebuildTouchBoxes = false; 632 } 633#endif 634 635 switch(id) 636 { 637 case GAME_CREATE_ONLINE_TIMER_ID: 638 { 639 bool bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad); 640 641 if(bMultiplayerAllowed != m_bMultiplayerAllowed) 642 { 643 if( bMultiplayerAllowed ) 644 { 645 bool bGameSetting_Online=(app.GetGameSettings(m_iPad,eGameSetting_Online)!=0); 646 m_MoreOptionsParams.bOnlineGame = bGameSetting_Online?TRUE:FALSE; 647 if(bGameSetting_Online) 648 { 649 m_MoreOptionsParams.bInviteOnly = (app.GetGameSettings(m_iPad,eGameSetting_InviteOnly)!=0)?TRUE:FALSE; 650 m_MoreOptionsParams.bAllowFriendsOfFriends = (app.GetGameSettings(m_iPad,eGameSetting_FriendsOfFriends)!=0)?TRUE:FALSE; 651 } 652 else 653 { 654 m_MoreOptionsParams.bInviteOnly = FALSE; 655 m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; 656 } 657 } 658 else 659 { 660 m_MoreOptionsParams.bOnlineGame = FALSE; 661 m_MoreOptionsParams.bInviteOnly = FALSE; 662 m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; 663 } 664 665 m_checkboxOnline.SetEnable(bMultiplayerAllowed); 666 m_checkboxOnline.setChecked(m_MoreOptionsParams.bOnlineGame); 667 668 m_bMultiplayerAllowed = bMultiplayerAllowed; 669 } 670 } 671 break; 672 // 4J-PB - Only Xbox will not have trial DLC patched into the game 673#ifdef _XBOX 674 case CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID: 675 { 676 // also check for any new texture packs info being available 677 // for each item in the mem list, check it's in the data list 678 679 CXuiCtrl4JList::LIST_ITEM_INFO ListInfo; 680 // for each iConfig, check if the data is available, and add it to the List, then remove it from the viConfig 681 for(int i=0;i<m_iTexturePacksNotInstalled;i++) 682 { 683 if(m_iConfigA[i]!=-1) 684 { 685 DWORD dwBytes=0; 686 PBYTE pbData=NULL; 687 //app.DebugPrintf("Retrieving iConfig %d from TPD\n",m_iConfigA[i]); 688 689 app.GetTPD(m_iConfigA[i],&pbData,&dwBytes); 690 691 ZeroMemory(&ListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO)); 692 if(dwBytes > 0 && pbData) 693 { 694 DWORD dwImageBytes=0; 695 PBYTE pbImageData=NULL; 696 697 app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbImageData,&dwImageBytes ); 698 ListInfo.fEnabled = TRUE; 699 ListInfo.iData = m_iConfigA[i]; 700 HRESULT hr=XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&ListInfo.hXuiBrush); 701 app.DebugPrintf("Adding texturepack %d from TPD\n",m_iConfigA[i]); 702 703 m_pTexturePacksList->AddData(ListInfo); 704 705 m_iConfigA[i]=-1; 706 } 707 } 708 } 709 } 710 break; 711#endif 712 }; 713} 714 715void UIScene_CreateWorldMenu::handleGainFocus(bool navBack) 716{ 717 if(navBack) 718 { 719 m_checkboxOnline.setChecked(m_MoreOptionsParams.bOnlineGame); 720 } 721} 722 723int UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback(LPVOID lpParam,bool bRes) 724{ 725 UIScene_CreateWorldMenu *pClass=(UIScene_CreateWorldMenu *)lpParam; 726 pClass->m_bIgnoreInput=false; 727 // 4J HEG - No reason to set value if keyboard was cancelled 728 if (bRes) 729 { 730 uint16_t pchText[128]; 731 ZeroMemory(pchText, 128 * sizeof(uint16_t) ); 732 InputManager.GetText(pchText); 733 734 if(pchText[0]!=0) 735 { 736 pClass->m_editWorldName.setLabel((wchar_t *)pchText); 737 pClass->m_worldName = (wchar_t *)pchText; 738 } 739 740 pClass->m_buttonCreateWorld.setEnable( !pClass->m_worldName.empty() ); 741 } 742 return 0; 743} 744 745void UIScene_CreateWorldMenu::checkStateAndStartGame() 746{ 747 int primaryPad = ProfileManager.GetPrimaryPad(); 748 bool isSignedInLive = true; 749 bool isOnlineGame = m_MoreOptionsParams.bOnlineGame; 750 int iPadNotSignedInLive = -1; 751 bool isLocalMultiplayerAvailable = app.IsLocalMultiplayerAvailable(); 752 753 for(unsigned int i = 0; i < XUSER_MAX_COUNT; i++) 754 { 755 if (ProfileManager.IsSignedIn(i) && (i == primaryPad || isLocalMultiplayerAvailable)) 756 { 757 if (isSignedInLive && !ProfileManager.IsSignedInLive(i)) 758 { 759 // Record the first non signed in live pad 760 iPadNotSignedInLive = i; 761 } 762 763 isSignedInLive = isSignedInLive && ProfileManager.IsSignedInLive(i); 764 } 765 } 766 767 // If this is an online game but not all players are signed in to Live, stop! 768 if (isOnlineGame && !isSignedInLive) 769 { 770#ifdef __ORBIS__ 771 assert(iPadNotSignedInLive != -1); 772 773 // Check if PSN is unavailable because of age restriction 774 int npAvailability = ProfileManager.getNPAvailability(iPadNotSignedInLive); 775 if (npAvailability == SCE_NP_ERROR_AGE_RESTRICTION) 776 { 777 m_bIgnoreInput = false; 778 // 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 779 UINT uiIDA[1]; 780 uiIDA[0]=IDS_OK; 781 ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, iPadNotSignedInLive); 782 } 783 else 784 { 785 m_bIgnoreInput = true; 786 UINT uiIDA[2]; 787 uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; 788 uiIDA[1] = IDS_CANCEL; 789 ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, iPadNotSignedInLive, &UIScene_CreateWorldMenu::MustSignInReturnedPSN, this); 790 } 791 return; 792/* 4J-PB - Add this after release 793#elif defined __PSVITA__ 794 m_bIgnoreInput=false; 795 // Determine why they're not "signed in live" 796 if (ProfileManager.IsSignedInPSN(ProfileManager.GetPrimaryPad())) 797 { 798 // Signed in to PSN but not connected (no internet access) 799 UINT uiIDA[1]; 800 uiIDA[0] = IDS_CONFIRM_OK; 801 ui.RequestErrorMessage(IDS_PRO_CURRENTLY_NOT_ONLINE_TITLE, IDS_PRO_PSNOFFLINE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad()); 802 } 803 else 804 { 805 // Not signed in to PSN 806 UINT uiIDA[1]; 807 uiIDA[0] = IDS_CONFIRM_OK; 808 ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad()); 809 return; 810 }*/ 811#else 812 m_bIgnoreInput=false; 813 UINT uiIDA[1]; 814 uiIDA[0]=IDS_CONFIRM_OK; 815 ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad()); 816 return; 817#endif 818 } 819 820#ifdef __ORBIS__ 821 822 bool bPlayStationPlus = true; 823 int iPadWithNoPlaystationPlus=0; 824 if(isOnlineGame && isSignedInLive) 825 { 826 for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) 827 { 828 if(ProfileManager.IsSignedIn(i) && (i == primaryPad || isLocalMultiplayerAvailable)) 829 { 830 if(ProfileManager.HasPlayStationPlus(i)==false) 831 { 832 bPlayStationPlus=false; 833 iPadWithNoPlaystationPlus=i; 834 break; 835 } 836 } 837 } 838 839 if(bPlayStationPlus==false) 840 { 841 m_bIgnoreInput=false; 842 843 if(ProfileManager.RequestingPlaystationPlus(iPadWithNoPlaystationPlus)) 844 { 845 // 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). 846 UINT uiIDA[1]; 847 uiIDA[0]=IDS_OK; 848 ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL); 849 return; 850 } 851 852 853 // 4J-PB - we're not allowed to show the text Playstation Plus - have to call the upsell all the time! 854 // upsell psplus 855 int32_t iResult=sceNpCommerceDialogInitialize(); 856 857 SceNpCommerceDialogParam param; 858 sceNpCommerceDialogParamInitialize(&param); 859 param.mode=SCE_NP_COMMERCE_DIALOG_MODE_PLUS; 860 param.features = SCE_NP_PLUS_FEATURE_REALTIME_MULTIPLAY; 861 param.userId = ProfileManager.getUserID(iPadWithNoPlaystationPlus); 862 863 iResult=sceNpCommerceDialogOpen(&param); 864 865// UINT uiIDA[2]; 866// uiIDA[0]=IDS_PLAY_OFFLINE; 867// uiIDA[1]=IDS_PLAYSTATIONPLUS_SIGNUP; 868// ui.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA,2,ProfileManager.GetPrimaryPad(),&UIScene_CreateWorldMenu::PSPlusReturned,this, app.GetStringTable(),NULL,0,false); 869 return; 870 } 871 } 872#endif 873 874 if(m_bGameModeCreative == true || m_MoreOptionsParams.bHostPrivileges == TRUE) 875 { 876 UINT uiIDA[2]; 877 uiIDA[0]=IDS_CONFIRM_OK; 878 uiIDA[1]=IDS_CONFIRM_CANCEL; 879 if(m_bGameModeCreative == true) 880 { 881 ui.RequestAlertMessage(IDS_TITLE_START_GAME, IDS_CONFIRM_START_CREATIVE, uiIDA, 2, m_iPad,&UIScene_CreateWorldMenu::ConfirmCreateReturned,this); 882 } 883 else 884 { 885 ui.RequestAlertMessage(IDS_TITLE_START_GAME, IDS_CONFIRM_START_HOST_PRIVILEGES, uiIDA, 2, m_iPad,&UIScene_CreateWorldMenu::ConfirmCreateReturned,this); 886 } 887 } 888 else 889 { 890 // 4J Stu - If we only have one controller connected, then don't show the sign-in UI again 891 DWORD connectedControllers = 0; 892 for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) 893 { 894 if( InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i) ) ++connectedControllers; 895 } 896 897 // Check if user-created content is allowed, as we cannot play multiplayer if it's not 898 //bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && m_MoreOptionsParams.bOnlineGame; 899 bool noUGC = false; 900 BOOL pccAllowed = TRUE; 901 BOOL pccFriendsAllowed = TRUE; 902 bool bContentRestricted = false; 903 904 ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); 905#if defined(__PS3__) || defined(__PSVITA__) 906 if(isOnlineGame && isSignedInLive) 907 { 908 ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,NULL,&bContentRestricted,NULL); 909 } 910#endif 911 912 noUGC = !pccAllowed && !pccFriendsAllowed; 913 914 if(isOnlineGame && isSignedInLive && app.IsLocalMultiplayerAvailable()) 915 { 916 // 4J-PB not sure why we aren't checking the content restriction for the main player here when multiple controllers are connected - adding now 917 if(noUGC ) 918 { 919 m_bIgnoreInput=false; 920 ui.RequestUGCMessageBox(); 921 } 922 else if(bContentRestricted ) 923 { 924 m_bIgnoreInput=false; 925 ui.RequestContentRestrictedMessageBox(); 926 } 927#ifdef __ORBIS__ 928 else if(bPlayStationPlus==false) 929 { 930 m_bIgnoreInput=false; 931 932 if(ProfileManager.RequestingPlaystationPlus(iPadWithNoPlaystationPlus)) 933 { 934 // 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). 935 UINT uiIDA[1]; 936 uiIDA[0]=IDS_OK; 937 ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL); 938 return; 939 } 940 941 // 4J-PB - we're not allowed to show the text Playstation Plus - have to call the upsell all the time! 942 // upsell psplus 943 int32_t iResult=sceNpCommerceDialogInitialize(); 944 945 SceNpCommerceDialogParam param; 946 sceNpCommerceDialogParamInitialize(&param); 947 param.mode=SCE_NP_COMMERCE_DIALOG_MODE_PLUS; 948 param.features = SCE_NP_PLUS_FEATURE_REALTIME_MULTIPLAY; 949 param.userId = ProfileManager.getUserID(iPadWithNoPlaystationPlus); 950 951 iResult=sceNpCommerceDialogOpen(&param); 952// UINT uiIDA[2]; 953// uiIDA[0]=IDS_PLAY_OFFLINE; 954// uiIDA[1]=IDS_PLAYSTATIONPLUS_SIGNUP; 955// ui.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA,2,ProfileManager.GetPrimaryPad(),&UIScene_CreateWorldMenu::PSPlusReturned,this, app.GetStringTable(),NULL,0,false); 956 } 957 958#endif 959 else 960 { 961#ifdef _WINDOWS64 962 // On Windows64, Xbox Live is unavailable. Skip QuadrantSignin and start directly. 963 CreateGame(this, 0); 964#else 965 //ProfileManager.RequestSignInUI(false, false, false, true, false,&CScene_MultiGameCreate::StartGame_SignInReturned, this,ProfileManager.GetPrimaryPad()); 966 SignInInfo info; 967 info.Func = &UIScene_CreateWorldMenu::StartGame_SignInReturned; 968 info.lpParam = this; 969 info.requireOnline = m_MoreOptionsParams.bOnlineGame; 970 ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_QuadrantSignin,&info); 971#endif 972 } 973 } 974 else 975 { 976 if(!pccAllowed && !pccFriendsAllowed) noUGC = true; 977 978 if(isOnlineGame && isSignedInLive && noUGC ) 979 { 980 m_bIgnoreInput=false; 981 ui.RequestUGCMessageBox(); 982 } 983 else if(isOnlineGame && isSignedInLive && bContentRestricted ) 984 { 985 m_bIgnoreInput=false; 986 ui.RequestContentRestrictedMessageBox(); 987 } 988#ifdef __ORBIS__ 989 else if(isOnlineGame && isSignedInLive && (bPlayStationPlus==false)) 990 { 991 m_bIgnoreInput=false; 992 if(ProfileManager.RequestingPlaystationPlus(iPadWithNoPlaystationPlus)) 993 { 994 // 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). 995 UINT uiIDA[1]; 996 uiIDA[0]=IDS_OK; 997 ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL); 998 return; 999 } 1000 1001 1002 setVisible( true ); 1003 1004 // 4J-PB - we're not allowed to show the text Playstation Plus - have to call the upsell all the time! 1005 // upsell psplus 1006 int32_t iResult=sceNpCommerceDialogInitialize(); 1007 1008 SceNpCommerceDialogParam param; 1009 sceNpCommerceDialogParamInitialize(&param); 1010 param.mode=SCE_NP_COMMERCE_DIALOG_MODE_PLUS; 1011 param.features = SCE_NP_PLUS_FEATURE_REALTIME_MULTIPLAY; 1012 param.userId = ProfileManager.getUserID(iPadWithNoPlaystationPlus); 1013 1014 iResult=sceNpCommerceDialogOpen(&param); 1015 1016// UINT uiIDA[2]; 1017// uiIDA[0]=IDS_PLAY_OFFLINE; 1018// uiIDA[1]=IDS_PLAYSTATIONPLUS_SIGNUP; 1019// ui.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA,2,ProfileManager.GetPrimaryPad(),&UIScene_CreateWorldMenu::PSPlusReturned,this, app.GetStringTable(),NULL,0,false); 1020 } 1021 1022#endif 1023 else 1024 { 1025#if defined(__ORBIS__) || defined(__PSVITA__) 1026 if(isOnlineGame) 1027 { 1028 bool chatRestricted = false; 1029 ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,NULL,NULL); 1030 if(chatRestricted) 1031 { 1032 ProfileManager.DisplaySystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_PSN_CHAT_RESTRICTION, ProfileManager.GetPrimaryPad() ); 1033 } 1034 } 1035#endif 1036 CreateGame(this, 0); 1037 } 1038 } 1039 } 1040 1041} 1042 1043// 4J Stu - Shared functionality that is the same whether we needed a quadrant sign-in or not 1044void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, DWORD dwLocalUsersMask) 1045{ 1046#if TO_BE_IMPLEMENTED 1047 // stop the timer running that causes a check for new texture packs in TMS but not installed, since this will run all through the create game, and will crash if it tries to create an hbrush 1048 XuiKillTimer(pClass->m_hObj,CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID); 1049#endif 1050 1051 bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pClass->m_MoreOptionsParams.bOnlineGame; 1052#ifdef __PSVITA__ 1053 if(CGameNetworkManager::usingAdhocMode()) 1054 { 1055 if(SQRNetworkManager_AdHoc_Vita::GetAdhocStatus())// && pClass->m_MoreOptionsParams.bOnlineGame) 1056 isClientSide = true; 1057 } 1058#endif // __PSVITA__ 1059 1060 bool isPrivate = pClass->m_MoreOptionsParams.bInviteOnly?true:false; 1061 1062 // clear out the app's terrain features list 1063 app.ClearTerrainFeaturePosition(); 1064 1065 // create the world and launch 1066 wstring wWorldName = pClass->m_worldName; 1067 1068 StorageManager.ResetSaveData(); 1069 // Make our next save default to the name of the level 1070 StorageManager.SetSaveTitle((wchar_t *)wWorldName.c_str()); 1071 1072 wstring wSeed; 1073 if(!pClass->m_MoreOptionsParams.seed.empty() ) 1074 { 1075 wSeed=pClass->m_MoreOptionsParams.seed; 1076 } 1077 else 1078 { 1079 // random 1080 wSeed=L""; 1081 } 1082 1083 // start the game 1084 bool isFlat = (pClass->m_MoreOptionsParams.bFlatWorld==TRUE); 1085 __int64 seedValue = 0; 1086 1087 NetworkGameInitData *param = new NetworkGameInitData(); 1088 1089 if (wSeed.length() != 0) 1090 { 1091 __int64 value = 0; 1092 unsigned int len = (unsigned int)wSeed.length(); 1093 1094 //Check if the input string contains a numerical value 1095 bool isNumber = true; 1096 for( unsigned int i = 0 ; i < len ; ++i ) 1097 { 1098 if( wSeed.at(i) < L'0' || wSeed.at(i) > L'9' ) 1099 { 1100 if( !(i==0 && wSeed.at(i) == L'-' ) ) 1101 { 1102 isNumber = false; 1103 break; 1104 } 1105 } 1106 } 1107 1108 //If the input string is a numerical value, convert it to a number 1109 if( isNumber ) 1110 value = _fromString<__int64>(wSeed); 1111 1112 //If the value is not 0 use it, otherwise use the algorithm from the java String.hashCode() function to hash it 1113 if( value != 0 ) 1114 seedValue = value; 1115 else 1116 { 1117 int hashValue = 0; 1118 for( unsigned int i = 0 ; i < len ; ++i ) 1119 hashValue = 31 * hashValue + wSeed.at(i); 1120 seedValue = hashValue; 1121 } 1122 } 1123 else 1124 { 1125 param->findSeed = true; // 4J - java code sets the seed to was (new Random())->nextLong() here - we used to at this point find a suitable seed, but now just set a flag so this is performed in Minecraft::Server::initServer. 1126 } 1127 1128 1129 param->seed = seedValue; 1130 param->saveData = NULL; 1131 param->texturePackId = pClass->m_MoreOptionsParams.dwTexturePack; 1132 1133 Minecraft *pMinecraft = Minecraft::GetInstance(); 1134 pMinecraft->skins->selectTexturePackById(pClass->m_MoreOptionsParams.dwTexturePack); 1135 1136 app.SetGameHostOption(eGameHostOption_Difficulty,Minecraft::GetInstance()->options->difficulty); 1137 app.SetGameHostOption(eGameHostOption_FriendsOfFriends,pClass->m_MoreOptionsParams.bAllowFriendsOfFriends); 1138 app.SetGameHostOption(eGameHostOption_Gamertags,app.GetGameSettings(pClass->m_iPad,eGameSetting_GamertagsVisible)?1:0); 1139 1140 app.SetGameHostOption(eGameHostOption_BedrockFog,app.GetGameSettings(pClass->m_iPad,eGameSetting_BedrockFog)?1:0); 1141 1142 app.SetGameHostOption(eGameHostOption_GameType,pClass->m_iGameModeId ); 1143 app.SetGameHostOption(eGameHostOption_LevelType,pClass->m_MoreOptionsParams.bFlatWorld ); 1144 app.SetGameHostOption(eGameHostOption_Structures,pClass->m_MoreOptionsParams.bStructures ); 1145 app.SetGameHostOption(eGameHostOption_BonusChest,pClass->m_MoreOptionsParams.bBonusChest ); 1146 1147 app.SetGameHostOption(eGameHostOption_PvP,pClass->m_MoreOptionsParams.bPVP); 1148 app.SetGameHostOption(eGameHostOption_TrustPlayers,pClass->m_MoreOptionsParams.bTrust ); 1149 app.SetGameHostOption(eGameHostOption_FireSpreads,pClass->m_MoreOptionsParams.bFireSpreads ); 1150 app.SetGameHostOption(eGameHostOption_TNT,pClass->m_MoreOptionsParams.bTNT ); 1151 app.SetGameHostOption(eGameHostOption_HostCanFly,pClass->m_MoreOptionsParams.bHostPrivileges); 1152 app.SetGameHostOption(eGameHostOption_HostCanChangeHunger,pClass->m_MoreOptionsParams.bHostPrivileges); 1153 app.SetGameHostOption(eGameHostOption_HostCanBeInvisible,pClass->m_MoreOptionsParams.bHostPrivileges ); 1154 1155 app.SetGameHostOption(eGameHostOption_MobGriefing, pClass->m_MoreOptionsParams.bMobGriefing); 1156 app.SetGameHostOption(eGameHostOption_KeepInventory, pClass->m_MoreOptionsParams.bKeepInventory); 1157 app.SetGameHostOption(eGameHostOption_DoMobSpawning, pClass->m_MoreOptionsParams.bDoMobSpawning); 1158 app.SetGameHostOption(eGameHostOption_DoMobLoot, pClass->m_MoreOptionsParams.bDoMobLoot); 1159 app.SetGameHostOption(eGameHostOption_DoTileDrops, pClass->m_MoreOptionsParams.bDoTileDrops); 1160 app.SetGameHostOption(eGameHostOption_NaturalRegeneration, pClass->m_MoreOptionsParams.bNaturalRegeneration); 1161 app.SetGameHostOption(eGameHostOption_DoDaylightCycle, pClass->m_MoreOptionsParams.bDoDaylightCycle); 1162 1163 app.SetGameHostOption(eGameHostOption_WasntSaveOwner, false); 1164#ifdef _LARGE_WORLDS 1165 app.SetGameHostOption(eGameHostOption_WorldSize, pClass->m_MoreOptionsParams.worldSize+1 ); // 0 is GAME_HOST_OPTION_WORLDSIZE_UNKNOWN 1166 pClass->m_MoreOptionsParams.currentWorldSize = (EGameHostOptionWorldSize)(pClass->m_MoreOptionsParams.worldSize+1); 1167 pClass->m_MoreOptionsParams.newWorldSize = (EGameHostOptionWorldSize)(pClass->m_MoreOptionsParams.worldSize+1); 1168#endif 1169 1170 g_NetworkManager.HostGame(dwLocalUsersMask,isClientSide,isPrivate,MINECRAFT_NET_MAX_PLAYERS,0); 1171 1172 param->settings = app.GetGameHostOption( eGameHostOption_All ); 1173 1174#ifdef _LARGE_WORLDS 1175 switch(pClass->m_MoreOptionsParams.worldSize) 1176 { 1177 case 0: 1178 // Classic 1179 param->xzSize = LEVEL_WIDTH_CLASSIC; 1180 param->hellScale = HELL_LEVEL_SCALE_CLASSIC; // hellsize = 54/3 = 18 1181 break; 1182 case 1: 1183 // Small 1184 param->xzSize = LEVEL_WIDTH_SMALL; 1185 param->hellScale = HELL_LEVEL_SCALE_SMALL; // hellsize = ceil(64/3) = 22 1186 break; 1187 case 2: 1188 // Medium 1189 param->xzSize = LEVEL_WIDTH_MEDIUM; 1190 param->hellScale = HELL_LEVEL_SCALE_MEDIUM; // hellsize= ceil(3*64/6) = 32 1191 break; 1192 case 3: 1193 // Large 1194 param->xzSize = LEVEL_WIDTH_LARGE; 1195 param->hellScale = HELL_LEVEL_SCALE_LARGE; // hellsize = ceil(5*64/8) = 40 1196 break; 1197 }; 1198#else 1199 param->xzSize = LEVEL_MAX_WIDTH; 1200 param->hellScale = HELL_LEVEL_MAX_SCALE; 1201#endif 1202 1203#ifndef _XBOX 1204 g_NetworkManager.FakeLocalPlayerJoined(); 1205#endif 1206 1207 LoadingInputParams *loadingParams = new LoadingInputParams(); 1208 loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; 1209 loadingParams->lpParam = (LPVOID)param; 1210 1211 // Reset the autosave time 1212 app.SetAutosaveTimerTime(); 1213 1214 UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); 1215 completionData->bShowBackground=TRUE; 1216 completionData->bShowLogo=TRUE; 1217 completionData->type = e_ProgressCompletion_CloseAllPlayersUIScenes; 1218 completionData->iPad = DEFAULT_XUI_MENU_USER; 1219 loadingParams->completionData = completionData; 1220 1221 ui.NavigateToScene(pClass->m_iPad,eUIScene_FullscreenProgress, loadingParams); 1222} 1223 1224 1225int UIScene_CreateWorldMenu::StartGame_SignInReturned(void *pParam,bool bContinue, int iPad) 1226{ 1227 UIScene_CreateWorldMenu* pClass = (UIScene_CreateWorldMenu*)pParam; 1228 1229 if(bContinue==true) 1230 { 1231 // It's possible that the player has not signed in - they can back out 1232 if(ProfileManager.IsSignedIn(pClass->m_iPad)) 1233 { 1234 bool isOnlineGame = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pClass->m_MoreOptionsParams.bOnlineGame; 1235 // bool isOnlineGame = pClass->m_MoreOptionsParams.bOnlineGame; 1236 int primaryPad = ProfileManager.GetPrimaryPad(); 1237 bool noPrivileges = false; 1238 DWORD dwLocalUsersMask = 0; 1239 bool isSignedInLive = ProfileManager.IsSignedInLive(primaryPad); 1240 int iPadNotSignedInLive = -1; 1241 bool isLocalMultiplayerAvailable = app.IsLocalMultiplayerAvailable(); 1242 1243 for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) 1244 { 1245 if (ProfileManager.IsSignedIn(i) && ((i == primaryPad) || isLocalMultiplayerAvailable)) 1246 { 1247 if (isSignedInLive && !ProfileManager.IsSignedInLive(i)) 1248 { 1249 // Record the first non signed in live pad 1250 iPadNotSignedInLive = i; 1251 } 1252 1253 if( !ProfileManager.AllowedToPlayMultiplayer(i) ) noPrivileges = true; 1254 dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(i); 1255 isSignedInLive = isSignedInLive && ProfileManager.IsSignedInLive(i); 1256 } 1257 } 1258 1259 // If this is an online game but not all players are signed in to Live, stop! 1260 if (isOnlineGame && !isSignedInLive) 1261 { 1262#ifdef __ORBIS__ 1263 assert(iPadNotSignedInLive != -1); 1264 1265 // Check if PSN is unavailable because of age restriction 1266 int npAvailability = ProfileManager.getNPAvailability(iPadNotSignedInLive); 1267 if (npAvailability == SCE_NP_ERROR_AGE_RESTRICTION) 1268 { 1269 pClass->m_bIgnoreInput = false; 1270 // 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 1271 UINT uiIDA[1]; 1272 uiIDA[0]=IDS_OK; 1273 ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, iPadNotSignedInLive); 1274 } 1275 else 1276 { 1277 pClass->m_bIgnoreInput=true; 1278 UINT uiIDA[2]; 1279 uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; 1280 uiIDA[1] = IDS_CANCEL; 1281 ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, iPadNotSignedInLive, &UIScene_CreateWorldMenu::MustSignInReturnedPSN, pClass); 1282 } 1283 return 0; 1284#else 1285 pClass->m_bIgnoreInput=false; 1286 UINT uiIDA[1]; 1287 uiIDA[0]=IDS_CONFIRM_OK; 1288 ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad()); 1289 return 0; 1290#endif 1291 } 1292 1293 // Check if user-created content is allowed, as we cannot play multiplayer if it's not 1294 bool noUGC = false; 1295 BOOL pccAllowed = TRUE; 1296 BOOL pccFriendsAllowed = TRUE; 1297 1298 ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); 1299 if(!pccAllowed && !pccFriendsAllowed) noUGC = true; 1300 1301 if(isOnlineGame && (noPrivileges || noUGC) ) 1302 { 1303 if( noUGC ) 1304 { 1305 pClass->m_bIgnoreInput = false; 1306 UINT uiIDA[1]; 1307 uiIDA[0]=IDS_CONFIRM_OK; 1308 ui.RequestAlertMessage( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad()); 1309 } 1310 else 1311 { 1312 pClass->m_bIgnoreInput = false; 1313 UINT uiIDA[1]; 1314 uiIDA[0]=IDS_CONFIRM_OK; 1315 ui.RequestAlertMessage( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_HOST_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad()); 1316 } 1317 } 1318 else 1319 { 1320 // 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. 1321 CreateGame(pClass, dwLocalUsersMask); 1322 } 1323 } 1324 } 1325 else 1326 { 1327 pClass->m_bIgnoreInput = false; 1328 } 1329 return 0; 1330} 1331 1332 1333int UIScene_CreateWorldMenu::ConfirmCreateReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 1334{ 1335 UIScene_CreateWorldMenu* pClass = (UIScene_CreateWorldMenu*)pParam; 1336 1337 if(result==C4JStorage::EMessage_ResultAccept) 1338 { 1339 bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pClass->m_MoreOptionsParams.bOnlineGame; 1340 1341 // 4J Stu - If we only have one controller connected, then don't show the sign-in UI again 1342 DWORD connectedControllers = 0; 1343 for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) 1344 { 1345 if( InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i) ) ++connectedControllers; 1346 } 1347 1348 if(isClientSide && app.IsLocalMultiplayerAvailable()) 1349 { 1350#ifdef _WINDOWS64 1351 // On Windows64, Xbox Live is unavailable. Skip QuadrantSignin and start directly. 1352 CreateGame(pClass, 0); 1353 return 0; 1354#else 1355 //ProfileManager.RequestSignInUI(false, false, false, true, false,&UIScene_CreateWorldMenu::StartGame_SignInReturned, pClass,ProfileManager.GetPrimaryPad()); 1356 SignInInfo info; 1357 info.Func = &UIScene_CreateWorldMenu::StartGame_SignInReturned; 1358 info.lpParam = pClass; 1359 info.requireOnline = pClass->m_MoreOptionsParams.bOnlineGame; 1360 ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_QuadrantSignin,&info); 1361#endif 1362 } 1363 else 1364 { 1365 // Check if user-created content is allowed, as we cannot play multiplayer if it's not 1366 bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pClass->m_MoreOptionsParams.bOnlineGame; 1367 bool noUGC = false; 1368 BOOL pccAllowed = TRUE; 1369 BOOL pccFriendsAllowed = TRUE; 1370 1371 ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); 1372 if(!pccAllowed && !pccFriendsAllowed) noUGC = true; 1373 1374 if(isClientSide && noUGC ) 1375 { 1376 pClass->m_bIgnoreInput = false; 1377 UINT uiIDA[1]; 1378 uiIDA[0]=IDS_CONFIRM_OK; 1379 ui.RequestAlertMessage( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad()); 1380 } 1381 else 1382 { 1383#if defined( __ORBIS__) || defined(__PSVITA__) 1384 bool isOnlineGame = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pClass->m_MoreOptionsParams.bOnlineGame; 1385 if(isOnlineGame) 1386 { 1387 bool chatRestricted = false; 1388 ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,NULL,NULL); 1389 if(chatRestricted) 1390 { 1391 ProfileManager.DisplaySystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_PSN_CHAT_RESTRICTION, ProfileManager.GetPrimaryPad() ); 1392 } 1393 } 1394#endif 1395 CreateGame(pClass, 0); 1396 } 1397 } 1398 } 1399 else 1400 { 1401 pClass->m_bIgnoreInput = false; 1402 } 1403 return 0; 1404} 1405 1406#ifdef __ORBIS__ 1407int UIScene_CreateWorldMenu::MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::EMessageResult result) 1408{ 1409 UIScene_CreateWorldMenu* pClass = (UIScene_CreateWorldMenu *)pParam; 1410 pClass->m_bIgnoreInput = false; 1411 1412 if(result==C4JStorage::EMessage_ResultAccept) 1413 { 1414 SQRNetworkManager_Orbis::AttemptPSNSignIn(&UIScene_CreateWorldMenu::StartGame_SignInReturned, pClass, false, iPad); 1415 } 1416 1417 return 0; 1418} 1419 1420// int UIScene_CreateWorldMenu::PSPlusReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 1421// { 1422// int32_t iResult; 1423// UIScene_CreateWorldMenu *pClass = (UIScene_CreateWorldMenu *)pParam; 1424// 1425// // continue offline, or upsell PS Plus? 1426// if(result==C4JStorage::EMessage_ResultDecline) 1427// { 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(pClass->m_iPad); 1436// 1437// iResult=sceNpCommerceDialogOpen(&param); 1438// } 1439// else if(result==C4JStorage::EMessage_ResultAccept) 1440// { 1441// // continue offline 1442// pClass->m_MoreOptionsParams.bOnlineGame=false; 1443// pClass->checkStateAndStartGame(); 1444// } 1445// 1446// pClass->m_bIgnoreInput=false; 1447// return 0; 1448// } 1449#endif 1450 1451 1452void UIScene_CreateWorldMenu::handleTouchBoxRebuild() 1453{ 1454 m_bRebuildTouchBoxes = true; 1455}