Initial commit. Needs debugging.

This commit is contained in:
J-D-K
2026-03-20 12:41:04 -04:00
parent d39fd80a20
commit 347f1bc75f
112 changed files with 1331 additions and 1109 deletions

View File

@@ -2,8 +2,9 @@
#include "appstates/FadeState.hpp"
#include "graphics/colors.hpp"
#include "graphics/fonts.hpp"
#include "graphics/screen.hpp"
#include "input.hpp"
#include "mathutil.hpp"
#include "sdl.hpp"
#include "strings/strings.hpp"
#include "ui/PopMessageManager.hpp"
@@ -11,26 +12,25 @@
// ---- Construction ----
TaskState::TaskState(sys::threadpool::JobFunction function, sys::Task::TaskData taskData)
{
m_task = std::make_unique<sys::Task>(function, taskData);
}
{ m_task = std::make_unique<sys::Task>(function, taskData); }
// ---- Public functions ----
void TaskState::update()
void TaskState::update(const sdl2::Input &input)
{
BaseTask::pop_on_plus();
BaseTask::pop_on_plus(input);
BaseTask::update_loading_glyph();
if (!m_task->is_running()) { TaskState::deactivate_state(); }
}
void TaskState::render()
void TaskState::render(sdl2::Renderer &renderer)
{
const std::string status = m_task->get_status();
const int statusX = 640 - (sdl::text::get_width(BaseTask::FONT_SIZE, status.c_str()) / 2);
const int statusWidth = sm_font->get_text_width(status);
const int statusX = math::Util<int>::center_within(graphics::SCREEN_WIDTH, statusWidth);
sdl::render_rect_fill(sdl::Texture::Null, 0, 0, graphics::SCREEN_WIDTH, graphics::SCREEN_HEIGHT, colors::DIM_BACKGROUND);
sdl::text::render(sdl::Texture::Null, statusX, 351, BaseTask::FONT_SIZE, sdl::text::NO_WRAP, colors::WHITE, status);
renderer.render_rectangle(0, 0, graphics::SCREEN_WIDTH, graphics::SCREEN_HEIGHT, colors::DIM_BACKGROUND);
sm_font->render_text(statusX, 351, colors::WHITE, status);
BaseTask::render_loading_glyph();
}
@@ -40,3 +40,13 @@ void TaskState::deactivate_state()
FadeState::create_and_push(colors::DIM_BACKGROUND, colors::ALPHA_FADE_END, colors::ALPHA_FADE_BEGIN, nullptr);
BaseState::deactivate();
}
// ---- Private Functions ----
void TaskState::initialize_static_members()
{
if (sm_font) { return; }
sm_font = sdl2::FontManager::create_load_resource<sdl2::SystemFont>(graphics::fonts::names::TWENTY_PIXEL,
graphics::fonts::sizes::TWENTY_PIXEL);
}