JKSV/source/appstates/BaseTask.cpp
2025-08-16 18:58:32 -04:00

47 lines
1.1 KiB
C++

#include "appstates/BaseTask.hpp"
#include "graphics/colors.hpp"
#include "input.hpp"
#include "strings/strings.hpp"
#include "ui/PopMessageManager.hpp"
namespace
{
/// @brief This is the time in milliseconds between changing glyphs.
constexpr uint64_t TICKS_GLYPH_TRIGGER = 50;
} // namespace
BaseTask::BaseTask()
: BaseState(false)
, m_popUnableExit(strings::get_by_name(strings::names::GENERAL_POPS, 0))
{
m_frameTimer.start(TICKS_GLYPH_TRIGGER);
}
void BaseTask::update()
{
const bool plusPressed = input::button_pressed(HidNpadButton_Plus);
if (!m_task->is_running())
{
BaseState::deactivate();
return;
}
else if (plusPressed) { ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_TICKS, m_popUnableExit); }
BaseTask::update_loading_glyph();
}
void BaseTask::render_loading_glyph()
{
sdl::text::render(sdl::Texture::Null, 56, 673, 32, sdl::text::NO_WRAP, m_colorMod, sm_glyphArray[m_currentFrame]);
}
void BaseTask::update_loading_glyph()
{
m_colorMod.update();
if (!m_frameTimer.is_triggered()) { return; }
if (++m_currentFrame % 8 == 0) { m_currentFrame = 0; }
}