aboutsummaryrefslogtreecommitdiff
path: root/libs/game_bethesda/src/games/fallout4vr/gamefallout4vr.cpp
blob: e0e5e38ef3c1762f51ddf66d686d831c2ecfc64d (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
#include "gamefallout4vr.h"

#include "fallout4vrdataarchives.h"
#include "fallout4vrgameplugins.h"
#include "fallout4vrmoddatachecker.h"
#include "fallout4vrmoddatacontent.h"
#include "fallout4vrsavegame.h"
#include "fallout4vrunmanagedmods.h"

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

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

#include <memory>

#include "scopeguard.h"

using namespace MOBase;

GameFallout4VR::GameFallout4VR() {}

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

  registerFeature(std::make_shared<Fallout4VRDataArchives>(this));
  registerFeature(std::make_shared<GamebryoLocalSavegames>(this, "Fallout4Custom.ini"));
  registerFeature(std::make_shared<Fallout4VRModDataChecker>(this));
  registerFeature(
      std::make_shared<Fallout4VRModDataContent>(m_Organizer->gameFeatures()));
  registerFeature(std::make_shared<GamebryoSaveGameInfo>(this));
  registerFeature(std::make_shared<Fallout4VRGamePlugins>(moInfo));
  registerFeature(std::make_shared<Fallout4VRUnmangedMods>(this));

  return true;
}

QString GameFallout4VR::gameName() const
{
  return "Fallout 4 VR";
}

void GameFallout4VR::detectGame()
{
  m_GamePath    = identifyGamePath();
  m_MyGamesPath = determineMyGamesPath("Fallout4VR", !m_GamePath.isEmpty());
}

QList<ExecutableInfo> GameFallout4VR::executables() const
{
  return QList<ExecutableInfo>()
         << ExecutableInfo("Fallout 4 VR", findInGameFolder(binaryName()))
         << ExecutableInfo("Creation Kit", findInGameFolder("CreationKit.exe"))
         << ExecutableInfo("LOOT", QFileInfo(getLootPath()))
                .withArgument("--game=\"Fallout4VR\"");
}

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

QString GameFallout4VR::name() const
{
  return "Fallout 4 VR Support Plugin";
}

QString GameFallout4VR::localizedName() const
{
  return tr("Fallout 4 VR Support Plugin");
}

QString GameFallout4VR::author() const
{
  return "MO2 Contibutors";
}

QString GameFallout4VR::description() const
{
  return tr("Adds support for the game Fallout 4 VR.\n"
            "Splash by %1")
      .arg("nekoyoubi");
}

MOBase::VersionInfo GameFallout4VR::version() const
{
  return VersionInfo(1, 6, 1, VersionInfo::RELEASE_FINAL);
}

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

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

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

    copyToProfile(myGamesPath(), path, "Fallout4Prefs.ini");
    copyToProfile(myGamesPath(), path, "Fallout4Custom.ini");
  }
}

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

QString GameFallout4VR::savegameSEExtension() const
{
  return "f4se";
}

std::shared_ptr<const GamebryoSaveGame>
GameFallout4VR::makeSaveGame(QString filePath) const
{
  return std::make_shared<const Fallout4VRSaveGame>(filePath, this);
}

QString GameFallout4VR::steamAPPId() const
{
  return "611660";
}

QStringList GameFallout4VR::primaryPlugins() const
{
  QStringList plugins = {"fallout4.esm", "fallout4_vr.esm"};

  plugins.append(CCPlugins());

  return plugins;
}

QStringList GameFallout4VR::gameVariants() const
{
  return {"Regular"};
}

QString GameFallout4VR::gameShortName() const
{
  return "Fallout4VR";
}

QStringList GameFallout4VR::validShortNames() const
{
  return {"Fallout4"};
}

QString GameFallout4VR::gameNexusName() const
{
  return QString();
}

QStringList GameFallout4VR::iniFiles() const
{
  return {"Fallout4.ini", "Fallout4Custom.ini", "Fallout4Prefs.ini"};
}

QStringList GameFallout4VR::DLCPlugins() const
{
  return {"dlcrobot.esm",
          "dlcworkshop01.esm",
          "dlccoast.esm",
          "dlcworkshop02.esm",
          "dlcworkshop03.esm",
          "dlcnukaworld.esm",
          "dlcultrahighresolution.esm"};
}

QStringList GameFallout4VR::CCPlugins() const
{
  QStringList plugins = {};
  QFile file(gameDirectory().absoluteFilePath("Fallout4.ccc"));
  if (file.open(QIODevice::ReadOnly)) {
    ON_BLOCK_EXIT([&file]() {
      file.close();
    });

    if (file.size() == 0) {
      return plugins;
    }
    while (!file.atEnd()) {
      QByteArray line = file.readLine().trimmed();
      QString modName;
      if ((line.size() > 0) && (line.at(0) != '#')) {
        modName = QString::fromUtf8(line.constData()).toLower();
      }

      if (modName.size() > 0) {
        if (!plugins.contains(modName, Qt::CaseInsensitive)) {
          plugins.append(modName);
        }
      }
    }
  }
  return plugins;
}

IPluginGame::LoadOrderMechanism GameFallout4VR::loadOrderMechanism() const
{
  return IPluginGame::LoadOrderMechanism::PluginsTxt;
}

int GameFallout4VR::nexusModOrganizerID() const
{
  return 0;  //...
}

int GameFallout4VR::nexusGameID() const
{
  return 0;
}

QString GameFallout4VR::getLauncherName() const
{
  return binaryName();  // Fallout 4 VR has no Launcher, so we just return the name of
                        // the game binary
}

QString GameFallout4VR::identifyGamePath() const
{
#ifdef _WIN32
  QString path = "Software\\Bethesda Softworks\\" + gameName();
  return findInRegistry(HKEY_LOCAL_MACHINE, path.toStdWString().c_str(),
                        L"Installed Path");
#else
  return GameGamebryo::identifyGamePath();
#endif
}