Browse Source

Moved to new lotro dat library interface

Ivan Arkhipov 3 years ago
parent
commit
0d5ea42b8e
42 changed files with 725 additions and 1701 deletions
  1. 1 1
      Legacy_v2.pro
  2. 65 75
      import/LotroDat/BinaryData.h
  3. 60 78
      import/LotroDat/DatFile.h
  4. 0 86
      import/LotroDat/DatOperationResult.h
  5. 0 56
      import/LotroDat/DatSubsystems/DatBackupManager.h
  6. 0 50
      import/LotroDat/DatSubsystems/DatExporter.h
  7. 0 92
      import/LotroDat/DatSubsystems/DatFileSystem.h
  8. 0 105
      import/LotroDat/DatSubsystems/DatIO.h
  9. 0 94
      import/LotroDat/DatSubsystems/DatLocaleManager.h
  10. 0 51
      import/LotroDat/DatSubsystems/DatPatcher.h
  11. 0 132
      import/LotroDat/DatSubsystems/DatStatus.h
  12. 58 62
      import/LotroDat/Database.h
  13. 0 17
      import/LotroDat/LotroDat.h
  14. 0 37
      import/LotroDat/SubDirectory.h
  15. 44 88
      import/LotroDat/SubFile.h
  16. 46 46
      import/LotroDat/SubfileData.h
  17. 19 29
      import/LotroDat/Subfiles/DdsSubFile.h
  18. 19 33
      import/LotroDat/Subfiles/FontSubFile.h
  19. 19 33
      import/LotroDat/Subfiles/JpgSubFile.h
  20. 19 28
      import/LotroDat/Subfiles/OggSubFile.h
  21. 50 75
      import/LotroDat/Subfiles/TextSubFile.h
  22. 19 32
      import/LotroDat/Subfiles/UnknownSubFile.h
  23. 19 32
      import/LotroDat/Subfiles/WavSubFile.h
  24. 115 0
      import/LotroDat/datexportapi.h
  25. 0 1
      src/Legacy/Legacy.pro
  26. 1 1
      src/Legacy/legacyapplication.cpp
  27. 111 274
      src/Legacy/models/lotrodatmanager.cpp
  28. 20 36
      src/Legacy/models/lotrodatmanager.h
  29. 0 3
      src/Legacy/models/patch/graphicspatch.cpp
  30. 0 1
      src/Legacy/models/patch/graphicspatch.h
  31. 2 2
      src/Legacy/models/patch/patch.cpp
  32. 0 2
      src/Legacy/models/patch/soundspatch.cpp
  33. 0 2
      src/Legacy/models/patch/textspatch.cpp
  34. 0 2
      src/Legacy/models/patch/videospatch.cpp
  35. 1 2
      src/Legacy/widgets/aboutwidget.cpp
  36. 1 3
      src/Legacy/widgets/aboutwidget.h
  37. 2 2
      src/Legacy/widgets/chooseversiondialog.cpp
  38. 1 2
      src/Legacy/widgets/helpwidget.cpp
  39. 1 3
      src/Legacy/widgets/helpwidget.h
  40. 10 10
      src/Legacy/widgets/mainwindow.cpp
  41. 3 4
      src/Legacy/widgets/mainwindow.h
  42. 19 19
      src/Legacy/widgets/settingswidget.cpp

+ 1 - 1
Legacy_v2.pro

@@ -16,5 +16,5 @@ TEMPLATE = subdirs
 SUBDIRS += \
     src/Launcher \
     src/Legacy \ 
-    src/Legacy-advanced \
+#    src/Legacy-advanced \
     src/LegacyLauncher

+ 65 - 75
import/LotroDat/BinaryData.h

@@ -1,75 +1,65 @@
-//
-// Created by Иван_Архипов on 31.10.2017.
-//
-
-#include <vector>
-
-#ifndef LOTRO_DAT_PATCHER_BINARYDATA_H
-#define LOTRO_DAT_PATCHER_BINARYDATA_H
-
-#include <cstdio>
-#include <string>
-
-extern  "C++"
-{
-namespace LOTRO_DAT
-{
-    class Database;
-
-    class BinaryData
-    {
-    public:
-        BinaryData();
-        BinaryData(const BinaryData &d);
-        BinaryData(BinaryData&& other) noexcept;
-        BinaryData(const char* data, unsigned int size);
-        explicit BinaryData(unsigned int size);
-        ~BinaryData();
-
-        unsigned char& operator[] (const unsigned int &pos);
-        BinaryData operator +(const BinaryData &b);
-
-        bool operator == (const BinaryData &b) const;
-        bool operator != (const BinaryData &b) const;
-        bool Empty() const;
-
-        void Append(const BinaryData &b, size_t offset = 0);
-
-        template <unsigned int T>
-        long long ToNumber(const long long &pos) const;
-
-        template <unsigned int T>
-        long long ToNumberRAW(const long long &pos) const;
-
-        template <unsigned int T>
-        static BinaryData FromNumber(const long long &number);
-
-        template <unsigned int T>
-        static BinaryData FromNumberRAW(const long long &number);
-
-        size_t size() const;
-        unsigned char* data() const;
-
-        BinaryData& operator=(const BinaryData& data);
-
-        BinaryData CutData(long long first = 0, long long last = -1) const;
-
-		bool WriteToFile(const char *filename) const;
-		bool WriteToFile(const std::string &filename) const;
-
-        void ReadFromFile(const char *filename);
-
-        void ReadFromFile(const std::string &filename);
-
-        bool CheckCompression() const;
-		BinaryData DecompressData(unsigned int offset = 0) const;
-        BinaryData CompressData(unsigned int offset = 0) const;
-
-    private:
-        unsigned char *data_;
-        size_t size_;
-    };
-}
-}
-
-#endif //LOTRO_DAT_PATCHER_BINARYDATA_H
+#ifndef LOTRO_DAT_BINARYDATA_H
+#define LOTRO_DAT_BINARYDATA_H
+
+#include <cstdio>
+#include <vector>
+#include <string>
+
+namespace LOTRO_DAT
+{
+    class Database;
+
+    class BinaryData
+    {
+    public:
+        BinaryData();
+        BinaryData(const BinaryData &d);
+        BinaryData(BinaryData&& other) noexcept;
+        BinaryData(const char* data, unsigned int size);
+        explicit BinaryData(unsigned int size);
+        ~BinaryData();
+
+        unsigned char& operator[] (const unsigned int &pos);
+        const unsigned char& operator[] (const unsigned int &pos) const;
+
+        BinaryData operator +(const BinaryData &b);
+
+        bool operator == (const BinaryData &b) const;
+        bool operator != (const BinaryData &b) const;
+        bool Empty() const;
+
+        void Append(const BinaryData &b, size_t offset = 0);
+
+        template <unsigned int T>
+        long long ToNumber(const long long &pos) const;
+
+        template <unsigned int T>
+        long long ToNumberRAW(const long long &pos) const;
+
+        template <unsigned int T>
+        static BinaryData FromNumber(const long long &number);
+
+        template <unsigned int T>
+        static BinaryData FromNumberRAW(const long long &number);
+
+        size_t size() const;
+        unsigned char* data() const;
+
+        BinaryData& operator=(const BinaryData& data);
+
+        BinaryData CutData(long long first = 0, long long last = -1) const;
+
+		bool WriteToFile(const char *filename) const;
+		bool WriteToFile(const std::string &filename) const;
+
+        void ReadFromFile(const char *filename);
+
+        void ReadFromFile(const std::string &filename);
+
+    private:
+        unsigned char *data_;
+        size_t size_;
+    };
+} // namespace LOTRO_DAT
+
+#endif //LOTRO_DAT_BINARYDATA_H

+ 60 - 78
import/LotroDat/DatFile.h

@@ -1,78 +1,60 @@
-//
-// Created by Иван_Архипов on 31.10.2017.
-//
-
-#ifndef LOTRO_DAT_PATCHER_DATFILE_H
-#define LOTRO_DAT_PATCHER_DATFILE_H
-
-#ifdef LOTRO_DAT_EXPORTS
-#define LOTRO_DAT_API __declspec(dllexport)
-#else
-#define LOTRO_DAT_API __declspec(dllimport)
-#endif
-
-#include <bits/unique_ptr.h>
-#include "DatSubsystems/DatBackupManager.h"
-#include "DatSubsystems/DatExporter.h"
-#include "DatSubsystems/DatFileSystem.h"
-#include "DatSubsystems/DatIO.h"
-#include "DatSubsystems/DatLocaleManager.h"
-#include "DatSubsystems/DatPatcher.h"
-#include "DatSubsystems/DatStatus.h"
-
-// Dat file names definitions
-
-extern "C++"
-{
-namespace LOTRO_DAT {
-    enum FILE_TYPE : int {
-        NO_TYPE = 0,
-        TEXT = 1,
-        JPG = 2,
-        DDS = 4,
-        WAV = 8,
-        OGG = 16,
-        FONT = 32,
-        UNKNOWN = 64
-    };
-
-    class DatFile {
-
-    public:
-        DatFile();
-        DatFile(const DatFile &other) = delete;
-        DatFile(DatFile &&other) = default;
-        DatFile &operator=(const DatFile &other) = delete;
-        DatFile &operator=(DatFile &&other) = default;
-        ~DatFile();
-
-        DatLocaleManager &GetLocaleManager();
-        DatExporter &GetExporter();
-        DatPatcher &GetPatcher();
-        DatBackupManager &GetBackupManager();
-        DatIO &GetIO();
-        DatFileSystem &GetFileSystem();
-        DatStatus &GetStatusModule();
-
-        DatOperationResult<> Initialise(const std::string &filename, long long dat_id);
-        DatOperationResult<> GatherInformation(const std::string &output_filename);
-        DatOperationResult<> Deinitialize();
-        bool Initialized();
-        long long GetDatID();
-
-    private:
-        std::unique_ptr<DatIO> io_;
-        std::unique_ptr<DatFileSystem> fileSystem_;
-        std::unique_ptr<DatLocaleManager> localeManager_;
-        std::unique_ptr<DatPatcher> patcher_;
-        std::unique_ptr<DatExporter> exporter_;
-        std::unique_ptr<DatBackupManager> backupManager_;
-        std::unique_ptr<DatStatus> status_;
-
-        bool initialized_;
-        long long dat_id_;
-    };
-}
-}
-
-#endif //LOTRO_DAT_PATCHER_DATFILE_H
+#include "datexportapi.h"
+#include "database.h"
+#include "subfile.h"
+
+#include <string>
+#include <functional>
+
+
+namespace LOTRO_DAT {
+
+struct SubfileInfo {
+	int file_id;
+	int size;
+	int iteration;
+
+	friend bool operator<(const SubfileInfo& info1, const SubfileInfo& info2) {
+		return info1.file_id < info2.file_id;
+	}
+};
+
+class DatFile;
+
+typedef std::function<void (const SubfileInfo&)> SubfileOperation;
+
+class DatFile {
+  public:
+  	DatFile(int file_handle);
+  	~DatFile();
+  	bool Init(const std::string& filename);
+	void LoadAllFilesInfo();
+  	void Deinit();
+
+	bool Initialized() const;
+	const std::string& GetFilename() const;
+	size_t GetFilesNumInDatFile();
+
+  	size_t PatchAllFilesFromDatabase(Database& db);
+	void PatchFile(SubfileData file_data);
+  	void PatchFile(int file_id, FILE_TYPE type, std::string path_to_file);
+
+	FILE_TYPE GetExistingFileType(int file_id);
+	void PerformOperationOnAllSubfiles(const SubfileOperation& operation);
+
+  	int ExportFilesByType(FILE_TYPE type, Database& db);
+  	int ExportFilesByType(FILE_TYPE type, std::string path_to_directory);
+  	
+  	void ExportFileById(int file_id, Database& db);
+	void ExportFileById(int file_id, std::string target_file_path);
+
+  private:
+  	static DatExportApi api_;
+  	int file_handle_;
+  	bool initialized_;
+	std::set<SubfileInfo> files_info_;
+	std::string filename_;
+
+  	BinaryData export_data_buf_;
+};
+
+} // namespace LOTRO_DAT

+ 0 - 86
import/LotroDat/DatOperationResult.h

