the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "UI.h"
3#include "UIScene_ConnectingProgress.h"
4#include "..\..\Minecraft.h"
5
6UIScene_ConnectingProgress::UIScene_ConnectingProgress(int iPad, void *_initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
7{
8 // Setup all the Iggy references we need for this scene
9 initialiseMovie();
10
11 parentLayer->addComponent(iPad,eUIComponent_Panorama);
12 parentLayer->addComponent(iPad,eUIComponent_Logo);
13
14 m_progressBar.showBar(false);
15 m_progressBar.setVisible( false );
16 m_labelTip.setVisible( false );
17
18 ConnectionProgressParams *param = (ConnectionProgressParams *)_initData;
19
20 if( param->stringId >= 0 )
21 {
22 m_labelTitle.init( app.GetString( param->stringId ) );
23 }
24 else
25 {
26 m_labelTitle.init( L"" );
27 }
28 m_progressBar.init(L"",0,0,100,0);
29 m_buttonConfirm.init( app.GetString( IDS_CONFIRM_OK ), eControl_Confirm );
30 m_buttonConfirm.setVisible(false);
31
32#if 0
33 if(app.GetLocalPlayerCount()>1)
34 {
35 app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad,false);
36 }
37#endif
38
39 m_showTooltips = param->showTooltips;
40 m_runFailTimer = param->setFailTimer;
41 m_timerTime = param->timerTime;
42 m_cancelFunc = param->cancelFunc;
43 m_cancelFuncParam = param->cancelFuncParam;
44 m_removeLocalPlayer = false;
45 m_showingButton = false;
46}
47
48UIScene_ConnectingProgress::~UIScene_ConnectingProgress()
49{
50 m_parentLayer->removeComponent(eUIComponent_Panorama);
51 m_parentLayer->removeComponent(eUIComponent_Logo);
52}
53
54void UIScene_ConnectingProgress::updateTooltips()
55{
56 // 4J-PB - removing the option of cancel join, since it didn't work anyway
57 //ui.SetTooltips( m_iPad, -1, m_showTooltips?IDS_TOOLTIPS_CANCEL_JOIN:-1);
58 ui.SetTooltips( m_iPad, -1, -1);
59}
60
61void UIScene_ConnectingProgress::tick()
62{
63 UIScene::tick();
64
65 if( m_removeLocalPlayer )
66 {
67 m_removeLocalPlayer = false;
68
69 Minecraft *pMinecraft = Minecraft::GetInstance();
70 pMinecraft->removeLocalPlayerIdx(m_iPad);
71#ifdef _XBOX_ONE
72 ProfileManager.RemoveGamepadFromGame(m_iPad);
73#endif
74 }
75}
76
77wstring UIScene_ConnectingProgress::getMoviePath()
78{
79 if(app.GetLocalPlayerCount() > 1 && !m_parentLayer->IsFullscreenGroup())
80 {
81 return L"FullscreenProgressSplit";
82 }
83 else
84 {
85 return L"FullscreenProgress";
86 }
87}
88
89void UIScene_ConnectingProgress::handleGainFocus(bool navBack)
90{
91 UIScene::handleGainFocus(navBack);
92 if(!navBack && m_runFailTimer) addTimer(0,m_timerTime);
93}
94
95void UIScene_ConnectingProgress::handleLoseFocus()
96{
97 int millisecsLeft = getTimer(0)->targetTime - System::currentTimeMillis();
98 int millisecsTaken = getTimer(0)->duration - millisecsLeft;
99 app.DebugPrintf("\n");
100 app.DebugPrintf("---------------------------------------------------------\n");
101 app.DebugPrintf("---------------------------------------------------------\n");
102 app.DebugPrintf("UIScene_ConnectingProgress time taken = %d millisecs\n", millisecsTaken);
103 app.DebugPrintf("---------------------------------------------------------\n");
104 app.DebugPrintf("---------------------------------------------------------\n");
105 app.DebugPrintf("\n");
106
107
108 killTimer(0);
109}
110
111void UIScene_ConnectingProgress::handleTimerComplete(int id)
112{
113 // Check if the connection failed
114 Minecraft *pMinecraft = Minecraft::GetInstance();
115
116 if( pMinecraft->m_connectionFailed[m_iPad] || !g_NetworkManager.IsInSession() )
117 {
118
119#if 0
120 app.RemoveBackScene(m_iPad);
121#endif
122
123 int exitReasonStringId;
124 switch(pMinecraft->m_connectionFailedReason[m_iPad])
125 {
126 case DisconnectPacket::eDisconnect_LoginTooLong:
127 exitReasonStringId = IDS_DISCONNECTED_LOGIN_TOO_LONG;
128 break;
129 case DisconnectPacket::eDisconnect_ServerFull:
130 exitReasonStringId = IDS_DISCONNECTED_SERVER_FULL;
131 break;
132 case DisconnectPacket::eDisconnect_Kicked:
133 exitReasonStringId = IDS_DISCONNECTED_KICKED;
134 break;
135 case DisconnectPacket::eDisconnect_NoUGC_AllLocal:
136 exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL;
137 break;
138 case DisconnectPacket::eDisconnect_NoUGC_Single_Local:
139 exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL;
140 break;
141#if defined(__PS3__) || defined(__ORBIS__)
142 case DisconnectPacket::eDisconnect_ContentRestricted_AllLocal:
143 exitReasonStringId = IDS_CONTENT_RESTRICTION_MULTIPLAYER;
144 break;
145 case DisconnectPacket::eDisconnect_ContentRestricted_Single_Local:
146 exitReasonStringId = IDS_CONTENT_RESTRICTION;
147 break;
148#endif
149#ifdef _XBOX
150 case DisconnectPacket::eDisconnect_NoUGC_Remote:
151 exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_REMOTE;
152 break;
153#endif
154 case DisconnectPacket::eDisconnect_NoFlying:
155 exitReasonStringId = IDS_DISCONNECTED_FLYING;
156 break;
157 case DisconnectPacket::eDisconnect_Quitting:
158 exitReasonStringId = IDS_DISCONNECTED_SERVER_QUIT;
159 break;
160 case DisconnectPacket::eDisconnect_OutdatedServer:
161 exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD;
162 break;
163 case DisconnectPacket::eDisconnect_OutdatedClient:
164 exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
165 break;
166#if defined __ORBIS__ || defined __PS3__ || defined __PSVITA__
167 case DisconnectPacket::eDisconnect_NATMismatch:
168 exitReasonStringId = IDS_DISCONNECTED_NAT_TYPE_MISMATCH;
169 break;
170#endif
171 default:
172 exitReasonStringId = IDS_CONNECTION_LOST_SERVER;
173 break;
174 }
175
176 if( m_iPad != ProfileManager.GetPrimaryPad() && g_NetworkManager.IsInSession() )
177 {
178 m_buttonConfirm.setVisible(true);
179 m_showingButton = true;
180
181 // Set text
182 m_labelTitle.setLabel( app.GetString( IDS_CONNECTION_FAILED ) );
183 m_progressBar.setLabel( app.GetString( exitReasonStringId ) );
184 m_progressBar.setVisible( true );
185 m_controlTimer.setVisible( false );
186 }
187 else
188 {
189 UINT uiIDA[1];
190 uiIDA[0]=IDS_CONFIRM_OK;
191 ui.RequestErrorMessage( IDS_CONNECTION_FAILED, exitReasonStringId, uiIDA,1,ProfileManager.GetPrimaryPad());
192 exitReasonStringId = -1;
193
194 //app.NavigateToHomeMenu();
195 app.SetAction(ProfileManager.GetPrimaryPad(),eAppAction_ExitWorld,(void *)TRUE);
196 }
197 }
198}
199
200void UIScene_ConnectingProgress::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
201{
202 //app.DebugPrintf("UIScene_DebugOverlay handling input for pad %d, key %d, down- %s, pressed- %s, released- %s\n", iPad, key, down?"TRUE":"FALSE", pressed?"TRUE":"FALSE", released?"TRUE":"FALSE");
203
204 if( m_showTooltips )
205 {
206 ui.AnimateKeyPress(m_iPad, key, repeat, pressed, released);
207
208 switch(key)
209 {
210// 4J-PB - Removed the option to cancel join - it didn't work anyway
211// case ACTION_MENU_CANCEL:
212// {
213// if(m_cancelFunc != NULL)
214// {
215// m_cancelFunc(m_cancelFuncParam);
216// }
217// else
218// {
219// // Cancel the join
220// Minecraft *pMinecraft = Minecraft::GetInstance();
221// pMinecraft->removeLocalPlayerIdx(m_iPad);
222// }
223// handled = true;
224// }
225// break;
226 case ACTION_MENU_OK:
227#ifdef __ORBIS__
228 case ACTION_MENU_TOUCHPAD_PRESS:
229#endif
230 if(pressed)
231 {
232 sendInputToMovie(key, repeat, pressed, released);
233 }
234 break;
235 case ACTION_MENU_UP:
236 case ACTION_MENU_DOWN:
237 if(pressed)
238 {
239 sendInputToMovie(key, repeat, pressed, released);
240 }
241 break;
242 }
243 }
244}
245
246void UIScene_ConnectingProgress::handlePress(F64 controlId, F64 childId)
247{
248 switch((int)controlId)
249 {
250 case eControl_Confirm:
251 if(m_showingButton)
252 {
253 if( m_iPad != ProfileManager.GetPrimaryPad() && g_NetworkManager.IsInSession() )
254 {
255 // The connection failed if we see the button, so the temp player should be removed and the viewports updated again
256 // This is actually done in the tick as we can't pull down the scene we are currently in from here
257 m_removeLocalPlayer = true;
258 }
259 else
260 {
261 ui.NavigateToHomeMenu();
262 //app.NavigateBack( ProfileManager.GetPrimaryPad() );
263 }
264 }
265 break;
266 }
267}