#pragma once #include #include #include #include #include #include #include #include struct GLFWwindow; namespace hex::init { using TaskFunction = std::function; struct Task { std::string name; std::function callback; bool async; }; enum FrameResult{ Success, Failure, Running }; struct Highlight { ImVec2 start; size_t count; ImColor color; }; class WindowSplash { public: WindowSplash(); ~WindowSplash(); bool loop(); FrameResult fullFrame(); void startStartupTasks(); void createTask(const Task &task); void addStartupTask(const std::string &taskName, const TaskFunction &function, bool async) { std::scoped_lock lock(m_tasksMutex); m_tasks.emplace_back(taskName, function, async); } private: GLFWwindow *m_window; std::mutex m_progressMutex; std::atomic m_progress = 0; std::list m_currTaskNames; void initGLFW(); void initImGui(); void loadAssets(); void exitGLFW() const; void exitImGui() const; std::future processTasksAsync(); std::atomic m_totalTaskCount, m_completedTaskCount; std::atomic m_taskStatus = true; std::list m_tasks; std::mutex m_tasksMutex; std::string m_gpuVendor; ImGuiExt::Texture m_splashBackgroundTexture; ImGuiExt::Texture m_splashTextTexture; std::future m_tasksSucceeded; std::array m_highlights; float m_progressLerp = 0.0F; }; }