the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 197 lines 4.5 kB view raw
1#include "stdafx.h" 2#include "UI.h" 3#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.entity.h" 4#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h" 5#include "..\..\Minecraft.h" 6#include "UIScene_DispenserMenu.h" 7 8UIScene_DispenserMenu::UIScene_DispenserMenu(int iPad, void *_initData, UILayer *parentLayer) : UIScene_AbstractContainerMenu(iPad, parentLayer) 9{ 10 // Setup all the Iggy references we need for this scene 11 initialiseMovie(); 12 13 TrapScreenInput *initData = (TrapScreenInput *)_initData; 14 15 m_labelDispenser.init(initData->trap->getName()); 16 17 Minecraft *pMinecraft = Minecraft::GetInstance(); 18 if( pMinecraft->localgameModes[initData->iPad] != NULL ) 19 { 20 TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; 21 m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); 22 gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Trap_Menu, this); 23 } 24 25 TrapMenu* menu = new TrapMenu( initData->inventory, initData->trap ); 26 27 m_containerSize = initData->trap->getContainerSize(); 28 Initialize( initData->iPad, menu, true, m_containerSize, eSectionTrapUsing, eSectionTrapMax ); 29 30 m_slotListTrap.addSlots(0, 9); 31 32 delete initData; 33} 34 35wstring UIScene_DispenserMenu::getMoviePath() 36{ 37 if(app.GetLocalPlayerCount() > 1) 38 { 39 return L"DispenserMenuSplit"; 40 } 41 else 42 { 43 return L"DispenserMenu"; 44 } 45} 46 47void UIScene_DispenserMenu::handleReload() 48{ 49 Initialize( m_iPad, m_menu, true, m_containerSize, eSectionTrapUsing, eSectionTrapMax ); 50 51 m_slotListTrap.addSlots(0, 9); 52} 53 54int UIScene_DispenserMenu::getSectionColumns(ESceneSection eSection) 55{ 56 int cols = 0; 57 switch( eSection ) 58 { 59 case eSectionTrapTrap: 60 cols = 3; 61 break; 62 case eSectionTrapInventory: 63 cols = 9; 64 break; 65 case eSectionTrapUsing: 66 cols = 9; 67 break; 68 default: 69 assert( false ); 70 break; 71 } 72 return cols; 73} 74 75int UIScene_DispenserMenu::getSectionRows(ESceneSection eSection) 76{ 77 int rows = 0; 78 switch( eSection ) 79 { 80 case eSectionTrapTrap: 81 rows = 3; 82 break; 83 case eSectionTrapInventory: 84 rows = 3; 85 break; 86 case eSectionTrapUsing: 87 rows = 1; 88 break; 89 default: 90 assert( false ); 91 break; 92 } 93 return rows; 94} 95 96void UIScene_DispenserMenu::GetPositionOfSection( ESceneSection eSection, UIVec2D* pPosition ) 97{ 98 switch( eSection ) 99 { 100 case eSectionTrapTrap: 101 pPosition->x = m_slotListTrap.getXPos(); 102 pPosition->y = m_slotListTrap.getYPos(); 103 break; 104 case eSectionTrapInventory: 105 pPosition->x = m_slotListInventory.getXPos(); 106 pPosition->y = m_slotListInventory.getYPos(); 107 break; 108 case eSectionTrapUsing: 109 pPosition->x = m_slotListHotbar.getXPos(); 110 pPosition->y = m_slotListHotbar.getYPos(); 111 break; 112 default: 113 assert( false ); 114 break; 115 } 116} 117 118void UIScene_DispenserMenu::GetItemScreenData( ESceneSection eSection, int iItemIndex, UIVec2D* pPosition, UIVec2D* pSize ) 119{ 120 UIVec2D sectionSize; 121 switch( eSection ) 122 { 123 case eSectionTrapTrap: 124 sectionSize.x = m_slotListTrap.getWidth(); 125 sectionSize.y = m_slotListTrap.getHeight(); 126 break; 127 case eSectionTrapInventory: 128 sectionSize.x = m_slotListInventory.getWidth(); 129 sectionSize.y = m_slotListInventory.getHeight(); 130 break; 131 case eSectionTrapUsing: 132 sectionSize.x = m_slotListHotbar.getWidth(); 133 sectionSize.y = m_slotListHotbar.getHeight(); 134 break; 135 default: 136 assert( false ); 137 break; 138 } 139 140 int rows = getSectionRows(eSection); 141 int cols = getSectionColumns(eSection); 142 143 pSize->x = sectionSize.x/cols; 144 pSize->y = sectionSize.y/rows; 145 146 int itemCol = iItemIndex % cols; 147 int itemRow = iItemIndex/cols; 148 149 pPosition->x = itemCol * pSize->x; 150 pPosition->y = itemRow * pSize->y; 151} 152 153void UIScene_DispenserMenu::setSectionSelectedSlot(ESceneSection eSection, int x, int y) 154{ 155 int cols = getSectionColumns(eSection); 156 157 int index = (y * cols) + x; 158 159 UIControl_SlotList *slotList = NULL; 160 switch( eSection ) 161 { 162 case eSectionTrapTrap: 163 slotList = &m_slotListTrap; 164 break; 165 case eSectionTrapInventory: 166 slotList = &m_slotListInventory; 167 break; 168 case eSectionTrapUsing: 169 slotList = &m_slotListHotbar; 170 break; 171 default: 172 assert( false ); 173 break; 174 } 175 slotList->setHighlightSlot(index); 176} 177 178UIControl *UIScene_DispenserMenu::getSection(ESceneSection eSection) 179{ 180 UIControl *control = NULL; 181 switch( eSection ) 182 { 183 case eSectionTrapTrap: 184 control = &m_slotListTrap; 185 break; 186 case eSectionTrapInventory: 187 control = &m_slotListInventory; 188 break; 189 case eSectionTrapUsing: 190 control = &m_slotListHotbar; 191 break; 192 default: 193 assert( false ); 194 break; 195 } 196 return control; 197}