the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1// Minecraft.cpp : Defines the entry point for the application.
2//
3
4#include "stdafx.h"
5#include "..\..\..\Minecraft.World\ByteArrayInputStream.h"
6#include "..\..\..\Minecraft.World\BufferedReader.h"
7#include "..\..\..\Minecraft.World\InputStreamReader.h"
8#include "..\..\..\Minecraft.World\ArrayWithLength.h"
9#include <assert.h>
10#include "XUI_Ctrl_4JIcon.h"
11#include "XUI_DLCOffers.h"
12#include "..\..\..\Minecraft.World\StringHelpers.h"
13#ifdef _XBOX
14#include <xavatar.h>
15#endif
16
17#define TIMER_ID_NETWORK_CONNECTION 1
18#define TIMER_ID_NAVIGATE_BACK 2
19// Constants
20
21//const wstring CScene_DLCOffers::DEFAULT_BANNER = L"Graphics/banner.png";
22
23// DLC Main
24
25HRESULT CScene_DLCMain::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
26{
27 iPad = *(int *) pInitData->pvInitData;
28
29 MapChildControls();
30
31 app.SetTickTMSDLCFiles(true);
32
33 XuiControlSetText(xList,app.GetString(IDS_DOWNLOADABLE_CONTENT_OFFERS));
34
35 //if(app.GetTMSDLCInfoRead())
36 {
37 m_Timer.SetShow(FALSE);
38 m_bIgnoreInput=false;
39
40 VOID *pObj;
41 XuiObjectFromHandle( xList, &pObj );
42 list = (CXuiCtrl4JList *) pObj;
43
44 ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK );
45
46 CXuiCtrl4JList::LIST_ITEM_INFO *pListInfo = new CXuiCtrl4JList::LIST_ITEM_INFO [e_DLC_MAX_MinecraftStore];
47 ZeroMemory(pListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO)*e_DLC_MAX_MinecraftStore);
48
49 m_bAllDLCContentRetrieved=false;
50 pListInfo[e_DLC_SkinPack].pwszText = app.GetString(IDS_DLC_MENU_SKINPACKS);
51 pListInfo[e_DLC_SkinPack].fEnabled=TRUE;
52 list->AddData(pListInfo[e_DLC_SkinPack]);
53
54 pListInfo[e_DLC_TexturePacks].pwszText = app.GetString(IDS_DLC_MENU_TEXTUREPACKS);
55 pListInfo[e_DLC_TexturePacks].fEnabled=TRUE;
56 list->AddData(pListInfo[e_DLC_TexturePacks]);
57
58 pListInfo[e_DLC_MashupPacks].pwszText = app.GetString(IDS_DLC_MENU_MASHUPPACKS);
59 pListInfo[e_DLC_MashupPacks].fEnabled=TRUE;
60 list->AddData(pListInfo[e_DLC_MashupPacks]);
61
62 pListInfo[e_DLC_Themes].pwszText = app.GetString(IDS_DLC_MENU_THEMES);
63 pListInfo[e_DLC_Themes].fEnabled=TRUE;
64 list->AddData(pListInfo[e_DLC_Themes]);
65
66 pListInfo[e_DLC_AvatarItems].pwszText = app.GetString(IDS_DLC_MENU_AVATARITEMS);
67 pListInfo[e_DLC_AvatarItems].fEnabled=TRUE;
68 list->AddData(pListInfo[e_DLC_AvatarItems]);
69
70 pListInfo[e_DLC_Gamerpics].pwszText = app.GetString(IDS_DLC_MENU_GAMERPICS);
71 pListInfo[e_DLC_Gamerpics].fEnabled=TRUE;
72 list->AddData(pListInfo[e_DLC_Gamerpics]);
73
74 app.AddDLCRequest(e_Marketplace_Content); // content is skin packs, texture packs and mash-up packs
75 app.AddDLCRequest(e_Marketplace_Gamerpics);
76 app.AddDLCRequest(e_Marketplace_Themes);
77 app.AddDLCRequest(e_Marketplace_AvatarItems);
78
79 // start retrieving the images needed from TMS
80 app.AddTMSPPFileTypeRequest(e_DLC_SkinPack);
81 app.AddTMSPPFileTypeRequest(e_DLC_Gamerpics);
82 app.AddTMSPPFileTypeRequest(e_DLC_Themes);
83 app.AddTMSPPFileTypeRequest(e_DLC_AvatarItems);
84 app.AddTMSPPFileTypeRequest(e_DLC_TexturePacks);
85 app.AddTMSPPFileTypeRequest(e_DLC_MashupPacks);
86 }
87
88 XuiElementInitUserFocus(xList, ProfileManager.GetPrimaryPad(), TRUE);
89 TelemetryManager->RecordMenuShown(iPad, eUIScene_DLCMainMenu, 0); // 4J JEV ?
90
91 return S_OK;
92}
93
94HRESULT CScene_DLCMain::OnDestroy()
95{
96 return S_OK;
97}
98
99HRESULT CScene_DLCMain::OnTimer(XUIMessageTimer *pData,BOOL& rfHandled)
100{
101 if(pData->nId==TIMER_ID_NETWORK_CONNECTION)
102 {
103 if(ProfileManager.GetLiveConnectionStatus()!=XONLINE_S_LOGON_CONNECTION_ESTABLISHED)
104 {
105 UINT uiIDA[1];
106 uiIDA[0]=IDS_CONFIRM_OK;
107
108 StorageManager.ClearDLCOffers();
109 app.ClearAndResetDLCDownloadQueue();
110 }
111 }
112 else if(pData->nId==TIMER_ID_NAVIGATE_BACK)
113 {
114 if(app.CheckTMSDLCCanStop())
115 {
116 XuiKillTimer(m_hObj,TIMER_ID_NAVIGATE_BACK);
117 app.NavigateBack(XUSER_INDEX_ANY);
118 }
119 }
120
121 return S_OK;
122}
123
124
125HRESULT CScene_DLCMain::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
126{
127 if(m_bIgnoreInput) return S_OK;
128
129 ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
130
131 switch(pInputData->dwKeyCode)
132 {
133 case VK_PAD_B:
134 case VK_ESCAPE:
135 app.SetTickTMSDLCFiles(false);
136
137 // set the timer running to navigate back when any tms retrieval has come in
138 XuiSetTimer(m_hObj,TIMER_ID_NAVIGATE_BACK,50);
139 m_bIgnoreInput=true;
140 m_Timer.SetShow(TRUE);
141 //app.NavigateBack(XUSER_INDEX_ANY);
142 rfHandled = TRUE;
143
144 break;
145 }
146
147 return S_OK;
148}
149
150HRESULT CScene_DLCMain::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
151{
152 ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
153
154 if(hObjPressed==xList)
155 {
156 int iIndex;
157 CXuiControl pItem;
158 iIndex=xList.GetCurSel(&pItem);
159
160 DLCOffersParam *param = new DLCOffersParam();
161 param->iPad = iPad;
162 param->iType = iIndex;
163
164 // promote the DLC content request type
165 app.AddDLCRequest((eDLCMarketplaceType)iIndex, true);
166 app.NavigateToScene(iPad,eUIScene_DLCOffersMenu, param);
167 }
168 return S_OK;
169}
170
171HRESULT CScene_DLCMain::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled)
172{
173 ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK );
174
175 return S_OK;
176}
177
178// DLC OFFERS
179
180//----------------------------------------------------------------------------------
181// Performs initialization tasks - retrieves controls.
182//----------------------------------------------------------------------------------
183HRESULT CScene_DLCOffers::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
184{
185 DLCOffersParam *param = (DLCOffersParam *) pInitData->pvInitData;
186 m_iPad = param->iPad;
187 m_iType = param->iType;
188 m_iOfferC = app.GetDLCOffersCount();
189 m_bIsFemale = false;
190 m_pNoImageFor_DLC=NULL;
191 bNoDLCToDisplay=true;
192 //hCostText=NULL;
193
194
195 // 4J JEV: Deleting this here seems simpler.
196 delete param;
197
198 // If this is the avatar items, we need to init the avatar system to allow us to find out what the player avatar gender is (since we should only display tshirts etc with the right gender)
199 // The init reserves 3MB of memory, so we shut down on leaving this.
200 if(m_iType==e_DLC_AvatarItems)
201 {
202 XAVATAR_METADATA AvatarMetadata;
203 HRESULT hRes;
204
205
206 hRes=XAvatarInitialize(XAVATAR_COORDINATE_SYSTEM_LEFT_HANDED,0,0,0,NULL);
207
208 // get the avatar gender
209 hRes=XAvatarGetMetadataLocalUser(m_iPad,&AvatarMetadata,NULL);
210
211 m_bIsFemale= (XAVATAR_BODY_TYPE_FEMALE == XAvatarMetadataGetBodyType(&AvatarMetadata));
212 // shutdown the avatar system
213
214 XAvatarShutdown();
215 }
216
217 m_bIsSD=!RenderManager.IsHiDef() && !RenderManager.IsWidescreen();
218
219 MapChildControls();
220
221 XuiControlSetText(m_List,app.GetString(IDS_DOWNLOADABLE_CONTENT_OFFERS));
222
223 m_bIgnorePress=true;
224
225 VOID *pObj;
226 m_hXuiBrush=NULL;
227
228 XuiObjectFromHandle( m_List, &pObj );
229 m_pOffersList = (CXuiCtrl4JList *)pObj;
230 m_bAllDLCContentRetrieved=false;
231
232 XuiElementInitUserFocus(m_hObj,ProfileManager.GetPrimaryPad(),TRUE);
233 TelemetryManager->RecordMenuShown(m_iPad, eUIScene_DLCOffersMenu, 0);
234 ui.SetTooltips( DEFAULT_XUI_MENU_USER, -1,IDS_TOOLTIPS_BACK);
235
236 // Disable the price tag display
237 m_PriceTag.SetShow(FALSE);
238
239 // If we don't yet have this DLC, we need to display a timer
240 m_bDLCRequiredIsRetrieved=false;
241
242 // Is the DLC we're looking for available?
243 if(!m_bDLCRequiredIsRetrieved)
244 {
245 if(app.DLCContentRetrieved((eDLCMarketplaceType)m_iType))
246 {
247 m_bDLCRequiredIsRetrieved=true;
248
249 // Retrieve the info
250 GetDLCInfo(app.GetDLCOffersCount(), false);
251 m_bIgnorePress=false;
252 }
253 }
254
255 XuiSetTimer(m_hObj,TIMER_ID_NETWORK_CONNECTION,50);
256
257 return S_OK;
258}
259
260HRESULT CScene_DLCOffers::GetDLCInfo( int iOfferC, bool bUpdateOnly )
261{
262 CXuiCtrl4JList::LIST_ITEM_INFO *pListInfo=NULL;
263 //XMARKETPLACE_CONTENTOFFER_INFO xOffer;
264 XMARKETPLACE_CURRENCY_CONTENTOFFER_INFO xOffer;
265 const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string
266 WCHAR szResourceLocator[ LOCATOR_SIZE ];
267 ZeroMemory(szResourceLocator,sizeof(WCHAR)*LOCATOR_SIZE);
268 const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL);
269 int iCount=0;
270
271 if(bUpdateOnly) // Just update the info on the current list
272 {
273 for(int i=0;i<iOfferC;i++)
274 {
275 xOffer = StorageManager.GetOffer(i);
276 // Check that this is in the list of known DLC
277 DLC_INFO *pDLC=app.GetDLCInfoForFullOfferID(xOffer.qwOfferID);
278 if(pDLC==NULL)
279 {
280 // try the trial version
281 pDLC=app.GetDLCInfoForTrialOfferID(xOffer.qwOfferID);
282 }
283
284 if(pDLC==NULL)
285 {
286 // skip this one
287#ifdef _DEBUG
288 app.DebugPrintf("Unknown offer - ");
289 OutputDebugStringW(xOffer.wszOfferName);
290 app.DebugPrintf("\n");
291#endif
292 continue;
293 }
294
295 // If the item has a gender, then skip ones that are the other gender
296 if((pDLC->iGender==1) && (m_bIsFemale==true))
297 {
298 app.DebugPrintf("Wrong gender\n");
299 continue;
300 }
301
302 // can't trust the offer type - partnernet is giving avatar items the CONTENT type
303 //if(Offer.dwOfferType==app.GetDLCContentType((eDLCContentType)m_iType))
304 if(pDLC->eDLCType==(eDLCContentType)m_iType)
305 {
306 if(xOffer.fUserHasPurchased)
307 {
308 HXUIBRUSH hBrush;
309
310 if(RenderManager.IsHiDef() || RenderManager.IsWidescreen())
311 {
312 swprintf(szResourceLocator, LOCATOR_SIZE, L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/Graphics/DLC_Tick.png");
313 XuiCreateTextureBrush(szResourceLocator,&hBrush);
314 }
315 else
316 {
317 swprintf(szResourceLocator, LOCATOR_SIZE, L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/Graphics/DLC_TickSmall.png");
318 XuiCreateTextureBrush(szResourceLocator,&hBrush);
319 }
320 m_pOffersList->UpdateGraphic(i,hBrush );
321 }
322
323 iCount++;
324 }
325 }
326
327 if(iCount>0)
328 {
329 bNoDLCToDisplay=false;
330 }
331 }
332 else
333 {
334 if(iOfferC!=0)
335 {
336 pListInfo = new CXuiCtrl4JList::LIST_ITEM_INFO [iOfferC];
337 ZeroMemory(pListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO)*iOfferC);
338 }
339
340 for(int i = 0; i < iOfferC; i++)
341 {
342 xOffer = StorageManager.GetOffer(i);
343
344 // Check that this is in the list of known DLC
345 DLC_INFO *pDLC=app.GetDLCInfoForFullOfferID(xOffer.qwOfferID);
346 if(pDLC==NULL)
347 {
348 // try the trial version
349 pDLC=app.GetDLCInfoForTrialOfferID(xOffer.qwOfferID);
350 }
351
352 if(pDLC==NULL)
353 {
354 // skip this one
355#ifdef _DEBUG
356 app.DebugPrintf("Unknown offer - ");
357 OutputDebugStringW(xOffer.wszOfferName);
358 app.DebugPrintf("\n");
359#endif
360 continue;
361 }
362
363 // can't trust the offer type - partnernet is giving avatar items the CONTENT type
364 //if(Offer.dwOfferType==app.GetDLCContentType((eDLCContentType)m_iType))
365 if(pDLC->eDLCType==(eDLCContentType)m_iType)
366 {
367 wstring wstrTemp=xOffer.wszOfferName;
368
369 // If the string starts with Minecraft, removed that
370
371 // Bug 49249 - JPN: Code Defect: Missing Text: String 'Minecraft' is missing in contents download screen.
372 // Looks like we shouldn't be removing this text for Japanese, and probably Chinese & Korean
373
374 DWORD dwLanguage = XGetLanguage( );
375 switch(dwLanguage)
376 {
377 case XC_LANGUAGE_KOREAN:
378 case XC_LANGUAGE_JAPANESE:
379 case XC_LANGUAGE_TCHINESE:
380 pListInfo[iCount].pwszText = xOffer.wszOfferName;
381 break;
382 default:
383 if(wstrTemp.compare(0,10,L"Minecraft ")==0)
384 {
385 pListInfo[iCount].pwszText = &xOffer.wszOfferName[10];
386 }
387 else
388 {
389 pListInfo[iCount].pwszText = xOffer.wszOfferName;
390 }
391 break;
392 }
393
394 pListInfo[iCount].fEnabled=TRUE;
395
396 // store the offer index
397 pListInfo[iCount].iData=i;
398 pListInfo[iCount].iSortIndex=(int)pDLC->uiSortIndex;
399#ifdef _DEBUG
400 app.DebugPrintf("Adding ");
401 OutputDebugStringW(pListInfo[iCount].pwszText);
402 app.DebugPrintf(" at %d\n",i);
403#endif
404
405 m_pOffersList->AddData(pListInfo[iCount],0,CXuiCtrl4JList::eSortList_Index);
406 //offerIndexes.push_back(i);
407
408 if(xOffer.fUserHasPurchased)
409 {
410 HXUIBRUSH hBrush;
411
412 if(RenderManager.IsHiDef() || RenderManager.IsWidescreen())
413 {
414 swprintf(szResourceLocator, LOCATOR_SIZE, L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/Graphics/DLC_Tick.png");
415 XuiCreateTextureBrush(szResourceLocator,&hBrush);
416 }
417 else
418 {
419 swprintf(szResourceLocator, LOCATOR_SIZE, L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/Graphics/DLC_TickSmall.png");
420 XuiCreateTextureBrush(szResourceLocator,&hBrush);
421 }
422 m_pOffersList->UpdateGraphicFromiData(i,hBrush);
423 }
424
425 /** 4J JEV:
426 * We've filtered results out from the list, need to keep track
427 * of the 'actual' list index.
428 */
429 iCount++;
430 }
431 }
432
433 // Check if there is nothing to display, and display the default "nothing available at this time"
434 if(iCount>0)
435 {
436 bNoDLCToDisplay=false;
437 }
438 }
439
440 // turn off the timer display
441 m_Timer.SetShow(FALSE);
442 if(iCount!=0)
443 {
444 // get the right index for the first list item - it will have been re-sorted internally in the list
445 int iIndex=0;
446 xOffer=StorageManager.GetOffer(m_pOffersList->GetData(iIndex).iData);
447 m_pOffersList->SetCurSelVisible(0);
448
449 DLC_INFO *dlc = app.GetDLCInfoForFullOfferID(xOffer.qwOfferID);
450 if (dlc != NULL)
451 {
452 BYTE *pData=NULL;
453 UINT uiSize=0;
454 DWORD dwSize=0;
455
456 WCHAR *cString = dlc->wchBanner;
457 // is the file in the TMS XZP?
458 int iIndex = app.GetLocalTMSFileIndex(cString, true);
459
460 if(iIndex!=-1)
461 {
462 // it's in the xzp
463 if(m_hXuiBrush!=NULL)
464 {
465 XuiDestroyBrush(m_hXuiBrush);
466 // clear the TMS XZP vector memory
467 //app.FreeLocalTMSFiles();
468 }
469 app.LoadLocalTMSFile(cString);
470 XuiCreateTextureBrushFromMemory(app.TMSFileA[iIndex].pbData,app.TMSFileA[iIndex].uiSize,&m_hXuiBrush);
471 }
472 else
473 {
474 bool bPresent = app.IsFileInMemoryTextures(cString);
475 if (!bPresent)
476 {
477 // Image has not come in yet
478 // Set the item monitored in the timer, so we can set the image when it comes in
479 m_pNoImageFor_DLC=dlc;
480 }
481 else
482 {
483 if(m_hXuiBrush!=NULL)
484 {
485 XuiDestroyBrush(m_hXuiBrush);
486 // clear the TMS XZP vector memory
487 //app.FreeLocalTMSFiles();
488 }
489 app.GetMemFileDetails(cString,&pData,&dwSize);
490 XuiCreateTextureBrushFromMemory(pData,dwSize,&m_hXuiBrush);
491 }
492 }
493 }
494
495 wchar_t formatting[40];
496 wstring wstrTemp = xOffer.wszSellText;
497 swprintf(formatting, 40, L"<font size=\"%d\">", m_bIsSD?12:14);
498 wstrTemp = formatting + wstrTemp;
499
500 m_SellText.SetText(wstrTemp.c_str());
501 m_SellText.SetShow(TRUE);
502
503 // set the price info
504 m_PriceTag.SetShow(TRUE);
505// swprintf(formatting, 40, L"%d",xOffer.dwPointsPrice);
506// wstrTemp=wstring(formatting);
507// m_PriceTag.SetText(wstrTemp.c_str());
508 m_PriceTag.SetText(xOffer.wszCurrencyPrice);
509
510 XuiElementSetShow(m_List,TRUE);
511 XuiElementSetFocus(m_List);
512
513 UpdateTooltips(xOffer);
514 }
515 else if(bNoDLCToDisplay)
516 {
517 // set the default text
518
519 wchar_t formatting[40];
520 wstring wstrTemp = app.GetString(IDS_NO_DLCOFFERS);
521 swprintf(formatting, 40, L"<font size=\"%d\">", m_bIsSD?12:14);
522 wstrTemp = formatting + wstrTemp;
523
524 m_SellText.SetText(wstrTemp.c_str());
525 m_SellText.SetShow(TRUE);
526 }
527 return S_OK;
528}
529
530HRESULT CScene_DLCOffers::OnDestroy()
531{
532 // 4J-PB - don't cancel the DLC anymore
533 //StorageManager.CancelGetDLCOffers();
534
535 // clear out any TMS images loaded from the XZP
536 app.FreeLocalTMSFiles(eTMSFileType_MinecraftStore);
537 return S_OK;
538}
539
540
541//----------------------------------------------------------------------------------
542// Handler for the button press message.
543//----------------------------------------------------------------------------------
544HRESULT CScene_DLCOffers::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
545{
546 if(m_bIgnorePress) return S_OK;
547
548 // This assumes all buttons can only be pressed with the A button
549 ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
550
551 if(hObjPressed==m_List)
552 {
553 CXuiControl pItem;
554 int iIndex;
555 CXuiCtrl4JList::LIST_ITEM_INFO ItemInfo;
556 // get the selected item
557 iIndex=m_List.GetCurSel(&pItem);
558 ItemInfo=m_pOffersList->GetData(iIndex);
559
560 ULONGLONG ullIndexA[1];
561
562 // check if it's already installed
563 // if(StorageManager.GetOffer(iIndex).fUserHasPurchased)
564 // {
565 //
566 // }
567 // else
568 // if it's already been purchased, we need to let the user download it anyway
569 {
570 ullIndexA[0]=StorageManager.GetOffer(ItemInfo.iData).qwOfferID;
571 StorageManager.InstallOffer(1,ullIndexA,NULL,NULL);
572 }
573 }
574
575 return S_OK;
576}
577
578HRESULT CScene_DLCOffers::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
579{
580 // Fix for Compliance fail -
581 // On a functional console, the game must not enter an extended unresponsive state, cause unintentional loss of player data, crash, or cause an unintended reboot of the machine.
582
583 //if(m_bIgnorePress) return S_OK;
584
585 ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
586
587 switch(pInputData->dwKeyCode)
588 {
589
590 case VK_PAD_B:
591 case VK_ESCAPE:
592 app.NavigateBack(XUSER_INDEX_ANY);
593 rfHandled = TRUE;
594
595 break;
596
597 case VK_PAD_RTHUMB_DOWN:
598 {
599 XUIHtmlScrollInfo ScrollInfo;
600
601 XuiHtmlControlGetVScrollInfo(m_SellText.m_hObj,&ScrollInfo);
602 if(!ScrollInfo.bScrolling)
603 {
604 XuiHtmlControlVScrollBy(m_SellText.m_hObj,1);
605 }
606 }
607 break;
608 case VK_PAD_RTHUMB_UP:
609 {
610 XUIHtmlScrollInfo ScrollInfo;
611
612 XuiHtmlControlGetVScrollInfo(m_SellText.m_hObj,&ScrollInfo);
613 if(!ScrollInfo.bScrolling)
614 {
615 XuiHtmlControlVScrollBy(m_SellText.m_hObj,-1);
616 }
617 }
618 break;
619 }
620
621 return S_OK;
622}
623
624
625HRESULT CScene_DLCOffers::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled)
626{
627 // re-enable button presses
628 m_bIgnorePress=false;
629
630 return S_OK;
631}
632
633//void CScene_DLCOffers::UpdateTooltips(XMARKETPLACE_CONTENTOFFER_INFO& xOffer)
634void CScene_DLCOffers::UpdateTooltips(XMARKETPLACE_CURRENCY_CONTENTOFFER_INFO& xOffer)
635{
636 // if the current offer hasn't been purchased already, check if there's a trial version available
637 if(xOffer.fUserHasPurchased==false )
638 {
639 ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_INSTALL,IDS_TOOLTIPS_BACK);
640 }
641 else
642 {
643 ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_REINSTALL,IDS_TOOLTIPS_BACK);
644 }
645}
646
647
648HRESULT CScene_DLCOffers::OnGetSourceDataImage(XUIMessageGetSourceImage *pGetSourceImageData,BOOL& bHandled)
649{
650 if( pGetSourceImageData->bItemData )
651 {
652 pGetSourceImageData->hBrush = m_hXuiBrush;
653
654 bHandled = TRUE;
655 }
656 return S_OK;
657}
658
659HRESULT CScene_DLCOffers::OnNotifySelChanged(HXUIOBJ hObjSource, XUINotifySelChanged *pNotifySelChangedData, BOOL& bHandled)
660{
661 //int index = pNotifySelChangedData->iItem;
662 // reset the image monitor, but not for the first selection
663 if(pNotifySelChangedData->iOldItem!=-1)
664 {
665 m_pNoImageFor_DLC=NULL;
666 }
667
668 if (m_List.TreeHasFocus())// && offerIndexes.size() > index)
669 {
670 CXuiControl pItem;
671 int iIndex;
672 CXuiCtrl4JList::LIST_ITEM_INFO ItemInfo;
673 // get the selected item
674 iIndex=m_List.GetCurSel(&pItem);
675 ItemInfo=m_pOffersList->GetData(iIndex);
676
677// XMARKETPLACE_CONTENTOFFER_INFO xOffer=
678// StorageManager.GetOffer(ItemInfo.iData);
679 XMARKETPLACE_CURRENCY_CONTENTOFFER_INFO xOffer=
680 StorageManager.GetOffer(ItemInfo.iData);
681
682
683 wchar_t formatting[40];
684 wstring wstrTemp=xOffer.wszSellText;
685 swprintf(formatting, 40, L"<font size=\"%d\">",m_bIsSD?12:14);
686 wstrTemp = wstring(formatting) + wstrTemp;
687
688 m_SellText.SetText(wstrTemp.c_str());
689
690 // set the price info
691 m_PriceTag.SetShow(TRUE);
692// swprintf(formatting, 40, L"%d",xOffer.dwPointsPrice);
693// wstrTemp=wstring(formatting);
694// m_PriceTag.SetText(wstrTemp.c_str());
695 m_PriceTag.SetText(xOffer.wszCurrencyPrice);
696
697 DLC_INFO *dlc = app.GetDLCInfoForTrialOfferID(xOffer.qwOfferID);
698 if(dlc==NULL)
699 {
700 dlc = app.GetDLCInfoForFullOfferID(xOffer.qwOfferID);
701 }
702
703 if (dlc != NULL)
704 {
705 BYTE *pImage=NULL;
706 UINT uiSize=0;
707 DWORD dwSize=0;
708
709 WCHAR *cString = dlc->wchBanner;
710
711 int iIndex = app.GetLocalTMSFileIndex(cString,true);
712
713 if(iIndex!=-1)
714 {
715 // it's in the xzp
716 if(m_hXuiBrush!=NULL)
717 {
718 XuiDestroyBrush(m_hXuiBrush);
719 // clear the TMS XZP vector memory
720 //app.FreeLocalTMSFiles();
721 }
722 app.LoadLocalTMSFile(cString);
723 XuiCreateTextureBrushFromMemory(app.TMSFileA[iIndex].pbData,app.TMSFileA[iIndex].uiSize,&m_hXuiBrush);
724 }
725 else
726 {
727 bool bPresent = app.IsFileInMemoryTextures(cString);
728 if (!bPresent)
729 {
730 // Image has not come in yet
731 // Set the item monitored in the timer, so we can set the image when it comes in
732 m_pNoImageFor_DLC=dlc;
733
734 // promote it to the top of the queue of images to be retrieved
735 // We can't trust the dwContentCategory from partnernet - it has avatar items as content instead of avatars
736 app.AddTMSPPFileTypeRequest(dlc->eDLCType,true);
737 }
738 else
739 {
740 if(m_hXuiBrush!=NULL)
741 {
742 XuiDestroyBrush(m_hXuiBrush);
743 // clear the TMS XZP vector memory
744 //app.FreeLocalTMSFiles();
745 }
746 app.GetMemFileDetails(cString,&pImage,&dwSize);
747 XuiCreateTextureBrushFromMemory(pImage,dwSize,&m_hXuiBrush);
748 }
749 }
750 }
751 else
752 {
753 if(m_hXuiBrush!=NULL)
754 {
755 XuiDestroyBrush(m_hXuiBrush);
756 // clear the TMS XZP vector memory
757 //app.FreeLocalTMSFiles();
758
759 m_hXuiBrush=NULL;
760 }
761 }
762
763 UpdateTooltips(xOffer);
764 }
765 else
766 {
767 m_SellText.SetText(L"");
768 ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_ACCEPT ,IDS_TOOLTIPS_BACK);
769 }
770 return S_OK;
771}
772
773
774HRESULT CScene_DLCOffers::OnTimer(XUIMessageTimer *pData,BOOL& rfHandled)
775{
776 // check the ethernet status - if it's disconnected, exit the xui
777
778 if(ProfileManager.GetLiveConnectionStatus()!=XONLINE_S_LOGON_CONNECTION_ESTABLISHED)
779 {
780 UINT uiIDA[1];
781 uiIDA[0]=IDS_CONFIRM_OK;
782
783 m_pOffersList->RemoveAllData();
784 m_iOfferC=0;
785 StorageManager.ClearDLCOffers();
786 app.ClearAndResetDLCDownloadQueue();
787
788 StorageManager.RequestMessageBox(IDS_CONNECTION_LOST, IDS_CONNECTION_LOST_LIVE, uiIDA, 1, ProfileManager.GetPrimaryPad(),&CConsoleMinecraftApp::EthernetDisconnectReturned,this, app.GetStringTable());
789 }
790
791 // Is the DLC we're looking for available?
792 if(!m_bDLCRequiredIsRetrieved)
793 {
794 if(app.DLCContentRetrieved((eDLCMarketplaceType)m_iType))
795 {
796 m_bDLCRequiredIsRetrieved=true;
797
798 // Retrieve the info
799 GetDLCInfo(app.GetDLCOffersCount(), false);
800 m_bIgnorePress=false;
801 }
802 }
803
804 // Check for any TMS image we're waiting for
805 if(m_pNoImageFor_DLC!=NULL)
806 {
807 // Is it present now?
808 WCHAR *cString = m_pNoImageFor_DLC->wchBanner;
809
810 bool bPresent = app.IsFileInMemoryTextures(cString);
811
812 if(bPresent)
813 {
814 BYTE *pImage=NULL;
815 DWORD dwSize=0;
816
817 if(m_hXuiBrush!=NULL)
818 {
819 XuiDestroyBrush(m_hXuiBrush);
820 // clear the TMS XZP vector memory
821 //app.FreeLocalTMSFiles();
822 }
823 app.GetMemFileDetails(cString,&pImage,&dwSize);
824 XuiCreateTextureBrushFromMemory(pImage,dwSize,&m_hXuiBrush);
825 m_pNoImageFor_DLC=NULL;
826 }
827 }
828
829 return S_OK;
830}
831
832// int CScene_DLCOffers::EthernetDisconnectReturned(void *pParam,int iPad,const C4JStorage::EMessageResult)
833// {
834// CConsoleMinecraftApp* pApp = (CConsoleMinecraftApp*)pParam;
835//
836// pApp->NavigateBack(XUSER_INDEX_ANY);
837//
838// return 0;
839// }
840
841HRESULT CScene_DLCOffers::OnCustomMessage_DLCInstalled()
842{
843 // mounted DLC may have changed - need to re-run the GetDLC
844 ui.SetTooltips( DEFAULT_XUI_MENU_USER, -1, IDS_TOOLTIPS_BACK);
845 m_bIgnorePress=true;
846 m_pOffersList->RemoveAllData();
847 m_iOfferC=0;
848
849 // Update the dlc info
850 StorageManager.ClearDLCOffers();
851 app.ClearAndResetDLCDownloadQueue();
852
853 // order these requests so the current DLC comes in first
854 switch(m_iType)
855 {
856 case e_DLC_Gamerpics:
857 app.AddDLCRequest(e_Marketplace_Gamerpics);
858 app.AddDLCRequest(e_Marketplace_Content);
859 app.AddDLCRequest(e_Marketplace_Themes);
860 app.AddDLCRequest(e_Marketplace_AvatarItems);
861 break;
862 case e_DLC_Themes:
863 app.AddDLCRequest(e_Marketplace_Themes);
864 app.AddDLCRequest(e_Marketplace_Content);
865 app.AddDLCRequest(e_Marketplace_Gamerpics);
866 app.AddDLCRequest(e_Marketplace_AvatarItems);
867 break;
868 case e_DLC_AvatarItems:
869 app.AddDLCRequest(e_Marketplace_AvatarItems);
870 app.AddDLCRequest(e_Marketplace_Content);
871 app.AddDLCRequest(e_Marketplace_Themes);
872 app.AddDLCRequest(e_Marketplace_Gamerpics);
873 break;
874 default:
875 app.AddDLCRequest(e_Marketplace_Content);
876 app.AddDLCRequest(e_Marketplace_Gamerpics);
877 app.AddDLCRequest(e_Marketplace_Themes);
878 app.AddDLCRequest(e_Marketplace_AvatarItems);
879 break;
880 }
881
882 m_Timer.SetShow(TRUE);
883 m_bDLCRequiredIsRetrieved=false;
884
885 return S_OK;
886}