// Minecraft.cpp : Defines the entry point for the application. // #include "stdafx.h" #include #include "XUI_Debug.h" #include "..\..\..\Minecraft.Client\StatsCounter.h" LPCWSTR CScene_Debug::m_DebugCheckboxTextA[eDebugSetting_Max+1]= { L"Load Saves From Local Folder Mode", L"Write Saves To Local Folder Mode", L"Freeze Players", //L"Not Used", L"Display Safe Area", L"Mobs don't attack", L"Freeze Time", L"Disable Weather", L"Craft Anything", L"Use DPad for debug", L"Mobs don't tick", L"Instant Mine", L"Show UI Console", L"Distributable Save", L"Debug Leaderboards", L"Height-Water-Biome Maps", L"Superflat nether", //L"Light/Dark background", L"More lightning when thundering", L"", }; LPCWSTR CScene_Debug::m_DebugButtonTextA[eDebugButton_Max+1]= { L"Award Theme", L"Award Avatar Item 1", L"Award Avatar Item 2", L"Award Avatar Item 3", L"Award Gamerpic 1", L"Award Gamerpic 2", L"Check Tips", L"Wipe Leaderboards", L"", }; //---------------------------------------------------------------------------------- // Performs initialization tasks - retrieves controls. //---------------------------------------------------------------------------------- HRESULT CScene_Debug::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { m_iPad=*(int *)pInitData->pvInitData; // set text and enable any debug options required int iCheckboxIndex=0; int iButtonIndex=0; float fWidth=500.0f; float fX=240.0f; float fY=200.0f; float fYInc=5.0f; float fControlHeight=25.0f; if((!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()) || app.GetLocalPlayerCount()>1) { fWidth=250.0f; fX=30.0f; fY=30.0f; fYInc=5.0f; fControlHeight=15.0f; } CXuiCheckbox *pCheckbox; CXuiControl *pButton; m_iTotalCheckboxElements=0; m_iTotalButtonElements=0; m_bOnCheckboxes=true; // count the items while((*m_DebugCheckboxTextA[m_iTotalCheckboxElements])!=0) { m_iTotalCheckboxElements++; } m_DebugCheckboxDataA= new DEBUGDATA [m_iTotalCheckboxElements]; while((*m_DebugCheckboxTextA[iCheckboxIndex])!=0) { XuiCreateObject( XUI_CLASS_CHECKBOX, &m_DebugCheckboxDataA[iCheckboxIndex].hXuiObj ); XuiObjectFromHandle( m_DebugCheckboxDataA[iCheckboxIndex].hXuiObj, &m_DebugCheckboxDataA[iCheckboxIndex].pvData ); pCheckbox = (CXuiCheckbox *)m_DebugCheckboxDataA[iCheckboxIndex].pvData; //m_phXuiObjA[iElementIndex] = pCheckbox->m_hObj; pCheckbox->SetText(m_DebugCheckboxTextA[iCheckboxIndex]); pCheckbox->SetShow(TRUE); D3DXVECTOR3 vPos; float tx,ty; pCheckbox->GetBounds(&tx,&ty); pCheckbox->SetBounds(fWidth,fControlHeight); vPos.x=fX; vPos.y=fY; vPos.z=0.0f; pCheckbox->SetPosition(&vPos); fY+=fControlHeight+fYInc; XuiElementAddChild(m_hObj,m_DebugCheckboxDataA[iCheckboxIndex].hXuiObj); iCheckboxIndex++; } // and the buttons if((!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())|| app.GetLocalPlayerCount()>1) { fWidth=260.0f; fX=300.0f; fY=30.0f; fControlHeight=40.0f; } else { fWidth=350.0f; fX=750.0f; fY=200.0f; fControlHeight=40.0f; } while((*m_DebugButtonTextA[m_iTotalButtonElements])!=0) { m_iTotalButtonElements++; } m_DebugButtonDataA= new DEBUGDATA [m_iTotalButtonElements]; while((*m_DebugButtonTextA[iButtonIndex])!=0) { XuiCreateObject( XUI_CLASS_BUTTON, &m_DebugButtonDataA[iButtonIndex].hXuiObj ); XuiObjectFromHandle( m_DebugButtonDataA[iButtonIndex].hXuiObj, &m_DebugButtonDataA[iButtonIndex].pvData ); pButton = (CXuiControl *)m_DebugButtonDataA[iButtonIndex].pvData; //m_phXuiObjA[iElementIndex] = pCheckbox->m_hObj; pButton->SetText(m_DebugButtonTextA[iButtonIndex]); pButton->SetShow(TRUE); D3DXVECTOR3 vPos; float tx,ty; pButton->GetBounds(&tx,&ty); pButton->SetBounds(fWidth,fControlHeight); vPos.x=fX; vPos.y=fY; vPos.z=0.0f; pButton->SetPosition(&vPos); fY+=fControlHeight+fYInc; XuiElementAddChild(m_hObj,m_DebugButtonDataA[iButtonIndex].hXuiObj); // if you're not the primary player, disable all these - you need a storage device for them if(ProfileManager.GetPrimaryPad()!=m_iPad) { XuiControlSetEnable(m_DebugButtonDataA[iButtonIndex].hXuiObj,FALSE); } iButtonIndex++; } unsigned int uiDebugBitmask=app.GetGameSettingsDebugMask(m_iPad); for(int i=0;iSetCheck( (uiDebugBitmask&(1<UserIndex, pInputData->dwKeyCode); HRESULT hr=S_OK; int iCurrentBitmaskIndex=0; unsigned int uiDebugBitmask=0L; // Explicitly handle X button presses if (pInputData->dwKeyCode == VK_PAD_B) { // check all the settings for(int i=0;iIsChecked()?(1<UserIndex)) { app.SetGameSettingsDebugMask(pInputData->UserIndex,uiDebugBitmask); if(app.DebugSettingsOn()) { app.ActionDebugMask(pInputData->UserIndex); } else { // force debug mask off app.ActionDebugMask(pInputData->UserIndex,true); } app.CheckGameSettingsChanged(true,pInputData->UserIndex); } app.NavigateBack(pInputData->UserIndex); rfHandled = TRUE; } return hr; } HRESULT CScene_Debug::OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled) { if(m_bOnCheckboxes) { // If it's not from the current control, ignore it if(m_DebugCheckboxDataA[m_iCurrentCheckboxElement].hXuiObj!=pControlNavigateData->hObjSource) return S_OK; switch(pControlNavigateData->nControlNavigate) { case XUI_CONTROL_NAVIGATE_UP: if(m_iCurrentCheckboxElement>0) { m_iCurrentCheckboxElement--; XuiElementSetUserFocus(m_DebugCheckboxDataA[m_iCurrentCheckboxElement].hXuiObj, m_iPad); } break; case XUI_CONTROL_NAVIGATE_DOWN: if((m_iCurrentCheckboxElement+1)hObjSource) return S_OK; switch(pControlNavigateData->nControlNavigate) { case XUI_CONTROL_NAVIGATE_UP: if(m_iCurrentButtonElement>0) { m_iCurrentButtonElement--; XuiElementSetUserFocus(m_DebugButtonDataA[m_iCurrentButtonElement].hXuiObj, m_iPad); } break; case XUI_CONTROL_NAVIGATE_DOWN: if((m_iCurrentButtonElement+1)UserIndex, VK_PAD_A); int iButton=0; while((iButtonUserIndex, eAward_socialPost ); break; case eDebugButton_Avatar_Item_1: ProfileManager.Award( pNotifyPressData->UserIndex, eAward_eatPorkChop ); break; case eDebugButton_Avatar_Item_2: ProfileManager.Award( pNotifyPressData->UserIndex, eAward_play100Days ); break; case eDebugButton_Avatar_Item_3: ProfileManager.Award( pNotifyPressData->UserIndex, eAward_arrowKillCreeper ); break; case eDebugButton_Gamerpic_1: ProfileManager.Award( pNotifyPressData->UserIndex, eAward_mine100Blocks ); break; case eDebugButton_Gamerpic_2: ProfileManager.Award( pNotifyPressData->UserIndex, eAward_kill10Creepers ); break; case eDebugButton_CheckTips: app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_DebugTips); break; case eDebugButton_WipeLeaderboards: #ifdef _DEBUG // commenting out so it doesn't get done by mistake // Minecraft::GetInstance()->stats[pNotifyPressData->UserIndex]->WipeLeaderboards(); #endif break; } return S_OK; }