Completed Fiesta Crafting Calculator

master
sigonasr2 1 year ago
parent e844a8f5ec
commit 52c76cce08
  1. 44
      FiestaCraftingCalculator/FiestaCraftingCalculator.cpp
  2. BIN
      FiestaCraftingCalculator/FiestaCraftingCalculator.rc
  3. 8
      FiestaCraftingCalculator/FiestaCraftingCalculator.vcxproj
  4. 13
      FiestaCraftingCalculator/FiestaCraftingCalculator.vcxproj.filters
  5. BIN
      FiestaCraftingCalculator/assets/button_plus_mask.png
  6. BIN
      FiestaCraftingCalculator/assets/icon.ico
  7. BIN
      FiestaCraftingCalculator/assets/plus_button.png
  8. 12
      FiestaCraftingCalculator/olcPGEX_QuickGUI.h
  9. 6
      FiestaCraftingCalculator/olcPixelGameEngine.h
  10. 17
      FiestaCraftingCalculator/resource.h

@ -172,6 +172,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine
recipeItems.push_back(IDToName[r.Product].name);
}
selectedItem=&PotionProdRecipes[0];
Amount->sText="1";
}
if(PotionProd->bHovered){
DisplayProdText="Potion Production";
@ -187,6 +188,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine
recipeItems.push_back(IDToName[r.Product].name);
}
selectedItem=&StoneProdRecipes[0];
Amount->sText="1";
}
if(StoneProd->bHovered){
DisplayProdText="Stone Production";
@ -202,6 +204,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine
recipeItems.push_back(IDToName[r.Product].name);
}
selectedItem=&ScrollProdRecipes[0];
Amount->sText="1";
}
if(ScrollProd->bHovered){
DisplayProdText="Scroll Production";
@ -217,6 +220,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine
recipeItems.push_back(IDToName[r.Product].name);
}
selectedItem=&CompRecipes[0];
Amount->sText="1";
}
if(CompProd->bHovered){
DisplayProdText="Material Composition";
@ -232,6 +236,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine
recipeItems.push_back(IDToName[r.Product].name);
}
selectedItem=&DecompRecipes[0];
Amount->sText="1";
}
if(DecompProd->bHovered){
DisplayProdText="Material Decomposition";
@ -258,6 +263,10 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine
pge->DrawStringPropDecal(displayPos+vf2d{10,10+54},DisplayProdText,WHITE,{2,2});
if(RecipeList->bVisible){
ItemData data = IDToName[selectedItem->Product];
int quantityRequested=1;
if(Amount->sText.size()>0&&Amount->sText[0]>='0'&&Amount->sText[0]<='9'){
quantityRequested=stoi(Amount->sText);
}
data.DrawIcon(pge,displayPos+vf2d{320,40});
float stringWidth=pge->GetTextSizeProp(data.name).x*2;
if(stringWidth>PANEL_WIDTH-356){
@ -266,7 +275,8 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine
} 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->DrawStringPropDecal(displayPos+vf2d{264,16},"Crafts: ",WHITE,{1.75,1.75});
pge->DrawStringPropDecal(displayPos+vf2d{360,58},"x "+std::to_string(selectedItem->amt*quantityRequested),WHITE,{1.75,1.75});
pge->DrawStringDecal(displayPos+vf2d{320,80},"Requires:");
float yOffset=0;
for(std::pair<std::string,int>&item:selectedItem->requiredItems){
@ -279,7 +289,7 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine
} 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});
pge->DrawStringPropDecal(displayPos+vf2d{360,110+yOffset},"x "+std::to_string(item.second*quantityRequested),WHITE,{1.75,1.75});
yOffset+=36;
}
if(Amount->m_bTextEdit){
@ -313,7 +323,9 @@ public:
}
static std::vector<Calculator*>calculators;
static Renderable ProdIcon,CloseIcon,CloseBackIcon,ProductionIcons,CollectibleIcons,CollectibleIcons2,GradeIcons;
Manager manager;
Button*AddButton;
static Renderable ProdIcon,CloseIcon,CloseBackIcon,ProductionIcons,CollectibleIcons,CollectibleIcons2,GradeIcons,PlusIcon,PlusBackIcon;
public:
std::string slurp(std::ifstream& in) {
std::ostringstream sstr;
@ -399,17 +411,36 @@ public:
CollectibleIcons.Load("assets/collectibles.png",nullptr,true);
CollectibleIcons2.Load("assets/collectibles2.png",nullptr,true);
GradeIcons.Load("assets/grade.png",nullptr,true);
PlusIcon.Load("assets/plus_button.png",nullptr,true);
PlusBackIcon.Load("assets/button_plus_mask.png",nullptr,true);
calculators.push_back(new Calculator());
AddButton=new Button(manager,"Add Panel",{PROGRAM_WIDTH-256,float(ScreenHeight()-Karen.Sprite()->height-240)},{172,36},{2,2});
return true;
}
void DrawCenteredStringDecal(const vf2d&pos,const std::string&text,Pixel col,const vf2d&scale){
DrawStringDecal(pos-GetTextSize(text)*scale/2,text,col,scale);
}
bool OnUserUpdate(float fElapsedTime) override
{
if(GetKey(SPACE).bPressed){
/*if(GetKey(SPACE).bPressed){
calculators.push_back(new Calculator());
}
}*/
DrawCenteredStringDecal({float(ScreenWidth()-175),64},"Fiesta Online",WHITE,{2,3});
DrawCenteredStringDecal({float(ScreenWidth()-175),64+24},"Crafting Calculator",WHITE,{2,3});
DrawCenteredStringDecal({float(ScreenWidth()-175),64+24*4},"Made using the",WHITE,{2,3});
DrawCenteredStringDecal({float(ScreenWidth()-175),64+24*5},"olcPixelGameEngine",WHITE,{2,3});
DrawDecal({float(ScreenWidth()-Karen.Sprite()->width),float(ScreenHeight()-Karen.Sprite()->height)},Karen.Decal());
int panelNumber=0;
manager.Update(this);
if(AddButton->bPressed){
calculators.push_back(new Calculator());
}
for(auto it=calculators.begin();it!=calculators.end();++it){
Calculator*c=*it;
if (!c->Update(this,panelNumber)){
@ -420,11 +451,12 @@ public:
}
++panelNumber;
}
manager.DrawDecal(this);
return true;
}
};
Renderable FiestaCraftingCalculator::ProdIcon,FiestaCraftingCalculator::CloseIcon,FiestaCraftingCalculator::CloseBackIcon,FiestaCraftingCalculator::ProductionIcons,FiestaCraftingCalculator::CollectibleIcons,FiestaCraftingCalculator::CollectibleIcons2,FiestaCraftingCalculator::GradeIcons;
Renderable FiestaCraftingCalculator::ProdIcon,FiestaCraftingCalculator::CloseIcon,FiestaCraftingCalculator::CloseBackIcon,FiestaCraftingCalculator::ProductionIcons,FiestaCraftingCalculator::CollectibleIcons,FiestaCraftingCalculator::CollectibleIcons2,FiestaCraftingCalculator::GradeIcons,FiestaCraftingCalculator::PlusIcon,FiestaCraftingCalculator::PlusBackIcon;
std::vector<FiestaCraftingCalculator::Recipe> FiestaCraftingCalculator::PotionProdRecipes;
std::vector<FiestaCraftingCalculator::Recipe> FiestaCraftingCalculator::StoneProdRecipes;
std::vector<FiestaCraftingCalculator::Recipe> FiestaCraftingCalculator::ScrollProdRecipes;

