Commit 76db1bbd authored by nanahira's avatar nanahira

Merge remote-tracking branch 'fh/patch-miniaudio' of ../../ygopro into develop

parents f23bf474 204c769a
......@@ -12,6 +12,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-2019, windows-2022]
audiolib: [miniaudio, irrklang]
runs-on: ${{ matrix.os }}
......@@ -90,13 +91,72 @@ jobs:
7z x ${{ steps.sqlite.outputs.filepath }}
move sqlite-amalgamation-3490100 sqlite3
- name: Download miniaudio
if: matrix.audiolib == 'miniaudio'
run: |
git clone --depth=1 --branch 0.11.22 https://github.com/mackron/miniaudio
- name: Download ogg
if: matrix.audiolib == 'miniaudio'
id: ogg
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/xiph/ogg/releases/download/v1.3.5/libogg-1.3.5.tar.gz
- name: Extract ogg
if: matrix.audiolib == 'miniaudio'
run: |
tar xf ${{ steps.ogg.outputs.filepath }}
move libogg-1.3.5 miniaudio/external/ogg
- name: Download opus
if: matrix.audiolib == 'miniaudio'
id: opus
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/xiph/opus/releases/download/v1.5.2/opus-1.5.2.tar.gz
- name: Extract opus
if: matrix.audiolib == 'miniaudio'
run: |
tar xf ${{ steps.opus.outputs.filepath }}
move opus-1.5.2 miniaudio/external/opus
- name: Download opusfile
if: matrix.audiolib == 'miniaudio'
id: opusfile
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/xiph/opusfile/releases/download/v0.12/opusfile-0.12.tar.gz
- name: Extract opusfile
if: matrix.audiolib == 'miniaudio'
run: |
tar xf ${{ steps.opusfile.outputs.filepath }}
move opusfile-0.12 miniaudio/external/opusfile
- name: Download vorbis
if: matrix.audiolib == 'miniaudio'
id: vorbis
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/xiph/vorbis/releases/download/v1.3.7/libvorbis-1.3.7.tar.gz
- name: Extract vorbis
if: matrix.audiolib == 'miniaudio'
run: |
tar xf ${{ steps.vorbis.outputs.filepath }}
move libvorbis-1.3.7 miniaudio/external/vorbis
- name: Download irrKlang
if: matrix.audiolib == 'irrklang'
id: irrKlang
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://www.ambiera.at/downloads/irrKlang-32bit-1.6.0.zip
- name: Extract irrKlang
if: matrix.audiolib == 'irrklang'
run: |
7z x ${{ steps.irrKlang.outputs.filepath }}
move irrKlang-1.6.0 irrKlang
......@@ -132,17 +192,28 @@ jobs:
- name: Copy premake files
run: |
xcopy /E premake\* .
xcopy /E resource\* .
- name: Use premake to generate Visual Studio solution (2019)
if: matrix.os == 'windows-2019'
- name: Use premake to generate Visual Studio solution (2019, miniaudio)
if: matrix.os == 'windows-2019' && matrix.audiolib == 'miniaudio'
run: |
.\premake5.exe vs2019 --winxp-support
- name: Use premake to generate Visual Studio solution (2022)
if: matrix.os == 'windows-2022'
- name: Use premake to generate Visual Studio solution (2022, miniaudio)
if: matrix.os == 'windows-2022' && matrix.audiolib == 'miniaudio'
run: |
.\premake5.exe vs2022
- name: Use premake to generate Visual Studio solution (2019, irrKlang)
if: matrix.os == 'windows-2019' && matrix.audiolib == 'irrklang'
run: |
.\premake5.exe vs2019 --winxp-support --audio-lib=irrklang
- name: Use premake to generate Visual Studio solution (2022, irrKlang)
if: matrix.os == 'windows-2022' && matrix.audiolib == 'irrklang'
run: |
.\premake5.exe vs2022 --audio-lib=irrklang
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
......@@ -153,7 +224,7 @@ jobs:
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: YGOPro-${{ matrix.os }}
name: YGOPro-${{ matrix.os }}-${{ matrix.audiolib }}
path: |
bin/release/YGOPro.exe
......@@ -196,7 +267,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libevent-dev libfreetype6-dev libgl1-mesa-dev libglu1-mesa-dev libsqlite3-dev libxxf86vm-dev
sudo apt-get install -y libevent-dev libfreetype6-dev libgl1-mesa-dev libglu1-mesa-dev libsqlite3-dev libxxf86vm-dev libopusfile-dev libvorbis-dev
- name: Download premake
id: premake
......@@ -221,6 +292,10 @@ jobs:
tar xf ${{ steps.lua.outputs.filepath }}
mv lua-5.4.7 lua
- name: Download miniaudio
run: |
git clone --depth=1 --branch 0.11.22 https://github.com/mackron/miniaudio
- name: Download irrlicht
run: |
git clone --depth=1 https://github.com/mercury233/irrlicht
......@@ -228,12 +303,13 @@ jobs:
- name: Copy premake files
run: |
cp -r premake/* .
cp -r resource/* .
- name: Use premake to generate make files
run: |
./premake5 gmake \
--no-use-irrklang \
--freetype-include-dir="/usr/include/freetype2"
--freetype-include-dir="/usr/include/freetype2" \
--opus-include-dir="/usr/include/opus"
- name: Make
run: |
......@@ -281,9 +357,9 @@ jobs:
# git pull origin master
# cd ..
# - name: Install dependencies
# run: |
# brew install freetype libevent libx11 sqlite zlib
- name: Install dependencies
run: |
brew install freetype libevent libx11 sqlite opus opusfile libvorbis
- name: Download premake
id: premake
......@@ -308,6 +384,10 @@ jobs:
tar xf ${{ steps.lua.outputs.filepath }}
mv lua-5.4.7 lua
- name: Download miniaudio
run: |
git clone --depth=1 --branch 0.11.22 https://github.com/mackron/miniaudio
- name: Download irrlicht
run: |
git clone --depth=1 https://github.com/mercury233/irrlicht
......@@ -321,14 +401,15 @@ jobs:
- name: Copy premake files
run: |
cp -r premake/* .
cp -r resource/* .
- name: Use premake to generate make files (Intel)
if: runner.arch == 'X64'
run: |
./premake5 gmake \
--cc=clang \
--no-use-irrklang \
--freetype-include-dir="/usr/local/include/freetype2" \
--opus-include-dir="/usr/local/include/opus" \
--irrlicht-include-dir="../irrlicht/include" \
--irrlicht-lib-dir="../irrlicht/source/Irrlicht/MacOSX/build/Release"
......@@ -337,13 +418,18 @@ jobs:
run: |
./premake5 gmake \
--cc=clang \
--no-use-irrklang \
--event-include-dir="/opt/homebrew/include" \
--event-lib-dir="/opt/homebrew/lib" \
--freetype-include-dir="/opt/homebrew/include/freetype2" \
--freetype-lib-dir="/opt/homebrew/lib" \
--sqlite-include-dir="/opt/homebrew/opt/sqlite/include" \
--sqlite-lib-dir="/opt/homebrew/opt/sqlite/lib" \
--miniaudio-include-dir="/opt/homebrew/include" \
--miniaudio-lib-dir="/opt/homebrew/lib" \
--opus-include-dir="/opt/homebrew/include/opus" \
--opus-lib-dir="/opt/homebrew/lib" \
--vorbis-include-dir="/opt/homebrew/include" \
--vorbis-lib-dir="/opt/homebrew/lib" \
--irrlicht-include-dir="../irrlicht/include" \
--irrlicht-lib-dir="../irrlicht/source/Irrlicht/MacOSX/build/Release"
......
......@@ -30,6 +30,7 @@
/irrklang
/ikpmp3
/lua
/miniaudio
/sqlite3
/gframe/*.ico
/gframe/ygopro.rc
......
......@@ -75,7 +75,7 @@ static unsigned int checkAvail(unsigned int ot, unsigned int avail) {
return DECKERROR_TCGONLY;
return DECKERROR_NOTAVAIL;
}
unsigned int DeckManager::CheckDeck(Deck& deck, int lfhash, int rule) {
unsigned int DeckManager::CheckDeck(const Deck& deck, unsigned int lfhash, int rule) {
std::unordered_map<int, int> ccount;
// rule
if(deck.main.size() < DECK_MIN_SIZE || deck.main.size() > DECK_MAX_SIZE)
......
......@@ -46,7 +46,7 @@ public:
void LoadLFList();
const wchar_t* GetLFListName(unsigned int lfhash);
const LFList* GetLFList(unsigned int lfhash);
unsigned int CheckDeck(Deck& deck, int lfhash, int rule);
unsigned int CheckDeck(const Deck& deck, unsigned int lfhash, int rule);
int LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec, bool is_packlist = false);
int LoadDeck(Deck& deck, std::istringstream& deckStream, bool is_packlist = false);
bool LoadSide(Deck& deck, int* dbuf, int mainc, int sidec);
......
......@@ -1898,12 +1898,14 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return true;
break;
}
#ifdef YGOPRO_USE_AUDIO
case CHECKBOX_ENABLE_MUSIC: {
if(!mainGame->chkEnableMusic->isChecked())
soundManager.StopBGM();
return true;
break;
}
#endif
case CHECKBOX_DISABLE_CHAT: {
bool show = (mainGame->is_building && !mainGame->is_siding) ? false : !mainGame->chkIgnore1->isChecked();
mainGame->wChat->setVisible(show);
......@@ -1996,6 +1998,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return true;
break;
}
#ifdef YGOPRO_USE_AUDIO
case SCROLL_VOLUME: {
mainGame->gameConf.sound_volume = (double)mainGame->scrSoundVolume->getPos() / 100;
mainGame->gameConf.music_volume = (double)mainGame->scrMusicVolume->getPos() / 100;
......@@ -2004,6 +2007,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return true;
break;
}
#endif
case SCROLL_TAB_HELPER: {
irr::core::rect<irr::s32> pos = mainGame->tabHelper->getRelativePosition();
mainGame->tabHelper->setRelativePosition(irr::core::recti(0, mainGame->scrTabHelper->getPos() * -1, pos.LowerRightCorner.X, pos.LowerRightCorner.Y));
......
......@@ -1437,7 +1437,7 @@ void Game::LoadConfig() {
gameConf.window_height = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "resize_popup_menu")) {
gameConf.resize_popup_menu = std::strtol(valbuf, nullptr, 10) > 0;
#ifdef YGOPRO_USE_IRRKLANG
#ifdef YGOPRO_USE_AUDIO
} else if(!std::strcmp(strbuf, "enable_sound")) {
gameConf.enable_sound = std::strtol(valbuf, nullptr, 10) > 0;
} else if(!std::strcmp(strbuf, "sound_volume")) {
......@@ -1542,7 +1542,7 @@ void Game::SaveConfig() {
std::fprintf(fp, "window_width = %d\n", gameConf.window_width);
std::fprintf(fp, "window_height = %d\n", gameConf.window_height);
std::fprintf(fp, "resize_popup_menu = %d\n", gameConf.resize_popup_menu ? 1 : 0);
#ifdef YGOPRO_USE_IRRKLANG
#ifdef YGOPRO_USE_AUDIO
std::fprintf(fp, "enable_sound = %d\n", (chkEnableSound->isChecked() ? 1 : 0));
std::fprintf(fp, "enable_music = %d\n", (chkEnableMusic->isChecked() ? 1 : 0));
std::fprintf(fp, "#Volume of sound and music, between 0 and 100\n");
......
......@@ -4,15 +4,12 @@ include "spmemvfs/."
project "YGOPro"
kind "WindowedApp"
cppdialect "C++14"
rtti "Off"
files { "*.cpp", "*.h" }
includedirs { "../ocgcore" }
links { "ocgcore", "clzma", "cspmemvfs", LUA_LIB_NAME, "sqlite3", "irrlicht", "freetype", "event" }
if BUILD_IKPMP3 then
links { "ikpmp3" }
end
if BUILD_EVENT then
includedirs { "../event/include" }
else
......@@ -41,11 +38,30 @@ project "YGOPro"
libdirs { SQLITE_LIB_DIR }
end
if USE_IRRKLANG then
defines { "YGOPRO_USE_IRRKLANG" }
includedirs { IRRKLANG_INCLUDE_DIR }
if not IRRKLANG_PRO then
libdirs { IRRKLANG_LIB_DIR }
if USE_AUDIO then
defines { "YGOPRO_USE_AUDIO" }
if AUDIO_LIB == "miniaudio" then
defines { "YGOPRO_USE_MINIAUDIO" }
includedirs { "../miniaudio/extras/miniaudio_split" }
links { "miniaudio" }
if MINIAUDIO_SUPPORT_OPUS_VORBIS then
defines { "YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS" }
includedirs { "../miniaudio/extras/decoders/libopus", "../miniaudio/extras/decoders/libvorbis" }
if not MINIAUDIO_BUILD_OPUS_VORBIS then
links { "opusfile", "vorbisfile", "opus", "vorbis", "ogg" }
libdirs { OPUS_LIB_DIR, VORBIS_LIB_DIR, OGG_LIBDIR }
end
end
end
if AUDIO_LIB == "irrklang" then
defines { "YGOPRO_USE_IRRKLANG" }
includedirs { IRRKLANG_INCLUDE_DIR }
if not IRRKLANG_PRO then
libdirs { IRRKLANG_LIB_DIR }
end
if IRRKLANG_PRO_BUILD_IKPMP3 then
links { "ikpmp3" }
end
end
end
......@@ -53,7 +69,8 @@ project "YGOPro"
defines { "_IRR_WCHAR_FILESYSTEM" }
files "ygopro.rc"
libdirs { "$(DXSDK_DIR)Lib/x86" }
if USE_IRRKLANG then
links { "opengl32", "ws2_32", "winmm", "gdi32", "kernel32", "user32", "imm32" }
if USE_AUDIO and AUDIO_LIB == "irrklang" then
links { "irrKlang" }
if IRRKLANG_PRO then
defines { "IRRKLANG_STATIC" }
......@@ -64,9 +81,6 @@ project "YGOPro"
filter {}
end
end
links { "opengl32", "ws2_32", "winmm", "gdi32", "kernel32", "user32", "imm32" }
filter "not action:vs*"
buildoptions { "-fno-rtti" }
filter "not system:windows"
links { "event_pthreads", "dl", "pthread" }
filter "system:macosx"
......@@ -76,12 +90,12 @@ project "YGOPro"
buildoptions { "--target=arm64-apple-macos12" }
linkoptions { "-arch arm64" }
end
if USE_IRRKLANG then
if USE_AUDIO and AUDIO_LIB == "irrklang" then
links { "irrklang" }
end
filter "system:linux"
links { "GL", "X11", "Xxf86vm" }
if USE_IRRKLANG then
if USE_AUDIO and AUDIO_LIB == "irrklang" then
links { "IrrKlang" }
linkoptions{ IRRKLANG_LINK_RPATH }
end
#include "sound_manager.h"
#include "myfilesystem.h"
#ifdef YGOPRO_USE_IRRKLANG
#if defined(YGOPRO_USE_MINIAUDIO) && defined(YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS)
#include <miniaudio_libopus.h>
#include <miniaudio_libvorbis.h>
#endif
#ifdef IRRKLANG_STATIC
#include "../ikpmp3/ikpMP3.h"
#endif
......@@ -9,10 +13,34 @@ namespace ygo {
SoundManager soundManager;
bool SoundManager::Init() {
#ifdef YGOPRO_USE_IRRKLANG
#ifdef YGOPRO_USE_AUDIO
bgm_scene = -1;
RefreshBGMList();
rnd.reset((unsigned int)std::time(nullptr));
#ifdef YGOPRO_USE_MINIAUDIO
engineConfig = ma_engine_config_init();
#ifdef YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS
ma_decoding_backend_vtable* pCustomBackendVTables[] =
{
ma_decoding_backend_libvorbis,
ma_decoding_backend_libopus
};
resourceManagerConfig = ma_resource_manager_config_init();
resourceManagerConfig.ppCustomDecodingBackendVTables = pCustomBackendVTables;
resourceManagerConfig.customDecodingBackendCount = sizeof(pCustomBackendVTables) / sizeof(pCustomBackendVTables[0]);
resourceManagerConfig.pCustomDecodingBackendUserData = NULL;
if(ma_resource_manager_init(&resourceManagerConfig, &resourceManager) != MA_SUCCESS) {
return false;
}
engineConfig.pResourceManager = &resourceManager;
#endif
if(ma_engine_init(&engineConfig, &engineSound) != MA_SUCCESS || ma_engine_init(&engineConfig, &engineMusic) != MA_SUCCESS) {
return false;
} else {
return true;
}
#endif // YGOPRO_USE_MINIAUDIO
#ifdef YGOPRO_USE_IRRKLANG
engineSound = irrklang::createIrrKlangDevice();
engineMusic = irrklang::createIrrKlangDevice();
if(!engineSound || !engineMusic) {
......@@ -24,10 +52,11 @@ bool SoundManager::Init() {
return true;
}
#endif // YGOPRO_USE_IRRKLANG
// TODO: Implement other sound engines
#endif // YGOPRO_USE_AUDIO
return false;
}
void SoundManager::RefreshBGMList() {
#ifdef YGOPRO_USE_AUDIO
RefershBGMDir(L"", BGM_DUEL);
RefershBGMDir(L"duel", BGM_DUEL);
RefershBGMDir(L"menu", BGM_MENU);
......@@ -36,11 +65,17 @@ void SoundManager::RefreshBGMList() {
RefershBGMDir(L"disadvantage", BGM_DISADVANTAGE);
RefershBGMDir(L"win", BGM_WIN);
RefershBGMDir(L"lose", BGM_LOSE);
#endif
}
void SoundManager::RefershBGMDir(std::wstring path, int scene) {
std::wstring search = L"./sound/BGM/" + path;
FileSystem::TraversalDir(search.c_str(), [this, &path, scene](const wchar_t* name, bool isdir) {
if(!isdir && (IsExtension(name, L".mp3") || IsExtension(name, L".ogg"))) {
if(!isdir && (
IsExtension(name, L".mp3")
#if defined(YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS) || defined(YGOPRO_USE_IRRKLANG)
|| IsExtension(name, L".ogg")
#endif
)) {
std::wstring filename = path + L"/" + name;
BGMList[BGM_ALL].push_back(filename);
BGMList[scene].push_back(filename);
......@@ -48,135 +83,145 @@ void SoundManager::RefershBGMDir(std::wstring path, int scene) {
});
}
void SoundManager::PlaySoundEffect(int sound) {
#ifdef YGOPRO_USE_IRRKLANG
#ifdef YGOPRO_USE_AUDIO
if(!mainGame->chkEnableSound->isChecked())
return;
engineSound->setSoundVolume(mainGame->gameConf.sound_volume);
char soundName[32];
switch(sound) {
case SOUND_SUMMON: {
engineSound->play2D("./sound/summon.wav");
strcpy(soundName, "summon");
break;
}
case SOUND_SPECIAL_SUMMON: {
engineSound->play2D("./sound/specialsummon.wav");
strcpy(soundName, "specialsummon");
break;
}
case SOUND_ACTIVATE: {
engineSound->play2D("./sound/activate.wav");
strcpy(soundName, "activate");
break;
}
case SOUND_SET: {
engineSound->play2D("./sound/set.wav");
strcpy(soundName, "set");
break;
}
case SOUND_FILP: {
engineSound->play2D("./sound/flip.wav");
strcpy(soundName, "flip");
break;
}
case SOUND_REVEAL: {
engineSound->play2D("./sound/reveal.wav");
strcpy(soundName, "reveal");
break;
}
case SOUND_EQUIP: {
engineSound->play2D("./sound/equip.wav");
strcpy(soundName, "equip");
break;
}
case SOUND_DESTROYED: {
engineSound->play2D("./sound/destroyed.wav");
strcpy(soundName, "destroyed");
break;
}
case SOUND_BANISHED: {
engineSound->play2D("./sound/banished.wav");
strcpy(soundName, "banished");
break;
}
case SOUND_TOKEN: {
engineSound->play2D("./sound/token.wav");
strcpy(soundName, "token");
break;
}
case SOUND_ATTACK: {
engineSound->play2D("./sound/attack.wav");
strcpy(soundName, "attack");
break;
}
case SOUND_DIRECT_ATTACK: {
engineSound->play2D("./sound/directattack.wav");
strcpy(soundName, "directattack");
break;
}
case SOUND_DRAW: {
engineSound->play2D("./sound/draw.wav");
strcpy(soundName, "draw");
break;
}
case SOUND_SHUFFLE: {
engineSound->play2D("./sound/shuffle.wav");
strcpy(soundName, "shuffle");
break;
}
case SOUND_DAMAGE: {
engineSound->play2D("./sound/damage.wav");
strcpy(soundName, "damage");
break;
}
case SOUND_RECOVER: {
engineSound->play2D("./sound/gainlp.wav");
strcpy(soundName, "recover");
break;
}
case SOUND_COUNTER_ADD: {
engineSound->play2D("./sound/addcounter.wav");
strcpy(soundName, "addcounter");
break;
}
case SOUND_COUNTER_REMOVE: {
engineSound->play2D("./sound/removecounter.wav");
strcpy(soundName, "removecounter");
break;
}
case SOUND_COIN: {
engineSound->play2D("./sound/coinflip.wav");
strcpy(soundName, "coin");
break;
}
case SOUND_DICE: {
engineSound->play2D("./sound/diceroll.wav");
strcpy(soundName, "dice");
break;
}
case SOUND_NEXT_TURN: {
engineSound->play2D("./sound/nextturn.wav");
strcpy(soundName, "nextturn");
break;
}
case SOUND_PHASE: {
engineSound->play2D("./sound/phase.wav");
strcpy(soundName, "phase");
break;
}
case SOUND_MENU: {
engineSound->play2D("./sound/menu.wav");
strcpy(soundName, "menu");
break;
}
case SOUND_BUTTON: {
engineSound->play2D("./sound/button.wav");
strcpy(soundName, "button");
break;
}
case SOUND_INFO: {
engineSound->play2D("./sound/info.wav");
strcpy(soundName, "info");
break;
}
case SOUND_QUESTION: {
engineSound->play2D("./sound/question.wav");
strcpy(soundName, "question");
break;
}
case SOUND_CARD_PICK: {
engineSound->play2D("./sound/cardpick.wav");
strcpy(soundName, "cardpick");
break;
}
case SOUND_CARD_DROP: {
engineSound->play2D("./sound/carddrop.wav");
strcpy(soundName, "carddrop");
break;
}
case SOUND_PLAYER_ENTER: {
engineSound->play2D("./sound/playerenter.wav");
strcpy(soundName, "playerenter");
break;
}
case SOUND_CHAT: {
engineSound->play2D("./sound/chatmessage.wav");
strcpy(soundName, "chat");
break;
}
default:
break;
}
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
#endif // YGOPRO_USE_AUDIO
}
void SoundManager::PlayDialogSound(irr::gui::IGUIElement * element) {
if(element == mainGame->wMessage) {
......@@ -201,25 +246,47 @@ void SoundManager::PlayDialogSound(irr::gui::IGUIElement * element) {
PlaySoundEffect(SOUND_QUESTION);
}
}
void SoundManager::PlayMusic(char* song, bool loop) {
bool SoundManager::IsCurrentlyPlaying(char* song) {
#ifdef YGOPRO_USE_MINIAUDIO
return currentPlayingMusic[0] && strcmp(currentPlayingMusic, song) == 0 && ma_sound_is_playing(&soundBGM);
#endif
#ifdef YGOPRO_USE_IRRKLANG
return engineMusic->isCurrentlyPlaying(song);
#endif
return false;
}
void SoundManager::PlayMusic(char* song, bool loop) {
#ifdef YGOPRO_USE_AUDIO
if(!mainGame->chkEnableMusic->isChecked())
return;
if(!engineMusic->isCurrentlyPlaying(song)) {
if(!IsCurrentlyPlaying(song)) {
StopBGM();
#ifdef YGOPRO_USE_MINIAUDIO
strcpy(currentPlayingMusic, song);
ma_sound_init_from_file(&engineMusic, song, MA_SOUND_FLAG_ASYNC | MA_SOUND_FLAG_STREAM, nullptr, nullptr, &soundBGM);
ma_sound_set_looping(&soundBGM, 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
}
#endif
}
void SoundManager::PlayBGM(int scene) {
#ifdef YGOPRO_USE_IRRKLANG
#ifdef YGOPRO_USE_AUDIO
if(!mainGame->chkEnableMusic->isChecked())
return;
if(!mainGame->chkMusicMode->isChecked())
scene = BGM_ALL;
char BGMName[1024];
#if defined(YGOPRO_USE_MINIAUDIO)
if(scene != bgm_scene || !IsCurrentlyPlaying(currentPlayingMusic)) {
#elif defined(YGOPRO_USE_IRRKLANG)
if(scene != bgm_scene || (soundBGM && soundBGM->isFinished())) {
#endif
int count = BGMList[scene].size();
if(count <= 0)
return;
......@@ -234,16 +301,28 @@ void SoundManager::PlayBGM(int scene) {
#endif
}
void SoundManager::StopBGM() {
#ifdef YGOPRO_USE_MINIAUDIO
if(!currentPlayingMusic[0])
return;
memset(currentPlayingMusic, 0, sizeof(currentPlayingMusic));
ma_sound_uninit(&soundBGM);
#endif
#ifdef YGOPRO_USE_IRRKLANG
engineMusic->stopAllSounds();
#endif
}
void SoundManager::SetSoundVolume(double volume) {
#ifdef YGOPRO_USE_MINIAUDIO
ma_engine_set_volume(&engineSound, volume);
#endif
#ifdef YGOPRO_USE_IRRKLANG
engineSound->setSoundVolume(volume);
#endif
}
void SoundManager::SetMusicVolume(double volume) {
#ifdef YGOPRO_USE_MINIAUDIO
ma_engine_set_volume(&engineMusic, volume);
#endif
#ifdef YGOPRO_USE_IRRKLANG
engineMusic->setSoundVolume(volume);
#endif
......
......@@ -3,6 +3,9 @@
#include "game.h"
#include "../ocgcore/mtrandom.h"
#ifdef YGOPRO_USE_MINIAUDIO
#include <miniaudio.h>
#endif
#ifdef YGOPRO_USE_IRRKLANG
#include <irrKlang.h>
#endif
......@@ -14,6 +17,17 @@ private:
std::vector<std::wstring> BGMList[8];
int bgm_scene;
mt19937 rnd;
#ifdef YGOPRO_USE_MINIAUDIO
ma_engine_config engineConfig;
#ifdef YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS
ma_resource_manager_config resourceManagerConfig;
ma_resource_manager resourceManager;
#endif
ma_engine engineSound;
ma_engine engineMusic;
ma_sound soundBGM;
char currentPlayingMusic[1024]{};
#endif
#ifdef YGOPRO_USE_IRRKLANG
irrklang::ISoundEngine* engineSound;
irrklang::ISoundEngine* engineMusic;
......@@ -26,6 +40,7 @@ public:
void RefreshBGMList();
void PlaySoundEffect(int sound);
void PlayDialogSound(irr::gui::IGUIElement * element);
bool IsCurrentlyPlaying(char* song);
void PlayMusic(char* song, bool loop);
void PlayBGM(int scene);
void StopBGM();
......
project "event"
kind "StaticLib"
cdialect "C11"
includedirs { "include", "compat" }
......
project "freetype"
kind "StaticLib"
cdialect "C11"
includedirs { "include" }
defines { "FT2_BUILD_LIBRARY" }
......
defines {
"_IRR_STATIC_LIB_",
"NO_IRR_USE_NON_SYSTEM_BZLIB_",
"NO_IRR_COMPILE_WITH_BZIP2_",
"NO_IRR_COMPILE_WITH_CONSOLE_DEVICE_",
"NO_IRR_COMPILE_WITH_DIRECT3D_8_",
"NO_IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_",
"NO_IRR_COMPILE_WITH_JOYSTICK_EVENTS_",
"NO_IRR_COMPILE_WITH_SOFTWARE_",
"NO_IRR_COMPILE_WITH_BURNINGSVIDEO_",
"NO_IRR_COMPILE_WITH_IRR_SCENE_LOADER_",
"NO_IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_",
"NO_IRR_COMPILE_WITH_IRR_MESH_LOADER_",
"NO_IRR_COMPILE_WITH_HALFLIFE_LOADER_",
"NO_IRR_COMPILE_WITH_MD2_LOADER_",
"NO_IRR_COMPILE_WITH_MD3_LOADER_",
"NO_IRR_COMPILE_WITH_3DS_LOADER_",
"NO_IRR_COMPILE_WITH_COLLADA_LOADER_",
"NO_IRR_COMPILE_WITH_CSM_LOADER_",
"NO_IRR_COMPILE_WITH_BSP_LOADER_",
"NO_IRR_COMPILE_WITH_DMF_LOADER_",
"NO_IRR_COMPILE_WITH_LMTS_LOADER_",
"NO_IRR_COMPILE_WITH_MY3D_LOADER_",
"NO_IRR_COMPILE_WITH_OBJ_LOADER_",
"NO_IRR_COMPILE_WITH_OCT_LOADER_",
"NO_IRR_COMPILE_WITH_LWO_LOADER_",
"NO_IRR_COMPILE_WITH_STL_LOADER_",
"NO_IRR_COMPILE_WITH_PLY_LOADER_",
"NO_IRR_COMPILE_WITH_SMF_LOADER_",
"NO_IRR_COMPILE_WITH_IRR_WRITER_",
"NO_IRR_COMPILE_WITH_COLLADA_WRITER_",
"NO_IRR_COMPILE_WITH_STL_WRITER_",
"NO_IRR_COMPILE_WITH_OBJ_WRITER_",
"NO_IRR_COMPILE_WITH_PLY_WRITER_",
"NO_IRR_COMPILE_WITH_PCX_LOADER_",
"NO_IRR_COMPILE_WITH_PPM_LOADER_",
"NO_IRR_COMPILE_WITH_PSD_LOADER_",
"NO_IRR_COMPILE_WITH_TGA_LOADER_",
"NO_IRR_COMPILE_WITH_WAL_LOADER_",
"NO_IRR_COMPILE_WITH_LMP_LOADER_",
"NO_IRR_COMPILE_WITH_RGB_LOADER_",
"NO_IRR_COMPILE_WITH_PCX_WRITER_",
"NO_IRR_COMPILE_WITH_PPM_WRITER_",
"NO_IRR_COMPILE_WITH_PSD_WRITER_",
"NO_IRR_COMPILE_WITH_TGA_WRITER_",
"NO__IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_",
"NO__IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_",
"NO__IRR_COMPILE_WITH_WAD_ARCHIVE_LOADER_",
}
project "irrlicht"
kind "StaticLib"
cdialect "C11"
includedirs { "include", "source/Irrlicht", "source/Irrlicht/jpeglib", "source/Irrlicht/libpng", "source/Irrlicht/zlib" }
defines { "_IRR_STATIC_LIB_" }
dofile("defines.lua")
exceptionhandling "Off"
rtti "Off"
files { "source/Irrlicht/CCgMaterialRenderer.cpp",
"source/Irrlicht/CD3D9CgMaterialRenderer.cpp",
"source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp",
"source/Irrlicht/CDefaultSceneNodeFactory.cpp",
"source/Irrlicht/CGeometryCreator.cpp",
"source/Irrlicht/CMeshCache.cpp",
"source/Irrlicht/CMeshManipulator.cpp",
"source/Irrlicht/COpenGLCgMaterialRenderer.cpp",
"source/Irrlicht/CSceneManager.cpp",
"source/Irrlicht/C3DSMeshFileLoader.cpp",
"source/Irrlicht/CSMFMeshFileLoader.cpp",
"source/Irrlicht/CAnimatedMeshHalfLife.cpp",
"source/Irrlicht/CAnimatedMeshMD2.cpp",
"source/Irrlicht/CAnimatedMeshMD3.cpp",
"source/Irrlicht/CB3DMeshFileLoader.cpp",
"source/Irrlicht/CBSPMeshFileLoader.cpp",
"source/Irrlicht/CColladaFileLoader.cpp",
"source/Irrlicht/CCSMLoader.cpp",
"source/Irrlicht/CDMFLoader.cpp",
"source/Irrlicht/CIrrMeshFileLoader.cpp",
"source/Irrlicht/CLMTSMeshFileLoader.cpp",
"source/Irrlicht/CLWOMeshFileLoader.cpp",
"source/Irrlicht/CMD2MeshFileLoader.cpp",
"source/Irrlicht/CMD3MeshFileLoader.cpp",
"source/Irrlicht/CMS3DMeshFileLoader.cpp",
"source/Irrlicht/CMY3DMeshFileLoader.cpp",
"source/Irrlicht/COBJMeshFileLoader.cpp",
"source/Irrlicht/COCTLoader.cpp",
"source/Irrlicht/COgreMeshFileLoader.cpp",
"source/Irrlicht/CPLYMeshFileLoader.cpp",
"source/Irrlicht/CQ3LevelMesh.cpp",
"source/Irrlicht/CSkinnedMesh.cpp",
"source/Irrlicht/CSTLMeshFileLoader.cpp",
"source/Irrlicht/CXMeshFileLoader.cpp",
"source/Irrlicht/CAnimatedMeshSceneNode.cpp",
"source/Irrlicht/CBillboardSceneNode.cpp",
"source/Irrlicht/CBoneSceneNode.cpp",
"source/Irrlicht/CCameraSceneNode.cpp",
"source/Irrlicht/CCubeSceneNode.cpp",
"source/Irrlicht/CDummyTransformationSceneNode.cpp",
"source/Irrlicht/CEmptySceneNode.cpp",
"source/Irrlicht/CLightSceneNode.cpp",
"source/Irrlicht/CMeshSceneNode.cpp",
"source/Irrlicht/COctreeSceneNode.cpp",
"source/Irrlicht/CQuake3ShaderSceneNode.cpp",
"source/Irrlicht/CShadowVolumeSceneNode.cpp",
"source/Irrlicht/CSkyBoxSceneNode.cpp",
"source/Irrlicht/CSkyDomeSceneNode.cpp",
"source/Irrlicht/CSphereSceneNode.cpp",
"source/Irrlicht/CTerrainSceneNode.cpp",
"source/Irrlicht/CTextSceneNode.cpp",
"source/Irrlicht/CVolumeLightSceneNode.cpp",
"source/Irrlicht/CWaterSurfaceSceneNode.cpp",
"source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp",
"source/Irrlicht/CParticleAttractionAffector.cpp",
"source/Irrlicht/CParticleBoxEmitter.cpp",
"source/Irrlicht/CParticleCylinderEmitter.cpp",
"source/Irrlicht/CParticleFadeOutAffector.cpp",
"source/Irrlicht/CParticleGravityAffector.cpp",
"source/Irrlicht/CParticleMeshEmitter.cpp",
"source/Irrlicht/CParticlePointEmitter.cpp",
"source/Irrlicht/CParticleRingEmitter.cpp",
"source/Irrlicht/CParticleRotationAffector.cpp",
"source/Irrlicht/CParticleScaleAffector.cpp",
"source/Irrlicht/CParticleSphereEmitter.cpp",
"source/Irrlicht/CParticleSystemSceneNode.cpp",
"source/Irrlicht/CMetaTriangleSelector.cpp",
"source/Irrlicht/COctreeTriangleSelector.cpp",
"source/Irrlicht/CSceneCollisionManager.cpp",
"source/Irrlicht/CTerrainTriangleSelector.cpp",
"source/Irrlicht/CTriangleBBSelector.cpp",
"source/Irrlicht/CTriangleSelector.cpp",
"source/Irrlicht/CSceneLoaderIrr.cpp",
"source/Irrlicht/CSceneNodeAnimatorCameraFPS.cpp",
"source/Irrlicht/CSceneNodeAnimatorCameraMaya.cpp",
"source/Irrlicht/CSceneNodeAnimatorCollisionResponse.cpp",
"source/Irrlicht/CSceneNodeAnimatorDelete.cpp",
"source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp",
"source/Irrlicht/CSceneNodeAnimatorFlyStraight.cpp",
"source/Irrlicht/CSceneNodeAnimatorFollowSpline.cpp",
"source/Irrlicht/CSceneNodeAnimatorRotation.cpp",
"source/Irrlicht/CSceneNodeAnimatorTexture.cpp",
"source/Irrlicht/CColladaMeshWriter.cpp",
"source/Irrlicht/CIrrMeshWriter.cpp",
"source/Irrlicht/COBJMeshWriter.cpp",
"source/Irrlicht/CPLYMeshWriter.cpp",
"source/Irrlicht/CSTLMeshWriter.cpp",
"source/Irrlicht/CVideoModeList.cpp",
"source/Irrlicht/CSoftwareDriver.cpp",
"source/Irrlicht/CSoftwareTexture.cpp",
"source/Irrlicht/CTRFlat.cpp",
"source/Irrlicht/CTRFlatWire.cpp",
"source/Irrlicht/CTRGouraud.cpp",
"source/Irrlicht/CTRGouraudWire.cpp",
"source/Irrlicht/CTRTextureFlat.cpp",
"source/Irrlicht/CTRTextureFlatWire.cpp",
"source/Irrlicht/CTRTextureGouraud.cpp",
"source/Irrlicht/CTRTextureGouraudAdd.cpp",
"source/Irrlicht/CTRTextureGouraudNoZ.cpp",
"source/Irrlicht/CTRTextureGouraudWire.cpp",
"source/Irrlicht/CZBuffer.cpp",
"source/Irrlicht/COpenGLDriver.cpp",
"source/Irrlicht/COpenGLExtensionHandler.cpp",
"source/Irrlicht/COpenGLNormalMapRenderer.cpp",
"source/Irrlicht/COpenGLParallaxMapRenderer.cpp",
"source/Irrlicht/COpenGLShaderMaterialRenderer.cpp",
"source/Irrlicht/COpenGLSLMaterialRenderer.cpp",
"source/Irrlicht/COpenGLTexture.cpp",
"source/Irrlicht/CD3D8Driver.cpp",
"source/Irrlicht/CD3D8NormalMapRenderer.cpp",
"source/Irrlicht/CD3D8ParallaxMapRenderer.cpp",
"source/Irrlicht/CD3D8ShaderMaterialRenderer.cpp",
"source/Irrlicht/CD3D8Texture.cpp",
"source/Irrlicht/CColorConverter.cpp",
"source/Irrlicht/CFPSCounter.cpp",
"source/Irrlicht/CImage.cpp",
"source/Irrlicht/CNullDriver.cpp",
"source/Irrlicht/CImageWriterBMP.cpp",
"source/Irrlicht/CImageWriterJPG.cpp",
"source/Irrlicht/CImageWriterPCX.cpp",
"source/Irrlicht/CImageWriterPNG.cpp",
"source/Irrlicht/CImageWriterPPM.cpp",
"source/Irrlicht/CImageWriterPSD.cpp",
"source/Irrlicht/CImageWriterTGA.cpp",
"source/Irrlicht/CImageLoaderBMP.cpp",
"source/Irrlicht/CImageLoaderDDS.cpp",
"source/Irrlicht/CImageLoaderJPG.cpp",
"source/Irrlicht/CImageLoaderPCX.cpp",
"source/Irrlicht/CImageLoaderPNG.cpp",
"source/Irrlicht/CImageLoaderPPM.cpp",
"source/Irrlicht/CImageLoaderPSD.cpp",
"source/Irrlicht/CImageLoaderRGB.cpp",
"source/Irrlicht/CImageLoaderTGA.cpp",
"source/Irrlicht/CImageLoaderWAL.cpp",
"source/Irrlicht/CD3D9Driver.cpp",
"source/Irrlicht/CD3D9HLSLMaterialRenderer.cpp",
"source/Irrlicht/CD3D9NormalMapRenderer.cpp",
"source/Irrlicht/CD3D9ParallaxMapRenderer.cpp",
"source/Irrlicht/CD3D9ShaderMaterialRenderer.cpp",
"source/Irrlicht/CD3D9Texture.cpp",
"source/Irrlicht/CBurningShader_Raster_Reference.cpp",
"source/Irrlicht/CDepthBuffer.cpp",
"source/Irrlicht/CSoftwareDriver2.cpp",
"source/Irrlicht/CSoftwareTexture2.cpp",
"source/Irrlicht/CTRGouraud2.cpp",
"source/Irrlicht/CTRGouraudAlpha2.cpp",
"source/Irrlicht/CTRGouraudAlphaNoZ2.cpp",
"source/Irrlicht/CTRNormalMap.cpp",
"source/Irrlicht/CTRStencilShadow.cpp",
"source/Irrlicht/CTRTextureBlend.cpp",
"source/Irrlicht/CTRTextureDetailMap2.cpp",
"source/Irrlicht/CTRTextureGouraud2.cpp",
"source/Irrlicht/CTRTextureGouraudAdd2.cpp",
"source/Irrlicht/CTRTextureGouraudAddNoZ2.cpp",
"source/Irrlicht/CTRTextureGouraudAlpha.cpp",
"source/Irrlicht/CTRTextureGouraudAlphaNoZ.cpp",
"source/Irrlicht/CTRTextureGouraudNoZ2.cpp",
"source/Irrlicht/CTRTextureGouraudVertexAlpha2.cpp",
"source/Irrlicht/CTRTextureLightMap2_Add.cpp",
"source/Irrlicht/CTRTextureLightMap2_M1.cpp",
"source/Irrlicht/CTRTextureLightMap2_M2.cpp",
"source/Irrlicht/CTRTextureLightMap2_M4.cpp",
"source/Irrlicht/CTRTextureLightMapGouraud2_M4.cpp",
"source/Irrlicht/CTRTextureWire2.cpp",
"source/Irrlicht/IBurningShader.cpp",
"source/Irrlicht/CLogger.cpp",
"source/Irrlicht/COSOperator.cpp",
"source/Irrlicht/Irrlicht.cpp",
"source/Irrlicht/os.cpp",
"source/Irrlicht/lzma/LzmaDec.c",
files { "include/*.h",
"source/Irrlicht/*.cpp",
"source/Irrlicht/lzma/*.h",
"source/Irrlicht/lzma/*.c",
"source/Irrlicht/zlib/zlib.h",
"source/Irrlicht/zlib/adler32.c",
"source/Irrlicht/zlib/compress.c",
"source/Irrlicht/zlib/crc32.h",
"source/Irrlicht/zlib/crc32.c",
"source/Irrlicht/zlib/deflate.h",
"source/Irrlicht/zlib/deflate.c",
"source/Irrlicht/zlib/inffast.h",
"source/Irrlicht/zlib/inffast.c",
"source/Irrlicht/zlib/inflate.h",
"source/Irrlicht/zlib/inflate.c",
"source/Irrlicht/zlib/inftrees.h",
"source/Irrlicht/zlib/inftrees.c",
"source/Irrlicht/zlib/trees.h",
"source/Irrlicht/zlib/trees.c",
"source/Irrlicht/zlib/uncompr.c",
"source/Irrlicht/zlib/zutil.h",
"source/Irrlicht/zlib/zutil.c",
"source/Irrlicht/jpeglib/jaricom.c",
"source/Irrlicht/jpeglib/jcapimin.c",
......@@ -249,73 +90,8 @@ project "irrlicht"
"source/Irrlicht/libpng/pngwrite.c",
"source/Irrlicht/libpng/pngwtran.c",
"source/Irrlicht/libpng/pngwutil.c",
"source/Irrlicht/aesGladman/aescrypt.cpp",
"source/Irrlicht/aesGladman/aeskey.cpp",
"source/Irrlicht/aesGladman/aestab.cpp",
"source/Irrlicht/aesGladman/fileenc.cpp",
"source/Irrlicht/aesGladman/hmac.cpp",
"source/Irrlicht/aesGladman/prng.cpp",
"source/Irrlicht/aesGladman/pwd2key.cpp",
"source/Irrlicht/aesGladman/sha1.cpp",
"source/Irrlicht/aesGladman/sha2.cpp",
"source/Irrlicht/bzip2/blocksort.c",
"source/Irrlicht/bzip2/bzcompress.c",
"source/Irrlicht/bzip2/bzlib.c",
"source/Irrlicht/bzip2/crctable.c",
"source/Irrlicht/bzip2/decompress.c",
"source/Irrlicht/bzip2/huffman.c",
"source/Irrlicht/bzip2/randtable.c",
"source/Irrlicht/CIrrDeviceConsole.cpp",
"source/Irrlicht/CIrrDeviceFB.cpp",
"source/Irrlicht/CIrrDeviceLinux.cpp",
"source/Irrlicht/CIrrDeviceSDL.cpp",
"source/Irrlicht/CIrrDeviceStub.cpp",
"source/Irrlicht/CIrrDeviceWin32.cpp",
"source/Irrlicht/CIrrDeviceWinCE.cpp",
"source/Irrlicht/CAttributes.cpp",
"source/Irrlicht/CFileList.cpp",
"source/Irrlicht/CFileSystem.cpp",
"source/Irrlicht/CLimitReadFile.cpp",
"source/Irrlicht/CMemoryFile.cpp",
"source/Irrlicht/CMountPointReader.cpp",
"source/Irrlicht/CNPKReader.cpp",
"source/Irrlicht/CPakReader.cpp",
"source/Irrlicht/CReadFile.cpp",
"source/Irrlicht/CTarReader.cpp",
"source/Irrlicht/CWADReader.cpp",
"source/Irrlicht/CWriteFile.cpp",
"source/Irrlicht/CXMLReader.cpp",
"source/Irrlicht/CXMLWriter.cpp",
"source/Irrlicht/CZipReader.cpp",
"source/Irrlicht/irrXML.cpp",
"source/Irrlicht/CDefaultGUIElementFactory.cpp",
"source/Irrlicht/CGUIButton.cpp",
"source/Irrlicht/CGUICheckBox.cpp",
"source/Irrlicht/CGUIColorSelectDialog.cpp",
"source/Irrlicht/CGUIComboBox.cpp",
"source/Irrlicht/CGUIContextMenu.cpp",
"source/Irrlicht/CGUIEditBox.cpp",
"source/Irrlicht/CGUIEnvironment.cpp",
"source/Irrlicht/CGUIFileOpenDialog.cpp",
"source/Irrlicht/CGUIFont.cpp",
"source/Irrlicht/CGUIImage.cpp",
"source/Irrlicht/CGUIImageList.cpp",
"source/Irrlicht/CGUIInOutFader.cpp",
"source/Irrlicht/CGUIListBox.cpp",
"source/Irrlicht/CGUIMenu.cpp",
"source/Irrlicht/CGUIMeshViewer.cpp",
"source/Irrlicht/CGUIMessageBox.cpp",
"source/Irrlicht/CGUIModalScreen.cpp",
"source/Irrlicht/CGUIScrollBar.cpp",
"source/Irrlicht/CGUISkin.cpp",
"source/Irrlicht/CGUISpinBox.cpp",
"source/Irrlicht/CGUISpriteBank.cpp",
"source/Irrlicht/CGUIStaticText.cpp",
"source/Irrlicht/CGUITabControl.cpp",
"source/Irrlicht/CGUITable.cpp",
"source/Irrlicht/CGUIToolBar.cpp",
"source/Irrlicht/CGUITreeView.cpp",
"source/Irrlicht/CGUIWindow.cpp" }
"source/Irrlicht/aesGladman/*.h",
"source/Irrlicht/aesGladman/*.cpp" }
filter { "system:windows" }
defines { "_IRR_WCHAR_FILESYSTEM" }
......
project "miniaudio"
kind "StaticLib"
files { "extras/miniaudio_split/miniaudio.*" }
defines { "MA_NO_ENCODING", "MA_NO_GENERATION", "MA_NO_NEON" }
if MINIAUDIO_SUPPORT_OPUS_VORBIS then
files { "extras/decoders/libopus/*", "extras/decoders/libvorbis/*" }
if MINIAUDIO_BUILD_OPUS_VORBIS then
files {
"external/ogg/src/bitwise.c",
"external/ogg/src/framing.c",
"external/opus/src/opus.c",
"external/opus/src/opus_decoder.c",
"external/opus/src/opus_multistream.c",
"external/opus/src/opus_multistream_decoder.c",
"external/opus/celt/bands.c",
"external/opus/celt/celt.c",
"external/opus/celt/celt_decoder.c",
"external/opus/celt/celt_lpc.c",
"external/opus/celt/cwrs.c",
"external/opus/celt/entcode.c",
"external/opus/celt/entdec.c",
"external/opus/celt/entenc.c",
"external/opus/celt/kiss_fft.c",
"external/opus/celt/laplace.c",
"external/opus/celt/mathops.c",
"external/opus/celt/mdct.c",
"external/opus/celt/modes.c",
"external/opus/celt/pitch.c",
"external/opus/celt/quant_bands.c",
"external/opus/celt/rate.c",
"external/opus/celt/vq.c",
"external/opus/celt/x86/pitch_avx.c",
"external/opus/celt/x86/pitch_sse.c",
"external/opus/celt/x86/vq_sse2.c",
"external/opus/celt/x86/x86_celt_map.c",
"external/opus/celt/x86/x86cpu.c",
"external/opus/silk/bwexpander.c",
"external/opus/silk/bwexpander_32.c",
"external/opus/silk/CNG.c",
"external/opus/silk/code_signs.c",
"external/opus/silk/dec_API.c",
"external/opus/silk/decode_core.c",
"external/opus/silk/decode_frame.c",
"external/opus/silk/decode_indices.c",
"external/opus/silk/decode_parameters.c",
"external/opus/silk/decode_pitch.c",
"external/opus/silk/decode_pulses.c",
"external/opus/silk/decoder_set_fs.c",
"external/opus/silk/gain_quant.c",
"external/opus/silk/init_decoder.c",
"external/opus/silk/lin2log.c",
"external/opus/silk/log2lin.c",
"external/opus/silk/LPC_analysis_filter.c",
"external/opus/silk/LPC_fit.c",
"external/opus/silk/LPC_inv_pred_gain.c",
"external/opus/silk/NLSF_decode.c",
"external/opus/silk/NLSF_stabilize.c",
"external/opus/silk/NLSF_unpack.c",
"external/opus/silk/NLSF2A.c",
"external/opus/silk/pitch_est_tables.c",
"external/opus/silk/PLC.c",
"external/opus/silk/resampler.c",
"external/opus/silk/resampler_private_AR2.c",
"external/opus/silk/resampler_private_down_FIR.c",
"external/opus/silk/resampler_private_IIR_FIR.c",
"external/opus/silk/resampler_private_up2_HQ.c",
"external/opus/silk/resampler_rom.c",
"external/opus/silk/shell_coder.c",
"external/opus/silk/sort.c",
"external/opus/silk/stereo_decode_pred.c",
"external/opus/silk/stereo_MS_to_LR.c",
"external/opus/silk/sum_sqr_shift.c",
"external/opus/silk/table_LSF_cos.c",
"external/opus/silk/tables_gain.c",
"external/opus/silk/tables_LTP.c",
"external/opus/silk/tables_NLSF_CB_NB_MB.c",
"external/opus/silk/tables_NLSF_CB_WB.c",
"external/opus/silk/tables_other.c",
"external/opus/silk/tables_pitch_lag.c",
"external/opus/silk/tables_pulses_per_block.c",
"external/opusfile/src/info.c",
"external/opusfile/src/internal.c",
"external/opusfile/src/opusfile.c",
"external/opusfile/src/stream.c",
"external/vorbis/lib/bitrate.c",
"external/vorbis/lib/block.c",
"external/vorbis/lib/codebook.c",
"external/vorbis/lib/envelope.c",
"external/vorbis/lib/floor0.c",
"external/vorbis/lib/floor1.c",
"external/vorbis/lib/info.c",
"external/vorbis/lib/lpc.c",
"external/vorbis/lib/lsp.c",
"external/vorbis/lib/mapping0.c",
"external/vorbis/lib/mdct.c",
"external/vorbis/lib/psy.c",
"external/vorbis/lib/registry.c",
"external/vorbis/lib/res0.c",
"external/vorbis/lib/sharedbook.c",
"external/vorbis/lib/smallft.c",
"external/vorbis/lib/synthesis.c",
"external/vorbis/lib/vorbisfile.c",
"external/vorbis/lib/window.c",
}
includedirs {
"external/ogg/include",
"external/opus/include",
"external/opus/celt",
"external/opus/silk",
"external/opusfile/include",
"external/vorbis/include",
}
defines {
"OPUS_BUILD", "USE_ALLOCA",
"OPUS_X86_PRESUME_SSE", "OPUS_X86_PRESUME_SSE2",
"OPUS_HAVE_RTCD", "OPUS_X86_MAY_HAVE_SSE", "OPUS_X86_MAY_HAVE_SSE4_1", "OPUS_X86_MAY_HAVE_AVX2",
}
else
includedirs { OPUS_INCLUDE_DIR, VORBIS_INCLUDE_DIR, OGG_INCLUDE_DIR }
end
end
filter "system:linux"
links { "dl", "pthread", "m" }
project "sqlite3"
kind "StaticLib"
cdialect "C11"
files { "sqlite3.c", "sqlite3.h" }
-- default global settings
BUILD_LUA = true
LUA_LIB_NAME = "lua"
BUILD_EVENT = os.istarget("windows")
BUILD_FREETYPE = os.istarget("windows")
BUILD_SQLITE = os.istarget("windows")
BUILD_IRRLICHT = not os.istarget("macosx")
USE_IRRKLANG = true
USE_AUDIO = true
AUDIO_LIB = "miniaudio"
MINIAUDIO_SUPPORT_OPUS_VORBIS = true
MINIAUDIO_BUILD_OPUS_VORBIS = os.istarget("windows")
IRRKLANG_PRO = false
LUA_LIB_NAME = "lua"
IRRKLANG_PRO_BUILD_IKPMP3 = false
-- read settings from command line or environment variables
......@@ -15,7 +21,7 @@ newoption { trigger = "build-lua", category = "YGOPro - lua", description = "" }
newoption { trigger = "no-build-lua", category = "YGOPro - lua", description = "" }
newoption { trigger = "lua-include-dir", category = "YGOPro - lua", description = "", value = "PATH" }
newoption { trigger = "lua-lib-dir", category = "YGOPro - lua", description = "", value = "PATH" }
newoption { trigger = "lua-lib-name", category = "YGOPro - lua", description = "", value = "NAME", default = "lua" }
newoption { trigger = "lua-lib-name", category = "YGOPro - lua", description = "", value = "NAME", default = LUA_LIB_NAME }
newoption { trigger = "build-event", category = "YGOPro - event", description = "" }
newoption { trigger = "no-build-event", category = "YGOPro - event", description = "" }
......@@ -37,8 +43,24 @@ newoption { trigger = "no-build-irrlicht", category = "YGOPro - irrlicht", descr
newoption { trigger = "irrlicht-include-dir", category = "YGOPro - irrlicht", description = "", value = "PATH" }
newoption { trigger = "irrlicht-lib-dir", category = "YGOPro - irrlicht", description = "", value = "PATH" }
newoption { trigger = "use-irrklang", category = "YGOPro - irrklang", description = "" }
newoption { trigger = "no-use-irrklang", category = "YGOPro - irrklang", description = "" }
newoption { trigger = "no-audio", category = "YGOPro", description = "" }
newoption { trigger = "audio-lib", category = "YGOPro", description = "", value = "miniaudio, irrklang", default = AUDIO_LIB }
newoption { trigger = "miniaudio-include-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "miniaudio-lib-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "miniaudio-support-opus-vorbis", category = "YGOPro - miniaudio", description = "" }
newoption { trigger = "no-miniaudio-support-opus-vorbis", category = "YGOPro - miniaudio", description = "" }
newoption { trigger = "build-opus-vorbis", category = "YGOPro - miniaudio", description = "" }
newoption { trigger = "no-build-opus-vorbis", category = "YGOPro - miniaudio", description = "" }
newoption { trigger = "opus-include-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "opus-lib-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "vorbis-include-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "vorbis-lib-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "ogg-include-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "ogg-lib-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "use-irrklang", category = "YGOPro - irrklang", description = "Deprecated, use audio-lib=irrklang" }
newoption { trigger = "no-use-irrklang", category = "YGOPro - irrklang", description = "Deprecated, use no-audio" }
newoption { trigger = "irrklang-include-dir", category = "YGOPro - irrklang", description = "", value = "PATH" }
newoption { trigger = "irrklang-lib-dir", category = "YGOPro - irrklang", description = "", value = "PATH" }
......@@ -108,37 +130,75 @@ if not BUILD_IRRLICHT then
IRRLICHT_LIB_DIR = GetParam("irrlicht-lib-dir") or os.findlib("irrlicht")
end
if GetParam("use-irrklang") then
USE_IRRKLANG = true
if GetParam("no-audio") then
USE_AUDIO = false
elseif GetParam("no-use-miniaudio") then
print("Warning: --no-use-miniaudio is deprecated, use --no-audio")
USE_AUDIO = false
elseif GetParam("use-miniaudio") then
print("Warning: --use-miniaudio is deprecated, use --audio-lib=miniaudio")
USE_AUDIO = true
AUDIO_LIB = "miniaudio"
elseif GetParam("no-use-irrklang") then
USE_IRRKLANG = false
end
if USE_IRRKLANG then
IRRKLANG_INCLUDE_DIR = GetParam("irrklang-include-dir") or "../irrklang/include"
if os.istarget("windows") then
IRRKLANG_LIB_DIR = "../irrklang/lib/Win32-visualStudio"
elseif os.istarget("linux") then
IRRKLANG_LIB_DIR = "../irrklang/bin/linux-gcc-64"
IRRKLANG_LINK_RPATH = "-Wl,-rpath=./lib/"
elseif os.istarget("macosx") then
IRRKLANG_LIB_DIR = "../irrklang/bin/macosx-gcc"
end
IRRKLANG_LIB_DIR = GetParam("irrklang-lib-dir") or IRRKLANG_LIB_DIR
print("Warning: --no-use-irrklang is deprecated, use --no-audio")
USE_AUDIO = false
elseif GetParam("use-irrklang") then
print("Warning: --use-irrklang is deprecated, use --audio-lib=irrklang")
USE_AUDIO = true
AUDIO_LIB = "irrklang"
end
if GetParam("irrklang-pro") and os.istarget("windows") then
IRRKLANG_PRO = true
elseif GetParam("no-irrklang-pro") then
IRRKLANG_PRO = false
end
if IRRKLANG_PRO then
-- irrklang pro can't use the pro lib to debug
IRRKLANG_PRO_RELEASE_LIB_DIR = GetParam("irrklang-pro-release-lib-dir") or "../irrklang/lib/Win32-vs2019"
IRRKLANG_PRO_DEBUG_LIB_DIR = GetParam("irrklang-pro-debug-lib-dir") or "../irrklang/lib/Win32-visualStudio-debug"
if USE_AUDIO then
AUDIO_LIB = GetParam("audio-lib") or AUDIO_LIB
if AUDIO_LIB == "miniaudio" then
if GetParam("miniaudio-support-opus-vorbis") then
MINIAUDIO_SUPPORT_OPUS_VORBIS = true
elseif GetParam("no-miniaudio-support-opus-vorbis") then
MINIAUDIO_SUPPORT_OPUS_VORBIS = false
end
if MINIAUDIO_SUPPORT_OPUS_VORBIS then
if GetParam("no-build-opus-vorbis") then
MINIAUDIO_BUILD_OPUS_VORBIS = false
elseif GetParam("build-opus-vorbis") then
MINIAUDIO_BUILD_OPUS_VORBIS = true
end
if not MINIAUDIO_BUILD_OPUS_VORBIS then
OPUS_INCLUDE_DIR = GetParam("opus-include-dir") or os.findheader("opus")
OPUS_LIB_DIR = GetParam("opus-lib-dir") or os.findlib("opusfile")
VORBIS_INCLUDE_DIR = GetParam("vorbis-include-dir") or os.findheader("vorbis")
VORBIS_LIB_DIR = GetParam("vorbis-lib-dir") or os.findlib("vorbis")
OGG_INCLUDE_DIR = GetParam("ogg-include-dir") or os.findheader("ogg")
OCG_LIB_DIR = GetParam("ogg-lib-dir") or os.findlib("ogg")
end
end
elseif AUDIO_LIB == "irrklang" then
print("Warning: irrKlang is deprecated and may be removed in future, please consider switching to miniaudio")
IRRKLANG_INCLUDE_DIR = GetParam("irrklang-include-dir") or "../irrklang/include"
if os.istarget("windows") then
IRRKLANG_LIB_DIR = "../irrklang/lib/Win32-visualStudio"
elseif os.istarget("linux") then
IRRKLANG_LIB_DIR = "../irrklang/bin/linux-gcc-64"
IRRKLANG_LINK_RPATH = "-Wl,-rpath=./irrklang/bin/linux-gcc-64/"
elseif os.istarget("macosx") then
IRRKLANG_LIB_DIR = "../irrklang/bin/macosx-gcc"
end
IRRKLANG_LIB_DIR = GetParam("irrklang-lib-dir") or IRRKLANG_LIB_DIR
if GetParam("irrklang-pro") and os.istarget("windows") then
IRRKLANG_PRO = true
elseif GetParam("no-irrklang-pro") then
IRRKLANG_PRO = false
end
if IRRKLANG_PRO then
-- irrklang pro can't use the pro lib to debug
IRRKLANG_PRO_RELEASE_LIB_DIR = GetParam("irrklang-pro-release-lib-dir") or "../irrklang/lib/Win32-vs2019"
IRRKLANG_PRO_DEBUG_LIB_DIR = GetParam("irrklang-pro-debug-lib-dir") or "../irrklang/lib/Win32-visualStudio-debug"
end
IRRKLANG_PRO_BUILD_IKPMP3 = GetParam("build-ikpmp3") or IRRKLANG_PRO
else
error("Unknown audio library: " .. AUDIO_LIB)
end
end
BUILD_IKPMP3 = USE_IRRKLANG and (GetParam("build-ikpmp3") or IRRKLANG_PRO)
if GetParam("winxp-support") and os.istarget("windows") then
WINXP_SUPPORT = true
end
......@@ -196,7 +256,7 @@ workspace "YGOPro"
flags { "LinkTimeOptimization" }
end
staticruntime "On"
disablewarnings { "4244", "4267", "4838", "4577", "4018", "4996", "4477", "4091", "4800", "6011", "6031", "6054", "6262" }
disablewarnings { "4244", "4267", "4838", "4996", "6011", "6031", "6054", "6262" }
filter { "configurations:Release", "not action:vs*" }
symbols "On"
......@@ -209,6 +269,10 @@ workspace "YGOPro"
disablewarnings { "6011", "6031", "6054", "6262" }
filter "action:vs*"
cdialect "C11"
if not WINXP_SUPPORT then
conformancemode "On"
end
vectorextensions "SSE2"
buildoptions { "/utf-8" }
defines { "_CRT_SECURE_NO_WARNINGS" }
......@@ -235,6 +299,11 @@ workspace "YGOPro"
if BUILD_SQLITE then
include "sqlite3"
end
if BUILD_IKPMP3 then
include "ikpmp3"
if USE_AUDIO then
if AUDIO_LIB=="miniaudio" then
include "miniaudio"
end
if IRRKLANG_PRO_BUILD_IKPMP3 then
include "ikpmp3"
end
end
......@@ -1249,3 +1249,5 @@
!setname 0x1c4 征龙 征竜
!setname 0x1c5 再世 再世
!setname 0x1c6 统王 ドミナス
!setname 0x1c7 塞勒凯特 Serket
!setname 0x1c8 阿匹卜 Apophis
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