|
@@ -91,7 +91,7 @@ void PatchInstaller::installPatch(QString patch_name, LOTRO_DAT::Database* datab
|
|
|
|
|
|
const int category = file.options["cat"] ? file.options["cat"].as<int>() : -1;
|
|
|
QString component_name = getComponentNameFromId(category);
|
|
|
- if (!Settings::getValue("Components/" + component_name).toBool()) {
|
|
|
+ if (category != -1 && !Settings::getValue("Components/" + component_name).toBool()) {
|
|
|
continue;
|
|
|
}
|
|
|
const int dat_id = file.options["did"] ? file.options["did"].as<int>() : 0;
|
|
@@ -156,19 +156,22 @@ void PatchInstaller::installLoadscreens(LOTRO_DAT::Database* database) {
|
|
|
}
|
|
|
|
|
|
void PatchInstaller::installVideos(LOTRO_DAT::Database* database) {
|
|
|
+
|
|
|
current_status.finished_parts += database->CountRows();
|
|
|
emit progressChanged(current_status);
|
|
|
|
|
|
+ download_video_total_videos = database->CountRows();
|
|
|
+ download_video_finished_videos = 0;
|
|
|
+
|
|
|
if (!Settings::getValue("Components/videos").toBool()) {
|
|
|
Settings::setValue("DatabaseNeedInstall/video", false);
|
|
|
return;
|
|
|
}
|
|
|
- video_downloaders_status.clear();
|
|
|
- QVector<Downloader*> video_downloaders;
|
|
|
|
|
|
LOTRO_DAT::SubfileData file;
|
|
|
while (!(file = database->GetNextFile()).Empty()) {
|
|
|
if (!file.options["name"] || !file.options["url"] || !file.options["hash"] || !file.options["folder"]) {
|
|
|
+ download_video_finished_videos++;
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -178,27 +181,28 @@ void PatchInstaller::installVideos(LOTRO_DAT::Database* database) {
|
|
|
const QString folder = QString::fromStdString(file.options["folder"].as<std::string>());
|
|
|
|
|
|
const QString full_filename = Settings::getValue("Lotro/game_path").toString() + "/" + folder + "/" + filename;
|
|
|
+
|
|
|
FileSystem::createFilePath(full_filename);
|
|
|
if (FileSystem::fileExists(full_filename) && FileSystem::fileHash(full_filename) == hash) {
|
|
|
+ download_video_finished_videos++;
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- QFile target_file(full_filename);
|
|
|
- target_file.open(QIODevice::WriteOnly);
|
|
|
+ QFile* target_file = new QFile(full_filename);
|
|
|
+ target_file->open(QIODevice::WriteOnly);
|
|
|
|
|
|
Downloader* video_downloader = new Downloader(this);
|
|
|
- video_downloaders_status[video_downloader] = Downloader::Status();
|
|
|
+ connect(video_downloader, &Downloader::progressChanged, this, &PatchInstaller::onDownloaderProgressChanged);
|
|
|
video_downloader->setUrl(url);
|
|
|
- video_downloader->targetFile = &target_file;
|
|
|
+ video_downloader->targetFile = target_file;
|
|
|
video_downloader->start();
|
|
|
- video_downloaders.push_back(video_downloader);
|
|
|
- }
|
|
|
+ video_downloader->waitForDownloaded();
|
|
|
+ video_downloader->targetFile->close();
|
|
|
+ video_downloader->targetFile->deleteLater();
|
|
|
+ video_downloader->targetFile = nullptr;
|
|
|
+ video_downloader->deleteLater();
|
|
|
|
|
|
- for (Downloader* downloader: video_downloaders) {
|
|
|
- downloader->waitForDownloaded();
|
|
|
- downloader->targetFile->close();
|
|
|
- downloader->targetFile = nullptr;
|
|
|
- downloader->deleteLater();
|
|
|
+ download_video_finished_videos++;
|
|
|
}
|
|
|
|
|
|
Settings::setValue("DatabaseNeedInstall/video", false);
|
|
@@ -375,7 +379,6 @@ void PatchInstaller::startPatchInstallationChain() {
|
|
|
qCritical() << "PatchInstallation: failed to initialize db " << patch_filename;
|
|
|
continue;
|
|
|
}
|
|
|
- LOTRO_DAT::SubfileData data = db->GetNextFile();
|
|
|
patch_databases[patch] = db;
|
|
|
current_status.total_parts += db->CountRows();
|
|
|
}
|
|
@@ -394,12 +397,6 @@ void PatchInstaller::startPatchInstallationChain() {
|
|
|
|
|
|
|
|
|
|
|
|
-void PatchInstaller::onDownloaderProgressChanged(Downloader* context, Downloader::Status progress) {
|
|
|
- video_downloaders_status[context] = progress;
|
|
|
-
|
|
|
- Downloader::Status cumulative_status;
|
|
|
- for (const Downloader::Status& status: video_downloaders_status.values()) {
|
|
|
- cumulative_status = cumulative_status + status;
|
|
|
- }
|
|
|
- emit videosDownloadProgressChanged(cumulative_status);
|
|
|
+void PatchInstaller::onDownloaderProgressChanged(Downloader*, Downloader::Status progress) {
|
|
|
+ emit videosDownloadProgressChanged(download_video_finished_videos, download_video_total_videos, progress);
|
|
|
}
|