the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include <xuiresource.h>
3#include <xuiapp.h>
4#include <assert.h>
5#include "..\..\..\Minecraft.World\StringHelpers.h"
6#include "..\..\Common\Tutorial\TutorialMode.h"
7#include "..\..\..\Minecraft.World\ConsoleSaveFileIO.h"
8#include "..\..\LocalPlayer.h"
9#include "..\..\Minecraft.h"
10#include "..\..\..\Minecraft.World\AABB.h"
11#include "..\..\..\Minecraft.World\Vec3.h"
12#include "..\..\..\Minecraft.World\ArrayWithLength.h"
13#include "..\..\..\Minecraft.World\File.h"
14#include "..\..\..\Minecraft.World\InputOutputStream.h"
15#include "..\..\MinecraftServer.h"
16#include "..\..\Options.h"
17#include "XUI_Ctrl_4JList.h"
18#include "XUI_MultiGameInfo.h"
19#include "XUI_MultiGameJoinLoad.h"
20#include "XUI_Ctrl_4JIcon.h"
21#include "XUI_LoadSettings.h"
22#include "..\..\..\Minecraft.World\LevelSettings.h"
23#include "..\..\TexturePackRepository.h"
24#include "..\..\TexturePack.h"
25#include "..\GameRules\ConsoleGameRules.h"
26#include "..\..\StringTable.h"
27#include "..\..\DLCTexturePack.h"
28
29#define GAME_CREATE_ONLINE_TIMER_ID 0
30#define GAME_CREATE_ONLINE_TIMER_TIME 100
31#define CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID 1
32#define CHECKFORAVAILABLETEXTUREPACKS_TIMER_TIME 100
33
34int CScene_LoadGameSettings::m_iDifficultyTitleSettingA[4]=
35{
36 IDS_DIFFICULTY_TITLE_PEACEFUL,
37 IDS_DIFFICULTY_TITLE_EASY,
38 IDS_DIFFICULTY_TITLE_NORMAL,
39 IDS_DIFFICULTY_TITLE_HARD
40};
41
42
43HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
44{
45 m_hXuiBrush = NULL;
46 m_bSetup = false;
47 m_texturePackDescDisplayed = false;
48 m_iConfigA=NULL;
49
50 WCHAR TempString[256];
51
52 m_params = (LoadMenuInitData *)pInitData->pvInitData;
53
54 m_MoreOptionsParams.bGenerateOptions=FALSE;
55 m_MoreOptionsParams.bPVP = TRUE;
56 m_MoreOptionsParams.bTrust = TRUE;
57 m_MoreOptionsParams.bFireSpreads = TRUE;
58 m_MoreOptionsParams.bTNT = TRUE;
59 m_MoreOptionsParams.bHostPrivileges = FALSE;
60 m_MoreOptionsParams.bResetNether = FALSE;
61 m_MoreOptionsParams.iPad = m_params->iPad;
62
63 // 4J-JEV: Fix for:
64 // TU12: Content: Gameplay: New "Mass Effect World" remembers and uses the settings of another - lately created - World.
65 m_MoreOptionsParams.bBonusChest = FALSE;
66 m_MoreOptionsParams.bFlatWorld = FALSE;
67 m_MoreOptionsParams.bStructures = TRUE;
68
69 m_iPad=m_params->iPad;
70 m_iSaveGameInfoIndex=m_params->iSaveGameInfoIndex;
71 m_levelGen = m_params->levelGen;
72
73 MapChildControls();
74
75 XuiControlSetText(m_MoreOptions,app.GetString(IDS_MORE_OPTIONS));
76 XuiControlSetText(m_ButtonLoad,app.GetString(IDS_LOAD));
77 XuiControlSetText(m_pTexturePacksList->m_hObj,app.GetString(IDS_DLC_MENU_TEXTUREPACKS));
78
79 m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
80 // 4J-PB - read the settings for the online flag. We'll only save this setting if the user changed it.
81 bool bGameSetting_Online=(app.GetGameSettings(m_iPad,eGameSetting_Online)!=0);
82 m_MoreOptionsParams.bOnlineSettingChangedBySystem=false;
83
84 // Set the text for friends of friends, and default to on
85 if( m_bMultiplayerAllowed)
86 {
87 m_MoreOptionsParams.bOnlineGame = bGameSetting_Online?TRUE:FALSE;
88 if(bGameSetting_Online)
89 {
90 m_MoreOptionsParams.bInviteOnly = (app.GetGameSettings(m_iPad,eGameSetting_InviteOnly)!=0)?TRUE:FALSE;
91 m_MoreOptionsParams.bAllowFriendsOfFriends = (app.GetGameSettings(m_iPad,eGameSetting_FriendsOfFriends)!=0)?TRUE:FALSE;
92 }
93 else
94 {
95 m_MoreOptionsParams.bInviteOnly = FALSE;
96 m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE;
97 }
98 }
99 else
100 {
101 m_MoreOptionsParams.bOnlineGame = FALSE;
102 m_MoreOptionsParams.bInviteOnly = FALSE;
103 m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE;
104 if(bGameSetting_Online)
105 {
106 // The profile settings say Online, but either the player is offline, or they are not allowed to play online
107 m_MoreOptionsParams.bOnlineSettingChangedBySystem=true;
108 }
109 }
110
111 XuiSetTimer(m_hObj,GAME_CREATE_ONLINE_TIMER_ID,GAME_CREATE_ONLINE_TIMER_TIME);
112 XuiSetTimer(m_hObj,CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID,CHECKFORAVAILABLETEXTUREPACKS_TIMER_TIME);
113
114 m_ButtonGameMode.SetText(app.GetString(IDS_GAMEMODE_SURVIVAL));
115 m_bGameModeSurvival=true;
116 m_CurrentDifficulty=app.GetGameSettings(m_iPad,eGameSetting_Difficulty);
117 m_SliderDifficulty.SetValue(m_CurrentDifficulty);
118 swprintf( (WCHAR *)TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[m_CurrentDifficulty]));
119 m_SliderDifficulty.SetText(TempString);
120
121 m_bHasBeenInCreative = false;
122
123 if(m_levelGen)
124 {
125 m_GameName.SetText(m_levelGen->getDisplayName());
126 if(m_levelGen->requiresTexturePack())
127 {
128 m_MoreOptionsParams.dwTexturePack = m_levelGen->getRequiredTexturePackId();
129 m_pTexturePacksList->SetEnable(FALSE);
130
131 // retrieve the save icon from the texture pack, if there is one
132 TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack);
133 DWORD dwImageBytes;
134 PBYTE pbImageData = tp->getPackIcon(dwImageBytes);
135
136 if(dwImageBytes > 0 && pbImageData)
137 {
138 XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&m_hXuiBrush);
139 }
140
141 // Set this level as created in creative mode, so that people can't use the themed worlds as an easy way to get achievements
142 m_bHasBeenInCreative = true;
143 m_GameCreatedMode.SetText( app.GetString(IDS_CREATED_IN_CREATIVE) );
144 }
145 }
146 else
147 {
148 // set the save icon
149 PBYTE pbImageData=NULL;
150 DWORD dwImageBytes=0;
151
152 StorageManager.GetSaveCacheFileInfo(m_params->iSaveGameInfoIndex,m_XContentData);
153 StorageManager.GetSaveCacheFileInfo(m_params->iSaveGameInfoIndex,&pbImageData,&dwImageBytes);
154
155 // if there is no thumbnail, retrieve the default one from the file.
156 // Don't delete the image data after creating the xuibrush, since we'll use it in the rename of the save
157 bool bHostOptionsRead = false;
158 unsigned int uiHostOptions = 0;
159 if(pbImageData==NULL)
160 {
161 DWORD dwResult=XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&m_XContentData,NULL,&dwImageBytes,NULL);
162 if(dwResult==ERROR_SUCCESS)
163 {
164 pbImageData = new BYTE[dwImageBytes];
165 XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&m_XContentData,pbImageData,&dwImageBytes,NULL);
166 XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&m_hXuiBrush);
167 }
168 }
169 else
170 {
171 // retrieve the seed value from the image metadata
172 ZeroMemory(m_szSeed,50);
173 app.GetImageTextData(pbImageData,dwImageBytes,(unsigned char *)&m_szSeed,uiHostOptions,bHostOptionsRead,m_MoreOptionsParams.dwTexturePack);
174 XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&m_hXuiBrush);
175
176// #ifdef _DEBUG
177// // dump out the thumbnail
178// HANDLE hThumbnail = CreateFile("GAME:\\thumbnail.png", GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, NULL);
179// DWORD dwBytes;
180// WriteFile(hThumbnail,pbImageData,dwImageBytes,&dwBytes,NULL);
181// XCloseHandle(hThumbnail);
182// #endif
183
184 if(m_szSeed[0]!=0)
185 {
186 swprintf( (WCHAR *)TempString, 256, L"%ls: %hs", app.GetString( IDS_SEED ),m_szSeed);
187 m_GameSeed.SetText(TempString);
188 }
189 else
190 {
191 m_GameSeed.SetText(L"");
192 }
193 }
194
195 // Setup all the text and checkboxes to match what the game was saved with on
196 if(bHostOptionsRead)
197 {
198 m_MoreOptionsParams.bPVP = app.GetGameHostOption(uiHostOptions,eGameHostOption_PvP)>0?TRUE:FALSE;
199 m_MoreOptionsParams.bTrust = app.GetGameHostOption(uiHostOptions,eGameHostOption_TrustPlayers)>0?TRUE:FALSE;
200 m_MoreOptionsParams.bFireSpreads = app.GetGameHostOption(uiHostOptions,eGameHostOption_FireSpreads)>0?TRUE:FALSE;
201 m_MoreOptionsParams.bTNT = app.GetGameHostOption(uiHostOptions,eGameHostOption_TNT)>0?TRUE:FALSE;
202 m_MoreOptionsParams.bHostPrivileges = app.GetGameHostOption(uiHostOptions,eGameHostOption_CheatsEnabled)>0?TRUE:FALSE;
203
204 m_bHasBeenInCreative = app.GetGameHostOption(uiHostOptions,eGameHostOption_HasBeenInCreative)>0;
205 if(app.GetGameHostOption(uiHostOptions,eGameHostOption_HasBeenInCreative)>0)
206 {
207 m_GameCreatedMode.SetText( app.GetString(IDS_CREATED_IN_CREATIVE) );
208 }
209 else
210 {
211 m_GameCreatedMode.SetText( app.GetString(IDS_CREATED_IN_SURVIVAL) );
212 }
213
214 if(app.GetGameHostOption(uiHostOptions,eGameHostOption_GameType)>0)
215 {
216 m_ButtonGameMode.SetText(app.GetString(IDS_GAMEMODE_CREATIVE));
217 m_bGameModeSurvival=false;
218 }
219
220 if(app.GetGameHostOption(uiHostOptions,eGameHostOption_FriendsOfFriends) && !(m_bMultiplayerAllowed && bGameSetting_Online))
221 {
222 m_MoreOptionsParams.bAllowFriendsOfFriends = TRUE;
223 }
224 }
225
226 m_GameName.SetText(m_XContentData.szDisplayName);
227 }
228
229 // 4J-PB - Load up any texture pack data we have locally in the XZP
230 for(int i=0;i<TMS_COUNT;i++)
231 {
232 if(app.TMSFileA[i].eTMSType==eTMSFileType_TexturePack)
233 {
234 app.LoadLocalTMSFile(app.TMSFileA[i].wchFilename,app.TMSFileA[i].eEXT);
235 app.AddMemoryTPDFile(app.TMSFileA[i].iConfig, app.TMSFileA[i].pbData,app.TMSFileA[i].uiSize);
236 }
237 }
238
239 int iRB=-1;
240
241 ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK, -1, -1);
242
243 //if(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())
244 {
245 CXuiSceneBase::ShowLogo( DEFAULT_XUI_MENU_USER, FALSE );
246 }
247
248 TelemetryManager->RecordMenuShown(m_iPad, eUIScene_LoadMenu, 0);
249 m_iTexturePacksNotInstalled=0;
250
251 // 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
252 if(app.StartInstallDLCProcess(m_iPad)==true)
253 {
254 // not doing a mount, so enable input
255 m_bIgnoreInput=true;
256 }
257 else
258 {
259 m_bIgnoreInput = false;
260
261 Minecraft *pMinecraft = Minecraft::GetInstance();
262 m_pTexturePacksList->SetSelectionChangedHandle(m_hObj);
263
264 int texturePacksCount = pMinecraft->skins->getTexturePackCount();
265 CXuiCtrl4JList::LIST_ITEM_INFO ListInfo;
266 HRESULT hr;
267 for(unsigned int i = 0; i < texturePacksCount; ++i)
268 {
269 TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i);
270 ZeroMemory(&ListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO));
271
272
273 DWORD dwImageBytes;
274 PBYTE pbImageData = tp->getPackIcon(dwImageBytes);
275
276 if(dwImageBytes > 0 && pbImageData)
277 {
278 ListInfo.fEnabled = TRUE;
279 DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tp;
280 if(pDLCTexPack)
281 {
282 int id=pDLCTexPack->getDLCParentPackId();
283
284 if(id==0)
285 {
286 // default texture pack - should come first
287 ListInfo.iSortIndex=0x0FFFFFFF;
288 }
289 else
290 {
291 ListInfo.iSortIndex=id;
292 ListInfo.iData=id;
293 }
294 }
295#ifdef _DEBUG
296 app.DebugPrintf("TP - ");
297 OutputDebugStringW(tp->getName().c_str());
298 app.DebugPrintf(", sort index - %d\n",ListInfo.iSortIndex);
299#endif
300 hr=XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&ListInfo.hXuiBrush);
301
302 m_pTexturePacksList->AddData(ListInfo,0,CXuiCtrl4JList::eSortList_Index);
303 }
304 }
305
306 m_currentTexturePackIndex = m_pTexturePacksList->GetIndexByUserData(m_MoreOptionsParams.dwTexturePack);
307 m_pTexturePacksList->SetCurSel(m_currentTexturePackIndex);
308 m_pTexturePacksList->SetTopItem(m_currentTexturePackIndex); // scroll the item into view if it's not visible
309 UpdateTexturePackDescription(m_currentTexturePackIndex);
310
311
312 // 4J-PB - there may be texture packs we don't have, so use the info from TMS for this
313 DLC_INFO *pDLCInfo=NULL;
314
315 // first pass - look to see if there are any that are not in the list
316 bool bTexturePackAlreadyListed;
317 bool bNeedToGetTPD=false;
318 m_iTexturePacksNotInstalled=0;
319
320 for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i)
321 {
322 bTexturePackAlreadyListed=false;
323 ULONGLONG ull=app.GetDLCInfoTexturesFullOffer(i);
324 pDLCInfo=app.GetDLCInfoForFullOfferID(ull);
325 for(unsigned int i = 0; i < texturePacksCount; ++i)
326 {
327 TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i);
328 if(pDLCInfo->iConfig==tp->getDLCParentPackId())
329 {
330 bTexturePackAlreadyListed=true;
331 }
332 }
333 if(bTexturePackAlreadyListed==false)
334 {
335 // some missing
336 bNeedToGetTPD=true;
337
338 m_iTexturePacksNotInstalled++;
339 }
340 }
341
342 if(bNeedToGetTPD==true)
343 {
344 // add a TMS request for them
345 app.AddTMSPPFileTypeRequest(e_DLC_TexturePackData);
346 m_iConfigA= new int [m_iTexturePacksNotInstalled];
347 m_iTexturePacksNotInstalled=0;
348
349 for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i)
350 {
351 bTexturePackAlreadyListed=false;
352 ULONGLONG ull=app.GetDLCInfoTexturesFullOffer(i);
353 pDLCInfo=app.GetDLCInfoForFullOfferID(ull);
354 for(unsigned int i = 0; i < texturePacksCount; ++i)
355 {
356 TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i);
357 if(pDLCInfo->iConfig==tp->getDLCParentPackId())
358 {
359 bTexturePackAlreadyListed=true;
360 }
361 }
362 if(bTexturePackAlreadyListed==false)
363 {
364 m_iConfigA[m_iTexturePacksNotInstalled++]=pDLCInfo->iConfig;
365 }
366 }
367 }
368 }
369
370 m_bSetup = true;
371
372 return S_OK;
373}
374
375HRESULT CScene_LoadGameSettings::OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled)
376{
377 pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE);
378
379 if(pControlNavigateData->hObjDest!=NULL)
380 {
381 bHandled=TRUE;
382 }
383
384 return S_OK;
385}
386
387HRESULT CScene_LoadGameSettings::LaunchGame(void)
388{
389 // stop the timer running that causes a check for new texture packs in TMS but not installed, since this will run all through the load game, and will crash if it tries to create an hbrush
390 XuiKillTimer(m_hObj,CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID);
391
392 if( (m_bGameModeSurvival != true || m_bHasBeenInCreative) || m_MoreOptionsParams.bHostPrivileges == TRUE)
393 {
394 UINT uiIDA[2];
395 uiIDA[0]=IDS_CONFIRM_OK;
396 uiIDA[1]=IDS_CONFIRM_CANCEL;
397 if(m_bGameModeSurvival != true || m_bHasBeenInCreative)
398 {
399 // 4J-PB - Need different text for Survival mode with a level that has been saved in Creative
400 if(m_bGameModeSurvival)
401 {
402 StorageManager.RequestMessageBox(IDS_TITLE_START_GAME, IDS_CONFIRM_START_SAVEDINCREATIVE, uiIDA, 2, m_iPad,&CScene_LoadGameSettings::ConfirmLoadReturned,this,app.GetStringTable());
403 }
404 else // it's creative mode
405 {
406 // has it previously been saved in creative?
407 if(m_bHasBeenInCreative)
408 {
409 // 4J-PB - We don't really need to tell the user this will have achievements disabled, since they already saved it in creative
410 // and they got the warning then
411 // inform them that leaderboard writes and achievements will be disabled
412 //StorageManager.RequestMessageBox(IDS_TITLE_START_GAME, IDS_CONFIRM_START_SAVEDINCREATIVE_CONTINUE, uiIDA, 1, m_iPad,&CScene_LoadGameSettings::ConfirmLoadReturned,this,app.GetStringTable());
413
414 if(m_levelGen != NULL)
415 {
416 LoadLevelGen(m_levelGen);
417 }
418 else
419 {
420 C4JStorage::ELoadGameStatus eLoadStatus=StorageManager.LoadSaveData(&m_XContentData,CScene_LoadGameSettings::LoadSaveDataReturned,this);
421
422 if(eLoadStatus==C4JStorage::ELoadGame_DeviceRemoved)
423 {
424 // disable saving
425 StorageManager.SetSaveDisabled(true);
426 StorageManager.SetSaveDeviceSelected(m_iPad,false);
427 UINT uiIDA[1];
428 uiIDA[0]=IDS_OK;
429 StorageManager.RequestMessageBox(IDS_STORAGEDEVICEPROBLEM_TITLE, IDS_FAILED_TO_LOADSAVE_TEXT, uiIDA, 1, m_iPad,&CScene_LoadGameSettings::DeviceRemovedDialogReturned,this);
430
431 }
432 }
433 }
434 else
435 {
436 // ask if they're sure they want to turn this into a creative map
437 StorageManager.RequestMessageBox(IDS_TITLE_START_GAME, IDS_CONFIRM_START_CREATIVE, uiIDA, 2, m_iPad,&CScene_LoadGameSettings::ConfirmLoadReturned,this,app.GetStringTable());
438 }
439 }
440 }
441 else
442 {
443 StorageManager.RequestMessageBox(IDS_TITLE_START_GAME, IDS_CONFIRM_START_HOST_PRIVILEGES, uiIDA, 2, m_iPad,&CScene_LoadGameSettings::ConfirmLoadReturned,this,app.GetStringTable());
444 }
445 }
446 else
447 {
448 if(m_levelGen != NULL)
449 {
450 LoadLevelGen(m_levelGen);
451 }
452 else
453 {
454 C4JStorage::ELoadGameStatus eLoadStatus=StorageManager.LoadSaveData(&m_XContentData,CScene_LoadGameSettings::LoadSaveDataReturned,this);
455
456 if(eLoadStatus==C4JStorage::ELoadGame_DeviceRemoved)
457 {
458 // disable saving
459 StorageManager.SetSaveDisabled(true);
460 StorageManager.SetSaveDeviceSelected(m_iPad,false);
461 UINT uiIDA[1];
462 uiIDA[0]=IDS_OK;
463 StorageManager.RequestMessageBox(IDS_STORAGEDEVICEPROBLEM_TITLE, IDS_FAILED_TO_LOADSAVE_TEXT, uiIDA, 1, m_iPad,&CScene_LoadGameSettings::DeviceRemovedDialogReturned,this);
464 }
465 }
466 }
467 return 0;
468}
469
470int CScene_LoadGameSettings::CheckResetNetherReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
471{
472 CScene_LoadGameSettings* pClass = (CScene_LoadGameSettings*)pParam;
473
474 // results switched for this dialog
475 if(result==C4JStorage::EMessage_ResultDecline)
476 {
477 // continue and reset the nether
478 pClass->LaunchGame();
479 }
480 else
481 {
482 // turn off the reset nether and continue
483 pClass->m_MoreOptionsParams.bResetNether=FALSE;
484 pClass->LaunchGame();
485 }
486 return 0;
487}
488
489HRESULT CScene_LoadGameSettings::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
490{
491 // 4J-PB - stop people double pressing this
492 if(m_bIgnoreInput) return S_OK;
493 Minecraft *pMinecraft=Minecraft::GetInstance();
494
495 // This assumes all buttons can only be pressed with the A button
496 ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
497
498 if(hObjPressed==m_ButtonLoad)
499 {
500 // Check if we need to upsell the texture pack
501 if(m_MoreOptionsParams.dwTexturePack!=0)
502 {
503 // texture pack hasn't been set yet, so check what it will be
504 TexturePack *pTexturePack = pMinecraft->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack);
505
506 if(pTexturePack==NULL)
507 {
508 // They've selected a texture pack they don't have yet
509 // upsell
510 CXuiCtrl4JList::LIST_ITEM_INFO ListItem;
511 // get the current index of the list, and then get the data
512 ListItem=m_pTexturePacksList->GetData(m_currentTexturePackIndex);
513
514
515 // upsell the texture pack
516
517 ULONGLONG ullOfferID_Full;
518 app.GetDLCFullOfferIDForPackID(ListItem.iData,&ullOfferID_Full);
519
520 // 4J-PB - if the full offer id is 0, then the texture pack dlc load failed
521 if(ullOfferID_Full!=0LL)
522 {
523 // tell sentient about the upsell of the full version of the skin pack
524 TelemetryManager->RecordUpsellPresented(ProfileManager.GetPrimaryPad(), eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF);
525
526 UINT uiIDA[3];
527
528 // Need to check if the texture pack has both Full and Trial versions - we may do some as free ones, so only Full
529 DLC_INFO *pDLCInfo=app.GetDLCInfoForFullOfferID(ullOfferID_Full);
530
531 if(pDLCInfo->ullOfferID_Trial!=0LL)
532 {
533 uiIDA[0]=IDS_TEXTUREPACK_FULLVERSION;
534 uiIDA[1]=IDS_TEXTURE_PACK_TRIALVERSION;
535 uiIDA[2]=IDS_CONFIRM_CANCEL;
536 // Give the player a warning about the texture pack missing
537 StorageManager.RequestMessageBox(IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 3, ProfileManager.GetPrimaryPad(),&CScene_LoadGameSettings::TexturePackDialogReturned,this,app.GetStringTable());
538 }
539 else
540 {
541 uiIDA[0]=IDS_TEXTUREPACK_FULLVERSION;
542 uiIDA[1]=IDS_CONFIRM_CANCEL;
543 // Give the player a warning about the texture pack missing
544 StorageManager.RequestMessageBox(IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CScene_LoadGameSettings::TexturePackDialogReturned,this,app.GetStringTable());
545 }
546
547 return S_OK;
548 }
549 }
550 }
551
552 // if the profile data has been changed, then force a profile write (we save the online/invite/friends of friends settings)
553 // It seems we're allowed to break the 5 minute rule if it's the result of a user action
554 // check the checkboxes
555
556 // Only save the online setting if the user changed it - we may change it because we're offline, but don't want that saved
557 if(!m_MoreOptionsParams.bOnlineSettingChangedBySystem)
558 {
559 app.SetGameSettings(m_iPad,eGameSetting_Online,m_MoreOptionsParams.bOnlineGame?1:0);
560 }
561 app.SetGameSettings(m_iPad,eGameSetting_InviteOnly,m_MoreOptionsParams.bInviteOnly?1:0);
562 app.SetGameSettings(m_iPad,eGameSetting_FriendsOfFriends,m_MoreOptionsParams.bAllowFriendsOfFriends?1:0);
563
564 app.CheckGameSettingsChanged(true,pNotifyPressData->UserIndex);
565
566 SetShow( FALSE );
567 m_bIgnoreInput = true;
568
569 // Check that we have the rights to use a texture pack we have selected.
570 if(m_MoreOptionsParams.dwTexturePack!=0)
571 {
572 // texture pack hasn't been set yet, so check what it will be
573 TexturePack *pTexturePack = pMinecraft->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack);
574
575 if(pTexturePack==NULL)
576 {
577 // DLC corrupt, so use the default textures
578 m_MoreOptionsParams.dwTexturePack=0;
579 }
580 else
581 {
582 m_pDLCPack=pTexturePack->getDLCPack();
583 // do we have a license?
584 if(m_pDLCPack && !m_pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" ))
585 {
586 // no
587 UINT uiIDA[1];
588 uiIDA[0]=IDS_OK;
589
590 if(!ProfileManager.IsSignedInLive(pNotifyPressData->UserIndex))
591 {
592 // need to be signed in to live
593 StorageManager.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1);
594 return S_OK;
595 }
596 else
597 {
598 // upsell
599
600 DLC_INFO *pDLCInfo = app.GetDLCInfoForTrialOfferID(m_pDLCPack->getPurchaseOfferId());
601 ULONGLONG ullOfferID_Full;
602
603 if(pDLCInfo!=NULL)
604 {
605 ullOfferID_Full=pDLCInfo->ullOfferID_Full;
606 }
607 else
608 {
609 ullOfferID_Full=pTexturePack->getDLCPack()->getPurchaseOfferId();
610 }
611
612 // tell sentient about the upsell of the full version of the texture pack
613 TelemetryManager->RecordUpsellPresented(pNotifyPressData->UserIndex, eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF);
614
615 UINT uiIDA[2];
616 uiIDA[0]=IDS_CONFIRM_OK;
617 uiIDA[1]=IDS_CONFIRM_CANCEL;
618
619 //StorageManager.RequestMessageBox(IDS_UNLOCK_DLC_TITLE, IDS_UNLOCK_DLC_SKIN, uiIDA, 2, pInputData->UserIndex,&CScene_SkinSelect::UnlockSkinReturned,this,app.GetStringTable());
620 StorageManager.RequestMessageBox(IDS_UNLOCK_DLC_TEXTUREPACK_TITLE, IDS_UNLOCK_DLC_TEXTUREPACK_TEXT, uiIDA, 2, pNotifyPressData->UserIndex,&CScene_LoadGameSettings::UnlockTexturePackReturned,this,app.GetStringTable());
621 return S_OK;
622 }
623 }
624 }
625 }
626
627 // Reset the background downloading, in case we changed it by attempting to download a texture pack
628 XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_AUTO);
629
630 // Check if they have the Reset Nether flag set, and confirm they want to do this
631 if(m_MoreOptionsParams.bResetNether==TRUE)
632 {
633 UINT uiIDA[2];
634 uiIDA[0]=IDS_DONT_RESET_NETHER;
635 uiIDA[1]=IDS_RESET_NETHER;
636
637 StorageManager.RequestMessageBox(IDS_RESETNETHER_TITLE, IDS_RESETNETHER_TEXT, uiIDA, 2, pNotifyPressData->UserIndex,&CScene_LoadGameSettings::CheckResetNetherReturned,this,app.GetStringTable());
638 }
639 else
640 {
641 LaunchGame();
642 }
643 }
644 else if(hObjPressed==m_MoreOptions)
645 {
646 app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_LaunchMoreOptionsMenu,&m_MoreOptionsParams);
647 }
648 else if(hObjPressed == m_ButtonGameMode)
649 {
650 if(m_bGameModeSurvival)
651 {
652 m_ButtonGameMode.SetText(app.GetString(IDS_GAMEMODE_CREATIVE));
653 m_bGameModeSurvival=false;
654 }
655 else
656 {
657 m_ButtonGameMode.SetText(app.GetString(IDS_GAMEMODE_SURVIVAL));
658 m_bGameModeSurvival=true;
659 }
660 }
661 else if(hObjPressed == m_pTexturePacksList->m_hObj)
662 {
663 UpdateCurrentTexturePack();
664 }
665 return S_OK;
666}
667
668HRESULT CScene_LoadGameSettings::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
669{
670 if(m_bIgnoreInput) return S_OK;
671
672 ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
673
674 // Explicitly handle B button presses
675 switch(pInputData->dwKeyCode)
676 {
677 case VK_PAD_B:
678 case VK_ESCAPE:
679 app.SetCorruptSaveDeleted(false);
680 app.NavigateBack(pInputData->UserIndex);
681 rfHandled = TRUE;
682 break;
683 case VK_PAD_RSHOULDER:
684/* if(app.m_bTransferSavesToXboxOne && ProfileManager.IsFullVersion())
685 {
686 app.NavigateToScene(m_iPad,eUIScene_TransferToXboxOne,m_params);
687 }
688 */
689 break;
690 }
691
692 return S_OK;
693}
694
695HRESULT CScene_LoadGameSettings::OnFontRendererChange()
696{
697 int iRB=-1;
698
699 ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK, -1, -1,-1,-1,-1,-1,-1,true);
700
701 return S_OK;
702}
703
704int CScene_LoadGameSettings::ConfirmLoadReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
705{
706 CScene_LoadGameSettings* pClass = (CScene_LoadGameSettings*)pParam;
707
708 if(result==C4JStorage::EMessage_ResultAccept)
709 {
710 if(pClass->m_levelGen != NULL)
711 {
712 pClass->LoadLevelGen(pClass->m_levelGen);
713 }
714 else
715 {
716 C4JStorage::ELoadGameStatus eLoadStatus=StorageManager.LoadSaveData(&pClass->m_XContentData,CScene_LoadGameSettings::LoadSaveDataReturned,pClass);
717
718 if(eLoadStatus==C4JStorage::ELoadGame_DeviceRemoved)
719 {
720 // disable saving
721 StorageManager.SetSaveDisabled(true);
722 StorageManager.SetSaveDeviceSelected(pClass->m_iPad,false);
723 UINT uiIDA[1];
724 uiIDA[0]=IDS_OK;
725 StorageManager.RequestMessageBox(IDS_STORAGEDEVICEPROBLEM_TITLE, IDS_FAILED_TO_LOADSAVE_TEXT, uiIDA, 1, pClass->m_iPad,&CScene_LoadGameSettings::DeviceRemovedDialogReturned,pClass);
726 }
727 }
728 }
729 else
730 {
731 pClass->SetShow( TRUE );
732 pClass->m_bIgnoreInput=false;
733 }
734 return 0;
735}
736
737HRESULT CScene_LoadGameSettings::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled )
738{
739 // 4J-PB - TODO - Don't think we can do this - if a 2nd player signs in here with an offline profile, the signed in LIVE player gets re-logged in, and bMultiplayerAllowed is false briefly
740 switch(pTimer->nId)
741 {
742 case GAME_CREATE_ONLINE_TIMER_ID:
743 {
744 bool bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
745
746 if(bMultiplayerAllowed != m_bMultiplayerAllowed)
747 {
748 if( bMultiplayerAllowed )
749 {
750 bool bGameSetting_Online=(app.GetGameSettings(m_iPad,eGameSetting_Online)!=0);
751 m_MoreOptionsParams.bOnlineGame = bGameSetting_Online?TRUE:FALSE;
752 if(bGameSetting_Online)
753 {
754 m_MoreOptionsParams.bInviteOnly = (app.GetGameSettings(m_iPad,eGameSetting_InviteOnly)!=0)?TRUE:FALSE;
755 m_MoreOptionsParams.bAllowFriendsOfFriends = (app.GetGameSettings(m_iPad,eGameSetting_FriendsOfFriends)!=0)?TRUE:FALSE;
756 }
757 else
758 {
759 m_MoreOptionsParams.bInviteOnly = FALSE;
760 m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE;
761 }
762 }
763 else
764 {
765 m_MoreOptionsParams.bOnlineGame = FALSE;
766 m_MoreOptionsParams.bInviteOnly = FALSE;
767 m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE;
768 }
769
770 m_bMultiplayerAllowed = bMultiplayerAllowed;
771 }
772 }
773 break;
774
775 case CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID:
776 {
777 // also check for any new texture packs info being available
778 // for each item in the mem list, check it's in the data list
779
780 CXuiCtrl4JList::LIST_ITEM_INFO ListInfo;
781 // for each iConfig, check if the data is available, and add it to the List, then remove it from the viConfig
782 for(int i=0;i<m_iTexturePacksNotInstalled;i++)
783 {
784 if(m_iConfigA[i]!=-1)
785 {
786 DWORD dwBytes=0;
787 PBYTE pbData=NULL;
788 app.GetTPD(m_iConfigA[i],&pbData,&dwBytes);
789
790 ZeroMemory(&ListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO));
791 if(dwBytes > 0 && pbData)
792 {
793 DWORD dwImageBytes=0;
794 PBYTE pbImageData=NULL;
795
796 app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbImageData,&dwImageBytes );
797 ListInfo.fEnabled = TRUE;
798 ListInfo.iData = m_iConfigA[i];
799 HRESULT hr=XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&ListInfo.hXuiBrush);
800
801 ListInfo.iSortIndex=m_iConfigA[i];
802 m_pTexturePacksList->AddData(ListInfo,0,CXuiCtrl4JList::eSortList_Index);
803
804 m_iConfigA[i]=-1;
805
806 m_currentTexturePackIndex = m_pTexturePacksList->GetIndexByUserData(m_MoreOptionsParams.dwTexturePack);
807 m_pTexturePacksList->SetCurSel(m_currentTexturePackIndex);
808 m_pTexturePacksList->SetTopItem(m_currentTexturePackIndex); // scroll the item into view if it's not visible
809 }
810 }
811 }
812 bool bAllDone=true;
813 for(int i=0;i<m_iTexturePacksNotInstalled;i++)
814 {
815 if(m_iConfigA[i]!=-1)
816 {
817 bAllDone = false;
818 }
819 }
820
821 if(bAllDone )
822 {
823 // kill this timer
824 XuiKillTimer(m_hObj,CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID);
825 }
826 }
827 break;
828 }
829
830 return S_OK;
831}
832 PBYTE pbData;
833
834int CScene_LoadGameSettings::Progress(void *pParam,float fProgress)
835{
836 app.DebugPrintf("Progress - %f\n",fProgress);
837
838 return 0;
839}
840
841int CScene_LoadGameSettings::LoadSaveDataReturned(void *pParam,bool bContinue)
842{
843 CScene_LoadGameSettings* pClass = (CScene_LoadGameSettings*)pParam;
844
845 if(bContinue==true)
846 {
847 bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pClass->m_MoreOptionsParams.bOnlineGame;
848
849 // 4J Stu - If we only have one controller connected, then don't show the sign-in UI again
850 DWORD connectedControllers = 0;
851 for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i)
852 {
853 if( InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i) ) ++connectedControllers;
854 }
855
856 if(!isClientSide || connectedControllers == 1 || !RenderManager.IsHiDef())
857 {
858 // Check if user-created content is allowed, as we cannot play multiplayer if it's not
859 bool noUGC = false;
860 BOOL pccAllowed = TRUE;
861 BOOL pccFriendsAllowed = TRUE;
862 ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed);
863 if(!pccAllowed && !pccFriendsAllowed) noUGC = true;
864
865 if(isClientSide && noUGC )
866 {
867 pClass->SetShow( TRUE );
868 pClass->m_bIgnoreInput=false;
869 UINT uiIDA[1];
870 uiIDA[0]=IDS_CONFIRM_OK;
871 StorageManager.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable());
872 }
873 else
874 {
875 DWORD dwLocalUsersMask = CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad());
876
877 // No guest problems so we don't need to force a sign-in of players here
878 StartGameFromSave(pClass, dwLocalUsersMask);
879 }
880 }
881 else
882 {
883 ProfileManager.RequestSignInUI(false, false, false, true, false,&CScene_LoadGameSettings::StartGame_SignInReturned, pParam,ProfileManager.GetPrimaryPad());
884 }
885 }
886 else
887 {
888 // the save is corrupt!
889
890 pClass->SetShow( TRUE );
891 pClass->m_bIgnoreInput=false;
892
893 // give the option to delete the save
894 UINT uiIDA[2];
895 uiIDA[0]=IDS_CONFIRM_CANCEL;
896 uiIDA[1]=IDS_CONFIRM_OK;
897 StorageManager.RequestMessageBox(IDS_CORRUPT_OR_DAMAGED_SAVE_TITLE, IDS_CORRUPT_OR_DAMAGED_SAVE_TEXT, uiIDA, 2,
898 pClass->m_iPad,&CScene_LoadGameSettings::DeleteSaveDialogReturned,pClass, app.GetStringTable());
899
900 }
901 return 0;
902}
903
904int CScene_LoadGameSettings::DeleteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
905{
906 CScene_LoadGameSettings* pClass = (CScene_LoadGameSettings*)pParam;
907
908 // results switched for this dialog
909 if(result==C4JStorage::EMessage_ResultDecline)
910 {
911#ifdef _XBOX
912 StorageManager.DeleteSaveData(&pClass->m_XContentData,CScene_LoadGameSettings::DeleteSaveDataReturned,pClass);
913#endif
914 }
915 else
916 {
917 pClass->m_bIgnoreInput=false;
918 }
919 return 0;
920}
921
922int CScene_LoadGameSettings::DeleteSaveDataReturned(void *pParam,bool bSuccess)
923{
924 CScene_LoadGameSettings* pClass = (CScene_LoadGameSettings*)pParam;
925
926 app.SetCorruptSaveDeleted(true);
927 app.NavigateBack(pClass->m_iPad);
928
929 return 0;
930}
931
932int CScene_LoadGameSettings::DeviceRemovedDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
933{
934 // need to back out of this scene
935 app.NavigateBack(iPad);
936
937 return 0;
938}
939
940// 4J Stu - Shared functionality that is the same whether we needed a quadrant sign-in or not
941void CScene_LoadGameSettings::StartGameFromSave(CScene_LoadGameSettings* pClass, DWORD dwLocalUsersMask)
942{
943 INT saveOrCheckpointId = 0;
944 bool validSave = StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId);
945 TelemetryManager->RecordLevelResume(pClass->m_iPad, eSen_FriendOrMatch_Playing_With_Invited_Friends, eSen_CompeteOrCoop_Coop_and_Competitive, app.GetGameSettings(pClass->m_iPad,eGameSetting_Difficulty), app.GetLocalPlayerCount(), g_NetworkManager.GetOnlinePlayerCount(), saveOrCheckpointId);
946
947 bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pClass->m_MoreOptionsParams.bOnlineGame;
948 bool isPrivate = (app.GetGameSettings(pClass->m_iPad,eGameSetting_InviteOnly)>0)?true:false;
949
950 g_NetworkManager.HostGame(dwLocalUsersMask,isClientSide,isPrivate,MINECRAFT_NET_MAX_PLAYERS,0);
951
952 NetworkGameInitData *param = new NetworkGameInitData();
953 param->seed = 0;
954 param->saveData = NULL;
955 param->texturePackId = pClass->m_MoreOptionsParams.dwTexturePack;
956
957 Minecraft *pMinecraft = Minecraft::GetInstance();
958 pMinecraft->skins->selectTexturePackById(pClass->m_MoreOptionsParams.dwTexturePack);
959 //pMinecraft->skins->updateUI();
960
961 app.SetGameHostOption(eGameHostOption_Difficulty,Minecraft::GetInstance()->options->difficulty);
962 app.SetGameHostOption(eGameHostOption_FriendsOfFriends,app.GetGameSettings(pClass->m_iPad,eGameSetting_FriendsOfFriends));
963 app.SetGameHostOption(eGameHostOption_Gamertags,app.GetGameSettings(pClass->m_iPad,eGameSetting_GamertagsVisible));
964
965 app.SetGameHostOption(eGameHostOption_BedrockFog,app.GetGameSettings(pClass->m_iPad,eGameSetting_BedrockFog)?1:0);
966
967 app.SetGameHostOption(eGameHostOption_PvP,pClass->m_MoreOptionsParams.bPVP);
968 app.SetGameHostOption(eGameHostOption_TrustPlayers,pClass->m_MoreOptionsParams.bTrust );
969 app.SetGameHostOption(eGameHostOption_FireSpreads,pClass->m_MoreOptionsParams.bFireSpreads );
970 app.SetGameHostOption(eGameHostOption_TNT,pClass->m_MoreOptionsParams.bTNT );
971 app.SetGameHostOption(eGameHostOption_HostCanFly,pClass->m_MoreOptionsParams.bHostPrivileges);
972 app.SetGameHostOption(eGameHostOption_HostCanChangeHunger,pClass->m_MoreOptionsParams.bHostPrivileges);
973 app.SetGameHostOption(eGameHostOption_HostCanBeInvisible,pClass->m_MoreOptionsParams.bHostPrivileges );
974
975 // flag if the user wants to reset the Nether to force a Fortress with netherwart etc.
976 app.SetResetNether((pClass->m_MoreOptionsParams.bResetNether==TRUE)?true:false);
977 // clear out the app's terrain features list
978 app.ClearTerrainFeaturePosition();
979
980 app.SetGameHostOption(eGameHostOption_GameType,pClass->m_bGameModeSurvival?GameType::SURVIVAL->getId():GameType::CREATIVE->getId());
981
982 param->settings = app.GetGameHostOption( eGameHostOption_All );
983
984 LoadingInputParams *loadingParams = new LoadingInputParams();
985 loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc;
986 loadingParams->lpParam = (LPVOID)param;
987
988 // Reset the autosave timer
989 app.SetAutosaveTimerTime();
990
991 UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData();
992 completionData->bShowBackground=TRUE;
993 completionData->bShowLogo=TRUE;
994 completionData->type = e_ProgressCompletion_CloseAllPlayersUIScenes;
995 completionData->iPad = DEFAULT_XUI_MENU_USER;
996 loadingParams->completionData = completionData;
997
998 app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams);
999}
1000
1001int CScene_LoadGameSettings::StartGame_SignInReturned(void *pParam,bool bContinue, int iPad)
1002{
1003 CScene_LoadGameSettings* pClass = (CScene_LoadGameSettings*)pParam;
1004
1005 if(bContinue==true)
1006 {
1007 // It's possible that the player has not signed in - they can back out
1008 if(ProfileManager.IsSignedIn(iPad))
1009 {
1010 DWORD dwLocalUsersMask = 0;
1011
1012 bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pClass->m_MoreOptionsParams.bOnlineGame;
1013 bool noPrivileges = false;
1014 for(unsigned int index = 0; index < XUSER_MAX_COUNT; ++index)
1015 {
1016 if(ProfileManager.IsSignedIn(index) )
1017 {
1018 if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true;
1019 dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(index);
1020 }
1021 }
1022
1023 // Check if user-created content is allowed, as we cannot play multiplayer if it's not
1024 bool noUGC = false;
1025 BOOL pccAllowed = TRUE;
1026 BOOL pccFriendsAllowed = TRUE;
1027 ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(), false, &pccAllowed,&pccFriendsAllowed);
1028 if(!pccAllowed && !pccFriendsAllowed) noUGC = true;
1029
1030 if(isClientSide && (noPrivileges || noUGC) )
1031 {
1032 if( noUGC )
1033 {
1034 pClass->SetShow( TRUE );
1035 pClass->m_bIgnoreInput=false;
1036 //pClass->m_bAbortSearch=false;
1037 UINT uiIDA[1];
1038 uiIDA[0]=IDS_CONFIRM_OK;
1039 StorageManager.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable());
1040 }
1041 else
1042 {
1043 pClass->SetShow( TRUE );
1044 pClass->m_bIgnoreInput=false;
1045 //pClass->m_bAbortSearch=false;
1046 UINT uiIDA[1];
1047 uiIDA[0]=IDS_CONFIRM_OK;
1048 StorageManager.RequestMessageBox( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_HOST_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable());
1049 }
1050 }
1051 else
1052 {
1053 StartGameFromSave(pClass, dwLocalUsersMask);
1054 }
1055 }
1056 }
1057 else
1058 {
1059 pClass->SetShow( TRUE );
1060 pClass->m_bIgnoreInput=false;
1061 //pClass->m_bAbortSearch=false;
1062 }
1063 return 0;
1064}
1065
1066
1067HRESULT CScene_LoadGameSettings::OnGetSourceDataImage(XUIMessageGetSourceImage *pGetSourceImageData,BOOL& bHandled)
1068{
1069 if( pGetSourceImageData->bItemData )
1070 {
1071 pGetSourceImageData->hBrush = m_hXuiBrush;
1072 bHandled = TRUE;
1073 }
1074 return S_OK;
1075}
1076
1077
1078HRESULT CScene_LoadGameSettings::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyValueChanged* pNotifyValueChanged, BOOL& bHandled )
1079{
1080 WCHAR TempString[256];
1081
1082 if(hObjSource==m_SliderDifficulty.GetSlider() )
1083 {
1084 app.SetGameSettings(m_iPad,eGameSetting_Difficulty,pNotifyValueChanged->nValue);
1085 swprintf( (WCHAR *)TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[pNotifyValueChanged->nValue]));
1086 m_SliderDifficulty.SetText(TempString);
1087 }
1088 return S_OK;
1089}
1090
1091HRESULT CScene_LoadGameSettings::OnTransitionStart( XUIMessageTransition *pTransition, BOOL& bHandled )
1092{
1093 //if(pTransition->dwTransAction==XUI_TRANSITION_ACTION_DESTROY ) return S_OK;
1094
1095 if(pTransition->dwTransAction==XUI_TRANSITION_ACTION_DESTROY ||
1096 pTransition->dwTransType == XUI_TRANSITION_FROM || pTransition->dwTransType == XUI_TRANSITION_BACKFROM)
1097 {
1098 // 4J Stu - We may have had to unload our font renderer in this scene if one of the save files
1099 // uses characters not in our font (eg asian chars) so restore our font renderer
1100 // This will not do anything if our font renderer is already loaded
1101 app.OverrideFontRenderer(true,true);
1102 }
1103 else if(pTransition->dwTransType == XUI_TRANSITION_TO || pTransition->dwTransType == XUI_TRANSITION_BACKTO)
1104 {
1105 m_SliderDifficulty.SetValueDisplay(FALSE);
1106 // 4J-PB - Need to check for installed DLC, which might have happened while you were on the More Options scene
1107 if(pTransition->dwTransType == XUI_TRANSITION_BACKTO)
1108 {
1109 // 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
1110 if(app.StartInstallDLCProcess(m_iPad)==false)
1111 {
1112 // not doing a mount, so re-enable input
1113 m_bIgnoreInput=false;
1114 }
1115 else
1116 {
1117 m_bIgnoreInput=true;
1118 m_pTexturePacksList->RemoveAllData();
1119 }
1120 }
1121 }
1122
1123 return S_OK;
1124}
1125
1126HRESULT CScene_LoadGameSettings::OnTransitionEnd( XUIMessageTransition *pTransition, BOOL& bHandled )
1127{
1128 //if(pTransition->dwTransAction==XUI_TRANSITION_ACTION_DESTROY ) return S_OK;
1129
1130 if(pTransition->dwTransAction==XUI_TRANSITION_ACTION_DESTROY ||
1131 pTransition->dwTransType == XUI_TRANSITION_FROM || pTransition->dwTransType == XUI_TRANSITION_BACKFROM)
1132 {
1133 }
1134 else if(pTransition->dwTransType == XUI_TRANSITION_TO || pTransition->dwTransType == XUI_TRANSITION_BACKTO)
1135 {
1136 if(m_bSetup && m_texturePackDescDisplayed)
1137 {
1138 XUITimeline *timeline;
1139 XUINamedFrame *startFrame, *endFrame;
1140 GetTimeline( &timeline );
1141 startFrame = timeline->FindNamedFrame( L"SlideOutEnd" );
1142 endFrame = timeline->FindNamedFrame( L"SlideOutEnd" );
1143 timeline->Play( startFrame->m_dwFrame, startFrame->m_dwFrame, endFrame->m_dwFrame, FALSE, FALSE );
1144 m_texturePackDescDisplayed = true;
1145 }
1146 }
1147
1148 return S_OK;
1149}
1150
1151int CScene_LoadGameSettings::UnlockTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
1152{
1153 CScene_LoadGameSettings* pScene = (CScene_LoadGameSettings*)pParam;
1154
1155 if(result==C4JStorage::EMessage_ResultAccept)
1156 {
1157 if(ProfileManager.IsSignedIn(iPad))
1158 {
1159 ULONGLONG ullIndexA[1];
1160 DLC_INFO *pDLCInfo = app.GetDLCInfoForTrialOfferID(pScene->m_pDLCPack->getPurchaseOfferId());
1161
1162 if(pDLCInfo!=NULL)
1163 {
1164 ullIndexA[0]=pDLCInfo->ullOfferID_Full;
1165 }
1166 else
1167 {
1168 ullIndexA[0]=pScene->m_pDLCPack->getPurchaseOfferId();
1169 }
1170
1171 StorageManager.InstallOffer(1,ullIndexA,NULL,NULL);
1172
1173 // the license change coming in when the offer has been installed will cause this scene to refresh
1174 }
1175 }
1176 else
1177 {
1178 TelemetryManager->RecordUpsellResponded(iPad, eSet_UpsellID_Texture_DLC, ( pScene->m_pDLCPack->getPurchaseOfferId() & 0xFFFFFFFF ), eSen_UpsellOutcome_Declined);
1179 }
1180
1181 pScene->m_bIgnoreInput = false;
1182 pScene->SetShow( TRUE );
1183
1184 return 0;
1185}
1186
1187HRESULT CScene_LoadGameSettings::OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled )
1188{
1189 if(hObjSource == m_pTexturePacksList->m_hObj)
1190 {
1191 UpdateTexturePackDescription(pNotifySelChangedData->iItem);
1192
1193 if(m_bSetup && !m_texturePackDescDisplayed)
1194 {
1195 XUITimeline *timeline;
1196 XUINamedFrame *startFrame, *endFrame;
1197 GetTimeline( &timeline );
1198 startFrame = timeline->FindNamedFrame( L"SlideOut" );
1199 endFrame = timeline->FindNamedFrame( L"SlideOutEnd" );
1200 timeline->Play( startFrame->m_dwFrame, startFrame->m_dwFrame, endFrame->m_dwFrame, FALSE, FALSE );
1201 m_texturePackDescDisplayed = true;
1202 }
1203 }
1204
1205 return S_OK;
1206}
1207
1208HRESULT CScene_LoadGameSettings::OnNotifyKillFocus(HXUIOBJ hObjSource, XUINotifyFocus *pNotifyFocusData, BOOL& bHandled)
1209{
1210 HXUIOBJ hSourceParent, hDestParent;
1211 XuiElementGetParent(hObjSource,&hSourceParent);
1212 XuiElementGetParent(pNotifyFocusData->hObjOther,&hDestParent);
1213 if(hSourceParent != hDestParent && pNotifyFocusData->hObjOther != m_pTexturePacksList->m_hObj && hSourceParent == m_pTexturePacksList->m_hObj)
1214 {
1215 m_pTexturePacksList->SetCurSel(m_currentTexturePackIndex);
1216 m_pTexturePacksList->SetTopItem(m_currentTexturePackIndex); // scroll the item into view if it's not visible
1217 }
1218 else if(!m_texturePackDescDisplayed && pNotifyFocusData->hObjOther == m_pTexturePacksList->m_hObj)
1219 {
1220 int texturePacksCount = Minecraft::GetInstance()->skins->getTexturePackCount();
1221 if(texturePacksCount == 1)
1222 {
1223 XUITimeline *timeline;
1224 XUINamedFrame *startFrame, *endFrame;
1225 GetTimeline( &timeline );
1226 startFrame = timeline->FindNamedFrame( L"SlideOut" );
1227 endFrame = timeline->FindNamedFrame( L"SlideOutEnd" );
1228 timeline->Play( startFrame->m_dwFrame, startFrame->m_dwFrame, endFrame->m_dwFrame, FALSE, FALSE );
1229 m_texturePackDescDisplayed = true;
1230 }
1231 }
1232
1233 return S_OK;
1234}
1235
1236void CScene_LoadGameSettings::UpdateTexturePackDescription(int index)
1237{
1238 int iTexPackId=m_pTexturePacksList->GetData(index).iData;
1239 TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackById(iTexPackId);
1240
1241 if(tp==NULL)
1242 {
1243 // this is probably a texture pack icon added from TMS
1244 DWORD dwBytes=0,dwFileBytes=0;
1245 PBYTE pbData=NULL,pbFileData=NULL;
1246
1247 CXuiCtrl4JList::LIST_ITEM_INFO ListItem;
1248 // get the current index of the list, and then get the data
1249 ListItem=m_pTexturePacksList->GetData(index);
1250
1251 app.GetTPD(ListItem.iData,&pbData,&dwBytes);
1252
1253 app.GetFileFromTPD(eTPDFileType_Loc,pbData,dwBytes,&pbFileData,&dwFileBytes );
1254 if(dwFileBytes > 0 && pbFileData)
1255 {
1256 StringTable *pStringTable = new StringTable(pbFileData, dwFileBytes);
1257 m_texturePackTitle.SetText(pStringTable->getString(L"IDS_DISPLAY_NAME"));
1258 m_texturePackDescription.SetText(pStringTable->getString(L"IDS_TP_DESCRIPTION"));
1259 }
1260
1261 app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbFileData,&dwFileBytes );
1262 if(dwFileBytes >= 0 && pbFileData)
1263 {
1264 XuiCreateTextureBrushFromMemory(pbFileData,dwFileBytes,&m_hTexturePackIconBrush);
1265 m_texturePackIcon->UseBrush(m_hTexturePackIconBrush);
1266 }
1267 app.GetFileFromTPD(eTPDFileType_Comparison,pbData,dwBytes,&pbFileData,&dwFileBytes );
1268 if(dwFileBytes >= 0 && pbFileData)
1269 {
1270 XuiCreateTextureBrushFromMemory(pbFileData,dwFileBytes,&m_hTexturePackComparisonBrush);
1271 m_texturePackComparison->UseBrush(m_hTexturePackComparisonBrush);
1272 }
1273 else
1274 {
1275 m_texturePackComparison->UseBrush(NULL);
1276 }
1277 }
1278 else
1279 {
1280 m_texturePackTitle.SetText(tp->getName().c_str());
1281 m_texturePackDescription.SetText(tp->getDesc1().c_str());
1282
1283 DWORD dwImageBytes;
1284 PBYTE pbImageData = tp->getPackIcon(dwImageBytes);
1285
1286 if(dwImageBytes > 0 && pbImageData)
1287 {
1288 XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&m_hTexturePackIconBrush);
1289 m_texturePackIcon->UseBrush(m_hTexturePackIconBrush);
1290 }
1291 else
1292 {
1293 m_texturePackIcon->UseBrush(NULL);
1294 }
1295
1296 pbImageData = tp->getPackComparison(dwImageBytes);
1297
1298 if(dwImageBytes > 0 && pbImageData)
1299 {
1300 XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&m_hTexturePackComparisonBrush);
1301 m_texturePackComparison->UseBrush(m_hTexturePackComparisonBrush);
1302 }
1303 else
1304 {
1305 m_texturePackComparison->UseBrush(NULL);
1306 }
1307 }
1308}
1309
1310void CScene_LoadGameSettings::ClearTexturePackDescription()
1311{
1312 m_texturePackTitle.SetText(L" ");
1313 m_texturePackDescription.SetText(L" ");
1314 m_texturePackComparison->UseBrush(NULL);
1315 m_texturePackIcon->UseBrush(NULL);
1316}
1317
1318void CScene_LoadGameSettings::UpdateCurrentTexturePack()
1319{
1320 m_currentTexturePackIndex = m_pTexturePacksList->GetCurSel();
1321 int iTexPackId=m_pTexturePacksList->GetData(m_currentTexturePackIndex).iData;
1322 TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackById(iTexPackId);
1323
1324 // if the texture pack is null, you don't have it yet
1325 if(tp==NULL)
1326 {
1327 // Upsell
1328
1329 CXuiCtrl4JList::LIST_ITEM_INFO ListItem;
1330 // get the current index of the list, and then get the data
1331 ListItem=m_pTexturePacksList->GetData(m_currentTexturePackIndex);
1332
1333
1334 // upsell the texture pack
1335 // tell sentient about the upsell of the full version of the skin pack
1336 ULONGLONG ullOfferID_Full;
1337 app.GetDLCFullOfferIDForPackID(ListItem.iData,&ullOfferID_Full);
1338
1339 TelemetryManager->RecordUpsellPresented(ProfileManager.GetPrimaryPad(), eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF);
1340
1341 UINT uiIDA[3];
1342
1343 // Need to check if the texture pack has both Full and Trial versions - we may do some as free ones, so only Full
1344 DLC_INFO *pDLCInfo=app.GetDLCInfoForFullOfferID(ullOfferID_Full);
1345
1346 if(pDLCInfo->ullOfferID_Trial!=0LL)
1347 {
1348 uiIDA[0]=IDS_TEXTUREPACK_FULLVERSION;
1349 uiIDA[1]=IDS_TEXTURE_PACK_TRIALVERSION;
1350 uiIDA[2]=IDS_CONFIRM_CANCEL;
1351 // Give the player a warning about the texture pack missing
1352 StorageManager.RequestMessageBox(IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 3, ProfileManager.GetPrimaryPad(),&CScene_LoadGameSettings::TexturePackDialogReturned,this,app.GetStringTable());
1353 }
1354 else
1355 {
1356 uiIDA[0]=IDS_TEXTUREPACK_FULLVERSION;
1357 uiIDA[1]=IDS_CONFIRM_CANCEL;
1358 // Give the player a warning about the texture pack missing
1359 StorageManager.RequestMessageBox(IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CScene_LoadGameSettings::TexturePackDialogReturned,this,app.GetStringTable());
1360 }
1361
1362 // do set the texture pack id, and on the user pressing create world, check they have it
1363 m_MoreOptionsParams.dwTexturePack = ListItem.iData;
1364
1365 return ;
1366 }
1367 else
1368 {
1369 m_MoreOptionsParams.dwTexturePack = tp->getId();
1370 }
1371}
1372
1373HRESULT CScene_LoadGameSettings::OnDestroy()
1374{
1375 if( m_hXuiBrush )
1376 {
1377 XuiDestroyBrush( m_hXuiBrush );
1378 }
1379
1380 // clear out the texture pack data
1381 for(int i=0;i<TMS_COUNT;i++)
1382 {
1383 if(app.TMSFileA[i].eTMSType==eTMSFileType_TexturePack)
1384 {
1385 app.RemoveMemoryTPDFile(app.TMSFileA[i].iConfig);
1386 }
1387 }
1388 app.FreeLocalTMSFiles(eTMSFileType_TexturePack);
1389
1390 return S_OK;
1391}
1392
1393void CScene_LoadGameSettings::LoadLevelGen(LevelGenerationOptions *levelGen)
1394{
1395 bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && m_MoreOptionsParams.bOnlineGame;
1396
1397 // 4J Stu - If we only have one controller connected, then don't show the sign-in UI again
1398 DWORD connectedControllers = 0;
1399 for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i)
1400 {
1401 if( InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i) ) ++connectedControllers;
1402 }
1403
1404 if(!isClientSide || connectedControllers == 1 || !RenderManager.IsHiDef())
1405 {
1406 // Check if user-created content is allowed, as we cannot play multiplayer if it's not
1407 bool noUGC = false;
1408 BOOL pccAllowed = TRUE;
1409 BOOL pccFriendsAllowed = TRUE;
1410 ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed);
1411 if(!pccAllowed && !pccFriendsAllowed) noUGC = true;
1412
1413 if(isClientSide && noUGC )
1414 {
1415 SetShow( TRUE );
1416 m_bIgnoreInput=false;
1417 UINT uiIDA[1];
1418 uiIDA[0]=IDS_CONFIRM_OK;
1419 StorageManager.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable());
1420 return;
1421 }
1422 }
1423
1424 DWORD dwLocalUsersMask = 0;
1425
1426 dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad());
1427 // Load data from disc
1428 //File saveFile( L"Tutorial\\Tutorial" );
1429 //LoadSaveFromDisk(&saveFile);
1430
1431 StorageManager.ResetSaveData();
1432 // Make our next save default to the name of the level
1433 StorageManager.SetSaveTitle(levelGen->getDefaultSaveName().c_str());
1434
1435 bool isPrivate = (app.GetGameSettings(m_iPad,eGameSetting_InviteOnly)>0)?true:false;
1436
1437 g_NetworkManager.HostGame(dwLocalUsersMask,isClientSide,isPrivate,MINECRAFT_NET_MAX_PLAYERS,0);
1438
1439 NetworkGameInitData *param = new NetworkGameInitData();
1440 param->seed = 0;
1441 param->saveData = NULL;
1442 param->levelGen = levelGen;
1443
1444 if(levelGen->requiresTexturePack())
1445 {
1446 param->texturePackId = levelGen->getRequiredTexturePackId();
1447
1448 Minecraft *pMinecraft = Minecraft::GetInstance();
1449 pMinecraft->skins->selectTexturePackById(param->texturePackId);
1450 //pMinecraft->skins->updateUI();
1451 }
1452
1453
1454 app.SetGameHostOption(eGameHostOption_Difficulty,Minecraft::GetInstance()->options->difficulty);
1455 app.SetGameHostOption(eGameHostOption_FriendsOfFriends,app.GetGameSettings(m_iPad,eGameSetting_FriendsOfFriends));
1456 app.SetGameHostOption(eGameHostOption_Gamertags,app.GetGameSettings(m_iPad,eGameSetting_GamertagsVisible));
1457
1458 app.SetGameHostOption(eGameHostOption_BedrockFog,app.GetGameSettings(m_iPad,eGameSetting_BedrockFog)?1:0);
1459
1460 // 4J-JEV: Fix for:
1461 // TU12: Content: Gameplay: New "Mass Effect World" remembers and uses the settings of another - lately created - World.
1462 app.SetGameHostOption(eGameHostOption_LevelType,m_MoreOptionsParams.bFlatWorld);
1463 app.SetGameHostOption(eGameHostOption_Structures,m_MoreOptionsParams.bStructures);
1464 app.SetGameHostOption(eGameHostOption_BonusChest,m_MoreOptionsParams.bBonusChest);
1465
1466 app.SetGameHostOption(eGameHostOption_PvP,m_MoreOptionsParams.bPVP);
1467 app.SetGameHostOption(eGameHostOption_TrustPlayers,m_MoreOptionsParams.bTrust );
1468 app.SetGameHostOption(eGameHostOption_FireSpreads,m_MoreOptionsParams.bFireSpreads );
1469 app.SetGameHostOption(eGameHostOption_TNT,m_MoreOptionsParams.bTNT );
1470 app.SetGameHostOption(eGameHostOption_HostCanFly,m_MoreOptionsParams.bHostPrivileges);
1471 app.SetGameHostOption(eGameHostOption_HostCanChangeHunger,m_MoreOptionsParams.bHostPrivileges);
1472 app.SetGameHostOption(eGameHostOption_HostCanBeInvisible,m_MoreOptionsParams.bHostPrivileges );
1473
1474 // flag if the user wants to reset the Nether to force a Fortress with netherwart etc.
1475 app.SetResetNether((m_MoreOptionsParams.bResetNether==TRUE)?true:false);
1476 // clear out the app's terrain features list
1477 app.ClearTerrainFeaturePosition();
1478
1479 app.SetGameHostOption(eGameHostOption_GameType,m_bGameModeSurvival?GameType::SURVIVAL->getId():GameType::CREATIVE->getId());
1480
1481 param->settings = app.GetGameHostOption( eGameHostOption_All );
1482
1483 LoadingInputParams *loadingParams = new LoadingInputParams();
1484 loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc;
1485 loadingParams->lpParam = (LPVOID)param;
1486
1487 // Reset the autosave timer
1488 app.SetAutosaveTimerTime();
1489
1490 UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData();
1491 completionData->bShowBackground=TRUE;
1492 completionData->bShowLogo=TRUE;
1493 completionData->type = e_ProgressCompletion_CloseAllPlayersUIScenes;
1494 completionData->iPad = DEFAULT_XUI_MENU_USER;
1495 loadingParams->completionData = completionData;
1496
1497 app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams);
1498}
1499
1500
1501HRESULT CScene_LoadGameSettings::OnCustomMessage_DLCInstalled()
1502{
1503 // mounted DLC may have changed
1504 if(app.StartInstallDLCProcess(m_iPad)==false)
1505 {
1506 // not doing a mount, so re-enable input
1507 m_bIgnoreInput=false;
1508 }
1509 else
1510 {
1511 m_bIgnoreInput=true;
1512 // clear out the texture pack list and do again
1513 m_pTexturePacksList->RemoveAllData();
1514 m_iTexturePacksNotInstalled=0;
1515
1516 }
1517
1518 // this will send a CustomMessage_DLCMountingComplete when done
1519 return S_OK;
1520}
1521
1522
1523HRESULT CScene_LoadGameSettings::OnCustomMessage_DLCMountingComplete()
1524{
1525 m_pTexturePacksList->SetSelectionChangedHandle(m_hObj);
1526 Minecraft *pMinecraft = Minecraft::GetInstance();
1527 int texturePacksCount = pMinecraft->skins->getTexturePackCount();
1528 CXuiCtrl4JList::LIST_ITEM_INFO ListInfo;
1529 HRESULT hr;
1530 for(unsigned int i = 0; i < texturePacksCount; ++i)
1531 {
1532 TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i);
1533 ZeroMemory(&ListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO));
1534
1535 DWORD dwImageBytes;
1536 PBYTE pbImageData = tp->getPackIcon(dwImageBytes);
1537
1538 if(dwImageBytes > 0 && pbImageData)
1539 {
1540 ListInfo.fEnabled = TRUE;
1541 hr=XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&ListInfo.hXuiBrush);
1542
1543 DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tp;
1544 if(pDLCTexPack)
1545 {
1546 int id=pDLCTexPack->getDLCParentPackId();
1547
1548 if(id==0)
1549 {
1550 // default texture pack - should come first
1551 ListInfo.iSortIndex=0x0FFFFFFF;
1552 }
1553 else
1554 {
1555 ListInfo.iSortIndex=id;
1556 ListInfo.iData=id;
1557 }
1558 }
1559 m_pTexturePacksList->AddData(ListInfo,0,CXuiCtrl4JList::eSortList_Index);
1560 }
1561 }
1562 m_currentTexturePackIndex = m_pTexturePacksList->GetIndexByUserData(m_MoreOptionsParams.dwTexturePack);
1563 m_pTexturePacksList->SetCurSel(m_currentTexturePackIndex);
1564 m_pTexturePacksList->SetTopItem(m_currentTexturePackIndex); // scroll the item into view if it's not visible
1565
1566 m_iTexturePacksNotInstalled=0;
1567
1568 // 4J-PB - there may be texture packs we don't have, so use the info from TMS for this
1569 DLC_INFO *pDLCInfo=NULL;
1570
1571 // first pass - look to see if there are any that are not in the list
1572 bool bTexturePackAlreadyListed;
1573 bool bNeedToGetTPD=false;
1574
1575 for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i)
1576 {
1577 bTexturePackAlreadyListed=false;
1578 ULONGLONG ull=app.GetDLCInfoTexturesFullOffer(i);
1579 pDLCInfo=app.GetDLCInfoForFullOfferID(ull);
1580 for(unsigned int i = 0; i < texturePacksCount; ++i)
1581 {
1582 TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i);
1583 if(pDLCInfo->iConfig==tp->getDLCParentPackId())
1584 {
1585 bTexturePackAlreadyListed=true;
1586 }
1587 }
1588 if(bTexturePackAlreadyListed==false)
1589 {
1590 // some missing
1591 bNeedToGetTPD=true;
1592
1593 m_iTexturePacksNotInstalled++;
1594 }
1595 }
1596
1597 if(bNeedToGetTPD==true)
1598 {
1599 // add a TMS request for them
1600 app.DebugPrintf("+++ Adding TMSPP request for texture pack data\n");
1601 app.AddTMSPPFileTypeRequest(e_DLC_TexturePackData);
1602 if(m_iConfigA!=NULL)
1603 {
1604 delete m_iConfigA;
1605 }
1606 m_iConfigA= new int [m_iTexturePacksNotInstalled];
1607 m_iTexturePacksNotInstalled=0;
1608
1609 for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i)
1610 {
1611 bTexturePackAlreadyListed=false;
1612 ULONGLONG ull=app.GetDLCInfoTexturesFullOffer(i);
1613 pDLCInfo=app.GetDLCInfoForFullOfferID(ull);
1614 for(unsigned int i = 0; i < texturePacksCount; ++i)
1615 {
1616 TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i);
1617 if(pDLCInfo->iConfig==tp->getDLCParentPackId())
1618 {
1619 bTexturePackAlreadyListed=true;
1620 }
1621 }
1622 if(bTexturePackAlreadyListed==false)
1623 {
1624 m_iConfigA[m_iTexturePacksNotInstalled++]=pDLCInfo->iConfig;
1625 }
1626 }
1627 }
1628
1629 UpdateTexturePackDescription(m_currentTexturePackIndex);
1630
1631 m_bIgnoreInput=false;
1632 app.m_dlcManager.checkForCorruptDLCAndAlert();
1633 return S_OK;
1634}
1635
1636int CScene_LoadGameSettings::TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
1637{
1638 CScene_LoadGameSettings *pClass = (CScene_LoadGameSettings *)pParam;
1639#ifdef _XBOX
1640 pClass->m_currentTexturePackIndex = pClass->m_pTexturePacksList->GetCurSel();
1641 // Exit with or without saving
1642 // Decline means install full version of the texture pack in this dialog
1643 if(result==C4JStorage::EMessage_ResultDecline || result==C4JStorage::EMessage_ResultAccept)
1644 {
1645 // we need to enable background downloading for the DLC
1646 XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW);
1647
1648 ULONGLONG ullOfferID_Full;
1649 ULONGLONG ullIndexA[1];
1650 CXuiCtrl4JList::LIST_ITEM_INFO ListItem;
1651 // get the current index of the list, and then get the data
1652 ListItem=pClass->m_pTexturePacksList->GetData(pClass->m_currentTexturePackIndex);
1653 app.GetDLCFullOfferIDForPackID(ListItem.iData,&ullOfferID_Full);
1654
1655 if( result==C4JStorage::EMessage_ResultAccept ) // Full version
1656 {
1657 ullIndexA[0]=ullOfferID_Full;
1658 StorageManager.InstallOffer(1,ullIndexA,NULL,NULL);
1659
1660 }
1661 else // trial version
1662 {
1663 // if there is no trial version, this is a Cancel
1664 DLC_INFO *pDLCInfo=app.GetDLCInfoForFullOfferID(ullOfferID_Full);
1665 if(pDLCInfo->ullOfferID_Trial!=0LL)
1666 {
1667 ullIndexA[0]=pDLCInfo->ullOfferID_Trial;
1668 StorageManager.InstallOffer(1,ullIndexA,NULL,NULL);
1669 }
1670 }
1671 }
1672#endif
1673 pClass->m_bIgnoreInput=false;
1674 return 0;
1675}
1676
1677HRESULT CScene_LoadGameSettings::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled)
1678{
1679 // update the tooltips
1680 int iRB=-1;
1681#ifdef _XBOX
1682
1683#endif
1684 CXuiSceneBase::SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK, -1, -1,-1,-1,-1,iRB);
1685 return S_OK;
1686}