2023-08-05 22:14:05 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-07-20 18:00:42 -04:00
|
|
|
#pragma once
|
|
|
|
|
2023-08-18 14:52:06 -04:00
|
|
|
#include <QDir>
|
2022-07-20 18:00:42 -04:00
|
|
|
#include <QNetworkAccessManager>
|
2022-08-15 11:14:37 -04:00
|
|
|
#include <QString>
|
2022-08-09 22:44:10 -04:00
|
|
|
#include <physis.hpp>
|
2022-07-20 18:00:42 -04:00
|
|
|
|
2023-07-30 14:56:24 -04:00
|
|
|
class LauncherCore;
|
|
|
|
|
2022-07-20 18:00:42 -04:00
|
|
|
// General-purpose patcher routine. It opens a nice dialog box, handles downloading
|
|
|
|
// and processing patches.
|
2023-07-30 08:49:34 -04:00
|
|
|
class Patcher : public QObject
|
|
|
|
{
|
2022-07-20 18:00:42 -04:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2023-07-30 14:56:24 -04:00
|
|
|
Patcher(LauncherCore &launcher, QString baseDirectory, GameData *game_data, QObject *parent = nullptr);
|
|
|
|
Patcher(LauncherCore &launcher, QString baseDirectory, BootData *game_data, QObject *parent = nullptr);
|
2022-07-20 18:00:42 -04:00
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
void processPatchList(QNetworkAccessManager &mgr, const QString &patchList);
|
2022-07-20 18:00:42 -04:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void done();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void checkIfDone();
|
2023-08-18 14:52:06 -04:00
|
|
|
void setupDirectories();
|
2022-07-20 18:00:42 -04:00
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
[[nodiscard]] bool isBoot() const
|
|
|
|
{
|
2022-08-09 22:44:10 -04:00
|
|
|
return boot_data != nullptr;
|
|
|
|
}
|
|
|
|
|
2022-07-20 18:00:42 -04:00
|
|
|
struct QueuedPatch {
|
|
|
|
QString name, repository, version, path;
|
2023-07-30 14:56:24 -04:00
|
|
|
QStringList hashes;
|
|
|
|
long hashBlockSize;
|
|
|
|
long length;
|
2022-07-20 18:00:42 -04:00
|
|
|
};
|
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
void processPatch(const QueuedPatch &patch);
|
2022-07-20 18:00:42 -04:00
|
|
|
|
|
|
|
QVector<QueuedPatch> patchQueue;
|
|
|
|
|
2023-08-18 14:52:06 -04:00
|
|
|
QDir patchesDir;
|
2022-07-20 18:00:42 -04:00
|
|
|
QString baseDirectory;
|
2023-07-30 08:49:34 -04:00
|
|
|
BootData *boot_data = nullptr;
|
|
|
|
GameData *game_data = nullptr;
|
2022-07-20 18:00:42 -04:00
|
|
|
|
|
|
|
int remainingPatches = -1;
|
2023-07-30 14:56:24 -04:00
|
|
|
|
|
|
|
LauncherCore &m_launcher;
|
2022-07-20 18:00:42 -04:00
|
|
|
};
|