aboutsummaryrefslogtreecommitdiff
path: root/libs/game_bethesda/src/games/fallout3/gamefallout3.cpp
blob: 75e1ea337768bd91b6fd697b2a4bbf8e6a927d5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#include "gamefallout3.h"

#include "fallout3bsainvalidation.h"
#include "fallout3dataarchives.h"
#include "fallout3moddatachecker.h"
#include "fallout3moddatacontent.h"
#include "fallout3savegame.h"
#include "fallout3scriptextender.h"

#include "executableinfo.h"
#include "pluginsetting.h"
#include "versioninfo.h"
#include <gamebryogameplugins.h>
#include <gamebryolocalsavegames.h>
#include <gamebryosavegameinfo.h>
#include <gamebryounmanagedmods.h>

#include <QCoreApplication>
#include <QDir>
#include <QFileInfo>
#include <QList>
#include <QObject>
#include <QString>
#include <QStringList>

#include <memory>

using namespace MOBase;

GameFallout3::GameFallout3() {}

bool GameFallout3::init(IOrganizer* moInfo)
{
  if (!GameGamebryo::init(moInfo)) {
    return false;
  }

  auto dataArchives = std::make_shared<Fallout3DataArchives>(this);
  registerFeature(std::make_shared<Fallout3ScriptExtender>(this));
  registerFeature(dataArchives);
  registerFeature(std::make_shared<Fallout3BSAInvalidation>(dataArchives.get(), this));
  registerFeature(std::make_shared<GamebryoSaveGameInfo>(this));
  registerFeature(std::make_shared<GamebryoLocalSavegames>(this, "Fallout.ini"));
  registerFeature(std::make_shared<Fallout3ModDataChecker>(this));
  registerFeature(
      std::make_shared<Fallout3ModDataContent>(m_Organizer->gameFeatures()));
  registerFeature(std::make_shared<GamebryoGamePlugins>(moInfo));
  registerFeature(std::make_shared<GamebryoUnmangedMods>(this));
  return true;
}

QString GameFallout3::identifyVariant() const
{
  if (QFile::exists(m_GamePath + "/Fallout3ng.exe")) {
    return "Low Violence";
  } else if (QFile::exists(m_GamePath + "/Galaxy.dll")) {
    return "GOG";
  } else if (QFile::exists(m_GamePath + "/FalloutLauncherEpic.exe")) {
    return "Epic Games";
  } else if (m_GamePath.endsWith("Fallout 3 goty")) {
    return "Steam (Game of the Year)";
  } else {
    return "Steam (Regular)";
  }
}

QString GameFallout3::identifyGamePath() const
{
  // Steam (Regular)
  auto result = parseSteamLocation("22300", "Fallout 3");

  // Steam (Game of the Year)
  if (result.isEmpty()) {
    result = parseSteamLocation("22370", "Fallout 3 goty");
  }

  // Epic Games
  if (result.isEmpty()) {
    // Fallout 3: Game of the Year Edition: adeae8bbfc94427db57c7dfecce3f1d4
    result = parseEpicGamesLocation({"adeae8bbfc94427db57c7dfecce3f1d4"});
    if (QFileInfo(result).isDir()) {
      QDir startPath = QDir(result);
      auto subDirs =
          startPath.entryList({"Fallout 3 GOTY*"}, QDir::Dirs | QDir::NoDotAndDotDot);
      if (!subDirs.isEmpty())
        result = startPath.absoluteFilePath(subDirs.first());
    }
  }

  // GOG (and Steam)
  if (result.isEmpty()) {
    result = GameGamebryo::identifyGamePath();
  }

  return result;
}

QString GameFallout3::gameName() const
{
  return "Fallout 3";
}

void GameFallout3::detectGame()
{
  m_GamePath = identifyGamePath();
  setGameVariant(identifyVariant());
  m_MyGamesPath = determineMyGamesPath("Fallout3");
}

QList<ExecutableInfo> GameFallout3::executables() const
{
  return QList<ExecutableInfo>()
         << ExecutableInfo("FOSE",
                           findInGameFolder(m_Organizer->gameFeatures()
                                                ->gameFeature<MOBase::ScriptExtender>()
                                                ->loaderName()))
         << ExecutableInfo("Fallout 3", findInGameFolder(binaryName()))
         << ExecutableInfo("Fallout Mod Manager", findInGameFolder("fomm/fomm.exe"))
         << ExecutableInfo("Construction Kit", findInGameFolder("geck.exe"))
         << ExecutableInfo("Fallout Launcher", findInGameFolder(getLauncherName()))
         << ExecutableInfo("BOSS", findInGameFolder("BOSS/BOSS.exe"))
         << ExecutableInfo("LOOT", QFileInfo(getLootPath()))
                .withArgument("--game=\"Fallout3\"");
}

