Peoplemon  0.1.0
Peoplemon 3 game source documentation
BagItemButton.hpp
Go to the documentation of this file.
1 #ifndef GAME_MENUS_BAGITEMBUTTON_HPP
2 #define GAME_MENUS_BAGITEMBUTTON_HPP
3 
4 #include <BLIB/Interfaces/Menu.hpp>
5 #include <Core/Player/Bag.hpp>
6 
14 namespace game
15 {
16 namespace menu
17 {
23 class BagItemButton : public bl::menu::Item {
24 public:
26  using Ptr = std::shared_ptr<BagItemButton>;
27 
34  static Ptr create(const core::player::Bag::Item& item);
35 
39  virtual ~BagItemButton() = default;
40 
44  void update(const core::player::Bag::Item& item);
45 
49  virtual glm::vec2 getSize() const override;
50 
54  const core::player::Bag::Item& getItem() const;
55 
56 protected:
63  virtual void doCreate(bl::engine::Engine& engine) override;
64 
70  virtual void doSceneAdd(bl::rc::Scene* overlay) override;
71 
75  virtual void doSceneRemove() override;
76 
80  virtual bl::ecs::Entity getEntity() const override;
81 
87  virtual void draw(bl::rc::scene::CodeScene::RenderContext& ctx) override;
88 
89 private:
91  bl::rc::res::TextureRef txtr;
92  bl::gfx::Sprite background;
93  bl::gfx::Text label;
94  bl::gfx::Text qty;
95 
97  void onSelect();
98  void onDeselect();
99 };
100 
101 } // namespace menu
102 } // namespace game
103 
104 #endif
Parent namespace for all functionality unique to the game.
Simple struct representing a set of items in the bag.
Definition: Bag.hpp:24
Represents a button for a quantity of items in the bag.
void update(const core::player::Bag::Item &item)
Updates the text labels from the given item.
const core::player::Bag::Item & getItem() const
Returns the item this button is representing.
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...
virtual void draw(bl::rc::scene::CodeScene::RenderContext &ctx) override
Renders the item.
std::shared_ptr< BagItemButton > Ptr
Pointer to the menu item.
static Ptr create(const core::player::Bag::Item &item)
Creates a new item button.
virtual glm::vec2 getSize() const override
Returns the size the button takes up.
virtual void doSceneRemove() override
Called when the item should be removed from the overlay.
virtual ~BagItemButton()=default
Destroy the Bag Item Button object.
virtual bl::ecs::Entity getEntity() const override
Returns the entity (or top level entity) of the item.
virtual void doSceneAdd(bl::rc::Scene *overlay) override
Called when the item should be added to the overlay.