From 38c5899fef2f21561a00bd5b1df3eff8577ec986 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Wed, 25 Nov 2015 19:31:05 +0000 Subject: Replace GameInfo::getNexusInfoUrl with IPluginGame::getNexusManagementUrl also added getNexusDisplayUrl for the other variant of getNexusPage Removed skyrim static versions note that Nexusinterface is now passed a game plugin rather than a URL and a game ID if you want to override the current game --- src/nexusinterface.cpp | 81 +++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 40 deletions(-) (limited to 'src/nexusinterface.cpp') 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 . */ #include "nexusinterface.h" + +#include "iplugingame.h" #include "nxmaccessmanager.h" #include "json.h" #include "selectiondialog.h" -#include #include -#include #include +#include + +#include + 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 &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,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 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 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) {} -- cgit v1.3.1 From 29dadf52f1c217ddee7ef9e0873cb4e12797318b Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Wed, 25 Nov 2015 20:40:34 +0000 Subject: Forgot to remove the redundant member --- src/mainwindow.cpp | 2 +- src/nexusinterface.cpp | 1 - src/nexusinterface.h | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) (limited to 'src/nexusinterface.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f3ffdf6c..2d90d5b8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3814,7 +3814,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(ToQString(GameInfo::instance().getNexusPage())), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { - //Why pass an empty variant of we're toggling an endorsement? + //Why pass an empty variant if we're toggling an endorsement? NexusInterface::instance()->requestToggleEndorsement( m_OrganizerCore.managedGame()->getNexusModOrganizerID(), true, this, QVariant(), ""); } diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index cbb9ad48..078ca29d 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -37,7 +37,6 @@ using namespace MOShared; NexusBridge::NexusBridge(const QString &subModule) : m_Interface(NexusInterface::instance()) - , m_Url() //Lazily initialised (but redundant) , m_SubModule(subModule) { } diff --git a/src/nexusinterface.h b/src/nexusinterface.h index 9f129510..091b5446 100644 --- a/src/nexusinterface.h +++ b/src/nexusinterface.h @@ -110,7 +110,6 @@ public slots: private: NexusInterface *m_Interface; - QString m_Url; QString m_SubModule; std::set m_RequestIDs; -- cgit v1.3.1 From 82e6c98043bd18f5329e8b6d0a6f99c4d28cc0a2 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Thu, 26 Nov 2015 07:39:35 +0000 Subject: Replace last occurrence of GameInfo::getNexusGameID and remove a whole load of gameinfo.h includes --- src/browserdialog.cpp | 6 ++---- src/categories.cpp | 4 ++-- src/directoryrefresher.cpp | 1 - src/executableslist.cpp | 8 +++++--- src/executableslist.h | 5 +++-- src/installationmanager.cpp | 7 +++++-- src/mainwindow.cpp | 2 ++ src/modinfo.cpp | 1 - src/modlist.cpp | 5 +++-- src/nexusinterface.cpp | 1 + src/nexusinterface.h | 1 - src/nxmaccessmanager.cpp | 15 +++++++++++++-- src/nxmaccessmanager.h | 7 ++++++- src/organizercore.cpp | 1 + src/organizerproxy.cpp | 1 - src/pluginlist.cpp | 1 - src/settingsdialog.cpp | 3 +-- src/shared/fallout3info.h | 1 - src/shared/falloutnvinfo.h | 1 - src/shared/gameinfo.h | 33 +++++++++++++-------------------- src/shared/oblivioninfo.h | 1 - src/shared/skyriminfo.h | 1 - src/spawn.cpp | 8 +++++--- src/syncoverwritedialog.cpp | 3 ++- src/transfersavesdialog.cpp | 5 ++++- src/transfersavesdialog.h | 6 ++---- 26 files changed, 70 insertions(+), 58 deletions(-) (limited to 'src/nexusinterface.cpp') diff --git a/src/browserdialog.cpp b/src/browserdialog.cpp index c382c112..bbdf95c5 100644 --- a/src/browserdialog.cpp +++ b/src/browserdialog.cpp @@ -18,18 +18,16 @@ along with Mod Organizer. If not, see . */ #include "browserdialog.h" + #include "ui_browserdialog.h" #include "browserview.h" - #include "messagedialog.h" #include "report.h" #include "persistentcookiejar.h" - #include "json.h" - #include -#include #include "settings.h" + #include #include #include diff --git a/src/categories.cpp b/src/categories.cpp index 400cc74b..59291a49 100644 --- a/src/categories.cpp +++ b/src/categories.cpp @@ -18,9 +18,10 @@ along with Mod Organizer. If not, see . */ #include "categories.h" + #include #include -#include + #include #include #include @@ -29,7 +30,6 @@ along with Mod Organizer. If not, see . using namespace MOBase; -using namespace MOShared; CategoryFactory* CategoryFactory::s_Instance = nullptr; diff --git a/src/directoryrefresher.cpp b/src/directoryrefresher.cpp index f4ad2a7d..4eac4103 100644 --- a/src/directoryrefresher.cpp +++ b/src/directoryrefresher.cpp @@ -23,7 +23,6 @@ along with Mod Organizer. If not, see . #include "utility.h" #include "report.h" #include "modinfo.h" -#include #include #include diff --git a/src/executableslist.cpp b/src/executableslist.cpp index 2182a425..a4511ade 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -18,16 +18,18 @@ along with Mod Organizer. If not, see . */ #include "executableslist.h" -#include + +#include "iplugingame.h" +#include "utility.h" + #include #include #include -#include "utility.h" + #include using namespace MOBase; -using namespace MOShared; ExecutablesList::ExecutablesList() diff --git a/src/executableslist.h b/src/executableslist.h index 833829c8..3d5ba0ed 100644 --- a/src/executableslist.h +++ b/src/executableslist.h @@ -20,13 +20,14 @@ along with Mod Organizer. If not, see . #ifndef EXECUTABLESLIST_H #define EXECUTABLESLIST_H +#include "executableinfo.h" #include + #include #include -#include -#include +namespace MOBase { class IPluginGame; } /*! * @brief Information about an executable diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index a6af1a7f..4b3722b8 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -18,6 +18,7 @@ along with Mod Organizer. If not, see . */ #include "installationmanager.h" + #include "utility.h" #include "report.h" #include "categories.h" @@ -32,9 +33,9 @@ along with Mod Organizer. If not, see . #include "modinfo.h" #include #include -#include #include #include + #include #include #include @@ -42,11 +43,13 @@ along with Mod Organizer. If not, see . #include #include #include -#include #include #include #include #include + +#include + #include #include diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2d90d5b8..3a2da562 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -68,6 +68,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include "gameinfo.h" #include #include @@ -113,6 +114,7 @@ along with Mod Organizer. If not, see . #include #include #include + #ifndef Q_MOC_RUN #include #include diff --git a/src/modinfo.cpp b/src/modinfo.cpp index df34c00f..ef195bea 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -29,7 +29,6 @@ along with Mod Organizer. If not, see . #include "messagedialog.h" #include "filenamestring.h" -#include #include #include #include diff --git a/src/modlist.cpp b/src/modlist.cpp index 197250a3..9d7f32c8 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -24,15 +24,14 @@ along with Mod Organizer. If not, see . #include "qtgroupingproxy.h" #include "viewmarkingscrollbar.h" #include "modlistsortproxy.h" -#include #include #include #include + #include #include #include #include -#include #include #include #include @@ -44,7 +43,9 @@ along with Mod Organizer. If not, see . #include #include #include + #include +#include #include diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index 078ca29d..8a7c88b6 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -555,6 +555,7 @@ void NexusInterface::requestTimeout() void NexusInterface::managedGameChanged(IPluginGame const *game) { m_Game = game; + m_AccessManager->managedGameChanged(game); } diff --git a/src/nexusinterface.h b/src/nexusinterface.h index 091b5446..807d0aec 100644 --- a/src/nexusinterface.h +++ b/src/nexusinterface.h @@ -21,7 +21,6 @@ along with Mod Organizer. If not, see . #define NEXUSINTERFACE_H #include -#include #include #include diff --git a/src/nxmaccessmanager.cpp b/src/nxmaccessmanager.cpp index 0763bb71..08572d50 100644 --- a/src/nxmaccessmanager.cpp +++ b/src/nxmaccessmanager.cpp @@ -18,6 +18,8 @@ along with Mod Organizer. If not, see . */ #include "nxmaccessmanager.h" + +#include "iplugingame.h" #include "nxmurl.h" #include "report.h" #include "utility.h" @@ -26,6 +28,7 @@ along with Mod Organizer. If not, see . #include "settings.h" #include #include + #include #include #include @@ -127,9 +130,13 @@ void NXMAccessManager::startLoginCheck() void NXMAccessManager::retrieveCredentials() { qDebug("retrieving credentials"); - QNetworkRequest request(ToQString(GameInfo::instance().getNexusPage()) + + //This may be overkill as + //www.nexusmods.com/Core/Libs/Flamework/Entities/User?GetCredentials + //seems to work fine. + QNetworkRequest request(m_Game->getNexusManagementURL() + QString("/Core/Libs/Flamework/Entities/User?GetCredentials&game_id=%1" - ).arg(GameInfo::instance().getNexusGameID())); + ).arg(m_Game->getNexusGameID())); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); request.setRawHeader("User-Agent", userAgent().toUtf8()); @@ -339,3 +346,7 @@ void NXMAccessManager::loginChecked() m_LoginReply = nullptr; } +void NXMAccessManager::managedGameChanged(MOBase::IPluginGame const *game) +{ + m_Game = game; +} diff --git a/src/nxmaccessmanager.h b/src/nxmaccessmanager.h index a03dbe36..2a016cad 100644 --- a/src/nxmaccessmanager.h +++ b/src/nxmaccessmanager.h @@ -27,6 +27,7 @@ along with Mod Organizer. If not, see . #include #include +namespace MOBase { class IPluginGame; } /** * @brief access manager extended to handle nxm links @@ -84,7 +85,9 @@ private slots: void loginError(QNetworkReply::NetworkError errorCode); void loginTimeout(); -public slots: +public: + //This would be a slot but the NexusInterface code calls this + void managedGameChanged(MOBase::IPluginGame const *game); protected: @@ -127,6 +130,8 @@ private: LOGIN_VALID } m_LoginState = LOGIN_NOT_CHECKED; + MOBase::IPluginGame const *m_Game; + }; #endif // NXMACCESSMANAGER_H diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 7473ec3e..66a3799a 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -162,6 +162,7 @@ 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))); + //This seems awfully imperative 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 *))); diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index fdc60a27..ba07c154 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -1,6 +1,5 @@ #include "organizerproxy.h" -#include #include #include diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 48b27f05..7a609374 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -24,7 +24,6 @@ along with Mod Organizer. If not, see . #include "scopeguard.h" #include "modinfo.h" #include -#include #include #include #include diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 36e177ab..c7f15dc9 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -24,19 +24,18 @@ along with Mod Organizer. If not, see . #include "helper.h" #include "noeditdelegate.h" #include "iplugingame.h" -#include #include "settings.h" #include #include #include #include + #define WIN32_LEAN_AND_MEAN #include using namespace MOBase; -using namespace MOShared; SettingsDialog::SettingsDialog(QWidget *parent) diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h index b5585eaf..e6064825 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -50,7 +50,6 @@ public: virtual std::wstring getReferenceDataFile(); virtual std::wstring getNexusPage(bool nmmScheme = true); - virtual int getNexusGameID() { return 120; } virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath); diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h index 40e11720..aa187fb3 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -50,7 +50,6 @@ public: virtual std::wstring getReferenceDataFile(); virtual std::wstring getNexusPage(bool nmmScheme = true); - 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 45069165..b6a4f142 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -47,29 +47,30 @@ public: TYPE_SKYRIM }; - enum LoadOrderMechanism { - TYPE_FILETIME, - TYPE_PLUGINSTXT - }; - public: virtual ~GameInfo() {} - //**USED ONLY IN HOOKDLL - virtual std::wstring getRegPath() = 0; - //**Used only in savegame which needs refactoring a lot. virtual GameInfo::Type getType() = 0; + //**Used only in savegame which needs refactoring a lot. + // get a list of file extensions for additional files belonging to a save game + virtual std::vector getSavegameAttachmentExtensions() = 0; + //**Currently only used in a nasty mess at initialisation time. virtual std::wstring getGameName() const = 0; //**USED IN HOOKDLL and in initialisation virtual std::wstring getGameDirectory() const; - // get a list of file extensions for additional files belonging to a save game - virtual std::vector getSavegameAttachmentExtensions() = 0; + //**USED IN HOOKDLL and initialisation + // initialise with the path to the mo directory (needs to be where hook.dll is stored). This + // needs to be called before the instance can be retrieved + static bool init(const std::wstring &moDirectory, const std::wstring &gamePath = L""); + + //**USED ONLY IN HOOKDLL + virtual std::wstring getRegPath() = 0; //**USED ONLY IN HOOKDLL // file name of this games ini file(s) @@ -78,20 +79,12 @@ public: //**USED ONLY IN HOOKDLL virtual std::wstring getReferenceDataFile() = 0; - virtual std::wstring getNexusPage(bool nmmScheme = true) = 0; - virtual int getNexusGameID() = 0; - //**USED ONLY IN HOOKDLL virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) = 0; -public: - - //**USED IN HOOKDLL - // initialise with the path to the mo directory (needs to be where hook.dll is stored). This - // needs to be called before the instance can be retrieved - static bool init(const std::wstring &moDirectory, const std::wstring &gamePath = L""); + virtual std::wstring getNexusPage(bool nmmScheme = true) = 0; - //**USED IN HOOKDLL + //**USED IN HOOKDLL and everywhere that uses GameInfo static GameInfo& instance(); protected: diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h index b6b3d867..f9045703 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -48,7 +48,6 @@ public: virtual std::wstring getReferenceDataFile(); virtual std::wstring getNexusPage(bool nmmScheme = true); - virtual int getNexusGameID() { return 101; } virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath); diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h index ee81ace3..47a35b3e 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -52,7 +52,6 @@ public: virtual std::wstring getNexusPage(bool nmmScheme = true); static int getNexusGameIDStatic() { return 110; } - virtual int getNexusGameID() { return getNexusGameIDStatic(); } virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath); diff --git a/src/spawn.cpp b/src/spawn.cpp index c79714bb..49e89a8b 100644 --- a/src/spawn.cpp +++ b/src/spawn.cpp @@ -18,18 +18,20 @@ along with Mod Organizer. If not, see . */ #include "spawn.h" + #include "report.h" #include "utility.h" -#include -#include #include #include -#include #include #include + #include #include +#include + +#include using namespace MOBase; using namespace MOShared; diff --git a/src/syncoverwritedialog.cpp b/src/syncoverwritedialog.cpp index 0e3e98d7..aeed0a55 100644 --- a/src/syncoverwritedialog.cpp +++ b/src/syncoverwritedialog.cpp @@ -18,10 +18,11 @@ along with Mod Organizer. If not, see . */ #include "syncoverwritedialog.h" + #include "ui_syncoverwritedialog.h" #include #include -#include + #include #include #include diff --git a/src/transfersavesdialog.cpp b/src/transfersavesdialog.cpp index d47d2bb0..4cb20944 100644 --- a/src/transfersavesdialog.cpp +++ b/src/transfersavesdialog.cpp @@ -18,12 +18,15 @@ along with Mod Organizer. If not, see . */ #include "transfersavesdialog.h" + #include "ui_transfersavesdialog.h" +#include "iplugingame.h" #include "savegamegamebyro.h" #include "utility.h" -#include + #include #include + #include #include diff --git a/src/transfersavesdialog.h b/src/transfersavesdialog.h index d9ea5b29..e2c556b4 100644 --- a/src/transfersavesdialog.h +++ b/src/transfersavesdialog.h @@ -22,11 +22,9 @@ along with Mod Organizer. If not, see . #include "tutorabledialog.h" #include "profile.h" -#include -namespace Ui { -class TransferSavesDialog; -} +namespace Ui { class TransferSavesDialog; } +namespace MOBase { class IPluginGame; } class SaveGame; -- cgit v1.3.1 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/mainwindow.cpp | 25 ++++++++++++++----------- src/modinfodialog.cpp | 14 +++++++++++--- src/nexusinterface.cpp | 13 +++++++++---- src/nxmaccessmanager.cpp | 35 ++++++++++++----------------------- src/nxmaccessmanager.h | 6 ------ src/shared/fallout3info.cpp | 9 --------- src/shared/fallout3info.h | 2 -- src/shared/falloutnvinfo.cpp | 10 ---------- src/shared/falloutnvinfo.h | 2 -- src/shared/gameinfo.h | 2 -- src/shared/oblivioninfo.cpp | 14 -------------- src/shared/oblivioninfo.h | 2 -- src/shared/skyriminfo.cpp | 11 ----------- src/shared/skyriminfo.h | 4 ---- 14 files changed, 46 insertions(+), 103 deletions(-) (limited to 'src/nexusinterface.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3a2da562..3f3d5286 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -19,6 +19,7 @@ along with Mod Organizer. If not, see . #include "mainwindow.h" #include "ui_mainwindow.h" + #include "spawn.h" #include "report.h" #include "modlist.h" @@ -68,7 +69,7 @@ along with Mod Organizer. If not, see . #include #include #include -#include "gameinfo.h" +#include #include #include @@ -95,10 +96,6 @@ along with Mod Organizer. If not, see . #include #include #include -#include -#include -#include -#include #include #include #include @@ -113,7 +110,6 @@ along with Mod Organizer. If not, see . #endif #include #include -#include #ifndef Q_MOC_RUN #include @@ -123,6 +119,11 @@ along with Mod Organizer. If not, see . #include #endif +#include +#include +#include +#include + #include #include #include @@ -2528,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(ToQString(GameInfo::instance().getNexusPage(false))).arg(modID)); + nexusLinkActivated(QString("%1/mods/%2").arg(m_OrganizerCore.managedGame()->getNexusDisplayURL()).arg(modID)); } else { MessageDialog::showMessage(tr("Nexus ID for this Mod is unknown"), this); } @@ -3420,7 +3421,9 @@ void MainWindow::on_actionSettings_triggered() void MainWindow::on_actionNexus_triggered() { - ::ShellExecuteW(nullptr, L"open", GameInfo::instance().getNexusPage(false).c_str(), nullptr, nullptr, SW_SHOWNORMAL); + ::ShellExecuteW(nullptr, L"open", + m_OrganizerCore.managedGame()->getNexusDisplayURL().toStdWString().c_str(), + nullptr, nullptr, SW_SHOWNORMAL); } @@ -3814,11 +3817,11 @@ void MainWindow::on_actionUpdate_triggered() 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())), + tr("Do you want to endorse Mod Organizer on %1 now?").arg( + m_OrganizerCore.managedGame()->getNexusDisplayURL()), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { - //Why pass an empty variant if we're toggling an endorsement? NexusInterface::instance()->requestToggleEndorsement( - m_OrganizerCore.managedGame()->getNexusModOrganizerID(), true, this, QVariant(), ""); + m_OrganizerCore.managedGame()->getNexusModOrganizerID(), true, this, QVariant(), QString()); } } 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); diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index 8a7c88b6..b6843c57 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -555,9 +555,14 @@ void NexusInterface::requestTimeout() void NexusInterface::managedGameChanged(IPluginGame const *game) { m_Game = game; - m_AccessManager->managedGameChanged(game); } +namespace { + QString get_management_url(MOBase::IPluginGame const *game) + { + return "http://nmm.nexusmods.com/" + game->getNexusName().toLower(); + } +} NexusInterface::NXMRequestInfo::NXMRequestInfo(int modID , NexusInterface::NXMRequestInfo::Type type @@ -573,7 +578,7 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(int modID , m_Timeout(nullptr) , m_Reroute(false) , m_ID(s_NextID.fetchAndAddAcquire(1)) - , m_URL(game->getNexusManagementURL()) + , m_URL(get_management_url(game)) , m_SubModule(subModule) , m_NexusGameID(game->getNexusGameID()) , m_Endorse(false) @@ -594,7 +599,7 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(std::vector modIDList , m_Timeout(nullptr) , m_Reroute(false) , m_ID(s_NextID.fetchAndAddAcquire(1)) - , m_URL(game->getNexusManagementURL()) + , m_URL(get_management_url(game)) , m_SubModule(subModule) , m_NexusGameID(game->getNexusGameID()) , m_Endorse(false) @@ -615,7 +620,7 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(int modID , m_Timeout(nullptr) , m_Reroute(false) , m_ID(s_NextID.fetchAndAddAcquire(1)) - , m_URL(game->getNexusManagementURL()) + , m_URL(get_management_url(game)) , m_SubModule(subModule) , m_NexusGameID(game->getNexusGameID()) , m_Endorse(false) diff --git a/src/nxmaccessmanager.cpp b/src/nxmaccessmanager.cpp index 08572d50..c37131eb 100644 --- a/src/nxmaccessmanager.cpp +++ b/src/nxmaccessmanager.cpp @@ -26,7 +26,6 @@ along with Mod Organizer. If not, see . #include "selfupdater.h" #include "persistentcookiejar.h" #include "settings.h" -#include #include #include @@ -42,10 +41,11 @@ along with Mod Organizer. If not, see . #include #include - using namespace MOBase; -using namespace MOShared; +namespace { + QString const Nexus_Management_URL("http://nmm.nexusmods.com"); +} // unfortunately Nexus doesn't seem to document these states, all I know is all these listed // are considered premium (27 should be lifetime premium) @@ -99,8 +99,7 @@ QNetworkReply *NXMAccessManager::createRequest( void NXMAccessManager::showCookies() const { - QUrl url(ToQString(GameInfo::instance().getNexusPage()) + "/"); - + QUrl url(Nexus_Management_URL + "/"); for (const QNetworkCookie &cookie : cookieJar()->cookiesForUrl(url)) { qDebug("%s - %s (expires: %s)", cookie.name().constData(), cookie.value().constData(), @@ -113,7 +112,7 @@ void NXMAccessManager::startLoginCheck() { if (hasLoginCookies()) { qDebug("validating login cookies"); - QNetworkRequest request(ToQString(GameInfo::instance().getNexusPage()) + "/Sessions/?Validate"); + QNetworkRequest request(Nexus_Management_URL + "/Sessions/?Validate"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); request.setRawHeader("User-Agent", userAgent().toUtf8()); @@ -131,12 +130,7 @@ void NXMAccessManager::retrieveCredentials() { qDebug("retrieving credentials"); - //This may be overkill as - //www.nexusmods.com/Core/Libs/Flamework/Entities/User?GetCredentials - //seems to work fine. - QNetworkRequest request(m_Game->getNexusManagementURL() - + QString("/Core/Libs/Flamework/Entities/User?GetCredentials&game_id=%1" - ).arg(m_Game->getNexusGameID())); + QNetworkRequest request(Nexus_Management_URL + "/Core/Libs/Flamework/Entities/User?GetCredentials"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); request.setRawHeader("User-Agent", userAgent().toUtf8()); @@ -231,8 +225,9 @@ QString NXMAccessManager::userAgent(const QString &subModule) const void NXMAccessManager::pageLogin() { qDebug("logging %s in on Nexus", qPrintable(m_Username)); - QString requestString = (ToQString(GameInfo::instance().getNexusPage()) + "/Sessions/?Login&uri=%1") - .arg(QString(QUrl::toPercentEncoding(ToQString(GameInfo::instance().getNexusPage())))); + + QString requestString = (Nexus_Management_URL + "/Sessions/?Login&uri=%1") + .arg(QString(QUrl::toPercentEncoding(Nexus_Management_URL))); QNetworkRequest request(requestString); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); @@ -296,15 +291,14 @@ void NXMAccessManager::loginError(QNetworkReply::NetworkError) bool NXMAccessManager::hasLoginCookies() const { - bool sidCookie = false; - QUrl url(ToQString(GameInfo::instance().getNexusPage()) + "/"); + QUrl url(Nexus_Management_URL + "/"); QList cookies = cookieJar()->cookiesForUrl(url); for (const QNetworkCookie &cookie : cookies) { if (cookie.name() == "sid") { - sidCookie = true; + return true; } } - return sidCookie; + return false; } @@ -345,8 +339,3 @@ void NXMAccessManager::loginChecked() m_LoginReply->deleteLater(); m_LoginReply = nullptr; } - -void NXMAccessManager::managedGameChanged(MOBase::IPluginGame const *game) -{ - m_Game = game; -} diff --git a/src/nxmaccessmanager.h b/src/nxmaccessmanager.h index 2a016cad..82bd2bd5 100644 --- a/src/nxmaccessmanager.h +++ b/src/nxmaccessmanager.h @@ -85,10 +85,6 @@ private slots: void loginError(QNetworkReply::NetworkError errorCode); void loginTimeout(); -public: - //This would be a slot but the NexusInterface code calls this - void managedGameChanged(MOBase::IPluginGame const *game); - protected: virtual QNetworkReply *createRequest( @@ -130,8 +126,6 @@ private: LOGIN_VALID } m_LoginState = LOGIN_NOT_CHECKED; - MOBase::IPluginGame const *m_Game; - }; #endif // NXMACCESSMANAGER_H diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp index cb2a3adf..043a25dc 100644 --- a/src/shared/fallout3info.cpp +++ b/src/shared/fallout3info.cpp @@ -78,15 +78,6 @@ std::wstring Fallout3Info::getReferenceDataFile() return L"Fallout - Meshes.bsa"; } -std::wstring Fallout3Info::getNexusPage(bool nmmScheme) -{ - if (nmmScheme) { - return L"http://nmm.nexusmods.com/fallout3"; - } else { - return L"http://www.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 e6064825..ed525588 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -49,8 +49,6 @@ public: virtual std::wstring getReferenceDataFile(); - virtual std::wstring getNexusPage(bool nmmScheme = true); - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath); // get a list of executables (game binary and known-to-work 3rd party tools). All of these are relative to diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp index bfc31c0b..88985ad6 100644 --- a/src/shared/falloutnvinfo.cpp +++ b/src/shared/falloutnvinfo.cpp @@ -78,16 +78,6 @@ std::wstring FalloutNVInfo::getReferenceDataFile() return L"Fallout - Meshes.bsa"; } -std::wstring FalloutNVInfo::getNexusPage(bool nmmScheme) -{ - if (nmmScheme) { - return L"http://nmm.nexusmods.com/newvegas"; - } else { - return L"http://www.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 aa187fb3..ee67ac17 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -49,8 +49,6 @@ public: virtual std::wstring getReferenceDataFile(); - virtual std::wstring getNexusPage(bool nmmScheme = true); - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath); // get a list of executables (game binary and known-to-work 3rd party tools). All of these are relative to diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index b6a4f142..de3af8b4 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -82,8 +82,6 @@ public: //**USED ONLY IN HOOKDLL virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) = 0; - virtual std::wstring getNexusPage(bool nmmScheme = true) = 0; - //**USED IN HOOKDLL and everywhere that uses GameInfo static GameInfo& instance(); diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp index 9bd5f4b1..a3dc3986 100644 --- a/src/shared/oblivioninfo.cpp +++ b/src/shared/oblivioninfo.cpp @@ -77,20 +77,6 @@ std::vector OblivionInfo::getIniFileNames() return boost::assign::list_of(L"oblivion.ini")(L"oblivionprefs.ini"); } - - - - -std::wstring OblivionInfo::getNexusPage(bool nmmScheme) -{ - if (nmmScheme) { - return L"http://nmm.nexusmods.com/oblivion"; - } else { - return L"http://www.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 f9045703..00048930 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -47,8 +47,6 @@ public: virtual std::wstring getReferenceDataFile(); - virtual std::wstring getNexusPage(bool nmmScheme = true); - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath); // get a list of executables (game binary and known-to-work 3rd party tools). All of these are relative to diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp index 9b192902..869ac47d 100644 --- a/src/shared/skyriminfo.cpp +++ b/src/shared/skyriminfo.cpp @@ -88,17 +88,6 @@ std::wstring SkyrimInfo::getReferenceDataFile() return L"Skyrim - Meshes.bsa"; } - -std::wstring SkyrimInfo::getNexusPage(bool nmmScheme) -{ - if (nmmScheme) { - return L"http://nmm.nexusmods.com/skyrim"; - } else { - return L"http://www.nexusmods.com/skyrim"; - } -} - - 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 47a35b3e..afba1974 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -49,10 +49,6 @@ public: virtual std::wstring getReferenceDataFile(); - virtual std::wstring getNexusPage(bool nmmScheme = true); - - static int getNexusGameIDStatic() { return 110; } - virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath); private: -- 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/nexusinterface.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 From ca54ee2e9a8f1d49d81d5c3b66a860b9b16992d6 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Thu, 26 Nov 2015 21:22:47 +0000 Subject: Renamed getNexusName to getGameShortName as previously because it hopefully isn't too nexus related. --- src/downloadmanager.cpp | 2 +- src/mainwindow.cpp | 2 +- src/nexusinterface.cpp | 6 +++--- src/organizercore.cpp | 4 ++-- src/settings.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/nexusinterface.cpp') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 4a6769b1..e95a315f 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -450,7 +450,7 @@ void DownloadManager::addNXMDownload(const QString &url) { NXMUrl nxmInfo(url); - QString managedGame = m_ManagedGame->getNexusName(); + QString managedGame = m_ManagedGame->getGameShortName(); qDebug("add nxm download: %s", qPrintable(url)); if (nxmInfo.game().compare(managedGame, Qt::CaseInsensitive) != 0) { qDebug("download requested for wrong game (game: %s, url: %s)", qPrintable(managedGame), qPrintable(nxmInfo.game())); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index dd5a1b01..152baee7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4401,7 +4401,7 @@ void MainWindow::on_bossButton_clicked() parameters << "--unattended" << "--stdout" << "--noreport" - << "--game" << m_OrganizerCore.managedGame()->getNexusName() + << "--game" << m_OrganizerCore.managedGame()->getGameShortName() << "--gamePath" << QString("\"%1\"").arg(m_OrganizerCore.managedGame()->gameDirectory().absolutePath()) << "--out" << outPath; diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index 7a0b0a17..aadfdc1e 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -244,12 +244,12 @@ 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/"); + name.startsWith("http://" + m_Game->getGameShortName().toLower() + ".nexusmods.com/mods/"); } QString NexusInterface::getGameURL() const { - return "http://www.nexusmods.com/" + m_Game->getNexusName().toLower(); + return "http://www.nexusmods.com/" + m_Game->getGameShortName().toLower(); } QString NexusInterface::getModURL(int modID) const @@ -576,7 +576,7 @@ void NexusInterface::managedGameChanged(IPluginGame const *game) namespace { QString get_management_url(MOBase::IPluginGame const *game) { - return "http://nmm.nexusmods.com/" + game->getNexusName().toLower(); + return "http://nmm.nexusmods.com/" + game->getGameShortName().toLower(); } } diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 66a3799a..042a9f1e 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -401,8 +401,8 @@ void OrganizerCore::connectPlugins(PluginContainer *container) } //Do this the hard way for (const IPluginGame * const game : container->plugins()) { - QString n = game->getNexusName(); - if (game->getNexusName() == "Skyrim") { + QString n = game->getGameShortName(); + if (game->getGameShortName() == "Skyrim") { m_Updater.setNexusDownload(game); break; } diff --git a/src/settings.cpp b/src/settings.cpp index 95462c82..e175b210 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -108,7 +108,7 @@ void Settings::registerAsNXMHandler(bool force) std::wstring nxmPath = ToWString(QCoreApplication::applicationDirPath() + "/nxmhandler.exe"); std::wstring executable = ToWString(QCoreApplication::applicationFilePath()); std::wstring mode = force ? L"forcereg" : L"reg"; - std::wstring parameters = mode + L" " + m_GamePlugin->getNexusName().toStdWString() + L" \"" + executable + L"\""; + std::wstring parameters = mode + L" " + m_GamePlugin->getGameShortName().toStdWString() + L" \"" + executable + L"\""; HINSTANCE res = ::ShellExecuteW(nullptr, L"open", nxmPath.c_str(), parameters.c_str(), nullptr, SW_SHOWNORMAL); if ((int)res <= 32) { QMessageBox::critical(nullptr, tr("Failed"), -- cgit v1.3.1