#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; log("set " + property_name + " to " + property + " in " + get_full_name()); } else { debug("empty string passed, not setting " + property_name + " in " + get_full_name()); } } else { debug(property_name + " already set to " + property + " in " + get_full_name() + ", not setting"); } } void Item::add_image_texture(std::shared_ptr texture_id) { image_textures.push_back(texture_id); } const std::vector>& Item::get_image_textures() const { return image_textures; } const std::shared_ptr& 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(get_image_textures().size())); }