the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 147 lines 4.8 kB view raw
1// Minecraft.cpp : Defines the entry point for the application. 2// 3 4#include "stdafx.h" 5 6#include <assert.h> 7#include "..\XUI\XUI_SocialPost.h" 8#include "..\..\..\Minecraft.World\StringHelpers.h" 9#include "..\..\..\Minecraft.World\SharedConstants.h" 10#include "..\..\..\Minecraft.World\Random.h" 11#include "..\..\..\Minecraft.Client\SurvivalMode.h" 12#include "..\..\..\Minecraft.Client\CreateWorldScreen.h" 13#include "..\..\..\Minecraft.World\ConsoleSaveFileIO.h" 14#include "..\..\..\Minecraft.World\AABB.h" 15#include "..\..\..\Minecraft.World\Vec3.h" 16#include "..\..\LocalPlayer.h" 17 18 19//---------------------------------------------------------------------------------- 20// Performs initialization tasks - retrieves controls. 21//---------------------------------------------------------------------------------- 22HRESULT CScene_SocialPost::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) 23{ 24 m_iPad = *(int *)pInitData->pvInitData; 25 26 MapChildControls(); 27 28 XuiControlSetText(m_text,app.GetString(IDS_SOCIAL_TEXT)); 29 XuiControlSetText(m_LabelCaption,app.GetString(IDS_SOCIAL_LABEL_CAPTION)); 30 XuiControlSetText(m_EditCaption,app.GetString(IDS_SOCIAL_DEFAULT_CAPTION)); 31 XuiControlSetText(m_LabelDescription,app.GetString(IDS_SOCIAL_LABEL_DESCRIPTION)); 32 XuiControlSetText(m_EditDesc,app.GetString(IDS_SOCIAL_DEFAULT_DESCRIPTION)); 33 XuiControlSetText(m_OK,app.GetString(IDS_CONFIRM_OK)); 34 35 ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); 36 37 38 m_EditCaption.SetTextLimit(MAX_SOCIALPOST_CAPTION); 39 m_EditDesc.SetTextLimit(MAX_SOCIALPOST_DESC); 40 41 // Hardcoded so posts will have this in 42 m_wTitle = L"Minecraft: Xbox 360 Edition"; 43 44 m_EditCaption.SetTitleAndText(IDS_NAME_CAPTION,IDS_NAME_CAPTION_TEXT); 45 m_EditDesc.SetTitleAndText(IDS_NAME_DESC,IDS_NAME_DESC_TEXT); 46 47 wstring wCaption = m_EditCaption.GetText(); 48 wstring wDesc = m_EditDesc.GetText(); 49 50 // set the caret to the end of the default text 51 m_EditCaption.SetCaretPosition((int)wCaption.length()); 52 m_EditDesc.SetCaretPosition((int)wDesc.length()); 53 54 BOOL bHasAllText = /*( wTitle.length()!=0) && */(wCaption.length()!=0) && (wDesc.length()!=0); 55 56 m_OK.SetEnable(bHasAllText); 57 58 if(app.GetLocalPlayerCount()>1) 59 { 60 app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad,false); 61 } 62 63 TelemetryManager->RecordMenuShown(m_iPad, eUIScene_SocialPost, 0); 64 65 return S_OK; 66} 67 68 69HRESULT CScene_SocialPost::OnNotifyValueChanged (HXUIOBJ hObjSource, XUINotifyValueChanged* pValueChangedData, BOOL& rfHandled) 70{ wstring wCaption = m_EditCaption.GetText(); 71wstring wDesc = m_EditDesc.GetText(); 72 73 74 if(/*(hObjSource == m_EditTitle) || */(hObjSource == m_EditCaption) || (hObjSource == m_EditDesc)) 75 { 76 // Enable the done button when we have all of the necessary information 77 //wstring wTitle = m_EditTitle.GetText(); 78 wstring wCaption = m_EditCaption.GetText(); 79 wstring wDesc = m_EditDesc.GetText(); 80 81 BOOL bHasAllText = /*( wTitle.length()!=0) &&*/ (wCaption.length()!=0) && (wDesc.length()!=0); 82 m_OK.SetEnable(bHasAllText); 83 } 84 85 return S_OK; 86} 87 88HRESULT CScene_SocialPost::OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled) 89{ 90 pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); 91 92 if(pControlNavigateData->hObjDest==NULL) 93 { 94 pControlNavigateData->hObjDest=pControlNavigateData->hObjSource; 95 } 96 97 bHandled=TRUE; 98 return S_OK; 99} 100 101//---------------------------------------------------------------------------------- 102// Handler for the button press message. 103//---------------------------------------------------------------------------------- 104HRESULT CScene_SocialPost::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled) 105{ 106 // This assumes all buttons can only be pressed with the A button 107 ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A); 108 109 if(hObjPressed==m_OK) 110 { 111 CSocialManager::Instance()->SetSocialPostText(m_wTitle.c_str(),m_EditCaption.GetText(),m_EditDesc.GetText()); 112 113 CSocialManager::Instance()->PostImageToSocialNetwork( eFacebook, pNotifyPressData->UserIndex, false); 114 115 app.NavigateBack(pNotifyPressData->UserIndex); 116 } 117 118 return S_OK; 119} 120 121 122HRESULT CScene_SocialPost::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled) 123{ 124 ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode); 125 126 //HXUIOBJ hFocus=XuiElementGetFocus(); 127 switch(pInputData->dwKeyCode) 128 { 129 130 case VK_PAD_B: 131 case VK_ESCAPE: 132 app.NavigateBack(pInputData->UserIndex); 133 rfHandled = TRUE; 134 135 break; 136 } 137 138 139 return S_OK; 140} 141 142 143HRESULT CScene_SocialPost::OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled) 144{ 145 bHandled=true; 146 return app.AdjustSplitscreenScene_PlayerChanged(m_hObj,&m_OriginalPosition,m_iPad,bJoining,false); 147}