Commit b3eb9985 authored by mercury233's avatar mercury233

add PlayDialogSound

parent bd8b1f92
......@@ -1019,7 +1019,6 @@ bool ClientField::ShowSelectSum(bool panelmode) {
BufferIO::CopyWStrRef(dataManager.GetSysString(210), pwbuf, 256);
mainGame->stQMessage->setText(wbuf);
mainGame->PopupElement(mainGame->wQuery);
soundManager.PlaySoundEffect(SOUND_QUESTION);
}
} else {
select_ready = false;
......@@ -1041,7 +1040,6 @@ bool ClientField::ShowSelectSum(bool panelmode) {
BufferIO::CopyWStrRef(dataManager.GetSysString(210), pwbuf, 256);
mainGame->stQMessage->setText(wbuf);
mainGame->PopupElement(mainGame->wQuery);
soundManager.PlaySoundEffect(SOUND_QUESTION);
}
} else
select_ready = false;
......
......@@ -128,7 +128,6 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)dataManager.GetSysString(1339));
mainGame->PopupElement(mainGame->wQuery);
soundManager.PlaySoundEffect(SOUND_QUESTION);
mainGame->gMutex.Unlock();
prev_operation = id;
break;
......@@ -185,7 +184,6 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
myswprintf(textBuffer, L"%ls\n%ls", mainGame->cbDBDecks->getItem(sel), dataManager.GetSysString(1337));
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)textBuffer);
mainGame->PopupElement(mainGame->wQuery);
soundManager.PlaySoundEffect(SOUND_QUESTION);
mainGame->gMutex.Unlock();
prev_operation = id;
break;
......@@ -195,7 +193,6 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)dataManager.GetSysString(1356));
mainGame->PopupElement(mainGame->wQuery);
soundManager.PlaySoundEffect(SOUND_QUESTION);
mainGame->gMutex.Unlock();
prev_operation = id;
break;
......@@ -359,7 +356,6 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)dataManager.GetSysString(1356));
mainGame->PopupElement(mainGame->wQuery);
soundManager.PlaySoundEffect(SOUND_QUESTION);
mainGame->gMutex.Unlock();
prev_operation = id;
break;
......
......@@ -2,6 +2,7 @@
#include "materials.h"
#include "image_manager.h"
#include "deck_manager.h"
#include "sound_manager.h"
#include "duelclient.h"
#include "../ocgcore/field.h"
......@@ -1008,6 +1009,7 @@ void Game::HideElement(irr::gui::IGUIElement * win, bool set_action) {
fadingList.push_back(fu);
}
void Game::PopupElement(irr::gui::IGUIElement * element, int hideframe) {
soundManager.PlayDialogSound(element);
element->getParent()->bringToFront(element);
if(!mainGame->is_building)
dField.panel = element;
......
......@@ -590,7 +590,6 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnCancelOrFinish->setVisible(false);
mainGame->stMessage->setText(dataManager.GetSysString(1500));
mainGame->PopupElement(mainGame->wMessage);
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->gMutex.Unlock();
mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait();
......@@ -633,7 +632,6 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mbstowcs(timetext, timebuf, size);
mainGame->ebRSName->setText(timetext);
mainGame->PopupElement(mainGame->wReplaySave);
soundManager.PlaySoundEffect(SOUND_QUESTION);
mainGame->gMutex.Unlock();
mainGame->replaySignal.Reset();
mainGame->replaySignal.Wait();
......@@ -820,7 +818,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->gMutex.Lock();
mainGame->stMessage->setText(L"Error occurs.");
mainGame->PopupElement(mainGame->wMessage);
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->gMutex.Unlock();
mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait();
......@@ -857,7 +854,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->gMutex.Lock();
mainGame->stMessage->setText(dataManager.GetDesc(data));
mainGame->PopupElement(mainGame->wMessage);
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->gMutex.Unlock();
mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait();
......@@ -1241,7 +1237,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, textBuffer);
mainGame->PopupElement(mainGame->wQuery);
soundManager.PlaySoundEffect(SOUND_QUESTION);
mainGame->gMutex.Unlock();
return false;
}
......@@ -1252,7 +1247,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)dataManager.GetDesc(desc));
mainGame->PopupElement(mainGame->wQuery);
soundManager.PlaySoundEffect(SOUND_QUESTION);
mainGame->gMutex.Unlock();
return false;
}
......@@ -1276,7 +1270,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
select_hint = 0;
mainGame->wOptions->setText(textBuffer);
mainGame->PopupElement(mainGame->wOptions);
soundManager.PlaySoundEffect(SOUND_QUESTION);
mainGame->gMutex.Unlock();
return false;
}
......@@ -1421,7 +1414,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
myswprintf(textBuffer, L"%ls\n%ls", event_string, dataManager.GetSysString(203));
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)textBuffer);
mainGame->PopupElement(mainGame->wQuery);
soundManager.PlaySoundEffect(SOUND_QUESTION);
}
}
mainGame->gMutex.Unlock();
......@@ -3143,7 +3135,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->gMutex.Lock();
mainGame->wANRace->setText(textBuffer);
mainGame->PopupElement(mainGame->wANRace);
soundManager.PlaySoundEffect(SOUND_QUESTION);
mainGame->gMutex.Unlock();
return false;
}
......@@ -3164,7 +3155,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->gMutex.Lock();
mainGame->wANAttribute->setText(textBuffer);
mainGame->PopupElement(mainGame->wANAttribute);
soundManager.PlaySoundEffect(SOUND_QUESTION);
mainGame->gMutex.Unlock();
return false;
}
......@@ -3181,7 +3171,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->wANCard->setText(textBuffer);
mainGame->dField.UpdateDeclarableCode(true);
mainGame->PopupElement(mainGame->wANCard);
soundManager.PlaySoundEffect(SOUND_QUESTION);
mainGame->gMutex.Unlock();
return false;
}
......@@ -3202,7 +3191,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
select_hint = 0;
mainGame->wANNumber->setText(textBuffer);
mainGame->PopupElement(mainGame->wANNumber);
soundManager.PlaySoundEffect(SOUND_QUESTION);
mainGame->gMutex.Unlock();
return false;
}
......@@ -3222,7 +3210,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->wANCard->setText(textBuffer);
mainGame->dField.UpdateDeclarableCode(true);
mainGame->PopupElement(mainGame->wANCard);
soundManager.PlaySoundEffect(SOUND_QUESTION);
mainGame->gMutex.Unlock();
return false;
}
......
......@@ -278,7 +278,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
else {
mainGame->PopupElement(mainGame->wQuery);
soundManager.PlaySoundEffect(SOUND_QUESTION);
ShowCancelOrFinishButton(0);
}
if (mainGame->wOptions->isVisible()) {
......@@ -1452,7 +1451,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
BufferIO::CopyWStrRef(dataManager.GetSysString(210), pwbuf, 256);
mainGame->stQMessage->setText(wbuf);
mainGame->PopupElement(mainGame->wQuery);
soundManager.PlaySoundEffect(SOUND_QUESTION);
}
}
} else {
......@@ -1628,7 +1626,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->HideElement(mainGame->wQuery, true);
} else {
mainGame->PopupElement(mainGame->wQuery);
soundManager.PlaySoundEffect(SOUND_QUESTION);
ShowCancelOrFinishButton(0);
}
if(mainGame->wOptions->isVisible()) {
......
......@@ -314,7 +314,6 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
mainGame->gMutex.Lock();
mainGame->stMessage->setText(L"Error occurs.");
mainGame->PopupElement(mainGame->wMessage);
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->gMutex.Unlock();
mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait();
......
......@@ -180,7 +180,6 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
mainGame->gMutex.Lock();
mainGame->stMessage->setText(L"Error occurs.");
mainGame->PopupElement(mainGame->wMessage);
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->gMutex.Unlock();
mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait();
......@@ -787,7 +786,6 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stMessage, 310, mainGame->textFont, msg);
mainGame->PopupElement(mainGame->wMessage);
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->gMutex.Unlock();
mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait();
......
......@@ -195,6 +195,25 @@ void SoundManager::PlaySoundEffect(int sound) {
engineSound->setSoundVolume(mainGame->gameConf.sound_volume);
#endif
}
void SoundManager::PlayDialogSound(irr::gui::IGUIElement * element) {
if(element == mainGame->wMessage) {
PlaySoundEffect(SOUND_INFO);
} else if(element == mainGame->wQuery) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wOptions) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wANAttribute) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wANCard) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wANNumber) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wANRace) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wReplaySave) {
PlaySoundEffect(SOUND_QUESTION);
}
}
void SoundManager::PlayMusic(char* song, bool loop) {
#ifdef YGOPRO_USE_IRRKLANG
if(!mainGame->chkEnableMusic->isChecked())
......
......@@ -27,6 +27,7 @@ public:
bool Init();
void RefreshBGMList();
void PlaySoundEffect(int sound);
void PlayDialogSound(irr::gui::IGUIElement * element);
void PlayMusic(char* song, bool loop);
void PlayBGM(int scene);
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