Animations.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #pragma once
  2. #include "CPaletteRGBA.h"
  3. namespace Gfx
  4. {
  5. struct SH3DefFile;
  6. class CImage;
  7. class CAnimation
  8. {
  9. protected:
  10. ui32 framesCount;
  11. ui32 width;
  12. ui32 height;
  13. inline CAnimation(ui32 fc, ui32 w, ui32 h) : framesCount(fc), width(w), height(h) {};
  14. public:
  15. static CAnimation* makeFromDEF(const SH3DefFile& def, size_t fileSize);
  16. virtual ~CAnimation();
  17. virtual CImage* getFrame(ui32 fnr) = 0;
  18. inline ui32 getFramesCount() { return framesCount; };
  19. inline ui32 getWidth() { return width; };
  20. inline ui32 getHeight() { return height; };
  21. };
  22. class COneFrameAnimation : CAnimation
  23. {
  24. friend class CAnimation;
  25. CImage& frame;
  26. protected:
  27. COneFrameAnimation(CImage& img);
  28. public:
  29. virtual ~COneFrameAnimation();
  30. virtual CImage* getFrame(ui32 fnr);
  31. };
  32. #pragma warning(disable : 4200)
  33. class CPalettedAnimation : CAnimation
  34. {
  35. friend class CAnimation;
  36. CPaletteRGBA palette;
  37. CImage* frames[];
  38. protected:
  39. CPalettedAnimation(const SH3DefFile& def, size_t fileSize);
  40. #pragma warning(disable : 4291)
  41. inline void* operator new(size_t size, ui32 frCount) {
  42. return ::operator new(size + frCount * sizeof(void*));
  43. }
  44. #pragma warning(default : 4291)
  45. public:
  46. virtual ~CPalettedAnimation();
  47. virtual CImage* getFrame(ui32 fnr);
  48. };
  49. #pragma warning(default : 4200)
  50. }