Peoplemon  0.1.0
Peoplemon 3 game source documentation
PeoplemonButton.hpp
Go to the documentation of this file.
1 #ifndef GAME_MENUS_PEOPLEMONBUTTON_HPP
2 #define GAME_MENUS_PEOPLEMONBUTTON_HPP
3 
4 #include <BLIB/Interfaces/Menu.hpp>
6 
7 namespace game
8 {
9 namespace menu
10 {
17 class PeoplemonButton : public bl::menu::Item {
18 public:
19  using Ptr = std::shared_ptr<PeoplemonButton>;
20 
25  virtual ~PeoplemonButton() = default;
26 
33  static Ptr create(const core::pplmn::OwnedPeoplemon& ppl);
34 
39  void setHighlightColor(const sf::Color& color);
40 
45  virtual glm::vec2 getSize() const override;
46 
52  void sync(const core::pplmn::OwnedPeoplemon& ppl);
53 
59  void update(float dt);
60 
65  bool synced() const;
66 
67 protected:
74  virtual void doCreate(bl::engine::Engine& engine) override;
75 
81  virtual void doSceneAdd(bl::rc::Scene* overlay) override;
82 
86  virtual void doSceneRemove() override;
87 
91  virtual bl::ecs::Entity getEntity() const override;
92 
98  virtual void draw(bl::rc::scene::CodeScene::RenderContext& ctx) override;
99 
100 private:
101  const core::pplmn::OwnedPeoplemon& ppl;
102  bl::engine::Engine* enginePtr;
103  bl::rc::Scene* overlay;
104  sf::Color color;
105  bool isSelected;
106  bl::rc::res::TextureRef txtr;
107  bl::rc::res::TextureRef faceTxtr;
108  bl::rc::res::TextureRef ailTxtr;
109  bl::gfx::Sprite image;
110  bl::gfx::Sprite face;
111  bl::gfx::Rectangle hpBar;
112  bl::gfx::Text name;
113  bl::gfx::Text level;
114  bl::gfx::Text item;
115  bl::gfx::Text hpText;
116  bl::gfx::Sprite ailment;
117  float hpBarTarget;
118 
120  void updateAilment(core::pplmn::Ailment ail);
121 };
122 
123 } // namespace menu
124 } // namespace game
125 
126 #endif
Ailment
Represents an ailment that a Peoplemon can have.
Definition: Ailment.hpp:16
Parent namespace for all functionality unique to the game.
Represents an instance of a peoplemon. Can be a wild peoplemon, trainer, or player peoplemon....
Menu item for peoplemon.
virtual void doSceneAdd(bl::rc::Scene *overlay) override
Called when the item should be added to the overlay.
static Ptr create(const core::pplmn::OwnedPeoplemon &ppl)
Creates a new peoplemon button from the peoplemon.
virtual void doSceneRemove() override
Called when the item should be removed from the overlay.
virtual ~PeoplemonButton()=default
Destroy the Peoplemon Button object.
void setHighlightColor(const sf::Color &color)
Set the highlight color.
bool synced() const
Returns whether or not this button is synced.
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< PeoplemonButton > Ptr
virtual glm::vec2 getSize() const override
Returns the size of the button.
void sync(const core::pplmn::OwnedPeoplemon &ppl)
Syncs the HP bar and ailment texture with the peoplemon.
void update(float dt)
Updates the HP bar.
virtual bl::ecs::Entity getEntity() const override
Returns the entity (or top level entity) of the item.