From 235d893eb845c3c8c0edb9dcdb703ce3ec31bdb5 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sat, 5 Dec 2015 19:13:05 +0000 Subject: Gets rid of last vestiges of GameInfo apart from startup and hookdll Working on sorting out savegame stuff --- src/mainwindow.cpp | 28 +++++++++++---- src/modinfoforeign.cpp | 8 +++-- src/savegame.cpp | 81 ++++++++++++-------------------------------- src/savegame.h | 20 +++-------- src/savegamegamebryo.cpp | 2 +- src/shared/fallout3info.cpp | 5 --- src/shared/fallout3info.h | 2 -- src/shared/falloutnvinfo.cpp | 5 --- src/shared/falloutnvinfo.h | 2 -- src/shared/gameinfo.cpp | 13 ------- src/shared/gameinfo.h | 20 ++++------- src/shared/oblivioninfo.cpp | 9 ----- src/shared/oblivioninfo.h | 2 -- src/shared/skyriminfo.cpp | 5 --- src/shared/skyriminfo.h | 2 -- 15 files changed, 61 insertions(+), 143 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7dd5d71b..aa45a0bd 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -835,15 +835,29 @@ SaveGameGamebryo *MainWindow::getSaveGame(const QString &name__) IPluginGame const *game = m_OrganizerCore.managedGame(); QString name(name__); + static int count = 0; //fudge with me -// game = m_PluginContainer.managedGame("Fallout 3"); -// name = "C:\\Users\\Dad\\Downloads\\Games\\Both good and evil saves -10416\\Save 106 - New Start Good, Vault 101 Entrance, 00.33.34.fos"; + switch (count) + { + case 0: + game = m_PluginContainer.managedGame("Fallout 3"); + name = "C:\\Users\\Dad\\Downloads\\Games\\Both good and evil saves -10416\\Save 106 - New Start Good, Vault 101 Entrance, 00.33.34.fos"; + break; + + case 1: + game = m_PluginContainer.managedGame("New Vegas"); + name = "C:\\Users\\Dad\\Downloads\\Games\\Crossroads - Clean Save-44883-1-0\\Crossroads.fos"; + break; -// game = m_PluginContainer.managedGame("New Vegas"); -// name = "C:\\Users\\Dad\\Downloads\\Games\\Crossroads - Clean Save-44883-1-0\\Crossroads.fos"; + case 2: + game = m_PluginContainer.managedGame("Oblivion"); + name = "C:\\Users\\Dad\\Saved Games\\Oblivion\\Saves\\Save 1537 - Hilary - Xirethard, Level 45, Playing Time 458.48.17.ess"; + break; -// game = m_PluginContainer.managedGame("Oblivion"); -// name = "C:\\Users\\Dad\\Saved Games\\Oblivion\\Saves\\Save 1537 - Hilary - Xirethard, Level 45, Playing Time 458.48.17.ess"; + case 3: + count = -1; + } + ++count; return new SaveGameGamebryo(this, name, game); } @@ -3210,7 +3224,7 @@ void MainWindow::deleteSavegame_clicked() foreach (const QModelIndex &idx, selectedIndexes) { QString name = idx.data().toString(); - SaveGame *save = new SaveGame(this, idx.data(Qt::UserRole).toString()); + SaveGame *save = new SaveGame(this, idx.data(Qt::UserRole).toString(), m_OrganizerCore.managedGame()); if (count < 10) { savesMsgLabel += "
  • " + QFileInfo(name).completeBaseName() + "
  • "; diff --git a/src/modinfoforeign.cpp b/src/modinfoforeign.cpp index c0e769c9..4dbe034b 100644 --- a/src/modinfoforeign.cpp +++ b/src/modinfoforeign.cpp @@ -1,8 +1,10 @@ #include "modinfoforeign.h" -#include "gameinfo.h" +#include "iplugingame.h" #include "utility.h" +#include + using namespace MOBase; using namespace MOShared; @@ -18,7 +20,9 @@ QDateTime ModInfoForeign::creationTime() const QString ModInfoForeign::absolutePath() const { - return QDir::fromNativeSeparators(ToQString(GameInfo::instance().getGameDirectory())) + "/data"; + //I ought to store this, it's used elsewhere + IPluginGame const *game = qApp->property("managed_game").value(); + return game->dataDirectory().absolutePath(); } std::vector ModInfoForeign::getFlags() const diff --git a/src/savegame.cpp b/src/savegame.cpp index 1cdabb2d..2b125575 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -18,50 +18,28 @@ along with Mod Organizer. If not, see . */ #include "savegame.h" -#include -#include -#include -#include -#include -#include -#include -#include "gameinfo.h" - - -SaveGame::SaveGame(QObject *parent) - : QObject(parent), m_FileName(), m_PCName(), m_PCLevel(0), m_PCLocation(), m_SaveNumber(0), m_Screenshot() -{ -} +#include "iplugingame.h" +#include "scriptextender.h" +#include "utility.h" -SaveGame::SaveGame(QObject *parent, const QString &filename) - : QObject(parent), m_FileName(filename), m_PCName(), m_PCLevel(0), m_PCLocation(), m_SaveNumber(0), m_Screenshot() -{ -} - +#include +#include +#include +#include -SaveGame::SaveGame(const SaveGame& reference) - : m_FileName(reference.m_FileName), m_PCName(reference.m_PCName), m_PCLevel(reference.m_PCLevel), - m_PCLocation(reference.m_PCLocation), m_SaveNumber(reference.m_SaveNumber), - m_Screenshot(reference.m_Screenshot) -{ -} +#include +#include +using namespace MOBase; -SaveGame& SaveGame::operator=(const SaveGame &reference) +SaveGame::SaveGame(QObject *parent, const QString &filename, const MOBase::IPluginGame *game) + : QObject(parent) + , m_FileName(filename) + , m_Game(game) { - if (&reference != this) { - m_FileName = reference.m_FileName; - m_PCName = reference.m_PCName; - m_PCLevel = reference.m_PCLevel; - m_PCLocation = reference.m_PCLocation; - m_SaveNumber = reference.m_SaveNumber; - m_Screenshot = reference.m_Screenshot; - } - return *this; } - SaveGame::~SaveGame() { } @@ -69,11 +47,14 @@ SaveGame::~SaveGame() QStringList SaveGame::attachedFiles() const { QStringList result; - foreach (const std::wstring &ext, MOShared::GameInfo::instance().getSavegameAttachmentExtensions()) { - QFileInfo fi(fileName()); - fi.setFile(fi.canonicalPath() + "/" + fi.completeBaseName() + "." + MOBase::ToQString(ext)); - if (fi.exists()) { - result.append(fi.filePath()); + ScriptExtender const *extender = m_Game->feature(); + if (extender != nullptr) { + for (QString const &ext : extender->saveGameAttachmentExtensions()) { + QFileInfo fi(fileName()); + fi.setFile(fi.canonicalPath() + "/" + fi.completeBaseName() + "." + ext); + if (fi.exists()) { + result.append(fi.filePath()); + } } } @@ -86,21 +67,3 @@ QStringList SaveGame::saveFiles() const result.append(fileName()); return result; } - - -void SaveGame::setCreationTime(const QString &fileName) -{ - QFileInfo creationTime(fileName); - QDateTime modified = creationTime.lastModified(); - memset(&m_CreationTime, 0, sizeof(SYSTEMTIME)); - - m_CreationTime.wDay = static_cast(modified.date().day()); - m_CreationTime.wDayOfWeek = static_cast(modified.date().dayOfWeek()); - m_CreationTime.wMonth = static_cast(modified.date().month()); - m_CreationTime.wYear =static_cast( modified.date().year()); - - m_CreationTime.wHour = static_cast(modified.time().hour()); - m_CreationTime.wMinute = static_cast(modified.time().minute()); - m_CreationTime.wSecond = static_cast(modified.time().second()); - m_CreationTime.wMilliseconds = static_cast(modified.time().msec()); -} diff --git a/src/savegame.h b/src/savegame.h index 1fd2f7ab..d1bf4691 100644 --- a/src/savegame.h +++ b/src/savegame.h @@ -31,6 +31,7 @@ along with Mod Organizer. If not, see . #define WIN32_LEAN_AND_MEAN #include +namespace MOBase { class IPluginGame; } /** * @brief represents a single save game @@ -41,23 +42,14 @@ Q_OBJECT public: - /** - * @brief construct an empty object - **/ - SaveGame(QObject *parent = 0); - /** * @brief construct a save game and immediately read out information from the file * * @param filename absolute path of the save game file **/ - SaveGame(QObject *parent, const QString &filename); - - SaveGame(const SaveGame& reference); - - SaveGame& operator=(const SaveGame &reference); + SaveGame(QObject *parent, const QString &filename, MOBase::IPluginGame const *game); - ~SaveGame(); + virtual ~SaveGame(); /** * @brief read out information from a savegame @@ -111,10 +103,6 @@ public: **/ const QImage &screenshot() const { return m_Screenshot; } -private: - - void setCreationTime(const QString &fileName); - protected: QString m_FileName; @@ -125,6 +113,8 @@ protected: SYSTEMTIME m_CreationTime; QImage m_Screenshot; +private: + MOBase::IPluginGame const * const m_Game; }; diff --git a/src/savegamegamebryo.cpp b/src/savegamegamebryo.cpp index 457cbdf2..68ed30af 100644 --- a/src/savegamegamebryo.cpp +++ b/src/savegamegamebryo.cpp @@ -31,7 +31,7 @@ using namespace MOBase; SaveGameGamebryo::SaveGameGamebryo(QObject *parent, const QString &fileName, IPluginGame const *game) - : SaveGame(parent, fileName) + : SaveGame(parent, fileName, game) , m_Plugins() { SaveGameInfo const *info = game->feature(); diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp index 008a046c..797d68ec 100644 --- a/src/shared/fallout3info.cpp +++ b/src/shared/fallout3info.cpp @@ -63,11 +63,6 @@ std::wstring Fallout3Info::getRegPathStatic() } -std::vector Fallout3Info::getSavegameAttachmentExtensions() const -{ - return std::vector(); -} - std::vector Fallout3Info::getIniFileNames() const { return boost::assign::list_of(L"fallout.ini")(L"falloutprefs.ini"); diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h index 21356924..5cf98e3b 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -37,8 +37,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() const { return getRegPathStatic(); } - virtual std::vector getSavegameAttachmentExtensions() const; - // file name of this games ini (no path) virtual std::vector getIniFileNames() const; diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp index 80d2fba5..6347224d 100644 --- a/src/shared/falloutnvinfo.cpp +++ b/src/shared/falloutnvinfo.cpp @@ -63,11 +63,6 @@ std::wstring FalloutNVInfo::getRegPathStatic() } } -std::vector FalloutNVInfo::getSavegameAttachmentExtensions() const -{ - return std::vector(); -} - std::vector FalloutNVInfo::getIniFileNames() const { return boost::assign::list_of(L"fallout.ini")(L"falloutprefs.ini"); diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h index 4bffff3f..04c13c7d 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -38,8 +38,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() const { return getRegPathStatic(); } - virtual std::vector getSavegameAttachmentExtensions() const; - // file name of this games ini (no path) virtual std::vector getIniFileNames() const; diff --git a/src/shared/gameinfo.cpp b/src/shared/gameinfo.cpp index e77b9d17..5c13a520 100644 --- a/src/shared/gameinfo.cpp +++ b/src/shared/gameinfo.cpp @@ -134,19 +134,6 @@ std::wstring GameInfo::getGameDirectory() const return m_GameDirectory; } -std::wstring GameInfo::getLocalAppFolder() const -{ - wchar_t localAppFolder[MAX_PATH]; - memset(localAppFolder, '\0', MAX_PATH * sizeof(wchar_t)); - - if (::SHGetFolderPathW(nullptr, CSIDL_LOCAL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, localAppFolder) == S_OK) { - return localAppFolder; - } else { - // fallback: try the registry - return getSpecialPath(L"Local AppData"); - } -} - std::wstring GameInfo::getSpecialPath(LPCWSTR name) const { HKEY key; diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index a5c615cf..7bc86d3a 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -42,20 +42,16 @@ public: virtual ~GameInfo() {} - //**USED IN HOOKDLL and savegame code - static GameInfo& instance(); - - //**Used only in savegame which needs refactoring a lot. - // get a list of file extensions for additional files belonging to a save game - virtual std::vector getSavegameAttachmentExtensions() const = 0; + //**USED IN HOOKDLL and at startup to set up for hookdll to work + // initialise with the path to the mo directory (needs to be where hook.dll is stored). This + // needs to be called before the instance can be retrieved + static bool init(const std::wstring &moDirectory, const std::wstring &gamePath = L""); //**USED ONLY IN HOOKDLL - virtual std::wstring getGameDirectory() const; + static GameInfo& instance(); //**USED ONLY IN HOOKDLL - // initialise with the path to the mo directory (needs to be where hook.dll is stored). This - // needs to be called before the instance can be retrieved - static bool init(const std::wstring &moDirectory, const std::wstring &gamePath = L""); + virtual std::wstring getGameDirectory() const; //**USED ONLY IN HOOKDLL virtual std::wstring getRegPath() const = 0; @@ -74,12 +70,8 @@ protected: GameInfo(const std::wstring &gameDirectory); - std::wstring getLocalAppFolder() const; - const std::wstring &getMyGamesDirectory() const { return m_MyGamesDirectory; } void identifyMyGamesDirectory(const std::wstring &file); - bool isValidModURL(int modID, const std::wstring &url, const std::wstring &alt) const; - private: static bool identifyGame(const std::wstring &searchPath); diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp index 8f1f1843..b50f1daa 100644 --- a/src/shared/oblivioninfo.cpp +++ b/src/shared/oblivioninfo.cpp @@ -63,15 +63,6 @@ std::wstring OblivionInfo::getRegPathStatic() } } - - - -std::vector OblivionInfo::getSavegameAttachmentExtensions() const -{ - return boost::assign::list_of(L"obse"); -} - - std::vector OblivionInfo::getIniFileNames() const { return boost::assign::list_of(L"oblivion.ini")(L"oblivionprefs.ini"); diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h index fc949f4b..bf0b2707 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -36,8 +36,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() const { return getRegPathStatic(); } - virtual std::vector getSavegameAttachmentExtensions() const; - // file name of this games ini (no path) virtual std::vector getIniFileNames() const; diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp index d255e60f..9662e66d 100644 --- a/src/shared/skyriminfo.cpp +++ b/src/shared/skyriminfo.cpp @@ -73,11 +73,6 @@ std::wstring SkyrimInfo::getRegPathStatic() } } -std::vector SkyrimInfo::getSavegameAttachmentExtensions() const -{ - return boost::assign::list_of(L"skse"); -} - std::vector SkyrimInfo::getIniFileNames() const { return boost::assign::list_of(L"skyrim.ini")(L"skyrimprefs.ini"); diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h index ac979d20..bd329403 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -38,8 +38,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() const { return getRegPathStatic(); } - virtual std::vector getSavegameAttachmentExtensions() const; - // file name of this games ini (no path) virtual std::vector getIniFileNames() const; -- cgit v1.3.1