Add in inventory quantity checks for equipment we don't have when crafting items

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
pull/35/head
Nic0Nic0Nii 10 months ago
parent 00e7a01ab1
commit 330ceefc5b
  1. 11
      Adventures in Lestoria/BlacksmithCraftingWindow.cpp
  2. 7
      Adventures in Lestoria/CraftItemWindow.cpp
  3. 11
      Adventures in Lestoria/EnhancementStatsLabel.h

@ -97,6 +97,16 @@ void Menu::InitializeBlacksmithCraftingWindow(){
const std::weak_ptr<Item>item=comp.lock()->GetItem();
std::string label="";
if(Inventory::GetItemCount(item.lock()->ActualName)==0){ //If we don't own the item we have to create it first.
if(item.lock()->EnhancementIsPossible()&&item.lock()->GetEnhancementInfo().size()>item.lock()->EnhancementLevel()+1){
label=std::format("#00FF00Craft {}",item.lock()->GetDisplayName());
}
Component<MenuLabel>(CRAFT_ITEM,"Enhancement Level Header")->SetLabel(label);
Component<MenuLabel>(CRAFT_ITEM,"Item Name Header")->SetLabel(std::format("Crafting {}",item.lock()->DisplayName()));
Component<EnhancementStatsLabel>(CRAFT_ITEM,"Enhancement Stats Label")->SetItem(item);
Component<RequiredMaterialsList>(CRAFT_ITEM,"Required Materials List")->SetItem(item);
Component<MenuComponent>(CRAFT_ITEM,"Craft Button")->SetGrayedOut(!item.lock()->CanEnhanceItem());
}else{ //We will open the menu that lets us enhance by one level.
if(item.lock()->EnhancementIsPossible()&&item.lock()->GetEnhancementInfo().size()>item.lock()->EnhancementLevel()+1){
label=std::format("Level {} ->#00AA00 {}",item.lock()->EnhancementLevel(),item.lock()->EnhancementLevel()+1);
}
@ -105,6 +115,7 @@ void Menu::InitializeBlacksmithCraftingWindow(){
Component<EnhancementStatsLabel>(CRAFT_ITEM,"Enhancement Stats Label")->SetItem(item);
Component<RequiredMaterialsList>(CRAFT_ITEM,"Required Materials List")->SetItem(item);
Component<MenuComponent>(CRAFT_ITEM,"Craft Button")->SetGrayedOut(!item.lock()->CanEnhanceItem());
}
Menu::OpenMenu(CRAFT_ITEM);
return true;
},

@ -30,7 +30,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of this software are copyright © 2023 The FreeType
Portions of this software are copyright <EFBFBD> 2023 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
@ -58,8 +58,13 @@ void Menu::InitializeCraftItemWindow(){
craftItemWindow->ADD("Craft Button",MenuComponent)(geom2d::rect<float>{{craftItemWindow->size.x-84,116},{48,12}},"Craft",[](MenuFuncData data){
const std::weak_ptr<Item>item=Component<EnhancementStatsLabel>(data.menu.GetType(),"Enhancement Stats Label")->GetItem();
if(item.lock()->CanEnhanceItem()){
if(Inventory::GetItemCount(item.lock()->ActualName())==0){ //We don't own this item, so we need to give the player this item and refresh the blacksmith's inventory.
Inventory::AddItem(item.lock()->ActualName());
Inventory::UpdateBlacksmithInventoryLists();
}else{ //Since we already own this equipment, just enhance it.
item.lock()->EnhanceItem();
}
}
std::string label="";
if(item.lock()->EnhancementIsPossible()&&item.lock()->GetEnhancementInfo().size()>item.lock()->EnhancementLevel()+1){
label=std::format("Level {} ->#00AA00 {}",item.lock()->EnhancementLevel(),item.lock()->EnhancementLevel()+1);

@ -30,7 +30,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of this software are copyright © 2023 The FreeType
Portions of this software are copyright <EFBFBD> 2023 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
@ -89,12 +89,21 @@ protected:
std::string percentageSign=attr.DisplayAsPercent()?"%":"";
if(Inventory::GetItemCount(itemRef.lock()->ActualName())==0){ //This item hasn't been created yet, so just show that we are developing the item first.
window.DrawShadowStringDecal(drawPos+vf2d{maxAttributeLabelSize+4+24,yOffset},std::format("{:<5}",
attr.ShowAsDecimal()?std::format("{:>4.2f}{}",value,percentageSign):std::format("{}{}",value,percentageSign),
nextStageValue!=0?
attr.ShowAsDecimal()?std::format("{:<4.2f}{}",nextStageValue,percentageSign):std::format("{}{}",nextStageValue,percentageSign)
:"MAX"),
WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x,1.0f);
}else{ //This item is getting enhanced to the next level.
window.DrawShadowStringDecal(drawPos+vf2d{maxAttributeLabelSize+4+24,yOffset},std::format("{:>5} ->#00AA00 {:<5}",
attr.ShowAsDecimal()?std::format("{:>4.2f}{}",value,percentageSign):std::format("{}{}",value,percentageSign),
nextStageValue!=0?
attr.ShowAsDecimal()?std::format("{:<4.2f}{}",nextStageValue,percentageSign):std::format("{}{}",nextStageValue,percentageSign)
:"MAX"),
WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x,1.0f);
}
yOffset+=16;
}
}else{

Loading…
Cancel
Save