void LuaProxy::Data::init() { std::string path = resolvePathFromSection(); std::ifstream luaData(path, std::ios::binary | std::ios::in); if (!luaData.is_open()){ std::ofstream luaDataCreate(path, std::ios::binary | std::ios::out); if (luaDataCreate.is_open()) luaDataCreate.close(); } if (luaData.is_open()){ while (!luaData.eof()) { std::string key; std::string value; std::getline(luaData, key); if (luaData.eof()) break; std::getline(luaData, value); replaceSubStr(key, "\\n", "\n"); replaceSubStr(value, "\\n", "\n"); m_data[key] = value; } luaData.close(); } }
//! //! \brief This function accepts MCI-alias and file path. Function used to poke initialization of sound engine and bind custom musics sent by SMBX Engine. //! \param alias MCI-Alias sent by SMBX Engine //! \param fileName File path sent by SMBX Engine //! void MusicManager::addSound(std::string alias, std::string fileName) { initAudioEngine(); //Load custom music if(alias=="music24") { //clear junk replaceSubStr(fileName, "\"", ""); replaceSubStr(fileName, "\\\\", "\\"); replaceSubStr(fileName, "/", "\\"); music_lvl[23].setPath(fileName); } }
std::string decodeJavaScriptParams (std::string params) { std::string result = params; // replace AvInt with int result = replaceSubStr (result,"AvInt","int"); result = replaceSubStr (result,"AvString","string"); result = replaceSubStr (result,"AvBool","bool"); result = replaceSubStr (result,"AvFloat","float"); return result; // replace AvString with string // replace AvBool with bool // replace Av }
std::wstring decodeJavaScriptParams (std::wstring params) { std::wstring result = params; // replace AvInt with int result = replaceSubStr (result,L"AvInt",L"int"); // replace AvString with string result = replaceSubStr (result,L"AvString",L"string"); // replace AvBool with bool result = replaceSubStr (result,L"AvBool",L"bool"); // replace Av result = replaceSubStr (result,L"AvFloat",L"float"); //result = replaceSubStr (result,L"@",L","); return result; }
void LuaProxy::Data::save(const std::string §ionName) { m_sectionName = sectionName; std::string path = resolvePathFromSection(); std::ofstream luaData(path, std::ios::binary | std::ios::out); if (luaData.is_open()){ for (std::map<std::string, std::string>::iterator it = m_data.begin(); it != m_data.end(); ++it) { std::string key = it->first; std::string value = it->second; replaceSubStr(key, "\n", "\\n"); replaceSubStr(value, "\n", "\\n"); luaData << key << std::endl; luaData << value << std::endl; } luaData.close(); } }
void Features:: init(string str) { replaceSubStr(str,":"," "); stringstream ss(str); ss>>t2s>>s2t>>t2sLex>>s2tLex>>distort>>length; length*=-1; distort*=-1; }
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()); } } }