mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-03-21 17:24:37 -05:00
Initial commit. Needs debugging.
This commit is contained in:
parent
d39fd80a20
commit
347f1bc75f
|
|
@ -1 +1 @@
|
|||
Subproject commit 9fa1be94b7c0393f479f47dc9a74908a38112fe8
|
||||
Subproject commit e890bf32fe42695fc6448921d1c503c3d1eaf8d6
|
||||
2
Makefile
2
Makefile
|
|
@ -183,7 +183,7 @@ clean:
|
|||
|
||||
#---------------------------------------------------------------------------------
|
||||
send: $(BUILD)
|
||||
@nxlink $(TARGET).nro
|
||||
@nxlink -a 192.168.0.171 $(TARGET).nro
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,21 @@ class JKSV
|
|||
static void request_quit() noexcept;
|
||||
|
||||
private:
|
||||
/// @brief SDL2 instance.
|
||||
sdl2::SDL2 m_sdl2{};
|
||||
|
||||
/// @brief SDL2 Window.
|
||||
sdl2::Window m_window{};
|
||||
|
||||
/// @brief SDL2 Renderer.
|
||||
sdl2::Renderer m_renderer{};
|
||||
|
||||
/// @brief SDL2 Audio.
|
||||
sdl2::Audio m_audio{};
|
||||
|
||||
/// @brief Not really a part of SDL2, but...
|
||||
sdl2::Input m_input{};
|
||||
|
||||
/// @brief Whether or not initialization was successful and JKSV is still running.
|
||||
static inline std::atomic_bool sm_isRunning{};
|
||||
|
||||
|
|
@ -37,7 +52,13 @@ class JKSV
|
|||
bool m_showTranslationInfo{};
|
||||
|
||||
/// @brief JKSV icon in upper left corner.
|
||||
sdl::SharedTexture m_headerIcon{};
|
||||
sdl2::SharedTexture m_headerIcon{};
|
||||
|
||||
/// @brief This is used for rendering JKSV.
|
||||
sdl2::SharedFont m_titleFont{};
|
||||
|
||||
/// @brief This is used to render the build date.
|
||||
sdl2::SharedFont m_buildFont{};
|
||||
|
||||
/// @brief Stores the translation string.
|
||||
std::string m_translationInfo{};
|
||||
|
|
@ -60,9 +81,6 @@ class JKSV
|
|||
// Creates the needed directories on SD.
|
||||
bool create_directories();
|
||||
|
||||
/// @brief Adds the text color changing characters.
|
||||
void add_color_chars();
|
||||
|
||||
/// @brief Retrieves the strings from the map and sets them up for printing.
|
||||
void setup_translation_info_strings();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#pragma once
|
||||
#include "appstates/BaseState.hpp"
|
||||
#include "sdl.hpp"
|
||||
|
||||
#include <concepts>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -14,10 +16,10 @@ class StateManager
|
|||
StateManager &operator=(StateManager &&) = delete;
|
||||
|
||||
/// @brief Runs the state update routine.
|
||||
static void update();
|
||||
static void update(const sdl2::Input &input);
|
||||
|
||||
/// @brief Runs the state rendering routine(s);
|
||||
static void render() noexcept;
|
||||
static void render(sdl2::Renderer &renderer) noexcept;
|
||||
|
||||
/// @brief Returns whether the back of the vector is a closable state.
|
||||
static bool back_is_closable() noexcept;
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ class AppletModeState final : public BaseState
|
|||
static inline std::shared_ptr<AppletModeState> create() { return std::make_shared<AppletModeState>(); }
|
||||
|
||||
/// @brief Runs the update routine. Basically does nothing.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Renders the message to the screen.
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
private:
|
||||
/// @brief Pointer to the string rendered to the screen.
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ class BackupMenuState final : public BaseState
|
|||
static inline std::shared_ptr<BackupMenuState> create(data::User *user,
|
||||
data::TitleInfo *titleInfo,
|
||||
const FsSaveDataInfo *saveInfo)
|
||||
{
|
||||
return std::make_shared<BackupMenuState>(user, titleInfo, saveInfo);
|
||||
}
|
||||
{ return std::make_shared<BackupMenuState>(user, titleInfo, saveInfo); }
|
||||
|
||||
/// @brief Creates and pushes a new BackupMenuState to the vector.
|
||||
static inline std::shared_ptr<BackupMenuState> create_and_push(data::User *user,
|
||||
|
|
@ -41,10 +39,10 @@ class BackupMenuState final : public BaseState
|
|||
}
|
||||
|
||||
/// @brief Required. Inherited virtual function from AppState.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Required. Inherited virtual function from AppState.
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
/// @brief Refreshes the directory listing and menu.
|
||||
void refresh();
|
||||
|
|
@ -153,7 +151,10 @@ class BackupMenuState final : public BaseState
|
|||
static inline std::shared_ptr<ui::SlideOutPanel> sm_slidePanel{};
|
||||
|
||||
/// @brief Inner render target so the menu only renders to a certain area.
|
||||
static inline sdl::SharedTexture sm_menuRenderTarget{};
|
||||
static inline sdl2::SharedTexture sm_menuRenderTarget{};
|
||||
|
||||
/// @brief Font used for rendering text.
|
||||
static inline sdl2::SharedFont sm_font{};
|
||||
|
||||
/// @brief Initializes the static members all instances share if they haven't been already.
|
||||
void initialize_static_members();
|
||||
|
|
@ -174,7 +175,7 @@ class BackupMenuState final : public BaseState
|
|||
void initialize_remote_storage();
|
||||
|
||||
/// @brief This is the function called when New Backup is selected.
|
||||
void name_and_create_backup();
|
||||
void name_and_create_backup(const sdl2::Input &input);
|
||||
|
||||
/// @brief This is the function called when a backup is selected to be overwritten.
|
||||
void confirm_overwrite();
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ class BaseState
|
|||
virtual ~BaseState();
|
||||
|
||||
/// @brief Every derived class is required to have this function.
|
||||
virtual void update() = 0;
|
||||
virtual void update(const sdl2::Input &input) = 0;
|
||||
|
||||
/// @brief Sub update routine. Meant to handle minor background tasks. Not meant for full update routines.
|
||||
virtual void sub_update() {};
|
||||
|
||||
/// @brief Every derived class is required to have this function.
|
||||
virtual void render() = 0;
|
||||
virtual void render(sdl2::Renderer &renderer) = 0;
|
||||
|
||||
/// @brief Deactivates state and allows JKSV to purge it from the vector.
|
||||
void deactivate();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
#include "appstates/BaseState.hpp"
|
||||
#include "sdl.hpp"
|
||||
#include "sys/sys.hpp"
|
||||
#include "ui/ColorMod.hpp"
|
||||
|
||||
|
|
@ -15,10 +16,10 @@ class BaseTask : public BaseState
|
|||
|
||||
/// @brief Runs the update routine for rendering the loading glyph animation.
|
||||
/// @param
|
||||
virtual void update() = 0;
|
||||
virtual void update(const sdl2::Input &input) = 0;
|
||||
|
||||
/// @brief Virtual render function.
|
||||
virtual void render() = 0;
|
||||
virtual void render(sdl2::Renderer &renderer) = 0;
|
||||
|
||||
protected:
|
||||
/// @brief Underlying system task. This needs to be allocated by the derived classes.
|
||||
|
|
@ -28,15 +29,12 @@ class BaseTask : public BaseState
|
|||
void update_loading_glyph();
|
||||
|
||||
/// @brief Displays the "can't quit JKSV" when plus is pressed.
|
||||
void pop_on_plus();
|
||||
void pop_on_plus(const sdl2::Input &input);
|
||||
|
||||
/// @brief This function renders the loading glyph in the bottom left corner.
|
||||
/// @note This is mostly just so users don't think JKSV has frozen when operations take a long time.
|
||||
void render_loading_glyph();
|
||||
|
||||
/// @brief This is the font size used for displaying text during tasks.
|
||||
static inline constexpr int FONT_SIZE = 20;
|
||||
|
||||
private:
|
||||
/// @brief This is the current frame of the loading glyph animation.
|
||||
int m_currentFrame{};
|
||||
|
|
@ -53,4 +51,10 @@ class BaseTask : public BaseState
|
|||
/// @brief This array holds the glyphs of the loading sequence. I think it's from the Wii?
|
||||
static inline constexpr std::array<std::string_view, 8> sm_glyphArray =
|
||||
{"\ue020", "\ue021", "\ue022", "\ue023", "\ue024", "\ue025", "\ue026", "\ue027"};
|
||||
|
||||
/// @brief Font for rendering the glyph.
|
||||
static inline sdl2::SharedFont sm_font{};
|
||||
|
||||
/// @brief Ensures the font is loaded.
|
||||
void initialize_static_members();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
#include "StateManager.hpp"
|
||||
#include "appstates/BaseState.hpp"
|
||||
#include "sdl.hpp"
|
||||
#include "ui/ui.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
|
@ -24,10 +25,10 @@ class BlacklistEditState final : public BaseState
|
|||
}
|
||||
|
||||
/// @brief Update override.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Render override.
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
private:
|
||||
/// @brief Local copy of the blacklist.
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
#include "appstates/ProgressState.hpp"
|
||||
#include "appstates/TaskState.hpp"
|
||||
#include "graphics/colors.hpp"
|
||||
#include "graphics/fonts.hpp"
|
||||
#include "graphics/screen.hpp"
|
||||
#include "input.hpp"
|
||||
#include "logging/logger.hpp"
|
||||
#include "sdl.hpp"
|
||||
#include "strings/strings.hpp"
|
||||
|
|
@ -108,9 +108,7 @@ class ConfirmState final : public BaseState
|
|||
sys::threadpool::JobFunction onConfirm,
|
||||
sys::threadpool::JobFunction onCancel,
|
||||
sys::Task::TaskData taskData)
|
||||
{
|
||||
return std::make_shared<ConfirmState>(query, holdRequired, onConfirm, onCancel, taskData);
|
||||
}
|
||||
{ return std::make_shared<ConfirmState>(query, holdRequired, onConfirm, onCancel, taskData); }
|
||||
|
||||
/// @brief Returns a new ConfirmState. See constructor.
|
||||
static inline std::shared_ptr<ConfirmState> create(std::string &query,
|
||||
|
|
@ -118,9 +116,7 @@ class ConfirmState final : public BaseState
|
|||
sys::threadpool::JobFunction onConfirm,
|
||||
sys::threadpool::JobFunction onCancel,
|
||||
sys::Task::TaskData taskData)
|
||||
{
|
||||
return std::make_shared<ConfirmState>(query, holdRequired, onConfirm, onCancel, taskData);
|
||||
}
|
||||
{ return std::make_shared<ConfirmState>(query, holdRequired, onConfirm, onCancel, taskData); }
|
||||
|
||||
/// @brief Creates and returns a new ConfirmState and pushes it.
|
||||
static inline std::shared_ptr<ConfirmState> create_and_push(std::string_view query,
|
||||
|
|
@ -173,23 +169,22 @@ class ConfirmState final : public BaseState
|
|||
}
|
||||
|
||||
/// @brief Just updates the ConfirmState.
|
||||
void update() override
|
||||
void update(const sdl2::Input &input) override
|
||||
{
|
||||
switch (m_state)
|
||||
{
|
||||
case State::Opening: ConfirmState::update_dimensions(); break;
|
||||
case State::Displaying: ConfirmState::update_handle_input(); break;
|
||||
case State::Displaying: ConfirmState::update_handle_input(input); break;
|
||||
case State::Closing: ConfirmState::update_dimensions(); break;
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Renders the state to screen.
|
||||
void render() override
|
||||
void render(sdl2::Renderer &renderer) override
|
||||
{
|
||||
// These are the rendering coordinates that aren't affected by the transition.
|
||||
static constexpr int TEXT_X = 312;
|
||||
static constexpr int TEXT_Y_OFFSET = 24;
|
||||
static constexpr int TEXT_FONT_SIZE = 20;
|
||||
static constexpr int TEXT_WRAP_WIDTH = 656;
|
||||
|
||||
// Divider line A.
|
||||
|
|
@ -204,59 +199,28 @@ class ConfirmState final : public BaseState
|
|||
static constexpr int LINE_Y_OFFSET = 192;
|
||||
|
||||
// Yes/NO
|
||||
static constexpr int OPTION_Y_OFFSET = 214;
|
||||
static constexpr int OPTION_FONT_SIZE = 22;
|
||||
static constexpr int OPTION_Y_OFFSET = 214;
|
||||
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
const int y = m_transition.get_y();
|
||||
|
||||
// This is the dimming rectangle.
|
||||
sdl::render_rect_fill(sdl::Texture::Null,
|
||||
0,
|
||||
0,
|
||||
graphics::SCREEN_WIDTH,
|
||||
graphics::SCREEN_HEIGHT,
|
||||
colors::DIM_BACKGROUND);
|
||||
renderer.render_rectangle(0, 0, graphics::SCREEN_WIDTH, graphics::SCREEN_HEIGHT, colors::DIM_BACKGROUND);
|
||||
|
||||
// Render the dialog. Only render the rest if we're in the display state.
|
||||
sm_dialog->render(sdl::Texture::Null, hasFocus);
|
||||
sm_dialog->render(renderer, hasFocus);
|
||||
if (!m_transition.in_place() || m_state != State::Displaying) { return; }
|
||||
|
||||
// Main string.
|
||||
sdl::text::render(sdl::Texture::Null,
|
||||
TEXT_X,
|
||||
y + TEXT_Y_OFFSET,
|
||||
TEXT_FONT_SIZE,
|
||||
TEXT_WRAP_WIDTH,
|
||||
colors::WHITE,
|
||||
m_query);
|
||||
sm_textFont->render_text_wrapped(TEXT_X, y + TEXT_Y_OFFSET, colors::WHITE, TEXT_WRAP_WIDTH, m_query);
|
||||
|
||||
// Divider lines.
|
||||
sdl::render_line(sdl::Texture::Null,
|
||||
LINE_A_X_A,
|
||||
y + LINE_Y_OFFSET,
|
||||
LINE_A_X_B,
|
||||
y + LINE_Y_OFFSET,
|
||||
colors::DIV_COLOR);
|
||||
sdl::render_line(sdl::Texture::Null, LINE_B_X, y + LINE_Y_OFFSET, LINE_B_X, y + LINE_B_Y_B, colors::DIV_COLOR);
|
||||
renderer.render_line(LINE_A_X_A, y + LINE_Y_OFFSET, LINE_A_X_B, y + LINE_Y_OFFSET, colors::DIV_COLOR);
|
||||
renderer.render_line(LINE_B_X, y + LINE_Y_OFFSET, LINE_B_X, y + LINE_B_Y_B, colors::DIV_COLOR);
|
||||
|
||||
// Yes
|
||||
sdl::text::render(sdl::Texture::Null,
|
||||
m_yesX,
|
||||
y + OPTION_Y_OFFSET,
|
||||
OPTION_FONT_SIZE,
|
||||
sdl::text::NO_WRAP,
|
||||
colors::WHITE,
|
||||
sm_yes);
|
||||
|
||||
// No
|
||||
sdl::text::render(sdl::Texture::Null,
|
||||
m_noX,
|
||||
y + OPTION_Y_OFFSET,
|
||||
OPTION_FONT_SIZE,
|
||||
sdl::text::NO_WRAP,
|
||||
colors::WHITE,
|
||||
sm_no);
|
||||
sm_optionFont->render_text(m_yesX, y + OPTION_Y_OFFSET, colors::WHITE, sm_yes);
|
||||
sm_optionFont->render_text(m_noX, y + OPTION_Y_OFFSET, colors::WHITE, sm_no);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -313,20 +277,26 @@ class ConfirmState final : public BaseState
|
|||
/// @brief This dialog is shared between all instances.
|
||||
static inline std::shared_ptr<ui::DialogBox> sm_dialog{};
|
||||
|
||||
/// @brief This is the font used to render the actual text.
|
||||
static inline sdl2::SharedFont sm_textFont{};
|
||||
|
||||
/// @brief This is the font used to render the Yes or No options.
|
||||
static inline sdl2::SharedFont sm_optionFont{};
|
||||
|
||||
/// @brief This sound is shared.
|
||||
static inline sdl::SharedSound sm_dialogPop{};
|
||||
static inline sdl2::SharedSound sm_dialogPop{};
|
||||
|
||||
void initialize_static_members()
|
||||
{
|
||||
// Name and path to the sound used.
|
||||
static constexpr std::string_view POP_SOUND = "ConfirmPop";
|
||||
static constexpr const char *POP_PATH = "romfs:/Sound/ConfirmPop.wav";
|
||||
static constexpr std::string_view POP_PATH = "romfs:/Sound/ConfirmPop.wav";
|
||||
|
||||
// To do: Not sure about checking the holding text.
|
||||
if (sm_dialog && sm_dialogPop && sm_yes && sm_no) { return; }
|
||||
if (sm_dialog && sm_dialogPop && sm_yes && sm_no && sm_textFont && sm_optionFont) { return; }
|
||||
|
||||
// Init dialog and get it started.
|
||||
sm_dialog = ui::DialogBox::create(0, 0, 0, 0);
|
||||
sm_dialogPop = sdl::SoundManager::load(POP_SOUND, POP_PATH);
|
||||
sm_dialogPop = sdl2::SoundManager::create_load_resource(POP_PATH, POP_PATH);
|
||||
sm_dialog->set_from_transition(m_transition, true);
|
||||
|
||||
// Load yes and no.
|
||||
|
|
@ -336,6 +306,13 @@ class ConfirmState final : public BaseState
|
|||
// Loop load the holding strings.
|
||||
const char *hold{};
|
||||
for (int i = 0; (hold = strings::get_by_name(strings::names::HOLDING_STRINGS, i)); i++) { sm_hold[i] = hold; }
|
||||
|
||||
// Fonts for rendering text.
|
||||
sm_textFont = sdl2::FontManager::create_load_resource<sdl2::SystemFont>(graphics::fonts::names::TWENTY_FOUR_PIXEL,
|
||||
graphics::fonts::sizes::TWENTY_PIXEL);
|
||||
sm_optionFont =
|
||||
sdl2::FontManager::create_load_resource<sdl2::SystemFont>(graphics::fonts::names::TWENTY_FOUR_PIXEL,
|
||||
graphics::fonts::sizes::TWENTY_FOUR_PIXEL);
|
||||
}
|
||||
|
||||
/// @brief Updates the dimensions of the dialog.
|
||||
|
|
@ -353,13 +330,13 @@ class ConfirmState final : public BaseState
|
|||
}
|
||||
|
||||
/// @brief Handles the input and updating.
|
||||
void update_handle_input() noexcept
|
||||
void update_handle_input(const sdl2::Input &input) noexcept
|
||||
{
|
||||
// Grab our input bools.
|
||||
const bool aPressed = input::button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input::button_pressed(HidNpadButton_B);
|
||||
const bool aHeld = input::button_held(HidNpadButton_A);
|
||||
const bool aReleased = input::button_released(HidNpadButton_A);
|
||||
const bool aPressed = input.button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input.button_pressed(HidNpadButton_B);
|
||||
const bool aHeld = input.button_held(HidNpadButton_A);
|
||||
const bool aReleased = input.button_released(HidNpadButton_A);
|
||||
|
||||
// This is to prevent A from auto triggering the dialog.
|
||||
m_triggerGuard = m_triggerGuard || (aPressed && !m_triggerGuard);
|
||||
|
|
@ -379,13 +356,13 @@ class ConfirmState final : public BaseState
|
|||
// This just centers the Yes or holding text.
|
||||
void center_yes()
|
||||
{
|
||||
const int yesWidth = sdl::text::get_width(22, sm_yes);
|
||||
const int yesWidth = sm_optionFont->get_text_width(sm_yes);
|
||||
m_yesX = COORD_YES_X - (yesWidth / 2);
|
||||
}
|
||||
|
||||
void center_no()
|
||||
{
|
||||
const int noWidth = sdl::text::get_width(22, sm_no);
|
||||
const int noWidth = sm_optionFont->get_text_width(sm_no);
|
||||
m_noX = COORD_NO_X - (noWidth / 2);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,41 +15,45 @@ class DataLoadingState final : public BaseTask
|
|||
using DestructFunction = std::function<void()>;
|
||||
|
||||
DataLoadingState(data::DataContext &context,
|
||||
sdl2::Renderer &renderer,
|
||||
DestructFunction destructFunction,
|
||||
sys::threadpool::JobFunction function,
|
||||
sys::Task::TaskData taskData);
|
||||
|
||||
static inline std::shared_ptr<DataLoadingState> create(data::DataContext &context,
|
||||
sdl2::Renderer &renderer,
|
||||
DestructFunction destructFunction,
|
||||
sys::threadpool::JobFunction function,
|
||||
sys::Task::TaskData taskData)
|
||||
{
|
||||
return std::make_shared<DataLoadingState>(context, destructFunction, function, taskData);
|
||||
}
|
||||
{ return std::make_shared<DataLoadingState>(context, renderer, destructFunction, function, taskData); }
|
||||
|
||||
static inline std::shared_ptr<DataLoadingState> create_and_push(data::DataContext &context,
|
||||
sdl2::Renderer &renderer,
|
||||
DestructFunction destructFunction,
|
||||
sys::threadpool::JobFunction function,
|
||||
sys::Task::TaskData taskData)
|
||||
{
|
||||
auto newState = DataLoadingState::create(context, destructFunction, function, taskData);
|
||||
auto newState = DataLoadingState::create(context, renderer, destructFunction, function, taskData);
|
||||
StateManager::push_state(newState);
|
||||
return newState;
|
||||
}
|
||||
|
||||
/// @brief Update override.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Updates the loading glyph.
|
||||
void sub_update() override;
|
||||
|
||||
/// @brief Render override.
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
private:
|
||||
/// @brief Reference to the data context to run post-init operations.
|
||||
data::DataContext &m_context;
|
||||
|
||||
/// @brief Reference to SDL2 renderer for loading icons.
|
||||
sdl2::Renderer &m_renderer;
|
||||
|
||||
/// @brief X coord of the status text.
|
||||
int m_statusX{};
|
||||
|
||||
|
|
@ -57,7 +61,10 @@ class DataLoadingState final : public BaseTask
|
|||
DestructFunction m_destructFunction{};
|
||||
|
||||
/// @brief Icon displayed in the center of the screen.
|
||||
static inline sdl::SharedTexture sm_jksvIcon{};
|
||||
static inline sdl2::SharedTexture sm_jksvIcon{};
|
||||
|
||||
/// @brief Font used for rendering the status.
|
||||
static inline sdl2::SharedFont sm_font{};
|
||||
|
||||
/// @brief Loads the icon if it hasn't been already.
|
||||
void initialize_static_members();
|
||||
|
|
|
|||
|
|
@ -9,26 +9,30 @@ class ExtrasMenuState final : public BaseState
|
|||
{
|
||||
public:
|
||||
/// @brief Constructor.
|
||||
ExtrasMenuState();
|
||||
ExtrasMenuState(sdl2::Renderer &renderer);
|
||||
|
||||
/// @brief Returns a new ExtrasMenuState
|
||||
static inline std::shared_ptr<ExtrasMenuState> create() { return std::make_shared<ExtrasMenuState>(); }
|
||||
static inline std::shared_ptr<ExtrasMenuState> create(sdl2::Renderer &renderer)
|
||||
{ return std::make_shared<ExtrasMenuState>(renderer); }
|
||||
|
||||
/// @brief Updates the menu.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Sub-update routine.
|
||||
void sub_update() override;
|
||||
|
||||
/// @brief Renders the menu to screen.
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
private:
|
||||
/// @brief Reference to renderer for launching refresh.
|
||||
sdl2::Renderer &m_renderer;
|
||||
|
||||
/// @brief Menu
|
||||
std::shared_ptr<ui::Menu> m_extrasMenu{};
|
||||
|
||||
/// @brief Render target for menu.
|
||||
sdl::SharedTexture m_renderTarget{};
|
||||
sdl2::SharedTexture m_renderTarget{};
|
||||
|
||||
/// @brief Control guider for bottom right corner.
|
||||
std::shared_ptr<ui::ControlGuide> m_controlGuide{};
|
||||
|
|
|
|||
|
|
@ -18,19 +18,17 @@ class FadeState final : public BaseState
|
|||
|
||||
/// @brief Creates a new fade in state.
|
||||
/// @param nextState The next state to push after the the fade is finished.
|
||||
FadeState(sdl::Color baseColor, uint8_t startAlpha, uint8_t endAlpha, std::shared_ptr<BaseState> nextState);
|
||||
FadeState(SDL_Color baseColor, uint8_t startAlpha, uint8_t endAlpha, std::shared_ptr<BaseState> nextState);
|
||||
|
||||
/// @brief Returns a new fade in state. See constructor.
|
||||
static inline std::shared_ptr<FadeState> create(sdl::Color baseColor,
|
||||
static inline std::shared_ptr<FadeState> create(SDL_Color baseColor,
|
||||
uint8_t startAlpha,
|
||||
uint8_t endAlpha,
|
||||
std::shared_ptr<BaseState> nextState)
|
||||
{
|
||||
return std::make_shared<FadeState>(baseColor, startAlpha, endAlpha, nextState);
|
||||
}
|
||||
{ return std::make_shared<FadeState>(baseColor, startAlpha, endAlpha, nextState); }
|
||||
|
||||
/// @brief Creates, returns and pushes a new FadeInState to the statemanager.
|
||||
static std::shared_ptr<FadeState> create_and_push(sdl::Color baseColor,
|
||||
static std::shared_ptr<FadeState> create_and_push(SDL_Color baseColor,
|
||||
uint8_t startAlpha,
|
||||
uint8_t endAlpha,
|
||||
std::shared_ptr<BaseState> nextState)
|
||||
|
|
@ -41,13 +39,14 @@ class FadeState final : public BaseState
|
|||
}
|
||||
|
||||
/// @brief Update override.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Render override.
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
private:
|
||||
sdl::Color m_baseColor{};
|
||||
/// @brief Base color of the fade.
|
||||
SDL_Color m_baseColor{};
|
||||
|
||||
/// @brief Alpha value.
|
||||
uint8_t m_alpha{};
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ class FileModeState final : public BaseState
|
|||
std::string_view mountB,
|
||||
int64_t journalSize = 0,
|
||||
bool isSystem = false)
|
||||
{
|
||||
return std::make_shared<FileModeState>(mountA, mountB, journalSize, isSystem);
|
||||
}
|
||||
{ return std::make_shared<FileModeState>(mountA, mountB, journalSize, isSystem); }
|
||||
|
||||
static inline std::shared_ptr<FileModeState> create_and_push(std::string_view mountA,
|
||||
std::string_view mountB,
|
||||
|
|
@ -32,10 +30,10 @@ class FileModeState final : public BaseState
|
|||
}
|
||||
|
||||
/// @brief Update override.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Render override.
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
/// @brief This thing is a headache without this.
|
||||
friend class FileOptionState;
|
||||
|
|
@ -95,7 +93,7 @@ class FileModeState final : public BaseState
|
|||
static inline std::shared_ptr<ui::Frame> sm_frame{};
|
||||
|
||||
/// @brief This is the render target the browsers are rendered to.
|
||||
static inline sdl::SharedTexture sm_renderTarget{};
|
||||
static inline sdl2::SharedTexture sm_renderTarget{};
|
||||
|
||||
/// @brief Control guide shared by all instances.
|
||||
static inline std::shared_ptr<ui::ControlGuide> sm_controlGuide{};
|
||||
|
|
@ -116,7 +114,7 @@ class FileModeState final : public BaseState
|
|||
void update_y() noexcept;
|
||||
|
||||
/// @brief Handles input.
|
||||
void update_handle_input() noexcept;
|
||||
void update_handle_input(const sdl2::Input &input) noexcept;
|
||||
|
||||
/// @brief Handles changing the current directory or opening the options.
|
||||
void enter_selected(fslib::Path &path, fslib::Directory &directory, ui::Menu &menu);
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ class FileOptionState final : public BaseState
|
|||
|
||||
/// @brief Inline creation function.
|
||||
static inline std::shared_ptr<FileOptionState> create(FileModeState *spawningState)
|
||||
{
|
||||
return std::make_shared<FileOptionState>(spawningState);
|
||||
}
|
||||
{ return std::make_shared<FileOptionState>(spawningState); }
|
||||
|
||||
/// @brief Same as above. Pushes state before returning it.
|
||||
static inline std::shared_ptr<FileOptionState> create_and_push(FileModeState *spawningState)
|
||||
|
|
@ -30,10 +28,10 @@ class FileOptionState final : public BaseState
|
|||
}
|
||||
|
||||
/// @brief Update routine.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Render routine.
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
/// @brief Signals to this state to update the source/target menu on the next update() call.
|
||||
void update_source();
|
||||
|
|
@ -95,7 +93,7 @@ class FileOptionState final : public BaseState
|
|||
void update_dimensions() noexcept;
|
||||
|
||||
/// @brief Updates and handles input.
|
||||
void update_handle_input() noexcept;
|
||||
void update_handle_input(const sdl2::Input &input) noexcept;
|
||||
|
||||
/// @brief Updates the FileModeState's source data.
|
||||
void update_filemode_source();
|
||||
|
|
|
|||
|
|
@ -13,27 +13,28 @@ class MainMenuState final : public BaseState
|
|||
{
|
||||
public:
|
||||
/// @brief Creates and initializes the main menu.
|
||||
MainMenuState();
|
||||
MainMenuState(sdl2::Renderer &renderer);
|
||||
|
||||
/// @brief Returns a new MainMenuState
|
||||
static inline std::shared_ptr<MainMenuState> create() { return std::make_shared<MainMenuState>(); }
|
||||
static inline std::shared_ptr<MainMenuState> create(sdl2::Renderer &renderer)
|
||||
{ return std::make_shared<MainMenuState>(renderer); }
|
||||
|
||||
/// @brief Creates and returns a new MainMenuState. Pushes it automatically.
|
||||
static inline std::shared_ptr<MainMenuState> create_and_push()
|
||||
static inline std::shared_ptr<MainMenuState> create_and_push(sdl2::Renderer &renderer)
|
||||
{
|
||||
auto newState = MainMenuState::create();
|
||||
auto newState = MainMenuState::create(renderer);
|
||||
StateManager::push_state(newState);
|
||||
return newState;
|
||||
}
|
||||
|
||||
/// @brief Runs update routine.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Runs the sub-update routine.
|
||||
void sub_update() override;
|
||||
|
||||
/// @brief Renders menu to screen.
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
/// @brief Allows the update task to signal it found an update.
|
||||
void signal_update_found();
|
||||
|
|
@ -54,16 +55,16 @@ class MainMenuState final : public BaseState
|
|||
|
||||
private:
|
||||
/// @brief Render target this state renders to.
|
||||
sdl::SharedTexture m_renderTarget{};
|
||||
sdl2::SharedTexture m_renderTarget{};
|
||||
|
||||
/// @brief The background gradient.
|
||||
sdl::SharedTexture m_background{};
|
||||
sdl2::SharedTexture m_background{};
|
||||
|
||||
/// @brief Icon for the settings option,
|
||||
sdl::SharedTexture m_settingsIcon{};
|
||||
sdl2::SharedTexture m_settingsIcon{};
|
||||
|
||||
/// @brief Icon for the extras option.
|
||||
sdl::SharedTexture m_extrasIcon{};
|
||||
sdl2::SharedTexture m_extrasIcon{};
|
||||
|
||||
/// @brief Special menu type that uses icons.
|
||||
std::shared_ptr<ui::IconMenu> m_mainMenu{};
|
||||
|
|
@ -93,7 +94,7 @@ class MainMenuState final : public BaseState
|
|||
static inline std::vector<std::shared_ptr<BaseState>> sm_states{};
|
||||
|
||||
/// @brief Creates the settings and extras.
|
||||
void initialize_settings_extras();
|
||||
void initialize_settings_extras(sdl2::Renderer &renderer);
|
||||
|
||||
/// @brief Pushes the icons to the main menu.
|
||||
void initialize_menu();
|
||||
|
|
|
|||
|
|
@ -21,15 +21,11 @@ class MessageState final : public BaseState
|
|||
|
||||
/// @brief Creates and returns a new MessageState. See constructor.
|
||||
static inline std::shared_ptr<MessageState> create(std::string_view message)
|
||||
{
|
||||
return std::make_shared<MessageState>(message);
|
||||
}
|
||||
{ return std::make_shared<MessageState>(message); }
|
||||
|
||||
/// @brief Creates and returns a new MessageState. See constructor.
|
||||
static inline std::shared_ptr<MessageState> create(std::string &message)
|
||||
{
|
||||
return std::make_shared<MessageState>(message);
|
||||
}
|
||||
{ return std::make_shared<MessageState>(message); }
|
||||
|
||||
/// @brief Same as above, only pushed to the StateManager before return.
|
||||
static inline std::shared_ptr<MessageState> create_and_push(std::string_view message)
|
||||
|
|
@ -66,10 +62,10 @@ class MessageState final : public BaseState
|
|||
}
|
||||
|
||||
/// @brief Update override.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Render override
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
private:
|
||||
/// @brief States this state can be in.
|
||||
|
|
@ -102,7 +98,13 @@ class MessageState final : public BaseState
|
|||
static inline std::shared_ptr<ui::DialogBox> sm_dialog{};
|
||||
|
||||
/// @brief This is the same sound that the confirmation uses.
|
||||
static inline sdl::SharedSound sm_dialogPop{};
|
||||
static inline sdl2::SharedSound sm_dialogPop{};
|
||||
|
||||
/// @brief Font used to render the message.
|
||||
static inline sdl2::SharedFont sm_textFont{};
|
||||
|
||||
/// @brief Font used to render the OK.
|
||||
static inline sdl2::SharedFont sm_optionFont{};
|
||||
|
||||
/// @brief Allocates and ensures ^
|
||||
void initialize_static_members();
|
||||
|
|
@ -111,7 +113,7 @@ class MessageState final : public BaseState
|
|||
void update_dimensions() noexcept;
|
||||
|
||||
/// @brief Updates and handles the input.
|
||||
void update_handle_input() noexcept;
|
||||
void update_handle_input(const sdl2::Input &input) noexcept;
|
||||
|
||||
/// @brief Closes and "hides" the dialog.
|
||||
void close_dialog();
|
||||
|
|
|
|||
|
|
@ -20,9 +20,7 @@ class ProgressState final : public BaseTask
|
|||
|
||||
/// @brief Creates and returns a new ProgressState
|
||||
static inline std::shared_ptr<ProgressState> create(sys::threadpool::JobFunction function, sys::Task::TaskData taskData)
|
||||
{
|
||||
return std::make_shared<ProgressState>(function, taskData);
|
||||
}
|
||||
{ return std::make_shared<ProgressState>(function, taskData); }
|
||||
|
||||
/// @brief Creates, pushes, then returns a new ProgressState.
|
||||
static inline std::shared_ptr<ProgressState> create_and_push(sys::threadpool::JobFunction function,
|
||||
|
|
@ -42,10 +40,10 @@ class ProgressState final : public BaseTask
|
|||
}
|
||||
|
||||
/// @brief Checks if the thread is finished and deactivates this state.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Renders the current progress to screen.
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
private:
|
||||
/// @brief States this state can be in.
|
||||
|
|
@ -84,7 +82,10 @@ class ProgressState final : public BaseTask
|
|||
static inline std::shared_ptr<ui::DialogBox> sm_dialog{};
|
||||
|
||||
/// @brief This is rendered over the edges of the bar to give it a slightly rounded look.
|
||||
static inline sdl::SharedTexture sm_barEdges{};
|
||||
static inline sdl2::SharedTexture sm_barEdges{};
|
||||
|
||||
/// @brief Font used for rendering text.
|
||||
static inline sdl2::SharedFont sm_font{};
|
||||
|
||||
/// @brief Initializes the shared dialog box.
|
||||
void initialize_static_members();
|
||||
|
|
|
|||
|
|
@ -19,9 +19,7 @@ class SaveCreateState final : public BaseState
|
|||
|
||||
/// @brief Returns a new SaveCreate state. See constructor for arguments.
|
||||
static inline std::shared_ptr<SaveCreateState> create(data::User *user, TitleSelectCommon *titleSelect)
|
||||
{
|
||||
return std::make_shared<SaveCreateState>(user, titleSelect);
|
||||
}
|
||||
{ return std::make_shared<SaveCreateState>(user, titleSelect); }
|
||||
|
||||
/// @brief Creates, pushes, returns and new SaveCreateState.
|
||||
static inline std::shared_ptr<SaveCreateState> create_and_push(data::User *user, TitleSelectCommon *titleSelect)
|
||||
|
|
@ -32,10 +30,10 @@ class SaveCreateState final : public BaseState
|
|||
}
|
||||
|
||||
/// @brief Runs the update routine.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Runs the render routine.
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
/// @brief This signals so data and the view can be refreshed on the next update() to avoid threading shenanigans.
|
||||
void refresh_required();
|
||||
|
|
|
|||
|
|
@ -15,9 +15,7 @@ class SaveImportState final : public BaseState
|
|||
SaveImportState(data::User *user);
|
||||
|
||||
static inline std::shared_ptr<SaveImportState> create(data::User *user)
|
||||
{
|
||||
return std::make_shared<SaveImportState>(user);
|
||||
}
|
||||
{ return std::make_shared<SaveImportState>(user); }
|
||||
|
||||
static inline std::shared_ptr<SaveImportState> create_and_push(data::User *user)
|
||||
{
|
||||
|
|
@ -26,9 +24,9 @@ class SaveImportState final : public BaseState
|
|||
return newState;
|
||||
}
|
||||
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
// clang-format off
|
||||
// Struct used to pass data to the task.
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ class SettingsState final : public BaseState
|
|||
static inline std::shared_ptr<SettingsState> create() { return std::make_shared<SettingsState>(); }
|
||||
|
||||
/// @brief Runs the update routine.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Sub update routine.
|
||||
void sub_update() override;
|
||||
|
||||
/// @brief Runs the render routine.
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
private:
|
||||
/// @brief Menu for selecting and toggling settings.
|
||||
|
|
@ -35,7 +35,7 @@ class SettingsState final : public BaseState
|
|||
std::shared_ptr<ui::ControlGuide> m_controlGuide{};
|
||||
|
||||
/// @brief Render target to render to.
|
||||
sdl::SharedTexture m_renderTarget{};
|
||||
sdl2::SharedTexture m_renderTarget{};
|
||||
|
||||
/// @brief Loads the settings menu strings.
|
||||
void load_settings_menu();
|
||||
|
|
|
|||
|
|
@ -16,9 +16,7 @@ class TaskState final : public BaseTask
|
|||
|
||||
/// @brief Constructs and returns a TaskState.
|
||||
static inline std::shared_ptr<TaskState> create(sys::threadpool::JobFunction function, sys::Task::TaskData taskData)
|
||||
{
|
||||
return std::make_shared<TaskState>(function, taskData);
|
||||
}
|
||||
{ return std::make_shared<TaskState>(function, taskData); }
|
||||
|
||||
/// @brief Constructs, pushes, then returns a new TaskState.
|
||||
static inline std::shared_ptr<TaskState> create_and_push(sys::threadpool::JobFunction function,
|
||||
|
|
@ -38,13 +36,19 @@ class TaskState final : public BaseTask
|
|||
}
|
||||
|
||||
/// @brief Runs update routine. Waits for thread function to signal finish and deactivates.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Run render routine. Prints m_task's status string to screen, basically.
|
||||
/// @param
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
private:
|
||||
/// @brief Font used for rendering text.
|
||||
static inline sdl2::SharedFont sm_font{};
|
||||
|
||||
/// @brief Ensures static members are initialized.
|
||||
void initialize_static_members();
|
||||
|
||||
/// @brief Performs some operations and marks the state for deletion.
|
||||
void deactivate_state();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,9 +15,7 @@ class TextTitleSelectState final : public TitleSelectCommon
|
|||
|
||||
/// @brief Creates and returns a new TextTitleSelect. See constructor.
|
||||
static inline std::shared_ptr<TextTitleSelectState> create(data::User *user)
|
||||
{
|
||||
return std::make_shared<TextTitleSelectState>(user);
|
||||
}
|
||||
{ return std::make_shared<TextTitleSelectState>(user); }
|
||||
|
||||
/// @brief Creates, pushes, and returns a new TextTitleSelect.
|
||||
static std::shared_ptr<TextTitleSelectState> create_and_push(data::User *user)
|
||||
|
|
@ -28,10 +26,10 @@ class TextTitleSelectState final : public TitleSelectCommon
|
|||
}
|
||||
|
||||
/// @brief Runs update routine.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Runs render routine.
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
/// @brief Refreshes view for changes.
|
||||
void refresh() override;
|
||||
|
|
@ -44,7 +42,7 @@ class TextTitleSelectState final : public TitleSelectCommon
|
|||
std::shared_ptr<ui::Menu> m_titleSelectMenu{};
|
||||
|
||||
/// @brief Target to render to.
|
||||
sdl::SharedTexture m_renderTarget{};
|
||||
sdl2::SharedTexture m_renderTarget{};
|
||||
|
||||
/// @brief Creates a new backup menu instance.
|
||||
void create_backup_menu();
|
||||
|
|
|
|||
|
|
@ -21,9 +21,7 @@ class TitleInfoState final : public BaseState
|
|||
static inline std::shared_ptr<TitleInfoState> create(data::User *user,
|
||||
data::TitleInfo *titleInfo,
|
||||
const FsSaveDataInfo *saveInfo)
|
||||
{
|
||||
return std::make_shared<TitleInfoState>(user, titleInfo, saveInfo);
|
||||
}
|
||||
{ return std::make_shared<TitleInfoState>(user, titleInfo, saveInfo); }
|
||||
|
||||
/// @brief Creates, pushes, and returns a new TitleInfoState.
|
||||
static inline std::shared_ptr<TitleInfoState> create_and_push(data::User *user,
|
||||
|
|
@ -36,10 +34,10 @@ class TitleInfoState final : public BaseState
|
|||
}
|
||||
|
||||
/// @brief Runs update routine.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Runs render routine.
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
private:
|
||||
/// @brief States this state can be in.
|
||||
|
|
@ -60,7 +58,7 @@ class TitleInfoState final : public BaseState
|
|||
const FsSaveDataInfo *m_saveInfo{};
|
||||
|
||||
/// @brief This is a pointer to the title's icon.
|
||||
sdl::SharedTexture m_icon{};
|
||||
sdl2::SharedTexture m_icon{};
|
||||
|
||||
/// @brief Transition for the open/close effect.
|
||||
ui::Transition m_transition{};
|
||||
|
|
@ -84,7 +82,7 @@ class TitleInfoState final : public BaseState
|
|||
static inline std::shared_ptr<ui::Frame> sm_frame{};
|
||||
|
||||
/// @brief This is the little chime that plays when this is opened.
|
||||
static inline sdl::SharedSound sm_openChime{};
|
||||
static inline sdl2::SharedSound sm_openChime{};
|
||||
|
||||
/// @brief Initializes the static members if they haven't been already.
|
||||
void initialize_static_members();
|
||||
|
|
@ -126,10 +124,10 @@ class TitleInfoState final : public BaseState
|
|||
void update_dimensions() noexcept;
|
||||
|
||||
/// @brief Handles input and updating.
|
||||
void update_handle_input() noexcept;
|
||||
void update_handle_input(const sdl2::Input &input) noexcept;
|
||||
|
||||
/// @brief Returns the color to clear the field with.
|
||||
inline sdl::Color get_field_color() noexcept;
|
||||
inline SDL_Color get_field_color() noexcept;
|
||||
|
||||
/// @brief Signals to close the state.
|
||||
void close() noexcept;
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ class TitleOptionState final : public BaseState
|
|||
data::TitleInfo *titleInfo,
|
||||
const FsSaveDataInfo *saveInfo,
|
||||
TitleSelectCommon *titleSelect)
|
||||
{
|
||||
return std::make_shared<TitleOptionState>(user, titleInfo, saveInfo, titleSelect);
|
||||
}
|
||||
{ return std::make_shared<TitleOptionState>(user, titleInfo, saveInfo, titleSelect); }
|
||||
|
||||
/// @brief Creates, pushes, and returns a new TitleOptionState
|
||||
static std::shared_ptr<TitleOptionState> create_and_push(data::User *user,
|
||||
|
|
@ -39,13 +37,13 @@ class TitleOptionState final : public BaseState
|
|||
}
|
||||
|
||||
/// @brief Runs update routine.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Handles hiding the panel.
|
||||
void sub_update() override;
|
||||
|
||||
/// @brief Runs the render routine.
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
/// @brief This function allows tasks to signal to the spawning state to close itself on the next update() call.
|
||||
void close_on_update();
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ class TitleSelectCommon : public BaseState
|
|||
virtual ~TitleSelectCommon() {};
|
||||
|
||||
/// @brief Required, inherited.
|
||||
virtual void update() = 0;
|
||||
virtual void update(const sdl2::Input &input) = 0;
|
||||
|
||||
/// @brief Sub-update routine. Normally in a file, but I didn't feel like it really needed one.
|
||||
void sub_update() override;
|
||||
|
||||
/// @brief Required, inherited.
|
||||
virtual void render() = 0;
|
||||
virtual void render(sdl2::Renderer &renderer) = 0;
|
||||
|
||||
/// @brief Both derived classes need this function.
|
||||
virtual void refresh() = 0;
|
||||
|
|
|
|||
|
|
@ -15,9 +15,7 @@ class TitleSelectState final : public TitleSelectCommon
|
|||
|
||||
/// @brief Returns a new TitleSelect state.
|
||||
static inline std::shared_ptr<TitleSelectState> create(data::User *user)
|
||||
{
|
||||
return std::make_shared<TitleSelectState>(user);
|
||||
}
|
||||
{ return std::make_shared<TitleSelectState>(user); }
|
||||
|
||||
/// @brief Creates, pushes, and returns a new TitleSelectState.
|
||||
static inline std::shared_ptr<TitleSelectState> create_and_push(data::User *user)
|
||||
|
|
@ -28,10 +26,10 @@ class TitleSelectState final : public TitleSelectCommon
|
|||
}
|
||||
|
||||
/// @brief Runs the update routine.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Runs the render routine.
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
/// @brief Refreshes the view.
|
||||
void refresh() override;
|
||||
|
|
@ -41,7 +39,7 @@ class TitleSelectState final : public TitleSelectCommon
|
|||
data::User *m_user{};
|
||||
|
||||
/// @brief Target to render to.
|
||||
sdl::SharedTexture m_renderTarget{};
|
||||
sdl2::SharedTexture m_renderTarget{};
|
||||
|
||||
/// @brief Tiled title selection view.
|
||||
std::shared_ptr<ui::TitleView> m_titleView{};
|
||||
|
|
|
|||
|
|
@ -18,9 +18,7 @@ class UserOptionState final : public BaseState
|
|||
|
||||
/// @brief Returns a new UserOptionState. See constructor.
|
||||
static inline std::shared_ptr<UserOptionState> create(data::User *user, TitleSelectCommon *titleSelect)
|
||||
{
|
||||
return std::make_shared<UserOptionState>(user, titleSelect);
|
||||
}
|
||||
{ return std::make_shared<UserOptionState>(user, titleSelect); }
|
||||
|
||||
/// @brief Creates, pushes, and returns a new UserOptionState.
|
||||
static inline std::shared_ptr<UserOptionState> create_and_push(data::User *user, TitleSelectCommon *titleSelect)
|
||||
|
|
@ -31,13 +29,13 @@ class UserOptionState final : public BaseState
|
|||
}
|
||||
|
||||
/// @brief Runs the render routine.
|
||||
void update() override;
|
||||
void update(const sdl2::Input &input) override;
|
||||
|
||||
/// @brief Handles hiding the panel.
|
||||
void sub_update() override;
|
||||
|
||||
/// @brief Runs the render routine.
|
||||
void render() override;
|
||||
void render(sdl2::Renderer &renderer) override;
|
||||
|
||||
/// @brief Signals to the main update() function that a refresh is needed.
|
||||
/// @note Like this to prevent threading headaches.
|
||||
|
|
|
|||
|
|
@ -10,16 +10,16 @@ namespace data
|
|||
DataCommon() = default;
|
||||
|
||||
/// @brief Function to load the icon to a texture.
|
||||
virtual void load_icon() = 0;
|
||||
virtual void load_icon(sdl2::Renderer &renderer) = 0;
|
||||
|
||||
/// @brief Returns the icon.
|
||||
sdl::SharedTexture get_icon() { return m_icon; };
|
||||
sdl2::SharedTexture &get_icon() { return m_icon; };
|
||||
|
||||
/// @brief Sets the icon.
|
||||
void set_icon(sdl::SharedTexture &icon) { m_icon = icon; };
|
||||
void set_icon(sdl2::SharedTexture &icon) { m_icon = icon; };
|
||||
|
||||
protected:
|
||||
/// @brief Shared texture of the icon.
|
||||
sdl::SharedTexture m_icon{};
|
||||
sdl2::SharedTexture m_icon{};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "data/DataCommon.hpp"
|
||||
#include "data/TitleInfo.hpp"
|
||||
#include "data/User.hpp"
|
||||
#include "sdl.hpp"
|
||||
#include "sys/Task.hpp"
|
||||
|
||||
#include <mutex>
|
||||
|
|
@ -56,7 +57,7 @@ namespace data
|
|||
bool write_cache(sys::Task *task);
|
||||
|
||||
/// @brief Processes the icon queue.
|
||||
void process_icon_queue();
|
||||
void process_icon_queue(sdl2::Renderer &renderer);
|
||||
|
||||
private:
|
||||
/// @brief User vector.
|
||||
|
|
|
|||
|
|
@ -83,16 +83,12 @@ namespace data
|
|||
/// @return True on success. False on failure.
|
||||
bool has_save_data_type(uint8_t saveType) const noexcept;
|
||||
|
||||
/// @brief Returns a pointer to the icon texture.
|
||||
/// @return Icon
|
||||
sdl::SharedTexture get_icon() const noexcept;
|
||||
|
||||
/// @brief Allows the path safe title to be set to a new path.
|
||||
/// @param newPathSafe Buffer containing the new safe path to use.
|
||||
void set_path_safe_title(const char *newPathSafe) noexcept;
|
||||
|
||||
/// @brief Loads the icon from the nacp.
|
||||
void load_icon() override;
|
||||
void load_icon(sdl2::Renderer &renderer) override;
|
||||
|
||||
private:
|
||||
/// @brief This defines how long the buffer is for the path safe version of the title.
|
||||
|
|
@ -114,7 +110,7 @@ namespace data
|
|||
char m_pathSafeTitle[TitleInfo::SIZE_PATH_SAFE]{};
|
||||
|
||||
/// @brief Shared icon texture.
|
||||
sdl::SharedTexture m_icon{};
|
||||
sdl2::SharedTexture m_icon{};
|
||||
|
||||
/// @brief Private function to get/create the path safe title.
|
||||
void get_create_path_safe_title() noexcept;
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ namespace data
|
|||
void load_user_data();
|
||||
|
||||
/// @brief Loads the icon from the system and converts it to a texture.
|
||||
void load_icon() override;
|
||||
void load_icon(sdl2::Renderer &renderer) override;
|
||||
|
||||
private:
|
||||
/// @brief Account's ID
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "data/TitleInfo.hpp"
|
||||
#include "data/User.hpp"
|
||||
#include "data/accountUID.hpp"
|
||||
#include "sdl.hpp"
|
||||
#include "sys/sys.hpp"
|
||||
|
||||
#include <unordered_map>
|
||||
|
|
@ -13,7 +14,7 @@ namespace data
|
|||
/// @brief Launches the data loading/initialization state.
|
||||
/// @param clear Whether or not the cache should be cleared.
|
||||
/// @param onDestruction Function that is executed upon destruction of the data loading screen.
|
||||
void launch_initialization(bool clear, std::function<void()> onDestruction);
|
||||
void launch_initialization(bool clear, sdl2::Renderer &renderer, std::function<void()> onDestruction);
|
||||
|
||||
/// @brief Writes pointers to users to vectorOut
|
||||
/// @param userList List to push the pointers to.
|
||||
|
|
|
|||
43
include/graphics/ScopedRender.hpp
Normal file
43
include/graphics/ScopedRender.hpp
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#pragma once
|
||||
#include "sdl.hpp"
|
||||
|
||||
#include <stack>
|
||||
|
||||
namespace graphics
|
||||
{
|
||||
/// @brief This is a workaround class because of SDLLib changes and I'm not willing to sink a ton of time into JKSV anymore.
|
||||
class ScopedRender final
|
||||
{
|
||||
public:
|
||||
/// @brief Constructs a new scoped rendering sequence.
|
||||
/// @param renderer Reference to the renderer.
|
||||
/// @param target Render target.
|
||||
ScopedRender(sdl2::Renderer &renderer, sdl2::SharedTexture target)
|
||||
: m_renderer{renderer}
|
||||
{
|
||||
// Push the target.
|
||||
sm_renderTargets.push(target);
|
||||
|
||||
// Set the target.
|
||||
renderer.set_render_target(sm_renderTargets.top());
|
||||
}
|
||||
|
||||
/// @brief Ends the ScopedRender'ing.
|
||||
~ScopedRender()
|
||||
{
|
||||
// Pop.
|
||||
sm_renderTargets.pop();
|
||||
|
||||
// Set.
|
||||
m_renderer.set_render_target(sm_renderTargets.top());
|
||||
}
|
||||
|
||||
private:
|
||||
/// @brief Reference to the renderer.
|
||||
sdl2::Renderer &m_renderer;
|
||||
|
||||
/// @brief Stack of render targets. Init'd with null as the base.
|
||||
static inline std::stack<sdl2::SharedTexture> sm_renderTargets =
|
||||
std::stack<sdl2::SharedTexture>({sdl2::Texture::null});
|
||||
};
|
||||
}
|
||||
|
|
@ -3,26 +3,26 @@
|
|||
|
||||
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};
|
||||
inline constexpr sdl::Color PINK = {0xFF4444FF};
|
||||
inline constexpr sdl::Color BLUE_GREEN = {0x00FFC5FF};
|
||||
inline constexpr sdl::Color CLEAR_COLOR = {0x2D2D2DFF};
|
||||
inline constexpr sdl::Color CLEAR_PANEL = {0x0D0D0DFF};
|
||||
inline constexpr sdl::Color DIALOG_DARK = {0x505050FF};
|
||||
inline constexpr sdl::Color DIALOG_LIGHT = {0xDCDCDCFF};
|
||||
inline constexpr sdl::Color DIM_BACKGROUND = {0x00061180};
|
||||
inline constexpr sdl::Color TRANSPARENT = {0x00000000};
|
||||
inline constexpr sdl::Color SLIDE_PANEL_CLEAR = {0x000000CC};
|
||||
inline constexpr sdl::Color DIV_COLOR = {0x707070FF};
|
||||
inline constexpr sdl::Color GUIDE_COLOR = {0x0000007F};
|
||||
inline constexpr sdl::Color BAR_GREEN = {0x11CC33FF};
|
||||
inline constexpr sdl::Color GOLD = {0xFFD700FF};
|
||||
inline constexpr SDL_Color WHITE = {0xFF, 0xFF, 0xFF, 0xFF};
|
||||
inline constexpr SDL_Color BLACK = {0x00, 0x00, 0x00, 0xFF};
|
||||
inline constexpr SDL_Color RED = {0xFF, 0x00, 0x00, 0xFF};
|
||||
inline constexpr SDL_Color DARK_RED = {0xDD, 0x00, 0x00, 0xFF};
|
||||
inline constexpr SDL_Color GREEN = {0x00, 0xFF, 0x00, 0xFF};
|
||||
inline constexpr SDL_Color BLUE = {0x00, 0x99, 0xEE, 0xFF};
|
||||
inline constexpr SDL_Color YELLOW = {0xF8, 0xFC, 0x00, 0xFF};
|
||||
inline constexpr SDL_Color PINK = {0xFF, 0x44, 0x44, 0xFF};
|
||||
inline constexpr SDL_Color BLUE_GREEN = {0x00, 0xFF, 0xC5, 0xFF};
|
||||
inline constexpr SDL_Color CLEAR_COLOR = {0x2D, 0x2D, 0x2D, 0xFF};
|
||||
inline constexpr SDL_Color CLEAR_PANEL = {0x0D, 0x0D, 0x0D, 0xFF};
|
||||
inline constexpr SDL_Color DIALOG_DARK = {0x50, 0x50, 0x50, 0xFF};
|
||||
inline constexpr SDL_Color DIALOG_LIGHT = {0xDC, 0xDC, 0xDC, 0xFF};
|
||||
inline constexpr SDL_Color DIM_BACKGROUND = {0x00, 0x06, 0x11, 0x80};
|
||||
inline constexpr SDL_Color TRANSPARENT = {0x00, 0x00, 0x00, 0x00};
|
||||
inline constexpr SDL_Color SLIDE_PANEL_CLEAR = {0x00, 0x00, 0x00, 0xCC};
|
||||
inline constexpr SDL_Color DIV_COLOR = {0x70, 0x70, 0x70, 0xFF};
|
||||
inline constexpr SDL_Color GUIDE_COLOR = {0x00, 0x00, 0x00, 0x7F};
|
||||
inline constexpr SDL_Color BAR_GREEN = {0x11, 0xCC, 0x33, 0xFF};
|
||||
inline constexpr SDL_Color GOLD = {0xFF, 0xD7, 0x00, 0xFF};
|
||||
|
||||
inline constexpr uint8_t ALPHA_FADE_BEGIN = 0x00;
|
||||
inline constexpr uint8_t ALPHA_FADE_END = 0x80;
|
||||
|
|
|
|||
28
include/graphics/fonts.hpp
Normal file
28
include/graphics/fonts.hpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#pragma once
|
||||
#include <string_view>
|
||||
|
||||
namespace graphics::fonts
|
||||
{
|
||||
namespace names
|
||||
{
|
||||
// These are all the internal names of the fonts so the mananger pulls and reuses them.
|
||||
inline constexpr std::string_view FOURTEEN_PIXEL = "FourteenPixel";
|
||||
inline constexpr std::string_view TWENTY_PIXEL = "TwentyPixel";
|
||||
inline constexpr std::string_view TWENTY_TWO_PIXEL = "TwentyTwoPixel";
|
||||
inline constexpr std::string_view TWENTY_FOUR_PIXEL = "TwentyFourPixel";
|
||||
inline constexpr std::string_view THIRTY_TWO_PIXEL = "ThirtyTwoPixel";
|
||||
inline constexpr std::string_view THIRTY_FOUR_PIXEL = "ThirtyFourPixel";
|
||||
}
|
||||
|
||||
namespace sizes
|
||||
{
|
||||
// These are the pixel sizes.
|
||||
inline constexpr int FOURTEEN_PIXEL = 14;
|
||||
inline constexpr int TWENTY_PIXEL = 20;
|
||||
inline constexpr int TWENTY_TWO_PIXEL = 22;
|
||||
inline constexpr int TWENTY_FOUR_PIXEL = 24;
|
||||
inline constexpr int THIRTY_TWO_PIXEL = 32;
|
||||
inline constexpr int THIRTY_FOUR_PIXEL = 34;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -12,5 +12,9 @@ namespace gfxutil
|
|||
/// @param background Background color to use.
|
||||
/// @param foreground Color to use to render the text.
|
||||
/// @return sdl::SharedTexture of the icon.
|
||||
sdl::SharedTexture create_generic_icon(std::string_view text, int fontSize, sdl::Color background, sdl::Color foreground);
|
||||
sdl2::SharedTexture create_generic_icon(sdl2::Renderer &renderer,
|
||||
std::string_view text,
|
||||
int fontSize,
|
||||
SDL_Color background,
|
||||
SDL_Color textColor);
|
||||
} // namespace gfxutil
|
||||
|
|
|
|||
17
include/graphics/targets.hpp
Normal file
17
include/graphics/targets.hpp
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
#include <string_view>
|
||||
|
||||
namespace graphics::targets
|
||||
{
|
||||
namespace names
|
||||
{
|
||||
inline constexpr std::string_view SECONDARY = "SecondaryTarget";
|
||||
}
|
||||
|
||||
namespace dims
|
||||
{
|
||||
// Dimensions of the secondary render target.
|
||||
inline constexpr int SECONDARY_WIDTH = 1080;
|
||||
inline constexpr int SECONDARY_HEIGHT = 555;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#pragma once
|
||||
#include <switch.h>
|
||||
|
||||
namespace input
|
||||
{
|
||||
/// @brief Initializes PadState and input.
|
||||
void initialize();
|
||||
|
||||
/// @brief Updates the PadState.
|
||||
void update() noexcept;
|
||||
|
||||
/// @brief Returns if a button was pressed the current frame, but not the previous.
|
||||
/// @param button Button to check.
|
||||
bool button_pressed(HidNpadButton button) noexcept;
|
||||
|
||||
/// @brief Returns if the button was pressed or held the previous and current frame.
|
||||
/// @param button Button to check.
|
||||
bool button_held(HidNpadButton button) noexcept;
|
||||
|
||||
/// @brief Returns if the button was pressed or held the previous frame, but not the current.
|
||||
/// @param button Button to check.
|
||||
bool button_released(HidNpadButton button) noexcept;
|
||||
} // namespace input
|
||||
|
|
@ -7,7 +7,11 @@ namespace math
|
|||
class Util
|
||||
{
|
||||
public:
|
||||
static inline Type absolute_distance(Type a, Type b) noexcept { return a > b ? a - b : b - a; }
|
||||
/// @brief Calculates the distance between two Types and returns the result as a positive Type.
|
||||
static inline constexpr Type absolute_distance(Type a, Type b) noexcept { return a > b ? a - b : b - a; }
|
||||
|
||||
/// @brief Returns size centered within area.
|
||||
static inline constexpr Type center_within(Type area, Type size) noexcept { return (area / 2) - (size / 2); }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,15 +19,13 @@ namespace ui
|
|||
|
||||
/// @brief Creates a returns a new BoundingBox. See constructor.
|
||||
static inline std::shared_ptr<ui::BoundingBox> create(int x, int y, int width, int height)
|
||||
{
|
||||
return std::make_shared<ui::BoundingBox>(x, y, width, height);
|
||||
}
|
||||
{ return std::make_shared<ui::BoundingBox>(x, y, width, height); }
|
||||
|
||||
/// @brief Update override.
|
||||
void update(bool hasFocus) override;
|
||||
void update(const sdl2::Input &input, bool hasFocus) override;
|
||||
|
||||
/// @brief Render override.
|
||||
void render(sdl::SharedTexture &target, bool hasFocus) override;
|
||||
void render(sdl2::Renderer &renderer, bool hasFocus) override;
|
||||
|
||||
/// @brief Sets the X coord.
|
||||
void set_x(int x) noexcept;
|
||||
|
|
@ -58,7 +56,7 @@ namespace ui
|
|||
ui::ColorMod m_colorMod{};
|
||||
|
||||
/// @brief This is shared by all instances.
|
||||
static inline sdl::SharedTexture sm_corners{};
|
||||
static inline sdl2::SharedTexture sm_corners{};
|
||||
|
||||
/// @brief Loads ^
|
||||
void initialize_static_members();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace ui
|
|||
|
||||
/// @brief Operator that allows using this as an sdl::Color directly.
|
||||
/// @note Since all of these pulse the same color, no sense in not doing this.
|
||||
operator sdl::Color() const noexcept;
|
||||
operator SDL_Color() const noexcept;
|
||||
|
||||
private:
|
||||
/// @brief Whether we're adding or subtracting from the color value.
|
||||
|
|
|
|||
|
|
@ -14,18 +14,16 @@ namespace ui
|
|||
|
||||
/// @brief Factory function to return a control guide.
|
||||
static inline std::shared_ptr<ControlGuide> create(const char *guide)
|
||||
{
|
||||
return std::make_shared<ControlGuide>(guide);
|
||||
}
|
||||
{ return std::make_shared<ControlGuide>(guide); }
|
||||
|
||||
/// @brief Update routine. Opens the guide.
|
||||
void update(bool hasFocus) override;
|
||||
void update(const sdl2::Input &input, bool hasFocus) override;
|
||||
|
||||
/// @brief Sub update routine. Handles hiding the control guide.
|
||||
void sub_update();
|
||||
|
||||
/// @brief Renders the control guide. Both arguments are ignored in this case.
|
||||
void render(sdl::SharedTexture &target, bool hasFocus) override;
|
||||
void render(sdl2::Renderer &renderer, bool hasFocus) override;
|
||||
|
||||
/// @brief This is a workaround for states where the guide can't really be hidden correctly. Ex: FileMode.
|
||||
void reset() noexcept;
|
||||
|
|
@ -59,7 +57,10 @@ namespace ui
|
|||
ControlGuide::State m_state{};
|
||||
|
||||
/// @brief This is shared by all instances.
|
||||
static inline sdl::SharedTexture sm_controlCap{};
|
||||
static inline sdl2::SharedTexture sm_controlCap{};
|
||||
|
||||
/// @brief Font used to render text.
|
||||
static inline sdl2::SharedFont sm_font{};
|
||||
|
||||
/// @brief Ensures the control guide cap is loaded for all instances.
|
||||
void initialize_static_members();
|
||||
|
|
|
|||
|
|
@ -29,17 +29,15 @@ namespace ui
|
|||
int width,
|
||||
int height,
|
||||
DialogBox::Type type = DialogBox::Type::Dark)
|
||||
{
|
||||
return std::make_shared<ui::DialogBox>(x, y, width, height, type);
|
||||
}
|
||||
{ return std::make_shared<ui::DialogBox>(x, y, width, height, type); }
|
||||
|
||||
/// @brief Update override. This does NOTHING!
|
||||
void update(bool hasFocus) override {};
|
||||
void update(const sdl2::Input &input, bool hasFocus) override {};
|
||||
|
||||
/// @brief Renders the dialog box to screen.
|
||||
/// @param target Render target to render to.
|
||||
/// @param hasFocus This is ignored.
|
||||
void render(sdl::SharedTexture &target, bool hasFocus) override;
|
||||
void render(sdl2::Renderer &renderer, bool hasFocus) override;
|
||||
|
||||
/// @brief Sets the X render coord.
|
||||
void set_x(int x) noexcept;
|
||||
|
|
@ -75,10 +73,10 @@ namespace ui
|
|||
DialogBox::Type m_type{};
|
||||
|
||||
/// @brief All instances shared this and the other.
|
||||
static inline sdl::SharedTexture sm_darkCorners{};
|
||||
static inline sdl2::SharedTexture sm_darkCorners{};
|
||||
|
||||
/// @brief This is the light cer
|
||||
static inline sdl::SharedTexture sm_lightCorners{};
|
||||
static inline sdl2::SharedTexture sm_lightCorners{};
|
||||
|
||||
/// @brief Initializes and loads the corners texture.
|
||||
void initialize_static_members();
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ namespace ui
|
|||
|
||||
/// @brief Virtual update method. All derived classes must have this.
|
||||
/// @param HasFocus Whether or not the state containing the element currently has focus.
|
||||
virtual void update(bool HasFocus) = 0;
|
||||
virtual void update(const sdl2::Input &input, bool HasFocus) = 0;
|
||||
|
||||
/// @brief Virtual render method. All derived classes must have this.
|
||||
/// @param target Target to render to.
|
||||
/// @param hasFocus Whether or not the containing state has focus.
|
||||
virtual void render(sdl::SharedTexture &target, bool hasFocus) = 0;
|
||||
virtual void render(sdl2::Renderer &renderer, bool hasFocus) = 0;
|
||||
};
|
||||
} // namespace ui
|
||||
|
|
|
|||
|
|
@ -15,15 +15,13 @@ namespace ui
|
|||
|
||||
/// @brief Inline function to make constructing nicer.
|
||||
static inline std::shared_ptr<ui::Frame> create(int x, int y, int width, int height)
|
||||
{
|
||||
return std::make_shared<ui::Frame>(x, y, width, height);
|
||||
}
|
||||
{ return std::make_shared<ui::Frame>(x, y, width, height); }
|
||||
|
||||
/// @brief Doesn't need to do anything for this.
|
||||
void update(bool hasFocus) override {};
|
||||
void update(const sdl2::Input &input, bool hasFocus) override {};
|
||||
|
||||
/// @brief Renders the frame to the target passed.
|
||||
void render(sdl::SharedTexture &target, bool hasFocus) override;
|
||||
void render(sdl2::Renderer &renderer, bool hasFocus) override;
|
||||
|
||||
/// @brief Sets the X coord.
|
||||
void set_x(int x) noexcept;
|
||||
|
|
@ -54,7 +52,7 @@ namespace ui
|
|||
int m_height{};
|
||||
|
||||
/// @brief This texture is shared by all instances.
|
||||
static inline sdl::SharedTexture sm_frameCorners{};
|
||||
static inline sdl2::SharedTexture sm_frameCorners{};
|
||||
|
||||
/// @brief Ensures the texture is loading if it hasn't been.
|
||||
void initialize_static_members();
|
||||
|
|
|
|||
|
|
@ -20,9 +20,7 @@ namespace ui
|
|||
|
||||
/// @brief Creates and returns a new IconMenu instance.
|
||||
static inline std::shared_ptr<ui::IconMenu> create(int x, int y, int renderTargetHeight)
|
||||
{
|
||||
return std::make_shared<ui::IconMenu>(x, y, renderTargetHeight);
|
||||
}
|
||||
{ return std::make_shared<ui::IconMenu>(x, y, renderTargetHeight); }
|
||||
|
||||
/// @brief Initializes the menu.
|
||||
/// @param x X coordinate to render the menu to.
|
||||
|
|
@ -33,19 +31,19 @@ namespace ui
|
|||
|
||||
/// @brief Runs the update routine.
|
||||
/// @param hasFocus Whether or not the containing state has focus.
|
||||
void update(bool hasFocus) override;
|
||||
void update(const sdl2::Input &input, bool hasFocus) override;
|
||||
|
||||
/// @brief Runs the render routine.
|
||||
/// @param target Target to render to.
|
||||
/// @param hasFocus Whether or not the containing state has focus.
|
||||
void render(sdl::SharedTexture &target, bool hasFocus) override;
|
||||
void render(sdl2::Renderer &renderer, bool hasFocus) override;
|
||||
|
||||
/// @brief Adds a new icon to the menu.
|
||||
/// @param newOption Icon to add.
|
||||
void add_option(sdl::SharedTexture newOption);
|
||||
void add_option(sdl2::SharedTexture newOption);
|
||||
|
||||
private:
|
||||
/// @brief Vector of shared texture pointers to textures used.
|
||||
std::vector<sdl::SharedTexture> m_options;
|
||||
std::vector<sdl2::SharedTexture> m_options;
|
||||
};
|
||||
} // namespace ui
|
||||
|
|
|
|||
|
|
@ -26,18 +26,16 @@ namespace ui
|
|||
|
||||
/// @brief Creates and returns a new ui::Menu instance.
|
||||
static inline std::shared_ptr<ui::Menu> create(int x, int y, int width, int fontSize, int renderTargetHeight)
|
||||
{
|
||||
return std::make_shared<ui::Menu>(x, y, width, fontSize, renderTargetHeight);
|
||||
}
|
||||
{ return std::make_shared<ui::Menu>(x, y, width, fontSize, renderTargetHeight); }
|
||||
|
||||
/// @brief Runs the update routine.
|
||||
/// @param hasFocus Whether or not the calling state has focus.
|
||||
void update(bool HasFocus) override;
|
||||
void update(const sdl2::Input &input, bool HasFocus) override;
|
||||
|
||||
/// @brief Renders the menu.
|
||||
/// @param target Target to render to.
|
||||
/// @param hasFocus Whether or not the calling state has focus.
|
||||
void render(sdl::SharedTexture &target, bool hasFocus) override;
|
||||
void render(sdl2::Renderer &renderer, bool hasFocus) override;
|
||||
|
||||
/// @brief Adds an option to the menu.
|
||||
/// @param newOption Option to add to menu.
|
||||
|
|
@ -94,7 +92,7 @@ namespace ui
|
|||
int m_optionHeight{};
|
||||
|
||||
/// @brief Target options are rendered to.
|
||||
sdl::SharedTexture m_optionTarget{};
|
||||
sdl2::SharedTexture m_optionTarget{};
|
||||
|
||||
/// @brief Bounding box for the selected option.
|
||||
std::shared_ptr<ui::BoundingBox> m_boundingBox{};
|
||||
|
|
@ -127,8 +125,11 @@ namespace ui
|
|||
/// @brief Text scroll for when the current option is too long to on screen.
|
||||
std::shared_ptr<ui::TextScroll> m_optionScroll{};
|
||||
|
||||
/// @brief Font used to render the text.
|
||||
sdl2::SharedFont m_font{};
|
||||
|
||||
/// @brief The sound played when the selected/cursor moves.
|
||||
static inline sdl::SharedSound sm_cursor{};
|
||||
static inline sdl2::SharedSound sm_cursor{};
|
||||
|
||||
/// @brief Calculates the alignment variables.
|
||||
void calculate_alignments() noexcept;
|
||||
|
|
@ -152,6 +153,6 @@ namespace ui
|
|||
void update_scrolling();
|
||||
|
||||
/// @brief Handles the menu's input routine.
|
||||
void handle_input();
|
||||
void handle_input(const sdl2::Input &input);
|
||||
};
|
||||
} // namespace ui
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace ui
|
||||
{
|
||||
class PopMessage
|
||||
class PopMessage final
|
||||
{
|
||||
public:
|
||||
/// @brief PopMessage constructor.
|
||||
|
|
@ -20,7 +20,7 @@ namespace ui
|
|||
void update(double targetY);
|
||||
|
||||
/// @brief Renders the dialog and text.
|
||||
void render();
|
||||
void render(sdl2::Renderer &renderer);
|
||||
|
||||
/// @brief Returns whether or not the message can be purged.
|
||||
bool finished() const noexcept;
|
||||
|
|
@ -65,7 +65,10 @@ namespace ui
|
|||
sys::Timer m_typeTimer{};
|
||||
|
||||
/// @brief This is the texture used for the ends of the messages.
|
||||
static inline sdl::SharedTexture sm_endCaps{};
|
||||
static inline sdl2::SharedTexture sm_endCaps{};
|
||||
|
||||
/// @brief Font used to render text.
|
||||
static inline sdl2::SharedFont sm_font{};
|
||||
|
||||
/// @brief Ensures ^ is loaded and ready to go.
|
||||
void initialize_static_members();
|
||||
|
|
@ -83,6 +86,6 @@ namespace ui
|
|||
void update_display_timer() noexcept;
|
||||
|
||||
/// @brief Renders the container around the message.
|
||||
void render_container() noexcept;
|
||||
void render_container(sdl2::Renderer &renderer) noexcept;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace ui
|
|||
static void update();
|
||||
|
||||
/// @brief Renders messages to screen.
|
||||
static void render();
|
||||
static void render(sdl2::Renderer &renderer);
|
||||
|
||||
/// @brief Pushes a new message to the queue for processing.
|
||||
static void push_message(int displayTicks, std::string_view message);
|
||||
|
|
@ -57,7 +57,7 @@ namespace ui
|
|||
std::mutex m_queueMutex{};
|
||||
|
||||
/// @brief The little chirp that's played when messages pop.
|
||||
sdl::SharedSound m_popSound{};
|
||||
sdl2::SharedSound m_popSound{};
|
||||
|
||||
/// @brief Loads the pop message sound into memory.
|
||||
void initialize_pop_sound();
|
||||
|
|
|
|||
|
|
@ -29,13 +29,11 @@ namespace ui
|
|||
|
||||
/// @brief Creates and returns and new ui::SlideOutPanel instance.
|
||||
static inline std::shared_ptr<ui::SlideOutPanel> create(int width, SlideOutPanel::Side side)
|
||||
{
|
||||
return std::make_shared<ui::SlideOutPanel>(width, side);
|
||||
}
|
||||
{ return std::make_shared<ui::SlideOutPanel>(width, side); }
|
||||
|
||||
/// @brief Runs the update routine.
|
||||
/// @param hasFocus Whether or not the calling state has focus.
|
||||
void update(bool hasFocus) override;
|
||||
void update(const sdl2::Input &input, bool hasFocus) override;
|
||||
|
||||
/// @brief Sub update routine. Allows the panel to hide and unhide itself even when not in focus.
|
||||
void sub_update();
|
||||
|
|
@ -43,10 +41,10 @@ namespace ui
|
|||
/// @brief Runs the render routine.
|
||||
/// @param target Target to render to.
|
||||
/// @param hasFocus Whether or the the calling state has focus.
|
||||
void render(sdl::SharedTexture &target, bool hasFocus) override;
|
||||
void render(sdl2::Renderer &renderer, bool hasFocus) override;
|
||||
|
||||
/// @brief Clears the target to a semi-transparent black. To do: Maybe not hard coded color.
|
||||
void clear_target();
|
||||
void clear_target(sdl2::Renderer &renderer);
|
||||
|
||||
/// @brief Resets the panel back to its default state.
|
||||
void reset() noexcept;
|
||||
|
|
@ -83,7 +81,7 @@ namespace ui
|
|||
|
||||
/// @brief Returns a pointer to the render target of the panel.
|
||||
/// @return Raw SDL_Texture pointer to target.
|
||||
sdl::SharedTexture &get_target() noexcept;
|
||||
sdl2::SharedTexture &get_target() noexcept;
|
||||
|
||||
private:
|
||||
/// @brief States the panel can be in.
|
||||
|
|
@ -113,7 +111,7 @@ namespace ui
|
|||
SlideOutPanel::State m_state{};
|
||||
|
||||
/// @brief Render target if panel.
|
||||
sdl::SharedTexture m_renderTarget{};
|
||||
sdl2::SharedTexture m_renderTarget{};
|
||||
|
||||
/// @brief Vector of elements.
|
||||
std::vector<std::shared_ptr<ui::Element>> m_elements{};
|
||||
|
|
@ -131,6 +129,6 @@ namespace ui
|
|||
void update_position_state() noexcept;
|
||||
|
||||
/// @brief Updates sub-elements.
|
||||
void update_sub_elements(bool hasFocus) noexcept;
|
||||
void update_sub_elements(const sdl2::Input &input, bool hasFocus) noexcept;
|
||||
};
|
||||
} // namespace ui
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ namespace ui
|
|||
int width,
|
||||
int height,
|
||||
int fontSize,
|
||||
sdl::Color textColor,
|
||||
sdl::Color clearColor,
|
||||
SDL_Color textColor,
|
||||
SDL_Color clearColor,
|
||||
bool center = true);
|
||||
|
||||
TextScroll(std::string &text,
|
||||
|
|
@ -38,8 +38,8 @@ namespace ui
|
|||
int width,
|
||||
int height,
|
||||
int fontSize,
|
||||
sdl::Color textColor,
|
||||
sdl::Color clearColor,
|
||||
SDL_Color textColor,
|
||||
SDL_Color clearColor,
|
||||
bool center = true);
|
||||
|
||||
/// @brief Creates and returns a new TextScroll. See constructor.
|
||||
|
|
@ -49,12 +49,10 @@ namespace ui
|
|||
int width,
|
||||
int height,
|
||||
int fontSize,
|
||||
sdl::Color textColor,
|
||||
sdl::Color clearColor,
|
||||
SDL_Color textColor,
|
||||
SDL_Color clearColor,
|
||||
bool center = true)
|
||||
{
|
||||
return std::make_shared<ui::TextScroll>(text, x, y, width, height, fontSize, textColor, clearColor, center);
|
||||
}
|
||||
{ return std::make_shared<ui::TextScroll>(text, x, y, width, height, fontSize, textColor, clearColor, center); }
|
||||
|
||||
static inline std::shared_ptr<ui::TextScroll> create(std::string &text,
|
||||
int x,
|
||||
|
|
@ -62,12 +60,10 @@ namespace ui
|
|||
int width,
|
||||
int height,
|
||||
int fontSize,
|
||||
sdl::Color textColor,
|
||||
sdl::Color clearColor,
|
||||
SDL_Color textColor,
|
||||
SDL_Color clearColor,
|
||||
bool center = true)
|
||||
{
|
||||
return std::make_shared<ui::TextScroll>(text, x, y, width, height, fontSize, textColor, clearColor, center);
|
||||
}
|
||||
{ return std::make_shared<ui::TextScroll>(text, x, y, width, height, fontSize, textColor, clearColor, center); }
|
||||
|
||||
/// @brief Creates/sets the text and parameters for TextScroll.
|
||||
/// @param text Text to display/scroll.
|
||||
|
|
@ -82,8 +78,8 @@ namespace ui
|
|||
int width,
|
||||
int height,
|
||||
int fontSize,
|
||||
sdl::Color textColor,
|
||||
sdl::Color clearColor,
|
||||
SDL_Color textColor,
|
||||
SDL_Color clearColor,
|
||||
bool center = true);
|
||||
|
||||
void initialize(std::string &text,
|
||||
|
|
@ -92,18 +88,18 @@ namespace ui
|
|||
int width,
|
||||
int height,
|
||||
int fontSize,
|
||||
sdl::Color textColor,
|
||||
sdl::Color clearColor,
|
||||
SDL_Color textColor,
|
||||
SDL_Color clearColor,
|
||||
bool center = true);
|
||||
|
||||
/// @brief Runs the update routine.
|
||||
/// @param hasFocus Whether or not the calling state has focus.
|
||||
void update(bool hasFocus) override;
|
||||
void update(const sdl2::Input &input, bool hasFocus) override;
|
||||
|
||||
/// @brief Runs the render routine.
|
||||
/// @param target Target to render to.
|
||||
/// @param hasFocus Whether or not the calling state has focus.
|
||||
void render(sdl::SharedTexture &target, bool hasFocus) override;
|
||||
void render(sdl2::Renderer &renderer, bool hasFocus) override;
|
||||
|
||||
/// @brief Returns the current text being used for scrolling.
|
||||
std::string_view get_text() const noexcept;
|
||||
|
|
@ -133,11 +129,14 @@ namespace ui
|
|||
/// @brief Font size used to calculate and render text.
|
||||
int m_fontSize{};
|
||||
|
||||
/// @brief Font used to render text.
|
||||
sdl2::SharedFont m_font{};
|
||||
|
||||
/// @brief Color used to render the text.
|
||||
sdl::Color m_textColor{};
|
||||
SDL_Color m_textColor{};
|
||||
|
||||
/// @brief Color used to clear the render target.
|
||||
sdl::Color m_clearColor{};
|
||||
SDL_Color m_clearColor{};
|
||||
|
||||
/// @brief Width of text in pixels.
|
||||
int m_textWidth{};
|
||||
|
|
@ -155,9 +154,16 @@ namespace ui
|
|||
bool m_textScrollTriggered{};
|
||||
|
||||
/// @brief Render target for the text so it can't be rendered outside of it.
|
||||
sdl::SharedTexture m_renderTarget{};
|
||||
sdl2::SharedTexture m_renderTarget{};
|
||||
|
||||
/// @brief Timer for scrolling text.
|
||||
sys::Timer m_scrollTimer;
|
||||
|
||||
/// @brief Generates and returns the name of the render target for the text scroll.
|
||||
std::string generate_target_name();
|
||||
|
||||
/// @brief Generates a font name using the font size passed.
|
||||
/// @param fontSize Size of the font.
|
||||
std::string generate_font_name(int fontSize);
|
||||
};
|
||||
} // namespace ui
|
||||
} // namespace ui
|
||||
|
|
@ -11,17 +11,17 @@ namespace ui
|
|||
/// @brief Constructor.
|
||||
/// @param isFavorite Whether the title is a favorite and should have the little heart rendered.
|
||||
/// @param icon Shared texture pointer to the icon.
|
||||
TitleTile(bool isFavorite, int index, sdl::SharedTexture icon);
|
||||
TitleTile(bool isFavorite, int index, sdl2::SharedTexture &icon);
|
||||
|
||||
/// @brief Runs the update routine.
|
||||
/// @param isSelected Whether or not the tile is selected and needs to expand.
|
||||
void update(int selected);
|
||||
void update(bool isSelected);
|
||||
|
||||
/// @brief Runs the render routine.
|
||||
/// @param target Target to render to.
|
||||
/// @param x X coordinate to render to.
|
||||
/// @param y Y coordinate to render to.
|
||||
void render(sdl::SharedTexture &target, int x, int y);
|
||||
void render(int x, int y);
|
||||
|
||||
/// @brief Resets the width and height of the tile.
|
||||
void reset() noexcept;
|
||||
|
|
@ -41,10 +41,13 @@ namespace ui
|
|||
/// @brief Whether or not the title is a favorite.
|
||||
bool m_isFavorite{};
|
||||
|
||||
|
||||
int m_index{};
|
||||
|
||||
/// @brief Title's icon texture.
|
||||
sdl::SharedTexture m_icon{};
|
||||
sdl2::SharedTexture m_icon{};
|
||||
|
||||
/// @brief Font used for rendering the heart over the icon.
|
||||
static inline sdl2::SharedFont sm_heartFont{};
|
||||
|
||||
/// @brief Ensures the font is loaded.,
|
||||
void initialize_static_members();
|
||||
};
|
||||
} // namespace ui
|
||||
|
|
|
|||
|
|
@ -20,18 +20,16 @@ namespace ui
|
|||
TitleView(data::User *user);
|
||||
|
||||
static inline std::shared_ptr<ui::TitleView> create(data::User *user)
|
||||
{
|
||||
return std::make_shared<ui::TitleView>(user);
|
||||
}
|
||||
{ return std::make_shared<ui::TitleView>(user); }
|
||||
|
||||
/// @brief Runs the update routine.
|
||||
/// @param hasFocus Whether the calling state has focus.
|
||||
void update(bool hasFocus) override;
|
||||
void update(const sdl2::Input &input, bool hasFocus) override;
|
||||
|
||||
/// @brief Runs the render routine.
|
||||
/// @param target Target to render to.
|
||||
/// @param hasFocus Whether or not the calling state has focus.
|
||||
void render(sdl::SharedTexture &target, bool hasFocus) override;
|
||||
void render(sdl2::Renderer &renderer, bool hasFocus) override;
|
||||
|
||||
/// @brief Returns index of the currently selected tile.
|
||||
/// @return Index of currently selected tile.
|
||||
|
|
@ -75,13 +73,13 @@ namespace ui
|
|||
std::shared_ptr<ui::BoundingBox> m_bounding{};
|
||||
|
||||
/// @brief Sound that is played when the selected title changes. This is shared with the menu code.
|
||||
static inline sdl::SharedSound sm_cursor{};
|
||||
static inline sdl2::SharedSound sm_cursor{};
|
||||
|
||||
/// @brief Ensures static members are initialized properly.
|
||||
void initialize_static_members();
|
||||
|
||||
/// @brief Performs the input routine.
|
||||
void handle_input();
|
||||
void handle_input(const sdl2::Input &input);
|
||||
|
||||
/// @brief Performs the "scrolling" routine.
|
||||
void handle_scrolling();
|
||||
|
|
|
|||
BIN
romfs/Text/DE.json.z
Normal file
BIN
romfs/Text/DE.json.z
Normal file
Binary file not shown.
BIN
romfs/Text/ENGB.json.z
Normal file
BIN
romfs/Text/ENGB.json.z
Normal file
Binary file not shown.
BIN
romfs/Text/ENUS.json.z
Normal file
BIN
romfs/Text/ENUS.json.z
Normal file
Binary file not shown.
BIN
romfs/Text/ES.json.z
Normal file
BIN
romfs/Text/ES.json.z
Normal file
Binary file not shown.
BIN
romfs/Text/ES419.json.z
Normal file
BIN
romfs/Text/ES419.json.z
Normal file
Binary file not shown.
BIN
romfs/Text/FR.json.z
Normal file
BIN
romfs/Text/FR.json.z
Normal file
Binary file not shown.
BIN
romfs/Text/FRCA.json.z
Normal file
BIN
romfs/Text/FRCA.json.z
Normal file
Binary file not shown.
BIN
romfs/Text/IT.json.z
Normal file
BIN
romfs/Text/IT.json.z
Normal file
Binary file not shown.
BIN
romfs/Text/JA.json.z
Normal file
BIN
romfs/Text/JA.json.z
Normal file
Binary file not shown.
BIN
romfs/Text/KO.json.z
Normal file
BIN
romfs/Text/KO.json.z
Normal file
Binary file not shown.
BIN
romfs/Text/NL.json.z
Normal file
BIN
romfs/Text/NL.json.z
Normal file
Binary file not shown.
BIN
romfs/Text/PT.json.z
Normal file
BIN
romfs/Text/PT.json.z
Normal file
Binary file not shown.
BIN
romfs/Text/PTBR.json.z
Normal file
BIN
romfs/Text/PTBR.json.z
Normal file
Binary file not shown.
BIN
romfs/Text/RU.json.z
Normal file
BIN
romfs/Text/RU.json.z
Normal file
Binary file not shown.
BIN
romfs/Text/ZHCN.json.z
Normal file
BIN
romfs/Text/ZHCN.json.z
Normal file
Binary file not shown.
BIN
romfs/Text/ZHTW.json.z
Normal file
BIN
romfs/Text/ZHTW.json.z
Normal file
Binary file not shown.
126
source/JKSV.cpp
126
source/JKSV.cpp
|
|
@ -11,8 +11,8 @@
|
|||
#include "error.hpp"
|
||||
#include "fslib.hpp"
|
||||
#include "graphics/colors.hpp"
|
||||
#include "graphics/fonts.hpp"
|
||||
#include "graphics/screen.hpp"
|
||||
#include "input.hpp"
|
||||
#include "logging/logger.hpp"
|
||||
#include "remote/remote.hpp"
|
||||
#include "sdl.hpp"
|
||||
|
|
@ -46,9 +46,9 @@ namespace
|
|||
|
||||
// This function allows any service init to be logged with its name without repeating the code.
|
||||
template <typename... Args>
|
||||
static bool initialize_service(Result (*function)(Args...), const char *serviceName, Args... args)
|
||||
static bool initialize_service(Result (*function)(Args...), const char *serviceName, Args &&...args)
|
||||
{
|
||||
Result error = (*function)(args...);
|
||||
Result error = (*function)(std::forward<Args>(args)...);
|
||||
if (R_FAILED(error))
|
||||
{
|
||||
logger::log("Error initializing %s: 0x%X.", serviceName, error);
|
||||
|
|
@ -60,7 +60,15 @@ static bool initialize_service(Result (*function)(Args...), const char *serviceN
|
|||
// ---- Construction ----
|
||||
|
||||
JKSV::JKSV()
|
||||
: m_sdl2()
|
||||
, m_window(graphics::SCREEN_WIDTH, graphics::SCREEN_HEIGHT)
|
||||
, m_renderer(m_window)
|
||||
, m_audio()
|
||||
, m_input()
|
||||
{
|
||||
// Ensure SDL initialized correctly. If not, return.
|
||||
if (!m_sdl2.is_initialized() || !m_window.is_initialized() || !m_renderer.is_initialized()) { return; }
|
||||
|
||||
// Set boost mode first.
|
||||
JKSV::set_boost_mode();
|
||||
|
||||
|
|
@ -78,7 +86,6 @@ JKSV::JKSV()
|
|||
ABORT_ON_FAILURE(curl::initialize());
|
||||
|
||||
// Config and input.
|
||||
input::initialize();
|
||||
config::initialize();
|
||||
|
||||
// These are the strings used in the UI.
|
||||
|
|
@ -94,8 +101,8 @@ JKSV::JKSV()
|
|||
sys::threadpool::push_job(remote::initialize, nullptr);
|
||||
|
||||
// Launch the loading init. Finish init is called afterwards.
|
||||
auto init_finish = []() { MainMenuState::create_and_push(); }; // Lambda that's exec'd after state is finished.
|
||||
data::launch_initialization(false, init_finish);
|
||||
auto init_finish = [&]() { MainMenuState::create_and_push(m_renderer); }; // Lambda that's exec'd after state is finished.
|
||||
data::launch_initialization(false, m_renderer, init_finish);
|
||||
|
||||
// This isn't required, but why not?
|
||||
FadeState::create_and_push(colors::BLACK, 0xFF, 0x00, nullptr);
|
||||
|
|
@ -115,8 +122,6 @@ JKSV::~JKSV()
|
|||
config::save();
|
||||
curl::exit();
|
||||
JKSV::exit_services();
|
||||
sdl::text::SystemFont::exit();
|
||||
sdl::exit();
|
||||
|
||||
appletSetCpuBoostMode(ApmCpuBoostMode_Normal);
|
||||
appletUnlockExit();
|
||||
|
|
@ -128,25 +133,35 @@ bool JKSV::is_running() const noexcept { return sm_isRunning && appletMainLoop()
|
|||
|
||||
void JKSV::update()
|
||||
{
|
||||
input::update();
|
||||
// Update the input instance.
|
||||
m_input.update();
|
||||
|
||||
const bool plusPressed = input::button_pressed(HidNpadButton_Plus);
|
||||
// Check if we should close.
|
||||
const bool plusPressed = m_input.button_pressed(HidNpadButton_Plus);
|
||||
const bool isClosable = StateManager::back_is_closable();
|
||||
if (plusPressed && isClosable) { sm_isRunning = false; }
|
||||
|
||||
StateManager::update();
|
||||
// Update states and pop-ups.
|
||||
StateManager::update(m_input);
|
||||
ui::PopMessageManager::update();
|
||||
}
|
||||
|
||||
void JKSV::render()
|
||||
{
|
||||
sdl::frame_begin(colors::CLEAR_COLOR);
|
||||
// Set target to frame buffer and clear.
|
||||
m_renderer.frame_begin(colors::CLEAR_COLOR);
|
||||
|
||||
// Render the base.
|
||||
JKSV::render_base();
|
||||
StateManager::render();
|
||||
ui::PopMessageManager::render();
|
||||
|
||||
sdl::frame_end();
|
||||
// Render the states.
|
||||
StateManager::render(m_renderer);
|
||||
|
||||
// Render pop-ups.
|
||||
ui::PopMessageManager::render(m_renderer);
|
||||
|
||||
// Present to screen.
|
||||
m_renderer.frame_end();
|
||||
}
|
||||
|
||||
void JKSV::request_quit() noexcept { sm_isRunning = false; }
|
||||
|
|
@ -188,18 +203,39 @@ bool JKSV::initialize_services()
|
|||
|
||||
bool JKSV::initialize_sdl()
|
||||
{
|
||||
// Initialize SDL, freetype and the system font.
|
||||
bool sdlInit = sdl::initialize("JKSV", graphics::SCREEN_WIDTH, graphics::SCREEN_HEIGHT);
|
||||
sdlInit = sdlInit && sdl::text::SystemFont::initialize();
|
||||
if (!sdlInit) { return false; }
|
||||
// These are for loading the header icon.
|
||||
static constexpr std::string_view HEADER_PATH = "romfs:/Textures/HeaderIcon.png";
|
||||
|
||||
// These are our breakpoints for wrapping lines.
|
||||
static constexpr std::array<uint32_t, 7> BREAKPOINTS = {L' ', L' ', L'/', L'_', L'-', L'。', L'、'};
|
||||
|
||||
// These are our color changing points.
|
||||
static constexpr std::array<std::pair<uint32_t, SDL_Color>, 7> COLOR_POINTS = {{{L'#', colors::BLUE},
|
||||
{L'*', colors::DARK_RED},
|
||||
{L'<', colors::YELLOW},
|
||||
{L'>', colors::GREEN},
|
||||
{L'`', colors::BLUE_GREEN},
|
||||
{L'^', colors::PINK},
|
||||
{L'$', colors::GOLD}}};
|
||||
|
||||
// Ensure SDL2 textures and sounds are ready to use.
|
||||
sdl2::Texture::initialize(m_renderer);
|
||||
sdl2::Sound::initialize(m_audio);
|
||||
|
||||
// Register break and color points.
|
||||
sdl2::Font::add_break_points(BREAKPOINTS);
|
||||
sdl2::Font::add_color_points(COLOR_POINTS);
|
||||
|
||||
// Load our fonts.
|
||||
m_titleFont = sdl2::FontManager::create_load_resource<sdl2::SystemFont>(graphics::fonts::names::THIRTY_FOUR_PIXEL,
|
||||
graphics::fonts::sizes::THIRTY_FOUR_PIXEL);
|
||||
m_buildFont = sdl2::FontManager::create_load_resource<sdl2::SystemFont>(graphics::fonts::names::FOURTEEN_PIXEL,
|
||||
graphics::fonts::sizes::FOURTEEN_PIXEL);
|
||||
|
||||
// Load the icon in the top left.
|
||||
m_headerIcon = sdl::TextureManager::load("headerIcon", "romfs:/Textures/HeaderIcon.png");
|
||||
m_headerIcon = sdl2::TextureManager::create_load_resource(HEADER_PATH, HEADER_PATH);
|
||||
if (!m_headerIcon) { return false; }
|
||||
|
||||
// Push the color changing characters.
|
||||
JKSV::add_color_chars();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -220,17 +256,6 @@ bool JKSV::create_directories()
|
|||
return true;
|
||||
}
|
||||
|
||||
void JKSV::add_color_chars()
|
||||
{
|
||||
sdl::text::add_color_character(L'#', colors::BLUE);
|
||||
sdl::text::add_color_character(L'*', colors::DARK_RED);
|
||||
sdl::text::add_color_character(L'<', colors::YELLOW);
|
||||
sdl::text::add_color_character(L'>', colors::GREEN);
|
||||
sdl::text::add_color_character(L'`', colors::BLUE_GREEN);
|
||||
sdl::text::add_color_character(L'^', colors::PINK);
|
||||
sdl::text::add_color_character(L'$', colors::GOLD);
|
||||
}
|
||||
|
||||
void JKSV::setup_translation_info_strings()
|
||||
{
|
||||
const char *translationFormat = strings::get_by_name(strings::names::TRANSLATION, 0);
|
||||
|
|
@ -269,43 +294,32 @@ void JKSV::render_base()
|
|||
static constexpr int HEADER_Y = 27;
|
||||
|
||||
// Coordinates for the title text.
|
||||
static constexpr int TITLE_X = 130;
|
||||
static constexpr int TITLE_Y = 32;
|
||||
static constexpr int TITLE_SIZE = 34;
|
||||
static constexpr int TITLE_X = 130;
|
||||
static constexpr int TITLE_Y = 32;
|
||||
|
||||
// Coordinates for the translation info and build date.
|
||||
static constexpr int BUILD_X = 8;
|
||||
static constexpr int BUILD_Y = 700;
|
||||
static constexpr int TRANS_Y = 680;
|
||||
static constexpr int BUILD_SIZE = 14;
|
||||
static constexpr int BUILD_X = 8;
|
||||
static constexpr int BUILD_Y = 700;
|
||||
static constexpr int TRANS_Y = 680;
|
||||
|
||||
// This is just the JKSV string.
|
||||
static constexpr std::string_view TITLE_TEXT = "JKSV";
|
||||
|
||||
// Top and bottom framing lines.
|
||||
sdl::render_line(sdl::Texture::Null, LINE_X_BEGIN, LINE_A_Y, LINE_X_END, LINE_A_Y, colors::WHITE);
|
||||
sdl::render_line(sdl::Texture::Null, LINE_X_BEGIN, LINE_B_Y, LINE_X_END, LINE_B_Y, colors::WHITE);
|
||||
m_renderer.render_line(LINE_X_BEGIN, LINE_A_Y, LINE_X_END, LINE_A_Y, colors::WHITE);
|
||||
m_renderer.render_line(LINE_X_BEGIN, LINE_B_Y, LINE_X_END, LINE_B_Y, colors::WHITE);
|
||||
|
||||
// Icon
|
||||
m_headerIcon->render(sdl::Texture::Null, HEADER_X, HEADER_Y);
|
||||
m_headerIcon->render(HEADER_X, HEADER_Y);
|
||||
|
||||
// "JKSV"
|
||||
sdl::text::render(sdl::Texture::Null, TITLE_X, TITLE_Y, TITLE_SIZE, sdl::text::NO_WRAP, colors::WHITE, TITLE_TEXT);
|
||||
m_titleFont->render_text(TITLE_X, TITLE_Y, colors::WHITE, TITLE_TEXT);
|
||||
|
||||
// Translation info in bottom left.
|
||||
if (m_showTranslationInfo)
|
||||
{
|
||||
sdl::text::render(sdl::Texture::Null,
|
||||
BUILD_X,
|
||||
TRANS_Y,
|
||||
BUILD_SIZE,
|
||||
sdl::text::NO_WRAP,
|
||||
colors::WHITE,
|
||||
m_translationInfo);
|
||||
}
|
||||
if (m_showTranslationInfo) { m_buildFont->render_text(BUILD_X, TRANS_Y, colors::WHITE, m_translationInfo); }
|
||||
|
||||
// Build date
|
||||
sdl::text::render(sdl::Texture::Null, BUILD_X, BUILD_Y, BUILD_SIZE, sdl::text::NO_WRAP, colors::WHITE, m_buildString);
|
||||
m_buildFont->render_text(BUILD_X, BUILD_Y, colors::WHITE, m_buildString);
|
||||
}
|
||||
|
||||
void JKSV::exit_services()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "StateManager.hpp"
|
||||
|
||||
void StateManager::update()
|
||||
void StateManager::update(const sdl2::Input &input)
|
||||
{
|
||||
// Grab the instance.
|
||||
StateManager &instance = StateManager::get_instance();
|
||||
|
|
@ -10,7 +10,7 @@ void StateManager::update()
|
|||
|
||||
{
|
||||
auto &back = stateVector.back();
|
||||
if (back->is_active() && back->has_focus()) { back->update(); }
|
||||
if (back->is_active() && back->has_focus()) { back->update(input); }
|
||||
}
|
||||
|
||||
// Purge uneeded states.
|
||||
|
|
@ -39,12 +39,12 @@ void StateManager::update()
|
|||
}
|
||||
}
|
||||
|
||||
void StateManager::render() noexcept
|
||||
void StateManager::render(sdl2::Renderer &renderer) noexcept
|
||||
{
|
||||
StateManager &instance = StateManager::get_instance();
|
||||
auto &stateVector = instance.m_stateVector;
|
||||
|
||||
for (std::shared_ptr<BaseState> &state : stateVector) { state->render(); }
|
||||
for (std::shared_ptr<BaseState> &state : stateVector) { state->render(renderer); }
|
||||
}
|
||||
|
||||
bool StateManager::back_is_closable() noexcept
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@
|
|||
#include "error.hpp"
|
||||
#include "fs/fs.hpp"
|
||||
#include "fslib.hpp"
|
||||
#include "graphics/ScopedRender.hpp"
|
||||
#include "graphics/colors.hpp"
|
||||
#include "input.hpp"
|
||||
#include "graphics/fonts.hpp"
|
||||
#include "keyboard/keyboard.hpp"
|
||||
#include "sdl.hpp"
|
||||
#include "strings/strings.hpp"
|
||||
|
|
@ -43,13 +44,13 @@ BackupMenuState::BackupMenuState(data::User *user, data::TitleInfo *titleInfo, c
|
|||
|
||||
// ---- Public functions ----
|
||||
|
||||
void BackupMenuState::update()
|
||||
void BackupMenuState::update(const sdl2::Input &input)
|
||||
{
|
||||
// Grab focus once and only once.
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
// Update the panel first.
|
||||
sm_slidePanel->update(hasFocus);
|
||||
sm_slidePanel->update(input, hasFocus);
|
||||
|
||||
// Grab these.
|
||||
const bool isOpen = sm_slidePanel->is_open();
|
||||
|
|
@ -67,11 +68,11 @@ void BackupMenuState::update()
|
|||
}
|
||||
|
||||
// Input bools.
|
||||
const bool aPressed = input::button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input::button_pressed(HidNpadButton_B);
|
||||
const bool xPressed = input::button_pressed(HidNpadButton_X);
|
||||
const bool yPressed = input::button_pressed(HidNpadButton_Y);
|
||||
const bool zrPressed = input::button_pressed(HidNpadButton_ZR);
|
||||
const bool aPressed = input.button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input.button_pressed(HidNpadButton_B);
|
||||
const bool xPressed = input.button_pressed(HidNpadButton_B);
|
||||
const bool yPressed = input.button_pressed(HidNpadButton_Y);
|
||||
const bool zrPressed = input.button_pressed(HidNpadButton_ZR);
|
||||
|
||||
// Conditions.
|
||||
const bool newSelected = selected == 0;
|
||||
|
|
@ -82,7 +83,7 @@ void BackupMenuState::update()
|
|||
const bool uploadBackup = zrPressed && !newSelected;
|
||||
const bool popEmpty = aPressed && !m_saveHasData;
|
||||
|
||||
if (newBackup) { BackupMenuState::name_and_create_backup(); }
|
||||
if (newBackup) { BackupMenuState::name_and_create_backup(input); }
|
||||
else if (overwriteBackup) { BackupMenuState::confirm_overwrite(); }
|
||||
else if (restoreBackup) { BackupMenuState::confirm_restore(); }
|
||||
else if (deleteBackup) { BackupMenuState::confirm_delete(); }
|
||||
|
|
@ -93,10 +94,10 @@ void BackupMenuState::update()
|
|||
|
||||
// Lock and update the menu.
|
||||
std::lock_guard menuGuard{sm_menuMutex};
|
||||
sm_backupMenu->update(hasFocus);
|
||||
sm_backupMenu->update(input, hasFocus);
|
||||
}
|
||||
|
||||
void BackupMenuState::render()
|
||||
void BackupMenuState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
// Line render coords.
|
||||
static constexpr int LINE_X = 10;
|
||||
|
|
@ -106,32 +107,37 @@ void BackupMenuState::render()
|
|||
static constexpr int CONTROL_X = 32;
|
||||
static constexpr int CONTROL_Y = 673;
|
||||
|
||||
// Clear the render target.
|
||||
sm_slidePanel->clear_target();
|
||||
|
||||
// Grab whether or not the state has focus and the render target for the panel.
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
sdl::SharedTexture &target = sm_slidePanel->get_target();
|
||||
|
||||
// Render the top, bottom lines. Control guide string.
|
||||
sdl::render_line(target, LINE_X, LINE_A_Y, sm_panelWidth - LINE_X, LINE_A_Y, colors::WHITE);
|
||||
sdl::render_line(target, LINE_X, LINE_B_Y, sm_panelWidth - LINE_X, LINE_B_Y, colors::WHITE);
|
||||
sdl::text::render(target, CONTROL_X, CONTROL_Y, 22, sdl::text::NO_WRAP, colors::WHITE, m_controlGuide);
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
// This is the target for the menu so it can't render outside of the lines above.
|
||||
sm_menuRenderTarget->clear(colors::TRANSPARENT);
|
||||
|
||||
// Lock and render the menu.
|
||||
{
|
||||
std::lock_guard menuGuard{sm_menuMutex};
|
||||
sm_backupMenu->render(sm_menuRenderTarget, hasFocus);
|
||||
graphics::ScopedRender menuRender{renderer, sm_menuRenderTarget};
|
||||
renderer.frame_begin(colors::TRANSPARENT);
|
||||
|
||||
// Lock and render the menu.
|
||||
{
|
||||
std::lock_guard menuGuard{sm_menuMutex};
|
||||
sm_backupMenu->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
// Get target and change target.
|
||||
{
|
||||
graphics::ScopedRender slideRender{renderer, sm_slidePanel->get_target()};
|
||||
renderer.frame_begin(colors::SLIDE_PANEL_CLEAR);
|
||||
|
||||
// Render the top, bottom lines. Control guide string.
|
||||
renderer.render_line(LINE_X, LINE_A_Y, sm_panelWidth - LINE_X, LINE_A_Y, colors::WHITE);
|
||||
renderer.render_line(LINE_X, LINE_B_Y, sm_panelWidth - LINE_X, LINE_B_Y, colors::WHITE);
|
||||
sm_font->render_text(CONTROL_X, CONTROL_Y, colors::WHITE, m_controlGuide);
|
||||
|
||||
// Render the menu target to the slide panel target.
|
||||
sm_menuRenderTarget->render(0, 43);
|
||||
}
|
||||
}
|
||||
|
||||
// Render the menu target to the slide panel target.
|
||||
sm_menuRenderTarget->render(target, 0, 43);
|
||||
|
||||
// Finally, render the target to the screen.
|
||||
sm_slidePanel->render(sdl::Texture::Null, hasFocus);
|
||||
sm_slidePanel->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
void BackupMenuState::refresh()
|
||||
|
|
@ -196,12 +202,18 @@ void BackupMenuState::save_data_written()
|
|||
|
||||
void BackupMenuState::initialize_static_members()
|
||||
{
|
||||
if (sm_backupMenu && sm_slidePanel && sm_menuRenderTarget && sm_panelWidth) { return; }
|
||||
// Name of the render target for the backup menu.
|
||||
static constexpr std::string_view BACKUP_TARGET = "BackupMenuTarget";
|
||||
|
||||
sm_panelWidth = sdl::text::get_width(22, m_controlGuide) + 64;
|
||||
sm_backupMenu = ui::Menu::create(8, 8, sm_panelWidth - 16, 22, 600);
|
||||
sm_slidePanel = ui::SlideOutPanel::create(sm_panelWidth, ui::SlideOutPanel::Side::Right);
|
||||
sm_menuRenderTarget = sdl::TextureManager::load("backupMenuTarget", sm_panelWidth, 600, SDL_TEXTUREACCESS_TARGET);
|
||||
if (sm_backupMenu && sm_slidePanel && sm_menuRenderTarget && sm_panelWidth && sm_font) { return; }
|
||||
|
||||
sm_font = sdl2::FontManager::create_load_resource<sdl2::SystemFont>(graphics::fonts::names::TWENTY_TWO_PIXEL,
|
||||
graphics::fonts::sizes::TWENTY_TWO_PIXEL);
|
||||
sm_panelWidth = sm_font->get_text_width(m_controlGuide) + 64;
|
||||
sm_backupMenu = ui::Menu::create(8, 8, sm_panelWidth - 16, 22, 600);
|
||||
sm_slidePanel = ui::SlideOutPanel::create(sm_panelWidth, ui::SlideOutPanel::Side::Right);
|
||||
sm_menuRenderTarget =
|
||||
sdl2::TextureManager::create_load_resource(BACKUP_TARGET, sm_panelWidth, 600, SDL_TEXTUREACCESS_TARGET);
|
||||
}
|
||||
|
||||
void BackupMenuState::ensure_target_directory()
|
||||
|
|
@ -262,7 +274,7 @@ void BackupMenuState::initialize_remote_storage()
|
|||
remote->change_directory(remoteDir);
|
||||
}
|
||||
|
||||
void BackupMenuState::name_and_create_backup()
|
||||
void BackupMenuState::name_and_create_backup(const sdl2::Input &input)
|
||||
{
|
||||
// Size of the buffer for naming backups.
|
||||
static constexpr size_t SIZE_NAME_LENGTH = 0x80;
|
||||
|
|
@ -279,7 +291,7 @@ void BackupMenuState::name_and_create_backup()
|
|||
const bool exportZip = autoUpload || config::get_by_key(config::keys::EXPORT_TO_ZIP);
|
||||
|
||||
// Input.
|
||||
const bool zrHeld = input::button_held(HidNpadButton_ZR);
|
||||
const bool zrHeld = input.button_held(HidNpadButton_ZR);
|
||||
|
||||
// Whether or not we should skip the keyboard.
|
||||
const bool autoNamed = (autoName || zrHeld); // This can be eval'd here.
|
||||
|
|
@ -525,7 +537,10 @@ void BackupMenuState::upload_backup()
|
|||
// Push the confirmation.
|
||||
ConfirmProgress::create_push_fade(query, holdRequired, tasks::backup::patch_backup, nullptr, m_dataStruct);
|
||||
}
|
||||
else { ProgressState::create_push_fade(tasks::backup::upload_backup, m_dataStruct); }
|
||||
else
|
||||
{
|
||||
ProgressState::create_push_fade(tasks::backup::upload_backup, m_dataStruct);
|
||||
}
|
||||
}
|
||||
|
||||
void BackupMenuState::pop_save_empty()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "appstates/BaseTask.hpp"
|
||||
|
||||
#include "graphics/colors.hpp"
|
||||
#include "input.hpp"
|
||||
#include "graphics/fonts.hpp"
|
||||
#include "strings/strings.hpp"
|
||||
#include "ui/PopMessageManager.hpp"
|
||||
|
||||
|
|
@ -15,7 +15,8 @@ namespace
|
|||
BaseTask::BaseTask()
|
||||
: BaseState(false)
|
||||
, m_frameTimer(TICKS_GLYPH_TRIGGER)
|
||||
, m_popUnableExit(strings::get_by_name(strings::names::GENERAL_POPS, 0)) {};
|
||||
, m_popUnableExit(strings::get_by_name(strings::names::GENERAL_POPS, 0))
|
||||
{ BaseTask::initialize_static_members(); }
|
||||
|
||||
// ---- Public functions ----
|
||||
|
||||
|
|
@ -27,9 +28,9 @@ void BaseTask::update_loading_glyph()
|
|||
else if (++m_currentFrame % 8 == 0) { m_currentFrame = 0; }
|
||||
}
|
||||
|
||||
void BaseTask::pop_on_plus()
|
||||
void BaseTask::pop_on_plus(const sdl2::Input &input)
|
||||
{
|
||||
const bool plusPressed = input::button_pressed(HidNpadButton_Plus);
|
||||
const bool plusPressed = input.button_pressed(HidNpadButton_Plus);
|
||||
|
||||
if (plusPressed) { ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_TICKS, m_popUnableExit); }
|
||||
}
|
||||
|
|
@ -37,15 +38,18 @@ void BaseTask::pop_on_plus()
|
|||
void BaseTask::render_loading_glyph()
|
||||
{
|
||||
// Render coords.
|
||||
static constexpr int RENDER_X = 56;
|
||||
static constexpr int RENDER_Y = 673;
|
||||
static constexpr int RENDER_SIZE = 32;
|
||||
static constexpr int RENDER_X = 56;
|
||||
static constexpr int RENDER_Y = 673;
|
||||
|
||||
sdl::text::render(sdl::Texture::Null,
|
||||
RENDER_X,
|
||||
RENDER_Y,
|
||||
RENDER_SIZE,
|
||||
sdl::text::NO_WRAP,
|
||||
m_colorMod,
|
||||
sm_glyphArray[m_currentFrame]);
|
||||
sm_font->render_text(RENDER_X, RENDER_Y, colors::WHITE, sm_glyphArray[m_currentFrame]);
|
||||
}
|
||||
|
||||
// ---- Private Functions ----
|
||||
|
||||
void BaseTask::initialize_static_members()
|
||||
{
|
||||
if (sm_font) { return; }
|
||||
|
||||
sm_font = sdl2::FontManager::create_load_resource<sdl2::SystemFont>(graphics::fonts::names::THIRTY_TWO_PIXEL,
|
||||
graphics::fonts::sizes::THIRTY_TWO_PIXEL);
|
||||
}
|
||||
|
|
@ -6,7 +6,6 @@
|
|||
#include "data/data.hpp"
|
||||
#include "error.hpp"
|
||||
#include "graphics/screen.hpp"
|
||||
#include "input.hpp"
|
||||
|
||||
// ---- Construction ----
|
||||
|
||||
|
|
@ -21,24 +20,24 @@ BlacklistEditState::BlacklistEditState()
|
|||
|
||||
// ---- Public functions ----
|
||||
|
||||
void BlacklistEditState::update()
|
||||
void BlacklistEditState::update(const sdl2::Input &input)
|
||||
{
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
const bool aPressed = input::button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input::button_pressed(HidNpadButton_B);
|
||||
const bool aPressed = input.button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input.button_pressed(HidNpadButton_B);
|
||||
|
||||
sm_slidePanel->update(hasFocus);
|
||||
sm_slidePanel->update(input, hasFocus);
|
||||
|
||||
if (aPressed) { BlacklistEditState::remove_from_blacklist(); }
|
||||
else if (sm_slidePanel->is_closed()) { BlacklistEditState::deactivate_state(); }
|
||||
else if (bPressed || m_blacklist.empty()) { sm_slidePanel->close(); }
|
||||
}
|
||||
|
||||
void BlacklistEditState::render()
|
||||
void BlacklistEditState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
sm_slidePanel->clear_target();
|
||||
sm_slidePanel->render(sdl::Texture::Null, hasFocus);
|
||||
|
||||
sm_slidePanel->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
// ---- Private functions ----
|
||||
|
|
|
|||
|
|
@ -1,22 +1,21 @@
|
|||
#include "appstates/DataLoadingState.hpp"
|
||||
|
||||
#include "graphics/colors.hpp"
|
||||
#include "graphics/fonts.hpp"
|
||||
#include "graphics/screen.hpp"
|
||||
#include "logging/logger.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr int SCREEN_CENTER = 640;
|
||||
}
|
||||
#include "mathutil.hpp"
|
||||
|
||||
// ---- Construction ----
|
||||
|
||||
DataLoadingState::DataLoadingState(data::DataContext &context,
|
||||
sdl2::Renderer &renderer,
|
||||
DestructFunction destructFunction,
|
||||
sys::threadpool::JobFunction function,
|
||||
sys::Task::TaskData taskData)
|
||||
: BaseTask()
|
||||
, m_context(context)
|
||||
, m_renderer(renderer)
|
||||
, m_destructFunction(destructFunction)
|
||||
{
|
||||
DataLoadingState::initialize_static_members();
|
||||
|
|
@ -25,27 +24,34 @@ DataLoadingState::DataLoadingState(data::DataContext &context,
|
|||
|
||||
// ---- Public functions ----
|
||||
|
||||
void DataLoadingState::update()
|
||||
void DataLoadingState::update(const sdl2::Input &input)
|
||||
{
|
||||
BaseTask::update_loading_glyph();
|
||||
if (!m_task->is_running()) { DataLoadingState::deactivate_state(); }
|
||||
m_context.process_icon_queue();
|
||||
m_context.process_icon_queue(m_renderer);
|
||||
}
|
||||
|
||||
void DataLoadingState::sub_update() { BaseTask::update_loading_glyph(); }
|
||||
|
||||
void DataLoadingState::render()
|
||||
void DataLoadingState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
static constexpr int ICON_X_COORD = SCREEN_CENTER - 128;
|
||||
static constexpr int ICON_Y_COORD = 226;
|
||||
const std::string status = m_task->get_status();
|
||||
// These are the dimensions of the icon loaded.
|
||||
static constexpr int ICON_WIDTH = 256;
|
||||
static constexpr int ICON_HEIGHT = 259;
|
||||
static constexpr int ICON_X = math::Util<int>::center_within(graphics::SCREEN_WIDTH, ICON_WIDTH);
|
||||
static constexpr int ICON_Y = math::Util<int>::center_within(graphics::SCREEN_HEIGHT, ICON_HEIGHT);
|
||||
|
||||
const int statusWidth = sdl::text::get_width(BaseTask::FONT_SIZE, status);
|
||||
m_statusX = SCREEN_CENTER - (statusWidth / 2);
|
||||
// Grab the status from the task and center it.
|
||||
const std::string status = m_task->get_status();
|
||||
const int statusWidth = sm_font->get_text_width(status);
|
||||
m_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::CLEAR_COLOR);
|
||||
sm_jksvIcon->render(sdl::Texture::Null, ICON_X_COORD, ICON_Y_COORD);
|
||||
sdl::text::render(sdl::Texture::Null, m_statusX, 673, BaseTask::FONT_SIZE, sdl::text::NO_WRAP, colors::WHITE, status);
|
||||
// This is to cover up the base rendering.
|
||||
renderer.render_rectangle(0, 0, graphics::SCREEN_WIDTH, graphics::SCREEN_HEIGHT, colors::CLEAR_COLOR);
|
||||
|
||||
// Render the icon, status and loading glyph.
|
||||
sm_jksvIcon->render(ICON_X, ICON_Y);
|
||||
sm_font->render_text(m_statusX, 673, colors::WHITE, status);
|
||||
BaseTask::render_loading_glyph();
|
||||
}
|
||||
|
||||
|
|
@ -53,15 +59,21 @@ void DataLoadingState::render()
|
|||
|
||||
void DataLoadingState::initialize_static_members()
|
||||
{
|
||||
if (sm_jksvIcon) { return; }
|
||||
// Path for the loading icon.
|
||||
static constexpr std::string_view ICON_PATH = "romfs:/Textures/LoadingIcon.png";
|
||||
|
||||
sm_jksvIcon = sdl::TextureManager::load("LoadingIcon", "romfs:/Textures/LoadingIcon.png");
|
||||
if (sm_jksvIcon && sm_font) { return; }
|
||||
|
||||
// Load icon and font.
|
||||
sm_jksvIcon = sdl2::TextureManager::create_load_resource(ICON_PATH, ICON_PATH);
|
||||
sm_font = sdl2::FontManager::create_load_resource<sdl2::SystemFont>(graphics::fonts::names::TWENTY_PIXEL,
|
||||
graphics::fonts::sizes::TWENTY_PIXEL);
|
||||
}
|
||||
|
||||
void DataLoadingState::deactivate_state()
|
||||
{
|
||||
// This is to catch any stragglers.
|
||||
m_context.process_icon_queue();
|
||||
m_context.process_icon_queue(m_renderer);
|
||||
if (m_destructFunction) { m_destructFunction(); }
|
||||
BaseState::deactivate();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,9 @@
|
|||
#include "appstates/MainMenuState.hpp"
|
||||
#include "data/data.hpp"
|
||||
#include "error.hpp"
|
||||
#include "graphics/ScopedRender.hpp"
|
||||
#include "graphics/colors.hpp"
|
||||
#include "input.hpp"
|
||||
#include "graphics/targets.hpp"
|
||||
#include "keyboard/keyboard.hpp"
|
||||
#include "strings/strings.hpp"
|
||||
#include "ui/PopMessageManager.hpp"
|
||||
|
|
@ -14,9 +15,6 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
// This target is shared be a lot of states.
|
||||
constexpr std::string_view SECONDARY_TARGET = "SecondaryTarget";
|
||||
|
||||
// Enum for switch case readability.
|
||||
enum
|
||||
{
|
||||
|
|
@ -35,23 +33,25 @@ static void finish_reinitialization();
|
|||
|
||||
// ---- Construction ----
|
||||
|
||||
ExtrasMenuState::ExtrasMenuState()
|
||||
: m_renderTarget(sdl::TextureManager::load(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_TARGET))
|
||||
ExtrasMenuState::ExtrasMenuState(sdl2::Renderer &renderer)
|
||||
: m_renderer(renderer)
|
||||
, m_renderTarget(sdl2::TextureManager::create_load_resource(graphics::targets::names::SECONDARY,
|
||||
graphics::targets::dims::SECONDARY_WIDTH,
|
||||
graphics::targets::dims::SECONDARY_HEIGHT,
|
||||
SDL_TEXTUREACCESS_TARGET))
|
||||
, m_controlGuide(ui::ControlGuide::create(strings::get_by_name(strings::names::CONTROL_GUIDES, 5)))
|
||||
{
|
||||
ExtrasMenuState::initialize_menu();
|
||||
}
|
||||
{ ExtrasMenuState::initialize_menu(); }
|
||||
|
||||
// ---- Public functions ----
|
||||
|
||||
void ExtrasMenuState::update()
|
||||
void ExtrasMenuState::update(const sdl2::Input &input)
|
||||
{
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
const bool aPressed = input::button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input::button_pressed(HidNpadButton_B);
|
||||
const bool aPressed = input.button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input.button_pressed(HidNpadButton_B);
|
||||
|
||||
m_extrasMenu->update(hasFocus);
|
||||
m_controlGuide->update(hasFocus);
|
||||
m_extrasMenu->update(input, hasFocus);
|
||||
m_controlGuide->update(input, hasFocus);
|
||||
|
||||
if (aPressed)
|
||||
{
|
||||
|
|
@ -71,14 +71,20 @@ void ExtrasMenuState::update()
|
|||
|
||||
void ExtrasMenuState::sub_update() { m_controlGuide->sub_update(); }
|
||||
|
||||
void ExtrasMenuState::render()
|
||||
void ExtrasMenuState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
m_renderTarget->clear(colors::TRANSPARENT);
|
||||
m_extrasMenu->render(m_renderTarget, hasFocus);
|
||||
m_renderTarget->render(sdl::Texture::Null, 201, 91);
|
||||
m_controlGuide->render(sdl::Texture::Null, hasFocus);
|
||||
{ // Set the render target.
|
||||
graphics::ScopedRender scopedRender{renderer, m_renderTarget};
|
||||
renderer.frame_begin(colors::TRANSPARENT);
|
||||
|
||||
// Render the menu to it.
|
||||
m_extrasMenu->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
m_renderTarget->render(201, 91);
|
||||
m_controlGuide->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
// ---- Private functions ----
|
||||
|
|
@ -93,7 +99,7 @@ void ExtrasMenuState::initialize_menu()
|
|||
}
|
||||
}
|
||||
|
||||
void ExtrasMenuState::reinitialize_data() { data::launch_initialization(true, finish_reinitialization); }
|
||||
void ExtrasMenuState::reinitialize_data() { data::launch_initialization(true, m_renderer, finish_reinitialization); }
|
||||
|
||||
void ExtrasMenuState::sd_to_sd_browser() { FileModeState::create_and_push("sdmc", "sdmc", false); }
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace
|
|||
}
|
||||
|
||||
// ---- Construction ----
|
||||
FadeState::FadeState(sdl::Color baseColor, uint8_t startAlpha, uint8_t endAlpha, std::shared_ptr<BaseState> nextState)
|
||||
FadeState::FadeState(SDL_Color baseColor, uint8_t startAlpha, uint8_t endAlpha, std::shared_ptr<BaseState> nextState)
|
||||
: m_baseColor(baseColor)
|
||||
, m_alpha(startAlpha)
|
||||
, m_endAlpha(endAlpha)
|
||||
|
|
@ -23,7 +23,7 @@ FadeState::FadeState(sdl::Color baseColor, uint8_t startAlpha, uint8_t endAlpha,
|
|||
m_fadeTimer.start(TICKS_TIMER_TRIGGER);
|
||||
}
|
||||
|
||||
void FadeState::update()
|
||||
void FadeState::update(const sdl2::Input &input)
|
||||
{
|
||||
if (m_alpha == m_endAlpha)
|
||||
{
|
||||
|
|
@ -38,12 +38,13 @@ void FadeState::update()
|
|||
}
|
||||
}
|
||||
|
||||
void FadeState::render()
|
||||
void FadeState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
const uint32_t rawColor = (m_baseColor.raw & 0xFFFFFF00) | m_alpha;
|
||||
const sdl::Color fadeColor{rawColor};
|
||||
// Update alpha.
|
||||
m_baseColor.a = m_alpha;
|
||||
|
||||
sdl::render_rect_fill(sdl::Texture::Null, 0, 0, graphics::SCREEN_WIDTH, graphics::SCREEN_HEIGHT, fadeColor);
|
||||
// Render overtop of everything.
|
||||
renderer.render_rectangle(0, 0, graphics::SCREEN_WIDTH, graphics::SCREEN_HEIGHT, m_baseColor);
|
||||
}
|
||||
|
||||
// ---- Private functions ----
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
#include "appstates/FileOptionState.hpp"
|
||||
#include "config/config.hpp"
|
||||
#include "graphics/ScopedRender.hpp"
|
||||
#include "graphics/colors.hpp"
|
||||
#include "graphics/screen.hpp"
|
||||
#include "input.hpp"
|
||||
#include "logging/logger.hpp"
|
||||
#include "mathutil.hpp"
|
||||
#include "strings/strings.hpp"
|
||||
|
|
@ -39,17 +39,17 @@ FileModeState::FileModeState(std::string_view mountA, std::string_view mountB, i
|
|||
|
||||
// ---- Public functions ----
|
||||
|
||||
void FileModeState::update()
|
||||
void FileModeState::update(const sdl2::Input &input)
|
||||
{
|
||||
switch (m_state)
|
||||
{
|
||||
case State::Rising:
|
||||
case State::Dropping: FileModeState::update_y(); break;
|
||||
case State::Open: FileModeState::update_handle_input(); break;
|
||||
case State::Open: FileModeState::update_handle_input(input); break;
|
||||
}
|
||||
}
|
||||
|
||||
void FileModeState::render()
|
||||
void FileModeState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
// Coords for divider lines.
|
||||
static constexpr int LINE_A_X = 617;
|
||||
|
|
@ -59,27 +59,25 @@ void FileModeState::render()
|
|||
static constexpr int LINE_Y_A = 0;
|
||||
static constexpr int LINE_Y_B = 538;
|
||||
|
||||
// Grab focus.
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
sm_renderTarget->clear(colors::TRANSPARENT);
|
||||
// Switch targets, clear.
|
||||
{
|
||||
graphics::ScopedRender scopedRender{renderer, sm_renderTarget};
|
||||
renderer.frame_begin(colors::TRANSPARENT);
|
||||
|
||||
// This is here so it's rendered underneath the pop-up frame.
|
||||
sm_controlGuide->render(sdl::Texture::Null, hasFocus);
|
||||
// Divider lines & menus.
|
||||
renderer.render_line(LINE_A_X, LINE_Y_A, LINE_A_X, LINE_Y_B, colors::WHITE);
|
||||
renderer.render_line(LINE_B_X, LINE_Y_A, LINE_B_X, LINE_Y_B, colors::DIALOG_DARK);
|
||||
m_dirMenuA->render(renderer, hasFocus && m_target == Target::MountA);
|
||||
m_dirMenuB->render(renderer, hasFocus && m_target == Target::MountB);
|
||||
}
|
||||
|
||||
// Center divider lines.
|
||||
sdl::render_line(sm_renderTarget, LINE_A_X, LINE_Y_A, LINE_A_X, LINE_Y_B, colors::WHITE);
|
||||
sdl::render_line(sm_renderTarget, LINE_B_X, LINE_Y_A, LINE_B_X, LINE_Y_B, colors::DIALOG_DARK);
|
||||
|
||||
// Menus
|
||||
m_dirMenuA->render(sm_renderTarget, hasFocus && m_target == Target::MountA);
|
||||
m_dirMenuB->render(sm_renderTarget, hasFocus && m_target == Target::MountB);
|
||||
|
||||
// Frame.
|
||||
sm_frame->render(sdl::Texture::Null, true);
|
||||
|
||||
// Main target.
|
||||
const int y = m_transition.get_y();
|
||||
sm_renderTarget->render(sdl::Texture::Null, 23, y + 12);
|
||||
// This needs to be in this specific order to look right.
|
||||
sm_controlGuide->render(renderer, hasFocus);
|
||||
sm_frame->render(renderer, hasFocus);
|
||||
sm_renderTarget->render(23, m_transition.get_y() + 12);
|
||||
}
|
||||
|
||||
// ---- Private functions ----
|
||||
|
|
@ -99,8 +97,9 @@ void FileModeState::initialize_static_members()
|
|||
|
||||
if (sm_frame && sm_renderTarget && sm_controlGuide) { return; }
|
||||
|
||||
sm_frame = ui::Frame::create(PERMA_X, graphics::SCREEN_HEIGHT, FRAME_WIDTH, FRAME_HEIGHT);
|
||||
sm_renderTarget = sdl::TextureManager::load(RENDER_TARGET_NAME, INNER_WIDTH, INNER_HEIGHT, SDL_TEXTUREACCESS_TARGET);
|
||||
sm_frame = ui::Frame::create(PERMA_X, graphics::SCREEN_HEIGHT, FRAME_WIDTH, FRAME_HEIGHT);
|
||||
sm_renderTarget =
|
||||
sdl2::TextureManager::create_load_resource(RENDER_TARGET_NAME, INNER_WIDTH, INNER_HEIGHT, SDL_TEXTUREACCESS_TARGET);
|
||||
sm_controlGuide = ui::ControlGuide::create(strings::get_by_name(strings::names::CONTROL_GUIDES, 4));
|
||||
}
|
||||
|
||||
|
|
@ -147,7 +146,10 @@ void FileModeState::initialize_directory_menu(const fslib::Path &path, fslib::Di
|
|||
{
|
||||
std::string option{};
|
||||
if (entry.is_directory()) { option = DIR_PREFIX; }
|
||||
else { option = FILE_PREFIX; }
|
||||
else
|
||||
{
|
||||
option = FILE_PREFIX;
|
||||
}
|
||||
|
||||
option += entry.get_filename();
|
||||
menu.add_option(option);
|
||||
|
|
@ -170,7 +172,7 @@ void FileModeState::update_y() noexcept
|
|||
else if (finishedDropping) { FileModeState::deactivate_state(); }
|
||||
}
|
||||
|
||||
void FileModeState::update_handle_input() noexcept
|
||||
void FileModeState::update_handle_input(const sdl2::Input &input) noexcept
|
||||
{
|
||||
// Get whether or not the state has focus.
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
|
@ -181,11 +183,11 @@ void FileModeState::update_handle_input() noexcept
|
|||
fslib::Directory &directory = FileModeState::get_source_directory();
|
||||
|
||||
// Input bools.
|
||||
const bool aPressed = input::button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input::button_pressed(HidNpadButton_B);
|
||||
const bool xPressed = input::button_pressed(HidNpadButton_X);
|
||||
const bool zlZRPressed = input::button_pressed(HidNpadButton_ZL) || input::button_pressed(HidNpadButton_ZR);
|
||||
const bool minusPressed = input::button_pressed(HidNpadButton_Minus);
|
||||
const bool aPressed = input.button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input.button_pressed(HidNpadButton_B);
|
||||
const bool xPressed = input.button_pressed(HidNpadButton_X);
|
||||
const bool zlZRPressed = input.button_pressed(HidNpadButton_ZL) || input.button_pressed(HidNpadButton_ZR);
|
||||
const bool minusPressed = input.button_pressed(HidNpadButton_Minus);
|
||||
|
||||
// Conditions
|
||||
if (aPressed) { FileModeState::enter_selected(path, directory, menu); }
|
||||
|
|
@ -199,8 +201,8 @@ void FileModeState::update_handle_input() noexcept
|
|||
}
|
||||
|
||||
// Update the menu and control guide.
|
||||
menu.update(hasFocus);
|
||||
sm_controlGuide->update(hasFocus);
|
||||
menu.update(input, hasFocus);
|
||||
sm_controlGuide->update(input, hasFocus);
|
||||
}
|
||||
|
||||
void FileModeState::enter_selected(fslib::Path &path, fslib::Directory &directory, ui::Menu &menu)
|
||||
|
|
@ -256,14 +258,10 @@ void FileModeState::enter_directory(fslib::Path &path,
|
|||
}
|
||||
|
||||
ui::Menu &FileModeState::get_source_menu() noexcept
|
||||
{
|
||||
return m_target == Target::MountA ? *m_dirMenuA.get() : *m_dirMenuB.get();
|
||||
}
|
||||
{ return m_target == Target::MountA ? *m_dirMenuA.get() : *m_dirMenuB.get(); }
|
||||
|
||||
ui::Menu &FileModeState::get_destination_menu() noexcept
|
||||
{
|
||||
return m_target == Target::MountA ? *m_dirMenuB.get() : *m_dirMenuA.get();
|
||||
}
|
||||
{ return m_target == Target::MountA ? *m_dirMenuB.get() : *m_dirMenuA.get(); }
|
||||
|
||||
fslib::Path &FileModeState::get_source_path() noexcept { return m_target == Target::MountA ? m_pathA : m_pathB; }
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
#include "error.hpp"
|
||||
#include "fs/fs.hpp"
|
||||
#include "fslib.hpp"
|
||||
#include "input.hpp"
|
||||
#include "keyboard/keyboard.hpp"
|
||||
#include "logging/logger.hpp"
|
||||
#include "mathutil.hpp"
|
||||
|
|
@ -70,23 +69,26 @@ FileOptionState::FileOptionState(FileModeState *spawningState)
|
|||
|
||||
// ---- Public functions ----
|
||||
|
||||
void FileOptionState::update()
|
||||
void FileOptionState::update(const sdl2::Input &input)
|
||||
{
|
||||
switch (m_state)
|
||||
{
|
||||
case State::Opening:
|
||||
case State::Closing: FileOptionState::update_dimensions(); break;
|
||||
case State::Opened: FileOptionState::update_handle_input(); break;
|
||||
case State::Opened: FileOptionState::update_handle_input(input); break;
|
||||
}
|
||||
}
|
||||
|
||||
void FileOptionState::render()
|
||||
void FileOptionState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
// Grab focus.
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
sm_dialog->render(sdl::Texture::Null, hasFocus);
|
||||
|
||||
// Render the dialog and bail if we're not read for the menu.
|
||||
sm_dialog->render(renderer, hasFocus);
|
||||
if (!m_transition.in_place()) { return; }
|
||||
|
||||
sm_copyMenu->render(sdl::Texture::Null, hasFocus);
|
||||
sm_copyMenu->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
void FileOptionState::update_source() { m_updateSource = true; }
|
||||
|
|
@ -156,7 +158,7 @@ void FileOptionState::update_dimensions() noexcept
|
|||
else if (isClosed) { FileOptionState::deactivate_state(); }
|
||||
}
|
||||
|
||||
void FileOptionState::update_handle_input() noexcept
|
||||
void FileOptionState::update_handle_input(const sdl2::Input &input) noexcept
|
||||
{
|
||||
// Grab whether or not the state has focus since this is actually used a lot.
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
|
@ -166,12 +168,12 @@ void FileOptionState::update_handle_input() noexcept
|
|||
else if (m_updateDest) { FileOptionState::update_filemode_dest(); }
|
||||
|
||||
// Update the menu input.
|
||||
sm_copyMenu->update(hasFocus);
|
||||
sm_copyMenu->update(input, hasFocus);
|
||||
|
||||
// Local input handling.
|
||||
const int selected = sm_copyMenu->get_selected();
|
||||
const bool aPressed = input::button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input::button_pressed(HidNpadButton_B);
|
||||
const bool aPressed = input.button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input.button_pressed(HidNpadButton_B);
|
||||
|
||||
if (aPressed)
|
||||
{
|
||||
|
|
@ -398,7 +400,10 @@ void FileOptionState::get_show_target_properties()
|
|||
|
||||
const bool isDir = fslib::directory_exists(targetPath);
|
||||
if (isDir) { FileOptionState::get_show_directory_properties(targetPath); }
|
||||
else { FileOptionState::get_show_file_properties(targetPath); }
|
||||
else
|
||||
{
|
||||
FileOptionState::get_show_file_properties(targetPath);
|
||||
}
|
||||
}
|
||||
|
||||
void FileOptionState::close_dialog() noexcept
|
||||
|
|
@ -460,11 +465,11 @@ void FileOptionState::get_show_file_properties(const fslib::Path &path)
|
|||
const std::string pathString = path.string();
|
||||
const std::string sizeString = get_size_string(fileSize);
|
||||
const std::string message = stringutil::get_formatted_string(messageFormat,
|
||||
pathString.c_str(),
|
||||
sizeString.c_str(),
|
||||
createdBuffer,
|
||||
lastModified,
|
||||
lastAccessed);
|
||||
pathString.c_str(),
|
||||
sizeString.c_str(),
|
||||
createdBuffer,
|
||||
lastModified,
|
||||
lastAccessed);
|
||||
|
||||
MessageState::create_and_push(message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
#include "appstates/TitleSelectState.hpp"
|
||||
#include "appstates/UserOptionState.hpp"
|
||||
#include "config/config.hpp"
|
||||
#include "graphics/ScopedRender.hpp"
|
||||
#include "graphics/colors.hpp"
|
||||
#include "input.hpp"
|
||||
#include "logging/logger.hpp"
|
||||
#include "remote/remote.hpp"
|
||||
#include "sdl.hpp"
|
||||
|
|
@ -21,18 +21,32 @@
|
|||
#include "tasks/update.hpp"
|
||||
#include "ui/PopMessageManager.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
// Main menu render target.
|
||||
constexpr std::string_view TARGET = "MainMenuTarget";
|
||||
constexpr int TARGET_WIDTH = 200;
|
||||
constexpr int TARGET_HEIGHT = 555;
|
||||
|
||||
// Background.
|
||||
constexpr std::string_view MAIN_BG = "romfs:/Textures/MenuBackground.png";
|
||||
constexpr std::string_view SETT_ICON = "romfs:/Textures/SettingsIcon.png";
|
||||
constexpr std::string_view EXTRA_ICON = "romfs:/Textures/ExtrasIcon.png";
|
||||
|
||||
}
|
||||
|
||||
// ---- Construction ----
|
||||
|
||||
MainMenuState::MainMenuState()
|
||||
: m_renderTarget(sdl::TextureManager::load("mainMenuTarget", 200, 555, SDL_TEXTUREACCESS_TARGET))
|
||||
, m_background(sdl::TextureManager::load("mainBackground", "romfs:/Textures/MenuBackground.png"))
|
||||
, m_settingsIcon(sdl::TextureManager::load("settingsIcon", "romfs:/Textures/SettingsIcon.png"))
|
||||
, m_extrasIcon(sdl::TextureManager::load("extrasIcon", "romfs:/Textures/ExtrasIcon.png"))
|
||||
MainMenuState::MainMenuState(sdl2::Renderer &renderer)
|
||||
: m_renderTarget(sdl2::TextureManager::create_load_resource(TARGET, TARGET_WIDTH, TARGET_HEIGHT, SDL_TEXTUREACCESS_TARGET))
|
||||
, m_background(sdl2::TextureManager::create_load_resource(MAIN_BG, MAIN_BG))
|
||||
, m_settingsIcon(sdl2::TextureManager::create_load_resource(SETT_ICON, SETT_ICON))
|
||||
, m_extrasIcon(sdl2::TextureManager::create_load_resource(EXTRA_ICON, EXTRA_ICON))
|
||||
, m_mainMenu(ui::IconMenu::create(50, 15, 555))
|
||||
, m_controlGuide(ui::ControlGuide::create(strings::get_by_name(strings::names::CONTROL_GUIDES, 0)))
|
||||
, m_dataStruct(std::make_shared<MainMenuState::DataStruct>())
|
||||
{
|
||||
MainMenuState::initialize_settings_extras();
|
||||
MainMenuState::initialize_settings_extras(renderer);
|
||||
MainMenuState::initialize_menu();
|
||||
MainMenuState::initialize_view_states();
|
||||
MainMenuState::initialize_data_struct();
|
||||
|
|
@ -41,14 +55,17 @@ MainMenuState::MainMenuState()
|
|||
|
||||
// ---- Public functions ----
|
||||
|
||||
void MainMenuState::update()
|
||||
void MainMenuState::update(const sdl2::Input &input)
|
||||
{
|
||||
const int selected = m_mainMenu->get_selected();
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
const bool aPressed = input::button_pressed(HidNpadButton_A);
|
||||
const bool xPressed = input::button_pressed(HidNpadButton_X);
|
||||
const bool yPressed = input::button_pressed(HidNpadButton_Y);
|
||||
|
||||
// Input
|
||||
const bool aPressed = input.button_pressed(HidNpadButton_A);
|
||||
const bool xPressed = input.button_pressed(HidNpadButton_X);
|
||||
const bool yPressed = input.button_pressed(HidNpadButton_Y);
|
||||
|
||||
// Whether or not to open the options targeting users.
|
||||
const bool toUserOptions = xPressed && selected < sm_userCount;
|
||||
|
||||
if (aPressed) { MainMenuState::push_target_state(); }
|
||||
|
|
@ -60,28 +77,38 @@ void MainMenuState::update()
|
|||
MainMenuState::confirm_update();
|
||||
}
|
||||
|
||||
m_mainMenu->update(hasFocus);
|
||||
m_controlGuide->update(hasFocus);
|
||||
m_mainMenu->update(input, hasFocus);
|
||||
m_controlGuide->update(input, hasFocus);
|
||||
|
||||
for (auto &state : sm_states) { state->sub_update(); }
|
||||
}
|
||||
|
||||
void MainMenuState::sub_update() { m_controlGuide->sub_update(); }
|
||||
|
||||
void MainMenuState::render()
|
||||
void MainMenuState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
const int selected = m_mainMenu->get_selected();
|
||||
|
||||
m_background->render(m_renderTarget, 0, 0);
|
||||
m_mainMenu->render(m_renderTarget, hasFocus);
|
||||
m_renderTarget->render(sdl::Texture::Null, 0, 91);
|
||||
m_controlGuide->render(sdl::Texture::Null, hasFocus);
|
||||
{
|
||||
// Switch target.
|
||||
graphics::ScopedRender scopedRender{renderer, m_renderTarget};
|
||||
renderer.frame_begin(colors::CLEAR_COLOR);
|
||||
|
||||
// Render background and menu.
|
||||
m_background->render(0, 0);
|
||||
m_mainMenu->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
// Main FB stuff.
|
||||
m_renderTarget->render(0, 91);
|
||||
m_controlGuide->render(renderer, hasFocus);
|
||||
|
||||
// If we have focus, render the state we're hovering.
|
||||
if (hasFocus)
|
||||
{
|
||||
BaseState *target = sm_states[selected].get();
|
||||
target->render();
|
||||
target->render(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +124,10 @@ void MainMenuState::initialize_view_states()
|
|||
std::shared_ptr<BaseState> state{};
|
||||
|
||||
if (jksmMode) { state = TextTitleSelectState::create(user); }
|
||||
else { state = TitleSelectState::create(user); }
|
||||
else
|
||||
{
|
||||
state = TitleSelectState::create(user);
|
||||
}
|
||||
|
||||
sm_states.push_back(state);
|
||||
}
|
||||
|
|
@ -116,12 +146,12 @@ void MainMenuState::refresh_view_states()
|
|||
|
||||
// ---- Private functions ----
|
||||
|
||||
void MainMenuState::initialize_settings_extras()
|
||||
void MainMenuState::initialize_settings_extras(sdl2::Renderer &renderer)
|
||||
{
|
||||
if (!sm_settingsState || !sm_extrasState)
|
||||
{
|
||||
sm_settingsState = SettingsState::create();
|
||||
sm_extrasState = ExtrasMenuState::create();
|
||||
sm_extrasState = ExtrasMenuState::create(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -186,7 +216,10 @@ void MainMenuState::backup_all_for_all()
|
|||
{
|
||||
ConfirmProgress::create_push_fade(query, true, tasks::mainmenu::backup_all_for_all_remote, nullptr, m_dataStruct);
|
||||
}
|
||||
else { ConfirmProgress::create_push_fade(query, true, tasks::mainmenu::backup_all_for_all_local, nullptr, m_dataStruct); }
|
||||
else
|
||||
{
|
||||
ConfirmProgress::create_push_fade(query, true, tasks::mainmenu::backup_all_for_all_local, nullptr, m_dataStruct);
|
||||
}
|
||||
}
|
||||
|
||||
void MainMenuState::confirm_update()
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
#include "StateManager.hpp"
|
||||
#include "appstates/FadeState.hpp"
|
||||
#include "graphics/colors.hpp"
|
||||
#include "graphics/fonts.hpp"
|
||||
#include "graphics/screen.hpp"
|
||||
#include "input.hpp"
|
||||
#include "mathutil.hpp"
|
||||
#include "strings/strings.hpp"
|
||||
|
||||
namespace
|
||||
|
|
@ -55,45 +56,57 @@ MessageState::MessageState(std::string &message)
|
|||
|
||||
// ---- Public functions ----
|
||||
|
||||
void MessageState::update()
|
||||
void MessageState::update(const sdl2::Input &input)
|
||||
{
|
||||
switch (m_state)
|
||||
{
|
||||
case State::Opening:
|
||||
case State::Closing: MessageState::update_dimensions(); break;
|
||||
case State::Displaying: MessageState::update_handle_input(); break;
|
||||
case State::Displaying: MessageState::update_handle_input(input); break;
|
||||
}
|
||||
}
|
||||
|
||||
void MessageState::render()
|
||||
void MessageState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
// This is were to render
|
||||
static constexpr int y = 229;
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
sdl::render_rect_fill(sdl::Texture::Null, 0, 0, graphics::SCREEN_WIDTH, graphics::SCREEN_HEIGHT, colors::DIM_BACKGROUND);
|
||||
sm_dialog->render(sdl::Texture::Null, hasFocus);
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
// Dim the background and render the dialog. Only continue if we're fully open.
|
||||
renderer.render_rectangle(0, 0, graphics::SCREEN_WIDTH, graphics::SCREEN_HEIGHT, colors::DIM_BACKGROUND);
|
||||
sm_dialog->render(renderer, hasFocus);
|
||||
if (!m_transition.in_place()) { return; }
|
||||
|
||||
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);
|
||||
sm_textFont->render_text_wrapped(312, y + 24, colors::WHITE, 656, m_message);
|
||||
renderer.render_line(280, y + 192, 999, y + 192, colors::DIV_COLOR);
|
||||
sm_optionFont->render_text(sm_okX, y + 214, colors::WHITE, sm_okText);
|
||||
}
|
||||
|
||||
// ---- Private functions ----
|
||||
|
||||
void MessageState::initialize_static_members()
|
||||
{
|
||||
static constexpr int HALF_WIDTH = 640;
|
||||
static constexpr std::string_view POP_SOUND = "ConfirmPop";
|
||||
static constexpr const char *POP_PATH = "romfs:/Sound/ConfirmPop.wav";
|
||||
static constexpr std::string_view CONFIRM_POP = "romfs:/Sound/ConfirmPop.wav";
|
||||
|
||||
if (sm_okText && sm_dialog && sm_dialogPop) { return; }
|
||||
if (sm_okText && sm_dialog && sm_dialogPop && sm_textFont && sm_optionFont) { return; }
|
||||
|
||||
sm_okText = strings::get_by_name(strings::names::YES_NO_OK, 2);
|
||||
sm_okX = HALF_WIDTH - (sdl::text::get_width(22, sm_okText) / 2);
|
||||
sm_dialog = ui::DialogBox::create(0, 0, 0, 0);
|
||||
sm_dialogPop = sdl::SoundManager::load(POP_SOUND, POP_PATH);
|
||||
// This is needed later, so it comes first.
|
||||
sm_textFont = sdl2::FontManager::create_load_resource<sdl2::SystemFont>(graphics::fonts::names::TWENTY_PIXEL,
|
||||
graphics::fonts::sizes::TWENTY_PIXEL);
|
||||
sm_optionFont = sdl2::FontManager::create_load_resource<sdl2::SystemFont>(graphics::fonts::names::THIRTY_TWO_PIXEL,
|
||||
graphics::fonts::sizes::TWENTY_TWO_PIXEL);
|
||||
|
||||
// OK text and X coord.
|
||||
sm_okText = strings::get_by_name(strings::names::YES_NO_OK, 2);
|
||||
sm_okX = math::Util<int>::center_within(graphics::SCREEN_WIDTH, sm_textFont->get_text_width(sm_okText));
|
||||
|
||||
// Dialog.
|
||||
sm_dialog = ui::DialogBox::create(0, 0, 0, 0);
|
||||
sm_dialog->set_from_transition(m_transition, true);
|
||||
|
||||
// Sound to play.
|
||||
sm_dialogPop = sdl2::SoundManager::create_load_resource(CONFIRM_POP, CONFIRM_POP);
|
||||
}
|
||||
|
||||
void MessageState::update_dimensions() noexcept
|
||||
|
|
@ -109,10 +122,10 @@ void MessageState::update_dimensions() noexcept
|
|||
else if (closed) { MessageState::deactivate_state(); }
|
||||
}
|
||||
|
||||
void MessageState::update_handle_input() noexcept
|
||||
void MessageState::update_handle_input(const sdl2::Input &input) noexcept
|
||||
{
|
||||
// Input bools.
|
||||
const bool aPressed = input::button_pressed(HidNpadButton_A);
|
||||
const bool aPressed = input.button_pressed(HidNpadButton_A);
|
||||
|
||||
// Handle the triggerguard.
|
||||
m_triggerGuard = m_triggerGuard || (aPressed && !m_triggerGuard);
|
||||
|
|
|
|||
|
|
@ -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 "stringutil.hpp"
|
||||
|
|
@ -43,17 +44,15 @@ ProgressState::ProgressState(sys::threadpool::JobFunction function, sys::Task::T
|
|||
TARGET_WIDTH,
|
||||
TARGET_HEIGHT,
|
||||
ui::Transition::DEFAULT_THRESHOLD)
|
||||
{
|
||||
initialize_static_members();
|
||||
}
|
||||
{ initialize_static_members(); }
|
||||
|
||||
// ---- Public functions ----
|
||||
|
||||
void ProgressState::update()
|
||||
void ProgressState::update(const sdl2::Input &input)
|
||||
{
|
||||
// These are always updated and aren't conditional.
|
||||
BaseTask::update_loading_glyph();
|
||||
BaseTask::pop_on_plus();
|
||||
BaseTask::pop_on_plus(input);
|
||||
|
||||
switch (m_state)
|
||||
{
|
||||
|
|
@ -63,7 +62,7 @@ void ProgressState::update()
|
|||
}
|
||||
}
|
||||
|
||||
void ProgressState::render()
|
||||
void ProgressState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
static constexpr int RIGHT_EDGE_X = (COORD_BAR_X + SIZE_BAR_WIDTH) - 16;
|
||||
|
||||
|
|
@ -71,51 +70,44 @@ void ProgressState::render()
|
|||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
// This will dim the background.
|
||||
sdl::render_rect_fill(sdl::Texture::Null, 0, 0, graphics::SCREEN_WIDTH, graphics::SCREEN_HEIGHT, colors::DIM_BACKGROUND);
|
||||
renderer.render_rectangle(0, 0, graphics::SCREEN_WIDTH, graphics::SCREEN_HEIGHT, colors::DIM_BACKGROUND);
|
||||
|
||||
// Render the glyph and dialog. Don't render anything else unless the task is running.
|
||||
BaseTask::render_loading_glyph();
|
||||
sm_dialog->render(sdl::Texture::Null, hasFocus);
|
||||
sm_dialog->render(renderer, hasFocus);
|
||||
if (m_state != State::Running) { return; }
|
||||
|
||||
// This just makes this easier to work with.
|
||||
const int barWidth = static_cast<int>(SIZE_BAR_WIDTH);
|
||||
|
||||
// Grab and render the status.
|
||||
const std::string status = m_task->get_status();
|
||||
sdl::text::render(sdl::Texture::Null, 312, 255, BaseTask::FONT_SIZE, 656, colors::WHITE, status);
|
||||
sm_font->render_text(312, 255, colors::WHITE, status);
|
||||
|
||||
// This is the divider line.
|
||||
sdl::render_line(sdl::Texture::Null, 280, 421, 999, 421, colors::DIV_COLOR);
|
||||
renderer.render_line(280, 421, 999, 421, colors::DIV_COLOR);
|
||||
|
||||
// Progress showing bar.
|
||||
sdl::render_rect_fill(sdl::Texture::Null, COORD_BAR_X, COORD_BAR_Y, barWidth, 32, colors::BLACK);
|
||||
sdl::render_rect_fill(sdl::Texture::Null, COORD_BAR_X, COORD_BAR_Y, m_progressBarWidth, 32, colors::BAR_GREEN);
|
||||
renderer.render_rectangle(COORD_BAR_X, COORD_BAR_Y, static_cast<int>(SIZE_BAR_WIDTH), 32, colors::BLACK);
|
||||
renderer.render_rectangle(COORD_BAR_X, COORD_BAR_Y, m_progressBarWidth, 32, colors::BAR_GREEN);
|
||||
|
||||
// These are the "caps" to round the edges of the bar.
|
||||
sm_barEdges->render_part(sdl::Texture::Null, COORD_BAR_X, COORD_BAR_Y, 0, 0, 16, 32);
|
||||
sm_barEdges->render_part(sdl::Texture::Null, RIGHT_EDGE_X, COORD_BAR_Y, 16, 0, 16, 32);
|
||||
sm_barEdges->render_part(COORD_BAR_X, COORD_BAR_Y, 0, 0, 16, 32);
|
||||
sm_barEdges->render_part(RIGHT_EDGE_X, COORD_BAR_Y, 16, 0, 16, 32);
|
||||
|
||||
// Progress string.
|
||||
sdl::text::render(sdl::Texture::Null,
|
||||
m_percentageX,
|
||||
COORD_TEXT_Y,
|
||||
BaseTask::FONT_SIZE,
|
||||
sdl::text::NO_WRAP,
|
||||
colors::WHITE,
|
||||
m_percentageString);
|
||||
sm_font->render_text(m_percentageX, COORD_TEXT_Y, colors::WHITE, m_percentageString);
|
||||
}
|
||||
|
||||
// ---- Private functions ----
|
||||
|
||||
void ProgressState::initialize_static_members()
|
||||
{
|
||||
static constexpr std::string_view BAR_EDGE_NAME = "BarEdges";
|
||||
static constexpr std::string_view BAR_EDGES = "romfs:/Textures/BarEdges/png";
|
||||
|
||||
if (sm_dialog && sm_barEdges) { return; }
|
||||
if (sm_dialog && sm_barEdges && sm_font) { return; }
|
||||
|
||||
sm_dialog = ui::DialogBox::create(0, 0, 0, 0);
|
||||
sm_barEdges = sdl::TextureManager::load(BAR_EDGE_NAME, "romfs:/Textures/BarEdges.png");
|
||||
sm_barEdges = sdl2::TextureManager::create_load_resource(BAR_EDGES, BAR_EDGES);
|
||||
sm_font = sdl2::FontManager::create_load_resource<sdl2::SystemFont>(graphics::fonts::names::TWENTY_PIXEL,
|
||||
graphics::fonts::sizes::TWENTY_PIXEL);
|
||||
sm_dialog->set_from_transition(m_transition, true);
|
||||
}
|
||||
|
||||
|
|
@ -152,9 +144,8 @@ void ProgressState::update_progress() noexcept
|
|||
// This is the actual string that's displayed.
|
||||
m_percentageString = stringutil::get_formatted_string("%u%%", m_progress);
|
||||
|
||||
const int stringWidth = sdl::text::get_width(BaseTask::FONT_SIZE, m_percentageString);
|
||||
// Center the string above.
|
||||
m_percentageX = COORD_DISPLAY_CENTER - (stringWidth / 2);
|
||||
const int stringWidth = sm_font->get_text_width(m_percentageString);
|
||||
m_percentageX = math::Util<int>::center_within(graphics::SCREEN_WIDTH, stringWidth);
|
||||
|
||||
// Handle closing and updating.
|
||||
const bool taskRunning = m_task->is_running();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
#include "data/data.hpp"
|
||||
#include "error.hpp"
|
||||
#include "fs/fs.hpp"
|
||||
#include "input.hpp"
|
||||
#include "keyboard/keyboard.hpp"
|
||||
#include "logging/logger.hpp"
|
||||
#include "strings/strings.hpp"
|
||||
|
|
@ -38,14 +37,14 @@ SaveCreateState::SaveCreateState(data::User *user, TitleSelectCommon *titleSelec
|
|||
|
||||
// ---- Public functions ----
|
||||
|
||||
void SaveCreateState::update()
|
||||
void SaveCreateState::update(const sdl2::Input &input)
|
||||
{
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
sm_slidePanel->update(hasFocus);
|
||||
sm_slidePanel->update(input, hasFocus);
|
||||
|
||||
const bool aPressed = input::button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input::button_pressed(HidNpadButton_B);
|
||||
const bool aPressed = input.button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input.button_pressed(HidNpadButton_B);
|
||||
const bool panelClosed = sm_slidePanel->is_closed();
|
||||
|
||||
if (m_refreshRequired.load())
|
||||
|
|
@ -60,13 +59,12 @@ void SaveCreateState::update()
|
|||
else if (panelClosed) { SaveCreateState::deactivate_state(); }
|
||||
}
|
||||
|
||||
void SaveCreateState::render()
|
||||
void SaveCreateState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
// Clear slide target, render menu, render slide to frame buffer.
|
||||
sm_slidePanel->clear_target();
|
||||
sm_slidePanel->render(sdl::Texture::Null, hasFocus);
|
||||
sm_slidePanel->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
void SaveCreateState::refresh_required() { m_refreshRequired.store(true); }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
#include "appstates/BackupMenuState.hpp"
|
||||
#include "appstates/ConfirmState.hpp"
|
||||
#include "config/config.hpp"
|
||||
#include "input.hpp"
|
||||
#include "strings/strings.hpp"
|
||||
#include "stringutil.hpp"
|
||||
#include "tasks/saveimport.hpp"
|
||||
|
|
@ -20,27 +19,26 @@ SaveImportState::SaveImportState(data::User *user)
|
|||
|
||||
// ---- Public functions ----
|
||||
|
||||
void SaveImportState::update()
|
||||
void SaveImportState::update(const sdl2::Input &input)
|
||||
{
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
sm_slidePanel->update(hasFocus);
|
||||
sm_slidePanel->update(input, hasFocus);
|
||||
if (!sm_slidePanel->is_open()) { return; }
|
||||
|
||||
const bool aPressed = input::button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input::button_pressed(HidNpadButton_B);
|
||||
const bool aPressed = input.button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input.button_pressed(HidNpadButton_B);
|
||||
|
||||
if (aPressed) { SaveImportState::import_backup(); }
|
||||
else if (bPressed) { sm_slidePanel->close(); }
|
||||
else if (sm_slidePanel->is_closed()) { SaveImportState::deactivate_state(); }
|
||||
}
|
||||
|
||||
void SaveImportState::render()
|
||||
void SaveImportState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
sm_slidePanel->clear_target();
|
||||
sm_slidePanel->render(sdl::Texture::Null, hasFocus);
|
||||
sm_slidePanel->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
// ---- Private functions ----
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@
|
|||
#include "error.hpp"
|
||||
#include "fs/fs.hpp"
|
||||
#include "fslib.hpp"
|
||||
#include "graphics/ScopedRender.hpp"
|
||||
#include "graphics/colors.hpp"
|
||||
#include "input.hpp"
|
||||
#include "graphics/targets.hpp"
|
||||
#include "keyboard/keyboard.hpp"
|
||||
#include "logging/logger.hpp"
|
||||
#include "strings/strings.hpp"
|
||||
|
|
@ -72,7 +73,10 @@ namespace
|
|||
SettingsState::SettingsState()
|
||||
: m_settingsMenu(ui::Menu::create(32, 10, 1000, 23, 555))
|
||||
, m_controlGuide(ui::ControlGuide::create(strings::get_by_name(strings::names::CONTROL_GUIDES, 3)))
|
||||
, m_renderTarget(sdl::TextureManager::load(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_TARGET))
|
||||
, m_renderTarget(sdl2::TextureManager::create_load_resource(graphics::targets::names::SECONDARY,
|
||||
graphics::targets::dims::SECONDARY_WIDTH,
|
||||
graphics::targets::dims::SECONDARY_HEIGHT,
|
||||
SDL_TEXTUREACCESS_TARGET))
|
||||
{
|
||||
SettingsState::load_settings_menu();
|
||||
SettingsState::load_extra_strings();
|
||||
|
|
@ -81,33 +85,44 @@ SettingsState::SettingsState()
|
|||
|
||||
// ---- Public functions ----
|
||||
|
||||
void SettingsState::update()
|
||||
void SettingsState::update(const sdl2::Input &input)
|
||||
{
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
const bool aPressed = input::button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input::button_pressed(HidNpadButton_B);
|
||||
const bool xPressed = input::button_pressed(HidNpadButton_X);
|
||||
const bool minusPressed = input::button_pressed(HidNpadButton_Minus);
|
||||
const bool aPressed = input.button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input.button_pressed(HidNpadButton_B);
|
||||
const bool xPressed = input.button_pressed(HidNpadButton_X);
|
||||
const bool minusPressed = input.button_pressed(HidNpadButton_Minus);
|
||||
|
||||
m_settingsMenu->update(hasFocus);
|
||||
m_settingsMenu->update(input, hasFocus);
|
||||
if (aPressed) { SettingsState::toggle_options(); }
|
||||
else if (xPressed) { SettingsState::reset_settings(); }
|
||||
else if (minusPressed) { SettingsState::create_push_description_message(); }
|
||||
else if (bPressed) { BaseState::deactivate(); }
|
||||
|
||||
m_controlGuide->update(hasFocus);
|
||||
m_controlGuide->update(input, hasFocus);
|
||||
}
|
||||
|
||||
void SettingsState::sub_update() { m_controlGuide->sub_update(); }
|
||||
|
||||
void SettingsState::render()
|
||||
void SettingsState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
// Grab focus state.
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
m_renderTarget->clear(colors::TRANSPARENT);
|
||||
m_settingsMenu->render(m_renderTarget, hasFocus);
|
||||
m_renderTarget->render(sdl::Texture::Null, 201, 91);
|
||||
m_controlGuide->render(sdl::Texture::Null, hasFocus);
|
||||
{
|
||||
// Set target and clear.
|
||||
graphics::ScopedRender scopedRender{renderer, m_renderTarget};
|
||||
renderer.frame_begin(colors::TRANSPARENT);
|
||||
|
||||
// Render what we need to.
|
||||
m_settingsMenu->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
// Render the target to the screen.
|
||||
m_renderTarget->render(201, 91);
|
||||
|
||||
// Control guide.
|
||||
m_controlGuide->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
// ---- Private functions ----
|
||||
|
|
@ -194,7 +209,10 @@ void SettingsState::change_working_directory()
|
|||
moved = fs::move_directory_recursively(oldPath, newPath);
|
||||
error::fslib(fslib::delete_directory_recursively(oldPath));
|
||||
}
|
||||
else { moved = fslib::rename_directory(oldPath, newPath); }
|
||||
else
|
||||
{
|
||||
moved = fslib::rename_directory(oldPath, newPath);
|
||||
}
|
||||
|
||||
if (!moved)
|
||||
{
|
||||
|
|
@ -292,7 +310,10 @@ void SettingsState::toggle_trash_folder()
|
|||
config::toggle_by_key(config::keys::ENABLE_TRASH_BIN);
|
||||
|
||||
if (trashEnabled) { error::fslib(fslib::delete_directory_recursively(trashPath)); }
|
||||
else { error::fslib(fslib::create_directory(trashPath)); }
|
||||
else
|
||||
{
|
||||
error::fslib(fslib::create_directory(trashPath));
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsState::cycle_anim_scaling()
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -7,58 +7,63 @@
|
|||
#include "config/config.hpp"
|
||||
#include "fs/save_mount.hpp"
|
||||
#include "fslib.hpp"
|
||||
#include "graphics/ScopedRender.hpp"
|
||||
#include "graphics/colors.hpp"
|
||||
#include "input.hpp"
|
||||
#include "graphics/targets.hpp"
|
||||
#include "logging/logger.hpp"
|
||||
#include "sdl.hpp"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace
|
||||
{
|
||||
// All of these states share this same target.
|
||||
constexpr std::string_view SECONDARY_TARGET = "SecondaryTarget";
|
||||
} // namespace
|
||||
|
||||
// ---- Construction ----
|
||||
|
||||
TextTitleSelectState::TextTitleSelectState(data::User *user)
|
||||
: TitleSelectCommon()
|
||||
, m_user(user)
|
||||
, m_titleSelectMenu(ui::Menu::create(32, 10, 1000, 23, 555))
|
||||
, m_renderTarget(sdl::TextureManager::load(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_TARGET))
|
||||
{
|
||||
TextTitleSelectState::refresh();
|
||||
}
|
||||
, m_renderTarget(sdl2::TextureManager::create_load_resource(graphics::targets::names::SECONDARY,
|
||||
graphics::targets::dims::SECONDARY_WIDTH,
|
||||
graphics::targets::dims::SECONDARY_HEIGHT,
|
||||
SDL_TEXTUREACCESS_TARGET))
|
||||
{ TextTitleSelectState::refresh(); }
|
||||
|
||||
// ---- Public functions ----
|
||||
|
||||
void TextTitleSelectState::update()
|
||||
void TextTitleSelectState::update(const sdl2::Input &input)
|
||||
{
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
const bool aPressed = input::button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input::button_pressed(HidNpadButton_B);
|
||||
const bool xPressed = input::button_pressed(HidNpadButton_X);
|
||||
const bool yPressed = input::button_pressed(HidNpadButton_Y);
|
||||
const bool aPressed = input.button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input.button_pressed(HidNpadButton_B);
|
||||
const bool xPressed = input.button_pressed(HidNpadButton_X);
|
||||
const bool yPressed = input.button_pressed(HidNpadButton_Y);
|
||||
|
||||
m_titleSelectMenu->update(hasFocus);
|
||||
m_titleSelectMenu->update(input, hasFocus);
|
||||
|
||||
if (aPressed) { TextTitleSelectState::create_backup_menu(); }
|
||||
else if (xPressed) { TextTitleSelectState::create_title_option_menu(); }
|
||||
else if (yPressed) { TextTitleSelectState::add_remove_favorite(); }
|
||||
else if (bPressed) { BaseState::deactivate(); }
|
||||
|
||||
sm_controlGuide->update(hasFocus);
|
||||
sm_controlGuide->update(input, hasFocus);
|
||||
}
|
||||
|
||||
void TextTitleSelectState::render()
|
||||
void TextTitleSelectState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
// Grab focus.
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
m_renderTarget->clear(colors::TRANSPARENT);
|
||||
m_titleSelectMenu->render(m_renderTarget, hasFocus);
|
||||
sm_controlGuide->render(sdl::Texture::Null, hasFocus);
|
||||
m_renderTarget->render(sdl::Texture::Null, 201, 91);
|
||||
{
|
||||
// Switch targets, clear.
|
||||
graphics::ScopedRender scopedRender{renderer, m_renderTarget};
|
||||
renderer.frame_begin(colors::TRANSPARENT);
|
||||
|
||||
// Render menu to target.
|
||||
m_titleSelectMenu->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
// Switch back, render target and guide.
|
||||
m_renderTarget->render(201, 91);
|
||||
sm_controlGuide->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
void TextTitleSelectState::refresh()
|
||||
|
|
@ -77,7 +82,10 @@ void TextTitleSelectState::refresh()
|
|||
|
||||
std::string option{};
|
||||
if (favorite) { option = std::string{STRING_HEART} + title; }
|
||||
else { option = title; }
|
||||
else
|
||||
{
|
||||
option = title;
|
||||
}
|
||||
|
||||
m_titleSelectMenu->add_option(option);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
#include "error.hpp"
|
||||
#include "fs/save_data_functions.hpp"
|
||||
#include "graphics/colors.hpp"
|
||||
#include "input.hpp"
|
||||
#include "sdl.hpp"
|
||||
#include "strings/strings.hpp"
|
||||
#include "stringutil.hpp"
|
||||
|
|
@ -36,8 +35,8 @@ namespace
|
|||
} // namespace
|
||||
|
||||
// Defined at bottom
|
||||
static inline std::shared_ptr<ui::TextScroll> create_new_field(std::string_view text, int x, int y, sdl::Color clear);
|
||||
static inline std::shared_ptr<ui::TextScroll> create_new_field(std::string &text, int x, int y, sdl::Color clear);
|
||||
static inline std::shared_ptr<ui::TextScroll> create_new_field(std::string_view text, int x, int y, SDL_Color clear);
|
||||
static inline std::shared_ptr<ui::TextScroll> create_new_field(std::string &text, int x, int y, SDL_Color clear);
|
||||
static bool is_a_best_game(uint64_t applicationID) noexcept;
|
||||
|
||||
// ---- Construction ----
|
||||
|
|
@ -65,35 +64,34 @@ TitleInfoState::TitleInfoState(data::User *user, data::TitleInfo *titleInfo, con
|
|||
|
||||
// ---- Public functions ----
|
||||
|
||||
void TitleInfoState::update()
|
||||
void TitleInfoState::update(const sdl2::Input &input)
|
||||
{
|
||||
switch (m_state)
|
||||
{
|
||||
case State::Opening:
|
||||
case State::Closing: TitleInfoState::update_dimensions(); break;
|
||||
case State::Displaying: TitleInfoState::update_handle_input(); break;
|
||||
case State::Displaying: TitleInfoState::update_handle_input(input); break;
|
||||
}
|
||||
}
|
||||
|
||||
void TitleInfoState::render()
|
||||
void TitleInfoState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
// Grab cause needed everywhere.
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
// Render the frame. Only continue further if we're currently displaying.
|
||||
sm_frame->render(sdl::Texture::Null, hasFocus);
|
||||
sm_frame->render(renderer, hasFocus);
|
||||
if (m_state != State::Displaying) { return; }
|
||||
|
||||
// We only want to render what's been triggered so far for the tiling in effect.
|
||||
for (int i = 0; i < m_fieldDisplayCount; i++) { m_infoFields[i]->render(sdl::Texture::Null, hasFocus); }
|
||||
for (int i = 0; i < m_fieldDisplayCount; i++) { m_infoFields[i]->render(renderer, hasFocus); }
|
||||
}
|
||||
|
||||
// ---- Private functions ----
|
||||
|
||||
void TitleInfoState::initialize_static_members()
|
||||
{
|
||||
static constexpr std::string_view CHIME_NAME = "TitleInfoChime";
|
||||
static constexpr const char *CHIME_PATH = "romfs:/Sound/TitleInfo.wav";
|
||||
static constexpr std::string_view CHIME_PATH = "romfs:/Sound/TitleInfo.wav";
|
||||
|
||||
if (sm_frame && sm_openChime)
|
||||
{
|
||||
|
|
@ -106,7 +104,7 @@ void TitleInfoState::initialize_static_members()
|
|||
const int width = m_transition.get_width();
|
||||
const int height = m_transition.get_height();
|
||||
sm_frame = ui::Frame::create(x, y, width, height);
|
||||
sm_openChime = sdl::SoundManager::load(CHIME_NAME, CHIME_PATH);
|
||||
sm_openChime = sdl2::SoundManager::create_load_resource(CHIME_PATH, CHIME_PATH);
|
||||
}
|
||||
|
||||
void TitleInfoState::initialize_info_fields()
|
||||
|
|
@ -166,13 +164,13 @@ void TitleInfoState::create_title(int y)
|
|||
{
|
||||
std::string bestTitle = BESTEST_STAR + " " + title + " " + BESTEST_STAR;
|
||||
field = ui::TextScroll::create(bestTitle,
|
||||
X,
|
||||
y,
|
||||
WIDTH,
|
||||
TITLE_FIELD_HEIGHT,
|
||||
TITLE_FONT_SIZE,
|
||||
colors::WHITE,
|
||||
colors::TRANSPARENT);
|
||||
X,
|
||||
y,
|
||||
WIDTH,
|
||||
TITLE_FIELD_HEIGHT,
|
||||
TITLE_FONT_SIZE,
|
||||
colors::WHITE,
|
||||
colors::TRANSPARENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -377,7 +375,7 @@ void TitleInfoState::update_dimensions() noexcept
|
|||
else if (closed) { TitleInfoState::deactivate_state(); }
|
||||
}
|
||||
|
||||
void TitleInfoState::update_handle_input() noexcept
|
||||
void TitleInfoState::update_handle_input(const sdl2::Input &input) noexcept
|
||||
{
|
||||
// Grab a cache this since it's needed a lot.
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
|
@ -387,14 +385,14 @@ void TitleInfoState::update_handle_input() noexcept
|
|||
if (m_fieldDisplayCount < currentCount && m_timer.is_triggered()) { ++m_fieldDisplayCount; }
|
||||
|
||||
// Update the actually displayed fields so the text scrolls if need be.
|
||||
for (int i = 0; i < m_fieldDisplayCount; i++) { m_infoFields[i]->update(hasFocus); }
|
||||
for (int i = 0; i < m_fieldDisplayCount; i++) { m_infoFields[i]->update(input, hasFocus); }
|
||||
|
||||
// Input bools.
|
||||
const bool bPressed = input::button_pressed(HidNpadButton_B);
|
||||
const bool bPressed = input.button_pressed(HidNpadButton_B);
|
||||
if (bPressed) { TitleInfoState::close(); }
|
||||
}
|
||||
|
||||
inline sdl::Color TitleInfoState::get_field_color() noexcept
|
||||
inline SDL_Color TitleInfoState::get_field_color() noexcept
|
||||
{
|
||||
m_fieldClearSwitch = m_fieldClearSwitch ? false : true;
|
||||
return m_fieldClearSwitch ? colors::DIALOG_DARK : colors::CLEAR_COLOR;
|
||||
|
|
@ -411,15 +409,11 @@ void TitleInfoState::deactivate_state() { BaseState::deactivate(); }
|
|||
|
||||
// ---- Static functions ----
|
||||
|
||||
static inline std::shared_ptr<ui::TextScroll> create_new_field(std::string_view text, int x, int y, sdl::Color clear)
|
||||
{
|
||||
return ui::TextScroll::create(text, x, y, SIZE_FIELD_WIDTH, SIZE_FIELD_HEIGHT, SIZE_FONT, colors::WHITE, clear, false);
|
||||
}
|
||||
static inline std::shared_ptr<ui::TextScroll> create_new_field(std::string_view text, int x, int y, SDL_Color clear)
|
||||
{ return ui::TextScroll::create(text, x, y, SIZE_FIELD_WIDTH, SIZE_FIELD_HEIGHT, SIZE_FONT, colors::WHITE, clear, false); }
|
||||
|
||||
static inline std::shared_ptr<ui::TextScroll> create_new_field(std::string &text, int x, int y, sdl::Color clear)
|
||||
{
|
||||
return ui::TextScroll::create(text, x, y, SIZE_FIELD_WIDTH, SIZE_FIELD_HEIGHT, SIZE_FONT, colors::WHITE, clear, false);
|
||||
}
|
||||
static inline std::shared_ptr<ui::TextScroll> create_new_field(std::string &text, int x, int y, SDL_Color clear)
|
||||
{ return ui::TextScroll::create(text, x, y, SIZE_FIELD_WIDTH, SIZE_FIELD_HEIGHT, SIZE_FONT, colors::WHITE, clear, false); }
|
||||
|
||||
static bool is_a_best_game(uint64_t applicationID) noexcept
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
#include "fs/fs.hpp"
|
||||
#include "fslib.hpp"
|
||||
#include "graphics/colors.hpp"
|
||||
#include "input.hpp"
|
||||
#include "keyboard/keyboard.hpp"
|
||||
#include "logging/logger.hpp"
|
||||
#include "remote/remote.hpp"
|
||||
|
|
@ -58,16 +57,16 @@ TitleOptionState::TitleOptionState(data::User *user,
|
|||
|
||||
// ---- Public functions ----
|
||||
|
||||
void TitleOptionState::update()
|
||||
void TitleOptionState::update(const sdl2::Input &input)
|
||||
{
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
sm_slidePanel->unhide_on_focus(hasFocus);
|
||||
sm_slidePanel->update(hasFocus);
|
||||
sm_slidePanel->update(input, hasFocus);
|
||||
|
||||
const bool isOpen = sm_slidePanel->is_open();
|
||||
const bool aPressed = input::button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input::button_pressed(HidNpadButton_B);
|
||||
const bool aPressed = input.button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input.button_pressed(HidNpadButton_B);
|
||||
const int selected = sm_titleOptionMenu->get_selected();
|
||||
|
||||
if (m_refreshRequired)
|
||||
|
|
@ -103,12 +102,13 @@ void TitleOptionState::update()
|
|||
|
||||
void TitleOptionState::sub_update() { sm_slidePanel->sub_update(); }
|
||||
|
||||
void TitleOptionState::render()
|
||||
void TitleOptionState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
// Grab focus.
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
sm_slidePanel->clear_target();
|
||||
sm_slidePanel->render(sdl::Texture::Null, hasFocus);
|
||||
// Render panel.
|
||||
sm_slidePanel->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
void TitleOptionState::close_on_update() { m_exitRequired = true; }
|
||||
|
|
|
|||
|
|
@ -5,8 +5,9 @@
|
|||
#include "appstates/MainMenuState.hpp"
|
||||
#include "appstates/TitleOptionState.hpp"
|
||||
#include "config/config.hpp"
|
||||
#include "graphics/ScopedRender.hpp"
|
||||
#include "graphics/colors.hpp"
|
||||
#include "input.hpp"
|
||||
#include "graphics/targets.hpp"
|
||||
#include "logging/logger.hpp"
|
||||
#include "sdl.hpp"
|
||||
#include "strings/strings.hpp"
|
||||
|
|
@ -24,21 +25,23 @@ namespace
|
|||
TitleSelectState::TitleSelectState(data::User *user)
|
||||
: TitleSelectCommon()
|
||||
, m_user(user)
|
||||
, m_renderTarget(sdl::TextureManager::load(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_TARGET))
|
||||
, m_renderTarget(sdl2::TextureManager::create_load_resource(graphics::targets::names::SECONDARY,
|
||||
graphics::targets::dims::SECONDARY_WIDTH,
|
||||
graphics::targets::dims::SECONDARY_HEIGHT,
|
||||
SDL_TEXTUREACCESS_TARGET))
|
||||
, m_titleView(ui::TitleView::create(m_user)) {};
|
||||
|
||||
|
||||
// ---- Public functions ----
|
||||
|
||||
void TitleSelectState::update()
|
||||
void TitleSelectState::update(const sdl2::Input &input)
|
||||
{
|
||||
if (!TitleSelectState::title_count_check()) { return; }
|
||||
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
const bool aPressed = input::button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input::button_pressed(HidNpadButton_B);
|
||||
const bool xPressed = input::button_pressed(HidNpadButton_X);
|
||||
const bool yPressed = input::button_pressed(HidNpadButton_Y);
|
||||
const bool aPressed = input.button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input.button_pressed(HidNpadButton_B);
|
||||
const bool xPressed = input.button_pressed(HidNpadButton_X);
|
||||
const bool yPressed = input.button_pressed(HidNpadButton_Y);
|
||||
|
||||
if (aPressed) { TitleSelectState::create_backup_menu(); }
|
||||
else if (xPressed) { TitleSelectState::create_title_option_menu(); }
|
||||
|
|
@ -49,18 +52,26 @@ void TitleSelectState::update()
|
|||
return;
|
||||
}
|
||||
|
||||
m_titleView->update(hasFocus);
|
||||
sm_controlGuide->update(hasFocus);
|
||||
m_titleView->update(input, hasFocus);
|
||||
sm_controlGuide->update(input, hasFocus);
|
||||
}
|
||||
|
||||
void TitleSelectState::render()
|
||||
void TitleSelectState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
// Grab focus status.
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
m_renderTarget->clear(colors::TRANSPARENT);
|
||||
m_titleView->render(m_renderTarget, hasFocus);
|
||||
sm_controlGuide->render(sdl::Texture::Null, hasFocus);
|
||||
m_renderTarget->render(sdl::Texture::Null, 201, 91);
|
||||
{
|
||||
// Set target, clear.
|
||||
graphics::ScopedRender scopedRender{renderer, m_renderTarget};
|
||||
renderer.frame_begin(colors::TRANSPARENT);
|
||||
|
||||
// Render view.
|
||||
m_titleView->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
m_renderTarget->render(201, 91);
|
||||
sm_controlGuide->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
void TitleSelectState::refresh() { m_titleView->refresh(); }
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
#include "error.hpp"
|
||||
#include "fs/fs.hpp"
|
||||
#include "fslib.hpp"
|
||||
#include "input.hpp"
|
||||
#include "logging/logger.hpp"
|
||||
#include "remote/remote.hpp"
|
||||
#include "strings/strings.hpp"
|
||||
|
|
@ -49,15 +48,15 @@ UserOptionState::UserOptionState(data::User *user, TitleSelectCommon *titleSelec
|
|||
|
||||
// ---- Public functions ----
|
||||
|
||||
void UserOptionState::update()
|
||||
void UserOptionState::update(const sdl2::Input &input)
|
||||
{
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
const bool aPressed = input::button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input::button_pressed(HidNpadButton_B);
|
||||
const bool aPressed = input.button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input.button_pressed(HidNpadButton_B);
|
||||
|
||||
// Start by running the unhide check routine and then update the panel.
|
||||
sm_menuPanel->unhide_on_focus(hasFocus);
|
||||
sm_menuPanel->update(hasFocus);
|
||||
sm_menuPanel->update(input, hasFocus);
|
||||
|
||||
// Refresh here if needed to avoid threading issues.
|
||||
if (m_refreshRequired)
|
||||
|
|
@ -86,14 +85,13 @@ void UserOptionState::update()
|
|||
|
||||
void UserOptionState::sub_update() { sm_menuPanel->sub_update(); }
|
||||
|
||||
void UserOptionState::render()
|
||||
void UserOptionState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
// Render target user's title selection screen.
|
||||
m_titleSelect->render();
|
||||
m_titleSelect->render(renderer);
|
||||
|
||||
// Render panel.
|
||||
sm_menuPanel->clear_target();
|
||||
sm_menuPanel->render(sdl::Texture::Null, BaseState::has_focus());
|
||||
sm_menuPanel->render(renderer, BaseState::has_focus());
|
||||
}
|
||||
|
||||
void UserOptionState::refresh_required() { m_refreshRequired = true; }
|
||||
|
|
|
|||
|
|
@ -104,7 +104,8 @@ void data::DataContext::load_application_records(sys::Task *task)
|
|||
NsApplicationRecord record{};
|
||||
|
||||
bool listError{};
|
||||
do {
|
||||
do
|
||||
{
|
||||
listError = error::libnx(nsListApplicationRecord(&record, 1, offset++, &count)) || count <= 0;
|
||||
if (listError) { break; }
|
||||
if (DataContext::title_is_loaded(record.application_id)) { continue; }
|
||||
|
|
@ -217,7 +218,8 @@ bool data::DataContext::read_cache(sys::Task *task)
|
|||
task->set_status(statusLoadingCache);
|
||||
|
||||
NsApplicationControlData controlData{};
|
||||
do {
|
||||
do
|
||||
{
|
||||
const bool dataRead = cacheZip.read(&controlData, SIZE_CTRL_DATA) == SIZE_CTRL_DATA;
|
||||
if (!dataRead) { continue; }
|
||||
|
||||
|
|
@ -270,9 +272,9 @@ bool data::DataContext::write_cache(sys::Task *task)
|
|||
return true;
|
||||
}
|
||||
|
||||
void data::DataContext::process_icon_queue()
|
||||
void data::DataContext::process_icon_queue(sdl2::Renderer &renderer)
|
||||
{
|
||||
std::lock_guard multiGuard{m_iconQueueMutex};
|
||||
for (data::DataCommon *common : m_iconQueue) { common->load_icon(); }
|
||||
for (data::DataCommon *common : m_iconQueue) { common->load_icon(renderer); }
|
||||
m_iconQueue.clear();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ data::TitleInfo::TitleInfo(uint64_t applicationID) noexcept
|
|||
// This will filter from even trying to fetch control data for system titles.
|
||||
const bool isSystem = applicationID & 0x8000000000000000;
|
||||
const bool getError = !isSystem && error::libnx(nsGetApplicationControlData(NsApplicationControlSource_Storage,
|
||||
m_applicationID,
|
||||
&m_data,
|
||||
SIZE_CTRL_DATA,
|
||||
&controlSize));
|
||||
m_applicationID,
|
||||
&m_data,
|
||||
SIZE_CTRL_DATA,
|
||||
&controlSize));
|
||||
const bool entryError = !getError && error::libnx(nacpGetLanguageEntry(&m_data.nacp, &m_entry));
|
||||
if (isSystem || getError)
|
||||
{
|
||||
|
|
@ -149,8 +149,6 @@ bool data::TitleInfo::has_save_data_type(uint8_t saveType) const noexcept
|
|||
return false;
|
||||
}
|
||||
|
||||
sdl::SharedTexture data::TitleInfo::get_icon() const noexcept { return m_icon; }
|
||||
|
||||
void data::TitleInfo::set_path_safe_title(const char *newPathSafe) noexcept
|
||||
{
|
||||
const size_t length = std::char_traits<char>::length(newPathSafe);
|
||||
|
|
@ -160,20 +158,16 @@ void data::TitleInfo::set_path_safe_title(const char *newPathSafe) noexcept
|
|||
std::memcpy(m_pathSafeTitle, newPathSafe, length);
|
||||
}
|
||||
|
||||
void data::TitleInfo::load_icon()
|
||||
void data::TitleInfo::load_icon(sdl2::Renderer &renderer)
|
||||
{
|
||||
// This is taken from the NacpStruct.
|
||||
static constexpr size_t SIZE_ICON = 0x20000;
|
||||
const std::string textureName = stringutil::get_formatted_string("%04X", m_applicationID & 0xFFFF);
|
||||
|
||||
if (m_hasData)
|
||||
{
|
||||
const std::string textureName = stringutil::get_formatted_string("%016llX", m_applicationID);
|
||||
m_icon = sdl::TextureManager::load(textureName, m_data.icon, SIZE_ICON);
|
||||
}
|
||||
if (m_hasData) { m_icon = sdl2::TextureManager::create_load_resource(textureName, m_data.icon, SIZE_ICON); }
|
||||
else
|
||||
{
|
||||
const std::string text = stringutil::get_formatted_string("%04X", m_applicationID & 0xFFFF);
|
||||
m_icon = gfxutil::create_generic_icon(text, 48, colors::DIALOG_DARK, colors::WHITE);
|
||||
m_icon = gfxutil::create_generic_icon(renderer, textureName, 48, colors::DIALOG_DARK, colors::WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,10 @@ data::User::User(AccountUid accountID, FsSaveDataType saveType) noexcept
|
|||
const bool profileError = error::libnx(accountGetProfile(&profile, m_accountID));
|
||||
const bool baseError = !profileError && error::libnx(accountProfileGet(&profile, nullptr, &profileBase));
|
||||
if (profileError || baseError) { User::create_account(); }
|
||||
else { User::load_account(profile, profileBase); }
|
||||
else
|
||||
{
|
||||
User::load_account(profile, profileBase);
|
||||
}
|
||||
accountProfileClose(&profile);
|
||||
}
|
||||
|
||||
|
|
@ -174,7 +177,10 @@ void data::User::load_user_data()
|
|||
{
|
||||
infoReader.open(SAVE_DATA_SPACE_ORDER[i], m_accountID, SIZE_SAVE_INFO_BUFFER);
|
||||
}
|
||||
else { infoReader.open(SAVE_DATA_SPACE_ORDER[i], m_saveType, SIZE_SAVE_INFO_BUFFER); }
|
||||
else
|
||||
{
|
||||
infoReader.open(SAVE_DATA_SPACE_ORDER[i], m_saveType, SIZE_SAVE_INFO_BUFFER);
|
||||
}
|
||||
if (!infoReader.is_open()) { continue; }
|
||||
|
||||
while (infoReader.read())
|
||||
|
|
@ -218,7 +224,7 @@ void data::User::load_user_data()
|
|||
User::sort_data();
|
||||
}
|
||||
|
||||
void data::User::load_icon()
|
||||
void data::User::load_icon(sdl2::Renderer &renderer)
|
||||
{
|
||||
const std::string iconName =
|
||||
stringutil::get_formatted_string("%016llX%016llX", m_nickname, m_accountID.uid[0], m_accountID.uid[1]);
|
||||
|
|
@ -230,7 +236,7 @@ void data::User::load_icon()
|
|||
const bool sizeError = !profileError && error::libnx(accountProfileGetImageSize(&profile, &iconSize));
|
||||
if (profileError || sizeError)
|
||||
{
|
||||
m_icon = gfxutil::create_generic_icon(m_nickname, SIZE_ICON_FONT, colors::DIALOG_DARK, colors::WHITE);
|
||||
m_icon = gfxutil::create_generic_icon(renderer, m_nickname, SIZE_ICON_FONT, colors::DIALOG_DARK, colors::WHITE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -239,9 +245,12 @@ void data::User::load_icon()
|
|||
if (loadError) { return; }
|
||||
|
||||
accountProfileClose(&profile);
|
||||
m_icon = sdl::TextureManager::load(iconName, iconBuffer.get(), iconSize);
|
||||
m_icon = sdl2::TextureManager::create_load_resource(iconName, iconBuffer.get(), iconSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_icon = gfxutil::create_generic_icon(renderer, m_nickname, SIZE_ICON_FONT, colors::DIALOG_DARK, colors::WHITE);
|
||||
}
|
||||
else { m_icon = gfxutil::create_generic_icon(m_nickname, SIZE_ICON_FONT, colors::DIALOG_DARK, colors::WHITE); }
|
||||
}
|
||||
|
||||
void data::User::load_account(AccountProfile &profile, AccountProfileBase &profileBase)
|
||||
|
|
|
|||
|
|
@ -25,21 +25,19 @@ namespace
|
|||
/// @brief The main routine for the task to load data.
|
||||
static void data_initialize_task(sys::threadpool::JobData taskData);
|
||||
|
||||
void data::launch_initialization(bool clearCache, std::function<void()> onDestruction)
|
||||
void data::launch_initialization(bool clearCache, sdl2::Renderer &renderer, std::function<void()> onDestruction)
|
||||
{
|
||||
auto taskData = std::make_shared<StateDataStruct>();
|
||||
taskData->clearCache = clearCache;
|
||||
|
||||
auto loadingState = DataLoadingState::create(s_context, onDestruction, data_initialize_task, taskData);
|
||||
auto loadingState = DataLoadingState::create(s_context, renderer, onDestruction, data_initialize_task, taskData);
|
||||
StateManager::push_state(loadingState);
|
||||
}
|
||||
|
||||
void data::get_users(data::UserList &userList) { s_context.get_users(userList); }
|
||||
|
||||
data::TitleInfo *data::get_title_info_by_id(uint64_t applicationID) noexcept
|
||||
{
|
||||
return s_context.get_title_by_id(applicationID);
|
||||
}
|
||||
{ return s_context.get_title_by_id(applicationID); }
|
||||
|
||||
void data::load_title_to_map(uint64_t applicationID) { s_context.load_title(applicationID); }
|
||||
|
||||
|
|
@ -48,9 +46,7 @@ bool data::title_exists_in_map(uint64_t applicationID) noexcept { return s_conte
|
|||
void data::get_title_info_list(data::TitleInfoList &listOut) { s_context.get_title_info_list(listOut); }
|
||||
|
||||
void data::get_title_info_by_type(FsSaveDataType saveType, data::TitleInfoList &listOut)
|
||||
{
|
||||
s_context.get_title_info_list_by_type(saveType, listOut);
|
||||
}
|
||||
{ s_context.get_title_info_list_by_type(saveType, listOut); }
|
||||
|
||||
static void data_initialize_task(sys::threadpool::JobData taskData)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,28 +1,41 @@
|
|||
#include "graphics/gfxutil.hpp"
|
||||
|
||||
namespace
|
||||
#include "graphics/ScopedRender.hpp"
|
||||
#include "mathutil.hpp"
|
||||
#include "stringutil.hpp"
|
||||
|
||||
sdl2::SharedTexture gfxutil::create_generic_icon(sdl2::Renderer &renderer,
|
||||
std::string_view text,
|
||||
int fontSize,
|
||||
SDL_Color background,
|
||||
SDL_Color textColor)
|
||||
{
|
||||
/// @brief Width of generic icons in pixels.
|
||||
constexpr int SIZE_ICON_WIDTH = 256;
|
||||
// Icon dimensions.
|
||||
static constexpr int ICON_WIDTH = 256;
|
||||
static constexpr int ICON_HEIGHT = 256;
|
||||
|
||||
/// @brief Height of generic icons in pixels.
|
||||
constexpr int SIZE_ICON_HEIGHT = 256;
|
||||
} // namespace
|
||||
// Create a new font to render with.
|
||||
const std::string fontName = stringutil::get_formatted_string("IconFont%i", fontSize);
|
||||
sdl2::SharedFont font = sdl2::FontManager::create_load_resource<sdl2::SystemFont>(fontName, fontSize);
|
||||
|
||||
sdl::SharedTexture gfxutil::create_generic_icon(std::string_view text,
|
||||
int fontSize,
|
||||
sdl::Color background,
|
||||
sdl::Color foreground)
|
||||
{
|
||||
// Create base icon texture.
|
||||
sdl::SharedTexture icon = sdl::TextureManager::load(text, SIZE_ICON_WIDTH, SIZE_ICON_HEIGHT, SDL_TEXTUREACCESS_TARGET);
|
||||
// Center our text.
|
||||
const int textWidth = font->get_text_width(text);
|
||||
const int textX = math::Util<int>::center_within(ICON_WIDTH, textWidth);
|
||||
const int textY = math::Util<int>::center_within(ICON_HEIGHT, fontSize);
|
||||
|
||||
// Get the centered X and Y coordinates.
|
||||
const int textX = (SIZE_ICON_WIDTH / 2) - (sdl::text::get_width(fontSize, text) / 2);
|
||||
const int textY = (SIZE_ICON_HEIGHT / 2) - (fontSize / 2);
|
||||
// Create the icon.
|
||||
sdl2::SharedTexture icon =
|
||||
sdl2::TextureManager::create_load_resource(text, ICON_WIDTH, ICON_HEIGHT, SDL_TEXTUREACCESS_TARGET);
|
||||
|
||||
icon->clear(background);
|
||||
sdl::text::render(icon, textX, textY, fontSize, sdl::text::NO_WRAP, foreground, text);
|
||||
{
|
||||
// Target the icon we just created.
|
||||
graphics::ScopedRender scopedRender(renderer, icon);
|
||||
|
||||
// Render.
|
||||
renderer.frame_begin(background);
|
||||
font->render_text(textX, textY, textColor, text);
|
||||
}
|
||||
|
||||
// Return.
|
||||
return icon;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
#include "input.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
PadState s_gamepad;
|
||||
}
|
||||
|
||||
void input::initialize()
|
||||
{
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
padInitializeDefault(&s_gamepad);
|
||||
}
|
||||
|
||||
void input::update() noexcept { padUpdate(&s_gamepad); }
|
||||
|
||||
bool input::button_pressed(HidNpadButton button) noexcept
|
||||
{
|
||||
return (s_gamepad.buttons_cur & button) && !(s_gamepad.buttons_old & button);
|
||||
}
|
||||
|
||||
bool input::button_held(HidNpadButton button) noexcept
|
||||
{
|
||||
return (s_gamepad.buttons_cur & button) && (s_gamepad.buttons_old & button);
|
||||
}
|
||||
|
||||
bool input::button_released(HidNpadButton button) noexcept
|
||||
{
|
||||
return (s_gamepad.buttons_old & button) && !(s_gamepad.buttons_cur & button);
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
#include "StateManager.hpp"
|
||||
#include "appstates/TaskState.hpp"
|
||||
#include "error.hpp"
|
||||
#include "input.hpp"
|
||||
#include "logging/logger.hpp"
|
||||
#include "remote/GoogleDrive.hpp"
|
||||
#include "remote/WebDav.hpp"
|
||||
|
|
@ -136,10 +135,6 @@ static void drive_sign_in(sys::threadpool::JobData taskData)
|
|||
|
||||
while (std::time(NULL) < expiration && !drive->poll_sign_in(deviceCode))
|
||||
{
|
||||
const bool bPressed = input::button_pressed(HidNpadButton_B);
|
||||
const bool bHeld = input::button_held(HidNpadButton_B);
|
||||
if (bPressed || bHeld) { break; }
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::seconds(pollingInterval));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,21 +16,26 @@ ui::BoundingBox::BoundingBox(int x, int y, int width, int height)
|
|||
, m_y(y)
|
||||
, m_width(width)
|
||||
, m_height(height)
|
||||
{
|
||||
BoundingBox::initialize_static_members();
|
||||
}
|
||||
{ BoundingBox::initialize_static_members(); }
|
||||
|
||||
// ---- Public functions ----
|
||||
|
||||
void ui::BoundingBox::update(bool hasFocus) { m_colorMod.update(); }
|
||||
void ui::BoundingBox::update(const sdl2::Input &input, bool hasFocus) { m_colorMod.update(); }
|
||||
|
||||
void ui::BoundingBox::render(sdl::SharedTexture &target, bool hasFocus)
|
||||
void ui::BoundingBox::render(sdl2::Renderer &renderer, bool hasFocus)
|
||||
{
|
||||
// Sizes of the pieces.
|
||||
static constexpr int CORNER_WIDTH = 8;
|
||||
static constexpr int CORNER_HEIGHT = 8;
|
||||
static constexpr int RECT_WIDTH = 4;
|
||||
static constexpr int RECT_HEIGHT = 4;
|
||||
|
||||
// Set texture color modifier.
|
||||
sm_corners->set_color_mod(m_colorMod);
|
||||
|
||||
const int rightX = (m_x + m_width) - CORNER_WIDTH;
|
||||
const int rightRectX = (m_x + m_width) - RECT_WIDTH;
|
||||
|
||||
// Calculating this all here maker the rest easier.
|
||||
const int rightX = (m_x + m_width) - CORNER_WIDTH;
|
||||
const int rightRectX = (m_x + m_width) - RECT_WIDTH;
|
||||
const int midX = m_x + CORNER_WIDTH;
|
||||
const int midY = m_y + CORNER_HEIGHT;
|
||||
const int midWidth = m_width - (CORNER_WIDTH * 2);
|
||||
|
|
@ -38,16 +43,19 @@ void ui::BoundingBox::render(sdl::SharedTexture &target, bool hasFocus)
|
|||
const int bottomY = (m_y + m_height) - CORNER_HEIGHT;
|
||||
const int bottomRectY = (m_y + m_height) - RECT_HEIGHT;
|
||||
|
||||
sm_corners->render_part(target, m_x, m_y, 0, 0, CORNER_WIDTH, CORNER_HEIGHT);
|
||||
sdl::render_rect_fill(target, midX, m_y, midWidth, RECT_HEIGHT, m_colorMod);
|
||||
sm_corners->render_part(target, rightX, m_y, CORNER_HEIGHT, 0, CORNER_WIDTH, CORNER_HEIGHT);
|
||||
// Top
|
||||
sm_corners->render_part(m_x, m_y, 0, 0, CORNER_WIDTH, CORNER_HEIGHT);
|
||||
renderer.render_rectangle(midX, m_y, midWidth, RECT_HEIGHT, m_colorMod);
|
||||
sm_corners->render_part(rightX, m_y, CORNER_HEIGHT, 0, CORNER_WIDTH, CORNER_HEIGHT);
|
||||
|
||||
// Middle
|
||||
sdl::render_rect_fill(target, m_x, midY, RECT_WIDTH, midHeight, m_colorMod);
|
||||
sdl::render_rect_fill(target, rightRectX, midY, RECT_WIDTH, midHeight, m_colorMod);
|
||||
renderer.render_rectangle(m_x, midY, RECT_WIDTH, midHeight, m_colorMod);
|
||||
renderer.render_rectangle(rightRectX, midY, RECT_WIDTH, midHeight, m_colorMod);
|
||||
|
||||
// Bottom
|
||||
sm_corners->render_part(target, m_x, bottomY, 0, CORNER_HEIGHT, CORNER_WIDTH, CORNER_HEIGHT);
|
||||
sdl::render_rect_fill(target, midX, bottomRectY, midWidth, RECT_HEIGHT, m_colorMod);
|
||||
sm_corners->render_part(target, rightX, bottomY, CORNER_WIDTH, CORNER_HEIGHT, CORNER_WIDTH, CORNER_HEIGHT);
|
||||
sm_corners->render_part(m_x, bottomY, 0, CORNER_HEIGHT, CORNER_WIDTH, CORNER_HEIGHT);
|
||||
renderer.render_rectangle(midX, bottomRectY, midWidth, RECT_HEIGHT, m_colorMod);
|
||||
sm_corners->render_part(rightX, bottomY, CORNER_WIDTH, CORNER_HEIGHT, CORNER_WIDTH, CORNER_HEIGHT);
|
||||
}
|
||||
|
||||
void ui::BoundingBox::set_x(int x) noexcept { m_x = x; }
|
||||
|
|
@ -62,6 +70,9 @@ void ui::BoundingBox::set_height(int height) noexcept { m_height = height; }
|
|||
|
||||
void ui::BoundingBox::initialize_static_members()
|
||||
{
|
||||
// Path to load the corner texture from?
|
||||
static constexpr std::string_view CORNER_PATH = "romfs:/Textures/MenuBounding.png";
|
||||
|
||||
if (sm_corners) { return; }
|
||||
sm_corners = sdl::TextureManager::load("menuCorners", "romfs:/Textures/MenuBounding.png");
|
||||
sm_corners = sdl2::TextureManager::create_load_resource(CORNER_PATH, CORNER_PATH);
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user