diff options
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/app.cpp | 24 | ||||
-rw-r--r-- | src/app/app.h | 3 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/app/app.cpp b/src/app/app.cpp index 429a9d4..628b7a9 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -401,8 +401,13 @@ bool CApplication::Create() return false; } - CResourceManager::AddLocation(m_dataPath, false); boost::filesystem::create_directories(m_savePath); + boost::filesystem::create_directories(m_savePath+"/mods"); + + LoadModsFromDir(m_dataPath+"/mods"); + LoadModsFromDir(m_savePath+"/mods"); + + CResourceManager::AddLocation(m_dataPath, false); CResourceManager::SetSaveLocation(m_savePath); CResourceManager::AddLocation(m_savePath, true); @@ -595,6 +600,23 @@ bool CApplication::CreateVideoSurface() return true; } +void CApplication::LoadModsFromDir(const std::string &dir) +{ + try { + boost::filesystem::directory_iterator iterator(dir); + for(; iterator != boost::filesystem::directory_iterator(); ++iterator) + { + std::string fn = iterator->path().string(); + CLogger::GetInstancePointer()->Info("Loading mod: '%s'\n", fn.c_str()); + CResourceManager::AddLocation(fn, false); + } + } + catch(std::exception &e) + { + CLogger::GetInstancePointer()->Warn("Unable to load mods from directory '%s': %s\n", dir.c_str(), e.what()); + } +} + void CApplication::Destroy() { m_joystickEnabled = false; diff --git a/src/app/app.h b/src/app/app.h index 0df3096..2049fb2 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -354,6 +354,9 @@ public: protected: //! Creates the window's SDL_Surface bool CreateVideoSurface(); + + //! Loads all mods from given directory + void LoadModsFromDir(const std::string &dir); //! Processes the captured SDL event to Event struct Event ProcessSystemEvent(); |