mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 12:51:42 +00:00
Rework waiting time into the installer process instead.
This commit is contained in:
parent
4fb6bf4d0d
commit
42d22ff91d
3 changed files with 16 additions and 9 deletions
|
|
@ -435,7 +435,7 @@ bool Installer::parseSources(const Input &input, Journal &journal, Sources &sour
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Installer::install(const Sources &sources, const std::filesystem::path &targetDirectory, bool skipHashChecks, Journal &journal, const std::function<bool()> &progressCallback)
|
bool Installer::install(const Sources &sources, const std::filesystem::path &targetDirectory, bool skipHashChecks, Journal &journal, std::chrono::seconds endWaitTime, const std::function<bool()> &progressCallback)
|
||||||
{
|
{
|
||||||
// Install files in reverse order of importance. In case of a process crash or power outage, this will increase the likelihood of the installation
|
// Install files in reverse order of importance. In case of a process crash or power outage, this will increase the likelihood of the installation
|
||||||
// missing critical files required for the game to run. These files are used as the way to detect if the game is installed.
|
// missing critical files required for the game to run. These files are used as the way to detect if the game is installed.
|
||||||
|
|
@ -504,11 +504,20 @@ bool Installer::install(const Sources &sources, const std::filesystem::path &tar
|
||||||
// Update the progress with the artificial amount attributed to the patching.
|
// Update the progress with the artificial amount attributed to the patching.
|
||||||
journal.progressCounter += PatcherContribution;
|
journal.progressCounter += PatcherContribution;
|
||||||
|
|
||||||
if (!progressCallback())
|
for (uint32_t i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
journal.lastResult = Journal::Result::Cancelled;
|
if (!progressCallback())
|
||||||
journal.lastErrorMessage = "Installation was cancelled.";
|
{
|
||||||
return false;
|
journal.lastResult = Journal::Result::Cancelled;
|
||||||
|
journal.lastErrorMessage = "Installation was cancelled.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
// Wait the specified amount of time to allow the consumer of the callbacks to animate, halt or cancel the installation for a while after it's finished.
|
||||||
|
std::this_thread::sleep_for(endWaitTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ struct Installer
|
||||||
static bool copyFiles(std::span<const FilePair> filePairs, const uint64_t *fileHashes, VirtualFileSystem &sourceVfs, const std::filesystem::path &targetDirectory, const std::string &validationFile, bool skipHashChecks, Journal &journal, const std::function<bool()> &progressCallback);
|
static bool copyFiles(std::span<const FilePair> filePairs, const uint64_t *fileHashes, VirtualFileSystem &sourceVfs, const std::filesystem::path &targetDirectory, const std::string &validationFile, bool skipHashChecks, Journal &journal, const std::function<bool()> &progressCallback);
|
||||||
static bool parseContent(const std::filesystem::path &sourcePath, std::unique_ptr<VirtualFileSystem> &targetVfs, Journal &journal);
|
static bool parseContent(const std::filesystem::path &sourcePath, std::unique_ptr<VirtualFileSystem> &targetVfs, Journal &journal);
|
||||||
static bool parseSources(const Input &input, Journal &journal, Sources &sources);
|
static bool parseSources(const Input &input, Journal &journal, Sources &sources);
|
||||||
static bool install(const Sources &sources, const std::filesystem::path &targetDirectory, bool skipHashChecks, Journal &journal, const std::function<bool()> &progressCallback);
|
static bool install(const Sources &sources, const std::filesystem::path &targetDirectory, bool skipHashChecks, Journal &journal, std::chrono::seconds endWaitTime, const std::function<bool()> &progressCallback);
|
||||||
static void rollback(Journal &journal);
|
static void rollback(Journal &journal);
|
||||||
|
|
||||||
// Convenience method for checking if the specified file contains the game. This should be used when the user selects the file.
|
// Convenience method for checking if the specified file contains the game. This should be used when the user selects the file.
|
||||||
|
|
|
||||||
|
|
@ -1286,7 +1286,7 @@ static void DrawInstallingProgress()
|
||||||
|
|
||||||
static void InstallerThread()
|
static void InstallerThread()
|
||||||
{
|
{
|
||||||
if (!Installer::install(g_installerSources, g_installPath, false, g_installerJournal, [&]() {
|
if (!Installer::install(g_installerSources, g_installPath, false, g_installerJournal, std::chrono::seconds(1), [&]() {
|
||||||
g_installerProgressRatioTarget = float(double(g_installerJournal.progressCounter) / double(g_installerJournal.progressTotal));
|
g_installerProgressRatioTarget = float(double(g_installerJournal.progressCounter) / double(g_installerJournal.progressTotal));
|
||||||
|
|
||||||
// If user is being asked for confirmation on cancelling the installation, halt the installer from progressing further.
|
// If user is being asked for confirmation on cancelling the installation, halt the installer from progressing further.
|
||||||
|
|
@ -1303,8 +1303,6 @@ static void InstallerThread()
|
||||||
Installer::rollback(g_installerJournal);
|
Installer::rollback(g_installerJournal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rest for a bit after finishing the installation, the device is tired
|
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
|
||||||
g_installerFinished = true;
|
g_installerFinished = true;
|
||||||
g_installerCancelled = false;
|
g_installerCancelled = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue