diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-04-23 09:53:31 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-04-23 09:55:12 +0200 |
commit | ddff0f1b7ea84f6a1321b8eb8a4d47317873d955 (patch) | |
tree | 28565c3a3d336559fcf149e1552ae237cc3d855d /src/MessagePart.cpp | |
parent | 1e0e68f9cda51c881b32a54d9eece71c1428f7ac (diff) |
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
Diffstat (limited to 'src/MessagePart.cpp')
-rw-r--r-- | src/MessagePart.cpp | 62 |
1 files changed, 0 insertions, 62 deletions
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 }; - } -} |