/* _______________ ,----------------------------------------------------------------. //`````````````\\ \ \ //~~~~~~~~~~~~~~~\\ \ by @ohsqueezy & @sleepin \ //=================\\ \ [ohsqueezy.itch.io] [sleepin.itch.io] \ // \\ \ \ // \\ \ code released under the zlib license [git.nugget.fun/pudding] \ // ☆ GUNKISS ☆ \\ \ \ //_________________________\\ `---------------------------------------------------------------*/ #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(sb::Texture texture) { image_textures.push_back(texture); } const std::vector& Item::get_image_textures() const { return image_textures; } const sb::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(get_image_textures().size())); }