diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-05-25 13:48:45 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-25 13:48:45 -0400 |
| commit | a721347fd130fcab19f2709892093f087bfac19e (patch) | |
| tree | ab4d6670668f519dd89066197cda349811f8978b /src/modinforegular.cpp | |
| parent | 08ae9db2fd2a07acb2433275fc84c2ca47267a92 (diff) | |
| parent | 9212a7d2e9611994dfc5fa2066b8ecbe68b198a8 (diff) | |
Merge pull request #1079 from Holt59/moinfo-improvements
ModInfo improvements
Diffstat (limited to 'src/modinforegular.cpp')
| -rw-r--r-- | src/modinforegular.cpp | 92 |
1 files changed, 45 insertions, 47 deletions
diff --git a/src/modinforegular.cpp b/src/modinforegular.cpp index d89716da..a1f1a04d 100644 --- a/src/modinforegular.cpp +++ b/src/modinforegular.cpp @@ -38,7 +38,6 @@ ModInfoRegular::ModInfoRegular(PluginContainer *pluginContainer, const IPluginGa , m_TrackedState(TRACKED_UNKNOWN) , m_NexusBridge(pluginContainer) { - testValid(); m_CreationTime = QFileInfo(path.absolutePath()).birthTime(); // read out the meta-file for information readMeta(); @@ -654,61 +653,60 @@ std::vector<ModInfo::EFlag> ModInfoRegular::getFlags() const } -std::vector<ModInfo::EContent> ModInfoRegular::getContents() const +std::vector<ModInfo::EContent> ModInfoRegular::doGetContents() const { - QTime now = QTime::currentTime(); - if (m_LastContentCheck.isNull() || (m_LastContentCheck.secsTo(now) > 60)) { - m_CachedContent.clear(); - QDir dir(absolutePath()); - if (dir.entryList(QStringList() << "*.esp" << "*.esm" << "*.esl").size() > 0) { - m_CachedContent.push_back(CONTENT_PLUGIN); - } - if (dir.entryList(QStringList() << "*.bsa" << "*.ba2").size() > 0) { - m_CachedContent.push_back(CONTENT_BSA); - } - //use >1 for ini files since there is meta.ini in all mods already. - if (dir.entryList(QStringList() << "*.ini").size() > 1) { - m_CachedContent.push_back(CONTENT_INI); - } + auto tree = contentFileTree(); + std::vector<ModInfo::EContent> contents; - if (dir.entryList(QStringList() << "*.modgroups").size() > 0) { - m_CachedContent.push_back(CONTENT_MODGROUP); + for (auto e : *tree) { + if (e->isFile()) { + auto suffix = e->suffix().toLower(); + if (suffix == "esp" || suffix == "esm" || suffix == "esl") { + contents.push_back(CONTENT_PLUGIN); + } + else if (suffix == "bsa" || suffix == "ba2") { + contents.push_back(CONTENT_BSA); + } + else if (suffix == "ini" && e->compare("meta.ini") != 0) { + contents.push_back(CONTENT_INI); + } + else if (suffix == "modgroups") { + contents.push_back(CONTENT_MODGROUP); + } } + else { + if (e->compare("textures") == 0 || e->compare("icons") == 0 || e->compare("bookart") == 0) + contents.push_back(CONTENT_TEXTURE); + if (e->compare("meshes") == 0) + contents.push_back(CONTENT_MESH); + if (e->compare("interface") == 0 || e->compare("menus") == 0) + contents.push_back(CONTENT_INTERFACE); + if (e->compare("music") == 0 || e->compare("sound") == 0) + contents.push_back(CONTENT_SOUND); + if (e->compare("scripts") == 0) + contents.push_back(CONTENT_SCRIPT); + if (e->compare("SkyProc Patchers") == 0) + contents.push_back(CONTENT_SKYPROC); + if (e->compare("MCM") == 0) + contents.push_back(CONTENT_MCM); + } + } - ScriptExtender *extender = qApp->property("managed_game") - .value<IPluginGame *>() - ->feature<ScriptExtender>(); - - if (extender != nullptr) { - QString sePluginPath = extender->PluginPath(); - if (dir.exists(sePluginPath)) { - m_CachedContent.push_back(CONTENT_SKSEFILES); - QDir sePluginDir(absolutePath() + "/" + sePluginPath); - if (sePluginDir.entryList(QStringList() << "*.dll").size() > 0) { - m_CachedContent.push_back(CONTENT_SKSE); + ScriptExtender* extender = m_GamePlugin->feature<ScriptExtender>(); + if (extender != nullptr) { + auto e = tree->findDirectory(extender->PluginPath()); + if (e) { + contents.push_back(CONTENT_SKSEFILES); + for (auto f : *e) { + if (f->hasSuffix("dll")) { + contents.push_back(CONTENT_SKSE); + break; } } } - if (dir.exists("textures") || dir.exists("icons") || dir.exists("bookart")) - m_CachedContent.push_back(CONTENT_TEXTURE); - if (dir.exists("meshes")) - m_CachedContent.push_back(CONTENT_MESH); - if (dir.exists("interface") || dir.exists("menus")) - m_CachedContent.push_back(CONTENT_INTERFACE); - if (dir.exists("music") || dir.exists("sound")) - m_CachedContent.push_back(CONTENT_SOUND); - if (dir.exists("scripts")) - m_CachedContent.push_back(CONTENT_SCRIPT); - if (dir.exists("SkyProc Patchers")) - m_CachedContent.push_back(CONTENT_SKYPROC); - if (dir.exists("MCM")) - m_CachedContent.push_back(CONTENT_MCM); - - m_LastContentCheck = QTime::currentTime(); } - return m_CachedContent; - + return contents; } |
