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 00000000..e3a332d6 Binary files /dev/null and b/Crawler/assets/currency_coin.png differ diff --git a/Crawler/assets/items/Pile of Coins.png b/Crawler/assets/items/Pile of Coins.png new file mode 100644 index 00000000..84663cd4 Binary files /dev/null and b/Crawler/assets/items/Pile of Coins.png differ diff --git a/Crawler/assets/money.png b/Crawler/assets/money.png new file mode 100644 index 00000000..ecc1b1d3 Binary files /dev/null and b/Crawler/assets/money.png differ