1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 19:57:45 +00:00
astra/launcher/src/gameinstaller.cpp

45 lines
1.3 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"
#include "profile.h"
GameInstaller::GameInstaller(LauncherCore &launcher, Profile &profile, QObject *parent)
: QObject(parent)
, m_launcher(launcher)
, m_profile(profile)
{
}
void GameInstaller::installGame()
{
const QString installDirectory = m_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 = m_launcher.mgr->get(request);
QObject::connect(reply, &QNetworkReply::finished, [this, reply, installDirectory] {
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();
const std::string installDirectoryStd = installDirectory.toStdString();
const std::string fileNameStd = file.fileName().toStdString();
physis_install_game(fileNameStd.c_str(), installDirectoryStd.c_str());
qDebug() << "Done installing to " << installDirectory << "!";
Q_EMIT installFinished();
});
}