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