@@ -1,86 +0,0 @@
-//
-// Created by kikab on 04.06.2018.
-//
-
-#ifndef LOTRO_DAT_LIBRARY_DATOPERATIONRESULT_H
-#define LOTRO_DAT_LIBRARY_DATOPERATIONRESULT_H
-
-#include <string>
-#include <memory>
-#include <utility>
-#include "BinaryData.h"
-#include <EasyLogging++/easylogging++.h>
-
-extern "C++"
-{
-namespace LOTRO_DAT {
-    enum DAT_OPERATION_RESULT {
-        SUCCESS = 1,
-        ERROR = 0
-    };
-
-    template<typename... OutputData>
-    class DatOperationResult {
-        typedef DAT_OPERATION_RESULT RESULT;
-    };
-
-    class __DatOperationResult_base {
-    public:
-        typedef DAT_OPERATION_RESULT RESULT;
-
-        __DatOperationResult_base() : result(SUCCESS), msg("No message") {}
-
-        __DatOperationResult_base(const __DatOperationResult_base &other) = default;
-
-        __DatOperationResult_base(__DatOperationResult_base &&other) noexcept = default;
-
-        __DatOperationResult_base(RESULT result_, std::string msg_) : result(result_), msg(std::move(msg_)) {
-            if (result_ == ERROR)
-                LOG(ERROR) << msg;
-        }
-
-        __DatOperationResult_base &operator=(const __DatOperationResult_base &other) = default;
-
-        __DatOperationResult_base &operator=(__DatOperationResult_base &&other) = default;
-
-        RESULT result;
-        std::string msg;
-    };
-
-    template<>
-    class DatOperationResult<> : public __DatOperationResult_base {
-    public:
-
-        DatOperationResult() : __DatOperationResult_base() {}
-
-        explicit DatOperationResult(RESULT result_) : __DatOperationResult_base(result_, "No message") {}
-
-        DatOperationResult(RESULT result_, std::string msg_) : __DatOperationResult_base(result_, std::move(msg_)) {}
-    };
-
-
-    template<typename Output>
-    class DatOperationResult<Output> : public __DatOperationResult_base {
-    public:
-        typedef DAT_OPERATION_RESULT RESULT;
-
-        DatOperationResult() = delete;
-
-        DatOperationResult(const DatOperationResult<Output> &other) : __DatOperationResult_base(), value(other.value) {}
-
-        DatOperationResult(DatOperationResult<Output> &&other) noexcept
-                : __DatOperationResult_base(), value(std::move(other.value)) {}
-
-        DatOperationResult(Output &&output_, RESULT result_, const std::string &msg_ = std::string("No message provided")) : __DatOperationResult_base(
-                result_, msg_), value(output_) {}
-
-        DatOperationResult(const Output &output_, RESULT result_, const std::string &msg_ = std::string("No message provided")) : __DatOperationResult_base(
-                result_, msg_), value(output_) {}
-
-        Output value;
-    };
-
-}
-}
-
-#endif //LOTRO_DAT_LIBRARY_DATOPERATIONRESULT_H

+ 0 - 56
import/LotroDat/DatSubsystems/DatBackupManager.h

@@ -1,56 +0,0 @@
-//
-// Created by kikab on 04.06.2018.
-//
-
-#ifndef LOTRO_DAT_LIBRARY_DATBACKUP_H
-#define LOTRO_DAT_LIBRARY_DATBACKUP_H
-
-#include <string>
-#include "../DatOperationResult.h"
-
-extern "C++" {
-namespace LOTRO_DAT {
-    class DatFile;
-
-    /*!
-     * \brief Модуль резервного копирования файлов
-     * \author Gi1dor
-     * \date 30.06.2018
-     *
-     * Класс для осуществления резервного копирования без деинициализации модулей и потери данных dat файла.
-     *
-     * \warning Объекты этого класса не должны создаваться отдельно! Созданием и управлением ими занимается класс DatFile
-     */
-
-    class DatBackupManager {
-    public:
-        DatBackupManager() = delete;
-
-        DatBackupManager(const DatBackupManager &other) = delete;
-
-        DatBackupManager &operator=(const DatBackupManager &other) = delete;
-
-        ~DatBackupManager() = default;
-
-        explicit DatBackupManager(DatFile *datFilePtr);
-
-        bool CheckIfBackupAvailable(const std::string &backup_datname);
-
-        DatOperationResult<> CreateBackup(const std::string &backup_datname);
-
-        DatOperationResult<> RestoreFromBackup(const std::string &backup_datname);
-
-        DatOperationResult<> RemoveBackup(const std::string &backup_datname);
-
-    private:
-
-        DatOperationResult<> CopyDatFile(DatFile &source, FILE* target);
-
-        DatFile *dat;
-
-        const unsigned COPY_BLOCK_SIZE = 16 * 1024 * 1024; // 16 megabytes
-    };
-}
-};
-
-#endif //LOTRO_DAT_LIBRARY_DATBACKUP_H

+ 0 - 50
import/LotroDat/DatSubsystems/DatExporter.h

@@ -1,50 +0,0 @@
-#ifndef LOTRO_DAT_LIBRARY_DATEXPORTER_H
-#define LOTRO_DAT_LIBRARY_DATEXPORTER_H
-
-#include "../DatOperationResult.h"
-#include "../Database.h"
-
-extern "C++" {
-namespace LOTRO_DAT {
-
-    enum FILE_TYPE : int;
-
-    /*!
-     * \brief Модуль экспорта файлов
-     * \author Gi1dor
-     * \date 30.06.2018
-     * Класс для экспорта файлов из dat контейнера. Позволяет извлекать файлы по их типам в базу данных или в папку.
-     * Также позволяет извлекать отдельные файлы по их id.
-     * \warning Объекты этого класса не должны создаваться отдельно! Созданием и управлением ими занимается класс DatFile
-     */
-
-    class DatExporter {
-    public:
-        DatExporter() = delete;
-
-        DatExporter(const DatExporter &other) = delete;
-
-        DatExporter &operator=(const DatExporter &other) = delete;
-
-        ~DatExporter() = default;
-
-        explicit DatExporter(DatFile *datFilePtr);
-
-        DatOperationResult<int> ExtractAllFilesByType(const FILE_TYPE &type, std::string output_directory_path);
-
-        DatOperationResult<> ExtractFileById(long long file_id, std::string output_filename);
-
-        DatOperationResult<int> ExtractAllFilesByType(const FILE_TYPE &type, Database *db);
-
-        DatOperationResult<> ExtractFileById(long long file_id, Database *db);
-
-    private:
-        DatOperationResult<> WriteStringToFile(const std::u16string &str, const std::string &path);
-
-        DatFile *dat;
-
-    };
-}
-};
-
-#endif //LOTRO_DAT_LIBRARY_DATEXPORTER_H

+ 0 - 92
import/LotroDat/DatSubsystems/DatFileSystem.h

@@ -1,92 +0,0 @@
-//
-// Created by kikab on 04.06.2018.
-//
-
-#ifndef LOTRO_DAT_LIBRARY_DATFILESYSTEM_H
-#define LOTRO_DAT_LIBRARY_DATFILESYSTEM_H
-
-#include <set>
-#include <map>
-#include <unordered_set>
-#include <unordered_map>
-#include <utility>
-#include <memory>
-
-#include "../DatOperationResult.h"
-#include "../SubFile.h"
-#include "../SubDirectory.h"
-
-extern "C++" {
-namespace LOTRO_DAT {
-    class DatFile;
-    class BinaryData;
-    class SubDirectory;
-
-
-    /*!
-     * \brief Модуль файловой системы
-     * \author Gi1dor
-     * \date 30.06.2018
-     * Класс для работы с внутренними файлами в dat-контейнере. Позволяет найти и извлечь данные необходимого файла
-     * или изменить информацию о нём
-     * \warning Объекты этого класса не должны создаваться отдельно! Созданием и управлением ими занимается класс DatFile
-     */
-
-    class DatFileSystem {
-
-    public:
-        DatFileSystem() = delete;
-        DatFileSystem(const DatFileSystem &other) = delete;
-        DatFileSystem& operator=(const DatFileSystem &other) = delete;
-        ~DatFileSystem() = default;
-
-        explicit DatFileSystem(DatFile *datFilePtr);
-
-        DatOperationResult<> Init();
-
-        DatOperationResult<> InitAllDirectories();
-
-        DatOperationResult<> InitAllFiles();
-
-        DatOperationResult<BinaryData> GetFileData(const SubFile& file, long long int offset);
-
-        DatOperationResult<std::shared_ptr<SubFile>> GetFile(long long file_id);
-
-        DatOperationResult<bool> CheckCorrectSubfile(const SubFile& file);
-
-        DatOperationResult<> UpdateFileInfo(const SubFile& file);
-
-        int GetInitialisedFilesNumber() const;
-
-        void PrintInformaion(FILE* file);
-
-        DatOperationResult<> DeInit();
-
-        DatOperationResult<> PerformOperationOnAllFiles(const std::function<void (std::shared_ptr<SubFile>&)>& function);
-
-        DatOperationResult<> CommitDirectories();
-
-    private:
-        DatOperationResult<> InitSubFile(long long file_id);
-
-        DatOperationResult<> InitSubDirectory(SubDirectory dir);
-
-    private:
-        DatFile *dat;
-        std::set<long long> subfile_pending_update;
-
-        std::map<long long, std::shared_ptr<SubFile> > dictionary_;
-
-        std::unordered_set<long long> visited_subdirectories_offsets_;
-        std::unordered_set<long long> visited_subfiles_ids_;
-
-        std::set<SubDirectory, SubDirectory::SubDirectoryOffsetComparator> subdir_init_queue_;
-        std::unordered_map<long long, SubFile> subfile_init_map_;
-        std::set<SubFile, SubFile::SubFileOffsetComparator> subfile_init_queue_;
-    public:
-        unsigned patched_file_end;
-    };
-}
-};
-
-#endif //LOTRO_DAT_LIBRARY_DATFILESYSTEM_H

+ 0 - 105
import/LotroDat/DatSubsystems/DatIO.h

@@ -1,105 +0,0 @@
-//
-// Created by kikab on 04.06.2018.
-//
-
-#ifndef LOTRO_DAT_LIBRARY_DATIO_H
-#define LOTRO_DAT_LIBRARY_DATIO_H
-
-#include <utility>
-#include "../DatOperationResult.h"
-
-extern "C++" {
-namespace LOTRO_DAT {
-    class BinaryData;
-
-    class DatFile;
-
-    class SubDirectory;
-
-    class SubFile;
-
-    /*!
-     * \brief Модуль ввода/вывода
-     * \author Gi1dor
-     * \date 30.06.2018
-     * Класс для работы с вводом-выводом данных в dat-контейнере. Предоставляет функции чтения/записи данных, а также
-     * информацию об основных параметрах dat файла
-     * \warning Объекты этого класса не должны создаваться отдельно! Созданием и управлением ими занимается класс DatFile
-     */
-
-    class DatIO {
-    public:
-        DatIO() = delete;
-        DatIO(const DatIO &other) = delete;
-        DatIO& operator=(const DatIO &other) = delete;
-        ~DatIO();
-
-        explicit DatIO(DatFile *datFilePtr);
-
-        DatOperationResult<> Init(const std::string &filename);
-
-        DatOperationResult<> ReadData(BinaryData &data, long long size, long long offset = 0, long long data_offset = 0) const;
-
-        DatOperationResult<> WriteData(const BinaryData &data, long long size, long long offset = 0, long long data_offset = 0);
-
-        DatOperationResult<long long> GetActualDatSize();
-
-        DatOperationResult<std::string> GetFilename();
-
-        void PrintInformaion(FILE* file);
-
-        DatOperationResult<> DeInit();
-
-        unsigned int GetHeaderHash();
-    private:
-
-        void ClearData();
-
-        //------------------------------------------------//
-        // PRIVATE INIT SECTION
-        //------------------------------------------------//
-
-        DatOperationResult<> OpenDatFile();
-
-        DatOperationResult<> ReadSuperBlock();
-
-        //------------------------------------------------//
-        // PRIVATE READ-WRITE SECTION
-        //------------------------------------------------//
-
-        void UpdateBufferIfNeeded(long long size_to_write);
-
-        //------------------------------------------------//
-        // PRIVATE DEINIT SECTION
-        //------------------------------------------------//
-
-        DatOperationResult<> ModifyFragmentationJournal();
-
-        DatOperationResult<> UpdateHeader();
-
-    private:
-        DatFile *dat;
-        FILE *file_handler_;
-        std::string filename_;
-
-    public:
-        /// Header values
-        long long constant1;
-        long long constant2;
-        long long file_size;
-        long long version1;
-        long long version2;
-        long long fragmentation_journal_size;
-        long long fragmentation_journal_end;
-        long long root_directory_offset;
-        long long fragmentation_journal_offset;
-        long long free_dat_size;
-
-    private:
-        long long actual_dat_size_;
-        const unsigned MAX_EOF_BUFFER = 15 * 1024 * 1024; /// Maximal size of buffer, which is written to the end of dat file to improve write speed of small fragments
-    };
-}
-};
-#endif //LOTRO_DAT_LIBRARY_DATIO_H
-

+ 0 - 94
import/LotroDat/DatSubsystems/DatLocaleManager.h

