Loading

Paste #pwdssci56

  1. #ifndef AST_H
  2. #define AST_H
  3.  
  4. #include <string>
  5. #include <vector>
  6. #include <string>
  7.  
  8. /** Temporary storage of an assigned field. */
  9. class FieldStorage
  10. {
  11. public:
  12.     FieldStorage();
  13.     FieldStorage(int number, int value, int line);
  14.     FieldStorage(int number, int key, int value, int line);
  15.     FieldStorage(int number, std::string text, int line);
  16.     FieldStorage(const FieldStorage &fs);
  17.     FieldStorage &operator=(const FieldStorage &fs);
  18.  
  19.     int m_iNumber;       ///< Field number being stored.
  20.  
  21.     int m_iKey;          ///< Key to store.
  22.     int m_iValue;        ///< Value to store.
  23.     std::string m_sText; ///< Text to store.
  24.  
  25.     int m_iLine;         ///< Line number with the assignment.
  26. };
  27.  
  28. /** Pair of integer numbers. */
  29. class PairInt
  30. {
  31. public:
  32.     PairInt() : m_iKey(0), m_iValue(0) { }
  33.  
  34.     PairInt(int key, int value) : m_iKey(key), m_iValue(value) { }
  35.  
  36.     PairInt(const PairInt &pi) : m_iKey(pi.m_iKey), m_iValue(pi.m_iValue) { }
  37.  
  38.     PairInt &operator=(const PairInt &pi)
  39.     {
  40.         if (this != &pi) {
  41.             m_iKey = pi.m_iKey;
  42.             m_iValue = pi.m_iValue;
  43.         }
  44.         return *this;
  45.     }
  46.  
  47.     int m_iKey;   ///< Key of the pair.
  48.     int m_iValue; ///< Value of the pair.
  49. };
  50.  
  51. /** Enumeration listing the fields of the data structures. */
  52. enum FieldNumber
  53. {
  54.     NOTHING,
  55.  
  56.     FE_TOP,        ///< Top
  57.     FE_LEFT,       ///< Left
  58.     FE_WIDTH,      ///< Width
  59.     FE_HEIGHT,     ///< Height
  60.     FE_XOFFSET,    ///< X offset
  61.     FE_YOFFSET,    ///< Y offset
  62.     FE_IMAGE,      ///< Image name
  63.     FE_RECOLOUR,   ///< Recolour image name
  64.     FE_RECOLLAYER, ///< Recolour layer field
  65.     FE_DISPLAY,    ///< Display condition (layer-class and layer-id)
  66.     FE_ALPHA,      ///< Amount of alpha
  67.     FE_HORFLIP,    ///< Horizontal flip
  68.     FE_VERTFLIP,   ///< Vertical flip
  69.  
  70.     AF_SOUND,      ///< Sound index
  71.  
  72.     AP_TILESIZE,   ///< Tile size
  73.     AP_VIEW,       ///< View direction
  74.  
  75.     FN_NUMBER_ENTRIES, ///< Number of fields.
  76. };
  77.  
  78. /** An element (a sprite) in a frame. */
  79. class FrameElement
  80. {
  81. public:
  82.     FrameElement();
  83.     FrameElement(const FrameElement &fe);
  84.     FrameElement &operator=(const FrameElement &fe);
  85.  
  86.     int m_iTop;                  ///< Top edge of the uncropped sprite in the image (by default, \c 0).
  87.     int m_iLeft;                 ///< Left edge of the uncropped sprite in the image (by default, \c 0).
  88.     int m_iWidth;                ///< Horizontal size of the uncropped sprite (\c -1 means the entire image).
  89.     int m_iHeight;               ///< Vertical size of the uncropped sprite (\c -1 means the entire image).
  90.     int m_iXoffset;              ///< Horizontal adjustment of the top-left edge of the sprite.
  91.     int m_iYoffset;              ///< Vertical adjustment of the top-left edge of the sprite.
  92.     std::string m_sImageName;    ///< Name of the 32bpp image file.
  93.     std::string m_sRecolourName; ///< Name of the 8bpp recolour image.
  94.     std::vector<PairInt> m_vRecolourLayers; ///< Recolour layer remapping
  95.     PairInt m_oDisplay;          ///< Display layer of the element.
  96.     int m_iAlpha;                ///< Amount of alpha.
  97.     bool m_bHorFlip;             ///< Whether to flip the sprite horizontally.
  98.     bool m_bVertFlip;            ///< Whether to flip the sprite vertically.
  99. };
  100.  
  101. // Merge sprite encoder + offset branch into this.
  102. //
  103.  
  104.  
  105. /** A frame in an animation. */
  106. class AnimationFrame
  107. {
  108. public:
  109.     AnimationFrame();
  110.     AnimationFrame(const AnimationFrame &af);
  111.     AnimationFrame &operator=(const AnimationFrame &af);
  112.  
  113.     int m_isound; ///< Sound index, if not \c -1.
  114.     std::vector<FrameElement> m_velements; ///< Frame elements.
  115. };
  116.  
  117. /** Animation view direction. */
  118. enum ViewDirection
  119. {
  120.     VD_NORTH,   ///< Viewing north.
  121.     VD_EAST,    ///< Viewing east.
  122.     VD_SOUTH,   ///< Viewing south.
  123.     VD_WEST,    ///< Viewing west.
  124.  
  125.     VD_INVALID, ///< Invalid direction (not specified).
  126. };
  127.  
  128. class Animation
  129. {
  130. public:
  131.     Animation();
  132.     Animation(const Animation &an);
  133.     Animation &operator=(const Animation &an);
  134.  
  135.     void AddProperties(const AnimationProperties &props);
  136.  
  137.     int m_itilesize;                       ///< Tile size.
  138.     ViewDirection m_eviewdirection;        ///< Animation view direction.
  139.     std::vector<AnimationFrame> m_vframes; ///< Frames of the animation.
  140. };
  141.  
  142. #endif

Comments