1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-21 04:07:46 +00:00
astra/launcher/core/src/gameinstaller.cpp

34 lines
1.1 KiB
C++
Raw Normal View History

#include "gameinstaller.h"
2022-08-15 11:14:37 -04:00
#include <QFile>
#include <QNetworkReply>
#include <QStandardPaths>
#include <physis.hpp>
#include "launchercore.h"
void installGame(LauncherCore& launcher, ProfileSettings& profile, std::function<void()> returnFunc) {
QString installDirectory = profile.gamePath;
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] {
2022-08-15 11:14:37 -04:00
QString dataDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
QFile file(dataDir + "/ffxivsetup.exe");
file.open(QIODevice::WriteOnly);
file.write(reply->readAll());
file.close();
2022-08-15 11:14:37 -04:00
physis_install_game(
installDirectory.toStdString().c_str(), (dataDir + "/ffxivsetup.exe").toStdString().c_str());
qDebug() << "Done installing to " << installDirectory << "!";
returnFunc();
});
}