summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.cpp31
-rw-r--r--src/mainwindow.cpp3
-rw-r--r--src/nexusinterface.cpp81
-rw-r--r--src/nexusinterface.h133
-rw-r--r--src/organizercore.cpp26
-rw-r--r--src/organizercore.h3
-rw-r--r--src/selfupdater.cpp40
-rw-r--r--src/selfupdater.h5
-rw-r--r--src/shared/fallout3info.cpp5
-rw-r--r--src/shared/fallout3info.h2
-rw-r--r--src/shared/falloutnvinfo.cpp6
-rw-r--r--src/shared/falloutnvinfo.h2
-rw-r--r--src/shared/gameinfo.h2
-rw-r--r--src/shared/oblivioninfo.cpp6
-rw-r--r--src/shared/oblivioninfo.h2
-rw-r--r--src/shared/skyriminfo.cpp11
-rw-r--r--src/shared/skyriminfo.h3
17 files changed, 221 insertions, 140 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 4f79b0b2..72a63dc6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -498,24 +498,27 @@ int main(int argc, char *argv[])
return 1;
}
- IPluginGame *game = organizer.managedGame();
+ //This is probably wrong too
+ {
+ IPluginGame *game = organizer.managedGameForUpdate();
- if (!settings.contains("game_edition")) {
- QStringList editions = game->gameVariants();
- if (editions.size() > 1) {
- SelectionDialog selection(QObject::tr("Please select the game edition you have (MO can't start the game correctly if this is set incorrectly!)"), nullptr);
- int index = 0;
- for (const QString &edition : editions) {
- selection.addChoice(edition, "", index++);
- }
- if (selection.exec() == QDialog::Rejected) {
- return -1;
- } else {
- settings.setValue("game_edition", selection.getChoiceString());
+ if (!settings.contains("game_edition")) {
+ QStringList editions = game->gameVariants();
+ if (editions.size() > 1) {
+ SelectionDialog selection(QObject::tr("Please select the game edition you have (MO can't start the game correctly if this is set incorrectly!)"), nullptr);
+ int index = 0;
+ for (const QString &edition : editions) {
+ selection.addChoice(edition, "", index++);
+ }
+ if (selection.exec() == QDialog::Rejected) {
+ return -1;
+ } else {
+ settings.setValue("game_edition", selection.getChoiceString());
+ }
}
}
+ game->setGameVariant(settings.value("game_edition").toString());
}
- game->setGameVariant(settings.value("game_edition").toString());
#pragma message("edition isn't used?")
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 05650219..f3ffdf6c 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -3814,8 +3814,9 @@ 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(ToQString(GameInfo::instance().getNexusPage())),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ //Why pass an empty variant of we're toggling an endorsement?
NexusInterface::instance()->requestToggleEndorsement(
- m_OrganizerCore.managedGame()->getNexusModOrganizerID(), true, this, QVariant(), QString());
+ m_OrganizerCore.managedGame()->getNexusModOrganizerID(), true, this, QVariant(), "");
}
}
diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp
index dc027be4..cbb9ad48 100644
--- a/src/nexusinterface.cpp
+++ b/src/nexusinterface.cpp
@@ -18,14 +18,18 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
*/
#include "nexusinterface.h"
+
+#include "iplugingame.h"
#include "nxmaccessmanager.h"
#include "json.h"
#include "selectiondialog.h"
-#include <QApplication>
#include <utility.h>
-#include <regex>
#include <util.h>
+#include <QApplication>
+
+#include <regex>
+
using namespace MOBase;
using namespace MOShared;
@@ -33,34 +37,34 @@ using namespace MOShared;
NexusBridge::NexusBridge(const QString &subModule)
: m_Interface(NexusInterface::instance())
- , m_Url() // lazy initialized
+ , m_Url() //Lazily initialised (but redundant)
, m_SubModule(subModule)
{
}
void NexusBridge::requestDescription(int modID, QVariant userData)
{
- m_RequestIDs.insert(m_Interface->requestDescription(modID, this, userData, m_SubModule, url()));
+ m_RequestIDs.insert(m_Interface->requestDescription(modID, this, userData, m_SubModule));
}
void NexusBridge::requestFiles(int modID, QVariant userData)
{
- m_RequestIDs.insert(m_Interface->requestFiles(modID, this, userData, m_SubModule, url()));
+ m_RequestIDs.insert(m_Interface->requestFiles(modID, this, userData, m_SubModule));
}
void NexusBridge::requestFileInfo(int modID, int fileID, QVariant userData)
{
- m_RequestIDs.insert(m_Interface->requestFileInfo(modID, fileID, this, userData, m_SubModule, url()));
+ m_RequestIDs.insert(m_Interface->requestFileInfo(modID, fileID, this, userData, m_SubModule));
}
void NexusBridge::requestDownloadURL(int modID, int fileID, QVariant userData)
{
- m_RequestIDs.insert(m_Interface->requestDownloadURL(modID, fileID, this, userData, m_SubModule, url()));
+ m_RequestIDs.insert(m_Interface->requestDownloadURL(modID, fileID, this, userData, m_SubModule));
}
void NexusBridge::requestToggleEndorsement(int modID, bool endorse, QVariant userData)
{
- m_RequestIDs.insert(m_Interface->requestToggleEndorsement(modID, endorse, this, userData, m_SubModule, url()));
+ m_RequestIDs.insert(m_Interface->requestToggleEndorsement(modID, endorse, this, userData, m_SubModule));
}
void NexusBridge::nxmDescriptionAvailable(int modID, QVariant userData, QVariant resultData, int requestID)
@@ -136,13 +140,6 @@ void NexusBridge::nxmRequestFailed(int modID, int fileID, QVariant userData, int
}
}
-QString NexusBridge::url() {
- if (m_Url.isEmpty()) {
- m_Url = MOBase::ToQString(MOShared::GameInfo::instance().getNexusInfoUrl());
- }
- return m_Url;
-}
-
QAtomicInt NexusInterface::NXMRequestInfo::s_NextID(0);
@@ -246,10 +243,9 @@ void NexusInterface::interpretNexusFileName(const QString &fileName, QString &mo
int NexusInterface::requestDescription(int modID, QObject *receiver, QVariant userData,
- const QString &subModule, const QString &url, int nexusGameId)
+ const QString &subModule, MOBase::IPluginGame const *game)
{
- NXMRequestInfo requestInfo(modID, NXMRequestInfo::TYPE_DESCRIPTION, userData, subModule, url,
- nexusGameId == -1 ? GameInfo::instance().getNexusGameID() : nexusGameId);
+ NXMRequestInfo requestInfo(modID, NXMRequestInfo::TYPE_DESCRIPTION, userData, subModule, game);
m_RequestQueue.enqueue(requestInfo);
connect(this, SIGNAL(nxmDescriptionAvailable(int,QVariant,QVariant,int)),
@@ -264,9 +260,9 @@ int NexusInterface::requestDescription(int modID, QObject *receiver, QVariant us
int NexusInterface::requestUpdates(const std::vector<int> &modIDs, QObject *receiver, QVariant userData,
- const QString &subModule, const QString &url)
+ const QString &subModule, MOBase::IPluginGame const *game)
{
- NXMRequestInfo requestInfo(modIDs, NXMRequestInfo::TYPE_GETUPDATES, userData, subModule, url, GameInfo::instance().getNexusGameID());
+ NXMRequestInfo requestInfo(modIDs, NXMRequestInfo::TYPE_GETUPDATES, userData, subModule, game);
m_RequestQueue.enqueue(requestInfo);
connect(this, SIGNAL(nxmUpdatesAvailable(std::vector<int>,QVariant,QVariant,int)),
@@ -300,9 +296,9 @@ void NexusInterface::fakeFiles()
int NexusInterface::requestFiles(int modID, QObject *receiver, QVariant userData,
- const QString &subModule, const QString &url)
+ const QString &subModule, MOBase::IPluginGame const *game)
{
- NXMRequestInfo requestInfo(modID, NXMRequestInfo::TYPE_FILES, userData, subModule, url, GameInfo::instance().getNexusGameID());
+ NXMRequestInfo requestInfo(modID, NXMRequestInfo::TYPE_FILES, userData, subModule, game);
m_RequestQueue.enqueue(requestInfo);
connect(this, SIGNAL(nxmFilesAvailable(int,QVariant,QVariant,int)),
receiver, SLOT(nxmFilesAvailable(int,QVariant,QVariant,int)), Qt::UniqueConnection);
@@ -320,9 +316,9 @@ int NexusInterface::requestFiles(int modID, QObject *receiver, QVariant userData
int NexusInterface::requestFileInfo(int modID, int fileID, QObject *receiver, QVariant userData, const QString &subModule,
- const QString &url)
+ MOBase::IPluginGame const *game)
{
- NXMRequestInfo requestInfo(modID, fileID, NXMRequestInfo::TYPE_FILEINFO, userData, subModule, url, GameInfo::instance().getNexusGameID());
+ NXMRequestInfo requestInfo(modID, fileID, NXMRequestInfo::TYPE_FILEINFO, userData, subModule, game);
m_RequestQueue.enqueue(requestInfo);
connect(this, SIGNAL(nxmFileInfoAvailable(int,int,QVariant,QVariant,int)),
@@ -337,9 +333,9 @@ int NexusInterface::requestFileInfo(int modID, int fileID, QObject *receiver, QV
int NexusInterface::requestDownloadURL(int modID, int fileID, QObject *receiver, QVariant userData,
- const QString &subModule, const QString &url)
+ const QString &subModule, MOBase::IPluginGame const *game)
{
- NXMRequestInfo requestInfo(modID, fileID, NXMRequestInfo::TYPE_DOWNLOADURL, userData, subModule, url, GameInfo::instance().getNexusGameID());
+ NXMRequestInfo requestInfo(modID, fileID, NXMRequestInfo::TYPE_DOWNLOADURL, userData, subModule, game);
m_RequestQueue.enqueue(requestInfo);
connect(this, SIGNAL(nxmDownloadURLsAvailable(int,int,QVariant,QVariant,int)),
@@ -354,9 +350,9 @@ int NexusInterface::requestDownloadURL(int modID, int fileID, QObject *receiver,
int NexusInterface::requestToggleEndorsement(int modID, bool endorse, QObject *receiver, QVariant userData,
- const QString &subModule, const QString &url)
+ const QString &subModule, MOBase::IPluginGame const *game)
{
- NXMRequestInfo requestInfo(modID, NXMRequestInfo::TYPE_TOGGLEENDORSEMENT, userData, subModule, url, GameInfo::instance().getNexusGameID());
+ NXMRequestInfo requestInfo(modID, NXMRequestInfo::TYPE_TOGGLEENDORSEMENT, userData, subModule, game);
requestInfo.m_Endorse = endorse;
m_RequestQueue.enqueue(requestInfo);
@@ -557,13 +553,18 @@ void NexusInterface::requestTimeout()
}
}
+void NexusInterface::managedGameChanged(IPluginGame const *game)
+{
+ m_Game = game;
+}
+
NexusInterface::NXMRequestInfo::NXMRequestInfo(int modID
, NexusInterface::NXMRequestInfo::Type type
, QVariant userData
, const QString &subModule
- , const QString &url
- , int nexusGameId)
+ , MOBase::IPluginGame const *game
+ )
: m_ModID(modID)
, m_FileID(0)
, m_Reply(nullptr)
@@ -572,9 +573,9 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(int modID
, m_Timeout(nullptr)
, m_Reroute(false)
, m_ID(s_NextID.fetchAndAddAcquire(1))
- , m_URL(url)
+ , m_URL(game->getNexusManagementURL())
, m_SubModule(subModule)
- , m_NexusGameID(nexusGameId)
+ , m_NexusGameID(game->getNexusGameID())
, m_Endorse(false)
{}
@@ -582,8 +583,8 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(std::vector<int> modIDList
, NexusInterface::NXMRequestInfo::Type type
, QVariant userData
, const QString &subModule
- , const QString &url
- , int nexusGameId)
+ , MOBase::IPluginGame const *game
+ )
: m_ModID(-1)
, m_ModIDList(modIDList)
, m_FileID(0)
@@ -593,9 +594,9 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(std::vector<int> modIDList
, m_Timeout(nullptr)
, m_Reroute(false)
, m_ID(s_NextID.fetchAndAddAcquire(1))
- , m_URL(url)
+ , m_URL(game->getNexusManagementURL())
, m_SubModule(subModule)
- , m_NexusGameID(nexusGameId)
+ , m_NexusGameID(game->getNexusGameID())
, m_Endorse(false)
{}
@@ -604,8 +605,8 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(int modID
, NexusInterface::NXMRequestInfo::Type type
, QVariant userData
, const QString &subModule
- , const QString &url
- , int nexusGameId)
+ , MOBase::IPluginGame const *game
+ )
: m_ModID(modID)
, m_FileID(fileID)
, m_Reply(nullptr)
@@ -614,8 +615,8 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(int modID
, m_Timeout(nullptr)
, m_Reroute(false)
, m_ID(s_NextID.fetchAndAddAcquire(1))
- , m_URL(url)
+ , m_URL(game->getNexusManagementURL())
, m_SubModule(subModule)
- , m_NexusGameID(nexusGameId)
+ , m_NexusGameID(game->getNexusGameID())
, m_Endorse(false)
{}
diff --git a/src/nexusinterface.h b/src/nexusinterface.h
index c0ee50cd..9f129510 100644
--- a/src/nexusinterface.h
+++ b/src/nexusinterface.h
@@ -20,20 +20,21 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#ifndef NEXUSINTERFACE_H
#define NEXUSINTERFACE_H
-
-
#include <utility.h>
#include <gameinfo.h>
#include <versioninfo.h>
#include <imodrepositorybridge.h>
+
#include <QNetworkReply>
#include <QNetworkDiskCache>
#include <QQueue>
#include <QVariant>
#include <QTimer>
+
#include <list>
#include <set>
+namespace MOBase { class IPluginGame; }
class NexusInterface;
class NXMAccessManager;
@@ -108,10 +109,6 @@ public slots:
private:
- QString url();
-
-private:
-
NexusInterface *m_Interface;
QString m_Url;
QString m_SubModule;
@@ -150,26 +147,64 @@ public:
/**
* @brief request description for a mod
*
+ * @param modID id of the mod caller is interested in (assumed to be for the current game)
+ * @param receiver the object to receive the result asynchronously via a signal (nxmDescriptionAvailable)
+ * @param userData user data to be returned with the result
+ * @return int an id to identify the request
+ **/
+ int requestDescription(int modID, QObject *receiver, QVariant userData, const QString &subModule)
+ {
+ return requestDescription(modID, receiver, userData, subModule, m_Game);
+ }
+
+ /**
+ * @brief request description for a mod
+ *
* @param modID id of the mod caller is interested in
* @param receiver the object to receive the result asynchronously via a signal (nxmDescriptionAvailable)
* @param userData user data to be returned with the result
- * @param url the url to request from
+ * @param game Game with which the mod is associated
* @return int an id to identify the request
**/
int requestDescription(int modID, QObject *receiver, QVariant userData, const QString &subModule,
- const QString &url = MOBase::ToQString(MOShared::GameInfo::instance().getNexusInfoUrl()),
- int nexusGameId = -1);
+ MOBase::IPluginGame const *game);
+
+ /**
+ * @brief request nexus descriptions for multiple mods at once
+ * @param modIDs a list of ids of mods the caller is interested in (assumed to be for the current game)
+ * @param receiver the object to receive the result asynchronously via a signal (nxmDescriptionAvailable)
+ * @param userData user data to be returned with the result
+ * @return int an id to identify the request
+ */
+ int requestUpdates(const std::vector<int> &modIDs, QObject *receiver, QVariant userData, const QString &subModule)
+ {
+ return requestUpdates(modIDs, receiver, userData, subModule, m_Game);
+ }
/**
* @brief request nexus descriptions for multiple mods at once
* @param modIDs a list of ids of mods the caller is interested in
* @param receiver the object to receive the result asynchronously via a signal (nxmDescriptionAvailable)
* @param userData user data to be returned with the result
- * @param url the url to request from
+ * @param game the game with which the mods are associated
* @return int an id to identify the request
*/
int requestUpdates(const std::vector<int> &modIDs, QObject *receiver, QVariant userData, const QString &subModule,
- const QString &url = MOBase::ToQString(MOShared::GameInfo::instance().getNexusInfoUrl()));
+ MOBase::IPluginGame const *game);
+
+ /**
+ * @brief request a list of the files belonging to a mod
+ *
+ * @param modID id of the mod caller is interested in (assumed to be for the current game)
+ * @param receiver the object to receive the result asynchronously via a signal (nxmFilesAvailable)
+ * @param userData user data to be returned with the result
+ * @return int an id to identify the request
+ **/
+ int requestFiles(int modID, QObject *receiver, QVariant userData, const QString &subModule)
+ {
+ return requestFiles(modID, receiver, userData, subModule, m_Game);
+ }
+
/**
* @brief request a list of the files belonging to a mod
@@ -177,24 +212,52 @@ public:
* @param modID id of the mod caller is interested in
* @param receiver the object to receive the result asynchronously via a signal (nxmFilesAvailable)
* @param userData user data to be returned with the result
- * @param url the url to request from
+ * @param game the game with which the mods are associated
* @return int an id to identify the request
**/
int requestFiles(int modID, QObject *receiver, QVariant userData, const QString &subModule,
- const QString &url = MOBase::ToQString(MOShared::GameInfo::instance().getNexusInfoUrl()));
+ MOBase::IPluginGame const *game);
/**
* @brief request info about a single file of a mod
*
- * @param modID id of the mod caller is interested in
+ * @param modID id of the mod caller is interested in (assumed to be for the current game)
* @param fileID id of the file the caller is interested in
* @param receiver the object to receive the result asynchronously via a signal (nxmFilesAvailable)
* @param userData user data to be returned with the result
- * @param url the url to request from
+ * @return int an id to identify the request
+ **/
+ int requestFileInfo(int modID, int fileID, QObject *receiver, QVariant userData, const QString &subModule)
+ {
+ return requestFileInfo(modID, fileID, receiver, userData, subModule, m_Game);
+ }
+
+ /**
+ * @brief request info about a single file of a mod
+ *
+ * @param modID id of the mod caller is interested in (assumed to be for the current game)
+ * @param fileID id of the file the caller is interested in
+ * @param receiver the object to receive the result asynchronously via a signal (nxmFilesAvailable)
+ * @param userData user data to be returned with the result
+ * @param game the game with which the mods are associated
* @return int an id to identify the request
**/
int requestFileInfo(int modID, int fileID, QObject *receiver, QVariant userData, const QString &subModule,
- const QString &url = MOBase::ToQString(MOShared::GameInfo::instance().getNexusInfoUrl()));
+ MOBase::IPluginGame const *game);
+
+ /**
+ * @brief request the download url of a file
+ *
+ * @param modID id of the mod caller is interested in (assumed to be for the current game)
+ * @param fileID id of the file the caller is interested in
+ * @param receiver the object to receive the result asynchronously via a signal (nxmFilesAvailable)
+ * @param userData user data to be returned with the result
+ * @return int an id to identify the request
+ **/
+ int requestDownloadURL(int modID, int fileID, QObject *receiver, QVariant userData, const QString &subModule)
+ {
+ return requestDownloadURL(modID, fileID, receiver, userData, subModule, m_Game);
+ }
/**
* @brief request the download url of a file
@@ -203,11 +266,23 @@ public:
* @param fileID id of the file the caller is interested in
* @param receiver the object to receive the result asynchronously via a signal (nxmFilesAvailable)
* @param userData user data to be returned with the result
- * @param url the url to request from
+ * @param game the game with which the mods are associated
* @return int an id to identify the request
**/
- int requestDownloadURL(int modID, int fileID, QObject *receiver, QVariant userData, const QString &subModule,
- const QString &url = MOBase::ToQString(MOShared::GameInfo::instance().getNexusInfoUrl()));
+ int requestDownloadURL(int modID, int fileID, QObject *receiver, QVariant userData, const QString &subModule, MOBase::IPluginGame const *game);
+
+ /**
+ * @brief toggle endorsement state of the mod
+ * @param modID id of the mod (assumed to be for the current game)
+ * @param endorse true if the mod should be endorsed, false for un-endorse
+ * @param receiver the object to receive the result asynchronously via a signal (nxmFilesAvailable)
+ * @param userData user data to be returned with the result
+ * @return int an id to identify the request
+ */
+ int requestToggleEndorsement(int modID, bool endorse, QObject *receiver, QVariant userData, const QString &subModule)
+ {
+ return requestToggleEndorsement(modID, endorse, receiver, userData, subModule, m_Game);
+ }
/**
* @brief toggle endorsement state of the mod
@@ -215,11 +290,11 @@ public:
* @param endorse true if the mod should be endorsed, false for un-endorse
* @param receiver the object to receive the result asynchronously via a signal (nxmFilesAvailable)
* @param userData user data to be returned with the result
- * @param url the url to request from
+ * @param game the game with which the mods are associated
* @return int an id to identify the request
*/
int requestToggleEndorsement(int modID, bool endorse, QObject *receiver, QVariant userData, const QString &subModule,
- const QString &url = MOBase::ToQString(MOShared::GameInfo::instance().getNexusInfoUrl()));
+ MOBase::IPluginGame const *game);
/**
* @param directory the directory to store cache files
@@ -247,6 +322,11 @@ public:
*/
static void interpretNexusFileName(const QString &fileName, QString &modName, int &modID, bool query);
+ /**
+ * @brief get the currently managed game
+ */
+ MOBase::IPluginGame const *managedGame() const;
+
signals:
void requestNXMDownload(const QString &url);
@@ -261,6 +341,9 @@ signals:
void nxmEndorsementToggled(int modID, QVariant userData, QVariant resultData, int requestID);
void nxmRequestFailed(int modID, int fileID, QVariant userData, int requestID, const QString &errorString);
+public slots:
+ void managedGameChanged(MOBase::IPluginGame const *game);
+
private slots:
void requestFinished();
@@ -295,9 +378,9 @@ private:
int m_ID;
int m_Endorse;
- NXMRequestInfo(int modID, Type type, QVariant userData, const QString &subModule, const QString &url, int nexusGameId);
- NXMRequestInfo(std::vector<int> modIDList, Type type, QVariant userData, const QString &subModule, const QString &url, int nexusGameId);
- NXMRequestInfo(int modID, int fileID, Type type, QVariant userData, const QString &subModule, const QString &url, int nexusGameId);
+ NXMRequestInfo(int modID, Type type, QVariant userData, const QString &subModule, MOBase::IPluginGame const *game);
+ NXMRequestInfo(std::vector<int> modIDList, Type type, QVariant userData, const QString &subModule, MOBase::IPluginGame const *game);
+ NXMRequestInfo(int modID, int fileID, Type type, QVariant userData, const QString &subModule, MOBase::IPluginGame const *game);
private:
static QAtomicInt s_NextID;
@@ -324,6 +407,8 @@ private:
MOBase::VersionInfo m_MOVersion;
QString m_NMMVersion;
+ MOBase::IPluginGame const *m_Game;
+
};
#endif // NEXUSINTERFACE_H
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index c3e10d37..7473ec3e 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -1,5 +1,6 @@
#include "organizercore.h"
+#include "iplugingame.h"
#include "mainwindow.h"
#include "messagedialog.h"
#include "logbuffer.h"
@@ -19,11 +20,14 @@
#include <appconfig.h>
#include <report.h>
#include <questionboxmemory.h>
+
#include <QNetworkInterface>
#include <QMessageBox>
#include <QDialogButtonBox>
#include <QApplication>
+
#include <Psapi.h>
+
#include <functional>
@@ -158,9 +162,10 @@ OrganizerCore::OrganizerCore(const QSettings &initSettings)
connect(NexusInterface::instance()->getAccessManager(), SIGNAL(loginSuccessful(bool)), this, SLOT(loginSuccessful(bool)));
connect(NexusInterface::instance()->getAccessManager(), SIGNAL(loginFailed(QString)), this, SLOT(loginFailed(QString)));
- connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame*)), &m_Settings, SLOT(managedGameChanged(MOBase::IPluginGame*)));
- connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame*)), &m_DownloadManager, SLOT(managedGameChanged(MOBase::IPluginGame*)));
- connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame*)), &m_PluginList, SLOT(managedGameChanged(MOBase::IPluginGame*)));
+ connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame const *)), &m_Settings, SLOT(managedGameChanged(MOBase::IPluginGame const *)));
+ connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame const *)), &m_DownloadManager, SLOT(managedGameChanged(MOBase::IPluginGame const *)));
+ connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame const *)), &m_PluginList, SLOT(managedGameChanged(MOBase::IPluginGame const *)));
+ connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame const *)), NexusInterface::instance(), SLOT(managedGameChanged(MOBase::IPluginGame const *)));
connect(&m_PluginList, &PluginList::writePluginsList, &m_PluginListsWriter, &DelayedFileWriterBase::write);
@@ -393,6 +398,14 @@ void OrganizerCore::connectPlugins(PluginContainer *container)
m_GamePlugin = m_PluginContainer->managedGame(m_GameName);
emit managedGameChanged(m_GamePlugin);
}
+ //Do this the hard way
+ for (const IPluginGame * const game : container->plugins<IPluginGame>()) {
+ QString n = game->getNexusName();
+ if (game->getNexusName() == "Skyrim") {
+ m_Updater.setNexusDownload(game);
+ break;
+ }
+ }
}
void OrganizerCore::disconnectPlugins()
@@ -1308,7 +1321,12 @@ PluginListSortProxy *OrganizerCore::createPluginListProxyModel()
return result;
}
-IPluginGame *OrganizerCore::managedGame() const
+IPluginGame const *OrganizerCore::managedGame() const
+{
+ return m_GamePlugin;
+}
+
+IPluginGame *OrganizerCore::managedGameForUpdate() const
{
return m_GamePlugin;
}
diff --git a/src/organizercore.h b/src/organizercore.h
index a673065a..c206e5e7 100644
--- a/src/organizercore.h
+++ b/src/organizercore.h
@@ -99,7 +99,8 @@ public:
ModListSortProxy *createModListProxyModel();
PluginListSortProxy *createPluginListProxyModel();
- MOBase::IPluginGame *managedGame() const;
+ MOBase::IPluginGame const *managedGame() const;
+ MOBase::IPluginGame *managedGameForUpdate() const;
bool isArchivesInit() const { return m_ArchivesInit; }
diff --git a/src/selfupdater.cpp b/src/selfupdater.cpp
index 7e42f322..8fb204d8 100644
--- a/src/selfupdater.cpp
+++ b/src/selfupdater.cpp
@@ -18,16 +18,18 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
*/
#include "selfupdater.h"
+
#include "utility.h"
#include "installationmanager.h"
+#include "iplugingame.h"
#include "messagedialog.h"
#include "downloadmanager.h"
#include "nexusinterface.h"
#include "nxmaccessmanager.h"
#include <versioninfo.h>
-#include <gameinfo.h>
-#include <skyriminfo.h>
#include <report.h>
+#include <util.h>
+
#include <QMessageBox>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
@@ -35,7 +37,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <QLibrary>
#include <QProcess>
#include <QApplication>
-#include <util.h>
#include <boost/bind.hpp>
@@ -62,6 +63,7 @@ SelfUpdater::SelfUpdater(NexusInterface *nexusInterface)
, m_UpdateRequestID(-1)
, m_Reply(nullptr)
, m_Attempts(3)
+ , m_NexusDownload(nullptr)
{
QLibrary archiveLib("dlls\\archive.dll");
if (!archiveLib.load()) {
@@ -101,12 +103,10 @@ void SelfUpdater::testForUpdate()
emit updateAvailable();
return;
}
-
- if (m_UpdateRequestID == -1) {
+ if (m_UpdateRequestID == -1 && m_NexusDownload != nullptr) {
m_UpdateRequestID = m_Interface->requestDescription(
- SkyrimInfo::getNexusModIDStatic(), this, QVariant(),
- QString(), ToQString(SkyrimInfo::getNexusInfoUrlStatic()),
- SkyrimInfo::getNexusGameIDStatic());
+ m_NexusDownload->getNexusModOrganizerID(), this, QVariant(),
+ QString(), m_NexusDownload);
}
}
@@ -123,9 +123,9 @@ void SelfUpdater::startUpdate()
if (QMessageBox::question(m_Parent, tr("Update"),
tr("An update is available (newest version: %1), do you want to install it?").arg(m_NewestVersion),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
- m_UpdateRequestID = m_Interface->requestFiles(SkyrimInfo::getNexusModIDStatic(),
- this, m_NewestVersion,
- ToQString(SkyrimInfo::getNexusInfoUrlStatic()));
+ m_UpdateRequestID = m_Interface->requestFiles(m_NexusDownload->getNexusModOrganizerID(),
+ this, m_NewestVersion, "",
+ m_NexusDownload);
}
}
}
@@ -434,18 +434,18 @@ void SelfUpdater::nxmFilesAvailable(int, QVariant userData, QVariant resultData,
if (updateFileID != -1) {
qDebug("update available: %d", updateFileID);
- m_UpdateRequestID = m_Interface->requestDownloadURL(SkyrimInfo::getNexusModIDStatic(),
- updateFileID, this, updateFileName,
- ToQString(SkyrimInfo::getNexusInfoUrlStatic()));
+ m_UpdateRequestID = m_Interface->requestDownloadURL(m_NexusDownload->getNexusModOrganizerID(),
+ updateFileID, this, updateFileName, "",
+ m_NexusDownload);
} else if (mainFileID != -1) {
qDebug("full download required: %d", mainFileID);
if (QMessageBox::question(m_Parent, tr("Update"),
tr("No incremental update available for this version, "
"the complete package needs to be downloaded (%1 kB)").arg(mainFileSize),
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
- m_UpdateRequestID = m_Interface->requestDownloadURL(SkyrimInfo::getNexusModIDStatic(),
- mainFileID, this, mainFileName,
- ToQString(SkyrimInfo::getNexusInfoUrlStatic()));
+ m_UpdateRequestID = m_Interface->requestDownloadURL(m_NexusDownload->getNexusModOrganizerID(),
+ mainFileID, this, mainFileName, "",
+ m_NexusDownload);
}
} else {
qCritical("no file for update found");
@@ -489,3 +489,9 @@ void SelfUpdater::nxmDownloadURLsAvailable(int, int, QVariant userData, QVariant
}
}
}
+
+/** Set the game check for updates */
+void SelfUpdater::setNexusDownload(MOBase::IPluginGame const *game)
+{
+ m_NexusDownload = game;
+}
diff --git a/src/selfupdater.h b/src/selfupdater.h
index 143b05cb..4fdc3d7d 100644
--- a/src/selfupdater.h
+++ b/src/selfupdater.h
@@ -29,6 +29,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <QFile>
#include <QProgressDialog>
+namespace MOBase { class IPluginGame; }
class NexusInterface;
@@ -83,6 +84,9 @@ public:
**/
MOBase::VersionInfo getVersion() const { return m_MOVersion; }
+ /** Set the game check for updates */
+ void setNexusDownload(MOBase::IPluginGame const *game);
+
public slots:
/**
@@ -146,6 +150,7 @@ private:
Archive *m_CurrentArchive;
+ MOBase::IPluginGame const *m_NexusDownload;
};
diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp
index 67dc85e0..cb2a3adf 100644
--- a/src/shared/fallout3info.cpp
+++ b/src/shared/fallout3info.cpp
@@ -87,11 +87,6 @@ std::wstring Fallout3Info::getNexusPage(bool nmmScheme)
}
}
-std::wstring Fallout3Info::getNexusInfoUrlStatic()
-{
- return L"http://nmm.nexusmods.com/fallout3";
-}
-
bool Fallout3Info::rerouteToProfile(const wchar_t *fileName, const wchar_t*)
{
static LPCWSTR profileFiles[] = { L"fallout.ini", L"falloutprefs.ini", L"plugins.txt", nullptr };
diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h
index 3688bc2e..b5585eaf 100644
--- a/src/shared/fallout3info.h
+++ b/src/shared/fallout3info.h
@@ -50,8 +50,6 @@ public:
virtual std::wstring getReferenceDataFile();
virtual std::wstring getNexusPage(bool nmmScheme = true);
- static std::wstring getNexusInfoUrlStatic();
- virtual std::wstring getNexusInfoUrl() { return getNexusInfoUrlStatic(); }
virtual int getNexusGameID() { return 120; }
virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath);
diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp
index c1eea4da..bfc31c0b 100644
--- a/src/shared/falloutnvinfo.cpp
+++ b/src/shared/falloutnvinfo.cpp
@@ -88,12 +88,6 @@ std::wstring FalloutNVInfo::getNexusPage(bool nmmScheme)
}
-std::wstring FalloutNVInfo::getNexusInfoUrlStatic()
-{
- return L"http://nmm.nexusmods.com/newvegas";
-}
-
-
bool FalloutNVInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t*)
{
static LPCWSTR profileFiles[] = { L"fallout.ini", L"falloutprefs.ini", L"plugins.txt", nullptr };
diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h
index 024ad9aa..40e11720 100644
--- a/src/shared/falloutnvinfo.h
+++ b/src/shared/falloutnvinfo.h
@@ -50,8 +50,6 @@ public:
virtual std::wstring getReferenceDataFile();
virtual std::wstring getNexusPage(bool nmmScheme = true);
- static std::wstring getNexusInfoUrlStatic();
- virtual std::wstring getNexusInfoUrl() { return getNexusInfoUrlStatic(); }
virtual int getNexusGameID() { return 130; }
virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath);
diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h
index 49b3133b..45069165 100644
--- a/src/shared/gameinfo.h
+++ b/src/shared/gameinfo.h
@@ -79,9 +79,7 @@ public:
virtual std::wstring getReferenceDataFile() = 0;
virtual std::wstring getNexusPage(bool nmmScheme = true) = 0;
- virtual std::wstring getNexusInfoUrl() = 0;
virtual int getNexusGameID() = 0;
- //**Still used: SkyrimInfo::getNexusModIDStatic
//**USED ONLY IN HOOKDLL
virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) = 0;
diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp
index 4cd03ae8..9bd5f4b1 100644
--- a/src/shared/oblivioninfo.cpp
+++ b/src/shared/oblivioninfo.cpp
@@ -91,12 +91,6 @@ std::wstring OblivionInfo::getNexusPage(bool nmmScheme)
}
-std::wstring OblivionInfo::getNexusInfoUrlStatic()
-{
- return L"http://nmm.nexusmods.com/oblivion";
-}
-
-
bool OblivionInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t*)
{
static LPCWSTR profileFiles[] = { L"oblivion.ini", L"oblivionprefs.ini", L"plugins.txt", nullptr };
diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h
index b298ed0a..b6b3d867 100644
--- a/src/shared/oblivioninfo.h
+++ b/src/shared/oblivioninfo.h
@@ -48,8 +48,6 @@ public:
virtual std::wstring getReferenceDataFile();
virtual std::wstring getNexusPage(bool nmmScheme = true);
- static std::wstring getNexusInfoUrlStatic();
- virtual std::wstring getNexusInfoUrl() { return getNexusInfoUrlStatic(); }
virtual int getNexusGameID() { return 101; }
virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath);
diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp
index f7fba7ab..9b192902 100644
--- a/src/shared/skyriminfo.cpp
+++ b/src/shared/skyriminfo.cpp
@@ -99,17 +99,6 @@ std::wstring SkyrimInfo::getNexusPage(bool nmmScheme)
}
-std::wstring SkyrimInfo::getNexusInfoUrlStatic()
-{
- return L"http://nmm.nexusmods.com/skyrim";
-}
-
-
-int SkyrimInfo::getNexusModIDStatic()
-{
- return 1334;
-}
-
bool SkyrimInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath)
{
static LPCWSTR profileFiles[] = { L"skyrim.ini", L"skyrimprefs.ini", L"loadorder.txt", nullptr };
diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h
index 93e2a948..ee81ace3 100644
--- a/src/shared/skyriminfo.h
+++ b/src/shared/skyriminfo.h
@@ -51,9 +51,6 @@ public:
virtual std::wstring getNexusPage(bool nmmScheme = true);
- static std::wstring getNexusInfoUrlStatic();
- virtual std::wstring getNexusInfoUrl() { return getNexusInfoUrlStatic(); }
- static int getNexusModIDStatic();
static int getNexusGameIDStatic() { return 110; }
virtual int getNexusGameID() { return getNexusGameIDStatic(); }