aboutsummaryrefslogtreecommitdiff
path: root/src/UsersSidePanel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/UsersSidePanel.cpp')
-rw-r--r--src/UsersSidePanel.cpp47
1 files changed, 47 insertions, 0 deletions
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 <SFML/Graphics/RectangleShape.hpp>
+#include <SFML/Graphics/Text.hpp>
+#include <vector>
+#include <cmath>
+
+using namespace std;
+
+namespace dchat
+{
+ vector<User*> 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;
+ }
+}