| 1 | /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ |
| 2 | /* If you are missing that file, acquire a complete release at teeworlds.com. */ |
| 3 | #ifndef GAME_CLIENT_COMPONENTS_KEY_BINDER_H |
| 4 | #define GAME_CLIENT_COMPONENTS_KEY_BINDER_H |
| 5 | |
| 6 | #include <game/client/component.h> |
| 7 | #include <game/client/components/binds.h> |
| 8 | #include <game/client/ui.h> |
| 9 | |
| 10 | // component to fetch keypresses, override all other input |
| 11 | class CKeyBinder : public CComponent |
| 12 | { |
| 13 | public: |
| 14 | int Sizeof() const override { return sizeof(*this); } |
| 15 | bool OnInput(const IInput::CEvent &Event) override; |
| 16 | |
| 17 | class CKeyReaderResult |
| 18 | { |
| 19 | public: |
| 20 | CBindSlot m_Bind; |
| 21 | bool m_Aborted; |
| 22 | }; |
| 23 | CKeyReaderResult DoKeyReader(CButtonContainer *pReaderButton, CButtonContainer *pClearButton, const CUIRect *pRect, const CBindSlot &CurrentBind, bool Activate); |
| 24 | bool IsActive() const; |
| 25 | |
| 26 | private: |
| 27 | const CButtonContainer *m_pKeyReaderId = nullptr; |
| 28 | bool m_TakeKey = false; |
| 29 | std::optional<CBindSlot> m_Key; |
| 30 | }; |
| 31 | |
| 32 | #endif |
| 33 | |