|
|
|
@ -11,9 +11,25 @@ using namespace olc::QuickGUI; |
|
|
|
|
int PANEL_WIDTH=620; |
|
|
|
|
int PANEL_HEIGHT=240; |
|
|
|
|
|
|
|
|
|
class Recipe{ |
|
|
|
|
std::string ProduceIndex; |
|
|
|
|
std::string DisplayName; |
|
|
|
|
std::string Product; |
|
|
|
|
int amt; |
|
|
|
|
std::vector<std::pair<std::string,int>>requiredItems; |
|
|
|
|
int expGained; |
|
|
|
|
int requiredExp; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
std::vector<Recipe>PotionProdRecipes; |
|
|
|
|
std::vector<Recipe>StoneProdRecipes; |
|
|
|
|
std::vector<Recipe>ScrollProdRecipes; |
|
|
|
|
std::vector<Recipe>CompRecipes; |
|
|
|
|
std::vector<Recipe>DecompRecipes; |
|
|
|
|
|
|
|
|
|
class FiestaCraftingCalculator : public olc::PixelGameEngine |
|
|
|
|
{ |
|
|
|
|
static Renderable ProdIcon; |
|
|
|
|
static Renderable ProdIcon,CloseIcon,CloseBackIcon; |
|
|
|
|
class Calculator{ |
|
|
|
|
Manager manager; |
|
|
|
|
vf2d displayPos={10,10}; |
|
|
|
@ -22,35 +38,72 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine |
|
|
|
|
ImageCheckBox*ScrollProd; |
|
|
|
|
ImageCheckBox*CompProd; |
|
|
|
|
ImageCheckBox*DecompProd; |
|
|
|
|
CustomButton*CloseButton; |
|
|
|
|
ListBox*RecipeList; |
|
|
|
|
std::string DisplayProdText; |
|
|
|
|
std::string SelectedProdText; |
|
|
|
|
public: |
|
|
|
|
Calculator(vf2d displayPos) |
|
|
|
|
:displayPos(displayPos){ |
|
|
|
|
Calculator(){ |
|
|
|
|
PotionProd=new ImageCheckBox(manager,FiestaCraftingCalculator::ProdIcon,false,displayPos+vi2d{10,10},{40,40},{192,128},{32,32}); |
|
|
|
|
StoneProd=new ImageCheckBox(manager,FiestaCraftingCalculator::ProdIcon,false,displayPos+vi2d{55,10},{40,40},{0,160},{32,32}); |
|
|
|
|
ScrollProd=new ImageCheckBox(manager,FiestaCraftingCalculator::ProdIcon,false,displayPos+vi2d{100,10},{40,40},{224,128},{32,32}); |
|
|
|
|
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}); |
|
|
|
|
} |
|
|
|
|
void Update(FiestaCraftingCalculator*pge){ |
|
|
|
|
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}; |
|
|
|
|
StoneProd->vPos=displayPos+vi2d{55,10}; |
|
|
|
|
ScrollProd->vPos=displayPos+vi2d{100,10}; |
|
|
|
|
CompProd->vPos=displayPos+vi2d{145,10}; |
|
|
|
|
DecompProd->vPos=displayPos+vi2d{190,10}; |
|
|
|
|
CloseButton->vPos=displayPos+vf2d{PANEL_WIDTH-30.f,0}; |
|
|
|
|
manager.Update(pge); |
|
|
|
|
DisplayProdText=SelectedProdText; |
|
|
|
|
if(CloseButton->bPressed){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if(PotionProd->bPressed){ |
|
|
|
|
StoneProd->bChecked=ScrollProd->bChecked=CompProd->bChecked=DecompProd->bChecked=false; |
|
|
|
|
SelectedProdText="Potion Production"; |
|
|
|
|
} |
|
|
|
|
if(PotionProd->bHovered){ |
|
|
|
|
DisplayProdText="Potion Production"; |
|
|
|
|
} |
|
|
|
|
if(StoneProd->bPressed){ |
|
|
|
|
PotionProd->bChecked=ScrollProd->bChecked=CompProd->bChecked=DecompProd->bChecked=false; |
|
|
|
|
SelectedProdText="Stone Production"; |
|
|
|
|
} |
|
|
|
|
if(StoneProd->bHovered){ |
|
|
|
|
DisplayProdText="Stone Production"; |
|
|
|
|
} |
|
|
|
|
if(ScrollProd->bPressed){ |
|
|
|
|
StoneProd->bChecked=PotionProd->bChecked=CompProd->bChecked=DecompProd->bChecked=false; |
|
|
|
|
SelectedProdText="Scroll Production"; |
|
|
|
|
} |
|
|
|
|
if(ScrollProd->bHovered){ |
|
|
|
|
DisplayProdText="Scroll Production"; |
|
|
|
|
} |
|
|
|
|
if(CompProd->bPressed){ |
|
|
|
|
StoneProd->bChecked=ScrollProd->bChecked=PotionProd->bChecked=DecompProd->bChecked=false; |
|
|
|
|
SelectedProdText="Material Composition"; |
|
|
|
|
} |
|
|
|
|
if(CompProd->bHovered){ |
|
|
|
|
DisplayProdText="Material Composition"; |
|
|
|
|
} |
|
|
|
|
if(DecompProd->bPressed){ |
|
|
|
|
StoneProd->bChecked=ScrollProd->bChecked=CompProd->bChecked=PotionProd->bChecked=false; |
|
|
|
|
SelectedProdText="Material Decomposition"; |
|
|
|
|
} |
|
|
|
|
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}); |
|
|
|
|
manager.DrawDecal(pge); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
std::vector<Calculator*>calculators; |
|
|
|
@ -65,31 +118,41 @@ public: |
|
|
|
|
bool OnUserCreate() override |
|
|
|
|
{ |
|
|
|
|
// Called once at the start, so create things here
|
|
|
|
|
ProdIcon.Load("assets/production_icons.png"); |
|
|
|
|
Karen.Load("assets/AdlF_Karen.png"); |
|
|
|
|
calculators.push_back(new Calculator({10,10})); |
|
|
|
|
ProdIcon.Load("assets/production_icons.png",nullptr,true); |
|
|
|
|
Karen.Load("assets/AdlF_Karen.png",nullptr,true); |
|
|
|
|
CloseIcon.Load("assets/close_button.png",nullptr,true); |
|
|
|
|
CloseBackIcon.Load("assets/button_mask.png",nullptr,true); |
|
|
|
|
calculators.push_back(new Calculator()); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool OnUserUpdate(float fElapsedTime) override |
|
|
|
|
{ |
|
|
|
|
if(GetKey(SPACE).bPressed){ |
|
|
|
|
calculators.push_back(new Calculator(vf2d{float(10+calculators.size()%2*PANEL_WIDTH),float(10+calculators.size()/2*PANEL_HEIGHT)})); |
|
|
|
|
calculators.push_back(new Calculator()); |
|
|
|
|
} |
|
|
|
|
DrawDecal({float(ScreenWidth()-Karen.Sprite()->width),float(ScreenHeight()-Karen.Sprite()->height)},Karen.Decal()); |
|
|
|
|
for(Calculator*c:calculators){ |
|
|
|
|
c->Update(this); |
|
|
|
|
int panelNumber=0; |
|
|
|
|
for(auto it=calculators.begin();it!=calculators.end();++it){ |
|
|
|
|
Calculator*c=*it; |
|
|
|
|
if (!c->Update(this,panelNumber)){ |
|
|
|
|
it=calculators.erase(it); |
|
|
|
|
if(it==calculators.end()){ |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
++panelNumber; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Renderable FiestaCraftingCalculator::ProdIcon; |
|
|
|
|
Renderable FiestaCraftingCalculator::ProdIcon,FiestaCraftingCalculator::CloseIcon,FiestaCraftingCalculator::CloseBackIcon; |
|
|
|
|
|
|
|
|
|
int main() |
|
|
|
|
{ |
|
|
|
|
FiestaCraftingCalculator calculator; |
|
|
|
|
if (calculator.Construct(PROGRAM_WIDTH, 960, 1, 1)) |
|
|
|
|
if (calculator.Construct(PROGRAM_WIDTH, 980, 1, 1)) |
|
|
|
|
calculator.Start(); |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|