CCreatureAnimation.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef __CCREATUREANIMATION_H__
  2. #define __CCREATUREANIMATION_H__
  3. #include "../global.h"
  4. #include "../CPlayerInterface.h"
  5. #include "../hch/CDefHandler.h"
  6. class CCreatureAnimation : public CIntObject
  7. {
  8. private:
  9. int totalEntries, DEFType, totalBlocks;
  10. int length;
  11. BMPPalette palette[256];
  12. int * RLEntries;
  13. struct SEntry
  14. {
  15. int offset;
  16. int group;
  17. } ;
  18. std::vector<SEntry> SEntries ;
  19. std::string defName, curDir;
  20. int readNormalNr (int pos, int bytCon, unsigned char * str=NULL) const;
  21. void putPixel(
  22. SDL_Surface * dest,
  23. const int & ftcp,
  24. const BMPPalette & color,
  25. const unsigned char & palc,
  26. const bool & yellowBorder,
  27. const bool & blueBorder,
  28. const unsigned char & animCount
  29. ) const;
  30. ////////////
  31. unsigned char * FDef; //animation raw data
  32. int curFrame, internalFrame; //number of currently displayed frame
  33. unsigned int frames; //number of frames
  34. public:
  35. std::map<int, std::vector<int> > frameGroups; //groups of frames; [groupID] -> vector of frame IDs in group
  36. int type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1])
  37. int fullWidth, fullHeight; //read-only, please!
  38. CCreatureAnimation(std::string name); //c-tor
  39. ~CCreatureAnimation(); //d-tor
  40. void setType(int type); //sets type of animation and cleares framecount
  41. int getType() const; //returns type of animation
  42. 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
  43. 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
  44. void incrementFrame();
  45. int getFrame() const;
  46. bool onLastFrameInGroup();
  47. bool once;
  48. void playOnce(int type); //plays once given stage of animation, then resets to 2
  49. int framesInGroup(int group) const; //retirns number of fromes in given group
  50. };
  51. #endif // __CCREATUREANIMATION_H__