#ifndef Animation_H #define Animation_H #include "Critical.h" #include "Zeichnung.h" namespace Framework { class Bild; //! Bild.h class LTDBDatei; //! DateiSystem.h class InitDatei; //! InitDatei.h class Rahmen; //! Rahmen.h //! Contains all images of a video animation class Animation2DData : public virtual ReferenceCounter { private: Bild** bilder; int bildAnzahl; int fps; bool wiederhohlen; bool transparent; Critical cs; public: //! Constructor DLLEXPORT Animation2DData(); //! Destructor DLLEXPORT ~Animation2DData(); //! This is necessary if multiple threads use this object simultaneously. //! If lock() is called by two threads, the last one waits until the //! first one has called unlock(). DLLEXPORT void lock(); //! This is necessary if multiple threads use this object simultaneously. //! If lock() is called by two threads, the last one waits until the //! first one has called unlock(). DLLEXPORT void unlock(); //! Loads all images from an InitDatei. The values 'fps', //! 'wiederhohlen' (true, false), 'transparent' (true, false) are also //! interpreted. The images must be in the correct order in the file. //! The name of the values does not matter, the value is the path to //! the ltdb file with /imagename appended. Example: fps=30 //! x=a.ltdb\aaaa.jpg //! y=a.ltdb\aaab.jpg //! \param datei The already loaded InitDatei DLLEXPORT void ladeAnimation(InitDatei* datei); //! Loads all images from an LTDB file in the order they are stored. //! \param datei The LTDB file DLLEXPORT void ladeAnimation(LTDBDatei* datei); //! Sets the frames per second of the video animation //! \param fps The number of frames per second DLLEXPORT void setFPS(int fps); //! Sets whether the animation repeats when it reaches the end //! \param wh 1 if the animation should repeat DLLEXPORT void setWiederhohlend(bool wh); //! Sets whether alpha blending should be used when drawing the images //! \param trp 1 if alpha blending should be used DLLEXPORT void setTransparent(bool trp); //! Deletes all images from the animation and resets all values to //! their defaults DLLEXPORT void reset(); //! Returns a specific image of the animation //! \param i The index of the image DLLEXPORT Bild* getBild(int i) const; //! Returns a specific image of the animation without increasing the //! reference counter //! \param i The index of the image DLLEXPORT Bild* zBild(int i) const; //! Returns the number of images in the animation DLLEXPORT int getBildAnzahl() const; //! Returns the number of frames per second DLLEXPORT int getFPS() const; //! Returns whether the animation repeats when it reaches the last //! image DLLEXPORT bool istWiederhohlend() const; //! Returns whether alpha blending is used when drawing the images DLLEXPORT bool istTransparent() const; }; //! A drawing that renders a video animation class Animation2D : public Zeichnung { private: Animation2DData* data; int jetzt; double ausgleich; unsigned char alpha; unsigned char maxAlpha; bool rahmen; Rahmen* ram; int aps; bool sichtbar; public: //! Constructor DLLEXPORT Animation2D(); //! Destructor DLLEXPORT virtual ~Animation2D(); //! Sets whether a border should be drawn around the animation //! \param ram 1 if a border should be drawn DLLEXPORT void setRahmen(bool ram); //! Sets a pointer to the used border //! \param ram The border DLLEXPORT void setRahmenZ(Rahmen* ram); //! Sets the width of the border //! \param br The width in pixels DLLEXPORT void setRahmenBreite(int br); //! Sets the color of the border //! \param fc The color in A8R8G8B8 format DLLEXPORT void setRahmenFarbe(int fc); //! Sets the animation to be displayed //! \param data The animation data DLLEXPORT void setAnimationDataZ(Animation2DData* data); //! Sets the transparency of the entire animation //! \param alpha The transparency DLLEXPORT void setAlphaMaske(unsigned char alpha); //! Sets the speed at which the animation fades in and out //! \param aps Alpha per second DLLEXPORT void setAPS(int aps); //! Sets the visibility of the animation //! \param sichtbar 1 if the animation should be shown, 0 if it should //! be hidden DLLEXPORT void setSichtbar(bool sichtbar); //! Processes the time that has passed since the last call of this //! function //! \param zeit The elapsed time in seconds DLLEXPORT bool tick(double zeit) override; //! Draws the animation into a specific image //! \param zRObj The image to draw into DLLEXPORT void render(Bild& zRObj) override; //! Returns the animation data DLLEXPORT Animation2DData* getAnimationData() const; //! Returns the animation data without increasing the reference counter DLLEXPORT Animation2DData* zAnimationData() const; //! Returns whether the animation is visible DLLEXPORT bool istSichtbar() const; //! Returns the index of the currently displayed image DLLEXPORT int getJetzt() const; //! Returns the transparency of the animation DLLEXPORT unsigned char getAlphaMaske() const; //! Returns whether a border is drawn around the animation DLLEXPORT bool hatRahmen() const; //! Returns the border of the animation DLLEXPORT Rahmen* getRahmen() const; //! Returns the border of the animation without increasing the //! reference counter DLLEXPORT Rahmen* zRahmen() const; //! Returns the width of the border in pixels DLLEXPORT int getRahmenBreite() const; //! Returns the color of the border in A8R8G8B8 format DLLEXPORT int getRahmenFarbe() const; //! Copies the animation so that it can be modified without //! affecting the original DLLEXPORT Zeichnung* dublizieren() const override; }; } // namespace Framework #endif