-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ install_ifn_and_launch() now properly waits for versions
- Loading branch information
1 parent
7438405
commit bbecc54
Showing
19 changed files
with
422 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
enum class Status { | ||
Waiting, | ||
Completed, | ||
Canceled, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,28 @@ | ||
#pragma once | ||
#include "Cool/Task/Task.hpp" | ||
#include "Cool/Task/TaskWithProgressBar.hpp" | ||
#include "ImGuiNotify/ImGuiNotify.hpp" | ||
#include "VersionName.hpp" | ||
|
||
class Task_InstallVersion : public Cool::Task { | ||
class Task_InstallVersion : public Cool::TaskWithProgressBar { | ||
public: | ||
Task_InstallVersion(VersionName version_name, std::string download_url, ImGuiNotify::NotificationId notification_id); | ||
|
||
void do_work() override; | ||
void cancel() override { _data->cancel.store(true); } | ||
auto needs_user_confirmation_to_cancel_when_closing_app() const -> bool override { return true; } | ||
auto name() const -> std::string override { return fmt::format("Installing {}", _version_name.as_string()); } | ||
Task_InstallVersion() = default; // Will install the latest version, because we don't specify a version name | ||
explicit Task_InstallVersion(VersionName version_name) | ||
: _version_name{std::move(version_name)} | ||
{} | ||
auto name() const -> std::string override { return fmt::format("Installing {}", _version_name ? _version_name->as_string() : "latest version"); } | ||
|
||
private: | ||
void on_success(); | ||
void on_cancel(); | ||
void on_error(std::string const& error_message); | ||
void on_version_not_installed(); | ||
void on_submit() override; | ||
void execute() override; | ||
void cleanup(bool has_been_canceled) override; | ||
|
||
auto needs_user_confirmation_to_cancel_when_closing_app() const -> bool override { return true; } | ||
auto text_in_notification_while_waiting_to_execute() const -> std::string override; | ||
auto notification_after_execution_completes() const -> ImGuiNotify::Notification override; | ||
|
||
private: | ||
VersionName _version_name; | ||
std::string _download_url{}; | ||
ImGuiNotify::NotificationId _notification_id{}; | ||
std::optional<VersionName> _version_name{}; | ||
std::optional<std::string> _download_url{}; | ||
|
||
struct DataSharedWithNotification { | ||
std::atomic<bool> cancel{false}; | ||
std::atomic<float> download_progress{0.f}; | ||
std::atomic<float> extraction_progress{0.f}; | ||
}; | ||
std::shared_ptr<DataSharedWithNotification> _data{std::make_shared<DataSharedWithNotification>()}; | ||
std::optional<std::string> _error_message{}; | ||
}; |
Oops, something went wrong.