the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 306 lines 9.9 kB view raw
1#include "stdafx.h" 2#include "XUI_MultiGameCreate.h" 3#include "XUI_MultiGameLaunchMoreOptions.h" 4#include "..\..\TexturePackRepository.h" 5#include "..\..\Minecraft.h" 6 7#define GAME_CREATE_ONLINE_TIMER_ID 0 8#define GAME_CREATE_ONLINE_TIMER_TIME 100 9 10//---------------------------------------------------------------------------------- 11// Performs initialization tasks - retrieves controls. 12//---------------------------------------------------------------------------------- 13HRESULT CScene_MultiGameLaunchMoreOptions::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) 14{ 15 MapChildControls(); 16 17 XuiControlSetText(m_CheckboxOnline,app.GetString(IDS_ONLINE_GAME)); 18 XuiControlSetText(m_CheckboxInviteOnly,app.GetString(IDS_INVITE_ONLY)); 19 XuiControlSetText(m_CheckboxAllowFoF,app.GetString(IDS_ALLOWFRIENDSOFFRIENDS)); 20 XuiControlSetText(m_CheckboxPVP,app.GetString(IDS_PLAYER_VS_PLAYER)); 21 XuiControlSetText(m_CheckboxTrustPlayers,app.GetString(IDS_TRUST_PLAYERS)); 22 XuiControlSetText(m_CheckboxFireSpreads,app.GetString(IDS_FIRE_SPREADS)); 23 XuiControlSetText(m_CheckboxTNTExplodes,app.GetString(IDS_TNT_EXPLODES)); 24 XuiControlSetText(m_CheckboxHostPrivileges,app.GetString(IDS_HOST_PRIVILEGES)); 25 XuiControlSetText(m_CheckboxResetNether,app.GetString(IDS_RESET_NETHER)); 26 XuiControlSetText(m_LabelWorldOptions,app.GetString(IDS_WORLD_OPTIONS)); 27 XuiControlSetText(m_CheckboxStructures,app.GetString(IDS_GENERATE_STRUCTURES)); 28 XuiControlSetText(m_CheckboxFlatWorld,app.GetString(IDS_SUPERFLAT_WORLD)); 29 XuiControlSetText(m_CheckboxBonusChest,app.GetString(IDS_BONUS_CHEST)); 30 31 m_params = (LaunchMoreOptionsMenuInitData *)pInitData->pvInitData; 32 33 if(m_params->bGenerateOptions) 34 { 35 m_CheckboxStructures.SetEnable(TRUE); 36 m_CheckboxFlatWorld.SetEnable(TRUE); 37 m_CheckboxBonusChest.SetEnable(TRUE); 38 m_CheckboxStructures.SetCheck(m_params->bStructures); 39 m_CheckboxFlatWorld.SetCheck (m_params->bFlatWorld); 40 m_CheckboxBonusChest.SetCheck(m_params->bBonusChest); 41 42 // This is a create world, so don't need Reset Nether 43 float fHeight, fCheckboxHeight, fWidth; 44 m_CheckboxResetNether.GetBounds(&fWidth, &fCheckboxHeight); 45 46 m_HostOptionGroup.GetBounds(&fWidth, &fHeight); 47 m_HostOptionGroup.SetBounds(fWidth, fHeight - fCheckboxHeight); 48 49 GetBounds(&fWidth,&fHeight); 50 SetBounds(fWidth, fHeight - fCheckboxHeight); 51 52 D3DXVECTOR3 pos; 53 GetPosition(&pos); 54 pos.y += (fCheckboxHeight/2); 55 SetPosition(&pos); 56 57 m_GenerationGroup.GetPosition(&pos); 58 pos.y -= fCheckboxHeight; 59 m_GenerationGroup.SetPosition(&pos); 60 61 m_CheckboxResetNether.SetShow(FALSE); 62 } 63 else 64 { 65 float fHeight, fGroupHeight, fWidth; 66 m_GenerationGroup.GetBounds(&fWidth, &fGroupHeight); 67 m_GenerationGroup.SetShow(FALSE); 68 m_GenerationGroup.SetEnable(FALSE); 69 m_CheckboxStructures.SetShow(FALSE); 70 m_CheckboxFlatWorld.SetShow(FALSE); 71 m_CheckboxBonusChest.SetShow(FALSE); 72 73 GetBounds(&fWidth,&fHeight); 74 SetBounds(fWidth, fHeight +10 - fGroupHeight); 75 76 D3DXVECTOR3 pos; 77 GetPosition(&pos); 78 pos.y += (fGroupHeight/2); 79 SetPosition(&pos); 80 81 m_CheckboxResetNether.SetEnable(TRUE); 82 m_CheckboxResetNether.SetCheck(m_params->bResetNether); 83 } 84 85 m_CheckboxPVP.SetEnable(TRUE); 86 m_CheckboxTrustPlayers.SetEnable(TRUE); 87 m_CheckboxFireSpreads.SetEnable(TRUE); 88 m_CheckboxTNTExplodes.SetEnable(TRUE); 89 m_CheckboxHostPrivileges.SetEnable(TRUE); 90 91 m_CheckboxPVP.SetCheck(m_params->bPVP); 92 m_CheckboxTrustPlayers.SetCheck (m_params->bTrust); 93 m_CheckboxFireSpreads.SetCheck(m_params->bFireSpreads); 94 m_CheckboxTNTExplodes.SetCheck(m_params->bTNT); 95 m_CheckboxHostPrivileges.SetCheck(m_params->bHostPrivileges); 96 97 98 m_CheckboxOnline.SetCheck(m_params->bOnlineGame); 99 m_CheckboxInviteOnly.SetCheck(m_params->bInviteOnly); 100 m_CheckboxAllowFoF.SetCheck(m_params->bAllowFriendsOfFriends); 101 102 m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_params->iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_params->iPad); 103 if(m_params->bOnlineSettingChangedBySystem) 104 { 105 m_CheckboxOnline.SetCheck(FALSE); 106 m_CheckboxOnline.SetEnable(FALSE); 107 m_CheckboxInviteOnly.SetCheck(FALSE); 108 m_CheckboxInviteOnly.SetEnable(FALSE); 109 m_CheckboxAllowFoF.SetCheck(FALSE); 110 m_CheckboxAllowFoF.SetEnable(FALSE); 111 } 112 else if(!m_params->bOnlineGame) 113 { 114 m_CheckboxInviteOnly.SetEnable(FALSE); 115 m_CheckboxAllowFoF.SetEnable(FALSE); 116 } 117 118 XuiSetTimer(m_hObj,GAME_CREATE_ONLINE_TIMER_ID,GAME_CREATE_ONLINE_TIMER_TIME); 119 120 ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); 121 122 CXuiSceneBase::ShowLogo( DEFAULT_XUI_MENU_USER, FALSE ); 123 124 125 //SentientManager.RecordMenuShown(m_params->iPad, eUIScene_CreateWorldMenu, 0); 126 127 return S_OK; 128} 129 130 131HRESULT CScene_MultiGameLaunchMoreOptions::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled) 132{ 133 ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode); 134 135 // Explicitly handle B button presses 136 switch(pInputData->dwKeyCode) 137 { 138 case VK_PAD_B: 139 case VK_ESCAPE: 140 m_params->bOnlineGame = m_CheckboxOnline.IsChecked(); 141 m_params->bInviteOnly = m_CheckboxInviteOnly.IsChecked(); 142 m_params->bAllowFriendsOfFriends = m_CheckboxAllowFoF.IsChecked(); 143 144 m_params->bStructures = m_CheckboxStructures.IsChecked(); 145 m_params->bFlatWorld = m_CheckboxFlatWorld.IsChecked(); 146 m_params->bBonusChest = m_CheckboxBonusChest.IsChecked(); 147 m_params->bPVP = m_CheckboxPVP.IsChecked(); 148 m_params->bTrust = m_CheckboxTrustPlayers.IsChecked(); 149 m_params->bFireSpreads = m_CheckboxFireSpreads.IsChecked(); 150 m_params->bTNT = m_CheckboxTNTExplodes.IsChecked(); 151 152 m_params->bHostPrivileges = m_CheckboxHostPrivileges.IsChecked(); 153 154 m_params->bResetNether = m_CheckboxResetNether.IsChecked(); 155 156 app.NavigateBack(pInputData->UserIndex); 157 rfHandled = TRUE; 158 break; 159 } 160 return S_OK; 161} 162 163 164HRESULT CScene_MultiGameLaunchMoreOptions::OnNotifySetFocus( HXUIOBJ hObjSource, XUINotifyFocus *pNotifyFocusData, BOOL& bHandled ) 165{ 166 int stringId = 0; 167 if(hObjSource == m_CheckboxStructures) 168 { 169 stringId = IDS_GAMEOPTION_STRUCTURES; 170 } 171 else if(hObjSource == m_CheckboxOnline) 172 { 173 stringId = IDS_GAMEOPTION_ONLINE; 174 } 175 else if(hObjSource == m_CheckboxInviteOnly) 176 { 177 stringId = IDS_GAMEOPTION_INVITEONLY; 178 } 179 else if(hObjSource == m_CheckboxAllowFoF) 180 { 181 stringId = IDS_GAMEOPTION_ALLOWFOF; 182 } 183 else if(hObjSource == m_CheckboxFlatWorld) 184 { 185 stringId = IDS_GAMEOPTION_SUPERFLAT; 186 } 187 else if(hObjSource == m_CheckboxBonusChest) 188 { 189 stringId = IDS_GAMEOPTION_BONUS_CHEST; 190 } 191 else if(hObjSource == m_CheckboxPVP) 192 { 193 stringId = IDS_GAMEOPTION_PVP; 194 } 195 else if(hObjSource == m_CheckboxTrustPlayers) 196 { 197 stringId = IDS_GAMEOPTION_TRUST; 198 } 199 else if(hObjSource == m_CheckboxFireSpreads) 200 { 201 stringId = IDS_GAMEOPTION_FIRE_SPREADS; 202 } 203 else if(hObjSource == m_CheckboxTNTExplodes) 204 { 205 stringId = IDS_GAMEOPTION_TNT_EXPLODES; 206 } 207 else if(hObjSource == m_CheckboxHostPrivileges) 208 { 209 stringId = IDS_GAMEOPTION_HOST_PRIVILEGES; 210 } 211 else if(hObjSource == m_CheckboxResetNether) 212 { 213 stringId = IDS_GAMEOPTION_RESET_NETHER; 214 } 215 216 wstring wsText=app.GetString(stringId); 217 int size = 14; 218 if(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()) 219 { 220 size = 12; 221 } 222 wchar_t startTags[64]; 223 swprintf(startTags,64,L"<font color=\"#%08x\" size=%d>",app.GetHTMLColour(eHTMLColor_White), size); 224 wsText= startTags + wsText; 225 226 m_Description.SetText(wsText.c_str()); 227 return S_OK; 228} 229 230HRESULT CScene_MultiGameLaunchMoreOptions::OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled) 231{ 232 pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); 233 234 if(pControlNavigateData->hObjDest!=NULL) 235 { 236 bHandled=TRUE; 237 } 238 239 return S_OK; 240} 241 242//---------------------------------------------------------------------------------- 243// Handler for the button press message. 244//---------------------------------------------------------------------------------- 245HRESULT CScene_MultiGameLaunchMoreOptions::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled) 246{ 247 // This assumes all buttons can only be pressed with the A button 248 ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A); 249 250 if(hObjPressed==m_CheckboxOnline) 251 { 252 if(m_CheckboxOnline.IsChecked()) 253 { 254 m_CheckboxInviteOnly.SetEnable(TRUE); 255 m_CheckboxAllowFoF.SetEnable(TRUE); 256 } 257 else 258 { 259 m_CheckboxInviteOnly.SetCheck(FALSE); 260 m_CheckboxInviteOnly.SetEnable(FALSE); 261 m_CheckboxAllowFoF.SetCheck(FALSE); 262 m_CheckboxAllowFoF.SetEnable(FALSE); 263 } 264 } 265 return S_OK; 266} 267 268HRESULT CScene_MultiGameLaunchMoreOptions::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled ) 269{ 270 // 4J-PB - TODO - Don't think we can do this - if a 2nd player signs in here with an offline profile, the signed in LIVE player gets re-logged in, and bMultiplayerAllowed is false briefly 271 if( pTimer->nId == GAME_CREATE_ONLINE_TIMER_ID) 272 { 273 bool bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_params->iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_params->iPad); 274 275 if(bMultiplayerAllowed != m_bMultiplayerAllowed) 276 { 277 if( bMultiplayerAllowed ) 278 { 279 bool bGameSetting_Online=(app.GetGameSettings(m_params->iPad,eGameSetting_Online)!=0); 280 m_CheckboxOnline.SetCheck(bGameSetting_Online?TRUE:FALSE); 281 if(bGameSetting_Online) 282 { 283 m_CheckboxInviteOnly.SetCheck((app.GetGameSettings(m_params->iPad,eGameSetting_InviteOnly)!=0)?TRUE:FALSE); 284 m_CheckboxAllowFoF.SetCheck((app.GetGameSettings(m_params->iPad,eGameSetting_FriendsOfFriends)!=0)?TRUE:FALSE); 285 } 286 else 287 { 288 m_CheckboxInviteOnly.SetCheck(FALSE); 289 m_CheckboxAllowFoF.SetCheck(FALSE); 290 } 291 } 292 else 293 { 294 m_CheckboxOnline.SetCheck(FALSE); 295 m_CheckboxOnline.SetEnable(FALSE); 296 m_CheckboxInviteOnly.SetCheck(FALSE); 297 m_CheckboxInviteOnly.SetEnable(FALSE); 298 m_CheckboxAllowFoF.SetCheck(FALSE); 299 } 300 301 m_bMultiplayerAllowed = bMultiplayerAllowed; 302 } 303 } 304 305 return S_OK; 306}