CMusicHandler.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef __CMUSICHANDLER_H__
  2. #define __CMUSICHANDLER_H__
  3. #include <SDL_mixer.h>
  4. #include "CSoundBase.h"
  5. /*
  6. * CMusicHandler.h, part of VCMI engine
  7. *
  8. * Authors: listed in file AUTHORS in main folder
  9. *
  10. * License: GNU General Public License v2.0 or later
  11. * Full text of license available in license.txt file, in main folder
  12. *
  13. */
  14. struct Mix_Chunk;
  15. class CSndHandler;
  16. class CMusicHandler
  17. {
  18. private:
  19. CSndHandler *sndh;
  20. class cachedSounds {
  21. public:
  22. std::string filename;
  23. Mix_Chunk *chunk;
  24. // This is some horrible C++ abuse. Isn't there any way to do
  25. // something simplier to init sounds?
  26. cachedSounds(std::string filename_in, Mix_Chunk *chunk_in):
  27. filename(filename_in), chunk(chunk_in) {};
  28. };
  29. std::map<soundBase::soundNames, cachedSounds> sounds;
  30. Mix_Chunk *GetSoundChunk(std::string srcName);
  31. public:
  32. CMusicHandler(): sndh(NULL) {};
  33. void initMusics();
  34. // Sounds
  35. int playSound(soundBase::soundNames soundID, int repeats=0);
  36. int playSoundFromSet(std::vector<soundBase::soundNames> &sound_vec);
  37. void stopSound(int handler) { Mix_HaltChannel(handler); };
  38. // Sets
  39. std::vector<soundBase::soundNames> pickup_sounds;
  40. std::vector<soundBase::soundNames> horseSounds;
  41. };
  42. #endif // __CMUSICHANDLER_H__