Animation.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #ifndef Animation_H
  2. #define Animation_H
  3. #include "Critical.h"
  4. #include "Zeichnung.h"
  5. namespace Framework
  6. {
  7. class Bild; //! Bild.h
  8. class LTDBDatei; //! DateiSystem.h
  9. class InitDatei; //! InitDatei.h
  10. class Rahmen; //! Rahmen.h
  11. //! Contains all images of a video animation
  12. class Animation2DData : public virtual ReferenceCounter
  13. {
  14. private:
  15. Bild** bilder;
  16. int bildAnzahl;
  17. int fps;
  18. bool wiederhohlen;
  19. bool transparent;
  20. Critical cs;
  21. public:
  22. //! Constructor
  23. DLLEXPORT Animation2DData();
  24. //! Destructor
  25. DLLEXPORT ~Animation2DData();
  26. //! This is necessary if multiple threads use this object simultaneously.
  27. //! If lock() is called by two threads, the last one waits until the
  28. //! first one has called unlock().
  29. DLLEXPORT void lock();
  30. //! This is necessary if multiple threads use this object simultaneously.
  31. //! If lock() is called by two threads, the last one waits until the
  32. //! first one has called unlock().
  33. DLLEXPORT void unlock();
  34. //! Loads all images from an InitDatei. The values 'fps',
  35. //! 'wiederhohlen' (true, false), 'transparent' (true, false) are also
  36. //! interpreted. The images must be in the correct order in the file.
  37. //! The name of the values does not matter, the value is the path to
  38. //! the ltdb file with /imagename appended. Example: fps=30
  39. //! x=a.ltdb\aaaa.jpg
  40. //! y=a.ltdb\aaab.jpg
  41. //! \param datei The already loaded InitDatei
  42. DLLEXPORT void ladeAnimation(InitDatei* datei);
  43. //! Loads all images from an LTDB file in the order they are stored.
  44. //! \param datei The LTDB file
  45. DLLEXPORT void ladeAnimation(LTDBDatei* datei);
  46. //! Sets the frames per second of the video animation
  47. //! \param fps The number of frames per second
  48. DLLEXPORT void setFPS(int fps);
  49. //! Sets whether the animation repeats when it reaches the end
  50. //! \param wh 1 if the animation should repeat
  51. DLLEXPORT void setWiederhohlend(bool wh);
  52. //! Sets whether alpha blending should be used when drawing the images
  53. //! \param trp 1 if alpha blending should be used
  54. DLLEXPORT void setTransparent(bool trp);
  55. //! Deletes all images from the animation and resets all values to
  56. //! their defaults
  57. DLLEXPORT void reset();
  58. //! Returns a specific image of the animation
  59. //! \param i The index of the image
  60. DLLEXPORT Bild* getBild(int i) const;
  61. //! Returns a specific image of the animation without increasing the
  62. //! reference counter
  63. //! \param i The index of the image
  64. DLLEXPORT Bild* zBild(int i) const;
  65. //! Returns the number of images in the animation
  66. DLLEXPORT int getBildAnzahl() const;
  67. //! Returns the number of frames per second
  68. DLLEXPORT int getFPS() const;
  69. //! Returns whether the animation repeats when it reaches the last
  70. //! image
  71. DLLEXPORT bool istWiederhohlend() const;
  72. //! Returns whether alpha blending is used when drawing the images
  73. DLLEXPORT bool istTransparent() const;
  74. };
  75. //! A drawing that renders a video animation
  76. class Animation2D : public Zeichnung
  77. {
  78. private:
  79. Animation2DData* data;
  80. int jetzt;
  81. double ausgleich;
  82. unsigned char alpha;
  83. unsigned char maxAlpha;
  84. bool rahmen;
  85. Rahmen* ram;
  86. int aps;
  87. bool sichtbar;
  88. public:
  89. //! Constructor
  90. DLLEXPORT Animation2D();
  91. //! Destructor
  92. DLLEXPORT virtual ~Animation2D();
  93. //! Sets whether a border should be drawn around the animation
  94. //! \param ram 1 if a border should be drawn
  95. DLLEXPORT void setRahmen(bool ram);
  96. //! Sets a pointer to the used border
  97. //! \param ram The border
  98. DLLEXPORT void setRahmenZ(Rahmen* ram);
  99. //! Sets the width of the border
  100. //! \param br The width in pixels
  101. DLLEXPORT void setRahmenBreite(int br);
  102. //! Sets the color of the border
  103. //! \param fc The color in A8R8G8B8 format
  104. DLLEXPORT void setRahmenFarbe(int fc);
  105. //! Sets the animation to be displayed
  106. //! \param data The animation data
  107. DLLEXPORT void setAnimationDataZ(Animation2DData* data);
  108. //! Sets the transparency of the entire animation
  109. //! \param alpha The transparency
  110. DLLEXPORT void setAlphaMaske(unsigned char alpha);
  111. //! Sets the speed at which the animation fades in and out
  112. //! \param aps Alpha per second
  113. DLLEXPORT void setAPS(int aps);
  114. //! Sets the visibility of the animation
  115. //! \param sichtbar 1 if the animation should be shown, 0 if it should
  116. //! be hidden
  117. DLLEXPORT void setSichtbar(bool sichtbar);
  118. //! Processes the time that has passed since the last call of this
  119. //! function
  120. //! \param zeit The elapsed time in seconds
  121. DLLEXPORT bool tick(double zeit) override;
  122. //! Draws the animation into a specific image
  123. //! \param zRObj The image to draw into
  124. DLLEXPORT void render(Bild& zRObj) override;
  125. //! Returns the animation data
  126. DLLEXPORT Animation2DData* getAnimationData() const;
  127. //! Returns the animation data without increasing the reference counter
  128. DLLEXPORT Animation2DData* zAnimationData() const;
  129. //! Returns whether the animation is visible
  130. DLLEXPORT bool istSichtbar() const;
  131. //! Returns the index of the currently displayed image
  132. DLLEXPORT int getJetzt() const;
  133. //! Returns the transparency of the animation
  134. DLLEXPORT unsigned char getAlphaMaske() const;
  135. //! Returns whether a border is drawn around the animation
  136. DLLEXPORT bool hatRahmen() const;
  137. //! Returns the border of the animation
  138. DLLEXPORT Rahmen* getRahmen() const;
  139. //! Returns the border of the animation without increasing the
  140. //! reference counter
  141. DLLEXPORT Rahmen* zRahmen() const;
  142. //! Returns the width of the border in pixels
  143. DLLEXPORT int getRahmenBreite() const;
  144. //! Returns the color of the border in A8R8G8B8 format
  145. DLLEXPORT int getRahmenFarbe() const;
  146. //! Copies the animation so that it can be modified without
  147. //! affecting the original
  148. DLLEXPORT Zeichnung* dublizieren() const override;
  149. };
  150. } // namespace Framework
  151. #endif