CDefHandler.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. unsigned char fbuffer[800];
  32. bool allowRepaint;
  33. int length;
  34. unsigned char * FDef;
  35. BMPPalette palette[256];
  36. unsigned int * RWEntries;
  37. int * RLEntries;
  38. struct SEntry
  39. {
  40. std::string name;
  41. int offset;
  42. int group;
  43. } ;
  44. std::vector<SEntry> SEntries ;
  45. char id[2];
  46. public:
  47. std::string defName, curDir;
  48. std::vector<Cimage> ourImages;
  49. bool alphaTransformed;
  50. ~CDefHandler();
  51. static void print (std::ostream & stream, int nr, int bytcon);
  52. int readNormalNr (int pos, int bytCon, unsigned char * str=NULL, bool cyclic=false);
  53. static unsigned char * CDefHandler::writeNormalNr (int nr, int bytCon);
  54. SDL_Surface * getSprite (int SIndex); //zapisuje klastke o zadanym numerze do "testtt.bmp"
  55. void openDef(std::string name);
  56. void expand(unsigned char N,unsigned char & BL, unsigned char & BR);
  57. void openFromMemory(unsigned char * table, int size, std::string name);
  58. CDefEssential * essentialize();
  59. };
  60. class CDefEssential //DefHandler with images only
  61. {
  62. public:
  63. std::vector<Cimage> ourImages;
  64. };
  65. #endif // CDEFHANDLER_H