summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mainwindow.cpp6
-rw-r--r--src/modinfodialog.cpp13
-rw-r--r--src/nexusinterface.cpp16
-rw-r--r--src/nexusinterface.h20
4 files changed, 44 insertions, 11 deletions
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 <http://www.gnu.org/licenses/>.
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<IPluginGame*>();
- 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<QLineEdit*>("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<IPluginGame*>();
- QString nexusLink = QString("%1/downloads/file.php?id=%2").arg(game->getNexusDisplayURL()).arg(modID);
+ QString nexusLink = NexusInterface::instance()->getModURL(modID);
QLabel *visitNexusLabel = findChild<QLabel*>("visitNexusLabel");
visitNexusLabel->setText(tr("<a href=\"%1\">Visit on Nexus</a>").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);