Add MessageState, tweak PopMessage again, add git templates.

This commit is contained in:
J-D-K
2025-08-07 17:41:58 -04:00
parent 5f4badf716
commit 7d9a294745
36 changed files with 1694 additions and 1507 deletions

View File

@@ -44,8 +44,8 @@ class ConfirmState final : public BaseState
ConfirmState(std::string_view query, bool holdRequired, TaskFunction function, std::shared_ptr<StructType> dataStruct)
: BaseState{false}
, m_query(query)
, m_yesText(strings::get_by_name(strings::names::YES_NO, 0))
, m_noText(strings::get_by_name(strings::names::YES_NO, 1))
, m_yesText(strings::get_by_name(strings::names::YES_NO_OK, 0))
, m_noText(strings::get_by_name(strings::names::YES_NO_OK, 1))
, m_holdRequired(holdRequired)
, m_function(function)
, m_dataStruct(dataStruct)
@@ -75,8 +75,19 @@ class ConfirmState final : public BaseState
std::shared_ptr<StructType> dataStruct)
{
// I'm gonna use a sneaky trick here. This shouldn't do this because it's confusing.
auto newState = create(query, holdRequired, function, dataStruct);
auto fadeState = FadeState::create_and_push(colors::DIM_BACKGROUND, 0x00, 0x88, newState);
auto newState = create(query, holdRequired, function, dataStruct);
StateManager::push_state(newState);
return newState;
}
/// @brief Same as above but with a fade transition pushed in between.
static std::shared_ptr<ConfirmState> create_push_fade(std::string_view query,
bool holdRequired,
TaskFunction function,
std::shared_ptr<StructType> dataStruct)
{
auto newState = ConfirmState::create(query, holdRequired, function, dataStruct);
FadeState::create_and_push(colors::DIM_BACKGROUND, 0x00, 0x88, newState);
return newState;
}
@@ -108,10 +119,10 @@ 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, 288, 18, 656, colors::WHITE, m_query);
sdl::text::render(sdl::Texture::Null, 312, 288, 20, 656, colors::WHITE, m_query);
sdl::render_line(sdl::Texture::Null, 280, 454, 999, 454, colors::WHITE);
sdl::render_line(sdl::Texture::Null, 640, 454, 640, 517, colors::WHITE);
sdl::render_line(sdl::Texture::Null, 280, 454, 999, 454, colors::DIV_COLOR);
sdl::render_line(sdl::Texture::Null, 640, 454, 640, 517, colors::DIV_COLOR);
sdl::text::render(sdl::Texture::Null, m_yesX, 476, 22, sdl::text::NO_WRAP, colors::WHITE, m_yesText);
sdl::text::render(sdl::Texture::Null, m_noX, 476, 22, sdl::text::NO_WRAP, colors::WHITE, m_noText);
@@ -205,7 +216,7 @@ class ConfirmState final : public BaseState
void hold_released()
{
m_yesText = strings::get_by_name(strings::names::YES_NO, 0);
m_yesText = strings::get_by_name(strings::names::YES_NO_OK, 0);
ConfirmState::center_yes();
}

View File

@@ -0,0 +1,51 @@
#pragma once
#include "appstates/BaseState.hpp"
#include "ui/DialogBox.hpp"
#include <memory>
#include <string>
class MessageState final : public BaseState
{
public:
/// @brief Constructor.
/// @param message Message to display.
MessageState(std::string_view message);
/// @brief Required. Does NOTHING~
~MessageState();
/// @brief Creates and returns a new MessageState. See constructor.
static std::shared_ptr<MessageState> create(std::string_view message);
/// @brief Same as above, only pushed to the StateManager before return.
static std::shared_ptr<MessageState> create_and_push(std::string_view message);
/// @brief Same as above, but creates and pushes a transition fade in between.
static std::shared_ptr<MessageState> create_and_push_fade(std::string_view message);
/// @brief Update override.
void update() override;
/// @brief Render override
void render() override;
private:
/// @brief Safe store of the message to display.
std::string m_message{};
/// @brief Prevents the state from auto triggering from a previous frame.
bool m_triggerGuard{};
/// @brief This is the OK string.
static inline const char *sm_okText{};
/// @brief The center X coord for the OK [A]
static inline int sm_okX{};
/// @brief All instances share this. There's no point in constantly allocating a new one.
static inline std::shared_ptr<ui::DialogBox> sm_dialog{};
/// @brief Allocates and ensures ^
void initialize_static_members();
};

