diff --git a/FiestaCraftingCalculator/FiestaCraftingCalculator.cpp b/FiestaCraftingCalculator/FiestaCraftingCalculator.cpp index 70cb9da..e0597e5 100644 --- a/FiestaCraftingCalculator/FiestaCraftingCalculator.cpp +++ b/FiestaCraftingCalculator/FiestaCraftingCalculator.cpp @@ -11,7 +11,193 @@ using namespace olc::QuickGUI; int PANEL_WIDTH=620; int PANEL_HEIGHT=240; +std::mapIDToName={ + {"El1","Elrue [1]"}, + {"El2","Elrue [2]"}, + {"El3","Elrue [3]"}, + {"El4","Elrue [4]"}, + {"El5","Elrue [5]"}, + {"Lix1","Lix [1]"}, + {"Lix2","Lix [2]"}, + {"Lix3","Lix [3]"}, + {"Lix4","Lix [4]"}, + {"Lix5","Lix [5]"}, + {"Xir1","Xir [1]"}, + {"Xir2","Xir [2]"}, + {"Xir3","Xir [3]"}, + {"Xir4","Xir [4]"}, + {"Xir5","Xir [5]"}, + {"BestLowHpPotion","HP Potion (Tier 1)"}, + {"LowHpPotion","HP Potion (Tier 2)"}, + {"NorHpPotion","HP Potion (Tier 3)"}, + {"HighHpPotion","HP Potion (Tier 4)"}, + {"BestHighHpPotion","HP Potion (Tier 5)"}, + {"BestLowSpPotion","SP Potion (Tier 1)"}, + {"LowSpPotion","SP Potion (Tier 2)"}, + {"NorSpPotion","SP Potion (Tier 3)"}, + {"HighSpPotion","SP Potion (Tier 4)"}, + {"BestHighSpPotion","SP Potion (Tier 5)"}, + {"BestLowConHPPotion","HP Regeneration Potion (Tier 1)"}, + {"LowConHPPotion","HP Regeneration Potion (Tier 2)"}, + {"NorConHPPotion","HP Regeneration Potion (Tier 3)"}, + {"HighConHPPotion","HP Regeneration Potion (Tier 4)"}, + {"BestHighConHPPotion","HP Regeneration Potion (Tier 5)"}, + {"BestLowConSPPotion","SP Regeneration Potion (Tier 1)"}, + {"LowConSPPotion","SP Regeneration Potion (Tier 2)"}, + {"NorConSPPotion","SP Regeneration Potion (Tier 3)"}, + {"HighConSPPotion","SP Regeneration Potion (Tier 4)"}, + {"BestHighConSPPotion","SP Regeneration Potion (Tier 5)"}, + {"BestLowTHScroll","Aim(Tier 1)"}, + {"LowTHScroll","Aim(Tier 2)"}, + {"NorTHScroll","Aim(Tier 3)"}, + {"HighTHScroll","Aim(Tier 4)"}, + {"BestHighTHScroll","Aim(Tier 5)"}, + {"BestLowTBScroll","Nature's Agility (Tier 1)"}, + {"LowTBScroll","Nature's Agility (Tier 2)"}, + {"NorTBScroll","Nature's Agility (Tier 3)"}, + {"HighTBScroll","Nature's Agility (Tier 4)"}, + {"BestHighTBScroll","Nature's Agility (Tier 5)"}, + {"BestLowMRScroll","Magical Defense (Tier 1)"}, + {"LowMRScroll","Magical Defense (Tier 2)"}, + {"NorMRScroll","Magical Defense (Tier 3)"}, + {"HighMRScroll","Magical Defense (Tier 4)"}, + {"BestHighMRScroll","Magical Defense (Tier 5)"}, + {"BestLowACScroll","Shield Increase (Tier 1)"}, + {"LowACScroll","Shield Increase (Tier 2)"}, + {"NorACScroll","Shield Increase (Tier 3)"}, + {"HighACScroll","Shield Increase (Tier 4)"}, + {"BestHighACScroll","Shield Increase (Tier 5)"}, + {"BestLowMaxHPScroll","Vitality (Tier 1)"}, + {"LowMaxHPScroll","Vitality (Tier 2)"}, + {"NorMaxHPScroll","Vitality (Tier 3)"}, + {"HighMaxHPScroll","Vitality (Tier 4)"}, + {"BestHighMaxHPScroll","Vitality (Tier 5)"}, + {"BestLowMaxSPScroll","Mentality (Tier 1)"}, + {"LowMaxSPScroll","Mentality (Tier 2)"}, + {"NorMaxSPScroll","Mentality (Tier 3)"}, + {"HighMaxSPScroll","Mentality (Tier 4)"}, + {"BestHighMaxSPScroll","Mentality (Tier 5)"}, + {"NorMSScroll","Speed Increase (Tier 3)"}, + {"LowMSScroll","Speed Increase (Tier 2)"}, + {"HighMSScroll","Speed Increase (Tier 4)"}, + {"BestMSScroll","Speed Increase (Tier 5)"}, + {"BestLowMSScroll","Speed Increase (Tier 1)"}, + {"LowPsnResiPotion","Antitoxin (Tier 1)"}, + {"NorPsnResiPotion","Antitoxin (Tier 2)"}, + {"HighPsnResiPotion","Antitoxin (Tier 3)"}, + {"LowDssResiPotion","Antibiotic (Tier 1)"}, + {"NorDssResiPotion","Antibiotic (Tier 2)"}, + {"HighDssResiPotion","Antibiotic (Tier 3)"}, + {"LowCurResiPotion","Bless (Tier 1)"}, + {"NorCurResiPotion","Bless (Tier 2)"}, + {"HighCurResiPotion","Bless (Tier 3)"}, + {"LowPsnCurPotion","Antidote (Tier 1)"}, + {"NorPsnCurPotion","Antidote (Tier 2)"}, + {"HighPsnCurPotion","Antidote (Tier 3)"}, + {"LowDssCurPotion","Cure (Tier 1)"}, + {"NorDssCurPotion","Cure (Tier 2)"}, + {"HighDssCurPotion","Cure (Tier 3)"}, + {"BestLowCurScroll","Divine Magic (Tier 1)"}, + {"LowCurScroll","Divine Magic (Tier 2)"}, + {"NorCurScroll","Divine Magic (Tier 3)"}, + {"HighCurScroll","Divine Magic (Tier 4)"}, + {"BestHighCurScroll","Divine Magic (Tier 5)"}, + {"NorBeastLeather","Beast Leather (Normal Quality)"}, + {"HighBeastLeather","Beast Leather (High Quality)"}, + {"BeastHead","Beast Head"}, + {"NorBeastTooth","Beast Dogtooth (Normal Quality)"}, + {"HighBeastTooth","Beast Dogtooth (High Quality)"}, + {"NorBrokenBone","Bone (Normal Quality)"}, + {"HighBrokenBone","Bone (High Quality)"}, + {"BestBrokenBone","Bone (Highest Quality)"}, + {"NorCleanWater","Spirit's Nectar (Normal Quality)"}, + {"HighCleanWater","Spirit's Nectar (High Quality)"}, + {"BestCleanWater","Spirit's Nectar (Highest Quality)"}, + {"IronBadge","Iron Badge"}, + {"NorCopperOre","Copper Ore (Normal Quality)"}, + {"HighCopperOre","Copper Ore (High Quality)"}, + {"NorGemDust","Gem Dust (Normal Quality)"}, + {"HighGemDust","Gem Dust (High Quality)"}, + {"BestGemDust","Gem Dust (Highest Quality)"}, + {"Violet","Vilolet"}, + {"Ramsear","Ramsear"}, + {"Salvia","Eucalyptus"}, + {"LowGoldOre","Gold Ore (Low Quality)"}, + {"NorGoldOre","Gold Ore (Normal Quality)"}, + {"HighGoldOre","Gold Ore (High Quality)"}, + {"NorKylinLeather","Summoned Beast Leather (Normal Quality)"}, + {"HighKylinLeather","Summoned Beast Leather (High Quality)"}, + {"KylinTooth","Summoned Beast's Tooth"}, + {"MermaidScale","Mermaid's Scale"}, + {"KylinFighterTail","Summoned Beast Fighter's Tail"}, + {"NorMagicCrystal","Magic Crystal (Normal Quality)"}, + {"HighMagicCrystal","Magic Crystal (High Quality)"}, + {"BestMagicCrystal","Magic Crystal (Highest Quality)"}, + {"NorMeat","Meat (Normal Quality)"}, + {"HighMeat","Meat (High Quality)"}, + {"BestMeat","Meat (Highest Quality)"}, + {"NorMushrooms","Mushroom (Normal Quality)"}, + {"HighMushrooms","Mushroom (High Quality)"}, + {"BestMushrooms","Mushroom (Highest Quality)"}, + {"NorPledge","Sign (Normal Quality)"}, + {"HighPledge","Sign (High Quality)"}, + {"BestPledge","Sign (Highest Quality)"}, + {"Rosemary","Rosemary"}, + {"Basil","Basil"}, + {"Marigold","Marigold"}, + {"LowSilverOre","Silver Ore (Low Quality)"}, + {"NorSilverOre","Silver Ore (Normal Quality)"}, + {"HighSilverOre","Silver Ore (High Quality)"}, + {"NorSkin","Leather (Normal Quality)"}, + {"HighSkin","Leather (High Quality)"}, + {"BestSkin","Leather (Highest Quality)"}, + {"NorSoulDust","Soul Dust (Normal Quality)"}, + {"HighSoulDust","Soul Dust (High Quality)"}, + {"BestSoulDust","Soul Dust (Highest Quality)"}, + {"NorSpiritDust","Spirit Dust (Normal Quality)"}, + {"HighSpiritDust","Spirit Dust (High Quality)"}, + {"BestSpiritDust","Spirit Dust (Highest Quality)"}, + {"NorToadStool","Toadstool (Normal Quality)"}, + {"HighToadStool","Toadstool (High Quality)"}, + {"BestToadStool","Toadstool (Highest Quality)"}, + {"Ruby","Ruby"}, + {"Sapphire","Sapphire"}, + {"NorWoodSab","Sap (Normal Quality)"}, + {"HighWoodSab","Sap (High Quality)"}, + {"BestWoodSab","Sap (Highest Quality)"}, + {"LowBeastLeather","Beast Leather (Low Quality)"}, + {"NorBeastLeather","Beast Leather (Normal Quality)"}, + {"HighBeastLeather","Beast Leather (High Quality)"}, + {"LowBeastTooth","Beast Dogtooth (Low Quality)"}, + {"NorBeastTooth","Beast Dogtooth (Normal Quality)"}, + {"HighBeastTooth","Beast Dogtooth (High Quality)"}, + {"LowBrokenBone","Bone (Low Quality)"}, + {"NorBrokenBone","Bone (Normal Quality)"}, + {"HighBrokenBone","Bone (High Quality)"}, + {"LowCleanWater","Spirit's Nectar (Low Quality)"}, + {"NorCleanWater","Spirit's Nectar (Normal Quality)"}, + {"HighCleanWater","Spirit's Nectar (High Quality)"}, + {"CommanderBadge","Master Commander's Badge"}, + {"LowCopperOre","Copper Ore (Low Quality)"}, + {"NorCopperOre","Copper Ore (Normal Quality)"}, + {"HighCopperOre","Copper Ore (High Quality)"}, + {"LowGemDust","Gem Dust (Low Quality)"}, + {"NorGemDust","Gem Dust (Normal Quality)"}, + {"HighGemDust","Gem Dust (High Quality)"}, + {"Geranium","Geranium"}, + {"Violet","Vilolet"}, + {"Ramsear","Ramsear"}, + {"LowGoldOre","Gold Ore (Low Quality)"}, + {"NorGoldOre","Gold Ore (Normal Quality)"}, + {"LowKylinLeather","Summoned Beast Leather (Low Quality)"}, + {"NorKylinLeather","Summoned Beast Leather (Normal Quality)"}, + {"HighKylinLeather","Summoned Beast Leather (High Quality)"}, + {"KylinTail","Summoned Beast's Tail"}, + {"LowMagicCrystal","Magic Crystal (Low Quality)"}, +}; + class Recipe{ +public: std::string ProduceIndex; std::string DisplayName; std::string Product; @@ -19,6 +205,19 @@ class Recipe{ std::vector>requiredItems; int expGained; int requiredExp; + Recipe(std::vector&data){ + ProduceIndex=data[1]; + DisplayName=data[2]; + Product=data[3]; + amt=stoi(data[4]); + for(int i=5;i<=20;i+=2){ + if(data[i].size()>1){ + requiredItems.push_back({data[i],stoi(data[i+1])}); + } + } + expGained=stoi(data[22]); + requiredExp=stoi(data[24]); + } }; std::vectorPotionProdRecipes; @@ -42,6 +241,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine ListBox*RecipeList; std::string DisplayProdText; std::string SelectedProdText; + std::vector recipeItems; public: Calculator(){ PotionProd=new ImageCheckBox(manager,FiestaCraftingCalculator::ProdIcon,false,displayPos+vi2d{10,10},{40,40},{192,128},{32,32}); @@ -50,6 +250,8 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine CompProd=new ImageCheckBox(manager,FiestaCraftingCalculator::ProdIcon,false,displayPos+vi2d{145,10},{40,40},{96,160},{32,32}); DecompProd=new ImageCheckBox(manager,FiestaCraftingCalculator::ProdIcon,false,displayPos+vi2d{190,10},{40,40},{64,160},{32,32}); CloseButton=new CustomButton(manager,FiestaCraftingCalculator::CloseIcon,FiestaCraftingCalculator::CloseBackIcon,displayPos+vf2d{PANEL_WIDTH-30.f,0},{26,26},{0,0},{26,26}); + RecipeList=new ListBox(manager,recipeItems,displayPos+vi2d{10,90},{240,140}); + RecipeList->bVisible=false; } bool Update(FiestaCraftingCalculator*pge,int panelNumber){ displayPos=vf2d{float(10+panelNumber%2*PANEL_WIDTH),float(10+panelNumber/2*PANEL_HEIGHT)}; @@ -59,6 +261,9 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine CompProd->vPos=displayPos+vi2d{145,10}; DecompProd->vPos=displayPos+vi2d{190,10}; CloseButton->vPos=displayPos+vf2d{PANEL_WIDTH-30.f,0}; + RecipeList->vPos=displayPos+vi2d{10,90}; + RecipeList->m_pSlider->vPosMin=displayPos+vi2d{10,90}+vf2d{240 - manager.fGrabRad - 1,manager.fGrabRad + 1 }; + RecipeList->m_pSlider->vPosMax=displayPos+vi2d{10,90}+vf2d{240 - manager.fGrabRad - 1,140-manager.fGrabRad - 1 }; manager.Update(pge); DisplayProdText=SelectedProdText; if(CloseButton->bPressed){ @@ -67,6 +272,13 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine if(PotionProd->bPressed){ StoneProd->bChecked=ScrollProd->bChecked=CompProd->bChecked=DecompProd->bChecked=false; SelectedProdText="Potion Production"; + RecipeList->bVisible=true; + recipeItems.clear(); + RecipeList->m_pSlider->fValue=0; + RecipeList->nSelectedItem=RecipeList->nPreviouslySelectedItem=0; + for(Recipe&r:PotionProdRecipes){ + recipeItems.push_back(r.DisplayName); + } } if(PotionProd->bHovered){ DisplayProdText="Potion Production"; @@ -74,6 +286,13 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine if(StoneProd->bPressed){ PotionProd->bChecked=ScrollProd->bChecked=CompProd->bChecked=DecompProd->bChecked=false; SelectedProdText="Stone Production"; + RecipeList->bVisible=true; + recipeItems.clear(); + RecipeList->m_pSlider->fValue=0; + RecipeList->nSelectedItem=RecipeList->nPreviouslySelectedItem=0; + for(Recipe&r:StoneProdRecipes){ + recipeItems.push_back(r.DisplayName); + } } if(StoneProd->bHovered){ DisplayProdText="Stone Production"; @@ -81,6 +300,13 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine if(ScrollProd->bPressed){ StoneProd->bChecked=PotionProd->bChecked=CompProd->bChecked=DecompProd->bChecked=false; SelectedProdText="Scroll Production"; + RecipeList->bVisible=true; + recipeItems.clear(); + RecipeList->m_pSlider->fValue=0; + RecipeList->nSelectedItem=RecipeList->nPreviouslySelectedItem=0; + for(Recipe&r:ScrollProdRecipes){ + recipeItems.push_back(r.DisplayName); + } } if(ScrollProd->bHovered){ DisplayProdText="Scroll Production"; @@ -88,6 +314,13 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine if(CompProd->bPressed){ StoneProd->bChecked=ScrollProd->bChecked=PotionProd->bChecked=DecompProd->bChecked=false; SelectedProdText="Material Composition"; + RecipeList->bVisible=true; + recipeItems.clear(); + RecipeList->m_pSlider->fValue=0; + RecipeList->nSelectedItem=RecipeList->nPreviouslySelectedItem=0; + for(Recipe&r:CompRecipes){ + recipeItems.push_back(r.DisplayName); + } } if(CompProd->bHovered){ DisplayProdText="Material Composition"; @@ -95,13 +328,20 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine if(DecompProd->bPressed){ StoneProd->bChecked=ScrollProd->bChecked=CompProd->bChecked=PotionProd->bChecked=false; SelectedProdText="Material Decomposition"; + RecipeList->bVisible=true; + recipeItems.clear(); + RecipeList->m_pSlider->fValue=0; + RecipeList->nSelectedItem=RecipeList->nPreviouslySelectedItem=0; + for(Recipe&r:DecompRecipes){ + recipeItems.push_back(r.DisplayName); + } } if(DecompProd->bHovered){ DisplayProdText="Material Decomposition"; } pge->GradientFillRectDecal(displayPos-vf2d{2,2},{float(PANEL_WIDTH),float(PANEL_HEIGHT)},{49, 32, 61,216},{0,0,0,216},{0,0,0,216},{49, 32, 61,216}); pge->DrawRectDecal(displayPos-vf2d{1,1},{float(PANEL_WIDTH),float(PANEL_HEIGHT)},{131, 90, 161}); - pge->DrawStringPropDecal(displayPos+vf2d{10,10+60},DisplayProdText,WHITE,{2,2}); + pge->DrawStringPropDecal(displayPos+vf2d{10,10+54},DisplayProdText,WHITE,{2,2}); manager.DrawDecal(pge); return true; } @@ -115,9 +355,74 @@ public: } public: + std::string slurp(std::ifstream& in) { + std::ostringstream sstr; + sstr << in.rdbuf(); + return sstr.str(); + } + bool OnUserCreate() override { // Called once at the start, so create things here + std::ifstream file=std::ifstream("assets/Produce.txt"); + std::string fileContents=slurp(file); + + std::string column=""; + std::vectordata; + for(int i=0;iGetMousePos() - vPos + olc::vi2d(2,0); + + bHovered=pge->GetMouseX() >= vPos.x && pge->GetMouseX() < vPos.x + vSize.x && + pge->GetMouseY() >= vPos.y && pge->GetMouseY() < vPos.y + vSize.y; + + if(bHovered){ + std::cout<<"Hovering"<GetMouse(olc::Mouse::LEFT).bPressed) { if (vMouse.x >= 0 && vMouse.x < vSize.x - (m_group.fGrabRad * 2) && vMouse.y >= 0 && vMouse.y < vSize.y) @@ -1110,7 +1117,16 @@ namespace olc::QuickGUI bSelectionChanged = nSelectedItem != nPreviouslySelectedItem; - m_pSlider->fMax = float(m_vList.size()); + m_pSlider->fMax = float(m_vList.size()-vSize.y/10+1); + + if(bHovered&&pge->GetMouseWheel()!=0){ + if(pge->GetMouseWheel()>0){ + m_pSlider->fValue=std::clamp(m_pSlider->fValue-1, m_pSlider->fMin, m_pSlider->fMax); + } else { + m_pSlider->fValue=std::clamp(m_pSlider->fValue+1, m_pSlider->fMin, m_pSlider->fMax); + } + } + m_group.Update(pge); } @@ -1135,8 +1151,8 @@ namespace olc::QuickGUI for (size_t idx = idx0; idx < idx1; idx++) { if (idx == nSelectedItem) - pge->FillRect(vTextPos - olc::vi2d(1,1), {int32_t(vSize.x - m_group.fGrabRad * 2), 10}, m_group.colHover); - pge->DrawStringProp(vTextPos, m_vList[idx]); + pge->FillRect(vTextPos - olc::vi2d(1,-1), {int32_t(vSize.x - m_group.fGrabRad * 2), 10}, m_group.colHover); + pge->DrawStringProp(vTextPos + olc::vi2d(0,2), m_vList[idx]); vTextPos.y += 10; } @@ -1158,8 +1174,8 @@ namespace olc::QuickGUI for (size_t idx = idx0; idx < idx1; idx++) { if (idx == nSelectedItem) - pge->FillRectDecal(vTextPos - olc::vi2d(1, 1), { vSize.x - m_group.fGrabRad * 2.0f, 10.0f }, m_group.colHover); - pge->DrawStringPropDecal(vTextPos, m_vList[idx]); + pge->FillRectDecal(vTextPos - olc::vi2d(1, -1), { vSize.x - m_group.fGrabRad * 2.0f, 10.0f }, m_group.colHover); + pge->DrawStringPropDecal(vTextPos + olc::vi2d(0,2), m_vList[idx]); vTextPos.y += 10; }