the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 242 lines 7.5 kB view raw
1// Minecraft.cpp : Defines the entry point for the application. 2// 3 4#include "stdafx.h" 5#include "..\XUI\XUI_Death.h" 6#include <assert.h> 7#include "..\..\..\Minecraft.World\AABB.h" 8#include "..\..\..\Minecraft.World\Vec3.h" 9#include "..\..\..\Minecraft.World\net.minecraft.stats.h" 10#include "..\..\..\Minecraft.Client\StatsCounter.h" 11#include "..\..\..\Minecraft.World\Entity.h" 12#include "..\..\..\Minecraft.Client\MultiplayerLocalPlayer.h" 13#include "..\..\..\Minecraft.World\Level.h" 14#include "..\..\..\Minecraft.World\ChunkSource.h" 15#include "..\..\..\Minecraft.Client\ProgressRenderer.h" 16#include "..\..\..\Minecraft.Client\GameRenderer.h" 17#include "..\..\..\Minecraft.Client\LevelRenderer.h" 18#include "..\..\..\Minecraft.World\Pos.h" 19#include "..\..\..\Minecraft.World\Dimension.h" 20#include "..\..\Minecraft.h" 21#include "..\..\Options.h" 22#include "..\..\LocalPlayer.h" 23#include "..\..\..\Minecraft.World\compression.h" 24//---------------------------------------------------------------------------------- 25// Performs initialization tasks - retrieves controls. 26//---------------------------------------------------------------------------------- 27HRESULT CScene_Death::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) 28{ 29 m_iPad = *(int *)pInitData->pvInitData; 30 31 m_bIgnoreInput = false; 32 33 MapChildControls(); 34 if(app.GetLocalPlayerCount()>1) 35 { 36 app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad); 37 } 38 39 XuiControlSetText(m_Title,app.GetString(IDS_YOU_DIED)); 40 XuiControlSetText(m_Buttons[BUTTON_DEATH_RESPAWN],app.GetString(IDS_RESPAWN)); 41 XuiControlSetText(m_Buttons[BUTTON_DEATH_EXITGAME],app.GetString(IDS_EXIT_GAME)); 42 43 // Display the tooltips 44 ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT); 45 46 return S_OK; 47} 48 49//---------------------------------------------------------------------------------- 50// Updates the UI when the list selection changes. 51//---------------------------------------------------------------------------------- 52HRESULT CScene_Death::OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled ) 53{ 54 if( hObjSource == m_Scene ) 55 { 56 /*int curSel = m_List.GetCurSel(); 57 58 // Set the locale with the current language. 59 XuiSetLocale( Languages[curSel].pszLanguagePath ); 60 61 // Apply the locale to the main scene. 62 XuiApplyLocale( m_hObj, NULL ); 63 64 // Update the text for the current value. 65 m_Value.SetText( m_List.GetText( curSel ) );*/ 66 67 68 69 bHandled = TRUE; 70 } 71 72 return S_OK; 73} 74 75//---------------------------------------------------------------------------------- 76// Handler for the button press message. 77//---------------------------------------------------------------------------------- 78HRESULT CScene_Death::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled) 79{ 80 if(m_bIgnoreInput) return S_OK; 81 82 // This assumes all buttons can only be pressed with the A button 83 ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A); 84 85 unsigned int uiButtonCounter=0; 86 87 while((uiButtonCounter<BUTTONS_DEATH_MAX) && (m_Buttons[uiButtonCounter]!=hObjPressed)) uiButtonCounter++; 88 89 Minecraft *pMinecraft=Minecraft::GetInstance(); 90 91 // Determine which button was pressed, 92 // and call the appropriate function. 93 switch(uiButtonCounter) 94 { 95 case BUTTON_DEATH_EXITGAME: 96 { 97 // 4J-PB - fix for #8333 - BLOCKER: If player decides to exit game, then cancels the exit player becomes stuck at game over screen 98 //m_bIgnoreInput = true; 99 // Check if it's the trial version 100 if(ProfileManager.IsFullVersion()) 101 { 102 UINT uiIDA[3]; 103 104 // is it the primary player exiting? 105 if(pNotifyPressData->UserIndex==ProfileManager.GetPrimaryPad()) 106 { 107 int playTime = -1; 108 if( pMinecraft->localplayers[pNotifyPressData->UserIndex] != NULL ) 109 { 110 playTime = (int)pMinecraft->localplayers[pNotifyPressData->UserIndex]->getSessionTimer(); 111 } 112 TelemetryManager->RecordLevelExit(pNotifyPressData->UserIndex, eSen_LevelExitStatus_Failed); 113 114 if(StorageManager.GetSaveDisabled()) 115 { 116 uiIDA[0]=IDS_CONFIRM_CANCEL; 117 uiIDA[1]=IDS_CONFIRM_OK; 118 StorageManager.RequestMessageBox(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_PROGRESS_LOST, uiIDA, 2, pNotifyPressData->UserIndex,&UIScene_PauseMenu::ExitGameDialogReturned,this, app.GetStringTable()); 119 } 120 else 121 { 122 if( g_NetworkManager.IsHost() ) 123 { 124 uiIDA[0]=IDS_CONFIRM_CANCEL; 125 uiIDA[1]=IDS_EXIT_GAME_SAVE; 126 uiIDA[2]=IDS_EXIT_GAME_NO_SAVE; 127 128 StorageManager.RequestMessageBox(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3, pNotifyPressData->UserIndex,&UIScene_PauseMenu::ExitGameSaveDialogReturned,this, app.GetStringTable()); 129 } 130 else 131 { 132 uiIDA[0]=IDS_CONFIRM_CANCEL; 133 uiIDA[1]=IDS_CONFIRM_OK; 134 135 StorageManager.RequestMessageBox(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, pNotifyPressData->UserIndex,&UIScene_PauseMenu::ExitGameDialogReturned,this, app.GetStringTable()); 136 } 137 } 138 } 139 else 140 { 141 TelemetryManager->RecordLevelExit(pNotifyPressData->UserIndex, eSen_LevelExitStatus_Failed); 142 143 // just exit the player 144 app.SetAction(pNotifyPressData->UserIndex,eAppAction_ExitPlayer); 145 } 146 } 147 else 148 { 149 // is it the primary player exiting? 150 if(pNotifyPressData->UserIndex==ProfileManager.GetPrimaryPad()) 151 { 152 TelemetryManager->RecordLevelExit(pNotifyPressData->UserIndex, eSen_LevelExitStatus_Failed); 153 154 // adjust the trial time played 155 CXuiSceneBase::ReduceTrialTimerValue(); 156 157 // exit the level 158 UINT uiIDA[2]; 159 uiIDA[0]=IDS_CONFIRM_CANCEL; 160 uiIDA[1]=IDS_CONFIRM_OK; 161 StorageManager.RequestMessageBox(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_PROGRESS_LOST, uiIDA, 2, pNotifyPressData->UserIndex,&UIScene_PauseMenu::ExitGameDialogReturned,this, app.GetStringTable()); 162 } 163 else 164 { 165 TelemetryManager->RecordLevelExit(pNotifyPressData->UserIndex, eSen_LevelExitStatus_Failed); 166 167 // just exit the player 168 app.SetAction(pNotifyPressData->UserIndex,eAppAction_ExitPlayer); 169 } 170 } 171 } 172 break; 173 case BUTTON_DEATH_RESPAWN: 174 { 175 m_bIgnoreInput = true; 176 app.SetAction(pNotifyPressData->UserIndex,eAppAction_Respawn); 177 } 178 179 break; 180 default: 181 break; 182 } 183 184 185 186 return S_OK; 187} 188 189HRESULT CScene_Death::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled) 190{ 191 ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode); 192 193 194 switch(pInputData->dwKeyCode) 195 { 196 197 case VK_PAD_B: 198 case VK_PAD_START: 199 case VK_ESCAPE: 200 201 // kill the crafting xui 202 // 4J Stu - No back out, must choose 203 //app.CloseXuiScenes(); 204 205 rfHandled = TRUE; 206 207 break; 208 } 209 210 return S_OK; 211} 212 213int CScene_Death::RespawnThreadProc( void* lpParameter ) 214{ 215 AABB::UseDefaultThreadStorage(); 216 Vec3::UseDefaultThreadStorage(); 217 Compression::UseDefaultThreadStorage(); 218 size_t iPad=(size_t)lpParameter; 219 220 Minecraft *pMinecraft=Minecraft::GetInstance(); 221 222 pMinecraft->localplayers[iPad]->respawn(); 223 224 app.SetGameStarted(true); 225 pMinecraft->gameRenderer->EnableUpdateThread(); 226 227 // If we are online, then we should wait here until the respawn is done 228 // If we are offline, this should release straight away 229 //WaitForSingleObject( pMinecraft->m_hPlayerRespawned, INFINITE ); 230 while(pMinecraft->localplayers[iPad]->GetPlayerRespawned()==false) 231 { 232 Sleep(50); 233 } 234 235 return S_OK; 236} 237 238HRESULT CScene_Death::OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled) 239{ 240 bHandled=true; 241 return app.AdjustSplitscreenScene_PlayerChanged(m_hObj,&m_OriginalPosition,m_iPad,bJoining); 242}