#include "pch.h" #include "SellSreenRow.h" #include "colors.h" #include "utils.h" SellSreenRow::SellSreenRow(const ItemStack& item, const Vector2f& pos, const Vector2f& size): m_Item(item), m_Pos(pos), m_Size(size) { m_NameText = new Text(PlayerInventory::GetItemName(item.m_ItemType), "fonts/verdana.ttf", 12, Colors::GREEN); m_CalculationText = new Text("Hello World", "fonts/verdana.ttf", 14, Colors::GREEN); this->GenerateCalcString(); m_Icon = PlayerInventory::GetItemIcon(item.m_ItemType); } SellSreenRow::~SellSreenRow() { delete m_NameText; delete m_CalculationText; } void SellSreenRow::Draw() const { //The row has, The icon, The name, The amount, an X, the value, an =, the total value //The icon Vector2f iconPos { m_Pos.x + 10, m_Pos.y + 2 }; m_Icon->Draw(iconPos); //The name Vector2f namePos { iconPos.x + 50, m_Pos.y + 8 }; m_NameText->Draw(namePos); Vector2f amountPos { namePos.x + 100, m_Pos.y + 8 }; m_CalculationText->Draw(amountPos); // utils::SetColor(Colors::GREEN); // utils::DrawRect(Rectf { m_Pos, m_Size }); } void SellSreenRow::Update(float) { // m_NameText->ChangeText("EXAMPLE"); // m_CalculationText->ChangeText(std::to_string(m_Item.m_Quantity)); GenerateCalcString(); } void SellSreenRow::GenerateCalcString() { std::string amount = std::to_string(m_Item.m_Quantity); std::string value = std::to_string(PlayerInventory::GetItemValue(m_Item.m_ItemType)); std::string totalValue = std::to_string(PlayerInventory::GetItemValue(m_Item.m_ItemType) * m_Item.m_Quantity); // NAME AMOUNT X VALUE = TOTAL VALUE std::string text = amount + " x $" + value + " = " + totalValue + "$"; m_CalculationText->ChangeText(text); }