#include "stdafx.h" #include "../../../Minecraft.World/net.minecraft.world.item.crafting.h" #include "../../../Minecraft.World/net.minecraft.world.level.tile.h" #include "../../../Minecraft.World/net.minecraft.stats.h" #include "../../LocalPlayer.h" #include "IUIScene_CraftingMenu.h" #include "UI.h" Recipy::_eGroupType IUIScene_CraftingMenu::m_GroupTypeMapping4GridA[IUIScene_CraftingMenu::m_iMaxGroupH2x2]= { Recipy::eGroupType_Structure, Recipy::eGroupType_Tool, Recipy::eGroupType_Food, Recipy::eGroupType_Mechanism, Recipy::eGroupType_Transport, Recipy::eGroupType_Decoration, }; Recipy::_eGroupType IUIScene_CraftingMenu::m_GroupTypeMapping9GridA[IUIScene_CraftingMenu::m_iMaxGroupH3x3]= { Recipy::eGroupType_Structure, Recipy::eGroupType_Tool, Recipy::eGroupType_Food, Recipy::eGroupType_Armour, Recipy::eGroupType_Mechanism, Recipy::eGroupType_Transport, Recipy::eGroupType_Decoration, }; LPCWSTR IUIScene_CraftingMenu::m_GroupIconNameA[m_iMaxGroupH3x3]= { L"Structures", L"Tools", L"Food", L"Armour", L"Mechanisms", L"Transport", L"Decoration", }; IUIScene_CraftingMenu::_eGroupTab IUIScene_CraftingMenu::m_GroupTabBkgMapping2x2A[m_iMaxGroupH2x2]= { eGroupTab_Left, eGroupTab_Middle, eGroupTab_Middle, eGroupTab_Middle, eGroupTab_Middle, eGroupTab_Right, }; IUIScene_CraftingMenu::_eGroupTab IUIScene_CraftingMenu::m_GroupTabBkgMapping3x3A[m_iMaxGroupH3x3]= { eGroupTab_Left, eGroupTab_Middle, eGroupTab_Middle, eGroupTab_Middle, eGroupTab_Middle, eGroupTab_Middle, eGroupTab_Right, }; IUIScene_CraftingMenu::IUIScene_CraftingMenu() { m_iCurrentSlotHIndex=0; m_iCurrentSlotVIndex=1; memset(CanBeMadeA,0,sizeof(CANBEMADE)*m_iMaxHSlotC); m_iRecipeC=0; m_iGroupHIndex = 0; m_iGroupVIndex = 0; m_pGroupA = nullptr; for(int i=0;ilocalgameModes[getPad()] != nullptr ) { Tutorial *tutorial = pMinecraft->localgameModes[getPad()]->getTutorial(); if(tutorial != nullptr) { tutorial->handleUIInput(iAction); if(ui.IsTutorialVisible(getPad()) && !tutorial->isInputAllowed(iAction)) { return S_OK; } } } if (iAction == ACTION_MENU_PAGEUP || iAction == ACTION_MENU_PAGEDOWN) { if (iAction == ACTION_MENU_PAGEUP) { m_iGroupVIndex = (m_iGroupVIndex == 0) ? getMaxVGroups() - 1 : m_iGroupVIndex - 1; } else { m_iGroupVIndex++; if (m_iGroupVIndex >= getMaxVGroups()) m_iGroupVIndex = 0; } m_iGroupHIndex = 0; m_iCurrentSlotHIndex = 0; m_iCurrentSlotVIndex = 1; ui.PlayUISFX(eSFX_Focus); if (isSpecialTab()) { Special_EnterTab(); } else { m_iDisplayDescription = DISPLAY_INVENTORY; setVGroupHighlight(m_iGroupVIndex); UpdateCraftingPanels(); CheckRecipesAvailable(); iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; iVSlotIndexA[1] = 0; iVSlotIndexA[2] = 1; UpdateVerticalSlots(); UpdateHighlight(); setGroupText(GetGroupNameText(m_pGroupA[m_iGroupHIndex])); UpdateTooltips(); } return true; } if (isSpecialTab()) { return Special_HandleKeyDown(iPad, iAction, bRepeat); } switch(iAction) { case ACTION_MENU_X: m_iDisplayDescription++; if (m_iDisplayDescription == DISPLAY_PREVIEW) m_iDisplayDescription++; if(m_iDisplayDescription>=DISPLAY_MAX) m_iDisplayDescription=DISPLAY_INVENTORY; ui.PlayUISFX(eSFX_Focus); UpdateMultiPanel(); UpdateTooltips(); break; case ACTION_MENU_PAUSEMENU: case ACTION_MENU_B: ui.ShowTooltip( iPad, eToolTipButtonX, false ); ui.ShowTooltip( iPad, eToolTipButtonB, false ); ui.ShowTooltip( iPad, eToolTipButtonA, false ); ui.ShowTooltip( iPad, eToolTipButtonRB, false ); ui.CloseUIScenes(iPad); bHandled = true; break; case ACTION_MENU_A: #ifdef __ORBIS__ case ACTION_MENU_TOUCHPAD_PRESS: #endif if(m_pPlayer && m_pPlayer->inventory) { Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); if(isCraftAnything()) { if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) { int iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; int iRecipe= CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; shared_ptr pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); if( pMinecraft->localgameModes[iPad] != nullptr) { Tutorial *tutorial = pMinecraft->localgameModes[iPad]->getTutorial(); if(tutorial != nullptr) { tutorial->onCrafted(pTempItemInst); } } pMinecraft->localgameModes[iPad]->handleCraftItem(iRecipe,m_pPlayer); if(m_pPlayer->inventory->add(pTempItemInst)==false) { m_pPlayer->drop(pTempItemInst); } ui.PlayUISFX(eSFX_Craft); } } else if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) { int iSlot = (CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) ? iVSlotIndexA[m_iCurrentSlotVIndex] : 0; int iRecipe= CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; shared_ptr pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); if( pMinecraft->localgameModes[iPad] != nullptr ) { Tutorial *tutorial = pMinecraft->localgameModes[iPad]->getTutorial(); if(tutorial != nullptr) { tutorial->createItemSelected(pTempItemInst, pRecipeIngredientsRequired[iRecipe].bCanMake[iPad]); } } if(pRecipeIngredientsRequired[iRecipe].bCanMake[iPad]) { pTempItemInst->onCraftedBy(m_pPlayer->level, dynamic_pointer_cast( m_pPlayer->shared_from_this() ), pTempItemInst->count ); pMinecraft->localgameModes[iPad]->handleCraftItem(iRecipe,m_pPlayer); ui.PlayUISFX(eSFX_Craft); for(int i=0;i ingItemInst = nullptr; if(pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]!=Recipes::ANY_AUX_VALUE) { ingItemInst = m_pPlayer->inventory->getResourceItem( pRecipeIngredientsRequired[iRecipe].iIngIDA[i],pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i] ); m_pPlayer->inventory->removeResource(pRecipeIngredientsRequired[iRecipe].iIngIDA[i],pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]); } else { ingItemInst = m_pPlayer->inventory->getResourceItem( pRecipeIngredientsRequired[iRecipe].iIngIDA[i] ); m_pPlayer->inventory->removeResource(pRecipeIngredientsRequired[iRecipe].iIngIDA[i]); } if (ingItemInst != nullptr) { if (ingItemInst->getItem()->hasCraftingRemainingItem()) { m_pPlayer->inventory->add(std::make_shared(ingItemInst->getItem()->getCraftingRemainingItem())); } } } } if(m_pPlayer->inventory->add(pTempItemInst)==false ) { m_pPlayer->drop(pTempItemInst); } switch(pTempItemInst->id ) { case Tile::crafting_table_Id: m_pPlayer->awardStat(GenericStats::buildWorkbench(), GenericStats::param_buildWorkbench()); break; case Item::wooden_pickaxe_Id: m_pPlayer->awardStat(GenericStats::buildPickaxe(), GenericStats::param_buildPickaxe()); break; case Tile::furnace_Id: m_pPlayer->awardStat(GenericStats::buildFurnace(), GenericStats::param_buildFurnace()); break; case Item::bread_Id: m_pPlayer->awardStat(GenericStats::makeBread(), GenericStats::param_makeBread()); break; case Item::cake_Id: m_pPlayer->awardStat(GenericStats::bakeCake(), GenericStats::param_bakeCake()); break; case Item::stone_pickaxe_Id: m_pPlayer->awardStat(GenericStats::buildBetterPickaxe(), GenericStats::param_buildBetterPickaxe()); break; case Tile::dispenser_Id: m_pPlayer->awardStat(GenericStats::dispenseWithThis(), GenericStats::param_dispenseWithThis()); break; case Tile::enchanting_table_Id: m_pPlayer->awardStat(GenericStats::enchantments(), GenericStats::param_enchantments()); break; case Tile::bookshelf_Id: m_pPlayer->awardStat(GenericStats::bookcase(), GenericStats::param_bookcase()); break; } switch (pTempItemInst->getItem()->getBaseItemType()) { case Item::eBaseItemType_hoe: m_pPlayer->awardStat(GenericStats::buildHoe(), GenericStats::param_buildHoe()); break; case Item::eBaseItemType_sword: m_pPlayer->awardStat(GenericStats::buildSword(), GenericStats::param_buildSword()); break; } CheckRecipesAvailable(); UpdateVerticalSlots(); UpdateHighlight(); } else { ui.PlayUISFX(eSFX_CraftFail); } } } break; case ACTION_MENU_LEFT_SCROLL: case ACTION_MENU_RIGHT_SCROLL: { int groupCount = (m_iContainerType == RECIPE_TYPE_3x3 ? m_iMaxGroupH3x3 : m_iMaxGroupH2x2); if (iAction == ACTION_MENU_LEFT_SCROLL) { m_iGroupHIndex = (m_iGroupHIndex == 0) ? groupCount - 1 : m_iGroupHIndex - 1; } else { m_iGroupHIndex++; if (m_iGroupHIndex >= groupCount) m_iGroupHIndex = 0; } setHGroupHighlight(m_iGroupHIndex); m_iCurrentSlotHIndex=0; m_iCurrentSlotVIndex=1; UpdateCraftingPanels(); CheckRecipesAvailable(); iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; iVSlotIndexA[1] = 0; iVSlotIndexA[2] = 1; ui.PlayUISFX(eSFX_Focus); UpdateVerticalSlots(); UpdateHighlight(); setGroupText(GetGroupNameText(m_pGroupA[m_iGroupHIndex])); } break; } bool bNoScrollSlots = false; if(m_bSplitscreen ||(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())) { bNoScrollSlots = true; } #ifdef __PSVITA__ bNoScrollSlots = true; #endif switch(iAction) { case ACTION_MENU_OTHER_STICK_UP: scrollDescriptionUp(); break; case ACTION_MENU_OTHER_STICK_DOWN: scrollDescriptionDown(); break; case ACTION_MENU_RIGHT: { int iOldHSlot=m_iCurrentSlotHIndex; m_iCurrentSlotHIndex++; if(m_iCurrentSlotHIndex>=m_iCraftablesMaxHSlotC) m_iCurrentSlotHIndex=0; m_iCurrentSlotVIndex=1; iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; iVSlotIndexA[1] = 0; iVSlotIndexA[2] = 1; UpdateVerticalSlots(); UpdateHighlight(); setShowCraftHSlot(iOldHSlot,true); ui.PlayUISFX(eSFX_Focus); bHandled = true; } break; case ACTION_MENU_LEFT: { if(m_iCraftablesMaxHSlotC!=0) { int iOldHSlot=m_iCurrentSlotHIndex; if(m_iCurrentSlotHIndex==0) m_iCurrentSlotHIndex=m_iCraftablesMaxHSlotC-1; else m_iCurrentSlotHIndex--; m_iCurrentSlotVIndex=1; iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; iVSlotIndexA[1] = 0; iVSlotIndexA[2] = 1; UpdateVerticalSlots(); UpdateHighlight(); setShowCraftHSlot(iOldHSlot,true); ui.PlayUISFX(eSFX_Focus); } bHandled = true; } break; case ACTION_MENU_UP: { if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) { if(bNoScrollSlots) { if(iVSlotIndexA[1]==0) { iVSlotIndexA[1]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; } else { iVSlotIndexA[1]--; } ui.PlayUISFX(eSFX_Focus); } else { if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>2) { if(m_iCurrentSlotVIndex!=0) { m_iCurrentSlotVIndex--; ui.PlayUISFX(eSFX_Focus); } else { iVSlotIndexA[2]=iVSlotIndexA[1]; iVSlotIndexA[1]=iVSlotIndexA[0]; if(iVSlotIndexA[0]==0) { iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; } else { iVSlotIndexA[0]--; } ui.PlayUISFX(eSFX_Focus); } } else { if(m_iCurrentSlotVIndex!=1) { m_iCurrentSlotVIndex--; ui.PlayUISFX(eSFX_Focus); } } UpdateVerticalSlots(); UpdateHighlight(); } } } break; case ACTION_MENU_DOWN: { if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) { if(bNoScrollSlots) { if(iVSlotIndexA[1]==(CanBeMadeA[m_iCurrentSlotHIndex].iCount-1)) { iVSlotIndexA[1]=0; } else { iVSlotIndexA[1]++; } ui.PlayUISFX(eSFX_Focus); } else { if (CanBeMadeA[m_iCurrentSlotHIndex].iCount > 2) { if (m_iCurrentSlotVIndex != 2) { m_iCurrentSlotVIndex++; ui.PlayUISFX(eSFX_Focus); } else { iVSlotIndexA[0] = iVSlotIndexA[1]; iVSlotIndexA[1] = iVSlotIndexA[2]; if (iVSlotIndexA[m_iCurrentSlotVIndex] == (CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1)) { iVSlotIndexA[2] = 0; } else { iVSlotIndexA[2]++; } ui.PlayUISFX(eSFX_Focus); } } else { if (m_iCurrentSlotVIndex != (CanBeMadeA[m_iCurrentSlotHIndex].iCount)) { m_iCurrentSlotVIndex++; ui.PlayUISFX(eSFX_Focus); } } UpdateVerticalSlots(); UpdateHighlight(); } } } break; } return bHandled; } void IUIScene_CraftingMenu::CheckRecipesAvailable() { if (isSpecialTab()) { Special_CheckRecipesAvailable(); return; } int iHSlotBrushControl=0; memset(CanBeMadeA,0,sizeof(CANBEMADE)*m_iCraftablesMaxHSlotC); hideAllHSlots(); if(m_pPlayer && m_pPlayer->inventory) { RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); int iRecipeC=static_cast(recipes->size()); auto itRecipe = recipes->begin(); for(int i=0;igetGroup()!=m_pGroupA[m_iGroupHIndex]) { itRecipe++; pRecipeIngredientsRequired[i].bCanMake[getPad()]=false; continue; } if((m_iContainerType==RECIPE_TYPE_2x2) && (pRecipeIngredientsRequired[i].iType==RECIPE_TYPE_3x3)) { itRecipe++; pRecipeIngredientsRequired[i].bCanMake[getPad()]=false; continue; } pRecipeIngredientsRequired[i].usBitmaskMissingGridIngredients[getPad()]=0; bool *bFoundA= new bool [pRecipeIngredientsRequired[i].iIngC]; for(int j=0;jinventory->items.length; k++) { if (m_pPlayer->inventory->items[k] != nullptr) { if((m_pPlayer->inventory->items[k]->id == pRecipeIngredientsRequired[i].iIngIDA[j]) && ((pRecipeIngredientsRequired[i].iIngAuxValA[j]==Recipes::ANY_AUX_VALUE) || (pRecipeIngredientsRequired[i].iIngAuxValA[j]==m_pPlayer->inventory->items[k]->getAuxValue())) ) { if(m_pPlayer->inventory->items[k]->GetCount()>=pRecipeIngredientsRequired[i].iIngValA[j]) { bFoundA[j]=true; } else { for(unsigned int l=0;linventory->items.length;l++) { if (m_pPlayer->inventory->items[l] != nullptr) { if( (m_pPlayer->inventory->items[l]->id == pRecipeIngredientsRequired[i].iIngIDA[j]) && ( (pRecipeIngredientsRequired[i].iIngAuxValA[j]==Recipes::ANY_AUX_VALUE) || (pRecipeIngredientsRequired[i].iIngAuxValA[j]==m_pPlayer->inventory->items[l]->getAuxValue() )) ) { iTotalCount+=m_pPlayer->inventory->items[l]->GetCount(); } } } if(iTotalCount>=pRecipeIngredientsRequired[i].iIngValA[j]) { bFoundA[j]=true; } } break; } } } if(bFoundA[j]==false) { int iMissing = pRecipeIngredientsRequired[i].iIngValA[j]-iTotalCount; int iGridIndex=0; while(iMissing!=0 && iGridIndex<9) { if(((pRecipeIngredientsRequired[i].uiGridA[iGridIndex]&0x00FFFFFF)==pRecipeIngredientsRequired[i].iIngIDA[j]) && ((pRecipeIngredientsRequired[i].iIngAuxValA[j]==Recipes::ANY_AUX_VALUE) ||((pRecipeIngredientsRequired[i].iIngAuxValA[j]&0xFF)== ((pRecipeIngredientsRequired[i].uiGridA[iGridIndex]&0xFF000000)>>24))) ) { pRecipeIngredientsRequired[i].usBitmaskMissingGridIngredients[getPad()]|=1< pTempItemInst=pRecipeIngredientsRequired[i].pRecipy->assemble(nullptr); int iID=pTempItemInst->getItem()->id; int iBaseType; if(iID<256) { iBaseType=Tile::tiles[iID]->getBaseItemType(); } else { iBaseType=pTempItemInst->getItem()->getBaseItemType(); } if(iBaseType!=Item::eBaseItemType_undefined) { for(int k=0;kgetRecipeIngredientsArray(); while((iIndex pTempItemInst=pRecipeIngredientsRequired[CanBeMadeA[iIndex].iRecipeA[0]].pRecipy->assemble(nullptr); unsigned int uiAlpha; if(isCraftAnything()) { uiAlpha = 31; } else { uiAlpha = pRecipeIngredientsRequired[CanBeMadeA[iIndex].iRecipeA[0]].bCanMake[getPad()] ? 31 : 16; } if( pTempItemInst->id == Item::clock_Id || pTempItemInst->id == Item::compass_Id ) { pTempItemInst->setAuxValue( 255 ); } setCraftHSlotItem(getPad(),iIndex,pTempItemInst,uiAlpha); iIndex++; } } void IUIScene_CraftingMenu::UpdateHighlight() { if (isSpecialTab()) { Special_UpdateHighlight(); return; } updateHighlightAndScrollPositions(); bool bCanBeMade = CanBeMadeA[m_iCurrentSlotHIndex].iCount != 0; if (bCanBeMade) { Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipes::getInstance()->getRecipeIngredientsArray(); int iSlot = (CanBeMadeA[m_iCurrentSlotHIndex].iCount > 1) ? iVSlotIndexA[m_iCurrentSlotVIndex] : 0; shared_ptr pTempItemInstAdditional = pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].pRecipy->assemble(nullptr); int id = pTempItemInstAdditional->getDescriptionId(); wstring itemstring; switch (id) { case IDS_TILE_TORCH: if (pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].iIngAuxValA[0] == 1) itemstring = app.GetString(IDS_TILE_TORCHCHARCOAL); else itemstring = app.GetString(IDS_TILE_TORCHCOAL); break; case IDS_ITEM_FIREBALL: if (pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].iIngAuxValA[2] == 1) itemstring = app.GetString(IDS_ITEM_FIREBALLCHARCOAL); else itemstring = app.GetString(IDS_ITEM_FIREBALLCOAL); break; default: if (pTempItemInstAdditional->hasCustomHoverName()) itemstring = pTempItemInstAdditional->getHoverName(); else itemstring = app.GetString(id); break; } setItemText(itemstring.c_str()); } else { setItemText(L""); } UpdateDescriptionText(bCanBeMade); DisplayIngredients(); UpdateMultiPanel(); UpdateTooltips(); } void IUIScene_CraftingMenu::UpdateVerticalSlots() { if (isSpecialTab()) { Special_UpdateVerticalSlots(); return; } Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); hideAllVSlots(); if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) { setShowCraftHSlot(m_iCurrentSlotHIndex,false); int iSlots=(CanBeMadeA[m_iCurrentSlotHIndex].iCount>2)?3:2; bool bNoScrollSlots = false; if(m_bSplitscreen ||(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())) { bNoScrollSlots = true; } #ifdef __PSVITA__ bNoScrollSlots = true; #endif for(int i=0;i pTempItemInstAdditional=pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iVSlotIndexA[i]]].pRecipy->assemble(nullptr); unsigned int uiAlpha; if(isCraftAnything()) { uiAlpha = 31; } else { uiAlpha = pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iVSlotIndexA[i]]].bCanMake[getPad()] ? 31 : 16; } if( pTempItemInstAdditional->id == Item::clock_Id || pTempItemInstAdditional->id == Item::compass_Id ) { pTempItemInstAdditional->setAuxValue( 255 ); } setCraftVSlotItem(getPad(),i,pTempItemInstAdditional,uiAlpha); updateVSlotPositions(iSlots, i); } } } void IUIScene_CraftingMenu::DisplayIngredients() { if (isSpecialTab()) { Special_DisplayIngredients(); return; } Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); hideAllIngredientsSlots(); if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) { int iSlot = (CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) ? iVSlotIndexA[m_iCurrentSlotVIndex] : 0; int iRecipy = CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; int iBoxWidth=(m_iContainerType==RECIPE_TYPE_2x2)?2:3; int iRecipe=iRecipy; bool bCanMakeRecipe = pRecipeIngredientsRequired[iRecipe].bCanMake[getPad()]; shared_ptr pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); m_iIngredientsC=pRecipeIngredientsRequired[iRecipe].iIngC; for(int i=0;i itemInst= std::make_shared(item, pRecipeIngredientsRequired[iRecipe].iIngValA[i], iAuxVal); int idescID; if( ((pTempItemInst->id==Item::bed_Id) &&(id==Tile::wool_Id)) || ((pTempItemInst->id==Item::painting_Id) &&(id==Tile::wool_Id)) ) { idescID=IDS_ANY_WOOL; } else if((pTempItemInst->id==Item::firework_charge_Id) && (id==Item::dye_Id)) { idescID=IDS_ITEM_DYE_POWDER; iAuxVal = 1; } else { idescID=itemInst->getDescriptionId(); } setIngredientDescriptionText(i,app.GetString(idescID)); if( (iAuxVal & 0xFF) == 0xFF) iAuxVal = 0; if( id == Item::clock_Id || id == Item::compass_Id ) { iAuxVal = 0xFF; } itemInst->setAuxValue(iAuxVal); setIngredientDescriptionItem(getPad(),i,itemInst); setIngredientDescriptionRedBox(i,false); } if( pTempItemInst->id == Item::clock_Id || pTempItemInst->id == Item::compass_Id ) { pTempItemInst->setAuxValue( 255 ); } setCraftingOutputSlotItem(getPad(), pTempItemInst); setCraftingOutputSlotRedBox(isCraftAnything() ? false : !bCanMakeRecipe); for (int x = 0; x < iBoxWidth; x++) { for (int y = 0; y < iBoxWidth; y++) { int index = x+y*iBoxWidth; if(pRecipeIngredientsRequired[iRecipy].uiGridA[x+y*3]!=0) { int id=pRecipeIngredientsRequired[iRecipy].uiGridA[x+y*3]&0x00FFFFFF; int iAuxVal=(pRecipeIngredientsRequired[iRecipy].uiGridA[x+y*3]&0xFF000000)>>24; for (int k = 0; k < pRecipeIngredientsRequired[iRecipy].iIngC; k++) { int fullAux = pRecipeIngredientsRequired[iRecipy].iIngAuxValA[k]; if (pRecipeIngredientsRequired[iRecipy].iIngIDA[k] == id && fullAux != Recipes::ANY_AUX_VALUE && (fullAux & 0xFF) == iAuxVal) { iAuxVal = fullAux; break; } } if( id == Item::clock_Id || id == Item::compass_Id ) { iAuxVal = 0xFF; } else if( pTempItemInst->id==Item::firework_charge_Id && id == Item::dye_Id) { iAuxVal = 1; } shared_ptr itemInst= std::make_shared(id, 1, iAuxVal); setIngredientSlotItem(getPad(),index,itemInst); if(isCraftAnything()) { setIngredientSlotRedBox(index, false); } else { setIngredientSlotRedBox(index, (pRecipeIngredientsRequired[iRecipy].usBitmaskMissingGridIngredients[getPad()]&(1<<(x+y*3)))!=0); } } else { setIngredientSlotRedBox(index, false); setIngredientSlotItem(getPad(),index,nullptr); } } } } else { setCraftingOutputSlotItem(getPad(), nullptr); setCraftingOutputSlotRedBox(false); m_iIngredientsC=0; int iIngredientsSlots = (m_iContainerType==RECIPE_TYPE_2x2) ? 4 : m_iIngredients3x3SlotC; for(int i=0;igetRecipeIngredientsArray(); if(bCanBeMade) { int iSlot = (CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) ? iVSlotIndexA[m_iCurrentSlotVIndex] : 0; shared_ptr pTempItemInst=pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].pRecipy->assemble(nullptr); int iID=pTempItemInst->getItem()->id; int iAuxVal=pTempItemInst->getAuxValue(); int iBaseType; if(iID<256) { iBaseType=Tile::tiles[iID]->getBaseItemType(); iIDSString = Tile::tiles[iID]->getUseDescriptionId(); } else { iBaseType=pTempItemInst->getItem()->getBaseItemType(); iIDSString = pTempItemInst->getUseDescriptionId(); } if(iBaseType==Item::eBaseItemType_cloth && iAuxVal==0) { iIDSString=IDS_DESC_WOOLSTRING; } if(iIDSString>=0) { wstring wsText=app.FormatHTMLString(getPad(),app.GetString(iIDSString)); wchar_t startTags[64]; swprintf(startTags,64,L"

