Initial migration from original FO4 plugin

This commit is contained in:
Jeremy Rimpo
2024-08-01 21:08:42 -05:00
commit 651890d422
27 changed files with 1076 additions and 0 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']
+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 London Plugin
on:
push:
branches: master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
runs-on: windows-2022
steps:
- name: Build Fallout 4 London 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 London 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: "."
+5
View File
@@ -0,0 +1,5 @@
edit
CMakeLists.txt.user
/msbuild.log
/*std*.log
/*build
+10
View File
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.16)
if(DEFINED DEPENDENCIES_DIR)
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/mo2.cmake)
else()
include(${CMAKE_CURRENT_LIST_DIR}/cmake_common/mo2.cmake)
endif()
project(game_fallout4london)
add_subdirectory(src)
+7
View File
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.16)
add_library(game_fallout4london SHARED)
mo2_configure_plugin(game_fallout4london
WARNINGS OFF
PRIVATE_DEPENDS creation)
mo2_install_target(game_fallout4london)
+14
View File
@@ -0,0 +1,14 @@
Import('qt_env')
env = qt_env.Clone()
# Shouldn't this be GAMEFALLOUT3_LIBRARY
env.AppendUnique(CPPDEFINES = [ 'GAMEFALLOUT4_LIBRARY' ])
env.RequiresGamebryo()
lib = env.SharedLibrary('gameFallout4London', env.Glob('*.cpp'))
env.InstallModule(lib)
res = env['QT_USED_MODULES']
Return('res')
+5
View File
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/Fallout4London">
<file alias="splash">splash.png</file>
</qresource>
</RCC>
+68
View File
@@ -0,0 +1,68 @@
#include "fallout4bsainvalidation.h"
#include "dummybsa.h"
#include "iplugingame.h"
#include "iprofile.h"
#include "registry.h"
#include <imoinfo.h>
#include <utility.h>
Fallout4LondonBSAInvalidation::Fallout4LondonBSAInvalidation(MOBase::DataArchives* dataArchives,
MOBase::IPluginGame const* game)
: GamebryoBSAInvalidation(dataArchives, "Fallout4Custom.ini", game)
{
m_IniFileName = "Fallout4Custom.ini";
m_Game = game;
}
bool Fallout4LondonBSAInvalidation::isInvalidationBSA(const QString& bsaName)
{
return false;
}
QString Fallout4LondonBSAInvalidation::invalidationBSAName() const
{
return "";
}
unsigned long Fallout4LondonBSAInvalidation::bsaVersion() const
{
return 0x68;
}
bool Fallout4LondonBSAInvalidation::prepareProfile(MOBase::IProfile* profile)
{
bool dirty = false;
QString basePath = profile->localSettingsEnabled()
? profile->absolutePath()
: m_Game->documentsDirectory().absolutePath();
QString iniFilePath = basePath + "/" + m_IniFileName;
WCHAR setting[MAX_PATH];
if (profile->invalidationActive(nullptr)) {
// write bInvalidateOlderFiles = 1, if needed
if (!::GetPrivateProfileStringW(L"Archive", L"bInvalidateOlderFiles", L"0", setting,
MAX_PATH, iniFilePath.toStdWString().c_str()) ||
wcstol(setting, nullptr, 10) != 1) {
dirty = true;
if (!MOBase::WriteRegistryValue(L"Archive", L"bInvalidateOlderFiles", L"1",
iniFilePath.toStdWString().c_str())) {
qWarning("failed to override data directory in \"%s\"",
qUtf8Printable(m_IniFileName));
}
}
if (!::GetPrivateProfileStringW(L"Archive", L"sResourceDataDirsFinal", L"STRINGS\\",
setting, MAX_PATH,
iniFilePath.toStdWString().c_str()) ||
wcscmp(setting, L"") != 0) {
dirty = true;
if (!MOBase::WriteRegistryValue(L"Archive", L"sResourceDataDirsFinal", L"",
iniFilePath.toStdWString().c_str())) {
qWarning("failed to override data directory in \"%s\"",
qUtf8Printable(m_IniFileName));
}
}
}
return dirty;
}
+33
View File
@@ -0,0 +1,33 @@
#ifndef FALLOUT4BSAINVALIDATION_H
#define FALLOUT4BSAINVALIDATION_H
#include "fallout4dataarchives.h"
#include "gamebryobsainvalidation.h"
#include <bsainvalidation.h>
#include <dataarchives.h>
#include <memory>
namespace MOBase
{
class IPluginGame;
}
class Fallout4LondonBSAInvalidation : public GamebryoBSAInvalidation
{
public:
Fallout4LondonBSAInvalidation(MOBase::DataArchives* dataArchives,
MOBase::IPluginGame const* game);
virtual bool isInvalidationBSA(const QString& bsaName) override;
virtual bool prepareProfile(MOBase::IProfile* profile) override;
private:
virtual QString invalidationBSAName() const override;
virtual unsigned long bsaVersion() const override;
private:
QString m_IniFileName;
MOBase::IPluginGame const* m_Game;
};
#endif // FALLOUT4BSAINVALIDATION_H
+48
View File
@@ -0,0 +1,48 @@
#include "fallout4dataarchives.h"
#include "iprofile.h"
#include <utility.h>
QStringList Fallout4LondonDataArchives::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"};
}
QStringList Fallout4LondonDataArchives::archives(const MOBase::IProfile* profile) const
{
QStringList result;
QString iniFile = profile->localSettingsEnabled()
? QDir(profile->absolutePath()).absoluteFilePath("fallout4.ini")
: localGameDirectory().absoluteFilePath("fallout4.ini");
result.append(getArchivesFromKey(iniFile, "SResourceArchiveList"));
result.append(getArchivesFromKey(iniFile, "SResourceArchiveList2"));
return result;
}
void Fallout4LondonDataArchives::writeArchiveList(MOBase::IProfile* profile,
const QStringList& before)
{
QString list = before.join(", ");
QString iniFile = profile->localSettingsEnabled()
? QDir(profile->absolutePath()).absoluteFilePath("fallout4.ini")
: localGameDirectory().absoluteFilePath("fallout4.ini");
if (list.length() > 255) {
int splitIdx = list.lastIndexOf(",", 256);
setArchivesToKey(iniFile, "SResourceArchiveList", list.mid(0, splitIdx));
setArchivesToKey(iniFile, "SResourceArchiveList2", list.mid(splitIdx + 2));
} else {
setArchivesToKey(iniFile, "SResourceArchiveList", list);
}
}
+27
View File
@@ -0,0 +1,27 @@
#ifndef FALLOUT4DATAARCHIVES_H
#define FALLOUT4DATAARCHIVES_H
#include "gamebryodataarchives.h"
namespace MOBase
{
class IProfile;
}
#include <QDir>
#include <QStringList>
class Fallout4LondonDataArchives : public GamebryoDataArchives
{
public:
using GamebryoDataArchives::GamebryoDataArchives;
virtual QStringList vanillaArchives() const override;
virtual QStringList archives(const MOBase::IProfile* profile) const override;
private:
virtual void writeArchiveList(MOBase::IProfile* profile,
const QStringList& before) override;
};
#endif // FALLOUT4DATAARCHIVES_H
+29
View File
@@ -0,0 +1,29 @@
#ifndef FALLOUT4_MODATACHECKER_H
#define FALLOUT4_MODATACHECKER_H
#include <gamebryomoddatachecker.h>
class Fallout4LondonModDataChecker : public GamebryoModDataChecker
{
public:
using GamebryoModDataChecker::GamebryoModDataChecker;
protected:
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"};
return result;
}
virtual const FileNameSet& possibleFileExtensions() const override
{
static FileNameSet result{"esp", "esm", "esl", "ba2",
"modgroups", "ini", "csg", "cdx"};
return result;
}
};
#endif // FALLOUT4_MODATACHECKER_H
+44
View File
@@ -0,0 +1,44 @@
#ifndef FALLOUT4_MODDATACONTENT_H
#define FALLOUT4_MODDATACONTENT_H
#include <gamebryomoddatacontent.h>
#include <ifiletree.h>
class Fallout4LondonModDataContent : public GamebryoModDataContent
{
protected:
enum Fallout4LondonContent
{
CONTENT_MATERIAL = CONTENT_NEXT_VALUE
};
public:
Fallout4LondonModDataContent(const MOBase::IGameFeatures* gameFeatures)
: GamebryoModDataContent(gameFeatures)
{
m_Enabled[CONTENT_SKYPROC] = false;
}
std::vector<Content> getAllContents() const override
{
auto contents = GamebryoModDataContent::getAllContents();
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
{
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.
}
}
return contents;
}
};
#endif // FALLOUT4_MODDATACONTENT_H
+79
View File
@@ -0,0 +1,79 @@
#include "fallout4savegame.h"
#include <Windows.h>
#include "gamefallout4.h"
Fallout4LondonSaveGame::Fallout4LondonSaveGame(QString const& fileName, GameFallout4London const* game)
: GamebryoSaveGame(fileName, game, true)
{
FileWrapper file(getFilepath(), "FO4_SAVEGAME");
FILETIME 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
SYSTEMTIME ctime;
::FileTimeToSystemTime(&creationTime, &ctime);
setCreationTime(ctime);
}
void Fallout4LondonSaveGame::fetchInformationFields(
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.read(saveNumber);
file.read(playerName);
unsigned long temp;
file.read(temp);
playerLevel = static_cast<unsigned short>(temp);
file.read(playerLocation);
QString ignore;
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.read(creationTime);
}
std::unique_ptr<GamebryoSaveGame::DataFields> Fallout4LondonSaveGame::fetchDataFields() const
{
FileWrapper file(getFilepath(), "FO4_SAVEGAME"); // 10bytes
{
QString dummyName, dummyLocation;
unsigned short dummyLevel;
unsigned long dummySaveNumber;
FILETIME dummyTime;
fetchInformationFields(file, dummySaveNumber, dummyName, dummyLevel, dummyLocation,
dummyTime);
}
QString ignore;
std::unique_ptr<DataFields> fields = std::make_unique<DataFields>();
fields->Screenshot = file.readImage(384, true);
uint8_t saveGameVersion = file.readChar();
file.read(ignore); // game version
file.skip<uint32_t>(); // plugin info size
fields->Plugins = file.readPlugins();
if (saveGameVersion >= 68) {
fields->LightPlugins = file.readLightPlugins();
}
return fields;
}
+24
View File
@@ -0,0 +1,24 @@
#ifndef FALLOUT4SAVEGAME_H
#define FALLOUT4SAVEGAME_H
#include "gamebryosavegame.h"
#include <Windows.h>
class GameFallout4London;
class Fallout4LondonSaveGame : public GamebryoSaveGame
{
public:
Fallout4LondonSaveGame(QString const& fileName, GameFallout4London 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;
std::unique_ptr<DataFields> fetchDataFields() const override;
};
#endif // FALLOUT4SAVEGAME_H
+18
View File
@@ -0,0 +1,18 @@
#include "fallout4scriptextender.h"
#include <QString>
#include <QStringList>
Fallout4LondonScriptExtender::Fallout4LondonScriptExtender(GameGamebryo const* game)
: GamebryoScriptExtender(game)
{}
QString Fallout4LondonScriptExtender::BinaryName() const
{
return "f4se_loader.exe";
}
QString Fallout4LondonScriptExtender::PluginPath() const
{
return "f4se/plugins";
}
+17
View File
@@ -0,0 +1,17 @@
#ifndef FALLOUT4SCRIPTEXTENDER_H
#define FALLOUT4SCRIPTEXTENDER_H
#include "gamebryoscriptextender.h"
class GameGamebryo;
class Fallout4LondonScriptExtender : public GamebryoScriptExtender
{
public:
Fallout4LondonScriptExtender(GameGamebryo const* game);
virtual QString BinaryName() const override;
virtual QString PluginPath() const override;
};
#endif // FALLOUT4SCRIPTEXTENDER_H
+63
View File
@@ -0,0 +1,63 @@
#include "fallout4unmanagedmods.h"
Fallout4LondonUnmangedMods::Fallout4LondonUnmangedMods(const GameGamebryo* game)
: GamebryoUnmangedMods(game)
{}
Fallout4LondonUnmangedMods::~Fallout4LondonUnmangedMods() {}
QStringList Fallout4LondonUnmangedMods::mods(bool onlyOfficial) const
{
QStringList result;
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"})) {
if (!pluginList.contains(fileName, Qt::CaseInsensitive)) {
if (!onlyOfficial || pluginList.contains(fileName, Qt::CaseInsensitive)) {
result.append(fileName.chopped(4)); // trims the extension off
}
}
}
return result;
}
QStringList Fallout4LondonUnmangedMods::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"})) {
archives.append(dataDir.absoluteFilePath(archiveName));
}
return archives;
}
QString Fallout4LondonUnmangedMods::displayName(const QString& modName) const
{
// unlike in earlier games, in fallout 4 the file name doesn't correspond to
// the public name
if (modName.compare("dlcrobot", Qt::CaseInsensitive) == 0) {
return "Automatron";
} else if (modName.compare("dlcworkshop01", Qt::CaseInsensitive) == 0) {
return "Wasteland Workshop";
} else if (modName.compare("dlccoast", Qt::CaseInsensitive) == 0) {
return "Far Harbor";
} else if (modName.compare("dlcworkshop02", Qt::CaseInsensitive) == 0) {
return "Contraptions Workshop";
} else if (modName.compare("dlcworkshop03", Qt::CaseInsensitive) == 0) {
return "Vault-Tec Workshop";
} else if (modName.compare("dlcnukaworld", Qt::CaseInsensitive) == 0) {
return "Nuka-World";
} else if (modName.compare("dlcultrahighresolution", Qt::CaseInsensitive) == 0) {
return "Ultra High Resolution Texture Pack";
} else {
return modName;
}
}

Some files were not shown because too many files have changed in this diff Show More