AudioHandler's functions to change volume now return new vol

origin/fixingSettings
thmaillarb 3 years ago
parent 2c8c0caafd
commit 1e56ca4a75

@ -104,11 +104,11 @@ AudioHandler newAudioHandler(int masterVol, int volMusic, int volSFX);
* \brief Changes volume for the SFX. * \brief Changes volume for the SFX.
* \param[in] volSFX The new volume for the SFX. * \param[in] volSFX The new volume for the SFX.
*/ */
void changeSFXVol(AudioHandler* ah, int volSFX); int changeSFXVol(AudioHandler* ah, int volSFX);
void changeMusicVol(AudioHandler* ah, int volMusic); int changeMusicVol(AudioHandler* ah, int volMusic);
void changeMasterVol(AudioHandler* ah, int masterVol); int changeMasterVol(AudioHandler* ah, int masterVol);
/** /**
* \brief Frees the music and SFX, and un-initializes the audio. * \brief Frees the music and SFX, and un-initializes the audio.

@ -91,26 +91,29 @@ AudioHandler newAudioHandler(int masterVol, int volMusic, int volSFX) {
return audioHandler; return audioHandler;
} }
void changeMusicVol(AudioHandler* ah, int volMusic) { int changeMusicVol(AudioHandler* ah, int volMusic) {
if (volMusic > 10) volMusic = 10; if (volMusic > 10) volMusic = 10;
if (volMusic < 0) volMusic = 0; if (volMusic < 0) volMusic = 0;
ah->volMusic = volMusic; ah->volMusic = volMusic;
Mix_VolumeMusic(ah->volMusic * ah->masterVol); Mix_VolumeMusic(ah->volMusic * ah->masterVol);
return ah->volMusic;
} }
void changeSFXVol(AudioHandler* ah, int volSFX) { int changeSFXVol(AudioHandler* ah, int volSFX) {
if (volSFX > 10) volSFX = 10; if (volSFX > 10) volSFX = 10;
if (volSFX < 0) volSFX = 0; if (volSFX < 0) volSFX = 0;
ah->volSFX = volSFX; ah->volSFX = volSFX;
Mix_Volume(-1, ah->volSFX * ah->masterVol); Mix_Volume(-1, ah->volSFX * ah->masterVol);
return ah->volSFX;
} }
void changeMasterVol(AudioHandler* ah, int masterVol) { int changeMasterVol(AudioHandler* ah, int masterVol) {
if (masterVol > 10) masterVol = 10; if (masterVol > 10) masterVol = 10;
if (masterVol < 0) masterVol = 0; if (masterVol < 0) masterVol = 0;
ah->masterVol = masterVol; ah->masterVol = masterVol;
Mix_VolumeMusic(ah->volMusic * ah->masterVol); Mix_VolumeMusic(ah->volMusic * ah->masterVol);
Mix_Volume(-1, ah->volSFX * ah->masterVol); Mix_Volume(-1, ah->volSFX * ah->masterVol);
return ah->masterVol;
} }
void freeAudioHandler(AudioHandler* audioHandler) { void freeAudioHandler(AudioHandler* audioHandler) {

Loading…
Cancel
Save