diff --git a/FiestaCraftingCalculator/FiestaCraftingCalculator.cpp b/FiestaCraftingCalculator/FiestaCraftingCalculator.cpp index f8c2e9a..69d0b87 100644 --- a/FiestaCraftingCalculator/FiestaCraftingCalculator.cpp +++ b/FiestaCraftingCalculator/FiestaCraftingCalculator.cpp @@ -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&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::vectorcalculators; - 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::PotionProdRecipes; std::vector FiestaCraftingCalculator::StoneProdRecipes; std::vector FiestaCraftingCalculator::ScrollProdRecipes; diff --git a/FiestaCraftingCalculator/FiestaCraftingCalculator.rc b/FiestaCraftingCalculator/FiestaCraftingCalculator.rc new file mode 100644 index 0000000..c99586f Binary files /dev/null and b/FiestaCraftingCalculator/FiestaCraftingCalculator.rc differ diff --git a/FiestaCraftingCalculator/FiestaCraftingCalculator.vcxproj b/FiestaCraftingCalculator/FiestaCraftingCalculator.vcxproj index a8d641a..b5ee537 100644 --- a/FiestaCraftingCalculator/FiestaCraftingCalculator.vcxproj +++ b/FiestaCraftingCalculator/FiestaCraftingCalculator.vcxproj @@ -119,6 +119,7 @@ true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true + stdcpp17 Console @@ -133,6 +134,13 @@ + + + + + + + diff --git a/FiestaCraftingCalculator/FiestaCraftingCalculator.vcxproj.filters b/FiestaCraftingCalculator/FiestaCraftingCalculator.vcxproj.filters index 8e2eb42..25ed271 100644 --- a/FiestaCraftingCalculator/FiestaCraftingCalculator.vcxproj.filters +++ b/FiestaCraftingCalculator/FiestaCraftingCalculator.vcxproj.filters @@ -26,5 +26,18 @@ Header Files + + Header Files + + + + + Resource Files + + + + + Resource Files + \ No newline at end of file diff --git a/FiestaCraftingCalculator/assets/button_plus_mask.png b/FiestaCraftingCalculator/assets/button_plus_mask.png new file mode 100644 index 0000000..5161b34 Binary files /dev/null and b/FiestaCraftingCalculator/assets/button_plus_mask.png differ diff --git a/FiestaCraftingCalculator/assets/icon.ico b/FiestaCraftingCalculator/assets/icon.ico new file mode 100644 index 0000000..56859c6 Binary files /dev/null and b/FiestaCraftingCalculator/assets/icon.ico differ diff --git a/FiestaCraftingCalculator/assets/plus_button.png b/FiestaCraftingCalculator/assets/plus_button.png new file mode 100644 index 0000000..d4a54d0 Binary files /dev/null and b/FiestaCraftingCalculator/assets/plus_button.png differ diff --git a/FiestaCraftingCalculator/olcPGEX_QuickGUI.h b/FiestaCraftingCalculator/olcPGEX_QuickGUI.h index 97abb1d..8985b3c 100644 --- a/FiestaCraftingCalculator/olcPGEX_QuickGUI.h +++ b/FiestaCraftingCalculator/olcPGEX_QuickGUI.h @@ -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 diff --git a/FiestaCraftingCalculator/olcPixelGameEngine.h b/FiestaCraftingCalculator/olcPixelGameEngine.h index 75db432..8163174 100644 --- a/FiestaCraftingCalculator/olcPixelGameEngine.h +++ b/FiestaCraftingCalculator/olcPixelGameEngine.h @@ -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(::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); diff --git a/FiestaCraftingCalculator/resource.h b/FiestaCraftingCalculator/resource.h new file mode 100644 index 0000000..b2f9d9a --- /dev/null +++ b/FiestaCraftingCalculator/resource.h @@ -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