Commit bd8b1f92 authored by mercury233's avatar mercury233

implement YGOPRO_USE_IRRKLANG switch

parent cc086f3f
...@@ -48,7 +48,6 @@ inline int _wtoi(const wchar_t * s) { ...@@ -48,7 +48,6 @@ inline int _wtoi(const wchar_t * s) {
#endif #endif
#include <irrlicht.h> #include <irrlicht.h>
#include <irrKlang.h>
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h> #include <GL/glu.h>
#include "CGUITTFont.h" #include "CGUITTFont.h"
......
...@@ -640,9 +640,14 @@ bool Game::Initialize() { ...@@ -640,9 +640,14 @@ bool Game::Initialize() {
if(!soundManager.Init()) { if(!soundManager.Init()) {
chkEnableSound->setChecked(false); chkEnableSound->setChecked(false);
chkEnableSound->setEnabled(false); chkEnableSound->setEnabled(false);
chkEnableSound->setVisible(false);
chkEnableMusic->setChecked(false); chkEnableMusic->setChecked(false);
chkEnableMusic->setEnabled(false); chkEnableMusic->setEnabled(false);
chkEnableMusic->setVisible(false);
scrSoundVolume->setVisible(false);
scrMusicVolume->setVisible(false);
chkMusicMode->setEnabled(false); chkMusicMode->setEnabled(false);
chkMusicMode->setVisible(false);
} }
env->getSkin()->setFont(guiFont); env->getSkin()->setFont(guiFont);
env->setFocus(wMainMenu); env->setFocus(wMainMenu);
......
#include "sound_manager.h" #include "sound_manager.h"
#ifdef IRRKLANG_STATIC
#include "../ikpmp3/ikpMP3.h"
#endif
namespace ygo { namespace ygo {
SoundManager soundManager; SoundManager soundManager;
bool SoundManager::Init() { bool SoundManager::Init() {
#ifdef YGOPRO_USE_IRRKLANG
bgm_scene = -1; bgm_scene = -1;
RefreshBGMList(); RefreshBGMList();
engineSound = irrklang::createIrrKlangDevice(); engineSound = irrklang::createIrrKlangDevice();
...@@ -21,6 +19,9 @@ bool SoundManager::Init() { ...@@ -21,6 +19,9 @@ bool SoundManager::Init() {
#endif #endif
return true; return true;
} }
#endif // YGOPRO_USE_IRRKLANG
// TODO: Implement other sound engines
return false;
} }
void SoundManager::RefreshBGMList() { void SoundManager::RefreshBGMList() {
RefershBGMDir(L"", BGM_DUEL); RefershBGMDir(L"", BGM_DUEL);
...@@ -64,6 +65,7 @@ void SoundManager::RefershBGMDir(std::wstring path, int scene) { ...@@ -64,6 +65,7 @@ void SoundManager::RefershBGMDir(std::wstring path, int scene) {
#endif #endif
} }
void SoundManager::PlaySoundEffect(int sound) { void SoundManager::PlaySoundEffect(int sound) {
#ifdef YGOPRO_USE_IRRKLANG
if(!mainGame->chkEnableSound->isChecked()) if(!mainGame->chkEnableSound->isChecked())
return; return;
switch(sound) { switch(sound) {
...@@ -191,8 +193,10 @@ void SoundManager::PlaySoundEffect(int sound) { ...@@ -191,8 +193,10 @@ void SoundManager::PlaySoundEffect(int sound) {
break; break;
} }
engineSound->setSoundVolume(mainGame->gameConf.sound_volume); engineSound->setSoundVolume(mainGame->gameConf.sound_volume);
#endif
} }
void SoundManager::PlayMusic(char* song, bool loop) { void SoundManager::PlayMusic(char* song, bool loop) {
#ifdef YGOPRO_USE_IRRKLANG
if(!mainGame->chkEnableMusic->isChecked()) if(!mainGame->chkEnableMusic->isChecked())
return; return;
if(!engineMusic->isCurrentlyPlaying(song)) { if(!engineMusic->isCurrentlyPlaying(song)) {
...@@ -200,8 +204,10 @@ void SoundManager::PlayMusic(char* song, bool loop) { ...@@ -200,8 +204,10 @@ void SoundManager::PlayMusic(char* song, bool loop) {
soundBGM = engineMusic->play2D(song, loop, false, true); soundBGM = engineMusic->play2D(song, loop, false, true);
engineMusic->setSoundVolume(mainGame->gameConf.music_volume); engineMusic->setSoundVolume(mainGame->gameConf.music_volume);
} }
#endif
} }
void SoundManager::PlayBGM(int scene) { void SoundManager::PlayBGM(int scene) {
#ifdef YGOPRO_USE_IRRKLANG
if(!mainGame->chkEnableMusic->isChecked()) if(!mainGame->chkEnableMusic->isChecked())
return; return;
if(!mainGame->chkMusicMode->isChecked()) if(!mainGame->chkMusicMode->isChecked())
...@@ -219,14 +225,21 @@ void SoundManager::PlayBGM(int scene) { ...@@ -219,14 +225,21 @@ void SoundManager::PlayBGM(int scene) {
BufferIO::EncodeUTF8(fname, BGMName); BufferIO::EncodeUTF8(fname, BGMName);
PlayMusic(BGMName, false); PlayMusic(BGMName, false);
} }
#endif
} }
void SoundManager::StopBGM() { void SoundManager::StopBGM() {
#ifdef YGOPRO_USE_IRRKLANG
engineMusic->stopAllSounds(); engineMusic->stopAllSounds();
#endif
} }
void SoundManager::SetSoundVolume(double volume) { void SoundManager::SetSoundVolume(double volume) {
#ifdef YGOPRO_USE_IRRKLANG
engineSound->setSoundVolume(volume); engineSound->setSoundVolume(volume);
#endif
} }
void SoundManager::SetMusicVolume(double volume) { void SoundManager::SetMusicVolume(double volume) {
#ifdef YGOPRO_USE_IRRKLANG
engineMusic->setSoundVolume(volume); engineMusic->setSoundVolume(volume);
#endif
} }
} }
...@@ -3,7 +3,12 @@ ...@@ -3,7 +3,12 @@
#include "config.h" #include "config.h"
#include "game.h" #include "game.h"
#include <vector> #ifdef YGOPRO_USE_IRRKLANG
#include <irrKlang.h>
#ifdef IRRKLANG_STATIC
#include "../ikpmp3/ikpMP3.h"
#endif
#endif
namespace ygo { namespace ygo {
...@@ -11,9 +16,11 @@ class SoundManager { ...@@ -11,9 +16,11 @@ class SoundManager {
private: private:
std::vector<std::wstring> BGMList[8]; std::vector<std::wstring> BGMList[8];
int bgm_scene; int bgm_scene;
#ifdef YGOPRO_USE_IRRKLANG
irrklang::ISoundEngine* engineSound; irrklang::ISoundEngine* engineSound;
irrklang::ISoundEngine* engineMusic; irrklang::ISoundEngine* engineMusic;
irrklang::ISound* soundBGM; irrklang::ISound* soundBGM;
#endif
void RefershBGMDir(std::wstring path, int scene); void RefershBGMDir(std::wstring path, int scene);
public: public:
......
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