Update for IPluginGame::listSaves().

This commit is contained in:
Mikaël Capelle
2020-11-18 19:24:38 +01:00
parent 1862e27066
commit 3a0ece46d0
6 changed files with 72 additions and 58 deletions
+42 -14
View File
@@ -1,10 +1,25 @@
#include "fallout3savegame.h"
Fallout3SaveGame::Fallout3SaveGame(QString const &fileName, MOBase::IPluginGame const *game) :
#include "gamefallout3.h"
Fallout3SaveGame::Fallout3SaveGame(QString const &fileName, GameFallout3 const *game) :
GamebryoSaveGame(fileName, game)
{
FileWrapper file(this, "FO3SAVEGAME");
FileWrapper file(getFilepath(), "FO3SAVEGAME");
unsigned long width, height;
fetchInformationFields(file, width, height, m_SaveNumber, m_PCName, m_PCLevel, m_PCLocation);
}
void Fallout3SaveGame::fetchInformationFields(
FileWrapper& file,
unsigned long& width,
unsigned long& height,
unsigned long& saveNumber,
QString& playerName,
unsigned short& playerLevel,
QString& playerLocation) const
{
file.skip<unsigned long>(); //Save header size
file.setHasFieldMarkers(true);
@@ -13,33 +28,46 @@ Fallout3SaveGame::Fallout3SaveGame(QString const &fileName, MOBase::IPluginGame
file.skip<unsigned long>(); //File version ?
file.skip<unsigned char>(); //delimiter
unsigned long width;
file.read(width);
unsigned long height;
file.read(height);
file.read(m_SaveNumber);
file.read(m_PCName);
file.read(saveNumber);
file.read(playerName);
QString whatthis;
file.read(whatthis);
long level;
file.read(level);
m_PCLevel = level;
playerLevel = level;
file.read(m_PCLocation);
file.read(playerLocation);
}
std::unique_ptr<GamebryoSaveGame::DataFields> Fallout3SaveGame::fetchDataFields() const
{
FileWrapper file(getFilepath(), "FO3SAVEGAME");
std::unique_ptr<DataFields> fields = std::make_unique<DataFields>();
unsigned long width, height;
{
QString dummyName, dummyLocation;
unsigned short dummyLevel;
unsigned long dummySaveNumber;
fetchInformationFields(file, width, height,
dummySaveNumber, dummyName, dummyLevel, dummyLocation);
}
QString playtime;
file.read(playtime);
file.readImage(width, height, 256);
fields->Screenshot = file.readImage(width, height, 256);
file.skip<char>(5); // unknown (1 byte), plugin size (4 bytes)
file.setPluginString(GamebryoSaveGame::StringType::TYPE_BSTRING);
file.readPlugins();
}
fields->Plugins = file.readPlugins();
return fields;
}
+16 -2
View File
@@ -3,12 +3,26 @@
#include "gamebryosavegame.h"
namespace MOBase { class IPluginGame; }
class GameFallout3;
class Fallout3SaveGame : public GamebryoSaveGame
{
public:
Fallout3SaveGame(QString const &fileName, MOBase::IPluginGame const *game);
Fallout3SaveGame(QString const &fileName, GameFallout3 const *game);
protected:
// Fetch easy-to-access information.
void fetchInformationFields(
FileWrapper& wrapper,
unsigned long& width,
unsigned long& height,
unsigned long& saveNumber,
QString& playerName,
unsigned short& playerLevel,
QString& playerLocation) const;
std::unique_ptr<DataFields> fetchDataFields() const override;
};
#endif // FALLOUT3SAVEGAME_H
-19
View File
@@ -1,19 +0,0 @@
#include "fallout3savegameinfo.h"
#include "fallout3savegame.h"
#include "gamegamebryo.h"
Fallout3SaveGameInfo::Fallout3SaveGameInfo(GameGamebryo const *game) :
GamebryoSaveGameInfo(game)
{
}
Fallout3SaveGameInfo::~Fallout3SaveGameInfo()
{
}
MOBase::ISaveGame const *Fallout3SaveGameInfo::getSaveGameInfo(const QString &file) const
{
return new Fallout3SaveGame(file, m_Game);
}
-17
View File
@@ -1,17 +0,0 @@
#ifndef FALLOUT3SAVEGAMEINFO_H
#define FALLOUT3SAVEGAMEINFO_H
#include "gamebryosavegameinfo.h"
class GameGamebryo;
class Fallout3SaveGameInfo : public GamebryoSaveGameInfo
{
public:
Fallout3SaveGameInfo(GameGamebryo const *game);
~Fallout3SaveGameInfo();
virtual MOBase::ISaveGame const *getSaveGameInfo(QString const &file) const override;
};
#endif // FALLOUT3SAVEGAMEINFO_H
+10 -4
View File
@@ -3,9 +3,9 @@
#include "fallout3bsainvalidation.h"
#include "fallout3scriptextender.h"
#include "fallout3dataarchives.h"
#include "fallout3savegameinfo.h"
#include "fallout3moddatachecker.h"
#include "fallout3moddatacontent.h"
#include "fallout3savegame.h"
#include "executableinfo.h"
#include "pluginsetting.h"
@@ -13,6 +13,7 @@
#include <gamebryolocalsavegames.h>
#include <gamebryogameplugins.h>
#include <gamebryounmanagedmods.h>
#include <gamebryosavegameinfo.h>
#include <QCoreApplication>
#include <QDir>
@@ -38,7 +39,7 @@ bool GameFallout3::init(IOrganizer *moInfo)
registerFeature<ScriptExtender>(new Fallout3ScriptExtender(this));
registerFeature<DataArchives>(new Fallout3DataArchives(myGamesPath()));
registerFeature<BSAInvalidation>(new Fallout3BSAInvalidation(feature<DataArchives>(), this));
registerFeature<SaveGameInfo>(new Fallout3SaveGameInfo(this));
registerFeature<SaveGameInfo>(new GamebryoSaveGameInfo(this));
registerFeature<LocalSavegames>(new GamebryoLocalSavegames(myGamesPath(), "fallout.ini"));
registerFeature<ModDataChecker>(new Fallout3ModDataChecker(this));
registerFeature<ModDataContent>(new Fallout3ModDataContent(this));
@@ -117,8 +118,8 @@ void GameFallout3::initializeProfile(const QDir &path, ProfileSettings settings)
}
copyToProfile(myGamesPath(), path, "falloutprefs.ini");
copyToProfile(myGamesPath(), path, "FalloutCustom.ini");
copyToProfile(myGamesPath(), path, "custom.ini");
copyToProfile(myGamesPath(), path, "FalloutCustom.ini");
copyToProfile(myGamesPath(), path, "custom.ini");
copyToProfile(myGamesPath(), path, "GECKCustom.ini");
copyToProfile(myGamesPath(), path, "GECKPrefs.ini");
}
@@ -134,6 +135,11 @@ QString GameFallout3::savegameSEExtension() const
return "";
}
std::shared_ptr<const GamebryoSaveGame> GameFallout3::makeSaveGame(QString filePath) const
{
return std::make_shared<const Fallout3SaveGame>(filePath, this);
}
QString GameFallout3::steamAPPId() const
{
if (selectedVariant() == "Game Of The Year") {
+4 -2
View File
@@ -23,8 +23,6 @@ public: // IPluginGame interface
virtual QList<MOBase::ExecutableInfo> executables() const override;
virtual QList<MOBase::ExecutableForcedLoadSetting> executableForcedLoads() const override;
virtual void initializeProfile(const QDir &path, ProfileSettings settings) const override;
virtual QString savegameExtension() const override;
virtual QString savegameSEExtension() const override;
virtual QString steamAPPId() const override;
virtual QStringList primaryPlugins() const override;
virtual QStringList gameVariants() const;
@@ -48,6 +46,10 @@ public: // IPlugin interface
protected:
virtual QString savegameExtension() const override;
virtual QString savegameSEExtension() const override;
std::shared_ptr<const GamebryoSaveGame> makeSaveGame(QString filePath) const override;
};
#endif // GAMEFALLOUT3_H