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