2021-04-17 15:46:26 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <future>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
|
|
|
|
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-09-07 20:33:49 +02:00
|
|
|
enum FrameResult{ success, failure, wait };
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
2022-09-19 16:54:19 +02:00
|
|
|
void addStartupTask(const std::string &taskName, const TaskFunction &task, bool async) {
|
|
|
|
this->m_tasks.emplace_back(taskName, task, 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
|
|
|
|
2022-01-18 00:10:10 +01:00
|
|
|
void exitGLFW();
|
|
|
|
void exitImGui();
|
2021-04-17 15:46:26 +02:00
|
|
|
|
|
|
|
std::future<bool> processTasksAsync();
|
|
|
|
|
2022-09-19 16:54:19 +02:00
|
|
|
std::vector<std::tuple<std::string, TaskFunction, bool>> m_tasks;
|
2022-02-15 22:36:36 +01:00
|
|
|
|
|
|
|
std::string m_gpuVendor;
|
2023-09-07 20:33:49 +02:00
|
|
|
|
|
|
|
ImGui::Texture splashBackgroundTexture;
|
|
|
|
ImGui::Texture splashTextTexture;
|
|
|
|
std::future<bool> tasksSucceeded;
|
|
|
|
std::array<Highlight, 3> highlights;
|
|
|
|
float progressLerp = 0.0F;
|
2021-04-17 15:46:26 +02:00
|
|
|
};
|
|
|
|
|
2021-12-22 13:16:51 +01:00
|
|
|
}
|