From cb09825455f43788e860e07375f13aec903d9234 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Mon, 18 Dec 2023 00:34:10 -0600 Subject: [PATCH] Added money display to inventory GUI. Corrected inventory amounts displaying incorrectly in inventory menus (references to other items fixed). Added MenuIconButton appearance flags to disable outlines/backgrounds --- Crawler/CharacterMenuWindow.cpp | 2 +- Crawler/InventoryWindow.cpp | 7 +++++++ Crawler/Item.cpp | 10 +++++++--- Crawler/Item.h | 5 +++-- Crawler/MenuIconButton.h | 10 ++++++++-- Crawler/MenuItemItemButton.h | 12 ++++++------ Crawler/Player.h | 2 +- Crawler/RowInventoryScrollableWindowComponent.h | 4 ++-- Crawler/RowItemDisplay.h | 10 +++++----- Crawler/Version.h | 2 +- Crawler/assets/config/Player.txt | 2 ++ Crawler/assets/config/gfx/gfx.txt | 1 + Crawler/assets/currency_coin.png | Bin 0 -> 769 bytes Crawler/assets/items/Pile of Coins.png | Bin 0 -> 845 bytes Crawler/assets/money.png | Bin 0 -> 810 bytes 15 files changed, 44 insertions(+), 23 deletions(-) create mode 100644 Crawler/assets/currency_coin.png create mode 100644 Crawler/assets/items/Pile of Coins.png create mode 100644 Crawler/assets/money.png diff --git a/Crawler/CharacterMenuWindow.cpp b/Crawler/CharacterMenuWindow.cpp index 3633d7b5..120e85ad 100644 --- a/Crawler/CharacterMenuWindow.cpp +++ b/Crawler/CharacterMenuWindow.cpp @@ -165,7 +165,7 @@ void Menu::InitializeCharacterMenuWindow(){ [&](MenuFuncData data){ RowItemDisplay*button=dynamic_cast(data.component); if(button!=nullptr){ - Item&buttonItem=button->GetItem(); + const Item&buttonItem=button->GetItem(); std::vectorstatsBeforeEquip; EquipSlot slot=EquipSlot(button->I(Attribute::EQUIP_TYPE)); for(ItemAttribute attribute:displayAttrs){ diff --git a/Crawler/InventoryWindow.cpp b/Crawler/InventoryWindow.cpp index b822ffbd..c5efec3a 100644 --- a/Crawler/InventoryWindow.cpp +++ b/Crawler/InventoryWindow.cpp @@ -48,6 +48,7 @@ All rights reserved. INCLUDE_game INCLUDE_ITEM_CATEGORIES INCLUDE_DATA +INCLUDE_GFX using A=Attribute; using enum ComponentAttr; using ButtonAttr::UNSELECTABLE; @@ -120,4 +121,10 @@ void Menu::InitializeInventoryWindow(){ inventoryWindow->ADD("Item Name Label",MenuLabel)({{226,84},{inventoryDescriptionWidth-6,12}},"",0.75f,LEFT_ALIGN|SHADOW)END; inventoryWindow->ADD("Item Description Label",MenuLabel)({{226,94},{inventoryDescriptionWidth-6,inventoryWindow->size.y-44-66}},"",0.5f,LEFT_ALIGN|SHADOW)END; #pragma endregion + + vf2d moneyIconPos={224+inventoryDescriptionWidth-24,28+inventoryWindow->size.y-44+8}; + auto moneyIcon=inventoryWindow->ADD("Money Icon",MenuIconButton)({moneyIconPos,{24,24}},GFX["money.png"].Decal(),DO_NOTHING,IconButtonAttr::NOT_SELECTABLE|IconButtonAttr::NO_OUTLINE|IconButtonAttr::NO_BACKGROUND)END; + std::string moneyText=std::to_string(game->GetPlayer()->GetMoney()); + vf2d moneyTextSize=game->GetTextSizeProp(moneyText)*2; + inventoryWindow->ADD("Money Label",MenuLabel)({moneyIconPos-vf2d{2+moneyTextSize.x,0},moneyTextSize},moneyText,2,SHADOW|LEFT_ALIGN)END; } \ No newline at end of file diff --git a/Crawler/Item.cpp b/Crawler/Item.cpp index ce35ddb8..8e24de7d 100644 --- a/Crawler/Item.cpp +++ b/Crawler/Item.cpp @@ -561,19 +561,19 @@ void ItemSet::AddSetBonus(std::string setName,int pieceCount,Stats&bonuses){ sets[setName].setBonusBreakpoints.push_back({pieceCount,bonuses}); } -void Inventory::EquipItem(Item&it,EquipSlot slot){ +void Inventory::EquipItem(const Item&it,EquipSlot slot){ if(!(it.it->slot&slot))return; EquipSlot equippedSlot=GetSlotEquippedIn(it); if(equippedSlot!=EquipSlot::NONE)UnequipItem(equippedSlot); if(GetEquip(slot)!=nullptr)UnequipItem(slot); - Inventory::equipment[slot]=⁢ + Inventory::equipment[slot]=const_cast(&it); PlayerStats::RecalculateEquipStats(); }; void Inventory::UnequipItem(EquipSlot slot){ Inventory::equipment[slot]=&Item::BLANK; PlayerStats::RecalculateEquipStats(); }; -EquipSlot Inventory::GetSlotEquippedIn(Item&it){ +EquipSlot Inventory::GetSlotEquippedIn(const Item&it){ for(int i=int(EquipSlot::HELMET);i<=int(EquipSlot::RING2);i<<=1){ EquipSlot slot=EquipSlot(i); Item*equip=GetEquip(slot); @@ -713,4 +713,8 @@ const bool Item::CanBePurchased()const{ void Item::SetAmt(uint32_t newAmt){ amt=newAmt; +} + +const Item&Inventory::GetInventorySlot(ITCategory itemCategory,size_t slot){ + return GetItem(get(itemCategory)[slot].ActualName()); } \ No newline at end of file diff --git a/Crawler/Item.h b/Crawler/Item.h index fa7d1b0f..d6ed6f3a 100644 --- a/Crawler/Item.h +++ b/Crawler/Item.h @@ -182,10 +182,11 @@ public: static bool RemoveItem(IT it,ITCategory inventory,uint32_t amt = 1); static bool RemoveItem(IT it,uint32_t amt=1); static std::vector&get(ITCategory itemCategory); + static const Item&GetInventorySlot(ITCategory itemCategory,size_t slot); static void Clear(ITCategory itemCategory); - static void EquipItem(Item&it,EquipSlot slot); + static void EquipItem(const Item&it,EquipSlot slot); static void UnequipItem(EquipSlot slot); - static EquipSlot GetSlotEquippedIn(Item&it); + static EquipSlot GetSlotEquippedIn(const Item&it); static Item*GetEquip(EquipSlot slot); static const std::mapGetEquippedItemSets(); diff --git a/Crawler/MenuIconButton.h b/Crawler/MenuIconButton.h index 928b39f4..332eada8 100644 --- a/Crawler/MenuIconButton.h +++ b/Crawler/MenuIconButton.h @@ -45,6 +45,9 @@ INCLUDE_game enum class IconButtonAttr{ SELECTABLE=0b0, NOT_SELECTABLE=int(ButtonAttr::UNSELECTABLE), + //Skipping 0b0010 + NO_OUTLINE=0b0100, //Adds an outline around the component. + NO_BACKGROUND=0b1000, //Renders the background of the menu theme for this component. }; class MenuIconButton:public MenuComponent{ @@ -52,9 +55,12 @@ protected: Decal*icon; public: inline MenuIconButton(geom2d::rectrect,Decal*icon,MenuFunc onClick,IconButtonAttr attributes=IconButtonAttr::SELECTABLE) - :MenuComponent(rect,"",onClick,ButtonAttr(attributes)),icon(icon){} + :MenuIconButton(rect,icon,MenuType::ENUM_END,onClick,attributes){} inline MenuIconButton(geom2d::rectrect,Decal*icon,MenuType menuDest,MenuFunc onClick,IconButtonAttr attributes=IconButtonAttr::SELECTABLE) - :MenuComponent(rect,"",menuDest,onClick,ButtonAttr(attributes)),icon(icon){} + :MenuComponent(rect,"",menuDest,onClick,ButtonAttr(attributes)),icon(icon){ + border=!(attributes&IconButtonAttr::NO_OUTLINE); + background=!(attributes&IconButtonAttr::NO_BACKGROUND); + } protected: virtual inline void Update(Crawler*game)override{ MenuComponent::Update(game); diff --git a/Crawler/MenuItemItemButton.h b/Crawler/MenuItemItemButton.h index 8837414f..08369959 100644 --- a/Crawler/MenuItemItemButton.h +++ b/Crawler/MenuItemItemButton.h @@ -50,18 +50,18 @@ INCLUDE_ITEM_DATA class MenuItemItemButton:public MenuIconButton{ private: - std::reference_wrapperitemRef; + std::reference_wrapperitemRef; std::string itemNameLabelName; std::string itemDescriptionLabelName; bool hideQty=false; CompactText compact=COMPACT; public: - inline MenuItemItemButton(geom2d::rectrect,Item&itemRef,MenuType menuDest,MenuFunc onClick,std::string itemNameLabelName,std::string itemDescriptionLabelName,IconButtonAttr attributes=IconButtonAttr::SELECTABLE) + inline MenuItemItemButton(geom2d::rectrect,const Item&itemRef,MenuType menuDest,MenuFunc onClick,std::string itemNameLabelName,std::string itemDescriptionLabelName,IconButtonAttr attributes=IconButtonAttr::SELECTABLE) :MenuIconButton(rect,(!itemRef.IsBlank())?const_cast(itemRef.Decal()):nullptr,menuDest,onClick,attributes),itemRef(itemRef),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName){ draggable=false; valid=!itemRef.IsBlank(); } - inline MenuItemItemButton(geom2d::rectrect,Item&itemRef,MenuType menuDest,MenuFunc onClick,MenuFunc onHover,MenuFunc onMouseOut,std::string itemNameLabelName="",std::string itemDescriptionLabelName="",IconButtonAttr attributes=IconButtonAttr::SELECTABLE) + inline MenuItemItemButton(geom2d::rectrect,const Item&itemRef,MenuType menuDest,MenuFunc onClick,MenuFunc onHover,MenuFunc onMouseOut,std::string itemNameLabelName="",std::string itemDescriptionLabelName="",IconButtonAttr attributes=IconButtonAttr::SELECTABLE) :MenuIconButton(rect,(!itemRef.IsBlank())?const_cast(itemRef.Decal()):nullptr,menuDest,onClick,attributes),itemRef(itemRef),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName){ runHoverFunctions=true; draggable=false; @@ -69,11 +69,11 @@ public: SetHoverFunc(onHover); SetMouseOutFunc(onMouseOut); } - inline Item&GetItem(){ + inline const Item&GetItem(){ return itemRef.get(); } - inline Item&SetItem(Item&newItem){ - return itemRef=std::reference_wrapper(newItem); + inline const Item&SetItem(const Item&newItem){ + return itemRef=std::reference_wrapper(newItem); } inline void SetShowQuantity(bool show){ this->hideQty=!show; diff --git a/Crawler/Player.h b/Crawler/Player.h index 5c281525..8f30d833 100644 --- a/Crawler/Player.h +++ b/Crawler/Player.h @@ -115,7 +115,7 @@ private: Ability useItem1; Ability useItem2; Ability useItem3; - uint32_t money=9999; + uint32_t money="Player.Starting Money"_I; protected: const float ATTACK_COOLDOWN="Warrior.Auto Attack.Cooldown"_F; const float MAGIC_ATTACK_COOLDOWN="Wizard.Auto Attack.Cooldown"_F; diff --git a/Crawler/RowInventoryScrollableWindowComponent.h b/Crawler/RowInventoryScrollableWindowComponent.h index dcc38b7d..209826a1 100644 --- a/Crawler/RowInventoryScrollableWindowComponent.h +++ b/Crawler/RowInventoryScrollableWindowComponent.h @@ -67,7 +67,7 @@ public: vf2d buttonSize=options.size; vf2d totalSpacing={options.padding+buttonSize.x,options.padding+buttonSize.y}; - auto newItem=ADD("item_"+cat+"_"+std::to_string(itemIndex),RowItemDisplay)({totalSpacing*vf2d{float(x),float(y)},buttonSize},Inventory::get(cat)[itemIndex],inventoryButtonClickAction,itemNameLabelName,itemDescriptionLabelName,inventoryButtonsActive?ButtonAttr::NONE:ButtonAttr::UNSELECTABLE)END; + auto newItem=ADD("item_"+cat+"_"+std::to_string(itemIndex),RowItemDisplay)({totalSpacing*vf2d{float(x),float(y)},buttonSize},Inventory::GetInventorySlot(cat,itemIndex),inventoryButtonClickAction,itemNameLabelName,itemDescriptionLabelName,inventoryButtonsActive?ButtonAttr::NONE:ButtonAttr::UNSELECTABLE)END; newItem->SetCompactDescriptions(compact==COMPACT); newItem->SetHoverFunc(inventoryButtonHoverAction); newItem->SetMouseOutFunc(inventoryButtonMouseOutAction); @@ -77,7 +77,7 @@ public: for(int counter=0;MenuComponent*component:components){ RowItemDisplay*item=dynamic_cast(component); if(item!=nullptr){ - item->SetItem(Inventory::get(cat)[counter]); + item->SetItem(Inventory::GetInventorySlot(cat,counter)); }else{ ERR("WARNING! Could not properly cast item to RowItemDisplay* type!"); } diff --git a/Crawler/RowItemDisplay.h b/Crawler/RowItemDisplay.h index 5d1fa6ed..3396668d 100644 --- a/Crawler/RowItemDisplay.h +++ b/Crawler/RowItemDisplay.h @@ -43,13 +43,13 @@ All rights reserved. INCLUDE_game class RowItemDisplay:public MenuComponent{ - std::reference_wrapperitemRef; + std::reference_wrapperitemRef; std::string itemNameLabelName; std::string itemDescriptionLabelName; CompactText compact=NON_COMPACT; bool showQuantity=true; public: - inline RowItemDisplay(geom2d::rectrect,Item&itemRef,MenuFunc onClick,std::string itemNameLabelName,std::string itemDescriptionLabelName,ButtonAttr attributes=ButtonAttr::NONE) + inline RowItemDisplay(geom2d::rectrect,const Item&itemRef,MenuFunc onClick,std::string itemNameLabelName,std::string itemDescriptionLabelName,ButtonAttr attributes=ButtonAttr::NONE) :MenuComponent(rect,"",onClick,attributes),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName),itemRef(itemRef){ if(itemRef.IsEquippable())SetShowQuantity(false); } @@ -98,11 +98,11 @@ public: virtual inline void SetShowQuantity(bool showQuantity){ this->showQuantity=showQuantity; } - virtual inline Item&GetItem(){ + virtual inline const Item&GetItem(){ return itemRef; } - virtual inline void SetItem(Item&itemRef){ - this->itemRef=std::reference_wrapper(itemRef); + virtual inline void SetItem(const Item&itemRef){ + this->itemRef=std::reference_wrapper(itemRef); } void UpdateLabel(){ if(itemRef.get().IsBlank())return; diff --git a/Crawler/Version.h b/Crawler/Version.h index 4ef7fffc..d715f75c 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 1 -#define VERSION_BUILD 4125 +#define VERSION_BUILD 4140 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/assets/config/Player.txt b/Crawler/assets/config/Player.txt index 2f90d64f..1731ebf8 100644 --- a/Crawler/assets/config/Player.txt +++ b/Crawler/assets/config/Player.txt @@ -3,6 +3,8 @@ Player BaseMana = 100 MoveSpd = 100 + Starting Money = 100 + # Amount of spd to increase/decrease vertically as you climb staircases StaircaseClimbSpd = 45 diff --git a/Crawler/assets/config/gfx/gfx.txt b/Crawler/assets/config/gfx/gfx.txt index abbec501..418458a6 100644 --- a/Crawler/assets/config/gfx/gfx.txt +++ b/Crawler/assets/config/gfx/gfx.txt @@ -42,6 +42,7 @@ Images GFX_FinishRingGreen = finishring_green.png GFX_SqareSkillIcon = square_skill_overlay_icon.png GFX_SqareSkillIconEmpty = square_skill_overlay_icon_empty.png + GFX_Money = money.png # Ability Icons GFX_Warrior_BattleCry_Icon = Ability Icons/battlecry.png diff --git a/Crawler/assets/currency_coin.png b/Crawler/assets/currency_coin.png new file mode 100644 index 0000000000000000000000000000000000000000..e3a332d60faf852de0d4010814c16e711e417c3f GIT binary patch literal 769 zcmV+c1OEJpP)EX>4Tx04R}tkv&MmKpe$iQ?()$5eteqWT;Mdu_BJ8ibb$c+6t{Ym|XfHG-*gu zTpR`0f`cE6RR4rtTPCT<| z>74h8L#!+*#OK7523?T&k?XR{Z=6dG3p_JqWYcrRA!4!A!Ey()vY`@B6NeR5qkJLf zvch?bvs$UK);;+Pg9U9l!*!ZtNMI33q#!~@4I8MyLWEY06ccIMk9+t>9e;{kGPyRu z$T5#9R7j2={11M2YZjwZZc;D~bidg4$2bt!1)6o+{yw(t<_X|`2ClTWzuEw1KS{5* zweS%zunk;Xw>5bWxZD9oo^;8O9LY~pC>DYDGy0}HFmwy_t-8In_Hp_EWT~sA8{ps& zm?%;9n#a3)JA3>0Osl^i%baq`rdX6200006VoOIv0QUgb0Ju&oFF61J010qNS#tmY zE+YT{E+YYWr9XB6000McNliru=L`}BG6#*S@U{Q|02y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{007xZL_t(Y$75g^1p^HjiBZJQ&i)^p_{X0=87Z;=+29vD z8d2mVJnD(Eh>?)t=mw($m_@iOVZv+p25*AF2Xg?fU}Pes5e9xp+(N}Tlc*pDJcC^2C5!HW&vSPieJaAc^caKvf}E??jbB8DHQa7tBF zI1-%?a9aTN0i}Q}AHaf$telLV{*l8OW-u&>I9{j`%nyvX@&UGpMhQVA!(kR+%WRAU zGa30=80Q_`nu+)GDq=!N3Cm+uwDCU?_8V00000NkvXXu0mjf%=$iV literal 0 HcmV?d00001 diff --git a/Crawler/assets/items/Pile of Coins.png b/Crawler/assets/items/Pile of Coins.png new file mode 100644 index 0000000000000000000000000000000000000000..84663cd47de3d2a1e6a3fafc6386ced98fe7a649 GIT binary patch literal 845 zcmV-T1G4;yP)EX>4Tx04R}tkv&MmKpe$iQ?()$5eteqWT;Mdu_BJ8ibb$c+6t{Ym|XfHG-*gu zTpR`0f`cE6RR4rtTPCT<| z>74h8L#!+*#OK7523?T&k?XR{Z=6dG3p_JqWYcrRA!4!A!Ey()vY`@B6NeR5qkJLf zvch?bvs$UK);;+Pg9U9l!*!ZtNMI33q#!~@4I8MyLWEY06ccIMk9+t>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