void MusicManager::loadSounds(std::string path, std::string root) { if( !file_existsX(path) ) return; INIReader SoundsIni( path ); if (SoundsIni.ParseError() < 0) { MessageBoxA(0, std::string(path+"\n\nError of read INI file").c_str(), "Error", 0); return; } curRoot=root; for(int i=0; i<91; i++) { std::string head = "sound-"+i2str(i+1); std::string fileName; std::string reserveChannel; fileName = SoundsIni.Get(head, "file", ""); if(fileName.size()==0) continue; reserveChannel = SoundsIni.Get(head, "single-channel", "0"); replaceSubStr(fileName, "\"", ""); replaceSubStr(fileName, "\\\\", "\\"); replaceSubStr(fileName, "/", "\\"); if( file_existsX(root+fileName) ) { sounds[i].setPath(root+fileName.c_str()); if(reserveChannel=="1") sounds[i].channel = 0; else sounds[i].channel = -1; } } }
// *EXPORT* On Level Load -- Run once as a level is loaded (including title screen level) int OnLvlLoad() { // Restore some code the hook overwrote *(DWORD*)0x00B25958 = 0; ResetLunaModule(); // WIP // dumpTypeLibrary((IDispatch*)*(DWORD*)0xB2D7E8, std::wcout); std::string custPath = WStr2Str(getCustomFolderPath()); std::string wldPath = WStr2Str(GM_FULLDIR); std::string SndRoot = MusicManager::SndRoot(); replaceSubStr(wldPath, "\"", ""); replaceSubStr(wldPath, "\\\\", "\\"); replaceSubStr(wldPath, "/", "\\"); replaceSubStr(SndRoot, "\"", ""); replaceSubStr(SndRoot, "\\\\", "\\"); replaceSubStr(SndRoot, "/", "\\"); bool doSoundLoading = false; if ((!custPath.empty()) && (file_existsX(custPath + "\\sounds.ini"))) { //If custom-level specific sounds.ini detected doSoundLoading = true; LevelCustomSounds = true; } else if (LevelCustomSounds) { //If custom-level specific sounds.ini was NOT detected, but was loaded recently - reload episode specific sounds doSoundLoading = true; LevelCustomSounds = false; } if (!episodeStarted) { //Load custom sounds if episode is not finally started if (wldPath != SndRoot) doSoundLoading = true; } if (doSoundLoading) MusicManager::loadCustomSounds(wldPath + "\\", custPath); // BMPBox::initMovieCache(); if(gLunaEnabled) { // Load autocode gAutoMan.Clear(false); gAutoMan.ReadFile((std::wstring)GM_FULLDIR); // Try to load world codes gAutoMan.ReadWorld((std::wstring)GM_FULLDIR); // Init var bank gSavedVarBank.TryLoadWorldVars(); gSavedVarBank.CheckSaveDeletion(); gSavedVarBank.CopyBank(&gAutoMan.m_UserVars); // Don't try to call the CLunaLua constructor... It's already // constructed automatically once, and trying to do this will call // the constructor extra times *without* ever calling the destructor, // which can result in a memory leak of the whole Lua state! // gLunaLua = CLunaLua(); gLunaLua.init(CLunaLua::LUNALUA_LEVEL, (std::wstring)GM_FULLDIR, Level::GetName()); gLunaLua.setReady(true); // Do some stuff gAutoMan.DoEvents(true); // do with init // Init some stuff InitLevel(); gAutoMan.m_Hearts = 2; // Recount deaths gDeathCounter.Recount(); } //PGE DBG STUFF //readAndWriteNPCSettings(); //overwriteFunc(); return 0; }
void MusicManager::loadMusics(std::string path, std::string root) { if( !file_existsX(path) ) return; INIReader MusicIni( path ); if (MusicIni.ParseError() < 0) { MessageBoxA(0, std::string(path+"\n\nError of read INI file").c_str(), "Error", 0); return; } curRoot=root; int i=0; //World music for(int j=1; (j<=16) && (i<74); i++, j++) { std::string head = "world-music-"+i2str(j); std::string fileName; fileName = MusicIni.Get(head, "file", ""); if(fileName.size()==0) continue; replaceSubStr(fileName, "\"", ""); replaceSubStr(fileName, "\\\\", "\\"); replaceSubStr(fileName, "/", "\\"); if (file_existsX(root + clearTrackNumber(fileName) )) { music_wld[j-1].setPath(root+fileName.c_str()); } } //Special music for(int j=1; (j<=3) && (i<74); i++, j++) { std::string head = "special-music-"+i2str(j); std::string fileName; fileName = MusicIni.Get(head, "file", ""); if(fileName.size()==0) continue; replaceSubStr(fileName, "\"", ""); replaceSubStr(fileName, "\\\\", "\\"); replaceSubStr(fileName, "/", "\\"); if (file_existsX(root + clearTrackNumber(fileName))) { music_spc[j-1].setPath(root+fileName.c_str()); } } //Level music for(int j=1; (j<=56) && (i<74); i++, j++) { if(j==24) j++; std::string head = "level-music-"+i2str(j); std::string fileName; fileName = MusicIni.Get(head, "file", ""); if(fileName.size()==0) continue; replaceSubStr(fileName, "\"", ""); replaceSubStr(fileName, "\\\\", "\\"); replaceSubStr(fileName, "/", "\\"); if (file_existsX(root + clearTrackNumber(fileName))) { music_lvl[j-1].setPath(root+fileName.c_str()); } } }