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#include "..\XUI\XUI_SettingsAll.h"
6
7//----------------------------------------------------------------------------------
8// Performs initialization tasks - retrieves controls.
9//----------------------------------------------------------------------------------
10HRESULT CScene_SettingsAll::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
11{
12 //WCHAR TempString[256];
13 m_iPad=*(int *)pInitData->pvInitData;
14 // if we're not in the game, we need to use basescene 0
15 bool bNotInGame=(Minecraft::GetInstance()->level==NULL);
16
17 MapChildControls();
18
19 XuiControlSetText(m_Buttons[BUTTON_ALL_OPTIONS],app.GetString(IDS_OPTIONS));
20 XuiControlSetText(m_Buttons[BUTTON_ALL_AUDIO],app.GetString(IDS_AUDIO));
21 XuiControlSetText(m_Buttons[BUTTON_ALL_CONTROL],app.GetString(IDS_CONTROL));
22 XuiControlSetText(m_Buttons[BUTTON_ALL_GRAPHICS],app.GetString(IDS_GRAPHICS));
23 XuiControlSetText(m_Buttons[BUTTON_ALL_UI],app.GetString(IDS_USER_INTERFACE));
24 XuiControlSetText(m_Buttons[BUTTON_ALL_RESETTODEFAULTS],app.GetString(IDS_RESET_TO_DEFAULTS));
25
26 if(ProfileManager.GetPrimaryPad()!=m_iPad)
27 {
28 D3DXVECTOR3 vec,vecControl;
29 m_Buttons[BUTTON_ALL_AUDIO].SetShow(FALSE);
30 m_Buttons[BUTTON_ALL_AUDIO].SetEnable(FALSE);
31 m_Buttons[BUTTON_ALL_GRAPHICS].SetShow(FALSE);
32 m_Buttons[BUTTON_ALL_GRAPHICS].SetEnable(FALSE);
33
34 float fButtonWidth, fButtonHeight;
35 m_Buttons[BUTTON_ALL_GRAPHICS].GetPosition(&vecControl);
36 m_Buttons[BUTTON_ALL_RESETTODEFAULTS].GetBounds(&fButtonWidth, &fButtonHeight);
37 m_Buttons[BUTTON_ALL_RESETTODEFAULTS].SetPosition(&vecControl);
38
39 m_Buttons[BUTTON_ALL_CONTROL].GetPosition(&vec);
40 m_Buttons[BUTTON_ALL_UI].SetPosition(&vec);
41
42 m_Buttons[BUTTON_ALL_AUDIO].GetPosition(&vec);
43 m_Buttons[BUTTON_ALL_CONTROL].SetPosition(&vec);
44
45 // Resize the whole scene
46 float fWidth, fHeight;
47 GetBounds(&fWidth, &fHeight);
48 SetBounds(fWidth, vecControl.y+fButtonHeight);
49 }
50
51 // if we're not in the game, we need to use basescene 0
52 if(bNotInGame)
53 {
54 ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
55 CXuiSceneBase::ShowBackground( DEFAULT_XUI_MENU_USER, TRUE );
56 }
57 else
58 {
59 ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
60 CXuiSceneBase::ShowBackground( m_iPad, FALSE );
61 }
62
63 if(app.GetLocalPlayerCount()>1)
64 {
65 app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad,false);
66 CXuiSceneBase::ShowLogo( m_iPad, FALSE );
67 }
68 else
69 {
70 if(bNotInGame)
71 {
72 CXuiSceneBase::ShowLogo( DEFAULT_XUI_MENU_USER, TRUE );
73 }
74 else
75 {
76 CXuiSceneBase::ShowLogo( m_iPad, TRUE );
77 }
78 }
79
80 return S_OK;
81}
82
83
84
85
86HRESULT CScene_SettingsAll::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
87{
88 ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
89
90 HRESULT hr=S_OK;
91
92 // Explicitly handle B button presses
93 switch(pInputData->dwKeyCode)
94 {
95 case VK_PAD_B:
96 case VK_ESCAPE:
97 // if the profile data has been changed, then force a profile write
98 // It seems we're allowed to break the 5 minute rule if it's the result of a user action
99
100 app.CheckGameSettingsChanged(true,pInputData->UserIndex);
101
102 app.NavigateBack(pInputData->UserIndex);
103 rfHandled = TRUE;
104 break;
105 }
106
107 return hr;
108}
109
110HRESULT CScene_SettingsAll::OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled)
111{
112 // added so we can skip greyed out items
113 pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE);
114
115 if(pControlNavigateData->hObjDest!=NULL)
116 {
117 bHandled=TRUE;
118 }
119
120 return S_OK;
121}
122
123HRESULT CScene_SettingsAll::OnTransitionStart( XUIMessageTransition *pTransition, BOOL& bHandled )
124{
125 //HRESULT hr;
126 if(pTransition->dwTransAction==XUI_TRANSITION_ACTION_DESTROY ) return S_OK;
127
128 if(pTransition->dwTransType == XUI_TRANSITION_TO || pTransition->dwTransType == XUI_TRANSITION_BACKTO)
129 {
130 // 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)
131 }
132
133 return S_OK;
134}
135
136//----------------------------------------------------------------------------------
137// Handler for the button press message.
138//----------------------------------------------------------------------------------
139HRESULT CScene_SettingsAll::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
140{
141 // This assumes all buttons can only be pressed with the A button
142 ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
143
144 unsigned int uiButtonCounter=0;
145
146 while((uiButtonCounter<BUTTONS_ALL_MAX) && (m_Buttons[uiButtonCounter]!=hObjPressed)) uiButtonCounter++;
147
148 switch(uiButtonCounter)
149 {
150 case BUTTON_ALL_OPTIONS:
151 app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_SettingsOptionsMenu);
152 break;
153 case BUTTON_ALL_AUDIO:
154 app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_SettingsAudioMenu);
155 break;
156 case BUTTON_ALL_CONTROL:
157 app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_SettingsControlMenu);
158 break;
159 case BUTTON_ALL_GRAPHICS:
160 app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_SettingsGraphicsMenu);
161 break;
162 case BUTTON_ALL_UI:
163 app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_SettingsUIMenu);
164 break;
165 case BUTTON_ALL_RESETTODEFAULTS:
166 {
167 // check they really want to do this
168 UINT uiIDA[2];
169 uiIDA[0]=IDS_CONFIRM_CANCEL;
170 uiIDA[1]=IDS_CONFIRM_OK;
171
172 StorageManager.RequestMessageBox(IDS_DEFAULTS_TITLE, IDS_DEFAULTS_TEXT, uiIDA, 2, pNotifyPressData->UserIndex,&CScene_SettingsAll::ResetDefaultsDialogReturned,this, app.GetStringTable());
173 }
174 break;
175
176 }
177
178 rfHandled=TRUE;
179 return S_OK;
180}
181
182HRESULT CScene_SettingsAll::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled)
183{
184 bool bNotInGame=(Minecraft::GetInstance()->level==NULL);
185
186 // if we're not in the game, we need to use basescene 0
187 if(bNotInGame)
188 {
189 ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
190 CXuiSceneBase::ShowLogo( DEFAULT_XUI_MENU_USER, TRUE );
191 }
192 else
193 {
194 ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
195 if(!RenderManager.IsHiDef() || app.GetLocalPlayerCount()>1)
196 {
197 CXuiSceneBase::ShowLogo( m_iPad, FALSE );
198 }
199 else
200 {
201 CXuiSceneBase::ShowLogo( m_iPad, TRUE );
202 }
203 }
204
205 return S_OK;
206}
207
208HRESULT CScene_SettingsAll::OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled)
209{
210 bHandled=true;
211 return app.AdjustSplitscreenScene_PlayerChanged(m_hObj,&m_OriginalPosition,m_iPad,bJoining);
212}
213
214int CScene_SettingsAll::ResetDefaultsDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
215{
216 //CScene_SettingsAll* pClass = (CScene_SettingsAll*)pParam;
217
218 // results switched for this dialog
219 if(result==C4JStorage::EMessage_ResultDecline)
220 {
221 app.SetDefaultOptions(ProfileManager.GetDashboardProfileSettings(iPad),iPad);
222 // if the profile data has been changed, then force a profile write
223 // It seems we're allowed to break the 5 minute rule if it's the result of a user action
224 app.CheckGameSettingsChanged(true,iPad);
225 }
226 return 0;
227}