CCreatureAnimation.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "../global.h"
  3. #include "../CPlayerInterface.h"
  4. #include "../hch/CDefHandler.h"
  5. class CCreatureAnimation : public CIntObject
  6. {
  7. private:
  8. int totalEntries, DEFType, totalBlocks;
  9. bool allowRepaint;
  10. int length;
  11. BMPPalette palette[256];
  12. unsigned int * RWEntries;
  13. int * RLEntries;
  14. struct SEntry
  15. {
  16. std::string name;
  17. int offset;
  18. int group;
  19. } ;
  20. std::vector<SEntry> SEntries ;
  21. char id[2];
  22. std::string defName, curDir;
  23. int readNormalNr (int pos, int bytCon, unsigned char * str=NULL, bool cyclic=false);
  24. void putPixel(SDL_Surface * dest, const int & ftcp, const BMPPalette & color, const unsigned char & palc, const bool & yellowBorder) const;
  25. ////////////
  26. unsigned char * FDef; //animation raw data
  27. unsigned int curFrame; //number of currently displayed frame
  28. unsigned int frames; //number of frames
  29. int type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1])
  30. public:
  31. int fullWidth, fullHeight; //read-only, please!
  32. CCreatureAnimation(std::string name); //c-tor
  33. ~CCreatureAnimation(); //d-tor
  34. void setType(int type); //sets type of animation and cleares framecount
  35. int getType() const; //returns type of animation
  36. 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
  37. 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
  38. int framesInGroup(int group) const; //retirns number of fromes in given group
  39. };