Skip to content

Commit

Permalink
Parse unmanaged file location when creating ModInfoForeign
Browse files Browse the repository at this point in the history
- Fixes issues with secondaryDataDirectories
  • Loading branch information
Silarn committed Jun 16, 2024
1 parent 6d08d43 commit 1e11ce0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/modinfoforeign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ QDateTime ModInfoForeign::creationTime() const
return m_CreationTime;
}

QString ModInfoForeign::absolutePath() const
{
// I ought to store this, it's used elsewhere
IPluginGame const* game = qApp->property("managed_game").value<IPluginGame*>();
return game->dataDirectory().absolutePath();
}

std::vector<ModInfo::EFlag> ModInfoForeign::getFlags() const
{
std::vector<ModInfo::EFlag> result = ModInfoWithConflictInfo::getFlags();
Expand Down Expand Up @@ -49,7 +42,15 @@ ModInfoForeign::ModInfoForeign(const QString& modName, const QString& referenceF
: ModInfoWithConflictInfo(core), m_ReferenceFile(referenceFile),
m_Archives(archives), m_ModType(modType)
{
m_CreationTime = QFileInfo(referenceFile).birthTime();
m_CreationTime = QFileInfo(referenceFile).birthTime();
IPluginGame const* game = qApp->property("managed_game").value<IPluginGame*>();
QMap<QString, QDir> directories = {{"data", game->dataDirectory()}};
directories.insert(game->secondaryDataDirectories());
for (QDir directory : directories) {
if (referenceFile.startsWith(directory.absolutePath(), Qt::CaseInsensitive)) {
m_BaseDirectory = directory.absolutePath();
}
}
switch (modType) {
case ModInfo::EModType::MOD_DLC:
m_Name = tr("DLC: ") + modName;
Expand Down
3 changes: 2 additions & 1 deletion src/modinfoforeign.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ModInfoForeign : public ModInfoWithConflictInfo
virtual QString comments() const override { return ""; }
virtual QString notes() const override { return ""; }
virtual QDateTime creationTime() const override;
virtual QString absolutePath() const override;
virtual QString absolutePath() const override { return m_BaseDirectory; }
virtual MOBase::VersionInfo newestVersion() const override { return QString(); }
virtual MOBase::VersionInfo ignoredVersion() const override { return QString(); }
virtual QString installationFile() const override { return ""; }
Expand Down Expand Up @@ -108,6 +108,7 @@ class ModInfoForeign : public ModInfoWithConflictInfo
QString m_Name;
QString m_InternalName;
QString m_ReferenceFile;
QString m_BaseDirectory;
QStringList m_Archives;
QDateTime m_CreationTime;
int m_Priority;
Expand Down

0 comments on commit 1e11ce0

Please sign in to comment.