@@ -1,94 +0,0 @@
-#ifndef LOTRO_DAT_LIBRARY_DATLOCALEMANAGER_H
-#define LOTRO_DAT_LIBRARY_DATLOCALEMANAGER_H
-
-#include <memory>
-#include <map>
-#include <set>
-
-#include "../DatOperationResult.h"
-
-extern "C++" {
-namespace LOTRO_DAT {
-    class DatFile;
-
-    class SubFile;
-
-    /*!
-     * \brief Модуль работы с локалями
-     * \author Gi1dor
-     * \date 06.07.2018
-     *
-     * Класс для работы с искуственно внедряемымыми в dat контейнер копиями файлов. Позволяет независимо хранить
-     * информацию о двух версиях каждого файла, которую можно подставлять в файловую систему.
-     * В рамках русификации хранит информацию об оригинальной и русифицированной версии тех файлов, для которых
-     * существует русификация.
-     *
-     * \warning Данные локалей чувствительны к обновлениям игры и могут быть стёрты после них!
-     * \warning Объекты этого класса не должны создаваться отдельно! Созданием и управлением ими занимается класс DatFile
-     */
-
-    class DatLocaleManager {
-        friend class DatStatus;
-    public:
-        enum LOCALE : int {
-            ORIGINAL = 0,
-            PATCHED = 1
-        };
-
-        DatLocaleManager() = delete;
-
-        DatLocaleManager(const DatLocaleManager &other) = delete;
-
-        DatLocaleManager &operator=(const DatLocaleManager &other) = delete;
-
-        ~DatLocaleManager() = default;
-
-        explicit DatLocaleManager(DatFile *datFilePtr);
-
-        DatOperationResult<> Init();
-
-        DatOperationResult<> SetLocale(LOCALE locale);
-
-        DatOperationResult<> DeInit();
-
-        DatOperationResult<> CommitLocales();
-
-        LOCALE GetCurrentLocale();
-
-        bool CheckLocaleCorrect();
-
-        void UpdateLocaleFile(LOCALE locale, const SubFile &file);
-
-        DatOperationResult<SubFile> GetLocaleFile(long long file_id, LOCALE locale);
-
-        void PrintInformaion(FILE *file);
-
-        bool CategoryIsInactive(long long category);
-
-        void UpdateCategory(long long file_id, long long category);
-
-        DatOperationResult<> EnableCategory(long long category);
-
-        DatOperationResult<> DisableCategory(long long category);
-
-        const std::set<long long>& GetInactiveCategories();
-
-    private:
-        std::map<long long, SubFile> &GetLocaleDictReference(LOCALE locale);
-
-        void ClearData();
-
-    private:
-        DatFile *dat;
-        std::map<long long, SubFile> orig_dict_;
-        std::map<long long, SubFile> patch_dict_;
-        std::set<long long> inactive_categories;
-        LOCALE current_locale_;
-        uint64_t dict_offset_ = 0;
-        uint64_t dict_size_ = 0;
-    };
-}
-};
-
-
-#endif //LOTRO_DAT_LIBRARY_DATLOCALEMANAGER_H

+ 0 - 51
import/LotroDat/DatSubsystems/DatPatcher.h

@@ -1,51 +0,0 @@
-//
-// Created by kikab on 04.06.2018.
-//
-
-#ifndef LOTRO_DAT_LIBRARY_DATPATCHER_H
-#define LOTRO_DAT_LIBRARY_DATPATCHER_H
-
-#include <yaml-cpp/yaml.h>
-#include "../DatOperationResult.h"
-
-extern "C++"
-{
-namespace LOTRO_DAT {
-    class DatFile;
-    class SubfileData;
-    class SubFile;
-    class Database;
-    class BinaryData;
-
-    /*!
-     * \brief Модуль экспорта файлов
-     * \author Gi1dor
-     * \date 30.06.2018
-     * Класс для изменения файлов в dat контейнере. Позволяет обновлять файлы, сохраняя их оригинальные версии
-     *
-     * \warning Объекты этого класса не должны создаваться отдельно! Созданием и управлением ими занимается класс DatFile
-     */
-
-    class DatPatcher {
-    public:
-        DatPatcher() = delete;
-        DatPatcher(const DatPatcher &other) = delete;
-        DatPatcher& operator=(const DatPatcher &other) = delete;
-        ~DatPatcher() = default;
-
-        explicit DatPatcher(DatFile *datFilePtr);
-
-        DatOperationResult<> PatchFile(const SubfileData &data, bool single_file = true);
-
-        DatOperationResult<int> PatchAllDatabase(Database *db);
-
-    private:
-        DatOperationResult<> ApplyFilePatch(std::shared_ptr<SubFile> file, BinaryData &data);
-
-    private:
-        DatFile *dat;
-    };
-}
-}
-
-#endif //LOTRO_DAT_LIBRARY_DATFILEPATCHER_H

+ 0 - 132
import/LotroDat/DatSubsystems/DatStatus.h

@@ -1,132 +0,0 @@
-#ifndef LOTRO_DAT_LIBRARY_DATSTATUS_H
-#define LOTRO_DAT_LIBRARY_DATSTATUS_H
-
-#include <string>
-#include <functional>
-#include <set>
-
-namespace LOTRO_DAT {
-    class DatFile;
-
-    /*!
-     * \brief Модуль статуса dat-файла
-     * \author Gi1dor
-     * \date 06.07.2018
-     *
-     * Класс для хранения информации о выполняемых процессах в dat-файле. Позволяет отслеживать прогресс выполнения
-     * во время операций создания резервных копий, применения патчей или извлечения файлов
-     *
-     * \warning Объекты этого класса не должны создаваться отдельно! Созданием и управлением ими занимается класс DatFile
-     */
-
-    class DatStatus {
-    public:
-        enum DAT_STATUS: int {
-            E_INITIALISING,
-            E_EXTRACTING,
-            E_PATCHING,
-            E_COMMITING,
-            E_BACKUP_CREATING,
-            E_BACKUP_RESTORING,
-            E_BACKUP_REMOVING,
-            E_GATHERING_INFO,
-            E_FREE
-        };
-
-        struct ProgressInfo {
-            DAT_STATUS status;
-            double percentage;
-            unsigned long long finished_parts;
-            unsigned long long total_parts;
-        };
-
-        using Callback = std::function<void(ProgressInfo)>; 
-        
-        struct CallbackStorage{
-        public:
-            CallbackStorage(Callback function_handle) {
-                func_ = function_handle;
-                handler_ = free_handler_++;
-            }
-
-            CallbackStorage(unsigned long long handler) {
-                func_ = nullptr;
-                handler_ = handler;
-            }
-
-            unsigned long long GetHandler() const {
-                return handler_;
-            }
-
-            bool operator<(const CallbackStorage& other) const {
-                return handler_ < other.handler_;
-            }
-
-            bool operator==(const CallbackStorage& other) const {
-                return handler_ == other.handler_;
-            }
-            
-            template<class ... Types>
-            void operator()(Types ... args) const {
-                func_(args...);
-            }
-
-        private:
-            Callback func_;
-            unsigned long long handler_;
-            static unsigned long long free_handler_;
-        };
-        
-        DatStatus() = delete;
-
-        DatStatus(const DatStatus &other) = delete;
-
-        DatStatus &operator=(const DatStatus &other) = delete;
-
-        ~DatStatus() = default;
-
-        explicit DatStatus(DatFile *datFilePtr);
-
-        void SetStatus(DAT_STATUS status);
-
-        void SetFinishedParts(unsigned long long finished_parts);
-
-        void SetTotalParts(unsigned long long total_parts);
-
-        void SetDebugMessage(const std::string &message);
-
-        DAT_STATUS GetStatus();
-
-        double GetPercentage();
-
-        unsigned long long GetFinishedParts();
-
-        unsigned long long GetTotalParts(); 
-
-        std::string GetDebugMessage();
-
-        void SetDefaultStatus();
-
-        bool CheckIfNotPatched();
-        
-        unsigned long long AddStatusChangedCallbackFunction(Callback func);
-
-        void RemoveStatusChangedCallbackFunction(unsigned long long handler);
-
-        void EraseAllCallbackFunctions();
-
-        void InvokeCallbackFunctions();
-
-    private:
-        DatFile *dat = nullptr;
-        DAT_STATUS status_ = DAT_STATUS::E_FREE;
-        unsigned long long finished_parts_ = 0;
-        unsigned long long total_parts_ = 0;
-        double percentage_ = 0;
-        std::string debug_message_ = "";
-
-        std::set<CallbackStorage> callback_functions_;
-    };
-}
-
-#endif //LOTRO_DAT_LIBRARY_DATSTATUS_H

+ 58 - 62
import/LotroDat/Database.h

@@ -1,63 +1,59 @@
-//
-// Created by Иван_Архипов on 17.11.2017.
-//
-
-#ifndef LOTRO_DAT_PATCHER_DATABASE_H
-#define LOTRO_DAT_PATCHER_DATABASE_H
-
-#include <SQLite/sqlite3.h>
-#include <string>
-#include <yaml-cpp/yaml.h>
-
-extern  "C++"
-{
-namespace LOTRO_DAT
-{
-    class BinaryData;
-    class SubfileData;
-
-    class Database {
-    public:
-        Database();
-
-        ~Database();
-
-        bool InitDatabase(const std::string &filename);
-
-        bool CloseDatabase();
-
-        bool PushFile(const SubfileData &data);
-
-        SubfileData GetNextFile();
-
-        bool RemoveDatabase();
-
-        bool ClearDatabase();
-
-        size_t CountRows();
-
-    private:
-        void ExecSql(const std::string &sql);
-
-        sqlite3* db_;
-        sqlite3_stmt* insert_request_;
-        sqlite3_stmt* fetch_one_request_;
-        sqlite3_stmt* get_rows_number_request_;
-
-
-        const std::string CreateTableCommand_ = "CREATE TABLE IF NOT EXISTS `patch_data` ( "
-            "`binary_data` BLOB, "
-            "`text_data` TEXT, "
-            "`options` TEXT NOT NULL);";
-
-        const std::string InsertFileCommand_ = "INSERT INTO `patch_data` "
-                "(`binary_data`, `text_data`, `options`) "
-                "VALUES (?, ?, ?); ";
-
-        const std::string FetchOneCommand = "SELECT * FROM `patch_data`";
-        const std::string ClearTableCommand_ = "DELETE * FROM `patch_data`";
-        const std::string GetRowsNumberCommand_ = "SELECT Count(*) as count FROM `patch_data`";
-    };
-}
-}
+#ifndef LOTRO_DAT_DATABASE_H
+#define LOTRO_DAT_DATABASE_H
+
+#include <SQLite/sqlite3.h>
+#include <string>
+#include <yaml-cpp/yaml.h>
+
+extern "C++" {
+namespace LOTRO_DAT {
+
+class BinaryData;
+class SubfileData;
+
+class Database {
+ public:
+  Database();
+
+  ~Database();
+
+  bool InitDatabase(const std::string &filename);
+
+  bool CloseDatabase();
+
+  bool PushFile(const SubfileData &data);
+
+  SubfileData GetNextFile();
+
+  bool RemoveDatabase();
+
+  bool ClearDatabase();
+
+  size_t CountRows();
+
+ private:
+  void ExecSql(const std::string &sql);
+
+  sqlite3* db_;
+  sqlite3_stmt* insert_request_;
+  sqlite3_stmt* fetch_one_request_;
+  sqlite3_stmt* get_rows_number_request_;
+
+
+  const std::string CreateTableCommand_ = "CREATE TABLE IF NOT EXISTS `patch_data` ( "
+    "`binary_data` BLOB, "
+    "`text_data` TEXT, "
+    "`options` TEXT NOT NULL);";
+
+  const std::string InsertFileCommand_ = "INSERT INTO `patch_data` "
+    "(`binary_data`, `text_data`, `options`) "
+    "VALUES (?, ?, ?); ";
+
+  const std::string FetchOneCommand = "SELECT * FROM `patch_data`";
+  const std::string ClearTableCommand_ = "DELETE * FROM `patch_data`";
+  const std::string GetRowsNumberCommand_ = "SELECT Count(*) as count FROM `patch_data`";
+};
+
+} // namespace LOTRO_DAT
+} // extern "C++"
 #endif

+ 0 - 17
import/LotroDat/LotroDat.h

@@ -1,17 +0,0 @@
-#ifndef LOTRO_DAT_LIB
-#define LOTRO_DAT_LIB
-
-#define LOTRO_DAT_VERSION  "8.0.0"
-#define LOTRO_DAT_VERSION_MAJOR ""
-#define LOTRO_DAT_VERSION_MINOR ""
-#define LOTRO_DAT_VERSION_PATCH ""
-
-#include "DatFile.h"
-#include "Database.h"
-#include "SubfileData.h"
-#include "DatOperationResult.h"
-
-#include <yaml-cpp/yaml.h>
-#include <ZLib/zlib.h>
-
-#endif /* LOTRO_DAT_LIB */

+ 0 - 37
import/LotroDat/SubDirectory.h

@@ -1,37 +0,0 @@
-//
-// Created by Иван_Архипов on 07.11.2017.
-//
-
-#ifndef LOTRO_DAT_PATCHER_SUBDIRECTORY_H
-#define LOTRO_DAT_PATCHER_SUBDIRECTORY_H
-
-extern "C++"
-{
-namespace LOTRO_DAT {
-    class SubDirectory {
-    public:
-        struct SubDirectoryOffsetComparator {
-            bool operator()(const SubDirectory &f, const SubDirectory &s) {
-                return f.offset_ < s.offset_;
-            }
-        };
-
-        SubDirectory() = default;
-
-        SubDirectory(const SubDirectory &other) = default;
-
-        SubDirectory &operator=(const SubDirectory &other) = default;
-
-        SubDirectory(long long unknown, long long offset);
-
-    public:
-        long long offset();
-
-    private:
-        long long unknown_;
-        long long offset_;
-    };
-}
-};
-
-#endif //LOTRO_DAT_PATCHER_SUBDIRECTORY_H

+ 44 - 88
import/LotroDat/SubFile.h

