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. int * RLEntries;
  22. struct SEntry
  23. {
  24. int offset;
  25. int group;
  26. } ;
  27. std::vector<SEntry> SEntries ;
  28. std::string defName, curDir;
  29. int readNormalNr (int pos, int bytCon, unsigned char * str=NULL) const;
  30. void putPixel(
  31. SDL_Surface * dest,
  32. const int & ftcp,
  33. const BMPPalette & color,
  34. const unsigned char & palc,
  35. const bool & yellowBorder,
  36. const bool & blueBorder,
  37. const unsigned char & animCount
  38. ) const;
  39. ////////////
  40. unsigned char * FDef; //animation raw data
  41. int curFrame, internalFrame; //number of currently displayed frame
  42. unsigned int frames; //number of frames
  43. public:
  44. std::map<int, std::vector<int> > frameGroups; //groups of frames; [groupID] -> vector of frame IDs in group
  45. int type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1])
  46. int fullWidth, fullHeight; //read-only, please!
  47. CCreatureAnimation(std::string name); //c-tor
  48. ~CCreatureAnimation(); //d-tor
  49. void setType(int type); //sets type of animation and cleares framecount
  50. int getType() const; //returns type of animation
  51. 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
  52. 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
  53. void incrementFrame();
  54. int getFrame() const;
  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__