2022-03-16 18:39:13 -04:00
|
|
|
#include "gameinstaller.h"
|
|
|
|
|
2022-08-15 11:14:37 -04:00
|
|
|
#include <QFile>
|
2022-03-16 18:39:13 -04:00
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QStandardPaths>
|
2022-07-21 20:53:19 -04:00
|
|
|
#include <physis.hpp>
|
2022-03-16 18:39:13 -04:00
|
|
|
|
|
|
|
#include "launchercore.h"
|
2023-07-30 08:49:34 -04:00
|
|
|
#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();
|
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"));
|
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
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);
|
2022-03-16 18:39:13 -04:00
|
|
|
|
|
|
|
QFile file(dataDir + "/ffxivsetup.exe");
|
|
|
|
file.open(QIODevice::WriteOnly);
|
|
|
|
file.write(reply->readAll());
|
|
|
|
file.close();
|
|
|
|
|
2023-05-13 17:37:30 -04:00
|
|
|
const std::string installDirectoryStd = installDirectory.toStdString();
|
|
|
|
const std::string fileNameStd = file.fileName().toStdString();
|
|
|
|
|
|
|
|
physis_install_game(fileNameStd.c_str(), installDirectoryStd.c_str());
|
2022-03-16 18:39:13 -04:00
|
|
|
|
2022-04-14 16:29:23 -04:00
|
|
|
qDebug() << "Done installing to " << installDirectory << "!";
|
2022-03-16 18:39:13 -04:00
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_EMIT installFinished();
|
2022-03-16 18:39:13 -04:00
|
|
|
});
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|