#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 #include #include #include 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 - ChannelTopPanel::getHeight())); rect.setFillColor(ColorScheme::getPanelColor()); rect.setPosition(windowSize.x - getWidth(), posY); //window.draw(rect); 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); // TODO: Remove this shit sf::String str = "Online - "; str += to_string(currentChannel->getUsers().size()); sf::Text text(str, *font, FONT_SIZE * Settings::getScaling() * 1.25f); text.setPosition(position); text.setFillColor(ColorScheme::getTextRegularColor()); window.draw(text); position.y += floor(font->getLineSpacing(text.getCharacterSize())); 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 floor(WIDTH * Settings::getScaling()); } }