diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index dc9c1807..eedc9206 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -2888,6 +2888,7 @@ void AiL::ClearLoadoutItem(int slot){ itemAbility.action=[&](Player*p,vf2d pos={}){ return game->UseLoadoutItem(1); }; + game->GetPlayer()->SetItem2UseFunc(itemAbility); Component(MenuType::ITEM_LOADOUT,"Loadout Item 2")->SetItem(Item::BLANK); Component(MenuType::ITEM_LOADOUT,"Loadout Item 2")->UpdateIcon(); }break; diff --git a/Adventures in Lestoria/BlacksmithCraftingWindow.cpp b/Adventures in Lestoria/BlacksmithCraftingWindow.cpp index 587fcfab..c3ee770c 100644 --- a/Adventures in Lestoria/BlacksmithCraftingWindow.cpp +++ b/Adventures in Lestoria/BlacksmithCraftingWindow.cpp @@ -120,7 +120,6 @@ void Menu::InitializeBlacksmithCraftingWindow(){ InventoryCreator::RowPlayerWeapons_InventoryUpdate, InventoryWindowOptions{.padding=1,.size={207,28}} )END; - AddInventoryListener(weaponsDisplay,"Equipment"); weaponsDisplay->SetCompactDescriptions(CRAFTING_INFO); #pragma endregion @@ -154,7 +153,6 @@ void Menu::InitializeBlacksmithCraftingWindow(){ InventoryCreator::RowPlayerArmor_InventoryUpdate, InventoryWindowOptions{.padding=1,.size={207,28}} )END; - AddInventoryListener(armorDisplay,"Equipment"); armorDisplay->Enable(false); armorDisplay->SetCompactDescriptions(CRAFTING_INFO); #pragma endregion diff --git a/Adventures in Lestoria/ClassInfo.h b/Adventures in Lestoria/ClassInfo.h index 2773d060..82dede0d 100644 --- a/Adventures in Lestoria/ClassInfo.h +++ b/Adventures in Lestoria/ClassInfo.h @@ -59,6 +59,7 @@ public: static inline Class StringToClass(std::string className){ const std::vector&classList=DATA["class_list"].GetValues(); auto it=std::find(classList.begin(),classList.end(),className); + if(it==classList.end())ERR(std::format("WARNING! Class {} does not exist!",className)); int element=int(std::distance(classList.begin(),it)); return Class(1< [](InventoryScrollableWindowComponent&component,ITCategory cat){ std::vector>weapons; std::copy_if(Inventory::get("Equipment").begin(),Inventory::get("Equipment").end(),std::back_inserter(weapons),[](std::shared_ptritem){return item->IsWeapon();}); + std::copy_if(Inventory::blacksmithInventory.begin(),Inventory::blacksmithInventory.end(),std::back_inserter(weapons),[](std::shared_ptritem){return item->IsWeapon();}); RowInventoryScrollableWindowComponent*c=DYNAMIC_CAST(&component); @@ -178,6 +179,7 @@ std::function [](InventoryScrollableWindowComponent&component,ITCategory cat){ std::vector>armor; std::copy_if(Inventory::get("Equipment").begin(),Inventory::get("Equipment").end(),std::back_inserter(armor),[](std::shared_ptritem){return item->IsArmor();}); + std::copy_if(Inventory::blacksmithInventory.begin(),Inventory::blacksmithInventory.end(),std::back_inserter(armor),[](std::shared_ptritem){return item->IsArmor();}); RowInventoryScrollableWindowComponent*c=DYNAMIC_CAST(&component); diff --git a/Adventures in Lestoria/InventoryCreator.h b/Adventures in Lestoria/InventoryCreator.h index d1090671..99d47718 100644 --- a/Adventures in Lestoria/InventoryCreator.h +++ b/Adventures in Lestoria/InventoryCreator.h @@ -50,6 +50,7 @@ private: class InventoryScrollableWindowComponent; class InventoryCreator{ + friend class Inventory; _SETUP(Player); _SETUP(RowPlayer); _SETUP(RowMerchant); diff --git a/Adventures in Lestoria/Item.cpp b/Adventures in Lestoria/Item.cpp index 902e6835..53e721ca 100644 --- a/Adventures in Lestoria/Item.cpp +++ b/Adventures in Lestoria/Item.cpp @@ -45,6 +45,8 @@ All rights reserved. #include #include "util.h" #include "SoundEffect.h" +#include "ClassInfo.h" +#include "RowInventoryScrollableWindowComponent.h" INCLUDE_game INCLUDE_DATA @@ -57,6 +59,7 @@ safemapITEM_SCRIPTS; safemap>ITEM_CATEGORIES; std::shared_ptrItem::BLANK=std::make_shared(); std::multimap>Inventory::_inventory; +std::vector>Inventory::blacksmithInventory; std::map>>Inventory::sortedInv; std::vectorItemOverlay::items; std::mapItemSet::sets; @@ -112,6 +115,7 @@ void ItemInfo::InitializeItems(){ Stats minStats; Stats maxStats; bool useDuringCast=false; + std::string equippableClass=""; EventName useSound; for(auto&[itemKey,itemValue]:data[key].GetKeys()){ std::string keyName=itemKey; @@ -152,6 +156,10 @@ void ItemInfo::InitializeItems(){ if(keyName=="UseSound"||keyName=="Equip Sound"){ useSound=data[key][keyName].GetString(); }else + if(keyName=="Class"){ + equippableClass=data[key][keyName].GetString(); + classutils::StringToClass(equippableClass); //If this errors out then we specified an invalid class! + }else if(keyName.starts_with("Alternative Name")){ if(ITEM_CONVERSIONS.count(data[key][keyName].GetString()))ERR(std::format("Item {} already exists in Item Conversion database! Cannot add a duplicate entry!",data[key][keyName].GetString())); ITEM_CONVERSIONS[data[key][keyName].GetString()]=key; @@ -241,6 +249,7 @@ void ItemInfo::InitializeItems(){ it.sellValue=sellValue; it.useDuringCast=useDuringCast; it.useSound=useSound; + it.equippableClass=equippableClass; if(slot.size()>0){ for(std::string&s:slot){ if(!nameToEquipSlot.count(s))ERR("WARNING! Tried to add item "<>Inventory::GetInventory(){ itemList.push_back(item); } return itemList; +} + +const std::string&ItemInfo::GetClass()const{ + return equippableClass; +} + +const std::string&Item::GetClass()const{ + return it->GetClass(); +} + +void Inventory::UpdateBlacksmithInventoryLists(){ + auto weaponsList=Component(BLACKSMITH,"Weapon Inventory Display"); + auto armorList=Component(BLACKSMITH,"Armor Inventory Display"); + + blacksmithInventory.clear(); + #pragma region Retrieve all equipment that the player currently does not own + for(auto&[key,size]:DATA.GetProperty("Equipment")){ + if(GetItemCount(key)==0){ + blacksmithInventory.push_back(std::make_shared(1,key)); + } + } + #pragma endregion + + InventoryCreator::RowPlayerWeapons_InventorySlotsUpdate(*DYNAMIC_POINTER_CAST(weaponsList),"Equipment"); + InventoryCreator::RowPlayerArmor_InventorySlotsUpdate(*DYNAMIC_POINTER_CAST(armorList),"Equipment"); } \ No newline at end of file diff --git a/Adventures in Lestoria/Item.h b/Adventures in Lestoria/Item.h index c0f3d478..d5a247a6 100644 --- a/Adventures in Lestoria/Item.h +++ b/Adventures in Lestoria/Item.h @@ -210,6 +210,7 @@ public: const bool CanBeSold()const; const bool CanBePurchased()const; const Stats&RandomStats()const; + const std::string&GetClass()const; void RandomizeStats(); const bool HasRandomizedStats()const; const EnhancementInfo&GetEnhancementInfo()const; @@ -229,6 +230,7 @@ class Inventory{ friend class ItemInfo; friend class Item; friend class SaveFile; + friend class InventoryCreator; public: static std::weak_ptrAddItem(IT it,uint32_t amt=1,bool monsterDrop=false); //Returns the actual amount available in your main inventory. @@ -249,6 +251,7 @@ public: static const std::mapGetEquippedItemSets(); //Gets all items currently on inventory (Ignores Stage Loot and Monster Loot Inventories) static const std::vector>GetInventory(); + static void UpdateBlacksmithInventoryLists(); static bool SwapItems(ITCategory itemCategory,uint32_t slot1,uint32_t slot2); //Makes sure this is a valid category. Will error out if it doesn't exist! Use for ERROR HANDLING! @@ -261,6 +264,7 @@ private: static void InsertIntoStageInventoryCategory(std::shared_ptritemRef,const bool monsterDrop); static bool ExecuteAction(IT item); static std::multimap>_inventory; + static std::vector>blacksmithInventory; static std::map>equipment; //Only contains "1" of every item, as this is a map to index items and not the actual storage of items! static std::map>>sortedInv; @@ -300,6 +304,8 @@ class ItemInfo{ uint32_t sellValue=0; //If true, this item's action is activated at the beginning of the cast instead of after the cast completes. bool useDuringCast=false; + //If blank, any class can equip this item. + std::string equippableClass=""; Stats minStats; Stats maxStats; private: @@ -338,6 +344,8 @@ public: const bool IsAccessory()const; const Stats GetMinStats()const; const Stats GetMaxStats()const; + //Get the class that can equip this item. + const std::string&GetClass()const; Stats RandomizeStats(); }; diff --git a/Adventures in Lestoria/MenuComponent.cpp b/Adventures in Lestoria/MenuComponent.cpp index 331f3ad0..45846c36 100644 --- a/Adventures in Lestoria/MenuComponent.cpp +++ b/Adventures in Lestoria/MenuComponent.cpp @@ -258,4 +258,7 @@ void MenuComponent::Click(){ } } +} +void MenuComponent::SetLabel(std::string newLabel){ + label=newLabel; } \ No newline at end of file diff --git a/Adventures in Lestoria/MenuComponent.h b/Adventures in Lestoria/MenuComponent.h index 18c99ec4..de62509a 100644 --- a/Adventures in Lestoria/MenuComponent.h +++ b/Adventures in Lestoria/MenuComponent.h @@ -155,4 +155,5 @@ public: virtual void OnPlayerMoneyUpdate(uint32_t newMoney); virtual void OnChapterUpdate(uint8_t newChapter); virtual void Click(); + virtual void SetLabel(std::string newLabel); }; \ No newline at end of file diff --git a/Adventures in Lestoria/Monster.h b/Adventures in Lestoria/Monster.h index f5a14cfa..89b2501d 100644 --- a/Adventures in Lestoria/Monster.h +++ b/Adventures in Lestoria/Monster.h @@ -123,6 +123,7 @@ class GameEvent; class Monster:IAttributable{ friend struct STRATEGY; friend class AiL; + friend class InventoryCreator; public: Monster()=delete; Monster(vf2d pos,MonsterData data,bool upperLevel=false,bool bossMob=false); diff --git a/Adventures in Lestoria/NPC.cpp b/Adventures in Lestoria/NPC.cpp index 6909efad..bad550f1 100644 --- a/Adventures in Lestoria/NPC.cpp +++ b/Adventures in Lestoria/NPC.cpp @@ -42,7 +42,8 @@ All rights reserved. #include "util.h" #include "Menu.h" #include "Unlock.h" -#include "MenuComponent.h" +#include "RowInventoryScrollableWindowComponent.h" +#include "InventoryCreator.h" using A=Attribute; @@ -67,10 +68,17 @@ void Monster::STRATEGY::NPC(Monster&m,float fElapsedTime,std::string strategy){ if(game->KEY_CONFIRM.Released()&&Menu::stack.size()==0){ if(m.npcData.function=="Blacksmith"){ Menu::OpenMenu(MenuType::BLACKSMITH); + //First reset all items displayed in the blacksmith's shop (showing only our equipment.) + Inventory::UpdateBlacksmithInventoryLists(); }else if(m.npcData.function=="PotionCrafting"){ Menu::OpenMenu(MenuType::SHERMAN); - Component(SHERMAN,"Consumable Crafting Button")->SetGrayedOut(!Unlock::IsUnlocked("NPCs.Sherman.Potion Crafting Unlock Condition"_S)); + bool locked=!Unlock::IsUnlocked("NPCs.Sherman.Potion Crafting Unlock Condition"_S); + std::string craftingButtonLabel="Consumable Crafting"; + if(locked)craftingButtonLabel="???"; + + Component(SHERMAN,"Consumable Crafting Button")->SetGrayedOut(locked); + Component(SHERMAN,"Consumable Crafting Button")->SetLabel(craftingButtonLabel); }else if(m.npcData.function=="TravelingMerchant"){ Menu::OpenMenu(MenuType::MERCHANT); diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 4d410790..e7ca87b5 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 3 #define VERSION_PATCH 0 -#define VERSION_BUILD 6587 +#define VERSION_BUILD 6604 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/config/items/Weapons.txt b/Adventures in Lestoria/assets/config/items/Weapons.txt index e43777f2..ad45ff51 100644 --- a/Adventures in Lestoria/assets/config/items/Weapons.txt +++ b/Adventures in Lestoria/assets/config/items/Weapons.txt @@ -4,6 +4,7 @@ Equipment { Slot = Weapon ItemCategory = Equipment + Class = Warrior # Stat Values of the item based on Enhancement level. # See ItemStats.txt for valid stat names @@ -109,6 +110,7 @@ Equipment { Slot = Weapon ItemCategory = Equipment + Class = Ranger # Stat Values of the item based on Enhancement level. # See ItemStats.txt for valid stat names @@ -203,6 +205,7 @@ Equipment { Slot = Weapon ItemCategory = Equipment + Class = Wizard # Stat Values of the item based on Enhancement level. # See ItemStats.txt for valid stat names @@ -297,6 +300,7 @@ Equipment { Slot = Weapon ItemCategory = Equipment + Class = Warrior # Stat Values of the item based on Enhancement level. # See ItemStats.txt for valid stat names @@ -382,6 +386,7 @@ Equipment { Slot = Weapon ItemCategory = Equipment + Class = Ranger # Stat Values of the item based on Enhancement level. # See ItemStats.txt for valid stat names @@ -467,6 +472,7 @@ Equipment { Slot = Weapon ItemCategory = Equipment + Class = Wizard # Stat Values of the item based on Enhancement level. # See ItemStats.txt for valid stat names @@ -552,6 +558,7 @@ Equipment { Slot = Weapon ItemCategory = Equipment + Class = Warrior # Stat Values of the item based on Enhancement level. # See ItemStats.txt for valid stat names @@ -637,6 +644,7 @@ Equipment { Slot = Weapon ItemCategory = Equipment + Class = Ranger # Stat Values of the item based on Enhancement level. # See ItemStats.txt for valid stat names @@ -722,6 +730,7 @@ Equipment { Slot = Weapon ItemCategory = Equipment + Class = Wizard # Stat Values of the item based on Enhancement level. # See ItemStats.txt for valid stat names @@ -807,6 +816,7 @@ Equipment { Slot = Weapon ItemCategory = Equipment + Class = Warrior # Stat Values of the item based on Enhancement level. # See ItemStats.txt for valid stat names @@ -892,6 +902,7 @@ Equipment { Slot = Weapon ItemCategory = Equipment + Class = Ranger # Stat Values of the item based on Enhancement level. # See ItemStats.txt for valid stat names @@ -977,6 +988,7 @@ Equipment { Slot = Weapon ItemCategory = Equipment + Class = Wizard # Stat Values of the item based on Enhancement level. # See ItemStats.txt for valid stat names @@ -1062,6 +1074,7 @@ Equipment { Slot = Weapon ItemCategory = Equipment + Class = Warrior # Stat Values of the item based on Enhancement level. # See ItemStats.txt for valid stat names @@ -1148,6 +1161,7 @@ Equipment { Slot = Weapon ItemCategory = Equipment + Class = Ranger # Stat Values of the item based on Enhancement level. # See ItemStats.txt for valid stat names @@ -1234,6 +1248,7 @@ Equipment { Slot = Weapon ItemCategory = Equipment + Class = Wizard # Stat Values of the item based on Enhancement level. # See ItemStats.txt for valid stat names diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index b20c78a1..b27f2bf8 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