#ifndef LEGACYAPP_H
#define LEGACYAPP_H

#include <QObject>
#include <QSettings>
#include <QApplication>

#include <LotroDat/LotroDat.h>

class PatchDownloader;

class LotroDatManager : public QObject
{
    Q_OBJECT

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

    bool Initialised();

    bool NotPatched();

    bool IsRusificationActive();

public slots:
    void InitialiseManager();

    void DeinitialiseManager();

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

    void ChangeTranslationLanguage();

    void InstallActivePatches();

    void InstallPatches();

    void InstallLoadscreens();

    void InstallVideos();

    void InstallUpdates();

    void InstallMicroPatch();

    void CreateBackup();

    void RestoreFromBackup();

    void RemoveBackup();

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

signals:
    void textStatusChanged();
    void imagesStatusChanged();
    void soundsStatusChanged();
    void generalStatusChanged();

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

private:
    LOTRO_DAT::DatFile client_local_file;
    LOTRO_DAT::DatFile client_general_file;
    QSettings* app_settings;
    PatchDownloader* patch_downloader;
};

#endif // LEGACYAPP_H