@@ -1,88 +1,44 @@
-//
-// Created by Иван_Архипов on 01.11.2017.
-//
-
-#ifndef LOTRO_DAT_PATCHER_SUBFILE_H
-#define LOTRO_DAT_PATCHER_SUBFILE_H
-
-#include <string>
-#include <vector>
-#include <yaml-cpp/yaml.h>
-
-extern "C++"
-{
-namespace LOTRO_DAT
-{
-    class DatFile;
-	class BinaryData;
-    class Database;
-    class SubfileData;
-
-    enum FILE_TYPE : int;
-
-    class SubFile
-    {
-        friend class DatFileSystem;
-		friend class DatPatcher;
-
-    public:
-        struct SubFileOffsetComparator {
-            bool operator() (const SubFile &f, const SubFile &s){
-                return f.file_offset_ < s.file_offset_;
-            }
-        };
-
-
-        SubFile();
-        SubFile(const SubFile &other) = default;
-		SubFile &operator =(const SubFile &other) = default;
-
-        SubFile(DatFile &dat, const BinaryData &header);
-		SubFile(DatFile &dat, long long dictionary_offset, long long fragments_count, long long unknown1,
-                long long file_id, long long file_offset, long long file_size, long long timestamp, long long version,
-                long long block_size);
-		virtual ~SubFile() = default;
-
-        virtual FILE_TYPE FileType() const;
-        virtual std::string Extension() const;
-
-        virtual SubfileData PrepareForExport(const BinaryData &file_data);
-        virtual BinaryData MakeForImport(const BinaryData &old_data, const SubfileData &data);
-		BinaryData MakeHeaderData() const;
-
-		long long dictionary_offset() const;
-        long long unknown1() const;
-        long long file_id() const;
-        long long file_offset() const;
-        long long file_size() const;
-        long long timestamp() const;
-        long long version() const;
-        long long block_size() const;
-		long long unknown2() const;
-
-		bool operator ==(const SubFile &b) const;
-		bool operator !=(const SubFile &b) const;
-
-
-        static FILE_TYPE GetSubfileType(DatFile& dat, SubFile preinit_file);
-        static std::shared_ptr<SubFile> MakeSubfile(DatFile& dat, SubFile preinit_file);
-
-        long long category;
-
-	protected:
-		DatFile *dat_;
-        long long dictionary_offset_;
-
-        long long unknown1_;
-        long long file_id_;
-        long long file_offset_;
-        long long file_size_;
-        long long timestamp_;
-        long long version_;
-        long long block_size_;
-		long long unknown2_;
-	};
-}
-};
-
-#endif //LOTRO_DAT_PATCHER_SUBFILE_H
+#ifndef LOTRO_DAT_SUBFILE_H
+#define LOTRO_DAT_SUBFILE_H
+
+#include "binarydata.h"
+#include "subfiledata.h"
+
+#include <string>
+
+namespace LOTRO_DAT {
+
+enum FILE_TYPE {
+  TEXT,
+  JPG,
+  DDS,
+  WAV,
+  OGG,
+  FONT,
+  UNKNOWN
+};
+
+FILE_TYPE FileTypeFromString(std::string ext);
+
+FILE_TYPE FileTypeFromFileContents(int file_id, const BinaryData& file_data);
+
+std::string StringFromFileType(FILE_TYPE type);
+
+BinaryData BuildForImport(const BinaryData& old_data, const SubfileData& outer_data);
+
+SubfileData BuildForExport(int file_id, const BinaryData& inner_data);
+
+namespace Subfiles {
+
+template<FILE_TYPE type> 
+class Subfile {
+ public:
+  static BinaryData BuildForImport(const BinaryData& old_data, const SubfileData& outer_data);
+
+  static SubfileData BuildForExport(const BinaryData& inner_data);
+};
+
+}; // namespace Subfiles
+}; // namespace LOTRO_DAT
+
+#endif // LOTRO_DAT_SUBFILE_H

+ 46 - 46
import/LotroDat/SubfileData.h

@@ -1,46 +1,46 @@
-//
-// Created by Иван_Архипов on 06.12.2017.
-//
-
-#ifndef LOTRO_DAT_LIBRARY_SUBFILEDATA_H
-#define LOTRO_DAT_LIBRARY_SUBFILEDATA_H
-
-#include <string>
-#include <yaml-cpp/yaml.h>
-#include "BinaryData.h"
-
-namespace LOTRO_DAT {
-    class SubfileData {
-    public:
-        SubfileData() {
-            binary_data = BinaryData(0);
-            text_data = std::u16string();
-            options = YAML::Node();
-        }
-
-        SubfileData(const BinaryData &binary_data_, const std::u16string &text_data_, const YAML::Node &options_) {
-            binary_data = binary_data_;
-            text_data = text_data_;
-            options = options_;
-        }
-
-        bool Empty() const {
-            return binary_data.size() == 0 && text_data.length() == 0;
-        }
-
-        bool operator == (const SubfileData &other) {
-            return binary_data == other.binary_data && text_data == other.text_data;
-        }
-
-        bool operator != (const SubfileData &other) {
-            return !(*this == other);
-        }
-
-    public:
-        BinaryData binary_data;
-        std::u16string text_data;
-        YAML::Node options;
-    };
-}
-
-#endif //LOTRO_DAT_LIBRARY_SUBFILEDATA_H
+//
+// Created by Иван_Архипов on 06.12.2017.
+//
+
+#ifndef LOTRO_DAT_LIBRARY_SUBFILEDATA_H
+#define LOTRO_DAT_LIBRARY_SUBFILEDATA_H
+
+#include <string>
+#include <yaml-cpp/yaml.h>
+#include "BinaryData.h"
+
+namespace LOTRO_DAT {
+    class SubfileData {
+    public:
+        SubfileData() {
+            binary_data = BinaryData(0);
+            text_data = std::u16string();
+            options = YAML::Node();
+        }
+
+        SubfileData(const BinaryData &binary_data_, const std::u16string &text_data_, const YAML::Node &options_) {
+            binary_data = binary_data_;
+            text_data = text_data_;
+            options = options_;
+        }
+
+        bool Empty() const {
+            return binary_data.size() == 0 && text_data.length() == 0;
+        }
+
+        bool operator == (const SubfileData &other) {
+            return binary_data == other.binary_data && text_data == other.text_data;
+        }
+
+        bool operator != (const SubfileData &other) {
+            return !(*this == other);
+        }
+
+    public:
+        BinaryData binary_data;
+        std::u16string text_data;
+        YAML::Node options;
+    };
+}
+
+#endif //LOTRO_DAT_LIBRARY_SUBFILEDATA_H

+ 19 - 29
import/LotroDat/Subfiles/DdsSubFile.h

@@ -1,29 +1,19 @@
-//
-// Created by Иван_Архипов on 24.11.2017.
-//
-
-#ifndef LOTRO_DAT_LIBRARY_DDSSUBFILE_H
-#define LOTRO_DAT_LIBRARY_DDSSUBFILE_H
-
-#include "../SubFile.h"
-
-namespace LOTRO_DAT {
-    class DdsSubFile : public SubFile {
-    public:
-        DdsSubFile() = delete;
-        explicit DdsSubFile(const DdsSubFile &other) = delete;
-        DdsSubFile &operator =(const DdsSubFile &other) = delete;
-
-        explicit DdsSubFile(SubFile preinit_file);
-
-        FILE_TYPE FileType() const override;
-
-        std::string Extension() const override;
-
-        SubfileData PrepareForExport(const BinaryData &file_data) override;
-
-        BinaryData MakeForImport(const BinaryData &old_data, const SubfileData &data) override;
-    };
-};
-
-#endif //LOTRO_DAT_LIBRARY_DDSSUBFILE_H
+#ifndef LOTRO_DAT_DDSSUBFILE_H
+#define LOTRO_DAT_DDSSUBFILE_H
+
+#include "subfile.h"
+
+namespace LOTRO_DAT {
+namespace Subfiles {
+
+template<> class Subfile<DDS> {
+  public:
+    static BinaryData BuildForImport(const BinaryData& old_data, const SubfileData& outer_data);
+
+    static SubfileData BuildForExport(const BinaryData& inner_data);
+};
+
+}; // namespace Subfiles
+}; // namespace LOTRO_DAT
+
+#endif //LOTRO_DAT_DDSSUBFILE_H

+ 19 - 33
import/LotroDat/Subfiles/FontSubFile.h

@@ -1,33 +1,19 @@
-//
-// Created by Иван_Архипов on 24.11.2017.
-//
-
-#ifndef LOTRO_DAT_LIBRARY_FONTSUBFILE_H
-#define LOTRO_DAT_LIBRARY_FONTSUBFILE_H
-
-
-#include "../SubFile.h"
-
-namespace LOTRO_DAT {
-    class FontSubFile : public SubFile {
-    public:
-        FontSubFile() = delete;
-        explicit FontSubFile(const FontSubFile &other) = delete;
-        FontSubFile &operator =(const FontSubFile &other) = delete;
-
-        explicit FontSubFile(SubFile preinit_file);
-
-        FILE_TYPE FileType() const override;
-
-        std::string Extension() const override;
-
-        SubfileData PrepareForExport(const BinaryData &file_data) override;
-
-        BinaryData MakeForImport(const BinaryData &old_data, const SubfileData &data) override;
-
-    };
-};
-
-
-
-#endif //LOTRO_DAT_LIBRARY_FONTSUBFILE_H
+#ifndef LOTRO_DAT_FONTSUBFILE_H
+#define LOTRO_DAT_FONTSUBFILE_H
+
+#include "subfile.h"
+
+namespace LOTRO_DAT {
+namespace Subfiles {
+
+template<> class Subfile<FONT> {
+  public:
+    static BinaryData BuildForImport(const BinaryData& old_data, const SubfileData& outer_data);
+
+    static SubfileData BuildForExport(const BinaryData& inner_data);
+};
+
+}; // namespace Subfiles
+}; // namespace LOTRO_DAT
+
+#endif //LOTRO_DAT_FONTSUBFILE_H

+ 19 - 33
import/LotroDat/Subfiles/JpgSubFile.h

@@ -1,33 +1,19 @@
-//
-// Created by Иван_Архипов on 24.11.2017.
-//
-
-#ifndef LOTRO_DAT_LIBRARY_JPGSUBFILE_H
-#define LOTRO_DAT_LIBRARY_JPGSUBFILE_H
-
-
-#include "../SubFile.h"
-
-namespace LOTRO_DAT {
-    class JpgSubFile : public SubFile {
-    public:
-        JpgSubFile() = delete;
-        explicit JpgSubFile(const JpgSubFile &other) = delete;
-        JpgSubFile &operator =(const JpgSubFile &other) = delete;
-
-        explicit JpgSubFile(SubFile preinit_file);
-
-
-        FILE_TYPE FileType() const override;
-
-        std::string Extension() const override;
-
-        SubfileData PrepareForExport(const BinaryData &file_data) override;
-
-        BinaryData MakeForImport(const BinaryData &old_data, const SubfileData &data) override;
-    };
-};
-
-
-
-#endif //LOTRO_DAT_LIBRARY_JPGSUBFILE_H
+#ifndef LOTRO_DAT_JPGSUBFILE_H
+#define LOTRO_DAT_JPGSUBFILE_H
+
+#include "subfile.h"
+
+namespace LOTRO_DAT {
+namespace Subfiles {
+
+template<> class Subfile<JPG> {
+  public:
+    static BinaryData BuildForImport(const BinaryData& old_data, const SubfileData& outer_data);
+
+    static SubfileData BuildForExport(const BinaryData& inner_data);
+};
+
+}; // namespace Subfiles
+}; // namespace LOTRO_DAT
+
+#endif //LOTRO_DAT_JPGSUBFILE_H

+ 19 - 28
import/LotroDat/Subfiles/OggSubFile.h

@@ -1,28 +1,19 @@
-//
-// Created by Иван_Архипов on 24.11.2017.
-//
-
-#ifndef LOTRO_DAT_LIBRARY_OGGSUBFILE_H
-#define LOTRO_DAT_LIBRARY_OGGSUBFILE_H
-
-#include "../SubFile.h"
-
-namespace LOTRO_DAT {
-    class OggSubFile : public SubFile {
-    public:
-        OggSubFile() = delete;
-        explicit OggSubFile(const OggSubFile &other) = delete;
-        OggSubFile &operator =(const OggSubFile &other) = delete;
-
-        explicit OggSubFile(SubFile preinit_file);
-
-        FILE_TYPE FileType() const override;
-        std::string Extension() const override;
-
-        SubfileData PrepareForExport(const BinaryData &file_data) override;
-
-        BinaryData MakeForImport(const BinaryData &old_data, const SubfileData &data) override;
-    };
-};
-
-#endif //LOTRO_DAT_LIBRARY_OGGSUBFILE_H
+#ifndef LOTRO_DAT_OGGSUBFILE_H
+#define LOTRO_DAT_OGGSUBFILE_H
+
+#include "subfile.h"
+
+namespace LOTRO_DAT {
+namespace Subfiles {
+
+template<> class Subfile<OGG> {
+  public:
+    static BinaryData BuildForImport(const BinaryData& old_data, const SubfileData& outer_data);
+
+    static SubfileData BuildForExport(const BinaryData& inner_data);
+};
+
+}; // namespace Subfiles
+}; // namespace LOTRO_DAT
+
+#endif //LOTRO_DAT_OGGSUBFILE_H