@ -119,6 +119,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -133,6 +134,13 @@
<ItemGroup>
<ClInclude Include="olcPGEX_QuickGUI.h" />
<ClInclude Include="olcPixelGameEngine.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="FiestaCraftingCalculator.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="assets\icon.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

@ -26,5 +26,18 @@
<ClInclude Include="olcPGEX_QuickGUI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="FiestaCraftingCalculator.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="assets\icon.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 723 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1004 B

@ -230,7 +230,8 @@ namespace olc::QuickGUI
Button(olc::QuickGUI::Manager& manager, // Associate with a Manager
const std::string& text, // Text to display
const olc::vf2d& pos, // Location of button top-left
const olc::vf2d& size); // Size of button
const olc::vf2d& size,
const olc::vf2d& fontScale={1,1}); // Size of button
public:
// Position of button
@ -239,6 +240,7 @@ namespace olc::QuickGUI
olc::vf2d vSize;
// Text displayed on button
std::string sText;
olc::vf2d fontScale;
public: // BaseControl overrides
void Update(olc::PixelGameEngine* pge) override;
@ -695,8 +697,8 @@ namespace olc::QuickGUI
#pragma endregion
#pragma region Button
Button::Button(olc::QuickGUI::Manager& manager, const std::string& text, const olc::vf2d& pos, const olc::vf2d& size)
: BaseControl(manager)
Button::Button(olc::QuickGUI::Manager& manager, const std::string& text, const olc::vf2d& pos, const olc::vf2d& size, const olc::vf2d& fontScale)
: BaseControl(manager),fontScale(fontScale)
{
vPos = pos; vSize = size; sText = text;
}
@ -791,8 +793,8 @@ namespace olc::QuickGUI
pge->FillRectDecal(vPos + olc::vf2d(1, 1), vSize - olc::vf2d(2, 2), m_manager.colBorder);
pge->SetDecalMode(olc::DecalMode::NORMAL);
olc::vf2d vText = pge->GetTextSizeProp(sText);
pge->DrawStringPropDecal(vPos + (vSize - vText) * 0.5f, sText, m_manager.colText);
olc::vf2d vText = pge->GetTextSizeProp(sText)*fontScale;
pge->DrawStringPropDecal(vPos + (vSize - vText) * 0.5f, sText, m_manager.colText,fontScale);
}
#pragma endregion

@ -5406,7 +5406,11 @@ namespace olc
virtual olc::rcode CreateWindowPane(const olc::vi2d& vWindowPos, olc::vi2d& vWindowSize, bool bFullScreen) override
{
WNDCLASS wc;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hIcon = static_cast<HICON>(::LoadImage(GetModuleHandle(nullptr),
MAKEINTRESOURCE(101),
IMAGE_ICON,
48, 48,
LR_DEFAULTCOLOR));;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.hInstance = GetModuleHandle(nullptr);

@ -0,0 +1,17 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by FiestaCraftingCalculator.rc
//
#define IDI_ICON1 101
#define MAINICON 101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
Loading…
Cancel
Save