",app.GetHTMLColour(eHTMLColor_Black)); wsText= startTags + wsText + L"

"; setDescriptionText(wsText.c_str()); } else { setDescriptionText(L""); } } else { setDescriptionText(L""); } } void IUIScene_CraftingMenu::UpdateTooltips() { if (isSpecialTab()) { Special_UpdateTooltips(); return; } Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); bool bDisplayCreate = false; if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) { int iSlot = (CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) ? iVSlotIndexA[m_iCurrentSlotVIndex] : 0; bDisplayCreate = pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].bCanMake[getPad()]; } int showNext = IDS_TOOLTIPS_SHOW_DESCRIPTION; if (m_iDisplayDescription == DISPLAY_DESCRIPTION) showNext = IDS_TOOLTIPS_SHOW_INGREDIENTS; else if (m_iDisplayDescription == DISPLAY_INGREDIENTS) showNext = IDS_TOOLTIPS_SHOW_INVENTORY; ui.SetTooltips( getPad(), bDisplayCreate?IDS_TOOLTIPS_CREATE:-1,IDS_TOOLTIPS_EXIT, showNext,-1, -2, IDS_TOOLTIPS_CHANGE_TYPE, -2, IDS_TOOLTIPS_CHANGE_GROUP); } void IUIScene_CraftingMenu::HandleInventoryUpdated() { if (isSpecialTab()) { Special_RefreshBaseItemSlots(nullptr); } CheckRecipesAvailable(); UpdateVerticalSlots(); UpdateHighlight(); UpdateTooltips(); } bool IUIScene_CraftingMenu::isItemSelected(int itemId) { if (isSpecialTab()) { int recipe = Special_GetSelectedRecipe(); if (recipe < 0) return false; shared_ptr result = m_specialRecipes[recipe].result; return result != nullptr && result->id == itemId; } bool isSelected = false; if(m_pPlayer && m_pPlayer->inventory) { Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) { int iSlot = (CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) ? iVSlotIndexA[m_iCurrentSlotVIndex] : 0; int iRecipe= CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; ItemInstance *pTempItemInst = (ItemInstance *)pRecipeIngredientsRequired[iRecipe].pRecipy->getResultItem(); if(pTempItemInst->id == itemId) { isSelected = true; } } } return isSelected; }