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

Compare commits

...

2 Commits

Author SHA1 Message Date
Freezarite
ca77b8f7e2
Merge 1dc00408de954953bf3c38ff3f2369ed2fbea80f into 361687f09f5218d2e7f8cf1dbc2e7b81d0e722b4 2025-01-28 20:51:02 +00:00
freezarite
1dc00408de pr stuff 2025-01-28 21:50:48 +01:00
2 changed files with 16 additions and 6 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.
*/
static void playMusic(BackgroundMusic sound, int loops, int volume, int ms);
static void playMusic(BackgroundMusic sound, int loops, int volume, int milliseconds);
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
@ -81,9 +81,16 @@ class SoundManager
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 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 SoundManager* getInstance() {
@ -96,4 +103,7 @@ class SoundManager
std::map<BackgroundMusic, Mix_Music*> music_cache;
std::map<SoundEffects, Mix_Chunk*> sound_cache;
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 ms)
void SoundManager::playMusic(BackgroundMusic music, int loops, int volume, int milliseconds)
{
if (!this_instance->music_cache.contains(music)) {
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)
return;
if(ms > 0)
if(milliseconds > 0)
{
Mix_FadeInMusic(this_instance->music_cache.at(music), loops, ms);
Mix_FadeInMusic(this_instance->music_cache.at(music), loops, milliseconds);
return;
}