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