Merge pull request #27 from ModOrganizer2/dev/format-and-gh-actions

Formatting and Github Actions
This commit is contained in:
Mikaël Capelle
2024-06-09 13:36:52 +02:00
committed by GitHub
19 changed files with 249 additions and 205 deletions
+41
View File
@@ -0,0 +1,41 @@
---
# We'll use defaults from the LLVM style, but with 4 columns indentation.
BasedOnStyle: LLVM
IndentWidth: 2
---
Language: Cpp
DeriveLineEnding: false
UseCRLF: true
DerivePointerAlignment: false
PointerAlignment: Left
AlignConsecutiveAssignments: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Empty
AlwaysBreakTemplateDeclarations: Yes
AccessModifierOffset: -2
AlignTrailingComments: true
SpacesBeforeTrailingComments: 2
NamespaceIndentation: Inner
MaxEmptyLinesToKeep: 1
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: true
ColumnLimit: 88
ForEachMacros: ['Q_FOREACH', 'foreach']
+1
View File
@@ -0,0 +1 @@
ca290eff60953a6c4a395522694b83a92a6052ea
+7
View File
@@ -0,0 +1,7 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.cpp text eol=crlf
*.h text eol=crlf
+16
View File
@@ -0,0 +1,16 @@
name: Build Fallout 4 Plugin
on:
push:
branches: master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
runs-on: windows-2022
steps:
- name: Build Fallout 4 Plugin
uses: ModOrganizer2/build-with-mob-action@master
with:
mo2-dependencies: cmake_common uibase game_gamebryo
+16
View File
@@ -0,0 +1,16 @@
name: Lint Fallout 4 Plugin
on:
push:
pull_request:
types: [opened, synchronize, reopened]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check format
uses: ModOrganizer2/check-formatting-action@master
with:
check-path: "."
-40
View File
@@ -1,40 +0,0 @@
version: 1.0.{build}
skip_branch_with_pr: true
image: Visual Studio 2019
environment:
WEBHOOK_URL:
secure: gOKbXaZM9ImtMD5XrYITvdyZUW/az082G9OIN1EC1Vbg57wBaeLhi49uGjxPw5GVujHku6kxN6ab89zhbS5GVeluR76GM83IbKV4Sh7udXzoYZZdg6YudtYHzdhCgUeiedpswbuczTq9ceIkkfSEWZuh/lMAAVVwvcGsJAnoPFw=
build_script:
- pwsh: >-
$ErrorActionPreference = 'Stop'
git clone --depth=1 --no-single-branch https://github.com/ModOrganizer2/modorganizer-umbrella.git c:\projects\modorganizer-umbrella
New-Item -ItemType Directory -Path c:\projects\modorganizer-build
cd c:\projects\modorganizer-umbrella
($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH -eq $null) ? ($branch = $env:APPVEYOR_REPO_BRANCH) : ($branch = $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH)
git checkout $(git show-ref --verify --quiet refs/remotes/origin/${branch} || echo '-b') ${branch}
C:\Python37-x64\python.exe unimake.py -d c:\projects\modorganizer-build -s Appveyor_Build=True ${env:APPVEYOR_PROJECT_NAME}
if($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode ) }
artifacts:
- path: vsbuild\src\RelWithDebInfo\game_fallout4.dll
name: game_fallout4_dll
- path: vsbuild\src\RelWithDebInfo\game_fallout4.pdb
name: game_fallout4_pdb
- path: vsbuild\src\RelWithDebInfo\game_fallout4.lib
name: game_fallout4_lib
on_success:
- ps: Set-Location -Path $env:APPVEYOR_BUILD_FOLDER
- ps: Invoke-RestMethod https://raw.githubusercontent.com/DiscordHooks/appveyor-discord-webhook/master/send.ps1 -o send.ps1
- ps: ./send.ps1 success $env:WEBHOOK_URL
on_failure:
- ps: Set-Location -Path $env:APPVEYOR_BUILD_FOLDER
- ps: Push-AppveyorArtifact ${env:APPVEYOR_BUILD_FOLDER}\stdout.log
- ps: Push-AppveyorArtifact ${env:APPVEYOR_BUILD_FOLDER}\stderr.log
- ps: Invoke-RestMethod https://raw.githubusercontent.com/DiscordHooks/appveyor-discord-webhook/master/send.ps1 -o send.ps1
- ps: ./send.ps1 failure $env:WEBHOOK_URL
+3 -2
View File
@@ -16,7 +16,8 @@ class IPluginGame;
class Fallout4BSAInvalidation : public GamebryoBSAInvalidation
{
public:
Fallout4BSAInvalidation(MOBase::DataArchives* dataArchives, MOBase::IPluginGame const* game);
Fallout4BSAInvalidation(MOBase::DataArchives* dataArchives,
MOBase::IPluginGame const* game);
virtual bool isInvalidationBSA(const QString& bsaName) override;
virtual bool prepareProfile(MOBase::IProfile* profile) override;
@@ -29,4 +30,4 @@ private:
MOBase::IPluginGame const* m_Game;
};
#endif // FALLOUT4BSAINVALIDATION_H
#endif // FALLOUT4BSAINVALIDATION_H
+21 -26
View File
@@ -3,50 +3,45 @@
#include "iprofile.h"
#include <utility.h>
Fallout4DataArchives::Fallout4DataArchives(const QDir &myGamesDir) :
GamebryoDataArchives(myGamesDir)
Fallout4DataArchives::Fallout4DataArchives(const QDir& myGamesDir)
: GamebryoDataArchives(myGamesDir)
{}
QStringList Fallout4DataArchives::vanillaArchives() const
{
return { "Fallout4 - Textures1.ba2"
, "Fallout4 - Textures2.ba2"
, "Fallout4 - Textures3.ba2"
, "Fallout4 - Textures4.ba2"
, "Fallout4 - Textures5.ba2"
, "Fallout4 - Textures6.ba2"
, "Fallout4 - Textures7.ba2"
, "Fallout4 - Textures8.ba2"
, "Fallout4 - Textures9.ba2"
, "Fallout4 - Meshes.ba2"
, "Fallout4 - MeshesExtra.ba2"
, "Fallout4 - Voices.ba2"
, "Fallout4 - Sounds.ba2"
, "Fallout4 - Interface.ba2"
, "Fallout4 - Animations.ba2"
, "Fallout4 - Materials.ba2"
, "Fallout4 - Shaders.ba2"
, "Fallout4 - Startup.ba2"
, "Fallout4 - Misc.ba2" };
return {"Fallout4 - Textures1.ba2", "Fallout4 - Textures2.ba2",
"Fallout4 - Textures3.ba2", "Fallout4 - Textures4.ba2",
"Fallout4 - Textures5.ba2", "Fallout4 - Textures6.ba2",
"Fallout4 - Textures7.ba2", "Fallout4 - Textures8.ba2",
"Fallout4 - Textures9.ba2", "Fallout4 - Meshes.ba2",
"Fallout4 - MeshesExtra.ba2", "Fallout4 - Voices.ba2",
"Fallout4 - Sounds.ba2", "Fallout4 - Interface.ba2",
"Fallout4 - Animations.ba2", "Fallout4 - Materials.ba2",
"Fallout4 - Shaders.ba2", "Fallout4 - Startup.ba2",
"Fallout4 - Misc.ba2"};
}
QStringList Fallout4DataArchives::archives(const MOBase::IProfile *profile) const
QStringList Fallout4DataArchives::archives(const MOBase::IProfile* profile) const
{
QStringList result;
QString iniFile = profile->localSettingsEnabled() ? QDir(profile->absolutePath()).absoluteFilePath("fallout4.ini") : m_LocalGameDir.absoluteFilePath("fallout4.ini");
QString iniFile = profile->localSettingsEnabled()
? QDir(profile->absolutePath()).absoluteFilePath("fallout4.ini")
: m_LocalGameDir.absoluteFilePath("fallout4.ini");
result.append(getArchivesFromKey(iniFile, "SResourceArchiveList"));
result.append(getArchivesFromKey(iniFile, "SResourceArchiveList2"));
return result;
}
void Fallout4DataArchives::writeArchiveList(MOBase::IProfile *profile, const QStringList &before)
void Fallout4DataArchives::writeArchiveList(MOBase::IProfile* profile,
const QStringList& before)
{
QString list = before.join(", ");
QString iniFile = profile->localSettingsEnabled() ? QDir(profile->absolutePath()).absoluteFilePath("fallout4.ini") : m_LocalGameDir.absoluteFilePath("fallout4.ini");
QString iniFile = profile->localSettingsEnabled()
? QDir(profile->absolutePath()).absoluteFilePath("fallout4.ini")
: m_LocalGameDir.absoluteFilePath("fallout4.ini");
if (list.length() > 255) {
int splitIdx = list.lastIndexOf(",", 256);
setArchivesToKey(iniFile, "SResourceArchiveList", list.mid(0, splitIdx));
+10 -10
View File
@@ -3,27 +3,27 @@
#include "gamebryodataarchives.h"
namespace MOBase { class IProfile; }
namespace MOBase
{
class IProfile;
}
#include <QStringList>
#include <QDir>
#include <QStringList>
class Fallout4DataArchives : public GamebryoDataArchives
{
public:
Fallout4DataArchives(const QDir &myGamesDir);
Fallout4DataArchives(const QDir& myGamesDir);
public:
virtual QStringList vanillaArchives() const override;
virtual QStringList archives(const MOBase::IProfile *profile) const override;
virtual QStringList archives(const MOBase::IProfile* profile) const override;
private:
virtual void writeArchiveList(MOBase::IProfile *profile, const QStringList &before) override;
virtual void writeArchiveList(MOBase::IProfile* profile,
const QStringList& before) override;
};
#endif // FALLOUT4DATAARCHIVES_H
#endif // FALLOUT4DATAARCHIVES_H
+11 -10
View File
@@ -9,20 +9,21 @@ public:
using GamebryoModDataChecker::GamebryoModDataChecker;
protected:
virtual const FileNameSet& possibleFolderNames() const override {
virtual const FileNameSet& possibleFolderNames() const override
{
static FileNameSet result{
"interface", "meshes", "music", "scripts", "sound", "strings", "textures",
"trees", "video", "materials", "f4se", "distantlod", "asi", "Tools", "MCM",
"distantland", "mits", "dllplugins", "CalienteTools", "shadersfx", "aaf"
};
"interface", "meshes", "music", "scripts", "sound", "strings",
"textures", "trees", "video", "materials", "f4se", "distantlod",
"asi", "Tools", "MCM", "distantland", "mits", "dllplugins",
"CalienteTools", "shadersfx", "aaf"};
return result;
}
virtual const FileNameSet& possibleFileExtensions() const override {
static FileNameSet result{
"esp", "esm", "esl", "ba2", "modgroups", "ini", "csg", "cdx"
};
virtual const FileNameSet& possibleFileExtensions() const override
{
static FileNameSet result{"esp", "esm", "esl", "ba2",
"modgroups", "ini", "csg", "cdx"};
return result;
}
};
#endif // FALLOUT4_MODATACHECKER_H
#endif // FALLOUT4_MODATACHECKER_H
+12 -9
View File
@@ -4,15 +4,17 @@
#include <gamebryomoddatacontent.h>
#include <ifiletree.h>
class Fallout4ModDataContent : public GamebryoModDataContent {
class Fallout4ModDataContent : public GamebryoModDataContent
{
protected:
enum Fallout4Content {
enum Fallout4Content
{
CONTENT_MATERIAL = CONTENT_NEXT_VALUE
};
public:
Fallout4ModDataContent(const MOBase::IGameFeatures* gameFeatures) :
GamebryoModDataContent(gameFeatures)
Fallout4ModDataContent(const MOBase::IGameFeatures* gameFeatures)
: GamebryoModDataContent(gameFeatures)
{
m_Enabled[CONTENT_SKYPROC] = false;
}
@@ -20,22 +22,23 @@ public:
std::vector<Content> getAllContents() const override
{
auto contents = GamebryoModDataContent::getAllContents();
contents.push_back(Content(CONTENT_MATERIAL, "Materials", ":/MO/gui/content/material"));
contents.push_back(
Content(CONTENT_MATERIAL, "Materials", ":/MO/gui/content/material"));
return contents;
}
std::vector<int> getContentsFor(
std::shared_ptr<const MOBase::IFileTree> fileTree) const override
std::vector<int>
getContentsFor(std::shared_ptr<const MOBase::IFileTree> fileTree) const override
{
auto contents = GamebryoModDataContent::getContentsFor(fileTree);
for (auto e : *fileTree) {
if (e->compare("materials") == 0) {
contents.push_back(CONTENT_MATERIAL);
break; // Early break if you have nothing else to check.
break; // Early break if you have nothing else to check.
}
}
return contents;
}
};
#endif // FALLOUT4_MODDATACONTENT_H
#endif // FALLOUT4_MODDATACONTENT_H
+21 -24
View File
@@ -4,17 +4,18 @@
#include "gamefallout4.h"
Fallout4SaveGame::Fallout4SaveGame(QString const &fileName, GameFallout4 const* game) :
GamebryoSaveGame(fileName, game, true)
Fallout4SaveGame::Fallout4SaveGame(QString const& fileName, GameFallout4 const* game)
: GamebryoSaveGame(fileName, game, true)
{
FileWrapper file(getFilepath(), "FO4_SAVEGAME");
FILETIME creationTime;
fetchInformationFields(file, m_SaveNumber, m_PCName, m_PCLevel, m_PCLocation, creationTime);
fetchInformationFields(file, m_SaveNumber, m_PCName, m_PCLevel, m_PCLocation,
creationTime);
//A file time is a 64-bit value that represents the number of 100-nanosecond
//intervals that have elapsed since 12:00 A.M. January 1, 1601 Coordinated Universal Time (UTC).
//So we need to convert that to something useful
// A file time is a 64-bit value that represents the number of 100-nanosecond
// intervals that have elapsed since 12:00 A.M. January 1, 1601 Coordinated Universal
// Time (UTC). So we need to convert that to something useful
SYSTEMTIME ctime;
::FileTimeToSystemTime(&creationTime, &ctime);
@@ -22,15 +23,11 @@ Fallout4SaveGame::Fallout4SaveGame(QString const &fileName, GameFallout4 const*
}
void Fallout4SaveGame::fetchInformationFields(
FileWrapper& file,
unsigned long& saveNumber,
QString& playerName,
unsigned short& playerLevel,
QString& playerLocation,
FILETIME& creationTime) const
FileWrapper& file, unsigned long& saveNumber, QString& playerName,
unsigned short& playerLevel, QString& playerLocation, FILETIME& creationTime) const
{
file.skip<unsigned long>(); // header size
file.skip<uint32_t>(); // header version
file.skip<unsigned long>(); // header size
file.skip<uint32_t>(); // header version
file.read(saveNumber);
file.read(playerName);
@@ -41,18 +38,18 @@ void Fallout4SaveGame::fetchInformationFields(
file.read(playerLocation);
QString ignore;
file.read(ignore); // playtime as ascii hh.mm.ss
file.read(ignore); // race name (i.e. BretonRace)
file.read(ignore); // playtime as ascii hh.mm.ss
file.read(ignore); // race name (i.e. BretonRace)
file.skip<unsigned short>(); // Player gender (0 = male)
file.skip<float>(2); // experience gathered, experience required
file.skip<unsigned short>(); // Player gender (0 = male)
file.skip<float>(2); // experience gathered, experience required
file.read(creationTime);
}
std::unique_ptr<GamebryoSaveGame::DataFields> Fallout4SaveGame::fetchDataFields() const
{
FileWrapper file(getFilepath(), "FO4_SAVEGAME"); //10bytes
FileWrapper file(getFilepath(), "FO4_SAVEGAME"); // 10bytes
{
QString dummyName, dummyLocation;
@@ -60,8 +57,8 @@ std::unique_ptr<GamebryoSaveGame::DataFields> Fallout4SaveGame::fetchDataFields(
unsigned long dummySaveNumber;
FILETIME dummyTime;
fetchInformationFields(file, dummySaveNumber, dummyName, dummyLevel,
dummyLocation, dummyTime);
fetchInformationFields(file, dummySaveNumber, dummyName, dummyLevel, dummyLocation,
dummyTime);
}
QString ignore;
@@ -70,8 +67,8 @@ std::unique_ptr<GamebryoSaveGame::DataFields> Fallout4SaveGame::fetchDataFields(
fields->Screenshot = file.readImage(384, true);
uint8_t saveGameVersion = file.readChar();
file.read(ignore); // game version
file.skip<uint32_t>(); // plugin info size
file.read(ignore); // game version
file.skip<uint32_t>(); // plugin info size
fields->Plugins = file.readPlugins();
if (saveGameVersion >= 68) {
@@ -79,4 +76,4 @@ std::unique_ptr<GamebryoSaveGame::DataFields> Fallout4SaveGame::fetchDataFields(
}
return fields;
}
}
+5 -10
View File
@@ -10,20 +10,15 @@ class GameFallout4;
class Fallout4SaveGame : public GamebryoSaveGame
{
public:
Fallout4SaveGame(QString const &fileName, GameFallout4 const* game);
Fallout4SaveGame(QString const& fileName, GameFallout4 const* game);
protected:
// Fetch easy-to-access information.
void fetchInformationFields(
FileWrapper& file,
unsigned long& saveNumber,
QString& playerName,
unsigned short& playerLevel,
QString& playerLocation,
FILETIME& creationTime) const;
void fetchInformationFields(FileWrapper& file, unsigned long& saveNumber,
QString& playerName, unsigned short& playerLevel,
QString& playerLocation, FILETIME& creationTime) const;
std::unique_ptr<DataFields> fetchDataFields() const override;
};
#endif // FALLOUT4SAVEGAME_H
#endif // FALLOUT4SAVEGAME_H
+3 -4
View File
@@ -3,10 +3,9 @@
#include <QString>
#include <QStringList>
Fallout4ScriptExtender::Fallout4ScriptExtender(GameGamebryo const *game) :
GamebryoScriptExtender(game)
{
}
Fallout4ScriptExtender::Fallout4ScriptExtender(GameGamebryo const* game)
: GamebryoScriptExtender(game)
{}
QString Fallout4ScriptExtender::BinaryName() const
{
+2 -3
View File
@@ -8,11 +8,10 @@ class GameGamebryo;
class Fallout4ScriptExtender : public GamebryoScriptExtender
{
public:
Fallout4ScriptExtender(GameGamebryo const *game);
Fallout4ScriptExtender(GameGamebryo const* game);
virtual QString BinaryName() const override;
virtual QString PluginPath() const override;
};
#endif // FALLOUT4SCRIPTEXTENDER_H
#endif // FALLOUT4SCRIPTEXTENDER_H
+12 -12
View File
@@ -1,27 +1,26 @@
#include "fallout4unmanagedmods.h"
Fallout4UnmangedMods::Fallout4UnmangedMods(const GameGamebryo *game)
: GamebryoUnmangedMods(game)
Fallout4UnmangedMods::Fallout4UnmangedMods(const GameGamebryo* game)
: GamebryoUnmangedMods(game)
{}
Fallout4UnmangedMods::~Fallout4UnmangedMods()
{}
Fallout4UnmangedMods::~Fallout4UnmangedMods() {}
QStringList Fallout4UnmangedMods::mods(bool onlyOfficial) const {
QStringList Fallout4UnmangedMods::mods(bool onlyOfficial) const
{
QStringList result;
QStringList pluginList = game()->primaryPlugins();
QStringList pluginList = game()->primaryPlugins();
QStringList otherPlugins = game()->DLCPlugins();
otherPlugins.append(game()->CCPlugins());
for (QString plugin : otherPlugins) {
pluginList.removeAll(plugin);
}
QDir dataDir(game()->dataDirectory());
for (const QString &fileName : dataDir.entryList({ "*.esp", "*.esl", "*.esm" })) {
for (const QString& fileName : dataDir.entryList({"*.esp", "*.esl", "*.esm"})) {
if (!pluginList.contains(fileName, Qt::CaseInsensitive)) {
if (!onlyOfficial || pluginList.contains(fileName, Qt::CaseInsensitive)) {
result.append(fileName.chopped(4)); // trims the extension off
result.append(fileName.chopped(4)); // trims the extension off
}
}
}
@@ -29,17 +28,18 @@ QStringList Fallout4UnmangedMods::mods(bool onlyOfficial) const {
return result;
}
QStringList Fallout4UnmangedMods::secondaryFiles(const QString &modName) const {
QStringList Fallout4UnmangedMods::secondaryFiles(const QString& modName) const
{
// file extension in FO4 is .ba2 instead of bsa
QStringList archives;
QDir dataDir = game()->dataDirectory();
for (const QString &archiveName : dataDir.entryList({modName + "*.ba2"})) {
for (const QString& archiveName : dataDir.entryList({modName + "*.ba2"})) {
archives.append(dataDir.absoluteFilePath(archiveName));
}
return archives;
}
QString Fallout4UnmangedMods::displayName(const QString &modName) const
QString Fallout4UnmangedMods::displayName(const QString& modName) const
{
// unlike in earlier games, in fallout 4 the file name doesn't correspond to
// the public name
+6 -9
View File
@@ -1,21 +1,18 @@
#ifndef FALLOUT4UNMANAGEDMODS_H
#define FALLOUT4UNMANAGEDMODS_H
#include "gamebryounmanagedmods.h"
#include <gamegamebryo.h>
class Fallout4UnmangedMods : public GamebryoUnmangedMods {
class Fallout4UnmangedMods : public GamebryoUnmangedMods
{
public:
Fallout4UnmangedMods(const GameGamebryo *game);
Fallout4UnmangedMods(const GameGamebryo* game);
~Fallout4UnmangedMods();
virtual QStringList mods(bool onlyOfficial) const override;
virtual QStringList secondaryFiles(const QString &modName) const override;
virtual QString displayName(const QString &modName) const override;
virtual QStringList secondaryFiles(const QString& modName) const override;
virtual QString displayName(const QString& modName) const override;
};
#endif // FALLOUT4UNMANAGEDMODS_H
#endif // FALLOUT4UNMANAGEDMODS_H
+53 -39
View File
@@ -2,18 +2,18 @@
#include "fallout4bsainvalidation.h"
#include "fallout4dataarchives.h"
#include "fallout4scriptextender.h"
#include "fallout4unmanagedmods.h"
#include "fallout4moddatachecker.h"
#include "fallout4moddatacontent.h"
#include "fallout4savegame.h"
#include "fallout4scriptextender.h"
#include "fallout4unmanagedmods.h"
#include <pluginsetting.h>
#include "versioninfo.h"
#include <creationgameplugins.h>
#include <executableinfo.h>
#include <gamebryolocalsavegames.h>
#include <gamebryosavegameinfo.h>
#include <creationgameplugins.h>
#include "versioninfo.h"
#include <pluginsetting.h>
#include <QCoreApplication>
#include <QDir>
@@ -29,11 +29,9 @@
using namespace MOBase;
GameFallout4::GameFallout4()
{
}
GameFallout4::GameFallout4() {}
bool GameFallout4::init(IOrganizer *moInfo)
bool GameFallout4::init(IOrganizer* moInfo)
{
if (!GameGamebryo::init(moInfo)) {
return false;
@@ -43,9 +41,11 @@ bool GameFallout4::init(IOrganizer *moInfo)
registerFeature(std::make_shared<Fallout4ScriptExtender>(this));
registerFeature(dataArchives);
registerFeature(std::make_shared<GamebryoLocalSavegames>(myGamesPath(), "fallout4custom.ini"));
registerFeature(
std::make_shared<GamebryoLocalSavegames>(myGamesPath(), "fallout4custom.ini"));
registerFeature(std::make_shared<Fallout4ModDataChecker>(this));
registerFeature(std::make_shared<Fallout4ModDataContent>(m_Organizer->gameFeatures()));
registerFeature(
std::make_shared<Fallout4ModDataContent>(m_Organizer->gameFeatures()));
registerFeature(std::make_shared<GamebryoSaveGameInfo>(this));
registerFeature(std::make_shared<CreationGamePlugins>(moInfo));
registerFeature(std::make_shared<Fallout4UnmangedMods>(this));
@@ -61,19 +61,23 @@ QString GameFallout4::gameName() const
void GameFallout4::detectGame()
{
m_GamePath = identifyGamePath();
m_GamePath = identifyGamePath();
m_MyGamesPath = determineMyGamesPath("Fallout4");
}
QList<ExecutableInfo> GameFallout4::executables() const
{
return QList<ExecutableInfo>()
<< ExecutableInfo("F4SE", findInGameFolder(m_Organizer->gameFeatures()->gameFeature<MOBase::ScriptExtender>()->loaderName()))
<< ExecutableInfo("Fallout 4", findInGameFolder(binaryName()))
<< ExecutableInfo("Fallout Launcher", findInGameFolder(getLauncherName()))
<< ExecutableInfo("Creation Kit", findInGameFolder("CreationKit.exe")).withSteamAppId("1946160")
<< ExecutableInfo("LOOT", QFileInfo(getLootPath())).withArgument("--game=\"Fallout4\"")
;
<< ExecutableInfo("F4SE",
findInGameFolder(m_Organizer->gameFeatures()
->gameFeature<MOBase::ScriptExtender>()
->loaderName()))
<< ExecutableInfo("Fallout 4", findInGameFolder(binaryName()))
<< ExecutableInfo("Fallout Launcher", findInGameFolder(getLauncherName()))
<< ExecutableInfo("Creation Kit", findInGameFolder("CreationKit.exe"))
.withSteamAppId("1946160")
<< ExecutableInfo("LOOT", QFileInfo(getLootPath()))
.withArgument("--game=\"Fallout4\"");
}
QList<ExecutableForcedLoadSetting> GameFallout4::executableForcedLoads() const
@@ -91,7 +95,6 @@ QString GameFallout4::localizedName() const
return tr("Fallout 4 Support Plugin");
}
QString GameFallout4::author() const
{
return "Tannin & MO2 Team";
@@ -100,7 +103,8 @@ QString GameFallout4::author() const
QString GameFallout4::description() const
{
return tr("Adds support for the game Fallout 4.\n"
"Splash by %1").arg("nekoyoubi");
"Splash by %1")
.arg("nekoyoubi");
}
MOBase::VersionInfo GameFallout4::version() const
@@ -117,31 +121,32 @@ MappingType GameFallout4::mappings() const
{
MappingType result;
if (testFilePlugins().isEmpty()) {
for (const QString& profileFile : { "plugins.txt", "loadorder.txt" }) {
result.push_back({ m_Organizer->profilePath() + "/" + profileFile,
for (const QString& profileFile : {"plugins.txt", "loadorder.txt"}) {
result.push_back({m_Organizer->profilePath() + "/" + profileFile,
localAppFolder() + "/" + gameShortName() + "/" + profileFile,
false });
false});
}
}
return result;
}
void GameFallout4::initializeProfile(const QDir &path, ProfileSettings settings) const
void GameFallout4::initializeProfile(const QDir& path, ProfileSettings settings) const
{
if (settings.testFlag(IPluginGame::MODS)) {
copyToProfile(localAppFolder() + "/Fallout4", path, "plugins.txt");
}
if (settings.testFlag(IPluginGame::CONFIGURATION)) {
if (settings.testFlag(IPluginGame::PREFER_DEFAULTS)
|| !QFileInfo(myGamesPath() + "/fallout4.ini").exists()) {
copyToProfile(gameDirectory().absolutePath(), path, "fallout4_default.ini", "fallout4.ini");
if (settings.testFlag(IPluginGame::PREFER_DEFAULTS) ||
!QFileInfo(myGamesPath() + "/fallout4.ini").exists()) {
copyToProfile(gameDirectory().absolutePath(), path, "fallout4_default.ini",
"fallout4.ini");
} else {
copyToProfile(myGamesPath(), path, "fallout4.ini");
}
copyToProfile(myGamesPath(), path, "fallout4prefs.ini");
copyToProfile(myGamesPath(), path, "fallout4custom.ini");
copyToProfile(myGamesPath(), path, "fallout4custom.ini");
}
}
@@ -155,7 +160,8 @@ QString GameFallout4::savegameSEExtension() const
return "f4se";
}
std::shared_ptr<const GamebryoSaveGame> GameFallout4::makeSaveGame(QString filePath) const
std::shared_ptr<const GamebryoSaveGame>
GameFallout4::makeSaveGame(QString filePath) const
{
return std::make_shared<const Fallout4SaveGame>(filePath, this);
}
@@ -170,15 +176,15 @@ QStringList GameFallout4::testFilePlugins() const
QStringList plugins;
if (m_Organizer != nullptr && m_Organizer->profile() != nullptr) {
QString customIni(
m_Organizer->profile()->absoluteIniFilePath("Fallout4Custom.ini"));
m_Organizer->profile()->absoluteIniFilePath("Fallout4Custom.ini"));
if (QFile(customIni).exists()) {
for (int i = 1; i <= 10; ++i) {
QString setting("sTestFile");
setting += std::to_string(i);
WCHAR value[MAX_PATH];
DWORD length = ::GetPrivateProfileStringW(
L"General", setting.toStdWString().c_str(), L"", value, MAX_PATH,
customIni.toStdWString().c_str());
L"General", setting.toStdWString().c_str(), L"", value, MAX_PATH,
customIni.toStdWString().c_str());
if (length && wcscmp(value, L"") != 0) {
QString plugin = QString::fromWCharArray(value, length);
if (!plugin.isEmpty() && !plugins.contains(plugin))
@@ -209,7 +215,7 @@ QStringList GameFallout4::primaryPlugins() const
QStringList GameFallout4::gameVariants() const
{
return { "Regular" };
return {"Regular"};
}
QString GameFallout4::gameShortName() const
@@ -224,13 +230,18 @@ QString GameFallout4::gameNexusName() const
QStringList GameFallout4::iniFiles() const
{
return { "fallout4.ini", "fallout4prefs.ini", "fallout4custom.ini" };
return {"fallout4.ini", "fallout4prefs.ini", "fallout4custom.ini"};
}
QStringList GameFallout4::DLCPlugins() const
{
return {"dlcrobot.esm", "dlcworkshop01.esm", "dlccoast.esm", "dlcworkshop02.esm", "dlcworkshop03.esm",
"dlcnukaworld.esm", "dlcultrahighresolution.esm"};
return {"dlcrobot.esm",
"dlcworkshop01.esm",
"dlccoast.esm",
"dlcworkshop02.esm",
"dlcworkshop03.esm",
"dlcnukaworld.esm",
"dlcultrahighresolution.esm"};
}
QStringList GameFallout4::CCPlugins() const
@@ -238,7 +249,9 @@ QStringList GameFallout4::CCPlugins() const
QStringList plugins = {};
QFile file(gameDirectory().absoluteFilePath("Fallout4.ccc"));
if (file.open(QIODevice::ReadOnly)) {
ON_BLOCK_EXIT([&file]() { file.close(); });
ON_BLOCK_EXIT([&file]() {
file.close();
});
if (file.size() == 0) {
return plugins;
@@ -310,7 +323,8 @@ QString GameFallout4::shortDescription(unsigned int key) const
}
}
QString GameFallout4::fullDescription(unsigned int key) const {
QString GameFallout4::fullDescription(unsigned int key) const
{
switch (key) {
case PROBLEM_TEST_FILE: {
return tr("<p>You have sTestFile settings in your "
@@ -319,4 +333,4 @@ QString GameFallout4::fullDescription(unsigned int key) const {
"Management is disabled.</p>");
}
}
}
}
+9 -7
View File
@@ -1,7 +1,6 @@
#ifndef GAMEFALLOUT4_H
#define GAMEFALLOUT4_H
#include "gamegamebryo.h"
#include "iplugindiagnose.h"
@@ -17,17 +16,19 @@ class GameFallout4 : public GameGamebryo, public MOBase::IPluginDiagnose
public:
GameFallout4();
virtual bool init(MOBase::IOrganizer *moInfo) override;
virtual bool init(MOBase::IOrganizer* moInfo) override;
public:
QStringList testFilePlugins() const;
public: // IPluginGame interface
public: // IPluginGame interface
virtual QString gameName() const override;
virtual void detectGame() override;
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 QList<MOBase::ExecutableForcedLoadSetting>
executableForcedLoads() const override;
virtual void initializeProfile(const QDir& path,
ProfileSettings settings) const override;
virtual QString steamAPPId() const override;
virtual QStringList primaryPlugins() const override;
virtual QStringList gameVariants() const override;
@@ -40,6 +41,7 @@ public: // IPluginGame interface
virtual LoadOrderMechanism loadOrderMechanism() const override;
virtual int nexusModOrganizerID() const override;
virtual int nexusGameID() const override;
public: // IPluginDiagnose interface
virtual std::vector<unsigned int> activeProblems() const override;
virtual QString shortDescription(unsigned int key) const override;
@@ -47,7 +49,7 @@ public: // IPluginDiagnose interface
virtual bool hasGuidedFix(unsigned int key) const override { return false; }
virtual void startGuidedFix(unsigned int key) const override {}
public: // IPlugin interface
public: // IPlugin interface
virtual QString name() const override;
virtual QString localizedName() const override;
virtual QString author() const override;
@@ -68,4 +70,4 @@ private:
static const unsigned int PROBLEM_TEST_FILE = 1;
};
#endif // GAMEFallout4_H
#endif // GAMEFallout4_H