Commit b0bf19e4 authored by mercury233's avatar mercury233

update

parent 4d3563de
...@@ -1898,14 +1898,12 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) { ...@@ -1898,14 +1898,12 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return true; return true;
break; break;
} }
#ifdef YGOPRO_USE_AUDIO
case CHECKBOX_ENABLE_MUSIC: { case CHECKBOX_ENABLE_MUSIC: {
if(!mainGame->chkEnableMusic->isChecked()) if(!mainGame->chkEnableMusic->isChecked())
soundManager.StopBGM(); soundManager.StopBGM();
return true; return true;
break; break;
} }
#endif
case CHECKBOX_DISABLE_CHAT: { case CHECKBOX_DISABLE_CHAT: {
bool show = (mainGame->is_building && !mainGame->is_siding) ? false : !mainGame->chkIgnore1->isChecked(); bool show = (mainGame->is_building && !mainGame->is_siding) ? false : !mainGame->chkIgnore1->isChecked();
mainGame->wChat->setVisible(show); mainGame->wChat->setVisible(show);
...@@ -1998,7 +1996,6 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) { ...@@ -1998,7 +1996,6 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return true; return true;
break; break;
} }
#ifdef YGOPRO_USE_AUDIO
case SCROLL_VOLUME: { case SCROLL_VOLUME: {
mainGame->gameConf.sound_volume = (double)mainGame->scrSoundVolume->getPos() / 100; mainGame->gameConf.sound_volume = (double)mainGame->scrSoundVolume->getPos() / 100;
mainGame->gameConf.music_volume = (double)mainGame->scrMusicVolume->getPos() / 100; mainGame->gameConf.music_volume = (double)mainGame->scrMusicVolume->getPos() / 100;
...@@ -2007,7 +2004,6 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) { ...@@ -2007,7 +2004,6 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return true; return true;
break; break;
} }
#endif
case SCROLL_TAB_HELPER: { case SCROLL_TAB_HELPER: {
irr::core::rect<irr::s32> pos = mainGame->tabHelper->getRelativePosition(); irr::core::rect<irr::s32> pos = mainGame->tabHelper->getRelativePosition();
mainGame->tabHelper->setRelativePosition(irr::core::recti(0, mainGame->scrTabHelper->getPos() * -1, pos.LowerRightCorner.X, pos.LowerRightCorner.Y)); mainGame->tabHelper->setRelativePosition(irr::core::recti(0, mainGame->scrTabHelper->getPos() * -1, pos.LowerRightCorner.X, pos.LowerRightCorner.Y));
......
...@@ -227,6 +227,7 @@ void SoundManager::PlaySoundEffect(int sound) { ...@@ -227,6 +227,7 @@ void SoundManager::PlaySoundEffect(int sound) {
#endif // YGOPRO_USE_AUDIO #endif // YGOPRO_USE_AUDIO
} }
void SoundManager::PlayDialogSound(irr::gui::IGUIElement * element) { void SoundManager::PlayDialogSound(irr::gui::IGUIElement * element) {
#ifdef YGOPRO_USE_AUDIO
if(element == mainGame->wMessage) { if(element == mainGame->wMessage) {
PlaySoundEffect(SOUND_INFO); PlaySoundEffect(SOUND_INFO);
} else if(element == mainGame->wQuery) { } else if(element == mainGame->wQuery) {
...@@ -248,15 +249,24 @@ void SoundManager::PlayDialogSound(irr::gui::IGUIElement * element) { ...@@ -248,15 +249,24 @@ void SoundManager::PlayDialogSound(irr::gui::IGUIElement * element) {
} else if(element == mainGame->wFTSelect) { } else if(element == mainGame->wFTSelect) {
PlaySoundEffect(SOUND_QUESTION); PlaySoundEffect(SOUND_QUESTION);
} }
#endif // YGOPRO_USE_AUDIO
} }
bool SoundManager::IsCurrentlyPlaying(wchar_t* music) { bool SoundManager::IsPlayingMusic(wchar_t* music) {
#ifdef YGOPRO_USE_MINIAUDIO #ifdef YGOPRO_USE_MINIAUDIO
return currentPlayingMusic[0] && !mywcsncasecmp(currentPlayingMusic, music, 1024) && ma_sound_is_playing(&soundBGM); if(music) {
return !mywcsncasecmp(currentPlayingMusic, music, 1024) && ma_sound_is_playing(&soundBGM);
} else {
return ma_sound_is_playing(&soundBGM);
}
#endif #endif
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_IRRKLANG
char cmusic[1024]; if(music) {
BufferIO::EncodeUTF8(music, cmusic); char cmusic[1024];
return engineMusic->isCurrentlyPlaying(cmusic); BufferIO::EncodeUTF8(music, cmusic);
return engineMusic->isCurrentlyPlaying(cmusic);
} else {
return soundBGM && !soundBGM->isFinished();
}
#endif #endif
return false; return false;
} }
...@@ -264,7 +274,7 @@ void SoundManager::PlayMusic(wchar_t* music, bool loop) { ...@@ -264,7 +274,7 @@ void SoundManager::PlayMusic(wchar_t* music, bool loop) {
#ifdef YGOPRO_USE_AUDIO #ifdef YGOPRO_USE_AUDIO
if(!mainGame->chkEnableMusic->isChecked()) if(!mainGame->chkEnableMusic->isChecked())
return; return;
if(!IsCurrentlyPlaying(music)) { if(!IsPlayingMusic(music)) {
StopBGM(); StopBGM();
SetMusicVolume(mainGame->gameConf.music_volume); SetMusicVolume(mainGame->gameConf.music_volume);
#ifdef YGOPRO_USE_MINIAUDIO #ifdef YGOPRO_USE_MINIAUDIO
...@@ -287,11 +297,7 @@ void SoundManager::PlayBGM(int scene) { ...@@ -287,11 +297,7 @@ void SoundManager::PlayBGM(int scene) {
return; return;
if(!mainGame->chkMusicMode->isChecked()) if(!mainGame->chkMusicMode->isChecked())
scene = BGM_ALL; scene = BGM_ALL;
#if defined(YGOPRO_USE_MINIAUDIO) if(scene != bgm_scene || !IsPlayingMusic()) {
if(scene != bgm_scene || !IsCurrentlyPlaying(currentPlayingMusic)) {
#elif defined(YGOPRO_USE_IRRKLANG)
if(scene != bgm_scene || (soundBGM && soundBGM->isFinished())) {
#endif
int count = BGMList[scene].size(); int count = BGMList[scene].size();
if(count <= 0) if(count <= 0)
return; return;
......
...@@ -15,7 +15,7 @@ namespace ygo { ...@@ -15,7 +15,7 @@ namespace ygo {
class SoundManager { class SoundManager {
private: private:
std::vector<std::wstring> BGMList[8]; std::vector<std::wstring> BGMList[8];
int bgm_scene; int bgm_scene{};
mt19937 rnd; mt19937 rnd;
#ifdef YGOPRO_USE_MINIAUDIO #ifdef YGOPRO_USE_MINIAUDIO
ma_engine_config engineConfig; ma_engine_config engineConfig;
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
void RefreshBGMList(); void RefreshBGMList();
void PlaySoundEffect(int sound); void PlaySoundEffect(int sound);
void PlayDialogSound(irr::gui::IGUIElement * element); void PlayDialogSound(irr::gui::IGUIElement * element);
bool IsCurrentlyPlaying(wchar_t* music); bool IsPlayingMusic(wchar_t* music = 0);
void PlayMusic(wchar_t* music, bool loop); void PlayMusic(wchar_t* music, bool loop);
void PlayBGM(int scene); void PlayBGM(int scene);
void StopBGM(); void StopBGM();
......
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