Show only local mods on the list

pyro-refactor
DavivaD 2019-07-27 17:58:12 +02:00
parent 6f3b14202e
commit 50c3c45ef8
1 changed files with 25 additions and 14 deletions

View File

@ -41,6 +41,9 @@
#include <algorithm> #include <algorithm>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
using namespace boost::filesystem;
namespace Ui namespace Ui
{ {
@ -224,10 +227,11 @@ void CScreenSetupMods::LoadMod(std::string modName)
void CScreenSetupMods::UpdateUnloadedModList() void CScreenSetupMods::UpdateUnloadedModList()
{ {
CWindow* pw; CWindow* pw;
CList* pl; CList* pl;
int i = 0; int i = 0;
std::string modName; std::string modPath, modPathRaw;
directory_iterator end_itr;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == nullptr ) return; if ( pw == nullptr ) return;
@ -236,12 +240,13 @@ void CScreenSetupMods::UpdateUnloadedModList()
if ( pl == nullptr ) return; if ( pl == nullptr ) return;
pl->Flush(); pl->Flush();
auto modsDir = CResourceManager::ListDirectories("mods/"); modPathRaw = CResourceManager::GetSaveLocation() + "/" + "mods" + "/";
std::sort(modsDir.begin(), modsDir.end()); modPath = modPathRaw.c_str();
for(auto const& modNameRaw : modsDir) for (directory_iterator itr(modPath); itr != end_itr; ++itr)
{ {
modName = modNameRaw; std::string modName = itr->path().string();
boost::erase_all(modName, modPath);
std::string::size_type enabled; std::string::size_type enabled;
enabled = modName.find('~'); enabled = modName.find('~');
if (enabled != std::string::npos) if (enabled != std::string::npos)
@ -250,13 +255,16 @@ void CScreenSetupMods::UpdateUnloadedModList()
pl->SetItemName(i++, modName); pl->SetItemName(i++, modName);
} }
} }
pl->ShowSelect(false); // shows the selected columns pl->ShowSelect(false); // shows the selected columns
} }
void CScreenSetupMods::UpdateLoadedModList() void CScreenSetupMods::UpdateLoadedModList()
{ {
CWindow* pw; CWindow* pw;
CList* pl; CList* pl;
int i = 0; int i = 0;
std::string modPath, modPathRaw;
directory_iterator end_itr;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == nullptr ) return; if ( pw == nullptr ) return;
@ -265,16 +273,19 @@ void CScreenSetupMods::UpdateLoadedModList()
if ( pl == nullptr ) return; if ( pl == nullptr ) return;
pl->Flush(); pl->Flush();
auto modsDir = CResourceManager::ListDirectories("mods/"); modPathRaw = CResourceManager::GetSaveLocation() + "/" + "mods" + "/";
std::sort(modsDir.begin(), modsDir.end()); modPath = modPathRaw.c_str();
for(auto const &modName : modsDir) for (directory_iterator itr(modPath); itr != end_itr; ++itr)
{ {
std::string modName = itr->path().string();
boost::erase_all(modName, modPath);
std::string::size_type enabled; std::string::size_type enabled;
enabled = modName.find('~'); enabled = modName.find('~');
if (enabled == std::string::npos) if (enabled == std::string::npos)
pl->SetItemName(i++, modName); pl->SetItemName(i++, modName);
} }
pl->ShowSelect(false); // shows the selected columns pl->ShowSelect(false); // shows the selected columns
} }
} // namespace Ui } // namespace Ui