diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-04-08 21:04:12 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2019-04-08 21:04:17 +0200 |
commit | 725ea566a2b6a12e0a02e4f570b6e99102e2d21b (patch) | |
tree | d35a338392e15f50402c2055d520e7b1c3ea36a2 /include/Gif.hpp | |
parent | 4aac8df198e3a5bd9c6efc95cdf4c520c2e05401 (diff) |
Refactor, remove a lot of code and use dchat core instead
Diffstat (limited to 'include/Gif.hpp')
-rw-r--r-- | include/Gif.hpp | 51 |
1 files changed, 9 insertions, 42 deletions
diff --git a/include/Gif.hpp b/include/Gif.hpp index ebcb5d4..6edef92 100644 --- a/include/Gif.hpp +++ b/include/Gif.hpp @@ -1,52 +1,19 @@ #pragma once -#include "StringView.hpp" -#include <SFML/Graphics/RenderTarget.hpp> +#include <dchat/Gif.hpp> #include <SFML/Graphics/Texture.hpp> -#include <SFML/Graphics/Sprite.hpp> -#include <SFML/System/Clock.hpp> -#include <boost/filesystem/path.hpp> -#include <stdexcept> -extern "C" -{ -#include <libnsgif.h> -} namespace dchat { - class GifLoadException : public std::runtime_error - { - public: - GifLoadException(const std::string &errMsg) : std::runtime_error(errMsg) {} - }; - - class Gif + class SfmlGif : public Gif { public: - // Throws GifLoadException on error - Gif(const boost::filesystem::path &filepath); - Gif(StringView &&fileContent); - ~Gif(); - - sf::Vector2u getSize() const; - - void setPosition(const sf::Vector2f &position); - sf::Vector2f getPosition() const; - - void setScale(const sf::Vector2f &scale); - void setColor(sf::Color color); - void draw(sf::RenderTarget &target, const sf::RenderStates &renderStates = sf::RenderStates::Default); - - static bool isDataGif(const StringView &data); - private: - void init(); - private: - gif_animation gif; - StringView fileContent; - unsigned int currentFrame; - sf::Sprite sprite; + SfmlGif(StringView fileContent); + virtual ~SfmlGif(){} + + bool createTexture() override; + void updateTexture(void *textureData) override; + sf::Texture texture; - double timeElapsedCs; - sf::Clock frameTimer; }; -} +}
\ No newline at end of file |