diff --git a/include/appstates/ConfirmState.hpp b/include/appstates/ConfirmState.hpp index f2ad7c6..801cb81 100644 --- a/include/appstates/ConfirmState.hpp +++ b/include/appstates/ConfirmState.hpp @@ -108,7 +108,8 @@ class ConfirmState final : public BaseState else if (holdTriggered) { ConfirmState::hold_triggered(); } else if (holdSustained) { ConfirmState::hold_sustained(); } else if (aReleased) { ConfirmState::hold_released(); } - else if (bPressed) { ConfirmState::cancelled(); } + else if (bPressed) { ConfirmState::close_dialog(); } + else if (m_close && m_transition.in_place()) { ConfirmState::deactivate_cancelled(); } } /// @brief Renders the state to screen. @@ -121,7 +122,7 @@ class ConfirmState final : public BaseState sdl::render_rect_fill(sdl::Texture::Null, 0, 0, 1280, 720, colors::DIM_BACKGROUND); sm_dialog->render(sdl::Texture::Null, hasFocus); - sdl::text::render(sdl::Texture::Null, 312, y + 32, 20, 656, colors::WHITE, m_query); + sdl::text::render(sdl::Texture::Null, 312, y + 24, 20, 656, colors::WHITE, m_query); sdl::render_line(sdl::Texture::Null, 280, y + 192, 999, y + 192, colors::DIV_COLOR); sdl::render_line(sdl::Texture::Null, 640, y + 192, 640, y + 255, colors::DIV_COLOR); @@ -228,7 +229,7 @@ class ConfirmState final : public BaseState ConfirmState::center_yes(); } - void cancelled() + void deactivate_cancelled() { FadeState::create_and_push(colors::DIM_BACKGROUND, colors::ALPHA_FADE_END, colors::ALPHA_FADE_BEGIN, nullptr); BaseState::deactivate(); diff --git a/include/appstates/ProgressState.hpp b/include/appstates/ProgressState.hpp index 88e8b47..efe5e17 100644 --- a/include/appstates/ProgressState.hpp +++ b/include/appstates/ProgressState.hpp @@ -37,8 +37,7 @@ class ProgressState final : public BaseTask sys::Task::TaskData taskData) { auto newState = ProgressState::create(function, taskData); - auto fade = - FadeState::create_and_push(colors::DIM_BACKGROUND, colors::ALPHA_FADE_BEGIN, colors::ALPHA_FADE_END, newState); + FadeState::create_and_push(colors::DIM_BACKGROUND, colors::ALPHA_FADE_BEGIN, colors::ALPHA_FADE_END, newState); return newState; } diff --git a/include/appstates/TaskState.hpp b/include/appstates/TaskState.hpp index 70d9298..b77f765 100644 --- a/include/appstates/TaskState.hpp +++ b/include/appstates/TaskState.hpp @@ -1,6 +1,8 @@ #pragma once #include "StateManager.hpp" #include "appstates/BaseTask.hpp" +#include "appstates/FadeState.hpp" +#include "graphics/colors.hpp" #include "sys/sys.hpp" #include @@ -27,6 +29,14 @@ class TaskState final : public BaseTask return newState; } + static inline std::shared_ptr create_push_fade(sys::threadpool::JobFunction function, + sys::Task::TaskData taskData) + { + auto newState = TaskState::create(function, taskData); + FadeState::create_and_push(colors::DIM_BACKGROUND, colors::ALPHA_FADE_BEGIN, colors::ALPHA_FADE_END, newState); + return newState; + } + /// @brief Runs update routine. Waits for thread function to signal finish and deactivates. void update() override; diff --git a/source/appstates/MessageState.cpp b/source/appstates/MessageState.cpp index f7330bf..5f1d637 100644 --- a/source/appstates/MessageState.cpp +++ b/source/appstates/MessageState.cpp @@ -35,7 +35,7 @@ void MessageState::render() sdl::render_rect_fill(sdl::Texture::Null, 0, 0, 1280, 720, colors::DIM_BACKGROUND); sm_dialog->render(sdl::Texture::Null, hasFocus); - sdl::text::render(sdl::Texture::Null, 312, y + 32, 20, 656, colors::WHITE, m_message); + sdl::text::render(sdl::Texture::Null, 312, y + 24, 20, 656, colors::WHITE, m_message); sdl::render_line(sdl::Texture::Null, 280, y + 192, 999, y + 192, colors::DIV_COLOR); sdl::text::render(sdl::Texture::Null, sm_okX, y + 214, 22, sdl::text::NO_WRAP, colors::WHITE, sm_okText); }