the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 379 lines 11 kB view raw
1#include "stdafx.h" 2#include "UI.h" 3#include "TexturePack.h" 4#include "TexturePackRepository.h" 5#include "Minecraft.h" 6#include "IUIScene_StartGame.h" 7 8IUIScene_StartGame::IUIScene_StartGame(int iPad, UILayer *parentLayer) : UIScene(iPad, parentLayer) 9{ 10 m_bIgnoreInput = false; 11 m_iTexturePacksNotInstalled=0; 12 m_texturePackDescDisplayed = false; 13 m_bShowTexturePackDescription = false; 14 m_iSetTexturePackDescription = -1; 15 16 Minecraft *pMinecraft = Minecraft::GetInstance(); 17 m_currentTexturePackIndex = pMinecraft->skins->getTexturePackIndex(0); 18} 19 20void IUIScene_StartGame::HandleDLCMountingComplete() 21{ 22 Minecraft *pMinecraft = Minecraft::GetInstance(); 23 // clear out the current texture pack list 24 m_texturePackList.clearSlots(); 25 26 int texturePacksCount = pMinecraft->skins->getTexturePackCount(); 27 28 for(unsigned int i = 0; i < texturePacksCount; ++i) 29 { 30 TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i); 31 32 DWORD dwImageBytes; 33 PBYTE pbImageData = tp->getPackIcon(dwImageBytes); 34 35 if(dwImageBytes > 0 && pbImageData) 36 { 37 wchar_t imageName[64]; 38 swprintf(imageName,64,L"tpack%08x",tp->getId()); 39 registerSubstitutionTexture(imageName, pbImageData, dwImageBytes); 40 m_texturePackList.addPack(i,imageName); 41 } 42 } 43 44 m_iTexturePacksNotInstalled=0; 45 46 // 4J-PB - there may be texture packs we don't have, so use the info from TMS for this 47 // REMOVE UNTIL WORKING 48 DLC_INFO *pDLCInfo=NULL; 49 50 // first pass - look to see if there are any that are not in the list 51 bool bTexturePackAlreadyListed; 52 bool bNeedToGetTPD=false; 53 54 for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i) 55 { 56 bTexturePackAlreadyListed=false; 57#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) 58 char *pchName=app.GetDLCInfoTextures(i); 59 pDLCInfo=app.GetDLCInfo(pchName); 60#elif defined _XBOX_ONE 61 pDLCInfo=app.GetDLCInfoForFullOfferID((WCHAR *)app.GetDLCInfoTexturesFullOffer(i).c_str()); 62#else 63 ULONGLONG ull=app.GetDLCInfoTexturesFullOffer(i); 64 pDLCInfo=app.GetDLCInfoForFullOfferID(ull); 65#endif 66 for(unsigned int i = 0; i < texturePacksCount; ++i) 67 { 68 TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i); 69 if(pDLCInfo->iConfig==tp->getDLCParentPackId()) 70 { 71 bTexturePackAlreadyListed=true; 72 } 73 } 74 if(bTexturePackAlreadyListed==false) 75 { 76 // some missing 77 bNeedToGetTPD=true; 78 79 m_iTexturePacksNotInstalled++; 80 } 81 } 82 83#if TO_BE_IMPLEMENTED 84 if(bNeedToGetTPD==true) 85 { 86 // add a TMS request for them 87 app.DebugPrintf("+++ Adding TMSPP request for texture pack data\n"); 88 app.AddTMSPPFileTypeRequest(e_DLC_TexturePackData); 89 if(m_iConfigA!=NULL) 90 { 91 delete m_iConfigA; 92 } 93 m_iConfigA= new int [m_iTexturePacksNotInstalled]; 94 m_iTexturePacksNotInstalled=0; 95 96 for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i) 97 { 98 bTexturePackAlreadyListed=false; 99 ULONGLONG ull=app.GetDLCInfoTexturesFullOffer(i); 100 pDLCInfo=app.GetDLCInfoForFullOfferID(ull); 101 for(unsigned int i = 0; i < texturePacksCount; ++i) 102 { 103 TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i); 104 if(pDLCInfo->iConfig==tp->getDLCParentPackId()) 105 { 106 bTexturePackAlreadyListed=true; 107 } 108 } 109 if(bTexturePackAlreadyListed==false) 110 { 111 m_iConfigA[m_iTexturePacksNotInstalled++]=pDLCInfo->iConfig; 112 } 113 } 114 } 115#endif 116 m_currentTexturePackIndex = pMinecraft->skins->getTexturePackIndex(0); 117 UpdateTexturePackDescription(m_currentTexturePackIndex); 118 119 m_texturePackList.selectSlot(m_currentTexturePackIndex); 120 m_bIgnoreInput=false; 121 app.m_dlcManager.checkForCorruptDLCAndAlert(); 122} 123 124void IUIScene_StartGame::handleSelectionChanged(F64 selectedId) 125{ 126 m_iSetTexturePackDescription = (int)selectedId; 127 128 if(!m_texturePackDescDisplayed) 129 { 130 m_bShowTexturePackDescription = true; 131 } 132} 133 134void IUIScene_StartGame::UpdateTexturePackDescription(int index) 135{ 136 TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackByIndex(index); 137 138 if(tp==NULL) 139 { 140#if TO_BE_IMPLEMENTED 141 // this is probably a texture pack icon added from TMS 142 143 DWORD dwBytes=0,dwFileBytes=0; 144 PBYTE pbData=NULL,pbFileData=NULL; 145 146 CXuiCtrl4JList::LIST_ITEM_INFO ListItem; 147 // get the current index of the list, and then get the data 148 ListItem=m_pTexturePacksList->GetData(index); 149 150 app.GetTPD(ListItem.iData,&pbData,&dwBytes); 151 152 app.GetFileFromTPD(eTPDFileType_Loc,pbData,dwBytes,&pbFileData,&dwFileBytes ); 153 if(dwFileBytes > 0 && pbFileData) 154 { 155 StringTable *pStringTable = new StringTable(pbFileData, dwFileBytes); 156 m_texturePackTitle.SetText(pStringTable->getString(L"IDS_DISPLAY_NAME")); 157 m_texturePackDescription.SetText(pStringTable->getString(L"IDS_TP_DESCRIPTION")); 158 } 159 160 app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbFileData,&dwFileBytes ); 161 if(dwFileBytes >= 0 && pbFileData) 162 { 163 XuiCreateTextureBrushFromMemory(pbFileData,dwFileBytes,&m_hTexturePackIconBrush); 164 m_texturePackIcon->UseBrush(m_hTexturePackIconBrush); 165 } 166 app.GetFileFromTPD(eTPDFileType_Comparison,pbData,dwBytes,&pbFileData,&dwFileBytes ); 167 if(dwFileBytes >= 0 && pbFileData) 168 { 169 XuiCreateTextureBrushFromMemory(pbFileData,dwFileBytes,&m_hTexturePackComparisonBrush); 170 m_texturePackComparison->UseBrush(m_hTexturePackComparisonBrush); 171 } 172 else 173 { 174 m_texturePackComparison->UseBrush(NULL); 175 } 176#endif 177 } 178 else 179 { 180 m_labelTexturePackName.setLabel(tp->getName()); 181 m_labelTexturePackDescription.setLabel(tp->getDesc1()); 182 183 DWORD dwImageBytes; 184 PBYTE pbImageData = tp->getPackIcon(dwImageBytes); 185 186 //if(dwImageBytes > 0 && pbImageData) 187 //{ 188 // registerSubstitutionTexture(L"texturePackIcon", pbImageData, dwImageBytes); 189 // m_bitmapTexturePackIcon.setTextureName(L"texturePackIcon"); 190 //} 191 192 wchar_t imageName[64]; 193 swprintf(imageName,64,L"tpack%08x",tp->getId()); 194 m_bitmapTexturePackIcon.setTextureName(imageName); 195 196 pbImageData = tp->getPackComparison(dwImageBytes); 197 198 if(dwImageBytes > 0 && pbImageData) 199 { 200 swprintf(imageName,64,L"texturePackComparison%08x",tp->getId()); 201 registerSubstitutionTexture(imageName, pbImageData, dwImageBytes); 202 m_bitmapComparison.setTextureName(imageName); 203 } 204 else 205 { 206 m_bitmapComparison.setTextureName(L""); 207 } 208 } 209} 210 211void IUIScene_StartGame::UpdateCurrentTexturePack(int iSlot) 212{ 213 m_currentTexturePackIndex = iSlot; 214 TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackByIndex(m_currentTexturePackIndex); 215 216 // if the texture pack is null, you don't have it yet 217 if(tp==NULL) 218 { 219#if TO_BE_IMPLEMENTED 220 // Upsell 221 222 CXuiCtrl4JList::LIST_ITEM_INFO ListItem; 223 // get the current index of the list, and then get the data 224 ListItem=m_pTexturePacksList->GetData(m_currentTexturePackIndex); 225 226 227 // upsell the texture pack 228 // tell sentient about the upsell of the full version of the skin pack 229 ULONGLONG ullOfferID_Full; 230 app.GetDLCFullOfferIDForPackID(ListItem.iData,&ullOfferID_Full); 231 232 TelemetryManager->RecordUpsellPresented(ProfileManager.GetPrimaryPad(), eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF); 233 234 UINT uiIDA[3]; 235 236 uiIDA[0]=IDS_TEXTUREPACK_FULLVERSION; 237 uiIDA[1]=IDS_TEXTURE_PACK_TRIALVERSION; 238 uiIDA[2]=IDS_CONFIRM_CANCEL; 239 240 241 // Give the player a warning about the texture pack missing 242 ui.RequestErrorMessage(IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 3, ProfileManager.GetPrimaryPad(),&:TexturePackDialogReturned,this); 243 244 // do set the texture pack id, and on the user pressing create world, check they have it 245 m_MoreOptionsParams.dwTexturePack = ListItem.iData; 246 return ; 247#endif 248 } 249 else 250 { 251 m_MoreOptionsParams.dwTexturePack = tp->getId(); 252 } 253} 254 255int IUIScene_StartGame::TrialTexturePackWarningReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 256{ 257 IUIScene_StartGame* pScene = (IUIScene_StartGame*)pParam; 258 259 if(result==C4JStorage::EMessage_ResultAccept) 260 { 261 pScene->checkStateAndStartGame(); 262 } 263 else 264 { 265 pScene->m_bIgnoreInput=false; 266 } 267 return 0; 268} 269 270int IUIScene_StartGame::UnlockTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 271{ 272 IUIScene_StartGame* pScene = (IUIScene_StartGame*)pParam; 273 274 if(result==C4JStorage::EMessage_ResultAccept) 275 { 276 if(ProfileManager.IsSignedIn(iPad)) 277 { 278#if defined _XBOX //|| defined _XBOX_ONE 279 ULONGLONG ullIndexA[1]; 280 DLC_INFO *pDLCInfo = app.GetDLCInfoForTrialOfferID(pScene->m_pDLCPack->getPurchaseOfferId()); 281 282 if(pDLCInfo!=NULL) 283 { 284 ullIndexA[0]=pDLCInfo->ullOfferID_Full; 285 } 286 else 287 { 288 ullIndexA[0]=pScene->m_pDLCPack->getPurchaseOfferId(); 289 } 290 291 292 StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); 293#elif defined _XBOX_ONE 294 //StorageManager.InstallOffer(1,StorageManager.GetOffer(iIndex).wszProductID,NULL,NULL); 295#endif 296 297 // the license change coming in when the offer has been installed will cause this scene to refresh 298 } 299 } 300 else 301 { 302#if defined _XBOX 303 TelemetryManager->RecordUpsellResponded(iPad, eSet_UpsellID_Texture_DLC, ( pScene->m_pDLCPack->getPurchaseOfferId() & 0xFFFFFFFF ), eSen_UpsellOutcome_Declined); 304#endif 305 } 306 307 pScene->m_bIgnoreInput = false; 308 309 return 0; 310} 311 312int IUIScene_StartGame::TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 313{ 314 IUIScene_StartGame *pClass = (IUIScene_StartGame *)pParam; 315 316 317#ifdef _XBOX 318 // Exit with or without saving 319 // Decline means install full version of the texture pack in this dialog 320 if(result==C4JStorage::EMessage_ResultDecline || result==C4JStorage::EMessage_ResultAccept) 321 { 322 // we need to enable background downloading for the DLC 323 XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); 324 325 ULONGLONG ullOfferID_Full; 326 ULONGLONG ullIndexA[1]; 327 CXuiCtrl4JList::LIST_ITEM_INFO ListItem; 328 // get the current index of the list, and then get the data 329 ListItem=pClass->m_pTexturePacksList->GetData(pClass->m_currentTexturePackIndex); 330 app.GetDLCFullOfferIDForPackID(ListItem.iData,&ullOfferID_Full); 331 332 if( result==C4JStorage::EMessage_ResultAccept ) // Full version 333 { 334 ullIndexA[0]=ullOfferID_Full; 335 StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); 336 337 } 338 else // trial version 339 { 340 // if there is no trial version, this is a Cancel 341 DLC_INFO *pDLCInfo=app.GetDLCInfoForFullOfferID(ullOfferID_Full); 342 if(pDLCInfo->ullOfferID_Trial!=0LL) 343 { 344 345 ullIndexA[0]=pDLCInfo->ullOfferID_Trial; 346 StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); 347 } 348 } 349 } 350#elif defined _XBOX_ONE 351 // Get the product id from the texture pack id 352 if(result==C4JStorage::EMessage_ResultAccept) 353 { 354 355 if(ProfileManager.IsSignedIn(iPad)) 356 { 357 if (ProfileManager.IsSignedInLive(iPad)) 358 { 359 wstring ProductId; 360 app.GetDLCFullOfferIDForPackID(pClass->m_MoreOptionsParams.dwTexturePack,ProductId); 361 362 363 StorageManager.InstallOffer(1,(WCHAR *)ProductId.c_str(),NULL,NULL); 364 365 // the license change coming in when the offer has been installed will cause this scene to refresh 366 } 367 else 368 { 369 // 4J-JEV: Fix for XB1: #165863 - XR-074: Compliance: With no active network connection user is unable to convert from Trial to Full texture pack and is not messaged why. 370 UINT uiIDA[1] = { IDS_CONFIRM_OK }; 371 ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, iPad); 372 } 373 } 374 } 375 376#endif 377 pClass->m_bIgnoreInput=false; 378 return 0; 379}