CSndHandler.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #pragma once
  2. #include <iosfwd>
  3. #include <SDL_stdinc.h>
  4. /*
  5. * CSndHandler.h, part of VCMI engine
  6. *
  7. * Authors: listed in file AUTHORS in main folder
  8. *
  9. * License: GNU General Public License v2.0 or later
  10. * Full text of license available in license.txt file, in main folder
  11. *
  12. */
  13. namespace boost
  14. {
  15. namespace iostreams
  16. {
  17. class mapped_file_source;
  18. }
  19. }
  20. struct MemberFile
  21. {
  22. std::ifstream * ifs;
  23. int length;
  24. };
  25. // sound entry structure in catalog
  26. struct soundEntry
  27. {
  28. char filename[40];
  29. Uint32 offset; /* little endian */
  30. Uint32 size; /* little endian */
  31. };
  32. // video entry structure in catalog
  33. struct videoEntry
  34. {
  35. char filename[40];
  36. Uint32 offset; /* little endian */
  37. };
  38. class CMediaHandler
  39. {
  40. protected:
  41. struct Entry
  42. {
  43. std::string name;
  44. ui32 size;
  45. ui32 offset;
  46. const char *data;
  47. };
  48. std::vector<boost::iostreams::mapped_file_source *> mfiles;
  49. boost::iostreams::mapped_file_source *add_file(std::string fname, bool important = true); //if not important, then we don't print warning when the file is missing
  50. public:
  51. std::vector<Entry> entries;
  52. std::map<std::string, int> fimap; // map of file and index
  53. ~CMediaHandler(); //d-tor
  54. void extract(std::string srcfile, std::string dstfile, bool caseSens=true); //saves selected file
  55. const char * extract (std::string srcfile, int & size); //return selecte file data, NULL if file doesn't exist
  56. void extract(int index, std::string dstfile); //saves selected file
  57. MemberFile getFile(std::string name);//nie testowane - sprawdzic
  58. const char * extract (int index, int & size); //return selecte file - NIE TESTOWANE
  59. };
  60. class CSndHandler: public CMediaHandler
  61. {
  62. public:
  63. void add_file(std::string fname, bool important = true); //if not important, then we don't print warning when the file is missing
  64. };
  65. class CVidHandler: public CMediaHandler
  66. {
  67. public:
  68. void add_file(std::string fname);
  69. };