Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #include <fstream>
- #define BUFSIZE MAX_PATH
- std::string replaceStrChar(std::string str, const std::string& replace, char ch){
- // set our locator equal to the first appearance of any character in replace
- size_t i = str.find_first_of(replace);
- unsigned found = str.find_first_of(replace);
- while (found != std::string::npos) { // While our position in the sting is in range.
- str[found] = ch; // Change the character at position.
- found = str.find_first_of(replace, found+1); // Relocate again.
- }
- return str; // return our new string.
- }
- void loadResources(){
- Ogre::ConfigFile cf;
- //Get Current Path
- char Buffer[BUFSIZE];
- DWORD dwRet;
- dwRet = GetCurrentDirectory(BUFSIZE, Buffer);
- // Replace Backslashes with Forwardslashes
- std::string currentPath;
- currentPath.assign(Buffer);
- currentPath = replaceStrChar(currentPath, "\\", (char) 47);
- std::string prefix = "FileSystem=";
- prefix.append(currentPath);
- std::ofstream fout;
- fout.open("resources.cfg");
- fout << "[General]" << std::endl;
- fout << prefix + "/Resources/Materials" << std::endl;
- fout << prefix + "/Resources/Models"<< std::endl;
- fout << prefix + "/Resources/Textures" << std::endl;
- fout << prefix + "/Resources/Particles" << std::endl;
- fout << prefix + "/Resources/Fonts" << std::endl;
- // fout << prefix + "/Resources/Sounds" << std::endl;
- fout.close();
- #ifdef _DEBUG
- cf.load("resources.cfg"); // the same atm
- #else
- cf.load("resources.cfg");
- #endif
- Ogre::ConfigFile::SectionIterator sectionIter = cf.getSectionIterator();
- Ogre::String sectionName, typeName, dataname;
- while (sectionIter.hasMoreElements()){
- sectionName = sectionIter.peekNextKey();
- Ogre::ConfigFile::SettingsMultiMap *settings = sectionIter.getNext();
- Ogre::ConfigFile::SettingsMultiMap::iterator i;
- for (i = settings->begin(); i != settings->end(); ++i){
- typeName = i->first;
- dataname = i->second;
- Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
- dataname, typeName, sectionName);
- }
- }
- Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement