CDefHandler.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #ifndef __CDEFHANDLER_H__
  2. #define __CDEFHANDLER_H__
  3. #include "../client/CBitmapHandler.h"
  4. #include <SDL_stdinc.h>
  5. struct SDL_Surface;
  6. class CDefEssential;
  7. class CLodHandler;
  8. /*
  9. * CDefHandler.h, part of VCMI engine
  10. *
  11. * Authors: listed in file AUTHORS in main folder
  12. *
  13. * License: GNU General Public License v2.0 or later
  14. * Full text of license available in license.txt file, in main folder
  15. *
  16. */
  17. struct Cimage
  18. {
  19. int groupNumber;
  20. std::string imName; //name without extension
  21. SDL_Surface * bitmap;
  22. };
  23. // Def entry in file. Integer fields are all little endian and will
  24. // need to be converted.
  25. struct SDefEntryBlock {
  26. Uint32 unknown1;
  27. Uint32 totalInBlock;
  28. Uint32 unknown2;
  29. Uint32 unknown3;
  30. unsigned char data[0];
  31. };
  32. // Def entry in file. Integer fields are all little endian and will
  33. // need to be converted.
  34. struct SDefEntry {
  35. Uint32 DEFType;
  36. Uint32 width;
  37. Uint32 height;
  38. Uint32 totalBlocks;
  39. struct {
  40. unsigned char R;
  41. unsigned char G;
  42. unsigned char B;
  43. } palette[256];
  44. // SDefEntry is followed by a series of SDefEntryBlock
  45. // This is commented out because VC++ doesn't accept C99 syntax.
  46. //struct SDefEntryBlock blocks[];
  47. };
  48. // Def entry in file. Integer fields are all little endian and will
  49. // need to be converted.
  50. struct SSpriteDef {
  51. Uint32 prSize;
  52. Uint32 defType2;
  53. Uint32 FullWidth;
  54. Uint32 FullHeight;
  55. Uint32 SpriteWidth;
  56. Uint32 SpriteHeight;
  57. Uint32 LeftMargin;
  58. Uint32 TopMargin;
  59. };
  60. class CDefHandler
  61. {
  62. private:
  63. unsigned int DEFType;
  64. int length;
  65. //unsigned int * RWEntries;
  66. struct SEntry
  67. {
  68. std::string name;
  69. int offset;
  70. int group;
  71. } ;
  72. std::vector<SEntry> SEntries ;
  73. public:
  74. int width, height; //width and height
  75. std::string defName;
  76. std::vector<Cimage> ourImages;
  77. bool alphaTransformed;
  78. bool notFreeImgs;
  79. CDefHandler(); //c-tor
  80. ~CDefHandler(); //d-tor
  81. SDL_Surface * getSprite (int SIndex, const unsigned char * FDef, const BMPPalette * palette) const; //zapisuje klatke o zadanym numerze do "testtt.bmp"
  82. void openDef(std::string name);
  83. static void expand(unsigned char N,unsigned char & BL, unsigned char & BR);
  84. void openFromMemory(unsigned char * table, std::string name);
  85. CDefEssential * essentialize();
  86. static CDefHandler * giveDef(std::string defName);
  87. static CDefEssential * giveDefEss(std::string defName);
  88. };
  89. class CDefEssential //DefHandler with images only
  90. {
  91. public:
  92. std::vector<Cimage> ourImages;
  93. ~CDefEssential(); //d-tor
  94. };
  95. #endif // __CDEFHANDLER_H__