Peoplemon  0.1.0
Peoplemon 3 game source documentation
StoreItemRow.hpp
Go to the documentation of this file.
1 #ifndef GAME_MENUS_STOREITEMROW_HPP
2 #define GAME_MENUS_STOREITEMROW_HPP
3 
4 #include <BLIB/Graphics/Dummy2D.hpp>
5 #include <BLIB/Interfaces/Menu.hpp>
6 #include <Core/Items/Id.hpp>
7 
8 namespace game
9 {
10 namespace menu
11 {
18 class StoreItemRow : public bl::menu::Item {
19 public:
21  using Ptr = std::shared_ptr<StoreItemRow>;
22 
24  static constexpr float Height = 18.f;
25 
34  static Ptr create(int qty, core::item::Id item, int price);
35 
43  static Ptr create(core::item::Id item, int price);
44 
49  virtual ~StoreItemRow() = default;
50 
56  void updateQty(int qty);
57 
62  virtual glm::vec2 getSize() const override;
63 
68  core::item::Id getItem() const;
69 
70 protected:
77  virtual void doCreate(bl::engine::Engine& engine) override;
78 
84  virtual void doSceneAdd(bl::rc::Scene* overlay) override;
85 
89  virtual void doSceneRemove() override;
90 
94  virtual bl::ecs::Entity getEntity() const override;
95 
101  virtual void draw(bl::rc::scene::CodeScene::RenderContext& ctx) override;
102 
103 private:
104  const core::item::Id item;
105  const int qty;
106  const int price;
107  bl::gfx::Dummy2D dummy;
108  bl::gfx::Text qtyText;
109  bl::gfx::Text nameText;
110  bl::gfx::Text priceText;
111 
112  StoreItemRow(int qty, core::item::Id item, int price);
113 };
114 
115 } // namespace menu
116 } // namespace game
117 
118 #endif
Id
Represents an item in its simplist form.
Definition: Id.hpp:24
Parent namespace for all functionality unique to the game.
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 ~StoreItemRow()=default
Destroy the Store Item Row object.
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.