2021-04-17 15:46:26 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <future>
|
2023-11-28 00:19:42 +01:00
|
|
|
#include <list>
|
|
|
|
#include <string>
|
2021-04-17 15:46:26 +02:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
|
2023-11-28 00:19:42 +01:00
|
|
|
#include <imgui.h>
|
|
|
|
#include <hex/ui/imgui_imhex_extensions.h>
|
|
|
|
|
2021-04-17 15:46:26 +02:00
|
|
|
struct GLFWwindow;
|
|
|
|
|
2021-04-20 21:46:48 +02:00
|
|
|
namespace hex::init {
|
2021-04-17 15:46:26 +02:00
|
|
|
|
2021-09-08 15:18:24 +02:00
|
|
|
using TaskFunction = std::function<bool()>;
|
|
|
|
|
2023-11-28 00:19:42 +01:00
|
|
|
struct Task {
|
|
|
|
std::string name;
|
|
|
|
std::function<bool()> callback;
|
|
|
|
bool async;
|
|
|
|
};
|
|
|
|
|
2023-12-08 10:29:44 +01:00
|
|
|
enum FrameResult{ Success, Failure, Running };
|
2023-09-07 20:33:49 +02:00
|
|
|
|
|
|
|
struct Highlight {
|
|
|
|
ImVec2 start;
|
|
|
|
size_t count;
|
|
|
|
ImColor color;
|
|
|
|
};
|
|
|
|
|
2021-04-17 15:46:26 +02:00
|
|
|
class WindowSplash {
|
|
|
|
public:
|
2021-12-30 23:21:32 +01:00
|
|
|
WindowSplash();
|
2021-04-17 15:46:26 +02:00
|
|
|
~WindowSplash();
|
|
|
|
|
2021-04-18 20:24:42 +02:00
|
|
|
bool loop();
|
2021-04-17 15:46:26 +02:00
|
|
|
|
2023-09-07 20:33:49 +02:00
|
|
|
FrameResult fullFrame();
|
|
|
|
void startStartupTasks();
|
|
|
|
|
2023-11-28 00:19:42 +01:00
|
|
|
void createTask(const Task &task);
|
|
|
|
|
|
|
|
void addStartupTask(const std::string &taskName, const TaskFunction &function, bool async) {
|
|
|
|
std::scoped_lock lock(this->m_tasksMutex);
|
|
|
|
|
|
|
|
this->m_tasks.emplace_back(taskName, function, async);
|
2021-04-17 15:46:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
GLFWwindow *m_window;
|
|
|
|
std::mutex m_progressMutex;
|
2022-09-19 21:56:43 +02:00
|
|
|
std::atomic<float> m_progress = 0;
|
2023-07-15 14:29:14 +02:00
|
|
|
std::list<std::string> m_currTaskNames;
|
2021-04-17 15:46:26 +02:00
|
|
|
|
|
|
|
void initGLFW();
|
|
|
|
void initImGui();
|
2023-09-07 20:33:49 +02:00
|
|
|
void initMyself();
|
2021-04-17 15:46:26 +02:00
|
|
|
|
2023-12-08 10:29:44 +01:00
|
|
|
void exitGLFW() const;
|
|
|
|
void exitImGui() const;
|
2021-04-17 15:46:26 +02:00
|
|
|
|
|
|
|
std::future<bool> processTasksAsync();
|
|
|
|
|
2023-11-28 00:19:42 +01:00
|
|
|
std::atomic<u32> m_totalTaskCount, m_completedTaskCount;
|
2023-11-28 00:47:03 +01:00
|
|
|
std::atomic<bool> m_taskStatus = true;
|
|
|
|
std::list<Task> m_tasks;
|
2023-11-28 00:19:42 +01:00
|
|
|
std::mutex m_tasksMutex;
|
2022-02-15 22:36:36 +01:00
|
|
|
|
|
|
|
std::string m_gpuVendor;
|
2023-09-07 20:33:49 +02:00
|
|
|
|
2023-11-16 22:24:06 +01:00
|
|
|
ImGuiExt::Texture splashBackgroundTexture;
|
|
|
|
ImGuiExt::Texture splashTextTexture;
|
2023-09-07 20:33:49 +02:00
|
|
|
std::future<bool> tasksSucceeded;
|
2023-12-17 20:33:17 +01:00
|
|
|
std::array<Highlight, 4> highlights;
|
2023-09-07 20:33:49 +02:00
|
|
|
float progressLerp = 0.0F;
|
2021-04-17 15:46:26 +02:00
|
|
|
};
|
|
|
|
|
2021-12-22 13:16:51 +01:00
|
|
|
}
|