Loading

Paste #p0okhcc21

  1. /** Data of an animation group. */
  2. class AnimGroupData
  3. {
  4. public:
  5.     AnimGroupData();
  6.     AnimGroupData(const AnimGroupData &ag);
  7.     AnimGroupData &operator=(const AnimGroupData &ag);
  8.  
  9.     int m_iTileSize;       ///< Size of a tile for this animation group.
  10.     int m_iAnimLength;     ///< Number of frames in an animation of this group.
  11.     std::string m_sName;   ///< Name of the animation group.
  12.  
  13.     int m_aFirstFrames[4]; ///< Index into AnimationStorage::m_vFrames of the first frame, else \c -1.
  14. };
  15.  
  16. /** Data of a frame in an animation. */
  17. class FrameData
  18. {
  19. public:
  20.     FrameData();
  21.     FrameData(const FrameData &fd);
  22.     FrameData &operator=(const FrameData &fd);
  23.  
  24.     int m_iSound;          ///< If non-zero, sound to play.
  25.     int m_iNumberElements; ///< Number of sprite elements in the frame.
  26.     int m_iFirstElement;   ///< Index of the first sprite element in AnimationStorage::m_vElements.
  27. };
  28.  
  29. /** Flags of a sprite element. */
  30. enum ElementFlags
  31. {
  32.     ELM_FLIP_VERT = 0x1, ///< Flip sprite vertically.
  33.     ELM_FLIP_HOR  = 0x2, ///< Flip sprite horizontally.
  34.     ELM_ALPHA_50  = 0x4, ///< Apply alpha 50%.
  35.     ELM_ALPHA_75  = 0x8, ///< Apply alpha 75%.
  36. };
  37.  
  38. /** Data of a sprite element in a frame. */
  39. class ElementData
  40. {
  41. public:
  42.     ElementData();
  43.     ElementData(const ElementData &ed);
  44.     ElementData &operator=(const ElementData &ed);
  45.  
  46.     int m_iSprite;
  47.     int m_iXoffset;
  48.     int m_iYoffset;
  49.     int m_iLayerClass; ///< Class of the display condition.
  50.     int m_iLayerId;    ///< Value of the display condition.
  51.     int m_iFlags;      ///< Flags, @see ElementFlags for the fields.
  52. };
  53.  
  54. /** Data of a sprite, used in an element. */
  55. class SpriteData
  56. {
  57. public:
  58.     SpriteData();
  59.     SpriteData(const SpriteData &sd);
  60.     SpriteData &operator=(const SpriteData &sd);
  61.  
  62.     int m_iWidth;
  63.     int m_iHeight;
  64.     int m_iDataLength; ///< Number of bytes in AnimationStorage::m_pSpriteData for this sprite.
  65.     int m_iDataOffset; ///< Offset of the first byte in AnimationStorage::m_pSpriteData.
  66. };
  67. class AnimationStorage
  68. {
  69. public:
  70.     AnimationStorage();
  71.  
  72.     bool LoadFile(Input &oInput);
  73.  
  74.     std::vector<AnimGroupData> m_vGroupedAnims;
  75.     std::vector<FrameData> m_vFrames;
  76.     std::vector<ElementData> m_vElements;
  77.     std::vector<SpriteData> m_vSprites;
  78.     unsigned char *m_pSpriteData;
  79.     size_t m_iSpriteDataSize;
  80.  
  81. private:
  82.     bool LoadAnimGroup(AnimGroupData &oAnimGrp, int iFramesUsed, Input &oInput);
  83.     bool LoadFrame(FrameData &oFrame, int &iElementsUsed, int iSpritesUsed, Input &oInput);
  84.     bool LoadSprite(SpriteData &oSprite, int &iSpriteDataUsed, oInput &oInput);
  85. };

Comments