From e010da4376616a42edcfe089fa7fa30e6d2d6470 Mon Sep 17 00:00:00 2001 From: DrPerkyLegit <116128211+DrPerkyLegit@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:55:19 -0400 Subject: [PATCH] another crafting table backup point --- .../Common/UI/IUIScene_CraftingMenu.cpp | 1391 +++++++++++------ .../Common/UI/IUIScene_CraftingMenu.h | 27 +- .../Common/UI/IUIScene_PauseMenu.cpp | 18 +- .../Common/UI/UIScene_CraftingMenu.cpp | 458 ++++-- .../Common/UI/UIScene_CraftingMenu.h | 52 +- Minecraft.Client/MultiPlayerGameMode.cpp | 13 +- Minecraft.Client/MultiPlayerGameMode.h | 3 + Minecraft.Client/PlayerConnection.cpp | 284 ++-- Minecraft.World/BannerItem.h | 19 + Minecraft.World/BannerPatternRecipe.cpp | 189 ++- Minecraft.World/BannerPatternRecipe.h | 13 +- Minecraft.World/CraftItemPacket.cpp | 102 +- Minecraft.World/CraftItemPacket.h | 17 +- Minecraft.World/ItemInstance.cpp | 5 +- Minecraft.World/Recipes.cpp | 13 +- 15 files changed, 1752 insertions(+), 852 deletions(-) diff --git a/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp index 9f2d16dc..dde5ae3a 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp @@ -29,11 +29,6 @@ Recipy::_eGroupType IUIScene_CraftingMenu::m_GroupTypeMapping9GridA[IUIScene_Cra Recipy::eGroupType_Decoration, }; -Recipy::_eGroupType IUIScene_CraftingMenu::m_GroupTypeBannerMapping4GridA[m_iMaxBannerGroupH2x2] = -{ - Recipy::eGroupType_Banner_CustomLogic, -}; - Recipy::_eGroupType IUIScene_CraftingMenu::m_GroupTypeBannerMapping9GridA[m_iMaxBannerGroupH3x3] = { Recipy::eGroupType_Banner_CustomLogic, @@ -127,6 +122,28 @@ IUIScene_CraftingMenu::IUIScene_CraftingMenu() iVSlotIndexA[i]=i; // start with 0,1,2 } + { + for (int t = 0; t < 5; t++) { + for (int s = 0; s < 12; s++) { + m_aBannerCraftPatterns[t][s] = -1; + } + } + + { + m_aBannerCraftPatterns[0][0] = 13; //cr + m_aBannerCraftPatterns[0][1] = 12; //ss + m_aBannerCraftPatterns[0][2] = 14; //sc + m_aBannerCraftPatterns[0][3] = 4; //bs + m_aBannerCraftPatterns[0][4] = 8; //cs + m_aBannerCraftPatterns[0][5] = 11; //dls + m_aBannerCraftPatterns[0][6] = 10; //drl + m_aBannerCraftPatterns[0][7] = 6; //ls + m_aBannerCraftPatterns[0][8] = 9; //ms + m_aBannerCraftPatterns[0][9] = 7; //rs + m_aBannerCraftPatterns[0][10] = 5; //ts + } + } + m_iDisplayDescription=DISPLAY_INVENTORY; m_iIngredientsC=0; } @@ -185,13 +202,35 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) switch(iAction) { - case ACTION_MENU_X: - if (m_iDisplayDescription != DISPLAY_PREVIEW) { - m_iDisplayDescription++; - if (m_iDisplayDescription == DISPLAY_PREVIEW) m_iDisplayDescription++; - } + case ACTION_MENU_Y: + if ((BannerPatternRecipe::getBannerPatternCount(m_selectedBannerEdit) + m_bannerPreviewData.size()) < 6) { + int patternId = m_aBannerCraftPatterns[m_iGroupHIndex - 1][m_iCurrentSlotHIndex]; + if (patternId != -1) { + int colorIndex = iVSlotIndexA[1]; + if (colorIndex == -1) colorIndex = DyePowderItem::WHITE; - if(m_iDisplayDescription==DISPLAY_MAX) m_iDisplayDescription=DISPLAY_INVENTORY; + m_bannerPreviewData.emplace_back(PreviewBannerData(patternId, colorIndex)); + rebuildPreviewItem(); + DisplayIngredients(); + ui.PlayUISFX(eSFX_Focus); + } + } + break; + case ACTION_MENU_X: + if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { + if (m_bannerPreviewData.size() > 0) { + m_bannerPreviewData.pop_back(); + rebuildPreviewItem(); + DisplayIngredients(); + } + } else { + if (m_iDisplayDescription != DISPLAY_PREVIEW) { + m_iDisplayDescription++; + if (m_iDisplayDescription == DISPLAY_PREVIEW) m_iDisplayDescription++; + } + + if(m_iDisplayDescription==DISPLAY_MAX) m_iDisplayDescription=DISPLAY_INVENTORY; + } ui.PlayUISFX(eSFX_Focus); UpdateMultiPanel(); UpdateTooltips(); @@ -215,178 +254,216 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) // Do some crafting! if(m_pPlayer && m_pPlayer->inventory) { - //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); - Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); - // Force a make if the debug is on - if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L< pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); - //int iIcon=pTempItemInst->getItem()->getIcon(pTempItemInst->getAuxValue()); - - if( pMinecraft->localgameModes[iPad] != nullptr) - { - Tutorial *tutorial = pMinecraft->localgameModes[iPad]->getTutorial(); - if(tutorial != nullptr) - { - tutorial->onCrafted(pTempItemInst); + if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0 && m_iCurrentSlotHIndex == 1) { + setSelectedBannerEdit(CurrentInventoryBanners[m_iCurrentSlotVIndex-1]); + } else if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { + if (app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & (1L << eDebugSetting_CraftAnything)) { + if (m_bannerPreviewData.size() > 0) { + shared_ptr pTempItemInst = ItemInstance::clone(m_selectedBannerEdit); + for (PreviewBannerData& data : m_bannerPreviewData) { + BannerPatternRecipe::addBannerPattern(m_bannerPreviewHolder, BannerPatternRecipe::PATTERNS[data.id].id, data.color); } - } - pMinecraft->localgameModes[iPad]->handleCraftItem(iRecipe,m_pPlayer); - - if(m_pPlayer->inventory->add(pTempItemInst)==false) - { - // no room in inventory, so throw it down - m_pPlayer->drop(pTempItemInst); - } - // play a sound - //pMinecraft->soundEngine->playUI( L"random.pop", 1.0f, 1.0f); - ui.PlayUISFX(eSFX_Craft); - } - } - else if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) - { - int iSlot; - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) - { - iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; - } - else - { - iSlot=0; - } - int iRecipe= CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; - shared_ptr pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); - //int iIcon=pTempItemInst->getItem()->getIcon(pTempItemInst->getAuxValue()); - - 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 ); - // TODO 4J Stu - handleCraftItem should do a lot more than what it does, loads of the "can we craft" code should also probably be - // shifted to the GameMode - pMinecraft->localgameModes[iPad]->handleCraftItem(iRecipe,m_pPlayer); - - // play a sound - //pMinecraft->soundEngine->playUI( L"random.pop", 1.0f, 1.0f); - ui.PlayUISFX(eSFX_Craft); - - if(pTempItemInst->id != Item::firework_charge_Id && pTempItemInst->id != Item::fireworks_Id) - { - // and remove those resources from your inventory - for(int i=0;i ingItemInst = nullptr; - // do we need to remove a specific aux value? - 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]); - } - - // 4J Stu - Fix for #13097 - Bug: Milk Buckets are removed when crafting Cake - if (ingItemInst != nullptr) - { - if (ingItemInst->getItem()->hasCraftingRemainingItem()) - { - // replace item with remaining result - m_pPlayer->inventory->add(std::make_shared(ingItemInst->getItem()->getCraftingRemainingItem())); - } - - } + if (pMinecraft->localgameModes[iPad] != nullptr) { + Tutorial* tutorial = pMinecraft->localgameModes[iPad]->getTutorial(); + if (tutorial != nullptr) { + tutorial->onCrafted(pTempItemInst); } } - // 4J Stu - Fix for #13119 - We should add the item after we remove the ingredients - if(m_pPlayer->inventory->add(pTempItemInst)==false ) + pMinecraft->localgameModes[iPad]->handleCraftBanner(m_selectedBannerEdit, m_bannerPreviewData, m_pPlayer); + + if (m_pPlayer->inventory->add(pTempItemInst) == false) { // no room in inventory, so throw it down m_pPlayer->drop(pTempItemInst); } + ui.PlayUISFX(eSFX_Craft); + } + } else if (m_bannerPreviewData.size() > 0) { - //4J Gordon: Achievements - switch(pTempItemInst->id ) + } + } else { + //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); + Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); + // Force a make if the debug is on + if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L< pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); + //int iIcon=pTempItemInst->getItem()->getIcon(pTempItemInst->getAuxValue()); + + if( pMinecraft->localgameModes[iPad] != nullptr) { - 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::wooden_hoe_Id: m_pPlayer->awardStat(GenericStats::buildHoe(), GenericStats::param_buildHoe()); 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 Item::wooden_sword_Id: m_pPlayer->awardStat(GenericStats::buildSword(), GenericStats::param_buildSword()); 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; + Tutorial *tutorial = pMinecraft->localgameModes[iPad]->getTutorial(); + if(tutorial != nullptr) + { + tutorial->onCrafted(pTempItemInst); + } } - // We've used some ingredients from our inventory, so update the recipes we can make - CheckRecipesAvailable(); - // don't reset the vertical slots - we want to stay where we are - UpdateVerticalSlots(); - UpdateHighlight(); + pMinecraft->localgameModes[iPad]->handleCraftItem(iRecipe,m_pPlayer); + + if(m_pPlayer->inventory->add(pTempItemInst)==false) + { + // no room in inventory, so throw it down + m_pPlayer->drop(pTempItemInst); + } + // play a sound + //pMinecraft->soundEngine->playUI( L"random.pop", 1.0f, 1.0f); + ui.PlayUISFX(eSFX_Craft); } } - else + else if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) { - //pMinecraft->soundEngine->playUI( L"btn.back", 1.0f, 1.0f); - ui.PlayUISFX(eSFX_CraftFail); + int iSlot; + if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) + { + iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; + } + else + { + iSlot=0; + } + int iRecipe= CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; + shared_ptr pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); + //int iIcon=pTempItemInst->getItem()->getIcon(pTempItemInst->getAuxValue()); + + 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 ); + // TODO 4J Stu - handleCraftItem should do a lot more than what it does, loads of the "can we craft" code should also probably be + // shifted to the GameMode + pMinecraft->localgameModes[iPad]->handleCraftItem(iRecipe,m_pPlayer); + + // play a sound + //pMinecraft->soundEngine->playUI( L"random.pop", 1.0f, 1.0f); + ui.PlayUISFX(eSFX_Craft); + + if(pTempItemInst->id != Item::firework_charge_Id && pTempItemInst->id != Item::fireworks_Id) + { + // and remove those resources from your inventory + for(int i=0;i ingItemInst = nullptr; + // do we need to remove a specific aux value? + 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]); + } + + // 4J Stu - Fix for #13097 - Bug: Milk Buckets are removed when crafting Cake + if (ingItemInst != nullptr) + { + if (ingItemInst->getItem()->hasCraftingRemainingItem()) + { + // replace item with remaining result + m_pPlayer->inventory->add(std::make_shared(ingItemInst->getItem()->getCraftingRemainingItem())); + } + + } + } + } + + // 4J Stu - Fix for #13119 - We should add the item after we remove the ingredients + if(m_pPlayer->inventory->add(pTempItemInst)==false ) + { + // no room in inventory, so throw it down + m_pPlayer->drop(pTempItemInst); + } + + //4J Gordon: Achievements + 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::wooden_hoe_Id: m_pPlayer->awardStat(GenericStats::buildHoe(), GenericStats::param_buildHoe()); 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 Item::wooden_sword_Id: m_pPlayer->awardStat(GenericStats::buildSword(), GenericStats::param_buildSword()); 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; + } + + // We've used some ingredients from our inventory, so update the recipes we can make + CheckRecipesAvailable(); + // don't reset the vertical slots - we want to stay where we are + UpdateVerticalSlots(); + UpdateHighlight(); + } + } + else + { + //pMinecraft->soundEngine->playUI( L"btn.back", 1.0f, 1.0f); + ui.PlayUISFX(eSFX_CraftFail); + } } } } break; case ACTION_MENU_LEFT_SCROLL: - if(m_iGroupHIndex==0) - { - if(m_iContainerType==RECIPE_TYPE_3x3) - { - m_iGroupHIndex=m_iMaxGroupH3x3-1; + if (m_iGroupVIndex == eGroupVType_Workbench) { + if (m_iGroupHIndex == 0) { + m_iGroupHIndex = ((m_iContainerType == RECIPE_TYPE_3x3 ? m_iMaxGroupH3x3 : m_iMaxGroupH2x2) - 1); + } else { + m_iGroupHIndex--; } - else - { - m_iGroupHIndex=m_iMaxGroupH2x2-1; + } else if (m_iGroupVIndex == eGroupVType_Banner) { + if (m_selectedBannerEdit != nullptr) { + if (m_iGroupHIndex == 1) { + m_iGroupHIndex = m_iMaxBannerGroupH3x3 - 1; + } else { + m_iGroupHIndex--; + } } } - else - { - m_iGroupHIndex--; - } + // turn on the new group setHGroupHighlight(m_iGroupHIndex); m_iCurrentSlotHIndex=0; m_iCurrentSlotVIndex=1; - + UpdateCraftingPanels(); CheckRecipesAvailable(); // reset the vertical slots - iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; - iVSlotIndexA[1]=0; - iVSlotIndexA[2]=1; + if (m_iGroupVIndex == eGroupVType_Workbench) { + iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; + iVSlotIndexA[1] = 0; + iVSlotIndexA[2] = 1; + } else if (m_iGroupVIndex == eGroupVType_Banner) { + iVSlotIndexA[0] = 15; // White + iVSlotIndexA[1] = 0; // Black (center) + iVSlotIndexA[2] = 1; // Red + } ui.PlayUISFX(eSFX_Focus); UpdateVerticalSlots(); UpdateHighlight(); @@ -395,13 +472,14 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) break; case ACTION_MENU_RIGHT_SCROLL: m_iGroupHIndex++; - if(m_iContainerType==RECIPE_TYPE_3x3) - { - if(m_iGroupHIndex==m_iMaxGroupH3x3) m_iGroupHIndex=0; - } - else - { - if(m_iGroupHIndex==m_iMaxGroupH2x2) m_iGroupHIndex=0; + if (m_iGroupVIndex == eGroupVType_Workbench) { + if (m_iGroupHIndex >= (m_iContainerType == RECIPE_TYPE_3x3 ? m_iMaxGroupH3x3 : m_iMaxGroupH2x2)) { + m_iGroupHIndex = 0; + } + } else if (m_iGroupVIndex == eGroupVType_Banner) { + if (m_iGroupHIndex >= m_iMaxBannerGroupH3x3) { + m_iGroupHIndex = 0; + } } // turn on the new group setHGroupHighlight(m_iGroupHIndex); @@ -411,9 +489,15 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) m_iCurrentSlotVIndex=1; CheckRecipesAvailable(); // reset the vertical slots - iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; - iVSlotIndexA[1]=0; - iVSlotIndexA[2]=1; + if (m_iGroupVIndex == eGroupVType_Workbench) { + iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; + iVSlotIndexA[1] = 0; + iVSlotIndexA[2] = 1; + } else if (m_iGroupVIndex == eGroupVType_Banner) { + iVSlotIndexA[0] = 15; // White + iVSlotIndexA[1] = 0; // Black (center) + iVSlotIndexA[2] = 1; // Red + } ui.PlayUISFX(eSFX_Focus); UpdateVerticalSlots(); UpdateHighlight(); @@ -448,17 +532,23 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) if(m_iCurrentSlotHIndex>=m_iCraftablesMaxHSlotC) m_iCurrentSlotHIndex=0; m_iCurrentSlotVIndex=1; // clear the indices - iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; - iVSlotIndexA[1]=0; - iVSlotIndexA[2]=1; + if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { + iVSlotIndexA[0] = 15; // White + iVSlotIndexA[1] = 0; // Black (center) + iVSlotIndexA[2] = 1; // Red + } else { + iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; + iVSlotIndexA[1] = 0; + iVSlotIndexA[2] = 1; + } UpdateVerticalSlots(); UpdateHighlight(); // re-enable the old hslot - if(CanBeMadeA[iOldHSlot].iCount>0) - { + //if(CanBeMadeA[iOldHSlot].iCount>0) + //{ setShowCraftHSlot(iOldHSlot,true); - } + //} ui.PlayUISFX(eSFX_Focus); bHandled = true; } @@ -472,17 +562,23 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) else m_iCurrentSlotHIndex--; m_iCurrentSlotVIndex=1; // clear the indices - iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; - iVSlotIndexA[1]=0; - iVSlotIndexA[2]=1; + if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { + iVSlotIndexA[0] = 15; // White + iVSlotIndexA[1] = 0; // Black (center) + iVSlotIndexA[2] = 1; // Red + } else { + iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; + iVSlotIndexA[1] = 0; + iVSlotIndexA[2] = 1; + } UpdateVerticalSlots(); UpdateHighlight(); // re-enable the old hslot - if(CanBeMadeA[iOldHSlot].iCount>0) - { + //if(CanBeMadeA[iOldHSlot].iCount>0) + //{ setShowCraftHSlot(iOldHSlot,true); - } + //} ui.PlayUISFX(eSFX_Focus); } bHandled = true; @@ -490,113 +586,179 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) break; case ACTION_MENU_UP: { - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) - { - if(bNoScrollSlots) - { - if(iVSlotIndexA[1]==0) - { - iVSlotIndexA[1]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; + if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0 && m_iCurrentSlotHIndex == 1) { + if (CurrentInventoryBanners.size() > 1) { + const int bannerCount = static_cast(CurrentInventoryBanners.size()); + + if (bNoScrollSlots) { + iVSlotIndexA[1] = (iVSlotIndexA[1] + bannerCount - 1) % bannerCount; + ui.PlayUISFX(eSFX_Focus); + } else { + if (bannerCount > 2) { + if (m_iCurrentSlotVIndex > 1) { + m_iCurrentSlotVIndex--; + } else { + iVSlotIndexA[2] = iVSlotIndexA[1]; + iVSlotIndexA[1] = iVSlotIndexA[0]; + iVSlotIndexA[0] = (iVSlotIndexA[0] + bannerCount - 1) % bannerCount; + } + + ui.PlayUISFX(eSFX_Focus); + } else { + m_iCurrentSlotVIndex = (m_iCurrentSlotVIndex == 1) ? 2 : 1; + ui.PlayUISFX(eSFX_Focus); + } + + UpdateVerticalSlots(); + UpdateHighlight(); } - else - { - iVSlotIndexA[1]--; - } - ui.PlayUISFX(eSFX_Focus); } - else - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>2) - { - { - if(m_iCurrentSlotVIndex!=0) + } else if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { + if (bNoScrollSlots) { + iVSlotIndexA[1] = (iVSlotIndexA[1] + 16 - 1) % 16; + ui.PlayUISFX(eSFX_Focus); + } else { + if (m_iCurrentSlotVIndex > 1) { + m_iCurrentSlotVIndex--; + } + else { + iVSlotIndexA[1] = (iVSlotIndexA[1] + 15) % 16; + iVSlotIndexA[0] = (iVSlotIndexA[1] + 15) % 16; + iVSlotIndexA[2] = (iVSlotIndexA[1] + 1) % 16; + } + + ui.PlayUISFX(eSFX_Focus); + + UpdateVerticalSlots(); + UpdateHighlight(); + } + } else { + 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) { + // just move the highlight + m_iCurrentSlotVIndex--; + ui.PlayUISFX(eSFX_Focus); + } else { + //move the slots + iVSlotIndexA[2]=iVSlotIndexA[1]; + iVSlotIndexA[1]=iVSlotIndexA[0]; + // on 0 and went up, so cycle the values + if(iVSlotIndexA[0]==0) { + iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; + } else { + iVSlotIndexA[0]--; + } + ui.PlayUISFX(eSFX_Focus); + } + } + } else { + if(m_iCurrentSlotVIndex!=1) { // just move the highlight m_iCurrentSlotVIndex--; ui.PlayUISFX(eSFX_Focus); } - else - { - //move the slots - iVSlotIndexA[2]=iVSlotIndexA[1]; - iVSlotIndexA[1]=iVSlotIndexA[0]; - // on 0 and went up, so cycle the values - if(iVSlotIndexA[0]==0) - { - iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; - } - else - { - iVSlotIndexA[0]--; - } - ui.PlayUISFX(eSFX_Focus); - } } + UpdateVerticalSlots(); + UpdateHighlight(); } - else - { - if(m_iCurrentSlotVIndex!=1) - { - // just move the highlight - 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; + if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0 && m_iCurrentSlotHIndex == 1) { + if(CurrentInventoryBanners.size()>1) { + if (bNoScrollSlots) { + iVSlotIndexA[1] = (iVSlotIndexA[1] + 1) % CurrentInventoryBanners.size(); + ui.PlayUISFX(eSFX_Focus); + } else { + const int bannerCount = static_cast(CurrentInventoryBanners.size()); + + if (bannerCount > 2) { + if (m_iCurrentSlotVIndex < 2) { + m_iCurrentSlotVIndex++; + } else { + iVSlotIndexA[0] = iVSlotIndexA[1]; + iVSlotIndexA[1] = iVSlotIndexA[2]; + iVSlotIndexA[2] = (iVSlotIndexA[2] + 1) % bannerCount; + + m_iCurrentSlotVIndex = 0; + } + + ui.PlayUISFX(eSFX_Focus); + } else { + m_iCurrentSlotVIndex = (m_iCurrentSlotVIndex == 1) ? 2 : 1; + ui.PlayUISFX(eSFX_Focus); + } + + UpdateVerticalSlots(); + UpdateHighlight(); } - else - { - iVSlotIndexA[1]++; + } + } else if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { + if (bNoScrollSlots) { + iVSlotIndexA[1] = (iVSlotIndexA[1] + 16 - 1) % 16; + ui.PlayUISFX(eSFX_Focus); + } else { + if (m_iCurrentSlotVIndex < 1) { + m_iCurrentSlotVIndex++; } + else { + iVSlotIndexA[1] = (iVSlotIndexA[1] + 1) % 16; + iVSlotIndexA[0] = (iVSlotIndexA[1] + 15) % 16; + iVSlotIndexA[2] = (iVSlotIndexA[1] + 1) % 16; + } + 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(); + } + } else { + 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; @@ -605,6 +767,78 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) return bHandled; } +bool IUIScene_CraftingMenu::hasItem(int id, int requiredCount, int aux) +{ + if (!m_pPlayer || !m_pPlayer->inventory) return false; + + int count = 0; + + for (unsigned int i = 0; i < m_pPlayer->inventory->items.length; ++i) { + const auto& item = m_pPlayer->inventory->items[i]; + + if (item == nullptr || item->id != id) continue; + + if (aux != -1 && item->getAuxValue() != aux) continue; + + count += item->count; + + if (count >= requiredCount) return true; + } + + return false; +} + +void IUIScene_CraftingMenu::rebuildPreviewItem() { + m_bannerPreviewHolder = ItemInstance::clone(m_selectedBannerEdit); + + for (PreviewBannerData& data : m_bannerPreviewData) { + BannerPatternRecipe::addBannerPattern(m_bannerPreviewHolder, BannerPatternRecipe::PATTERNS[data.id].id, data.color); + } +} + +int IUIScene_CraftingMenu::hasItemCounts(int id, int requiredCount, int aux) +{ + if (!m_pPlayer || !m_pPlayer->inventory) return 0; + + int count = 0; + + for (unsigned int i = 0; i < m_pPlayer->inventory->items.length; ++i) { + const auto& item = m_pPlayer->inventory->items[i]; + + if (item == nullptr || item->id != id) continue; + + if (aux != -1 && item->getAuxValue() != aux) continue; + + count += item->count; + + if (requiredCount != -1 && count >= requiredCount) return count; + } + + return count; +} + +bool IUIScene_CraftingMenu::canCraftPattern(const BannerPatternRecipe::PatternInfo& pattern, char color) { + + if (pattern.specialItemId != 0) { + if (hasItem(pattern.specialItemId, 1, pattern.specialItemAux)) return true; + } else { + int requiredDye = 0; + for (int row = 0; row < 3; ++row) { + for (int col = 0; col < 3; ++col) { + if (pattern.rows[row][col] != ' ') ++requiredDye; + } + } + + if (hasItem(Item::dye_Id, requiredDye, color)) return true; + } + + return false; +} + +static inline bool DoesPatternHaveVertical(int id) { + return true; +} + ////////////////////////////////////////////////////////////////////////// // // CheckRecipesAvailable @@ -616,11 +850,32 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() // clear the current list memset(CanBeMadeA,0,sizeof(CANBEMADE)*m_iCraftablesMaxHSlotC); + CurrentInventoryBanners.clear(); hideAllHSlots(); if(m_pPlayer && m_pPlayer->inventory) { + for (unsigned int k = 0; k < m_pPlayer->inventory->items.length; k++) { + if (m_pPlayer->inventory->items[k] != nullptr) { + if (m_pPlayer->inventory->items[k]->id == Tile::standing_banner_Id) { + CurrentInventoryBanners.push_back(m_pPlayer->inventory->items[k]); + } + } + } + + if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { + for (int i = 0; i < 12; i++) { + int patternId = m_aBannerCraftPatterns[m_iGroupHIndex-1][i]; + if (patternId == -1) continue; + + BannerPatternRecipe::PatternInfo pattern = BannerPatternRecipe::PATTERNS[patternId]; + bool canCraft = canCraftPattern(pattern, DyePowderItem::BLACK) || (app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & (1L << eDebugSetting_CraftAnything)); + setCraftHSlotItem(getPad(), i, BannerPatternRecipe::createBannerWithPattern(pattern.id, DyePowderItem::BLACK), canCraft ? 31 : 16); + } + return; + } + // dump out the inventory /* for (unsigned int k = 0; k < m_pPlayer->inventory->items.length; k++) { @@ -908,68 +1163,78 @@ void IUIScene_CraftingMenu::UpdateHighlight() { updateHighlightAndScrollPositions(); - bool bCanBeMade=CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0; - if(bCanBeMade) - { - //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); - Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); - int iSlot; - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) + if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0 && m_iCurrentSlotHIndex == 1) { + wstring selectedBannerName = CurrentInventoryBanners[m_iCurrentSlotVIndex - 1]->getHoverName(); + setItemText(selectedBannerName.c_str()); + setDescriptionText(selectedBannerName.c_str()); + } else if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { + setItemText(L""); + setDescriptionText(L""); + }else { + bool bCanBeMade = CanBeMadeA[m_iCurrentSlotHIndex].iCount != 0; + if (bCanBeMade) { - iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; + //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); + Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipes::getInstance()->getRecipeIngredientsArray(); + int iSlot; + if (CanBeMadeA[m_iCurrentSlotHIndex].iCount > 1) + { + iSlot = iVSlotIndexA[m_iCurrentSlotVIndex]; + } + else + { + iSlot = 0; + } + shared_ptr pTempItemInstAdditional = pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].pRecipy->assemble(nullptr); + + // special case for the torch coal/charcoal + 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 { - iSlot=0; + setItemText(L""); } - shared_ptr pTempItemInstAdditional=pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].pRecipy->assemble(nullptr); - - // special case for the torch coal/charcoal - 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()); + UpdateDescriptionText(bCanBeMade); } - else - { - setItemText(L""); - } - UpdateDescriptionText(bCanBeMade); DisplayIngredients(); UpdateMultiPanel(); @@ -990,61 +1255,89 @@ void IUIScene_CraftingMenu::UpdateVerticalSlots() // update the vertical items for the current horizontal slot hideAllVSlots(); - // could have either 1 or 2 vertical slots, above and below the horizontal slot - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) - { - // turn off the horizontal one since we could be cycling through others - setShowCraftHSlot(m_iCurrentSlotHIndex,false); - int iSlots=(CanBeMadeA[m_iCurrentSlotHIndex].iCount>2)?3:2; + if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { + int patternId = m_aBannerCraftPatterns[m_iGroupHIndex - 1][m_iCurrentSlotHIndex]; + if (patternId != -1 && DoesPatternHaveVertical(patternId)) { + setShowCraftHSlot(m_iCurrentSlotHIndex, false); - // 4J-Tomk - check if we've only got one vertical scroll slot (480, splits & Vita) - bool bNoScrollSlots = false; - if(m_bSplitscreen ||(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())) - { - bNoScrollSlots = true; + bool bNoScrollSlots = false; + if (m_bSplitscreen || (!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())) + { + bNoScrollSlots = true; + } + + for (int i = 0; i < 3; i++) { + if (bNoScrollSlots) { + if (i != 1) continue; + } + + int colorIndex = iVSlotIndexA[i]; + if (colorIndex == -1) colorIndex = DyePowderItem::WHITE; + + const BannerPatternRecipe::PatternInfo& pattern = BannerPatternRecipe::PATTERNS[patternId]; + bool canCraft = canCraftPattern(pattern, colorIndex) || (app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & (1L << eDebugSetting_CraftAnything)); + setCraftVSlotItem(getPad(), i, BannerPatternRecipe::createBannerWithPattern(pattern.id, colorIndex), canCraft ? 31 : 16); + updateVSlotPositions(3, i); + } } -#ifdef __PSVITA__ - bNoScrollSlots = true; -#endif + } else { - for(int i=0;i1) { - // 4J this check determines if the crafting scene has only one vertical scroll slot - if(bNoScrollSlots) - { - if(i!=1) continue; - } - shared_ptr pTempItemInstAdditional=pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iVSlotIndexA[i]]].pRecipy->assemble(nullptr); + // turn off the horizontal one since we could be cycling through others + setShowCraftHSlot(m_iCurrentSlotHIndex,false); + int iSlots=(CanBeMadeA[m_iCurrentSlotHIndex].iCount>2)?3:2; - assert(pTempItemInstAdditional->id!=0); - unsigned int uiAlpha; - - if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L< pTempItemInstAdditional=pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iVSlotIndexA[i]]].pRecipy->assemble(nullptr); + + assert(pTempItemInstAdditional->id!=0); + unsigned int uiAlpha; + + if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<id == Item::clock_Id || pTempItemInstAdditional->id == Item::compass_Id ) + { + pTempItemInstAdditional->setAuxValue( 255 ); + } + + setCraftVSlotItem(getPad(),i,pTempItemInstAdditional,uiAlpha); + + updateVSlotPositions(iSlots, i); } - - // 4J Stu - For clocks and compasses we set the aux value to a special one that signals we should use a default texture - // rather than the dynamic one for the player - if( pTempItemInstAdditional->id == Item::clock_Id || pTempItemInstAdditional->id == Item::compass_Id ) - { - pTempItemInstAdditional->setAuxValue( 255 ); - } - - setCraftVSlotItem(getPad(),i,pTempItemInstAdditional,uiAlpha); - - updateVSlotPositions(iSlots, i); } } } @@ -1056,182 +1349,274 @@ void IUIScene_CraftingMenu::UpdateVerticalSlots() ////////////////////////////////////////////////////////////////////////// void IUIScene_CraftingMenu::DisplayIngredients() { - //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); - Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); - // hide the previous ingredients - hideAllIngredientsSlots(); + if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0 && m_iCurrentSlotHIndex == 1) { + hideAllIngredientsSlots(); - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) - { - int iSlot,iRecipy; - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) - { - iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; - iRecipy=CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; - } - else - { - iSlot=0; - iRecipy=CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[0]; - } + if (CurrentInventoryBanners.size() >= 1) { + auto selectedBanner = CurrentInventoryBanners[m_iCurrentSlotVIndex - 1]; - // show the 2x2 or 3x3 to make the current item - int iBoxWidth=(m_iContainerType==RECIPE_TYPE_2x2)?2:3; - int iRecipe=CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; - bool bCanMakeRecipe = pRecipeIngredientsRequired[iRecipe].bCanMake[getPad()]; - shared_ptr pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); + setCraftingOutputSlotItem(getPad(), selectedBanner); + setCraftingOutputSlotRedBox(false); - m_iIngredientsC=pRecipeIngredientsRequired[iRecipe].iIngC; - - // update the ingredients required - these will all be hidden until cycled by the user - for(int i=0;i itemInst= std::make_shared(item, pRecipeIngredientsRequired[iRecipe].iIngValA[i], iAuxVal); - - // 4J-PB - a very special case - the bed can use any kind of wool, so we can't use the item description - // and the same goes for the painting - 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; + // if it's a 2x2 , only clear the 4 m_pCraftingIngredientA slots + int iIngredientsSlots = (m_iContainerType == RECIPE_TYPE_2x2) ? 4 : m_iIngredients3x3SlotC; + for (int i = 0; i < iIngredientsSlots; i++) { + setIngredientSlotRedBox(i, false); + setIngredientSlotItem(getPad(), i, nullptr); } - 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) // 4J Stu - If the aux value is set to match any - iAuxVal = 0; - - // 4J Stu - For clocks and compasses we set the aux value to a special one that signals we should use a default texture - // rather than the dynamic one for the player - if( id == Item::clock_Id || id == Item::compass_Id ) - { - iAuxVal = 0xFF; - } - itemInst->setAuxValue(iAuxVal); - - setIngredientDescriptionItem(getPad(),i,itemInst); - setIngredientDescriptionRedBox(i,false); + int centerSlot = (m_iContainerType == RECIPE_TYPE_2x2) ? 4 : 5; + setIngredientSlotItem(getPad(), centerSlot-1, selectedBanner); } + } else if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { + hideAllIngredientsSlots(); - // 4J Stu - For clocks and compasses we set the aux value to a special one that signals we should use a default texture - // rather than the dynamic one for the player - if( pTempItemInst->id == Item::clock_Id || pTempItemInst->id == Item::compass_Id ) - { - pTempItemInst->setAuxValue( 255 ); - } + int patternId = m_aBannerCraftPatterns[m_iGroupHIndex - 1][m_iCurrentSlotHIndex]; + if (patternId != -1) { + const BannerPatternRecipe::PatternInfo& pattern = BannerPatternRecipe::PATTERNS[patternId]; - // don't grey out the output icon - setCraftingOutputSlotItem(getPad(), pTempItemInst); + int colorIndex = iVSlotIndexA[1]; + if (colorIndex == -1) colorIndex = DyePowderItem::WHITE; - if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<(Item::dye_Id, 1, colorIndex); + auto whiteBanner = std::make_shared(Tile::standing_banner_Id, 1, 0); + + const int bannerPositions[] = { 4, 1, 7, 8, 6, 5, 3, 2, 0 }; + int bannerSlot = -1; + + for (int position : bannerPositions) { + int row = position / 3; + int col = position % 3; + + if (pattern.rows[row][col] == ' ') { + bannerSlot = position; + break; + } + } + + int dyeCount = hasItemCounts(dyeItem->id, -1, dyeItem->getAuxValue()); + int dyeAlreadyConsumed = 0; + + for (PreviewBannerData& data : m_bannerPreviewData) { + if (data.color == colorIndex) { + const BannerPatternRecipe::PatternInfo& pendingPattern = BannerPatternRecipe::PATTERNS[data.id]; + + for (int row = 0; row < 3; ++row) { + for (int col = 0; col < 3; ++col) { + int slot = row * 3 + col; + if (pendingPattern.rows[row][col] != ' ') { + dyeAlreadyConsumed++; + } + } + } + } + } + + dyeCount -= dyeAlreadyConsumed; + + for (int row = 0; row < 3; ++row) { + for (int col = 0; col < 3; ++col) { + int slot = row * 3 + col; + bool enableRedSlot = false; + + if (slot == bannerSlot) { + setIngredientSlotItem(getPad(), slot, whiteBanner); + } else if (pattern.rows[row][col] != ' ') { + setIngredientSlotItem(getPad(), slot, dyeItem); + if (dyeCount <= 0 && !(app.DebugSettingsOn() && (app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & (1L << eDebugSetting_CraftAnything)))) enableRedSlot = true; + else dyeCount--; + } else { + setIngredientSlotItem(getPad(), slot, nullptr); + } + setIngredientSlotRedBox(slot, enableRedSlot); + } + } + + setCraftingOutputSlotItem(getPad(), BannerPatternRecipe::createBannerWithPattern(pattern.id, colorIndex)); + setCraftingOutputSlotRedBox(!((canCraftPattern(pattern, colorIndex)) || (app.DebugSettingsOn() && (app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & (1L << eDebugSetting_CraftAnything))))); + } else { + setCraftingOutputSlotItem(getPad(), nullptr); setCraftingOutputSlotRedBox(false); } - else + } else { + //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); + Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); + + // hide the previous ingredients + hideAllIngredientsSlots(); + + if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) { - if(bCanMakeRecipe==false) + int iSlot,iRecipy; + if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) { - setCraftingOutputSlotRedBox(true); + iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; + iRecipy=CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; } else { - setCraftingOutputSlotRedBox(false); + iSlot=0; + iRecipy=CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[0]; } - } - 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; - assert(id!=0); - 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; - } - } + // show the 2x2 or 3x3 to make the current item + int iBoxWidth=(m_iContainerType==RECIPE_TYPE_2x2)?2:3; + int iRecipe=CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; + bool bCanMakeRecipe = pRecipeIngredientsRequired[iRecipe].bCanMake[getPad()]; + shared_ptr pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); - // 4J Stu - For clocks and compasses we set the aux value to a special one that signals we should use a default texture - // rather than the dynamic one for the player - 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); - // show the ingredients we don't have if we can't make the recipe - if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<