From d4754f4d3ca7451d784e89ae1ddef240666dfdf8 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Thu, 15 Oct 2015 18:44:39 +0100 Subject: Fix for some nexus fomods having the old version of the mod link and not the new version. Also fixed a lot of const correctness things --- src/shared/skyriminfo.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/shared/skyriminfo.cpp') diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp index f66fcef4..7c85fe10 100644 --- a/src/shared/skyriminfo.cpp +++ b/src/shared/skyriminfo.cpp @@ -91,7 +91,7 @@ GameInfo::LoadOrderMechanism SkyrimInfo::getLoadOrderMechanism() const } } -std::vector SkyrimInfo::getDLCPlugins() +std::vector SkyrimInfo::getDLCPlugins() const { return boost::assign::list_of (L"Dawnguard.esm") (L"Dragonborn.esm") @@ -102,23 +102,23 @@ std::vector SkyrimInfo::getDLCPlugins() ; } -std::vector SkyrimInfo::getSavegameAttachmentExtensions() +std::vector SkyrimInfo::getSavegameAttachmentExtensions() const { return boost::assign::list_of(L"skse"); } -std::vector SkyrimInfo::getIniFileNames() +std::vector SkyrimInfo::getIniFileNames() const { return boost::assign::list_of(L"skyrim.ini")(L"skyrimprefs.ini"); } -std::wstring SkyrimInfo::getReferenceDataFile() +std::wstring SkyrimInfo::getReferenceDataFile() const { return L"Skyrim - Meshes.bsa"; } -std::wstring SkyrimInfo::getNexusPage(bool nmmScheme) +std::wstring SkyrimInfo::getNexusPage(bool nmmScheme) const { if (nmmScheme) { return L"http://nmm.nexusmods.com/skyrim"; @@ -139,7 +139,7 @@ int SkyrimInfo::getNexusModIDStatic() return 1334; } -bool SkyrimInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) +bool SkyrimInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) const { static LPCWSTR profileFiles[] = { L"skyrim.ini", L"skyrimprefs.ini", L"loadorder.txt", nullptr }; @@ -157,5 +157,10 @@ bool SkyrimInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPa return false; } +bool SkyrimInfo::isValidModURL(int modID, const std::wstring &url) const +{ + return GameInfo::isValidModURL(modID, url, L"http://skyrim.nexusmods.com"); +} + } // namespace MOShared -- cgit v1.3.1 From 49de6e8d2555234c5da132c5fc35287083fe7ef7 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Fri, 20 Nov 2015 18:07:06 +0000 Subject: Get rid of `GameIfo::getOrganizerDirectory` and associated member variable qApp->getProperty("dataPath") can be used instead (and is pretty much everywhere else) so it's unnecessary --- src/main.cpp | 9 +++++---- src/organizercore.cpp | 1 + src/organizerproxy.cpp | 4 +++- src/selfupdater.cpp | 6 +++--- src/settingsdialog.cpp | 2 +- src/shared/fallout3info.cpp | 4 ++-- src/shared/fallout3info.h | 2 +- src/shared/falloutnvinfo.cpp | 4 ++-- src/shared/falloutnvinfo.h | 2 +- src/shared/gameinfo.cpp | 18 +++++++++--------- src/shared/gameinfo.h | 14 +++++++++----- src/shared/oblivioninfo.cpp | 4 ++-- src/shared/oblivioninfo.h | 2 +- src/shared/skyriminfo.cpp | 4 ++-- src/shared/skyriminfo.h | 2 +- 15 files changed, 43 insertions(+), 35 deletions(-) (limited to 'src/shared/skyriminfo.cpp') diff --git a/src/main.cpp b/src/main.cpp index 773bfc16..ff34145d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -86,7 +86,8 @@ using namespace MOShared; bool createAndMakeWritable(const std::wstring &subPath) { - QString fullPath = qApp->property("dataPath").toString() + "/" + QString::fromStdWString(subPath); + QString const dataPath = qApp->property("dataPath").toString(); + QString fullPath = dataPath + "/" + QString::fromStdWString(subPath); if (!QDir(fullPath).exists()) { QDir().mkdir(fullPath); @@ -100,7 +101,7 @@ bool createAndMakeWritable(const std::wstring &subPath) "will be made writable for the current user account). You will be asked to run " "\"helper.exe\" with administrative rights."), QMessageBox::Yes | QMessageBox::Cancel) == QMessageBox::Yes) { - if (!Helper::init(GameInfo::instance().getOrganizerDirectory())) { + if (!Helper::init(dataPath.toStdWString())) { return false; } } else { @@ -341,7 +342,7 @@ int main(int argc, char *argv[]) instanceID = instanceFile.readAll().trimmed(); } - QString dataPath = + QString const dataPath = instanceID.isEmpty() ? application.applicationDirPath() : QDir::fromNativeSeparators( QStandardPaths::writableLocation(QStandardPaths::DataLocation) @@ -373,7 +374,7 @@ int main(int argc, char *argv[]) QSplashScreen splash(pixmap); try { - if (!bootstrap()) { // requires gameinfo to be initialised! + if (!bootstrap()) { return -1; } diff --git a/src/organizercore.cpp b/src/organizercore.cpp index a9284e97..c1f091d9 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1,4 +1,5 @@ #include "organizercore.h" + #include "mainwindow.h" #include "gameinfoimpl.h" #include "messagedialog.h" diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index 095cb0bb..9e85929f 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -1,7 +1,9 @@ #include "organizerproxy.h" + #include #include +#include using namespace MOBase; using namespace MOShared; @@ -40,7 +42,7 @@ QString OrganizerProxy::downloadsPath() const QString OrganizerProxy::overwritePath() const { - return QDir::fromNativeSeparators(ToQString(GameInfo::instance().getOrganizerDirectory())) + return QDir::fromNativeSeparators(qApp->property("dataPath").toString()) + "/" + ToQString(AppConfig::overwritePath()); } diff --git a/src/selfupdater.cpp b/src/selfupdater.cpp index bcf81cfd..7e42f322 100644 --- a/src/selfupdater.cpp +++ b/src/selfupdater.cpp @@ -159,7 +159,7 @@ void SelfUpdater::download(const QString &downloadLink, const QString &fileName) QNetworkRequest request(dlUrl); m_Canceled = false; m_Reply = accessManager->get(request); - m_UpdateFile.setFileName(QDir::fromNativeSeparators(ToQString(GameInfo::instance().getOrganizerDirectory()).append("\\").append(fileName))); + m_UpdateFile.setFileName(QDir::fromNativeSeparators(qApp->property("dataPath").toString()).append("/").append(fileName)); m_UpdateFile.open(QIODevice::WriteOnly); showProgress(); @@ -243,7 +243,7 @@ void SelfUpdater::downloadCancel() void SelfUpdater::installUpdate() { - const QString mopath = QDir::fromNativeSeparators(ToQString(GameInfo::instance().getOrganizerDirectory())); + const QString mopath = QDir::fromNativeSeparators(qApp->property("dataPath").toString()); QString backupPath = mopath + "/update_backup"; QDir().mkdir(backupPath); @@ -281,7 +281,7 @@ void SelfUpdater::installUpdate() } // now unpack the archive into the mo directory - if (!m_CurrentArchive->extract(GameInfo::instance().getOrganizerDirectory().c_str(), + if (!m_CurrentArchive->extract(QDir::toNativeSeparators(mopath).toStdWString().c_str(), new MethodCallback(this, &SelfUpdater::updateProgress), new MethodCallback(this, &SelfUpdater::updateProgressFile), new MethodCallback(this, &SelfUpdater::report7ZipError))) { diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 765858f5..f2160719 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -87,7 +87,7 @@ void SettingsDialog::on_categoriesBtn_clicked() void SettingsDialog::on_bsaDateBtn_clicked() { - Helper::backdateBSAs(GameInfo::instance().getOrganizerDirectory(), GameInfo::instance().getGameDirectory().append(L"\\data")); + Helper::backdateBSAs(qApp->property("dataPath").toString().toStdWString(), GameInfo::instance().getGameDirectory().append(L"\\data")); } void SettingsDialog::on_browseDownloadDirBtn_clicked() diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp index 0b369b50..055d3b38 100644 --- a/src/shared/fallout3info.cpp +++ b/src/shared/fallout3info.cpp @@ -30,8 +30,8 @@ along with Mod Organizer. If not, see . namespace MOShared { -Fallout3Info::Fallout3Info(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : GameInfo(moDirectory, moDataDirectory, gameDirectory) +Fallout3Info::Fallout3Info(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) + : GameInfo(moDataDirectory, gameDirectory) { identifyMyGamesDirectory(L"fallout3"); } diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h index 0045581d..d019ee07 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -69,7 +69,7 @@ public: private: - Fallout3Info(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + Fallout3Info(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); static bool identifyGame(const std::wstring &searchPath); diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp index 1203bd25..2ddbf055 100644 --- a/src/shared/falloutnvinfo.cpp +++ b/src/shared/falloutnvinfo.cpp @@ -31,8 +31,8 @@ along with Mod Organizer. If not, see . namespace MOShared { -FalloutNVInfo::FalloutNVInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : GameInfo(moDirectory, moDataDirectory, gameDirectory) +FalloutNVInfo::FalloutNVInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) + : GameInfo(moDataDirectory, gameDirectory) { identifyMyGamesDirectory(L"falloutnv"); } diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h index e1a614d2..9a9004ec 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -102,7 +102,7 @@ public: private: - FalloutNVInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + FalloutNVInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); static bool identifyGame(const std::wstring &searchPath); }; diff --git a/src/shared/gameinfo.cpp b/src/shared/gameinfo.cpp index 1f25cec1..e5e47cdf 100644 --- a/src/shared/gameinfo.cpp +++ b/src/shared/gameinfo.cpp @@ -40,8 +40,8 @@ namespace MOShared { GameInfo* GameInfo::s_Instance = nullptr; -GameInfo::GameInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : m_GameDirectory(gameDirectory), m_OrganizerDirectory(moDirectory), m_OrganizerDataDirectory(moDataDirectory) +GameInfo::GameInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) + : m_GameDirectory(gameDirectory), m_OrganizerDataDirectory(moDataDirectory) { atexit(&cleanup); } @@ -87,16 +87,16 @@ void GameInfo::identifyMyGamesDirectory(const std::wstring &file) } -bool GameInfo::identifyGame(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &searchPath) +bool GameInfo::identifyGame(const std::wstring &moDataDirectory, const std::wstring &searchPath) { if (OblivionInfo::identifyGame(searchPath)) { - s_Instance = new OblivionInfo(moDirectory, moDataDirectory, searchPath); + s_Instance = new OblivionInfo(moDataDirectory, searchPath); } else if (Fallout3Info::identifyGame(searchPath)) { - s_Instance = new Fallout3Info(moDirectory, moDataDirectory, searchPath); + s_Instance = new Fallout3Info(moDataDirectory, searchPath); } else if (FalloutNVInfo::identifyGame(searchPath)) { - s_Instance = new FalloutNVInfo(moDirectory, moDataDirectory, searchPath); + s_Instance = new FalloutNVInfo(moDataDirectory, searchPath); } else if (SkyrimInfo::identifyGame(searchPath)) { - s_Instance = new SkyrimInfo(moDirectory, moDataDirectory, searchPath); + s_Instance = new SkyrimInfo(moDataDirectory, searchPath); } return s_Instance != nullptr; @@ -109,14 +109,14 @@ bool GameInfo::init(const std::wstring &moDirectory, const std::wstring &moDataD if (gamePath.length() == 0) { // search upward in the directory until a recognized game-binary is found std::wstring searchPath(moDirectory); - while (!identifyGame(moDirectory, moDataDirectory, searchPath)) { + while (!identifyGame(moDataDirectory, searchPath)) { size_t lastSep = searchPath.find_last_of(L"/\\"); if (lastSep == std::string::npos) { return false; } searchPath.erase(lastSep); } - } else if (!identifyGame(moDirectory, moDataDirectory, gamePath)) { + } else if (!identifyGame(moDataDirectory, gamePath)) { return false; } } diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index a32b6b82..1d4b050b 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -56,8 +56,7 @@ public: virtual ~GameInfo() {} - std::wstring getOrganizerDirectory() { return m_OrganizerDirectory; } - + //**USED IN HOOKDLL virtual std::wstring getRegPath() = 0; virtual std::wstring getBinaryName() = 0; @@ -70,6 +69,7 @@ public: /// exception if the mechanism can't be determined virtual LoadOrderMechanism getLoadOrderMechanism() const { return TYPE_FILETIME; } + //**USED IN HOOKDLL virtual std::wstring getGameDirectory() const; virtual bool requiresSteam() const; @@ -80,9 +80,11 @@ public: // get a set of esp/esm files that are part of known dlcs virtual std::vector getDLCPlugins() = 0; + //**USED IN HOOKDLL // file name of this games ini file(s) virtual std::vector getIniFileNames() = 0; + //**USED IN HOOKDLL virtual std::wstring getReferenceDataFile() = 0; virtual std::wstring getNexusPage(bool nmmScheme = true) = 0; @@ -90,19 +92,22 @@ public: virtual int getNexusModID() = 0; virtual int getNexusGameID() = 0; + //**USED 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 &moDataDirectory, const std::wstring &gamePath = L""); + //**USED IN HOOKDLL static GameInfo& instance(); protected: - GameInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + GameInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); std::wstring getLocalAppFolder() const; const std::wstring &getMyGamesDirectory() const { return m_MyGamesDirectory; } @@ -110,7 +115,7 @@ protected: private: - static bool identifyGame(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &searchPath); + static bool identifyGame(const std::wstring &moDataDirectory, const std::wstring &searchPath); std::wstring getSpecialPath(LPCWSTR name) const; static void cleanup(); @@ -122,7 +127,6 @@ private: std::wstring m_MyGamesDirectory; std::wstring m_GameDirectory; - std::wstring m_OrganizerDirectory; std::wstring m_OrganizerDataDirectory; }; diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp index 16748f58..a5760570 100644 --- a/src/shared/oblivioninfo.cpp +++ b/src/shared/oblivioninfo.cpp @@ -31,8 +31,8 @@ along with Mod Organizer. If not, see . namespace MOShared { -OblivionInfo::OblivionInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : GameInfo(moDirectory, moDataDirectory, gameDirectory) +OblivionInfo::OblivionInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) + : GameInfo(moDataDirectory, gameDirectory) { identifyMyGamesDirectory(L"oblivion"); } diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h index 87ba26ff..0a6c416c 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -100,7 +100,7 @@ public: private: - OblivionInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + OblivionInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); static bool identifyGame(const std::wstring &searchPath); diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp index f66fcef4..e122390d 100644 --- a/src/shared/skyriminfo.cpp +++ b/src/shared/skyriminfo.cpp @@ -33,8 +33,8 @@ along with Mod Organizer. If not, see . namespace MOShared { -SkyrimInfo::SkyrimInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : GameInfo(moDirectory, moDataDirectory, gameDirectory) +SkyrimInfo::SkyrimInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) + : GameInfo(moDataDirectory, gameDirectory) { identifyMyGamesDirectory(L"skyrim"); diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h index 5951f910..f52be73a 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -68,7 +68,7 @@ public: private: - SkyrimInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + SkyrimInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); static bool identifyGame(const std::wstring &searchPath); -- cgit v1.3.1 From f339cc8431c0a7b6a4d514599e6fa57a75eb6495 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Fri, 20 Nov 2015 19:34:09 +0000 Subject: Member variable unused so removed it. Leaves one asking *why* the datapath can be inside the game directory. --- src/main.cpp | 2 +- src/shared/fallout3info.cpp | 4 ++-- src/shared/fallout3info.h | 2 +- src/shared/falloutnvinfo.cpp | 4 ++-- src/shared/falloutnvinfo.h | 2 +- src/shared/gameinfo.cpp | 20 ++++++++++---------- src/shared/gameinfo.h | 7 +++---- src/shared/oblivioninfo.cpp | 4 ++-- src/shared/oblivioninfo.h | 2 +- src/shared/skyriminfo.cpp | 4 ++-- src/shared/skyriminfo.h | 2 +- 11 files changed, 26 insertions(+), 27 deletions(-) (limited to 'src/shared/skyriminfo.cpp') diff --git a/src/main.cpp b/src/main.cpp index ff34145d..4f79b0b2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -446,7 +446,7 @@ int main(int argc, char *argv[]) QString gamePath = QString::fromUtf8(settings.value("gamePath", "").toByteArray()); bool done = false; while (!done) { - if (!GameInfo::init(ToWString(application.applicationDirPath()), ToWString(dataPath), ToWString(QDir::toNativeSeparators(gamePath)))) { + if (!GameInfo::init(ToWString(application.applicationDirPath()), ToWString(QDir::toNativeSeparators(gamePath)))) { if (!gamePath.isEmpty()) { reportError(QObject::tr("No game identified in \"%1\". The directory is required to contain " "the game binary and its launcher.").arg(gamePath)); diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp index 055d3b38..9c6ad5b9 100644 --- a/src/shared/fallout3info.cpp +++ b/src/shared/fallout3info.cpp @@ -30,8 +30,8 @@ along with Mod Organizer. If not, see . namespace MOShared { -Fallout3Info::Fallout3Info(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : GameInfo(moDataDirectory, gameDirectory) +Fallout3Info::Fallout3Info(const std::wstring &gameDirectory) + : GameInfo(gameDirectory) { identifyMyGamesDirectory(L"fallout3"); } diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h index d019ee07..51abe073 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -69,7 +69,7 @@ public: private: - Fallout3Info(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + Fallout3Info(const std::wstring &gameDirectory); static bool identifyGame(const std::wstring &searchPath); diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp index 2ddbf055..4601caf5 100644 --- a/src/shared/falloutnvinfo.cpp +++ b/src/shared/falloutnvinfo.cpp @@ -31,8 +31,8 @@ along with Mod Organizer. If not, see . namespace MOShared { -FalloutNVInfo::FalloutNVInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : GameInfo(moDataDirectory, gameDirectory) +FalloutNVInfo::FalloutNVInfo(const std::wstring &gameDirectory) + : GameInfo(gameDirectory) { identifyMyGamesDirectory(L"falloutnv"); } diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h index 9a9004ec..59b52323 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -102,7 +102,7 @@ public: private: - FalloutNVInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + FalloutNVInfo(const std::wstring &gameDirectory); static bool identifyGame(const std::wstring &searchPath); }; diff --git a/src/shared/gameinfo.cpp b/src/shared/gameinfo.cpp index e5e47cdf..703f4a40 100644 --- a/src/shared/gameinfo.cpp +++ b/src/shared/gameinfo.cpp @@ -40,8 +40,8 @@ namespace MOShared { GameInfo* GameInfo::s_Instance = nullptr; -GameInfo::GameInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : m_GameDirectory(gameDirectory), m_OrganizerDataDirectory(moDataDirectory) +GameInfo::GameInfo(const std::wstring &gameDirectory) + : m_GameDirectory(gameDirectory) { atexit(&cleanup); } @@ -87,36 +87,36 @@ void GameInfo::identifyMyGamesDirectory(const std::wstring &file) } -bool GameInfo::identifyGame(const std::wstring &moDataDirectory, const std::wstring &searchPath) +bool GameInfo::identifyGame(const std::wstring &searchPath) { if (OblivionInfo::identifyGame(searchPath)) { - s_Instance = new OblivionInfo(moDataDirectory, searchPath); + s_Instance = new OblivionInfo(searchPath); } else if (Fallout3Info::identifyGame(searchPath)) { - s_Instance = new Fallout3Info(moDataDirectory, searchPath); + s_Instance = new Fallout3Info(searchPath); } else if (FalloutNVInfo::identifyGame(searchPath)) { - s_Instance = new FalloutNVInfo(moDataDirectory, searchPath); + s_Instance = new FalloutNVInfo(searchPath); } else if (SkyrimInfo::identifyGame(searchPath)) { - s_Instance = new SkyrimInfo(moDataDirectory, searchPath); + s_Instance = new SkyrimInfo(searchPath); } return s_Instance != nullptr; } -bool GameInfo::init(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gamePath) +bool GameInfo::init(const std::wstring &moDirectory, const std::wstring &gamePath) { if (s_Instance == nullptr) { if (gamePath.length() == 0) { // search upward in the directory until a recognized game-binary is found std::wstring searchPath(moDirectory); - while (!identifyGame(moDataDirectory, searchPath)) { + while (!identifyGame(searchPath)) { size_t lastSep = searchPath.find_last_of(L"/\\"); if (lastSep == std::string::npos) { return false; } searchPath.erase(lastSep); } - } else if (!identifyGame(moDataDirectory, gamePath)) { + } else if (!identifyGame(gamePath)) { return false; } } diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index 1d4b050b..47a5e767 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -100,14 +100,14 @@ 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 &moDataDirectory, const std::wstring &gamePath = L""); + static bool init(const std::wstring &moDirectory, const std::wstring &gamePath = L""); //**USED IN HOOKDLL static GameInfo& instance(); protected: - GameInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + GameInfo(const std::wstring &gameDirectory); std::wstring getLocalAppFolder() const; const std::wstring &getMyGamesDirectory() const { return m_MyGamesDirectory; } @@ -115,7 +115,7 @@ protected: private: - static bool identifyGame(const std::wstring &moDataDirectory, const std::wstring &searchPath); + static bool identifyGame(const std::wstring &searchPath); std::wstring getSpecialPath(LPCWSTR name) const; static void cleanup(); @@ -127,7 +127,6 @@ private: std::wstring m_MyGamesDirectory; std::wstring m_GameDirectory; - std::wstring m_OrganizerDataDirectory; }; diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp index a5760570..4b0a8499 100644 --- a/src/shared/oblivioninfo.cpp +++ b/src/shared/oblivioninfo.cpp @@ -31,8 +31,8 @@ along with Mod Organizer. If not, see . namespace MOShared { -OblivionInfo::OblivionInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : GameInfo(moDataDirectory, gameDirectory) +OblivionInfo::OblivionInfo(const std::wstring &gameDirectory) + : GameInfo(gameDirectory) { identifyMyGamesDirectory(L"oblivion"); } diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h index 0a6c416c..ac10b80a 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -100,7 +100,7 @@ public: private: - OblivionInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + OblivionInfo(const std::wstring &gameDirectory); static bool identifyGame(const std::wstring &searchPath); diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp index e122390d..bd901357 100644 --- a/src/shared/skyriminfo.cpp +++ b/src/shared/skyriminfo.cpp @@ -33,8 +33,8 @@ along with Mod Organizer. If not, see . namespace MOShared { -SkyrimInfo::SkyrimInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : GameInfo(moDataDirectory, gameDirectory) +SkyrimInfo::SkyrimInfo(const std::wstring &gameDirectory) + : GameInfo(gameDirectory) { identifyMyGamesDirectory(L"skyrim"); diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h index f52be73a..65977a69 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -68,7 +68,7 @@ public: private: - SkyrimInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + SkyrimInfo(const std::wstring &gameDirectory); static bool identifyGame(const std::wstring &searchPath); -- cgit v1.3.1 From 3659284ab6bdbf0845cf846600a26db688584d6f Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Mon, 23 Nov 2015 18:32:30 +0000 Subject: Remove most instances of GameInfo::getname, and transfer getDLCPlugins to the plugingame interface Also commented out startDownloadNexusFile as it doesn't appear to be used anywhere --- src/downloadmanager.cpp | 3 ++- src/downloadmanager.h | 2 ++ src/mainwindow.cpp | 2 +- src/modinfo.cpp | 24 +++++++++++++++--------- src/modinfo.h | 18 +++++++++++------- src/organizercore.cpp | 8 ++++---- src/shared/fallout3info.cpp | 10 ---------- src/shared/fallout3info.h | 1 - src/shared/falloutnvinfo.cpp | 14 -------------- src/shared/falloutnvinfo.h | 34 ---------------------------------- src/shared/gameinfo.h | 3 --- src/shared/oblivioninfo.cpp | 23 ----------------------- src/shared/oblivioninfo.h | 35 ----------------------------------- src/shared/skyriminfo.cpp | 11 ----------- src/shared/skyriminfo.h | 2 -- 15 files changed, 35 insertions(+), 155 deletions(-) (limited to 'src/shared/skyriminfo.cpp') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index bc78cdc6..e0d76765 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -1235,13 +1235,14 @@ int DownloadManager::startDownloadURLs(const QStringList &urls) return m_ActiveDownloads.size() - 1; } +/* This doesn't appear to be used by anything int DownloadManager::startDownloadNexusFile(int modID, int fileID) { int newID = m_ActiveDownloads.size(); addNXMDownload(QString("nxm://%1/mods/%2/files/%3").arg(ToQString(MOShared::GameInfo::instance().getGameName())).arg(modID).arg(fileID)); return newID; } - +*/ QString DownloadManager::downloadPath(int id) { return getFilePath(id); diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 57bd592d..f13cc65d 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -328,7 +328,9 @@ public: virtual int startDownloadURLs(const QStringList &urls); + /* This doesn't appear to be used anywhere virtual int startDownloadNexusFile(int modID, int fileID); + */ virtual QString downloadPath(int id); /** diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7142bcb1..3c331c65 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -358,7 +358,7 @@ MainWindow::~MainWindow() void MainWindow::updateWindowTitle(const QString &accountName, bool premium) { QString title = QString("%1 Mod Organizer v%2").arg( - ToQString(GameInfo::instance().getGameName()), + m_OrganizerCore.managedGame()->gameName(), m_OrganizerCore.getVersion().displayString()); if (accountName.isEmpty()) { diff --git a/src/modinfo.cpp b/src/modinfo.cpp index e0d888e6..59205b12 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -203,7 +203,7 @@ unsigned int ModInfo::findMod(const boost::function &filter } -void ModInfo::updateFromDisc(const QString &modDirectory, DirectoryEntry **directoryStructure, bool displayForeign) +void ModInfo::updateFromDisc(const QString &modDirectory, DirectoryEntry **directoryStructure, bool displayForeign, MOBase::IPluginGame const *game) { QMutexLocker lock(&s_Mutex); s_Collection.clear(); @@ -219,19 +219,25 @@ void ModInfo::updateFromDisc(const QString &modDirectory, DirectoryEntry **direc } { // list plugins in the data directory and make a foreign-managed mod out of each - std::vector dlcPlugins = GameInfo::instance().getDLCPlugins(); - QDir dataDir(QDir::fromNativeSeparators(ToQString(GameInfo::instance().getGameDirectory())) + "/data"); - foreach (const QFileInfo &file, dataDir.entryInfoList(QStringList() << "*.esp" << "*.esm")) { - if ((file.baseName() != "Update") // hide update - && (file.baseName() != ToQString(GameInfo::instance().getGameName())) // hide the game esp + QStringList dlcPlugins = game->getDLCPlugins(); + QStringList mainPlugins = game->getPrimaryPlugins(); + QDir dataDir(game->dataDirectory()); + for (const QString &file : dataDir.entryList({ "*.esp", "*.esm" })) { + if (std::find_if(mainPlugins.begin(), mainPlugins.end(), + [&file](QString const &p) { + return p.compare(file, Qt::CaseInsensitive) == 0; }) == mainPlugins.end() && (displayForeign // show non-dlc bundles only if the user wants them - || std::find(dlcPlugins.begin(), dlcPlugins.end(), ToWString(file.fileName())) != dlcPlugins.end())) { + || std::find_if(dlcPlugins.begin(), dlcPlugins.end(), + [&file](QString const &p) { + return p.compare(file, Qt::CaseInsensitive) == 0; }) != dlcPlugins.end())) { + + QFileInfo f(file); //Just so I can get a basename... QStringList archives; - foreach (const QString archiveName, dataDir.entryList(QStringList() << file.baseName() + "*.bsa")) { + for (const QString &archiveName : dataDir.entryList({ f.baseName() + "*.bsa" })) { archives.append(dataDir.absoluteFilePath(archiveName)); } - createFromPlugin(file.fileName(), archives, directoryStructure); + createFromPlugin(file, archives, directoryStructure); } } } diff --git a/src/modinfo.h b/src/modinfo.h index da97b09b..6de4123b 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -23,19 +23,23 @@ along with Mod Organizer. If not, see . #include "nexusinterface.h" #include #include +//#include -#include +#include +class QDir; #include -#include -#include #include -#include +#include +#include + +#include + #include #include #include -#include -using MOBase::ModRepositoryFileInfo; +namespace MOBase { class IPluginGame; } +namespace MOShared { class DirectoryEntry; } /** * @brief Represents meta information about a single mod. @@ -103,7 +107,7 @@ public: /** * @brief read the mod directory and Mod ModInfo objects for all subdirectories **/ - static void updateFromDisc(const QString &modDirectory, MOShared::DirectoryEntry **directoryStructure, bool displayForeign); + static void updateFromDisc(const QString &modDirectory, MOShared::DirectoryEntry **directoryStructure, bool displayForeign, const MOBase::IPluginGame *game); static void clear() { s_Collection.clear(); s_ModsByName.clear(); s_ModsByModID.clear(); } diff --git a/src/organizercore.cpp b/src/organizercore.cpp index ee69c46b..7a2f95d3 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -320,7 +320,7 @@ void OrganizerCore::updateExecutablesList(QSettings &settings) return; } - m_ExecutablesList.init(m_PluginContainer->managedGame(ToQString(GameInfo::instance().getGameName()))); + m_ExecutablesList.init(managedGame()); qDebug("setting up configured executables"); @@ -348,7 +348,7 @@ void OrganizerCore::updateExecutablesList(QSettings &settings) settings.endArray(); // TODO this has nothing to do with executables list move to an appropriate function! - ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure, m_Settings.displayForeign()); + ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure, m_Settings.displayForeign(), managedGame()); } void OrganizerCore::setUserInterface(IUserInterface *userInterface, QWidget *widget) @@ -1125,7 +1125,7 @@ void OrganizerCore::refreshModList(bool saveChanges) if (saveChanges) { m_CurrentProfile->modlistWriter().writeImmediately(true); } - ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure, m_Settings.displayForeign()); + ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure, m_Settings.displayForeign(), managedGame()); m_CurrentProfile->refreshModStatus(); @@ -1367,7 +1367,7 @@ void OrganizerCore::directory_refreshed() void OrganizerCore::profileRefresh() { // have to refresh mods twice (again in refreshModList), otherwise the refresh isn't complete. Not sure why - ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure, m_Settings.displayForeign()); + ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure, m_Settings.displayForeign(), managedGame()); m_CurrentProfile->refreshModStatus(); refreshModList(); diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp index 9c6ad5b9..95d1d299 100644 --- a/src/shared/fallout3info.cpp +++ b/src/shared/fallout3info.cpp @@ -63,16 +63,6 @@ std::wstring Fallout3Info::getRegPathStatic() } -std::vector Fallout3Info::getDLCPlugins() -{ - return boost::assign::list_of (L"ThePitt.esm") - (L"Anchorage.esm") - (L"BrokenSteel.esm") - (L"PointLookout.esm") - (L"Zeta.esm") - ; -} - std::vector Fallout3Info::getSavegameAttachmentExtensions() { return std::vector(); diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h index 90bb6ec0..ae6a27c7 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -43,7 +43,6 @@ public: virtual std::wstring getGameName() const { return L"Fallout 3"; } virtual std::wstring getGameShortName() const { return L"Fallout3"; } - virtual std::vector getDLCPlugins(); virtual std::vector getSavegameAttachmentExtensions(); // file name of this games ini (no path) diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp index 4601caf5..b5fb4f04 100644 --- a/src/shared/falloutnvinfo.cpp +++ b/src/shared/falloutnvinfo.cpp @@ -63,20 +63,6 @@ std::wstring FalloutNVInfo::getRegPathStatic() } } -std::vector FalloutNVInfo::getDLCPlugins() -{ - return boost::assign::list_of (L"DeadMoney.esm") - (L"HonestHearts.esm") - (L"OldWorldBlues.esm") - (L"LonesomeRoad.esm") - (L"GunRunnersArsenal.esm") - (L"CaravanPack.esm") - (L"ClassicPack.esm") - (L"MercenaryPack.esm") - (L"TribalPack.esm") - ; -} - std::vector FalloutNVInfo::getSavegameAttachmentExtensions() { return std::vector(); diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h index 613694b2..2179bf2f 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -43,40 +43,6 @@ public: virtual std::wstring getGameName() const { return L"New Vegas"; } virtual std::wstring getGameShortName() const { return L"FalloutNV"; } -// virtual bool requiresSteam() const { return true; } - -/* virtual std::wstring getInvalidationBSA() - { - return L"Fallout - Invalidation.bsa"; - } - - virtual bool isInvalidationBSA(const std::wstring &bsaName) - { - static LPCWSTR invalidation[] = { L"Fallout - AI!.bsa", L"Fallout - Invalidation.bsa", nullptr }; - - for (int i = 0; invalidation[i] != nullptr; ++i) { - if (wcscmp(bsaName.c_str(), invalidation[i]) == 0) { - return true; - } - } - return false; - } - - virtual std::vector getVanillaBSAs() - { - return boost::assign::list_of (L"Fallout - Textures.bsa") - (L"Fallout - Textures2.bsa") - (L"Fallout - Meshes.bsa") - (L"Fallout - Voices1.bsa") - (L"Fallout - Sound.bsa") - (L"Fallout - Misc.bsa"); - } - - virtual std::vector getPrimaryPlugins() - { - return boost::assign::list_of(L"falloutnv.esm"); - }*/ - virtual std::vector getDLCPlugins(); virtual std::vector getSavegameAttachmentExtensions(); // file name of this games ini (no path) diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index e1a70597..9ae42159 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -74,9 +74,6 @@ public: // get a list of file extensions for additional files belonging to a save game virtual std::vector getSavegameAttachmentExtensions() = 0; - // get a set of esp/esm files that are part of known dlcs - virtual std::vector getDLCPlugins() = 0; - //**USED IN HOOKDLL // file name of this games ini file(s) virtual std::vector getIniFileNames() = 0; diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp index 4b0a8499..27de1275 100644 --- a/src/shared/oblivioninfo.cpp +++ b/src/shared/oblivioninfo.cpp @@ -66,29 +66,6 @@ std::wstring OblivionInfo::getRegPathStatic() - - - - - - - -std::vector OblivionInfo::getDLCPlugins() -{ - return boost::assign::list_of (L"DLCShiveringIsles.esp") - (L"Knights.esp") - (L"DLCFrostcrag.esp") - (L"DLCSpellTomes.esp") - (L"DLCMehrunesRazor.esp") - (L"DLCOrrery.esp") - (L"DLCSpellTomes.esp") - (L"DLCThievesDen.esp") - (L"DLCVileLair.esp") - (L"DLCHorseArmor.esp") - ; -} - - std::vector OblivionInfo::getSavegameAttachmentExtensions() { return boost::assign::list_of(L"obse"); diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h index fcdac6bd..2a550e0e 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -40,41 +40,6 @@ public: virtual std::wstring getGameName() const { return L"Oblivion"; } virtual std::wstring getGameShortName() const { return L"Oblivion"; } -/* - virtual std::wstring getInvalidationBSA() - { - return L"Oblivion - Invalidation.bsa"; - } - - virtual bool isInvalidationBSA(const std::wstring &bsaName) - { - static LPCWSTR invalidation[] = { L"Oblivion - Invalidation.bsa", L"ArchiveInvalidationInvalidated!.bsa", - L"BSARedirection.bsa", nullptr }; - - for (int i = 0; invalidation[i] != nullptr; ++i) { - if (wcscmp(bsaName.c_str(), invalidation[i]) == 0) { - return true; - } - } - return false; - } - - virtual std::vector getVanillaBSAs() - { - return boost::assign::list_of(L"Oblivion - Meshes.bsa") - (L"Oblivion - Textures - Compressed.bsa") - (L"Oblivion - Sounds.bsa") - (L"Oblivion - Voices1.bsa") - (L"Oblivion - Voices2.bsa") - (L"Oblivion - Misc.bsa"); - } - - virtual std::vector getPrimaryPlugins() - { - return boost::assign::list_of(L"oblivion.esm"); - }*/ - - virtual std::vector getDLCPlugins(); virtual std::vector getSavegameAttachmentExtensions(); // file name of this games ini (no path) diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp index bd901357..189d2ed0 100644 --- a/src/shared/skyriminfo.cpp +++ b/src/shared/skyriminfo.cpp @@ -91,17 +91,6 @@ GameInfo::LoadOrderMechanism SkyrimInfo::getLoadOrderMechanism() const } } -std::vector SkyrimInfo::getDLCPlugins() -{ - return boost::assign::list_of (L"Dawnguard.esm") - (L"Dragonborn.esm") - (L"HearthFires.esm") - (L"HighResTexturePack01.esp") - (L"HighResTexturePack02.esp") - (L"HighResTexturePack03.esp") - ; -} - std::vector SkyrimInfo::getSavegameAttachmentExtensions() { return boost::assign::list_of(L"skse"); diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h index f26cd065..741f76c9 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -45,8 +45,6 @@ public: virtual LoadOrderMechanism getLoadOrderMechanism() const; - virtual std::vector getDLCPlugins(); - virtual std::vector getSavegameAttachmentExtensions(); // file name of this games ini (no path) -- cgit v1.3.1 From c7d583bcf1eeb08182f5f7610690ba104e0f8a84 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Tue, 24 Nov 2015 14:21:19 +0000 Subject: Replace GameInfo::getLoadorderMechanism with IPluginGame::getLoadOrderMechanism --- src/mainwindow.cpp | 4 ++-- src/organizercore.cpp | 5 +++-- src/pluginlist.cpp | 11 ++++++++--- src/pluginlist.h | 12 ++++++++++++ src/shared/gameinfo.h | 4 ---- src/shared/skyriminfo.cpp | 18 ------------------ src/shared/skyriminfo.h | 2 -- 7 files changed, 25 insertions(+), 31 deletions(-) (limited to 'src/shared/skyriminfo.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c08993c1..1651d0c6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4527,12 +4527,12 @@ void MainWindow::on_bossButton_clicked() // if the game specifies load order by file time, our own load order file needs to be removed because it's outdated. // refreshESPList will then use the file time as the load order. - if (GameInfo::instance().getLoadOrderMechanism() == GameInfo::TYPE_FILETIME) { + if (m_OrganizerCore.managedGame()->getLoadOrderMechanism() == IPluginGame::LoadOrderMechanism::FileTime) { qDebug("removing loadorder.txt"); QFile::remove(m_OrganizerCore.currentProfile()->getLoadOrderFileName()); } m_OrganizerCore.refreshESPList(); - if (GameInfo::instance().getLoadOrderMechanism() == GameInfo::TYPE_FILETIME) { + if (m_OrganizerCore.managedGame()->getLoadOrderMechanism() == IPluginGame::LoadOrderMechanism::FileTime) { // the load order should have been retrieved from file time, now save it to our own format m_OrganizerCore.savePluginList(); } diff --git a/src/organizercore.cpp b/src/organizercore.cpp index c81a473c..24077923 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -160,6 +160,7 @@ OrganizerCore::OrganizerCore(const QSettings &initSettings) 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(&m_PluginList, &PluginList::writePluginsList, &m_PluginListsWriter, &DelayedFileWriterBase::write); @@ -920,12 +921,12 @@ void OrganizerCore::spawnBinary(const QFileInfo &binary, const QString &argument refreshDirectoryStructure(); // need to remove our stored load order because it may be outdated if a foreign tool changed the // file time. After removing that file, refreshESPList will use the file time as the order - if (GameInfo::instance().getLoadOrderMechanism() == GameInfo::TYPE_FILETIME) { + if (managedGame()->getLoadOrderMechanism() == IPluginGame::LoadOrderMechanism::FileTime) { qDebug("removing loadorder.txt"); QFile::remove(m_CurrentProfile->getLoadOrderFileName()); } refreshESPList(); - if (GameInfo::instance().getLoadOrderMechanism() == GameInfo::TYPE_FILETIME) { + if (managedGame()->getLoadOrderMechanism() == IPluginGame::LoadOrderMechanism::FileTime) { // the load order should have been retrieved from file time, now save it to our own format savePluginList(); } diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index e7d493a7..6f883645 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -128,7 +128,7 @@ void PluginList::refresh(const QString &profileName m_ESPsByPriority.clear(); m_ESPs.clear(); - QStringList primaryPlugins = qApp->property("managed_game").value()->getPrimaryPlugins(); + QStringList primaryPlugins = m_GamePlugin->getPrimaryPlugins(); m_CurrentProfile = profileName; @@ -313,7 +313,7 @@ bool PluginList::readLoadOrder(const QString &fileName) int priority = 0; - QStringList primaryPlugins = qApp->property("managed_game").value()->getPrimaryPlugins(); + QStringList primaryPlugins = m_GamePlugin->getPrimaryPlugins(); for (const QString &plugin : primaryPlugins) { if (availableESPs.find(plugin) != availableESPs.end()) { m_ESPLoadOrder[plugin] = priority++; @@ -504,7 +504,7 @@ void PluginList::saveTo(const QString &pluginFileName bool PluginList::saveLoadOrder(DirectoryEntry &directoryStructure) { - if (GameInfo::instance().getLoadOrderMechanism() != GameInfo::TYPE_FILETIME) { + if (m_GamePlugin->getLoadOrderMechanism() != IPluginGame::LoadOrderMechanism::FileTime) { // nothing to do return true; } @@ -1210,3 +1210,8 @@ PluginList::ESPInfo::ESPInfo(const QString &name, bool enabled, m_IsDummy = false; } } + +void PluginList::managedGameChanged(IPluginGame *gamePlugin) +{ + m_GamePlugin = gamePlugin; +} diff --git a/src/pluginlist.h b/src/pluginlist.h index f8972f05..01d4bfbe 100644 --- a/src/pluginlist.h +++ b/src/pluginlist.h @@ -22,16 +22,20 @@ along with Mod Organizer. If not, see . #include #include +namespace MOBase { class IPluginGame; } + #include #include #include #include + #pragma warning(push) #pragma warning(disable: 4100) #ifndef Q_MOC_RUN #include #include #endif + #include #include @@ -253,6 +257,12 @@ public slots: **/ void disableAll(); + /** + * @brief The currently managed game has changed + * @param gamePlugin + */ + void managedGameChanged(MOBase::IPluginGame *gamePlugin); + signals: /** @@ -337,6 +347,8 @@ private: QTemporaryFile m_TempFile; + MOBase::IPluginGame *m_GamePlugin; + }; #pragma warning(pop) diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index c3fec128..06b96d61 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -65,10 +65,6 @@ public: //**Currently only used in a nasty mess at initialisation time. virtual std::wstring getGameName() const = 0; - /// determine the load order mechanism used by this game. this may throw an - /// exception if the mechanism can't be determined - virtual LoadOrderMechanism getLoadOrderMechanism() const { return TYPE_FILETIME; } - //**USED IN HOOKDLL virtual std::wstring getGameDirectory() const; diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp index 189d2ed0..f7fba7ab 100644 --- a/src/shared/skyriminfo.cpp +++ b/src/shared/skyriminfo.cpp @@ -73,24 +73,6 @@ std::wstring SkyrimInfo::getRegPathStatic() } } -GameInfo::LoadOrderMechanism SkyrimInfo::getLoadOrderMechanism() const -{ - std::wstring fileName = getGameDirectory() + L"\\TESV.exe"; - - try { - VS_FIXEDFILEINFO versionInfo = GetFileVersion(fileName); - if ((versionInfo.dwFileVersionMS > 0x10004) || // version >= 1.5.x? - ((versionInfo.dwFileVersionMS == 0x10004) && (versionInfo.dwFileVersionLS >= 0x1A0000))) { // version >= ?.4.26 - return TYPE_PLUGINSTXT; - } else { - return TYPE_FILETIME; - } - } catch (const std::exception &e) { - log("TESV.exe is invalid: %s", e.what()); - return TYPE_FILETIME; - } -} - std::vector SkyrimInfo::getSavegameAttachmentExtensions() { return boost::assign::list_of(L"skse"); diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h index 1bf67c11..13c82456 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -42,8 +42,6 @@ public: virtual std::wstring getGameName() const { return L"Skyrim"; } - virtual LoadOrderMechanism getLoadOrderMechanism() const; - virtual std::vector getSavegameAttachmentExtensions(); // file name of this games ini (no path) -- cgit v1.3.1 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/main.cpp | 33 ++++++----- src/mainwindow.cpp | 3 +- src/nexusinterface.cpp | 81 +++++++++++++------------- src/nexusinterface.h | 133 +++++++++++++++++++++++++++++++++++-------- src/organizercore.cpp | 26 +++++++-- src/organizercore.h | 3 +- src/selfupdater.cpp | 40 +++++++------ src/selfupdater.h | 5 ++ src/shared/fallout3info.cpp | 5 -- src/shared/fallout3info.h | 2 - src/shared/falloutnvinfo.cpp | 6 -- src/shared/falloutnvinfo.h | 2 - src/shared/gameinfo.h | 2 - src/shared/oblivioninfo.cpp | 6 -- src/shared/oblivioninfo.h | 2 - src/shared/skyriminfo.cpp | 11 ---- src/shared/skyriminfo.h | 3 - 17 files changed, 222 insertions(+), 141 deletions(-) (limited to 'src/shared/skyriminfo.cpp') 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(); - - 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()); + //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()); + } } } + 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 . */ #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) {} 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 . #ifndef NEXUSINTERFACE_H #define NEXUSINTERFACE_H - - #include #include #include #include + #include #include #include #include #include + #include #include +namespace MOBase { class IPluginGame; } class NexusInterface; class NXMAccessManager; @@ -106,10 +107,6 @@ public slots: void nxmEndorsementToggled(int modID, QVariant userData, QVariant resultData, int requestID); void nxmRequestFailed(int modID, int fileID, QVariant userData, int requestID, const QString &errorMessage); -private: - - QString url(); - private: NexusInterface *m_Interface; @@ -147,29 +144,67 @@ public: */ void cleanup(); + /** + * @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 &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 &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 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 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 #include #include + #include #include #include #include + #include + #include @@ -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()) { + 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 . */ #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 -#include -#include #include +#include + #include #include #include @@ -35,7 +37,6 @@ along with Mod Organizer. If not, see . #include #include #include -#include #include @@ -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 . #include #include +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(); } -- 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/shared/skyriminfo.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 235d893eb845c3c8c0edb9dcdb703ce3ec31bdb5 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sat, 5 Dec 2015 19:13:05 +0000 Subject: Gets rid of last vestiges of GameInfo apart from startup and hookdll Working on sorting out savegame stuff --- src/mainwindow.cpp | 28 +++++++++++---- src/modinfoforeign.cpp | 8 +++-- src/savegame.cpp | 81 ++++++++++++-------------------------------- src/savegame.h | 20 +++-------- src/savegamegamebryo.cpp | 2 +- src/shared/fallout3info.cpp | 5 --- src/shared/fallout3info.h | 2 -- src/shared/falloutnvinfo.cpp | 5 --- src/shared/falloutnvinfo.h | 2 -- src/shared/gameinfo.cpp | 13 ------- src/shared/gameinfo.h | 20 ++++------- src/shared/oblivioninfo.cpp | 9 ----- src/shared/oblivioninfo.h | 2 -- src/shared/skyriminfo.cpp | 5 --- src/shared/skyriminfo.h | 2 -- 15 files changed, 61 insertions(+), 143 deletions(-) (limited to 'src/shared/skyriminfo.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7dd5d71b..aa45a0bd 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -835,15 +835,29 @@ SaveGameGamebryo *MainWindow::getSaveGame(const QString &name__) IPluginGame const *game = m_OrganizerCore.managedGame(); QString name(name__); + static int count = 0; //fudge with me -// game = m_PluginContainer.managedGame("Fallout 3"); -// name = "C:\\Users\\Dad\\Downloads\\Games\\Both good and evil saves -10416\\Save 106 - New Start Good, Vault 101 Entrance, 00.33.34.fos"; + switch (count) + { + case 0: + game = m_PluginContainer.managedGame("Fallout 3"); + name = "C:\\Users\\Dad\\Downloads\\Games\\Both good and evil saves -10416\\Save 106 - New Start Good, Vault 101 Entrance, 00.33.34.fos"; + break; + + case 1: + game = m_PluginContainer.managedGame("New Vegas"); + name = "C:\\Users\\Dad\\Downloads\\Games\\Crossroads - Clean Save-44883-1-0\\Crossroads.fos"; + break; -// game = m_PluginContainer.managedGame("New Vegas"); -// name = "C:\\Users\\Dad\\Downloads\\Games\\Crossroads - Clean Save-44883-1-0\\Crossroads.fos"; + case 2: + game = m_PluginContainer.managedGame("Oblivion"); + name = "C:\\Users\\Dad\\Saved Games\\Oblivion\\Saves\\Save 1537 - Hilary - Xirethard, Level 45, Playing Time 458.48.17.ess"; + break; -// game = m_PluginContainer.managedGame("Oblivion"); -// name = "C:\\Users\\Dad\\Saved Games\\Oblivion\\Saves\\Save 1537 - Hilary - Xirethard, Level 45, Playing Time 458.48.17.ess"; + case 3: + count = -1; + } + ++count; return new SaveGameGamebryo(this, name, game); } @@ -3210,7 +3224,7 @@ void MainWindow::deleteSavegame_clicked() foreach (const QModelIndex &idx, selectedIndexes) { QString name = idx.data().toString(); - SaveGame *save = new SaveGame(this, idx.data(Qt::UserRole).toString()); + SaveGame *save = new SaveGame(this, idx.data(Qt::UserRole).toString(), m_OrganizerCore.managedGame()); if (count < 10) { savesMsgLabel += "
  • " + QFileInfo(name).completeBaseName() + "
  • "; diff --git a/src/modinfoforeign.cpp b/src/modinfoforeign.cpp index c0e769c9..4dbe034b 100644 --- a/src/modinfoforeign.cpp +++ b/src/modinfoforeign.cpp @@ -1,8 +1,10 @@ #include "modinfoforeign.h" -#include "gameinfo.h" +#include "iplugingame.h" #include "utility.h" +#include + using namespace MOBase; using namespace MOShared; @@ -18,7 +20,9 @@ QDateTime ModInfoForeign::creationTime() const QString ModInfoForeign::absolutePath() const { - return QDir::fromNativeSeparators(ToQString(GameInfo::instance().getGameDirectory())) + "/data"; + //I ought to store this, it's used elsewhere + IPluginGame const *game = qApp->property("managed_game").value(); + return game->dataDirectory().absolutePath(); } std::vector ModInfoForeign::getFlags() const diff --git a/src/savegame.cpp b/src/savegame.cpp index 1cdabb2d..2b125575 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -18,50 +18,28 @@ along with Mod Organizer. If not, see . */ #include "savegame.h" -#include -#include -#include -#include -#include -#include -#include -#include "gameinfo.h" - - -SaveGame::SaveGame(QObject *parent) - : QObject(parent), m_FileName(), m_PCName(), m_PCLevel(0), m_PCLocation(), m_SaveNumber(0), m_Screenshot() -{ -} +#include "iplugingame.h" +#include "scriptextender.h" +#include "utility.h" -SaveGame::SaveGame(QObject *parent, const QString &filename) - : QObject(parent), m_FileName(filename), m_PCName(), m_PCLevel(0), m_PCLocation(), m_SaveNumber(0), m_Screenshot() -{ -} - +#include +#include +#include +#include -SaveGame::SaveGame(const SaveGame& reference) - : m_FileName(reference.m_FileName), m_PCName(reference.m_PCName), m_PCLevel(reference.m_PCLevel), - m_PCLocation(reference.m_PCLocation), m_SaveNumber(reference.m_SaveNumber), - m_Screenshot(reference.m_Screenshot) -{ -} +#include +#include +using namespace MOBase; -SaveGame& SaveGame::operator=(const SaveGame &reference) +SaveGame::SaveGame(QObject *parent, const QString &filename, const MOBase::IPluginGame *game) + : QObject(parent) + , m_FileName(filename) + , m_Game(game) { - if (&reference != this) { - m_FileName = reference.m_FileName; - m_PCName = reference.m_PCName; - m_PCLevel = reference.m_PCLevel; - m_PCLocation = reference.m_PCLocation; - m_SaveNumber = reference.m_SaveNumber; - m_Screenshot = reference.m_Screenshot; - } - return *this; } - SaveGame::~SaveGame() { } @@ -69,11 +47,14 @@ SaveGame::~SaveGame() QStringList SaveGame::attachedFiles() const { QStringList result; - foreach (const std::wstring &ext, MOShared::GameInfo::instance().getSavegameAttachmentExtensions()) { - QFileInfo fi(fileName()); - fi.setFile(fi.canonicalPath() + "/" + fi.completeBaseName() + "." + MOBase::ToQString(ext)); - if (fi.exists()) { - result.append(fi.filePath()); + ScriptExtender const *extender = m_Game->feature(); + if (extender != nullptr) { + for (QString const &ext : extender->saveGameAttachmentExtensions()) { + QFileInfo fi(fileName()); + fi.setFile(fi.canonicalPath() + "/" + fi.completeBaseName() + "." + ext); + if (fi.exists()) { + result.append(fi.filePath()); + } } } @@ -86,21 +67,3 @@ QStringList SaveGame::saveFiles() const result.append(fileName()); return result; } - - -void SaveGame::setCreationTime(const QString &fileName) -{ - QFileInfo creationTime(fileName); - QDateTime modified = creationTime.lastModified(); - memset(&m_CreationTime, 0, sizeof(SYSTEMTIME)); - - m_CreationTime.wDay = static_cast(modified.date().day()); - m_CreationTime.wDayOfWeek = static_cast(modified.date().dayOfWeek()); - m_CreationTime.wMonth = static_cast(modified.date().month()); - m_CreationTime.wYear =static_cast( modified.date().year()); - - m_CreationTime.wHour = static_cast(modified.time().hour()); - m_CreationTime.wMinute = static_cast(modified.time().minute()); - m_CreationTime.wSecond = static_cast(modified.time().second()); - m_CreationTime.wMilliseconds = static_cast(modified.time().msec()); -} diff --git a/src/savegame.h b/src/savegame.h index 1fd2f7ab..d1bf4691 100644 --- a/src/savegame.h +++ b/src/savegame.h @@ -31,6 +31,7 @@ along with Mod Organizer. If not, see . #define WIN32_LEAN_AND_MEAN #include +namespace MOBase { class IPluginGame; } /** * @brief represents a single save game @@ -41,23 +42,14 @@ Q_OBJECT public: - /** - * @brief construct an empty object - **/ - SaveGame(QObject *parent = 0); - /** * @brief construct a save game and immediately read out information from the file * * @param filename absolute path of the save game file **/ - SaveGame(QObject *parent, const QString &filename); - - SaveGame(const SaveGame& reference); - - SaveGame& operator=(const SaveGame &reference); + SaveGame(QObject *parent, const QString &filename, MOBase::IPluginGame const *game); - ~SaveGame(); + virtual ~SaveGame(); /** * @brief read out information from a savegame @@ -111,10 +103,6 @@ public: **/ const QImage &screenshot() const { return m_Screenshot; } -private: - - void setCreationTime(const QString &fileName); - protected: QString m_FileName; @@ -125,6 +113,8 @@ protected: SYSTEMTIME m_CreationTime; QImage m_Screenshot; +private: + MOBase::IPluginGame const * const m_Game; }; diff --git a/src/savegamegamebryo.cpp b/src/savegamegamebryo.cpp index 457cbdf2..68ed30af 100644 --- a/src/savegamegamebryo.cpp +++ b/src/savegamegamebryo.cpp @@ -31,7 +31,7 @@ using namespace MOBase; SaveGameGamebryo::SaveGameGamebryo(QObject *parent, const QString &fileName, IPluginGame const *game) - : SaveGame(parent, fileName) + : SaveGame(parent, fileName, game) , m_Plugins() { SaveGameInfo const *info = game->feature(); diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp index 008a046c..797d68ec 100644 --- a/src/shared/fallout3info.cpp +++ b/src/shared/fallout3info.cpp @@ -63,11 +63,6 @@ std::wstring Fallout3Info::getRegPathStatic() } -std::vector Fallout3Info::getSavegameAttachmentExtensions() const -{ - return std::vector(); -} - std::vector Fallout3Info::getIniFileNames() const { return boost::assign::list_of(L"fallout.ini")(L"falloutprefs.ini"); diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h index 21356924..5cf98e3b 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -37,8 +37,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() const { return getRegPathStatic(); } - virtual std::vector getSavegameAttachmentExtensions() const; - // file name of this games ini (no path) virtual std::vector getIniFileNames() const; diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp index 80d2fba5..6347224d 100644 --- a/src/shared/falloutnvinfo.cpp +++ b/src/shared/falloutnvinfo.cpp @@ -63,11 +63,6 @@ std::wstring FalloutNVInfo::getRegPathStatic() } } -std::vector FalloutNVInfo::getSavegameAttachmentExtensions() const -{ - return std::vector(); -} - std::vector FalloutNVInfo::getIniFileNames() const { return boost::assign::list_of(L"fallout.ini")(L"falloutprefs.ini"); diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h index 4bffff3f..04c13c7d 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -38,8 +38,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() const { return getRegPathStatic(); } - virtual std::vector getSavegameAttachmentExtensions() const; - // file name of this games ini (no path) virtual std::vector getIniFileNames() const; diff --git a/src/shared/gameinfo.cpp b/src/shared/gameinfo.cpp index e77b9d17..5c13a520 100644 --- a/src/shared/gameinfo.cpp +++ b/src/shared/gameinfo.cpp @@ -134,19 +134,6 @@ std::wstring GameInfo::getGameDirectory() const return m_GameDirectory; } -std::wstring GameInfo::getLocalAppFolder() const -{ - wchar_t localAppFolder[MAX_PATH]; - memset(localAppFolder, '\0', MAX_PATH * sizeof(wchar_t)); - - if (::SHGetFolderPathW(nullptr, CSIDL_LOCAL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, localAppFolder) == S_OK) { - return localAppFolder; - } else { - // fallback: try the registry - return getSpecialPath(L"Local AppData"); - } -} - std::wstring GameInfo::getSpecialPath(LPCWSTR name) const { HKEY key; diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index a5c615cf..7bc86d3a 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -42,20 +42,16 @@ public: virtual ~GameInfo() {} - //**USED IN HOOKDLL and savegame code - static GameInfo& instance(); - - //**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() const = 0; + //**USED IN HOOKDLL and at startup to set up for hookdll to work + // 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 getGameDirectory() const; + static GameInfo& instance(); //**USED ONLY 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 getGameDirectory() const; //**USED ONLY IN HOOKDLL virtual std::wstring getRegPath() const = 0; @@ -74,12 +70,8 @@ protected: GameInfo(const std::wstring &gameDirectory); - std::wstring getLocalAppFolder() const; - const std::wstring &getMyGamesDirectory() const { return m_MyGamesDirectory; } void identifyMyGamesDirectory(const std::wstring &file); - bool isValidModURL(int modID, const std::wstring &url, const std::wstring &alt) const; - private: static bool identifyGame(const std::wstring &searchPath); diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp index 8f1f1843..b50f1daa 100644 --- a/src/shared/oblivioninfo.cpp +++ b/src/shared/oblivioninfo.cpp @@ -63,15 +63,6 @@ std::wstring OblivionInfo::getRegPathStatic() } } - - - -std::vector OblivionInfo::getSavegameAttachmentExtensions() const -{ - return boost::assign::list_of(L"obse"); -} - - std::vector OblivionInfo::getIniFileNames() const { return boost::assign::list_of(L"oblivion.ini")(L"oblivionprefs.ini"); diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h index fc949f4b..bf0b2707 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -36,8 +36,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() const { return getRegPathStatic(); } - virtual std::vector getSavegameAttachmentExtensions() const; - // file name of this games ini (no path) virtual std::vector getIniFileNames() const; diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp index d255e60f..9662e66d 100644 --- a/src/shared/skyriminfo.cpp +++ b/src/shared/skyriminfo.cpp @@ -73,11 +73,6 @@ std::wstring SkyrimInfo::getRegPathStatic() } } -std::vector SkyrimInfo::getSavegameAttachmentExtensions() const -{ - return boost::assign::list_of(L"skse"); -} - std::vector SkyrimInfo::getIniFileNames() const { return boost::assign::list_of(L"skyrim.ini")(L"skyrimprefs.ini"); diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h index ac979d20..bd329403 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -38,8 +38,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() const { return getRegPathStatic(); } - virtual std::vector getSavegameAttachmentExtensions() const; - // file name of this games ini (no path) virtual std::vector getIniFileNames() const; -- cgit v1.3.1