|
@@ -2,6 +2,7 @@
|
|
|
#include "filesystem.h"
|
|
|
#include "LotroDat/Subfiles/TextSubFile.h"
|
|
|
#include "models/patchdownloader.h"
|
|
|
+#include "models/settings.h"
|
|
|
|
|
|
#include <QtConcurrent/QtConcurrent>
|
|
|
#include <QFontDatabase>
|
|
@@ -15,8 +16,8 @@
|
|
|
Q_DECLARE_METATYPE(LOTRO_DAT::DatLocaleManager::LOCALE)
|
|
|
Q_DECLARE_METATYPE(QVector<QVariant>)
|
|
|
|
|
|
-LotroDatManager::LotroDatManager(QSettings* settings, QObject *parent) :
|
|
|
- QObject(parent), app_settings(settings) {
|
|
|
+LotroDatManager::LotroDatManager(QObject *parent) :
|
|
|
+ QObject(parent) {
|
|
|
|
|
|
qRegisterMetaType<QVector<QVariant>>();
|
|
|
qRegisterMetaType<LOTRO_DAT::DatLocaleManager::LOCALE>();
|
|
@@ -46,9 +47,10 @@ void LotroDatManager::InitialiseManager()
|
|
|
{
|
|
|
qDebug() << "Initialising .dat manager";
|
|
|
emit processStarted("InitialiseManager");
|
|
|
- QString game_folder = app_settings->value("General/game_folder_path", QString()).toString();
|
|
|
- QString locale_prefix = app_settings->value("General/original_locale", "English").toString();
|
|
|
- if (game_folder.isEmpty() || !FileSystem::fileExists(game_folder + "client_local_" + locale_prefix + ".dat")
|
|
|
+ QString game_folder = Settings::getValue("Lotro/game_path").toString();
|
|
|
+ QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
|
|
|
+
|
|
|
+ if (game_folder == "none" || !FileSystem::fileExists(game_folder + "client_local_" + locale_prefix + ".dat")
|
|
|
|| !FileSystem::fileExists(game_folder + "client_general.dat")) {
|
|
|
|
|
|
qDebug() << "Finished initialisation .dat manager - error: required files not found!";
|
|
@@ -106,7 +108,14 @@ void LotroDatManager::StartGame(LOTRO_DAT::DatLocaleManager::LOCALE locale)
|
|
|
client_general_file.GetLocaleManager().SetLocale(locale);
|
|
|
client_local_file.GetLocaleManager().SetLocale(locale);
|
|
|
|
|
|
- QString game_folder = app_settings->value("General/game_folder_path", QString()).toString();
|
|
|
+ QString game_folder = Settings::getValue("Lotro/game_path").toString();
|
|
|
+
|
|
|
+ if (game_folder == "none") {
|
|
|
+ emit caughtError("StartGame", {"GameFolderNotSet"});
|
|
|
+ qDebug() << "Starting game FAILED - game folder wasnt set!";
|
|
|
+ emit processFinished("StartGame");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
if (!FileSystem::fileExists(QApplication::applicationDirPath() + "/Launcher.exe")) {
|
|
|
emit caughtError("StartGame", {"NoGameLauncherInLegacyDir"});
|
|
@@ -171,7 +180,7 @@ void LotroDatManager::InstallActivePatches()
|
|
|
void LotroDatManager::SetupAllPatches()
|
|
|
{
|
|
|
foreach (QString patch_name, all_patch_names) {
|
|
|
- if (app_settings->value("PatchDatabasesDownload/" + patch_name, "Disabled").toString() == "Disabled") {
|
|
|
+ if (Settings::getValue("DatabaseDownload/" + patch_name).toString() == "Disabled") {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -180,7 +189,7 @@ void LotroDatManager::SetupAllPatches()
|
|
|
|
|
|
if (patch_name == "video") {
|
|
|
InstallVideos();
|
|
|
- app_settings->setValue("PatchApplied/" + patch_name, "True");
|
|
|
+ Settings::setValue("DatabaseApplied/" + patch_name, "True");
|
|
|
current_installing_patch_name = "none";
|
|
|
emit processFinished("SetupPatch", {patch_name});
|
|
|
return;
|
|
@@ -188,13 +197,13 @@ void LotroDatManager::SetupAllPatches()
|
|
|
|
|
|
if (patch_name == "loadscreen") {
|
|
|
InstallLoadscreens();
|
|
|
- app_settings->setValue("PatchApplied/" + patch_name, "True");
|
|
|
+ Settings::setValue("DatabaseApplied/" + patch_name, "True");
|
|
|
current_installing_patch_name = "none";
|
|
|
emit processFinished("SetupPatch", {patch_name});
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- QString database_path = app_settings->value("PatchPath/" + patch_name, "none").toString(); //patch_downloader->getDatabasePathByPatchName(patch_name);
|
|
|
+ QString database_path = Settings::getValue("DatabasePath/" + patch_name).toString(); //patch_downloader->getDatabasePathByPatchName(patch_name);
|
|
|
if (database_path == "none") {
|
|
|
qDebug() << __FUNCTION__ << "Database for " << patch_name << " has no database path! Skipping!";
|
|
|
continue;
|
|
@@ -214,7 +223,7 @@ void LotroDatManager::SetupAllPatches()
|
|
|
|
|
|
db.CloseDatabase();
|
|
|
|
|
|
- app_settings->setValue("PatchApplied/" + patch_name, "True");
|
|
|
+ Settings::setValue("DatabaseApplied/" + patch_name, "True");
|
|
|
current_installing_patch_name = "none";
|
|
|
emit processFinished("SetupPatch", {patch_name});
|
|
|
}
|
|
@@ -224,11 +233,13 @@ void LotroDatManager::InstallLoadscreens()
|
|
|
{
|
|
|
emit processStarted("InstallLoadscreens");
|
|
|
|
|
|
- if (app_settings->value("PatchDatabasesDownload/loadscreen", "Disabled").toString() == "Disabled")
|
|
|
+ if (Settings::getValue("DatabaseDownload/loadscreen").toString() == "Disabled") {
|
|
|
+ emit processFinished("InstallLoadscreens", {"Success"});
|
|
|
return;
|
|
|
+ }
|
|
|
|
|
|
- QString game_folder = app_settings->value("General/game_folder_path", QString()).toString();
|
|
|
- QString locale_prefix = app_settings->value("General/original_locale", "English").toString();
|
|
|
+ QString game_folder = Settings::getValue("Lotro/game_path").toString();
|
|
|
+ QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
|
|
|
|
|
|
QString raw_folder;
|
|
|
if (locale_prefix == "English")
|
|
@@ -240,6 +251,11 @@ void LotroDatManager::InstallLoadscreens()
|
|
|
|
|
|
QString folder = game_folder + "/raw/" + raw_folder + "/logo/";
|
|
|
|
|
|
+ if (!FileSystem::folderExists(folder)) {
|
|
|
+ emit processFinished("InstallLoadscreens", {"Error", "Incorrect folder"});
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
QString mainscreen =
|
|
|
game_folder == "en"
|
|
|
? "lotro_ad_pregame.jpg"
|
|
@@ -259,7 +275,7 @@ void LotroDatManager::InstallLoadscreens()
|
|
|
<< "lotro_generic_teleport_screen_10.jpg";
|
|
|
|
|
|
|
|
|
- QString database_path = app_settings->value("PatchPath/loadscreen", "none").toString();
|
|
|
+ QString database_path = Settings::getValue("DatabasePath/loadscreen").toString();
|
|
|
if (database_path == "none") {
|
|
|
qDebug() << __FUNCTION__ << "No path to loadscreens patch found!";
|
|
|
return;
|
|
@@ -287,15 +303,26 @@ void LotroDatManager::InstallLoadscreens()
|
|
|
|
|
|
void LotroDatManager::InstallVideos()
|
|
|
{
|
|
|
+ if (Settings::getValue("DatabaseDownload/video").toString() == "Disabled")
|
|
|
+ return;
|
|
|
+
|
|
|
emit processStarted("InstallVideos");
|
|
|
- if (app_settings->value("PatchDatabasesDownload/video", "Disabled").toString() == "Disabled")
|
|
|
+
|
|
|
+ QString game_folder = Settings::getValue("Lotro/game_path").toString();
|
|
|
+
|
|
|
+ if (game_folder == "none") {
|
|
|
+ qDebug() << __FUNCTION__ << "No path to game folder found!";
|
|
|
+ emit caughtError("InstallVideos", {"ErrorGameFolderNotFound"});
|
|
|
+ emit processFinished("InstallVideos");
|
|
|
return;
|
|
|
+ }
|
|
|
|
|
|
- QString game_folder = app_settings->value("General/game_folder_path", QString()).toString();
|
|
|
+ QString database_path = Settings::getValue("DatabasePath/video").toString();
|
|
|
|
|
|
- QString database_path = app_settings->value("PatchPath/video", "none").toString();
|
|
|
if (database_path == "none") {
|
|
|
qDebug() << __FUNCTION__ << "No path to videos patch found!";
|
|
|
+ emit caughtError("InstallVideos", {"ErrorFindDatabase"});
|
|
|
+ emit processFinished("InstallVideos");
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -352,8 +379,9 @@ void LotroDatManager::InstallUpdates()
|
|
|
{
|
|
|
emit processStarted("InstallUpdates");
|
|
|
foreach (QString patch_name, all_patch_names) {
|
|
|
- if (app_settings->value("PatchDatabasesDownload/" + patch_name, "Disabled").toString() == "Disabled" ||
|
|
|
- app_settings->value("PatchApplied/" + patch_name, "False").toString() == "True") {
|
|
|
+ if (Settings::getValue("DatabaseDownload/" + patch_name).toString() == "Disabled" ||
|
|
|
+ Settings::getValue("DatabaseApplied/" + patch_name).toString() == "True")
|
|
|
+ {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -362,21 +390,17 @@ void LotroDatManager::InstallUpdates()
|
|
|
|
|
|
if (patch_name == "video") {
|
|
|
InstallVideos();
|
|
|
- app_settings->setValue("PatchApplied/" + patch_name, "True");
|
|
|
+ Settings::setValue("DatabaseApplied/" + patch_name, "True");
|
|
|
current_installing_patch_name = "none";
|
|
|
- emit processFinished("SetupPatch", {patch_name});
|
|
|
- return;
|
|
|
}
|
|
|
|
|
|
if (patch_name == "loadscreen") {
|
|
|
InstallLoadscreens();
|
|
|
- app_settings->setValue("PatchApplied/" + patch_name, "True");
|
|
|
+ Settings::setValue("DatabaseApplied/" + patch_name, "True");
|
|
|
current_installing_patch_name = "none";
|
|
|
- emit processFinished("SetupPatch", {patch_name});
|
|
|
- return;
|
|
|
}
|
|
|
|
|
|
- QString database_path = app_settings->value("PatchPath/" + patch_name, "none").toString(); //patch_downloader->getDatabasePathByPatchName(patch_name);
|
|
|
+ QString database_path = Settings::getValue("PatchPath/" + patch_name).toString();
|
|
|
if (database_path == "none") {
|
|
|
qDebug() << __FUNCTION__ << "Database for " << patch_name << " has no database path! Skipping!";
|
|
|
continue;
|
|
@@ -396,7 +420,7 @@ void LotroDatManager::InstallUpdates()
|
|
|
|
|
|
db.CloseDatabase();
|
|
|
|
|
|
- app_settings->setValue("PatchApplied/" + patch_name, "True");
|
|
|
+ Settings::setValue("DatabaseApplied/" + patch_name, "True");
|
|
|
current_installing_patch_name = "none";
|
|
|
emit processFinished("SetupPatch", {patch_name});
|
|
|
}
|
|
@@ -410,7 +434,7 @@ void LotroDatManager::InstallMicroPatch()
|
|
|
void LotroDatManager::CreateBackup()
|
|
|
{
|
|
|
emit processStarted("CreateBackup");
|
|
|
- QString locale_prefix = app_settings->value("General/original_locale", "English").toString();
|
|
|
+ QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
|
|
|
client_local_file.GetBackupManager().CreateBackup((QApplication::applicationDirPath() + "/backup/client_local_" + locale_prefix + ".dat").toStdString());
|
|
|
client_general_file.GetBackupManager().CreateBackup((QApplication::applicationDirPath() + "/backup/client_general.dat").toStdString());
|
|
|
emit processFinished("CreateBackup");
|
|
@@ -419,7 +443,7 @@ void LotroDatManager::CreateBackup()
|
|
|
void LotroDatManager::RestoreFromBackup()
|
|
|
{
|
|
|
emit processStarted("CreateBackup");
|
|
|
- QString locale_prefix = app_settings->value("General/original_locale", "English").toString();
|
|
|
+ QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
|
|
|
client_local_file.GetBackupManager().RestoreFromBackup((QApplication::applicationDirPath() + "/backup/client_local_" + locale_prefix + ".dat").toStdString());
|
|
|
client_general_file.GetBackupManager().RestoreFromBackup((QApplication::applicationDirPath() + "/backup/client_general.dat").toStdString());
|
|
|
emit processFinished("CreateBackup");
|
|
@@ -428,7 +452,7 @@ void LotroDatManager::RestoreFromBackup()
|
|
|
void LotroDatManager::RemoveBackup()
|
|
|
{
|
|
|
emit processStarted("CreateBackup");
|
|
|
- QString locale_prefix = app_settings->value("General/original_locale", "English").toString();
|
|
|
+ QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
|
|
|
client_local_file.GetBackupManager().RemoveBackup((QApplication::applicationDirPath() + "/backup/client_local_" + locale_prefix + ".dat").toStdString());
|
|
|
client_general_file.GetBackupManager().RemoveBackup((QApplication::applicationDirPath() + "/backup/client_general.dat").toStdString());
|
|
|
emit processFinished("CreateBackup");
|
|
@@ -436,19 +460,19 @@ void LotroDatManager::RemoveBackup()
|
|
|
|
|
|
void LotroDatManager::ApplyTexts()
|
|
|
{
|
|
|
- if (app_settings->value("PatchApplyOptions/texts_general", "Disabled").toString() == "Enabled") {
|
|
|
+ if (Settings::getValue("Components/texts_main").toString() == "Enabled") {
|
|
|
client_local_file.GetLocaleManager().EnableCategory(100);
|
|
|
} else {
|
|
|
client_local_file.GetLocaleManager().DisableCategory(100);
|
|
|
}
|
|
|
|
|
|
- if (app_settings->value("PatchApplyOptions/texts_emotes", "Disabled").toString() == "Enabled") {
|
|
|
+ if (Settings::getValue("Components/texts_emotes").toString() == "Enabled") {
|
|
|
client_local_file.GetLocaleManager().EnableCategory(101);
|
|
|
} else {
|
|
|
client_local_file.GetLocaleManager().DisableCategory(101);
|
|
|
}
|
|
|
|
|
|
- if (app_settings->value("PatchApplyOptions/texts_items", "Disabled").toString() == "Enabled") {
|
|
|
+ if (Settings::getValue("Components/texts_items").toString() == "Enabled") {
|
|
|
client_local_file.GetLocaleManager().EnableCategory(102);
|
|
|
} else {
|
|
|
client_local_file.GetLocaleManager().DisableCategory(102);
|
|
@@ -456,7 +480,7 @@ void LotroDatManager::ApplyTexts()
|
|
|
}
|
|
|
|
|
|
void LotroDatManager::ApplyImages() {
|
|
|
- if (app_settings->value("PatchApplyOptions/maps", "Disabled").toString() == "Enabled") {
|
|
|
+ if (Settings::getValue("Components/maps").toString() == "Enabled") {
|
|
|
client_local_file.GetLocaleManager().EnableCategory(200);
|
|
|
} else {
|
|
|
client_local_file.GetLocaleManager().DisableCategory(200);
|
|
@@ -465,13 +489,13 @@ void LotroDatManager::ApplyImages() {
|
|
|
|
|
|
void LotroDatManager::ApplySounds() {
|
|
|
emit processStarted("ApplySounds");
|
|
|
- if (app_settings->value("PatchApplyOptions/sounds", "Disabled").toString() == "Enabled") {
|
|
|
+ if (Settings::getValue("Components/sounds").toString() == "Enabled") {
|
|
|
client_local_file.GetLocaleManager().EnableCategory(300);
|
|
|
} else {
|
|
|
client_local_file.GetLocaleManager().DisableCategory(300);
|
|
|
}
|
|
|
|
|
|
- if (app_settings->value("PatchApplyOptions/video", "Disabled").toString() == "Enabled") {
|
|
|
+ if (Settings::getValue("Components/videos").toString() == "Enabled") {
|
|
|
client_local_file.GetLocaleManager().EnableCategory(103);
|
|
|
} else {
|
|
|
client_local_file.GetLocaleManager().DisableCategory(103);
|
|
@@ -482,9 +506,17 @@ void LotroDatManager::ApplySounds() {
|
|
|
bool LotroDatManager::startLotroLauncherWithParameters(LOTRO_DAT::DatLocaleManager::LOCALE locale)
|
|
|
{
|
|
|
QStringList args;
|
|
|
- args << "-skiprawdownload";
|
|
|
- if (locale == LOTRO_DAT::DatLocaleManager::PATCHED)
|
|
|
+ if (Settings::getValue("Lotro/skip_raw_download").toString() == "True") {
|
|
|
+ args << "-skiprawdownload";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Settings::getValue("Lotro/no_splash_screen").toString() == "True") {
|
|
|
+ args << "-nosplashscreen";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (locale == LOTRO_DAT::DatLocaleManager::PATCHED) {
|
|
|
args << "gamelaunch" << "-disablePatch";
|
|
|
+ }
|
|
|
|
|
|
client_general_file.Deinitialize();
|
|
|
client_local_file.Deinitialize();
|
|
@@ -500,7 +532,7 @@ bool LotroDatManager::startLotroLauncherWithParameters(LOTRO_DAT::DatLocaleManag
|
|
|
|
|
|
qDebug() << "Запускаем игру со следующими аргументами: " << args;
|
|
|
|
|
|
- QFile f(app_settings->value("General/game_folder_path", "none").toString() + "/LotroLauncher.exe");
|
|
|
+ QFile f(Settings::getValue("Lotro/game_path").toString() + "/LotroLauncher.exe");
|
|
|
QProcess process;
|
|
|
|
|
|
if (FileSystem::fileExists(f.fileName())) {
|