Commit 6eec50d7 authored by edo9300's avatar edo9300

sound

parent 822aa75f
......@@ -47,6 +47,7 @@ inline int _wtoi(const wchar_t * s) {
#endif
#include <irrlicht.h>
#include <irrKlang.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "CGUITTFont.h"
......
......@@ -248,6 +248,12 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
}
break;
}
case SCROLL_VOLUME: {
mainGame->gameConf.volume = (double)mainGame->srcVolume->getPos() / 100;
mainGame->engineSound->setSoundVolume(mainGame->gameConf.volume);
mainGame->engineMusic->setSoundVolume(mainGame->gameConf.volume);
break;
}
}
case irr::gui::EGET_EDITBOX_ENTER: {
switch(id) {
......@@ -426,6 +432,13 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
}
}
}
case irr::gui::EGET_CHECKBOX_CHANGED: {
case CHECKBOX_ENABLE_MUSIC: {
if (!mainGame->chkEnableMusic->isChecked())
mainGame->engineMusic->stopAllSounds();
break;
}
}
default: break;
}
break;
......
......@@ -704,6 +704,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
break;
}
case STOC_HS_PLAYER_ENTER: {
mainGame->PlaySoundEffect("./sound/playerenter.wav");
STOC_HS_PlayerEnter* pkt = (STOC_HS_PlayerEnter*)pdata;
if(pkt->pos > 3)
break;
......@@ -737,6 +738,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
break;
mainGame->gMutex.Lock();
if(state < 8) {
mainGame->PlaySoundEffect("./sound/playerenter.wav");
wchar_t* prename = (wchar_t*)mainGame->stHostPrepDuelist[pos]->getText();
mainGame->stHostPrepDuelist[state]->setText(prename);
mainGame->stHostPrepDuelist[pos]->setText(L"");
......@@ -1761,6 +1763,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
}
case MSG_SHUFFLE_DECK: {
mainGame->PlaySoundEffect("./sound/shuffle.wav");
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
if(mainGame->dField.deck[player].size() < 2)
return true;
......@@ -1951,6 +1954,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
}
case MSG_NEW_TURN: {
mainGame->PlaySoundEffect("./sound/nextturn.wav");
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
mainGame->dInfo.turn++;
if(!mainGame->dInfo.isTag && mainGame->dInfo.turn == 3 && !mainGame->dInfo.isReplay && mainGame->dInfo.player_type < 7) {
......@@ -1987,6 +1991,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
}
case MSG_NEW_PHASE: {
mainGame->PlaySoundEffect("./sound/phase.wav");
unsigned short phase = BufferIO::ReadInt16(pbuf);
mainGame->btnDP->setVisible(false);
mainGame->btnSP->setVisible(false);
......@@ -2046,7 +2051,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
int cl = BufferIO::ReadUInt8(pbuf);
int cs = BufferIO::ReadInt8(pbuf);
int cp = BufferIO::ReadInt8(pbuf);
/*int reason = */BufferIO::ReadInt32(pbuf);
int reason = BufferIO::ReadInt32(pbuf);
if (reason & REASON_DESTROY && pl != cl)
mainGame->PlaySoundEffect("./sound/destroyed.wav");
if (pl == 0) {
ClientCard* pcard = new ClientCard();
pcard->position = cp;
......@@ -2261,6 +2268,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
}
case MSG_SET: {
mainGame->PlaySoundEffect("./sound/set.wav");
/*int code = */BufferIO::ReadInt32(pbuf);
/*int cc = mainGame->LocalPlayer*/(BufferIO::ReadInt8(pbuf));
/*int cl = */BufferIO::ReadInt8(pbuf);
......@@ -2313,6 +2321,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
}
case MSG_SUMMONING: {
mainGame->PlaySoundEffect("./sound/summon.wav");
unsigned int code = (unsigned int)BufferIO::ReadInt32(pbuf);
/*int cc = */mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
/*int cl = */BufferIO::ReadInt8(pbuf);
......@@ -2335,6 +2344,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
}
case MSG_SPSUMMONING: {
mainGame->PlaySoundEffect("./sound/specialsummon.wav");
unsigned int code = (unsigned int)BufferIO::ReadInt32(pbuf);
/*int cc = */mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
/*int cl = */BufferIO::ReadInt8(pbuf);
......@@ -2356,6 +2366,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
}
case MSG_FLIPSUMMONING: {
mainGame->PlaySoundEffect("./sound/flip.wav");
unsigned int code = (unsigned int)BufferIO::ReadInt32(pbuf);
int cc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int cl = BufferIO::ReadInt8(pbuf);
......@@ -2383,6 +2394,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
}
case MSG_CHAINING: {
mainGame->PlaySoundEffect("./sound/activate.wav");
unsigned int code = (unsigned int)BufferIO::ReadInt32(pbuf);
int pcc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int pcl = BufferIO::ReadInt8(pbuf);
......@@ -2555,6 +2567,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
} else {
for (int i = 0; i < count; ++i) {
mainGame->PlaySoundEffect("./sound/draw.wav");
mainGame->gMutex.Lock();
pcard = mainGame->dField.GetCard(player, LOCATION_DECK, mainGame->dField.deck[player].size() - 1);
mainGame->dField.deck[player].erase(mainGame->dField.deck[player].end() - 1);
......@@ -2571,6 +2584,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
}
case MSG_DAMAGE: {
mainGame->PlaySoundEffect("./sound/damage.wav");
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int val = BufferIO::ReadInt32(pbuf);
int final = mainGame->dInfo.lp[player] - val;
......@@ -2601,6 +2615,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
}
case MSG_RECOVER: {
mainGame->PlaySoundEffect("./sound/gainlp.wav");
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int val = BufferIO::ReadInt32(pbuf);
int final = mainGame->dInfo.lp[player] + val;
......@@ -2629,6 +2644,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
}
case MSG_EQUIP: {
mainGame->PlaySoundEffect("./sound/equip.wav");
int c1 = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l1 = BufferIO::ReadInt8(pbuf);
int s1 = BufferIO::ReadInt8(pbuf);
......@@ -2746,6 +2762,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
break;
}
case MSG_PAY_LPCOST: {
mainGame->PlaySoundEffect("./sound/damage.wav");
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int cost = BufferIO::ReadInt32(pbuf);
int final = mainGame->dInfo.lp[player] - cost;
......@@ -2772,6 +2789,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
}
case MSG_ADD_COUNTER: {
mainGame->PlaySoundEffect("./sound/addcounter.wav");
int type = BufferIO::ReadInt16(pbuf);
int c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l = BufferIO::ReadInt8(pbuf);
......@@ -2794,6 +2812,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
}
case MSG_REMOVE_COUNTER: {
mainGame->PlaySoundEffect("./sound/removecounter.wav");
int type = BufferIO::ReadInt16(pbuf);
int c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l = BufferIO::ReadInt8(pbuf);
......@@ -2816,6 +2835,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
}
case MSG_ATTACK: {
mainGame->PlaySoundEffect("./sound/attack.wav");
int ca = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int la = BufferIO::ReadInt8(pbuf);
int sa = BufferIO::ReadInt8(pbuf);
......@@ -2924,6 +2944,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
}
case MSG_TOSS_COIN: {
mainGame->PlaySoundEffect("./sound/coinflip.wav");
/*int player = */mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int count = BufferIO::ReadInt8(pbuf);
wchar_t* pwbuf = textBuffer;
......@@ -2947,6 +2968,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
}
case MSG_TOSS_DICE: {
mainGame->PlaySoundEffect("./sound/diceroll.wav");
/*int player = */mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int count = BufferIO::ReadInt8(pbuf);
wchar_t* pwbuf = textBuffer;
......
......@@ -876,6 +876,11 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
break;
}
case CHECKBOX_ENABLE_MUSIC: {
if(!mainGame->chkEnableMusic->isChecked())
mainGame->engineMusic->stopAllSounds();
break;
}
}
break;
}
......@@ -1017,6 +1022,12 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->SetStaticText(mainGame->stText, mainGame->stText->getRelativePosition().getWidth()-25, mainGame->textFont, mainGame->showingtext, pos);
break;
}
case SCROLL_VOLUME: {
mainGame->gameConf.volume = (double)mainGame->srcVolume->getPos() / 100;
mainGame->engineSound->setSoundVolume(mainGame->gameConf.volume);
mainGame->engineMusic->setSoundVolume(mainGame->gameConf.volume);
break;
}
break;
}
}
......
This diff is collapsed.
......@@ -36,6 +36,11 @@ struct Config {
int control_mode;
int draw_field_spell;
int separate_clear_button;
bool enablesound;
double volume;
bool enablemusic;
int BGM_index;
};
struct DuelInfo {
......@@ -86,6 +91,7 @@ public:
void RefreshDeck(irr::gui::IGUIComboBox* cbDeck);
void RefreshReplay();
void RefreshSingleplay();
void RefreshBGMList();
void DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, float* cv);
void DrawBackGround();
void DrawCards();
......@@ -105,6 +111,9 @@ public:
void AddChatMsg(wchar_t* msg, int player);
void ClearTextures();
void CloseDuelWindow();
void PlaySoundEffect(char* sound);
void PlayMusic(char* song, bool loop);
void PlayBGM();
int LocalPlayer(int player);
const wchar_t* LocalName(int local_player);
......@@ -135,6 +144,7 @@ public:
std::list<FadingUnit> fadingList;
std::vector<int> logParam;
std::wstring chatMsg[8];
std::vector<std::wstring> BGMList;
int hideChatTimer;
bool hideChat;
......@@ -196,6 +206,7 @@ public:
irr::gui::IGUIStaticText* stDataInfo;
irr::gui::IGUIStaticText* stSetName;
irr::gui::IGUIStaticText* stText;
irr::gui::IGUIStaticText* stVolume;
irr::gui::IGUIScrollBar* scrCardText;
irr::gui::IGUICheckBox* chkAutoPos;
irr::gui::IGUICheckBox* chkRandomPos;
......@@ -203,9 +214,12 @@ public:
irr::gui::IGUICheckBox* chkWaitChain;
irr::gui::IGUICheckBox* chkHideSetname;
irr::gui::IGUICheckBox* chkHideHintButton;
irr::gui::IGUICheckBox* chkEnableSound;
irr::gui::IGUICheckBox* chkEnableMusic;
irr::gui::IGUIListBox* lstLog;
irr::gui::IGUIButton* btnClearLog;
irr::gui::IGUIButton* btnSaveLog;
irr::gui::IGUIScrollBar* srcVolume;
//main menu
irr::gui::IGUIWindow* wMainMenu;
irr::gui::IGUIButton* btnLanMode;
......@@ -419,6 +433,9 @@ public:
irr::gui::IGUIButton* btnReplaySwap;
//surrender/leave
irr::gui::IGUIButton* btnLeaveGame;
//soundEngine
irrklang::ISoundEngine* engineSound;
irrklang::ISoundEngine* engineMusic;
//chain control
irr::gui::IGUIButton* btnChainIgnore;
irr::gui::IGUIButton* btnChainAlways;
......@@ -571,5 +588,7 @@ extern Game* mainGame;
#define CHECK_TURBO_DUEL_3 364
#define CHECK_COMMAND_DUEL 365
#define CHECK_DECK_MASTER_DUEL 366
#define CHECKBOX_ENABLE_MUSIC 361
#define SCROLL_VOLUME 362
#define COMBOBOX_SORTTYPE 370
#endif // GAME_H
......@@ -6,12 +6,13 @@ project "ygopro"
files { "**.cpp", "**.cc", "**.c", "**.h" }
excludes "lzma/**"
includedirs { "../ocgcore" }
links { "ocgcore", "clzma", "Irrlicht", "freetype", "sqlite3", "lua" , "event"}
links { "ocgcore", "clzma", "Irrlicht", "freetype", "sqlite3", "lua" , "event", "irrKlang"}
configuration "windows"
files "ygopro.rc"
excludes "CGUIButton.cpp"
includedirs { "../irrlicht/include", "../freetype/include", "../event/include", "../sqlite3" }
includedirs { "../irrlicht/include", "../freetype/include", "../event/include", "../sqlite3", "../irrKlang-1.5.0/include" }
libdirs { "../irrKlang-1.5.0/lib/Win32-visualStudio" }
links { "opengl32", "ws2_32", "winmm", "gdi32", "kernel32", "user32", "imm32" }
configuration {"windows", "not vs*"}
includedirs { "/mingw/include/irrlicht", "/mingw/include/freetype2" }
......
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