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
|
|
|
|
|
|
|
class WindowSplash {
|
|
|
|
public:
|
2021-04-20 21:46:48 +02:00
|
|
|
WindowSplash(int &argc, char **&argv);
|
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-04-18 20:24:42 +02:00
|
|
|
void addStartupTask(std::string_view taskName, const std::function<bool()> &task) {
|
|
|
|
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();
|
|
|
|
|
|
|
|
void deinitGLFW();
|
|
|
|
void deinitImGui();
|
|
|
|
|
|
|
|
std::future<bool> processTasksAsync();
|
|
|
|
|
2021-04-18 20:24:42 +02:00
|
|
|
std::vector<std::pair<std::string, std::function<bool()>>> m_tasks;
|
2021-04-17 15:46:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|