diff options
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 |