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_DLCOffersMenu.h"
4#include "..\..\..\Minecraft.World\StringHelpers.h"
5#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
6#include "Common\Network\Sony\SonyHttp.h"
7#endif
8
9#ifdef __PSVITA__
10#include "PSVita\Network\SonyCommerce_Vita.h"
11#endif
12
13#define PLAYER_ONLINE_TIMER_ID 0
14#define PLAYER_ONLINE_TIMER_TIME 100
15
16UIScene_DLCOffersMenu::UIScene_DLCOffersMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
17{
18 m_bProductInfoShown=false;
19 DLCOffersParam *param=(DLCOffersParam *)initData;
20 m_iProductInfoIndex=param->iType;
21 m_iCurrentDLC=0;
22 m_iTotalDLC=0;
23#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
24 m_pvProductInfo=NULL;
25#endif
26 m_bAddAllDLCButtons=true;
27
28 // Setup all the Iggy references we need for this scene
29 initialiseMovie();
30 // Alert the app the we want to be informed of ethernet connections
31 app.SetLiveLinkRequired( true );
32
33 m_bIsSD=!RenderManager.IsHiDef() && !RenderManager.IsWidescreen();
34
35 m_labelOffers.init(app.GetString(IDS_DOWNLOADABLE_CONTENT_OFFERS));
36 m_buttonListOffers.init(eControl_OffersList);
37 m_labelHTMLSellText.init(L" ");
38 m_labelPriceTag.init(L" ");
39 TelemetryManager->RecordMenuShown(m_iPad, eUIScene_DLCOffersMenu, 0);
40
41 m_bHasPurchased = false;
42 m_bIsSelected = false;
43
44 if(m_loadedResolution == eSceneResolution_1080)
45 {
46#ifdef _DURANGO
47 m_labelXboxStore.init( app.GetString(IDS_XBOX_STORE) );
48#else
49 m_labelXboxStore.init( L"" );
50#endif
51 }
52
53#ifdef _DURANGO
54 m_pNoImageFor_DLC = NULL;
55 // If we don't yet have this DLC, we need to display a timer
56 m_bDLCRequiredIsRetrieved=false;
57 m_bIgnorePress=true;
58 m_bSelectionChanged=true;
59 // display a timer
60 m_Timer.setVisible(true);
61
62#endif
63
64#ifdef __ORBIS__
65 //sceNpCommerceShowPsStoreIcon(SCE_NP_COMMERCE_PS_STORE_ICON_CENTER);
66#endif
67
68#if ( defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ )
69 addTimer( PLAYER_ONLINE_TIMER_ID, PLAYER_ONLINE_TIMER_TIME );
70#endif
71
72#ifdef __PSVITA__
73 ui.TouchBoxRebuild(this);
74#endif
75}
76
77UIScene_DLCOffersMenu::~UIScene_DLCOffersMenu()
78{
79 // Alert the app the we no longer want to be informed of ethernet connections
80 app.SetLiveLinkRequired( false );
81}
82
83void UIScene_DLCOffersMenu::handleTimerComplete(int id)
84{
85#if ( defined __PS3__ || defined __ORBIS__ || defined __PSVITA__)
86 switch(id)
87 {
88 case PLAYER_ONLINE_TIMER_ID:
89#ifndef _WINDOWS64
90 if(ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad())==false)
91 {
92 // check the player hasn't gone offline
93 // If they have, bring up the PSN warning and exit from the DLC menu
94 unsigned int uiIDA[1];
95 uiIDA[0]=IDS_OK;
96 C4JStorage::EMessageResult result = ui.RequestErrorMessage( IDS_CONNECTION_LOST, g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_LOST_LIVE_NO_EXIT), uiIDA,1,ProfileManager.GetPrimaryPad(),UIScene_DLCOffersMenu::ExitDLCOffersMenu,this);
97 }
98#endif
99 break;
100 }
101#endif
102}
103
104int UIScene_DLCOffersMenu::ExitDLCOffersMenu(void *pParam,int iPad,C4JStorage::EMessageResult result)
105{
106 UIScene_DLCOffersMenu* pClass = (UIScene_DLCOffersMenu*)pParam;
107
108#if defined __ORBIS__ || defined __PSVITA__
109 app.GetCommerce()->HidePsStoreIcon();
110#endif
111 ui.NavigateToHomeMenu();//iPad,eUIScene_MainMenu);
112
113 return 0;
114}
115
116wstring UIScene_DLCOffersMenu::getMoviePath()
117{
118 return L"DLCOffersMenu";
119}
120
121void UIScene_DLCOffersMenu::updateTooltips()
122{
123 int iA = -1;
124 if(m_bIsSelected)
125 {
126 if( !m_bHasPurchased )
127 {
128 iA = IDS_TOOLTIPS_INSTALL;
129 }
130 else
131 {
132 iA = IDS_TOOLTIPS_REINSTALL;
133 }
134 }
135 ui.SetTooltips( m_iPad, iA,IDS_TOOLTIPS_BACK);
136}
137
138void UIScene_DLCOffersMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
139{
140 //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");
141 ui.AnimateKeyPress(m_iPad, key, repeat, pressed, released);
142
143 switch(key)
144 {
145 case ACTION_MENU_CANCEL:
146 if(pressed)
147 {
148 navigateBack();
149 }
150 break;
151 case ACTION_MENU_OK:
152#ifdef __ORBIS__
153 case ACTION_MENU_TOUCHPAD_PRESS:
154#endif
155 sendInputToMovie(key, repeat, pressed, released);
156 break;
157 case ACTION_MENU_UP:
158 if(pressed)
159 {
160 // 4J - TomK don't proceed if there is no DLC to navigate through
161 if(m_iTotalDLC > 0)
162 {
163 if(m_iCurrentDLC > 0)
164 m_iCurrentDLC--;
165
166 m_bProductInfoShown = false;
167 }
168 }
169 sendInputToMovie(key, repeat, pressed, released);
170 break;
171
172 case ACTION_MENU_DOWN:
173 if(pressed)
174 {
175 // 4J - TomK don't proceed if there is no DLC to navigate through
176 if(m_iTotalDLC > 0)
177 {
178 if(m_iCurrentDLC < (m_iTotalDLC - 1))
179 m_iCurrentDLC++;
180
181 m_bProductInfoShown = false;
182 }
183 }
184 sendInputToMovie(key, repeat, pressed, released);
185 break;
186
187 case ACTION_MENU_LEFT:
188 /*
189#ifdef _DEBUG
190 static int iTextC=0;
191 switch(iTextC)
192 {
193 case 0:
194 m_labelHTMLSellText.init("Voici un fantastique mini-pack de 24 apparences pour personnaliser votre personnage Minecraft et vous mettre dans l'ambiance des f�tes de fin d'ann�e.<br><br>1-4 joueurs<br>2-8 joueurs en r�seau<br><br> Cet article fait l�objet d�une licence ou d�une sous-licence de Sony Computer Entertainment America, et est soumis aux conditions g�n�rales du service du r�seau, au contrat d�utilisateur, aux restrictions d�utilisation de cet article et aux autres conditions applicables, disponibles sur le site www.us.playstation.com/support/useragreements. Si vous ne souhaitez pas accepter ces conditions, ne t�l�chargez pas ce produit. Cet article peut �tre utilis� avec un maximum de deux syst�mes PlayStation�3 activ�s associ�s � ce compte Sony Entertainment Network.�<br><br>'Minecraft' est une marque commerciale de Notch Development AB.");
195 break;
196 case 1:
197 m_labelHTMLSellText.init("Un fabuloso minipack de 24 aspectos para personalizar tu personaje de Minecraft y ponerte a tono con las fiestas.<br><br>1-4 jugadores<br>2-8 jugadores en red<br><br> Sony Computer Entertainment America le concede la licencia o sublicencia de este art�culo, que est� sujeto a los t�rminos de servicio y al acuerdo de usuario de la red. Las restricciones de uso de este art�culo, as� como otros t�rminos aplicables, se encuentran en www.us.playstation.com/support/useragreements. Si no desea aceptar todos estos t�rminos, no descargue este art�culo. Este art�culo puede usarse en hasta dos sistemas PlayStation�3 activados asociados con esta cuenta de Sony Entertainment Network.�<br><br>'Minecraft' es una marca comercial de Notch Development AB.");
198 break;
199 case 2:
200 m_labelHTMLSellText.init("Este � um incr�vel pacote com 24 capas para personalizar seu personagem no Minecraft e entrar no clima de final de ano.<br><br>1-4 Jogadores<br>Jogadores em rede 2-8<br><br> Este item est� sendo licenciado ou sublicenciado para voc� pela Sony Computer Entertainment America e est� sujeito aos Termos de Servi�o da Rede e Acordo do Usu�rio, as restri��es de uso deste item e outros termos aplic�veis est�o localizados em www.us.playstation.com/support/useragreements. Caso n�o queira aceitar todos esses termos, n�o baixe este item. Este item pode ser usado com at� 2 sistemas PlayStation�3 ativados associados a esta Conta de Rede Sony Entertainment.�<br><br>'Minecraft' � uma marca registrada da Notch Development AB");
201 break;
202 }
203 iTextC++;
204 if(iTextC>2) iTextC=0;
205#endif
206 */
207 case ACTION_MENU_RIGHT:
208 case ACTION_MENU_OTHER_STICK_DOWN:
209 case ACTION_MENU_OTHER_STICK_UP:
210 // don't pass down PageUp or PageDown because this will cause conflicts between the buttonlist and scrollable html text component
211 //case ACTION_MENU_PAGEUP:
212 //case ACTION_MENU_PAGEDOWN:
213 sendInputToMovie(key, repeat, pressed, released);
214 break;
215 }
216}
217
218void UIScene_DLCOffersMenu::handlePress(F64 controlId, F64 childId)
219{
220 switch((int)controlId)
221 {
222 case eControl_OffersList:
223 {
224#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
225 // buy the DLC
226
227 vector<SonyCommerce::ProductInfo >::iterator it = m_pvProductInfo->begin();
228 string teststring;
229 for(int i=0;i<childId;i++)
230 {
231 it++;
232 }
233
234 SonyCommerce::ProductInfo info = *it;
235
236#ifdef __PS3__
237 // is the item purchasable?
238 if(info.purchasabilityFlag==1)
239 {
240 // can be bought
241 app.Checkout(info.skuId);
242 }
243 else
244 {
245 if((info.annotation & (SCE_NP_COMMERCE2_SKU_ANN_PURCHASED_CANNOT_PURCHASE_AGAIN | SCE_NP_COMMERCE2_SKU_ANN_PURCHASED_CAN_PURCHASE_AGAIN))!=0)
246 {
247 app.DownloadAlreadyPurchased(info.skuId);
248 }
249 }
250#else // __ORBIS__
251 // is the item purchasable?
252 if(info.purchasabilityFlag==SCE_TOOLKIT_NP_COMMERCE_NOT_PURCHASED)
253 {
254 // can be bought
255 app.Checkout(info.skuId);
256 }
257 else
258 {
259 app.DownloadAlreadyPurchased(info.skuId);
260 }
261#endif // __PS3__
262#elif defined _XBOX_ONE
263 int iIndex = (int)childId;
264 StorageManager.InstallOffer(1,StorageManager.GetOffer(iIndex).wszProductID,NULL,NULL);
265#else
266 int iIndex = (int)childId;
267
268 ULONGLONG ullIndexA[1];
269 ullIndexA[0]=StorageManager.GetOffer(iIndex).qwOfferID;
270 StorageManager.InstallOffer(1,ullIndexA,NULL,NULL);
271#endif
272 }
273 break;
274 }
275}
276
277void UIScene_DLCOffersMenu::handleSelectionChanged(F64 selectedId)
278{
279
280}
281
282void UIScene_DLCOffersMenu::handleFocusChange(F64 controlId, F64 childId)
283{
284 app.DebugPrintf("UIScene_DLCOffersMenu::handleFocusChange\n");
285
286#ifdef __PSVITA__
287 // set this here on Vita, in case we've came from a touch screen press. Fixes bug #5794
288 if((int)controlId == eControl_OffersList)
289 {
290 m_bProductInfoShown = false;
291 m_iCurrentDLC = (int)childId;
292 }
293#endif
294
295#ifdef _DURANGO
296 m_bSelectionChanged=true; // to tell the tick to update the display
297 // 4J-PB can't call settexturename from a callback
298 /*if(m_buttonListOffers.hasFocus() && (childId>-1))
299 {
300 int iIndex = (int)childId;
301 MARKETPLACE_CONTENTOFFER_INFO xOffer = StorageManager.GetOffer(iIndex);
302 UpdateDisplay(xOffer);
303 }*/
304#endif
305
306#if defined __PSVITA__ || defined __ORBIS__
307 if(m_pvProductInfo)
308 {
309 m_bIsSelected = true;
310 vector<SonyCommerce::ProductInfo >::iterator it = m_pvProductInfo->begin();
311 string teststring;
312 for(int i=0;i<childId;i++)
313 {
314 it++;
315 }
316
317 SonyCommerce::ProductInfo info = *it;
318 if(info.purchasabilityFlag==SCE_TOOLKIT_NP_COMMERCE_NOT_PURCHASED)
319 {
320 m_bHasPurchased=false;
321 }
322 else
323 {
324 m_bHasPurchased=true;
325 }
326
327 updateTooltips();
328 }
329#endif
330}
331
332void UIScene_DLCOffersMenu::tick()
333{
334 UIScene::tick();
335
336#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
337
338 if(m_bAddAllDLCButtons)
339 {
340 // need to fill out all the dlc buttons
341
342 if((m_bProductInfoShown==false) && app.GetCommerceProductListRetrieved() && app.GetCommerceProductListInfoRetrieved())
343 {
344 m_bAddAllDLCButtons=false;
345 // add the categories to the list box
346 if(m_pvProductInfo==NULL)
347 {
348 m_pvProductInfo=app.GetProductList(m_iProductInfoIndex);
349 if(m_pvProductInfo==NULL)
350 {
351 m_iTotalDLC=0;
352 // need to display text to say no downloadable content available yet
353 m_labelOffers.setLabel(app.GetString(IDS_NO_DLCCATEGORIES));
354
355 m_bProductInfoShown=true;
356 return;
357 }
358 else m_iTotalDLC=m_pvProductInfo->size();
359 }
360
361 vector<SonyCommerce::ProductInfo >::iterator it = m_pvProductInfo->begin();
362 string teststring;
363 bool bFirstItemSet=false;
364 for(int i=0;i<m_iTotalDLC;i++)
365 {
366 SonyCommerce::ProductInfo info = *it;
367
368 if(strncmp(info.productName,"Minecraft ",10)==0)
369 {
370 teststring=&info.productName[10];
371
372 }
373 else
374 {
375 teststring=info.productName;
376 }
377
378 bool bDLCIsAvailable=false;
379
380#ifdef __PS3__
381 // is the item purchasable?
382 if(info.purchasabilityFlag==1)
383 {
384 // can be bought
385 app.DebugPrintf("Adding DLC (%s) - not bought\n",teststring.c_str());
386 m_buttonListOffers.addItem(teststring,false,i);
387 bDLCIsAvailable=true;
388 }
389 else
390 {
391 if((info.annotation & (SCE_NP_COMMERCE2_SKU_ANN_PURCHASED_CANNOT_PURCHASE_AGAIN | SCE_NP_COMMERCE2_SKU_ANN_PURCHASED_CAN_PURCHASE_AGAIN))!=0)
392 {
393 app.DebugPrintf("Adding DLC (%s) - bought\n",teststring.c_str());
394 m_buttonListOffers.addItem(teststring,true,i);
395 bDLCIsAvailable=true;
396 }
397 }
398#else // __ORBIS__
399 // is the item purchasable?
400 if(info.purchasabilityFlag==SCE_TOOLKIT_NP_COMMERCE_NOT_PURCHASED)
401 {
402 // can be bought
403 m_buttonListOffers.addItem(teststring,false,i);
404 bDLCIsAvailable=true;
405 }
406 else
407 {
408 m_buttonListOffers.addItem(teststring,true,i);
409 bDLCIsAvailable=true;
410 }
411#endif // __PS3__
412
413 // set the other details for the first item
414 if(bDLCIsAvailable && (bFirstItemSet==false))
415 {
416 bFirstItemSet=true;
417
418 // 4J-PB - info.longDescription isn't null terminated
419 char chLongDescription[SCE_NP_COMMERCE2_PRODUCT_LONG_DESCRIPTION_LEN+1];
420 memcpy(chLongDescription,info.longDescription,SCE_NP_COMMERCE2_PRODUCT_LONG_DESCRIPTION_LEN);
421 chLongDescription[SCE_NP_COMMERCE2_PRODUCT_LONG_DESCRIPTION_LEN]=0;
422 m_labelHTMLSellText.setLabel(chLongDescription);
423
424 if(info.ui32Price==0)
425 {
426 m_labelPriceTag.setLabel(app.GetString(IDS_DLC_PRICE_FREE));
427 }
428 else
429 {
430 teststring=info.price;
431 m_labelPriceTag.setLabel(teststring);
432 }
433
434 // get the image - if we haven't already
435 wstring textureName = filenametowstring(info.imageUrl);
436
437 if(hasRegisteredSubstitutionTexture(textureName)==false)
438 {
439 PBYTE pbImageData;
440 int iImageDataBytes=0;
441 bool bDeleteData;
442#ifdef __ORBIS__
443 // check the local files first
444 SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfoFromKeyname(info.productId);
445
446 // does the DLC info have an image?
447 if(pSONYDLCInfo && pSONYDLCInfo->dwImageBytes!=0)
448 {
449 pbImageData=pSONYDLCInfo->pbImageData;
450 iImageDataBytes=pSONYDLCInfo->dwImageBytes;
451 bDeleteData=false; // we'll clean up the local LDC images
452 }
453 else
454#endif
455 if(info.imageUrl[0]!=0)
456 {
457 SonyHttp::getDataFromURL(info.imageUrl,(void **)&pbImageData,&iImageDataBytes);
458 bDeleteData=true;
459 }
460
461 if(iImageDataBytes!=0)
462 {
463 // set the image
464 registerSubstitutionTexture(textureName,pbImageData,iImageDataBytes,bDeleteData);
465 m_bitmapIconOfferImage.setTextureName(textureName);
466 // 4J Stu - Don't delete this
467 //delete [] pbImageData;
468 }
469 else
470 {
471 m_bitmapIconOfferImage.setTextureName(L"");
472 }
473 }
474 else
475 {
476 m_bitmapIconOfferImage.setTextureName(textureName);
477 }
478 }
479 it++;
480 }
481
482 if(bFirstItemSet==false)
483 {
484 // we were not able to add any items to the list
485 m_labelOffers.setLabel(app.GetString(IDS_NO_DLCCATEGORIES));
486 }
487 else
488 {
489 // set the focus to the first thing in the categories if there are any
490 if(m_pvProductInfo->size()>0)
491 {
492 m_buttonListOffers.setFocus(true);
493 }
494 else
495 {
496 // need to display text to say no downloadable content available yet
497 m_labelOffers.setLabel(app.GetString(IDS_NO_DLCCATEGORIES));
498 }
499 }
500
501 m_Timer.setVisible(false);
502 m_bProductInfoShown=true;
503 }
504 }
505 else
506 {
507#ifdef __PSVITA__
508 // MGH - fixes bug 5768 on Vita - should be extended properly to work for other platforms
509 if((SonyCommerce_Vita::getPurchasabilityUpdated()) && app.GetCommerceProductListRetrieved()&& app.GetCommerceProductListInfoRetrieved() && m_iTotalDLC > 0)
510 {
511
512 {
513 vector<SonyCommerce::ProductInfo >::iterator it = m_pvProductInfo->begin();
514 for(int i=0;i<m_iTotalDLC;i++)
515 {
516 SonyCommerce::ProductInfo info = *it;
517 // is the item purchasable?
518 if(info.purchasabilityFlag==SCE_TOOLKIT_NP_COMMERCE_NOT_PURCHASED)
519 {
520 // can be bought
521 m_buttonListOffers.showTick(i, false);
522 }
523 else
524 {
525 m_buttonListOffers.showTick(i, true);
526 }
527 it++;
528 }
529 }
530 }
531#endif
532
533
534 // just update the details based on what the current selection is / TomK-4J - don't proceed if total DLC is 0 (bug 4757)
535 if((m_bProductInfoShown==false) && app.GetCommerceProductListRetrieved()&& app.GetCommerceProductListInfoRetrieved() && m_iTotalDLC > 0)
536 {
537
538
539 vector<SonyCommerce::ProductInfo >::iterator it = m_pvProductInfo->begin();
540 string teststring;
541 for(int i=0;i<m_iCurrentDLC;i++)
542 {
543 it++;
544 }
545
546 SonyCommerce::ProductInfo info = *it;
547
548 // 4J-PB - info.longDescription isn't null terminated
549 char chLongDescription[SCE_NP_COMMERCE2_PRODUCT_LONG_DESCRIPTION_LEN+1];
550 memcpy(chLongDescription,info.longDescription,SCE_NP_COMMERCE2_PRODUCT_LONG_DESCRIPTION_LEN);
551 chLongDescription[SCE_NP_COMMERCE2_PRODUCT_LONG_DESCRIPTION_LEN]=0;
552 m_labelHTMLSellText.setLabel(chLongDescription);
553
554 if(info.ui32Price==0)
555 {
556 m_labelPriceTag.setLabel(app.GetString(IDS_DLC_PRICE_FREE));
557 }
558 else
559 {
560 teststring=info.price;
561 m_labelPriceTag.setLabel(teststring);
562 }
563
564 // get the image
565
566 // then retrieve from the web
567 wstring textureName = filenametowstring(info.imageUrl);
568
569 if(hasRegisteredSubstitutionTexture(textureName)==false)
570 {
571 PBYTE pbImageData;
572 int iImageDataBytes=0;
573 bool bDeleteData;
574#ifdef __ORBIS__
575 // check the local files first
576 SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfoFromKeyname(info.productId);
577
578 // does the DLC info have an image?
579 if(pSONYDLCInfo->dwImageBytes!=0)
580 {
581 pbImageData=pSONYDLCInfo->pbImageData;
582 iImageDataBytes=pSONYDLCInfo->dwImageBytes;
583 bDeleteData=false; // we'll clean up the local LDC images
584 }
585 else
586#endif
587 {
588 SonyHttp::getDataFromURL(info.imageUrl,(void **)&pbImageData,&iImageDataBytes);
589 bDeleteData=true;
590 }
591
592 if(iImageDataBytes!=0)
593 {
594 // set the image
595 registerSubstitutionTexture(textureName,pbImageData,iImageDataBytes, bDeleteData);
596 m_bitmapIconOfferImage.setTextureName(textureName);
597
598 // 4J Stu - Don't delete this
599 //delete [] pbImageData;
600 }
601 else
602 {
603 m_bitmapIconOfferImage.setTextureName(L"");
604 }
605 }
606 else
607 {
608 m_bitmapIconOfferImage.setTextureName(textureName);
609 }
610 m_bProductInfoShown=true;
611 m_Timer.setVisible(false);
612 }
613
614 }
615#elif defined _XBOX_ONE
616 if(m_bAddAllDLCButtons)
617 {
618 // Is the DLC we're looking for available?
619 if(!m_bDLCRequiredIsRetrieved)
620 {
621 // DLCContentRetrieved is to see if the type of content has been retrieved - and on Durango there is only type 0 - XMARKETPLACE_OFFERING_TYPE_CONTENT
622 if(app.DLCContentRetrieved(e_Marketplace_Content))
623 {
624 m_bDLCRequiredIsRetrieved=true;
625
626 // Retrieve the info
627 GetDLCInfo(app.GetDLCOffersCount(), false);
628 m_bIgnorePress=false;
629 m_bAddAllDLCButtons=false;
630
631 // hide the timer
632 m_Timer.setVisible(false);
633 }
634 }
635 }
636
637 // have to wait until we have the offers
638 if(m_bSelectionChanged && m_bDLCRequiredIsRetrieved)
639 {
640 // need to update text and icon
641 if(m_buttonListOffers.hasFocus() && (getControlChildFocus()>-1))
642 {
643 int iIndex = getControlChildFocus();
644 MARKETPLACE_CONTENTOFFER_INFO xOffer = StorageManager.GetOffer(iIndex);
645
646 if (!ui.UsingBitmapFont()) // 4J-JEV: Replace characters we don't have.
647 {
648 for (int i=0; xOffer.wszCurrencyPrice[i]!=0; i++)
649 {
650 WCHAR *c = &xOffer.wszCurrencyPrice[i];
651 if (*c == L'\u20A9') *c = L'\uFFE6'; // Korean Won.
652 else if (*c == L'\u00A5') *c = L'\uFFE5'; // Japanese Yen.
653 }
654 }
655
656 if(UpdateDisplay(xOffer))
657 {
658 // image was available
659 m_bSelectionChanged=false;
660 }
661 }
662 }
663
664// if(m_bBitmapOfferIconDisplayed==false)
665// {
666// // do we have it yet?
667// if
668// }
669 // retrieve the icons for the DLC
670// if(m_vIconRetrieval.size()>0)
671// {
672// // for each icon, request it, and remove it from the list
673// // the callback for the retrieval will update the display if needed
674//
675// AUTO_VAR(itEnd, m_vIconRetrieval.end());
676// for (AUTO_VAR(it, m_vIconRetrieval.begin()); it != itEnd; it++)
677// {
678//
679// }
680//
681// }
682#endif
683}
684
685#if defined _XBOX_ONE
686void UIScene_DLCOffersMenu::GetDLCInfo( int iOfferC, bool bUpdateOnly )
687{
688 MARKETPLACE_CONTENTOFFER_INFO xOffer;
689 int iCount=0;
690 bool bNoDLCToDisplay = true;
691 unsigned int uiDLCCount=0;
692
693
694 if(bUpdateOnly) // Just update the info on the current list
695 {
696
697 }
698 else
699 {
700 // clear out the list
701 m_buttonListOffers.clearList();
702
703 // need to reorder the DLC display according to dlc uiSortIndex
704 SORTINDEXSTRUCT *OrderA = new SORTINDEXSTRUCT [iOfferC];
705
706 for(int i = 0; i < iOfferC; i++)
707 {
708 xOffer = StorageManager.GetOffer(i);
709 // Check that this is in the list of known DLC
710 DLC_INFO *pDLC=app.GetDLCInfoForFullOfferID(xOffer.wszProductID);
711
712 if(pDLC!=NULL)
713 {
714 OrderA[uiDLCCount].uiContentIndex=i;
715 OrderA[uiDLCCount++].uiSortIndex=pDLC->uiSortIndex;
716 }
717 else
718 {
719 app.DebugPrintf("Unknown offer - %ls\n",xOffer.wszOfferName);
720 }
721 }
722
723 qsort( OrderA, uiDLCCount, sizeof(SORTINDEXSTRUCT), OrderSortFunction );
724
725 for(int i = 0; i < uiDLCCount; i++)
726 {
727 xOffer = StorageManager.GetOffer(OrderA[i].uiContentIndex);
728
729 // Check that this is in the list of known DLC
730 DLC_INFO *pDLC=app.GetDLCInfoForFullOfferID(xOffer.wszProductID);
731
732 if(pDLC==NULL)
733 {
734 // skip this one
735 app.DebugPrintf("Unknown offer - %ls\n",xOffer.wszOfferName);
736 continue;
737 }
738
739 if(pDLC->eDLCType==(eDLCContentType)m_iProductInfoIndex)
740 {
741 wstring wstrTemp=xOffer.wszOfferName;
742
743 // 4J-PB - Rog requested we remove the Minecraft at the start of the name. It's required for the Bing search, but gets in the way here
744 app.DebugPrintf("Adding %ls at %d\n",wstrTemp.c_str(), i);
745
746 if(wcsncmp(L"Minecraft ",wstrTemp.c_str(),10)==0)
747 {
748 app.DebugPrintf("Removing Minecraft from name\n");
749 WCHAR *pwchNewName=(WCHAR *)wstrTemp.c_str();
750 wstrTemp=&pwchNewName[10];
751 }
752
753#ifdef _XBOX_ONE
754 // 4J-PB - the hasPurchased comes from the local installed package info
755 // find the DLC in the installed packages
756 XCONTENT_DATA *pContentData=StorageManager.GetInstalledDLC(xOffer.wszProductID);
757
758 if(pContentData!=NULL)
759 {
760 m_buttonListOffers.addItem(wstrTemp,!pContentData->bTrialLicense,OrderA[i].uiContentIndex);
761 }
762 else
763 {
764 m_buttonListOffers.addItem(wstrTemp,false,OrderA[i].uiContentIndex);
765 }
766#else
767 m_buttonListOffers.addItem(wstrTemp,xOffer.fUserHasPurchased,OrderA[i].uiContentIndex);
768#endif
769
770 // add the required image to the retrieval queue
771 m_vIconRetrieval.push_back(pDLC->wchBanner);
772
773 /** 4J JEV:
774 * We've filtered results out from the list, need to keep track
775 * of the 'actual' list index.
776 */
777 iCount++;
778 }
779 }
780
781
782 // Check if there is nothing to display, and display the default "nothing available at this time"
783 if(iCount>0)
784 {
785 bNoDLCToDisplay=false;
786 xOffer = StorageManager.GetOffer(OrderA[0].uiContentIndex);
787 //m_buttonListOffers.setCurrentSelection(0);
788
789 UpdateDisplay(xOffer);
790 }
791 delete OrderA;
792 }
793
794 // turn off the timer display
795 //m_Timer.SetShow(FALSE);
796 if(bNoDLCToDisplay)
797 {
798 // set the default text
799
800 wchar_t formatting[40];
801 wstring wstrTemp = app.GetString(IDS_NO_DLCOFFERS);
802// swprintf(formatting, 40, L"<font size=\"%d\">", m_bIsSD?12:14);
803// wstrTemp = formatting + wstrTemp;
804
805 m_labelHTMLSellText.setLabel(wstrTemp);
806 m_labelPriceTag.setVisible(false);
807 }
808}
809
810int UIScene_DLCOffersMenu::OrderSortFunction(const void* a, const void* b)
811{
812 return ((SORTINDEXSTRUCT*)b)->uiSortIndex - ((SORTINDEXSTRUCT*)a)->uiSortIndex;
813}
814
815void UIScene_DLCOffersMenu::UpdateTooltips(MARKETPLACE_CONTENTOFFER_INFO& xOffer)
816{
817 m_bHasPurchased = xOffer.fUserHasPurchased;
818 m_bIsSelected = true;
819 updateTooltips();
820}
821
822bool UIScene_DLCOffersMenu::UpdateDisplay(MARKETPLACE_CONTENTOFFER_INFO& xOffer)
823{
824 bool bImageAvailable=false;
825#ifdef _XBOX_ONE
826 DLC_INFO *dlc = app.GetDLCInfoForFullOfferID(xOffer.wszProductID);
827#else
828 DLC_INFO *dlc = app.GetDLCInfoForFullOfferID(xOffer.wszOfferName);
829#endif
830
831 if (dlc != NULL)
832 {
833 WCHAR *cString = dlc->wchBanner;
834
835
836 // is the file in the local DLC images?
837 // is the file in the TMS XZP?
838 //int iIndex = app.GetLocalTMSFileIndex(cString, true);
839
840 if(dlc->dwImageBytes!=0)
841 {
842 //app.LoadLocalTMSFile(cString);
843
844 // set the image - no delete
845 registerSubstitutionTexture(cString,dlc->pbImageData,dlc->dwImageBytes,false);
846 m_bitmapIconOfferImage.setTextureName(cString);
847 bImageAvailable=true;
848 }
849 else
850 {
851 bool bPresent = app.IsFileInMemoryTextures(cString);
852 if (!bPresent)
853 {
854 // Image has not come in yet
855 // Set the item monitored in the timer, so we can set the image when it comes in
856 m_pNoImageFor_DLC=dlc;
857
858 app.AddTMSPPFileTypeRequest(dlc->eDLCType,true);
859 bImageAvailable=false;
860 //m_bitmapIconOfferImage.setTextureName(L"");
861 }
862 else
863 {
864 if(hasRegisteredSubstitutionTexture(cString)==false)
865 {
866 BYTE *pData=NULL;
867 DWORD dwSize=0;
868 app.GetMemFileDetails(cString,&pData,&dwSize);
869 // set the image
870#ifdef _XBOX_ONE
871 registerSubstitutionTexture(cString,pData,dwSize);
872#else
873 registerSubstitutionTexture(cString,pData,dwSize,true);
874#endif
875 m_bitmapIconOfferImage.setTextureName(cString);
876 }
877 else
878 {
879 m_bitmapIconOfferImage.setTextureName(cString);
880 }
881 bImageAvailable=true;
882 }
883 }
884
885 m_labelHTMLSellText.setLabel(xOffer.wszSellText);
886
887 // set the price info
888 m_labelPriceTag.setVisible(true);
889 m_labelPriceTag.setLabel(xOffer.wszCurrencyPrice);
890
891 UpdateTooltips(xOffer);
892 }
893 else
894 {
895 wchar_t formatting[40];
896 wstring wstrTemp = app.GetString(IDS_NO_DLCOFFERS);
897 m_labelHTMLSellText.setLabel(wstrTemp.c_str());
898 m_labelPriceTag.setVisible(false);
899 }
900
901 return bImageAvailable;
902}
903#endif
904
905#ifdef _XBOX_ONE
906void UIScene_DLCOffersMenu::HandleDLCLicenseChange()
907{
908 // flag an update of the display
909 int iOfferC=app.GetDLCOffersCount();
910
911 GetDLCInfo(iOfferC,false);
912}
913#endif // _XBOX_ONE
914
915#ifdef __PS3__
916void UIScene_DLCOffersMenu::HandleDLCInstalled()
917{
918 app.DebugPrintf(4,"UIScene_DLCOffersMenu::HandleDLCInstalled\n");
919
920// m_buttonListOffers.clearList();
921// m_bAddAllDLCButtons=true;
922// m_bProductInfoShown=false;
923}
924
925// void UIScene_DLCOffersMenu::HandleDLCMountingComplete()
926// {
927// app.DebugPrintf(4,"UIScene_SkinSelectMenu::HandleDLCMountingComplete\n");
928//}
929
930
931#endif