瀏覽代碼

Restructured from src/gui to models/widgets

Ivan Arkhipov 6 年之前
父節點
當前提交
469e4b9160

+ 38 - 37
src/Legacy/Legacy.pro

@@ -14,47 +14,39 @@ CXXFLAGS += -O2 -fno-stack-limit
 CONFIG += resources_big
 
 SOURCES += \
-    src/main.cpp \
-    gui/mainwindow.cpp \
-    src/menuentry.cpp \
-    src/legacyapp.cpp \
-    src/filesystem.cpp \
-    gui/statuswidget.cpp \
-    gui/rusificationwidget.cpp \
-    gui/settingswidget.cpp \
-    gui/newswidget.cpp \
-    gui/helpwidget.cpp \
-    src/networkdownloader.cpp \
-    src/rusificationtreeitem.cpp
+    main.cpp \
+    models/downloader.cpp \
+    models/filesystem.cpp \
+    models/lotromanager.cpp \
+    widgets/helpwidget.cpp \
+    widgets/mainwindow.cpp \
+    widgets/menuentry.cpp \
+    widgets/newswidget.cpp \
+    widgets/rusificationtreeitem.cpp \
+    widgets/rusificationwidget.cpp \
+    widgets/settingswidget.cpp \
+    widgets/statuswidget.cpp
 
 HEADERS += \
-    gui/mainwindow.h \
-    src/menuentry.h \
-    src/legacyapp.h \
-    src/filesystem.h \
-    gui/statuswidget.h \
-    gui/rusificationwidget.h \
-    gui/settingswidget.h \
-    gui/newswidget.h \
-    gui/helpwidget.h \
-    src/networkdownloader.h \
-    src/rusificationtreeitem.h
+    models/downloader.h \
+    models/filesystem.h \
+    models/lotromanager.h \
+    widgets/helpwidget.h \
+    widgets/mainwindow.h \
+    widgets/menuentry.h \
+    widgets/newswidget.h \
+    widgets/rusificationtreeitem.h \
+    widgets/rusificationwidget.h \
+    widgets/settingswidget.h \
+    widgets/statuswidget.h
 
 FORMS += \
-    gui/mainwindow.ui \
-    gui/statuswidget.ui \
-    gui/rusificationwidget.ui \
-    gui/settingswidget.ui \
-    gui/newswidget.ui \
-    gui/helpwidget.ui
-
-CONFIG(debug, debug|release) {
-	RESOURCES += \
-                resources/backgrounds.qrc \
-                resources/common.qrc
-} else {
-	include(build_res.pri)
-}
+    widgets/helpwidget.ui \
+    widgets/mainwindow.ui \
+    widgets/newswidget.ui \
+    widgets/rusificationwidget.ui \
+    widgets/settingswidget.ui \
+    widgets/statuswidget.ui
 
 win32:RC_ICONS = $$PWD/resources/appicon.ico
 
@@ -64,3 +56,12 @@ INCLUDEPATH += $$PWD/gui
 LIBS += -llibLotroDat_static
 LIBS += -llibyaml-cpp
 LIBS += -llibzlibstatic
+
+
+CONFIG(debug, debug|release) {
+        RESOURCES += \
+                resources/backgrounds.qrc \
+                resources/common.qrc
+} else {
+        include(build_res.pri)
+}

+ 44 - 0
src/Legacy/main.cpp

@@ -0,0 +1,44 @@
+#include <QApplication>
+#include <QMessageBox>
+#include <QLockFile>
+#include <QDir>
+
+#include "widgets/mainwindow.h"
+
+#include <QTextCodec>
+#include <QDebug>
+#include <QResource>
+#include <QFontDatabase>
+
+int main(int argc, char *argv[])
+{
+    setlocale(LC_ALL,"Russian");
+    QApplication a(argc, argv);
+
+    qDebug() << "Checking if there's another instance of Legacy";
+
+    QLockFile lockFile(QDir::temp().absoluteFilePath("rulotro.lock"));
+    if(!lockFile.tryLock(1)){
+        QMessageBox msgBox;
+        msgBox.setIcon(QMessageBox::Warning);
+        msgBox.setText("Приложение уже запущено.\nРазрешено запускать только один экземпляр приложения.");
+        msgBox.exec();
+        return 1;
+    }
+
+    qDebug() << "Registering resources";
+    QResource::registerResource(QApplication::applicationDirPath() + "/data01.gtr");
+    QResource::registerResource(QApplication::applicationDirPath() + "/data02.gtr");
+
+    QFontDatabase::addApplicationFont(":/assets/fonts/trajan.ttf");
+    QFontDatabase::addApplicationFont(":/assets/fonts/viking.ttf");
+    QFontDatabase::addApplicationFont(":/assets/fonts/title.ttf");
+
+    qDebug() << "Starting main frame initialisation...";
+
+    MainWindow* main_window = new MainWindow(nullptr);
+    main_window->setAttribute(Qt::WA_DeleteOnClose);
+
+    qDebug() << "Finished initialisation, starting application...";
+    return a.exec();
+}

+ 14 - 14
src/Legacy/src/networkdownloader.cpp → src/Legacy/models/downloader.cpp

@@ -1,34 +1,34 @@
-#include "networkdownloader.h"
+#include "downloader.h"
 #include <QEventLoop>
 #include <QApplication>
 #include <QDebug>
 
-NetworkDownloader::NetworkDownloader(QObject *parent) :QObject(parent), busy(false)
+Downloader::Downloader(QObject *parent) :QObject(parent), busy(false)
 {
     connect(&m_WebCtrl, SIGNAL(finished(QNetworkReply*)), this, SLOT(onDownloadFinished(QNetworkReply*)));
 }
 
