CDefHandler.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef __CDEFHANDLER_H__
  2. #define __CDEFHANDLER_H__
  3. #include "../client/CBitmapHandler.h"
  4. struct SDL_Surface;
  5. class CDefEssential;
  6. class CLodHandler;
  7. /*
  8. * CDefHandler.h, part of VCMI engine
  9. *
  10. * Authors: listed in file AUTHORS in main folder
  11. *
  12. * License: GNU General Public License v2.0 or later
  13. * Full text of license available in license.txt file, in main folder
  14. *
  15. */
  16. struct Cimage
  17. {
  18. int groupNumber;
  19. std::string imName; //name without extension
  20. SDL_Surface * bitmap;
  21. };
  22. class CDefHandler
  23. {
  24. private:
  25. int totalEntries, DEFType, totalBlocks;
  26. bool allowRepaint;
  27. int length;
  28. unsigned int * RWEntries;
  29. struct SEntry
  30. {
  31. std::string name;
  32. int offset;
  33. int group;
  34. } ;
  35. std::vector<SEntry> SEntries ;
  36. public:
  37. int width, height; //width and height
  38. std::string defName, curDir;
  39. std::vector<Cimage> ourImages;
  40. bool alphaTransformed;
  41. bool notFreeImgs;
  42. CDefHandler(); //c-tor
  43. ~CDefHandler(); //d-tor
  44. static void print (std::ostream & stream, int nr, int bytcon);
  45. int readNormalNr (int pos, int bytCon, unsigned char * str=NULL, bool cyclic=false);
  46. static unsigned char *writeNormalNr (int nr, int bytCon);
  47. SDL_Surface * getSprite (int SIndex, unsigned char * FDef, BMPPalette * palette); //zapisuje klatke o zadanym numerze do "testtt.bmp"
  48. void openDef(std::string name);
  49. void expand(unsigned char N,unsigned char & BL, unsigned char & BR);
  50. void openFromMemory(unsigned char * table, std::string name);
  51. CDefEssential * essentialize();
  52. static CDefHandler * giveDef(std::string defName);
  53. static CDefEssential * giveDefEss(std::string defName);
  54. };
  55. class CDefEssential //DefHandler with images only
  56. {
  57. public:
  58. std::vector<Cimage> ourImages;
  59. ~CDefEssential(); //d-tor
  60. };
  61. #endif // __CDEFHANDLER_H__