the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 242 lines 6.7 kB view raw
1#include "stdafx.h" 2#include "UI.h" 3#if defined(__PS3__) || defined(__ORBIS__) 4#include "Common\Network\Sony\SonyCommerce.h" 5#endif 6#include "UIScene_DLCMainMenu.h" 7 8#define PLAYER_ONLINE_TIMER_ID 0 9#define PLAYER_ONLINE_TIMER_TIME 100 10 11UIScene_DLCMainMenu::UIScene_DLCMainMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) 12{ 13 // Setup all the Iggy references we need for this scene 14 initialiseMovie(); 15 // Alert the app the we want to be informed of ethernet connections 16 app.SetLiveLinkRequired( true ); 17 18 m_labelOffers.init(IDS_DOWNLOADABLE_CONTENT_OFFERS); 19 m_buttonListOffers.init(eControl_OffersList); 20 21#if defined _XBOX_ONE || defined __ORBIS__ 22 // load any local DLC images 23 app.LoadLocalDLCImages(); 24#endif 25 26#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) 27 // show a timer on this menu 28 m_Timer.setVisible(true); 29 30 m_bCategoriesShown=false; 31#endif 32 33 if(m_loadedResolution == eSceneResolution_1080) 34 { 35#ifdef _DURANGO 36 m_labelXboxStore.init(IDS_XBOX_STORE); 37#else 38 m_labelXboxStore.init( L"" ); 39#endif 40 } 41 42#if defined(_DURANGO) 43 m_Timer.setVisible(false); 44 45 m_buttonListOffers.addItem(IDS_DLC_MENU_SKINPACKS,e_DLC_SkinPack); 46 m_buttonListOffers.addItem(IDS_DLC_MENU_TEXTUREPACKS,e_DLC_TexturePacks); 47 m_buttonListOffers.addItem(IDS_DLC_MENU_MASHUPPACKS,e_DLC_MashupPacks); 48 49 app.AddDLCRequest(e_Marketplace_Content); // content is skin packs, texture packs and mash-up packs 50 // we also need to mount the local DLC so we can tell what's been purchased 51 app.StartInstallDLCProcess(iPad); 52#endif 53 54 TelemetryManager->RecordMenuShown(iPad, eUIScene_DLCMainMenu, 0); 55 56#if defined __ORBIS__ || defined __PSVITA__ 57 app.GetCommerce()->ShowPsStoreIcon(); 58#endif 59 60#if ( defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ ) 61 addTimer( PLAYER_ONLINE_TIMER_ID, PLAYER_ONLINE_TIMER_TIME ); 62#endif 63} 64 65UIScene_DLCMainMenu::~UIScene_DLCMainMenu() 66{ 67 // Alert the app the we no longer want to be informed of ethernet connections 68 app.SetLiveLinkRequired( false ); 69#if defined _XBOX_ONE || defined __ORBIS__ 70 app.FreeLocalDLCImages(); 71#endif 72 73#ifdef _XBOX_ONE 74 // 4J-JEV: Have to switch back to user preferred languge now. 75 setLanguageOverride(true); 76#endif 77} 78 79wstring UIScene_DLCMainMenu::getMoviePath() 80{ 81 return L"DLCMainMenu"; 82} 83 84void UIScene_DLCMainMenu::updateTooltips() 85{ 86 ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK ); 87} 88 89void UIScene_DLCMainMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) 90{ 91 //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"); 92 ui.AnimateKeyPress(m_iPad, key, repeat, pressed, released); 93 94 switch(key) 95 { 96 case ACTION_MENU_CANCEL: 97 if(pressed) 98 { 99#if defined __ORBIS__ || defined __PSVITA__ 100 app.GetCommerce()->HidePsStoreIcon(); 101#endif 102 navigateBack(); 103 } 104 break; 105 case ACTION_MENU_OK: 106#ifdef __ORBIS__ 107 case ACTION_MENU_TOUCHPAD_PRESS: 108#endif 109 sendInputToMovie(key, repeat, pressed, released); 110 break; 111 case ACTION_MENU_UP: 112 case ACTION_MENU_DOWN: 113 case ACTION_MENU_LEFT: 114 case ACTION_MENU_RIGHT: 115 case ACTION_MENU_PAGEUP: 116 case ACTION_MENU_PAGEDOWN: 117 sendInputToMovie(key, repeat, pressed, released); 118 break; 119 } 120} 121 122void UIScene_DLCMainMenu::handlePress(F64 controlId, F64 childId) 123{ 124 switch((int)controlId) 125 { 126 case eControl_OffersList: 127 { 128 int iIndex = (int)childId; 129 DLCOffersParam *param = new DLCOffersParam(); 130 param->iPad = m_iPad; 131 132 param->iType = iIndex; 133 // promote the DLC content request type 134 135 // Xbox One will have requested the marketplace content - there is only that type 136#ifndef _XBOX_ONE 137 app.AddDLCRequest((eDLCMarketplaceType)iIndex, true); 138#endif 139 killTimer(PLAYER_ONLINE_TIMER_ID); 140 ui.NavigateToScene(m_iPad, eUIScene_DLCOffersMenu, param); 141 break; 142 } 143 }; 144} 145 146void UIScene_DLCMainMenu::handleTimerComplete(int id) 147{ 148#if ( defined __PS3__ || defined __ORBIS__ || defined __PSVITA__) 149 switch(id) 150 { 151 case PLAYER_ONLINE_TIMER_ID: 152#ifndef _WINDOWS64 153 if(ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad())==false) 154 { 155 // check the player hasn't gone offline 156 // If they have, bring up the PSN warning and exit from the leaderboards 157 unsigned int uiIDA[1]; 158 uiIDA[0]=IDS_OK; 159 C4JStorage::EMessageResult result = ui.RequestErrorMessage( IDS_CONNECTION_LOST, g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_LOST_LIVE_NO_EXIT), uiIDA,1,ProfileManager.GetPrimaryPad(),UIScene_DLCMainMenu::ExitDLCMainMenu,this); 160 } 161#endif 162 break; 163 } 164#endif 165} 166 167int UIScene_DLCMainMenu::ExitDLCMainMenu(void *pParam,int iPad,C4JStorage::EMessageResult result) 168{ 169 UIScene_DLCMainMenu* pClass = (UIScene_DLCMainMenu*)pParam; 170 171#if defined __ORBIS__ || defined __PSVITA__ 172 app.GetCommerce()->HidePsStoreIcon(); 173#endif 174 pClass->navigateBack(); 175 176 return 0; 177} 178 179void UIScene_DLCMainMenu::handleGainFocus(bool navBack) 180{ 181 UIScene::handleGainFocus(navBack); 182 183 updateTooltips(); 184 185 if(navBack) 186 { 187 // add the timer back in 188#if ( defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ ) 189 addTimer( PLAYER_ONLINE_TIMER_ID, PLAYER_ONLINE_TIMER_TIME ); 190#endif 191 } 192} 193 194void UIScene_DLCMainMenu::tick() 195{ 196 UIScene::tick(); 197 198#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) 199 if((m_bCategoriesShown==false) && (app.GetCommerceCategoriesRetrieved())) 200 { 201 // disable the timer display on this menu 202 m_Timer.setVisible(false); 203 m_bCategoriesShown=true; 204 205 // add the categories to the list box 206 SonyCommerce::CategoryInfo *pCategories=app.GetCategoryInfo(); 207 std::list<SonyCommerce::CategoryInfoSub>::iterator iter = pCategories->subCategories.begin(); 208 SonyCommerce::CategoryInfoSub category; 209 for(int i=0;i<pCategories->countOfSubCategories;i++) 210 { 211 // add a button in with the subcategory 212 category = (SonyCommerce::CategoryInfoSub)(*iter); 213 214 string teststring=category.categoryName; 215 m_buttonListOffers.addItem(teststring,i); 216 217 iter++; 218 } 219 220 // set the focus to the first thing in the categories if there are any 221 if(pCategories->countOfSubCategories>0) 222 { 223 m_buttonListOffers.setFocus(true); 224 } 225 else 226 { 227#if defined __ORBIS__ || defined __PSVITA__ || defined __PS3__ 228 app.CheckForEmptyStore(ProfileManager.GetPrimaryPad()); 229#endif 230 // need to display text to say no downloadable content available yet 231 m_labelOffers.setLabel(app.GetString(IDS_NO_DLCCATEGORIES)); 232 233#ifdef __ORBIS__ 234 // 4J-JEV: TRC Requirement (R4055), need to display this system message. 235 ProfileManager.DisplaySystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_EMPTY_STORE, ProfileManager.GetPrimaryPad() ); 236#endif 237 } 238 239 } 240#endif 241} 242