CCreatureAnimation.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef __CCREATUREANIMATION_H__
  2. #define __CCREATUREANIMATION_H__
  3. #include "../global.h"
  4. #include "../hch/CDefHandler.h"
  5. #include "GUIBase.h"
  6. /*
  7. * CCreatureAnimation.h, part of VCMI engine
  8. *
  9. * Authors: listed in file AUTHORS in main folder
  10. *
  11. * License: GNU General Public License v2.0 or later
  12. * Full text of license available in license.txt file, in main folder
  13. *
  14. */
  15. class CCreatureAnimation : public CIntObject
  16. {
  17. private:
  18. int totalEntries, DEFType, totalBlocks;
  19. int length;
  20. BMPPalette palette[256];
  21. struct SEntry
  22. {
  23. int offset;
  24. int group;
  25. } ;
  26. std::vector<SEntry> SEntries ;
  27. std::string defName, curDir;
  28. int readNormalNr (int pos, int bytCon, unsigned char * str=NULL) const;
  29. void putPixel(
  30. SDL_Surface * dest,
  31. const int & ftcp,
  32. const BMPPalette & color,
  33. const unsigned char & palc,
  34. const bool & yellowBorder,
  35. const bool & blueBorder,
  36. const unsigned char & animCount
  37. ) const;
  38. ////////////
  39. unsigned char * FDef; //animation raw data
  40. int curFrame, internalFrame; //number of currently displayed frame
  41. unsigned int frames; //number of frames
  42. public:
  43. std::map<int, std::vector<int> > frameGroups; //groups of frames; [groupID] -> vector of frame IDs in group
  44. int type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1])
  45. int fullWidth, fullHeight; //read-only, please!
  46. CCreatureAnimation(std::string name); //c-tor
  47. ~CCreatureAnimation(); //d-tor
  48. void setType(int type); //sets type of animation and cleares framecount
  49. int getType() const; //returns type of animation
  50. int nextFrame(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
  51. int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool IncrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
  52. void incrementFrame();
  53. int getFrame() const;
  54. bool onFirstFrameInGroup();
  55. bool onLastFrameInGroup();
  56. bool once;
  57. void playOnce(int type); //plays once given stage of animation, then resets to 2
  58. int framesInGroup(int group) const; //retirns number of fromes in given group
  59. };
  60. #endif // __CCREATUREANIMATION_H__