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
|
|
|
|
2021-09-08 15:18:24 +02:00
|
|
|
void addStartupTask(const std::string &taskName, const TaskFunction &task) {
|
2021-04-18 20:24:42 +02:00
|
|
|
this->m_tasks.emplace_back(taskName, task);
|
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();
|
|
|
|
|
2021-09-08 15:18:24 +02:00
|
|
|
std::vector<std::pair<std::string, TaskFunction>> m_tasks;
|
2021-04-17 15:46:26 +02:00
|
|
|
};
|
|
|
|
|
2021-12-22 13:16:51 +01:00
|
|
|
}
|