From 28493a2102b552c7693aa853fb382978d782cd74 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Thu, 29 Jun 2023 10:19:08 -0700 Subject: [PATCH] Display Items required and items produced. --- .../FiestaCraftingCalculator.cpp | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/FiestaCraftingCalculator/FiestaCraftingCalculator.cpp b/FiestaCraftingCalculator/FiestaCraftingCalculator.cpp index e1c620a..9a872c6 100644 --- a/FiestaCraftingCalculator/FiestaCraftingCalculator.cpp +++ b/FiestaCraftingCalculator/FiestaCraftingCalculator.cpp @@ -165,7 +165,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine RecipeList->m_pSlider->fValue=0; RecipeList->nSelectedItem=RecipeList->nPreviouslySelectedItem=0; for(Recipe&r:PotionProdRecipes){ - recipeItems.push_back(r.DisplayName); + recipeItems.push_back(IDToName[r.Product].name); } selectedItem=&PotionProdRecipes[0]; } @@ -180,7 +180,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine RecipeList->m_pSlider->fValue=0; RecipeList->nSelectedItem=RecipeList->nPreviouslySelectedItem=0; for(Recipe&r:StoneProdRecipes){ - recipeItems.push_back(r.DisplayName); + recipeItems.push_back(IDToName[r.Product].name); } selectedItem=&StoneProdRecipes[0]; } @@ -195,7 +195,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine RecipeList->m_pSlider->fValue=0; RecipeList->nSelectedItem=RecipeList->nPreviouslySelectedItem=0; for(Recipe&r:ScrollProdRecipes){ - recipeItems.push_back(r.DisplayName); + recipeItems.push_back(IDToName[r.Product].name); } selectedItem=&ScrollProdRecipes[0]; } @@ -210,7 +210,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine RecipeList->m_pSlider->fValue=0; RecipeList->nSelectedItem=RecipeList->nPreviouslySelectedItem=0; for(Recipe&r:CompRecipes){ - recipeItems.push_back(r.DisplayName); + recipeItems.push_back(IDToName[r.Product].name); } selectedItem=&CompRecipes[0]; } @@ -225,7 +225,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine RecipeList->m_pSlider->fValue=0; RecipeList->nSelectedItem=RecipeList->nPreviouslySelectedItem=0; for(Recipe&r:DecompRecipes){ - recipeItems.push_back(r.DisplayName); + recipeItems.push_back(IDToName[r.Product].name); } selectedItem=&DecompRecipes[0]; } @@ -255,6 +255,29 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine if(RecipeList->bVisible){ ItemData data = IDToName[selectedItem->Product]; data.DrawIcon(pge,displayPos+vf2d{320,40}); + float stringWidth=pge->GetTextSizeProp(data.name).x*2; + if(stringWidth>PANEL_WIDTH-356){ + float scale=(PANEL_WIDTH-356)/stringWidth; + pge->DrawStringPropDecal(displayPos+vf2d{356,40},data.name,WHITE,{2*scale,2}); + } else { + pge->DrawStringPropDecal(displayPos+vf2d{356,40},data.name,WHITE,{2,2}); + } + pge->DrawStringPropDecal(displayPos+vf2d{360,58},"x "+std::to_string(selectedItem->amt),WHITE,{1.75,1.75}); + pge->DrawStringDecal(displayPos+vf2d{320,80},"Requires:"); + float yOffset=0; + for(std::pair&item:selectedItem->requiredItems){ + data = IDToName[item.first]; + data.DrawIcon(pge,displayPos+vf2d{320,92+yOffset}); + float stringWidth=pge->GetTextSizeProp(data.name).x*2; + if(stringWidth>PANEL_WIDTH-356){ + float scale=(PANEL_WIDTH-356)/stringWidth; + pge->DrawStringPropDecal(displayPos+vf2d{356,92+yOffset},data.name,WHITE,{2*scale,2}); + } else { + pge->DrawStringPropDecal(displayPos+vf2d{356,92+yOffset},data.name,WHITE,{2,2}); + } + pge->DrawStringPropDecal(displayPos+vf2d{360,110+yOffset},"x "+std::to_string(item.second),WHITE,{1.75,1.75}); + yOffset+=36; + } } manager.DrawDecal(pge); return true;