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/organizercore.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/organizercore.cpp') 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" -- cgit v1.3.1 From efb54100dcfe8ac83284ec59e6706c488ecb10e7 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sat, 21 Nov 2015 12:30:33 +0000 Subject: Removal of (get)BinaryName --- src/gameinfoimpl.cpp | 5 +++-- src/gameinfoimpl.h | 2 +- src/organizer.pro | 6 +++--- src/organizercore.cpp | 8 ++------ src/organizercore.h | 2 +- src/organizerproxy.cpp | 13 +++++++++---- src/organizerproxy.h | 9 +++++---- src/shared/fallout3info.h | 1 - src/shared/falloutnvinfo.h | 1 - src/shared/gameinfo.h | 1 - src/shared/oblivioninfo.h | 1 - src/shared/skyriminfo.h | 1 - 12 files changed, 24 insertions(+), 26 deletions(-) (limited to 'src/organizercore.cpp') diff --git a/src/gameinfoimpl.cpp b/src/gameinfoimpl.cpp index 025ce4e6..a0dd832e 100644 --- a/src/gameinfoimpl.cpp +++ b/src/gameinfoimpl.cpp @@ -47,8 +47,9 @@ QString GameInfoImpl::path() const { return QDir::fromNativeSeparators(ToQString(GameInfo::instance().getGameDirectory())); } - +/* QString GameInfoImpl::binaryName() const { - return ToQString(GameInfo::instance().getBinaryName()); + return ToQString(GameInfo::instance().getgetBinaryName()); } +*/ diff --git a/src/gameinfoimpl.h b/src/gameinfoimpl.h index 3ed7be6b..b78321c4 100644 --- a/src/gameinfoimpl.h +++ b/src/gameinfoimpl.h @@ -32,7 +32,7 @@ public: virtual Type type() const; virtual QString path() const; - virtual QString binaryName() const; +// virtual QString binaryName() const; }; diff --git a/src/organizer.pro b/src/organizer.pro index 261e3c1c..65c1e4d3 100644 --- a/src/organizer.pro +++ b/src/organizer.pro @@ -355,10 +355,10 @@ CONFIG(debug, debug|release) { } OTHER_FILES += \ - SConscript + SConscript \ + CMakeLists.txt DISTFILES += \ tutorials/tutorial_primer_main.js \ tutorials/Tooltip.qml \ - tutorials/TooltipArea.qml \ - SConscript + tutorials/TooltipArea.qml diff --git a/src/organizercore.cpp b/src/organizercore.cpp index c1f091d9..d56f64cb 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -594,14 +594,10 @@ MOBase::VersionInfo OrganizerCore::appVersion() const return m_Updater.getVersion(); } -MOBase::IModInterface *OrganizerCore::getMod(const QString &name) +MOBase::IModInterface *OrganizerCore::getMod(const QString &name) const { unsigned int index = ModInfo::getIndex(name); - if (index == UINT_MAX) { - return nullptr; - } else { - return ModInfo::getByIndex(index).data(); - } + return index == UINT_MAX ? nullptr : ModInfo::getByIndex(index).data(); } MOBase::IModInterface *OrganizerCore::createMod(GuessedValue &name) diff --git a/src/organizercore.h b/src/organizercore.h index 85f0e0c4..3524dcb5 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -132,7 +132,7 @@ public: QString profilePath() const; QString downloadsPath() const; MOBase::VersionInfo appVersion() const; - MOBase::IModInterface *getMod(const QString &name); + MOBase::IModInterface *getMod(const QString &name) const; MOBase::IModInterface *createMod(MOBase::GuessedValue &name); bool removeMod(MOBase::IModInterface *mod); void modDataChanged(MOBase::IModInterface *mod); diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index 9e85929f..17c5a16f 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -52,7 +52,7 @@ VersionInfo OrganizerProxy::appVersion() const return m_Proxied->appVersion(); } -IModInterface *OrganizerProxy::getMod(const QString &name) +IModInterface *OrganizerProxy::getMod(const QString &name) const { return m_Proxied->getMod(name); } @@ -157,17 +157,22 @@ QList OrganizerProxy::findFileInfos(const QString return m_Proxied->findFileInfos(path, filter); } -MOBase::IDownloadManager *OrganizerProxy::downloadManager() +MOBase::IDownloadManager *OrganizerProxy::downloadManager() const { return m_Proxied->downloadManager(); } -MOBase::IPluginList *OrganizerProxy::pluginList() +MOBase::IPluginList *OrganizerProxy::pluginList() const { return m_Proxied->pluginList(); } -MOBase::IModList *OrganizerProxy::modList() +MOBase::IModList *OrganizerProxy::modList() const { return m_Proxied->modList(); } + +MOBase::IPluginGame *OrganizerProxy::managedGame() const +{ + return m_Proxied->managedGame(); +} diff --git a/src/organizerproxy.h b/src/organizerproxy.h index fb502a7f..31009c8a 100644 --- a/src/organizerproxy.h +++ b/src/organizerproxy.h @@ -19,7 +19,7 @@ public: virtual QString downloadsPath() const; virtual QString overwritePath() const; virtual MOBase::VersionInfo appVersion() const; - virtual MOBase::IModInterface *getMod(const QString &name); + virtual MOBase::IModInterface *getMod(const QString &name) const; virtual MOBase::IModInterface *createMod(MOBase::GuessedValue &name); virtual bool removeMod(MOBase::IModInterface *mod); virtual void modDataChanged(MOBase::IModInterface *mod); @@ -35,9 +35,9 @@ public: virtual QStringList getFileOrigins(const QString &fileName) const; virtual QList findFileInfos(const QString &path, const std::function &filter) const; - virtual MOBase::IDownloadManager *downloadManager(); - virtual MOBase::IPluginList *pluginList(); - virtual MOBase::IModList *modList(); + virtual MOBase::IDownloadManager *downloadManager() const; + virtual MOBase::IPluginList *pluginList() const; + virtual MOBase::IModList *modList() const; virtual HANDLE startApplication(const QString &executable, const QStringList &args = QStringList(), const QString &cwd = "", const QString &profile = ""); virtual bool waitForApplication(HANDLE handle, LPDWORD exitCode = nullptr) const; virtual void refreshModList(bool saveChanges); @@ -46,6 +46,7 @@ public: virtual bool onFinishedRun(const std::function &func); virtual bool onModInstalled(const std::function &func); + virtual MOBase::IPluginGame *managedGame() const; private: diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h index 51abe073..90bb6ec0 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -37,7 +37,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() { return getRegPathStatic(); } - virtual std::wstring getBinaryName() { return L"Fallout3.exe"; } virtual GameInfo::Type getType() { return TYPE_FALLOUT3; } diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h index 59b52323..613694b2 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -37,7 +37,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() { return getRegPathStatic(); } - virtual std::wstring getBinaryName() { return L"FalloutNV.exe"; } virtual GameInfo::Type getType() { return TYPE_FALLOUTNV; } diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index 47a5e767..57613e5e 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -58,7 +58,6 @@ public: //**USED IN HOOKDLL virtual std::wstring getRegPath() = 0; - virtual std::wstring getBinaryName() = 0; virtual GameInfo::Type getType() = 0; diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h index ac10b80a..fcdac6bd 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -35,7 +35,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() { return getRegPathStatic(); } - virtual std::wstring getBinaryName() { return L"Oblivion.exe"; } virtual GameInfo::Type getType() { return TYPE_OBLIVION; } diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h index 65977a69..f26cd065 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -37,7 +37,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() { return getRegPathStatic(); } - virtual std::wstring getBinaryName() { return L"TESV.exe"; } virtual GameInfo::Type getType() { return TYPE_SKYRIM; } -- cgit v1.3.1 From 4dbb3b148d874238b0f8dab323f198cc8d4e40c6 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sat, 21 Nov 2015 17:26:34 +0000 Subject: Replace some instances of qApp->property("managed_game") with the saved pointer. Pedantic note: This doesn't help the possibility of supporting multiple executables greatly, we'd have to have a lot of register-for-change events. --- src/mainwindow.cpp | 3 +-- src/organizercore.cpp | 3 +-- src/profile.cpp | 21 ++++++++++----------- src/profile.h | 1 + 4 files changed, 13 insertions(+), 15 deletions(-) (limited to 'src/organizercore.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 26ff4b98..84a51b62 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1332,8 +1332,7 @@ void MainWindow::updateBSAList(const QStringList &defaultArchives, const QString std::vector> items; - IPluginGame *gamePlugin = qApp->property("managed_game").value(); - BSAInvalidation *invalidation = gamePlugin->feature(); + BSAInvalidation *invalidation = m_OrganizerCore.managedGame()->feature(); std::vector files = m_OrganizerCore.directoryStructure()->getFiles(); QStringList plugins = m_OrganizerCore.findFiles("", [] (const QString &fileName) -> bool { diff --git a/src/organizercore.cpp b/src/organizercore.cpp index d56f64cb..517a9bfb 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1570,8 +1570,7 @@ void OrganizerCore::prepareStart() { std::vector> OrganizerCore::fileMapping() { - IPluginGame *game = qApp->property("managed_game").value(); - return fileMapping(game->dataDirectory().absolutePath(), + return fileMapping(managedGame()->dataDirectory().absolutePath(), directoryStructure(), directoryStructure()); } diff --git a/src/profile.cpp b/src/profile.cpp index b990fbc1..cf3622b0 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -18,6 +18,7 @@ along with Mod Organizer. If not, see . */ #include "profile.h" + #include "gameinfo.h" #include "windows_error.h" #include "modinfo.h" @@ -30,16 +31,18 @@ along with Mod Organizer. If not, see . #include #include #include + #include #include #include #include + #include +#include #define WIN32_LEAN_AND_MEAN #include #include -#include using namespace MOBase; using namespace MOShared; @@ -47,6 +50,7 @@ using namespace MOShared; Profile::Profile() : m_ModListWriter(std::bind(&Profile::writeModlistNow, this)) + , m_GamePlugin(qApp->property("managed_game").value()) { } @@ -101,6 +105,7 @@ Profile::Profile(const QString &name, IPluginGame *gamePlugin, bool useDefaultSe Profile::Profile(const QDir &directory, IPluginGame *gamePlugin) : m_Directory(directory) + , m_GamePlugin(gamePlugin) , m_ModListWriter(std::bind(&Profile::writeModlistNow, this)) { assert(gamePlugin != nullptr); @@ -568,10 +573,8 @@ void Profile::mergeTweaks(ModInfo::Ptr modInfo, const QString &tweakedIni) const bool Profile::invalidationActive(bool *supported) const { - IPluginGame *gamePlugin = qApp->property("managed_game").value(); - - BSAInvalidation *invalidation = gamePlugin->feature(); - DataArchives *dataArchives = gamePlugin->feature(); + BSAInvalidation *invalidation = m_GamePlugin->feature(); + DataArchives *dataArchives = m_GamePlugin->feature(); if ((invalidation != nullptr) && (dataArchives != nullptr)) { if (supported != nullptr) { @@ -593,9 +596,7 @@ bool Profile::invalidationActive(bool *supported) const void Profile::deactivateInvalidation() { - IPluginGame *gamePlugin = qApp->property("managed_game").value(); - - BSAInvalidation *invalidation = gamePlugin->feature(); + BSAInvalidation *invalidation = m_GamePlugin->feature(); if (invalidation != nullptr) { invalidation->deactivate(this); @@ -605,9 +606,7 @@ void Profile::deactivateInvalidation() void Profile::activateInvalidation() { - IPluginGame *gamePlugin = qApp->property("managed_game").value(); - - BSAInvalidation *invalidation = gamePlugin->feature(); + BSAInvalidation *invalidation = m_GamePlugin->feature(); if (invalidation != nullptr) { invalidation->activate(this); diff --git a/src/profile.h b/src/profile.h index 342b6fa0..9c8139e9 100644 --- a/src/profile.h +++ b/src/profile.h @@ -65,6 +65,7 @@ public: * @param filter save game filter. Defaults to <no filter>. **/ Profile(const QString &name, MOBase::IPluginGame *gamePlugin, bool useDefaultSettings); + /** * @brief constructor * -- cgit v1.3.1 From 159501d0763c3e801d3997d8d4d72accd5f7a9f9 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sun, 22 Nov 2015 08:46:46 +0000 Subject: Removes igameinfo.h from everywhere apart from (sort of) the pythonrunner plugin. Also comment out the filemapping function because it's large and doesn't appear to be used anywhere --- src/gameinfoimpl.cpp | 2 +- src/gameinfoimpl.h | 2 +- src/organizercore.cpp | 3 ++- src/organizercore.h | 6 ++++-- src/profile.cpp | 1 - 5 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/organizercore.cpp') diff --git a/src/gameinfoimpl.cpp b/src/gameinfoimpl.cpp index 133c6de6..580ee02c 100644 --- a/src/gameinfoimpl.cpp +++ b/src/gameinfoimpl.cpp @@ -31,6 +31,7 @@ GameInfoImpl::GameInfoImpl() { } +/* IGameInfo::Type GameInfoImpl::type() const { switch (GameInfo::instance().getType()) { @@ -42,7 +43,6 @@ IGameInfo::Type GameInfoImpl::type() const } } -/* QString GameInfoImpl::path() const { return QDir::fromNativeSeparators(ToQString(GameInfo::instance().getGameDirectory())); diff --git a/src/gameinfoimpl.h b/src/gameinfoimpl.h index b764b224..f3a21669 100644 --- a/src/gameinfoimpl.h +++ b/src/gameinfoimpl.h @@ -30,7 +30,7 @@ class GameInfoImpl : public MOBase::IGameInfo public: GameInfoImpl(); - virtual Type type() const; +// virtual Type type() const; // virtual QString path() const; // virtual QString binaryName() const; diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 517a9bfb..704dc734 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1568,6 +1568,7 @@ void OrganizerCore::prepareStart() { storeSettings(); } +/* std::vector> OrganizerCore::fileMapping() { return fileMapping(managedGame()->dataDirectory().absolutePath(), @@ -1606,4 +1607,4 @@ std::vector> OrganizerCore::fileMapping( return result; } - +*/ diff --git a/src/organizercore.h b/src/organizercore.h index 3524dcb5..00cf6934 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -157,7 +157,7 @@ public: bool onFinishedRun(const std::function &func); void refreshModList(bool saveChanges = true); - std::vector > fileMapping(); + //std::vector > fileMapping(); public: // IPluginDiagnose interface @@ -210,9 +210,11 @@ private: bool testForSteam(); - std::vector> fileMapping(const QString &dataPath, + /* + * std::vector> fileMapping(const QString &dataPath, const MOShared::DirectoryEntry *base, const MOShared::DirectoryEntry *directoryEntry); +*/ private slots: diff --git a/src/profile.cpp b/src/profile.cpp index cf3622b0..c6a2b43d 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -19,7 +19,6 @@ along with Mod Organizer. If not, see . #include "profile.h" -#include "gameinfo.h" #include "windows_error.h" #include "modinfo.h" #include "safewritefile.h" -- cgit v1.3.1 From efaba9070639dbdc77955784b5de3365c9271738 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sun, 22 Nov 2015 21:18:56 +0000 Subject: Final eradication of igameinfo and adding python wrappers for IPluginGame --- src/CMakeLists.txt | 2 -- src/gameinfoimpl.cpp | 55 -------------------------------------------------- src/gameinfoimpl.h | 39 ----------------------------------- src/mainwindow.cpp | 1 - src/organizer.pro | 2 -- src/organizercore.cpp | 10 +-------- src/organizercore.h | 3 --- src/organizerproxy.cpp | 5 ----- src/organizerproxy.h | 1 - 9 files changed, 1 insertion(+), 117 deletions(-) delete mode 100644 src/gameinfoimpl.cpp delete mode 100644 src/gameinfoimpl.h (limited to 'src/organizercore.cpp') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 22b725de..8a2964d4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -61,7 +61,6 @@ SET(organizer_SRCS moapplication.cpp profileinputdialog.cpp icondelegate.cpp - gameinfoimpl.cpp csvbuilder.cpp savetextasdialog.cpp qtgroupingproxy.cpp @@ -150,7 +149,6 @@ SET(organizer_HDRS moapplication.h profileinputdialog.h icondelegate.h - gameinfoimpl.h csvbuilder.h savetextasdialog.h qtgroupingproxy.h diff --git a/src/gameinfoimpl.cpp b/src/gameinfoimpl.cpp deleted file mode 100644 index 580ee02c..00000000 --- a/src/gameinfoimpl.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* -Copyright (C) 2012 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Mod Organizer is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Mod Organizer. If not, see . -*/ - -#include "gameinfoimpl.h" -#include -#include -#include - - -using namespace MOBase; -using namespace MOShared; - - -GameInfoImpl::GameInfoImpl() -{ -} - -/* -IGameInfo::Type GameInfoImpl::type() const -{ - switch (GameInfo::instance().getType()) { - case GameInfo::TYPE_OBLIVION: return IGameInfo::TYPE_OBLIVION; - case GameInfo::TYPE_FALLOUT3: return IGameInfo::TYPE_FALLOUT3; - case GameInfo::TYPE_FALLOUTNV: return IGameInfo::TYPE_FALLOUTNV; - case GameInfo::TYPE_SKYRIM: return IGameInfo::TYPE_SKYRIM; - default: throw MyException(QObject::tr("invalid game type %1").arg(GameInfo::instance().getType())); - } -} - -QString GameInfoImpl::path() const -{ - return QDir::fromNativeSeparators(ToQString(GameInfo::instance().getGameDirectory())); -} - -QString GameInfoImpl::binaryName() const -{ - return ToQString(GameInfo::instance().getgetBinaryName()); -} -*/ diff --git a/src/gameinfoimpl.h b/src/gameinfoimpl.h deleted file mode 100644 index f3a21669..00000000 --- a/src/gameinfoimpl.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright (C) 2012 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Mod Organizer is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Mod Organizer. If not, see . -*/ - -#ifndef GAMEINFOIMPL_H -#define GAMEINFOIMPL_H - - -#include -#include - - -class GameInfoImpl : public MOBase::IGameInfo -{ -public: - GameInfoImpl(); - -// virtual Type type() const; -// virtual QString path() const; -// virtual QString binaryName() const; - -}; - -#endif // GAMEINFOIMPL_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 84a51b62..7142bcb1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -52,7 +52,6 @@ along with Mod Organizer. If not, see . #include "credentialsdialog.h" #include "selectiondialog.h" #include "csvbuilder.h" -#include "gameinfoimpl.h" #include "savetextasdialog.h" #include "problemsdialog.h" #include "previewdialog.h" diff --git a/src/organizer.pro b/src/organizer.pro index 65c1e4d3..2869fda5 100644 --- a/src/organizer.pro +++ b/src/organizer.pro @@ -70,7 +70,6 @@ SOURCES += \ moapplication.cpp \ profileinputdialog.cpp \ icondelegate.cpp \ - gameinfoimpl.cpp \ csvbuilder.cpp \ savetextasdialog.cpp \ qtgroupingproxy.cpp \ @@ -145,7 +144,6 @@ HEADERS += \ moapplication.h \ profileinputdialog.h \ icondelegate.h \ - gameinfoimpl.h \ csvbuilder.h \ savetextasdialog.h \ qtgroupingproxy.h \ diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 704dc734..826d5bea 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1,7 +1,6 @@ #include "organizercore.h" #include "mainwindow.h" -#include "gameinfoimpl.h" #include "messagedialog.h" #include "logbuffer.h" #include "credentialsdialog.h" @@ -119,8 +118,7 @@ QStringList toStringList(InputIterator current, InputIterator end) OrganizerCore::OrganizerCore(const QSettings &initSettings) - : m_GameInfo(new GameInfoImpl()) - , m_UserInterface(nullptr) + : m_UserInterface(nullptr) , m_PluginContainer(nullptr) , m_GameName() , m_CurrentProfile(nullptr) @@ -187,7 +185,6 @@ OrganizerCore::~OrganizerCore() m_ModList.setProfile(nullptr); NexusInterface::instance()->cleanup(); - delete m_GameInfo; delete m_DirectoryStructure; } @@ -556,11 +553,6 @@ void OrganizerCore::setCurrentProfile(const QString &profileName) refreshDirectoryStructure(); } -MOBase::IGameInfo &OrganizerCore::gameInfo() const -{ - return *m_GameInfo; -} - MOBase::IModRepositoryBridge *OrganizerCore::createNexusBridge() const { return new NexusBridge(); diff --git a/src/organizercore.h b/src/organizercore.h index 00cf6934..6075eb18 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -126,7 +126,6 @@ public: MOBase::DelayedFileWriter &pluginsWriter() { return m_PluginListsWriter; } public: - MOBase::IGameInfo &gameInfo() const; MOBase::IModRepositoryBridge *createNexusBridge() const; QString profileName() const; QString profilePath() const; @@ -231,8 +230,6 @@ private: private: - MOBase::IGameInfo *m_GameInfo; - IUserInterface *m_UserInterface; PluginContainer *m_PluginContainer; QString m_GameName; diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index 17c5a16f..3c103ff0 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -15,11 +15,6 @@ OrganizerProxy::OrganizerProxy(OrganizerCore *organizer, const QString &pluginNa { } -IGameInfo &OrganizerProxy::gameInfo() const -{ - return m_Proxied->gameInfo(); -} - IModRepositoryBridge *OrganizerProxy::createNexusBridge() const { return new NexusBridge(m_PluginName); diff --git a/src/organizerproxy.h b/src/organizerproxy.h index 31009c8a..2f5e0970 100644 --- a/src/organizerproxy.h +++ b/src/organizerproxy.h @@ -12,7 +12,6 @@ public: OrganizerProxy(OrganizerCore *organizer, const QString &pluginName); - virtual MOBase::IGameInfo &gameInfo() const; virtual MOBase::IModRepositoryBridge *createNexusBridge() const; virtual QString profileName() const; virtual QString profilePath() const; -- cgit v1.3.1 From 2a50683133953edd80606aedbdd93a7f10d4a7d8 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Mon, 23 Nov 2015 13:35:48 +0000 Subject: Removed 'requiresSteam' which is only used in one place and might or might not be game related --- src/organizercore.cpp | 5 ++++- src/shared/gameinfo.cpp | 5 ----- src/shared/gameinfo.h | 2 -- 3 files changed, 4 insertions(+), 8 deletions(-) (limited to 'src/organizercore.cpp') diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 826d5bea..ee69c46b 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -950,7 +950,10 @@ HANDLE OrganizerCore::spawnBinaryDirect(const QFileInfo &binary, const QString & ::SetEnvironmentVariableW(L"SteamAPPId", ToWString(m_Settings.getSteamAppID()).c_str()); } - if ((GameInfo::instance().requiresSteam()) + + //This could possibly be extracted somewhere else but it's probably for when + //we have more than one provider of game registration. + if (QFileInfo(managedGame()->gameDirectory().absoluteFilePath("steam_api.dll")).exists() && (m_Settings.getLoadMechanism() == LoadMechanism::LOAD_MODORGANIZER)) { if (!testForSteam()) { QWidget *window = qApp->activeWindow(); diff --git a/src/shared/gameinfo.cpp b/src/shared/gameinfo.cpp index 703f4a40..2890e9cc 100644 --- a/src/shared/gameinfo.cpp +++ b/src/shared/gameinfo.cpp @@ -135,11 +135,6 @@ std::wstring GameInfo::getGameDirectory() const return m_GameDirectory; } -bool GameInfo::requiresSteam() const -{ - return FileExists(getGameDirectory() + L"\\steam_api.dll"); -} - std::wstring GameInfo::getLocalAppFolder() const { wchar_t localAppFolder[MAX_PATH]; diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index 57613e5e..e1a70597 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -71,8 +71,6 @@ public: //**USED IN HOOKDLL virtual std::wstring getGameDirectory() const; - virtual bool requiresSteam() const; - // get a list of file extensions for additional files belonging to a save game virtual std::vector getSavegameAttachmentExtensions() = 0; -- 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/organizercore.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 37c3bea7dd5a562a97c00b740103cc2868b3013b Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Tue, 24 Nov 2015 06:58:29 +0000 Subject: Removes all uses of GameInfo::getShortName, replaced by IPluginGame::getNexustName --- src/downloadmanager.cpp | 11 +++++++++-- src/downloadmanager.h | 4 ++++ src/mainwindow.cpp | 18 +++++++++--------- src/organizercore.cpp | 1 + src/settings.cpp | 14 +++++--------- src/shared/fallout3info.h | 1 - src/shared/falloutnvinfo.h | 1 - src/shared/gameinfo.h | 1 - src/shared/oblivioninfo.h | 2 +- src/shared/skyriminfo.h | 1 - 10 files changed, 29 insertions(+), 25 deletions(-) (limited to 'src/organizercore.cpp') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index e0d76765..588b8bb9 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -18,10 +18,11 @@ along with Mod Organizer. If not, see . */ #include "downloadmanager.h" + #include "nxmurl.h" #include "nexusinterface.h" #include "nxmaccessmanager.h" -#include +#include "iplugingame.h" #include #include #include "utility.h" @@ -30,6 +31,7 @@ along with Mod Organizer. If not, see . #include "bbcode.h" #include #include + #include #include #include @@ -37,6 +39,7 @@ along with Mod Organizer. If not, see . #include #include #include + #include #include @@ -447,7 +450,7 @@ void DownloadManager::addNXMDownload(const QString &url) { NXMUrl nxmInfo(url); - QString managedGame = ToQString(MOShared::GameInfo::instance().getGameShortName()); + QString managedGame = m_ManagedGame->getNexusName(); qDebug("add nxm download: %s", qPrintable(url)); if (nxmInfo.game().compare(managedGame, Qt::CaseInsensitive) != 0) { qDebug("download requested for wrong game (game: %s, url: %s)", qPrintable(managedGame), qPrintable(nxmInfo.game())); @@ -1462,3 +1465,7 @@ void DownloadManager::directoryChanged(const QString&) refreshList(); } +void DownloadManager::managedGameChanged(MOBase::IPluginGame *managedGame) +{ + m_ManagedGame = managedGame; +} diff --git a/src/downloadmanager.h b/src/downloadmanager.h index f13cc65d..faa4267e 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -35,6 +35,7 @@ along with Mod Organizer. If not, see . #include #include +namespace MOBase { class IPluginGame; } class NexusInterface; @@ -416,6 +417,8 @@ public slots: void nxmRequestFailed(int modID, int fileID, QVariant userData, int requestID, const QString &errorString); + void managedGameChanged(MOBase::IPluginGame *gamePlugin); + private slots: void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); @@ -503,6 +506,7 @@ private: QRegExp m_DateExpression; + MOBase::IPluginGame *m_ManagedGame; }; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3c331c65..ceb118ea 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -58,10 +58,8 @@ along with Mod Organizer. If not, see . #include "browserdialog.h" #include "aboutdialog.h" #include "safewritefile.h" -#include "organizerproxy.h" #include "nxmaccessmanager.h" #include -#include #include #include #include @@ -70,15 +68,11 @@ along with Mod Organizer. If not, see . #include #include #include -#include -#include -#include -#include + #include #include #include #include -#include #include #include #include @@ -126,8 +120,14 @@ along with Mod Organizer. If not, see . #include #include #endif + +#include #include #include +#include +#include +#include +#include #ifdef TEST_MODELS #include "modeltest.h" @@ -4391,8 +4391,8 @@ void MainWindow::on_bossButton_clicked() parameters << "--unattended" << "--stdout" << "--noreport" - << "--game" << ToQString(GameInfo::instance().getGameShortName()) - << "--gamePath" << QString("\"%1\"").arg(ToQString(GameInfo::instance().getGameDirectory())) + << "--game" << m_OrganizerCore.managedGame()->getNexusName() + << "--gamePath" << QString("\"%1\"").arg(m_OrganizerCore.managedGame()->gameDirectory().absolutePath()) << "--out" << outPath; if (m_DidUpdateMasterList) { diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 7a2f95d3..c81a473c 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -159,6 +159,7 @@ OrganizerCore::OrganizerCore(const QSettings &initSettings) 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(&m_PluginList, &PluginList::writePluginsList, &m_PluginListsWriter, &DelayedFileWriterBase::write); diff --git a/src/settings.cpp b/src/settings.cpp index 4c2a34c8..61d6aaa3 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -23,25 +23,21 @@ along with Mod Organizer. If not, see . #include "utility.h" #include "helper.h" #include "json.h" -#include #include #include #include #include -#include -#include -#include #include -#include #include +#include +#include +#include +#include #include - using namespace MOBase; -using namespace MOShared; - template class QListWidgetItemEx : public QListWidgetItem { @@ -112,7 +108,7 @@ void Settings::registerAsNXMHandler(bool force) std::wstring nxmPath = ToWString(QCoreApplication::applicationDirPath() + "/nxmhandler.exe"); std::wstring executable = ToWString(QCoreApplication::applicationFilePath()); std::wstring mode = force ? L"forcereg" : L"reg"; - std::wstring parameters = mode + L" " + GameInfo::instance().getGameShortName() + L" \"" + executable + L"\""; + std::wstring parameters = mode + L" " + m_GamePlugin->getNexusName().toStdWString() + L" \"" + executable + L"\""; HINSTANCE res = ::ShellExecuteW(nullptr, L"open", nxmPath.c_str(), parameters.c_str(), nullptr, SW_SHOWNORMAL); if ((int)res <= 32) { QMessageBox::critical(nullptr, tr("Failed"), diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h index ae6a27c7..ed130e53 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -41,7 +41,6 @@ public: virtual GameInfo::Type getType() { return TYPE_FALLOUT3; } virtual std::wstring getGameName() const { return L"Fallout 3"; } - virtual std::wstring getGameShortName() const { return L"Fallout3"; } virtual std::vector getSavegameAttachmentExtensions(); diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h index 2179bf2f..75febd4c 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -41,7 +41,6 @@ public: virtual GameInfo::Type getType() { return TYPE_FALLOUTNV; } virtual std::wstring getGameName() const { return L"New Vegas"; } - virtual std::wstring getGameShortName() const { return L"FalloutNV"; } virtual std::vector getSavegameAttachmentExtensions(); diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index 9ae42159..9538a19c 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -62,7 +62,6 @@ public: virtual GameInfo::Type getType() = 0; virtual std::wstring getGameName() const = 0; - virtual std::wstring getGameShortName() const = 0; /// determine the load order mechanism used by this game. this may throw an /// exception if the mechanism can't be determined diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h index 2a550e0e..a9808d77 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -39,7 +39,7 @@ public: virtual GameInfo::Type getType() { return TYPE_OBLIVION; } virtual std::wstring getGameName() const { return L"Oblivion"; } - virtual std::wstring getGameShortName() const { return L"Oblivion"; } + virtual std::vector getSavegameAttachmentExtensions(); // file name of this games ini (no path) diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h index 741f76c9..1bf67c11 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -41,7 +41,6 @@ public: virtual GameInfo::Type getType() { return TYPE_SKYRIM; } virtual std::wstring getGameName() const { return L"Skyrim"; } - virtual std::wstring getGameShortName() const { return L"Skyrim"; } virtual LoadOrderMechanism getLoadOrderMechanism() const; -- 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/organizercore.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 78b686b2bc507a5606bc7c673745b02346bc667a Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Wed, 25 Nov 2015 08:22:40 +0000 Subject: Removes all references to GameInfo::getGameDirectory apart from one during startup Did some const correctness improvements Also may have fixed a potential crash as the Profile copy constructor didn't copy the m_GamePlugin membber --- src/directoryrefresher.cpp | 8 +++++++- src/loadmechanism.cpp | 1 + src/mainwindow.cpp | 23 ++++++++++++----------- src/mainwindow.h | 4 ---- src/modinfo.cpp | 5 +++-- src/organizercore.cpp | 2 +- src/profile.cpp | 8 +++++--- src/profile.h | 8 ++++---- src/profilesdialog.cpp | 12 ++++++------ src/profilesdialog.h | 4 ++-- src/settingsdialog.cpp | 11 +++++++++-- src/shared/gameinfo.h | 2 +- src/transfersavesdialog.cpp | 2 +- src/transfersavesdialog.h | 4 ++-- 14 files changed, 54 insertions(+), 40 deletions(-) (limited to 'src/organizercore.cpp') diff --git a/src/directoryrefresher.cpp b/src/directoryrefresher.cpp index c253f384..f4ad2a7d 100644 --- a/src/directoryrefresher.cpp +++ b/src/directoryrefresher.cpp @@ -18,10 +18,14 @@ along with Mod Organizer. If not, see . */ #include "directoryrefresher.h" + +#include "iplugingame.h" #include "utility.h" #include "report.h" #include "modinfo.h" #include + +#include #include #include @@ -141,7 +145,9 @@ void DirectoryRefresher::refresh() m_DirectoryStructure = new DirectoryEntry(L"data", nullptr, 0); - std::wstring dataDirectory = GameInfo::instance().getGameDirectory() + L"\\data"; + IPluginGame *game = qApp->property("managed_game").value(); + + std::wstring dataDirectory = QDir::toNativeSeparators(game->dataDirectory().absolutePath()).toStdWString(); m_DirectoryStructure->addFromOrigin(L"data", dataDirectory, 0); // TODO what was the point of having the priority in this tuple? the list is already sorted by priority diff --git a/src/loadmechanism.cpp b/src/loadmechanism.cpp index 4d06bea9..0d95c51c 100644 --- a/src/loadmechanism.cpp +++ b/src/loadmechanism.cpp @@ -64,6 +64,7 @@ void LoadMechanism::removeHintFile(QDir &targetDirectory) bool LoadMechanism::isDirectLoadingSupported() { + //FIXME: Seriously? isn't there a 'do i need steam' thing? IPluginGame *game = qApp->property("managed_game").value(); if (game->gameName().compare("oblivion", Qt::CaseInsensitive) == 0) { // oblivion can be loaded directly if it's not the steam variant diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5856f57f..05650219 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -153,7 +153,6 @@ MainWindow::MainWindow(const QString &exeName , m_ModListGroupingProxy(nullptr) , m_ModListSortProxy(nullptr) , m_OldExecutableIndex(-1) - , m_GamePath(ToQString(GameInfo::instance().getGameDirectory())) , m_CategoryFactory(CategoryFactory::instance()) , m_ContextItem(nullptr) , m_ContextAction(nullptr) @@ -1031,9 +1030,9 @@ void MainWindow::on_profileBox_currentIndexChanged(int index) if (ui->profileBox->currentIndex() == 0) { ui->profileBox->setCurrentIndex(previousIndex); - ProfilesDialog(ui->profileBox->currentText(), this).exec(); + ProfilesDialog(ui->profileBox->currentText(), m_OrganizerCore.managedGame(), this).exec(); while (!refreshProfiles()) { - ProfilesDialog(ui->profileBox->currentText(), this).exec(); + ProfilesDialog(ui->profileBox->currentText(), m_OrganizerCore.managedGame(), this).exec(); } } else { activateSelectedProfile(); @@ -1819,16 +1818,18 @@ void MainWindow::on_actionInstallMod_triggered() void MainWindow::on_actionAdd_Profile_triggered() { - bool repeat = true; - while (repeat) { - ProfilesDialog profilesDialog(m_GamePath, this); + for (;;) { + //Note: Calling this with an invalid profile name. Not quite sure why + ProfilesDialog profilesDialog(m_OrganizerCore.managedGame()->gameDirectory().absolutePath(), + m_OrganizerCore.managedGame(), + this); // workaround: need to disable monitoring of the saves directory, otherwise the active // profile directory is locked stopMonitorSaves(); profilesDialog.exec(); refreshSaveList(); // since the save list may now be outdated we have to refresh it completely if (refreshProfiles() && !profilesDialog.failed()) { - repeat = false; + break; } } // addProfile(); @@ -3225,9 +3226,9 @@ void MainWindow::fixMods_clicked() // search in data { - QDir dataDir(m_GamePath + "/data"); + QDir dataDir(m_OrganizerCore.managedGame()->dataDirectory()); QStringList esps = dataDir.entryList(espFilter); - foreach (const QString &esp, esps) { + for (const QString &esp : esps) { std::map >::iterator iter = missingPlugins.find(esp); if (iter != missingPlugins.end()) { iter->second.push_back(""); @@ -3241,7 +3242,7 @@ void MainWindow::fixMods_clicked() ModInfo::Ptr modInfo = ModInfo::getByIndex(modIndex); QStringList esps = QDir(modInfo->absolutePath()).entryList(espFilter); - foreach (const QString &esp, esps) { + for (const QString &esp : esps) { std::map >::iterator iter = missingPlugins.find(esp); if (iter != missingPlugins.end()) { iter->second.push_back(modInfo->name()); @@ -3253,7 +3254,7 @@ void MainWindow::fixMods_clicked() { QDir overwriteDir(qApp->property("dataPath").toString() + "/" + QString::fromStdWString(AppConfig::overwritePath())); QStringList esps = overwriteDir.entryList(espFilter); - foreach (const QString &esp, esps) { + for (const QString &esp : esps) { std::map >::iterator iter = missingPlugins.find(esp); if (iter != missingPlugins.end()) { iter->second.push_back(""); diff --git a/src/mainwindow.h b/src/mainwindow.h index 55ae40b9..b97a728e 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -285,15 +285,11 @@ private: int m_OldExecutableIndex; - QString m_GamePath; - int m_ContextRow; QPersistentModelIndex m_ContextIdx; QTreeWidgetItem *m_ContextItem; QAction *m_ContextAction; - //int m_SelectedSaveGame; - CategoryFactory &m_CategoryFactory; int m_ModsToUpdate; diff --git a/src/modinfo.cpp b/src/modinfo.cpp index a0628bd8..d79a7919 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -1134,14 +1134,15 @@ 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 *game = qApp->property("managed_game").value(); + return game->dataDirectory().absolutePath(); } std::vector ModInfoForeign::getFlags() const { std::vector result = ModInfoWithConflictInfo::getFlags(); result.push_back(FLAG_FOREIGN); - return result; } diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 24077923..c3e10d37 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1011,7 +1011,7 @@ HANDLE OrganizerCore::startApplication(const QString &executable, const QStringL binary = QFileInfo(executable); if (binary.isRelative()) { // relative path, should be relative to game directory - binary = QFileInfo(QDir::fromNativeSeparators(ToQString(GameInfo::instance().getGameDirectory())) + "/" + executable); + binary = QFileInfo(managedGame()->gameDirectory().absoluteFilePath(executable)); } if (cwd.length() == 0) { currentDirectory = binary.absolutePath(); diff --git a/src/profile.cpp b/src/profile.cpp index 42dc56d1..77f6ebd1 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -54,7 +54,7 @@ void Profile::touchFile(QString fileName) } } -Profile::Profile(const QString &name, IPluginGame *gamePlugin, bool useDefaultSettings) +Profile::Profile(const QString &name, IPluginGame const *gamePlugin, bool useDefaultSettings) : m_ModListWriter(std::bind(&Profile::writeModlistNow, this)) , m_GamePlugin(gamePlugin) { @@ -95,7 +95,7 @@ Profile::Profile(const QString &name, IPluginGame *gamePlugin, bool useDefaultSe } -Profile::Profile(const QDir &directory, IPluginGame *gamePlugin) +Profile::Profile(const QDir &directory, IPluginGame const *gamePlugin) : m_Directory(directory) , m_GamePlugin(gamePlugin) , m_ModListWriter(std::bind(&Profile::writeModlistNow, this)) @@ -122,6 +122,8 @@ Profile::Profile(const QDir &directory, IPluginGame *gamePlugin) Profile::Profile(const Profile &reference) : m_Directory(reference.m_Directory) , m_ModListWriter(std::bind(&Profile::writeModlistNow, this)) + , m_GamePlugin(reference.m_GamePlugin) + { refreshModStatus(); } @@ -483,7 +485,7 @@ void Profile::setModPriority(unsigned int index, int &newPriority) m_ModListWriter.write(); } -Profile *Profile::createPtrFrom(const QString &name, const Profile &reference, MOBase::IPluginGame *gamePlugin) +Profile *Profile::createPtrFrom(const QString &name, const Profile &reference, MOBase::IPluginGame const *gamePlugin) { QString profileDirectory = qApp->property("dataPath").toString() + "/" + QString::fromStdWString(AppConfig::profilesPath()) + "/" + name; reference.copyFilesTo(profileDirectory); diff --git a/src/profile.h b/src/profile.h index e9edca56..b306e0c5 100644 --- a/src/profile.h +++ b/src/profile.h @@ -57,7 +57,7 @@ public: * @param name name of the new profile * @param filter save game filter. Defaults to <no filter>. **/ - Profile(const QString &name, MOBase::IPluginGame *gamePlugin, bool useDefaultSettings); + Profile(const QString &name, MOBase::IPluginGame const *gamePlugin, bool useDefaultSettings); /** * @brief constructor @@ -67,7 +67,7 @@ public: * invoking this should always produce a working profile * @param directory directory to read the profile from **/ - Profile(const QDir &directory, MOBase::IPluginGame *gamePlugin); + Profile(const QDir &directory, MOBase::IPluginGame const *gamePlugin); Profile(const Profile &reference); @@ -82,7 +82,7 @@ public: * @param name of the new profile * @param reference profile to copy from **/ - static Profile *createPtrFrom(const QString &name, const Profile &reference, MOBase::IPluginGame *gamePlugin); + static Profile *createPtrFrom(const QString &name, const Profile &reference, MOBase::IPluginGame const *gamePlugin); MOBase::DelayedFileWriter &modlistWriter() { return m_ModListWriter; } @@ -302,7 +302,7 @@ private: QDir m_Directory; - MOBase::IPluginGame *m_GamePlugin; + MOBase::IPluginGame const * const m_GamePlugin; mutable QByteArray m_LastModlistHash; std::vector m_ModStatus; diff --git a/src/profilesdialog.cpp b/src/profilesdialog.cpp index 58be5448..b21aee53 100644 --- a/src/profilesdialog.cpp +++ b/src/profilesdialog.cpp @@ -42,10 +42,11 @@ using namespace MOShared; Q_DECLARE_METATYPE(Profile::Ptr) -ProfilesDialog::ProfilesDialog(const QString &profileName, QWidget *parent) +ProfilesDialog::ProfilesDialog(const QString &profileName, MOBase::IPluginGame const *game, QWidget *parent) : TutorableDialog("Profiles", parent) , ui(new Ui::ProfilesDialog) , m_FailState(false) + , m_Game(game) { ui->setupUi(this); @@ -65,7 +66,6 @@ ProfilesDialog::ProfilesDialog(const QString &profileName, QWidget *parent) QCheckBox *invalidationBox = findChild("invalidationBox"); - IPluginGame *game = qApp->property("managed_game").value(); BSAInvalidation *invalidation = game->feature(); if (invalidation == nullptr) { @@ -104,7 +104,7 @@ QListWidgetItem *ProfilesDialog::addItem(const QString &name) QDir profileDir(name); QListWidgetItem *newItem = new QListWidgetItem(profileDir.dirName(), m_ProfilesList); try { - newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(new Profile(profileDir, qApp->property("managed_game").value())))); + newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(new Profile(profileDir, m_Game)))); m_FailState = false; } catch (const std::exception& e) { reportError(tr("failed to create profile: %1").arg(e.what())); @@ -117,7 +117,7 @@ void ProfilesDialog::createProfile(const QString &name, bool useDefaultSettings) try { QListWidget *profilesList = findChild("profilesList"); QListWidgetItem *newItem = new QListWidgetItem(name, profilesList); - newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(new Profile(name, qApp->property("managed_game").value(), useDefaultSettings)))); + newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(new Profile(name, m_Game, useDefaultSettings)))); profilesList->addItem(newItem); m_FailState = false; } catch (const std::exception&) { @@ -131,7 +131,7 @@ void ProfilesDialog::createProfile(const QString &name, const Profile &reference try { QListWidget *profilesList = findChild("profilesList"); QListWidgetItem *newItem = new QListWidgetItem(name, profilesList); - newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(Profile::createPtrFrom(name, reference, qApp->property("managed_game").value())))); + newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(Profile::createPtrFrom(name, reference, m_Game)))); profilesList->addItem(newItem); m_FailState = false; } catch (const std::exception&) { @@ -324,6 +324,6 @@ void ProfilesDialog::on_localSavesBox_stateChanged(int state) void ProfilesDialog::on_transferButton_clicked() { const Profile::Ptr currentProfile = m_ProfilesList->currentItem()->data(Qt::UserRole).value(); - TransferSavesDialog transferDialog(*currentProfile, qApp->property("managed_game").value(), this); + TransferSavesDialog transferDialog(*currentProfile, m_Game, this); transferDialog.exec(); } diff --git a/src/profilesdialog.h b/src/profilesdialog.h index 6dd0c1d4..26476883 100644 --- a/src/profilesdialog.h +++ b/src/profilesdialog.h @@ -50,7 +50,7 @@ public: * @param parent parent widget * @todo the game path could be retrieved from GameInfo just as easily **/ - explicit ProfilesDialog(const QString &profileName, QWidget *parent = 0); + explicit ProfilesDialog(const QString &profileName, MOBase::IPluginGame const *game, QWidget *parent = 0); ~ProfilesDialog(); /** @@ -93,7 +93,7 @@ private: Ui::ProfilesDialog *ui; QListWidget *m_ProfilesList; bool m_FailState; - + MOBase::IPluginGame const *m_Game; }; #endif // PROFILESDIALOG_H diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index f2160719..36e177ab 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -18,18 +18,21 @@ along with Mod Organizer. If not, see . */ #include "settingsdialog.h" + #include "ui_settingsdialog.h" #include "categoriesdialog.h" #include "helper.h" #include "noeditdelegate.h" +#include "iplugingame.h" #include +#include "settings.h" + #include #include #include #include #define WIN32_LEAN_AND_MEAN #include -#include "settings.h" using namespace MOBase; @@ -87,7 +90,11 @@ void SettingsDialog::on_categoriesBtn_clicked() void SettingsDialog::on_bsaDateBtn_clicked() { - Helper::backdateBSAs(qApp->property("dataPath").toString().toStdWString(), GameInfo::instance().getGameDirectory().append(L"\\data")); + IPluginGame *game = qApp->property("managed_game").value(); + QDir dir = game->dataDirectory(); + + Helper::backdateBSAs(qApp->property("dataPath").toString().toStdWString(), + dir.absolutePath().toStdWString()); } void SettingsDialog::on_browseDownloadDirBtn_clicked() diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index da6fb3dc..49b3133b 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -65,7 +65,7 @@ public: //**Currently only used in a nasty mess at initialisation time. virtual std::wstring getGameName() const = 0; - //**USED IN HOOKDLL + //**USED IN HOOKDLL and in initialisation virtual std::wstring getGameDirectory() const; // get a list of file extensions for additional files belonging to a save game diff --git a/src/transfersavesdialog.cpp b/src/transfersavesdialog.cpp index 73267f75..d47d2bb0 100644 --- a/src/transfersavesdialog.cpp +++ b/src/transfersavesdialog.cpp @@ -32,7 +32,7 @@ using namespace MOBase; using namespace MOShared; -TransferSavesDialog::TransferSavesDialog(const Profile &profile, IPluginGame *gamePlugin, QWidget *parent) +TransferSavesDialog::TransferSavesDialog(const Profile &profile, IPluginGame const *gamePlugin, QWidget *parent) : TutorableDialog("TransferSaves", parent) , ui(new Ui::TransferSavesDialog) , m_Profile(profile) diff --git a/src/transfersavesdialog.h b/src/transfersavesdialog.h index b9265b6a..d9ea5b29 100644 --- a/src/transfersavesdialog.h +++ b/src/transfersavesdialog.h @@ -35,7 +35,7 @@ class TransferSavesDialog : public MOBase::TutorableDialog Q_OBJECT public: - explicit TransferSavesDialog(const Profile &profile, MOBase::IPluginGame *gamePlugin, QWidget *parent = 0); + explicit TransferSavesDialog(const Profile &profile, MOBase::IPluginGame const *gamePlugin, QWidget *parent = 0); ~TransferSavesDialog(); private slots: @@ -76,7 +76,7 @@ private: Profile m_Profile; - MOBase::IPluginGame *m_GamePlugin; + MOBase::IPluginGame const *m_GamePlugin; std::vector m_GlobalSaves; std::vector m_LocalSaves; -- 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/organizercore.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 82e6c98043bd18f5329e8b6d0a6f99c4d28cc0a2 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Thu, 26 Nov 2015 07:39:35 +0000 Subject: Replace last occurrence of GameInfo::getNexusGameID and remove a whole load of gameinfo.h includes --- src/browserdialog.cpp | 6 ++---- src/categories.cpp | 4 ++-- src/directoryrefresher.cpp | 1 - src/executableslist.cpp | 8 +++++--- src/executableslist.h | 5 +++-- src/installationmanager.cpp | 7 +++++-- src/mainwindow.cpp | 2 ++ src/modinfo.cpp | 1 - src/modlist.cpp | 5 +++-- src/nexusinterface.cpp | 1 + src/nexusinterface.h | 1 - src/nxmaccessmanager.cpp | 15 +++++++++++++-- src/nxmaccessmanager.h | 7 ++++++- src/organizercore.cpp | 1 + src/organizerproxy.cpp | 1 - src/pluginlist.cpp | 1 - src/settingsdialog.cpp | 3 +-- src/shared/fallout3info.h | 1 - src/shared/falloutnvinfo.h | 1 - src/shared/gameinfo.h | 33 +++++++++++++-------------------- src/shared/oblivioninfo.h | 1 - src/shared/skyriminfo.h | 1 - src/spawn.cpp | 8 +++++--- src/syncoverwritedialog.cpp | 3 ++- src/transfersavesdialog.cpp | 5 ++++- src/transfersavesdialog.h | 6 ++---- 26 files changed, 70 insertions(+), 58 deletions(-) (limited to 'src/organizercore.cpp') diff --git a/src/browserdialog.cpp b/src/browserdialog.cpp index c382c112..bbdf95c5 100644 --- a/src/browserdialog.cpp +++ b/src/browserdialog.cpp @@ -18,18 +18,16 @@ along with Mod Organizer. If not, see . */ #include "browserdialog.h" + #include "ui_browserdialog.h" #include "browserview.h" - #include "messagedialog.h" #include "report.h" #include "persistentcookiejar.h" - #include "json.h" - #include -#include #include "settings.h" + #include #include #include diff --git a/src/categories.cpp b/src/categories.cpp index 400cc74b..59291a49 100644 --- a/src/categories.cpp +++ b/src/categories.cpp @@ -18,9 +18,10 @@ along with Mod Organizer. If not, see . */ #include "categories.h" + #include #include -#include + #include #include #include @@ -29,7 +30,6 @@ along with Mod Organizer. If not, see . using namespace MOBase; -using namespace MOShared; CategoryFactory* CategoryFactory::s_Instance = nullptr; diff --git a/src/directoryrefresher.cpp b/src/directoryrefresher.cpp index f4ad2a7d..4eac4103 100644 --- a/src/directoryrefresher.cpp +++ b/src/directoryrefresher.cpp @@ -23,7 +23,6 @@ along with Mod Organizer. If not, see . #include "utility.h" #include "report.h" #include "modinfo.h" -#include #include #include diff --git a/src/executableslist.cpp b/src/executableslist.cpp index 2182a425..a4511ade 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -18,16 +18,18 @@ along with Mod Organizer. If not, see . */ #include "executableslist.h" -#include + +#include "iplugingame.h" +#include "utility.h" + #include #include #include -#include "utility.h" + #include using namespace MOBase; -using namespace MOShared; ExecutablesList::ExecutablesList() diff --git a/src/executableslist.h b/src/executableslist.h index 833829c8..3d5ba0ed 100644 --- a/src/executableslist.h +++ b/src/executableslist.h @@ -20,13 +20,14 @@ along with Mod Organizer. If not, see . #ifndef EXECUTABLESLIST_H #define EXECUTABLESLIST_H +#include "executableinfo.h" #include + #include #include -#include -#include +namespace MOBase { class IPluginGame; } /*! * @brief Information about an executable diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index a6af1a7f..4b3722b8 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -18,6 +18,7 @@ along with Mod Organizer. If not, see . */ #include "installationmanager.h" + #include "utility.h" #include "report.h" #include "categories.h" @@ -32,9 +33,9 @@ along with Mod Organizer. If not, see . #include "modinfo.h" #include #include -#include #include #include + #include #include #include @@ -42,11 +43,13 @@ along with Mod Organizer. If not, see . #include #include #include -#include #include #include #include #include + +#include + #include #include diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2d90d5b8..3a2da562 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -68,6 +68,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include "gameinfo.h" #include #include @@ -113,6 +114,7 @@ along with Mod Organizer. If not, see . #include #include #include + #ifndef Q_MOC_RUN #include #include diff --git a/src/modinfo.cpp b/src/modinfo.cpp index df34c00f..ef195bea 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -29,7 +29,6 @@ along with Mod Organizer. If not, see . #include "messagedialog.h" #include "filenamestring.h" -#include #include #include #include diff --git a/src/modlist.cpp b/src/modlist.cpp index 197250a3..9d7f32c8 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -24,15 +24,14 @@ along with Mod Organizer. If not, see . #include "qtgroupingproxy.h" #include "viewmarkingscrollbar.h" #include "modlistsortproxy.h" -#include #include #include #include + #include #include #include #include -#include #include #include #include @@ -44,7 +43,9 @@ along with Mod Organizer. If not, see . #include #include #include + #include +#include #include diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index 078ca29d..8a7c88b6 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -555,6 +555,7 @@ void NexusInterface::requestTimeout() void NexusInterface::managedGameChanged(IPluginGame const *game) { m_Game = game; + m_AccessManager->managedGameChanged(game); } diff --git a/src/nexusinterface.h b/src/nexusinterface.h index 091b5446..807d0aec 100644 --- a/src/nexusinterface.h +++ b/src/nexusinterface.h @@ -21,7 +21,6 @@ along with Mod Organizer. If not, see . #define NEXUSINTERFACE_H #include -#include #include #include diff --git a/src/nxmaccessmanager.cpp b/src/nxmaccessmanager.cpp index 0763bb71..08572d50 100644 --- a/src/nxmaccessmanager.cpp +++ b/src/nxmaccessmanager.cpp @@ -18,6 +18,8 @@ along with Mod Organizer. If not, see . */ #include "nxmaccessmanager.h" + +#include "iplugingame.h" #include "nxmurl.h" #include "report.h" #include "utility.h" @@ -26,6 +28,7 @@ along with Mod Organizer. If not, see . #include "settings.h" #include #include + #include #include #include @@ -127,9 +130,13 @@ void NXMAccessManager::startLoginCheck() void NXMAccessManager::retrieveCredentials() { qDebug("retrieving credentials"); - QNetworkRequest request(ToQString(GameInfo::instance().getNexusPage()) + + //This may be overkill as + //www.nexusmods.com/Core/Libs/Flamework/Entities/User?GetCredentials + //seems to work fine. + QNetworkRequest request(m_Game->getNexusManagementURL() + QString("/Core/Libs/Flamework/Entities/User?GetCredentials&game_id=%1" - ).arg(GameInfo::instance().getNexusGameID())); + ).arg(m_Game->getNexusGameID())); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); request.setRawHeader("User-Agent", userAgent().toUtf8()); @@ -339,3 +346,7 @@ void NXMAccessManager::loginChecked() m_LoginReply = nullptr; } +void NXMAccessManager::managedGameChanged(MOBase::IPluginGame const *game) +{ + m_Game = game; +} diff --git a/src/nxmaccessmanager.h b/src/nxmaccessmanager.h index a03dbe36..2a016cad 100644 --- a/src/nxmaccessmanager.h +++ b/src/nxmaccessmanager.h @@ -27,6 +27,7 @@ along with Mod Organizer. If not, see . #include #include +namespace MOBase { class IPluginGame; } /** * @brief access manager extended to handle nxm links @@ -84,7 +85,9 @@ private slots: void loginError(QNetworkReply::NetworkError errorCode); void loginTimeout(); -public slots: +public: + //This would be a slot but the NexusInterface code calls this + void managedGameChanged(MOBase::IPluginGame const *game); protected: @@ -127,6 +130,8 @@ private: LOGIN_VALID } m_LoginState = LOGIN_NOT_CHECKED; + MOBase::IPluginGame const *m_Game; + }; #endif // NXMACCESSMANAGER_H diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 7473ec3e..66a3799a 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -162,6 +162,7 @@ OrganizerCore::OrganizerCore(const QSettings &initSettings) connect(NexusInterface::instance()->getAccessManager(), SIGNAL(loginSuccessful(bool)), this, SLOT(loginSuccessful(bool))); connect(NexusInterface::instance()->getAccessManager(), SIGNAL(loginFailed(QString)), this, SLOT(loginFailed(QString))); + //This seems awfully imperative connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame const *)), &m_Settings, SLOT(managedGameChanged(MOBase::IPluginGame const *))); connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame const *)), &m_DownloadManager, SLOT(managedGameChanged(MOBase::IPluginGame const *))); connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame const *)), &m_PluginList, SLOT(managedGameChanged(MOBase::IPluginGame const *))); diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index fdc60a27..ba07c154 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -1,6 +1,5 @@ #include "organizerproxy.h" -#include #include #include diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 48b27f05..7a609374 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -24,7 +24,6 @@ along with Mod Organizer. If not, see . #include "scopeguard.h" #include "modinfo.h" #include -#include #include #include #include diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 36e177ab..c7f15dc9 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -24,19 +24,18 @@ along with Mod Organizer. If not, see . #include "helper.h" #include "noeditdelegate.h" #include "iplugingame.h" -#include #include "settings.h" #include #include #include #include + #define WIN32_LEAN_AND_MEAN #include using namespace MOBase; -using namespace MOShared; SettingsDialog::SettingsDialog(QWidget *parent) diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h index b5585eaf..e6064825 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -50,7 +50,6 @@ public: virtual std::wstring getReferenceDataFile(); virtual std::wstring getNexusPage(bool nmmScheme = true); - virtual int getNexusGameID() { return 120; } virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath); diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h index 40e11720..aa187fb3 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -50,7 +50,6 @@ public: virtual std::wstring getReferenceDataFile(); virtual std::wstring getNexusPage(bool nmmScheme = true); - virtual int getNexusGameID() { return 130; } virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath); diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index 45069165..b6a4f142 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -47,29 +47,30 @@ public: TYPE_SKYRIM }; - enum LoadOrderMechanism { - TYPE_FILETIME, - TYPE_PLUGINSTXT - }; - public: virtual ~GameInfo() {} - //**USED ONLY IN HOOKDLL - virtual std::wstring getRegPath() = 0; - //**Used only in savegame which needs refactoring a lot. virtual GameInfo::Type getType() = 0; + //**Used only in savegame which needs refactoring a lot. + // get a list of file extensions for additional files belonging to a save game + virtual std::vector getSavegameAttachmentExtensions() = 0; + //**Currently only used in a nasty mess at initialisation time. virtual std::wstring getGameName() const = 0; //**USED IN HOOKDLL and in initialisation virtual std::wstring getGameDirectory() const; - // get a list of file extensions for additional files belonging to a save game - virtual std::vector getSavegameAttachmentExtensions() = 0; + //**USED IN HOOKDLL and initialisation + // initialise with the path to the mo directory (needs to be where hook.dll is stored). This + // needs to be called before the instance can be retrieved + static bool init(const std::wstring &moDirectory, const std::wstring &gamePath = L""); + + //**USED ONLY IN HOOKDLL + virtual std::wstring getRegPath() = 0; //**USED ONLY IN HOOKDLL // file name of this games ini file(s) @@ -78,20 +79,12 @@ public: //**USED ONLY IN HOOKDLL virtual std::wstring getReferenceDataFile() = 0; - virtual std::wstring getNexusPage(bool nmmScheme = true) = 0; - virtual int getNexusGameID() = 0; - //**USED ONLY IN HOOKDLL virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) = 0; -public: - - //**USED IN HOOKDLL - // initialise with the path to the mo directory (needs to be where hook.dll is stored). This - // needs to be called before the instance can be retrieved - static bool init(const std::wstring &moDirectory, const std::wstring &gamePath = L""); + virtual std::wstring getNexusPage(bool nmmScheme = true) = 0; - //**USED IN HOOKDLL + //**USED IN HOOKDLL and everywhere that uses GameInfo static GameInfo& instance(); protected: diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h index b6b3d867..f9045703 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -48,7 +48,6 @@ public: virtual std::wstring getReferenceDataFile(); virtual std::wstring getNexusPage(bool nmmScheme = true); - virtual int getNexusGameID() { return 101; } virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath); diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h index ee81ace3..47a35b3e 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -52,7 +52,6 @@ public: virtual std::wstring getNexusPage(bool nmmScheme = true); static int getNexusGameIDStatic() { return 110; } - virtual int getNexusGameID() { return getNexusGameIDStatic(); } virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath); diff --git a/src/spawn.cpp b/src/spawn.cpp index c79714bb..49e89a8b 100644 --- a/src/spawn.cpp +++ b/src/spawn.cpp @@ -18,18 +18,20 @@ along with Mod Organizer. If not, see . */ #include "spawn.h" + #include "report.h" #include "utility.h" -#include -#include #include #include -#include #include #include + #include #include +#include + +#include using namespace MOBase; using namespace MOShared; diff --git a/src/syncoverwritedialog.cpp b/src/syncoverwritedialog.cpp index 0e3e98d7..aeed0a55 100644 --- a/src/syncoverwritedialog.cpp +++ b/src/syncoverwritedialog.cpp @@ -18,10 +18,11 @@ along with Mod Organizer. If not, see . */ #include "syncoverwritedialog.h" + #include "ui_syncoverwritedialog.h" #include #include -#include + #include #include #include diff --git a/src/transfersavesdialog.cpp b/src/transfersavesdialog.cpp index d47d2bb0..4cb20944 100644 --- a/src/transfersavesdialog.cpp +++ b/src/transfersavesdialog.cpp @@ -18,12 +18,15 @@ along with Mod Organizer. If not, see . */ #include "transfersavesdialog.h" + #include "ui_transfersavesdialog.h" +#include "iplugingame.h" #include "savegamegamebyro.h" #include "utility.h" -#include + #include #include + #include #include diff --git a/src/transfersavesdialog.h b/src/transfersavesdialog.h index d9ea5b29..e2c556b4 100644 --- a/src/transfersavesdialog.h +++ b/src/transfersavesdialog.h @@ -22,11 +22,9 @@ along with Mod Organizer. If not, see . #include "tutorabledialog.h" #include "profile.h" -#include -namespace Ui { -class TransferSavesDialog; -} +namespace Ui { class TransferSavesDialog; } +namespace MOBase { class IPluginGame; } class SaveGame; -- cgit v1.3.1 From ca54ee2e9a8f1d49d81d5c3b66a860b9b16992d6 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Thu, 26 Nov 2015 21:22:47 +0000 Subject: Renamed getNexusName to getGameShortName as previously because it hopefully isn't too nexus related. --- src/downloadmanager.cpp | 2 +- src/mainwindow.cpp | 2 +- src/nexusinterface.cpp | 6 +++--- src/organizercore.cpp | 4 ++-- src/settings.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/organizercore.cpp') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 4a6769b1..e95a315f 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -450,7 +450,7 @@ void DownloadManager::addNXMDownload(const QString &url) { NXMUrl nxmInfo(url); - QString managedGame = m_ManagedGame->getNexusName(); + QString managedGame = m_ManagedGame->getGameShortName(); qDebug("add nxm download: %s", qPrintable(url)); if (nxmInfo.game().compare(managedGame, Qt::CaseInsensitive) != 0) { qDebug("download requested for wrong game (game: %s, url: %s)", qPrintable(managedGame), qPrintable(nxmInfo.game())); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index dd5a1b01..152baee7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4401,7 +4401,7 @@ void MainWindow::on_bossButton_clicked() parameters << "--unattended" << "--stdout" << "--noreport" - << "--game" << m_OrganizerCore.managedGame()->getNexusName() + << "--game" << m_OrganizerCore.managedGame()->getGameShortName() << "--gamePath" << QString("\"%1\"").arg(m_OrganizerCore.managedGame()->gameDirectory().absolutePath()) << "--out" << outPath; diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index 7a0b0a17..aadfdc1e 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -244,12 +244,12 @@ bool NexusInterface::isURLGameRelated(const QUrl &url) const { QString const name(url.toString()); return name.startsWith(getGameURL() + "/") || - name.startsWith("http://" + m_Game->getNexusName().toLower() + ".nexusmods.com/mods/"); + name.startsWith("http://" + m_Game->getGameShortName().toLower() + ".nexusmods.com/mods/"); } QString NexusInterface::getGameURL() const { - return "http://www.nexusmods.com/" + m_Game->getNexusName().toLower(); + return "http://www.nexusmods.com/" + m_Game->getGameShortName().toLower(); } QString NexusInterface::getModURL(int modID) const @@ -576,7 +576,7 @@ void NexusInterface::managedGameChanged(IPluginGame const *game) namespace { QString get_management_url(MOBase::IPluginGame const *game) { - return "http://nmm.nexusmods.com/" + game->getNexusName().toLower(); + return "http://nmm.nexusmods.com/" + game->getGameShortName().toLower(); } } diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 66a3799a..042a9f1e 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -401,8 +401,8 @@ void OrganizerCore::connectPlugins(PluginContainer *container) } //Do this the hard way for (const IPluginGame * const game : container->plugins()) { - QString n = game->getNexusName(); - if (game->getNexusName() == "Skyrim") { + QString n = game->getGameShortName(); + if (game->getGameShortName() == "Skyrim") { m_Updater.setNexusDownload(game); break; } diff --git a/src/settings.cpp b/src/settings.cpp index 95462c82..e175b210 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -108,7 +108,7 @@ void Settings::registerAsNXMHandler(bool force) std::wstring nxmPath = ToWString(QCoreApplication::applicationDirPath() + "/nxmhandler.exe"); std::wstring executable = ToWString(QCoreApplication::applicationFilePath()); std::wstring mode = force ? L"forcereg" : L"reg"; - std::wstring parameters = mode + L" " + m_GamePlugin->getNexusName().toStdWString() + L" \"" + executable + L"\""; + std::wstring parameters = mode + L" " + m_GamePlugin->getGameShortName().toStdWString() + L" \"" + executable + L"\""; HINSTANCE res = ::ShellExecuteW(nullptr, L"open", nxmPath.c_str(), parameters.c_str(), nullptr, SW_SHOWNORMAL); if ((int)res <= 32) { QMessageBox::critical(nullptr, tr("Failed"), -- cgit v1.3.1 From 9e2bcffc32157b99a2d7364b869a4423ba827a32 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sat, 28 Nov 2015 14:53:32 +0000 Subject: Reworked startup considerably so now no longer dependant on GameInfo Did some const correctness to the "managed_game" property as you shouldn't really be altering the plugin details whilst MO is running --- src/directoryrefresher.cpp | 2 +- src/loadmechanism.cpp | 14 ++-- src/main.cpp | 204 ++++++++++++++++++++++++++++++--------------- src/modinfo.cpp | 6 +- src/organizercore.cpp | 18 ++-- src/organizercore.h | 5 +- src/settingsdialog.cpp | 2 +- src/shared/fallout3info.h | 2 - src/shared/falloutnvinfo.h | 2 - src/shared/gameinfo.h | 7 +- src/shared/oblivioninfo.h | 2 - src/shared/skyriminfo.h | 2 - 12 files changed, 156 insertions(+), 110 deletions(-) (limited to 'src/organizercore.cpp') diff --git a/src/directoryrefresher.cpp b/src/directoryrefresher.cpp index 4eac4103..f50a717e 100644 --- a/src/directoryrefresher.cpp +++ b/src/directoryrefresher.cpp @@ -144,7 +144,7 @@ void DirectoryRefresher::refresh() m_DirectoryStructure = new DirectoryEntry(L"data", nullptr, 0); - IPluginGame *game = qApp->property("managed_game").value(); + IPluginGame const *game = qApp->property("managed_game").value(); std::wstring dataDirectory = QDir::toNativeSeparators(game->dataDirectory().absolutePath()).toStdWString(); m_DirectoryStructure->addFromOrigin(L"data", dataDirectory, 0); diff --git a/src/loadmechanism.cpp b/src/loadmechanism.cpp index 0d95c51c..521473b0 100644 --- a/src/loadmechanism.cpp +++ b/src/loadmechanism.cpp @@ -65,7 +65,7 @@ void LoadMechanism::removeHintFile(QDir &targetDirectory) bool LoadMechanism::isDirectLoadingSupported() { //FIXME: Seriously? isn't there a 'do i need steam' thing? - IPluginGame *game = qApp->property("managed_game").value(); + IPluginGame const *game = qApp->property("managed_game").value(); if (game->gameName().compare("oblivion", Qt::CaseInsensitive) == 0) { // oblivion can be loaded directly if it's not the steam variant return !game->gameDirectory().exists("steam_api.dll"); @@ -77,7 +77,7 @@ bool LoadMechanism::isDirectLoadingSupported() bool LoadMechanism::isScriptExtenderSupported() { - IPluginGame *game = qApp->property("managed_game").value(); + IPluginGame const *game = qApp->property("managed_game").value(); ScriptExtender *extender = game->feature(); // test if there even is an extender for the managed game and if so whether it's installed @@ -93,7 +93,7 @@ bool LoadMechanism::isProxyDLLSupported() // plus: the proxy dll hasn't been working for at least the whole 1.12.x versions of MO and // noone reported it so why maintain an unused feature? return false; -/* IPluginGame *game = qApp->property("managed_game").value(); +/* IPluginGame const *game = qApp->property("managed_game").value(); return game->gameDirectory().exists(QString::fromStdWString(AppConfig::proxyDLLTarget()));*/ } @@ -125,7 +125,7 @@ bool LoadMechanism::hashIdentical(const QString &fileNameLHS, const QString &fil void LoadMechanism::deactivateScriptExtender() { try { - IPluginGame *game = qApp->property("managed_game").value(); + IPluginGame const *game = qApp->property("managed_game").value(); ScriptExtender *extender = game->feature(); if (extender == nullptr) { throw MyException(QObject::tr("game doesn't support a script extender")); @@ -151,7 +151,7 @@ void LoadMechanism::deactivateScriptExtender() void LoadMechanism::deactivateProxyDLL() { try { - IPluginGame *game = qApp->property("managed_game").value(); + IPluginGame const *game = qApp->property("managed_game").value(); QString targetPath = game->gameDirectory().absoluteFilePath(QString::fromStdWString(AppConfig::proxyDLLTarget())); @@ -180,7 +180,7 @@ void LoadMechanism::deactivateProxyDLL() void LoadMechanism::activateScriptExtender() { try { - IPluginGame *game = qApp->property("managed_game").value(); + IPluginGame const *game = qApp->property("managed_game").value(); ScriptExtender *extender = game->feature(); if (extender == nullptr) { throw MyException(QObject::tr("game doesn't support a script extender")); @@ -220,7 +220,7 @@ void LoadMechanism::activateScriptExtender() void LoadMechanism::activateProxyDLL() { try { - IPluginGame *game = qApp->property("managed_game").value(); + IPluginGame const *game = qApp->property("managed_game").value(); QString targetPath = game->gameDirectory().absoluteFilePath(QString::fromStdWString(AppConfig::proxyDLLTarget())); diff --git a/src/main.cpp b/src/main.cpp index 72a63dc6..78145a74 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -330,6 +330,122 @@ QString determineProfile(QStringList &arguments, const QSettings &settings) return selectedProfileName; } +MOBase::IPluginGame *selectGame(QSettings &settings, QDir const &gamePath, MOBase::IPluginGame *game) +{ + settings.setValue("gameName", game->gameName()); + if (gamePath == game->gameDirectory()) { + settings.remove("gamePath"); + } else { + QString gameDir = gamePath.absolutePath(); + game->setGamePath(gameDir); + settings.setValue("gamePath", QDir::toNativeSeparators(gameDir).toUtf8().constData()); + } + return game; //Woot +} + + +MOBase::IPluginGame *determineCurrentGame(QString const &moPath, QSettings &settings, PluginContainer const &plugins) +{ + //Determine what game we are running where. Be very paranoid in case the + //user has done something odd. + //If the game name has been set up, use that. + QString gameName = settings.value("gameName", "").toString(); + if (!gameName.isEmpty()) { + MOBase::IPluginGame *game = plugins.managedGame(gameName); + if (game == nullptr) { + reportError(QObject::tr("Plugin to handle %1 no longer installed").arg(gameName)); + return nullptr; + } + QString gamePath = QString::fromUtf8(settings.value("gamePath", "").toByteArray()); + if (gamePath == "") { + gamePath = game->gameDirectory().absolutePath(); + } + QDir gameDir(gamePath); + if (game->looksValid(gameDir)) { + return selectGame(settings, gameDir, game); + } + } + + //gameName wasn't set, or otherwise can't be found. Try looking through all + //the plugins using the gamePath + QString gamePath = QString::fromUtf8(settings.value("gamePath", "").toByteArray()); + if (!gamePath.isEmpty()) { + QDir gameDir(gamePath); + //Look to see if one of the installed games binary file exists in the current + //game directory. + for (IPluginGame * const game : plugins.plugins()) { + if (game->looksValid(gameDir)) { + return selectGame(settings, gameDir, game); + } + } + } + + //OK, we are in a new setup or existing info is useless. + //See if MO has been installed inside a game directory + for (IPluginGame * const game : plugins.plugins()) { + if (game->isInstalled() && moPath.startsWith(game->gameDirectory().absolutePath())) { + //Found it. + return selectGame(settings, game->gameDirectory(), game); + } + } + + //Try walking up the directory tree to see if MO has been installed inside a game + { + QDir gameDir(moPath); + do { + //Look to see if one of the installed games binary file exists in the current + //directory. + for (IPluginGame * const game : plugins.plugins()) { + if (game->looksValid(gameDir)) { + return selectGame(settings, gameDir, game); + } + } + //OK, chop off the last directory and try again + } while (gameDir.cdUp()); + } + + //Then try a selection dialogue. + if (!gamePath.isEmpty() || !gameName.isEmpty()) { + reportError(QObject::tr("Could not use configuration settings for game \"%1\", path \"%2\"."). + arg(gameName).arg(gamePath)); + } + + SelectionDialog selection(QObject::tr("Please select the game to manage"), nullptr, QSize(32, 32)); + + for (IPluginGame *game : plugins.plugins()) { + if (game->isInstalled()) { + QString path = game->gameDirectory().absolutePath(); + selection.addChoice(game->gameIcon(), game->gameName(), path, QVariant::fromValue(game)); + } + } + + selection.addChoice(QString("Browse..."), QString(), QVariant::fromValue(static_cast(nullptr))); + + while (selection.exec() != QDialog::Rejected) { + IPluginGame * game = selection.getChoiceData().value(); + if (game != nullptr) { + return selectGame(settings, game->gameDirectory(), game); + } + + gamePath = QFileDialog::getExistingDirectory( + nullptr, QObject::tr("Please select the game to manage"), QString(), + QFileDialog::ShowDirsOnly); + + if (!gamePath.isEmpty()) { + QDir gameDir(gamePath); + for (IPluginGame * const game : plugins.plugins()) { + if (game->looksValid(gameDir)) { + return selectGame(settings, gameDir, game); + } + } + reportError(QObject::tr("No game identified in \"%1\". The directory is required to contain " + "the game binary and its launcher.").arg(gamePath)); + } + } + + return nullptr; +} + int main(int argc, char *argv[]) { MOApplication application(argc, argv); @@ -443,86 +559,36 @@ int main(int argc, char *argv[]) PluginContainer pluginContainer(&organizer); pluginContainer.loadPlugins(); - QString gamePath = QString::fromUtf8(settings.value("gamePath", "").toByteArray()); - bool done = false; - while (!done) { - 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)); - } - SelectionDialog selection(QObject::tr("Please select the game to manage"), nullptr, QSize(32, 32)); - - for (const IPluginGame * const game : pluginContainer.plugins()) { - if (game->isInstalled()) { - QString path = game->gameDirectory().absolutePath(); - selection.addChoice(game->gameIcon(), game->gameName(), path, path); - } - } - - selection.addChoice(QString("Browse..."), QString(), QString()); - - if (selection.exec() == QDialog::Rejected) { - gamePath = ""; - done = true; - } else { - gamePath = QDir::cleanPath(selection.getChoiceData().toString()); - if (gamePath.isEmpty()) { - gamePath = QFileDialog::getExistingDirectory( - nullptr, QObject::tr("Please select the game to manage"), QString(), - QFileDialog::ShowDirsOnly); - qDebug() << "manually selected path " << gamePath; - } - } - } else { - done = true; - gamePath = ToQString(GameInfo::instance().getGameDirectory()); - } - } - - if (gamePath.isEmpty()) { - // game not found and user canceled - return -1; - } else if (gamePath.length() != 0) { - // user selected a folder and game was initialised with it - qDebug("game path: %s", qPrintable(gamePath)); - settings.setValue("gamePath", gamePath.toUtf8().constData()); + MOBase::IPluginGame *game = determineCurrentGame(application.applicationDirPath(), settings, pluginContainer); + if (game == nullptr) { + return 1; } - organizer.setManagedGame(ToQString(GameInfo::instance().getGameName()), gamePath); + organizer.setManagedGame(game); organizer.createDefaultProfile(); - if (pluginContainer.managedGame(ToQString(GameInfo::instance().getGameName())) == nullptr) { - reportError(QObject::tr("Plugin to handle %1 not installed").arg(ToQString(GameInfo::instance().getGameName()))); - return 1; - } - - //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()); - } + //See the pragma - we apparently don't use this so not sure why we check it + 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?") - qDebug("managing game at %s", qPrintable(QDir::toNativeSeparators(gamePath))); + qDebug("managing game at %s", qPrintable(QDir::toNativeSeparators(game->gameDirectory().absolutePath()))); organizer.updateExecutablesList(settings); diff --git a/src/modinfo.cpp b/src/modinfo.cpp index ef195bea..03ab9a95 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -290,7 +290,7 @@ int ModInfo::checkAllForUpdate(QObject *receiver) std::vector modIDs; //I ought to store this, it's used elsewhere - IPluginGame *game = qApp->property("managed_game").value(); + IPluginGame const *game = qApp->property("managed_game").value(); modIDs.push_back(game->getNexusModOrganizerID()); @@ -935,7 +935,7 @@ std::vector ModInfoRegular::getContents() const m_CachedContent.push_back(CONTENT_BSA); } - ScriptExtender *extender = qApp->property("managed_game").value()->feature(); + ScriptExtender *extender = qApp->property("managed_game").value()->feature(); if (extender != nullptr) { QString sePluginPath = extender->name() + "/plugins"; @@ -1137,7 +1137,7 @@ QDateTime ModInfoForeign::creationTime() const QString ModInfoForeign::absolutePath() const { //I ought to store this, it's used elsewhere - IPluginGame *game = qApp->property("managed_game").value(); + IPluginGame const *game = qApp->property("managed_game").value(); return game->dataDirectory().absolutePath(); } diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 042a9f1e..06a6dba4 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -422,15 +422,12 @@ void OrganizerCore::disconnectPlugins() m_PluginContainer = nullptr; } -void OrganizerCore::setManagedGame(const QString &gameName, const QString &gamePath) +void OrganizerCore::setManagedGame(MOBase::IPluginGame const *game) { - m_GameName = gameName; - if (m_PluginContainer != nullptr) { - m_GamePlugin = m_PluginContainer->managedGame(m_GameName); - m_GamePlugin->setGamePath(gamePath); - qApp->setProperty("managed_game", QVariant::fromValue(m_GamePlugin)); - emit managedGameChanged(m_GamePlugin); - } + m_GameName = game->gameName(); + m_GamePlugin = game; + qApp->setProperty("managed_game", QVariant::fromValue(m_GamePlugin)); + emit managedGameChanged(m_GamePlugin); } Settings &OrganizerCore::settings() @@ -1327,11 +1324,6 @@ IPluginGame const *OrganizerCore::managedGame() const return m_GamePlugin; } -IPluginGame *OrganizerCore::managedGameForUpdate() const -{ - return m_GamePlugin; -} - std::vector OrganizerCore::enabledArchives() { std::vector result; diff --git a/src/organizercore.h b/src/organizercore.h index c206e5e7..5cfbaca4 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -73,7 +73,7 @@ public: void connectPlugins(PluginContainer *container); void disconnectPlugins(); - void setManagedGame(const QString &gameName, const QString &gamePath); + void setManagedGame(const MOBase::IPluginGame *game); void updateExecutablesList(QSettings &settings); @@ -100,7 +100,6 @@ public: PluginListSortProxy *createPluginListProxyModel(); MOBase::IPluginGame const *managedGame() const; - MOBase::IPluginGame *managedGameForUpdate() const; bool isArchivesInit() const { return m_ArchivesInit; } @@ -234,7 +233,7 @@ private: IUserInterface *m_UserInterface; PluginContainer *m_PluginContainer; QString m_GameName; - MOBase::IPluginGame *m_GamePlugin; + MOBase::IPluginGame const *m_GamePlugin; Profile *m_CurrentProfile; diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index c7f15dc9..8bc1dbc6 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -89,7 +89,7 @@ void SettingsDialog::on_categoriesBtn_clicked() void SettingsDialog::on_bsaDateBtn_clicked() { - IPluginGame *game = qApp->property("managed_game").value(); + IPluginGame const *game = qApp->property("managed_game").value(); QDir dir = game->dataDirectory(); Helper::backdateBSAs(qApp->property("dataPath").toString().toStdWString(), diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h index ed525588..69eb9c45 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -40,8 +40,6 @@ public: virtual GameInfo::Type getType() { return TYPE_FALLOUT3; } - virtual std::wstring getGameName() const { return L"Fallout 3"; } - virtual std::vector getSavegameAttachmentExtensions(); // file name of this games ini (no path) diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h index ee67ac17..a7ee089e 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -40,8 +40,6 @@ public: virtual GameInfo::Type getType() { return TYPE_FALLOUTNV; } - virtual std::wstring getGameName() const { return L"New Vegas"; } - 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 de3af8b4..55161952 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -58,13 +58,10 @@ public: // get a list of file extensions for additional files belonging to a save game virtual std::vector getSavegameAttachmentExtensions() = 0; - //**Currently only used in a nasty mess at initialisation time. - virtual std::wstring getGameName() const = 0; - - //**USED IN HOOKDLL and in initialisation + //**USED IN HOOKDLL virtual std::wstring getGameDirectory() const; - //**USED IN HOOKDLL and initialisation + //**USED IN HOOKDLL // initialise with the path to the mo directory (needs to be where hook.dll is stored). This // needs to be called before the instance can be retrieved static bool init(const std::wstring &moDirectory, const std::wstring &gamePath = L""); diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h index 00048930..e0a861bf 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -38,8 +38,6 @@ public: virtual GameInfo::Type getType() { return TYPE_OBLIVION; } - virtual std::wstring getGameName() const { return L"Oblivion"; } - virtual std::vector getSavegameAttachmentExtensions(); // file name of this games ini (no path) diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h index afba1974..17b542ab 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -40,8 +40,6 @@ public: virtual GameInfo::Type getType() { return TYPE_SKYRIM; } - virtual std::wstring getGameName() const { return L"Skyrim"; } - virtual std::vector getSavegameAttachmentExtensions(); // file name of this games ini (no path) -- cgit v1.3.1