From 3b03f87070d91f63f0dc3c7152723727781dcccf Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 28 Apr 2018 11:52:04 +0200 Subject: Add commands, users side panel, improve image download start using odhtdb --- src/UsersSidePanel.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/UsersSidePanel.cpp (limited to 'src/UsersSidePanel.cpp') diff --git a/src/UsersSidePanel.cpp b/src/UsersSidePanel.cpp new file mode 100644 index 0000000..5af01bc --- /dev/null +++ b/src/UsersSidePanel.cpp @@ -0,0 +1,47 @@ +#include "../include/UsersSidePanel.hpp" +#include "../include/ResourceCache.hpp" +#include "../include/Settings.hpp" +#include +#include +#include +#include + +using namespace std; + +namespace dchat +{ + vector users; + const float width = 200.0f; + const unsigned int FONT_SIZE = 20; + + void UsersSidePanel::addUser(User *user) + { + users.push_back(user); + } + + 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); + + const sf::Font &font = ResourceCache::getFont("fonts/Roboto-Regular.ttf"); + sf::Vector2f position(rect.getPosition().x + 10.0f, 10.0f); + for(User *user : users) + { + // 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; + } +} -- cgit v1.2.3