2
0

CCreatureAnimation.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef CCREATUREANIMATION_H
  2. #define CCREATUREANIMATION_H
  3. #ifdef _MSC_VER
  4. #pragma once
  5. #endif
  6. #include "../global.h"
  7. #include "../CPlayerInterface.h"
  8. #include "../hch/CDefHandler.h"
  9. class CCreatureAnimation : public CIntObject
  10. {
  11. private:
  12. int totalEntries, DEFType, totalBlocks;
  13. int length;
  14. BMPPalette palette[256];
  15. int * RLEntries;
  16. struct SEntry
  17. {
  18. std::string name;
  19. int offset;
  20. int group;
  21. } ;
  22. std::vector<SEntry> SEntries ;
  23. std::string defName, curDir;
  24. int readNormalNr (int pos, int bytCon, unsigned char * str=NULL) const;
  25. void putPixel(
  26. SDL_Surface * dest,
  27. const int & ftcp,
  28. const BMPPalette & color,
  29. const unsigned char & palc,
  30. const bool & yellowBorder
  31. ) const;
  32. ////////////
  33. unsigned char * FDef; //animation raw data
  34. int curFrame; //number of currently displayed frame
  35. unsigned int frames; //number of frames
  36. public:
  37. int type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1])
  38. int fullWidth, fullHeight; //read-only, please!
  39. CCreatureAnimation(std::string name); //c-tor
  40. ~CCreatureAnimation(); //d-tor
  41. void setType(int type); //sets type of animation and cleares framecount
  42. int getType() const; //returns type of animation
  43. int nextFrame(SDL_Surface * dest, int x, int y, bool attacker, bool incrementFrame = true, bool yellowBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
  44. int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, bool IncrementFrame = true, bool yellowBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
  45. void incrementFrame();
  46. int getFrame() const;
  47. int framesInGroup(int group) const; //retirns number of fromes in given group
  48. };
  49. #endif //CCREATUREANIMATION_H