#include "../include/UsersSidePanel.hpp" #include "../include/ResourceCache.hpp" #include "../include/Settings.hpp" #include "../include/Channel.hpp" #include #include #include #include using namespace std; namespace dchat { Channel *currentChannel = nullptr; const float width = 200.0f; const unsigned int FONT_SIZE = 20; void UsersSidePanel::setCurrentChannel(Channel *channel) { currentChannel = channel; } Channel* UsersSidePanel::getCurrentChannel() { return currentChannel; } void UsersSidePanel::draw(sf::RenderWindow &window) { auto windowSize = window.getSize(); sf::RectangleShape rect(sf::Vector2f(width, windowSize.y)); rect.setFillColor(sf::Color(30, 30, 30)); rect.setPosition(windowSize.x - width, 0.0f); window.draw(rect); if(!currentChannel) return; const sf::Font *font = ResourceCache::getFont("fonts/Roboto-Regular.ttf"); sf::Vector2f position(rect.getPosition().x + 10.0f, 10.0f); 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); window.draw(text); position.y += font->getLineSpacing(FONT_SIZE * Settings::getScaling()); } } float UsersSidePanel::getWidth() { return width; } }