Commit 4d8564bd authored by nanahira's avatar nanahira

Merge branch 'server-develop' into server

parents 77c9b43b 24d07a16
...@@ -6,6 +6,8 @@ if [ ! -d "miniaudio" ]; then ...@@ -6,6 +6,8 @@ if [ ! -d "miniaudio" ]; then
git clone --depth=1 --branch 0.11.22 https://github.com/mackron/miniaudio git clone --depth=1 --branch 0.11.22 https://github.com/mackron/miniaudio
fi fi
cp -rf miniaudio/extras/miniaudio_split/miniaudio.* miniaudio/
mkdir -p miniaudio/external mkdir -p miniaudio/external
install_external() { install_external() {
......
...@@ -95,6 +95,9 @@ jobs: ...@@ -95,6 +95,9 @@ jobs:
if: matrix.audiolib == 'miniaudio' if: matrix.audiolib == 'miniaudio'
run: | run: |
git clone --depth=1 --branch 0.11.22 https://github.com/mackron/miniaudio git clone --depth=1 --branch 0.11.22 https://github.com/mackron/miniaudio
cd miniaudio
xcopy /Y extras\miniaudio_split\miniaudio.* .
cd ..
- name: Download ogg - name: Download ogg
if: matrix.audiolib == 'miniaudio' if: matrix.audiolib == 'miniaudio'
...@@ -295,6 +298,9 @@ jobs: ...@@ -295,6 +298,9 @@ jobs:
- name: Download miniaudio - name: Download miniaudio
run: | run: |
git clone --depth=1 --branch 0.11.22 https://github.com/mackron/miniaudio git clone --depth=1 --branch 0.11.22 https://github.com/mackron/miniaudio
cd miniaudio
cp extras/miniaudio_split/miniaudio.* .
cd ..
- name: Download irrlicht - name: Download irrlicht
run: | run: |
...@@ -387,6 +393,9 @@ jobs: ...@@ -387,6 +393,9 @@ jobs:
- name: Download miniaudio - name: Download miniaudio
run: | run: |
git clone --depth=1 --branch 0.11.22 https://github.com/mackron/miniaudio git clone --depth=1 --branch 0.11.22 https://github.com/mackron/miniaudio
cd miniaudio
cp extras/miniaudio_split/miniaudio.* .
cd ..
- name: Download irrlicht - name: Download irrlicht
run: | run: |
......
...@@ -1312,11 +1312,11 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) { ...@@ -1312,11 +1312,11 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
} }
//playing custom bgm //playing custom bgm
case 21: { //HINT_MUSIC case 21: { //HINT_MUSIC
char BGMName[1024];
if (data) { if (data) {
char textBufferU[1024];
myswprintf(textBuffer, L"./sound/BGM/custom/%ls.mp3", dataManager.GetDesc(data)); myswprintf(textBuffer, L"./sound/BGM/custom/%ls.mp3", dataManager.GetDesc(data));
BufferIO::EncodeUTF8(textBuffer, BGMName); BufferIO::EncodeUTF8(textBuffer, textBufferU);
soundManager.PlayCustomBGM(BGMName); soundManager.PlayCustomBGM(textBufferU);
} else { } else {
soundManager.StopBGM(); soundManager.StopBGM();
} }
...@@ -1324,11 +1324,11 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) { ...@@ -1324,11 +1324,11 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
} }
//playing custom sound effect //playing custom sound effect
case 22: { //HINT_SOUND case 22: { //HINT_SOUND
char SoundName[1024];
if (data) { if (data) {
char textBufferU[1024];
myswprintf(textBuffer, L"./sound/custom/%ls.wav", dataManager.GetDesc(data)); myswprintf(textBuffer, L"./sound/custom/%ls.wav", dataManager.GetDesc(data));
BufferIO::EncodeUTF8(textBuffer, SoundName); BufferIO::EncodeUTF8(textBuffer, textBufferU);
soundManager.PlayCustomSound(SoundName); soundManager.PlayCustomSound(textBufferU);
} else { } else {
soundManager.StopSound(); soundManager.StopSound();
} }
...@@ -1336,11 +1336,11 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) { ...@@ -1336,11 +1336,11 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
} }
//playing custom bgm in ogg format //playing custom bgm in ogg format
case 23: { //HINT_MUSIC_OGG case 23: { //HINT_MUSIC_OGG
char BGMName[1024];
if (data) { if (data) {
char textBufferU[1024];
myswprintf(textBuffer, L"./sound/BGM/custom/%ls.ogg", dataManager.GetDesc(data)); myswprintf(textBuffer, L"./sound/BGM/custom/%ls.ogg", dataManager.GetDesc(data));
BufferIO::EncodeUTF8(textBuffer, BGMName); BufferIO::EncodeUTF8(textBuffer, textBufferU);
soundManager.PlayCustomBGM(BGMName); soundManager.PlayCustomBGM(textBufferU);
} else { } else {
soundManager.StopBGM(); soundManager.StopBGM();
} }
......
...@@ -280,7 +280,7 @@ bool Game::Initialize() { ...@@ -280,7 +280,7 @@ bool Game::Initialize() {
SetWindowsIcon(); SetWindowsIcon();
//main menu //main menu
wchar_t strbuf[256]; wchar_t strbuf[256];
myswprintf(strbuf, L"KoishiPro %X.0%X.%X Overdose", (PRO_VERSION & 0xf000U) >> 12, (PRO_VERSION & 0x0ff0U) >> 4, PRO_VERSION & 0x000fU); myswprintf(strbuf, L"KoishiPro %X.0%X.%X Bumblebee", (PRO_VERSION & 0xf000U) >> 12, (PRO_VERSION & 0x0ff0U) >> 4, PRO_VERSION & 0x000fU);
wMainMenu = env->addWindow(irr::core::rect<irr::s32>(370, 200, 650, 415), false, strbuf); wMainMenu = env->addWindow(irr::core::rect<irr::s32>(370, 200, 650, 415), false, strbuf);
wMainMenu->getCloseButton()->setVisible(false); wMainMenu->getCloseButton()->setVisible(false);
btnLanMode = env->addButton(irr::core::rect<irr::s32>(10, 30, 270, 60), wMainMenu, BUTTON_LAN_MODE, dataManager.GetSysString(1200)); btnLanMode = env->addButton(irr::core::rect<irr::s32>(10, 30, 270, 60), wMainMenu, BUTTON_LAN_MODE, dataManager.GetSysString(1200));
......
...@@ -85,7 +85,7 @@ end ...@@ -85,7 +85,7 @@ end
defines { "YGOPRO_USE_AUDIO" } defines { "YGOPRO_USE_AUDIO" }
if AUDIO_LIB == "miniaudio" then if AUDIO_LIB == "miniaudio" then
defines { "YGOPRO_USE_MINIAUDIO" } defines { "YGOPRO_USE_MINIAUDIO" }
includedirs { "../miniaudio/extras/miniaudio_split" } includedirs { "../miniaudio" }
links { "miniaudio" } links { "miniaudio" }
if MINIAUDIO_SUPPORT_OPUS_VORBIS then if MINIAUDIO_SUPPORT_OPUS_VORBIS then
defines { "YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS" } defines { "YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS" }
......
...@@ -36,6 +36,7 @@ bool SoundManager::Init() { ...@@ -36,6 +36,7 @@ bool SoundManager::Init() {
} }
engineConfig.pResourceManager = &resourceManager; engineConfig.pResourceManager = &resourceManager;
#endif #endif
playingSoundEffect = FALSE;
if(ma_engine_init(&engineConfig, &engineSound) != MA_SUCCESS || ma_engine_init(&engineConfig, &engineMusic) != MA_SUCCESS) { if(ma_engine_init(&engineConfig, &engineSound) != MA_SUCCESS || ma_engine_init(&engineConfig, &engineMusic) != MA_SUCCESS) {
return false; return false;
} else { } else {
...@@ -85,6 +86,29 @@ void SoundManager::RefershBGMDir(std::wstring path, int scene) { ...@@ -85,6 +86,29 @@ void SoundManager::RefershBGMDir(std::wstring path, int scene) {
} }
}); });
} }
void SoundManager::PlaySound(char* sound) {
#ifdef YGOPRO_USE_AUDIO
if(!mainGame->chkEnableSound->isChecked())
return;
#ifdef YGOPRO_USE_MINIAUDIO
StopSound();
SetSoundVolume(mainGame->gameConf.sound_volume);
playingSoundEffect = TRUE;
#ifdef _WIN32
wchar_t sound_w[1024];
BufferIO::DecodeUTF8(sound, sound_w);
ma_sound_init_from_file_w(&engineSound, sound_w, MA_SOUND_FLAG_ASYNC | MA_SOUND_FLAG_STREAM, nullptr, nullptr, &soundEffect);
#else
ma_sound_init_from_file(&engineSound, sound, MA_SOUND_FLAG_ASYNC | MA_SOUND_FLAG_STREAM, nullptr, nullptr, &soundEffect);
#endif
ma_sound_start(&soundEffect);
#endif
#ifdef YGOPRO_USE_IRRKLANG
SetSoundVolume(mainGame->gameConf.sound_volume);
engineSound->play2D(soundPath);
#endif
#endif
}
void SoundManager::PlaySoundEffect(int sound) { void SoundManager::PlaySoundEffect(int sound) {
#ifdef YGOPRO_USE_AUDIO #ifdef YGOPRO_USE_AUDIO
if(!mainGame->chkEnableSound->isChecked()) if(!mainGame->chkEnableSound->isChecked())
...@@ -220,14 +244,7 @@ void SoundManager::PlaySoundEffect(int sound) { ...@@ -220,14 +244,7 @@ void SoundManager::PlaySoundEffect(int sound) {
} }
char soundPath[40]; char soundPath[40];
std::snprintf(soundPath, 40, "./sound/%s.wav", soundName); std::snprintf(soundPath, 40, "./sound/%s.wav", soundName);
#ifdef YGOPRO_USE_MINIAUDIO PlaySound(soundPath);
ma_engine_set_volume(&engineSound, mainGame->gameConf.sound_volume);
ma_engine_play_sound(&engineSound, soundPath, nullptr);
#endif
#ifdef YGOPRO_USE_IRRKLANG
engineSound->setSoundVolume(mainGame->gameConf.sound_volume);
engineSound->play2D(soundPath);
#endif
#endif // YGOPRO_USE_AUDIO #endif // YGOPRO_USE_AUDIO
} }
void SoundManager::PlayDialogSound(irr::gui::IGUIElement * element) { void SoundManager::PlayDialogSound(irr::gui::IGUIElement * element) {
...@@ -268,6 +285,7 @@ void SoundManager::PlayMusic(char* song, bool loop) { ...@@ -268,6 +285,7 @@ void SoundManager::PlayMusic(char* song, bool loop) {
return; return;
if(!IsCurrentlyPlaying(song)) { if(!IsCurrentlyPlaying(song)) {
StopBGM(); StopBGM();
SetMusicVolume(mainGame->gameConf.music_volume);
#ifdef YGOPRO_USE_MINIAUDIO #ifdef YGOPRO_USE_MINIAUDIO
strcpy(currentPlayingMusic, song); strcpy(currentPlayingMusic, song);
#ifdef _WIN32 #ifdef _WIN32
...@@ -281,8 +299,6 @@ void SoundManager::PlayMusic(char* song, bool loop) { ...@@ -281,8 +299,6 @@ void SoundManager::PlayMusic(char* song, bool loop) {
ma_sound_start(&soundBGM); ma_sound_start(&soundBGM);
#endif #endif
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_IRRKLANG
engineMusic->stopAllSounds();
engineMusic->setSoundVolume(mainGame->gameConf.music_volume);
soundBGM = engineMusic->play2D(song, loop, false, true); soundBGM = engineMusic->play2D(song, loop, false, true);
#endif #endif
} }
...@@ -327,18 +343,7 @@ void SoundManager::PlayCustomBGM(char* BGMName) { ...@@ -327,18 +343,7 @@ void SoundManager::PlayCustomBGM(char* BGMName) {
#endif #endif
} }
void SoundManager::PlayCustomSound(char* SoundName) { void SoundManager::PlayCustomSound(char* SoundName) {
#ifdef YGOPRO_USE_AUDIO PlaySound(SoundName);
if(!mainGame->chkEnableSound->isChecked())
return;
#ifdef YGOPRO_USE_MINIAUDIO
ma_engine_set_volume(&engineSound, mainGame->gameConf.sound_volume);
ma_engine_play_sound(&engineSound, SoundName, nullptr);
#endif
#ifdef YGOPRO_USE_IRRKLANG
engineSound->setSoundVolume(mainGame->gameConf.sound_volume);
engineSound->play2D(SoundName);
#endif
#endif
} }
void SoundManager::StopBGM() { void SoundManager::StopBGM() {
#ifdef YGOPRO_USE_MINIAUDIO #ifdef YGOPRO_USE_MINIAUDIO
...@@ -352,7 +357,15 @@ void SoundManager::StopBGM() { ...@@ -352,7 +357,15 @@ void SoundManager::StopBGM() {
#endif #endif
} }
void SoundManager::StopSound() { void SoundManager::StopSound() {
// TODO: stop all sounds #ifdef YGOPRO_USE_MINIAUDIO
if(!playingSoundEffect)
return;
playingSoundEffect = FALSE;
ma_sound_uninit(&soundEffect);
#endif
#ifdef YGOPRO_USE_IRRKLANG
engineSound->stopAllSounds();
#endif
} }
void SoundManager::SetSoundVolume(double volume) { void SoundManager::SetSoundVolume(double volume) {
#ifdef YGOPRO_USE_MINIAUDIO #ifdef YGOPRO_USE_MINIAUDIO
......
...@@ -29,6 +29,8 @@ private: ...@@ -29,6 +29,8 @@ private:
ma_engine engineMusic; ma_engine engineMusic;
ma_sound soundBGM; ma_sound soundBGM;
char currentPlayingMusic[1024]{}; char currentPlayingMusic[1024]{};
ma_sound soundEffect;
char playingSoundEffect;
#endif #endif
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_IRRKLANG
irrklang::ISoundEngine* engineSound; irrklang::ISoundEngine* engineSound;
...@@ -40,6 +42,7 @@ private: ...@@ -40,6 +42,7 @@ private:
public: public:
bool Init(); bool Init();
void RefreshBGMList(); void RefreshBGMList();
void PlaySound(char* sound);
void PlaySoundEffect(int sound); void PlaySoundEffect(int sound);
void PlayDialogSound(irr::gui::IGUIElement * element); void PlayDialogSound(irr::gui::IGUIElement * element);
bool IsCurrentlyPlaying(char* song); bool IsCurrentlyPlaying(char* song);
......
Subproject commit 59563d732ecd7edf8a83d5547a3fbbf1dde2b44a Subproject commit cd8598dd962280fabc48971c5de0e434682bb1df
project "miniaudio" project "miniaudio"
kind "StaticLib" kind "StaticLib"
files { "extras/miniaudio_split/miniaudio.*" } files { "miniaudio.c", "miniaudio.h" }
defines { "MA_NO_ENCODING", "MA_NO_GENERATION", "MA_NO_NEON" } defines { "MA_NO_ENCODING", "MA_NO_GENERATION", "MA_NO_NEON" }
if MINIAUDIO_SUPPORT_OPUS_VORBIS then if MINIAUDIO_SUPPORT_OPUS_VORBIS then
......
Subproject commit 28782ebd949a70081a9f3c5c867d12cba80e756d 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