aboutsummaryrefslogtreecommitdiff
path: root/include/Chatbar.hpp
blob: 10bbebda26f50cb86740d4c84253906e88b928a4 (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
41
42
#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 sf::Vector2f getInputPosition(sf::RenderWindow &window);
        static sf::Vector2f getInputSize(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<std::string, std::string>& getBinds();
    private:
        void processChatCommand(const StringView &cmd);
    private:
        Text text;
        sf::RectangleShape background;
        sf::RectangleShape inputBackground;
        bool focused;
    };
}