blob: f665d1fcd7cd18a822a81baed0ddb21a901b754c (
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
43
44
45
46
47
48
49
50
|
#include "../include/UsersSidePanel.hpp"
#include "../include/ChannelTopPanel.hpp"
#include "../include/ResourceCache.hpp"
#include "../include/Settings.hpp"
#include "../include/Channel.hpp"
#include "../include/ColorScheme.hpp"
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/Text.hpp>
#include <vector>
#include <cmath>
using namespace std;
namespace dchat
{
const float WIDTH = 250.0f;
const unsigned int FONT_SIZE = 20;
void UsersSidePanel::draw(sf::RenderWindow &window)
{
float posY = ChannelTopPanel::getHeight();
auto windowSize = window.getSize();
sf::RectangleShape rect(sf::Vector2f(getWidth(), windowSize.y));
rect.setFillColor(ColorScheme::getPanelColor());
rect.setPosition(windowSize.x - getWidth(), posY);
window.draw(rect);
posY += 10.0f;
Channel *currentChannel = Channel::getCurrent();
if(!currentChannel) return;
const sf::Font *font = ResourceCache::getFont("fonts/Roboto-Regular.ttf");
sf::Vector2f position(rect.getPosition().x + 10.0f, posY);
for(User *user : currentChannel->getUsers())
{
// TODO: Remove this shit
sf::String str = sf::String::fromUtf8(user->getName().begin(), user->getName().end());
sf::Text text(str, *font, FONT_SIZE * Settings::getScaling());
text.setPosition(position);
text.setFillColor(sf::Color(15, 192, 252));
window.draw(text);
position.y += floor(font->getLineSpacing(FONT_SIZE * Settings::getScaling()));
}
}
float UsersSidePanel::getWidth()
{
return WIDTH * Settings::getScaling();
}
}
|