summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Tanner <trtanner@btinternet.com>2015-12-05 19:13:05 +0000
committerThomas Tanner <trtanner@btinternet.com>2015-12-05 19:13:05 +0000
commit235d893eb845c3c8c0edb9dcdb703ce3ec31bdb5 (patch)
tree14f0902f6ba9626447f57795604a6f7e5f479f1a
parentc2ed844eeb2d213a72c405eb47e077da00f084fe (diff)
Gets rid of last vestiges of GameInfo apart from startup and hookdll
Working on sorting out savegame stuff
-rw-r--r--src/mainwindow.cpp28
-rw-r--r--src/modinfoforeign.cpp8
-rw-r--r--src/savegame.cpp81
-rw-r--r--src/savegame.h20
-rw-r--r--src/savegamegamebryo.cpp2
-rw-r--r--src/shared/fallout3info.cpp5
-rw-r--r--src/shared/fallout3info.h2
-rw-r--r--src/shared/falloutnvinfo.cpp5
-rw-r--r--src/shared/falloutnvinfo.h2
-rw-r--r--src/shared/gameinfo.cpp13
-rw-r--r--src/shared/gameinfo.h20
-rw-r--r--src/shared/oblivioninfo.cpp9
-rw-r--r--src/shared/oblivioninfo.h2
-rw-r--r--src/shared/skyriminfo.cpp5
-rw-r--r--src/shared/skyriminfo.h2
15 files changed, 61 insertions, 143 deletions
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 += "<li>" + QFileInfo(name).completeBaseName() + "</li>";
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 <QApplication>
+
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<IPluginGame const *>();
+ return game->dataDirectory().absolutePath();
}
std::vector<ModInfo::EFlag> 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 <http://www.gnu.org/licenses/>.
*/
#include "savegame.h"
-#include <QFile>
-#include <QBuffer>
-#include <set>
-#include <QFileInfo>
-#include <QDateTime>
-#include <utility.h>
-#include <limits>
-#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 <QApplication>
+#include <QDateTime>
+#include <QFile>
+#include <QFileInfo>
-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 <limits>
+#include <set>
+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<ScriptExtender>();
+ 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<WORD>(modified.date().day());
- m_CreationTime.wDayOfWeek = static_cast<WORD>(modified.date().dayOfWeek());
- m_CreationTime.wMonth = static_cast<WORD>(modified.date().month());
- m_CreationTime.wYear =static_cast<WORD>( modified.date().year());
-
- m_CreationTime.wHour = static_cast<WORD>(modified.time().hour());
- m_CreationTime.wMinute = static_cast<WORD>(modified.time().minute());
- m_CreationTime.wSecond = static_cast<WORD>(modified.time().second());
- m_CreationTime.wMilliseconds = static_cast<WORD>(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 <http://www.gnu.org/licenses/>.
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
+namespace MOBase { class IPluginGame; }
/**
* @brief represents a single save game
@@ -42,22 +43,13 @@ 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<SaveGameInfo>();
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<std::wstring> Fallout3Info::getSavegameAttachmentExtensions() const
-{
- return std::vector<std::wstring>();
-}
-
std::vector<std::wstring> 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<std::wstring> getSavegameAttachmentExtensions() const;
-
// file name of this games ini (no path)
virtual std::vector<std::wstring> 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<std::wstring> FalloutNVInfo::getSavegameAttachmentExtensions() const
-{
- return std::vector<std::wstring>();
-}
-
std::vector<std::wstring> 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<std::wstring> getSavegameAttachmentExtensions() const;
-
// file name of this games ini (no path)
virtual std::vector<std::wstring> 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<std::wstring> 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<std::wstring> OblivionInfo::getSavegameAttachmentExtensions() const
-{
- return boost::assign::list_of(L"obse");
-}
-
-
std::vector<std::wstring> 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<std::wstring> getSavegameAttachmentExtensions() const;
-
// file name of this games ini (no path)
virtual std::vector<std::wstring> 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<std::wstring> SkyrimInfo::getSavegameAttachmentExtensions() const
-{
- return boost::assign::list_of(L"skse");
-}
-
std::vector<std::wstring> 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<std::wstring> getSavegameAttachmentExtensions() const;
-
// file name of this games ini (no path)
virtual std::vector<std::wstring> getIniFileNames() const;