From ddff0f1b7ea84f6a1321b8eb8a4d47317873d955 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 23 Apr 2018 09:53:31 +0200 Subject: Add word wrap for message board & TODO TODO: Message board is now redrawn every frame. Text should be modified to render on static & dynamic texture -> text & static images on static texture, gif & video on dynamic texture --- src/MessagePart.cpp | 62 ----------------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 src/MessagePart.cpp (limited to 'src/MessagePart.cpp') diff --git a/src/MessagePart.cpp b/src/MessagePart.cpp deleted file mode 100644 index 215c239..0000000 --- a/src/MessagePart.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "../include/MessagePart.hpp" -#include "../include/ResourceCache.hpp" -#include "../include/Settings.hpp" - -using namespace std; - -namespace dchat -{ - const float MESSAGE_PART_SIZE = 27; - - float MessagePart::getSizeScaled() - { - return MESSAGE_PART_SIZE * Settings::getScaling(); - } - - MessagePartText::MessagePartText(const string &_text, bool _newLine) : - MessagePart(Type::TEXT, _newLine), - text("", ResourceCache::getFont("fonts/Roboto-Regular.ttf"), MessagePartText::getFontSizeScaled()) - { - text.setString(sf::String::fromUtf8(_text.begin(), _text.end())); - } - - float MessagePartText::getFontSizeScaled() - { - return MessagePart::getSizeScaled() * 0.8f; - } - - sf::Vector2f MessagePartText::getPosition() const - { - return text.getPosition(); - } - - sf::Vector2f MessagePartText::getSize() const - { - return sf::Vector2f(text.getLocalBounds().width, getFontSizeScaled()); - } - - MessagePartEmoji::MessagePartEmoji(const string &_url, bool _newLine) : - MessagePart(Type::EMOJI, _newLine), - url(_url), - dirty(true) - { - - } - - float MessagePartEmoji::getHeightScaled() - { - return MessagePart::getSizeScaled() * 1.0f; - } - - sf::Vector2f MessagePartEmoji::getPosition() const - { - return sprite.getPosition(); - } - - sf::Vector2f MessagePartEmoji::getSize() const - { - auto spriteScale = sprite.getScale(); - auto textureSize = sprite.getTexture()->getSize(); - return { (float)textureSize.x * spriteScale.x, (float)textureSize.y * spriteScale.y }; - } -} -- cgit v1.2.3