|
|
|
@ -11,12 +11,8 @@ using namespace olc::QuickGUI; |
|
|
|
|
int PANEL_WIDTH=620; |
|
|
|
|
int PANEL_HEIGHT=240; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FiestaCraftingCalculator : public olc::PixelGameEngine |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum Image{ |
|
|
|
|
PRODUCTION, |
|
|
|
|
COLLECTIBLE, |
|
|
|
@ -126,10 +122,12 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine |
|
|
|
|
ImageCheckBox*DecompProd; |
|
|
|
|
CustomButton*CloseButton; |
|
|
|
|
ListBox*RecipeList; |
|
|
|
|
TextBox*Amount; |
|
|
|
|
std::string DisplayProdText; |
|
|
|
|
std::string SelectedProdText; |
|
|
|
|
std::vector<std::string> recipeItems; |
|
|
|
|
Recipe*selectedItem; |
|
|
|
|
static bool disabledAllCalculators; |
|
|
|
|
public: |
|
|
|
|
Calculator(){ |
|
|
|
|
PotionProd=new ImageCheckBox(manager,FiestaCraftingCalculator::ProdIcon,false,displayPos+vi2d{10,10},{40,40},{192,128},{32,32}); |
|
|
|
@ -139,8 +137,13 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine |
|
|
|
|
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},{300,140},16); |
|
|
|
|
Amount=new TextBox(manager,"1",displayPos+vi2d{356,10},{68,24},{2,2}); |
|
|
|
|
Amount->bVisible=false; |
|
|
|
|
RecipeList->bVisible=false; |
|
|
|
|
} |
|
|
|
|
void OnTextEntryComplete(const std::string& sText){ |
|
|
|
|
//Amount->m_bTextEdit=false;
|
|
|
|
|
} |
|
|
|
|
bool Update(FiestaCraftingCalculator*pge,int panelNumber){ |
|
|
|
|
displayPos=vf2d{float(10+panelNumber%2*PANEL_WIDTH),float(10+panelNumber/2*PANEL_HEIGHT)}; |
|
|
|
|
PotionProd->vPos=displayPos+vi2d{10,10}; |
|
|
|
@ -152,6 +155,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine |
|
|
|
|
RecipeList->vPos=displayPos+vi2d{10,90}; |
|
|
|
|
RecipeList->m_pSlider->vPosMin=displayPos+vi2d{10,90}+vf2d{300 - manager.fGrabRad - 1,manager.fGrabRad + 1 }; |
|
|
|
|
RecipeList->m_pSlider->vPosMax=displayPos+vi2d{10,90}+vf2d{300 - manager.fGrabRad - 1,140-manager.fGrabRad - 1 }; |
|
|
|
|
Amount->vPos=displayPos+vi2d{356,10}; |
|
|
|
|
manager.Update(pge); |
|
|
|
|
DisplayProdText=SelectedProdText; |
|
|
|
|
if(CloseButton->bPressed){ |
|
|
|
@ -160,7 +164,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine |
|
|
|
|
if(PotionProd->bPressed){ |
|
|
|
|
StoneProd->bChecked=ScrollProd->bChecked=CompProd->bChecked=DecompProd->bChecked=false; |
|
|
|
|
SelectedProdText="Potion Production"; |
|
|
|
|
RecipeList->bVisible=true; |
|
|
|
|
RecipeList->bVisible=Amount->bVisible=true; |
|
|
|
|
recipeItems.clear(); |
|
|
|
|
RecipeList->m_pSlider->fValue=0; |
|
|
|
|
RecipeList->nSelectedItem=RecipeList->nPreviouslySelectedItem=0; |
|
|
|
@ -175,7 +179,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine |
|
|
|
|
if(StoneProd->bPressed){ |
|
|
|
|
PotionProd->bChecked=ScrollProd->bChecked=CompProd->bChecked=DecompProd->bChecked=false; |
|
|
|
|
SelectedProdText="Stone Production"; |
|
|
|
|
RecipeList->bVisible=true; |
|
|
|
|
RecipeList->bVisible=Amount->bVisible=true; |
|
|
|
|
recipeItems.clear(); |
|
|
|
|
RecipeList->m_pSlider->fValue=0; |
|
|
|
|
RecipeList->nSelectedItem=RecipeList->nPreviouslySelectedItem=0; |
|
|
|
@ -190,7 +194,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine |
|
|
|
|
if(ScrollProd->bPressed){ |
|
|
|
|
StoneProd->bChecked=PotionProd->bChecked=CompProd->bChecked=DecompProd->bChecked=false; |
|
|
|
|
SelectedProdText="Scroll Production"; |
|
|
|
|
RecipeList->bVisible=true; |
|
|
|
|
RecipeList->bVisible=Amount->bVisible=true; |
|
|
|
|
recipeItems.clear(); |
|
|
|
|
RecipeList->m_pSlider->fValue=0; |
|
|
|
|
RecipeList->nSelectedItem=RecipeList->nPreviouslySelectedItem=0; |
|
|
|
@ -205,7 +209,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine |
|
|
|
|
if(CompProd->bPressed){ |
|
|
|
|
StoneProd->bChecked=ScrollProd->bChecked=PotionProd->bChecked=DecompProd->bChecked=false; |
|
|
|
|
SelectedProdText="Material Composition"; |
|
|
|
|
RecipeList->bVisible=true; |
|
|
|
|
RecipeList->bVisible=Amount->bVisible=true; |
|
|
|
|
recipeItems.clear(); |
|
|
|
|
RecipeList->m_pSlider->fValue=0; |
|
|
|
|
RecipeList->nSelectedItem=RecipeList->nPreviouslySelectedItem=0; |
|
|
|
@ -220,7 +224,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine |
|
|
|
|
if(DecompProd->bPressed){ |
|
|
|
|
StoneProd->bChecked=ScrollProd->bChecked=CompProd->bChecked=PotionProd->bChecked=false; |
|
|
|
|
SelectedProdText="Material Decomposition"; |
|
|
|
|
RecipeList->bVisible=true; |
|
|
|
|
RecipeList->bVisible=Amount->bVisible=true; |
|
|
|
|
recipeItems.clear(); |
|
|
|
|
RecipeList->m_pSlider->fValue=0; |
|
|
|
|
RecipeList->nSelectedItem=RecipeList->nPreviouslySelectedItem=0; |
|
|
|
@ -278,12 +282,29 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine |
|
|
|
|
pge->DrawStringPropDecal(displayPos+vf2d{360,110+yOffset},"x "+std::to_string(item.second),WHITE,{1.75,1.75}); |
|
|
|
|
yOffset+=36; |
|
|
|
|
} |
|
|
|
|
if(Amount->m_bTextEdit){ |
|
|
|
|
for(Calculator*c:calculators){ |
|
|
|
|
if(c!=this){ |
|
|
|
|
c->Amount->Enable(false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
disabledAllCalculators=true; |
|
|
|
|
} else
|
|
|
|
|
if (disabledAllCalculators){ |
|
|
|
|
for(Calculator*c:calculators){ |
|
|
|
|
c->Amount->Enable(true); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(Amount->sText.size()>4){ |
|
|
|
|
Amount->sText=Amount->sText.substr(0,4); |
|
|
|
|
pge->sTextEntryString=Amount->sText; |
|
|
|
|
pge->nTextEntryCursor=4; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
manager.DrawDecal(pge); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
std::vector<Calculator*>calculators; |
|
|
|
|
Renderable Karen; |
|
|
|
|
public: |
|
|
|
|
FiestaCraftingCalculator() |
|
|
|
@ -291,6 +312,7 @@ public: |
|
|
|
|
sAppName = "Fiesta Crafting Calculator"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static std::vector<Calculator*>calculators; |
|
|
|
|
static Renderable ProdIcon,CloseIcon,CloseBackIcon,ProductionIcons,CollectibleIcons,CollectibleIcons2,GradeIcons; |
|
|
|
|
public: |
|
|
|
|
std::string slurp(std::ifstream& in) { |
|
|
|
@ -299,6 +321,14 @@ public: |
|
|
|
|
return sstr.str(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void OnTextEntryComplete(const std::string& sText)override{ |
|
|
|
|
|
|
|
|
|
for(auto it=calculators.begin();it!=calculators.end();++it){ |
|
|
|
|
Calculator*c=*it; |
|
|
|
|
c->OnTextEntryComplete(sText); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool OnUserCreate() override |
|
|
|
|
{ |
|
|
|
|
// Called once at the start, so create things here
|
|
|
|
@ -583,6 +613,8 @@ std::map<std::string,FiestaCraftingCalculator::ItemData>FiestaCraftingCalculator |
|
|
|
|
{"Converter2",{"Alchemy Stone[2]",{255,255,0},{4,2},PRODUCTION}}, |
|
|
|
|
{"Converter4",{"Alchemy Stone[4]",{0,255,255},{4,2},PRODUCTION}}, |
|
|
|
|
}; |
|
|
|
|
std::vector<FiestaCraftingCalculator::Calculator*>FiestaCraftingCalculator::calculators; |
|
|
|
|
bool FiestaCraftingCalculator::Calculator::disabledAllCalculators=false; |
|
|
|
|
int main() |
|
|
|
|
{ |
|
|
|
|
FiestaCraftingCalculator calculator; |
|
|
|
|