2022-03-16 18:39:13 -04:00
|
|
|
#include "gameinstaller.h"
|
|
|
|
|
|
|
|
#include <installextract.h>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QStandardPaths>
|
|
|
|
#include <QFile>
|
|
|
|
|
|
|
|
#include "launchercore.h"
|
|
|
|
|
2022-04-14 16:29:23 -04:00
|
|
|
void installGame(LauncherCore& launcher, ProfileSettings& profile, std::function<void()> returnFunc) {
|
|
|
|
QString installDirectory = profile.gamePath;
|
2022-03-16 18:39:13 -04:00
|
|
|
qDebug() << "Installing game to " << installDirectory << "!";
|
|
|
|
|
|
|
|
qDebug() << "Now downloading installer file...";
|
|
|
|
|
|
|
|
QNetworkRequest request(QUrl("https://gdl.square-enix.com/ffxiv/inst/ffxivsetup.exe"));
|
|
|
|
|
|
|
|
auto reply = launcher.mgr->get(request);
|
|
|
|
launcher.connect(reply, &QNetworkReply::finished, [reply, installDirectory, returnFunc] {
|
|
|
|
QString dataDir =
|
|
|
|
QStandardPaths::writableLocation(QStandardPaths::TempLocation);
|
|
|
|
|
|
|
|
QFile file(dataDir + "/ffxivsetup.exe");
|
|
|
|
file.open(QIODevice::WriteOnly);
|
|
|
|
file.write(reply->readAll());
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
extractBootstrapFiles((dataDir + "/ffxivsetup.exe").toStdString(), installDirectory.toStdString());
|
|
|
|
|
2022-04-14 16:29:23 -04:00
|
|
|
qDebug() << "Done installing to " << installDirectory << "!";
|
2022-03-16 18:39:13 -04:00
|
|
|
|
|
|
|
returnFunc();
|
|
|
|
});
|
|
|
|
}
|