Commit 7dd1005a authored by nanahira's avatar nanahira

fix Linux things

parent 9ee4f416
......@@ -1312,11 +1312,9 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
}
//playing custom bgm
case 21: { //HINT_MUSIC
char BGMName[1024];
if (data) {
myswprintf(textBuffer, L"./sound/BGM/custom/%ls.mp3", dataManager.GetDesc(data));
BufferIO::EncodeUTF8(textBuffer, BGMName);
soundManager.PlayCustomBGM(BGMName);
soundManager.PlayCustomBGM(textBuffer);
} else {
soundManager.StopBGM();
}
......@@ -1324,11 +1322,9 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
}
//playing custom sound effect
case 22: { //HINT_SOUND
char SoundName[1024];
if (data) {
myswprintf(textBuffer, L"./sound/custom/%ls.wav", dataManager.GetDesc(data));
BufferIO::EncodeUTF8(textBuffer, SoundName);
soundManager.PlayCustomSound(SoundName);
soundManager.PlayCustomSound(textBuffer);
} else {
soundManager.StopSound();
}
......@@ -1336,11 +1332,9 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
}
//playing custom bgm in ogg format
case 23: { //HINT_MUSIC_OGG
char BGMName[1024];
if (data) {
myswprintf(textBuffer, L"./sound/BGM/custom/%ls.ogg", dataManager.GetDesc(data));
BufferIO::EncodeUTF8(textBuffer, BGMName);
soundManager.PlayCustomBGM(BGMName);
soundManager.PlayCustomBGM(textBuffer);
} else {
soundManager.StopBGM();
}
......
......@@ -272,7 +272,13 @@ void SoundManager::PlayMusic(wchar_t* music, bool loop) {
StopBGM();
#ifdef YGOPRO_USE_MINIAUDIO
BufferIO::CopyWStr(music, currentPlayingMusic, 1024);
#ifdef _WIN32
ma_sound_init_from_file_w(&engineMusic, music, MA_SOUND_FLAG_ASYNC | MA_SOUND_FLAG_STREAM, nullptr, nullptr, &soundBGM);
#else
char musicU[1024];
BufferIO::EncodeUTF8(music, musicU);
ma_sound_init_from_file(&engineMusic, musicU, MA_SOUND_FLAG_ASYNC | MA_SOUND_FLAG_STREAM, nullptr, nullptr, &soundBGM);
#endif
ma_sound_set_looping(&soundBGM, loop);
ma_sound_start(&soundBGM);
#endif
......@@ -309,7 +315,7 @@ void SoundManager::PlayBGM(int scene) {
}
#endif
}
void SoundManager::PlayCustomBGM(char* BGMName) {
void SoundManager::PlayCustomBGM(wchar_t* BGMName) {
#ifdef YGOPRO_USE_AUDIO
if(!mainGame->chkEnableMusic->isChecked() || !mainGame->chkMusicMode->isChecked() || bgm_process || IsCurrentlyPlaying(BGMName))
return;
......@@ -322,17 +328,19 @@ void SoundManager::PlayCustomBGM(char* BGMName) {
bgm_process = false;
#endif
}
void SoundManager::PlayCustomSound(char* SoundName) {
void SoundManager::PlayCustomSound(wchar_t* SoundName) {
#ifdef YGOPRO_USE_AUDIO
if(!mainGame->chkEnableSound->isChecked())
return;
char soundNameU[1024];
BufferIO::EncodeUTF8(SoundName, soundNameU);
#ifdef YGOPRO_USE_MINIAUDIO
ma_engine_set_volume(&engineSound, mainGame->gameConf.sound_volume);
ma_engine_play_sound(&engineSound, SoundName, nullptr);
ma_engine_play_sound(&engineSound, soundNameU, nullptr);
#endif
#ifdef YGOPRO_USE_IRRKLANG
engineSound->setSoundVolume(mainGame->gameConf.sound_volume);
engineSound->play2D(SoundName);
engineSound->play2D(soundNameU);
#endif
#endif
}
......
......@@ -45,8 +45,8 @@ public:
bool IsCurrentlyPlaying(wchar_t* music);
void PlayMusic(wchar_t* music, bool loop);
void PlayBGM(int scene);
void PlayCustomBGM(char* BGMName);
void PlayCustomSound(char* SoundName);
void PlayCustomBGM(wchar_t* BGMName);
void PlayCustomSound(wchar_t* SoundName);
void StopBGM();
void StopSound();
void SetSoundVolume(double volume);
......
Subproject commit cb76df61140cb650bce988dbe637a66e8a6cbc12
Subproject commit 9f141e8cdfc7adee127eaca1a7981e816b555ae3
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