mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-03-22 01:34:13 -05:00
65 lines
2.4 KiB
C++
65 lines
2.4 KiB
C++
#pragma once
|
|
#include "StateManager.hpp"
|
|
#include "appstates/BaseTask.hpp"
|
|
#include "data/DataContext.hpp"
|
|
#include "sdl.hpp"
|
|
#include "sys/OpTimer.hpp"
|
|
|
|
#include <functional>
|
|
#include <vector>
|
|
|
|
class DataLoadingState final : public BaseTask
|
|
{
|
|
public:
|
|
/// @brief This is a definition for functions that are called at destruction.
|
|
using DestructFunction = std::function<void()>;
|
|
|
|
DataLoadingState(data::DataContext &context,
|
|
DestructFunction destructFunction,
|
|
sys::threadpool::JobFunction function,
|
|
sys::Task::TaskData taskData);
|
|
|
|
static inline std::shared_ptr<DataLoadingState> create(data::DataContext &context,
|
|
DestructFunction destructFunction,
|
|
sys::threadpool::JobFunction function,
|
|
sys::Task::TaskData taskData)
|
|
{
|
|
return std::make_shared<DataLoadingState>(context, destructFunction, function, taskData);
|
|
}
|
|
|
|
static inline std::shared_ptr<DataLoadingState> create_and_push(data::DataContext &context,
|
|
DestructFunction destructFunction,
|
|
sys::threadpool::JobFunction function,
|
|
sys::Task::TaskData taskData)
|
|
{
|
|
auto newState = DataLoadingState::create(context, destructFunction, function, taskData);
|
|
StateManager::push_state(newState);
|
|
return newState;
|
|
}
|
|
|
|
/// @brief Update override.
|
|
void update() override;
|
|
|
|
/// @brief Render override.
|
|
void render() override;
|
|
|
|
private:
|
|
/// @brief Reference to the data context to run post-init operations.
|
|
data::DataContext &m_context;
|
|
|
|
/// @brief X coord of the status text.
|
|
int m_statusX{};
|
|
|
|
/// @brief The functions called upon destruction.
|
|
DestructFunction m_destructFunction{};
|
|
|
|
/// @brief Icon displayed in the center of the screen.
|
|
static inline sdl::SharedTexture sm_jksvIcon{};
|
|
|
|
/// @brief Loads the icon if it hasn't been already.
|
|
void initialize_static_members();
|
|
|
|
/// @brief
|
|
void deactivate_state();
|
|
};
|