the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 309 lines 7.5 kB view raw
1#include "stdafx.h" 2#include "UI.h" 3#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h" 4#include "..\..\..\Minecraft.World\net.minecraft.world.item.alchemy.h" 5#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.entity.h" 6#include "..\..\Minecraft.h" 7#include "UIScene_BrewingStandMenu.h" 8 9UIScene_BrewingStandMenu::UIScene_BrewingStandMenu(int iPad, void *_initData, UILayer *parentLayer) : UIScene_AbstractContainerMenu(iPad, parentLayer) 10{ 11 // Setup all the Iggy references we need for this scene 12 initialiseMovie(); 13 14 m_progressBrewingArrow.init(L"",0,0,PotionBrewing::BREWING_TIME_SECONDS * SharedConstants::TICKS_PER_SECOND,0); 15 m_progressBrewingBubbles.init(L"",0,0,30,0); 16 17 BrewingScreenInput *initData = (BrewingScreenInput *)_initData; 18 m_brewingStand = initData->brewingStand; 19 20 m_labelBrewingStand.init( m_brewingStand->getName() ); 21 22 Minecraft *pMinecraft = Minecraft::GetInstance(); 23 if( pMinecraft->localgameModes[initData->iPad] != NULL ) 24 { 25 TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; 26 m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); 27 gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Brewing_Menu, this); 28 } 29 30 BrewingStandMenu* menu = new BrewingStandMenu( initData->inventory, initData->brewingStand ); 31 32 Initialize( initData->iPad, menu, true, BrewingStandMenu::INV_SLOT_START, eSectionBrewingUsing, eSectionBrewingMax ); 33 34 m_slotListIngredient.addSlots(BrewingStandMenu::INGREDIENT_SLOT, 1); 35 36 for(unsigned int i = 0; i < 3; ++i) 37 { 38 m_slotListBottles[i].addSlots(BrewingStandMenu::BOTTLE_SLOT_START + i, 1); 39 } 40 41 if(initData) delete initData; 42 43 app.SetRichPresenceContext(iPad, CONTEXT_GAME_STATE_BREWING); 44} 45 46wstring UIScene_BrewingStandMenu::getMoviePath() 47{ 48 if(app.GetLocalPlayerCount() > 1) 49 { 50 return L"BrewingStandMenuSplit"; 51 } 52 else 53 { 54 return L"BrewingStandMenu"; 55 } 56} 57 58void UIScene_BrewingStandMenu::handleReload() 59{ 60 Initialize( m_iPad, m_menu, true, BrewingStandMenu::INV_SLOT_START, eSectionBrewingUsing, eSectionBrewingMax ); 61 62 m_slotListIngredient.addSlots(BrewingStandMenu::INGREDIENT_SLOT, 1); 63 64 for(unsigned int i = 0; i < 3; ++i) 65 { 66 m_slotListBottles[i].addSlots(BrewingStandMenu::BOTTLE_SLOT_START + i, 1); 67 } 68} 69 70void UIScene_BrewingStandMenu::tick() 71{ 72 m_progressBrewingArrow.setProgress( m_brewingStand->getBrewTime() ); 73 74 int value = 0; 75 int bubbleStep = (m_brewingStand->getBrewTime() / 2) % 7; 76 switch (bubbleStep) 77 { 78 case 0: 79 value = 0; 80 break; 81 case 6: 82 value = 5; 83 break; 84 case 5: 85 value = 10; 86 break; 87 case 4: 88 value = 15; 89 break; 90 case 3: 91 value = 20; 92 break; 93 case 2: 94 value = 25; 95 break; 96 case 1: 97 value = 30; 98 break; 99 } 100 m_progressBrewingBubbles.setProgress( value); 101 UIScene_AbstractContainerMenu::tick(); 102} 103 104int UIScene_BrewingStandMenu::getSectionColumns(ESceneSection eSection) 105{ 106 int cols = 0; 107 switch( eSection ) 108 { 109 case eSectionBrewingBottle1: 110 cols = 1; 111 break; 112 case eSectionBrewingBottle2: 113 cols = 1; 114 break; 115 case eSectionBrewingBottle3: 116 cols = 1; 117 break; 118 case eSectionBrewingIngredient: 119 cols = 1; 120 break; 121 case eSectionBrewingInventory: 122 cols = 9; 123 break; 124 case eSectionBrewingUsing: 125 cols = 9; 126 break; 127 default: 128 assert( false ); 129 break; 130 } 131 return cols; 132} 133 134int UIScene_BrewingStandMenu::getSectionRows(ESceneSection eSection) 135{ 136 int rows = 0; 137 switch( eSection ) 138 { 139 case eSectionBrewingBottle1: 140 rows = 1; 141 break; 142 case eSectionBrewingBottle2: 143 rows = 1; 144 break; 145 case eSectionBrewingBottle3: 146 rows = 1; 147 break; 148 case eSectionBrewingIngredient: 149 rows = 1; 150 break; 151 case eSectionBrewingInventory: 152 rows = 3; 153 break; 154 case eSectionBrewingUsing: 155 rows = 1; 156 break; 157 default: 158 assert( false ); 159 break; 160 } 161 return rows; 162} 163 164void UIScene_BrewingStandMenu::GetPositionOfSection( ESceneSection eSection, UIVec2D* pPosition ) 165{ 166 switch( eSection ) 167 { 168 case eSectionBrewingBottle1: 169 pPosition->x = m_slotListBottles[0].getXPos(); 170 pPosition->y = m_slotListBottles[0].getYPos(); 171 break; 172 case eSectionBrewingBottle2: 173 pPosition->x = m_slotListBottles[1].getXPos(); 174 pPosition->y = m_slotListBottles[1].getYPos(); 175 break; 176 case eSectionBrewingBottle3: 177 pPosition->x = m_slotListBottles[2].getXPos(); 178 pPosition->y = m_slotListBottles[2].getYPos(); 179 break; 180 case eSectionBrewingIngredient: 181 pPosition->x = m_slotListIngredient.getXPos(); 182 pPosition->y = m_slotListIngredient.getYPos(); 183 break; 184 case eSectionBrewingInventory: 185 pPosition->x = m_slotListInventory.getXPos(); 186 pPosition->y = m_slotListInventory.getYPos(); 187 break; 188 case eSectionBrewingUsing: 189 pPosition->x = m_slotListHotbar.getXPos(); 190 pPosition->y = m_slotListHotbar.getYPos(); 191 break; 192 default: 193 assert( false ); 194 break; 195 } 196} 197 198void UIScene_BrewingStandMenu::GetItemScreenData( ESceneSection eSection, int iItemIndex, UIVec2D* pPosition, UIVec2D* pSize ) 199{ 200 UIVec2D sectionSize; 201 202 switch( eSection ) 203 { 204 case eSectionBrewingBottle1: 205 sectionSize.x = m_slotListBottles[0].getWidth(); 206 sectionSize.y = m_slotListBottles[0].getHeight(); 207 break; 208 case eSectionBrewingBottle2: 209 sectionSize.x = m_slotListBottles[1].getWidth(); 210 sectionSize.y = m_slotListBottles[1].getHeight(); 211 break; 212 case eSectionBrewingBottle3: 213 sectionSize.x = m_slotListBottles[2].getWidth(); 214 sectionSize.y = m_slotListBottles[2].getHeight(); 215 break; 216 case eSectionBrewingIngredient: 217 sectionSize.x = m_slotListIngredient.getWidth(); 218 sectionSize.y = m_slotListIngredient.getHeight(); 219 break; 220 case eSectionBrewingInventory: 221 sectionSize.x = m_slotListInventory.getWidth(); 222 sectionSize.y = m_slotListInventory.getHeight(); 223 break; 224 case eSectionBrewingUsing: 225 sectionSize.x = m_slotListHotbar.getWidth(); 226 sectionSize.y = m_slotListHotbar.getHeight(); 227 break; 228 default: 229 assert( false ); 230 break; 231 } 232 233 int rows = getSectionRows(eSection); 234 int cols = getSectionColumns(eSection); 235 236 pSize->x = sectionSize.x/cols; 237 pSize->y = sectionSize.y/rows; 238 239 int itemCol = iItemIndex % cols; 240 int itemRow = iItemIndex/cols; 241 242 pPosition->x = itemCol * pSize->x; 243 pPosition->y = itemRow * pSize->y; 244} 245 246void UIScene_BrewingStandMenu::setSectionSelectedSlot(ESceneSection eSection, int x, int y) 247{ 248 int cols = getSectionColumns(eSection); 249 250 int index = (y * cols) + x; 251 252 UIControl_SlotList *slotList = NULL; 253 switch( eSection ) 254 { 255 case eSectionBrewingBottle1: 256 slotList = &m_slotListBottles[0]; 257 break; 258 case eSectionBrewingBottle2: 259 slotList = &m_slotListBottles[1]; 260 break; 261 case eSectionBrewingBottle3: 262 slotList = &m_slotListBottles[2]; 263 break; 264 case eSectionBrewingIngredient: 265 slotList = &m_slotListIngredient; 266 break; 267 case eSectionBrewingInventory: 268 slotList = &m_slotListInventory; 269 break; 270 case eSectionBrewingUsing: 271 slotList = &m_slotListHotbar; 272 break; 273 default: 274 assert( false ); 275 break; 276 } 277 278 slotList->setHighlightSlot(index); 279} 280 281UIControl *UIScene_BrewingStandMenu::getSection(ESceneSection eSection) 282{ 283 UIControl *control = NULL; 284 switch( eSection ) 285 { 286 case eSectionBrewingBottle1: 287 control = &m_slotListBottles[0]; 288 break; 289 case eSectionBrewingBottle2: 290 control = &m_slotListBottles[1]; 291 break; 292 case eSectionBrewingBottle3: 293 control = &m_slotListBottles[2]; 294 break; 295 case eSectionBrewingIngredient: 296 control = &m_slotListIngredient; 297 break; 298 case eSectionBrewingInventory: 299 control = &m_slotListInventory; 300 break; 301 case eSectionBrewingUsing: 302 control = &m_slotListHotbar; 303 break; 304 default: 305 assert( false ); 306 break; 307 } 308 return control; 309}