#pragma once #include "StringView.hpp" #include #include #include #include #include #include #include namespace dchat { class Channel; class Chatbar { public: Chatbar(); void addChar(sf::Uint32 codePoint); void addString(const std::string &strToAdd); const sf::String& getString() const; void removePreviousChar(); void removeNextChar(); void clear(); void moveCaretLeft(); void moveCaretRight(); bool isFocused() const; void processEvent(const sf::Event &event, Channel *channel); void draw(sf::RenderWindow &window); static float getHeight(); static bool addBind(const std::string &key, const std::string &value, bool updateFile = true); static bool removeBind(const std::string &key, bool updateFile = true); static const std::unordered_map& getBinds(); private: void processChatCommand(const StringView &cmd); private: sf::Text text; sf::RectangleShape background; sf::RectangleShape inputBackground; int caretIndex; sf::Vector2f caretOffset; sf::Clock blinkTimer; bool focused; }; }