0
0
mirror of https://github.com/Nimac0/SDL_Minigame synced 2026-01-12 15:53:42 +00:00

Compare commits

..

1 Commits

2 changed files with 6 additions and 16 deletions

View File

@ -68,7 +68,7 @@ class SoundManager
* *
* Handles how often track can loop, as well as the volume at which the specified track should play and if it fades in. * Handles how often track can loop, as well as the volume at which the specified track should play and if it fades in.
*/ */
static void playMusic(BackgroundMusic sound, int loops, int volume, int milliseconds); static void playMusic(BackgroundMusic sound, int loops, int volume, int ms);
static void setSoundVolume(int volume, int channel); //!< Volume handling for sound effects (either all or on a specific channel) static void setSoundVolume(int volume, int channel); //!< Volume handling for sound effects (either all or on a specific channel)
static void setMusicVolume(int volume); //!< Volume handling for music track static void setMusicVolume(int volume); //!< Volume handling for music track
@ -81,16 +81,9 @@ class SoundManager
static void fadeOutMusic(int ms); //!< Handles fading out a music track static void fadeOutMusic(int ms); //!< Handles fading out a music track
/*! static void addSingleSoundEffect(SoundEffects soundEffect, const char* path);
* \brief Initializes sound-effects and adds them to a cache
*
*/
static void addSoundEffects(const std::map<SoundEffects, const char*> &effects); static void addSoundEffects(const std::map<SoundEffects, const char*> &effects);
static void addSingleBackgroundMusic(BackgroundMusic backgroundMusic, const char* path);
/*!
* \brief Initializes background-music and adds them to a cache
*
*/
static void addBackgroundMusic(const std::map<BackgroundMusic, const char*> &backgroundMusic); static void addBackgroundMusic(const std::map<BackgroundMusic, const char*> &backgroundMusic);
static SoundManager* getInstance() { static SoundManager* getInstance() {
@ -103,7 +96,4 @@ class SoundManager
std::map<BackgroundMusic, Mix_Music*> music_cache; std::map<BackgroundMusic, Mix_Music*> music_cache;
std::map<SoundEffects, Mix_Chunk*> sound_cache; std::map<SoundEffects, Mix_Chunk*> sound_cache;
static SoundManager* this_instance; static SoundManager* this_instance;
static void addSingleBackgroundMusic(BackgroundMusic backgroundMusic, const char* path);
static void addSingleSoundEffect(SoundEffects soundEffect, const char* path);
}; };

View File

@ -83,7 +83,7 @@ void SoundManager::playSound(SoundEffects sound, bool canOverlap, int loops, int
} }
} }
void SoundManager::playMusic(BackgroundMusic music, int loops, int volume, int milliseconds) void SoundManager::playMusic(BackgroundMusic music, int loops, int volume, int ms)
{ {
if (!this_instance->music_cache.contains(music)) { if (!this_instance->music_cache.contains(music)) {
std::cerr << "Error playing music: music not found" << std::endl; std::cerr << "Error playing music: music not found" << std::endl;
@ -93,9 +93,9 @@ void SoundManager::playMusic(BackgroundMusic music, int loops, int volume, int m
if (Mix_PlayingMusic() != 0 || Mix_Fading() == Mix_Fading::MIX_FADING_IN) if (Mix_PlayingMusic() != 0 || Mix_Fading() == Mix_Fading::MIX_FADING_IN)
return; return;
if(milliseconds > 0) if(ms > 0)
{ {
Mix_FadeInMusic(this_instance->music_cache.at(music), loops, milliseconds); Mix_FadeInMusic(this_instance->music_cache.at(music), loops, ms);
return; return;
} }