the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 462 lines 13 kB view raw
1// Minecraft.cpp : Defines the entry point for the application. 2// 3 4#include "stdafx.h" 5 6#include <assert.h> 7#include "..\XUI\XUI_HelpAndOptions.h" 8 9 10//---------------------------------------------------------------------------------- 11// Performs initialization tasks - retrieves controls. 12//---------------------------------------------------------------------------------- 13HRESULT CScene_HelpAndOptions::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) 14{ 15 m_iPad = *(int *)pInitData->pvInitData; 16 bool bNotInGame=(Minecraft::GetInstance()->level==NULL); 17 18 MapChildControls(); 19 XuiControlSetText(m_Buttons[BUTTON_HAO_CHANGESKIN],app.GetString(IDS_CHANGE_SKIN)); 20 XuiControlSetText(m_Buttons[BUTTON_HAO_HOWTOPLAY],app.GetString(IDS_HOW_TO_PLAY)); 21 XuiControlSetText(m_Buttons[BUTTON_HAO_CONTROLS],app.GetString(IDS_CONTROLS)); 22 XuiControlSetText(m_Buttons[BUTTON_HAO_SETTINGS],app.GetString(IDS_SETTINGS)); 23 XuiControlSetText(m_Buttons[BUTTON_HAO_CREDITS],app.GetString(IDS_CREDITS)); 24 XuiControlSetText(m_Buttons[BUTTON_HAO_REINSTALL],app.GetString(IDS_REINSTALL_CONTENT)); 25 XuiControlSetText(m_Buttons[BUTTON_HAO_DEBUG],app.GetString(IDS_DEBUG_SETTINGS)); 26 27 //if(app.GetTMSDLCInfoRead()) 28 { 29 m_Timer.SetShow(FALSE); 30 m_bIgnoreInput=false; 31 32 #ifndef _FINAL_BUILD 33 if(!app.DebugSettingsOn()) 34 { 35 m_Buttons[BUTTON_HAO_DEBUG].SetEnable(FALSE); 36 m_Buttons[BUTTON_HAO_DEBUG].SetShow(FALSE); 37 } 38 else 39 { 40 m_Buttons[BUTTON_HAO_DEBUG].SetEnable(TRUE); 41 m_Buttons[BUTTON_HAO_DEBUG].SetShow(TRUE); 42 43 } 44 #endif 45 46 // 4J-PB - do not need a storage device to see this menu - just need one when you choose to re-install them 47 48 // any content to be re-installed? 49 if(m_iPad==ProfileManager.GetPrimaryPad() && bNotInGame) 50 { 51 // We should show the reinstall menu 52 app.DebugPrintf("Reinstall Menu required...\n"); 53 m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(TRUE); 54 m_Buttons[BUTTON_HAO_REINSTALL].SetShow(TRUE); 55 } 56 else 57 { 58 m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(FALSE); 59 m_Buttons[BUTTON_HAO_REINSTALL].SetShow(FALSE); 60 } 61 62 if(app.GetLocalPlayerCount()>1) 63 { 64 // no credits in splitscreen 65 D3DXVECTOR3 vec; 66 67 m_Buttons[BUTTON_HAO_CREDITS].GetPosition(&vec); 68 69 m_Buttons[BUTTON_HAO_CREDITS].SetEnable(FALSE); 70 m_Buttons[BUTTON_HAO_CREDITS].SetShow(FALSE); 71 72 m_Buttons[BUTTON_HAO_REINSTALL].SetPosition(&vec); 73 74 app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad,false); 75 CXuiSceneBase::ShowLogo( m_iPad, FALSE ); 76 77 if(ProfileManager.GetPrimaryPad()!=m_iPad) 78 { 79 m_Buttons[BUTTON_HAO_DEBUG].SetEnable(FALSE); 80 m_Buttons[BUTTON_HAO_DEBUG].SetShow(FALSE); 81 } 82 } 83 else 84 { 85 if(bNotInGame) 86 { 87 CXuiSceneBase::ShowLogo( DEFAULT_XUI_MENU_USER, TRUE ); 88 } 89 else 90 { 91 CXuiSceneBase::ShowLogo( m_iPad, TRUE ); 92 } 93 } 94 // Display the tooltips 95 96 // if we're not in the game, we need to use basescene 0 97 if(bNotInGame) 98 { 99 ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); 100 } 101 else 102 { 103 ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); 104 } 105 106 107 if(!ProfileManager.IsFullVersion() )//|| ProfileManager.IsGuest(m_iPad)) 108 { 109 // disable save button 110 m_Buttons[BUTTON_HAO_CHANGESKIN].SetEnable(FALSE); 111 m_Buttons[BUTTON_HAO_CHANGESKIN].EnableInput(FALSE); 112 // set the focus to the second button 113 114 XuiElementSetUserFocus(m_Buttons[BUTTON_HAO_HOWTOPLAY].m_hObj, m_iPad); 115 } 116 } 117 /*else 118 { 119 m_bIgnoreInput=true; 120 m_Timer.SetShow(TRUE); 121 122 // hide all the buttons 123 for(int i=0;i<BUTTONS_HAO_MAX;i++) 124 { 125 m_Buttons[i].SetEnable(FALSE); 126 m_Buttons[i].SetShow(FALSE); 127 } 128 129 if(bNotInGame) 130 { 131 ui.SetTooltips( DEFAULT_XUI_MENU_USER, -1,-1); 132 } 133 else 134 { 135 ui.SetTooltips( m_iPad, -1,-1); 136 } 137 }*/ 138 return S_OK; 139} 140 141/*HRESULT CScene_HelpAndOptions::OnTMSDLCFileRetrieved( ) 142{ 143 bool bNotInGame=(Minecraft::GetInstance()->level==NULL); 144 m_Timer.SetShow(FALSE); 145 m_bIgnoreInput=false; 146 147 // show all the buttons - except the debug settings and reinstall content 148 m_Buttons[BUTTON_HAO_CHANGESKIN].SetEnable(TRUE); 149 m_Buttons[BUTTON_HAO_CHANGESKIN].SetShow(TRUE); 150 m_Buttons[BUTTON_HAO_HOWTOPLAY].SetEnable(TRUE); 151 m_Buttons[BUTTON_HAO_HOWTOPLAY].SetShow(TRUE); 152 m_Buttons[BUTTON_HAO_CONTROLS].SetEnable(TRUE); 153 m_Buttons[BUTTON_HAO_CONTROLS].SetShow(TRUE); 154 m_Buttons[BUTTON_HAO_SETTINGS].SetEnable(TRUE); 155 m_Buttons[BUTTON_HAO_SETTINGS].SetShow(TRUE); 156 m_Buttons[BUTTON_HAO_CREDITS].SetEnable(TRUE); 157 m_Buttons[BUTTON_HAO_CREDITS].SetShow(TRUE); 158 159 160 161#ifndef _FINAL_BUILD 162 if(!app.DebugSettingsOn()) 163 { 164 m_Buttons[BUTTON_HAO_DEBUG].SetEnable(FALSE); 165 m_Buttons[BUTTON_HAO_DEBUG].SetShow(FALSE); 166 } 167 else 168 { 169 m_Buttons[BUTTON_HAO_DEBUG].SetEnable(TRUE); 170 m_Buttons[BUTTON_HAO_DEBUG].SetShow(TRUE); 171 172 } 173#endif 174 175 // 4J-PB - do not need a storage device to see this menu - just need one when you choose to re-install them 176 177 // any content to be re-installed? 178 if(m_iPad==ProfileManager.GetPrimaryPad() && bNotInGame) 179 { 180 // We should show the reinstall menu 181 app.DebugPrintf("Reinstall Menu required...\n"); 182 m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(TRUE); 183 m_Buttons[BUTTON_HAO_REINSTALL].SetShow(TRUE); 184 } 185 else 186 { 187 m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(FALSE); 188 m_Buttons[BUTTON_HAO_REINSTALL].SetShow(FALSE); 189 } 190 191 if(app.GetLocalPlayerCount()>1) 192 { 193 // no credits in splitscreen 194 D3DXVECTOR3 vec; 195 196 m_Buttons[BUTTON_HAO_CREDITS].GetPosition(&vec); 197 198 m_Buttons[BUTTON_HAO_CREDITS].SetEnable(FALSE); 199 m_Buttons[BUTTON_HAO_CREDITS].SetShow(FALSE); 200 201 m_Buttons[BUTTON_HAO_REINSTALL].SetPosition(&vec); 202 203 app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad,false); 204 CXuiSceneBase::ShowLogo( m_iPad, FALSE ); 205 206 if(ProfileManager.GetPrimaryPad()!=m_iPad) 207 { 208 m_Buttons[BUTTON_HAO_DEBUG].SetEnable(FALSE); 209 m_Buttons[BUTTON_HAO_DEBUG].SetShow(FALSE); 210 } 211 } 212 else 213 { 214 if(bNotInGame) 215 { 216 CXuiSceneBase::ShowLogo( DEFAULT_XUI_MENU_USER, TRUE ); 217 } 218 else 219 { 220 CXuiSceneBase::ShowLogo( m_iPad, TRUE ); 221 } 222 } 223 // Display the tooltips 224 225 // if we're not in the game, we need to use basescene 0 226 if(bNotInGame) 227 { 228 ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); 229 } 230 else 231 { 232 ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); 233 } 234 235 236 if(!ProfileManager.IsFullVersion() )//|| ProfileManager.IsGuest(m_iPad)) 237 { 238 // disable save button 239 m_Buttons[BUTTON_HAO_CHANGESKIN].SetEnable(FALSE); 240 m_Buttons[BUTTON_HAO_CHANGESKIN].EnableInput(FALSE); 241 // set the focus to the second button 242 243 XuiElementSetUserFocus(m_Buttons[BUTTON_HAO_HOWTOPLAY].m_hObj, m_iPad); 244 } 245 else 246 { 247 XuiElementSetUserFocus(m_Buttons[BUTTON_HAO_CHANGESKIN].m_hObj, m_iPad); 248 } 249 return S_OK; 250}*/ 251 252HRESULT CScene_HelpAndOptions::OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled) 253{ 254 pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); 255 256 if(pControlNavigateData->hObjDest!=NULL) 257 { 258 bHandled=TRUE; 259 } 260 261 return S_OK; 262} 263 264//---------------------------------------------------------------------------------- 265// Handler for the button press message. 266//---------------------------------------------------------------------------------- 267HRESULT CScene_HelpAndOptions::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled) 268{ 269 // This assumes all buttons can only be pressed with the A button 270 ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A); 271 272 unsigned int uiButtonCounter=0; 273 274 while((uiButtonCounter<BUTTONS_HAO_MAX) && (m_Buttons[uiButtonCounter]!=hObjPressed)) uiButtonCounter++; 275 276 // Determine which button was pressed, 277 // and call the appropriate function. 278 279 switch(uiButtonCounter) 280 { 281 case BUTTON_HAO_HOWTOPLAY: 282 app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_HowToPlayMenu); 283 break; 284 case BUTTON_HAO_CONTROLS: 285 app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_ControlsMenu); 286 break; 287 case BUTTON_HAO_SETTINGS: 288 app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_SettingsMenu); 289 break; 290 case BUTTON_HAO_CHANGESKIN: 291 app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_SkinSelectMenu); 292 break; 293 case BUTTON_HAO_CREDITS: 294 app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_Credits); 295 break; 296 297 case BUTTON_HAO_REINSTALL: 298 app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_ReinstallMenu); 299 break; 300 301 case BUTTON_HAO_DEBUG: 302 app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_DebugOptions); 303 break; 304 305 default: 306 break; 307 } 308 309 return S_OK; 310} 311 312HRESULT CScene_HelpAndOptions::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled) 313{ 314 if(m_bIgnoreInput) return S_OK; 315 316 // ignore a held down key to avoid skipping this scene if the user changes a setting and presses B for slightly too long 317 if((pInputData->dwFlags&XUI_INPUT_FLAG_REPEAT)&&(pInputData->dwKeyCode==VK_PAD_B)) 318 { 319 return S_OK; 320 } 321 322 ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode); 323 324 switch(pInputData->dwKeyCode) 325 { 326 327 case VK_PAD_B: 328 case VK_ESCAPE: 329 BYTE userIndex = pInputData->UserIndex; 330 if( !app.IsPauseMenuDisplayed(userIndex) ) 331 { 332 // If we are not from a pause menu, then we are from the main menu 333 userIndex = XUSER_INDEX_ANY; 334 } 335 336 app.NavigateBack(userIndex); 337 rfHandled = TRUE; 338 339 break; 340 } 341 342 return S_OK; 343} 344 345HRESULT CScene_HelpAndOptions::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled) 346{ 347 bool bNotInGame=(Minecraft::GetInstance()->level==NULL); 348 349 if(bNotInGame) 350 { 351 ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); 352 CXuiSceneBase::ShowLogo( DEFAULT_XUI_MENU_USER, TRUE ); 353 354 if(m_iPad==ProfileManager.GetPrimaryPad() )//&& 355 // StorageManager.GetSaveDeviceSelected(m_iPad) && 356 // !StorageManager.GetSaveDisabled() && 357// ( ProfileManager.IsAwardsFlagSet(m_iPad,eAward_mine100Blocks) || 358// ProfileManager.IsAwardsFlagSet(m_iPad,eAward_kill10Creepers) || 359// ProfileManager.IsAwardsFlagSet(m_iPad,eAward_eatPorkChop) || 360// ProfileManager.IsAwardsFlagSet(m_iPad,eAward_play100Days) || 361// ProfileManager.IsAwardsFlagSet(m_iPad,eAward_arrowKillCreeper) || 362// ProfileManager.IsAwardsFlagSet(m_iPad,eAward_socialPost)) ) 363 { 364 // We should show the reinstall menu 365 app.DebugPrintf("Reinstall Menu required...\n"); 366 m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(TRUE); 367 m_Buttons[BUTTON_HAO_REINSTALL].SetShow(TRUE); 368 } 369 else 370 { 371 m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(FALSE); 372 m_Buttons[BUTTON_HAO_REINSTALL].SetShow(FALSE); 373 } 374 375 } 376 else 377 { 378 ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); 379 if(app.GetLocalPlayerCount()>1) 380 { 381 CXuiSceneBase::ShowLogo( m_iPad, FALSE ); 382 } 383 else 384 { 385 CXuiSceneBase::ShowLogo( m_iPad, TRUE ); 386 } 387 } 388 389 return S_OK; 390} 391 392 393// int CScene_HelpAndOptions::ResetDefaultsDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 394// { 395// CScene_HelpAndOptions* pClass = (CScene_HelpAndOptions*)pParam; 396// 397// // results switched for this dialog 398// if(result==C4JStorage::EMessage_ResultDecline) 399// { 400// app.SetDefaultOptions(ProfileManager.GetDashboardProfileSettings(pClass->m_iPad),pClass->m_iPad); 401// // if the profile data has been changed, then force a profile write 402// // It seems we're allowed to break the 5 minute rule if it's the result of a user action 403// app.CheckGameSettingsChanged(true,iPad); 404// } 405// return 0; 406// } 407 408HRESULT CScene_HelpAndOptions::OnTransitionStart( XUIMessageTransition *pTransition, BOOL& bHandled ) 409{ 410 if(pTransition->dwTransAction==XUI_TRANSITION_ACTION_DESTROY ) return S_OK; 411 412 if(pTransition->dwTransType == XUI_TRANSITION_TO || pTransition->dwTransType == XUI_TRANSITION_BACKTO) 413 { 414 415 // 4J-PB - Going to resize buttons if the text is too big to fit on any of them (Br-pt problem with the length of Unlock Full Game) 416 XUIRect xuiRect; 417 HXUIOBJ visual=NULL; 418 HXUIOBJ text; 419 float fMaxTextLen=0.0f; 420 float fTextVisualLen; 421 float fMaxButton; 422 float fWidth,fHeight; 423 424 HRESULT hr=XuiControlGetVisual(m_Buttons[0].m_hObj,&visual); 425 hr=XuiElementGetChildById(visual,L"text_Label",&text); 426 hr=XuiElementGetBounds(text,&fTextVisualLen,&fHeight); 427 m_Buttons[0].GetBounds(&fMaxButton,&fHeight); 428 429 430 for(int i=0;i<BUTTONS_HAO_MAX;i++) 431 { 432 hr=XuiTextPresenterMeasureText(text, m_Buttons[i].GetText(), &xuiRect); 433 if(xuiRect.right>fMaxTextLen) fMaxTextLen=xuiRect.right; 434 } 435 436 if(fTextVisualLen<fMaxTextLen) 437 { 438 D3DXVECTOR3 vec; 439 440 // centre is vec.x+(fWidth/2) 441 for(int i=0;i<BUTTONS_HAO_MAX;i++) 442 { 443 // need to resize and reposition the buttons 444 m_Buttons[i].GetPosition(&vec); 445 m_Buttons[i].GetBounds(&fWidth,&fHeight); 446 vec.x= vec.x+(fWidth/2.0f)-(fMaxTextLen/2.0f); 447 448 m_Buttons[i].SetPosition(&vec); 449 m_Buttons[i].SetBounds(fMaxButton+fMaxTextLen-fTextVisualLen,fHeight); 450 } 451 } 452 } 453 454 return S_OK; 455} 456 457 458HRESULT CScene_HelpAndOptions::OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled) 459{ 460 bHandled=true; 461 return app.AdjustSplitscreenScene_PlayerChanged(m_hObj,&m_OriginalPosition,m_iPad,bJoining,false); 462}