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
6#include <assert.h>
7#include "XUI_Debug.h"
8#include "..\..\..\Minecraft.Client\StatsCounter.h"
9
10LPCWSTR CScene_Debug::m_DebugCheckboxTextA[eDebugSetting_Max+1]=
11{
12 L"Load Saves From Local Folder Mode",
13 L"Write Saves To Local Folder Mode",
14 L"Freeze Players", //L"Not Used",
15 L"Display Safe Area",
16 L"Mobs don't attack",
17 L"Freeze Time",
18 L"Disable Weather",
19 L"Craft Anything",
20 L"Use DPad for debug",
21 L"Mobs don't tick",
22 L"Instant Mine",
23 L"Show UI Console",
24 L"Distributable Save",
25 L"Debug Leaderboards",
26 L"Height-Water-Biome Maps",
27 L"Superflat nether",
28 //L"Light/Dark background",
29 L"More lightning when thundering",
30 L"",
31};
32
33LPCWSTR CScene_Debug::m_DebugButtonTextA[eDebugButton_Max+1]=
34{
35 L"Award Theme",
36 L"Award Avatar Item 1",
37 L"Award Avatar Item 2",
38 L"Award Avatar Item 3",
39 L"Award Gamerpic 1",
40 L"Award Gamerpic 2",
41 L"Check Tips",
42 L"Wipe Leaderboards",
43 L"",
44};
45
46
47
48//----------------------------------------------------------------------------------
49// Performs initialization tasks - retrieves controls.
50//----------------------------------------------------------------------------------
51HRESULT CScene_Debug::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
52{
53 m_iPad=*(int *)pInitData->pvInitData;
54
55 // set text and enable any debug options required
56 int iCheckboxIndex=0;
57 int iButtonIndex=0;
58 float fWidth=500.0f;
59 float fX=240.0f;
60 float fY=200.0f;
61 float fYInc=5.0f;
62 float fControlHeight=25.0f;
63
64 if((!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()) || app.GetLocalPlayerCount()>1)
65 {
66 fWidth=250.0f;
67 fX=30.0f;
68 fY=30.0f;
69 fYInc=5.0f;
70 fControlHeight=15.0f;
71 }
72
73 CXuiCheckbox *pCheckbox;
74 CXuiControl *pButton;
75 m_iTotalCheckboxElements=0;
76 m_iTotalButtonElements=0;
77 m_bOnCheckboxes=true;
78
79 // count the items
80 while((*m_DebugCheckboxTextA[m_iTotalCheckboxElements])!=0)
81 {
82 m_iTotalCheckboxElements++;
83 }
84
85 m_DebugCheckboxDataA= new DEBUGDATA [m_iTotalCheckboxElements];
86
87 while((*m_DebugCheckboxTextA[iCheckboxIndex])!=0)
88 {
89 XuiCreateObject( XUI_CLASS_CHECKBOX, &m_DebugCheckboxDataA[iCheckboxIndex].hXuiObj );
90 XuiObjectFromHandle( m_DebugCheckboxDataA[iCheckboxIndex].hXuiObj, &m_DebugCheckboxDataA[iCheckboxIndex].pvData );
91
92 pCheckbox = (CXuiCheckbox *)m_DebugCheckboxDataA[iCheckboxIndex].pvData;
93 //m_phXuiObjA[iElementIndex] = pCheckbox->m_hObj;
94 pCheckbox->SetText(m_DebugCheckboxTextA[iCheckboxIndex]);
95 pCheckbox->SetShow(TRUE);
96
97 D3DXVECTOR3 vPos;
98 float tx,ty;
99 pCheckbox->GetBounds(&tx,&ty);
100 pCheckbox->SetBounds(fWidth,fControlHeight);
101 vPos.x=fX;
102 vPos.y=fY;
103 vPos.z=0.0f;
104 pCheckbox->SetPosition(&vPos);
105 fY+=fControlHeight+fYInc;
106
107 XuiElementAddChild(m_hObj,m_DebugCheckboxDataA[iCheckboxIndex].hXuiObj);
108
109 iCheckboxIndex++;
110 }
111
112 // and the buttons
113 if((!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())|| app.GetLocalPlayerCount()>1)
114 {
115 fWidth=260.0f;
116 fX=300.0f;
117 fY=30.0f;
118 fControlHeight=40.0f;
119 }
120 else
121 {
122 fWidth=350.0f;
123 fX=750.0f;
124 fY=200.0f;
125 fControlHeight=40.0f;
126 }
127
128
129
130 while((*m_DebugButtonTextA[m_iTotalButtonElements])!=0)
131 {
132 m_iTotalButtonElements++;
133 }
134
135 m_DebugButtonDataA= new DEBUGDATA [m_iTotalButtonElements];
136
137 while((*m_DebugButtonTextA[iButtonIndex])!=0)
138 {
139 XuiCreateObject( XUI_CLASS_BUTTON, &m_DebugButtonDataA[iButtonIndex].hXuiObj );
140 XuiObjectFromHandle( m_DebugButtonDataA[iButtonIndex].hXuiObj, &m_DebugButtonDataA[iButtonIndex].pvData );
141
142 pButton = (CXuiControl *)m_DebugButtonDataA[iButtonIndex].pvData;
143 //m_phXuiObjA[iElementIndex] = pCheckbox->m_hObj;
144 pButton->SetText(m_DebugButtonTextA[iButtonIndex]);
145 pButton->SetShow(TRUE);
146
147 D3DXVECTOR3 vPos;
148 float tx,ty;
149 pButton->GetBounds(&tx,&ty);
150 pButton->SetBounds(fWidth,fControlHeight);
151 vPos.x=fX;
152 vPos.y=fY;
153 vPos.z=0.0f;
154 pButton->SetPosition(&vPos);
155 fY+=fControlHeight+fYInc;
156
157 XuiElementAddChild(m_hObj,m_DebugButtonDataA[iButtonIndex].hXuiObj);
158
159 // if you're not the primary player, disable all these - you need a storage device for them
160
161 if(ProfileManager.GetPrimaryPad()!=m_iPad)
162 {
163 XuiControlSetEnable(m_DebugButtonDataA[iButtonIndex].hXuiObj,FALSE);
164 }
165 iButtonIndex++;
166 }
167
168
169
170 unsigned int uiDebugBitmask=app.GetGameSettingsDebugMask(m_iPad);
171
172 for(int i=0;i<iCheckboxIndex;i++)
173 {
174 CXuiCheckbox *pCheckbox = (CXuiCheckbox *)m_DebugCheckboxDataA[i].pvData;
175 pCheckbox->SetCheck( (uiDebugBitmask&(1<<i)) ?TRUE:FALSE);
176 }
177
178
179 if(m_DebugCheckboxDataA[0].hXuiObj)
180 {
181 XuiElementSetUserFocus(m_DebugCheckboxDataA[0].hXuiObj,m_iPad);
182 }
183
184 m_iCurrentCheckboxElement=0;
185 m_iCurrentButtonElement=0;
186
187#ifdef _DEBUG
188 // testing the upload of the player custom skin
189// wstring wsTemp;
190//
191// wsTemp=L"Deadmau5_Skin.png";
192// app.UploadFileToGlobalStorage(m_iPad,C4JStorage::eGlobalStorage_TitleUser,&wsTemp);
193// wsTemp=L"Mojang_Cape.png";
194// app.UploadFileToGlobalStorage(m_iPad,C4JStorage::eGlobalStorage_TitleUser,&wsTemp);
195// wsTemp=L"4J_Cape.png";
196// app.UploadFileToGlobalStorage(m_iPad,C4JStorage::eGlobalStorage_TitleUser,&wsTemp);
197#endif
198
199 return S_OK;
200}
201
202HRESULT CScene_Debug::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
203{
204 ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
205
206 HRESULT hr=S_OK;
207 int iCurrentBitmaskIndex=0;
208 unsigned int uiDebugBitmask=0L;
209
210 // Explicitly handle X button presses
211 if (pInputData->dwKeyCode == VK_PAD_B)
212 {
213 // check all the settings
214 for(int i=0;i<m_iTotalCheckboxElements;i++)
215 {
216 CXuiCheckbox *pCheckbox = (CXuiCheckbox *)m_DebugCheckboxDataA[i].pvData;
217 uiDebugBitmask|=pCheckbox->IsChecked()?(1<<iCurrentBitmaskIndex):0;
218 iCurrentBitmaskIndex++;
219 }
220
221 if(uiDebugBitmask!=app.GetGameSettingsDebugMask(pInputData->UserIndex))
222 {
223 app.SetGameSettingsDebugMask(pInputData->UserIndex,uiDebugBitmask);
224 if(app.DebugSettingsOn())
225 {
226 app.ActionDebugMask(pInputData->UserIndex);
227 }
228 else
229 {
230 // force debug mask off
231 app.ActionDebugMask(pInputData->UserIndex,true);
232 }
233
234 app.CheckGameSettingsChanged(true,pInputData->UserIndex);
235 }
236 app.NavigateBack(pInputData->UserIndex);
237 rfHandled = TRUE;
238 }
239
240
241 return hr;
242}
243
244
245HRESULT CScene_Debug::OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled)
246{
247 if(m_bOnCheckboxes)
248 {
249 // If it's not from the current control, ignore it
250 if(m_DebugCheckboxDataA[m_iCurrentCheckboxElement].hXuiObj!=pControlNavigateData->hObjSource) return S_OK;
251
252 switch(pControlNavigateData->nControlNavigate)
253 {
254 case XUI_CONTROL_NAVIGATE_UP:
255 if(m_iCurrentCheckboxElement>0)
256 {
257 m_iCurrentCheckboxElement--;
258 XuiElementSetUserFocus(m_DebugCheckboxDataA[m_iCurrentCheckboxElement].hXuiObj, m_iPad);
259 }
260 break;
261 case XUI_CONTROL_NAVIGATE_DOWN:
262 if((m_iCurrentCheckboxElement+1)<m_iTotalCheckboxElements)
263 {
264 m_iCurrentCheckboxElement++;
265 XuiElementSetUserFocus(m_DebugCheckboxDataA[m_iCurrentCheckboxElement].hXuiObj, m_iPad);
266 }
267 break;
268 case XUI_CONTROL_NAVIGATE_RIGHT:
269 m_bOnCheckboxes=false;
270 if(m_iCurrentCheckboxElement<m_iTotalButtonElements)
271 {
272 m_iCurrentButtonElement=m_iCurrentCheckboxElement;
273 }
274 XuiElementSetUserFocus(m_DebugButtonDataA[m_iCurrentButtonElement].hXuiObj, m_iPad);
275 break;
276 }
277 }
278 else
279 {
280 // If it's not from the current control, ignore it
281 if(m_DebugButtonDataA[m_iCurrentButtonElement].hXuiObj!=pControlNavigateData->hObjSource) return S_OK;
282
283 switch(pControlNavigateData->nControlNavigate)
284 {
285 case XUI_CONTROL_NAVIGATE_UP:
286 if(m_iCurrentButtonElement>0)
287 {
288 m_iCurrentButtonElement--;
289 XuiElementSetUserFocus(m_DebugButtonDataA[m_iCurrentButtonElement].hXuiObj, m_iPad);
290 }
291 break;
292 case XUI_CONTROL_NAVIGATE_DOWN:
293 if((m_iCurrentButtonElement+1)<m_iTotalButtonElements)
294 {
295 m_iCurrentButtonElement++;
296 XuiElementSetUserFocus(m_DebugButtonDataA[m_iCurrentButtonElement].hXuiObj, m_iPad);
297 }
298 break;
299
300 case XUI_CONTROL_NAVIGATE_LEFT:
301 m_bOnCheckboxes=true;
302 if(m_iCurrentButtonElement<m_iTotalCheckboxElements)
303 {
304 m_iCurrentCheckboxElement=m_iCurrentButtonElement;
305 }
306 XuiElementSetUserFocus(m_DebugCheckboxDataA[m_iCurrentCheckboxElement].hXuiObj, m_iPad);
307 break;
308 }
309 }
310
311
312
313 return S_OK;
314}
315//----------------------------------------------------------------------------------
316// Updates the UI when the list selection changes.
317//----------------------------------------------------------------------------------
318HRESULT CScene_Debug::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyValueChanged* pNotifyValueChanged, BOOL& bHandled )
319{
320
321 return S_OK;
322}
323//----------------------------------------------------------------------------------
324// Updates the UI when the list selection changes.
325//----------------------------------------------------------------------------------
326HRESULT CScene_Debug::OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled )
327{
328
329
330 return S_OK;
331}
332
333//----------------------------------------------------------------------------------
334// Handler for the button press message.
335//----------------------------------------------------------------------------------
336HRESULT CScene_Debug::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
337{
338 // This assumes all buttons can only be pressed with the A button
339 ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
340
341 int iButton=0;
342
343 while((iButton<m_iTotalButtonElements) && m_DebugButtonDataA[iButton].hXuiObj!=hObjPressed)
344 {
345 iButton++;
346 }
347
348 if(iButton==m_iTotalButtonElements)
349 {
350 // it's not a button then
351 return S_OK;
352 }
353
354 // you need to be the primary player to be able to earn these, since you need a storage device
355
356 switch(iButton)
357 {
358 case eDebugButton_Theme:
359 ProfileManager.Award( pNotifyPressData->UserIndex, eAward_socialPost );
360 break;
361 case eDebugButton_Avatar_Item_1:
362 ProfileManager.Award( pNotifyPressData->UserIndex, eAward_eatPorkChop );
363 break;
364 case eDebugButton_Avatar_Item_2:
365 ProfileManager.Award( pNotifyPressData->UserIndex, eAward_play100Days );
366 break;
367 case eDebugButton_Avatar_Item_3:
368 ProfileManager.Award( pNotifyPressData->UserIndex, eAward_arrowKillCreeper );
369 break;
370 case eDebugButton_Gamerpic_1:
371 ProfileManager.Award( pNotifyPressData->UserIndex, eAward_mine100Blocks );
372 break;
373 case eDebugButton_Gamerpic_2:
374 ProfileManager.Award( pNotifyPressData->UserIndex, eAward_kill10Creepers );
375 break;
376 case eDebugButton_CheckTips:
377 app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_DebugTips);
378 break;
379
380 case eDebugButton_WipeLeaderboards:
381#ifdef _DEBUG
382// commenting out so it doesn't get done by mistake
383// Minecraft::GetInstance()->stats[pNotifyPressData->UserIndex]->WipeLeaderboards();
384#endif
385 break;
386
387 }
388
389 return S_OK;
390}
391