+ 50 - 75
import/LotroDat/Subfiles/TextSubFile.h

@@ -1,75 +1,50 @@
-//
-// Created by Иван_Архипов on 24.11.2017.
-//
-
-#ifndef LOTRO_DAT_LIBRARY_TEXTSUBFILE_H
-#define LOTRO_DAT_LIBRARY_TEXTSUBFILE_H
-
-#include "../SubFile.h"
-#include "../SubfileData.h"
-#include "../BinaryData.h"
-
-#include <vector>
-#include <unordered_map>
-
-namespace LOTRO_DAT {
-    struct TextFragment {
-        long long fragment_id;
-        std::u16string text;
-        std::string args;
-
-        friend bool operator < (const TextFragment &first, const TextFragment &second) {
-            return first.fragment_id < second.fragment_id;
-        }
-    };
-
-    class TextSubFile : public SubFile {
-    public:
-        TextSubFile() = delete;
-        explicit TextSubFile(const TextSubFile &other) = delete;
-        SubFile &operator =(const TextSubFile &other) = delete;
-
-        explicit TextSubFile(SubFile preinit_file);
-
-        FILE_TYPE FileType() const override;
-
-        std::string Extension() const override;
-
-        SubfileData PrepareForExport(const BinaryData &file_data) override;
-
-        BinaryData MakeForImport(const BinaryData &old_data, const SubfileData &data) override;
-
-    private:
-        std::vector<TextFragment> patch_fragments_;
-
-        std::vector<std::u16string> text_pieces_;
-        std::vector<long long> argument_references_;
-        std::vector<std::vector<BinaryData>> argument_strings_;
-
-        static BinaryData buffer_;
-
-    private:
-        void MakePieces(const BinaryData &data, long long &offset);
-
-        void MakeArgumentReferences(const BinaryData &data, long long &offset);
-
-        void MakeArgumentStrings(const BinaryData &data, long long &offset);
-
-        void ParsePatchFragments(const SubfileData &data);
-
-        BinaryData BuildPieces(const BinaryData &data, const TextFragment &new_data, long long &offset);
-
-        BinaryData BuildArgumentReferences(const BinaryData &data, const TextFragment &new_data, long long &offset);
-
-        BinaryData BuildArgumentStrings(const BinaryData &data, const TextFragment &new_data, long long &offset);
-
-        BinaryData GetPieceData(const BinaryData &data, long long &offset) const;
-
-        BinaryData GetArgumentReferenceData(const BinaryData &data, long long &offset) const;
-
-        BinaryData GetArgumentStringsData(const BinaryData &data, long long &offset) const;
-    };
-};
-
-
-#endif //LOTRO_DAT_LIBRARY_TEXTSUBFILE_H
+#ifndef LOTRO_DAT_TEXTSUBFILE_H
+#define LOTRO_DAT_TEXTSUBFILE_H
+
+#include "subfile.h"
+
+namespace LOTRO_DAT {
+namespace Subfiles {
+
+struct TextFragment {
+    long long fragment_id;
+    std::u16string text;
+    std::string args;
+
+    friend bool operator < (const TextFragment &first, const TextFragment &second) {
+        return first.fragment_id < second.fragment_id;
+    }
+};
+
+template<> class Subfile<TEXT> {
+  public:
+    static BinaryData BuildForImport(const BinaryData& old_data, const SubfileData& outer_data);
+
+    static SubfileData BuildForExport(const BinaryData& inner_data);
+  
+  private:
+    static std::vector<std::u16string> MakePieces(const BinaryData &data, long long &offset);
+
+    static std::vector<long long> MakeArgumentReferences(const BinaryData &data, long long &offset);
+
+    static std::vector<std::vector<BinaryData>> MakeArgumentStrings(const BinaryData &data, long long &offset);
+
+    static std::vector<TextFragment> ParsePatchFragments(const SubfileData &data);
+
+    static BinaryData BuildPieces(const BinaryData &data, const TextFragment &new_data, long long &offset);
+
+    static BinaryData BuildArgumentReferences(const BinaryData &data, const TextFragment &new_data, long long &offset);
+
+    static BinaryData BuildArgumentStrings(const BinaryData &data, const TextFragment &new_data, long long &offset);
+
+    static BinaryData GetPieceData(const BinaryData &data, long long &offset);
+
+    static BinaryData GetArgumentReferenceData(const BinaryData &data, long long &offset);
+
+    static BinaryData GetArgumentStringsData(const BinaryData &data, long long &offset);
+};
+
+}; // namespace Subfiles
+}; // namespace LOTRO_DAT
+
+#endif //LOTRO_DAT_TEXTSUBFILE_H

+ 19 - 32
import/LotroDat/Subfiles/UnknownSubFile.h

@@ -1,32 +1,19 @@
-//
-// Created by Иван_Архипов on 24.11.2017.
-//
-
-#ifndef LOTRO_DAT_LIBRARY_UNKNOWNSUBFILE_H
-#define LOTRO_DAT_LIBRARY_UNKNOWNSUBFILE_H
-
-#include "../SubFile.h"
-
-namespace LOTRO_DAT {
-    class UnknownSubFile : public SubFile {
-    public:
-        UnknownSubFile() = delete;
-        explicit UnknownSubFile(const UnknownSubFile &other) = delete;
-        SubFile &operator =(const UnknownSubFile &other) = delete;
-
-        explicit UnknownSubFile(SubFile preinit_file);
-
-        FILE_TYPE FileType() const override;
-        std::string Extension() const override;
-
-        SubfileData PrepareForExport(const BinaryData &file_data) override;
-
-        BinaryData MakeForImport(const BinaryData &old_data, const SubfileData &data) override;
-
-    };
-};
-
-
-
-
-#endif //LOTRO_DAT_LIBRARY_UNKNOWNSUBFILE_H
+#ifndef LOTRO_DAT_UNKNOWNSUBFILE_H
+#define LOTRO_DAT_UNKNOWNSUBFILE_H
+
+#include "subfile.h"
+
+namespace LOTRO_DAT {
+namespace Subfiles {
+
+template<> class Subfile<UNKNOWN> {
+  public:
+    static BinaryData BuildForImport(const BinaryData& old_data, const SubfileData& outer_data);
+
+    static SubfileData BuildForExport(const BinaryData& inner_data);
+};
+
+}; // namespace Subfiles
+}; // namespace LOTRO_DAT
+
+#endif //LOTRO_DAT_UNKNOWNSUBFILE_H

+ 19 - 32
import/LotroDat/Subfiles/WavSubFile.h

@@ -1,32 +1,19 @@
-//
-// Created by Иван_Архипов on 24.11.2017.
-//
-
-#ifndef LOTRO_DAT_LIBRARY_WAVSUBFILE_H
-#define LOTRO_DAT_LIBRARY_WAVSUBFILE_H
-
-#include "../SubFile.h"
-
-namespace LOTRO_DAT {
-    class WavSubFile : public SubFile {
-    public:
-        WavSubFile() = delete;
-        explicit WavSubFile(const WavSubFile &other) = delete;
-        WavSubFile &operator =(const WavSubFile &other) = delete;
-
-        explicit WavSubFile(SubFile preinit_file);
-
-
-        FILE_TYPE FileType() const override;
-
-        std::string Extension() const override;
-
-        SubfileData PrepareForExport(const BinaryData &file_data) override;
-
-        BinaryData MakeForImport(const BinaryData &old_data, const SubfileData &data) override;
-
-    };
-};
-
-
-#endif //LOTRO_DAT_LIBRARY_WAVSUBFILE_H
+#ifndef LOTRO_DAT_WAVSUBFILE_H
+#define LOTRO_DAT_WAVSUBFILE_H
+
+#include "subfile.h"
+
+namespace LOTRO_DAT {
+namespace Subfiles {
+
+template<> class Subfile<WAV> {
+  public:
+    static BinaryData BuildForImport(const BinaryData& old_data, const SubfileData& outer_data);
+
+    static SubfileData BuildForExport(const BinaryData& inner_data);
+};
+
+}; // namespace Subfiles
+}; // namespace LOTRO_DAT
+
+#endif //LOTRO_DAT_WAVSUBFILE_H

+ 115 - 0
import/LotroDat/datexportapi.h

@@ -0,0 +1,115 @@
+#include <windows.h>
+
+namespace DatExportApiPrivate {
+  typedef int (__stdcall * OpenDatFileFunc)(
+                                        int, // handle
+                                        const char*, // filename
+                                        unsigned int, // flags
+                                        int*, // did_master_map
+                                        int*, // block_size
+                                        int*, // vnum_dat_file
+                                        int*, // vnum_game_data
+                                        unsigned long*, // dat_file_id
+                                        void*, // dat_id_stamp
+                                        void* // first_iter_guid
+                                        );
+
+  typedef int (__stdcall * GetNumSubfilesFunc)(
+                                        int // handle
+                                        );
+
+  typedef int (__stdcall * GetSubFileSizesFunc)(
+                                        int, // handle
+                                        int*, // file_id list pointer
+                                        int*, // size list pointer
+                                        int*, // iteration list pointer
+                                        int, // offset (index from 0 to num_subfiles - 1)
+                                        int // count of files to get size of
+                                        );
+
+  typedef int (__stdcall * GetSubFileVersionFunc)(
+                                        int, // handle
+                                        int // file_id
+                                        );
+  
+  typedef int (__stdcall * GetSubfileDataFunc)(
+                                        int, // handle
+                                        int, // file_id
+                                        void*, // buffer for storing data
+                                        int, // 0
+                                        int* // version
+                                        );
+
+
+  typedef int (__stdcall * CloseDatFileFunc)(
+                                        int // handle
+                                        );
+
+  typedef int (__stdcall * PurgeSubFileDataFunc)(
+                                        int, // handle
+                                        int // file_id
+                                        );
+
+  typedef int (__stdcall * PutSubFileDataFunc)(
+                                        int, // handle
+                                        int, // file_id
+                                        void*, // buffer with subfile data
+                                        int, // 0
+                                        int, // size of data in bytes
+                                        int, // version
+                                        int, // iteration
+                                        bool // 0
+                                        );
+
+  typedef int (__stdcall * FlushFunc)(
+                                        int // handle
+                                        );
+};
+
+
+class DatExportApi {
+ public:
+  DatExportApi();
+
+  int OpenDatFile(int handle, const char* filename, unsigned int flags);
+
+  int GetNumSubfiles(int handle);
+
+  void GetSubfileSizes(int handle, int* file_ids, int* size, int* iteration, int offset, int count);
+
+  int GetSubfileVersion(int handle, int file_id);
+
+  int GetSubfileData(int handle, int file_id, void* target_buf, int& version);
+
+  void CloseDatFile(int handle);
+
+  int PurgeSubfileData(int handle, int file_id);
+
+  int PutSubfileData(int handle, int file_id, void* data, int offset, int size, int version, int iteration, bool compress = false);
+
+  void Flush(int handle);
+
+  ~DatExportApi();
+
+ private:
+  HMODULE datexport_dll_;
+
+  FARPROC open_dat_file_addr_;
+  volatile DatExportApiPrivate::OpenDatFileFunc open_dat_file_func_;
+  FARPROC get_num_subfiles_addr_;
+  volatile DatExportApiPrivate::GetNumSubfilesFunc get_num_subfiles_func_;
+  FARPROC get_subfile_sizes_addr_;
+  volatile DatExportApiPrivate::GetSubFileSizesFunc get_subfile_sizes_func_;
+  FARPROC get_subfile_version_addr_;
+  volatile DatExportApiPrivate::GetSubFileVersionFunc get_subfile_version_func_;
+  FARPROC get_subfile_data_addr_;
+  volatile DatExportApiPrivate::GetSubfileDataFunc get_subfile_data_func_;
+  FARPROC close_dat_file_addr_;
+  volatile DatExportApiPrivate::CloseDatFileFunc close_dat_file_func_;
+  FARPROC purge_subfile_data_addr_;
+  volatile DatExportApiPrivate::PurgeSubFileDataFunc purge_subfile_data_func_;
+  FARPROC put_subfile_data_addr_;
+  volatile DatExportApiPrivate::PutSubFileDataFunc put_subfile_data_func_;
+  FARPROC flush_addr_;
+  volatile DatExportApiPrivate::FlushFunc flush_func_; 
+};

+ 0 - 1
src/Legacy/Legacy.pro

@@ -94,7 +94,6 @@ INCLUDEPATH += $$PWD/gui
 
 LIBS += -llibLotroDat_static
 LIBS += -llibyaml-cpp
