12 constexpr
unsigned int FontSize = 16;
13 constexpr
float Margin = 1.f;
14 constexpr
float TopMargin = Margin * 0.5f;
15 constexpr
float Width = 352.f;
26 StoreItemRow::StoreItemRow(
int qty,
core::item::Id item,
int price)
32 qtyText.getSection().setString(std::to_string(std::min(qty, 999)));
41 dummy.setSize({Width,
Height});
44 qtyText.setParent(dummy);
45 qtyText.getTransform().setPosition({Margin, TopMargin});
47 float LeftMargin = 30.f;
49 else { LeftMargin = Margin; }
51 nameText.create(engine,
56 nameText.getTransform().setPosition({Margin * 2.f + LeftMargin, TopMargin});
57 nameText.setParent(dummy);
59 priceText.create(engine,
61 "$" + std::to_string(price),
64 priceText.getTransform().setPosition(
65 {Width - Margin - priceText.getLocalBounds().width - 6.f, TopMargin});
66 priceText.setParent(dummy);
70 nameText.addToScene(overlay, bl::rc::UpdateSpeed::Static);
71 priceText.addToScene(overlay, bl::rc::UpdateSpeed::Static);
72 qtyText.addToScene(overlay, bl::rc::UpdateSpeed::Static);
76 nameText.removeFromScene();
77 priceText.removeFromScene();
78 qtyText.removeFromScene();
Id
Represents an item in its simplist form.
Parent namespace for all functionality unique to the game.
static const std::string & getName(item::Id item)
Returns the name of the given item.
static const sf::VulkanFont & MenuFont()
Menu item for an item in the store. Does both sellable and for-sale items.
virtual void draw(bl::rc::scene::CodeScene::RenderContext &ctx) override
Renders the item.
void updateQty(int qty)
Updates the text for how many items can be sold.
core::item::Id getItem() const
Returns the item that this row represents.
static Ptr create(int qty, core::item::Id item, int price)
Creates a new menu item in sell mode.
virtual void doCreate(bl::engine::Engine &engine) override
Called at least once when the item is added to a menu. Should create required graphics primitives and...
std::shared_ptr< StoreItemRow > Ptr
Pointer to the menu item.
static constexpr float Height
Height of a single item in pixels.
virtual void doSceneRemove() override
Called when the item should be removed from the overlay.
virtual void doSceneAdd(bl::rc::Scene *overlay) override
Called when the item should be added to the overlay.
virtual glm::vec2 getSize() const override
Returns the size that the row takes up.
virtual bl::ecs::Entity getEntity() const override
Returns the entity (or top level entity) of the item.