// Minecraft.cpp : Defines the entry point for the application. // #include "stdafx.h" #include #include "..\XUI\XUI_HelpAndOptions.h" //---------------------------------------------------------------------------------- // Performs initialization tasks - retrieves controls. //---------------------------------------------------------------------------------- HRESULT CScene_HelpAndOptions::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { m_iPad = *(int *)pInitData->pvInitData; bool bNotInGame=(Minecraft::GetInstance()->level==NULL); MapChildControls(); XuiControlSetText(m_Buttons[BUTTON_HAO_HOWTOPLAY],app.GetString(IDS_HOW_TO_PLAY)); XuiControlSetText(m_Buttons[BUTTON_HAO_CONTROLS],app.GetString(IDS_CONTROLS)); XuiControlSetText(m_Buttons[BUTTON_HAO_SETTINGS],app.GetString(IDS_SETTINGS)); XuiControlSetText(m_Buttons[BUTTON_HAO_CREDITS],app.GetString(IDS_CREDITS)); XuiControlSetText(m_Buttons[BUTTON_HAO_RESETTODEFAULTS],app.GetString(IDS_RESET_TO_DEFAULTS)); XuiControlSetText(m_Buttons[BUTTON_HAO_REINSTALL],app.GetString(IDS_REINSTALL_CONTENT)); XuiControlSetText(m_Buttons[BUTTON_HAO_DEBUG],app.GetString(IDS_DEBUG_SETTINGS)); m_Timer.SetShow(FALSE); m_bIgnoreInput=false; #ifndef _FINAL_BUILD if(!app.DebugSettingsOn()) { m_Buttons[BUTTON_HAO_DEBUG].SetEnable(FALSE); m_Buttons[BUTTON_HAO_DEBUG].SetShow(FALSE); } else { m_Buttons[BUTTON_HAO_DEBUG].SetEnable(TRUE); m_Buttons[BUTTON_HAO_DEBUG].SetShow(TRUE); } #endif // 4J-PB - do not need a storage device to see this menu - just need one when you choose to re-install them // any content to be re-installed? if(app.GetTMSDLCInfoRead() && m_iPad==ProfileManager.GetPrimaryPad() && bNotInGame) { // We should show the reinstall menu app.DebugPrintf("Reinstall Menu required...\n"); m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(TRUE); m_Buttons[BUTTON_HAO_REINSTALL].SetShow(TRUE); } else { D3DXVECTOR3 vec; m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(FALSE); m_Buttons[BUTTON_HAO_REINSTALL].SetShow(FALSE); m_Buttons[BUTTON_HAO_REINSTALL].GetPosition(&vec); m_Buttons[BUTTON_HAO_DEBUG].SetPosition(&vec); } if(app.GetLocalPlayerCount()>1) { // no credits in splitscreen D3DXVECTOR3 vec,vec2; m_Buttons[BUTTON_HAO_CREDITS].GetPosition(&vec); m_Buttons[BUTTON_HAO_CREDITS].SetEnable(FALSE); m_Buttons[BUTTON_HAO_CREDITS].SetShow(FALSE); m_Buttons[BUTTON_HAO_RESETTODEFAULTS].GetPosition(&vec2); m_Buttons[BUTTON_HAO_RESETTODEFAULTS].SetPosition(&vec); m_Buttons[BUTTON_HAO_DEBUG].SetPosition(&vec2); app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad,false); CXuiSceneBase::ShowLogo( m_iPad, FALSE ); if(ProfileManager.GetPrimaryPad()!=m_iPad) { m_Buttons[BUTTON_HAO_DEBUG].SetEnable(FALSE); m_Buttons[BUTTON_HAO_DEBUG].SetShow(FALSE); } } else { if(bNotInGame) { CXuiSceneBase::ShowLogo( DEFAULT_XUI_MENU_USER, TRUE ); } else { CXuiSceneBase::ShowLogo( m_iPad, TRUE ); } } // Display the tooltips // if we're not in the game, we need to use basescene 0 if(bNotInGame) { ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); } else { ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); } XuiElementSetUserFocus(m_Buttons[BUTTON_HAO_HOWTOPLAY].m_hObj, m_iPad); return S_OK; } HRESULT CScene_HelpAndOptions::OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled) { pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); if(pControlNavigateData->hObjDest!=NULL) { bHandled=TRUE; } return S_OK; } //---------------------------------------------------------------------------------- // Handler for the button press message. //---------------------------------------------------------------------------------- HRESULT CScene_HelpAndOptions::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled) { // This assumes all buttons can only be pressed with the A button ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A); unsigned int uiButtonCounter=0; while((uiButtonCounterUserIndex,eUIScene_HowToPlayMenu); break; case BUTTON_HAO_CONTROLS: app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_ControlsMenu); break; case BUTTON_HAO_SETTINGS: app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_SettingsMenu); break; case BUTTON_HAO_CREDITS: app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_Credits); break; case BUTTON_HAO_RESETTODEFAULTS: { // check they really want to do this UINT uiIDA[2]; uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_CONFIRM_OK; StorageManager.RequestMessageBox(IDS_DEFAULTS_TITLE, IDS_DEFAULTS_TEXT, uiIDA, 2, pNotifyPressData->UserIndex,&CScene_HelpAndOptions::ResetDefaultsDialogReturned,this, app.GetStringTable()); } break; case BUTTON_HAO_DEBUG: app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_DebugOptions); break; default: break; } return S_OK; } HRESULT CScene_HelpAndOptions::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled) { if(m_bIgnoreInput) return S_OK; // ignore a held down key to avoid skipping this scene if the user changes a setting and presses B for slightly too long if((pInputData->dwFlags&XUI_INPUT_FLAG_REPEAT)&&(pInputData->dwKeyCode==VK_PAD_B)) { return S_OK; } ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode); switch(pInputData->dwKeyCode) { case VK_PAD_B: case VK_ESCAPE: BYTE userIndex = pInputData->UserIndex; if( !app.IsPauseMenuDisplayed(userIndex) ) { // If we are not from a pause menu, then we are from the main menu userIndex = XUSER_INDEX_ANY; } app.NavigateBack(userIndex); rfHandled = TRUE; break; } return S_OK; } HRESULT CScene_HelpAndOptions::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled) { bool bNotInGame=(Minecraft::GetInstance()->level==NULL); if(bNotInGame) { ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); CXuiSceneBase::ShowLogo( DEFAULT_XUI_MENU_USER, TRUE ); } else { ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); if(app.GetLocalPlayerCount()>1) { CXuiSceneBase::ShowLogo( m_iPad, FALSE ); } else { CXuiSceneBase::ShowLogo( m_iPad, TRUE ); } } return S_OK; } int CScene_HelpAndOptions::ResetDefaultsDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { //CScene_SettingsAll* pClass = (CScene_SettingsAll*)pParam; // results switched for this dialog if(result==C4JStorage::EMessage_ResultDecline) { app.SetDefaultOptions(ProfileManager.GetDashboardProfileSettings(iPad),iPad); // if the profile data has been changed, then force a profile write // It seems we're allowed to break the 5 minute rule if it's the result of a user action app.CheckGameSettingsChanged(true,iPad); } return 0; } HRESULT CScene_HelpAndOptions::OnTransitionStart( XUIMessageTransition *pTransition, BOOL& bHandled ) { if(pTransition->dwTransAction==XUI_TRANSITION_ACTION_DESTROY ) return S_OK; if(pTransition->dwTransType == XUI_TRANSITION_TO || pTransition->dwTransType == XUI_TRANSITION_BACKTO) { // 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) XUIRect xuiRect; HXUIOBJ visual=NULL; HXUIOBJ text; float fMaxTextLen=0.0f; float fTextVisualLen; float fMaxButton; float fWidth,fHeight; HRESULT hr=XuiControlGetVisual(m_Buttons[0].m_hObj,&visual); hr=XuiElementGetChildById(visual,L"text_Label",&text); hr=XuiElementGetBounds(text,&fTextVisualLen,&fHeight); m_Buttons[0].GetBounds(&fMaxButton,&fHeight); for(int i=0;ifMaxTextLen) fMaxTextLen=xuiRect.right; } if(fTextVisualLen