|
@@ -7,8 +7,113 @@
|
|
|
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()));
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+bool LotroManager::execute(QStringList operation) {
|
|
|
+ qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Вызываем execute() команды ", cmd[0].toLocal8Bit().data());
|
|
|
+
|
|
|
+ if (busy_ || cmd.size() == 0) {
|
|
|
+ qWarning("%s:%i: %s", __FILE__, __LINE__, "Ошибка! Уже выполняется другой процесс с данными!");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (std::find(available_operations_.begin(), available_operations_.end(), cmd[0])
|
|
|
+ == available_operations_.end()) {
|
|
|
+
|
|
|
+ qWarning("%s:%i: %s%s%s", __FILE__, __LINE__, "Ошибка! Операция ", cmd[0].toLocal8Bit().data(), " не найдена в списке доступных!");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (operation[0] == "StartGame") {
|
|
|
+ QtConcurrent::run([=]() {
|
|
|
+ emit dat_operation_started("StartGame");
|
|
|
+ startGame();
|
|
|
+ emit dat_operation_finished("StartGame");
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (operation[0] == "SetLocale" && operation.size() == 2) {
|
|
|
+ QtConcurrent::run([=]() {
|
|
|
+ setGameLocale(operation[1]);
|
|
|
+ emit operation_finished("ApplyLoadScreens");
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (operation[0] == "ChangeBaseLocale" && operation.size() == 2) {
|
|
|
+ QtConcurrent::run([=]() {
|
|
|
+ changeBaseLocale(operation[1]);
|
|
|
+ emit operation_finished("ApplyLoadScreens");
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (operation[0] == "ApplyPatch" && operation.size() == 2) {
|
|
|
+ QtConcurrent::run([=]() {
|
|
|
+ applyPatch(operation[1]);
|
|
|
+ emit operation_finished("ApplyLoadScreens");
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (operation[0] == "ApplyMicroPatch") {
|
|
|
+ QtConcurrent::run([=]() {
|
|
|
+ applyMicroPatch();
|
|
|
+ emit operation_finished("ApplyLoadScreens");
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (operation[0] == "ApplyLoadScreens") {
|
|
|
+ QtConcurrent::run([=]() {
|
|
|
+ applyLoadscreens();
|
|
|
+ emit operation_finished("ApplyLoadScreens");
|
|
|
+ });
|
|
|
+
|
|
|
+ //applyLoadscreens();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (operation[0] == "ApplyGlobal") {
|
|
|
+ QtConcurrent::run([=]() {
|
|
|
+ applyPatch("fonts");
|
|
|
+ applyPatch("images");
|
|
|
+ applyPatch("texts");
|
|
|
+ applyPatch("sounds");
|
|
|
+ applyLoadscreens();
|
|
|
+ applyMicroPatch();
|
|
|
+ emit operation_finished("ApplyGlobal");
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (operation[0] == "CheckDatFile") {
|
|
|
+ QtConcurrent::run(checkDatFile);
|
|
|
+ //checkDatFile();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (operation[0] == "SaveDatFiles") {
|
|
|
+ QtConcurrent::run(saveDatFiles);
|
|
|
+ //saveDatFiles();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+bool LotroManager::isBusy() {
|
|
|
+ return busy_;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
void LotroManager::saveDatFiles() {
|
|
|
for (auto dat_file : dat_files_)
|
|
|
dat_file.CloseDatFile();
|
|
@@ -114,7 +219,7 @@ void LotroManager::applyPatch(QString name){
|
|
|
App *app = &App::getInstance();
|
|
|
app->window->ui->hintLabel->setText("Установка патчей");
|
|
|
app->window->ui->exthintLabel->setText("Ожидайте. Идет установка выбранных патчей");
|
|
|
- qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Начинаем применение патча ", app->helper->stringToChar(name));
|
|
|
+ qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Начинаем применение патча ", name.toLocal8Bit().data());
|
|
|
QLabel* label = app->window->findChild<QLabel*>(name + "Status");
|
|
|
QDir dir(QApplication::applicationDirPath() + "/data");
|
|
|
if (!dir.exists()) {
|
|
@@ -124,9 +229,9 @@ void LotroManager::applyPatch(QString name){
|
|
|
}
|
|
|
|
|
|
QStringList paths = dir.entryList(QStringList(name + "*"));
|
|
|
- qDebug() << app->helper->stringToChar("data/" + paths.first());
|
|
|
+ qDebug() << QString("data/" + paths.first()).toLocal8Bit().data();
|
|
|
if(!paths.empty()){
|
|
|
- database_.InitDatabase(app->helper->stringToChar("data/" + paths.first()));
|
|
|
+ database_.InitDatabase(QString("data/" + paths.first()).toLocal8Bit().data());
|
|
|
int indb = database_.CountRows();
|
|
|
qInfo("%s:%i: %s%d", __FILE__, __LINE__, "Файлов в обновлении: ", indb);
|
|
|
for(int i = 0; i<=indb; i++){
|
|
@@ -257,7 +362,7 @@ void LotroManager::applyMicroPatch(){
|
|
|
app->window->ui->hintLabel->setText("Установка последних обновлений");
|
|
|
app->window->ui->exthintLabel->setText("Подождите пока закончится применение обновлений");
|
|
|
|
|
|
- database_.InitDatabase(app->helper->stringToChar(app->network->micropatch));
|
|
|
+ database_.InitDatabase(app->network->micropatch.toLocal8Bit().data());
|
|
|
int indb = database_.CountRows();
|
|
|
qInfo("%s:%i: %s%d", __FILE__, __LINE__, "Файлов в обновлении: ", indb);
|
|
|
|
|
@@ -316,7 +421,7 @@ void LotroManager::applyLoadscreens(){
|
|
|
subfile = database_.GetNextFile();
|
|
|
qDebug() << i;
|
|
|
if (!subfile.Empty()){
|
|
|
- qInfo("%s:%i: %s", __FILE__, __LINE__, app->helper->stringToChar(folder + filenames[i]));
|
|
|
+ qInfo("%s:%i: %s", __FILE__, __LINE__, (folder + filenames[i]).toLocal8Bit().data());
|
|
|
QFile::remove(folder + filenames[i]);
|
|
|
subfile.binary_data.WriteToFile((folder + filenames[i]).toStdString());
|
|
|
}
|
|
@@ -388,7 +493,7 @@ void LotroManager::prepareMicroPatch(){
|
|
|
qInfo("%s:%i: %s", __FILE__, __LINE__, "Опция активна. Начинаем загрузку обновлений");
|
|
|
app->network->micropatch = QApplication::applicationDirPath() + "/data/micro/" + QString::number(timestamp) + ".db";
|
|
|
if(!FileSystem::fileExists(app->network->micropatch)){
|
|
|
- qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Файл патча: ", app->helper->stringToChar(app->network->micropatch));
|
|
|
+ qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Файл патча: ", app->network->micropatch.toLocal8Bit().data());
|
|
|
app->network->micropatch = app->network->getMicroPath(timestamp);
|
|
|
}
|
|
|
app->window->ui->hintLabel->setText("Загрузка завершена");
|
|
@@ -399,19 +504,15 @@ void LotroManager::prepareMicroPatch(){
|
|
|
app->logSectionEnd();
|
|
|
}
|
|
|
|
|
|
-void LotroManager::saveLocale(int locale, QPushButton * button){
|
|
|
+void LotroManager::changeBaseLocale(QString locale) {
|
|
|
App *app = &App::getInstance();
|
|
|
QString file;
|
|
|
|
|
|
- if(locale == 0) file = "client_local_English.dat";
|
|
|
- if(locale == 1) file = "client_local_DE.dat";
|
|
|
- if(locale == 2) file = "client_local_FR.dat";
|
|
|
+ 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->window->ui->enButton->setEnabled(true);
|
|
|
- app->window->ui->deButton->setEnabled(true);
|
|
|
- app->window->ui->frButton->setEnabled(true);
|
|
|
- button->setEnabled(false);
|
|
|
+ if (FileSystem::fileExists(app->config->getValue("Local", "folder") + "/" + file)) {
|
|
|
app->config->setValue("Local", "file", file);
|
|
|
} else {
|
|
|
QString text = "Данная локализация отсутствует";
|
|
@@ -449,7 +550,6 @@ bool LotroManager::setGameLocale(QString locale){
|
|
|
app->window->ui->goCancel->setEnabled(true);
|
|
|
app->helper->setState("free");
|
|
|
qDebug() << "Locale changed";
|
|
|
-
|
|
|
return true;
|
|
|
}
|
|
|
|