From dd37152eae382ee95535b289b17b0a727e4038f5 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Thu, 26 Nov 2015 17:48:50 +0000 Subject: This removes getNexusPage from GameInfo and is currently in the game plugin. I'm looking to move it to the nexus interface though as it doesn't really relate to the game plugin. I've also removed the MananagementURL as - you can log into nexus without needing to specify the game - See above - it doesn't belong with the game plugin This gets rid of all dependencies bar game saving and logging in --- src/modinfodialog.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/modinfodialog.cpp') diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp index 35da228b..c4acb31e 100644 --- a/src/modinfodialog.cpp +++ b/src/modinfodialog.cpp @@ -20,6 +20,7 @@ along with Mod Organizer. If not, see . #include "modinfodialog.h" #include "ui_modinfodialog.h" +#include "iplugingame.h" #include "report.h" #include "utility.h" #include "messagedialog.h" @@ -36,9 +37,11 @@ along with Mod Organizer. If not, see . #include #include #include +#include + #include + #include -#include using namespace MOBase; @@ -688,7 +691,9 @@ void ModInfoDialog::on_visitNexusLabel_linkActivated(const QString &link) void ModInfoDialog::linkClicked(const QUrl &url) { - if (url.toString().startsWith(ToQString(GameInfo::instance().getNexusPage(false)))) { + //FIXME: See elsewhere. This needs to be a property of the installed mod. + IPluginGame *game = qApp->property("managed_game").value(); + if (game->isRelatedURL(url)) { this->close(); emit nexusLinkActivated(url.toString()); } else { @@ -832,7 +837,10 @@ void ModInfoDialog::activateNexusTab() QLineEdit *modIDEdit = findChild("modIDEdit"); int modID = modIDEdit->text().toInt(); if (modID != 0) { - QString nexusLink = QString("%1/downloads/file.php?id=%2").arg(ToQString(GameInfo::instance().getNexusPage(false))).arg(modID); + //FIXME: We should remember the game for which this mod was installed in the + //modInfo and get the web page via that. + IPluginGame *game = qApp->property("managed_game").value(); + QString nexusLink = QString("%1/downloads/file.php?id=%2").arg(game->getNexusDisplayURL()).arg(modID); QLabel *visitNexusLabel = findChild("visitNexusLabel"); visitNexusLabel->setText(tr("Visit on Nexus").arg(nexusLink)); visitNexusLabel->setToolTip(nexusLink); -- cgit v1.3.1 From 1b1fc247dfc4eade8ab34679ca7c58e850a0a1a3 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Thu, 26 Nov 2015 17:54:25 +0000 Subject: Remove remaining gameInfo --- src/modinfodialog.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/modinfodialog.cpp') diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp index c4acb31e..70ae5deb 100644 --- a/src/modinfodialog.cpp +++ b/src/modinfodialog.cpp @@ -28,7 +28,6 @@ along with Mod Organizer. If not, see . #include "questionboxmemory.h" #include "settings.h" #include "categories.h" -#include #include #include @@ -45,7 +44,6 @@ along with Mod Organizer. If not, see . using namespace MOBase; -using namespace MOShared; class ModFileListWidget : public QListWidgetItem { -- cgit v1.3.1 From 2025145ff6e1ddf1b433eae2f9418e10a6fea82e Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Thu, 26 Nov 2015 21:02:45 +0000 Subject: Replaced the IPluginGame getNexusDisplayURL with some APIs in NexusInterface It makes more sense to have them here as they have very little to do with the game, more to do with the origin of the mod. --- src/mainwindow.cpp | 6 +++--- src/modinfodialog.cpp | 13 +++++-------- src/nexusinterface.cpp | 16 ++++++++++++++++ src/nexusinterface.h | 20 ++++++++++++++++++++ 4 files changed, 44 insertions(+), 11 deletions(-) (limited to 'src/modinfodialog.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3f3d5286..dd5a1b01 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2529,7 +2529,7 @@ void MainWindow::visitOnNexus_clicked() { int modID = m_OrganizerCore.modList()->data(m_OrganizerCore.modList()->index(m_ContextRow, 0), Qt::UserRole).toInt(); if (modID > 0) { - nexusLinkActivated(QString("%1/mods/%2").arg(m_OrganizerCore.managedGame()->getNexusDisplayURL()).arg(modID)); + nexusLinkActivated(NexusInterface::instance()->getModURL(modID)); } else { MessageDialog::showMessage(tr("Nexus ID for this Mod is unknown"), this); } @@ -3422,7 +3422,7 @@ void MainWindow::on_actionSettings_triggered() void MainWindow::on_actionNexus_triggered() { ::ShellExecuteW(nullptr, L"open", - m_OrganizerCore.managedGame()->getNexusDisplayURL().toStdWString().c_str(), + NexusInterface::instance()->getGameURL().toStdWString().c_str(), nullptr, nullptr, SW_SHOWNORMAL); } @@ -3818,7 +3818,7 @@ void MainWindow::on_actionEndorseMO_triggered() { if (QMessageBox::question(this, tr("Endorse Mod Organizer"), tr("Do you want to endorse Mod Organizer on %1 now?").arg( - m_OrganizerCore.managedGame()->getNexusDisplayURL()), + NexusInterface::instance()->getGameURL()), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { NexusInterface::instance()->requestToggleEndorsement( m_OrganizerCore.managedGame()->getNexusModOrganizerID(), true, this, QVariant(), QString()); diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp index 70ae5deb..687f641e 100644 --- a/src/modinfodialog.cpp +++ b/src/modinfodialog.cpp @@ -44,6 +44,7 @@ along with Mod Organizer. If not, see . using namespace MOBase; +using namespace MOShared; class ModFileListWidget : public QListWidgetItem { @@ -689,9 +690,9 @@ void ModInfoDialog::on_visitNexusLabel_linkActivated(const QString &link) void ModInfoDialog::linkClicked(const QUrl &url) { - //FIXME: See elsewhere. This needs to be a property of the installed mod. - IPluginGame *game = qApp->property("managed_game").value(); - if (game->isRelatedURL(url)) { + //Ideally we'd ask the mod for the game and the web service then pass the game + //and URL to the web service + if (NexusInterface::instance()->isURLGameRelated(url)) { this->close(); emit nexusLinkActivated(url.toString()); } else { @@ -835,15 +836,11 @@ void ModInfoDialog::activateNexusTab() QLineEdit *modIDEdit = findChild("modIDEdit"); int modID = modIDEdit->text().toInt(); if (modID != 0) { - //FIXME: We should remember the game for which this mod was installed in the - //modInfo and get the web page via that. - IPluginGame *game = qApp->property("managed_game").value(); - QString nexusLink = QString("%1/downloads/file.php?id=%2").arg(game->getNexusDisplayURL()).arg(modID); + QString nexusLink = NexusInterface::instance()->getModURL(modID); QLabel *visitNexusLabel = findChild("visitNexusLabel"); visitNexusLabel->setText(tr("Visit on Nexus").arg(nexusLink)); visitNexusLabel->setToolTip(nexusLink); - if (m_ModInfo->getNexusDescription().isEmpty() || QDateTime::currentDateTime() > m_ModInfo->getLastNexusQuery().addDays(1)) { refreshNexusData(modID); diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index b6843c57..7a0b0a17 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -240,6 +240,22 @@ void NexusInterface::interpretNexusFileName(const QString &fileName, QString &mo } } +bool NexusInterface::isURLGameRelated(const QUrl &url) const +{ + QString const name(url.toString()); + return name.startsWith(getGameURL() + "/") || + name.startsWith("http://" + m_Game->getNexusName().toLower() + ".nexusmods.com/mods/"); +} + +QString NexusInterface::getGameURL() const +{ + return "http://www.nexusmods.com/" + m_Game->getNexusName().toLower(); +} + +QString NexusInterface::getModURL(int modID) const +{ + return QString("%1/mods/%2").arg(getGameURL()).arg(modID); +} int NexusInterface::requestDescription(int modID, QObject *receiver, QVariant userData, const QString &subModule, MOBase::IPluginGame const *game) diff --git a/src/nexusinterface.h b/src/nexusinterface.h index 807d0aec..3fa8f564 100644 --- a/src/nexusinterface.h +++ b/src/nexusinterface.h @@ -325,6 +325,26 @@ public: */ MOBase::IPluginGame const *managedGame() const; + /** + * @brief see if the passed URL is related to the current game + * + * Arguably, this should optionally take a gameplugin pointer + */ + bool isURLGameRelated(QUrl const &url) const; + + /** + * @brief Get the nexus page for the current game + * + * Arguably, this should optionally take a gameplugin pointer + */ + QString getGameURL() const; + + /** + * @brief Get the URL for the mod web page + * @param modID + */ + QString getModURL(int modID) const; + signals: void requestNXMDownload(const QString &url); -- cgit v1.3.1