#ifndef AST_H #define AST_H #include #include #include /** Temporary storage of an assigned field. */ class FieldStorage { public: FieldStorage(); FieldStorage(int number, int value, int line); FieldStorage(int number, int key, int value, int line); FieldStorage(int number, std::string text, int line); FieldStorage(const FieldStorage &fs); FieldStorage &operator=(const FieldStorage &fs); int m_iNumber; ///< Field number being stored. int m_iKey; ///< Key to store. int m_iValue; ///< Value to store. std::string m_sText; ///< Text to store. int m_iLine; ///< Line number with the assignment. }; /** Pair of integer numbers. */ class PairInt { public: PairInt() : m_iKey(0), m_iValue(0) { } PairInt(int key, int value) : m_iKey(key), m_iValue(value) { } PairInt(const PairInt &pi) : m_iKey(pi.m_iKey), m_iValue(pi.m_iValue) { } PairInt &operator=(const PairInt &pi) { if (this != &pi) { m_iKey = pi.m_iKey; m_iValue = pi.m_iValue; } return *this; } int m_iKey; ///< Key of the pair. int m_iValue; ///< Value of the pair. }; /** Enumeration listing the fields of the data structures. */ enum FieldNumber { NOTHING, FE_TOP, ///< Top FE_LEFT, ///< Left FE_WIDTH, ///< Width FE_HEIGHT, ///< Height FE_XOFFSET, ///< X offset FE_YOFFSET, ///< Y offset FE_IMAGE, ///< Image name FE_RECOLOUR, ///< Recolour image name FE_RECOLLAYER, ///< Recolour layer field FE_DISPLAY, ///< Display condition (layer-class and layer-id) FE_ALPHA, ///< Amount of alpha FE_HORFLIP, ///< Horizontal flip FE_VERTFLIP, ///< Vertical flip AF_SOUND, ///< Sound index AP_TILESIZE, ///< Tile size AP_VIEW, ///< View direction FN_NUMBER_ENTRIES, ///< Number of fields. }; /** An element (a sprite) in a frame. */ class FrameElement { public: FrameElement(); FrameElement(const FrameElement &fe); FrameElement &operator=(const FrameElement &fe); int m_iTop; ///< Top edge of the uncropped sprite in the image (by default, \c 0). int m_iLeft; ///< Left edge of the uncropped sprite in the image (by default, \c 0). int m_iWidth; ///< Horizontal size of the uncropped sprite (\c -1 means the entire image). int m_iHeight; ///< Vertical size of the uncropped sprite (\c -1 means the entire image). int m_iXoffset; ///< Horizontal adjustment of the top-left edge of the sprite. int m_iYoffset; ///< Vertical adjustment of the top-left edge of the sprite. std::string m_sImageName; ///< Name of the 32bpp image file. std::string m_sRecolourName; ///< Name of the 8bpp recolour image. std::vector m_vRecolourLayers; ///< Recolour layer remapping PairInt m_oDisplay; ///< Display layer of the element. int m_iAlpha; ///< Amount of alpha. bool m_bHorFlip; ///< Whether to flip the sprite horizontally. bool m_bVertFlip; ///< Whether to flip the sprite vertically. }; // Merge sprite encoder + offset branch into this. // /** A frame in an animation. */ class AnimationFrame { public: AnimationFrame(); AnimationFrame(const AnimationFrame &af); AnimationFrame &operator=(const AnimationFrame &af); int m_isound; ///< Sound index, if not \c -1. std::vector m_velements; ///< Frame elements. }; /** Animation view direction. */ enum ViewDirection { VD_NORTH, ///< Viewing north. VD_EAST, ///< Viewing east. VD_SOUTH, ///< Viewing south. VD_WEST, ///< Viewing west. VD_INVALID, ///< Invalid direction (not specified). }; class Animation { public: Animation(); Animation(const Animation &an); Animation &operator=(const Animation &an); void AddProperties(const AnimationProperties &props); int m_itilesize; ///< Tile size. ViewDirection m_eviewdirection; ///< Animation view direction. std::vector m_vframes; ///< Frames of the animation. }; #endif