QList<ExecutableForcedLoadSetting> GameFallout3::executableForcedLoads() const
{
  return QList<ExecutableForcedLoadSetting>();
}

QString GameFallout3::name() const
{
  return "Fallout 3 Support Plugin";
}

QString GameFallout3::localizedName() const
{
  return tr("Fallout 3 Support Plugin");
}

QString GameFallout3::author() const
{
  return "Tannin";
}

QString GameFallout3::description() const
{
  return tr("Adds support for the game Fallout 3.");
}

MOBase::VersionInfo GameFallout3::version() const
{
  return VersionInfo(1, 4, 1, VersionInfo::RELEASE_FINAL);
}

QList<PluginSetting> GameFallout3::settings() const
{
  return QList<PluginSetting>();
}

void GameFallout3::initializeProfile(const QDir& path, ProfileSettings settings) const
{
  if (settings.testFlag(IPluginGame::MODS)) {
    copyToProfile(localAppFolder() + "/Fallout3", path, "plugins.txt");
    copyToProfile(localAppFolder() + "/Fallout3", path, "loadorder.txt");
  }

  if (settings.testFlag(IPluginGame::CONFIGURATION)) {
    if (settings.testFlag(IPluginGame::PREFER_DEFAULTS) ||
        !QFileInfo(myGamesPath(), "Fallout.ini").exists()) {
      copyToProfile(gameDirectory().absolutePath(), path, "Fallout_default.ini",
                    "Fallout.ini");
    } else {
      copyToProfile(myGamesPath(), path, "Fallout.ini");
    }

    copyToProfile(myGamesPath(), path, "FalloutPrefs.ini");
    copyToProfile(myGamesPath(), path, "FalloutCustom.ini");
    copyToProfile(myGamesPath(), path, "custom.ini");
    copyToProfile(myGamesPath(), path, "GECKCustom.ini");
    copyToProfile(myGamesPath(), path, "GECKPrefs.ini");
  }
}

QString GameFallout3::savegameExtension() const
{
  return "fos";
}

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() == "Steam (Game Of The Year)") {
    return "22370";
  } else if (selectedVariant() == "Steam (Regular)") {
    return "22300";
  } else {
    return "";
  }
}

QStringList GameFallout3::primaryPlugins() const
{
  return {"fallout3.esm"};
}

QStringList GameFallout3::gameVariants() const
{
  return {"Steam (Regular)", "Steam (Game Of The Year)", "Epic Games", "GOG",
          "Low Violence"};
}

QString GameFallout3::binaryName() const
{
  if (selectedVariant() == "Low Violence") {
    return "Fallout3ng.exe";
  } else {
    return GameGamebryo::binaryName();
  }
}

QString GameFallout3::gameShortName() const
{
  return "Fallout3";
}

QStringList GameFallout3::validShortNames() const
{
  return {"FalloutNV"};
}

QString GameFallout3::gameNexusName() const
{
  return "fallout3";
}

QStringList GameFallout3::iniFiles() const
{
  return {"Fallout.ini", "FalloutPrefs.ini", "FalloutCustom.ini", "GECKCustom.ini",
          "GECKPrefs.ini"};
}

QStringList GameFallout3::DLCPlugins() const
{
  return {"ThePitt.esm", "Anchorage.esm", "BrokenSteel.esm", "PointLookout.esm",
          "Zeta.esm"};
}

int GameFallout3::nexusModOrganizerID() const
{
  return 16348;
}

int GameFallout3::nexusGameID() const
{
  return 120;
}

QString GameFallout3::getLauncherName() const
{
  const QMap<QString, QString> names = {
      {"Steam (Regular)", "Fallout3Launcher.exe"},
      {"Steam (Game of the Year)", "Fallout3Launcher.exe"},
      {"Epic Games", "FalloutLauncherEpic.exe"},
      {"GOG", "FalloutLauncher.exe"},
      {"Low Violence", "Fallout3Launcher.exe"}};

  return names.value(selectedVariant());
}