mirror of
https://github.com/ModOrganizer2/modorganizer-game_enderalse.git
synced 2026-07-27 14:08:06 -07:00
Update following gamebryo updates for myGamesPath() in game feature. (#11)
This commit is contained in:
@@ -3,10 +3,6 @@
|
||||
#include "iprofile.h"
|
||||
#include <utility.h>
|
||||
|
||||
EnderalSEDataArchives::EnderalSEDataArchives(const QDir& myGamesDir)
|
||||
: GamebryoDataArchives(myGamesDir)
|
||||
{}
|
||||
|
||||
QStringList EnderalSEDataArchives::vanillaArchives() const
|
||||
{
|
||||
return {"Skyrim - Textures0.bsa",
|
||||
@@ -43,7 +39,7 @@ QStringList EnderalSEDataArchives::archives(const MOBase::IProfile* profile) con
|
||||
|
||||
QString iniFile = profile->localSettingsEnabled()
|
||||
? QDir(profile->absolutePath()).absoluteFilePath("enderal.ini")
|
||||
: m_LocalGameDir.absoluteFilePath("enderal.ini");
|
||||
: localGameDirectory().absoluteFilePath("enderal.ini");
|
||||
result.append(getArchivesFromKey(iniFile, "SResourceArchiveList", 512));
|
||||
result.append(getArchivesFromKey(iniFile, "SResourceArchiveList2", 512));
|
||||
|
||||
@@ -57,7 +53,7 @@ void EnderalSEDataArchives::writeArchiveList(MOBase::IProfile* profile,
|
||||
|
||||
QString iniFile = profile->localSettingsEnabled()
|
||||
? QDir(profile->absolutePath()).absoluteFilePath("enderal.ini")
|
||||
: m_LocalGameDir.absoluteFilePath("enderal.ini");
|
||||
: localGameDirectory().absoluteFilePath("enderal.ini");
|
||||
if (list.length() > 511) {
|
||||
int splitIdx = list.lastIndexOf(",", 512);
|
||||
setArchivesToKey(iniFile, "SResourceArchiveList", list.mid(0, splitIdx));
|
||||
|
||||
@@ -12,11 +12,9 @@ class IProfile;
|
||||
|
||||
class EnderalSEDataArchives : public GamebryoDataArchives
|
||||
{
|
||||
|
||||
public:
|
||||
EnderalSEDataArchives(const QDir& myGamesDir);
|
||||
using GamebryoDataArchives::GamebryoDataArchives;
|
||||
|
||||
public:
|
||||
virtual QStringList vanillaArchives() const override;
|
||||
virtual QStringList archives(const MOBase::IProfile* profile) const override;
|
||||
|
||||
|
||||
@@ -17,108 +17,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "enderalselocalsavegames.h"
|
||||
#include "registry.h"
|
||||
#include <QtDebug>
|
||||
#include <iprofile.h>
|
||||
#include <stddef.h>
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
|
||||
static const QString LocalSavesDummy = "..\\Enderal Special Edition\\__MO_Saves\\";
|
||||
|
||||
EnderalSELocalSavegames::EnderalSELocalSavegames(const QDir& myGamesDir,
|
||||
const QString& iniFileName)
|
||||
: m_LocalSavesDir(myGamesDir.absoluteFilePath(LocalSavesDummy)),
|
||||
m_LocalGameDir(myGamesDir.absolutePath()), m_IniFileName(iniFileName)
|
||||
{}
|
||||
|
||||
MappingType EnderalSELocalSavegames::mappings(const QDir& profileSaveDir) const
|
||||
QString EnderalSELocalSavegames::localSavesDummy() const
|
||||
{
|
||||
return {{profileSaveDir.absolutePath(), m_LocalSavesDir.absolutePath(), true, true}};
|
||||
}
|
||||
|
||||
bool EnderalSELocalSavegames::prepareProfile(MOBase::IProfile* profile)
|
||||
{
|
||||
bool enable = profile->localSavesEnabled();
|
||||
|
||||
QString basePath = profile->localSettingsEnabled() ? profile->absolutePath()
|
||||
: m_LocalGameDir.absolutePath();
|
||||
QString iniFilePath = basePath + "/" + m_IniFileName;
|
||||
QString saveIni = profile->absolutePath() + "/" + "savepath.ini";
|
||||
|
||||
// Get the current sLocalSavePath
|
||||
WCHAR currentPath[MAX_PATH];
|
||||
GetPrivateProfileStringW(L"General", L"sLocalSavePath", L"SKIP_ME", currentPath,
|
||||
MAX_PATH, iniFilePath.toStdWString().c_str());
|
||||
bool alreadyEnabled =
|
||||
wcscmp(currentPath, LocalSavesDummy.toStdWString().c_str()) == 0;
|
||||
|
||||
// Get the current bUseMyGamesDirectory
|
||||
WCHAR currentMyGames[MAX_PATH];
|
||||
GetPrivateProfileStringW(L"General", L"bUseMyGamesDirectory", L"SKIP_ME",
|
||||
currentMyGames, MAX_PATH,
|
||||
iniFilePath.toStdWString().c_str());
|
||||
|
||||
// Create the __MO_Saves directory if local saves are enabled and it doesn't exist
|
||||
if (enable) {
|
||||
QDir saves = QDir(m_LocalGameDir.absolutePath() + "/" + LocalSavesDummy);
|
||||
if (!saves.exists()) {
|
||||
saves.mkdir(".");
|
||||
}
|
||||
}
|
||||
|
||||
// Set the path to __MO_Saves if it's not already
|
||||
if (enable && !alreadyEnabled) {
|
||||
// If the path is not blank, save it to savepath.ini
|
||||
if (wcscmp(currentPath, L"SKIP_ME") != 0) {
|
||||
MOBase::WriteRegistryValue(L"General", L"sLocalSavePath", currentPath,
|
||||
saveIni.toStdWString().c_str());
|
||||
}
|
||||
if (wcscmp(currentMyGames, L"SKIP_ME") != 0) {
|
||||
MOBase::WriteRegistryValue(L"General", L"bUseMyGamesDirectory", currentMyGames,
|
||||
saveIni.toStdWString().c_str());
|
||||
}
|
||||
MOBase::WriteRegistryValue(L"General", L"sLocalSavePath",
|
||||
LocalSavesDummy.toStdWString().c_str(),
|
||||
iniFilePath.toStdWString().c_str());
|
||||
MOBase::WriteRegistryValue(L"General", L"bUseMyGamesDirectory", L"1",
|
||||
iniFilePath.toStdWString().c_str());
|
||||
}
|
||||
|
||||
// Get rid of the local saves setting if it's still there
|
||||
if (!enable && alreadyEnabled) {
|
||||
// If savepath.ini exists, use it and delete it
|
||||
if (QFile::exists(saveIni)) {
|
||||
WCHAR savedPath[MAX_PATH];
|
||||
WCHAR savedMyGames[MAX_PATH];
|
||||
GetPrivateProfileStringW(L"General", L"sLocalSavePath", L"DELETE_ME", savedPath,
|
||||
MAX_PATH, saveIni.toStdWString().c_str());
|
||||
GetPrivateProfileStringW(L"General", L"bUseMyGamesDirectory", L"DELETE_ME",
|
||||
savedMyGames, MAX_PATH, saveIni.toStdWString().c_str());
|
||||
if (wcscmp(savedPath, L"DELETE_ME") != 0) {
|
||||
MOBase::WriteRegistryValue(L"General", L"sLocalSavePath", savedPath,
|
||||
iniFilePath.toStdWString().c_str());
|
||||
} else {
|
||||
MOBase::WriteRegistryValue(L"General", L"sLocalSavePath", NULL,
|
||||
iniFilePath.toStdWString().c_str());
|
||||
}
|
||||
if (wcscmp(savedMyGames, L"DELETE_ME") != 0) {
|
||||
MOBase::WriteRegistryValue(L"General", L"bUseMyGamesDirectory", savedMyGames,
|
||||
iniFilePath.toStdWString().c_str());
|
||||
} else {
|
||||
MOBase::WriteRegistryValue(L"General", L"bUseMyGamesDirectory", NULL,
|
||||
iniFilePath.toStdWString().c_str());
|
||||
}
|
||||
QFile::remove(saveIni);
|
||||
}
|
||||
// Otherwise just delete the setting
|
||||
else {
|
||||
MOBase::WriteRegistryValue(L"General", L"sLocalSavePath", NULL,
|
||||
iniFilePath.toStdWString().c_str());
|
||||
MOBase::WriteRegistryValue(L"General", L"bUseMyGamesDirectory", NULL,
|
||||
iniFilePath.toStdWString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
return enable != alreadyEnabled;
|
||||
return "..\\Enderal Special Edition\\__MO_Saves\\";
|
||||
}
|
||||
|
||||
@@ -1,24 +1,17 @@
|
||||
#ifndef ENDERALSELOCALSAVEGAMES_H
|
||||
#define ENDERALSELOCALSAVEGAMES_H
|
||||
|
||||
#include <localsavegames.h>
|
||||
#include <gamebryolocalsavegames.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QString>
|
||||
|
||||
class EnderalSELocalSavegames : public MOBase::LocalSavegames
|
||||
class EnderalSELocalSavegames : public GamebryoLocalSavegames
|
||||
{
|
||||
|
||||
public:
|
||||
EnderalSELocalSavegames(const QDir& myGamesDir, const QString& iniFileName);
|
||||
using GamebryoLocalSavegames::GamebryoLocalSavegames;
|
||||
|
||||
virtual MappingType mappings(const QDir& profileSaveDir) const override;
|
||||
virtual bool prepareProfile(MOBase::IProfile* profile) override;
|
||||
|
||||
private:
|
||||
QDir m_LocalSavesDir;
|
||||
QDir m_LocalGameDir;
|
||||
QString m_IniFileName;
|
||||
protected:
|
||||
QString localSavesDummy() const override;
|
||||
};
|
||||
|
||||
#endif // ENDERALSELOCALSAVEGAMES_H
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
<context>
|
||||
<name>GameEnderalSE</name>
|
||||
<message>
|
||||
<location filename="gameenderalse.cpp" line="194"/>
|
||||
<location filename="gameenderalse.cpp" line="185"/>
|
||||
<source>Enderal Special Edition Support Plugin</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="gameenderalse.cpp" line="204"/>
|
||||
<location filename="gameenderalse.cpp" line="195"/>
|
||||
<source>Adds support for the game Enderal Special Edition.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
||||
+2
-11
@@ -84,9 +84,6 @@ void GameEnderalSE::setGamePath(const QString& path)
|
||||
m_GamePath = path;
|
||||
checkVariants();
|
||||
m_MyGamesPath = determineMyGamesPath(gameDirectoryName());
|
||||
registerFeature(std::make_shared<EnderalSEDataArchives>(myGamesPath()));
|
||||
registerFeature(
|
||||
std::make_shared<EnderalSELocalSavegames>(myGamesPath(), "Enderal.ini"));
|
||||
}
|
||||
|
||||
QDir GameEnderalSE::savesDirectory() const
|
||||
@@ -94,11 +91,6 @@ QDir GameEnderalSE::savesDirectory() const
|
||||
return QDir(m_MyGamesPath + "/Saves");
|
||||
}
|
||||
|
||||
QString GameEnderalSE::myGamesPath() const
|
||||
{
|
||||
return m_MyGamesPath;
|
||||
}
|
||||
|
||||
bool GameEnderalSE::isInstalled() const
|
||||
{
|
||||
return !m_GamePath.isEmpty();
|
||||
@@ -110,11 +102,10 @@ bool GameEnderalSE::init(IOrganizer* moInfo)
|
||||
return false;
|
||||
}
|
||||
|
||||
auto dataArchives = std::make_shared<EnderalSEDataArchives>(myGamesPath());
|
||||
auto dataArchives = std::make_shared<EnderalSEDataArchives>(this);
|
||||
registerFeature(std::make_shared<EnderalSEScriptExtender>(this));
|
||||
registerFeature(dataArchives);
|
||||
registerFeature(
|
||||
std::make_shared<EnderalSELocalSavegames>(myGamesPath(), "enderal.ini"));
|
||||
registerFeature(std::make_shared<EnderalSELocalSavegames>(this, "enderal.ini"));
|
||||
registerFeature(std::make_shared<EnderalSEModDataChecker>(this));
|
||||
registerFeature(std::make_shared<EnderalSEModDataContent>(moInfo->gameFeatures()));
|
||||
registerFeature(std::make_shared<GamebryoSaveGameInfo>(this));
|
||||
|
||||
@@ -65,7 +65,6 @@ protected:
|
||||
QDir documentsDirectory() const;
|
||||
QDir savesDirectory() const;
|
||||
QFileInfo findInGameFolder(const QString& relativePath) const;
|
||||
QString myGamesPath() const;
|
||||
|
||||
void checkVariants();
|
||||
void setVariant(QString variant);
|
||||
|
||||
Reference in New Issue
Block a user