Commit d8378afb authored by mercury233's avatar mercury233

update sounds

parent 092621e0
......@@ -1011,6 +1011,7 @@ bool ClientField::ShowSelectSum(bool panelmode) {
BufferIO::CopyWStrRef(dataManager.GetSysString(210), pwbuf, 256);
mainGame->stQMessage->setText(wbuf);
mainGame->PopupElement(mainGame->wQuery);
mainGame->PlaySoundEffect(SOUND_QUESTION);
}
} else {
select_ready = false;
......@@ -1032,6 +1033,7 @@ bool ClientField::ShowSelectSum(bool panelmode) {
BufferIO::CopyWStrRef(dataManager.GetSysString(210), pwbuf, 256);
mainGame->stQMessage->setText(wbuf);
mainGame->PopupElement(mainGame->wQuery);
mainGame->PlaySoundEffect(SOUND_QUESTION);
}
} else
select_ready = false;
......
......@@ -118,11 +118,13 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break;
switch(event.GUIEvent.EventType) {
case irr::gui::EGET_BUTTON_CLICKED: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
switch(id) {
case BUTTON_CLEAR_DECK: {
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)dataManager.GetSysString(1339));
mainGame->PopupElement(mainGame->wQuery);
mainGame->PlaySoundEffect(SOUND_QUESTION);
mainGame->gMutex.Unlock();
prev_operation = id;
break;
......@@ -179,6 +181,7 @@ 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);
mainGame->PlaySoundEffect(SOUND_QUESTION);
mainGame->gMutex.Unlock();
prev_operation = id;
break;
......@@ -188,6 +191,7 @@ 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);
mainGame->PlaySoundEffect(SOUND_QUESTION);
mainGame->gMutex.Unlock();
prev_operation = id;
break;
......@@ -345,6 +349,7 @@ 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);
mainGame->PlaySoundEffect(SOUND_QUESTION);
mainGame->gMutex.Unlock();
prev_operation = id;
break;
......@@ -496,6 +501,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
is_starting_dragging = false;
if(!is_draging)
break;
mainGame->PlaySoundEffect(SOUND_CARD_DROP);
bool pushed = false;
if(hovered_pos == 1)
pushed = push_main(draging_pointer, hovered_seq);
......@@ -525,6 +531,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
auto pointer = dataManager.GetCodePointer(hovered_code);
if(pointer == dataManager._datas.end())
break;
mainGame->PlaySoundEffect(SOUND_CARD_DROP);
if(hovered_pos == 1) {
if(push_side(pointer))
pop_main(hovered_seq);
......@@ -542,6 +549,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
if(!is_draging) {
if(hovered_pos == 0 || hovered_seq == -1)
break;
mainGame->PlaySoundEffect(SOUND_CARD_DROP);
if(hovered_pos == 1) {
pop_main(hovered_seq);
} else if(hovered_pos == 2) {
......@@ -558,6 +566,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
push_side(pointer);
}
} else {
mainGame->PlaySoundEffect(SOUND_CARD_PICK);
if(click_pos == 1) {
push_side(draging_pointer);
} else if(click_pos == 2) {
......@@ -584,6 +593,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
auto pointer = dataManager.GetCodePointer(hovered_code);
if(!check_limit(pointer))
break;
mainGame->PlaySoundEffect(SOUND_CARD_PICK);
if (hovered_pos == 1) {
if(!push_main(pointer))
push_side(pointer);
......@@ -602,6 +612,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case irr::EMIE_MOUSE_MOVED: {
if(is_starting_dragging) {
is_draging = true;
mainGame->PlaySoundEffect(SOUND_CARD_PICK);
if(hovered_pos == 1)
pop_main(hovered_seq);
else if(hovered_pos == 2)
......
This diff is collapsed.
......@@ -40,6 +40,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
case BUTTON_FIRST:
case BUTTON_SECOND: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
mainGame->HideElement(mainGame->wFTSelect);
CTOS_TPResult cstr;
cstr.res = BUTTON_SECOND - id;
......@@ -49,6 +50,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case BUTTON_REPLAY_START: {
if(!mainGame->dInfo.isReplay)
break;
mainGame->PlaySoundEffect(SOUND_BUTTON);
mainGame->btnReplayStart->setVisible(false);
mainGame->btnReplayPause->setVisible(true);
mainGame->btnReplayStep->setVisible(false);
......@@ -59,6 +61,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case BUTTON_REPLAY_PAUSE: {
if(!mainGame->dInfo.isReplay)
break;
mainGame->PlaySoundEffect(SOUND_BUTTON);
mainGame->btnReplayStart->setVisible(true);
mainGame->btnReplayPause->setVisible(false);
mainGame->btnReplayStep->setVisible(true);
......@@ -69,16 +72,19 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case BUTTON_REPLAY_STEP: {
if(!mainGame->dInfo.isReplay)
break;
mainGame->PlaySoundEffect(SOUND_BUTTON);
ReplayMode::Pause(false, true);
break;
}
case BUTTON_REPLAY_EXIT: {
if(!mainGame->dInfo.isReplay)
break;
mainGame->PlaySoundEffect(SOUND_BUTTON);
ReplayMode::StopReplay();
break;
}
case BUTTON_REPLAY_SWAP: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
if(mainGame->dInfo.isReplay)
ReplayMode::SwapField();
else if (mainGame->dInfo.player_type == 7)
......@@ -88,24 +94,28 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case BUTTON_REPLAY_UNDO: {
if(!mainGame->dInfo.isReplay)
break;
mainGame->PlaySoundEffect(SOUND_BUTTON);
ReplayMode::Undo();
break;
}
case BUTTON_REPLAY_SAVE: {
if(mainGame->ebRSName->getText()[0] == 0)
break;
mainGame->PlaySoundEffect(SOUND_BUTTON);
mainGame->actionParam = 1;
mainGame->HideElement(mainGame->wReplaySave);
mainGame->replaySignal.Set();
break;
}
case BUTTON_REPLAY_CANCEL: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
mainGame->actionParam = 0;
mainGame->HideElement(mainGame->wReplaySave);
mainGame->replaySignal.Set();
break;
}
case BUTTON_LEAVE_GAME: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
if(mainGame->dInfo.isSingleMode) {
mainGame->singleSignal.SetNoWait(true);
SingleMode::StopPlay(false);
......@@ -131,6 +141,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_CHAIN_IGNORE: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
mainGame->ignore_chain = mainGame->btnChainIgnore->isPressed();
mainGame->always_chain = false;
mainGame->chain_when_avail = false;
......@@ -138,6 +149,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_CHAIN_ALWAYS: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
mainGame->always_chain = mainGame->btnChainAlways->isPressed();
mainGame->ignore_chain = false;
mainGame->chain_when_avail = false;
......@@ -145,6 +157,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_CHAIN_WHENAVAIL: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
mainGame->chain_when_avail = mainGame->btnChainWhenAvail->isPressed();
mainGame->always_chain = false;
mainGame->ignore_chain = false;
......@@ -152,6 +165,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_CANCEL_OR_FINISH: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
switch (mainGame->dInfo.curMsg) {
case MSG_WAITING: {
if (mainGame->wCardSelect->isVisible()) {
......@@ -261,6 +275,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
else {
mainGame->PopupElement(mainGame->wQuery);
mainGame->PlaySoundEffect(SOUND_QUESTION);
ShowCancelOrFinishButton(0);
}
if (mainGame->wOptions->isVisible()) {
......@@ -282,11 +297,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_MSG_OK: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
mainGame->HideElement(mainGame->wMessage);
mainGame->actionSignal.Set();
break;
}
case BUTTON_YES: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
switch(mainGame->dInfo.curMsg) {
case MSG_SELECT_YESNO:
case MSG_SELECT_EFFECTYN: {
......@@ -320,6 +337,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_NO: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
switch(mainGame->dInfo.curMsg) {
case MSG_SELECT_YESNO:
case MSG_SELECT_EFFECTYN: {
......@@ -372,6 +390,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_OPTION_PREV: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
selected_option--;
mainGame->btnOptionn->setVisible(true);
if(selected_option == 0)
......@@ -380,6 +399,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_OPTION_NEXT: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
selected_option++;
mainGame->btnOptionp->setVisible(true);
if(selected_option == select_options.size() - 1)
......@@ -388,6 +408,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_OPTION_OK: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
if (mainGame->dInfo.curMsg == MSG_SELECT_OPTION) {
DuelClient::SetResponseI(selected_option);
} else {
......@@ -405,11 +426,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_ANNUMBER_OK: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
DuelClient::SetResponseI(mainGame->cbANNumber->getSelected());
mainGame->HideElement(mainGame->wANNumber, true);
break;
}
case BUTTON_ANCARD_OK: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
int sel = mainGame->lstANCard->getSelected();
if(sel == -1)
break;
......@@ -1426,6 +1449,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
BufferIO::CopyWStrRef(dataManager.GetSysString(210), pwbuf, 256);
mainGame->stQMessage->setText(wbuf);
mainGame->PopupElement(mainGame->wQuery);
mainGame->PlaySoundEffect(SOUND_QUESTION);
}
}
} else {
......@@ -1601,6 +1625,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->HideElement(mainGame->wQuery, true);
} else {
mainGame->PopupElement(mainGame->wQuery);
mainGame->PlaySoundEffect(SOUND_QUESTION);
ShowCancelOrFinishButton(0);
}
if(mainGame->wOptions->isVisible()) {
......@@ -1951,6 +1976,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
s32 id = event.GUIEvent.Caller->getID();
switch(event.GUIEvent.EventType) {
case irr::gui::EGET_BUTTON_CLICKED: {
mainGame->PlaySoundEffect(SOUND_BUTTON);
switch(id) {
case BUTTON_CLEAR_LOG: {
mainGame->lstLog->clear();
......
......@@ -1136,11 +1136,130 @@ void Game::SaveConfig() {
fprintf(fp, "music_mode = %d\n", ((mainGame->chkMusicMode->isChecked()) ? 1 : 0));
fclose(fp);
}
void Game::PlaySoundEffect(char* sound) {
if(mainGame->chkEnableSound->isChecked()) {
engineSound->play2D(sound);
engineSound->setSoundVolume(gameConf.sound_volume);
void Game::PlaySoundEffect(int sound) {
if(!mainGame->chkEnableSound->isChecked())
return;
switch(sound) {
case SOUND_SUMMON: {
engineSound->play2D("./sound/summon.wav");
break;
}
case SOUND_SPECIAL_SUMMON: {
engineSound->play2D("./sound/specialsummon.wav");
break;
}
case SOUND_ACTIVATE: {
engineSound->play2D("./sound/activate.wav");
break;
}
case SOUND_SET: {
engineSound->play2D("./sound/set.wav");
break;
}
case SOUND_FILP: {
engineSound->play2D("./sound/flip.wav");
break;
}
case SOUND_REVEAL: {
engineSound->play2D("./sound/reveal.wav");
break;
}
case SOUND_EQUIP: {
engineSound->play2D("./sound/equip.wav");
break;
}
case SOUND_DESTROYED: {
engineSound->play2D("./sound/destroyed.wav");
break;
}
case SOUND_BANISHED: {
engineSound->play2D("./sound/banished.wav");
break;
}
case SOUND_ATTACK: {
engineSound->play2D("./sound/attack.wav");
break;
}
case SOUND_DIRECT_ATTACK: {
engineSound->play2D("./sound/directattack.wav");
break;
}
case SOUND_DRAW: {
engineSound->play2D("./sound/draw.wav");
break;
}
case SOUND_SHUFFLE: {
engineSound->play2D("./sound/shuffle.wav");
break;
}
case SOUND_DAMAGE: {
engineSound->play2D("./sound/damage.wav");
break;
}
case SOUND_RECOVER: {
engineSound->play2D("./sound/gainlp.wav");
break;
}
case SOUND_COUNTER_ADD: {
engineSound->play2D("./sound/addcounter.wav");
break;
}
case SOUND_COUNTER_REMOVE: {
engineSound->play2D("./sound/removecounter.wav");
break;
}
case SOUND_COIN: {
engineSound->play2D("./sound/coinflip.wav");
break;
}
case SOUND_DICE: {
engineSound->play2D("./sound/diceroll.wav");
break;
}
case SOUND_NEXT_TURN: {
engineSound->play2D("./sound/nextturn.wav");
break;
}
case SOUND_PHASE: {
engineSound->play2D("./sound/phase.wav");
break;
}
case SOUND_MENU: {
engineSound->play2D("./sound/menu.wav");
break;
}
case SOUND_BUTTON: {
engineSound->play2D("./sound/button.wav");
break;
}
case SOUND_INFO: {
engineSound->play2D("./sound/info.wav");
break;
}
case SOUND_QUESTION: {
engineSound->play2D("./sound/question.wav");
break;
}
case SOUND_CARD_PICK: {
engineSound->play2D("./sound/cardpick.wav");
break;
}
case SOUND_CARD_DROP: {
engineSound->play2D("./sound/carddrop.wav");
break;
}
case SOUND_PLAYER_ENTER: {
engineSound->play2D("./sound/playerenter.wav");
break;
}
case SOUND_CHAT: {
engineSound->play2D("./sound/chatmessage.wav");
break;
}
default:
break;
}
engineSound->setSoundVolume(gameConf.sound_volume);
}
void Game::PlayMusic(char* song, bool loop) {
if(mainGame->chkEnableMusic->isChecked()) {
......@@ -1266,17 +1385,17 @@ void Game::AddChatMsg(wchar_t* msg, int player) {
chatMsg[0].append(L": ");
break;
case 1: //from client
mainGame->PlaySoundEffect("./sound/chatmessage.wav");
mainGame->PlaySoundEffect(SOUND_CHAT);
chatMsg[0].append(dInfo.clientname);
chatMsg[0].append(L": ");
break;
case 2: //host tag
mainGame->PlaySoundEffect("./sound/chatmessage.wav");
mainGame->PlaySoundEffect(SOUND_CHAT);
chatMsg[0].append(dInfo.hostname_tag);
chatMsg[0].append(L": ");
break;
case 3: //client tag
mainGame->PlaySoundEffect("./sound/chatmessage.wav");
mainGame->PlaySoundEffect(SOUND_CHAT);
chatMsg[0].append(dInfo.clientname_tag);
chatMsg[0].append(L": ");
break;
......@@ -1285,7 +1404,7 @@ void Game::AddChatMsg(wchar_t* msg, int player) {
chatMsg[0].append(L": ");
break;
case 8: //system custom message, no prefix.
mainGame->PlaySoundEffect("./sound/chatmessage.wav");
mainGame->PlaySoundEffect(SOUND_CHAT);
chatMsg[0].append(L"[System]: ");
break;
case 9: //error message
......
......@@ -120,7 +120,7 @@ public:
void AddDebugMsg(char* msgbuf);
void ClearTextures();
void CloseDuelWindow();
void PlaySoundEffect(char* sound);
void PlaySoundEffect(int sound);
void PlayMusic(char* song, bool loop);
void PlayBGM();
......@@ -581,5 +581,37 @@ extern Game* mainGame;
#define BUTTON_MARKS_FILTER 380
#define BUTTON_MARKERS_OK 381
#define SOUND_SUMMON 101
#define SOUND_SPECIAL_SUMMON 102
#define SOUND_ACTIVATE 103
#define SOUND_SET 104
#define SOUND_FILP 105
#define SOUND_REVEAL 106
#define SOUND_EQUIP 107
#define SOUND_DESTROYED 108
#define SOUND_BANISHED 109
#define SOUND_ATTACK 201
#define SOUND_DIRECT_ATTACK 202
#define SOUND_DRAW 203
#define SOUND_SHUFFLE 204
#define SOUND_DAMAGE 205
#define SOUND_RECOVER 206
#define SOUND_COUNTER_ADD 207
#define SOUND_COUNTER_REMOVE 208
#define SOUND_COIN 209
#define SOUND_DICE 210
#define SOUND_NEXT_TURN 211
#define SOUND_PHASE 212
#define SOUND_MENU 301
#define SOUND_BUTTON 302
#define SOUND_INFO 303
#define SOUND_QUESTION 304
#define SOUND_CARD_PICK 305
#define SOUND_CARD_DROP 306
#define SOUND_PLAYER_ENTER 307
#define SOUND_CHAT 308
#define DEFAULT_DUEL_RULE 4
#endif // GAME_H
......@@ -17,6 +17,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
s32 id = caller->getID();
switch(event.GUIEvent.EventType) {
case irr::gui::EGET_BUTTON_CLICKED: {
if(id < 110)
mainGame->PlaySoundEffect(SOUND_MENU);
else
mainGame->PlaySoundEffect(SOUND_BUTTON);
switch(id) {
case BUTTON_MODE_EXIT: {
mainGame->device->closeDevice();
......
......@@ -174,6 +174,7 @@ int ReplayMode::ReplayThread(void* param) {
if(mainGame->wCardSelect->isVisible())
mainGame->HideElement(mainGame->wCardSelect);
mainGame->PopupElement(mainGame->wMessage);
mainGame->PlaySoundEffect(SOUND_INFO);
mainGame->gMutex.Unlock();
mainGame->actionSignal.Wait();
mainGame->gMutex.Lock();
......@@ -327,6 +328,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
mainGame->gMutex.Lock();
mainGame->stMessage->setText(L"Error occurs.");
mainGame->PopupElement(mainGame->wMessage);
mainGame->PlaySoundEffect(SOUND_INFO);
mainGame->gMutex.Unlock();
mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait();
......
......@@ -132,6 +132,7 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
mainGame->gMutex.Lock();
mainGame->stMessage->setText(L"Error occurs.");
mainGame->PopupElement(mainGame->wMessage);
mainGame->PlaySoundEffect(SOUND_INFO);
mainGame->gMutex.Unlock();
mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait();
......@@ -738,6 +739,7 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stMessage, 310, mainGame->textFont, msg);
mainGame->PopupElement(mainGame->wMessage);
mainGame->PlaySoundEffect(SOUND_INFO);
mainGame->gMutex.Unlock();
mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait();
......
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