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 "..\..\Minecraft.h"
8#include "..\..\..\Minecraft.World\DisconnectPacket.h"
9
10//----------------------------------------------------------------------------------
11// Performs initialization tasks - retrieves controls.
12//----------------------------------------------------------------------------------
13HRESULT CScene_ConnectingProgress::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
14{
15 ConnectionProgressParams *param = (ConnectionProgressParams *)pInitData->pvInitData;
16 m_iPad = param->iPad;
17 MapChildControls();
18
19 if( param->stringId >= 0 )
20 {
21 m_title.SetText( app.GetString( param->stringId ) );
22 }
23 else
24 {
25 m_title.SetText( L"" );
26 }
27
28 m_buttonConfirm.SetText( app.GetString( IDS_CONFIRM_OK ) );
29
30 if(app.GetLocalPlayerCount()>1)
31 {
32 app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad,false);
33 }
34
35 CXuiSceneBase::ShowBackground( m_iPad, TRUE );
36 CXuiSceneBase::ShowLogo( m_iPad, TRUE );
37
38 m_showTooltips = param->showTooltips;
39 if( param->showTooltips )
40 ui.SetTooltips( m_iPad, -1, IDS_TOOLTIPS_CANCEL_JOIN, -1, -1 );
41 else
42 ui.SetTooltips( m_iPad, -1 );
43
44 m_runFailTimer = param->setFailTimer;
45 m_timerTime = param->timerTime;
46
47 return S_OK;
48}
49
50// The framework calls this handler when the object is to be destroyed.
51HRESULT CScene_ConnectingProgress::OnDestroy()
52{
53 return S_OK;
54}
55
56//----------------------------------------------------------------------------------
57// Updates the UI when the list selection changes.
58//----------------------------------------------------------------------------------
59HRESULT CScene_ConnectingProgress::OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled )
60{
61 return S_OK;
62}
63
64//----------------------------------------------------------------------------------
65// Handler for the button press message.
66//----------------------------------------------------------------------------------
67HRESULT CScene_ConnectingProgress::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
68{
69 // This assumes all buttons can only be pressed with the A button
70 ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
71
72 if(hObjPressed == m_buttonConfirm)
73 {
74 if( m_iPad != ProfileManager.GetPrimaryPad() && g_NetworkManager.IsInSession() )
75 {
76 // The connection failed if we see the button, so the temp player should be removed and the viewports updated again
77 Minecraft *pMinecraft = Minecraft::GetInstance();
78 pMinecraft->removeLocalPlayerIdx(m_iPad);
79 }
80 else
81 {
82 app.NavigateToHomeMenu();
83 //app.NavigateBack( ProfileManager.GetPrimaryPad() );
84 }
85 }
86
87 return S_OK;
88}
89
90HRESULT CScene_ConnectingProgress::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
91{
92 if( m_showTooltips )
93 {
94 ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
95
96 // Explicitly handle B button presses
97 if (pInputData->dwKeyCode == VK_PAD_B)
98 {
99 // Cancel the join
100 Minecraft *pMinecraft = Minecraft::GetInstance();
101 pMinecraft->removeLocalPlayerIdx(m_iPad);
102 rfHandled = TRUE;
103 }
104 }
105 return S_OK;
106}
107
108HRESULT CScene_ConnectingProgress::OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled)
109{
110 // This gets called every frame, so use it to update our two text boxes
111
112 return S_OK;
113}
114
115HRESULT CScene_ConnectingProgress::OnTransitionStart( XUIMessageTransition *pTransition, BOOL& bHandled )
116{
117 //if(m_runFailTimer) XuiSetTimer(m_hObj,0,m_timerTime);
118 if( pTransition->dwTransType == XUI_TRANSITION_FROM )
119 {
120 XuiKillTimer(m_hObj,0);
121 }
122
123 return S_OK;
124}
125
126HRESULT CScene_ConnectingProgress::OnTransitionEnd( XUIMessageTransition *pTransition, BOOL& bHandled )
127{
128 // are we being destroyed? If so, don't do anything
129 if(pTransition->dwTransAction==XUI_TRANSITION_ACTION_DESTROY )
130 {
131 return S_OK;
132 }
133
134 if( pTransition->dwTransType == XUI_TRANSITION_TO )
135 {
136 if(m_runFailTimer) XuiSetTimer(m_hObj,0,m_timerTime);
137 }
138
139 return S_OK;
140}
141
142HRESULT CScene_ConnectingProgress::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled )
143{
144 // Check if the connection failed
145 Minecraft *pMinecraft = Minecraft::GetInstance();
146
147 if( pMinecraft->m_connectionFailed[m_iPad] || !g_NetworkManager.IsInSession() )
148 {
149 app.RemoveBackScene(m_iPad);
150
151 // 4J-PB - timers auto repeat, so kill it
152 XuiKillTimer(m_hObj,0);
153
154 int exitReasonStringId;
155 switch(pMinecraft->m_connectionFailedReason[m_iPad])
156 {
157 case DisconnectPacket::eDisconnect_LoginTooLong:
158 exitReasonStringId = IDS_DISCONNECTED_LOGIN_TOO_LONG;
159 break;
160 case DisconnectPacket::eDisconnect_ServerFull:
161 exitReasonStringId = IDS_DISCONNECTED_SERVER_FULL;
162 break;
163 case DisconnectPacket::eDisconnect_Kicked:
164 exitReasonStringId = IDS_DISCONNECTED_KICKED;
165 break;
166 case DisconnectPacket::eDisconnect_NoUGC_AllLocal:
167 exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL;
168 break;
169 case DisconnectPacket::eDisconnect_NoUGC_Single_Local:
170 exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL;
171 break;
172 case DisconnectPacket::eDisconnect_NoUGC_Remote:
173 exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_REMOTE;
174 break;
175 case DisconnectPacket::eDisconnect_NoFlying:
176 exitReasonStringId = IDS_DISCONNECTED_FLYING;
177 break;
178 case DisconnectPacket::eDisconnect_Quitting:
179 exitReasonStringId = IDS_DISCONNECTED_SERVER_QUIT;
180 break;
181 case DisconnectPacket::eDisconnect_OutdatedServer:
182 exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD;
183 break;
184 case DisconnectPacket::eDisconnect_OutdatedClient:
185 exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
186 break;
187 default:
188 exitReasonStringId = IDS_CONNECTION_LOST_SERVER;
189 break;
190 }
191
192 if( m_iPad != ProfileManager.GetPrimaryPad() && g_NetworkManager.IsInSession() )
193 {
194 m_buttonConfirm.SetShow(TRUE);
195 m_buttonConfirm.SetFocus(m_iPad);
196
197 // Set text
198 m_title.SetText( app.GetString( IDS_CONNECTION_FAILED ) );
199 m_status.SetText( app.GetString( exitReasonStringId ) );
200 }
201 else
202 {
203 UINT uiIDA[1];
204 uiIDA[0]=IDS_CONFIRM_OK;
205#ifdef _XBOX
206 StorageManager.RequestMessageBox( IDS_CONNECTION_FAILED, exitReasonStringId, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable());
207#endif
208 exitReasonStringId = -1;
209
210 //app.NavigateToHomeMenu();
211 app.SetAction(ProfileManager.GetPrimaryPad(),eAppAction_ExitWorld,(void *)TRUE);
212 }
213 }
214
215 return S_OK;
216}