Peoplemon  0.1.0
Peoplemon 3 game source documentation
ScreenKeyboard.hpp
Go to the documentation of this file.
1 #ifndef CORE_SYSTEMS_HUD_SCREENKEYBOARD_HPP
2 #define CORE_SYSTEMS_HUD_SCREENKEYBOARD_HPP
3 
4 #include <BLIB/Graphics.hpp>
5 #include <BLIB/Interfaces/Menu.hpp>
6 #include <BLIB/Resources.hpp>
8 
15 namespace core
16 {
17 namespace system
18 {
20 namespace hud
21 {
28 public:
29  using OnSubmit = std::function<void(const std::string&)>;
30 
37  ScreenKeyboard(bl::engine::Engine& engine, const OnSubmit& onSubmit);
38 
43 
50  void start(unsigned int minLen = 0, unsigned int maxLen = 16);
51 
55  void stop();
56 
60  void setPosition(const sf::Vector2f& position);
61 
65  const std::string& value() const;
66 
70  sf::Vector2f getSize() const;
71 
78  void process(unsigned int ctrl, bool ignoreDebounce);
79 
80 private:
81  bl::engine::Engine& engine;
82  const OnSubmit onSubmit;
83  unsigned int minLen;
84  unsigned int maxLen;
85  std::string input;
86 
87  sf::Vector2f position;
88  bl::gfx::Text renderedInput;
89  bl::gfx::Rectangle background;
90 
91  core::input::MenuDriver inputDriver;
92  bl::menu::Menu keyboardMenu;
93 
94  void onKeyPress(char key);
95  void onEnter();
96  void lazyCreate();
97 };
98 
99 } // namespace hud
100 } // namespace system
101 } // namespace core
102 
103 #endif
bl::menu::TriggerDriver< Control::MoveUp, Control::MoveRight, Control::MoveDown, Control::MoveLeft, Control::Interact > MenuDriver
Helper typedef for Peoplemon specific menu driving.
Definition: MenuDriver.hpp:18
Core classes and functionality for both the editor and game.
A screen keyboard for getting arbitrary user input.
std::function< void(const std::string &)> OnSubmit
sf::Vector2f getSize() const
Returns the size of the screen keyboard.
void start(unsigned int minLen=0, unsigned int maxLen=16)
Subscribes the keyboard to the event bus.
void process(unsigned int ctrl, bool ignoreDebounce)
Handles player input.
void setPosition(const sf::Vector2f &position)
Sets the position of the keyboard. The default is (??)
void stop()
Unsubscribes the keyboard from the event bus.
ScreenKeyboard(bl::engine::Engine &engine, const OnSubmit &onSubmit)
Construct a new Screen Keyboard.
~ScreenKeyboard()
Unsubscribes the keyboard if still subscribed.
const std::string & value() const
Returns the current input value.