#ifndef LEGACYAPP_H
#define LEGACYAPP_H

#include <QObject>
#include <QSettings>
#include <QApplication>
#include <QVector>
#include <QVariant>

#include <LotroDat/LotroDat.h>

class PatchDownloader;

class LotroDatManager : public QObject
{
    Q_OBJECT

public:
    explicit LotroDatManager(QSettings* settings, QObject *parent = nullptr);

    bool Initialised();

    bool NotPatched();

// TODO:
//    bool IsRusificationActive();

    unsigned getPercent();

    QString getCurrentInstallingPatchName();

public slots:
    void InitialiseManager();

    void DeinitialiseManager();

    void StartGame(LOTRO_DAT::DatLocaleManager::LOCALE locale);

    void ChangeTranslationLanguage();

    void InstallActivePatches();

    void SetupAllPatches();

    void InstallUpdates();

    void InstallMicroPatch();

    void CreateBackup();

    void RestoreFromBackup();

    void RemoveBackup();

private:
    bool startLotroLauncherWithParameters(LOTRO_DAT::DatLocaleManager::LOCALE locale);
    void ApplyTexts();
    void ApplyImages();
    void ApplySounds();
    void InstallLoadscreens();
    void InstallVideos();

signals:
    // general signals. First argument is process_name, second - processed values
    void processStarted(QString, QVector<QVariant> parameters = QVector<QVariant>());
    void processFinished(QString, QVector<QVariant> parameters = QVector<QVariant>());
    void progressChanged();
    void caughtError(QString, QVector<QVariant>);

private:
    const QStringList all_patch_names = {"sound", "text", "image", "loadscreen", "texture", "font", "video"};

    QString current_installing_patch_name;
    int video_percent;
    int loadscreens_percent;

    LOTRO_DAT::DatFile client_local_file;
    LOTRO_DAT::DatFile client_general_file;
    QSettings* app_settings;
};

#endif // LEGACYAPP_H
