Peoplemon  0.1.0
Peoplemon 3 game source documentation
QtyEntry.hpp
Go to the documentation of this file.
1 #ifndef CORE_SYSTEMS_HUD_QTYENTRY_HPP
2 #define CORE_SYSTEMS_HUD_QTYENTRY_HPP
3 
4 #include <BLIB/Graphics.hpp>
5 
6 namespace core
7 {
8 namespace system
9 {
10 namespace hud
11 {
18 class QtyEntry {
19 public:
25  QtyEntry(bl::engine::Engine& engine);
26 
32  void setPosition(const sf::Vector2f& position);
33 
38  sf::Vector2f getSize() const;
39 
47  void configure(int minQty, int maxQty, int qty);
48 
53  int curQty() const;
54 
62  void up(int q, bool ignoreDebounce);
63 
71  void down(int q, bool ignoreDebounce);
72 
76  void hide();
77 
78 private:
79  bl::engine::Engine& engine;
80  bl::rc::Overlay* currentOverlay;
81  sf::Vector2f position;
82  bl::gfx::Rectangle background;
83  bl::gfx::Text text;
84  bl::gfx::Triangle upArrow;
85  bl::gfx::Triangle downArrow;
86  sf::Clock debounce;
87 
88  int qty;
89  int minQty;
90  int maxQty;
91 
92  void ensureCreated();
93  void updateText();
94  bool rateLimit(bool ignore);
95 };
96 } // namespace hud
97 } // namespace system
98 } // namespace core
99 
100 #endif
Core classes and functionality for both the editor and game.
Helper class to render a number selector.
Definition: QtyEntry.hpp:18
void configure(int minQty, int maxQty, int qty)
Configures the entry with the given parameters and adds to the overlay.
Definition: QtyEntry.cpp:69
void setPosition(const sf::Vector2f &position)
Sets the position of the selector.
Definition: QtyEntry.cpp:60
void up(int q, bool ignoreDebounce)
Increments the qty up.
Definition: QtyEntry.cpp:105
void down(int q, bool ignoreDebounce)
Decrements the qty down.
Definition: QtyEntry.cpp:112
sf::Vector2f getSize() const
Returns the size of the entry in pixels.
Definition: QtyEntry.cpp:67
void hide()
Removes the quantity entry from the overlay.
Definition: QtyEntry.cpp:53
int curQty() const
Returns the currently selected qty.
Definition: QtyEntry.cpp:103
QtyEntry(bl::engine::Engine &engine)
Construct a new quantity entry helper.
Definition: QtyEntry.cpp:16