-LIBS += -llibzlibstatic
 
 
 CONFIG(debug, debug|release) {

+ 1 - 1
src/Legacy/legacyapplication.cpp

@@ -74,7 +74,7 @@ bool LegacyApplication::init()
     patch_downloader_thread_->start();
 
     qDebug() << "Starting GUI initialisation...";
-    gui = new MainWindow(nullptr);
+    gui = new MainWindow();
     connect(this, &LegacyApplication::ErrorStatusChanged, gui, &MainWindow::onErrorStatusChanged);
     connect(this, &LegacyApplication::SecondsToNextTryToInitChanged, gui, &MainWindow::onSecondsToNextTryToInitChanged);
 

+ 111 - 274
src/Legacy/models/lotrodatmanager.cpp

@@ -5,139 +5,29 @@
 #include <QDebug>
 #include <QProcess>
 
-Q_DECLARE_METATYPE(LOTRO_DAT::DatLocaleManager::LOCALE)
 Q_DECLARE_METATYPE(LotroDatManager::Category)
-Q_DECLARE_METATYPE(LotroDatManager::Status)
 
 
-void debug::ClientLocalDatStatusChangedHandler(DatStatus::ProgressInfo info) {
-    if (info.status == DatStatus::DAT_STATUS::E_FREE) {
-        std::cout << "CLIENT_LOCAL: operation finished" << std::endl;
-        return;
-    }
-    if (info.status == DatStatus::DAT_STATUS::E_BACKUP_CREATING) {
-        std::cout << "CLIENT_LOCAL: creating backup " << info.percentage << "% "
-        << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
-        return;
-    }
-    if (info.status == DatStatus::DAT_STATUS::E_BACKUP_REMOVING) {
-        std::cout << "CLIENT_LOCAL: removing backup " << info.percentage << "% "
-        << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
-        return;
-    }
-    if (info.status == DatStatus::DAT_STATUS::E_BACKUP_RESTORING) {
-        std::cout << "CLIENT_LOCAL: restoring backup " << info.percentage << "% "
-        << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
-        return;
-    }
-    if (info.status == DatStatus::DAT_STATUS::E_COMMITING) {
-        std::cout << "CLIENT_LOCAL: applying locales " << info.percentage << "% "
-        << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
-        return;
-    }
-    if (info.status == DatStatus::DAT_STATUS::E_EXTRACTING) {
-        std::cout << "CLIENT_LOCAL: extracting data " << info.percentage << "% "
-        << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
-        return;
-    }
-    if (info.status == DatStatus::DAT_STATUS::E_GATHERING_INFO) {
-        std::cout << "CLIENT_LOCAL: gathering info " << info.percentage << "% "
-        << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
-        return;
-    }
-    if (info.status == DatStatus::DAT_STATUS::E_INITIALISING) {
-        std::cout << "CLIENT_LOCAL: initialising " << info.percentage << "% "
-        << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
-        return;
-    }
-    if (info.status == DatStatus::DAT_STATUS::E_PATCHING) {
-        std::cout << "CLIENT_LOCAL: applying patch " << info.percentage << "% "
-        << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
-        return;
-    }
-}
-
-void debug::ClientGeneralDatStatusChangedHandler(DatStatus::ProgressInfo info) {
-    if (info.status == DatStatus::DAT_STATUS::E_FREE) {
-        std::cout << "CLIENT_GENERAL: operation finished" << std::endl;
-        return;
-    }
-    if (info.status == DatStatus::DAT_STATUS::E_BACKUP_CREATING) {
-        std::cout << "CLIENT_GENERAL: creating backup " << info.percentage << "% "
-        << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
-        return;
-    }
-    if (info.status == DatStatus::DAT_STATUS::E_BACKUP_REMOVING) {
-        std::cout << "CLIENT_GENERAL: removing backup " << info.percentage << "% "
-        << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
-        return;
-    }
-    if (info.status == DatStatus::DAT_STATUS::E_BACKUP_RESTORING) {
-        std::cout << "CLIENT_GENERAL: restoring backup " << info.percentage << "% "
-        << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
-        return;
-    }
-    if (info.status == DatStatus::DAT_STATUS::E_COMMITING) {
-        std::cout << "CLIENT_GENERAL: applying locales " << info.percentage << "% "
-        << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
-        return;
-    }
-    if (info.status == DatStatus::DAT_STATUS::E_EXTRACTING) {
-        std::cout << "CLIENT_GENERAL: extracting data " << info.percentage << "% "
-        << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
-        return;
-    }
-    if (info.status == DatStatus::DAT_STATUS::E_GATHERING_INFO) {
-        std::cout << "CLIENT_GENERAL: gathering info " << info.percentage << "% "
-        << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
-        return;
-    }
-    if (info.status == DatStatus::DAT_STATUS::E_INITIALISING) {
-        std::cout << "CLIENT_GENERAL: initialising " << info.percentage << "% "
-        << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
-        return;
-    }
-    if (info.status == DatStatus::DAT_STATUS::E_PATCHING) {
-        std::cout << "CLIENT_GENERAL: applying patch " << info.percentage << "% "
-        << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
-        return;
-    }
+LotroDatManager::LotroDatManager(QObject *parent) :  QObject(parent), client_local_file_(1), client_general_file_(2) {
 }
 
-LotroDatManager::LotroDatManager(QObject *parent) :
-    QObject(parent) {
-
-    qRegisterMetaType<Status>("Status");
-    qRegisterMetaType<LOTRO_DAT::DatLocaleManager::LOCALE>("LOCALE");
-    client_local_file_.GetStatusModule().AddStatusChangedCallbackFunction(client_local_status_updated_callback_);
-    client_general_file_.GetStatusModule().AddStatusChangedCallbackFunction(client_general_status_updated_callback_);
-}
-
-LotroDatManager::~LotroDatManager()
-{
+LotroDatManager::~LotroDatManager() {
     deinitializeManager();
 }
 
-bool LotroDatManager::Initialised()
-{
+bool LotroDatManager::initialised() {
     return client_general_file_.Initialized() && client_local_file_.Initialized();
 }
 
-bool LotroDatManager::NotPatched()
-{
-    return !client_local_file_.GetStatusModule().CheckIfNotPatched() && !client_local_file_.GetStatusModule().CheckIfNotPatched();
-}
-
-bool LotroDatManager::DatPathIsRelevant()
-{
+bool LotroDatManager::datPathIsRelevant() {
     QString game_folder = Settings::getValue("Lotro/game_path").toString();
     QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
 
     QString client_local_filepath = game_folder + "/client_local_" + locale_prefix + ".dat";
     QString client_general_filepath = game_folder + "/client_general.dat";
 
-    QString client_local_current_path = QString::fromStdString(client_local_file_.GetIO().GetFilename().value);
-    QString client_general_current_path = QString::fromStdString(client_general_file_.GetIO().GetFilename().value);
+    QString client_local_current_path = QString::fromStdString(client_local_file_.GetFilename());
+    QString client_general_current_path = QString::fromStdString(client_general_file_.GetFilename());
 
     return QFileInfo(client_local_filepath) != QFileInfo(client_local_current_path)
             || QFileInfo(client_general_filepath) != QFileInfo(client_general_current_path);
@@ -154,13 +44,6 @@ void LotroDatManager::initializeManager()
     QString client_local_filepath = game_folder + "/client_local_" + locale_prefix + ".dat";
     QString client_general_filepath = game_folder + "/client_general.dat";
 
-    if (game_folder == "none") {
-        qDebug() << __FUNCTION__ << "Finished initialisation LotroDatManager - error: .dat files not found!";
-        emit errorOccured("initializeManager", {}, "FolderNotDefined");
-        emit operationFinished("initializeManager", {}, false);
-        return;
-    }
-
     if (!FileSystem::fileExists(client_local_filepath) || !FileSystem::fileExists(client_general_filepath)) {
         emit errorOccured("initializeManager", {}, "DatFilesNotFound");
         emit operationFinished("initializeManager", {}, false);
@@ -179,14 +62,12 @@ void LotroDatManager::initializeManager()
 
     // Initialising client_local_*.dat file and client_general.dat
 
-    auto client_local_init_res = client_local_file_.Initialise(client_local_filepath.toStdString(), 0);
-    auto client_general_init_res = client_general_file_.Initialise(client_general_filepath.toStdString(), 1);
+    auto client_local_init_res = client_local_file_.Init(client_local_filepath.toStdString());
+    auto client_general_init_res = client_general_file_.Init(client_general_filepath.toStdString());
 
-    if (client_local_init_res.result != LOTRO_DAT::SUCCESS
-        || client_general_init_res.result != LOTRO_DAT::SUCCESS)
-    {
-        client_local_file_.Deinitialize();
-        client_general_file_.Deinitialize();
+    if (!client_local_init_res || !client_general_init_res) {
+        client_local_file_.Deinit();
+        client_general_file_.Deinit();
 
         qDebug() << __FUNCTION__ << "Finished LotroDatManager initialisation - error: DatFile initialisation error!";
 
@@ -196,57 +77,55 @@ void LotroDatManager::initializeManager()
     }
 
     qDebug() << "LotroDatManager initialisation successfull! Dat files: "
-             << QString::fromStdString(client_general_file_.GetIO().GetFilename().value)
-             << QString::fromStdString(client_local_file_.GetIO().GetFilename().value);
+             << QString::fromStdString(client_general_file_.GetFilename())
+             << QString::fromStdString(client_local_file_.GetFilename());
 
     emit operationFinished("initializeManager", {}, true);
 }
 
-void LotroDatManager::deinitializeManager()
-{
+void LotroDatManager::deinitializeManager() {
     emit operationStarted("deinitializeManager");
-    client_local_file_.Deinitialize();
-    client_general_file_.Deinitialize();
+    client_local_file_.Deinit();
+    client_general_file_.Deinit();
     emit operationFinished("deinitializeManager");
 }
 
-void LotroDatManager::startGame(LOTRO_DAT::DatLocaleManager::LOCALE locale)
-{
-    emit operationStarted("startGame", {locale});
-
-    client_general_file_.GetLocaleManager().SetLocale(locale);
-    client_local_file_.GetLocaleManager().SetLocale(locale);
+void LotroDatManager::startGame(bool freeze_updates) {
+    // if freeze_updates is set to True, original game
+    // launcher will be replaced with special program,
+    // which controls lotro startup and prevents from updates
+    emit operationStarted("startGame");
 
     QString game_folder = Settings::getValue("Lotro/game_path").toString();
 
     if (game_folder == "none") {
         qDebug() << __FUNCTION__ << "Starting game FAILED - game folder wasnt set!";
-        emit errorOccured("startGame", {locale}, "GameFolderNotSet");
-        emit operationFinished("startGame", {locale}, false);
+        emit errorOccured("startGame", {}, "GameFolderNotSet");
+        emit operationFinished("startGame", {}, false);
         return;
     }
 
     if (!FileSystem::fileExists(QApplication::applicationDirPath() + "/Launcher.exe")) {
         qDebug() << __FUNCTION__ << "Starting game FAILED - no game launcher in legacy directory found!";
-        emit errorOccured("startGame", {locale}, "NoGameLauncherInLegacyDir");
-        emit operationFinished("startGame", {locale}, false);
+        emit errorOccured("startGame", {}, "NoGameLauncherInLegacyDir");
+        emit operationFinished("startGame", {}, false);
         return;
     }
 
-    if (locale == LOTRO_DAT::DatLocaleManager::PATCHED) {
+    if (freeze_updates) {
         QFile::remove(game_folder + "/lotro_ru.exe");
         if (!QFile::copy(QApplication::applicationDirPath() + "/LotroLauncher.exe", game_folder + "/lotro_ru.exe")) {
             qDebug() << __FUNCTION__ << "Starting game FAILED - cannot copy LotroLauncher to lotro_ru.exe!!";
-            emit errorOccured("startGame", {locale}, "LauncherCopyFailed");
-            emit operationFinished("startGame", {locale}, false);
+            emit errorOccured("startGame", {}, "LauncherCopyFailed");
+            emit operationFinished("startGame", {}, false);
             return;
         }
 
         QFile::remove(game_folder + "/LotroLauncher.exe");
         if (!QFile::copy(QApplication::applicationDirPath() + "/Launcher.exe", game_folder + "/LotroLauncher.exe")) {
             qDebug() << __FUNCTION__ << "Starting game FAILED - cannot copy GameLauncher to LotroLauncher!!";
-            emit errorOccured("startGame", {locale}, "NoAccessToGameLauncher");
-            emit operationFinished("startGame", {locale}, false);
+            emit errorOccured("startGame", {}, "NoAccessToGameLauncher");
+            emit operationFinished("startGame", {}, false);
             return;
         }
 
@@ -259,164 +138,122 @@ void LotroDatManager::startGame(LOTRO_DAT::DatLocaleManager::LOCALE locale)
         QFile::remove(game_folder + "/LotroLauncher.exe");
         if (!QFile::copy(QApplication::applicationDirPath() + "/LotroLauncher.exe", game_folder + "/LotroLauncher.exe")) {
             qDebug() << __FUNCTION__ << "Starting game FAILED - cannot copy LotroLauncher from working dir to LotroLauncher in lotro dir!!";
-            emit errorOccured("startGame", {locale}, "NoAccessToGameLauncher");
-            emit operationFinished("startGame", {locale}, false);
+            emit errorOccured("startGame", {}, "NoAccessToGameLauncher");
+            emit operationFinished("startGame", {}, false);
             return;
         }
     }
 
-    if (!startLotroLauncherWithParameters(locale)) {
-        emit errorOccured("startGame", {locale}, "StartLotroLauncherWithParametersFailed");
-        emit operationFinished("startGame", {locale}, false);
-        return;
+    QStringList args;
+    if (freeze_updates) {
+        args << "gamelaunch" << "-disablePatch";
     }
 
-    emit operationFinished("startGame", {locale}, true);
-}
-
-void LotroDatManager::installPatch(QString patch_name, QString database_path)
-{
-    emit operationStarted("installPatch", {patch_name, database_path});
-    LOTRO_DAT::Database db;
-
-    if (!db.InitDatabase(database_path.toStdString())) {
-        emit errorOccured("installPatch", {patch_name, database_path}, "ErrorInitDatabase");
-        emit operationFinished("installPatch", {patch_name, database_path}, false);
-        return;
+    if (Settings::getValue("Lotro/skip_raw_download").toBool()) {
+        args << "-skiprawdownload";
     }
 
-    if (client_local_file_.GetPatcher().PatchAllDatabase(&db).result != LOTRO_DAT::SUCCESS) {
-        db.CloseDatabase();
-        emit errorOccured("installPatch", {patch_name, database_path}, "ErrorPatchClientLocal");
-        emit operationFinished("installPatch", {patch_name, database_path}, false);
-        return;
+    if (Settings::getValue("Lotro/no_splash_screen").toBool()) {
+        args << "-nosplashscreen";
     }
 
-    if (client_general_file_.GetPatcher().PatchAllDatabase(&db).result != LOTRO_DAT::SUCCESS) {
-        db.CloseDatabase();
-        emit errorOccured("installPatch", {patch_name, database_path});
-        emit operationFinished("installPatch", {patch_name, database_path}, false);
-        return;
+    client_general_file_.Deinit();
+    client_local_file_.Deinit();
+
+    QString username = Settings::getValue("Account/username").toString();
+    QString password = Settings::getValue("Account/password").toString();
+    if (!username.isEmpty() && !password.isEmpty()) {
+        args << "-username" << username << "-password" << password;
     }
 
-    db.CloseDatabase();
-    emit operationFinished("installPatch", {patch_name, database_path}, true);
-}
+    qDebug() << __FUNCTION__ << "Starting game with arguments: " << args;
 
-void LotroDatManager::enableCategory(QString patch_name, LotroDatManager::Category category)
-{
-    emit operationStarted("enableCategory", {patch_name, category});
+    QFile f(Settings::getValue("Lotro/game_path").toString() + "/LotroLauncher.exe");
+    QProcess process;
 
-    if (client_local_file_.GetLocaleManager().EnableCategory(category).result != LOTRO_DAT::SUCCESS) {
-        emit errorOccured("enableCategory", {patch_name, category}, "ErrorEnableCategoryClientLocal");
-        emit operationFinished("enableCategory", {patch_name, category}, false);
-        return;
-    }
+    if (FileSystem::fileExists(f.fileName())) {
+        if (f.fileName().contains(" ")) {
+            f.setFileName("\"" + f.fileName() + "\"");
+        }
 
-    if (client_general_file_.GetLocaleManager().EnableCategory(category).result != LOTRO_DAT::SUCCESS) {
-        emit errorOccured("enableCategory", {patch_name, category}, "ErrorEnableCategoryClientGeneral");
-        emit operationFinished("enableCategory", {patch_name, category}, false);
-        return;
+        process.startDetached(f.fileName(), args);
+        process.waitForFinished(-1);
+        QApplication::quit();
     }
 
-    emit operationFinished("enableCategory", {patch_name, category});
+    emit operationFinished("startGame");
 }
 
-void LotroDatManager::disableCategory(QString patch_name, LotroDatManager::Category category)
-{
-    emit operationStarted("disableCategory", {patch_name, category});
+void LotroDatManager::installPatch(QString patch_name, QString database_path, RESOURCE_FILE_TYPE dat_file) {
+    emit operationStarted("installPatch", {patch_name, database_path});
+    LOTRO_DAT::Database db;
 
-    if (client_local_file_.GetLocaleManager().DisableCategory(category).result != LOTRO_DAT::SUCCESS) {
-        emit errorOccured("disableCategory", {patch_name, category}, "ErrorDisableCategoryClientLocal");
-        emit operationFinished("disableCategory", {patch_name, category}, false);
+    if (!db.InitDatabase(database_path.toStdString())) {
+        qDebug() << __FUNCTION__ << "Error database " << database_path << ": failed to open!";
         return;
     }
 
-    if (client_general_file_.GetLocaleManager().DisableCategory(category).result != LOTRO_DAT::SUCCESS) {
-        emit errorOccured("disableCategory", {patch_name, category}, "ErrorDisableCategoryClientGeneral");
-        emit operationFinished("disableCategory", {patch_name, category}, false);
-        return;
+    size_t patched_files_num = 0;
+
+    LOTRO_DAT::SubfileData file;
+    int i = 0;
+    const int total_files = db.CountRows();
+    qDebug() << "Patching all files from database...";
+    while (!(file = db.GetNextFile()).Empty()) {
+        if (i * 100 / total_files != (i - 1) * 100 / total_files) {
+            qDebug() << "Completed " << i * 100 / total_files << "%";
+        }
+        ++i;
+
+        if (!file.options["fid"]) {
+            continue;
+        }
+
+        if (dat_file == E_CLIENT_LOCAL) {
+            client_local_file_.PatchFile(file);
+        } else if (dat_file == E_CLIENT_GENERAL) {
+            client_general_file_.PatchFile(file);
+        }
+        ++patched_files_num;
     }
 
-    emit operationFinished("disableCategory", {patch_name, category}, true);
+    db.CloseDatabase();
+    emit operationFinished("installPatch", {patch_name, database_path}, true);
 }
 
 void LotroDatManager::createBackup()
 {
-    emit operationStarted("createBackup");
-    QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
-    QString client_local_backup_path = QApplication::applicationDirPath() + Settings::getValue("Backup/path").toString() + "client_local_" + locale_prefix + ".dat";
-    QString client_general_backup_path = QApplication::applicationDirPath() + Settings::getValue("Backup/path").toString() + "client_general.dat";
-    auto loc_res = client_local_file_.GetBackupManager().CreateBackup(client_local_backup_path.toStdString());
-    auto gen_res = client_general_file_.GetBackupManager().CreateBackup(client_general_backup_path.toStdString());
-    bool operations_result = (loc_res.result == LOTRO_DAT::SUCCESS && gen_res.result == LOTRO_DAT::SUCCESS);
-
-    emit operationFinished("createBackup", {client_local_backup_path, client_general_backup_path}, operations_result);
+//    emit operationStarted("createBackup");
+//    QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
+//    QString client_local_backup_path = QApplication::applicationDirPath() + Settings::getValue("Backup/path").toString() + "client_local_" + locale_prefix + ".dat";
+//    QString client_general_backup_path = QApplication::applicationDirPath() + Settings::getValue("Backup/path").toString() + "client_general.dat";
+//    auto loc_res = client_local_file_.GetBackupManager().CreateBackup(client_local_backup_path.toStdString());
+//    auto gen_res = client_general_file_.GetBackupManager().CreateBackup(client_general_backup_path.toStdString());
+//    bool operations_result = (loc_res.result == LOTRO_DAT::SUCCESS && gen_res.result == LOTRO_DAT::SUCCESS);
+
+//    emit operationFinished("createBackup", {client_local_backup_path, client_general_backup_path}, operations_result);
 }
 
 void LotroDatManager::restoreFromBackup()
 {
-    emit operationStarted("restoreFromBackup");
-    QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
-    QString client_local_backup_path = QApplication::applicationDirPath() + Settings::getValue("Backup/path").toString() + "client_local_" + locale_prefix + ".dat";
-    QString client_general_backup_path = QApplication::applicationDirPath() + Settings::getValue("Backup/path").toString() + "client_general.dat";
-    auto loc_res = client_local_file_.GetBackupManager().RestoreFromBackup(client_local_backup_path.toStdString());
-    auto gen_res = client_general_file_.GetBackupManager().RestoreFromBackup(client_general_backup_path.toStdString());
-    bool operations_result = (loc_res.result == LOTRO_DAT::SUCCESS && gen_res.result == LOTRO_DAT::SUCCESS);
-    emit operationFinished("restoreFromBackup", {}, operations_result);
+//    emit operationStarted("restoreFromBackup");
+//    QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
+//    QString client_local_backup_path = QApplication::applicationDirPath() + Settings::getValue("Backup/path").toString() + "client_local_" + locale_prefix + ".dat";
+//    QString client_general_backup_path = QApplication::applicationDirPath() + Settings::getValue("Backup/path").toString() + "client_general.dat";
+//    auto loc_res = client_local_file_.GetBackupManager().RestoreFromBackup(client_local_backup_path.toStdString());
+//    auto gen_res = client_general_file_.GetBackupManager().RestoreFromBackup(client_general_backup_path.toStdString());
+//    bool operations_result = (loc_res.result == LOTRO_DAT::SUCCESS && gen_res.result == LOTRO_DAT::SUCCESS);
+//    emit operationFinished("restoreFromBackup", {}, operations_result);
 }
 
 void LotroDatManager::removeBackup()
 {
-    emit operationStarted("removeBackup");
-    QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
-    QString client_local_backup_path = QApplication::applicationDirPath() + Settings::getValue("Backup/path").toString() + "client_local_" + locale_prefix + ".dat";
-    QString client_general_backup_path = QApplication::applicationDirPath() + Settings::getValue("Backup/path").toString() + "client_general.dat";
-    auto loc_res = client_local_file_.GetBackupManager().RemoveBackup(client_local_backup_path.toStdString());
-    auto gen_res = client_general_file_.GetBackupManager().RemoveBackup(client_general_backup_path.toStdString());
-    bool operations_result = (loc_res.result == LOTRO_DAT::SUCCESS && gen_res.result == LOTRO_DAT::SUCCESS);
-    emit operationFinished("removeBackup", {}, operations_result);
-}
-
-bool LotroDatManager::startLotroLauncherWithParameters(LOTRO_DAT::DatLocaleManager::LOCALE locale)
-{
-    QStringList args;
-    if (Settings::getValue("Lotro/skip_raw_download").toBool()) {
-        args << "-skiprawdownload";
-    }
-
-    if (Settings::getValue("Lotro/no_splash_screen").toBool()) {
-        args << "-nosplashscreen";
-    }
-
-    if (locale == LOTRO_DAT::DatLocaleManager::PATCHED) {
-        args << "gamelaunch" << "-disablePatch";
-    }
-
-    client_general_file_.Deinitialize();
-    client_local_file_.Deinitialize();
-
-    QString username = Settings::getValue("Account/username").toString();
-    QString password = Settings::getValue("Account/password").toString();
-    if (!username.isEmpty() && !password.isEmpty()) {
-        args << "-username" << username << "-password" << password;
-    }
-
-    qDebug() << __FUNCTION__ << "Starting game with arguments: " << args;
-
-    QFile f(Settings::getValue("Lotro/game_path").toString() + "/LotroLauncher.exe");
-    QProcess process;
-
-    if (FileSystem::fileExists(f.fileName())) {
-        if (f.fileName().contains(" ")) {
-            f.setFileName("\"" + f.fileName() + "\"");
-        }
-
-        process.startDetached(f.fileName(), args);
-        process.waitForFinished(-1);
-        QApplication::quit();
-        return true;
-    } else {
-        return false;
-    }
+//    emit operationStarted("removeBackup");
+//    QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
+//    QString client_local_backup_path = QApplication::applicationDirPath() + Settings::getValue("Backup/path").toString() + "client_local_" + locale_prefix + ".dat";
+//    QString client_general_backup_path = QApplication::applicationDirPath() + Settings::getValue("Backup/path").toString() + "client_general.dat";
+//    auto loc_res = client_local_file_.GetBackupManager().RemoveBackup(client_local_backup_path.toStdString());
+//    auto gen_res = client_general_file_.GetBackupManager().RemoveBackup(client_general_backup_path.toStdString());
+//    bool operations_result = (loc_res.result == LOTRO_DAT::SUCCESS && gen_res.result == LOTRO_DAT::SUCCESS);
+//    emit operationFinished("removeBackup", {}, operations_result);
 }

+ 20 - 36
src/Legacy/models/lotrodatmanager.h

@@ -7,23 +7,17 @@
 #include <QVector>
 #include <QVariant>
 
-#include <LotroDat/LotroDat.h>
-
-using LOTRO_DAT::DatStatus;
-
-namespace debug {
-
-void ClientLocalDatStatusChangedHandler(DatStatus::ProgressInfo info);
-
-void ClientGeneralDatStatusChangedHandler(DatStatus::ProgressInfo info);
-}
+#include <LotroDat/datfile.h>
+#include <LotroDat/database.h>
 
 class LotroDatManager : public QObject
 {
     Q_OBJECT
 
 public:
-    using Status = LOTRO_DAT::DatStatus::ProgressInfo;
+    struct Status {
+
+    };
 
     enum Category : int {
         E_TEXTS_COMMON = 100,
@@ -36,29 +30,33 @@ public:
         E_FONTS_COMMON = 400
     };
 
-public:
-    explicit LotroDatManager(QObject *parent = nullptr);
+    enum RESOURCE_FILE_TYPE : int {
+        E_CLIENT_LOCAL = 0,
+        E_CLIENT_GENERAL = 1
+    };
 
+public:
     ~LotroDatManager();
 
-    bool Initialised();
+    void init();
+    bool initialised();
 
-    bool NotPatched();
+//    TODO: bool NotPatched();
+
+    bool datPathIsRelevant();
+
+private:
+    explicit LotroDatManager(QObject *parent = nullptr);
 
-    bool DatPathIsRelevant();
 
 public slots:
     void initializeManager();
 
     void deinitializeManager();
 
-    void startGame(LOTRO_DAT::DatLocaleManager::LOCALE locale);
-
-    void installPatch(QString patch_name, QString database_path);
+    void startGame(bool freeze_updates);
 
-    void enableCategory(QString patch_name, LotroDatManager::Category category);
-
-    void disableCategory(QString patch_name, LotroDatManager::Category category);
+    void installPatch(QString patch_name, QString database_path, RESOURCE_FILE_TYPE dat_file);
 
     void createBackup();
 
@@ -66,9 +64,6 @@ public slots:
 
     void removeBackup();
 
-private:
-    bool startLotroLauncherWithParameters(LOTRO_DAT::DatLocaleManager::LOCALE locale);
-
 signals:
     void operationStarted(QString operation_name, QVector<QVariant> args = {});
     void errorOccured(QString operation_name, QVector<QVariant> args = {}, QString message = "No error message provided");
@@ -78,17 +73,6 @@ signals:
 private:
     LOTRO_DAT::DatFile client_local_file_;
     LOTRO_DAT::DatFile client_general_file_;
-
-    const LOTRO_DAT::DatStatus::Callback client_local_status_updated_callback_ = [&](Status status) {
-        emit statusChanged(status);
-        debug::ClientLocalDatStatusChangedHandler(status);
-    };
-
-    const LOTRO_DAT::DatStatus::Callback client_general_status_updated_callback_ = [&](Status status) {
-        emit statusChanged(status);
-        debug::ClientGeneralDatStatusChangedHandler(status);
-    };
-
 };
 
 #endif // LEGACYAPP_H

+ 0 - 3
src/Legacy/models/patch/graphicspatch.cpp

@@ -1,7 +1,4 @@
 #include "graphicspatch.h"
-#include "LotroDat/LotroDat.h"
-#include "LotroDat/Database.h"
-#include "models/lotrodatmanager.h"
 
 #include <QUrlQuery>
 #include <QSet>

+ 0 - 1
src/Legacy/models/patch/graphicspatch.h

@@ -4,7 +4,6 @@
 #include <QObject>
 
 #include "models/patch/patch.h"
-#include "models/lotrodatmanager.h"
 
 class GraphicsPatch : public Patch
 {

+ 2 - 2
src/Legacy/models/patch/patch.cpp

@@ -137,8 +137,8 @@ Patch::OperationProgress::OperationProgress(Downloader::Status status)
 }
 
 Patch::OperationProgress::OperationProgress(LotroDatManager::Status status) {
-    install_finished_parts = status.finished_parts;
-    install_total_parts = status.total_parts;
+//    install_finished_parts = status.finished_parts;
+//    install_total_parts = status.total_parts;
 }
 
 Patch::OperationProgress Patch::OperationProgress::operator+(const Patch::OperationProgress &other) const

+ 0 - 2
src/Legacy/models/patch/soundspatch.cpp

@@ -1,6 +1,4 @@
 #include "soundspatch.h"
-#include "LotroDat/LotroDat.h"
-#include "LotroDat/Database.h"
 
 #include <QUrlQuery>
 #include <QSet>

+ 0 - 2
src/Legacy/models/patch/textspatch.cpp

@@ -1,6 +1,4 @@
 #include "textspatch.h"
-#include "LotroDat/LotroDat.h"
-#include "LotroDat/Database.h"
 
 #include <QUrlQuery>
 #include <QSet>

+ 0 - 2
src/Legacy/models/patch/videospatch.cpp

@@ -1,6 +1,4 @@
 #include "videospatch.h"
-#include "LotroDat/LotroDat.h"
-#include "LotroDat/Database.h"
 
 #include <QUrlQuery>
 #include <QSet>

+ 1 - 2
src/Legacy/widgets/aboutwidget.cpp

@@ -8,10 +8,9 @@
 
 #include <QDesktopServices>
 
-AboutWidget::AboutWidget(PatchList *legacy_patches, QWidget *parent)
+AboutWidget::AboutWidget(QWidget *parent)
     : QWidget(parent)
     , ui(new Ui::AboutWidget)
-    , legacy_patches_(legacy_patches)
 {
     ui->setupUi(this);
 }

+ 1 - 3
src/Legacy/widgets/aboutwidget.h

@@ -14,7 +14,7 @@ class AboutWidget : public QWidget
     Q_OBJECT
 
 public:
-    explicit AboutWidget(PatchList* legacy_patches, QWidget *parent = 0);
+    explicit AboutWidget(QWidget *parent = 0);
     ~AboutWidget();
 
 public slots:
@@ -34,8 +34,6 @@ private slots:
 
 private:
     Ui::AboutWidget *ui;
-
-    PatchList *legacy_patches_;
 };
 
 #endif // AboutWidget_H

+ 2 - 2
src/Legacy/widgets/chooseversiondialog.cpp

@@ -42,14 +42,14 @@ void ChooseVersionDialog::on_start_patched_clicked()
 {
     ui->wait_widget->show();
     ui->cancel_widget->hide();
-    QMetaObject::invokeMethod(mgr_, "startGame", Qt::QueuedConnection, Q_ARG(LOTRO_DAT::DatLocaleManager::LOCALE, LOTRO_DAT::DatLocaleManager::PATCHED));
+    QMetaObject::invokeMethod(mgr_, "startGame", Qt::QueuedConnection, Q_ARG(bool, true));
 }
 
 void ChooseVersionDialog::on_start_original_clicked()
 {
     ui->wait_widget->show();
     ui->cancel_widget->hide();
-    QMetaObject::invokeMethod(mgr_, "startGame", Qt::QueuedConnection, Q_ARG(LOTRO_DAT::DatLocaleManager::LOCALE, LOTRO_DAT::DatLocaleManager::ORIGINAL));
+    QMetaObject::invokeMethod(mgr_, "startGame", Qt::QueuedConnection, Q_ARG(bool, false));
 }
 
 void ChooseVersionDialog::on_cancel_clicked()

+ 1 - 2
src/Legacy/widgets/helpwidget.cpp

@@ -7,10 +7,9 @@
 #include <QDebug>
 #include <QScrollBar>
 
-HelpWidget::HelpWidget(PatchList* legacy_patches, QWidget *parent)
+HelpWidget::HelpWidget(QWidget *parent)
     : QWidget(parent)
     , ui(new Ui::HelpWidget)
-    , legacy_patches_(legacy_patches)
 {
     ui->setupUi(this);
     currently_active_entry = ui->menuentry_1;

+ 1 - 3
src/Legacy/widgets/helpwidget.h

@@ -18,7 +18,7 @@ class HelpWidget : public QWidget
     Q_OBJECT
 
 public:
-    explicit HelpWidget(PatchList *legacy_patches, QWidget *parent = 0);
+    explicit HelpWidget(QWidget *parent = 0);
 
     ~HelpWidget();
 
@@ -49,8 +49,6 @@ private slots:
 private:
     Ui::HelpWidget *ui;
 
-    PatchList *legacy_patches_;
-
     QPushButton* currently_active_entry = nullptr;
     QPropertyAnimation* menuHoverWidgetAnimation = nullptr;
     QPropertyAnimation* scrollAreaContentsAnimation = nullptr;

+ 10 - 10
src/Legacy/widgets/mainwindow.cpp

@@ -4,7 +4,8 @@
 
 #include "widgets/chooseversiondialog.h"
 #include "widgets/dialogwindow.h"
-#include "models/patchlist.h"
+#include "models/patchdownloader.h"
+#include "models/lotrodatmanager.h"
 
 #include <QBitmap>
 #include <QPainter>
@@ -26,9 +27,8 @@ namespace Ui {
 class StatusWidget;
 }
 
-MainWindow::MainWindow(PatchList *legacy_patches, QWidget *parent)
+MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent, Qt::Window | Qt::FramelessWindowHint)
-    , legacy_patches_(legacy_patches)
     , ui(new Ui::MainWindow)
     , current_active_entry_(nullptr)
     , current_hovered_entry_(nullptr)
@@ -49,9 +49,9 @@ MainWindow::MainWindow(PatchList *legacy_patches, QWidget *parent)
 
     qDebug() << __FUNCTION__ << "Initialising main frame...";
     status_widget_ = new StatusWidget(this);
-    settings_widget_ = new SettingsWidget(legacy_patches_, this);
-    help_widget_ = new HelpWidget(legacy_patches_, this);
-    about_widget_ = new AboutWidget(legacy_patches_, this);
+    settings_widget_ = new SettingsWidget(nullptr, this);
+    help_widget_ = new HelpWidget(this);
+    about_widget_ = new AboutWidget(this);
 
     ui->content_layout->addWidget(status_widget_);
     ui->content_layout->addWidget(settings_widget_);
@@ -285,8 +285,8 @@ void MainWindow::onPatchOperationsFinished()
 
 void MainWindow::makeConnections()
 {
-    connect(legacy_patches_, &PatchList::patchOperationsStarted, this, &MainWindow::onPatchOperationsStarted);
-    connect(legacy_patches_, &PatchList::patchOperationsFinished, this, &MainWindow::onPatchOperationsFinished);
+//    connect(legacy_patches_, &PatchList::patchOperationsStarted, this, &MainWindow::onPatchOperationsStarted);
+//    connect(legacy_patches_, &PatchList::patchOperationsFinished, this, &MainWindow::onPatchOperationsFinished);
 }
 
 void MainWindow::setupMenuHoverWidget()
@@ -382,13 +382,13 @@ void MainWindow::showChooseVersionDialog()
 //    effect->setBlurRadius(10);
 //    effect->setBlurHints(QGraphicsBlurEffect::QualityHint);
 //    ui->content_area->setGraphicsEffect(effect);
-//    choose_locale_dialog_->show();
+    choose_locale_dialog_->show();
 }
 
 void MainWindow::hideChooseVersionDialog()
 {
 //    ui->content_area->setGraphicsEffect(nullptr);
-//    choose_locale_dialog_->hide();
+    choose_locale_dialog_->hide();
 }
 
 void MainWindow::onErrorStatusChanged(AppErrorStatus status)

+ 3 - 4
src/Legacy/widgets/mainwindow.h

@@ -25,14 +25,15 @@ class MainWindow;
 
 class MenuEntry;
 class DialogWindow;
-class PatchList;
+class LotroDatManager;
+class PatchDownloader;
 
 class MainWindow : public QMainWindow
 {
     Q_OBJECT
 
 public:
-    explicit MainWindow(PatchList *legacy_patches, QWidget *parent = 0);
+    explicit MainWindow(QWidget *parent = 0);
     ~MainWindow();
     int getLastDialogResult();
 
@@ -99,8 +100,6 @@ private:
 private:
     bool show_warning_on_close = false;
 
-    PatchList *legacy_patches_;
-
     Ui::MainWindow *ui;
 
     MenuEntry* current_active_entry_;

+ 19 - 19
src/Legacy/widgets/settingswidget.cpp

@@ -199,25 +199,25 @@ void SettingsWidget::resizeEvent(QResizeEvent *)
 
 void SettingsWidget::onLotroManagerProcessChanged(LotroDatManager::Status status)
 {
-    if (status.status != LOTRO_DAT::DatStatus::E_BACKUP_CREATING &&
-            status.status != LOTRO_DAT::DatStatus::E_BACKUP_REMOVING &&
-            status.status != LOTRO_DAT::DatStatus::E_BACKUP_RESTORING) {
-        return;
-    }
-
-    QString operation;
-    if (status.status == LOTRO_DAT::DatStatus::E_BACKUP_CREATING) {
-        operation = "Создание копии";
-    }
-    if (status.status == LOTRO_DAT::DatStatus::E_BACKUP_REMOVING) {
-        operation = "Удаление копии";
-    }
-    if (status.status == LOTRO_DAT::DatStatus::E_BACKUP_RESTORING) {
-        operation = "Восстановление данных";
-    }
-
-    operation = operation + " " + QString::number(status.percentage, 'f', 1) + "%";
-    ui->backup_status_value->setText(operation);
+//    if (status.status != LOTRO_DAT::DatStatus::E_BACKUP_CREATING &&
+//            status.status != LOTRO_DAT::DatStatus::E_BACKUP_REMOVING &&
+//            status.status != LOTRO_DAT::DatStatus::E_BACKUP_RESTORING) {
+//        return;
+//    }
+
+//    QString operation;
+//    if (status.status == LOTRO_DAT::DatStatus::E_BACKUP_CREATING) {
+//        operation = "Создание копии";
+//    }
+//    if (status.status == LOTRO_DAT::DatStatus::E_BACKUP_REMOVING) {
+//        operation = "Удаление копии";
+//    }
+//    if (status.status == LOTRO_DAT::DatStatus::E_BACKUP_RESTORING) {
+//        operation = "Восстановление данных";
+//    }
+
+//    operation = operation + " " + QString::number(status.percentage, 'f', 1) + "%";
+//    ui->backup_status_value->setText(operation);
 }
 
 void SettingsWidget::onBackupSettingsInfoChanged()