View File

@@ -48,19 +48,28 @@ class SettingsState final : public BaseState
/// @brief Runs a routine to update the menu strings for the menu.
void update_menu_options();
/// @brief Changes the current output directory of JKSV.
void change_working_directory();
/// @brief Creates and pushes the blacklist editing panel/state.
void create_push_blacklist_edit();
/// @brief Toggles or executes the code to changed the selected menu option.
void toggle_options();
/// @brief Creates and pushes the message with the description.
void create_push_description_message();
/// @brief Cycles and wraps the Zip compression level.
void cycle_zip_level();
/// @brief Cycles and wraps the title sort type.
void cycle_sort_type();
/// @brief Toggles JKSM mode and calls the main menu to reinitialize the views.
void toggle_jksm_mode();
/// @brief Cycles and wraps the animation scaling (1.0 to 4.0);
void cycle_anim_scaling();
// Returns On/Off depending on the value passed.

View File

@@ -6,6 +6,7 @@ namespace colors
inline constexpr sdl::Color WHITE = {0xFFFFFFFF};
inline constexpr sdl::Color BLACK = {0x000000FF};
inline constexpr sdl::Color RED = {0xFF0000FF};
inline constexpr sdl::Color DARK_RED = {0xDD0000FF};
inline constexpr sdl::Color GREEN = {0x00FF00FF};
inline constexpr sdl::Color BLUE = {0x0099EEFF};
inline constexpr sdl::Color YELLOW = {0xF8FC00FF};
@@ -17,4 +18,9 @@ namespace colors
inline constexpr sdl::Color DIM_BACKGROUND = {0x00000088};
inline constexpr sdl::Color TRANSPARENT = {0x00000000};
inline constexpr sdl::Color SLIDE_PANEL_CLEAR = {0x000000CC};
inline constexpr sdl::Color DIV_COLOR = {0x707070FF};
inline constexpr uint8_t ALPHA_FADE_BEGIN = 0x00;
inline constexpr uint8_t ALPHA_FADE_END = 0x88;
} // namespace colors

View File

@@ -11,16 +11,13 @@ namespace input
/// @brief Returns if a button was pressed the current frame, but not the previous.
/// @param button Button to check.
/// @return True if button is pressed. False if it wasn't.
bool button_pressed(HidNpadButton button);
/// @brief Returns if the button was pressed or held the previous and current frame.
/// @param button Button to check.
/// @return True if button is held. False if it isn't.
bool button_held(HidNpadButton button);
/// @brief Returns if the button was pressed or held the previous frame, but not the current.
/// @param button Button to check.
/// @return True if the button was released. False if it wasn't.
bool button_released(HidNpadButton button);
} // namespace input

View File

@@ -45,6 +45,6 @@ namespace strings
static constexpr std::string_view USEROPTION_STATUS = "UserOptionStatus";
static constexpr std::string_view USEROPTION_MENU = "UserOptions";
static constexpr std::string_view WEBDAV = "WebDavStrings";
static constexpr std::string_view YES_NO = "YesNo";
static constexpr std::string_view YES_NO_OK = "YesNoOK";
} // namespace names
} // namespace strings

View File

@@ -23,7 +23,7 @@ namespace ui
private:
// Every message begins off screen.
static inline constexpr int PERMA_X = 20;
static inline constexpr int START_X = 624;
static inline constexpr double START_Y = 720;
static inline constexpr int START_WIDTH = 32;
static inline constexpr int PERMA_HEIGHT = 48;
@@ -37,6 +37,9 @@ namespace ui
/// @brief The current, actual Y coord.
double m_y{};
/// @brief Currently rendering coordinate for the text.
int m_textX{};
/// @brief Current width;
int m_width{};