gunkiss/src/Item.cpp

93 lines
2.8 KiB
C++

/* _______________ +---------------------------------------------------------------------------------------+
//~~~~~~~~~~~~~\\ | a game by @ohsqueezy & @sleepin |
//```````````````\\ | [ohsqueezy.itch.io] [instagram.com/sleepin] |
//_0_0_0_0_0_0_0_0_\\ | |
//_/_/_/_/___\_\_\_\_\\ | with code licensed for copy, modification and redistribution [git.nugget.fun/pudding] |
//GGGUUUNNNKKKIIISSSSSS\\ | |
//_/__/__/__/_\__\__\__\_\\ | 😀 Thank you for choosing Puddendo for your business 😀 |
+---------------------------------------------------------------------------------------+ */
#include "Item.hpp"
Item::Item(Node* parent) : Node(parent) {};
void Item::set_text_property(const std::string& value, std::string& property, const std::string& property_name)
{
if (property == "")
{
if (value != "")
{
property = value;
sb::Log::log("set " + property_name + " to " + property + " in " + get_full_name());
}
else
{
sb::Log::log("empty string passed, not setting " + property_name + " in " + get_full_name(), sb::Log::DEBUG);
}
}
else
{
sb::Log::log(property_name + " already set to " + property + " in " + get_full_name() + ", not setting", sb::Log::DEBUG);
}
}
void Item::add_image_texture(Texture texture)
{
image_textures.push_back(texture);
}
const std::vector<Texture>& Item::get_image_textures() const
{
return image_textures;
}
const Texture& Item::get_active_image_texture() const
{
return get_image_textures()[current_image_index];
}
void Item::set_brand_name(const std::string& name)
{
set_text_property(name, brand_name, "brand name");
}
const std::string& Item::get_brand_name() const
{
return brand_name;
}
void Item::set_product_name(const std::string& name)
{
set_text_property(name, product_name, "product name");
}
const std::string& Item::get_product_name() const
{
return product_name;
}
void Item::set_upc(const std::string& upc)
{
set_text_property(upc, this->upc, "UPC");
}
const std::string& Item::get_upc() const
{
return upc;
}
std::string Item::get_full_name() const
{
std::string name = get_brand_name();
if (name != "")
{
name += " ";
}
name += get_product_name();
return name;
}
void Item::increment_image_index(int increment)
{
current_image_index = sb::mod(current_image_index + increment, static_cast<int>(get_image_textures().size()));
}