1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-21 20:27:45 +00:00
astra/launcher/include/patcher.h

66 lines
1.6 KiB
C
Raw Normal View History

// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include "patchlist.h"
#include <QDir>
#include <QNetworkAccessManager>
2022-08-15 11:14:37 -04:00
#include <QString>
2022-08-09 22:44:10 -04:00
#include <physis.hpp>
2023-09-16 20:12:42 -04:00
#include <qcorotask.h>
class LauncherCore;
// General-purpose patcher routine. It opens a nice dialog box, handles downloading
// and processing patches.
class Patcher : public QObject
{
Q_OBJECT
2023-09-17 08:32:47 -04:00
public:
2023-09-16 21:18:50 -04:00
Patcher(LauncherCore &launcher, const QString &baseDirectory, GameData &gameData, QObject *parent = nullptr);
Patcher(LauncherCore &launcher, const QString &baseDirectory, BootData &bootData, QObject *parent = nullptr);
QCoro::Task<bool> patch(const PatchList &patchList);
private:
void setupDirectories();
2023-09-16 21:18:50 -04:00
[[nodiscard]] QString getBaseString() const;
[[nodiscard]] bool isBoot() const
{
2023-09-16 21:18:50 -04:00
return m_bootData != nullptr;
2022-08-09 22:44:10 -04:00
}
struct QueuedPatch {
QString name, repository, version, path;
QStringList hashes;
long hashBlockSize;
long length;
2023-09-16 20:30:34 -04:00
bool isBoot;
2023-09-16 21:18:50 -04:00
[[nodiscard]] QString getVersion() const
2023-09-16 20:30:34 -04:00
{
if (isBoot) {
return QStringLiteral("ffxivboot - %1").arg(name);
} else {
return QStringLiteral("%1 - %2").arg(repository, name);
}
}
};
void processPatch(const QueuedPatch &patch);
2023-09-16 21:18:50 -04:00
QVector<QueuedPatch> m_patchQueue;
2023-09-16 21:18:50 -04:00
QDir m_patchesDir;
QString m_baseDirectory;
BootData *m_bootData = nullptr;
GameData *m_gameData = nullptr;
2023-09-16 21:18:50 -04:00
int m_remainingPatches = -1;
LauncherCore &m_launcher;
2023-09-16 20:30:34 -04:00
};