|
@@ -1,4 +1,4 @@
|
|
|
-#include "lotromanager.h"
|
|
|
+#include "lotrodatmanager.h"
|
|
|
#include "filesystem.h"
|
|
|
#include "LotroDat/Subfiles/TextSubFile.h"
|
|
|
|
|
@@ -14,14 +14,14 @@
|
|
|
Q_DECLARE_METATYPE(LOTRO_DAT::FILE_TYPE)
|
|
|
Q_DECLARE_METATYPE(LOTRO_DAT::SubfileData)
|
|
|
|
|
|
-LotroManager::LotroManager(QSettings* app_settings_, QObject *parent) :
|
|
|
+LotroDatManager::LotroDatManager(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) {
|
|
|
+void LotroDatManager::initialiseDatFile(QString file_path) {
|
|
|
emit processStarted("initialiseDatFile", {file_path});
|
|
|
|
|
|
qDebug() << "Initialising file " << file_path;
|
|
@@ -36,7 +36,7 @@ void LotroManager::initialiseDatFile(QString file_path) {
|
|
|
emit processFinished("initialiseDatFile", {QString("Success"), file_path});
|
|
|
}
|
|
|
|
|
|
-void LotroManager::deinitialiseDatFile()
|
|
|
+void LotroDatManager::deinitialiseDatFile()
|
|
|
{
|
|
|
emit processStarted("deintialiseDatFile", {});
|
|
|
qDebug() << "Deinitialising file...";
|
|
@@ -44,7 +44,7 @@ void LotroManager::deinitialiseDatFile()
|
|
|
emit processFinished("deinitialiseDatFile", {});
|
|
|
}
|
|
|
|
|
|
-void LotroManager::changeLocale() {
|
|
|
+void LotroDatManager::changeLocale() {
|
|
|
qDebug() << "Changing locale of dat file...";
|
|
|
|
|
|
auto current_locale = file.GetLocaleManager().GetCurrentLocale();
|
|
@@ -70,11 +70,12 @@ void LotroManager::changeLocale() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void LotroManager::getLocaleFileContents(long long file_id, int locale) {
|
|
|
+void LotroDatManager::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) {
|
|
|
+
|
|
|
+ if (!getfile_op.result && locale != LOTRO_DAT::DatLocaleManager::ORIGINAL) {
|
|
|
emit caughtError("getLocaleFileContents", {"Файл не найден!", QString("Не удаётся найти файл с id ") + QString::number(file_id)});
|
|
|
emit processFinished("getLocaleFileContents", {"Error"});
|
|
|
return;
|
|
@@ -83,7 +84,7 @@ void LotroManager::getLocaleFileContents(long long file_id, int locale) {
|
|
|
LOTRO_DAT::SubFile subfile = getfile_op.value;
|
|
|
|
|
|
auto getrealfile_op = file.GetFileSystem().GetFile(file_id);
|
|
|
- if (!getfile_op.result) {
|
|
|
+ if (!getrealfile_op.result) {
|
|
|
emit caughtError("getLocaleFileContents", {"Файл не найден!", QString("Не удаётся найти в словаре файл с id ") + QString::number(file_id)});
|
|
|
emit processFinished("getLocaleFileContents", {"Error"});
|
|
|
return;
|
|
@@ -95,11 +96,17 @@ void LotroManager::getLocaleFileContents(long long file_id, int locale) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (!getfile_op.result)
|
|
|
+ subfile = *(getrealfile_op.value);
|
|
|
+
|
|
|
LOTRO_DAT::TextSubFile text_subfile(subfile);
|
|
|
|
|
|
auto getfiledata_op = file.GetFileSystem().GetFileData(subfile, 8);
|
|
|
|
|
|
- if (getfile_op.result == LOTRO_DAT::ERROR) {
|
|
|
+ if (getfiledata_op.result == LOTRO_DAT::ERROR) {
|
|
|
emit caughtError("getLocaleFileContents", {"Ошибка извлечения!", QString("Обнаружены некорректные данные файла в словаре! Файл ресурсов мог быть повреждён!\nid = ") + QString::number(file_id) + ", locale_id = " + QString::number(locale)});
|
|
|
emit processFinished("getLocaleFileContents", {"Error"});
|
|
|
return;
|
|
@@ -110,7 +117,7 @@ void LotroManager::getLocaleFileContents(long long file_id, int locale) {
|
|
|
emit processFinished("getLocaleFileContents", {"Success", file_id, locale});
|
|
|
}
|
|
|
|
|
|
-void LotroManager::importFilesFromDatabase(QString database_path) {
|
|
|
+void LotroDatManager::importFilesFromDatabase(QString database_path) {
|
|
|
emit processStarted("importFilesFromDatabase", {database_path});
|
|
|
|
|
|
if (!FileSystem::fileExists(database_path)) {
|
|
@@ -137,7 +144,7 @@ void LotroManager::importFilesFromDatabase(QString database_path) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void LotroManager::importFile(long long file_id, QString file_path) {
|
|
|
+void LotroDatManager::importFile(long long file_id, QString file_path) {
|
|
|
emit processStarted("importFile", {file_id, file_path});
|
|
|
|
|
|
if (!FileSystem::fileExists(file_path)) {
|
|
@@ -202,7 +209,7 @@ void LotroManager::importFile(long long file_id, QString file_path) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-void LotroManager::importTextFragment(long long file_id, long long fragment_id,
|
|
|
+void LotroDatManager::importTextFragment(long long file_id, long long fragment_id,
|
|
|
QString fragment_contents, QString arguments) {
|
|
|
emit processStarted("importTextFragment", {file_id, fragment_id});
|
|
|
|
|
@@ -261,7 +268,7 @@ void LotroManager::importTextFragment(long long file_id, long long fragment_id,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void LotroManager::getTextFragment(long long file_id, long long fragment_id) {
|
|
|
+void LotroDatManager::getTextFragment(long long file_id, long long fragment_id) {
|
|
|
emit processStarted("getTextFragment", {file_id, fragment_id});
|
|
|
|
|
|
auto getfile_op = file.GetFileSystem().GetFile(file_id);
|
|
@@ -315,7 +322,7 @@ void LotroManager::getTextFragment(long long file_id, long long fragment_id) {
|
|
|
emit processFinished("getTextFragment", {"Success"});
|
|
|
}
|
|
|
|
|
|
-void LotroManager::createCoreStatusFile(QString output_filename) {
|
|
|
+void LotroDatManager::createCoreStatusFile(QString output_filename) {
|
|
|
emit processStarted("createCoreStatusFile", {output_filename});
|
|
|
auto gatherinfo_op = file.GatherInformation(output_filename.toStdString());
|
|
|
|
|
@@ -327,7 +334,7 @@ void LotroManager::createCoreStatusFile(QString output_filename) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void LotroManager::extractSingleFile(QString output_filename, long long file_id) {
|
|
|
+void LotroDatManager::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) {
|
|
@@ -338,7 +345,7 @@ void LotroManager::extractSingleFile(QString output_filename, long long file_id)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void LotroManager::extractSingleFileToDatabase(QString database_path, long long file_id) {
|
|
|
+void LotroDatManager::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())) {
|
|
@@ -357,7 +364,7 @@ void LotroManager::extractSingleFileToDatabase(QString database_path, long long
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void LotroManager::extractGrouppedFiles(QString output_foldername, LOTRO_DAT::FILE_TYPE type) {
|
|
|
+void LotroDatManager::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) {
|
|
@@ -368,7 +375,7 @@ void LotroManager::extractGrouppedFiles(QString output_foldername, LOTRO_DAT::FI
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void LotroManager::extractGrouppedFilesToDatabase(QString database_path, LOTRO_DAT::FILE_TYPE type) {
|
|
|
+void LotroDatManager::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())) {
|
|
@@ -386,7 +393,7 @@ void LotroManager::extractGrouppedFilesToDatabase(QString database_path, LOTRO_D
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void LotroManager::getUnactiveCategories() {
|
|
|
+void LotroDatManager::getUnactiveCategories() {
|
|
|
emit processStarted("getUnactiveCategories", {});
|
|
|
|
|
|
const std::set<long long>& categories = file.GetLocaleManager().GetInactiveCategories();
|
|
@@ -402,7 +409,7 @@ void LotroManager::getUnactiveCategories() {
|
|
|
emit processFinished("getUnactiveCategories", {"Success"});
|
|
|
}
|
|
|
|
|
|
-void LotroManager::startGame() {
|
|
|
+void LotroDatManager::startGame() {
|
|
|
emit processStarted("startGame", {});
|
|
|
|
|
|
QStringList args;
|
|
@@ -437,17 +444,34 @@ void LotroManager::startGame() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void LotroManager::getLocaleFileInfo(long long file_id, int locale) {
|
|
|
+void LotroDatManager::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) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (!getfile_op.result && locale != LOTRO_DAT::DatLocaleManager::ORIGINAL) {
|
|
|
emit caughtError("getLocaleFileInfo", {"Файл не найден!", QString("Не удаётся найти в ресурсах файл с id ") + QString::number(file_id)});
|
|
|
emit processFinished("getLocaleFileInfo", {"Error"});
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- LOTRO_DAT::SubFile subfile = getfile_op.value;
|
|
|
+ LOTRO_DAT::SubFile subfile;
|
|
|
+ if (getfile_op.result) {
|
|
|
+ subfile = getfile_op.value;
|
|
|
+ } else {
|
|
|
+ auto getdictfile_op = file.GetFileSystem().GetFile(file_id);
|
|
|
+ if (!getdictfile_op.result) {
|
|
|
+ emit caughtError("getLocaleFileInfo", {"Файл не найден!", QString("Не удаётся найти в ресурсах файл с id ") + QString::number(file_id)});
|
|
|
+ emit processFinished("getLocaleFileInfo", {"Error"});
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ subfile = *(getdictfile_op.value);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
QString result = "Locale file info:\n "
|
|
|
"dictionary_offset: " + QString::number(subfile.dictionary_offset()) + "\n"
|
|
@@ -465,7 +489,7 @@ void LotroManager::getLocaleFileInfo(long long file_id, int locale) {
|
|
|
emit processFinished("getLocaleFileInfo", {"Success"});
|
|
|
}
|
|
|
|
|
|
-void LotroManager::getFileInfo(long long file_id) {
|
|
|
+void LotroDatManager::getFileInfo(long long file_id) {
|
|
|
emit processStarted(QString("getFileInfo"), {file_id});
|
|
|
|
|
|
auto getfile_op = file.GetFileSystem().GetFile(file_id);
|
|
@@ -492,7 +516,7 @@ void LotroManager::getFileInfo(long long file_id) {
|
|
|
emit processFinished("getFileInfo", {"Success"});
|
|
|
}
|
|
|
|
|
|
-void LotroManager::disableCategory(long long category_id)
|
|
|
+void LotroDatManager::disableCategory(long long category_id)
|
|
|
{
|
|
|
emit processStarted(QString("disableCategory"), {category_id});
|
|
|
file.GetLocaleManager().DisableCategory(category_id);
|
|
@@ -502,7 +526,7 @@ void LotroManager::disableCategory(long long category_id)
|
|
|
emit processFinished("disableCategory", {"Success"});
|
|
|
}
|
|
|
|
|
|
-void LotroManager::enableCategory(long long category_id)
|
|
|
+void LotroDatManager::enableCategory(long long category_id)
|
|
|
{
|
|
|
emit processStarted(QString("enableCategory"), {category_id});
|
|
|
file.GetLocaleManager().EnableCategory(category_id);
|
|
@@ -512,19 +536,19 @@ void LotroManager::enableCategory(long long category_id)
|
|
|
emit processFinished("enableCategory", {"Success"});
|
|
|
}
|
|
|
|
|
|
-LOTRO_DAT::DatStatus *LotroManager::getStatusModule()
|
|
|
+LOTRO_DAT::DatStatus *LotroDatManager::getStatusModule()
|
|
|
{
|
|
|
return &file.GetStatusModule();
|
|
|
}
|
|
|
|
|
|
-bool LotroManager::initialised() {
|
|
|
+bool LotroDatManager::initialised() {
|
|
|
return file.Initialized();
|
|
|
}
|
|
|
|
|
|
-int LotroManager::currentLocale() {
|
|
|
+int LotroDatManager::currentLocale() {
|
|
|
return file.GetLocaleManager().GetCurrentLocale();
|
|
|
}
|
|
|
|
|
|
-bool LotroManager::notPatched() {
|
|
|
+bool LotroDatManager::notPatched() {
|
|
|
return file.GetStatusModule().CheckIfNotPatched();
|
|
|
}
|