Animations.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #pragma once
  2. #include "CPaletteRGBA.h"
  3. namespace Gfx
  4. {
  5. struct SH3DefFile;
  6. class CImage;
  7. class CAnimation
  8. {
  9. protected:
  10. size_t 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 size_t 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. #ifdef _MSC_VER
  33. #pragma warning(disable : 4200)
  34. #pragma warning(disable : 4291)
  35. #endif
  36. class CPalettedAnimation : CAnimation
  37. {
  38. friend class CAnimation;
  39. CPaletteRGBA palette;
  40. CImage* frames[];
  41. protected:
  42. CPalettedAnimation(const SH3DefFile& def, size_t fileSize);
  43. inline void* operator new(size_t size, size_t frCount) {
  44. return ::operator new(size + frCount * sizeof(void*));
  45. }
  46. public:
  47. virtual ~CPalettedAnimation();
  48. virtual CImage* getFrame(ui32 fnr);
  49. };
  50. #ifdef _MSC_VER
  51. #pragma warning(default : 4200)
  52. #pragma warning(default : 4291)
  53. #endif
  54. }