summaryrefslogtreecommitdiff
path: root/src/downloadmanager.cpp
diff options
context:
space:
mode:
authorSilarn <jrim@rimpo.org>2019-05-23 22:24:57 -0500
committerSilarn <jrim@rimpo.org>2019-05-23 22:24:57 -0500
commit2d58ad346c9e8840d3864080d62999e686962a76 (patch)
treee08642f2e2bd29807044490025efbba8b2687a0c /src/downloadmanager.cpp
parenta0500fef6c7db55c51334cc1bfc39cc9393fa16b (diff)
Add support for new Nexus API game codes to NXM link handling
Diffstat (limited to 'src/downloadmanager.cpp')
-rw-r--r--src/downloadmanager.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index 78162f11..d4a6c37f 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -549,10 +549,21 @@ void DownloadManager::addNXMDownload(const QString &url)
NXMUrl nxmInfo(url);
QStringList validGames;
+ MOBase::IPluginGame* foundGame = nullptr;
validGames.append(m_ManagedGame->gameShortName());
validGames.append(m_ManagedGame->validShortNames());
+ for (auto game : validGames) {
+ MOBase::IPluginGame* gamePlugin = m_OrganizerCore->getGame(game);
+ if (
+ nxmInfo.game().compare(gamePlugin->gameShortName(), Qt::CaseInsensitive) == 0 ||
+ nxmInfo.game().compare(gamePlugin->gameNexusName(), Qt::CaseInsensitive) == 0
+ ) {
+ foundGame = gamePlugin;
+ break;
+ }
+ }
qDebug("add nxm download: %s", qUtf8Printable(url));
- if (!validGames.contains(nxmInfo.game(), Qt::CaseInsensitive)) {
+ if (foundGame == nullptr) {
qDebug("download requested for wrong game (game: %s, url: %s)", qUtf8Printable(m_ManagedGame->gameShortName()), qUtf8Printable(nxmInfo.game()));
QMessageBox::information(nullptr, tr("Wrong Game"), tr("The download link is for a mod for \"%1\" but this instance of MO "
"has been set up for \"%2\".").arg(nxmInfo.game()).arg(m_ManagedGame->gameShortName()), QMessageBox::Ok);
@@ -560,7 +571,7 @@ void DownloadManager::addNXMDownload(const QString &url)
}
for (auto tuple : m_PendingDownloads) {
- if (std::get<0>(tuple).compare(nxmInfo.game(), Qt::CaseInsensitive) == 0, std::get<1>(tuple) == nxmInfo.modId() && std::get<2>(tuple) == nxmInfo.fileId()) {
+ if (std::get<0>(tuple).compare(foundGame->gameShortName(), Qt::CaseInsensitive) == 0, std::get<1>(tuple) == nxmInfo.modId() && std::get<2>(tuple) == nxmInfo.fileId()) {
QString debugStr("download requested is already queued (mod: %1, file: %2)");
QString infoStr(tr("There is already a download queued for this file.\n\nMod %1\nFile %2"));
@@ -620,7 +631,7 @@ void DownloadManager::addNXMDownload(const QString &url)
emit aboutToUpdate();
- m_PendingDownloads.append(std::make_tuple(nxmInfo.game(), nxmInfo.modId(), nxmInfo.fileId()));
+ m_PendingDownloads.append(std::make_tuple(foundGame->gameShortName(), nxmInfo.modId(), nxmInfo.fileId()));
emit update(-1);
emit downloadAdded();
@@ -631,7 +642,7 @@ void DownloadManager::addNXMDownload(const QString &url)
info->nexusDownloadUser = nxmInfo.userId();
QObject *test = info;
- m_RequestIDs.insert(m_NexusInterface->requestFileInfo(nxmInfo.game(), nxmInfo.modId(), nxmInfo.fileId(), this, qVariantFromValue(test), ""));
+ m_RequestIDs.insert(m_NexusInterface->requestFileInfo(foundGame->gameShortName(), nxmInfo.modId(), nxmInfo.fileId(), this, qVariantFromValue(test), ""));
}