-NetworkDownloader::~NetworkDownloader() {
+Downloader::~Downloader() {
 }
 
-QUrl NetworkDownloader::getUrl()
+QUrl Downloader::getUrl()
 {
     return url;
 }
 
-void NetworkDownloader::setUrl(const QUrl &_url)
+void Downloader::setUrl(const QUrl &_url)
 {
     url = _url;
 }
 
-void NetworkDownloader::waitForDownloaded()
+void Downloader::waitForDownloaded()
 {
     QEventLoop loop;
-    connect(this, &NetworkDownloader::downloadFinished, &loop, &QEventLoop::quit);
+    connect(this, &Downloader::downloadFinished, &loop, &QEventLoop::quit);
     loop.exec();
 }
 
-void NetworkDownloader::start()
+void Downloader::start()
 {
     if (busy) {
         qDebug() << "Cannot download " << url << ", downloader is busy!";
@@ -40,24 +40,24 @@ void NetworkDownloader::start()
     QNetworkRequest request(url);
     m_CurrentReply = m_WebCtrl.get(request);
     m_CurrentReply->setReadBufferSize(download_speed_limit);
-    connect(m_CurrentReply, &QNetworkReply::readyRead, this, &NetworkDownloader::onReadyRead);
-    connect(m_CurrentReply, &QNetworkReply::downloadProgress, this, &NetworkDownloader::progressChanged);
+    connect(m_CurrentReply, &QNetworkReply::readyRead, this, &Downloader::onReadyRead);
+    connect(m_CurrentReply, &QNetworkReply::downloadProgress, this, &Downloader::progressChanged);
 }
 
-void NetworkDownloader::updateDownloadSpeedLimit(int bytes_per_sec)
+void Downloader::updateDownloadSpeedLimit(int bytes_per_sec)
 {
     download_speed_limit = bytes_per_sec;
     if (m_CurrentReply)
         m_CurrentReply->setReadBufferSize(bytes_per_sec);
 }
 
-void NetworkDownloader::stop()
+void Downloader::stop()
 {
     m_CurrentReply->abort();
     busy = false;
 }
 
-void NetworkDownloader::onDownloadFinished(QNetworkReply*) {
+void Downloader::onDownloadFinished(QNetworkReply*) {
     if (m_CurrentReply)
         m_CurrentReply->deleteLater();
 
@@ -65,7 +65,7 @@ void NetworkDownloader::onDownloadFinished(QNetworkReply*) {
     emit downloadFinished();
 }
 
-void NetworkDownloader::onReadyRead()
+void Downloader::onReadyRead()
 {
     QByteArray readdata = m_CurrentReply->readAll();
     if (targetFile && targetFile->isWritable())

+ 3 - 3
src/Legacy/src/networkdownloader.h → src/Legacy/models/downloader.h

@@ -8,13 +8,13 @@
 #include <QFile>
 #include <QByteArray>
 
-class NetworkDownloader : public QObject
+class Downloader : public QObject
 {
     Q_OBJECT
 
 public:
-    explicit NetworkDownloader(QObject *parent = 0);
-    virtual ~NetworkDownloader();
+    explicit Downloader(QObject *parent = 0);
+    virtual ~Downloader();
 
     QUrl getUrl();
     void setUrl(const QUrl& _url);

+ 0 - 0
src/Legacy/src/filesystem.cpp → src/Legacy/models/filesystem.cpp


+ 0 - 0
src/Legacy/src/filesystem.h → src/Legacy/models/filesystem.h


+ 507 - 0
src/Legacy/models/lotromanager.cpp

@@ -0,0 +1,507 @@
+#include "lotromanager.h"
+#include "filesystem.h"
+#include "LotroDat/Subfiles/TextSubFile.h"
+
+#include <QtConcurrent/QtConcurrent>
+#include <QFontDatabase>
+#include <QMessageBox>
+
+#include <string>
+#include <iostream>
+#include <fstream>
+
+Q_DECLARE_METATYPE(LOTRO_DAT::FILE_TYPE)
+Q_DECLARE_METATYPE(LOTRO_DAT::SubfileData)
+
+LotroManager::LotroManager(QSettings* app_settings_, QObject *parent) :
+    QObject(parent), app_settings(app_settings_) {
+
+    qRegisterMetaType<LOTRO_DAT::FILE_TYPE>();
+    qRegisterMetaType<LOTRO_DAT::SubfileData>();
+}
+
+void LotroManager::initialiseDatFile(QString file_path) {
+    emit processStarted("initialiseDatFile", {file_path});
+
+    qDebug() << "Initialising file " << file_path;
+
+    if (!FileSystem::fileExists(file_path)) {
+        emit caughtError(QString("initialiseDatFile"), {QString("Ошибка инициализации"), QString("Файл " + file_path + " несуществует! Невозможно инициализировать файл ресурсов.")});
+        emit processFinished("initialiseDatFile", {QString("Error"), file_path});
+        return;
+    }
+
+    file.Initialise((file_path).toStdString(), 0);
+    emit processFinished("initialiseDatFile", {QString("Success"), file_path});
+}
+
+void LotroManager::deinitialiseDatFile()
+{
+    emit processStarted("deintialiseDatFile", {});
+    qDebug() << "Deinitialising file...";
+    file.Deinitialize();
+    emit processFinished("deinitialiseDatFile", {});
+}
+
+void LotroManager::changeLocale() {
+    qDebug() << "Changing locale of dat file...";
+    // Setting locale, opposite to current
+    auto current_locale = file.GetLocaleManager().GetCurrentLocale();
+    auto new_locale = current_locale == LOTRO_DAT::DatLocaleManager::PATCHED ?
+                LOTRO_DAT::DatLocaleManager::ORIGINAL :
+                LOTRO_DAT::DatLocaleManager::PATCHED;
+
+    QString old_locale_name = (current_locale == LOTRO_DAT::DatLocaleManager::PATCHED ? "Русифицированная" : "Оригинальная");
+    QString new_locale_name = (new_locale == LOTRO_DAT::DatLocaleManager::PATCHED ? "Русифицированная" : "Оригинальная");
+    emit processStarted("changeLocale", {old_locale_name, new_locale_name});
+
+
+    auto operation = file.GetLocaleManager().SetLocale(new_locale);
+
+    auto new_current_locale = file.GetLocaleManager().GetCurrentLocale();
+    QString new_current_locale_name = (new_current_locale == LOTRO_DAT::DatLocaleManager::PATCHED ? "Русифицированная" : "Оригинальная");
+
+    if (operation.result == LOTRO_DAT::SUCCESS) {
+        emit processFinished("changeLocale", {"Success", new_current_locale_name});
+    } else {
+        emit caughtError("changeLocale", {"Ошибка смены локали!", QString("Не удалось сменить локаль игры! Текущая локаль: ") + new_current_locale_name});
+        emit processFinished("changeLocale", {"Error", new_current_locale_name});
+    }
+}
+
+void LotroManager::getLocaleFileContents(long long file_id, int locale) {
+    emit processStarted("getLocaleFileContents", {file_id, locale});
+
+    auto getfile_op = file.GetLocaleManager().GetLocaleFile(file_id, (LOTRO_DAT::DatLocaleManager::LOCALE)locale);
+    if (!getfile_op.result) {
+        emit caughtError("getLocaleFileContents", {"Файл не найден!", QString("Не удаётся найти файл с id ") + QString::number(file_id)});
+        emit processFinished("getLocaleFileContents", {"Error"});
+        return;
+    }
+
+    LOTRO_DAT::SubFile subfile = getfile_op.value;
+
+    auto getrealfile_op = file.GetFileSystem().GetFile(file_id);
+    if (!getfile_op.result) {
+        emit caughtError("getLocaleFileContents", {"Файл не найден!", QString("Не удаётся найти в словаре файл с id ") + QString::number(file_id)});
+        emit processFinished("getLocaleFileContents", {"Error"});
+        return;
+    }
+
+    if (getrealfile_op.value->FileType() != LOTRO_DAT::TEXT) {
+        emit caughtError("getLocaleFileContents", {"Некорректный формат!", QString("Получение данных локали доступно только для текстовых файлов!")});
+        emit processFinished("getLocaleFileContents", {"Error"});
+        return;
+    }
+
+    LOTRO_DAT::TextSubFile text_subfile(subfile);
+
+    auto getfiledata_op = file.GetFileSystem().GetFileData(subfile, 8);
+
+    if (getfile_op.result == LOTRO_DAT::ERROR) {
+        emit caughtError("getLocaleFileContents", {"Ошибка извлечения!", QString("Обнаружены некорректные данные файла в словаре! Файл ресурсов мог быть повреждён!\nid = ") + QString::number(file_id) + ", locale_id = " + QString::number(locale)});
+        emit processFinished("getLocaleFileContents", {"Error"});
+        return;
+    }
+
+    LOTRO_DAT::SubfileData result = text_subfile.PrepareForExport(getfiledata_op.value);
+    emit localeFileContentsReceived(locale, result);
+    emit processFinished("getLocaleFileContents", {"Success", file_id, locale});
+}
+
+void LotroManager::importFilesFromDatabase(QString database_path) {
+    emit processStarted("importFilesFromDatabase", {database_path});
+
+    if (!FileSystem::fileExists(database_path)) {
+        emit caughtError(QString("importFilesFromDatabase"), {QString("Ошибка импорта!"), QString("Файл " + database_path + " не существует! Невозможно инициализировать базу данных!")});
+        emit processFinished("importFilesFromDatabase", {QString("Error")});
+        return;
+    }
+
+    LOTRO_DAT::Database db;
+    if (!db.InitDatabase(database_path.toStdString())) {
+        emit caughtError("importFilesFromDatabase", {QString("Ошибка импорта!"), QString("Внутренняя ошибка инициализации базы данных!")});
+        emit processFinished("importFilesFromDatabase", {QString("Error")});
+        return;
+    }
+
+    auto patch_operation = file.GetPatcher().PatchAllDatabase(&db);
+
+    if (patch_operation.result == LOTRO_DAT::SUCCESS) {
+        file.GetFileSystem().CommitDirectories();
+        file.GetLocaleManager().CommitLocales();
+        emit processFinished("importFilesFromDatabase", {QString("Success"), patch_operation.value});
+    } else {
+        emit processFinished("importFilesFromDatabase", {QString("Error"), 0});
+    }
+}
+
+void LotroManager::importFile(long long file_id, QString file_path) {
+    emit processStarted("importFile", {file_id, file_path});
+
+    if (!FileSystem::fileExists(file_path)) {
+        emit caughtError("importFile", {QString("Ошибка импорта!"), QString("Файл ") + file_path + QString(" не существует!")});
+        emit processFinished("importFile", {QString("Error")});
+        return;
+    }
+
+    LOTRO_DAT::SubfileData data;
+
+    data.options["fid"] = file_id;
+
+    auto getfile_op = file.GetFileSystem().GetFile(file_id);
+    if (getfile_op.result == LOTRO_DAT::ERROR) {
+        emit caughtError("importFile", {QString("Ошибка импорта!"), QString("Файл с id ") + QString::number(file_id) + QString(" не существует в ресурсах игры! Невозможно импортировать :/")});
+        emit processFinished("importFile", {QString("Error")});
+        return;
+    }
+
+    LOTRO_DAT::SubFile subfile = *(getfile_op.value);
+    data.options["ext"] = subfile.Extension();
+    data.options["cat"] = subfile.category;
+
+    if (subfile.FileType() == LOTRO_DAT::TEXT) {
+        std::basic_ifstream<char16_t> input_stream(file_path.toStdString(), std::ios::in);
+        if (!input_stream.is_open()) {
+            emit caughtError("importFile", {QString("Ошибка импорта!"), QString("Текстовый файл ") + file_path + QString(" не удаётся открыть!")});
+            emit processFinished("importFile", {QString("Error")});
+            return;
+        }
+
+        std::basic_stringstream<char16_t>  strStream;
+        strStream << input_stream.rdbuf();//read the file
+        data.text_data = strStream.str();//str holds the content of the file
+
+        input_stream.close();
+    } else {
+        QFile data_file(file_path);
+        data_file.open(QIODevice::ReadOnly);
+
+        if (!data_file.isOpen()) {
+            emit caughtError("importFile", {QString("Ошибка импорта!"), QString("Файл ") + file_path + QString(" не удаётся открыть!")});
+            emit processFinished("importFile", {QString("Error")});
+            return;
+        }
+
+        QByteArray contents = data_file.readAll();
+        data.binary_data = LOTRO_DAT::BinaryData(contents.constData(), contents.size());
+    }
+
+
+    auto patchfile_op = file.GetPatcher().PatchFile(data);
+
+    if (patchfile_op.result == LOTRO_DAT::SUCCESS) {
+        file.GetFileSystem().CommitDirectories();
+        file.GetLocaleManager().CommitLocales();
+        emit processFinished("importFile", {QString("Success")});
+    } else {
+        emit caughtError("importFile", {QString("Ошибка импорта!"), QString("Возникла внутренняя ошибка применения патча. Импорт завершился с ошибкой")});
+        emit processFinished("importFile", {QString("Error")});
+    }
+    return;
+}
+
+void LotroManager::importTextFragment(long long file_id, long long fragment_id,
+                               QString fragment_contents, QString arguments) {
+    emit processStarted("importTextFragment", {file_id, fragment_id});
+
+    if (fragment_contents.contains("DO_NOT_TOUCH-1!")) {
+        emit caughtError("importTextFragment", {"Ошибка формата!", QString("Текстовые данные содержат указатели на аргументы DO_NOT_TOUCH! с встроенным указанием порядка аргументов (как на сайте) Такого быть не должно! Пользуйтесь порядком перечисления аргументов внизу")});
+        emit processFinished("importTextFragment", {"Error"});
+        return;
+    }
+
+    auto getfile_op = file.GetFileSystem().GetFile(file_id);
+    if (!getfile_op.result) {
+        emit caughtError("importTextFragment", {"Файл не найден!", QString("Не удаётся найти в ресурсах файл с id ") + QString::number(file_id)});
+        emit processFinished("importTextFragment", {"Error"});
+        return;
+    }
+
+    auto subfile = getfile_op.value;
+
+    auto getfiledata_op = file.GetFileSystem().GetFileData(*subfile, 8);
+
+    if (getfile_op.result == LOTRO_DAT::ERROR) {
+        emit caughtError("importTextFragment", {"Ошибка импорта!", QString("Обнаружены некорректные данные файла в словаре! Файл ресурсов мог быть повреждён!\nid = ") + QString::number(file_id)});
+        emit processFinished("importTextFragment", {"Error"});
+        return;
+    }
+
+    LOTRO_DAT::SubfileData data = subfile->PrepareForExport(getfiledata_op.value);
+    if (data.Empty()) {
+        emit caughtError("importTextFragment", {"Ошибка импорта!", QString("Не удалось подготовить файл к изменению фрагмента!\nid = ") + QString::number(file_id)});
+        emit processFinished("importTextFragment", {"Error"});
+        return;
+    }
+
+    unsigned beginning = data.text_data.find(QString::number(fragment_id).toStdU16String(), 0);
+    if (beginning == std::u16string::npos) {
+        emit caughtError("importTextFragment", {"Ошибка импорта!", QString("Не удалось найти фрагмент в файле!\nid = ") + QString::number(file_id) + "\nfragment_id = " + QString::number(fragment_id)});
+        emit processFinished("importTextFragment", {"Error"});
+        return;
+    }
+
+    unsigned ending = data.text_data.find(QString("|||").toStdU16String(), beginning);
+
+    QString new_fragment = QString::number(fragment_id) + ":::" + arguments + ":::" + fragment_contents;
+    std::u16string new_text =  data.text_data.substr(0, beginning) + new_fragment.toStdU16String() + data.text_data.substr(ending);
+    data.text_data = new_text;
+
+    auto patchfile_op = file.GetPatcher().PatchFile(data);
+
+    if (patchfile_op.result == LOTRO_DAT::SUCCESS) {
+        file.GetFileSystem().CommitDirectories();
+        file.GetLocaleManager().CommitLocales();
+        emit processFinished("importTextFragment", {QString("Success")});
+    } else {
+        emit caughtError("importTextFragment", {QString("Ошибка импорта!"), QString("Возникла внутренняя ошибка применения патча. Импорт завершился с ошибкой")});
+        emit processFinished("importTextFragment", {QString("Error")});
+    }
+}
+
+void LotroManager::getTextFragment(long long file_id, long long fragment_id) {
+    emit processStarted("getTextFragment", {file_id, fragment_id});
+
+    auto getfile_op = file.GetFileSystem().GetFile(file_id);
+    if (!getfile_op.result) {
+        emit caughtError("getTextFragment", {"Файл не найден!", QString("Не удаётся найти в ресурсах файл с id ") + QString::number(file_id)});
+        emit processFinished("getTextFragment", {"Error"});
+        return;
+    }
+
+    auto subfile = getfile_op.value;
+
+    auto getfiledata_op = file.GetFileSystem().GetFileData(*subfile, 8);
+
+    if (getfile_op.result == LOTRO_DAT::ERROR) {
+        emit caughtError("getTextFragment", {"Ошибка импорта!", QString("Обнаружены некорректные данные файла в словаре! Файл ресурсов мог быть повреждён!\nid = ") + QString::number(file_id)});
+        emit processFinished("getTextFragment", {"Error"});
+        return;
+    }
+
+    LOTRO_DAT::SubfileData data = subfile->PrepareForExport(getfiledata_op.value);
+    if (data.Empty()) {
+        emit caughtError("getTextFragment", {"Ошибка импорта!", QString("Не удалось подготовить файл к изменению фрагмента!\nid = ") + QString::number(file_id)});
+        emit processFinished("getTextFragment", {"Error"});
+        return;
+    }
+
+    unsigned beginning = data.text_data.find(QString::number(fragment_id).toStdU16String(), 0);
+    if (beginning == std::u16string::npos) {
+        emit caughtError("getTextFragment", {"Ошибка импорта!", QString("Не удалось найти фрагмент в файле!\nid = ") + QString::number(file_id) + "\nfragment_id = " + QString::number(fragment_id)});
+        emit processFinished("getTextFragment", {"Error"});
+        return;
+    }
+
+    unsigned ending = data.text_data.find(QString("|||").toStdU16String(), beginning);
+
+    unsigned size = std::u16string::npos;
+
+    if (ending != std::u16string::npos)
+        size = ending - beginning;
+
+    std::u16string str = data.text_data.substr(beginning, size);
+
+    QStringList splitted_fragment = QString::fromStdU16String(str).split(":::");
+    if (splitted_fragment.size() != 3) {
+        emit caughtError("getTextFragment", {"Ошибка импорта!", QString("Получены некорректные данные фрагмента!\nДанные:") + QString::fromStdU16String(str)});
+        emit processFinished("getTextFragment", {"Error"});
+        return;
+    }
+
+    emit textFragmentReceived(splitted_fragment.at(1), splitted_fragment.at(2));
+    emit processFinished("getTextFragment", {"Success"});
+}
+
+void LotroManager::createCoreStatusFile(QString output_filename) {
+    emit processStarted("createCoreStatusFile", {output_filename});
+    auto gatherinfo_op = file.GatherInformation(output_filename.toStdString());
+
+    if (gatherinfo_op.result == LOTRO_DAT::SUCCESS) {
+        emit processFinished("createCoreStatusFile", {"Success", output_filename});
+    } else {
+        emit caughtError("createCoreStatusFile", {"Ошибка сбора информации!", QString("Не удаётся создать файл информации ядра")});
+        emit processFinished("createCoreStatusFile", {"Error", output_filename});
+    }
+}
+
+void LotroManager::extractSingleFile(QString output_filename, long long file_id) {
+    emit processStarted("extractSingleFile", {output_filename, file_id});
+    auto extractfile_op = file.GetExporter().ExtractFileById(file_id, output_filename.toStdString());
+    if (extractfile_op.result == LOTRO_DAT::SUCCESS) {
+        emit processFinished("extractSingleFile", {"Success", output_filename, file_id});
+    } else {
+        emit caughtError("extractSingleFile", {"Ошибка экспорта!", QString("Не удаётся экспортировать файл " + QString::number(file_id) + " в файл " + output_filename)});
+        emit processFinished("extractSingleFile", {"Error", output_filename});
+    }
+}
+
+void LotroManager::extractSingleFileToDatabase(QString database_path, long long file_id) {
+    emit processStarted("extractSingleFileToDatabase", {database_path, file_id});
+    LOTRO_DAT::Database db;
+    if (!db.InitDatabase(database_path.toStdString())) {
+        emit caughtError("extractSingleFileToDatabase", {"Ошибка экспорта!", QString("Не удаётся создать/открыть базу данных " + database_path)});
+        emit processFinished("extractSingleFileToDatabase", {"Error", database_path});
+        return;
+    }
+
+    auto extractfile_op = file.GetExporter().ExtractFileById(file_id, &db);
+
+    if (extractfile_op.result == LOTRO_DAT::SUCCESS) {
+        emit processFinished("extractSingleFileToDatabase", {"Success", database_path, file_id});
+    } else {
+        emit caughtError("extractSingleFileToDatabase", {"Ошибка экспорта!", QString("Не удаётся экспортировать файл " + QString::number(file_id) + " в базу данных " + database_path)});
+        emit processFinished("extractSingleFileToDatabase", {"Error", database_path});
+    }
+}
+
+void LotroManager::extractGrouppedFiles(QString output_foldername, LOTRO_DAT::FILE_TYPE type) {
+    emit processStarted("extractGrouppedFiles", {output_foldername, type});
+    auto extractfile_op = file.GetExporter().ExtractAllFilesByType(type, output_foldername.toStdString());
+    if (extractfile_op.result == LOTRO_DAT::SUCCESS) {
+        emit processFinished("extractGrouppedFiles", {"Success", output_foldername, type, extractfile_op.value});
+    } else {
+        emit caughtError("extractGrouppedFiles", {"Ошибка экспорта!", QString("Не удаётся экспортировать файлы с типом " + QString::number(type) + " в папку " + output_foldername)});
+        emit processFinished("extractGrouppedFiles", {"Error", output_foldername, type, extractfile_op.value});
+    }
+}
+
+void LotroManager::extractGrouppedFilesToDatabase(QString database_path, LOTRO_DAT::FILE_TYPE type) {
+    emit processStarted(QString("extractGrouppedFilesToDatabase"), {database_path, type});
+    LOTRO_DAT::Database db;
+    if (!db.InitDatabase(database_path.toStdString())) {
+        emit caughtError("extractGrouppedFilesToDatabase", {"Ошибка экспорта!", QString("Не удаётся создать/открыть базу данных " + database_path)});
+        emit processFinished("extractGrouppedFilesToDatabase", {"Error", database_path});
+        return;
+    }
+
+    auto extractfile_op = file.GetExporter().ExtractAllFilesByType(type, &db);
+    if (extractfile_op.result == LOTRO_DAT::SUCCESS) {
+        emit processFinished("extractGrouppedFilesToDatabase", {"Success", database_path, type, extractfile_op.value});
+    } else {
+        emit caughtError("extractGrouppedFilesToDatabase", {"Ошибка экспорта!", QString("Не удаётся экспортировать файлы с типом " + QString::number(type) + " в базу данных " + database_path)});
+        emit processFinished("extractGrouppedFilesToDatabase", {"Error", database_path, extractfile_op.value});
+    }
+}
+
+void LotroManager::getUnactiveCategories() {
+    emit processStarted("getUnactiveCategories", {});
+
+    const std::set<long long>& categories = file.GetLocaleManager().GetInactiveCategories();
+
+    QStringList result;
+    for (long long category : categories) {
+        result << QString::number(category);
+    }
+
+    emit unactiveCategoriesReceived(result);
+    emit processFinished("getUnactiveCategories", {"Success"});
+}
+
+void LotroManager::startGame() {
+    emit processStarted("startGame", {});
+
+    QStringList args;
+    args << "-skiprawdownload" << "-nosplash";
+    if (file.GetLocaleManager().GetCurrentLocale() == LOTRO_DAT::DatLocaleManager::PATCHED)
+        args << "-disablePatch";
+
+    file.Deinitialize();
+
+    if(FileSystem::fileExists(QApplication::applicationDirPath() + "/user.ini")){
+        QSettings login(QApplication::applicationDirPath() + "/user.ini", QSettings::IniFormat );
+        login.beginGroup("Account");
+        QString username = login.value("username", "").toString();
+        QString password = login.value("password", "").toString();
+        login.endGroup();
+        args << "-username" << username << "-password" << password;
+    }
+
+    qDebug() << "Запускаем игру со следующими аргументами: " << args;
+
+    QFile f(app_settings->value("Local", "folder").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);
+        emit processFinished("startGame", {});
+    } else {
+        emit caughtError("startGame", {"Ошибка запуска игры!", QString("Не удалось найти файл LotroLauncher в папке: ") + app_settings->value("Local", "folder").toString()});
+        emit processFinished("startGame", {"Error"});
+    }
+}
+
+void LotroManager::getLocaleFileInfo(long long file_id, int locale) {
+    emit processStarted("getLocaleFileInfo", {file_id, locale});
+
+    auto getfile_op = file.GetLocaleManager().GetLocaleFile(file_id, (LOTRO_DAT::DatLocaleManager::LOCALE)locale);
+    if (!getfile_op.result) {
+        emit caughtError("getLocaleFileInfo", {"Файл не найден!", QString("Не удаётся найти в ресурсах файл с id ") + QString::number(file_id)});
+        emit processFinished("getLocaleFileInfo", {"Error"});
+        return;
+    }
+
+    LOTRO_DAT::SubFile subfile = getfile_op.value;
+
+    QString result = "Locale file info:\n "
+                     "dictionary_offset: " + QString::number(subfile.dictionary_offset()) + "\n"
+                     "unknown1: " + QString::number(subfile.unknown1()) + "\n"
+                     "file_id: " + QString::number(subfile.file_id()) + "\n"
+                     "file_offset: " + QString::number(subfile.file_offset()) + "\n"
+                     "file_size: " + QString::number(subfile.file_size()) + "\n"
+                     "timestamp: " + QString::number(subfile.timestamp()) + "\n"
+                     "version: " + QString::number(subfile.version()) + "\n"
+                     "block_size: " + QString::number(subfile.block_size()) + "\n"
+                     "unknown2: " + QString::number(subfile.file_id()) + "\n"
+                     "category: " + QString::number(subfile.category) + "\n";
+
+    emit localeFileInfoReceived(locale, result);
+    emit processFinished("getLocaleFileInfo", {"Success"});
+}
+
+void LotroManager::getFileInfo(long long file_id) {
+    emit processStarted(QString("getFileInfo"), {file_id});
+
+    auto getfile_op = file.GetFileSystem().GetFile(file_id);
+    if (!getfile_op.result) {
+        emit caughtError("getFileInfo", {"Файл не найден!", QString("Не удаётся найти файл с id ") + QString::number(file_id)});
+        emit processFinished("getFileInfo", {"Error"});
+        return;
+    }
+
+    LOTRO_DAT::SubFile subfile = *getfile_op.value;
+
+    QString result = "Locale file info:\n "
+                     "dictionary_offset: " + QString::number(subfile.dictionary_offset()) + "\n"
+                     "unknown1: " + QString::number(subfile.unknown1()) + "\n"
+                     "file_id: " + QString::number(subfile.file_id()) + "\n"
+                     "file_offset: " + QString::number(subfile.file_offset()) + "\n"
+                     "file_size: " + QString::number(subfile.file_size()) + "\n"
+                     "timestamp: " + QString::number(subfile.timestamp()) + "\n"
+                     "version: " + QString::number(subfile.version()) + "\n"
+                     "block_size: " + QString::number(subfile.block_size()) + "\n"
+                     "unknown2: " + QString::number(subfile.file_id()) + "\n";
+
+    emit fileInfoReceived(result);
+    emit processFinished("getFileInfo", {"Success"});
+}
+
+LOTRO_DAT::DatStatus *LotroManager::getStatusModule()
+{
+    return &file.GetStatusModule();
+}
+
+bool LotroManager::initialised() {
+    return file.Initialized();
+}
+
+int LotroManager::currentLocale() {
+    return file.GetLocaleManager().GetCurrentLocale();
+}
+
+bool LotroManager::notPatched() {
+    return file.GetStatusModule().CheckIfNotPatched();
+}

+ 77 - 0
src/Legacy/models/lotromanager.h

@@ -0,0 +1,77 @@
+#ifndef LEGACYAPP_H
+#define LEGACYAPP_H
+
+#include <QObject>
+#include <QSettings>
+#include <QApplication>
+
+#include <LotroDat/LotroDat.h>
+
+class LotroManager : public QObject
+{
+    Q_OBJECT
+
+public:
+    explicit LotroManager(QSettings* app_settings_, QObject *parent = nullptr);
+
+    bool initialised();
+
+    int currentLocale();
+
+    bool notPatched();
+
+public slots:
+    void initialiseDatFile(QString file_path);
+
+    void deinitialiseDatFile();
+
+    void changeLocale();
+
+    void getLocaleFileContents(long long file_id, int locale);
+
+    void importFilesFromDatabase(QString database_path);
+
+    void importFile(long long file_id, QString file_path);
+
+    void importTextFragment(long long file_id, long long fragment_id, QString fragment_contents, QString arguments);
+
+    void getTextFragment(long long file_id, long long fragment_id);
+
+    void createCoreStatusFile(QString output_filename);
+
+    void extractSingleFile(QString output_filename, long long file_id);
+
+    void extractSingleFileToDatabase(QString database_path, long long file_id);
+
+    void extractGrouppedFiles(QString output_foldername, LOTRO_DAT::FILE_TYPE type);
+
+    void extractGrouppedFilesToDatabase(QString database_path, LOTRO_DAT::FILE_TYPE type);
+
+    void getUnactiveCategories();
+
+    void startGame();
+
+    void getLocaleFileInfo(long long file_id, int locale);
+
+    void getFileInfo(long long file_id);
+
+    LOTRO_DAT::DatStatus *getStatusModule();
+
+signals:
+    // general signals. First argument is process_name, second - processed values
+    void processStarted(QString, QVector<QVariant>);
+    void processFinished(QString, QVector<QVariant>);
+    void processUpdated(QString, QVector<QVariant>);
+    void caughtError(QString, QVector<QVariant>);
+
+    void textFragmentReceived(QString, QString);
+    void unactiveCategoriesReceived(QStringList);
+    void localeFileContentsReceived(int, LOTRO_DAT::SubfileData); // extention, contents
+    void localeFileInfoReceived(int, QString);
+    void fileInfoReceived(QString);
+private:
+    LOTRO_DAT::DatFile file;
+    QSettings* app_settings;
+};
+
+#endif // LEGACYAPP_H

+ 0 - 47
src/Legacy/src/legacyapp.cpp

@@ -1,47 +0,0 @@
-#include "legacyapp.h"
-#include "filesystem.h"
-
-#include <QtConcurrent/QtConcurrent>
-#include <QFontDatabase>
-
-LegacyApp::LegacyApp(QObject *parent) : QObject(parent), window(this),
-    client_local_dat(), client_local_dat_busy(false),
-    properties(qApp->applicationDirPath() + "/legacy_v2.ini", QSettings::IniFormat)
-{
-    properties.setIniCodec("UTF-8");
-}
-
-void LegacyApp::Init()
-{
-    QResource::registerResource(QApplication::applicationDirPath() + "/data01.gtr");
-    QResource::registerResource(QApplication::applicationDirPath() + "/data02.gtr");
-
-    QFontDatabase::addApplicationFont(":/assets/fonts/trajan.ttf");
-    QFontDatabase::addApplicationFont(":/assets/fonts/viking.ttf");
-    QFontDatabase::addApplicationFont(":/assets/fonts/title.ttf");
-
-
-    window.Init();
-    StartDatFilesInitialisation();
-}
-
-void LegacyApp::StartDatFilesInitialisation()
-{
-    QString lotro_dir_path = properties.value("settings/lotro_folder", "none").toString();
-    QString locale = properties.value("lotro/locale", "English").toString();
-
-    qDebug() << "Initialising file " << lotro_dir_path + "/client_local_" + locale + ".dat";
-
-    QtConcurrent::run([this, lotro_dir_path, locale](){
-        if (client_local_dat_busy == false) {
-            client_local_dat_busy = true;
-            client_local_dat.Initialise((lotro_dir_path + "/client_local_" + locale + ".dat").toStdString(), 0);
-            client_local_dat_busy = false;
-        }
-    });
-}
-
-void LegacyApp::DownloadFinished()
-{
-    // TODO
-}

+ 0 - 47
src/Legacy/src/legacyapp.h

@@ -1,47 +0,0 @@
-#ifndef LEGACYAPP_H
-#define LEGACYAPP_H
-
-#include <QObject>
-#include <QSettings>
-#include <QApplication>
-
-#include <queue>
-
-#include "mainwindow.h"
-#include <LotroDat/LotroDat.h>
-
-class MainWindow;
-class NetworkDownloader;
-
-class LegacyApp : public QObject
-{
-    Q_OBJECT
-
-public:
-    explicit LegacyApp(QObject *parent = nullptr);
-
-    void Init();
-
-private:
-    void StartDatFilesInitialisation();
-
-signals:
-
-private slots:
-    void DownloadFinished();
-
-
-public:
-    MainWindow window;
-
-    LOTRO_DAT::DatFile client_local_dat;
-    std::queue<QString> patch_databases_queue;
-    bool client_local_dat_busy;
-
-    QSettings properties;
-
-    NetworkDownloader* dowloader;
-    std::queue<std::pair<QString, QString>> download_queue;
-};
-
-#endif // LEGACYAPP_H

+ 0 - 22
src/Legacy/src/main.cpp

@@ -1,22 +0,0 @@
-#include <QApplication>
-#include <QMessageBox>
-#include <QLockFile>
-#include <QDir>
-#include "legacyapp.h"
-
-int main(int argc, char *argv[])
-{
-    QApplication a(argc, argv);
-    QLockFile lockFile(QDir::temp().absoluteFilePath("rulotro.lock"));
-    if(!lockFile.tryLock(1)){
-        QMessageBox msgBox;
-        msgBox.setIcon(QMessageBox::Warning);
-        msgBox.setText("Приложение уже запущено.\nРазрешено запускать только один экземпляр приложения.");
-        msgBox.exec();
-        return 1;
-    }
-
-    LegacyApp app;
-    app.Init();
-    return a.exec();
-}

+ 0 - 0
src/Legacy/gui/helpwidget.cpp → src/Legacy/widgets/helpwidget.cpp


+ 0 - 0
src/Legacy/gui/helpwidget.h → src/Legacy/widgets/helpwidget.h


+ 0 - 0
src/Legacy/gui/helpwidget.ui → src/Legacy/widgets/helpwidget.ui


+ 85 - 57
src/Legacy/gui/mainwindow.cpp → src/Legacy/widgets/mainwindow.cpp

@@ -12,48 +12,62 @@
 #include <QDesktopWidget>
 #include <QtConcurrent/QtConcurrent>
 
-MainWindow::MainWindow(LegacyApp *app, QWidget *parent) :
-    QMainWindow(parent, Qt::Window | Qt::FramelessWindowHint), app(app),
+MainWindow::MainWindow(QWidget *parent) :
+    QMainWindow(parent, Qt::Window | Qt::FramelessWindowHint),
     ui(new Ui::MainWindow), menuHoverWidget(nullptr), menuHoverWidgetAnimation(nullptr)
 {
-}
-
-void MainWindow::Init() {
     ui->setupUi(this);
 
-    status_frame = new StatusWidget(app, this);
-    ui->content_layout->addWidget(status_frame);
+    qDebug() << "Initialising Settings module";
+    QSettings *settings = new QSettings(qApp->applicationDirPath() + "/legacy_v2.ini", QSettings::IniFormat);
 
-    rusification_frame = new RusificationWidget(app, this);
-    ui->content_layout->addWidget(rusification_frame);
 
-    settings_frame = new SettingsWidget(app, this);
-    ui->content_layout->addWidget(settings_frame);
+    qDebug() << "Creating lotro manager instance & thread";
+    lotro_mgr_thread = new QThread();
+    lotro_manager = new LotroManager(settings);
+    QObject::connect(lotro_mgr_thread, &QThread::finished, lotro_manager, &QObject::deleteLater, Qt::QueuedConnection);
+    lotro_manager->moveToThread(lotro_mgr_thread);
+    lotro_mgr_thread->start();
 
-    news_frame = new NewsWidget(app, this);
-    ui->content_layout->addWidget(news_frame);
+    status_widget = new StatusWidget(this);
+    rusification_widget = new RusificationWidget(this);
+    settings_widget = new SettingsWidget(this);
+    news_widget = new NewsWidget(this);
+    help_widget = new HelpWidget(this);
 
-    help_frame = new HelpWidget(app, this);
+    ui->content_layout->addWidget(status_frame);
+    ui->content_layout->addWidget(rusification_frame);
+    ui->content_layout->addWidget(settings_frame);
+    ui->content_layout->addWidget(news_frame);
     ui->content_layout->addWidget(help_frame);
 
+    ui->centralWidget->setStyleSheet("");
+
     hideAllContentWidgets();
     status_frame->show();
 
+    qDebug() << "Making fonts and making background";
     changeFontSizeRecursive(100, this);
 
     qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
-    background = new QPixmap();
-    background->load(":/assets/backgrounds/bg" + QString::number(qrand() % MAX_PIXMAP_ID + 1) + ".png");
-    setupWindowBackgroundAndMask();
+    current_bg_id = qrand() % MAX_PIXMAP_ID + 1;
+    QPixmap background(":/backgrounds/bg" + QString::number(current_bg_id) + ".png");
+    setupWindowBackgroundAndMask(background);
+
     setupMenuHoverWidget();
 
     updateGeometry();
     repaint();
 
+    qDebug() << "Initialising background updates";
     background_update_timer.setInterval(30 * 1000);
     connect(&background_update_timer, &QTimer::timeout, this, &MainWindow::randomChangeBackground);
     background_update_timer.start();
-    ui->centralWidget->setStyleSheet("");
+
+    qDebug() << "Initialising main window connections";
+    makeConnections();
+
+    qDebug() << "Finishing main frame initialisation";
     show();
 }
 
@@ -86,6 +100,23 @@ void MainWindow::resizeEvent(QResizeEvent * event)
     setupWindowBackgroundAndMask();
 }
 
+void MainWindow::enableMenuItems()
+{
+    ui->menuentry_1_common->setEnabled(true);
+    ui->menuentry_2_common->setEnabled(true);
+    ui->menuentry_3_common->setEnabled(true);
+    ui->menuentry_4_common->setEnabled(true);
+}
+
+void MainWindow::disableMenuItems()
+{
+    ui->menuentry_1_common->setEnabled(false);
+    ui->menuentry_2_common->setEnabled(false);
+    ui->menuentry_3_common->setEnabled(false);
+    ui->menuentry_4_common->setEnabled(false);
+}
+
+
 void MainWindow::randomChangeBackground()
 {
     if (!qApp)
@@ -93,42 +124,33 @@ void MainWindow::randomChangeBackground()
 
     qDebug() << "Starting background update";
 
-    if (fade_animation_timer.isActive()) {
-        qDebug() << "MainWindow::startBackgroundUpdate() - cannot start, because update is still active";
-        return;
-    }
 
-    next_pixmap_opacity = 0;
     int next_pixmap_id = qrand() % MAX_PIXMAP_ID + 1;
-
-    if (!next_pixmap)
-        next_pixmap = new QPixmap();
-
-    next_pixmap->load(":/assets/backgrounds/bg" + QString::number(next_pixmap_id) + ".png");
-    qDebug() << "Next pixmap id" << next_pixmap_id << "!";
-
-    if (next_pixmap->isNull()) {
-        qDebug() << "Incorrect pixmap id " << next_pixmap_id << "!";
-        return;
+    while (next_pixmap_id == current_bg_id) {
+        next_pixmap_id = qrand() % MAX_PIXMAP_ID + 1;
     }
+    qDebug() << "Next background id = " << next_pixmap_id;
+
+    QPixmap *cur_bg = new QPixmap(current_bg.scaled(size()));
+    QPixmap *new_bg= new QPixmap(QPixmap(":/backgrounds/bg" + QString::number(next_pixmap_id) + ".png").scaled(size()));
+    current_bg_id = next_pixmap_id;
 
-    QtConcurrent::run([this](){
-        qDebug() << "Starting background update";
-        while (next_pixmap_opacity < 1 && qApp) {
-            if (!qApp)
-                return;
+    QtConcurrent::run([cur_bg, new_bg, this](){
+        const int iterations_num = 150;
+        const int iteration_sleep = 75;
 
+        for (int i = 0; i < iterations_num && qApp; i++) {
             QPainter painter;
-            painter.begin(background);
-            painter.setOpacity(next_pixmap_opacity);
+            painter.begin(cur_bg);
+            painter.setOpacity(double(10 + i) / double(iterations_num));
             painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
-            painter.drawPixmap(0,0, *next_pixmap);
+            painter.drawPixmap(0,0, *new_bg);
             painter.end();
-
-            setupWindowBackgroundAndMask();
-            next_pixmap_opacity += 0.005;
-            QThread::msleep(50);
+            QMetaObject::invokeMethod(this, "setupWindowBackgroundAndMask", Qt::QueuedConnection, Q_ARG(QPixmap, *cur_bg));
+            QThread::msleep(iteration_sleep);
         }
+        delete cur_bg;
+        delete new_bg;
         qDebug() << "Background update finished";
     });
 }
@@ -142,31 +164,31 @@ MainWindow::~MainWindow()
 void MainWindow::on_menuentry_1_common_clicked()
 {
     hideAllContentWidgets();
-    status_frame->show();
+    status_widget->show();
 }
 
 void MainWindow::on_menuentry_2_common_clicked()
 {
     hideAllContentWidgets();
-    settings_frame->show();
+    settings_widget->show();
 }
 
 void MainWindow::on_menuentry_3_common_clicked()
 {
     hideAllContentWidgets();
-    rusification_frame->show();
+    rusification_widget->show();
 }
 
 void MainWindow::on_menuentry_4_common_clicked()
 {
     hideAllContentWidgets();
-    news_frame->show();
+    news_widget->show();
 }
 
 void MainWindow::on_menuentry_5_common_clicked()
 {
     hideAllContentWidgets();
-    help_frame->show();
+    help_widget->show();
 }
 
 void MainWindow::onHoverMenuentry()
@@ -174,9 +196,11 @@ void MainWindow::onHoverMenuentry()
     moveMenuHoverWidget(MenuEntry::getHoverLabel());
 }
 
-void MainWindow::setupWindowBackgroundAndMask()
+void MainWindow::setupWindowBackgroundAndMask(QPixmap background)
 {
-    current_bg = background->scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+    if (!qApp)
+        return;
+    current_bg = background.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
     current_mask = current_bg.mask();
     setMask(current_mask);
 
@@ -185,6 +209,10 @@ void MainWindow::setupWindowBackgroundAndMask()
     setPalette(palette);
 }
 
+void MainWindow::makeConnections()
+{
+}
+
 void MainWindow::setupMenuHoverWidget()
 {
     menuHoverWidget = new QWidget(ui->menu_widget);
@@ -241,11 +269,11 @@ void MainWindow::checkMenuIsHovered()
 
 void MainWindow::hideAllContentWidgets()
 {
-    status_frame->hide();
-    rusification_frame->hide();
-    settings_frame->hide();
-    news_frame->hide();
-    help_frame->hide();
+    status_widget->hide();
+    rusification_widget->hide();
+    settings_widget->hide();
+    news_widget->hide();
+    help_widget->hide();
 }
 
 void MainWindow::changeFontSizeRecursive(size_t percent, QWidget *widget)

+ 16 - 22
src/Legacy/gui/mainwindow.h → src/Legacy/widgets/mainwindow.h

@@ -18,18 +18,17 @@ class MainWindow;
 }
 
 class MenuEntry;
-class LegacyApp;
+// class LotroManager;
+// class NetworkUpdater;
+// class PatchDownloader;
+// class NewsDownloader;
 
 class MainWindow : public QMainWindow
 {
     Q_OBJECT
-    struct PixmapObertka{
-        QPixmap* pixmap;
-    };
 
 public:
-    explicit MainWindow(LegacyApp *app = 0, QWidget *parent = 0);
-    void Init();
+    explicit MainWindow(QWidget *parent = 0);
     void changeFontSizeRecursive(size_t percent, QWidget* widget);
     ~MainWindow();
 
@@ -57,8 +56,10 @@ private slots:
 
     void on_minimizeButton_clicked();
 
+    void setupWindowBackgroundAndMask(QPixmap background);
+
 private:
-    void setupWindowBackgroundAndMask();
+    void makeConnections();
 
     void setupMenuHoverWidget();
 
@@ -69,10 +70,14 @@ private:
     void hideAllContentWidgets();
 
 private:
-    LegacyApp *app;
-
     Ui::MainWindow *ui;
 
+    StatusWidget *status_widget;
+    RusificationWidget *rusification_widget;
+    SettingsWidget *settings_widget;
+    NewsWidget *news_widget;
+    HelpWidget *help_widget;
+
     QWidget* menuHoverWidget;
     QPropertyAnimation* menuHoverWidgetAnimation;
     QPropertyAnimation* menuHoverWidgetScaleAnimation;
@@ -80,23 +85,12 @@ private:
 
     QPoint dragPosition;
 
-    StatusWidget *status_frame;
-    RusificationWidget *rusification_frame;
-    SettingsWidget *settings_frame;
-    NewsWidget *news_frame;
-    HelpWidget *help_frame;
-
-    QPixmap *background;
-    QPixmap *next_pixmap {nullptr};
-
+    int current_bg_id;
     QPixmap current_bg;
     QBitmap current_mask;
-
     QTimer background_update_timer;
-    QTimer fade_animation_timer;
-    double next_pixmap_opacity;
 
-    const int MAX_PIXMAP_ID = 9;
+    const int MAX_PIXMAP_ID = 14;
 
     const size_t common_font_size = 15;
     const size_t title_font_size = 17;

+ 0 - 0
src/Legacy/gui/mainwindow.ui → src/Legacy/widgets/mainwindow.ui


+ 0 - 0
src/Legacy/src/menuentry.cpp → src/Legacy/widgets/menuentry.cpp


+ 0 - 0
src/Legacy/src/menuentry.h → src/Legacy/widgets/menuentry.h


+ 0 - 0
src/Legacy/gui/newswidget.cpp → src/Legacy/widgets/newswidget.cpp


+ 0 - 0
src/Legacy/gui/newswidget.h → src/Legacy/widgets/newswidget.h


+ 0 - 0
src/Legacy/gui/newswidget.ui → src/Legacy/widgets/newswidget.ui


+ 0 - 0
src/Legacy/src/rusificationtreeitem.cpp → src/Legacy/widgets/rusificationtreeitem.cpp


+ 0 - 0
src/Legacy/src/rusificationtreeitem.h → src/Legacy/widgets/rusificationtreeitem.h


+ 0 - 0
src/Legacy/gui/rusificationwidget.cpp → src/Legacy/widgets/rusificationwidget.cpp


+ 0 - 0
src/Legacy/gui/rusificationwidget.h → src/Legacy/widgets/rusificationwidget.h


+ 0 - 0
src/Legacy/gui/rusificationwidget.ui → src/Legacy/widgets/rusificationwidget.ui


+ 0 - 0
src/Legacy/gui/settingswidget.cpp → src/Legacy/widgets/settingswidget.cpp


+ 0 - 0
src/Legacy/gui/settingswidget.h → src/Legacy/widgets/settingswidget.h


+ 0 - 0
src/Legacy/gui/settingswidget.ui → src/Legacy/widgets/settingswidget.ui


+ 0 - 0
src/Legacy/gui/statuswidget.cpp → src/Legacy/widgets/statuswidget.cpp


+ 0 - 0
src/Legacy/gui/statuswidget.h → src/Legacy/widgets/statuswidget.h


+ 0 - 0
src/Legacy/gui/statuswidget.ui → src/Legacy/widgets/statuswidget.ui