#ifndef LEGACYAPP_H
#define LEGACYAPP_H

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

#include <LotroDat/LotroDat.h>

class LotroDatManager : public QObject
{
    Q_OBJECT

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

    bool initialised();

    int currentLocale();

    bool notPatched();

public slots:
    void initialiseDatFile(QString file_path);

    void deinitialiseDatFile();

    void changeLocale();

    void getLocaleFileContents(long long file_id, int locale);

    void importFilesFromDatabase(QString database_path);

    void importFile(long long file_id, QString file_path);

    void importTextFragment(long long file_id, long long fragment_id, QString fragment_contents, QString arguments);

    void getTextFragment(long long file_id, long long fragment_id);

    void createCoreStatusFile(QString output_filename);

    void extractSingleFile(QString output_filename, long long file_id);

    void extractSingleFileToDatabase(QString database_path, long long file_id);

    void extractGrouppedFiles(QString output_foldername, LOTRO_DAT::FILE_TYPE type);

    void extractGrouppedFilesToDatabase(QString database_path, LOTRO_DAT::FILE_TYPE type);

    void getUnactiveCategories();

    void startGame();

    void getLocaleFileInfo(long long file_id, int locale);

    void getFileInfo(long long file_id);

    void disableCategory(long long category_id);

    void enableCategory(long long category_id);

    LOTRO_DAT::DatStatus *getStatusModule();

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

    void textFragmentReceived(QString, QString);
    void unactiveCategoriesReceived(QStringList);
    void localeFileContentsReceived(int, LOTRO_DAT::SubfileData); // extention, contents
    void localeFileInfoReceived(int, QString);
    void fileInfoReceived(QString);
private:
    LOTRO_DAT::DatFile file;
    QSettings* app_settings;
};

#endif // LEGACYAPP_H
