the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 787 lines 22 kB view raw
1#include "stdafx.h" 2#include "UI.h" 3#include "..\..\Minecraft.h" 4#include "..\..\MultiplayerLocalPlayer.h" 5#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h" 6#include "UIScene_CraftingMenu.h" 7 8#ifdef __PSVITA__ 9#define GAME_CRAFTING_TOUCHUPDATE_TIMER_ID 0 10#define GAME_CRAFTING_TOUCHUPDATE_TIMER_TIME 100 11#endif 12 13UIScene_CraftingMenu::UIScene_CraftingMenu(int iPad, void *_initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) 14{ 15 m_bIgnoreKeyPresses = false; 16 17 CraftingPanelScreenInput* initData = (CraftingPanelScreenInput*)_initData; 18 m_iContainerType=initData->iContainerType; 19 m_pPlayer=initData->player; 20 m_bSplitscreen=initData->bSplitscreen; 21 22 // Setup all the Iggy references we need for this scene 23 initialiseMovie(); 24 25 for(unsigned int i = 0; i < 4; ++i) m_labelIngredientsDesc[i].init(L""); 26 m_labelDescription.init(L""); 27 m_labelGroupName.init(L""); 28 m_labelItemName.init(L""); 29 m_labelInventory.init( app.GetString(IDS_INVENTORY) ); 30 m_labelIngredients.init( app.GetString(IDS_INGREDIENTS) ); 31 32 if(m_iContainerType==RECIPE_TYPE_2x2) 33 { 34 m_menu = m_pPlayer->inventoryMenu; 35 m_iMenuInventoryStart = InventoryMenu::INV_SLOT_START; 36 m_iMenuHotBarStart = InventoryMenu::USE_ROW_SLOT_START; 37 } 38 else 39 { 40 CraftingMenu *menu = new CraftingMenu(m_pPlayer->inventory, m_pPlayer->level, initData->x, initData->y, initData->z); 41 Minecraft::GetInstance()->localplayers[m_iPad]->containerMenu = menu; 42 43 m_menu = menu; 44 m_iMenuInventoryStart = CraftingMenu::INV_SLOT_START; 45 m_iMenuHotBarStart = CraftingMenu::USE_ROW_SLOT_START; 46 } 47 m_slotListInventory.addSlots(CRAFTING_INVENTORY_SLOT_START,CRAFTING_INVENTORY_SLOT_END - CRAFTING_INVENTORY_SLOT_START); 48 m_slotListHotBar.addSlots(CRAFTING_HOTBAR_SLOT_START, CRAFTING_HOTBAR_SLOT_END - CRAFTING_HOTBAR_SLOT_START); 49 50#if TO_BE_IMPLEMENTED 51 // if we are in splitscreen, then we need to figure out if we want to move this scene 52 if(m_bSplitscreen) 53 { 54 app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad); 55 } 56 57 XuiElementSetShow(m_hGrid,TRUE); 58 XuiElementSetShow(m_hPanel,TRUE); 59#endif 60 61 if(m_iContainerType==RECIPE_TYPE_3x3) 62 { 63 m_iIngredientsMaxSlotC = m_iIngredients3x3SlotC; 64 m_pGroupA=(Recipy::_eGroupType *)&m_GroupTypeMapping9GridA; 65 m_pGroupTabA=(_eGroupTab *)&m_GroupTabBkgMapping3x3A; 66 m_iCraftablesMaxHSlotC=m_iMaxHSlot3x3C; 67 } 68 else 69 { 70 m_iIngredientsMaxSlotC = m_iIngredients2x2SlotC; 71 m_pGroupA=(Recipy::_eGroupType *)&m_GroupTypeMapping4GridA; 72 m_pGroupTabA=(_eGroupTab *)&m_GroupTabBkgMapping2x2A; 73 m_iCraftablesMaxHSlotC=m_iMaxHSlot2x2C; 74 } 75 76#if TO_BE_IMPLEMENTED 77 78 79 // display the first group tab 80 m_hTabGroupA[m_iGroupIndex].SetShow(TRUE); 81 82 // store the slot 0 position 83 m_pHSlotsBrushImageControl[0]->GetPosition(&m_vSlot0Pos); 84 m_pHSlotsBrushImageControl[1]->GetPosition(&vec); 85 m_fSlotSize=vec.x-m_vSlot0Pos.x; 86 87 // store the slot 0 highlight position 88 m_hHighlight.GetPosition(&m_vSlot0HighlightPos); 89 // Store the V slot position 90 m_hScrollBar2.GetPosition(&m_vSlot0V2ScrollPos); 91 m_hScrollBar3.GetPosition(&m_vSlot0V3ScrollPos); 92 93 // get the position of the slot from the xui, and apply any offset needed 94 for(int i=0;i<m_iCraftablesMaxHSlotC;i++) 95 { 96 m_pHSlotsBrushImageControl[i]->SetShow(FALSE); 97 } 98 99 XuiElementSetShow(m_hGridInventory,FALSE); 100 101 m_hScrollBar2.SetShow(FALSE); 102 m_hScrollBar3.SetShow(FALSE); 103 104#endif 105 106 app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_CRAFTING); 107 setGroupText(GetGroupNameText(m_pGroupA[m_iGroupIndex])); 108 109 // Update the tutorial state 110 Minecraft *pMinecraft = Minecraft::GetInstance(); 111 112 if( pMinecraft->localgameModes[m_iPad] != NULL ) 113 { 114 TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; 115 m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); 116 if(m_iContainerType==RECIPE_TYPE_2x2) 117 { 118 gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_2x2Crafting_Menu, this); 119 } 120 else 121 { 122 gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_3x3Crafting_Menu, this); 123 } 124 } 125 126#ifdef _TO_BE_IMPLEMENTED 127 XuiSetTimer(m_hObj,IGNORE_KEYPRESS_TIMERID,IGNORE_KEYPRESS_TIME); 128#endif 129 130 for(unsigned int i = 0; i < 4; ++i) 131 { 132 m_slotListIngredients[i].addSlot(CRAFTING_INGREDIENTS_DESCRIPTION_START + i); 133 } 134 m_slotListCraftingOutput.addSlot(CRAFTING_OUTPUT_SLOT_START); 135 m_slotListIngredientsLayout.addSlots(CRAFTING_INGREDIENTS_LAYOUT_START, m_iIngredientsMaxSlotC); 136 137 // 3 Slot vertical scroll 138 m_slotListCrafting3VSlots[0].addSlot(CRAFTING_V_SLOT_START + 0); 139 m_slotListCrafting3VSlots[1].addSlot(CRAFTING_V_SLOT_START + 1); 140 m_slotListCrafting3VSlots[2].addSlot(CRAFTING_V_SLOT_START + 2); 141 142 // 2 Slot vertical scroll 143 // 2 slot scroll has swapped order 144 m_slotListCrafting2VSlots[0].addSlot(CRAFTING_V_SLOT_START + 1); 145 m_slotListCrafting2VSlots[1].addSlot(CRAFTING_V_SLOT_START + 0); 146 147 // 1 Slot scroll (for 480 mainly) 148 m_slotListCrafting1VSlots.addSlot(CRAFTING_V_SLOT_START); 149 150 m_slotListCraftingHSlots.addSlots(CRAFTING_H_SLOT_START,m_iCraftablesMaxHSlotC); 151 152 // Check which recipes are available with the resources we have 153 CheckRecipesAvailable(); 154 // reset the vertical slots 155 iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; 156 iVSlotIndexA[1]=0; 157 iVSlotIndexA[2]=1; 158 UpdateVerticalSlots(); 159 UpdateHighlight(); 160 161 if(initData) delete initData; 162 163 // in this scene, we override the press sound with our own for crafting success or fail 164 ui.OverrideSFX(m_iPad,ACTION_MENU_A,true); 165 ui.OverrideSFX(m_iPad,ACTION_MENU_OK,true); 166#ifdef __ORBIS__ 167 ui.OverrideSFX(m_iPad,ACTION_MENU_TOUCHPAD_PRESS,true); 168#endif 169 ui.OverrideSFX(m_iPad,ACTION_MENU_LEFT_SCROLL,true); 170 ui.OverrideSFX(m_iPad,ACTION_MENU_RIGHT_SCROLL,true); 171 ui.OverrideSFX(m_iPad,ACTION_MENU_LEFT,true); 172 ui.OverrideSFX(m_iPad,ACTION_MENU_RIGHT,true); 173 ui.OverrideSFX(m_iPad,ACTION_MENU_UP,true); 174 ui.OverrideSFX(m_iPad,ACTION_MENU_DOWN,true); 175 176 // 4J-PB - Must be after the CanBeMade list has been set up with CheckRecipesAvailable 177 UpdateTooltips(); 178 179#ifdef __PSVITA__ 180 // initialise vita touch controls with ids 181 for(unsigned int i = 0; i < ETouchInput_Count; ++i) 182 { 183 m_TouchInput[i].init(i); 184 } 185 ui.TouchBoxRebuild(this); 186#endif 187} 188 189void UIScene_CraftingMenu::handleDestroy() 190{ 191 Minecraft *pMinecraft = Minecraft::GetInstance(); 192 193 if( pMinecraft->localgameModes[m_iPad] != NULL ) 194 { 195 TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; 196 if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); 197 } 198 199 // 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) 200 if(Minecraft::GetInstance()->localplayers[m_iPad] != NULL && Minecraft::GetInstance()->localplayers[m_iPad]->containerMenu->containerId == m_menu->containerId) 201 { 202 Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); 203 } 204 205 ui.OverrideSFX(m_iPad,ACTION_MENU_A,false); 206 ui.OverrideSFX(m_iPad,ACTION_MENU_OK,false); 207#ifdef __ORBIS__ 208 ui.OverrideSFX(m_iPad,ACTION_MENU_TOUCHPAD_PRESS,false); 209#endif 210 ui.OverrideSFX(m_iPad,ACTION_MENU_LEFT_SCROLL,false); 211 ui.OverrideSFX(m_iPad,ACTION_MENU_RIGHT_SCROLL,false); 212 ui.OverrideSFX(m_iPad,ACTION_MENU_LEFT,false); 213 ui.OverrideSFX(m_iPad,ACTION_MENU_RIGHT,false); 214 ui.OverrideSFX(m_iPad,ACTION_MENU_UP,false); 215 ui.OverrideSFX(m_iPad,ACTION_MENU_DOWN,false); 216} 217 218EUIScene UIScene_CraftingMenu::getSceneType() 219{ 220 if(m_iContainerType==RECIPE_TYPE_3x3) 221 { 222 return eUIScene_Crafting3x3Menu; 223 } 224 else 225 { 226 return eUIScene_Crafting2x2Menu; 227 } 228} 229 230wstring UIScene_CraftingMenu::getMoviePath() 231{ 232 if(app.GetLocalPlayerCount() > 1) 233 { 234 m_bSplitscreen = true; 235 if(m_iContainerType==RECIPE_TYPE_3x3) 236 { 237 return L"Crafting3x3MenuSplit"; 238 } 239 else 240 { 241 return L"Crafting2x2MenuSplit"; 242 } 243 } 244 else 245 { 246 if(m_iContainerType==RECIPE_TYPE_3x3) 247 { 248 return L"Crafting3x3Menu"; 249 } 250 else 251 { 252 return L"Crafting2x2Menu"; 253 } 254 } 255} 256 257#ifdef __PSVITA__ 258UIControl* UIScene_CraftingMenu::GetMainPanel() 259{ 260 return &m_controlMainPanel; 261} 262 263void UIScene_CraftingMenu::handleTouchInput(unsigned int iPad, S32 x, S32 y, int iId, bool bPressed, bool bRepeat, bool bReleased) 264{ 265 // perform action on release 266 if(bPressed) 267 { 268 if(iId == ETouchInput_CraftingHSlots) 269 { 270 m_iCraftingSlotTouchStartY = y; 271 } 272 } 273 else if(bRepeat) 274 { 275 if(iId == ETouchInput_CraftingHSlots) 276 { 277 if(y >= m_iCraftingSlotTouchStartY + m_TouchInput[ETouchInput_CraftingHSlots].getHeight()) // scroll list down 278 { 279 if(iVSlotIndexA[1]==(CanBeMadeA[m_iCurrentSlotHIndex].iCount-1)) 280 { 281 iVSlotIndexA[1]=0; 282 } 283 else 284 { 285 iVSlotIndexA[1]++; 286 } 287 ui.PlayUISFX(eSFX_Focus); 288 289 UpdateVerticalSlots(); 290 UpdateHighlight(); 291 292 m_iCraftingSlotTouchStartY = y; 293 } 294 else if(y <= m_iCraftingSlotTouchStartY - m_TouchInput[ETouchInput_CraftingHSlots].getHeight()) // scroll list up 295 { 296 if(iVSlotIndexA[1]==0) 297 { 298 iVSlotIndexA[1]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; 299 } 300 else 301 { 302 iVSlotIndexA[1]--; 303 } 304 ui.PlayUISFX(eSFX_Focus); 305 306 UpdateVerticalSlots(); 307 UpdateHighlight(); 308 309 m_iCraftingSlotTouchStartY = y; 310 } 311 } 312 } 313 else if(bReleased) 314 { 315 if(iId >= ETouchInput_TouchPanel_0 && iId <= ETouchInput_TouchPanel_6) // Touch Change Group 316 { 317 m_iGroupIndex = iId; 318 // turn on the new group 319 showTabHighlight(m_iGroupIndex,true); 320 321 m_iCurrentSlotHIndex=0; 322 m_iCurrentSlotVIndex=1; 323 CheckRecipesAvailable(); 324 // reset the vertical slots 325 iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; 326 iVSlotIndexA[1]=0; 327 iVSlotIndexA[2]=1; 328 ui.PlayUISFX(eSFX_Focus); 329 UpdateVerticalSlots(); 330 UpdateHighlight(); 331 setGroupText(GetGroupNameText(m_pGroupA[m_iGroupIndex])); 332 } 333 else if(iId == ETouchInput_CraftingHSlots) // Touch Change Slot 334 { 335 int iMaxHSlots = 0; 336 if(m_iContainerType==RECIPE_TYPE_3x3) 337 { 338 iMaxHSlots = m_iMaxHSlot3x3C; 339 } 340 else 341 { 342 iMaxHSlots = m_iMaxHSlot2x2C; 343 } 344 345 int iNewSlot = (x - m_TouchInput[ETouchInput_CraftingHSlots].getXPos() - m_controlMainPanel.getXPos()) / m_TouchInput[ETouchInput_CraftingHSlots].getHeight(); 346 347 int iOldHSlot=m_iCurrentSlotHIndex; 348 349 m_iCurrentSlotHIndex = iNewSlot; 350 if(m_iCurrentSlotHIndex>=m_iCraftablesMaxHSlotC) m_iCurrentSlotHIndex=0; 351 m_iCurrentSlotVIndex=1; 352 // clear the indices 353 iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; 354 iVSlotIndexA[1]=0; 355 iVSlotIndexA[2]=1; 356 357 UpdateVerticalSlots(); 358 UpdateHighlight(); 359 // re-enable the old hslot 360 if(CanBeMadeA[iOldHSlot].iCount>0) 361 { 362 setShowCraftHSlot(iOldHSlot,true); 363 } 364 ui.PlayUISFX(eSFX_Focus); 365 } 366 } 367} 368 369void UIScene_CraftingMenu::handleTouchBoxRebuild() 370{ 371 addTimer(GAME_CRAFTING_TOUCHUPDATE_TIMER_ID,GAME_CRAFTING_TOUCHUPDATE_TIMER_TIME); 372} 373 374void UIScene_CraftingMenu::handleTimerComplete(int id) 375{ 376 if(id == GAME_CRAFTING_TOUCHUPDATE_TIMER_ID) 377 { 378 // we cannot rebuild touch boxes in an iggy callback because it requires further iggy calls 379 GetMainPanel()->UpdateControl(); 380 ui.TouchBoxRebuild(this); 381 killTimer(GAME_CRAFTING_TOUCHUPDATE_TIMER_ID); 382 } 383} 384#endif 385 386void UIScene_CraftingMenu::handleReload() 387{ 388 m_slotListInventory.addSlots(CRAFTING_INVENTORY_SLOT_START,CRAFTING_INVENTORY_SLOT_END - CRAFTING_INVENTORY_SLOT_START); 389 m_slotListHotBar.addSlots(CRAFTING_HOTBAR_SLOT_START, CRAFTING_HOTBAR_SLOT_END - CRAFTING_HOTBAR_SLOT_START); 390 391 for(unsigned int i = 0; i < 4; ++i) 392 { 393 m_slotListIngredients[i].addSlot(CRAFTING_INGREDIENTS_DESCRIPTION_START + i); 394 } 395 m_slotListCraftingOutput.addSlot(CRAFTING_OUTPUT_SLOT_START); 396 m_slotListIngredientsLayout.addSlots(CRAFTING_INGREDIENTS_LAYOUT_START, m_iIngredientsMaxSlotC); 397 398 // 3 Slot vertical scroll 399 m_slotListCrafting3VSlots[0].addSlot(CRAFTING_V_SLOT_START + 0); 400 m_slotListCrafting3VSlots[1].addSlot(CRAFTING_V_SLOT_START + 1); 401 m_slotListCrafting3VSlots[2].addSlot(CRAFTING_V_SLOT_START + 2); 402 403 // 2 Slot vertical scroll 404 // 2 slot scroll has swapped order 405 m_slotListCrafting2VSlots[0].addSlot(CRAFTING_V_SLOT_START + 1); 406 m_slotListCrafting2VSlots[1].addSlot(CRAFTING_V_SLOT_START + 0); 407 408 // 1 Slot scroll (for 480 mainly) 409 m_slotListCrafting1VSlots.addSlot(CRAFTING_V_SLOT_START); 410 411 m_slotListCraftingHSlots.addSlots(CRAFTING_H_SLOT_START,m_iCraftablesMaxHSlotC); 412 413 app.DebugPrintf(app.USER_SR,"Reloading MultiPanel\n"); 414 int temp = m_iDisplayDescription; 415 m_iDisplayDescription = m_iDisplayDescription==0?1:0; 416 UpdateMultiPanel(); 417 m_iDisplayDescription = temp; 418 UpdateMultiPanel(); 419 420 app.DebugPrintf(app.USER_SR,"Reloading Highlight and scroll\n"); 421 422 // reset the vertical slots 423 m_iCurrentSlotHIndex = 0; 424 m_iCurrentSlotVIndex = 1; 425 iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; 426 iVSlotIndexA[1]=0; 427 iVSlotIndexA[2]=1; 428 UpdateVerticalSlots(); 429 UpdateHighlight(); 430 431 app.DebugPrintf(app.USER_SR,"Reloading tabs\n"); 432 showTabHighlight(0,false); 433 showTabHighlight(m_iGroupIndex,true); 434} 435 436void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion *region) 437{ 438 Minecraft *pMinecraft = Minecraft::GetInstance(); 439 if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return; 440 441 shared_ptr<ItemInstance> item = nullptr; 442 int slotId = -1; 443 float alpha = 1.0f; 444 bool decorations = true; 445 bool inventoryItem = false; 446 swscanf((wchar_t*)region->name,L"slot_%d",&slotId); 447 if (slotId == -1) 448 { 449 app.DebugPrintf("This is not the control we are looking for\n"); 450 } 451 else if(slotId >= CRAFTING_INVENTORY_SLOT_START && slotId < CRAFTING_INVENTORY_SLOT_END) 452 { 453 int iIndex = slotId - CRAFTING_INVENTORY_SLOT_START; 454 iIndex += m_iMenuInventoryStart; 455 Slot *slot = m_menu->getSlot(iIndex); 456 item = slot->getItem(); 457 inventoryItem = true; 458 } 459 else if(slotId >= CRAFTING_HOTBAR_SLOT_START && slotId < CRAFTING_HOTBAR_SLOT_END) 460 { 461 int iIndex = slotId - CRAFTING_HOTBAR_SLOT_START; 462 iIndex += m_iMenuHotBarStart; 463 Slot *slot = m_menu->getSlot(iIndex); 464 item = slot->getItem(); 465 inventoryItem = true; 466 } 467 else if(slotId >= CRAFTING_V_SLOT_START && slotId < CRAFTING_V_SLOT_END ) 468 { 469 decorations = false; 470 int iIndex = slotId - CRAFTING_V_SLOT_START; 471 if(m_vSlotsInfo[iIndex].show) 472 { 473 item = m_vSlotsInfo[iIndex].item; 474 alpha = ((float)m_vSlotsInfo[iIndex].alpha)/31.0f; 475 } 476 } 477 else if(slotId >= CRAFTING_H_SLOT_START && slotId < (CRAFTING_H_SLOT_START + m_iCraftablesMaxHSlotC) ) 478 { 479 decorations = false; 480 int iIndex = slotId - CRAFTING_H_SLOT_START; 481 if(m_hSlotsInfo[iIndex].show) 482 { 483 item = m_hSlotsInfo[iIndex].item; 484 alpha = ((float)m_hSlotsInfo[iIndex].alpha)/31.0f; 485 } 486 } 487 else if(slotId >= CRAFTING_INGREDIENTS_LAYOUT_START && slotId < (CRAFTING_INGREDIENTS_LAYOUT_START + m_iIngredientsMaxSlotC) ) 488 { 489 int iIndex = slotId - CRAFTING_INGREDIENTS_LAYOUT_START; 490 if(m_ingredientsSlotsInfo[iIndex].show) 491 { 492 item = m_ingredientsSlotsInfo[iIndex].item; 493 alpha = ((float)m_ingredientsSlotsInfo[iIndex].alpha)/31.0f; 494 } 495 } 496 else if(slotId >= CRAFTING_INGREDIENTS_DESCRIPTION_START && slotId < (CRAFTING_INGREDIENTS_DESCRIPTION_START + 4) ) 497 { 498 int iIndex = slotId - CRAFTING_INGREDIENTS_DESCRIPTION_START; 499 if(m_ingredientsInfo[iIndex].show) 500 { 501 item = m_ingredientsInfo[iIndex].item; 502 alpha = ((float)m_ingredientsInfo[iIndex].alpha)/31.0f; 503 } 504 } 505 else if(slotId == CRAFTING_OUTPUT_SLOT_START ) 506 { 507 if(m_craftingOutputSlotInfo.show) 508 { 509 item = m_craftingOutputSlotInfo.item; 510 alpha = ((float)m_craftingOutputSlotInfo.alpha)/31.0f; 511 } 512 } 513 514 if(item != NULL) 515 { 516 if(!inventoryItem) 517 { 518 if( item->id == Item::clock_Id || item->id == Item::compass_Id ) 519 { 520 // 4J Stu - For clocks and compasses we set the aux value to a special one that signals we should use a default texture 521 // rather than the dynamic one for the player 522 item->setAuxValue(0xFF); 523 } 524 else if( (item->getAuxValue() & 0xFF) == 0xFF) 525 { 526 // 4J Stu - If the aux value is set to match any 527 item->setAuxValue(0); 528 } 529 } 530 customDrawSlotControl(region,m_iPad,item,alpha,item->isFoil(),decorations); 531 } 532} 533 534int UIScene_CraftingMenu::getPad() 535{ 536 return m_iPad; 537} 538 539bool UIScene_CraftingMenu::allowRepeat(int key) 540{ 541 switch(key) 542 { 543 // X is used to open this menu, so don't let it repeat 544 case ACTION_MENU_X: 545 return false; 546 } 547 return true; 548} 549 550void UIScene_CraftingMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) 551{ 552 //app.DebugPrintf("UIScene_InventoryMenu handling input for pad %d, key %d, down- %s, pressed- %s, released- %s\n", iPad, key, down?"TRUE":"FALSE", pressed?"TRUE":"FALSE", released?"TRUE":"FALSE"); 553 ui.AnimateKeyPress(m_iPad, key, repeat, pressed, released); 554 555 switch(key) 556 { 557 case ACTION_MENU_OTHER_STICK_UP: 558 case ACTION_MENU_OTHER_STICK_DOWN: 559 sendInputToMovie(key,repeat,pressed,released); 560 break; 561 default: 562 if(pressed) 563 { 564 handled = handleKeyDown(m_iPad, key, repeat); 565 } 566 break; 567 }; 568} 569 570void UIScene_CraftingMenu::hideAllHSlots() 571{ 572 for(unsigned int iIndex = 0; iIndex < m_iMaxHSlotC; ++iIndex) 573 { 574 m_hSlotsInfo[iIndex].item = nullptr; 575 m_hSlotsInfo[iIndex].alpha = 31; 576 m_hSlotsInfo[iIndex].show = false; 577 } 578} 579 580void UIScene_CraftingMenu::hideAllVSlots() 581{ 582 for(unsigned int iIndex = 0; iIndex < m_iMaxDisplayedVSlotC; ++iIndex) 583 { 584 m_vSlotsInfo[iIndex].item = nullptr; 585 m_vSlotsInfo[iIndex].alpha = 31; 586 m_vSlotsInfo[iIndex].show = false; 587 } 588} 589 590void UIScene_CraftingMenu::hideAllIngredientsSlots() 591{ 592 for(int i=0;i<m_iIngredientsC;i++) 593 { 594 m_ingredientsInfo[i].item = nullptr; 595 m_ingredientsInfo[i].alpha = 31; 596 m_ingredientsInfo[i].show = false; 597 598 m_labelIngredientsDesc[i].setLabel(L""); 599 600 IggyDataValue result; 601 IggyDataValue value[2]; 602 603 value[0].type = IGGY_DATATYPE_number; 604 value[0].number = i; 605 606 value[1].type = IGGY_DATATYPE_boolean; 607 value[1].boolval = false; 608 IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ) , m_funcShowIngredientSlot , 2 , value ); 609 } 610} 611 612void UIScene_CraftingMenu::setCraftHSlotItem(int iPad, int iIndex, shared_ptr<ItemInstance> item, unsigned int uiAlpha) 613{ 614 m_hSlotsInfo[iIndex].item = item; 615 m_hSlotsInfo[iIndex].alpha = uiAlpha; 616 m_hSlotsInfo[iIndex].show = true; 617} 618 619void UIScene_CraftingMenu::setCraftVSlotItem(int iPad, int iIndex, shared_ptr<ItemInstance> item, unsigned int uiAlpha) 620{ 621 m_vSlotsInfo[iIndex].item = item; 622 m_vSlotsInfo[iIndex].alpha = uiAlpha; 623 m_vSlotsInfo[iIndex].show = true; 624} 625 626void UIScene_CraftingMenu::setCraftingOutputSlotItem(int iPad, shared_ptr<ItemInstance> item) 627{ 628 m_craftingOutputSlotInfo.item = item; 629 m_craftingOutputSlotInfo.alpha = 31; 630 m_craftingOutputSlotInfo.show = item != NULL; 631} 632 633void UIScene_CraftingMenu::setCraftingOutputSlotRedBox(bool show) 634{ 635 m_slotListCraftingOutput.showSlotRedBox(0,show); 636} 637 638void UIScene_CraftingMenu::setIngredientSlotItem(int iPad, int index, shared_ptr<ItemInstance> item) 639{ 640 m_ingredientsSlotsInfo[index].item = item; 641 m_ingredientsSlotsInfo[index].alpha = 31; 642 m_ingredientsSlotsInfo[index].show = item != NULL; 643} 644 645void UIScene_CraftingMenu::setIngredientSlotRedBox(int index, bool show) 646{ 647 m_slotListIngredientsLayout.showSlotRedBox(index,show); 648} 649 650void UIScene_CraftingMenu::setIngredientDescriptionItem(int iPad, int index, shared_ptr<ItemInstance> item) 651{ 652 m_ingredientsInfo[index].item = item; 653 m_ingredientsInfo[index].alpha = 31; 654 m_ingredientsInfo[index].show = item != NULL; 655 656 IggyDataValue result; 657 IggyDataValue value[2]; 658 659 value[0].type = IGGY_DATATYPE_number; 660 value[0].number = index; 661 662 value[1].type = IGGY_DATATYPE_boolean; 663 value[1].boolval = m_ingredientsInfo[index].show; 664 IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ) , m_funcShowIngredientSlot , 2 , value ); 665} 666 667void UIScene_CraftingMenu::setIngredientDescriptionRedBox(int index, bool show) 668{ 669 m_slotListIngredients[index].showSlotRedBox(0,show); 670} 671 672void UIScene_CraftingMenu::setIngredientDescriptionText(int index, LPCWSTR text) 673{ 674 m_labelIngredientsDesc[index].setLabel(text); 675} 676 677 678void UIScene_CraftingMenu::setShowCraftHSlot(int iIndex, bool show) 679{ 680 m_hSlotsInfo[iIndex].show = show; 681} 682 683void UIScene_CraftingMenu::showTabHighlight(int iIndex, bool show) 684{ 685 if(show) 686 { 687 IggyDataValue result; 688 IggyDataValue value[1]; 689 690 value[0].type = IGGY_DATATYPE_number; 691 value[0].number = iIndex; 692 IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ) , m_funcSetActiveTab , 1 , value ); 693 } 694} 695 696void UIScene_CraftingMenu::setGroupText(LPCWSTR text) 697{ 698 m_labelGroupName.setLabel(text); 699} 700 701void UIScene_CraftingMenu::setDescriptionText(LPCWSTR text) 702{ 703 m_labelDescription.setLabel(text); 704} 705 706void UIScene_CraftingMenu::setItemText(LPCWSTR text) 707{ 708 m_labelItemName.setLabel(text); 709} 710 711void UIScene_CraftingMenu::UpdateMultiPanel() 712{ 713 // Call Iggy function to show the current panel 714 IggyDataValue result; 715 IggyDataValue value[1]; 716 717 value[0].type = IGGY_DATATYPE_number; 718 value[0].number = m_iDisplayDescription; 719 720 IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ) , m_funcShowPanelDisplay , 1 , value ); 721} 722 723void UIScene_CraftingMenu::scrollDescriptionUp() 724{ 725 // handled differently 726} 727 728void UIScene_CraftingMenu::scrollDescriptionDown() 729{ 730 // handled differently 731} 732 733void UIScene_CraftingMenu::updateHighlightAndScrollPositions() 734{ 735 { 736 IggyDataValue result; 737 IggyDataValue value[2]; 738 739 value[0].type = IGGY_DATATYPE_number; 740 value[0].number = m_iCurrentSlotHIndex; 741 742 int selectorType = 0; 743 if(CanBeMadeA[m_iCurrentSlotHIndex].iCount == 2) 744 { 745 selectorType = 1; 746 } 747 else if( CanBeMadeA[m_iCurrentSlotHIndex].iCount > 2) 748 { 749 selectorType = 2; 750 } 751 752 value[1].type = IGGY_DATATYPE_number; 753 value[1].number = selectorType; 754 755 IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ) , m_funcMoveSelector , 2 , value ); 756 } 757 758 { 759 IggyDataValue result; 760 IggyDataValue value[1]; 761 762 value[0].type = IGGY_DATATYPE_number; 763 value[0].number = m_iCurrentSlotVIndex; 764 765 IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ) , m_funcSelectVerticalItem , 1 , value ); 766 } 767} 768 769void UIScene_CraftingMenu::HandleMessage(EUIMessage message, void *data) 770{ 771 switch(message) 772 { 773 case eUIMessage_InventoryUpdated: 774 handleInventoryUpdated(data); 775 break; 776 }; 777} 778 779void UIScene_CraftingMenu::handleInventoryUpdated(LPVOID data) 780{ 781 HandleInventoryUpdated(); 782} 783 784void UIScene_CraftingMenu::updateVSlotPositions(int iSlots, int i) 785{ 786 // Not needed 787}