PakLoader.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * PakLoader.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "PakLoader.h"
  12. #include "../../../lib/filesystem/ResourcePath.h"
  13. class SDLImageShared;
  14. class PakLoader
  15. {
  16. public:
  17. struct ImageEntry
  18. {
  19. std::string name;
  20. uint32_t sheetIndex = 0;
  21. uint32_t spriteOffsetX = 0;
  22. uint32_t unknown1 = 0;
  23. uint32_t spriteOffsetY = 0;
  24. uint32_t unknown2 = 0;
  25. uint32_t sheetOffsetX = 0;
  26. uint32_t sheetOffsetY = 0;
  27. uint32_t width = 0;
  28. uint32_t height = 0;
  29. uint32_t rotation = 0;
  30. uint32_t hasShadow = 0;
  31. uint32_t shadowSheetIndex = 0;
  32. uint32_t shadowSheetOffsetX = 0;
  33. uint32_t shadowSheetOffsetY = 0;
  34. uint32_t shadowWidth = 0;
  35. uint32_t shadowHeight = 0;
  36. uint32_t shadowRotation = 0;
  37. };
  38. struct SheetEntry
  39. {
  40. uint32_t compressedSize = 0;
  41. uint32_t fullSize = 0;
  42. };
  43. struct ArchiveEntry
  44. {
  45. std::string name = "";
  46. uint32_t metadataOffset = 0;
  47. uint32_t metadataSize = 0;
  48. uint32_t countSheets = 0;
  49. uint32_t compressedSize = 0;
  50. uint32_t fullSize = 0;
  51. uint32_t scale = 0;
  52. std::vector<SheetEntry> sheets;
  53. std::vector<ImageEntry> images;
  54. };
  55. void loadPak(ResourcePath path, int scale, std::unordered_set<std::string> animToSkip, std::unordered_set<std::string> imagesToSkip, std::unordered_set<std::string> suffixesToSkip);
  56. std::map<ResourcePath, std::vector<ArchiveEntry>> content;
  57. // Fast lookup: imageName -> (ResourcePath, ImageEntry*, ArchiveEntry*)
  58. std::unordered_map<int, std::unordered_map<std::string, std::tuple<ResourcePath, ImageEntry*, ArchiveEntry*>>> imagesByName;
  59. };