[Super-tux-commit] supertux/lib/audio musicref.cpp,1.1,1.2 musicref.h,1.1,1.2 sound.cpp,1.1,1.2 soun
Brought to you by:
wkendrick
From: Tobias G. <to...@us...> - 2004-07-21 16:52:31
|
Update of /cvsroot/super-tux/supertux/lib/audio In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32238/lib/audio Modified Files: musicref.cpp musicref.h sound.cpp sound_manager.cpp sound_manager.h Log Message: The SuperTux library features a SuperTux namespace now. + minor Bugfixes and cleanups Index: sound_manager.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/audio/sound_manager.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- sound_manager.cpp 20 Jul 2004 17:51:35 -0000 1.1 +++ sound_manager.cpp 21 Jul 2004 16:51:50 -0000 1.2 @@ -27,6 +27,8 @@ #include "app/setup.h" #include "special/moving_object.h" +using namespace SuperTux; + SoundManager::SoundManager() : current_music(0), music_enabled(true) { Index: musicref.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/audio/musicref.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- musicref.cpp 20 Jul 2004 17:51:34 -0000 1.1 +++ musicref.cpp 21 Jul 2004 16:51:50 -0000 1.2 @@ -20,6 +20,8 @@ #include "audio/musicref.h" +using namespace SuperTux; + MusicRef::MusicRef() : music(0) { Index: sound_manager.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/audio/sound_manager.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- sound_manager.h 20 Jul 2004 20:33:14 -0000 1.3 +++ sound_manager.h 21 Jul 2004 16:51:50 -0000 1.4 @@ -26,65 +26,70 @@ #include "SDL_mixer.h" #include "math/vector.h" -class MusicRef; -class MovingObject; +namespace SuperTux + { -/// Sound manager -/** This class handles all sounds that are played - */ -class SoundManager -{ -public: - SoundManager(); - ~SoundManager(); + class MusicRef; + class MovingObject; - /// Play sound. - void play_sound(Mix_Chunk* sound); - /// Play sound relative to two Vectors. - void play_sound(Mix_Chunk* sound, const Vector& pos, const Vector& pos2); - /// Play sound relative to a MovingObject and a Vector. - void play_sound(Mix_Chunk* sound, const MovingObject* object, const Vector& pos); + /// Sound manager + /** This class handles all sounds that are played + */ + class SoundManager + { + public: + SoundManager(); + ~SoundManager(); - /// Load music. - /** Is used to load the music for a MusicRef. */ - MusicRef load_music(const std::string& file); - /// Test if a certain music file exists. - bool exists_music(const std::string& filename); - - /// Play music. - /** @Param loops: Defaults to -1, which means endless loops. */ - void play_music(const MusicRef& music, int loops = -1); - - /// Halt music. - void halt_music(); + /// Play sound. + void play_sound(Mix_Chunk* sound); + /// Play sound relative to two Vectors. + void play_sound(Mix_Chunk* sound, const Vector& pos, const Vector& pos2); + /// Play sound relative to a MovingObject and a Vector. + void play_sound(Mix_Chunk* sound, const MovingObject* object, const Vector& pos); - /// Enable/Disable music. - void enable_music(bool enable); + /// Load music. + /** Is used to load the music for a MusicRef. */ + MusicRef load_music(const std::string& file); + /// Test if a certain music file exists. + bool exists_music(const std::string& filename); -private: - // music part - friend class MusicRef; - - /// Resource for music. - /** Contains the raw music data and - information for music reference - counting. */ - class MusicResource - { - public: - ~MusicResource(); + /// Play music. + /** @param loops: Defaults to -1, which means endless loops. */ + void play_music(const MusicRef& music, int loops = -1); - SoundManager* manager; - Mix_Music* music; - int refcount; - }; + /// Halt music. + void halt_music(); - void free_music(MusicResource* music); + /// Enable/Disable music. + void enable_music(bool enable); - std::map<std::string, MusicResource> musics; - MusicResource* current_music; - bool music_enabled; -}; + private: + // music part + friend class MusicRef; + + /// Resource for music. + /** Contains the raw music data and + information for music reference + counting. */ + class MusicResource + { + public: + ~MusicResource(); + + SoundManager* manager; + Mix_Music* music; + int refcount; + }; + + void free_music(MusicResource* music); + + std::map<std::string, MusicResource> musics; + MusicResource* current_music; + bool music_enabled; + }; + +} // namespace SuperTux #endif /*SUPERTUX_SOUND_MANAGER_H*/ Index: musicref.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/audio/musicref.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- musicref.h 20 Jul 2004 17:51:34 -0000 1.1 +++ musicref.h 21 Jul 2004 16:51:50 -0000 1.2 @@ -22,24 +22,29 @@ #include "audio/sound_manager.h" -/** This class holds a reference to a music file and maintains a correct - * refcount for that file. - */ -class MusicRef -{ -public: - MusicRef(); - MusicRef(const MusicRef& other); - ~MusicRef(); +namespace SuperTux + { - MusicRef& operator= (const MusicRef& other); + /** This class holds a reference to a music file and maintains a correct + * refcount for that file. + */ + class MusicRef + { + public: + MusicRef(); + MusicRef(const MusicRef& other); + ~MusicRef(); -private: - friend class SoundManager; - MusicRef(SoundManager::MusicResource* music); - - SoundManager::MusicResource* music; -}; + MusicRef& operator= (const MusicRef& other); + + private: + friend class SoundManager; + MusicRef(SoundManager::MusicResource* music); + + SoundManager::MusicResource* music; + }; + +} //namespace SuperTux #endif /*SUPERTUX_MUSICREF_H*/ |