Commit 72f9ec34 authored by nanahira's avatar nanahira

simplify logic & fix bgm set volume

parent 82f1e003
...@@ -220,12 +220,11 @@ void SoundManager::PlaySoundEffect(int sound) { ...@@ -220,12 +220,11 @@ void SoundManager::PlaySoundEffect(int sound) {
} }
char soundPath[40]; char soundPath[40];
std::snprintf(soundPath, 40, "./sound/%s.wav", soundName); std::snprintf(soundPath, 40, "./sound/%s.wav", soundName);
SetSoundVolume(mainGame->gameConf.sound_volume);
#ifdef YGOPRO_USE_MINIAUDIO #ifdef YGOPRO_USE_MINIAUDIO
ma_engine_set_volume(&engineSound, mainGame->gameConf.sound_volume);
ma_engine_play_sound(&engineSound, soundPath, nullptr); ma_engine_play_sound(&engineSound, soundPath, nullptr);
#endif #endif
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_IRRKLANG
engineSound->setSoundVolume(mainGame->gameConf.sound_volume);
engineSound->play2D(soundPath); engineSound->play2D(soundPath);
#endif #endif
#endif // YGOPRO_USE_AUDIO #endif // YGOPRO_USE_AUDIO
...@@ -268,6 +267,7 @@ void SoundManager::PlayMusic(char* song, bool loop) { ...@@ -268,6 +267,7 @@ void SoundManager::PlayMusic(char* song, bool loop) {
return; return;
if(!IsCurrentlyPlaying(song)) { if(!IsCurrentlyPlaying(song)) {
StopBGM(); StopBGM();
SetMusicVolume(mainGame->gameConf.music_volume);
#ifdef YGOPRO_USE_MINIAUDIO #ifdef YGOPRO_USE_MINIAUDIO
strcpy(currentPlayingMusic, song); strcpy(currentPlayingMusic, song);
#ifdef _WIN32 #ifdef _WIN32
...@@ -281,8 +281,6 @@ void SoundManager::PlayMusic(char* song, bool loop) { ...@@ -281,8 +281,6 @@ void SoundManager::PlayMusic(char* song, bool loop) {
ma_sound_start(&soundBGM); ma_sound_start(&soundBGM);
#endif #endif
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_IRRKLANG
engineMusic->stopAllSounds();
engineMusic->setSoundVolume(mainGame->gameConf.music_volume);
soundBGM = engineMusic->play2D(song, loop, false, true); soundBGM = engineMusic->play2D(song, loop, false, true);
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment