From 8fedca57802f5953f0ab229c48849ae54c9d851c Mon Sep 17 00:00:00 2001 From: elsid Date: Thu, 16 Dec 2021 21:48:47 +0100 Subject: [PATCH] Fix navmesh cache progress bar jumps When initial approximation of maximum progress based on numer of cells is too high comparing to real number of navmesh tiles. --- apps/launcher/datafilespage.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 097dc21dd2..f5efa8bbcc 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -457,11 +457,18 @@ void Launcher::DataFilesPage::updateNavMeshProgress() QRegularExpressionMatch match = pattern.match(text); if (!match.hasMatch()) return; - int maximum = match.captured(2).toInt(); + int value = match.captured(1).toInt(); + const int maximum = match.captured(2).toInt(); if (text.contains("cell")) - maximum *= 100; - ui.navMeshProgressBar->setMaximum(std::max(ui.navMeshProgressBar->maximum(), maximum)); - ui.navMeshProgressBar->setValue(match.captured(1).toInt()); + ui.navMeshProgressBar->setMaximum(maximum * 100); + else if (maximum > ui.navMeshProgressBar->maximum()) + ui.navMeshProgressBar->setMaximum(maximum); + else + value += static_cast(std::round( + (ui.navMeshProgressBar->maximum() - maximum) + * (static_cast(value) / static_cast(maximum)) + )); + ui.navMeshProgressBar->setValue(value); } void Launcher::DataFilesPage::navMeshToolFinished(int exitCode, QProcess::ExitStatus exitStatus)