aboutsummaryrefslogtreecommitdiff
path: root/include/Chatbar.hpp
blob: df492ac8f21fec143c69c3f0f398326d1d37b44d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once

#include "StringView.hpp"
#include "Text.hpp"
#include "Cache.hpp"
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Window/Event.hpp>
#include <SFML/System/Clock.hpp>
#include <string>
#include <unordered_map>

namespace dchat
{
    class Channel;
    
    class Chatbar
    {
    public:
        Chatbar();
        
        bool isFocused() const;
        
        void processEvent(const sf::Event &event, Cache &cache, Channel *channel);
        void draw(sf::RenderWindow &window, Cache &cache);
        
        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<std::string, std::string>& getBinds();
    private:
        void processChatCommand(const StringView &cmd);
    private:
        Text text;
        sf::RectangleShape background;
        sf::RectangleShape inputBackground;
        bool focused;
    };
}