From 52c76cce08e25ebac8d3c2dad68e3878c50ff5be Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Thu, 29 Jun 2023 12:05:09 -0700 Subject: [PATCH] Completed Fiesta Crafting Calculator --- .../FiestaCraftingCalculator.cpp | 44 +++++++++++++++--- .../FiestaCraftingCalculator.rc | Bin 0 -> 3450 bytes .../FiestaCraftingCalculator.vcxproj | 8 ++++ .../FiestaCraftingCalculator.vcxproj.filters | 13 ++++++ .../assets/button_plus_mask.png | Bin 0 -> 723 bytes FiestaCraftingCalculator/assets/icon.ico | Bin 0 -> 4286 bytes .../assets/plus_button.png | Bin 0 -> 1004 bytes FiestaCraftingCalculator/olcPGEX_QuickGUI.h | 12 +++-- FiestaCraftingCalculator/olcPixelGameEngine.h | 6 ++- FiestaCraftingCalculator/resource.h | 17 +++++++ 10 files changed, 88 insertions(+), 12 deletions(-) create mode 100644 FiestaCraftingCalculator/FiestaCraftingCalculator.rc create mode 100644 FiestaCraftingCalculator/assets/button_plus_mask.png create mode 100644 FiestaCraftingCalculator/assets/icon.ico create mode 100644 FiestaCraftingCalculator/assets/plus_button.png create mode 100644 FiestaCraftingCalculator/resource.h 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 0000000000000000000000000000000000000000..c99586f65f49cebcacc4653d1621b665561c8f2e GIT binary patch literal 3450 zcmdUx-)|B@5Xa})#Q$NXFE$$R$D3~jS|rkHN@+A9Ap`_T=s`HpnE1C>Ki^%}Ug1t{ z_2JA0c6V-Oc4l_wyYv0JW;JtmYBL+z$`+RLo7fuKCA8EwHncgrhCN|8o7zW9_^qI? zna9vp%#z!%8nJflq-|zPc&hf$9&k#{&j(NwzRuwud)~^PeAPZ##dAyY!1GPKoOB=A zJL}qo^{i=aduszbw_~VH)@RnS4^X=NpIRMChjlz(Hk5Bf>*DOJMO=1cJRwR8yTbo9 z(NP>O@cKRfZM<&ar{Zx8{RO|>8~ObmeDU!Oa<}7OzKBJOLUwG3l`?69-}lRn82PBT zTywO}ak~liH|M5Oa=_VR?mS@^>#)lzRAp+1Ia!cqYHH@=_2^b@jnQ~yCuCKqsV?=? zqq-WLJRrL|4C(#GaD|c==r|{b2S}YEf9Ox`Ks|%nV{Z98jg-LGLU)^5eQi(C-G#3X zCCKb@4EP$VI%I%+Db4`Z$0eS;;ne1ThXwgn9&-gUCNFi>w9r?)H zw`W`Q)%}HtNlLhKpEL3hzhe7%Q?Wj{)hD9^_TN}pWYNoeT6EWQ4m=)@sWf3s7{Z7= zyxGsTct_sLcYVv%_Ufzv}pyI5Us+Rho`Q2rPoF^OC+jDgbieMF8 zT4j4PML4fA{>@vJ&C+tMV@1SSC^zx3DC$J^k)d23Wvz)w5a++`NrlwE?nz@DvsRRA VEenfZf`qyd((HGj`}ZzQKLDk?sMr7i literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..5161b34fa5f8fe311e5ad9ceb4cb142699b5855c GIT binary patch literal 723 zcmV;^0xbQBP)EX>4Tx04R}tkv&MmKpe$iTeU^14t5Z!kfAzR5EXHhDi*;)X)CnqU~=gfG-*gu zTpR`0f`cE6RRFSdL}hb93mEq9V~S)E9naHG;u^$RLb{e z9hNz7aaJld*19KuVKA?*q`6Krj5wB%KoSBZ)KEqRCZe>eq!>uie$2%`Z2ObslE_sC zBgX=&P$1fV@IUz7tx=eobdrKGp!>zLK1KomF3_x7*7vbxHBSKFGjOH0{nZ9A`$>Ae ztwoN2foPI5*rG<=dR)a000?uMObu0Z*6U5Zgc=ca%Ew3 zWn>_CX>@2HM@dakSAh-}00020Nkl+W@d0i;LKm>ASAhX$w)2&;OZFg?n)`u-YZEd z)oq6&a_QdP-r-tb&ox#`IX!+U<+xz?FM#CyA<^LrxB(dL<3kUX=2ZXy002ovPDHLk FV1i^*C4;K7~IeB{qDO*nV7Wv(3O!sqr_PZ5dYl7T>4;a(%Vv zFM3 zDSipJEN@Ipi=RDI(@8(q_4|#v=fUeHfxTi8z5ZSHmEbGBcI{bD>+D98W~|Nd9tIcT zhIg`?8I;%8nKk_A-o7PEx4iAX z?Pm|z3rVkXWBySQwq;)%m!m+|?Orol_07r_y;ECMV2`#G`@2+6*q_on9Ozbyf-N8c zUbQ#-j)LETE8>W6T&vkIsc&1UUpngIvT|du)Vs3M9ZpXusy1#o0q2*$eY)T9bA|sL z+<}7M^uiq@%3YbB^(r_9=X>-5dH*WkWHsS%$5swnOOqe zD&W2XuEQ^ha!==H4tR6%OJ4fV!=Iu*kg(IgaEjlH9PeUg&MsAk$DXOBd(7k-++#p0 z=;z$Tc2|=zKRe+3@gb0RbM`Y9e?2;w&i@kpH@F8XgI3}nLxy+YXAg#(y%*06No)Uf zD?jIkI|pvTf7zTp1OIk&e)_A746lg!fiB1VhNQj5->!up+p*?s#nH$(R_P9SWog4U zSzHp$VSN`|ol)L2VY|yKKRr`7aOvGL{$4_IwP}5_sJbt=dcZ#xA9BI(8jhZHe;9fF zk>7+`#p~cZdaKr`ci8LEHT$l_{hj`Di+?};o(plq4|gF0bI`3o7Q^dL|4$=hkxWe4);Ebzd=tp3_oX|;@`;*;5Rau^Roj3I@Rn}KRW=No6vm?e8Aa1#$Wp} z^V9z`bnpQ)=%?OP^BaEgWSb-^hw2~haWGpA85w{KU!)G)K6Nb^h2H~M7hsvVNY)!~rryDD;E1PsRq?f(KFHDw(iMvsfZ z(0-8(rNmD|?IH!XVgH{CeBZ7IcRQAY$JKqn^f#FP4)`v;`;4t4Y> z1I+(^=zs8|gId$iJuo_e|0=jexAN1iVE^=+8FDRGwQ;}<+=IVQ<9`my2I7nP z`=2xVg7jW+je}wE4{v|*uYGCzTmBAb8`y~ZPZ0OtI`jThVeu~r?6oh0v);_G8EdjB zDKgd!ZA0-16C(q?)(qN$w6tXSh<-OJP{az z`!W~?lF)6;&*ec83H&Ttr_6lVq)a*Hj7ir&-D}f)p@7pzZV(qg`e*`bIlCghbml? zUX_74;BK_A1%C3T%Ak6WoEenX`8hlK-+4#>1HvB7h`S?ih~n^ocp!2}%nBdCJ)uXq zKpC#d3Q&n0Pk_3>F8dl>!%u^dK~g-2_Y%_U=}8Q~h`nwbkp)_YGTwB5X zP_M&jG8g~;qi`C2WVi|MdxEllU1{QiBXe?Brqn1id~RPMb05%kV|;QIOL|5xDu_tXCXR@y>h literal 0 HcmV?d00001 diff --git a/FiestaCraftingCalculator/assets/plus_button.png b/FiestaCraftingCalculator/assets/plus_button.png new file mode 100644 index 0000000000000000000000000000000000000000..d4a54d0a221ed66866816a552afc8dc7f0e1b36c GIT binary patch literal 1004 zcmVEX>4Tx04R}tkv&MmKpe$iTeU^14t5Z!kfAzR5EXHhDi*;)X)CnqU~=gfG-*gu zTpR`0f`cE6RRFSdL}hb93mEq9V~S)E9naHG;u^$RLb{e z9hNz7aaJld*19KuVKA?*q`6Krj5wB%KoSBZ)KEqRCZe>eq!>uie$2%`Z2ObslE_sC zBgX=&P$1fV@IUz7tx=eobdrKGp!>zLK1KomF3_x7*7vbxHBSKFGjOH0{nZ9A`$>Ae ztwoN2foPI5*j3VDw1pf000?uMObu0Z*6U5Zgc=ca%Ew3 zWn>_CX>@2HM@dakSAh-}0005QNklK`fC9)y$DstAf5tJ zAT;_0IYD)W-od>>bAsN$v!NQ9+-6OYsTo9|f@3dQsMn<~f>?H(+P{?#A3nZEevd#0 zoO6bVW2Ka=s%q3UO#%SW>-8R@C|dOU{TU%-I-k#f!9JvvL74E9@{VQ~w zuoOZRQcBWUB!uu78%`|i9N|DL>l_&yPJ|HNmNUkN6UVtYSZssiTp(k^$;RnB006D^ z$ET;>r}g@-(>^|4BLDyyeBC-BsGoHN%A%Y82J@ftUxyKvpG-v@)D_GaJL@6byQfdSzLMb&OhGDF=*4E1b9DLPhgE9FillRectDecal(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