CDefHandler.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef CDEFHANDLER_H
  2. #define CDEFHANDLER_H
  3. #include "SDL.h"
  4. #include "CSemiDefHandler.h"
  5. class CDefEssential;
  6. struct BMPHeader
  7. {
  8. int fullSize, _h1, _h2, _h3, _c1, _c2, _c3, _c4, x, y,
  9. dataSize1, dataSize2; //DataSize=X*Y+2*Y
  10. unsigned char _c5[8];
  11. void print(std::ostream & out);
  12. BMPHeader(){_h1=_h2=0;for(int i=0;i<8;i++)_c5[i]=0;};
  13. };/*
  14. struct DEFHeader
  15. {
  16. int type, width, height, groups;
  17. unsigned char palette[767];
  18. };
  19. struct DEFGroup
  20. {
  21. int ID, items, unknown1, unknown2;
  22. };*/
  23. struct BMPPalette
  24. {
  25. unsigned char R,G,B,F;
  26. };
  27. class CDefHandler
  28. {
  29. private:
  30. int totalEntries, DEFType, totalBlocks, fullWidth, fullHeight;
  31. bool allowRepaint;
  32. int length;
  33. unsigned char * FDef;
  34. BMPPalette palette[256];
  35. unsigned int * RWEntries;
  36. int * RLEntries;
  37. struct SEntry
  38. {
  39. std::string name;
  40. int offset;
  41. int group;
  42. } ;
  43. std::vector<SEntry> SEntries ;
  44. char id[2];
  45. public:
  46. std::string defName, curDir;
  47. std::vector<Cimage> ourImages;
  48. bool alphaTransformed;
  49. bool notFreeImgs;
  50. CDefHandler();
  51. ~CDefHandler();
  52. static void print (std::ostream & stream, int nr, int bytcon);
  53. int readNormalNr (int pos, int bytCon, unsigned char * str=NULL, bool cyclic=false);
  54. static unsigned char * CDefHandler::writeNormalNr (int nr, int bytCon);
  55. SDL_Surface * getSprite (int SIndex); //zapisuje klatke o zadanym numerze do "testtt.bmp"
  56. void openDef(std::string name);
  57. void expand(unsigned char N,unsigned char & BL, unsigned char & BR);
  58. void openFromMemory(unsigned char * table, int size, std::string name);
  59. CDefEssential * essentialize();
  60. };
  61. class CDefEssential //DefHandler with images only
  62. {
  63. public:
  64. std::vector<Cimage> ourImages;
  65. };
  66. #endif // CDEFHANDLER_H