the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 209 lines 6.7 kB view raw
1#include "stdafx.h" 2 3#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h" 4 5#include "..\..\..\Minecraft.World\Container.h" 6#include "..\..\..\Minecraft.World\Slot.h" 7#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.h" 8#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.entity.h" 9#include "..\..\..\Minecraft.World\net.minecraft.world.item.h" 10#include "..\..\..\Minecraft.World\net.minecraft.world.entity.player.h" 11 12#include "..\..\..\Minecraft.World\net.minecraft.stats.h" 13#include "..\..\MultiplayerLocalPlayer.h" 14#include "..\..\Common\Tutorial\Tutorial.h" 15#include "..\..\Common\Tutorial\TutorialMode.h" 16#include "..\..\Minecraft.h" 17 18#include "XUI_Scene_AbstractContainer.h" 19#include "XUI_Ctrl_SlotItem.h" 20#include "XUI_Ctrl_SlotList.h" 21#include "XUI_Ctrl_SlotItemListItem.h" 22 23#include "..\..\Common\Potion_macros.h" 24 25//-------------------------------------------------------------------------------------- 26// Name: CXuiSceneInventoryCreative::OnInit 27// Desc: Message handler for XM_INIT 28//-------------------------------------------------------------------------------------- 29HRESULT CXuiSceneInventoryCreative::OnInit( XUIMessageInit *pInitData, BOOL &bHandled ) 30{ 31 D3DXVECTOR3 vec; 32 MapChildControls(); 33 34 Minecraft *pMinecraft = Minecraft::GetInstance(); 35 36 InventoryScreenInput *initData = (InventoryScreenInput *)pInitData->pvInitData; 37 m_iPad=initData->iPad; 38 m_bSplitscreen=initData->bSplitscreen; 39 40 // if we are in splitscreen, then we need to figure out if we want to move this scene 41 42 if(m_bSplitscreen) 43 { 44 if(m_bSplitscreen) 45 { 46 app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad); 47 } 48 } 49 50#ifdef _XBOX 51 if( pMinecraft->localgameModes[initData->iPad] != NULL ) 52 { 53 TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; 54 m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); 55 gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Creative_Inventory_Menu, this); 56 } 57#endif 58 59 // 4J JEV - Does this still count as opening the inventory? 60 initData->player->awardStat(GenericStats::openInventory(), GenericStats::param_noArgs()); 61 62 // 4J JEV - Item Picker Menu 63 shared_ptr<SimpleContainer> creativeContainer = shared_ptr<SimpleContainer>(new SimpleContainer( 0, TabSpec::MAX_SIZE + 9 )); 64 itemPickerMenu = new ItemPickerMenu(creativeContainer, initData->player->inventory); 65 66 // 4J JEV - InitDataAssociations. 67 m_containerControl->SetData( initData->iPad, itemPickerMenu, TabSpec::rows, TabSpec::columns, 0, TabSpec::MAX_SIZE ); 68 m_useRowControl->SetData( initData->iPad, itemPickerMenu, 1, 9, TabSpec::MAX_SIZE, TabSpec::MAX_SIZE + 9 ); 69 m_pointerControl->SetUserIndex(m_pointerControl->m_hObj, initData->iPad); 70 71 // Initialize superclass. 72 CXuiSceneAbstractContainer::Initialize( initData->iPad, itemPickerMenu, false, -1, eSectionInventoryCreativeUsing, eSectionInventoryCreativeMax, initData->bNavigateBack ); 73 74 delete initData; 75 76 // Change the point at which the cursor stops so we can't move the pointer over the tabs 77 D3DXVECTOR3 containerPos; 78 m_containerControl->GetPosition(&containerPos); 79 m_fPointerMinY += containerPos.y; 80 81 // 4J JEV - Settup Tabs 82 for (int i = 0; i < eCreativeInventoryTab_COUNT; i++) 83 { 84 m_hTabGroupA[i].SetShow(FALSE); 85 } 86 87 m_curTab = eCreativeInventoryTab_COUNT; 88 switchTab(eCreativeInventoryTab_BuildingBlocks); 89 90 return S_OK; 91} 92 93HRESULT CXuiSceneInventoryCreative::OnDestroy() 94{ 95 Minecraft *pMinecraft = Minecraft::GetInstance(); 96 97#ifdef _XBOX 98 if( pMinecraft->localgameModes[m_iPad] != NULL ) 99 { 100 TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; 101 if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); 102 } 103#endif 104 105 // 4J Stu - Fix for #11302 - TCR 001: Network Connectivity: Host crashed after being killed by the client while accessing a chest during burst packet loss. 106 // We need to make sure that we call closeContainer() anytime this menu is closed, even if it is forced to close by some other reason (like the player dying) 107 if(Minecraft::GetInstance()->localplayers[m_iPad] != NULL) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); 108 return S_OK; 109} 110 111////////////////////////////////////////////////////////////////////////// 112// 113// OnTransitionEnd 114// 115////////////////////////////////////////////////////////////////////////// 116HRESULT CXuiSceneInventoryCreative::OnTransitionEnd( XUIMessageTransition *pTransData, BOOL& bHandled ) 117{ 118 // are we being destroyed? If so, don't do anything 119 if(pTransData->dwTransAction==XUI_TRANSITION_ACTION_DESTROY ) 120 { 121 return S_OK; 122 } 123 124 // Fix for issue caused by autosave while crafting is up 125 if(pTransData->dwTransType == XUI_TRANSITION_TO || pTransData->dwTransType == XUI_TRANSITION_BACKTO) 126 { 127 for(int i=0;i<eCreativeInventoryTab_COUNT;i++) 128 { 129 m_hGroupIconA[i].PlayVisualRange(specs[i]->m_icon,NULL,specs[i]->m_icon); 130 XuiElementSetShow(m_hGroupIconA[i].m_hObj,TRUE); 131 } 132 } 133 134 return S_OK; 135} 136 137CXuiControl* CXuiSceneInventoryCreative::GetSectionControl( ESceneSection eSection ) 138{ 139 switch( eSection ) 140 { 141 case eSectionInventoryCreativeUsing: 142 return (CXuiControl *)m_useRowControl; 143 break; 144 case eSectionInventoryCreativeSelector: 145 return (CXuiControl *)m_containerControl; 146 break; 147 default: 148 assert( false ); 149 break; 150 } 151 return NULL; 152} 153 154CXuiCtrlSlotList* CXuiSceneInventoryCreative::GetSectionSlotList( ESceneSection eSection ) 155{ 156 switch( eSection ) 157 { 158 case eSectionInventoryCreativeUsing: 159 return m_useRowControl; 160 break; 161 case eSectionInventoryCreativeSelector: 162 return m_containerControl; 163 break; 164 default: 165 assert( false ); 166 break; 167 } 168 return NULL; 169} 170 171void CXuiSceneInventoryCreative::updateTabHighlightAndText(ECreativeInventoryTabs tab) 172{ 173 if (m_curTab < eCreativeInventoryTab_COUNT) 174 { 175 m_hTabGroupA[m_curTab].SetShow(FALSE); 176 } 177 178 m_hTabGroupA[tab].SetShow(TRUE); 179 wstring wsText=app.GetString(specs[tab]->m_descriptionId); 180 m_GroupDescription.SetText(wsText.c_str()); 181 m_GroupDescription.SetShow(TRUE); 182} 183 184void CXuiSceneInventoryCreative::updateScrollCurrentPage(int currentPage, int pageCount) 185{ 186 m_pageSlider.SetEnable(pageCount > 1); 187 188 if(pageCount == 1) 189 { 190 m_pageSlider.SetRange(0,1); 191 m_pageSlider.SetValue(0); 192 } 193 else 194 { 195 m_pageSlider.SetRange(0,pageCount - 1); 196 m_pageSlider.SetValue(currentPage - 1); 197 } 198 199 m_scrollUp.SetShow(currentPage > 1); 200 m_scrollUp.PlayOptionalVisual(L"ScrollMore",L"EndScrollMore"); 201 202 203 m_scrollDown.SetShow(currentPage < pageCount); 204 m_scrollDown.PlayOptionalVisual(L"ScrollMore",L"EndScrollMore"); 205 206 //wchar_t pageNum[10]; 207 //swprintf(pageNum,10,L"%d/%d",currentPage,pageCount); 208 //m_pageNumber.SetText(pageNum); 209}