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()>;
|
|
|
|
|
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
|
|
|
|
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;
|
2021-04-20 21:46:48 +02:00
|
|
|
float m_progress = 0;
|
2021-04-18 20:24:42 +02:00
|
|
|
std::string m_currTaskName;
|
2021-04-17 15:46:26 +02:00
|
|
|
|
|
|
|
void initGLFW();
|
|
|
|
void initImGui();
|
|
|
|
|
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;
|
2021-04-17 15:46:26 +02:00
|
|
|
};
|
|
|
|
|
2021-12-22 13:16:51 +01:00
|
|
|
}
|