Commit ffd9a43b authored by Unicorn369's avatar Unicorn369 Committed by fallenstardust

update

parent cb8715a6
This diff is collapsed.
...@@ -1135,6 +1135,7 @@ void Game::HideElement(irr::gui::IGUIElement * win, bool set_action) { ...@@ -1135,6 +1135,7 @@ void Game::HideElement(irr::gui::IGUIElement * win, bool set_action) {
fadingList.push_back(fu); fadingList.push_back(fu);
} }
void Game::PopupElement(irr::gui::IGUIElement * element, int hideframe) { void Game::PopupElement(irr::gui::IGUIElement * element, int hideframe) {
mainGame->soundManager->PlayDialogSound(element);
element->getParent()->bringToFront(element); element->getParent()->bringToFront(element);
if(!is_building) if(!is_building)
dField.panel = element; dField.panel = element;
......
This diff is collapsed.
This diff is collapsed.
...@@ -81,8 +81,8 @@ bool Game::Initialize() { ...@@ -81,8 +81,8 @@ bool Game::Initialize() {
setPositionFix(appPosition); setPositionFix(appPosition);
device->setProcessReceiver(this); device->setProcessReceiver(this);
soundEffectPlayer = new AndroidSoundEffectPlayer(app); //soundEffectPlayer = new AndroidSoundEffectPlayer(app);
soundEffectPlayer->setSEEnabled(options->isSoundEffectEnabled()); //soundEffectPlayer->setSEEnabled(options->isSoundEffectEnabled());
app->onInputEvent = android::handleInput; app->onInputEvent = android::handleInput;
ILogger* logger = device->getLogger(); ILogger* logger = device->getLogger();
// logger->setLogLevel(ELL_WARNING); // logger->setLogLevel(ELL_WARNING);
...@@ -433,7 +433,7 @@ bool Game::Initialize() { ...@@ -433,7 +433,7 @@ bool Game::Initialize() {
scrSoundVolume = env->addScrollBar(true, rect<s32>(posX + 110 * xScale, posY, posX + 250 * xScale, posY + 30 * yScale), tabHelper, SCROLL_VOLUME); scrSoundVolume = env->addScrollBar(true, rect<s32>(posX + 110 * xScale, posY, posX + 250 * xScale, posY + 30 * yScale), tabHelper, SCROLL_VOLUME);
scrSoundVolume->setMax(100); scrSoundVolume->setMax(100);
scrSoundVolume->setMin(0); scrSoundVolume->setMin(0);
scrSoundVolume->setPos(gameConf.sound_volume * 100); scrSoundVolume->setPos(gameConf.sound_volume);
scrSoundVolume->setLargeStep(1); scrSoundVolume->setLargeStep(1);
scrSoundVolume->setSmallStep(1); scrSoundVolume->setSmallStep(1);
posY += 60; posY += 60;
...@@ -442,7 +442,7 @@ bool Game::Initialize() { ...@@ -442,7 +442,7 @@ bool Game::Initialize() {
scrMusicVolume = env->addScrollBar(true, rect<s32>(posX + 110 * xScale, posY, posX + 250 * xScale, posY + 30 * yScale), tabHelper, SCROLL_VOLUME); scrMusicVolume = env->addScrollBar(true, rect<s32>(posX + 110 * xScale, posY, posX + 250 * xScale, posY + 30 * yScale), tabHelper, SCROLL_VOLUME);
scrMusicVolume->setMax(100); scrMusicVolume->setMax(100);
scrMusicVolume->setMin(0); scrMusicVolume->setMin(0);
scrMusicVolume->setPos(gameConf.music_volume * 100); scrMusicVolume->setPos(gameConf.music_volume);
scrMusicVolume->setLargeStep(1); scrMusicVolume->setLargeStep(1);
scrMusicVolume->setSmallStep(1); scrMusicVolume->setSmallStep(1);
elmTabHelperLast = chkEnableMusic; elmTabHelperLast = chkEnableMusic;
...@@ -959,7 +959,7 @@ bool Game::Initialize() { ...@@ -959,7 +959,7 @@ bool Game::Initialize() {
btnCancelOrFinish = env->addButton(rect<s32>(205 * xScale, 220 * yScale, 305 * xScale, 275 * yScale), 0, BUTTON_CANCEL_OR_FINISH, dataManager.GetSysString(1295)); btnCancelOrFinish = env->addButton(rect<s32>(205 * xScale, 220 * yScale, 305 * xScale, 275 * yScale), 0, BUTTON_CANCEL_OR_FINISH, dataManager.GetSysString(1295));
btnCancelOrFinish->setVisible(false); btnCancelOrFinish->setVisible(false);
soundManager = Utils::make_unique<SoundManager>(); soundManager = Utils::make_unique<SoundManager>();
if(!soundManager->Init(gameConf.sound_volume, gameConf.music_volume, gameConf.enable_sound, gameConf.enable_music, nullptr)) { if(!soundManager->Init((double)gameConf.sound_volume / 100, (double)gameConf.music_volume / 100, gameConf.enable_sound, gameConf.enable_music, nullptr)) {
chkEnableSound->setChecked(false); chkEnableSound->setChecked(false);
chkEnableSound->setEnabled(false); chkEnableSound->setEnabled(false);
chkEnableSound->setVisible(false); chkEnableSound->setVisible(false);
...@@ -1226,7 +1226,7 @@ void Game::MainLoop() { ...@@ -1226,7 +1226,7 @@ void Game::MainLoop() {
usleep(500000); usleep(500000);
#endif #endif
SaveConfig(); SaveConfig();
delete soundEffectPlayer; //delete soundEffectPlayer;
usleep(500000); usleep(500000);
// device->drop(); // device->drop();
} }
...@@ -1526,10 +1526,10 @@ void Game::SaveConfig() { ...@@ -1526,10 +1526,10 @@ void Game::SaveConfig() {
gameConf.enable_music = chkEnableMusic->isChecked() ? 1 : 0; gameConf.enable_music = chkEnableMusic->isChecked() ? 1 : 0;
android::saveIntSetting(appMain, "enable_music", gameConf.enable_music); android::saveIntSetting(appMain, "enable_music", gameConf.enable_music);
//gameConf.sound_volume = gameConf.sound_volume = (double)scrSoundVolume->getPos();
// android::saveIntSetting(appMain, "sound_volume", gameConf.sound_volume); android::saveIntSetting(appMain, "sound_volume", gameConf.sound_volume);
//gameConf.music_volume = gameConf.music_volume = (double)scrMusicVolume->getPos();
// android::saveIntSetting(appMain, "music_volume", gameConf.music_volume); android::saveIntSetting(appMain, "music_volume", gameConf.music_volume);
//gameConf.control_mode = control_mode->isChecked()?1:0; //gameConf.control_mode = control_mode->isChecked()?1:0;
// android::saveIntSetting(appMain, "control_mode", gameConf.control_mode); // android::saveIntSetting(appMain, "control_mode", gameConf.control_mode);
...@@ -1638,10 +1638,12 @@ void Game::AddChatMsg(const wchar_t* msg, int player) { ...@@ -1638,10 +1638,12 @@ void Game::AddChatMsg(const wchar_t* msg, int player) {
chatType[0] = player; chatType[0] = player;
switch(player) { switch(player) {
case 0: //from host case 0: //from host
soundManager->PlaySoundEffect(SoundManager::SFX::CHAT);
chatMsg[0].append(dInfo.hostname); chatMsg[0].append(dInfo.hostname);
chatMsg[0].append(L": "); chatMsg[0].append(L": ");
break; break;
case 1: //from client case 1: //from client
soundManager->PlaySoundEffect(SoundManager::SFX::CHAT);
chatMsg[0].append(dInfo.clientname); chatMsg[0].append(dInfo.clientname);
chatMsg[0].append(L": "); chatMsg[0].append(L": ");
break; break;
...@@ -1650,6 +1652,7 @@ void Game::AddChatMsg(const wchar_t* msg, int player) { ...@@ -1650,6 +1652,7 @@ void Game::AddChatMsg(const wchar_t* msg, int player) {
chatMsg[0].append(L": "); chatMsg[0].append(L": ");
break; break;
case 3: //client tag case 3: //client tag
soundManager->PlaySoundEffect(SoundManager::SFX::CHAT);
chatMsg[0].append(dInfo.clientname_tag); chatMsg[0].append(dInfo.clientname_tag);
chatMsg[0].append(L": "); chatMsg[0].append(L": ");
break; break;
...@@ -1658,6 +1661,7 @@ void Game::AddChatMsg(const wchar_t* msg, int player) { ...@@ -1658,6 +1661,7 @@ void Game::AddChatMsg(const wchar_t* msg, int player) {
chatMsg[0].append(L": "); chatMsg[0].append(L": ");
break; break;
case 8: //system custom message, no prefix. case 8: //system custom message, no prefix.
soundManager->PlaySoundEffect(SoundManager::SFX::CHAT);
chatMsg[0].append(L"[System]: "); chatMsg[0].append(L"[System]: ");
break; break;
case 9: //error message case 9: //error message
......
...@@ -55,15 +55,19 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -55,15 +55,19 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} }
switch(event.GUIEvent.EventType) { switch(event.GUIEvent.EventType) {
case irr::gui::EGET_BUTTON_CLICKED: { case irr::gui::EGET_BUTTON_CLICKED: {
if(id < 110)
mainGame->soundManager->PlaySoundEffect(SoundManager::SFX::INFO);
else
mainGame->soundManager->PlaySoundEffect(SoundManager::SFX::BUTTON);
switch(id) { switch(id) {
case BUTTON_MODE_EXIT: { case BUTTON_MODE_EXIT: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
mainGame->SaveConfig(); mainGame->SaveConfig();
mainGame->device->closeDevice(); mainGame->device->closeDevice();
break; break;
} }
case BUTTON_LAN_MODE: { case BUTTON_LAN_MODE: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
mainGame->btnCreateHost->setEnabled(true); mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true); mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true); mainGame->btnJoinCancel->setEnabled(true);
...@@ -92,6 +96,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -92,6 +96,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int status = evutil_getaddrinfo(hostname, port, &hints, &answer); int status = evutil_getaddrinfo(hostname, port, &hints, &answer);
if(status != 0) { if(status != 0) {
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->soundManager->PlaySoundEffect(SoundManager::SFX::INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1412)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1412));
mainGame->gMutex.unlock(); mainGame->gMutex.unlock();
break; break;
...@@ -112,7 +117,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -112,7 +117,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_JOIN_CANCEL: { case BUTTON_JOIN_CANCEL: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
mainGame->HideElement(mainGame->wLanWindow); mainGame->HideElement(mainGame->wLanWindow);
mainGame->ShowElement(mainGame->wMainMenu); mainGame->ShowElement(mainGame->wMainMenu);
if(exit_on_return) if(exit_on_return)
...@@ -120,12 +125,12 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -120,12 +125,12 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_LAN_REFRESH: { case BUTTON_LAN_REFRESH: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
DuelClient::BeginRefreshHost(); DuelClient::BeginRefreshHost();
break; break;
} }
case BUTTON_CREATE_HOST: { case BUTTON_CREATE_HOST: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
mainGame->btnHostConfirm->setEnabled(true); mainGame->btnHostConfirm->setEnabled(true);
mainGame->btnHostCancel->setEnabled(true); mainGame->btnHostCancel->setEnabled(true);
mainGame->HideElement(mainGame->wLanWindow); mainGame->HideElement(mainGame->wLanWindow);
...@@ -133,7 +138,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -133,7 +138,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_HOST_CONFIRM: { case BUTTON_HOST_CONFIRM: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
bot_mode = false; bot_mode = false;
BufferIO::CopyWStr(mainGame->ebServerName->getText(), mainGame->gameConf.gamename, 20); BufferIO::CopyWStr(mainGame->ebServerName->getText(), mainGame->gameConf.gamename, 20);
if(!NetServer::StartServer(mainGame->gameConf.serverport)) if(!NetServer::StartServer(mainGame->gameConf.serverport))
...@@ -147,7 +152,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -147,7 +152,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_HOST_CANCEL: { case BUTTON_HOST_CANCEL: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
mainGame->btnCreateHost->setEnabled(true); mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true); mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true); mainGame->btnJoinCancel->setEnabled(true);
...@@ -156,18 +161,18 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -156,18 +161,18 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_HP_DUELIST: { case BUTTON_HP_DUELIST: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
mainGame->cbDeckSelect->setEnabled(true); mainGame->cbDeckSelect->setEnabled(true);
DuelClient::SendPacketToServer(CTOS_HS_TODUELIST); DuelClient::SendPacketToServer(CTOS_HS_TODUELIST);
break; break;
} }
case BUTTON_HP_OBSERVER: { case BUTTON_HP_OBSERVER: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
DuelClient::SendPacketToServer(CTOS_HS_TOOBSERVER); DuelClient::SendPacketToServer(CTOS_HS_TOOBSERVER);
break; break;
} }
case BUTTON_HP_KICK: { case BUTTON_HP_KICK: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
int id = 0; int id = 0;
while(id < 4) { while(id < 4) {
if(mainGame->btnHostPrepKick[id] == caller) if(mainGame->btnHostPrepKick[id] == caller)
...@@ -180,7 +185,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -180,7 +185,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_HP_READY: { case BUTTON_HP_READY: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
if(mainGame->cbCategorySelect->getSelected() == -1 || mainGame->cbDeckSelect->getSelected() == -1 || if(mainGame->cbCategorySelect->getSelected() == -1 || mainGame->cbDeckSelect->getSelected() == -1 ||
!deckManager.LoadDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect)) { !deckManager.LoadDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect)) {
break; break;
...@@ -192,19 +197,19 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -192,19 +197,19 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_HP_NOTREADY: { case BUTTON_HP_NOTREADY: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
DuelClient::SendPacketToServer(CTOS_HS_NOTREADY); DuelClient::SendPacketToServer(CTOS_HS_NOTREADY);
mainGame->cbCategorySelect->setEnabled(true); mainGame->cbCategorySelect->setEnabled(true);
mainGame->cbDeckSelect->setEnabled(true); mainGame->cbDeckSelect->setEnabled(true);
break; break;
} }
case BUTTON_HP_START: { case BUTTON_HP_START: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
DuelClient::SendPacketToServer(CTOS_HS_START); DuelClient::SendPacketToServer(CTOS_HS_START);
break; break;
} }
case BUTTON_HP_CANCEL: { case BUTTON_HP_CANCEL: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
DuelClient::StopClient(); DuelClient::StopClient();
mainGame->btnCreateHost->setEnabled(true); mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true); mainGame->btnJoinHost->setEnabled(true);
...@@ -223,7 +228,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -223,7 +228,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_REPLAY_MODE: { case BUTTON_REPLAY_MODE: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
mainGame->HideElement(mainGame->wMainMenu); mainGame->HideElement(mainGame->wMainMenu);
mainGame->ShowElement(mainGame->wReplay); mainGame->ShowElement(mainGame->wReplay);
mainGame->ebRepStartTurn->setText(L"1"); mainGame->ebRepStartTurn->setText(L"1");
...@@ -232,7 +237,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -232,7 +237,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_SINGLE_MODE: { case BUTTON_SINGLE_MODE: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
mainGame->HideElement(mainGame->wMainMenu); mainGame->HideElement(mainGame->wMainMenu);
mainGame->ShowElement(mainGame->wSinglePlay); mainGame->ShowElement(mainGame->wSinglePlay);
mainGame->RefreshSingleplay(); mainGame->RefreshSingleplay();
...@@ -240,7 +245,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -240,7 +245,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_LOAD_REPLAY: { case BUTTON_LOAD_REPLAY: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
if(mainGame->lstReplayList->getSelected() == -1) if(mainGame->lstReplayList->getSelected() == -1)
break; break;
if(!ReplayMode::cur_replay.OpenReplay(mainGame->lstReplayList->getListItem(mainGame->lstReplayList->getSelected()))) if(!ReplayMode::cur_replay.OpenReplay(mainGame->lstReplayList->getListItem(mainGame->lstReplayList->getSelected())))
...@@ -293,7 +298,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -293,7 +298,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_CANCEL_REPLAY: { case BUTTON_CANCEL_REPLAY: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
mainGame->HideElement(mainGame->wReplay); mainGame->HideElement(mainGame->wReplay);
mainGame->ShowElement(mainGame->wMainMenu); mainGame->ShowElement(mainGame->wMainMenu);
break; break;
...@@ -406,7 +411,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -406,7 +411,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_LOAD_SINGLEPLAY: { case BUTTON_LOAD_SINGLEPLAY: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
if(mainGame->lstSinglePlayList->getSelected() == -1) if(mainGame->lstSinglePlayList->getSelected() == -1)
break; break;
mainGame->singleSignal.SetNoWait(false); mainGame->singleSignal.SetNoWait(false);
...@@ -414,14 +419,14 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -414,14 +419,14 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_CANCEL_SINGLEPLAY: { case BUTTON_CANCEL_SINGLEPLAY: {
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
mainGame->HideElement(mainGame->wSinglePlay); mainGame->HideElement(mainGame->wSinglePlay);
mainGame->ShowElement(mainGame->wMainMenu); mainGame->ShowElement(mainGame->wMainMenu);
break; break;
} }
case BUTTON_DECK_EDIT: { case BUTTON_DECK_EDIT: {
mainGame->RefreshCategoryDeck(mainGame->cbDBCategory, mainGame->cbDBDecks); mainGame->RefreshCategoryDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
mainGame->soundEffectPlayer->doPressButton(); //mainGame->soundEffectPlayer->doPressButton();
if(mainGame->cbDBCategory->getSelected() != -1 && mainGame->cbDBDecks->getSelected() != -1) { if(mainGame->cbDBCategory->getSelected() != -1 && mainGame->cbDBDecks->getSelected() != -1) {
deckManager.LoadDeck(mainGame->cbDBCategory, mainGame->cbDBDecks); deckManager.LoadDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
mainGame->ebDeckname->setText(L""); mainGame->ebDeckname->setText(L"");
......
#include "sound_manager.h" #include "sound_manager.h"
#include "config.h" #include "config.h"
#include "game.h"
namespace ygo { namespace ygo {
...@@ -80,12 +81,40 @@ void SoundManager::PlaySoundEffect(SFX sound) { ...@@ -80,12 +81,40 @@ void SoundManager::PlaySoundEffect(SFX sound) {
{DICE, "./sound/diceroll.wav"}, {DICE, "./sound/diceroll.wav"},
{NEXT_TURN, "./sound/nextturn.wav"}, {NEXT_TURN, "./sound/nextturn.wav"},
{PHASE, "./sound/phase.wav"}, {PHASE, "./sound/phase.wav"},
{BUTTON, "./sound/button.wav"},
{INFO, "./sound/info.wav"},
{QUESTION, "./sound/question.wav"},
{CARD_PICK, "./sound/cardpick.wav"},
{CARD_DROP, "./sound/carddrop.wav"},
{PLAYER_ENTER, "./sound/playerenter.wav"}, {PLAYER_ENTER, "./sound/playerenter.wav"},
{CHAT, "./sound/chatmessage.wav"} {CHAT, "./sound/chatmessage.wav"}
}; };
if (!soundsEnabled) return; if (!soundsEnabled) return;
if (sfx) sfx->play(fx.at(sound), false); if (sfx) sfx->play(fx.at(sound), false);
} }
void SoundManager::PlayDialogSound(irr::gui::IGUIElement * element) {
if(element == mainGame->wMessage) {
PlaySoundEffect(SoundManager::SFX::INFO);
} else if(element == mainGame->wQuery) {
PlaySoundEffect(SoundManager::SFX::QUESTION);
} else if(element == mainGame->wSurrender) {
PlaySoundEffect(SoundManager::SFX::QUESTION);
} else if(element == mainGame->wOptions) {
PlaySoundEffect(SoundManager::SFX::QUESTION);
} else if(element == mainGame->wANAttribute) {
PlaySoundEffect(SoundManager::SFX::QUESTION);
} else if(element == mainGame->wANCard) {
PlaySoundEffect(SoundManager::SFX::QUESTION);
} else if(element == mainGame->wANNumber) {
PlaySoundEffect(SoundManager::SFX::QUESTION);
} else if(element == mainGame->wANRace) {
PlaySoundEffect(SoundManager::SFX::QUESTION);
} else if(element == mainGame->wReplaySave) {
PlaySoundEffect(SoundManager::SFX::QUESTION);
} else if(element == mainGame->wFTSelect) {
PlaySoundEffect(SoundManager::SFX::QUESTION);
}
}
void SoundManager::PlayMusic(const std::string& song, bool loop) { void SoundManager::PlayMusic(const std::string& song, bool loop) {
if(!musicEnabled) return; if(!musicEnabled) return;
StopBGM(); StopBGM();
...@@ -98,7 +127,7 @@ void SoundManager::PlayBGM(BGM scene) { ...@@ -98,7 +127,7 @@ void SoundManager::PlayBGM(BGM scene) {
bgm_scene = scene; bgm_scene = scene;
int bgm = (std::uniform_int_distribution<>(0, count - 1))(rnd); int bgm = (std::uniform_int_distribution<>(0, count - 1))(rnd);
std::string BGMName = "./sound/BGM/" + list[bgm]; std::string BGMName = "./sound/BGM/" + list[bgm];
PlayMusic(BGMName, true); PlayMusic(BGMName, false);
} }
} }
void SoundManager::StopBGM() { void SoundManager::StopBGM() {
......
...@@ -32,6 +32,11 @@ public: ...@@ -32,6 +32,11 @@ public:
DICE, DICE,
NEXT_TURN, NEXT_TURN,
PHASE, PHASE,
BUTTON,
INFO,
QUESTION,
CARD_PICK,
CARD_DROP,
PLAYER_ENTER, PLAYER_ENTER,
CHAT CHAT
}; };
...@@ -48,6 +53,7 @@ public: ...@@ -48,6 +53,7 @@ public:
bool Init(double sounds_volume, double music_volume, bool sounds_enabled, bool music_enabled, void* payload = nullptr); bool Init(double sounds_volume, double music_volume, bool sounds_enabled, bool music_enabled, void* payload = nullptr);
void RefreshBGMList(); void RefreshBGMList();
void PlaySoundEffect(SFX sound); void PlaySoundEffect(SFX sound);
void PlayDialogSound(irr::gui::IGUIElement * element);
void PlayMusic(const std::string& song, bool loop); void PlayMusic(const std::string& song, bool loop);
void PlayBGM(BGM scene); void PlayBGM(BGM 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