|
@@ -4,121 +4,129 @@
|
|
|
|
|
|
#include <QStringList>
|
|
|
|
|
|
-LotroManager::LotroManager(QObject *parent) : QObject(parent)
|
|
|
-{
|
|
|
+LotroManager::LotroManager(QObject *parent) : QObject(parent){
|
|
|
dat_files_.resize(5);
|
|
|
- operations_queue_.clear();
|
|
|
busy_ = false;
|
|
|
|
|
|
- connect(this, SIGNAL(dat_operation_started()), this, SLOT(on_dat_operation_started()));
|
|
|
+ connect(this, SIGNAL(dat_operation_started(QString)), this, SLOT(on_dat_operation_started(QString)));
|
|
|
+ connect(this, SIGNAL(dat_operation_finished(QString,QString)), this, SLOT(on_dat_operation_finished(QString,QString)));
|
|
|
}
|
|
|
|
|
|
+bool LotroManager::execute(QString command, QString args, QString name) {
|
|
|
+ qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Вызываем execute() команды ", command.toLocal8Bit().data());
|
|
|
|
|
|
-bool LotroManager::execute(QStringList operation) {
|
|
|
- qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Вызываем execute() команды ", cmd[0].toLocal8Bit().data());
|
|
|
-
|
|
|
- if (busy_ || cmd.size() == 0) {
|
|
|
+ if (busy_) {
|
|
|
qWarning("%s:%i: %s", __FILE__, __LINE__, "Ошибка! Уже выполняется другой процесс с данными!");
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if (std::find(available_operations_.begin(), available_operations_.end(), cmd[0])
|
|
|
+ if (std::find(available_operations_.begin(), available_operations_.end(), command)
|
|
|
== available_operations_.end()) {
|
|
|
|
|
|
- qWarning("%s:%i: %s%s%s", __FILE__, __LINE__, "Ошибка! Операция ", cmd[0].toLocal8Bit().data(), " не найдена в списке доступных!");
|
|
|
+ qWarning("%s:%i: %s%s%s", __FILE__, __LINE__, "Ошибка! Операция ", command.toLocal8Bit().data(), " не найдена в списке доступных!");
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if (operation[0] == "StartGame") {
|
|
|
+ if (command == "StartGame") {
|
|
|
QtConcurrent::run([=]() {
|
|
|
- emit dat_operation_started("StartGame");
|
|
|
+ emit dat_operation_started(command, args, name);
|
|
|
startGame();
|
|
|
- emit dat_operation_finished("StartGame");
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (operation[0] == "SetLocale" && operation.size() == 2) {
|
|
|
- QtConcurrent::run([=]() {
|
|
|
- setGameLocale(operation[1]);
|
|
|
- emit operation_finished("ApplyLoadScreens");
|
|
|
+ emit dat_operation_finished(command, args, name);
|
|
|
});
|
|
|
- return;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
- if (operation[0] == "ChangeBaseLocale" && operation.size() == 2) {
|
|
|
+ if (command == "SetLocale") {
|
|
|
QtConcurrent::run([=]() {
|
|
|
- changeBaseLocale(operation[1]);
|
|
|
- emit operation_finished("ApplyLoadScreens");
|
|
|
+ emit dat_operation_started(command, args, name);
|
|
|
+ setGameLocale(args);
|
|
|
+ emit dat_operation_finished(command, args, name);
|
|
|
});
|
|
|
- return;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
- if (operation[0] == "ApplyPatch" && operation.size() == 2) {
|
|
|
+ if (command == "ApplyPatch") {
|
|
|
QtConcurrent::run([=]() {
|
|
|
- applyPatch(operation[1]);
|
|
|
- emit operation_finished("ApplyLoadScreens");
|
|
|
+ emit dat_operation_started(command, args, name);
|
|
|
+ applyPatch(args);
|
|
|
+ emit dat_operation_finished(command, args, name);
|
|
|
});
|
|
|
- return;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
- if (operation[0] == "ApplyMicroPatch") {
|
|
|
+ if (command == "ApplyMicroPatch") {
|
|
|
QtConcurrent::run([=]() {
|
|
|
+ emit dat_operation_started(command, args, name);
|
|
|
applyMicroPatch();
|
|
|
- emit operation_finished("ApplyLoadScreens");
|
|
|
+ emit dat_operation_finished(command, args, name);
|
|
|
});
|
|
|
- return;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
- if (operation[0] == "ApplyLoadScreens") {
|
|
|
+ if (command == "ApplyLoadScreens") {
|
|
|
QtConcurrent::run([=]() {
|
|
|
+ emit dat_operation_started(command, args, name);
|
|
|
applyLoadscreens();
|
|
|
- emit operation_finished("ApplyLoadScreens");
|
|
|
+ emit dat_operation_finished(command, args, name);
|
|
|
});
|
|
|
-
|
|
|
- //applyLoadscreens();
|
|
|
- return;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
- if (operation[0] == "ApplyGlobal") {
|
|
|
+ if (command == "ApplyGlobal") {
|
|
|
QtConcurrent::run([=]() {
|
|
|
+ emit dat_operation_started(command, args, name);
|
|
|
applyPatch("fonts");
|
|
|
- applyPatch("images");
|
|
|
- applyPatch("texts");
|
|
|
applyPatch("sounds");
|
|
|
+ applyPatch("texts");
|
|
|
+ applyPatch("images");
|
|
|
applyLoadscreens();
|
|
|
applyMicroPatch();
|
|
|
- emit operation_finished("ApplyGlobal");
|
|
|
+ emit dat_operation_finished(command, args, name);
|
|
|
});
|
|
|
- return;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
- if (operation[0] == "CheckDatFile") {
|
|
|
- QtConcurrent::run(checkDatFile);
|
|
|
- //checkDatFile();
|
|
|
- return;
|
|
|
+ if (command == "CheckDatFile") {
|
|
|
+ QtConcurrent::run([=]() {
|
|
|
+ emit dat_operation_started(command, args, name);
|
|
|
+ int result = checkDatFile();
|
|
|
+ emit dat_operation_finished(command, args, name, QString::number(result));
|
|
|
+ });
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
- if (operation[0] == "SaveDatFiles") {
|
|
|
- QtConcurrent::run(saveDatFiles);
|
|
|
- //saveDatFiles();
|
|
|
- return;
|
|
|
+ if (command == "SaveDatFiles") {
|
|
|
+ QtConcurrent::run([=]() {
|
|
|
+ emit dat_operation_started(command, args, name);
|
|
|
+ saveDatFiles();
|
|
|
+ emit dat_operation_finished(command, args, name);
|
|
|
+ });
|
|
|
+ return true;
|
|
|
}
|
|
|
-
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
bool LotroManager::isBusy() {
|
|
|
return busy_;
|
|
|
}
|
|
|
|
|
|
+void LotroManager::on_dat_operation_started(QString command, QString, QString name) {
|
|
|
+ qInfo("%s:%i: %s%s %s %s", __FILE__, __LINE__, "Получен сигнал начала операции ", command.toLocal8Bit().data()
|
|
|
+ , "с именем", name.toLocal8Bit().data());
|
|
|
+ busy_ = true;
|
|
|
+}
|
|
|
+
|
|
|
+void LotroManager::on_dat_operation_finished(QString command, QString, QString name, QString result) {
|
|
|
+ qInfo("%s:%i: %s%s %s %s %s %s", __FILE__, __LINE__
|
|
|
+ , "Получен сигнал завершения операции ", command.toLocal8Bit().data()
|
|
|
+ , "с именем", name.toLocal8Bit().data()
|
|
|
+ , "с результатом", result.toLocal8Bit().data());
|
|
|
+ busy_ = false;
|
|
|
+}
|
|
|
|
|
|
void LotroManager::saveDatFiles() {
|
|
|
for (auto dat_file : dat_files_)
|
|
|
dat_file.CloseDatFile();
|
|
|
- App *app = &App::getInstance();
|
|
|
- app->helper->setState("free");
|
|
|
}
|
|
|
|
|
|
void LotroManager::startGame(){
|
|
@@ -156,7 +164,7 @@ void LotroManager::startGame(){
|
|
|
} else {
|
|
|
QString text = "Запуск не удался";
|
|
|
QString info = "Не удалось запустить игру. Не найден файл TurbineLauncher.exe или невозможно получить к нему доступ. "
|
|
|
- "Проверьте в 'Настройках', что у вас указан верный путь к игре, закрыт лаунчер игры и повторите попытку запуска.";
|
|
|
+ "Проверьте в разделе 'Настройки', что у вас указан верный путь к игре, закрыт лаунчер игры и повторите попытку запуска.";
|
|
|
app->helper->myDialogBox(text, info, "OK", "Отмена", "gandalf.png", "", "", 400, 160, true, false);
|
|
|
}
|
|
|
}
|
|
@@ -201,8 +209,7 @@ bool LotroManager::openDatFile(int id) {
|
|
|
int dat_state = dat_files_[id].InitDatFile(filename.toLocal8Bit().toStdString(), id);
|
|
|
qDebug("%s:%i: %s%d", __FILE__, __LINE__, "Состояние dat-файла: ", dat_state);
|
|
|
|
|
|
- if(dat_state > 0){
|
|
|
- app->helper->setState("busy");
|
|
|
+ if(dat_state > 0) {
|
|
|
return true;
|
|
|
} else {
|
|
|
QString text = "Нет доступа к файлам игры";
|
|
@@ -230,7 +237,7 @@ void LotroManager::applyPatch(QString name){
|
|
|
|
|
|
QStringList paths = dir.entryList(QStringList(name + "*"));
|
|
|
qDebug() << QString("data/" + paths.first()).toLocal8Bit().data();
|
|
|
- if(!paths.empty()){
|
|
|
+ if(!paths.empty()) {
|
|
|
database_.InitDatabase(QString("data/" + paths.first()).toLocal8Bit().data());
|
|
|
int indb = database_.CountRows();
|
|
|
qInfo("%s:%i: %s%d", __FILE__, __LINE__, "Файлов в обновлении: ", indb);
|
|
@@ -239,8 +246,7 @@ void LotroManager::applyPatch(QString name){
|
|
|
if (label != nullptr)
|
|
|
label->setText(QString("Применение ... ") + QString::fromLatin1("%1").arg(i*100.0/indb, 3, 'f', 1) + QString("%"));
|
|
|
}
|
|
|
- if(label != nullptr)label->setText("Готово");
|
|
|
- //for (int i = 0; i < 5; i++) app->datfiles[i].CommitChanges();
|
|
|
+ if(label != nullptr) label->setText("Готово");
|
|
|
app->config->setValue("Applied", name, paths.first());
|
|
|
database_.CloseDatabase();
|
|
|
}
|
|
@@ -248,109 +254,21 @@ void LotroManager::applyPatch(QString name){
|
|
|
app->window->ui->exthintLabel->setText("Применение выбранных вами патчей закончено");
|
|
|
}
|
|
|
|
|
|
-void LotroManager::applyGlobal(){
|
|
|
- App *app = &App::getInstance();
|
|
|
-
|
|
|
- // Применяем патч с заставочными экранами
|
|
|
- if(app->config->getValue("Editor", "screens") == "true"){
|
|
|
- applyLoadscreens();
|
|
|
- } else {
|
|
|
- QString dateline = app->config->getValue("Datetime", "loadscreens");
|
|
|
- if(dateline != "-1"){
|
|
|
- QStringList date = dateline.split(" ");
|
|
|
- app->window->ui->loadscreensStatus->setText(date[0]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // Применяем остальные патчи
|
|
|
- QStringList names;
|
|
|
- QStringList need;
|
|
|
- QFuture<void> f;
|
|
|
- f = QtConcurrent::run([=]() {});
|
|
|
- names << "fonts" << "sounds" << "texts" << "images" << "videos" << "textures";
|
|
|
- QDir dir(QApplication::applicationDirPath() + "/data");
|
|
|
-
|
|
|
- foreach(QString name, names) {
|
|
|
-
|
|
|
- QStringList list = dir.entryList(QStringList(name + "*"));
|
|
|
-
|
|
|
- if (list.size() > 0 && list.first() != ""){
|
|
|
- QString isset = app->config->getValue("Applied", name);
|
|
|
- if (list.first() != isset && app->config->getValue("Editor", name) == "true") {
|
|
|
- need.append(name);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Helper *helper = new Helper();
|
|
|
- QFutureWatcher<void> * watcher = new QFutureWatcher<void>();
|
|
|
- connect(watcher, SIGNAL(finished()), helper, SLOT(handleFinisheddd()));
|
|
|
-
|
|
|
- if(need.size() > 0){
|
|
|
- watcher->setFuture(QtConcurrent::run([=]() {
|
|
|
- if(openDatFile(0)){
|
|
|
- foreach(QString name, need) {
|
|
|
- applyPatch(name);
|
|
|
- }
|
|
|
- saveDatFiles();
|
|
|
- }
|
|
|
- }));
|
|
|
- } else {
|
|
|
- installMicroPatch();
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-bool LotroManager::isDatReady(){
|
|
|
- App *app = &App::getInstance();
|
|
|
- bool free;
|
|
|
- QString dir = app->config->getValue("Local", "folder");
|
|
|
- QString file = app->config->getValue("Local", "file");
|
|
|
- QFile fl(dir+"/" + file);
|
|
|
- qDebug() << fl.fileName();
|
|
|
- if(FileSystem::fileExists(fl.fileName())){
|
|
|
- QDir game_dir(dir);
|
|
|
- free = game_dir.rename(fl.fileName(), fl.fileName() + "99");
|
|
|
- game_dir.rename(fl.fileName() + "99", fl.fileName());
|
|
|
- } else {
|
|
|
- free = false;
|
|
|
- }
|
|
|
- if(free == true) qDebug() << "Dat is FREE"; else qDebug() << "Dat is BUSY";
|
|
|
- return free;
|
|
|
-}
|
|
|
-
|
|
|
int LotroManager::checkDatFile(){
|
|
|
- //bool CheckIfUpdatedByGame(); // Обновлялся ли игрой
|
|
|
- //bool CheckIfNotPatched(); // Был ли хоть раз пропатчен новым лаунчером
|
|
|
- //bool CheckIfPatchedByOldLauncher(); // Был ли хоть раз пропатчен старым лаунчером
|
|
|
+ App* app = &App::getInstance();
|
|
|
|
|
|
- App *app = &App::getInstance();
|
|
|
- if (!openDatFile(0)) {
|
|
|
+ if (openDatFile(0) < 0)
|
|
|
return 0;
|
|
|
- }
|
|
|
|
|
|
- if(dat_files_[0].CheckIfUpdatedByGame()){
|
|
|
+ if(dat_files_[0].CheckIfUpdatedByGame())
|
|
|
return 1;
|
|
|
- //app->ready = false;
|
|
|
- //QString text = "Файлы локализации изменены";
|
|
|
- //QString info = "В процессе последнего запуска игры были установлены обновления игрового клиента. Это могло затронуть файлы локализации. Желаете провести проверку и исправить поврежденные участки перевода? Вы можете в любой момент сделать это самостоятельно, нажав кнопку «Применить патчи заново».";
|
|
|
- //app->helper->myDialogBox(text, info, "OK", "Отмена", "gandalf.png", "applypaths", "", 400, 220, true, true);
|
|
|
- }
|
|
|
|
|
|
- if(dat_files_[0].CheckIfNotPatched() && app->config->getValue("Local", "runfirst") == "1"){
|
|
|
+ if(dat_files_[0].CheckIfNotPatched() && app->config->getValue("Local", "runfirst") == "1")
|
|
|
return 2;
|
|
|
- //app->ready = false;
|
|
|
- //QString text = "Файлы локализации отсутствуют";
|
|
|
- //QString info = "Текущий файл локализации не содержит патчей. Возможно это первый запуск «Наследия» с данным игровым клиентом, или клиент был обновлён игровым лаунчером. Применить выбранные патчи в данному файлу?";
|
|
|
- //app->helper->myDialogBox(text, info, "OK", "Отмена", "gandalf.png", "applypaths", "", 420, 200, true, true);
|
|
|
- }
|
|
|
|
|
|
- if(dat_files_[0].CheckIfPatchedByOldLauncher()){
|
|
|
+ if(dat_files_[0].CheckIfPatchedByOldLauncher())
|
|
|
return 3;
|
|
|
- //QString text = "Файлы локализации не являются оригинальными";
|
|
|
- //QString info = "Внимание! Присутствующие в вашем игровом клиенте файлы локализации не являются оригинальными, поскольку были модифицированы другой программой.<br/><strong>Мы настоятельно рекомендуем перекачать оригинальные версии файлов, поскольку правильная работа Наследия с данными файлами не гарантируется!</strong>";
|
|
|
- //app->helper->myDialogBox(text, info, "Перекачать", "Не надо", "gandalf.png", "loaddatfile", "", 550, 200, true, true);
|
|
|
- }
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -504,31 +422,7 @@ void LotroManager::prepareMicroPatch(){
|
|
|
app->logSectionEnd();
|
|
|
}
|
|
|
|
|
|
-void LotroManager::changeBaseLocale(QString locale) {
|
|
|
- App *app = &App::getInstance();
|
|
|
- QString file;
|
|
|
-
|
|
|
- if(locale == "en") file = "client_local_English.dat";
|
|
|
- if(locale == "de") file = "client_local_DE.dat";
|
|
|
- if(locale == "fr") file = "client_local_FR.dat";
|
|
|
-
|
|
|
- if (FileSystem::fileExists(app->config->getValue("Local", "folder") + "/" + file)) {
|
|
|
- app->config->setValue("Local", "file", file);
|
|
|
- } else {
|
|
|
- QString text = "Данная локализация отсутствует";
|
|
|
- QString info = "В настоящий момент вы не можете выбрать данную опцию, поскольку файл " + file + " отсутствует в вашем игровом клиенте. Чтобы скачать его, запустите официальный лаунчер, выберите желаемый язык в верхней правой части окна и дождитесь, когда загрузка необходимых файлов завершится.";
|
|
|
- app->helper->myDialogBox(text, info, "OK", "Отмена", "gandalf.png", "", "", 400, 220, true, false);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
bool LotroManager::setGameLocale(QString locale){
|
|
|
- App *app = &App::getInstance();
|
|
|
- app->window->ui->goHint->show();
|
|
|
- app->helper->setState("busy");
|
|
|
- app->window->ui->goLocal->setEnabled(false);
|
|
|
- app->window->ui->goOriginal->setEnabled(false);
|
|
|
- app->window->ui->goCancel->setEnabled(false);
|
|
|
-
|
|
|
if(openDatFile(0)){
|
|
|
LOCALE loc = dat_files_[0].current_locale();
|
|
|
dat_locale_ = loc;
|
|
@@ -541,18 +435,9 @@ bool LotroManager::setGameLocale(QString locale){
|
|
|
if(locale == "Original" && loc != ORIGINAL){ qDebug()<< "Current locale RU"; dat_files_[0].SetLocale(ORIGINAL); dat_locale_ = ORIGINAL;}
|
|
|
saveDatFiles();
|
|
|
}
|
|
|
-
|
|
|
- app->window->ui->goHint->hide();
|
|
|
- app->window->ui->goProgress->hide();
|
|
|
- app->window->ui->startbox->hide();
|
|
|
- app->window->ui->goLocal->setEnabled(true);
|
|
|
- app->window->ui->goOriginal->setEnabled(true);
|
|
|
- app->window->ui->goCancel->setEnabled(true);
|
|
|
- app->helper->setState("free");
|
|
|
- qDebug() << "Locale changed";
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-void LotroManager::handleFinisheddd(){
|
|
|
- installMicroPatch();
|
|
|
-}
|
|
|
+//void LotroManager::handleFinisheddd(){
|
|
|
+// installMicroPatch();
|
|
|
+//}
|