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 "UI.h"
3#include "UIScene_PauseMenu.h"
4#include "..\..\MinecraftServer.h"
5#include "..\..\MultiplayerLocalPlayer.h"
6#include "..\..\TexturePackRepository.h"
7#include "..\..\TexturePack.h"
8#include "..\..\DLCTexturePack.h"
9#include "..\..\..\Minecraft.World\StringHelpers.h"
10#ifdef __ORBIS__
11#include <error_dialog.h>
12#endif
13
14#ifdef _DURANGO
15#include "..\..\Durango\Leaderboards\DurangoStatsDebugger.h"
16#endif
17
18#ifdef __PSVITA__
19#include "PSVita\Network\SonyCommerce_Vita.h"
20#endif
21
22#if defined __PS3__ || defined __ORBIS__
23#define USE_SONY_REMOTE_STORAGE
24#endif
25
26UIScene_PauseMenu::UIScene_PauseMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
27{
28 // Setup all the Iggy references we need for this scene
29 initialiseMovie();
30 m_bIgnoreInput=false;
31 m_eAction=eAction_None;
32
33 m_buttons[BUTTON_PAUSE_RESUMEGAME].init(app.GetString(IDS_RESUME_GAME),BUTTON_PAUSE_RESUMEGAME);
34 m_buttons[BUTTON_PAUSE_HELPANDOPTIONS].init(app.GetString(IDS_HELP_AND_OPTIONS),BUTTON_PAUSE_HELPANDOPTIONS);
35 m_buttons[BUTTON_PAUSE_LEADERBOARDS].init(app.GetString(IDS_LEADERBOARDS),BUTTON_PAUSE_LEADERBOARDS);
36#ifdef _DURANGO
37 m_buttons[BUTTON_PAUSE_XBOXHELP].init(app.GetString(IDS_XBOX_HELP_APP), BUTTON_PAUSE_XBOXHELP);
38#else
39 m_buttons[BUTTON_PAUSE_ACHIEVEMENTS].init(app.GetString(IDS_ACHIEVEMENTS),BUTTON_PAUSE_ACHIEVEMENTS);
40#endif
41#if defined(_XBOX_ONE) || defined(__ORBIS__)
42 m_bTrialTexturePack = false;
43 if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin())
44 {
45 TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
46 DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack;
47
48 m_pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack();
49
50 if(!m_pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" ))
51 {
52 m_bTrialTexturePack = true;
53 }
54 }
55
56 // 4J-TomK - check for all possible labels being fed into BUTTON_PAUSE_SAVEGAME (Bug 163775)
57 // this has to be done before button initialisation!
58 wchar_t saveButtonLabels[2][256];
59 swprintf( saveButtonLabels[0], 256, L"%ls", app.GetString( IDS_SAVE_GAME ));
60 swprintf( saveButtonLabels[1], 256, L"%ls", app.GetString( IDS_DISABLE_AUTOSAVE ));
61 m_buttons[BUTTON_PAUSE_SAVEGAME].setAllPossibleLabels(2,saveButtonLabels);
62
63 if(app.GetGameHostOption(eGameHostOption_DisableSaving) || m_bTrialTexturePack)
64 {
65 m_savesDisabled = true;
66 m_buttons[BUTTON_PAUSE_SAVEGAME].init(app.GetString(IDS_SAVE_GAME),BUTTON_PAUSE_SAVEGAME);
67 }
68 else
69 {
70 m_savesDisabled = false;
71 m_buttons[BUTTON_PAUSE_SAVEGAME].init(app.GetString(IDS_DISABLE_AUTOSAVE),BUTTON_PAUSE_SAVEGAME);
72 }
73#else
74 m_buttons[BUTTON_PAUSE_SAVEGAME].init(app.GetString(IDS_SAVE_GAME),BUTTON_PAUSE_SAVEGAME);
75#endif
76 m_buttons[BUTTON_PAUSE_EXITGAME].init(app.GetString(IDS_EXIT_GAME),BUTTON_PAUSE_EXITGAME);
77
78 if(!ProfileManager.IsFullVersion())
79 {
80 // hide the trial timer
81 ui.ShowTrialTimer(false);
82 }
83
84 updateControlsVisibility();
85
86 doHorizontalResizeCheck();
87
88 // get rid of the quadrant display if it's on
89 ui.HidePressStart();
90
91#if TO_BE_IMPLEMENTED
92 XuiSetTimer(m_hObj,IGNORE_KEYPRESS_TIMERID,IGNORE_KEYPRESS_TIME);
93#endif
94
95 if( g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 )
96 {
97 app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_PauseServer,(void *)TRUE);
98 }
99
100 TelemetryManager->RecordMenuShown(m_iPad, eUIScene_PauseMenu, 0);
101 TelemetryManager->RecordPauseOrInactive(m_iPad);
102
103 Minecraft *pMinecraft = Minecraft::GetInstance();
104 if(pMinecraft != NULL && pMinecraft->localgameModes[iPad] != NULL )
105 {
106 TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[iPad];
107
108 // This just allows it to be shown
109 gameMode->getTutorial()->showTutorialPopup(false);
110 }
111 m_bErrorDialogRunning = false;
112}
113
114UIScene_PauseMenu::~UIScene_PauseMenu()
115{
116 Minecraft *pMinecraft = Minecraft::GetInstance();
117 if(pMinecraft != NULL && pMinecraft->localgameModes[m_iPad] != NULL )
118 {
119 TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad];
120
121 // This just allows it to be shown
122 gameMode->getTutorial()->showTutorialPopup(true);
123 }
124
125 m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,false);
126 m_parentLayer->showComponent(m_iPad,eUIComponent_MenuBackground,false);
127 m_parentLayer->showComponent(m_iPad,eUIComponent_Logo,false);
128}
129
130wstring UIScene_PauseMenu::getMoviePath()
131{
132 if(app.GetLocalPlayerCount() > 1)
133 {
134 return L"PauseMenuSplit";
135 }
136 else
137 {
138 return L"PauseMenu";
139 }
140}
141
142void UIScene_PauseMenu::tick()
143{
144 UIScene::tick();
145
146#ifdef __PSVITA__
147 // 4J-MGH - Need to check for installed DLC here, as we delay the installation of the key file on Vita
148 if(!app.DLCInstallProcessCompleted()) app.StartInstallDLCProcess(0);
149#endif
150
151
152#if defined _XBOX_ONE || defined __ORBIS__
153 if(!m_bTrialTexturePack && m_savesDisabled != (app.GetGameHostOption(eGameHostOption_DisableSaving) != 0) && ProfileManager.GetPrimaryPad() == m_iPad )
154 {
155 // We show the save button if saves are disabled as this lets us show a prompt to enable them (via purchasing a texture pack)
156 if( app.GetGameHostOption(eGameHostOption_DisableSaving) )
157 {
158 m_savesDisabled = true;
159 m_buttons[BUTTON_PAUSE_SAVEGAME].setLabel( app.GetString(IDS_SAVE_GAME) );
160 }
161 else
162 {
163 m_savesDisabled = false;
164 m_buttons[BUTTON_PAUSE_SAVEGAME].setLabel( app.GetString(IDS_DISABLE_AUTOSAVE) );
165 }
166 }
167#endif
168
169#ifdef __ORBIS__
170 // Process the error dialog (for a patch being available)
171 if(m_bErrorDialogRunning)
172 {
173 SceErrorDialogStatus stat = sceErrorDialogUpdateStatus();
174 if( stat == SCE_ERROR_DIALOG_STATUS_FINISHED )
175 {
176 sceErrorDialogTerminate();
177 m_bErrorDialogRunning=false;
178 }
179 }
180#endif
181}
182
183void UIScene_PauseMenu::updateTooltips()
184{
185 bool bUserisClientSide = ProfileManager.IsSignedInLive(m_iPad);
186 bool bIsisPrimaryHost=g_NetworkManager.IsHost() && (ProfileManager.GetPrimaryPad()==m_iPad);
187
188#ifdef _XBOX_ONE
189 bool bDisplayBanTip = !g_NetworkManager.IsLocalGame() && !bIsisPrimaryHost && !ProfileManager.IsGuest(m_iPad);
190#endif
191
192 int iY = -1;
193#if defined __PS3__ || defined __ORBIS__
194 if(m_iPad == ProfileManager.GetPrimaryPad() ) iY = IDS_TOOLTIPS_GAME_INVITES;
195#endif
196 int iRB = -1;
197 int iX = -1;
198
199 if(ProfileManager.IsFullVersion())
200 {
201 if(StorageManager.GetSaveDisabled())
202 {
203 iX = bIsisPrimaryHost?IDS_TOOLTIPS_SELECTDEVICE:-1;
204#ifdef _XBOX_ONE
205 iRB = bDisplayBanTip?IDS_TOOLTIPS_BANLEVEL:-1;
206#endif
207 if( CSocialManager::Instance()->IsTitleAllowedToPostImages() && CSocialManager::Instance()->AreAllUsersAllowedToPostImages() && bUserisClientSide )
208 {
209#ifndef __PS3__
210 iY = IDS_TOOLTIPS_SHARE;
211#endif
212 }
213 }
214 else
215 {
216 iX = bIsisPrimaryHost?IDS_TOOLTIPS_CHANGEDEVICE:-1;
217#ifdef _XBOX_ONE
218 iRB = bDisplayBanTip?IDS_TOOLTIPS_BANLEVEL:-1;
219#endif
220 if( CSocialManager::Instance()->IsTitleAllowedToPostImages() && CSocialManager::Instance()->AreAllUsersAllowedToPostImages() && bUserisClientSide)
221 {
222#ifndef __PS3__
223 iY = IDS_TOOLTIPS_SHARE;
224#endif
225 }
226 }
227 }
228 ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK,iX,iY, -1,-1,-1,iRB);
229}
230
231void UIScene_PauseMenu::updateComponents()
232{
233 m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,false);
234 m_parentLayer->showComponent(m_iPad,eUIComponent_MenuBackground,true);
235
236 if( app.GetLocalPlayerCount() == 1 ) m_parentLayer->showComponent(m_iPad,eUIComponent_Logo,true);
237 else m_parentLayer->showComponent(m_iPad,eUIComponent_Logo,false);
238}
239
240void UIScene_PauseMenu::handlePreReload()
241{
242#if defined _XBOX_ONE || defined __ORBIS__
243 if(ProfileManager.GetPrimaryPad() == m_iPad)
244 {
245 // 4J-TomK - check for all possible labels being fed into BUTTON_PAUSE_SAVEGAME (Bug 163775)
246 // this has to be done before button initialisation!
247 wchar_t saveButtonLabels[2][256];
248 swprintf( saveButtonLabels[0], 256, L"%ls", app.GetString( IDS_SAVE_GAME ));
249 swprintf( saveButtonLabels[1], 256, L"%ls", app.GetString( IDS_DISABLE_AUTOSAVE ));
250 m_buttons[BUTTON_PAUSE_SAVEGAME].setAllPossibleLabels(2,saveButtonLabels);
251 }
252#endif
253}
254
255void UIScene_PauseMenu::handleReload()
256{
257 updateTooltips();
258 updateControlsVisibility();
259
260#if defined _XBOX_ONE || defined __ORBIS__
261 if(ProfileManager.GetPrimaryPad() == m_iPad)
262 {
263 // We show the save button if saves are disabled as this lets us show a prompt to enable them (via purchasing a texture pack)
264 if( app.GetGameHostOption(eGameHostOption_DisableSaving) || m_bTrialTexturePack )
265 {
266 m_savesDisabled = true;
267 m_buttons[BUTTON_PAUSE_SAVEGAME].setLabel( app.GetString(IDS_SAVE_GAME) );
268 }
269 else
270 {
271 m_savesDisabled = false;
272 m_buttons[BUTTON_PAUSE_SAVEGAME].setLabel( app.GetString(IDS_DISABLE_AUTOSAVE) );
273 }
274 }
275#endif
276
277 doHorizontalResizeCheck();
278}
279
280void UIScene_PauseMenu::updateControlsVisibility()
281{
282 // are we the primary player?
283 // 4J-PB - fix for 7844 & 7845 -
284 // TCR # 128: XLA Pause Menu: When in a multiplayer game as a client the Pause Menu does not have a Leaderboards option.
285 // TCR # 128: XLA Pause Menu: When in a multiplayer game as a client the Pause Menu does not have an Achievements option.
286 if(ProfileManager.GetPrimaryPad()==m_iPad) // && g_NetworkManager.IsHost())
287 {
288 // are we in splitscreen?
289 // how many local players do we have?
290 if( app.GetLocalPlayerCount()>1 )
291 {
292 // Hide the BUTTON_PAUSE_LEADERBOARDS and BUTTON_PAUSE_ACHIEVEMENTS
293 removeControl( &m_buttons[BUTTON_PAUSE_LEADERBOARDS], false );
294#ifndef _XBOX_ONE
295 removeControl( &m_buttons[BUTTON_PAUSE_ACHIEVEMENTS], false );
296#endif
297 }
298#ifdef __PSVITA__
299 // MGH added - remove leaderboards in adhoc
300 if(CGameNetworkManager::usingAdhocMode())
301 {
302 removeControl( &m_buttons[BUTTON_PAUSE_LEADERBOARDS], false );
303 }
304#endif
305
306 if( !g_NetworkManager.IsHost() )
307 {
308 // Hide the BUTTON_PAUSE_SAVEGAME
309 removeControl( &m_buttons[BUTTON_PAUSE_SAVEGAME], false );
310 }
311 }
312 else
313 {
314 // Hide the BUTTON_PAUSE_LEADERBOARDS, BUTTON_PAUSE_ACHIEVEMENTS and BUTTON_PAUSE_SAVEGAME
315 removeControl( &m_buttons[BUTTON_PAUSE_LEADERBOARDS], false );
316#ifndef _XBOX_ONE
317 removeControl( &m_buttons[BUTTON_PAUSE_ACHIEVEMENTS], false );
318#endif
319 removeControl( &m_buttons[BUTTON_PAUSE_SAVEGAME], false );
320 }
321
322 // is saving disabled?
323 if(StorageManager.GetSaveDisabled())
324 {
325#ifdef _XBOX
326 // disable save button
327 m_buttons[BUTTON_PAUSE_SAVEGAME].setEnable(false);
328#endif
329 }
330
331#if defined(__PS3__) || defined (__PSVITA__) || defined(__ORBIS__)
332 // We don't have a way to display trophies/achievements, so remove the button, and we're allowed to not have it on Xbox One
333 removeControl( &m_buttons[BUTTON_PAUSE_ACHIEVEMENTS], false );
334#endif
335
336}
337
338void UIScene_PauseMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
339{
340 if(m_bIgnoreInput)
341 {
342 return;
343 }
344
345 //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");
346 ui.AnimateKeyPress(iPad, key, repeat, pressed, released);
347
348#ifdef _XBOX_ONE
349 bool bIsisPrimaryHost=g_NetworkManager.IsHost() && (ProfileManager.GetPrimaryPad()==iPad);
350 bool bDisplayBanTip = !g_NetworkManager.IsLocalGame() && !bIsisPrimaryHost && !ProfileManager.IsGuest(iPad);
351#endif
352
353 switch(key)
354 {
355#ifdef _DURANGO
356 case ACTION_MENU_GTC_RESUME:
357#endif
358#if defined(__PS3__) // not for Orbis - we want to use the pause menu (touchpad press) to select a menu item
359 case ACTION_MENU_PAUSEMENU:
360#endif
361 case ACTION_MENU_CANCEL:
362 if(pressed)
363 {
364#ifdef _DURANGO
365 //DurangoStatsDebugger::PrintStats(iPad);
366#endif
367
368 if( iPad == ProfileManager.GetPrimaryPad() && g_NetworkManager.IsLocalGame() )
369 {
370 app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_PauseServer,(void *)FALSE);
371 }
372
373 ui.PlayUISFX(eSFX_Back);
374 navigateBack();
375 if(!ProfileManager.IsFullVersion())
376 {
377 ui.ShowTrialTimer(true);
378 }
379 }
380 break;
381 case ACTION_MENU_OK:
382#ifdef __ORBIS__
383 case ACTION_MENU_TOUCHPAD_PRESS:
384#endif
385 case ACTION_MENU_UP:
386 case ACTION_MENU_DOWN:
387 if(pressed)
388 {
389 sendInputToMovie(key, repeat, pressed, released);
390 }
391 break;
392
393#if TO_BE_IMPLEMENTED
394 case VK_PAD_X:
395 // Change device
396 if(bIsisPrimaryHost)
397 {
398 // we need a function to deal with the return from this - if it changes, we need to update the pause menu and tooltips
399 // Fix for #12531 - TCR 001: BAS Game Stability: When a player selects to change a storage
400 // device, and repeatedly backs out of the SD screen, disconnects from LIVE, and then selects a SD, the title crashes.
401 m_bIgnoreInput=true;
402
403 StorageManager.SetSaveDevice(&UIScene_PauseMenu::DeviceSelectReturned,this,true);
404 }
405 rfHandled = TRUE;
406 break;
407#endif
408
409 case ACTION_MENU_Y:
410 {
411
412#if defined(__PS3__) || defined(__ORBIS__)
413 if(pressed && iPad == ProfileManager.GetPrimaryPad())
414 {
415#ifdef __ORBIS__
416 // If a patch is available, can't view invites
417 if (CheckForPatch()) break;
418#endif
419
420 // Are we offline?
421 if(!ProfileManager.IsSignedInLive(iPad))
422 {
423 m_eAction=eAction_ViewInvitesPSN;
424#ifdef __ORBIS__
425 int npAvailability = ProfileManager.getNPAvailability(iPad);
426 if (npAvailability == SCE_NP_ERROR_AGE_RESTRICTION)
427 {
428 // 4J Stu - This is a bit messy and is due to the library incorrectly returning false for IsSignedInLive is the npAvailability isn't SCE_OK
429 UINT uiIDA[1];
430 uiIDA[0]=IDS_OK;
431 ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, iPad);
432 }
433 else
434 // Determine why they're not "signed in live"
435 if (ProfileManager.isSignedInPSN(iPad))
436 {
437 // Signed in to PSN but not connected (no internet access)
438 assert(!ProfileManager.isConnectedToPSN(iPad));
439
440 UINT uiIDA[1];
441 uiIDA[0] = IDS_OK;
442 ui.RequestErrorMessage( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, iPad);
443 }
444 else
445 {
446 // Not signed in to PSN
447 UINT uiIDA[1];
448 uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT;
449 ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, iPad, &UIScene_PauseMenu::MustSignInReturnedPSN, (LPVOID)GetCallbackUniqueId() );
450 }
451#else // __PS3__
452 // get them to sign in to online
453 UINT uiIDA[1];
454 uiIDA[0]=IDS_PRO_NOTONLINE_ACCEPT;
455 ui.RequestAlertMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, iPad, &UIScene_PauseMenu::MustSignInReturnedPSN, (LPVOID)GetCallbackUniqueId() );
456#endif
457 }
458 else
459 {
460#ifdef __ORBIS__
461 SQRNetworkManager_Orbis::RecvInviteGUI();
462#else // __PS3__
463 int ret = sceNpBasicRecvMessageCustom(SCE_NP_BASIC_MESSAGE_MAIN_TYPE_INVITE, SCE_NP_BASIC_RECV_MESSAGE_OPTIONS_INCLUDE_BOOTABLE, SYS_MEMORY_CONTAINER_ID_INVALID);
464 app.DebugPrintf("sceNpBasicRecvMessageCustom return %d ( %08x )\n", ret, ret);
465#endif
466 }
467 }
468#else
469#if TO_BE_IMPLEMENTED
470 if(bUserisClientSide)
471 {
472 // 4J Stu - Added check in 1.8.2 bug fix (TU6) to stop repeat key presses
473 bool bCanScreenshot = true;
474 for(int j=0; j < XUSER_MAX_COUNT;++j)
475 {
476 if(app.GetXuiAction(j) == eAppAction_SocialPostScreenshot)
477 {
478 bCanScreenshot = false;
479 break;
480 }
481 }
482 if(bCanScreenshot) app.SetAction(pInputData->UserIndex,eAppAction_SocialPost);
483 }
484 rfHandled = TRUE;
485#endif
486#endif // __PS3__
487 }
488 break;
489#ifdef _XBOX_ONE
490 case ACTION_MENU_RIGHT_SCROLL:
491 if( bDisplayBanTip )
492 {
493 UINT uiIDA[2];
494 uiIDA[0]=IDS_CONFIRM_CANCEL;
495 uiIDA[1]=IDS_CONFIRM_OK;
496 ui.RequestAlertMessage(IDS_ACTION_BAN_LEVEL_TITLE, IDS_ACTION_BAN_LEVEL_DESCRIPTION, uiIDA, 2, iPad,&UIScene_PauseMenu::BanGameDialogReturned,(LPVOID)GetCallbackUniqueId() );
497
498 //rfHandled = TRUE;
499 }
500 break;
501#endif
502 }
503}
504
505void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId)
506{
507 if(m_bIgnoreInput) return;
508
509 switch((int)controlId)
510 {
511 case BUTTON_PAUSE_RESUMEGAME:
512 if( m_iPad == ProfileManager.GetPrimaryPad() && g_NetworkManager.IsLocalGame() )
513 {
514 app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_PauseServer,(void *)FALSE);
515 }
516 navigateBack();
517 break;
518 case BUTTON_PAUSE_LEADERBOARDS:
519 {
520 UINT uiIDA[1];
521 uiIDA[0]=IDS_OK;
522
523 //4J Gordon: Being used for the leaderboards proper now
524 // guests can't look at leaderboards
525 if(ProfileManager.IsGuest(m_iPad))
526 {
527 ui.RequestAlertMessage(IDS_PRO_GUESTPROFILE_TITLE, IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad());
528 }
529 else if(!ProfileManager.IsSignedInLive(m_iPad))
530 {
531#ifdef __ORBIS__
532 // If a patch is available, can't show leaderboard
533 if (CheckForPatch()) break;
534
535 // Check for content restricted user
536 // Update error code
537 int errorCode = ProfileManager.getNPAvailability(m_iPad);
538
539 // Check if PSN is unavailable because of age restriction
540 if (errorCode == SCE_NP_ERROR_AGE_RESTRICTION)
541 {
542 UINT uiIDA[1];
543 uiIDA[0] = IDS_CONFIRM_OK;
544 ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, m_iPad);
545
546 break;;
547 }
548
549#endif
550
551#if defined __PS3__ || __PSVITA__
552 // get them to sign in to online
553 m_eAction=eAction_ViewLeaderboardsPSN;
554 UINT uiIDA[1];
555 uiIDA[0]=IDS_PRO_NOTONLINE_ACCEPT;
556 ui.RequestAlertMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, ProfileManager.GetPrimaryPad(),&UIScene_PauseMenu::MustSignInReturnedPSN,(LPVOID)GetCallbackUniqueId() );
557#elif defined(__ORBIS__)
558 m_eAction=eAction_ViewLeaderboardsPSN;
559 int npAvailability = ProfileManager.getNPAvailability(m_iPad);
560 if (npAvailability == SCE_NP_ERROR_AGE_RESTRICTION)
561 {
562 // 4J Stu - This is a bit messy and is due to the library incorrectly returning false for IsSignedInLive is the npAvailability isn't SCE_OK
563 UINT uiIDA[1];
564 uiIDA[0]=IDS_OK;
565 ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, m_iPad);
566 }
567 else
568 // Determine why they're not "signed in live"
569 if (ProfileManager.isSignedInPSN(m_iPad))
570 {
571 // Signed in to PSN but not connected (no internet access)
572
573 // Id
574 assert(!ProfileManager.isConnectedToPSN(m_iPad));
575
576 UINT uiIDA[1];
577 uiIDA[0] = IDS_OK;
578 ui.RequestErrorMessage( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, m_iPad);
579 }
580 else
581 {
582 // Not signed in to PSN
583 UINT uiIDA[1];
584 uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT;
585 ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, m_iPad, &UIScene_PauseMenu::MustSignInReturnedPSN, (LPVOID)GetCallbackUniqueId() );
586 }
587#else
588 UINT uiIDA[1] = { IDS_OK };
589 ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, m_iPad);
590#endif
591 }
592 else
593 {
594 bool bContentRestricted=false;
595#if defined(__PS3__) || defined(__PSVITA__)
596 ProfileManager.GetChatAndContentRestrictions(m_iPad,true,NULL,&bContentRestricted,NULL);
597#endif
598 if(bContentRestricted)
599 {
600#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
601 // you can't see leaderboards
602 UINT uiIDA[1];
603 uiIDA[0]=IDS_CONFIRM_OK;
604 ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, m_iPad);
605#endif
606 }
607 else
608 {
609 ui.NavigateToScene(m_iPad, eUIScene_LeaderboardsMenu);
610 }
611 }
612 }
613 break;
614#ifdef _DURANGO
615 case BUTTON_PAUSE_XBOXHELP:
616 {
617 // 4J: Launch the crummy xbox help application.
618 WXS::User^ user = ProfileManager.GetUser(m_iPad);
619 Windows::Xbox::ApplicationModel::Help::Show(user);
620 }
621 break;
622#elif TO_BE_IMPLEMENTED
623 case BUTTON_PAUSE_ACHIEVEMENTS:
624
625 // guests can't look at achievements
626 if(ProfileManager.IsGuest(pNotifyPressData->UserIndex))
627 {
628 UINT uiIDA[1];
629 uiIDA[0]=IDS_OK;
630 ui.RequestAlertMessage(IDS_PRO_GUESTPROFILE_TITLE, IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad());
631 }
632 else
633 {
634 XShowAchievementsUI( pNotifyPressData->UserIndex );
635 }
636 break;
637#endif
638
639 case BUTTON_PAUSE_HELPANDOPTIONS:
640 ui.NavigateToScene(m_iPad,eUIScene_HelpAndOptionsMenu);
641 break;
642 case BUTTON_PAUSE_SAVEGAME:
643 PerformActionSaveGame();
644 break;
645 case BUTTON_PAUSE_EXITGAME:
646 {
647 Minecraft *pMinecraft = Minecraft::GetInstance();
648 // Check if it's the trial version
649 if(ProfileManager.IsFullVersion())
650 {
651 UINT uiIDA[3];
652
653 // is it the primary player exiting?
654 if(m_iPad==ProfileManager.GetPrimaryPad())
655 {
656 int playTime = -1;
657 if( pMinecraft->localplayers[m_iPad] != NULL )
658 {
659 playTime = (int)pMinecraft->localplayers[m_iPad]->getSessionTimer();
660 }
661
662#if defined(_XBOX_ONE) || defined(__ORBIS__)
663 uiIDA[0]=IDS_CONFIRM_CANCEL;
664 uiIDA[1]=IDS_CONFIRM_OK;
665
666 if(g_NetworkManager.IsHost() && StorageManager.GetSaveDisabled())
667 {
668 uiIDA[0]=IDS_CONFIRM_CANCEL;
669 uiIDA[1]=IDS_EXIT_GAME_SAVE;
670 uiIDA[2]=IDS_EXIT_GAME_NO_SAVE;
671
672 if(g_NetworkManager.GetPlayerCount()>1)
673 {
674 ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE, uiIDA, 3, m_iPad,&UIScene_PauseMenu::ExitGameSaveDialogReturned, (LPVOID)GetCallbackUniqueId());
675 }
676 else
677 {
678 ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3, m_iPad,&UIScene_PauseMenu::ExitGameSaveDialogReturned, (LPVOID)GetCallbackUniqueId());
679 }
680 }
681 else if(g_NetworkManager.IsHost() && g_NetworkManager.GetPlayerCount()>1)
682 {
683 ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT, uiIDA, 2, m_iPad,&IUIScene_PauseMenu::ExitGameDialogReturned, (LPVOID)GetCallbackUniqueId());
684 }
685 else
686 {
687 ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, m_iPad,&IUIScene_PauseMenu::ExitGameDialogReturned, (LPVOID)GetCallbackUniqueId());
688 }
689#else
690 if(StorageManager.GetSaveDisabled())
691 {
692 uiIDA[0]=IDS_CONFIRM_CANCEL;
693 uiIDA[1]=IDS_CONFIRM_OK;
694 ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_PROGRESS_LOST, uiIDA, 2, m_iPad,&IUIScene_PauseMenu::ExitGameDialogReturned, (LPVOID)GetCallbackUniqueId());
695 }
696 else
697 {
698 if( g_NetworkManager.IsHost() )
699 {
700 uiIDA[0]=IDS_CONFIRM_CANCEL;
701 uiIDA[1]=IDS_EXIT_GAME_SAVE;
702 uiIDA[2]=IDS_EXIT_GAME_NO_SAVE;
703
704 if(g_NetworkManager.GetPlayerCount()>1)
705 {
706 ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE, uiIDA, 3, m_iPad,&UIScene_PauseMenu::ExitGameSaveDialogReturned, (LPVOID)GetCallbackUniqueId());
707 }
708 else
709 {
710 ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3, m_iPad,&UIScene_PauseMenu::ExitGameSaveDialogReturned, (LPVOID)GetCallbackUniqueId());
711 }
712 }
713 else
714 {
715 uiIDA[0]=IDS_CONFIRM_CANCEL;
716 uiIDA[1]=IDS_CONFIRM_OK;
717
718 ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, m_iPad,&IUIScene_PauseMenu::ExitGameDialogReturned, (LPVOID)GetCallbackUniqueId());
719 }
720 }
721#endif
722 }
723 else
724 {
725 int playTime = -1;
726 if( pMinecraft->localplayers[m_iPad] != NULL )
727 {
728 playTime = (int)pMinecraft->localplayers[m_iPad]->getSessionTimer();
729 }
730
731 TelemetryManager->RecordLevelExit(m_iPad, eSen_LevelExitStatus_Exited);
732
733
734 // just exit the player
735 app.SetAction(m_iPad,eAppAction_ExitPlayer);
736 }
737 }
738 else
739 {
740 // is it the primary player exiting?
741 if(m_iPad==ProfileManager.GetPrimaryPad())
742 {
743 int playTime = -1;
744 if( pMinecraft->localplayers[m_iPad] != NULL )
745 {
746 playTime = (int)pMinecraft->localplayers[m_iPad]->getSessionTimer();
747 }
748
749 // adjust the trial time played
750 ui.ReduceTrialTimerValue();
751
752 // exit the level
753 UINT uiIDA[2];
754 uiIDA[0]=IDS_CONFIRM_CANCEL;
755 uiIDA[1]=IDS_CONFIRM_OK;
756 ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_PROGRESS_LOST, uiIDA, 2, m_iPad,&IUIScene_PauseMenu::ExitGameDialogReturned, (LPVOID)GetCallbackUniqueId());
757
758 }
759 else
760 {
761 int playTime = -1;
762 if( pMinecraft->localplayers[m_iPad] != NULL )
763 {
764 playTime = (int)pMinecraft->localplayers[m_iPad]->getSessionTimer();
765 }
766
767 TelemetryManager->RecordLevelExit(m_iPad, eSen_LevelExitStatus_Exited);
768
769 // just exit the player
770 app.SetAction(m_iPad,eAppAction_ExitPlayer);
771 }
772 }
773 }
774 break;
775 }
776}
777
778void UIScene_PauseMenu::PerformActionSaveGame()
779{
780 // is the player trying to save in the trial version?
781 if(!ProfileManager.IsFullVersion())
782 {
783#ifdef __ORBIS__
784 // If a patch is available, can't buy full game
785 if (CheckForPatch()) return;
786#endif
787
788 // Unlock the full version?
789 if(!ProfileManager.IsSignedInLive(m_iPad))
790 {
791#if defined(__PS3__) || defined (__PSVITA__)
792 m_eAction=eAction_SaveGamePSN;
793 UINT uiIDA[2];
794 uiIDA[0]=IDS_PRO_NOTONLINE_ACCEPT;
795 uiIDA[1]=IDS_PRO_NOTONLINE_DECLINE;
796 ui.RequestAlertMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 2, ProfileManager.GetPrimaryPad(),&UIScene_PauseMenu::MustSignInReturnedPSN,(LPVOID)GetCallbackUniqueId());
797#elif defined(__ORBIS__)
798 m_eAction=eAction_SaveGamePSN;
799 int npAvailability = ProfileManager.getNPAvailability(m_iPad);
800 if (npAvailability == SCE_NP_ERROR_AGE_RESTRICTION)
801 {
802 // 4J Stu - This is a bit messy and is due to the library incorrectly returning false for IsSignedInLive is the npAvailability isn't SCE_OK
803 UINT uiIDA[1];
804 uiIDA[0]=IDS_OK;
805 ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, m_iPad);
806 }
807 else
808 // Determine why they're not "signed in live"
809 if (ProfileManager.isSignedInPSN(m_iPad))
810 {
811 // Signed in to PSN but not connected (no internet access)
812 assert(!ProfileManager.isConnectedToPSN(m_iPad));
813
814 UINT uiIDA[1];
815 uiIDA[0] = IDS_OK;
816 ui.RequestErrorMessage( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, m_iPad);
817 }
818 else
819 {
820 // Not signed in to PSN
821 UINT uiIDA[1];
822 uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT;
823 ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, m_iPad, &UIScene_PauseMenu::MustSignInReturnedPSN, (LPVOID)GetCallbackUniqueId());
824 }
825#endif
826 }
827 else
828 {
829 UINT uiIDA[2];
830 uiIDA[0]=IDS_CONFIRM_OK;
831 uiIDA[1]=IDS_CONFIRM_CANCEL;
832 ui.RequestAlertMessage(IDS_UNLOCK_TITLE, IDS_UNLOCK_TOSAVE_TEXT, uiIDA, 2,m_iPad,&UIScene_PauseMenu::UnlockFullSaveReturned,(LPVOID)GetCallbackUniqueId());
833 }
834
835 return;
836 }
837
838 // 4J-PB - Is the player trying to save but they are using a trial texturepack ?
839 if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin())
840 {
841 TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
842 DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack;
843
844 m_pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack();
845
846 if(!m_pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" ))
847 {
848 // upsell
849#ifdef _XBOX
850 ULONGLONG ullOfferID_Full;
851 // get the dlc texture pack
852 DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack;
853
854 app.GetDLCFullOfferIDForPackID(pDLCTexPack->getDLCParentPackId(),&ullOfferID_Full);
855
856 // tell sentient about the upsell of the full version of the texture pack
857 TelemetryManager->RecordUpsellPresented(m_iPad, eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF);
858#endif
859 UINT uiIDA[2];
860 uiIDA[0]=IDS_CONFIRM_OK;
861 uiIDA[1]=IDS_CONFIRM_CANCEL;
862
863 // Give the player a warning about the trial version of the texture pack
864#ifdef __PSVITA__
865 if(app.DLCInstallProcessCompleted() && !SonyCommerce_Vita::getDLCUpgradePending()) // MGH - devtrack #5861 On vita it can take a bit after the install has finished to register the purchase, so make sure we don't end up asking to purchase again
866#endif
867 {
868 ui.RequestAlertMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, m_iPad,&UIScene_PauseMenu::WarningTrialTexturePackReturned,(LPVOID)GetCallbackUniqueId());
869 }
870
871 return;
872 }
873 else
874 {
875 m_bTrialTexturePack = false;
876 }
877 }
878
879 // does the save exist?
880 bool bSaveExists;
881 C4JStorage::ESaveGameState result=StorageManager.DoesSaveExist(&bSaveExists);
882
883#ifdef _XBOX
884 if(result == C4JStorage::ELoadGame_DeviceRemoved)
885 {
886 // this will be a tester trying to be clever
887 UINT uiIDA[2];
888 uiIDA[0]=IDS_SELECTANEWDEVICE;
889 uiIDA[1]=IDS_NODEVICE_DECLINE;
890
891 ui.RequestAlertMessage(IDS_STORAGEDEVICEPROBLEM_TITLE, IDS_FAILED_TO_LOADSAVE_TEXT, uiIDA, 2, m_iPad,&IUIScene_PauseMenu::DeviceRemovedDialogReturned,(LPVOID)GetCallbackUniqueId());
892 }
893 else
894#endif
895 {
896#if defined(_XBOX_ONE) || defined(__ORBIS__)
897 if(!m_savesDisabled)
898 {
899 UINT uiIDA[2];
900 uiIDA[0]=IDS_CANCEL;
901 uiIDA[1]=IDS_CONFIRM_OK;
902 ui.RequestAlertMessage(IDS_TITLE_DISABLE_AUTOSAVE, IDS_CONFIRM_DISABLE_AUTOSAVE, uiIDA, 2, m_iPad,&IUIScene_PauseMenu::DisableAutosaveDialogReturned,(LPVOID)GetCallbackUniqueId());
903 }
904 else
905#endif
906 // we need to ask if they are sure they want to overwrite the existing game
907 if(bSaveExists)
908 {
909 UINT uiIDA[2];
910 uiIDA[0]=IDS_CONFIRM_CANCEL;
911 uiIDA[1]=IDS_CONFIRM_OK;
912 ui.RequestAlertMessage(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, m_iPad,&IUIScene_PauseMenu::SaveGameDialogReturned,(LPVOID)GetCallbackUniqueId());
913 }
914 else
915 {
916#if defined(_XBOX_ONE) || defined(__ORBIS__)
917 UINT uiIDA[2];
918 uiIDA[0]=IDS_CONFIRM_CANCEL;
919 uiIDA[1]=IDS_CONFIRM_OK;
920 ui.RequestAlertMessage(IDS_TITLE_ENABLE_AUTOSAVE, IDS_CONFIRM_ENABLE_AUTOSAVE, uiIDA, 2, m_iPad,&IUIScene_PauseMenu::EnableAutosaveDialogReturned,(LPVOID)GetCallbackUniqueId());
921#else
922 // flag a app action of save game
923 app.SetAction(m_iPad,eAppAction_SaveGame);
924#endif
925 }
926 }
927}
928
929void UIScene_PauseMenu::ShowScene(bool show)
930{
931 app.DebugPrintf("UIScene_PauseMenu::ShowScene is not implemented\n");
932}
933
934void UIScene_PauseMenu::HandleDLCInstalled()
935{
936 // mounted DLC may have changed
937 if(app.StartInstallDLCProcess(m_iPad)==false)
938 {
939 // not doing a mount, so re-enable input
940 //m_bIgnoreInput=false;
941 app.DebugPrintf("UIScene_PauseMenu::HandleDLCInstalled - m_bIgnoreInput false\n");
942 }
943 else
944 {
945 // 4J-PB - Somehow, on th edisc build, we get in here, but don't call HandleDLCMountingComplete, so input locks up
946 //m_bIgnoreInput=true;
947 app.DebugPrintf("UIScene_PauseMenu::HandleDLCInstalled - m_bIgnoreInput true\n");
948 }
949 // this will send a CustomMessage_DLCMountingComplete when done
950}
951
952
953void UIScene_PauseMenu::HandleDLCMountingComplete()
954{
955 // check if we should display the save option
956
957 //m_bIgnoreInput=false;
958 app.DebugPrintf("UIScene_PauseMenu::HandleDLCMountingComplete - m_bIgnoreInput false \n");
959
960 // if(ProfileManager.IsFullVersion())
961 // {
962 // bool bIsisPrimaryHost=g_NetworkManager.IsHost() && (ProfileManager.GetPrimaryPad()==m_iPad);
963 //
964 // if(bIsisPrimaryHost)
965 // {
966 // m_buttons[BUTTON_PAUSE_SAVEGAME].setEnable(true);
967 // }
968 // }
969}
970
971int UIScene_PauseMenu::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
972{
973 Minecraft *pMinecraft=Minecraft::GetInstance();
974
975 if(result==C4JStorage::EMessage_ResultAccept)
976 {
977 if(ProfileManager.IsSignedInLive(pMinecraft->player->GetXboxPad()))
978 {
979 // 4J-PB - need to check this user can access the store
980#if defined(__PS3__) || defined(__PSVITA__)
981 bool bContentRestricted;
982 ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL);
983 if(bContentRestricted)
984 {
985 UINT uiIDA[1];
986 uiIDA[0]=IDS_CONFIRM_OK;
987 ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, ProfileManager.GetPrimaryPad());
988 }
989 else
990#endif
991 {
992 ProfileManager.DisplayFullVersionPurchase(false,pMinecraft->player->GetXboxPad(),eSen_UpsellID_Full_Version_Of_Game);
993 }
994 }
995 }
996 else
997 {
998 //SentientManager.RecordUpsellResponded(iPad, eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID, eSen_UpsellOutcome_Declined);
999 }
1000
1001 return 0;
1002}
1003
1004int UIScene_PauseMenu::SaveGame_SignInReturned(void *pParam,bool bContinue, int iPad)
1005{
1006 UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)ui.GetSceneFromCallbackId((size_t)pParam);
1007 if(pClass) pClass->SetIgnoreInput(false);
1008
1009 if(bContinue==true)
1010 {
1011 if(pClass) pClass->PerformActionSaveGame();
1012 }
1013
1014 return 0;
1015}
1016
1017#ifdef _XBOX_ONE
1018int UIScene_PauseMenu::BanGameDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
1019{
1020 // results switched for this dialog
1021 if(result==C4JStorage::EMessage_ResultDecline)
1022 {
1023 app.SetAction(iPad,eAppAction_BanLevel);
1024 }
1025 return 0;
1026}
1027#endif
1028
1029#if defined(__PS3__) || defined (__PSVITA__) || defined(__ORBIS__)
1030int UIScene_PauseMenu::MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::EMessageResult result)
1031{
1032 UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)ui.GetSceneFromCallbackId((size_t)pParam);
1033 if(result==C4JStorage::EMessage_ResultAccept && pClass)
1034 {
1035#ifdef __PS3__
1036 switch(pClass->m_eAction)
1037 {
1038 case eAction_ViewLeaderboardsPSN:
1039 SQRNetworkManager_PS3::AttemptPSNSignIn(&UIScene_PauseMenu::ViewLeaderboards_SignInReturned, pParam);
1040 break;
1041 case eAction_ViewInvitesPSN:
1042 SQRNetworkManager_PS3::AttemptPSNSignIn(&UIScene_PauseMenu::ViewInvites_SignInReturned, pParam);
1043 break;
1044 case eAction_SaveGamePSN:
1045 SQRNetworkManager_PS3::AttemptPSNSignIn(&UIScene_PauseMenu::SaveGame_SignInReturned, pParam);
1046 break;
1047 case eAction_BuyTexturePackPSN:
1048 SQRNetworkManager_PS3::AttemptPSNSignIn(&UIScene_PauseMenu::BuyTexturePack_SignInReturned, pParam);
1049 break;
1050 }
1051#elif defined __PSVITA__
1052 switch(pClass->m_eAction)
1053 {
1054 case eAction_ViewLeaderboardsPSN:
1055 //CD - Must force Ad-Hoc off if they want leaderboard PSN sign-in
1056 //Save settings change
1057 app.SetGameSettings(0, eGameSetting_PSVita_NetworkModeAdhoc, 0);
1058 //Force off
1059 CGameNetworkManager::setAdhocMode(false);
1060 //Now Sign-in
1061 SQRNetworkManager_Vita::AttemptPSNSignIn(&UIScene_PauseMenu::ViewLeaderboards_SignInReturned, pParam);
1062 break;
1063 case eAction_ViewInvitesPSN:
1064 SQRNetworkManager_Vita::AttemptPSNSignIn(&UIScene_PauseMenu::ViewInvites_SignInReturned, pParam);
1065 break;
1066 case eAction_SaveGamePSN:
1067 pClass->SetIgnoreInput(true);
1068 SQRNetworkManager_Vita::AttemptPSNSignIn(&UIScene_PauseMenu::SaveGame_SignInReturned, pParam, true);
1069 break;
1070 case eAction_BuyTexturePackPSN:
1071 SQRNetworkManager_Vita::AttemptPSNSignIn(&UIScene_PauseMenu::BuyTexturePack_SignInReturned, pParam);
1072 break;
1073 }
1074#else
1075 switch(pClass->m_eAction)
1076 {
1077 case eAction_ViewLeaderboardsPSN:
1078 SQRNetworkManager_Orbis::AttemptPSNSignIn(&UIScene_PauseMenu::ViewLeaderboards_SignInReturned, pClass, false, iPad);
1079 break;
1080 case eAction_ViewInvitesPSN:
1081 SQRNetworkManager_Orbis::AttemptPSNSignIn(&UIScene_PauseMenu::ViewInvites_SignInReturned, pClass, false, iPad);
1082 break;
1083 case eAction_SaveGamePSN:
1084 SQRNetworkManager_Orbis::AttemptPSNSignIn(&UIScene_PauseMenu::SaveGame_SignInReturned, pClass, false, iPad);
1085 break;
1086 case eAction_BuyTexturePackPSN:
1087 SQRNetworkManager_Orbis::AttemptPSNSignIn(&UIScene_PauseMenu::BuyTexturePack_SignInReturned, pClass, false, iPad);
1088 break;
1089 }
1090#endif
1091 }
1092
1093 return 0;
1094}
1095
1096int UIScene_PauseMenu::ViewLeaderboards_SignInReturned(void *pParam,bool bContinue, int iPad)
1097{
1098 UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)ui.GetSceneFromCallbackId((size_t)pParam);
1099 if(!pClass) return 0;
1100
1101 if(bContinue==true)
1102 {
1103 UINT uiIDA[1];
1104 uiIDA[0]=IDS_CONFIRM_OK;
1105
1106 // guests can't look at leaderboards
1107 if(ProfileManager.IsGuest(pClass->m_iPad))
1108 {
1109 ui.RequestAlertMessage(IDS_PRO_GUESTPROFILE_TITLE, IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad());
1110 }
1111 else if(ProfileManager.IsSignedInLive(iPad))
1112 {
1113#ifndef __ORBIS__
1114 bool bContentRestricted=false;
1115 ProfileManager.GetChatAndContentRestrictions(pClass->m_iPad,true,NULL,&bContentRestricted,NULL);
1116 if(bContentRestricted)
1117 {
1118 // you can't see leaderboards
1119 ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, ProfileManager.GetPrimaryPad());
1120 }
1121 else
1122#endif
1123 {
1124 ui.NavigateToScene(pClass->m_iPad, eUIScene_LeaderboardsMenu);
1125 }
1126 }
1127 }
1128
1129 return 0;
1130}
1131
1132int UIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
1133{
1134 UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)ui.GetSceneFromCallbackId((size_t)pParam);
1135
1136#ifdef __ORBIS__
1137 // If a patch is available, can't proceed
1138 if (!pClass || pClass->CheckForPatch()) return 0;
1139#endif
1140
1141#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
1142 if(result==C4JStorage::EMessage_ResultAccept)
1143 {
1144 if(!ProfileManager.IsSignedInLive(iPad))
1145 {
1146 if(pClass) pClass->m_eAction=eAction_SaveGamePSN;
1147#ifdef __ORBIS__// Check if PSN is unavailable because of age restriction
1148 int npAvailability = ProfileManager.getNPAvailability(iPad);
1149 if (npAvailability == SCE_NP_ERROR_AGE_RESTRICTION)
1150 {
1151 // 4J Stu - This is a bit messy and is due to the library incorrectly returning false for IsSignedInLive is the npAvailability isn't SCE_OK
1152 UINT uiIDA[1];
1153 uiIDA[0]=IDS_OK;
1154 ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, iPad);
1155 }
1156 else
1157 // Determine why they're not "signed in live"
1158 if (ProfileManager.isSignedInPSN(iPad))
1159 {
1160 // Signed in to PSN but not connected (no internet access)
1161 assert(!ProfileManager.isConnectedToPSN(iPad));
1162
1163 UINT uiIDA[1];
1164 uiIDA[0] = IDS_OK;
1165 ui.RequestErrorMessage( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, iPad);
1166 }
1167 else
1168 {
1169 UINT uiIDA[1];
1170 uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT;
1171 ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, iPad, &UIScene_PauseMenu::MustSignInReturnedPSN, pParam);
1172 }
1173#else // __PS3__
1174 // You're not signed in to PSN!
1175 UINT uiIDA[2];
1176 uiIDA[0]=IDS_PRO_NOTONLINE_ACCEPT;
1177 uiIDA[1]=IDS_PRO_NOTONLINE_DECLINE;
1178 ui.RequestAlertMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 2, iPad,&UIScene_PauseMenu::MustSignInReturnedPSN,pParam);
1179#endif
1180 }
1181 else
1182 {
1183#ifndef __ORBIS__
1184 // 4J-PB - need to check this user can access the store
1185 bool bContentRestricted=false;
1186 ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL);
1187 if(bContentRestricted)
1188 {
1189 UINT uiIDA[1];
1190 uiIDA[0]=IDS_CONFIRM_OK;
1191 ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, iPad);
1192 }
1193 else
1194#endif
1195 {
1196 // need to get info on the pack to see if the user has already downloaded it
1197 TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
1198 DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack;
1199
1200 // retrieve the store name for the skin pack
1201 DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack();
1202 const char *pchPackName=wstringtofilename(pDLCPack->getName());
1203 app.DebugPrintf("Texture Pack - %s\n",pchPackName);
1204 SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo((char *)pchPackName);
1205
1206 if(pSONYDLCInfo!=NULL)
1207 {
1208 char chName[42];
1209 char chKeyName[20];
1210 char chSkuID[SCE_NP_COMMERCE2_SKU_ID_LEN];
1211
1212 memset(chSkuID,0,SCE_NP_COMMERCE2_SKU_ID_LEN);
1213 // find the info on the skin pack
1214 // we have to retrieve the skuid from the store info, it can't be hardcoded since Sony may change it.
1215 // So we assume the first sku for the product is the one we want
1216
1217 // MGH - keyname in the DLC file is 16 chars long, but there's no space for a NULL terminating char
1218 memset(chKeyName, 0, sizeof(chKeyName));
1219 strncpy(chKeyName, pSONYDLCInfo->chDLCKeyname, 16);
1220
1221#ifdef __ORBIS__
1222 strcpy(chName, chKeyName);
1223#else
1224 sprintf(chName,"%s-%s",app.GetCommerceCategory(),chKeyName);
1225#endif
1226 app.GetDLCSkuIDFromProductList(chName,chSkuID);
1227
1228 // 4J-PB - need to check for an empty store
1229#if defined __ORBIS__ || defined __PSVITA__ || defined __PS3__
1230 if(app.CheckForEmptyStore(iPad)==false)
1231#endif
1232 {
1233 if(app.DLCAlreadyPurchased(chSkuID))
1234 {
1235 app.DownloadAlreadyPurchased(chSkuID);
1236 }
1237 else
1238 {
1239 app.Checkout(chSkuID);
1240 }
1241 }
1242 }
1243 }
1244 }
1245 }
1246#endif //
1247
1248 return 0;
1249}
1250
1251int UIScene_PauseMenu::BuyTexturePack_SignInReturned(void *pParam,bool bContinue, int iPad)
1252{
1253 if(bContinue==true)
1254 {
1255 // Check if we're signed in to LIVE
1256 if(ProfileManager.IsSignedInLive(iPad))
1257 {
1258#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
1259
1260#ifndef __ORBIS__
1261 // 4J-PB - need to check this user can access the store
1262 bool bContentRestricted=false;
1263 ProfileManager.GetChatAndContentRestrictions(iPad,true,NULL,&bContentRestricted,NULL);
1264 if(bContentRestricted)
1265 {
1266 UINT uiIDA[1];
1267 uiIDA[0]=IDS_CONFIRM_OK;
1268 ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, iPad);
1269 }
1270 else
1271#endif
1272 {
1273 // need to get info on the pack to see if the user has already downloaded it
1274 TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
1275 DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack;
1276
1277 // retrieve the store name for the skin pack
1278 DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack();
1279 const char *pchPackName=wstringtofilename(pDLCPack->getName());
1280 app.DebugPrintf("Texture Pack - %s\n",pchPackName);
1281 SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo((char *)pchPackName);
1282
1283 if(pSONYDLCInfo!=NULL)
1284 {
1285 char chName[42];
1286 char chKeyName[20];
1287 char chSkuID[SCE_NP_COMMERCE2_SKU_ID_LEN];
1288
1289 memset(chSkuID,0,SCE_NP_COMMERCE2_SKU_ID_LEN);
1290 // find the info on the skin pack
1291 // we have to retrieve the skuid from the store info, it can't be hardcoded since Sony may change it.
1292 // So we assume the first sku for the product is the one we want
1293
1294 // MGH - keyname in the DLC file is 16 chars long, but there's no space for a NULL terminating char
1295 memset(chKeyName, 0, sizeof(chKeyName));
1296 strncpy(chKeyName, pSONYDLCInfo->chDLCKeyname, 16);
1297
1298#ifdef __ORBIS__
1299 strcpy(chName, chKeyName);
1300#else
1301 sprintf(chName,"%s-%s",app.GetCommerceCategory(),chKeyName);
1302#endif
1303 app.GetDLCSkuIDFromProductList(chName,chSkuID);
1304
1305 // 4J-PB - need to check for an empty store
1306#if defined __ORBIS__ || defined __PSVITA__ || defined __PS3__
1307 if(app.CheckForEmptyStore(iPad)==false)
1308#endif
1309 {
1310 if(app.DLCAlreadyPurchased(chSkuID))
1311 {
1312 app.DownloadAlreadyPurchased(chSkuID);
1313 }
1314 else
1315 {
1316 app.Checkout(chSkuID);
1317 }
1318 }
1319 }
1320 }
1321#else
1322 // TO BE IMPEMENTED FOR ORBIS
1323#endif
1324 }
1325 }
1326 return 0;
1327}
1328
1329int UIScene_PauseMenu::ViewInvites_SignInReturned(void *pParam,bool bContinue, int iPad)
1330{
1331 if(bContinue==true)
1332 {
1333 // Check if we're signed in to LIVE
1334 if(ProfileManager.IsSignedInLive(iPad))
1335 {
1336#ifdef __ORBIS__
1337 SQRNetworkManager_Orbis::RecvInviteGUI();
1338#elif defined __PS3__
1339 int ret = sceNpBasicRecvMessageCustom(SCE_NP_BASIC_MESSAGE_MAIN_TYPE_INVITE, SCE_NP_BASIC_RECV_MESSAGE_OPTIONS_INCLUDE_BOOTABLE, SYS_MEMORY_CONTAINER_ID_INVALID);
1340 app.DebugPrintf("sceNpBasicRecvMessageCustom return %d ( %08x )\n", ret, ret);
1341#else // __PSVITA__
1342 PSVITA_STUBBED;
1343#endif
1344 }
1345 }
1346 return 0;
1347}
1348
1349
1350int UIScene_PauseMenu::ExitGameSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
1351{
1352 // Exit with or without saving
1353 // Decline means save in this dialog
1354 if(result==C4JStorage::EMessage_ResultDecline || result==C4JStorage::EMessage_ResultThirdOption)
1355 {
1356 if( result==C4JStorage::EMessage_ResultDecline ) // Save
1357 {
1358 // 4J-PB - Is the player trying to save but they are using a trial texturepack ?
1359 if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin())
1360 {
1361 TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
1362 DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack;
1363
1364 DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack();
1365 if(!pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" ))
1366 {
1367#ifdef _XBOX
1368 // upsell
1369 ULONGLONG ullOfferID_Full;
1370 // get the dlc texture pack
1371 DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack;
1372
1373 app.GetDLCFullOfferIDForPackID(pDLCTexPack->getDLCParentPackId(),&ullOfferID_Full);
1374
1375 // tell sentient about the upsell of the full version of the skin pack
1376 TelemetryManager->RecordUpsellPresented(iPad, eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF);
1377#endif
1378
1379 UINT uiIDA[2];
1380 uiIDA[0]=IDS_CONFIRM_OK;
1381 uiIDA[1]=IDS_CONFIRM_CANCEL;
1382
1383 // Give the player a warning about the trial version of the texture pack
1384 ui.RequestAlertMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad() ,&UIScene_PauseMenu::WarningTrialTexturePackReturned, pParam);
1385
1386 return S_OK;
1387 }
1388 }
1389
1390 // does the save exist?
1391 bool bSaveExists;
1392 StorageManager.DoesSaveExist(&bSaveExists);
1393 // 4J-PB - we check if the save exists inside the libs
1394 // we need to ask if they are sure they want to overwrite the existing game
1395 if(bSaveExists)
1396 {
1397 UINT uiIDA[2];
1398 uiIDA[0]=IDS_CONFIRM_CANCEL;
1399 uiIDA[1]=IDS_CONFIRM_OK;
1400 ui.RequestAlertMessage(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(),&IUIScene_PauseMenu::ExitGameAndSaveReturned, pParam);
1401 return 0;
1402 }
1403 else
1404 {
1405#if defined(_XBOX_ONE) || defined(__ORBIS__)
1406 StorageManager.SetSaveDisabled(false);
1407#endif
1408 MinecraftServer::getInstance()->setSaveOnExit( true );
1409 }
1410 }
1411 else
1412 {
1413 // been a few requests for a confirm on exit without saving
1414 UINT uiIDA[2];
1415 uiIDA[0]=IDS_CONFIRM_CANCEL;
1416 uiIDA[1]=IDS_CONFIRM_OK;
1417 ui.RequestAlertMessage(IDS_TITLE_DECLINE_SAVE_GAME, IDS_CONFIRM_DECLINE_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(),&IUIScene_PauseMenu::ExitGameDeclineSaveReturned, pParam);
1418 return 0;
1419 }
1420
1421 app.SetAction(iPad,eAppAction_ExitWorld);
1422 }
1423 return 0;
1424}
1425
1426#endif
1427
1428void UIScene_PauseMenu::SetIgnoreInput(bool ignoreInput)
1429{
1430 m_bIgnoreInput = ignoreInput;
1431}
1432
1433#ifdef _XBOX_ONE
1434void UIScene_PauseMenu::HandleDLCLicenseChange()
1435{
1436}
1437#endif
1438
1439#ifdef __ORBIS__
1440bool UIScene_PauseMenu::CheckForPatch()
1441{
1442 int npAvailability = ProfileManager.getNPAvailability(ProfileManager.GetPrimaryPad());
1443
1444 bool bPatchAvailable;
1445 switch(npAvailability)
1446 {
1447 case SCE_NP_ERROR_LATEST_PATCH_PKG_EXIST:
1448 case SCE_NP_ERROR_LATEST_PATCH_PKG_DOWNLOADED:
1449 bPatchAvailable=true;
1450 break;
1451 default:
1452 bPatchAvailable=false;
1453 break;
1454 }
1455
1456 if(bPatchAvailable)
1457 {
1458 int32_t ret = sceErrorDialogInitialize();
1459 if ( ret==SCE_OK )
1460 {
1461 m_bErrorDialogRunning = true;
1462
1463 SceErrorDialogParam param;
1464 sceErrorDialogParamInitialize( ¶m );
1465 // 4J-PB - We want to display the option to get the patch now
1466 param.errorCode = SCE_NP_ERROR_LATEST_PATCH_PKG_DOWNLOADED;//pClass->m_errorCode;
1467 ret = sceUserServiceGetInitialUser( ¶m.userId );
1468 if ( ret == SCE_OK )
1469 {
1470 ret = sceErrorDialogOpen( ¶m );
1471 }
1472 else
1473 {
1474 sceErrorDialogTerminate();
1475 }
1476 }
1477 }
1478
1479 return bPatchAvailable;
1480}
1481#endif