the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 1737 lines 48 kB view raw
1#include "stdafx.h" 2#include "UI.h" 3#include "UIScene_SkinSelectMenu.h" 4#include "..\..\..\Minecraft.World\StringHelpers.h" 5#ifdef __ORBIS__ 6#include <error_dialog.h> 7#elif defined __PSVITA__ 8#include <message_dialog.h> 9#endif 10 11#define SKIN_SELECT_PACK_DEFAULT 0 12#define SKIN_SELECT_PACK_FAVORITES 1 13//#define SKIN_SELECT_PACK_PLAYER_CUSTOM 1 14#define SKIN_SELECT_MAX_DEFAULTS 2 15 16WCHAR *UIScene_SkinSelectMenu::wchDefaultNamesA[]= 17{ 18 L"USE LOCALISED VERSION", // Server selected 19 L"Steve", 20 L"Tennis Steve", 21 L"Tuxedo Steve", 22 L"Athlete Steve", 23 L"Scottish Steve", 24 L"Prisoner Steve", 25 L"Cyclist Steve", 26 L"Boxer Steve", 27}; 28 29UIScene_SkinSelectMenu::UIScene_SkinSelectMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) 30{ 31 // Setup all the Iggy references we need for this scene 32 initialiseMovie(); 33 34 m_labelSelected.init( app.GetString( IDS_SELECTED ) ); 35 36#ifdef __ORBIS__ 37 m_bErrorDialogRunning=false; 38#endif 39 40 m_bIgnoreInput=false; 41 m_bNoSkinsToShow = false; 42 43 m_currentPack = NULL; 44 m_packIndex = SKIN_SELECT_PACK_DEFAULT; 45 m_skinIndex = 0; 46 47 m_originalSkinId = app.GetPlayerSkinId(iPad); 48 m_currentSkinPath = app.GetPlayerSkinName(iPad); 49 m_selectedSkinPath = L""; 50 m_selectedCapePath = L""; 51 m_vAdditionalSkinBoxes = NULL; 52 53 m_bSlidingSkins = false; 54 m_bAnimatingMove = false; 55 m_bSkinIndexChanged = false; 56 57 m_currentNavigation = eSkinNavigation_Skin; 58 59 m_currentPackCount = 0; 60 61 m_characters[eCharacter_Current].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Forward); 62 63 m_characters[eCharacter_Next1].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Left); 64 m_characters[eCharacter_Next2].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Left); 65 m_characters[eCharacter_Next3].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Left); 66 m_characters[eCharacter_Next4].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Left); 67 68 m_characters[eCharacter_Previous1].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Right); 69 m_characters[eCharacter_Previous2].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Right); 70 m_characters[eCharacter_Previous3].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Right); 71 m_characters[eCharacter_Previous4].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Right); 72 73 m_labelSkinName.init(L""); 74 m_labelSkinOrigin.init(L""); 75 76 m_leftLabel = L""; 77 m_centreLabel = L""; 78 m_rightLabel = L""; 79 80#ifdef __PSVITA__ 81 // initialise vita tab controls with ids 82 m_TouchTabLeft.init(ETouchInput_TabLeft); 83 m_TouchTabRight.init(ETouchInput_TabRight); 84 m_TouchTabCenter.init(ETouchInput_TabCenter); 85 m_TouchIggyCharacters.init(ETouchInput_IggyCharacters); 86#endif 87 88 // block input if we're waiting for DLC to install. The end of dlc mounting custom message will fill the save list 89 if(app.StartInstallDLCProcess(m_iPad)) 90 { 91 // DLC mounting in progress, so disable input 92 m_bIgnoreInput=true; 93 94 m_controlTimer.setVisible( true ); 95 m_controlIggyCharacters.setVisible( false ); 96 m_controlSkinNamePlate.setVisible( false ); 97 98 setCharacterLocked(false); 99 setCharacterSelected(false); 100 } 101 else 102 { 103 m_controlTimer.setVisible( false ); 104 105 if(app.m_dlcManager.getPackCount(DLCManager::e_DLCType_Skin)>0) 106 { 107 // Change to display the favorites if there are any. The current skin will be in there (probably) - need to check for it 108 m_currentPack = app.m_dlcManager.getPackContainingSkin(m_currentSkinPath); 109 bool bFound; 110 if(m_currentPack != NULL) 111 { 112 m_packIndex = app.m_dlcManager.getPackIndex(m_currentPack,bFound,DLCManager::e_DLCType_Skin) + SKIN_SELECT_MAX_DEFAULTS; 113 } 114 } 115 116 // If we have any favourites, set this to the favourites 117 // first validate the favorite skins - we might have uninstalled the DLC needed for them 118 app.ValidateFavoriteSkins(m_iPad); 119 120 if(app.GetPlayerFavoriteSkinsCount(m_iPad)>0) 121 { 122 m_packIndex = SKIN_SELECT_PACK_FAVORITES; 123 } 124 125 handlePackIndexChanged(); 126 } 127 128 // Display the tooltips 129 130#ifdef __PSVITA__ 131 InitializeCriticalSection(&m_DLCInstallCS); // to prevent a race condition between the install and the mounted callback 132#endif 133 134} 135 136void UIScene_SkinSelectMenu::updateTooltips() 137{ 138 ui.SetTooltips( m_iPad, m_bNoSkinsToShow?-1:IDS_TOOLTIPS_SELECT_SKIN,IDS_TOOLTIPS_CANCEL,-1,-1,-1,-1,-1,-1,IDS_TOOLTIPS_NAVIGATE); 139} 140 141void UIScene_SkinSelectMenu::updateComponents() 142{ 143 m_parentLayer->showComponent(m_iPad,eUIComponent_Logo,false); 144} 145 146wstring UIScene_SkinSelectMenu::getMoviePath() 147{ 148 if(app.GetLocalPlayerCount() > 1) 149 { 150 return L"SkinSelectMenuSplit"; 151 } 152 else 153 { 154 return L"SkinSelectMenu"; 155 } 156} 157 158void UIScene_SkinSelectMenu::tick() 159{ 160 UIScene::tick(); 161 162 if(m_bSkinIndexChanged) 163 { 164 m_bSkinIndexChanged = false; 165 handleSkinIndexChanged(); 166 } 167 168 // check for new DLC installed 169 170 // check for the patch error dialog 171#ifdef __ORBIS__ 172 173 // process the error dialog (for a patch being available) 174 if(m_bErrorDialogRunning) 175 { 176 SceErrorDialogStatus stat = sceErrorDialogUpdateStatus(); 177 if( stat == SCE_ERROR_DIALOG_STATUS_FINISHED ) 178 { 179 sceErrorDialogTerminate(); 180 m_bErrorDialogRunning=false; 181 } 182 } 183 184#endif 185} 186 187void UIScene_SkinSelectMenu::handleAnimationEnd() 188{ 189 if(m_bSlidingSkins) 190 { 191 m_bSlidingSkins = false; 192 193 m_characters[eCharacter_Current].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Forward, false); 194 m_characters[eCharacter_Next1].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Left, false); 195 m_characters[eCharacter_Previous1].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Right, false); 196 197 m_bSkinIndexChanged = true; 198 //handleSkinIndexChanged(); 199 200 m_bAnimatingMove = false; 201 } 202} 203 204void UIScene_SkinSelectMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) 205{ 206 if (m_bIgnoreInput) return; 207 //app.DebugPrintf("UIScene_DebugOverlay handling input for pad %d, key %d, down- %s, pressed- %s, released- %s\n", iPad, key, down?"TRUE":"FALSE", pressed?"TRUE":"FALSE", released?"TRUE":"FALSE"); 208 209 switch(key) 210 { 211 case ACTION_MENU_CANCEL: 212 if(pressed) 213 { 214 ui.AnimateKeyPress(iPad, key, repeat, pressed, released); 215 app.CheckGameSettingsChanged(true,iPad); 216 navigateBack(); 217 } 218 break; 219 case ACTION_MENU_OK: 220#ifdef __ORBIS__ 221 case ACTION_MENU_TOUCHPAD_PRESS: 222#endif 223 if(pressed) 224 { 225 InputActionOK(iPad); 226 } 227 break; 228 case ACTION_MENU_UP: 229 case ACTION_MENU_DOWN: 230 if(pressed) 231 { 232 if(m_packIndex==SKIN_SELECT_PACK_FAVORITES) 233 { 234 if(app.GetPlayerFavoriteSkinsCount(iPad)==0) 235 { 236 // ignore this, since there are no skins being displayed 237 break; 238 } 239 } 240 241 ui.AnimateKeyPress(iPad, key, repeat, pressed, released); 242 ui.PlayUISFX(eSFX_Scroll); 243 switch(m_currentNavigation) 244 { 245 case eSkinNavigation_Pack: 246 m_currentNavigation = eSkinNavigation_Skin; 247 break; 248 case eSkinNavigation_Skin: 249 m_currentNavigation = eSkinNavigation_Pack; 250 break; 251 }; 252 sendInputToMovie(key, repeat, pressed, released); 253 } 254 break; 255 case ACTION_MENU_LEFT: 256 if(pressed) 257 { 258 if( m_currentNavigation == eSkinNavigation_Skin ) 259 { 260 if(!m_bAnimatingMove) 261 { 262 ui.AnimateKeyPress(iPad, key, repeat, pressed, released); 263 ui.PlayUISFX(eSFX_Scroll); 264 265 m_skinIndex = getPreviousSkinIndex(m_skinIndex); 266 //handleSkinIndexChanged(); 267 268 m_bSlidingSkins = true; 269 m_bAnimatingMove = true; 270 271 m_characters[eCharacter_Current].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Left, true); 272 m_characters[eCharacter_Previous1].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Forward, true); 273 274 // 4J Stu - Swapped nav buttons 275 sendInputToMovie(ACTION_MENU_RIGHT, repeat, pressed, released); 276 } 277 } 278 else if( m_currentNavigation == eSkinNavigation_Pack ) 279 { 280 ui.AnimateKeyPress(iPad, key, repeat, pressed, released); 281 ui.PlayUISFX(eSFX_Scroll); 282 DWORD startingIndex = m_packIndex; 283 m_packIndex = getPreviousPackIndex(m_packIndex); 284 if(startingIndex != m_packIndex) 285 { 286 handlePackIndexChanged(); 287 } 288 } 289 } 290 break; 291 case ACTION_MENU_RIGHT: 292 if(pressed) 293 { 294 if( m_currentNavigation == eSkinNavigation_Skin ) 295 { 296 if(!m_bAnimatingMove) 297 { 298 ui.AnimateKeyPress(iPad, key, repeat, pressed, released); 299 ui.PlayUISFX(eSFX_Scroll); 300 m_skinIndex = getNextSkinIndex(m_skinIndex); 301 //handleSkinIndexChanged(); 302 303 m_bSlidingSkins = true; 304 m_bAnimatingMove = true; 305 306 m_characters[eCharacter_Current].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Right, true); 307 m_characters[eCharacter_Next1].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Forward, true); 308 309 // 4J Stu - Swapped nav buttons 310 sendInputToMovie(ACTION_MENU_LEFT, repeat, pressed, released); 311 } 312 } 313 else if( m_currentNavigation == eSkinNavigation_Pack ) 314 { 315 ui.AnimateKeyPress(iPad, key, repeat, pressed, released); 316 ui.PlayUISFX(eSFX_Scroll); 317 DWORD startingIndex = m_packIndex; 318 m_packIndex = getNextPackIndex(m_packIndex); 319 if(startingIndex != m_packIndex) 320 { 321 handlePackIndexChanged(); 322 } 323 } 324 } 325 break; 326 case ACTION_MENU_OTHER_STICK_PRESS: 327 if(pressed) 328 { 329 ui.PlayUISFX(eSFX_Press); 330 if( m_currentNavigation == eSkinNavigation_Skin ) 331 { 332 m_characters[eCharacter_Current].ResetRotation(); 333 } 334 } 335 break; 336 case ACTION_MENU_OTHER_STICK_LEFT: 337 if(pressed) 338 { 339 if( m_currentNavigation == eSkinNavigation_Skin ) 340 { 341 m_characters[eCharacter_Current].m_incYRot = true; 342 } 343 else 344 { 345 ui.PlayUISFX(eSFX_Scroll); 346 } 347 } 348 else if(released) 349 { 350 m_characters[eCharacter_Current].m_incYRot = false; 351 } 352 break; 353 case ACTION_MENU_OTHER_STICK_RIGHT: 354 if(pressed) 355 { 356 if( m_currentNavigation == eSkinNavigation_Skin ) 357 { 358 m_characters[eCharacter_Current].m_decYRot = true; 359 } 360 else 361 { 362 ui.PlayUISFX(eSFX_Scroll); 363 } 364 } 365 else if(released) 366 { 367 m_characters[eCharacter_Current].m_decYRot = false; 368 } 369 break; 370 case ACTION_MENU_OTHER_STICK_UP: 371 if(pressed) 372 { 373 if( m_currentNavigation == eSkinNavigation_Skin ) 374 { 375 //m_previewControl->m_incXRot = true; 376 m_characters[eCharacter_Current].CyclePreviousAnimation(); 377 } 378 else 379 { 380 ui.PlayUISFX(eSFX_Scroll); 381 } 382 } 383 break; 384 case ACTION_MENU_OTHER_STICK_DOWN: 385 if(pressed) 386 { 387 if( m_currentNavigation == eSkinNavigation_Skin ) 388 { 389 //m_previewControl->m_decXRot = true; 390 m_characters[eCharacter_Current].CycleNextAnimation(); 391 } 392 else 393 { 394 ui.PlayUISFX(eSFX_Scroll); 395 } 396 } 397 break; 398 } 399} 400 401void UIScene_SkinSelectMenu::InputActionOK(unsigned int iPad) 402{ 403 ui.AnimateKeyPress(iPad, ACTION_MENU_OK, false, true, false); 404 405 // if the profile data has been changed, then force a profile write 406 // It seems we're allowed to break the 5 minute rule if it's the result of a user action 407 switch(m_packIndex) 408 { 409 case SKIN_SELECT_PACK_DEFAULT: 410 app.SetPlayerSkin(iPad, m_skinIndex); 411 app.SetPlayerCape(iPad, 0); 412 m_currentSkinPath = app.GetPlayerSkinName(iPad); 413 m_originalSkinId = app.GetPlayerSkinId(iPad); 414 setCharacterSelected(true); 415 ui.PlayUISFX(eSFX_Press); 416 break; 417 case SKIN_SELECT_PACK_FAVORITES: 418 if(app.GetPlayerFavoriteSkinsCount(iPad)>0) 419 { 420 // get the pack number from the skin id 421 wchar_t chars[256]; 422 swprintf(chars, 256, L"dlcskin%08d.png", app.GetPlayerFavoriteSkin(iPad,m_skinIndex)); 423 424 DLCPack *Pack=app.m_dlcManager.getPackContainingSkin(chars); 425 426 if(Pack) 427 { 428 DLCSkinFile *skinFile = Pack->getSkinFile(chars); 429 app.SetPlayerSkin(iPad, skinFile->getPath()); 430 app.SetPlayerCape(iPad, skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape)); 431 setCharacterSelected(true); 432 m_currentSkinPath = app.GetPlayerSkinName(iPad); 433 m_originalSkinId = app.GetPlayerSkinId(iPad); 434 app.SetPlayerFavoriteSkinsPos(iPad,m_skinIndex); 435 } 436} 437 break; 438 default: 439 if( m_currentPack != NULL ) 440 { 441 bool renableInputAfterOperation = true; 442 m_bIgnoreInput = true; 443 444 DLCSkinFile *skinFile = m_currentPack->getSkinFile(m_skinIndex); 445 446 // Is this a free skin? 447 448 if(!skinFile->getParameterAsBool( DLCManager::e_DLCParamType_Free )) 449 { 450 // do we have a license? 451 //if(true) 452 if(!m_currentPack->hasPurchasedFile( DLCManager::e_DLCType_Skin, skinFile->getPath() )) 453 { 454#ifdef __ORBIS__ 455 // 4J-PB - Check if there is a patch for the game 456 int errorCode = ProfileManager.getNPAvailability(ProfileManager.GetPrimaryPad()); 457 458 bool bPatchAvailable; 459 switch(errorCode) 460 { 461 case SCE_NP_ERROR_LATEST_PATCH_PKG_EXIST: 462 case SCE_NP_ERROR_LATEST_PATCH_PKG_DOWNLOADED: 463 bPatchAvailable=true; 464 break; 465 default: 466 bPatchAvailable=false; 467 break; 468 } 469 470 if(bPatchAvailable) 471 { 472 int32_t ret=sceErrorDialogInitialize(); 473 m_bErrorDialogRunning=true; 474 if ( ret==SCE_OK ) 475 { 476 SceErrorDialogParam param; 477 sceErrorDialogParamInitialize( &param ); 478 // 4J-PB - We want to display the option to get the patch now 479 param.errorCode = SCE_NP_ERROR_LATEST_PATCH_PKG_DOWNLOADED;//pClass->m_errorCode; 480 ret = sceUserServiceGetInitialUser( &param.userId ); 481 if ( ret == SCE_OK ) 482 { 483 ret=sceErrorDialogOpen( &param ); 484 break; 485 } 486 } 487 } 488#endif 489 490 // no 491 UINT uiIDA[1]; 492 uiIDA[0]=IDS_OK; 493 494#ifdef __ORBIS__ 495 // Check if PSN is unavailable because of age restriction 496 int npAvailability = ProfileManager.getNPAvailability(iPad); 497 if (npAvailability == SCE_NP_ERROR_AGE_RESTRICTION) 498 { 499 ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, iPad); 500 } 501 else 502#endif 503 // We need to upsell the full version 504 if(ProfileManager.IsGuest(iPad)) 505 { 506 // can't buy 507 ui.RequestAlertMessage(IDS_PRO_GUESTPROFILE_TITLE, IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1,iPad); 508 } 509#if defined(__PS3__) || defined(__ORBIS__) || defined __PSVITA__ 510 // are we online? 511 else if(!ProfileManager.IsSignedInLive(iPad)) 512 { 513 showNotOnlineDialog(iPad); 514 } 515#endif 516 else 517 { 518 // upsell 519#ifdef _XBOX 520 DLC_INFO *pDLCInfo = app.GetDLCInfoForTrialOfferID(m_currentPack->getPurchaseOfferId()); 521 ULONGLONG ullOfferID_Full; 522 523 if(pDLCInfo!=NULL) 524 { 525 ullOfferID_Full=pDLCInfo->ullOfferID_Full; 526 } 527 else 528 { 529 ullOfferID_Full=m_currentPack->getPurchaseOfferId(); 530 } 531 532 // tell sentient about the upsell of the full version of the skin pack 533 SentientManager.RecordUpsellPresented(iPad, eSet_UpsellID_Skin_DLC, ullOfferID_Full & 0xFFFFFFFF); 534#endif 535 bool bContentRestricted=false; 536#if defined(__PS3__) || defined(__PSVITA__) 537 ProfileManager.GetChatAndContentRestrictions(m_iPad,true,NULL,&bContentRestricted,NULL); 538#endif 539 if(bContentRestricted) 540 { 541#if !(defined(_XBOX) || defined(_WINDOWS64) || defined(_XBOX_ONE)) // 4J Stu - Temp to get the win build running, but so we check this for other platforms 542 // you can't see the store 543 UINT uiIDA[1]; 544 uiIDA[0]=IDS_CONFIRM_OK; 545 ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, iPad); 546#endif 547 } 548 else 549 { 550 // 4J-PB - need to check for an empty store 551#if defined __ORBIS__ || defined __PSVITA__ || defined __PS3__ 552 if(app.CheckForEmptyStore(iPad)==false) 553#endif 554 { 555 m_bIgnoreInput = true; 556 renableInputAfterOperation = false; 557 558 UINT uiIDA[2] = { IDS_CONFIRM_OK, IDS_CONFIRM_CANCEL }; 559 ui.RequestAlertMessage(IDS_UNLOCK_DLC_TITLE, IDS_UNLOCK_DLC_SKIN, uiIDA, 2, iPad,&UIScene_SkinSelectMenu::UnlockSkinReturned,this); 560 } 561 } 562 } 563 } 564 else 565 { 566 app.SetPlayerSkin(iPad, skinFile->getPath()); 567 app.SetPlayerCape(iPad, skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape)); 568 setCharacterSelected(true); 569 m_currentSkinPath = app.GetPlayerSkinName(iPad); 570 m_originalSkinId = app.GetPlayerSkinId(iPad); 571 572 // push this onto the favorite list 573 AddFavoriteSkin(m_iPad,GET_DLC_SKIN_ID_FROM_BITMASK(m_originalSkinId)); 574 } 575 } 576 else 577 { 578 app.SetPlayerSkin(iPad, skinFile->getPath()); 579 app.SetPlayerCape(iPad, skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape)); 580 setCharacterSelected(true); 581 m_currentSkinPath = app.GetPlayerSkinName(iPad); 582 m_originalSkinId = app.GetPlayerSkinId(iPad); 583 584 // push this onto the favorite list 585 AddFavoriteSkin(iPad,GET_DLC_SKIN_ID_FROM_BITMASK(m_originalSkinId)); 586 } 587 588 if (renableInputAfterOperation) 589 { 590 m_bIgnoreInput = false; 591 } 592 } 593 594 ui.PlayUISFX(eSFX_Press); 595 break; 596 } 597} 598 599void UIScene_SkinSelectMenu::customDraw(IggyCustomDrawCallbackRegion *region) 600{ 601 int characterId = -1; 602 swscanf((wchar_t*)region->name,L"Character%d",&characterId); 603 if (characterId == -1) 604 { 605 app.DebugPrintf("Invalid character to render found\n"); 606 } 607 else 608 { 609 // Setup GDraw, normal game render states and matrices 610 CustomDrawData *customDrawRegion = ui.setupCustomDraw(this,region); 611 delete customDrawRegion; 612 613 //app.DebugPrintf("Scissor x0= %d, y0= %d, x1= %d, y1= %d\n", region->scissor_x0, region->scissor_y0, region->scissor_x1, region->scissor_y1); 614 //app.DebugPrintf("Stencil mask= %d, stencil ref= %d, stencil write= %d\n", region->stencil_func_mask, region->stencil_func_ref, region->stencil_write_mask); 615#ifdef __PS3__ 616 if(region->stencil_func_ref != 0) RenderManager.StateSetStencil(GL_EQUAL,region->stencil_func_ref,region->stencil_func_mask); 617#elif __PSVITA__ 618 // AP - make sure the skins are only drawn inside the smokey panel 619 if(region->stencil_func_ref != 0) RenderManager.StateSetStencil(SCE_GXM_STENCIL_FUNC_EQUAL,region->stencil_func_mask,region->stencil_write_mask); 620#else 621 if(region->stencil_func_ref != 0) RenderManager.StateSetStencil(GL_EQUAL,region->stencil_func_ref, region->stencil_func_mask,region->stencil_write_mask); 622#endif 623 m_characters[characterId].render(region); 624 625 // Finish GDraw and anything else that needs to be finalised 626 ui.endCustomDraw(region); 627 } 628} 629 630void UIScene_SkinSelectMenu::handleSkinIndexChanged() 631{ 632 BOOL showPrevious = FALSE, showNext = FALSE; 633 DWORD previousIndex = 0, nextIndex = 0; 634 wstring skinName = L""; 635 wstring skinOrigin = L""; 636 bool bSkinIsFree=false; 637 bool bLicensed=false; 638 DLCSkinFile *skinFile=NULL; 639 DLCPack *Pack=NULL; 640 BYTE sidePreviewControlsL,sidePreviewControlsR; 641 m_bNoSkinsToShow=false; 642 643 TEXTURE_NAME backupTexture = TN_MOB_CHAR; 644 645 setCharacterSelected(false); 646 647 m_controlSkinNamePlate.setVisible( false ); 648 649 if( m_currentPack != NULL ) 650 { 651 skinFile = m_currentPack->getSkinFile(m_skinIndex); 652 m_selectedSkinPath = skinFile->getPath(); 653 m_selectedCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); 654 m_vAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); 655 656 skinName = skinFile->getParameterAsString( DLCManager::e_DLCParamType_DisplayName ); 657 skinOrigin = skinFile->getParameterAsString( DLCManager::e_DLCParamType_ThemeName ); 658 659 if( m_selectedSkinPath.compare( m_currentSkinPath ) == 0 ) 660 { 661 setCharacterSelected(true); 662 } 663 664 bSkinIsFree = skinFile->getParameterAsBool( DLCManager::e_DLCParamType_Free ); 665 bLicensed = m_currentPack->hasPurchasedFile( DLCManager::e_DLCType_Skin, m_selectedSkinPath ); 666 667 setCharacterLocked(!(bSkinIsFree || bLicensed)); 668 669 m_characters[eCharacter_Current].setVisible(true); 670 m_controlSkinNamePlate.setVisible( true ); 671 } 672 else 673 { 674 m_selectedSkinPath = L""; 675 m_selectedCapePath = L""; 676 m_vAdditionalSkinBoxes = NULL; 677 678 switch(m_packIndex) 679 { 680 case SKIN_SELECT_PACK_DEFAULT: 681 backupTexture = getTextureId(m_skinIndex); 682 683 if( m_skinIndex == eDefaultSkins_ServerSelected ) 684 { 685 skinName = app.GetString(IDS_DEFAULT_SKINS); 686 } 687 else 688 { 689 skinName = wchDefaultNamesA[m_skinIndex]; 690 } 691 692 if( m_originalSkinId == m_skinIndex ) 693 { 694 setCharacterSelected(true); 695 } 696 setCharacterLocked(false); 697 setCharacterLocked(false); 698 699 m_characters[eCharacter_Current].setVisible(true); 700 m_controlSkinNamePlate.setVisible( true ); 701 702 break; 703 case SKIN_SELECT_PACK_FAVORITES: 704 705 if(app.GetPlayerFavoriteSkinsCount(m_iPad)>0) 706 { 707 // get the pack number from the skin id 708 wchar_t chars[256]; 709 swprintf(chars, 256, L"dlcskin%08d.png", app.GetPlayerFavoriteSkin(m_iPad,m_skinIndex)); 710 711 Pack=app.m_dlcManager.getPackContainingSkin(chars); 712 if(Pack) 713 { 714 skinFile = Pack->getSkinFile(chars); 715 716 m_selectedSkinPath = skinFile->getPath(); 717 m_selectedCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); 718 m_vAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); 719 720 skinName = skinFile->getParameterAsString( DLCManager::e_DLCParamType_DisplayName ); 721 skinOrigin = skinFile->getParameterAsString( DLCManager::e_DLCParamType_ThemeName ); 722 723 if( m_selectedSkinPath.compare( m_currentSkinPath ) == 0 ) 724 { 725 setCharacterSelected(true); 726 } 727 728 bSkinIsFree = skinFile->getParameterAsBool( DLCManager::e_DLCParamType_Free ); 729 bLicensed = Pack->hasPurchasedFile( DLCManager::e_DLCType_Skin, m_selectedSkinPath ); 730 731 setCharacterLocked(!(bSkinIsFree || bLicensed)); 732 m_controlSkinNamePlate.setVisible( true ); 733 } 734 else 735 { 736 setCharacterSelected(false); 737 setCharacterLocked(false); 738 } 739 } 740 else 741 { 742 //disable the display 743 m_characters[eCharacter_Current].setVisible(false); 744 745 // change the tooltips 746 m_bNoSkinsToShow=true; 747 } 748 break; 749 } 750 } 751 752 m_labelSkinName.setLabel(skinName); 753 m_labelSkinOrigin.setLabel(skinOrigin); 754 755 756 if(m_vAdditionalSkinBoxes && m_vAdditionalSkinBoxes->size()!=0) 757 { 758 // add the boxes to the humanoid model, but only if we've not done this already 759 760 vector<ModelPart *> *pAdditionalModelParts = app.GetAdditionalModelParts(skinFile->getSkinID()); 761 if(pAdditionalModelParts==NULL) 762 { 763 pAdditionalModelParts = app.SetAdditionalSkinBoxes(skinFile->getSkinID(),m_vAdditionalSkinBoxes); 764 } 765 } 766 767 if(skinFile!=NULL) 768 { 769 app.SetAnimOverrideBitmask(skinFile->getSkinID(),skinFile->getAnimOverrideBitmask()); 770 } 771 772 m_characters[eCharacter_Current].SetTexture(m_selectedSkinPath, backupTexture); 773 m_characters[eCharacter_Current].SetCapeTexture(m_selectedCapePath); 774 775 showNext = TRUE; 776 showPrevious = TRUE; 777 nextIndex = getNextSkinIndex(m_skinIndex); 778 previousIndex = getPreviousSkinIndex(m_skinIndex); 779 780 wstring otherSkinPath = L""; 781 wstring otherCapePath = L""; 782 vector<SKIN_BOX *> *othervAdditionalSkinBoxes=NULL; 783 wchar_t chars[256]; 784 785 // turn off all displays 786 for(unsigned int i = eCharacter_Current + 1; i < eCharacter_COUNT; ++i) 787 { 788 m_characters[i].setVisible(false); 789 } 790 791 unsigned int uiCurrentFavoriteC=app.GetPlayerFavoriteSkinsCount(m_iPad); 792 793 if(m_packIndex==SKIN_SELECT_PACK_FAVORITES) 794 { 795 // might not be enough to cycle through 796 if(uiCurrentFavoriteC<((sidePreviewControls*2)+1)) 797 { 798 if(uiCurrentFavoriteC==0) 799 { 800 sidePreviewControlsL=sidePreviewControlsR=0; 801 } 802 // might be an odd number 803 else if((uiCurrentFavoriteC-1)%2==1) 804 { 805 sidePreviewControlsL=1+(uiCurrentFavoriteC-1)/2; 806 sidePreviewControlsR=(uiCurrentFavoriteC-1)/2; 807 } 808 else 809 { 810 sidePreviewControlsL=sidePreviewControlsR=(uiCurrentFavoriteC-1)/2; 811 } 812 } 813 else 814 { 815 sidePreviewControlsL=sidePreviewControlsR=sidePreviewControls; 816 } 817 } 818 else 819 { 820 sidePreviewControlsL=sidePreviewControlsR=sidePreviewControls; 821 } 822 823 for(BYTE i = 0; i < sidePreviewControlsR; ++i) 824 { 825 if(showNext) 826 { 827 skinFile=NULL; 828 829 m_characters[eCharacter_Next1 + i].setVisible(true); 830 831 if( m_currentPack != NULL ) 832 { 833 skinFile = m_currentPack->getSkinFile(nextIndex); 834 otherSkinPath = skinFile->getPath(); 835 otherCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); 836 othervAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); 837 backupTexture = TN_MOB_CHAR; 838 } 839 else 840 { 841 otherSkinPath = L""; 842 otherCapePath = L""; 843 othervAdditionalSkinBoxes=NULL; 844 switch(m_packIndex) 845 { 846 case SKIN_SELECT_PACK_DEFAULT: 847 backupTexture = getTextureId(nextIndex); 848 break; 849 case SKIN_SELECT_PACK_FAVORITES: 850 if(uiCurrentFavoriteC>0) 851 { 852 // get the pack number from the skin id 853 swprintf(chars, 256, L"dlcskin%08d.png", app.GetPlayerFavoriteSkin(m_iPad,nextIndex)); 854 855 Pack=app.m_dlcManager.getPackContainingSkin(chars); 856 if(Pack) 857 { 858 skinFile = Pack->getSkinFile(chars); 859 860 otherSkinPath = skinFile->getPath(); 861 otherCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); 862 othervAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); 863 backupTexture = TN_MOB_CHAR; 864 } 865 } 866 break; 867 default: 868 break; 869 } 870 871 } 872 if(othervAdditionalSkinBoxes && othervAdditionalSkinBoxes->size()!=0) 873 { 874 vector<ModelPart *> *pAdditionalModelParts = app.GetAdditionalModelParts(skinFile->getSkinID()); 875 if(pAdditionalModelParts==NULL) 876 { 877 pAdditionalModelParts = app.SetAdditionalSkinBoxes(skinFile->getSkinID(),othervAdditionalSkinBoxes); 878 } 879 } 880 // 4J-PB - anim override needs set before SetTexture 881 if(skinFile!=NULL) 882 { 883 app.SetAnimOverrideBitmask(skinFile->getSkinID(),skinFile->getAnimOverrideBitmask()); 884 } 885 m_characters[eCharacter_Next1 + i].SetTexture(otherSkinPath, backupTexture); 886 m_characters[eCharacter_Next1 + i].SetCapeTexture(otherCapePath); 887 } 888 889 nextIndex = getNextSkinIndex(nextIndex); 890 } 891 892 893 894 for(BYTE i = 0; i < sidePreviewControlsL; ++i) 895 { 896 if(showPrevious) 897 { 898 skinFile=NULL; 899 900 m_characters[eCharacter_Previous1 + i].setVisible(true); 901 902 if( m_currentPack != NULL ) 903 { 904 skinFile = m_currentPack->getSkinFile(previousIndex); 905 otherSkinPath = skinFile->getPath(); 906 otherCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); 907 othervAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); 908 backupTexture = TN_MOB_CHAR; 909 } 910 else 911 { 912 otherSkinPath = L""; 913 otherCapePath = L""; 914 othervAdditionalSkinBoxes=NULL; 915 switch(m_packIndex) 916 { 917 case SKIN_SELECT_PACK_DEFAULT: 918 backupTexture = getTextureId(previousIndex); 919 break; 920 case SKIN_SELECT_PACK_FAVORITES: 921 if(uiCurrentFavoriteC>0) 922 { 923 // get the pack number from the skin id 924 swprintf(chars, 256, L"dlcskin%08d.png", app.GetPlayerFavoriteSkin(m_iPad,previousIndex)); 925 926 Pack=app.m_dlcManager.getPackContainingSkin(chars); 927 if(Pack) 928 { 929 skinFile = Pack->getSkinFile(chars); 930 931 otherSkinPath = skinFile->getPath(); 932 otherCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); 933 othervAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); 934 backupTexture = TN_MOB_CHAR; 935 } 936 } 937 938 break; 939 default: 940 break; 941 } 942 } 943 if(othervAdditionalSkinBoxes && othervAdditionalSkinBoxes->size()!=0) 944 { 945 vector<ModelPart *> *pAdditionalModelParts = app.GetAdditionalModelParts(skinFile->getSkinID()); 946 if(pAdditionalModelParts==NULL) 947 { 948 pAdditionalModelParts = app.SetAdditionalSkinBoxes(skinFile->getSkinID(),othervAdditionalSkinBoxes); 949 } 950 } 951 // 4J-PB - anim override needs set before SetTexture 952 if(skinFile) 953 { 954 app.SetAnimOverrideBitmask(skinFile->getSkinID(),skinFile->getAnimOverrideBitmask()); 955 } 956 m_characters[eCharacter_Previous1 + i].SetTexture(otherSkinPath, backupTexture); 957 m_characters[eCharacter_Previous1 + i].SetCapeTexture(otherCapePath); 958 } 959 960 previousIndex = getPreviousSkinIndex(previousIndex); 961 } 962 963 updateTooltips(); 964} 965 966TEXTURE_NAME UIScene_SkinSelectMenu::getTextureId(int skinIndex) 967{ 968 TEXTURE_NAME texture = TN_MOB_CHAR; 969 switch(skinIndex) 970 { 971 case eDefaultSkins_ServerSelected: 972 case eDefaultSkins_Skin0: 973 texture = TN_MOB_CHAR; 974 break; 975 case eDefaultSkins_Skin1: 976 texture = TN_MOB_CHAR1; 977 break; 978 case eDefaultSkins_Skin2: 979 texture = TN_MOB_CHAR2; 980 break; 981 case eDefaultSkins_Skin3: 982 texture = TN_MOB_CHAR3; 983 break; 984 case eDefaultSkins_Skin4: 985 texture = TN_MOB_CHAR4; 986 break; 987 case eDefaultSkins_Skin5: 988 texture = TN_MOB_CHAR5; 989 break; 990 case eDefaultSkins_Skin6: 991 texture = TN_MOB_CHAR6; 992 break; 993 case eDefaultSkins_Skin7: 994 texture = TN_MOB_CHAR7; 995 break; 996 }; 997 998 return texture; 999} 1000 1001int UIScene_SkinSelectMenu::getNextSkinIndex(DWORD sourceIndex) 1002{ 1003 int nextSkin = sourceIndex; 1004 1005 // special case for favourites 1006 switch(m_packIndex) 1007 { 1008 1009 case SKIN_SELECT_PACK_FAVORITES: 1010 ++nextSkin; 1011 if(nextSkin>=app.GetPlayerFavoriteSkinsCount(m_iPad)) 1012 { 1013 nextSkin=0; 1014 } 1015 1016 break; 1017 default: 1018 ++nextSkin; 1019 1020 if(m_packIndex == SKIN_SELECT_PACK_DEFAULT && nextSkin >= eDefaultSkins_Count) 1021 { 1022 nextSkin = eDefaultSkins_ServerSelected; 1023 } 1024 else if(m_currentPack != NULL && nextSkin>=m_currentPack->getSkinCount()) 1025 { 1026 nextSkin = 0; 1027 } 1028 break; 1029 } 1030 1031 1032 return nextSkin; 1033} 1034 1035int UIScene_SkinSelectMenu::getPreviousSkinIndex(DWORD sourceIndex) 1036{ 1037 int previousSkin = sourceIndex; 1038 switch(m_packIndex) 1039 { 1040 1041 case SKIN_SELECT_PACK_FAVORITES: 1042 if(previousSkin==0) 1043 { 1044 previousSkin = app.GetPlayerFavoriteSkinsCount(m_iPad) - 1; 1045 } 1046 else 1047 { 1048 --previousSkin; 1049 } 1050 break; 1051 default: 1052 if(previousSkin==0) 1053 { 1054 if(m_packIndex == SKIN_SELECT_PACK_DEFAULT) 1055 { 1056 previousSkin = eDefaultSkins_Count - 1; 1057 } 1058 else if(m_currentPack != NULL) 1059 { 1060 previousSkin = m_currentPack->getSkinCount()-1; 1061 } 1062 } 1063 else 1064 { 1065 --previousSkin; 1066 } 1067 break; 1068 } 1069 1070 1071 return previousSkin; 1072} 1073 1074void UIScene_SkinSelectMenu::handlePackIndexChanged() 1075{ 1076 if(m_packIndex >= SKIN_SELECT_MAX_DEFAULTS) 1077 { 1078 m_currentPack = app.m_dlcManager.getPack(m_packIndex - SKIN_SELECT_MAX_DEFAULTS, DLCManager::e_DLCType_Skin); 1079 } 1080 else 1081 { 1082 m_currentPack = NULL; 1083 } 1084 m_skinIndex = 0; 1085 if(m_currentPack != NULL) 1086 { 1087 bool found; 1088 DWORD currentSkinIndex = m_currentPack->getSkinIndexAt(m_currentSkinPath, found); 1089 if(found) m_skinIndex = currentSkinIndex; 1090 } 1091 else 1092 { 1093 switch(m_packIndex) 1094 { 1095 case SKIN_SELECT_PACK_DEFAULT: 1096 if( !GET_IS_DLC_SKIN_FROM_BITMASK(m_originalSkinId) ) 1097 { 1098 DWORD ugcSkinIndex = GET_UGC_SKIN_ID_FROM_BITMASK(m_originalSkinId); 1099 DWORD defaultSkinIndex = GET_DEFAULT_SKIN_ID_FROM_BITMASK(m_originalSkinId); 1100 if( ugcSkinIndex == 0 ) 1101 { 1102 m_skinIndex = (EDefaultSkins) defaultSkinIndex; 1103 } 1104 } 1105 break; 1106 case SKIN_SELECT_PACK_FAVORITES: 1107 if(app.GetPlayerFavoriteSkinsCount(m_iPad)>0) 1108 { 1109 bool found; 1110 wchar_t chars[256]; 1111 // get the pack number from the skin id 1112 swprintf(chars, 256, L"dlcskin%08d.png", app.GetPlayerFavoriteSkin(m_iPad,app.GetPlayerFavoriteSkinsPos(m_iPad))); 1113 1114 DLCPack *Pack=app.m_dlcManager.getPackContainingSkin(chars); 1115 if(Pack) 1116 { 1117 DWORD currentSkinIndex = Pack->getSkinIndexAt(m_currentSkinPath, found); 1118 if(found) m_skinIndex = app.GetPlayerFavoriteSkinsPos(m_iPad); 1119 } 1120 } 1121 break; 1122 default: 1123 break; 1124 } 1125 } 1126 handleSkinIndexChanged(); 1127 updatePackDisplay(); 1128} 1129 1130std::wstring fakeWideToRealWide(const wchar_t* original) 1131{ 1132 const char* name = reinterpret_cast<const char*>(original); 1133 int len = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0); 1134 std::wstring wName(len, 0); 1135 MultiByteToWideChar(CP_UTF8, 0, name, -1, &wName[0], len); 1136 return wName.c_str(); 1137} 1138 1139void UIScene_SkinSelectMenu::updatePackDisplay() 1140{ 1141 m_currentPackCount = app.m_dlcManager.getPackCount(DLCManager::e_DLCType_Skin) + SKIN_SELECT_MAX_DEFAULTS; 1142 1143 if(m_packIndex >= SKIN_SELECT_MAX_DEFAULTS) 1144 { 1145 DLCPack *thisPack = app.m_dlcManager.getPack(m_packIndex - SKIN_SELECT_MAX_DEFAULTS, DLCManager::e_DLCType_Skin); 1146 // Fix the incorrect string type on title to display correctly 1147 setCentreLabel(fakeWideToRealWide(thisPack->getName().c_str())); 1148 //setCentreLabel(thisPack->getName().c_str()); 1149 } 1150 else 1151 { 1152 switch(m_packIndex) 1153 { 1154 case SKIN_SELECT_PACK_DEFAULT: 1155 setCentreLabel(app.GetString(IDS_NO_SKIN_PACK)); 1156 break; 1157 case SKIN_SELECT_PACK_FAVORITES: 1158 setCentreLabel(app.GetString(IDS_FAVORITES_SKIN_PACK)); 1159 break; 1160 } 1161 } 1162 1163 int nextPackIndex = getNextPackIndex(m_packIndex); 1164 if(nextPackIndex >= SKIN_SELECT_MAX_DEFAULTS) 1165 { 1166 DLCPack *thisPack = app.m_dlcManager.getPack(nextPackIndex - SKIN_SELECT_MAX_DEFAULTS, DLCManager::e_DLCType_Skin); 1167 // Fix the incorrect string type on title to display correctly 1168 setRightLabel(fakeWideToRealWide(thisPack->getName().c_str())); 1169 //setRightLabel(thisPack->getName().c_str()); 1170 } 1171 else 1172 { 1173 switch(nextPackIndex) 1174 { 1175 case SKIN_SELECT_PACK_DEFAULT: 1176 setRightLabel(app.GetString(IDS_NO_SKIN_PACK)); 1177 break; 1178 case SKIN_SELECT_PACK_FAVORITES: 1179 setRightLabel(app.GetString(IDS_FAVORITES_SKIN_PACK)); 1180 break; 1181 } 1182 } 1183 1184 int previousPackIndex = getPreviousPackIndex(m_packIndex); 1185 if(previousPackIndex >= SKIN_SELECT_MAX_DEFAULTS) 1186 { 1187 DLCPack *thisPack = app.m_dlcManager.getPack(previousPackIndex - SKIN_SELECT_MAX_DEFAULTS, DLCManager::e_DLCType_Skin); 1188 // Fix the incorrect string type on title to display correctly 1189 setLeftLabel(fakeWideToRealWide(thisPack->getName().c_str())); 1190 //setLeftLabel(thisPack->getName().c_str()); 1191 } 1192 else 1193 { 1194 switch(previousPackIndex) 1195 { 1196 case SKIN_SELECT_PACK_DEFAULT: 1197 setLeftLabel(app.GetString(IDS_NO_SKIN_PACK)); 1198 break; 1199 case SKIN_SELECT_PACK_FAVORITES: 1200 setLeftLabel(app.GetString(IDS_FAVORITES_SKIN_PACK)); 1201 break; 1202 } 1203 } 1204 1205} 1206 1207int UIScene_SkinSelectMenu::getNextPackIndex(DWORD sourceIndex) 1208{ 1209 int nextPack = sourceIndex; 1210 ++nextPack; 1211 if(nextPack > app.m_dlcManager.getPackCount(DLCManager::e_DLCType_Skin) - 1 + SKIN_SELECT_MAX_DEFAULTS) 1212 { 1213 nextPack = SKIN_SELECT_PACK_DEFAULT; 1214 } 1215 1216 return nextPack; 1217} 1218 1219int UIScene_SkinSelectMenu::getPreviousPackIndex(DWORD sourceIndex) 1220{ 1221 int previousPack = sourceIndex; 1222 if (previousPack == SKIN_SELECT_PACK_DEFAULT) 1223 { 1224 DWORD packCount = app.m_dlcManager.getPackCount(DLCManager::e_DLCType_Skin); 1225 1226 if (packCount > 0) 1227 { 1228 previousPack = packCount + SKIN_SELECT_MAX_DEFAULTS - 1; 1229 } 1230 else 1231 { 1232 previousPack = SKIN_SELECT_MAX_DEFAULTS - 1; 1233 } 1234 } 1235 else 1236 { 1237 --previousPack; 1238 } 1239 1240 return previousPack; 1241} 1242 1243void UIScene_SkinSelectMenu::setCharacterSelected(bool selected) 1244{ 1245 IggyDataValue result; 1246 IggyDataValue value[1]; 1247 value[0].type = IGGY_DATATYPE_boolean; 1248 value[0].boolval = selected; 1249 IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetPlayerCharacterSelected , 1 , value ); 1250} 1251 1252void UIScene_SkinSelectMenu::setCharacterLocked(bool locked) 1253{ 1254 IggyDataValue result; 1255 IggyDataValue value[1]; 1256 value[0].type = IGGY_DATATYPE_boolean; 1257 value[0].boolval = locked; 1258 IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetCharacterLocked , 1 , value ); 1259} 1260 1261void UIScene_SkinSelectMenu::setLeftLabel(const wstring &label) 1262{ 1263 if(label.compare(m_leftLabel) != 0) 1264 { 1265 m_leftLabel = label; 1266 1267 IggyDataValue result; 1268 IggyDataValue value[1]; 1269 1270 IggyStringUTF16 stringVal; 1271 stringVal.string = (IggyUTF16*)label.c_str(); 1272 stringVal.length = label.length(); 1273 1274 value[0].type = IGGY_DATATYPE_string_UTF16; 1275 value[0].string16 = stringVal; 1276 IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetLeftLabel , 1 , value ); 1277 } 1278} 1279 1280void UIScene_SkinSelectMenu::setCentreLabel(const wstring &label) 1281{ 1282 if(label.compare(m_centreLabel) != 0) 1283 { 1284 m_centreLabel = label; 1285 1286 IggyDataValue result; 1287 IggyDataValue value[1]; 1288 1289 IggyStringUTF16 stringVal; 1290 stringVal.string = (IggyUTF16*)label.c_str(); 1291 stringVal.length = label.length(); 1292 1293 value[0].type = IGGY_DATATYPE_string_UTF16; 1294 value[0].string16 = stringVal; 1295 IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetCentreLabel , 1 , value ); 1296 } 1297} 1298 1299void UIScene_SkinSelectMenu::setRightLabel(const wstring &label) 1300{ 1301 if(label.compare(m_rightLabel) != 0) 1302 { 1303 m_rightLabel = label; 1304 1305 IggyDataValue result; 1306 IggyDataValue value[1]; 1307 1308 IggyStringUTF16 stringVal; 1309 stringVal.string = (IggyUTF16*)label.c_str(); 1310 stringVal.length = label.length(); 1311 1312 value[0].type = IGGY_DATATYPE_string_UTF16; 1313 value[0].string16 = stringVal; 1314 IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetRightLabel , 1 , value ); 1315 } 1316} 1317 1318#ifdef __PSVITA__ 1319void UIScene_SkinSelectMenu::handleTouchInput(unsigned int iPad, S32 x, S32 y, int iId, bool bPressed, bool bRepeat, bool bReleased) 1320{ 1321 if(bPressed) 1322 { 1323 switch(iId) 1324 { 1325 case ETouchInput_TabLeft: 1326 case ETouchInput_TabRight: 1327 case ETouchInput_TabCenter: 1328 // change to pack navigation if not already there! 1329 if(m_currentNavigation != eSkinNavigation_Pack) 1330 { 1331 ui.PlayUISFX(eSFX_Scroll); 1332 m_currentNavigation = eSkinNavigation_Pack; 1333 sendInputToMovie(ACTION_MENU_UP, false, true, false); 1334 } 1335 break; 1336 case ETouchInput_IggyCharacters: 1337 if(m_packIndex == SKIN_SELECT_PACK_FAVORITES) 1338 { 1339 if(app.GetPlayerFavoriteSkinsCount(m_iPad)==0) 1340 { 1341 // ignore this, since there are no skins being displayed 1342 break; 1343 } 1344 } 1345 // change to skin navigation if not already there! 1346 if(m_currentNavigation != eSkinNavigation_Skin) 1347 { 1348 ui.PlayUISFX(eSFX_Scroll); 1349 m_currentNavigation = eSkinNavigation_Skin; 1350 sendInputToMovie(ACTION_MENU_DOWN, false, true, false); 1351 } 1352 // remember touch x start 1353 m_iTouchXStart = x; 1354 m_bTouchScrolled = false; 1355 break; 1356 } 1357 } 1358 else if(bRepeat) 1359 { 1360 switch(iId) 1361 { 1362 case ETouchInput_TabLeft: 1363 /* no action */ 1364 break; 1365 case ETouchInput_TabRight: 1366 /* no action */ 1367 break; 1368 case ETouchInput_IggyCharacters: 1369 if(m_currentNavigation != eSkinNavigation_Skin) 1370 { 1371 // not in skin select mode 1372 break; 1373 } 1374 if(x < m_iTouchXStart - 50) 1375 { 1376 if(!m_bAnimatingMove && !m_bTouchScrolled) 1377 { 1378 ui.PlayUISFX(eSFX_Scroll); 1379 m_skinIndex = getNextSkinIndex(m_skinIndex); 1380 //handleSkinIndexChanged(); 1381 1382 m_bSlidingSkins = true; 1383 m_bAnimatingMove = true; 1384 1385 m_characters[eCharacter_Current].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Right, true); 1386 m_characters[eCharacter_Next1].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Forward, true); 1387 1388 // 4J Stu - Swapped nav buttons 1389 sendInputToMovie(ACTION_MENU_LEFT, false, true, false); 1390 1391 m_bTouchScrolled = true; 1392 } 1393 } 1394 else if(x > m_iTouchXStart + 50) 1395 { 1396 if(!m_bAnimatingMove && !m_bTouchScrolled) 1397 { 1398 ui.PlayUISFX(eSFX_Scroll); 1399 1400 m_skinIndex = getPreviousSkinIndex(m_skinIndex); 1401 //handleSkinIndexChanged(); 1402 1403 m_bSlidingSkins = true; 1404 m_bAnimatingMove = true; 1405 1406 m_characters[eCharacter_Current].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Left, true); 1407 m_characters[eCharacter_Previous1].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Forward, true); 1408 1409 // 4J Stu - Swapped nav buttons 1410 sendInputToMovie(ACTION_MENU_RIGHT, false, true, false); 1411 1412 m_bTouchScrolled = true; 1413 } 1414 } 1415 break; 1416 } 1417 } 1418 else if(bReleased) 1419 { 1420 switch(iId) 1421 { 1422 case ETouchInput_TabLeft: 1423 if( m_currentNavigation == eSkinNavigation_Pack ) 1424 { 1425 ui.PlayUISFX(eSFX_Scroll); 1426 DWORD startingIndex = m_packIndex; 1427 m_packIndex = getPreviousPackIndex(m_packIndex); 1428 if(startingIndex != m_packIndex) 1429 { 1430 handlePackIndexChanged(); 1431 } 1432 } 1433 break; 1434 case ETouchInput_TabRight: 1435 if( m_currentNavigation == eSkinNavigation_Pack ) 1436 { 1437 ui.PlayUISFX(eSFX_Scroll); 1438 DWORD startingIndex = m_packIndex; 1439 m_packIndex = getNextPackIndex(m_packIndex); 1440 if(startingIndex != m_packIndex) 1441 { 1442 handlePackIndexChanged(); 1443 } 1444 } 1445 break; 1446 case ETouchInput_IggyCharacters: 1447 if(!m_bTouchScrolled) 1448 { 1449 InputActionOK(iPad); 1450 } 1451 break; 1452 } 1453 } 1454} 1455#endif 1456 1457void UIScene_SkinSelectMenu::HandleDLCInstalled() 1458{ 1459#ifdef __PSVITA__ 1460 EnterCriticalSection(&m_DLCInstallCS); // to prevent a race condition between the install and the mounted callback 1461#endif 1462 1463 app.DebugPrintf(4,"UIScene_SkinSelectMenu::HandleDLCInstalled\n"); 1464 // mounted DLC may have changed 1465 if(app.StartInstallDLCProcess(m_iPad)==false) 1466 { 1467 // not doing a mount, so re-enable input 1468 app.DebugPrintf(4,"UIScene_SkinSelectMenu::HandleDLCInstalled - not doing a mount, so re-enable input\n"); 1469 m_bIgnoreInput=false; 1470 } 1471 else 1472 { 1473 m_bIgnoreInput=true; 1474 m_controlTimer.setVisible( true ); 1475 m_controlIggyCharacters.setVisible( false ); 1476 m_controlSkinNamePlate.setVisible( false ); 1477 } 1478 1479 // this will send a CustomMessage_DLCMountingComplete when done 1480 1481#ifdef __PSVITA__ 1482 LeaveCriticalSection(&m_DLCInstallCS); 1483#endif 1484 1485} 1486 1487 1488void UIScene_SkinSelectMenu::HandleDLCMountingComplete() 1489{ 1490#ifdef __PSVITA__ 1491 EnterCriticalSection(&m_DLCInstallCS); // to prevent a race condition between the install and the mounted callback 1492#endif 1493 app.DebugPrintf(4,"UIScene_SkinSelectMenu::HandleDLCMountingComplete\n"); 1494 m_controlTimer.setVisible( false ); 1495 m_controlIggyCharacters.setVisible( true ); 1496 m_controlSkinNamePlate.setVisible( true ); 1497 1498 m_packIndex = SKIN_SELECT_PACK_DEFAULT; 1499 1500 if(app.m_dlcManager.getPackCount(DLCManager::e_DLCType_Skin)>0) 1501 { 1502 m_currentPack = app.m_dlcManager.getPackContainingSkin(m_currentSkinPath); 1503 if(m_currentPack != NULL) 1504 { 1505 bool bFound = false; 1506 m_packIndex = app.m_dlcManager.getPackIndex(m_currentPack,bFound,DLCManager::e_DLCType_Skin) + SKIN_SELECT_MAX_DEFAULTS; 1507 } 1508 } 1509 1510 // If we have any favourites, set this to the favourites 1511 // first validate the favorite skins - we might have uninstalled the DLC needed for them 1512 app.ValidateFavoriteSkins(m_iPad); 1513 1514 if(app.GetPlayerFavoriteSkinsCount(m_iPad)>0) 1515 { 1516 m_packIndex = SKIN_SELECT_PACK_FAVORITES; 1517 } 1518 1519 handlePackIndexChanged(); 1520 1521 m_bIgnoreInput=false; 1522 app.m_dlcManager.checkForCorruptDLCAndAlert(); 1523 bool bInGame=(Minecraft::GetInstance()->level!=NULL); 1524 1525#if TO_BE_IMPLEMENTED 1526 if(bInGame) XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_AUTO); 1527#endif 1528#ifdef __PSVITA__ 1529 LeaveCriticalSection(&m_DLCInstallCS); 1530#endif 1531} 1532 1533void UIScene_SkinSelectMenu::showNotOnlineDialog(int iPad) 1534{ 1535 // need to be signed in to live. get them to sign in to online 1536#if defined(__PS3__) 1537 SQRNetworkManager_PS3::AttemptPSNSignIn(NULL, this); 1538 1539#elif defined(__PSVITA__) 1540 if(CGameNetworkManager::usingAdhocMode() && SQRNetworkManager_AdHoc_Vita::GetAdhocStatus()) 1541 { 1542 // we're in adhoc mode, we really need to ask before disconnecting 1543 UINT uiIDA[2]; 1544 uiIDA[0]=IDS_PRO_NOTONLINE_ACCEPT; 1545 uiIDA[1]=IDS_CANCEL; 1546 ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&UIScene_SkinSelectMenu::MustSignInReturned,NULL); 1547 } 1548 else 1549 { 1550 SQRNetworkManager_Vita::AttemptPSNSignIn(NULL, this); 1551 } 1552 1553#elif defined(__ORBIS__) 1554 SQRNetworkManager_Orbis::AttemptPSNSignIn(NULL, this, false, iPad); 1555 1556#elif defined(_DURANGO) 1557 1558 UINT uiIDA[1] = { IDS_CONFIRM_OK }; 1559 ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, iPad ); 1560 1561#endif 1562} 1563 1564int UIScene_SkinSelectMenu::UnlockSkinReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 1565{ 1566 UIScene_SkinSelectMenu* pScene = (UIScene_SkinSelectMenu*)pParam; 1567 1568 if ( (result == C4JStorage::EMessage_ResultAccept) 1569 && ProfileManager.IsSignedIn(iPad) 1570 ) 1571 { 1572 if (ProfileManager.IsSignedInLive(iPad)) 1573 { 1574#if defined(__PS3__) || defined(__ORBIS__) || defined __PSVITA__ 1575 // need to get info on the pack to see if the user has already downloaded it 1576 1577 // retrieve the store name for the skin pack 1578 wstring wStrPackName=pScene->m_currentPack->getName(); 1579 const char *pchPackName=wstringtofilename(wStrPackName); 1580 SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo((char *)pchPackName); 1581 1582 if (pSONYDLCInfo != NULL) 1583 { 1584 char chName[42]; 1585 char chKeyName[20]; 1586 char chSkuID[SCE_NP_COMMERCE2_SKU_ID_LEN]; 1587 1588 memset(chSkuID,0,SCE_NP_COMMERCE2_SKU_ID_LEN); 1589 // find the info on the skin pack 1590 // we have to retrieve the skuid from the store info, it can't be hardcoded since Sony may change it. 1591 // So we assume the first sku for the product is the one we want 1592 1593 // while the store is screwed, hardcode the sku 1594 //sprintf(chName,"%s-%s-%s",app.GetCommerceCategory(),pSONYDLCInfo->chDLCKeyname,"EURO"); 1595 1596 // MGH - keyname in the DLC file is 16 chars long, but there's no space for a NULL terminating char 1597 memset(chKeyName, 0, sizeof(chKeyName)); 1598 strncpy(chKeyName, pSONYDLCInfo->chDLCKeyname, 16); 1599 1600#ifdef __ORBIS__ 1601 strcpy(chName, chKeyName); 1602#else 1603 sprintf(chName,"%s-%s",app.GetCommerceCategory(),chKeyName); 1604#endif 1605 app.GetDLCSkuIDFromProductList(chName,chSkuID); 1606 1607#if defined __ORBIS__ || defined __PSVITA__ || defined __PS3__ 1608 if (app.CheckForEmptyStore(iPad) == false) 1609#endif 1610 { 1611 if (app.DLCAlreadyPurchased(chSkuID)) 1612 { 1613 app.DebugPrintf("Already purchased this DLC - DownloadAlreadyPurchased \n"); 1614 app.DownloadAlreadyPurchased(chSkuID); 1615 } 1616 else 1617 { 1618 app.DebugPrintf("Not yet purchased this DLC - Checkout \n"); 1619 app.Checkout(chSkuID); 1620 } 1621 } 1622 } 1623 // need to re-enable input because the user can back out of the store purchase, and we'll be stuck 1624 pScene->m_bIgnoreInput = false; // MGH - moved this to outside the pSONYDLCInfo, so we don't get stuck 1625#elif defined _XBOX_ONE 1626 StorageManager.InstallOffer(1,(WCHAR *)(pScene->m_currentPack->getPurchaseOfferId().c_str()), &RenableInput, pScene, NULL); 1627#endif 1628 } 1629 else // Is signed in, but not live. 1630 { 1631 pScene->showNotOnlineDialog(iPad); 1632 pScene->m_bIgnoreInput = false; 1633 } 1634 } 1635 else 1636 { 1637 pScene->m_bIgnoreInput = false; 1638 } 1639 1640 return 0; 1641} 1642 1643int UIScene_SkinSelectMenu::RenableInput(LPVOID lpVoid, int, int) 1644{ 1645 ((UIScene_SkinSelectMenu*) lpVoid)->m_bIgnoreInput = false; 1646 return 0; 1647} 1648 1649void UIScene_SkinSelectMenu::AddFavoriteSkin(int iPad,int iSkinID) 1650{ 1651 // Is this favorite skin already in the array? 1652 unsigned int uiCurrentFavoriteSkinsCount=app.GetPlayerFavoriteSkinsCount(iPad); 1653 1654 for(int i=0;i<uiCurrentFavoriteSkinsCount;i++) 1655 { 1656 if(app.GetPlayerFavoriteSkin(m_iPad,i)==iSkinID) 1657 { 1658 app.SetPlayerFavoriteSkinsPos(m_iPad,i); 1659 return; 1660 } 1661 } 1662 1663 unsigned char ucPos=app.GetPlayerFavoriteSkinsPos(m_iPad); 1664 if(ucPos==(MAX_FAVORITE_SKINS-1)) 1665 { 1666 ucPos=0; 1667 } 1668 else 1669 { 1670 if(uiCurrentFavoriteSkinsCount>0) 1671 { 1672 ucPos++; 1673 } 1674 else 1675 { 1676 ucPos=0; 1677 } 1678 } 1679 1680 app.SetPlayerFavoriteSkin(iPad,(int)ucPos,iSkinID); 1681 app.SetPlayerFavoriteSkinsPos(m_iPad,ucPos); 1682} 1683 1684 1685void UIScene_SkinSelectMenu::handleReload() 1686{ 1687 // Reinitialise a few values to prevent problems on reload 1688 m_bIgnoreInput=false; 1689 1690 m_currentNavigation = eSkinNavigation_Skin; 1691 m_currentPackCount = 0; 1692 1693 m_labelSkinName.init(L""); 1694 m_labelSkinOrigin.init(L""); 1695 1696 m_leftLabel = L""; 1697 m_centreLabel = L""; 1698 m_rightLabel = L""; 1699 1700 handlePackIndexChanged(); 1701} 1702 1703#ifdef _XBOX_ONE 1704void UIScene_SkinSelectMenu::HandleDLCLicenseChange() 1705{ 1706 // update the lock flag 1707 handleSkinIndexChanged(); 1708} 1709#endif 1710 1711 1712 1713 1714#ifdef __PSVITA__ 1715int UIScene_SkinSelectMenu::MustSignInReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 1716{ 1717 if(result==C4JStorage::EMessage_ResultAccept) 1718 { 1719#ifdef __PS3__ 1720 SQRNetworkManager_PS3::AttemptPSNSignIn(&UIScene_SkinSelectMenu::PSNSignInReturned, pParam,true); 1721#elif defined __PSVITA__ 1722 SQRNetworkManager_Vita::AttemptPSNSignIn(&UIScene_SkinSelectMenu::PSNSignInReturned, pParam,true); 1723#elif defined __ORBIS__ 1724 SQRNetworkManager_Orbis::AttemptPSNSignIn(&UIScene_SkinSelectMenu::PSNSignInReturned, pParam,true); 1725#endif 1726 } 1727 return 0; 1728} 1729 1730int UIScene_SkinSelectMenu::PSNSignInReturned(void* pParam, bool bContinue, int iPad) 1731{ 1732 if( bContinue ) 1733 { 1734 } 1735 return 0; 1736} 1737#endif // __PSVITA__