diff --git a/include/JKSV.hpp b/include/JKSV.hpp index f7be225..24ddc45 100644 --- a/include/JKSV.hpp +++ b/include/JKSV.hpp @@ -45,6 +45,9 @@ class JKSV /// @brief Stores the build string. std::string m_buildString{}; + /// @brief Sets the system to enable boost mode. + void set_boost_mode(); + /// @brief Initializes fslib and takes care of a few other things. bool initialize_filesystem(); @@ -60,6 +63,12 @@ class JKSV /// @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(); + + /// @brief Renders the base UI. + void render_base(); + /// @brief Exits all services. void exit_services(); }; diff --git a/include/appstates/BackupMenuState.hpp b/include/appstates/BackupMenuState.hpp index bb79bf3..3405d47 100644 --- a/include/appstates/BackupMenuState.hpp +++ b/include/appstates/BackupMenuState.hpp @@ -1,4 +1,5 @@ #pragma once + #include "StateManager.hpp" #include "appstates/BaseState.hpp" #include "data/data.hpp" @@ -171,6 +172,7 @@ class BackupMenuState final : public BaseState /// @brief Performs some operations and then marks the state for purging. void deactivate_state(); + /// @brief Inline. Returns if the user is "system" type. inline bool user_is_system() { const uint8_t saveType = m_user->get_account_save_type(); diff --git a/include/appstates/BaseState.hpp b/include/appstates/BaseState.hpp index 264f013..d00b3a2 100644 --- a/include/appstates/BaseState.hpp +++ b/include/appstates/BaseState.hpp @@ -1,4 +1,5 @@ #pragma once + #include "sdl.hpp" #include diff --git a/include/appstates/MainMenuState.hpp b/include/appstates/MainMenuState.hpp index b2d9364..a5c5084 100644 --- a/include/appstates/MainMenuState.hpp +++ b/include/appstates/MainMenuState.hpp @@ -113,5 +113,6 @@ class MainMenuState final : public BaseState /// @brief Backups up all save data for all users. void backup_all_for_all(); + /// @brief Pushes the update notice and allows the user to select whether or not they want to update JKSV. void confirm_update(); }; diff --git a/romfs/Sound/ConfirmPop.wav b/romfs/Sound/ConfirmPop.wav index 26eae17..abbcddf 100644 Binary files a/romfs/Sound/ConfirmPop.wav and b/romfs/Sound/ConfirmPop.wav differ diff --git a/romfs/Sound/MenuCursor.wav b/romfs/Sound/MenuCursor.wav index 028d732..2ccb1eb 100644 Binary files a/romfs/Sound/MenuCursor.wav and b/romfs/Sound/MenuCursor.wav differ diff --git a/romfs/Sound/PopMessage.wav b/romfs/Sound/PopMessage.wav index 1adfc16..fd183c8 100644 Binary files a/romfs/Sound/PopMessage.wav and b/romfs/Sound/PopMessage.wav differ diff --git a/romfs/Sound/TitleInfo.wav b/romfs/Sound/TitleInfo.wav index 56db9de..aaa84ee 100644 Binary files a/romfs/Sound/TitleInfo.wav and b/romfs/Sound/TitleInfo.wav differ diff --git a/source/JKSV.cpp b/source/JKSV.cpp index e976e54..d1e81a3 100644 --- a/source/JKSV.cpp +++ b/source/JKSV.cpp @@ -43,6 +43,7 @@ namespace } // namespace +// This function allows any service init to be logged with its name without repeating the code. template static bool initialize_service(Result (*function)(Args...), const char *serviceName, Args... args) { @@ -55,41 +56,53 @@ static bool initialize_service(Result (*function)(Args...), const char *serviceN return true; } -// Definition at bottom. -static void finish_initialization(); +// ---- Construction ---- -// This can't really have an initializer list since it sets everything up. JKSV::JKSV() { - appletSetCpuBoostMode(ApmCpuBoostMode_FastLoad); + // Set boost mode first. + JKSV::set_boost_mode(); + + // Nothing in JKSV can really continue without these. ABORT_ON_FAILURE(JKSV::initialize_services()); ABORT_ON_FAILURE(JKSV::initialize_filesystem()); + + // Create the log file if it hasn't been already. logger::initialize(); + + // SDL2 ABORT_ON_FAILURE(JKSV::initialize_sdl()); + // Curl. ABORT_ON_FAILURE(curl::initialize()); + + // Config and input. input::initialize(); config::initialize(); + // These are the strings used in the UI. ABORT_ON_FAILURE(strings::initialize()); // This is fatal now. - const char *translationFormat = strings::get_by_name(strings::names::TRANSLATION, 0); - const char *author = strings::get_by_name(strings::names::TRANSLATION, 1); - m_showTranslationInfo = std::char_traits::compare(author, "NULL", 4) != 0; // This is whether or not to show. - m_translationInfo = stringutil::get_formatted_string(translationFormat, author); - m_buildString = stringutil::get_formatted_string("v. %02d.%02d.%04d", builddate::MONTH, builddate::DAY, builddate::YEAR); - // This needs the config init'd or read to work. JKSV::create_directories(); - sys::threadpool::initialize(); + sys::threadpool::initialize(); // This is the thread pool so JKSV isn't constantly creating and destroying threads. + // Push the remote init. sys::threadpool::push_job(remote::initialize, nullptr); - data::launch_initialization(false, finish_initialization); + + // 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); + + // This isn't required, but why not? FadeState::create_and_push(colors::BLACK, 0xFF, 0x00, nullptr); + // JKSV is now running. sm_isRunning = true; } +// ---- Destruction ---- + JKSV::~JKSV() { sys::threadpool::exit(); @@ -103,6 +116,8 @@ JKSV::~JKSV() appletUnlockExit(); } +// ---- Public functions ---- + bool JKSV::is_running() const noexcept { return sm_isRunning && appletMainLoop(); } void JKSV::update() @@ -121,22 +136,7 @@ void JKSV::render() { sdl::frame_begin(colors::CLEAR_COLOR); - // Top and bottom divider lines. - sdl::render_line(sdl::Texture::Null, 30, 88, 1250, 88, colors::WHITE); - sdl::render_line(sdl::Texture::Null, 30, 648, 1250, 648, colors::WHITE); - // Icon - m_headerIcon->render(sdl::Texture::Null, 66, 27); - // "JKSV" - sdl::text::render(sdl::Texture::Null, 130, 32, 34, sdl::text::NO_WRAP, colors::WHITE, "JKSV"); - - // Translation info in bottom left. - if (m_showTranslationInfo) - { - sdl::text::render(sdl::Texture::Null, 8, 680, 14, sdl::text::NO_WRAP, colors::WHITE, m_translationInfo); - } - // Build date - sdl::text::render(sdl::Texture::Null, 8, 700, 14, sdl::text::NO_WRAP, colors::WHITE, m_buildString); - + JKSV::render_base(); StateManager::render(); ui::PopMessageManager::render(); @@ -145,6 +145,14 @@ void JKSV::render() void JKSV::request_quit() noexcept { sm_isRunning = false; } +// ---- Private functions ---- + +void JKSV::set_boost_mode() +{ + // Log for errors, but not fatal. + error::libnx(appletSetCpuBoostMode(ApmCpuBoostMode_FastLoad)); +} + bool JKSV::initialize_filesystem() { // This needs to be in this specific order @@ -174,10 +182,16 @@ bool JKSV::initialize_services() bool JKSV::initialize_sdl() { + // Initialize SDL, freetype and the system font. bool sdlInit = sdl::initialize("JKSV", 1280, 720); sdlInit = sdlInit && sdl::text::initialize(); + + // Load the icon in the top left. m_headerIcon = sdl::TextureManager::load("headerIcon", "romfs:/Textures/HeaderIcon.png"); + + // Push the color changing characters. JKSV::add_color_chars(); + return sdlInit && m_headerIcon; } @@ -209,6 +223,39 @@ void JKSV::add_color_chars() 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); + const char *author = strings::get_by_name(strings::names::TRANSLATION, 1); + m_showTranslationInfo = std::char_traits::compare(author, "NULL", 4) != 0; // This is whether or not to show. + m_translationInfo = stringutil::get_formatted_string(translationFormat, author); + m_buildString = stringutil::get_formatted_string("v. %02d.%02d.%04d", builddate::MONTH, builddate::DAY, builddate::YEAR); +} + +void JKSV::render_base() +{ + static constexpr std::string_view TITLE_TEXT = "JKSV"; + + // Top and bottom framing lines. + sdl::render_line(sdl::Texture::Null, 30, 88, 1250, 88, colors::WHITE); + sdl::render_line(sdl::Texture::Null, 30, 648, 1250, 648, colors::WHITE); + + // Icon + m_headerIcon->render(sdl::Texture::Null, 66, 27); + + // "JKSV" + sdl::text::render(sdl::Texture::Null, 130, 32, 34, sdl::text::NO_WRAP, colors::WHITE, TITLE_TEXT); + + // Translation info in bottom left. + if (m_showTranslationInfo) + { + sdl::text::render(sdl::Texture::Null, 8, 680, 14, sdl::text::NO_WRAP, colors::WHITE, m_translationInfo); + } + + // Build date + sdl::text::render(sdl::Texture::Null, 8, 700, 14, sdl::text::NO_WRAP, colors::WHITE, m_buildString); +} + void JKSV::exit_services() { nifmExit(); @@ -221,5 +268,3 @@ void JKSV::exit_services() nsExit(); accountExit(); } - -static void finish_initialization() { MainMenuState::create_and_push(); } diff --git a/source/appstates/BackupMenuState.cpp b/source/appstates/BackupMenuState.cpp index 009759d..69ff816 100644 --- a/source/appstates/BackupMenuState.cpp +++ b/source/appstates/BackupMenuState.cpp @@ -21,6 +21,8 @@ #include +// ---- Construction ---- + BackupMenuState::BackupMenuState(data::User *user, data::TitleInfo *titleInfo, const FsSaveDataInfo *saveInfo) : m_user(user) , m_titleInfo(titleInfo) @@ -39,6 +41,8 @@ BackupMenuState::BackupMenuState(data::User *user, data::TitleInfo *titleInfo, c BackupMenuState::refresh(); } +// ---- Public functions ---- + void BackupMenuState::update() { const bool hasFocus = BaseState::has_focus(); @@ -140,6 +144,9 @@ void BackupMenuState::save_data_written() if (!m_saveHasData) { m_saveHasData = true; } } + +// ---- Private functions ---- + void BackupMenuState::initialize_static_members() { if (sm_backupMenu && sm_slidePanel && sm_menuRenderTarget && sm_panelWidth) { return; } diff --git a/source/appstates/BaseState.cpp b/source/appstates/BaseState.cpp index d307432..05e6b0c 100644 --- a/source/appstates/BaseState.cpp +++ b/source/appstates/BaseState.cpp @@ -4,6 +4,7 @@ #include +// ---- Construction ---- BaseState::BaseState(bool isClosable) : m_isClosable(isClosable) { @@ -17,6 +18,8 @@ BaseState::~BaseState() error::libnx(appletEndBlockingHomeButtonShortAndLongPressed()); } +// ---- Public functions ---- + void BaseState::deactivate() { m_isActive = false; } void BaseState::reactivate() { m_isActive = true; } diff --git a/source/appstates/BaseTask.cpp b/source/appstates/BaseTask.cpp index c790fa8..6a1ea1c 100644 --- a/source/appstates/BaseTask.cpp +++ b/source/appstates/BaseTask.cpp @@ -11,11 +11,14 @@ namespace constexpr uint64_t TICKS_GLYPH_TRIGGER = 50; } // namespace +// ---- Construction ---- BaseTask::BaseTask() : BaseState(false) , m_frameTimer(TICKS_GLYPH_TRIGGER) , m_popUnableExit(strings::get_by_name(strings::names::GENERAL_POPS, 0)) {}; +// ---- Public functions ---- + void BaseTask::update_loading_glyph() { m_colorMod.update(); diff --git a/source/appstates/BlacklistEditState.cpp b/source/appstates/BlacklistEditState.cpp index 1b66b59..0cc1fab 100644 --- a/source/appstates/BlacklistEditState.cpp +++ b/source/appstates/BlacklistEditState.cpp @@ -7,6 +7,8 @@ #include "error.hpp" #include "input.hpp" +// ---- Construction ---- + BlacklistEditState::BlacklistEditState() : BaseState() { @@ -16,6 +18,8 @@ BlacklistEditState::BlacklistEditState() BlacklistEditState::refresh_menu(); } +// ---- Public functions ---- + void BlacklistEditState::update() { const bool hasFocus = BaseState::has_focus(); @@ -36,6 +40,8 @@ void BlacklistEditState::render() sm_slidePanel->render(sdl::Texture::Null, hasFocus); } +// ---- Private functions ---- + void BlacklistEditState::initialize_static_members() { if (sm_slidePanel) { return; } diff --git a/source/appstates/DataLoadingState.cpp b/source/appstates/DataLoadingState.cpp index dbfadff..7255d5c 100644 --- a/source/appstates/DataLoadingState.cpp +++ b/source/appstates/DataLoadingState.cpp @@ -8,6 +8,8 @@ namespace constexpr int SCREEN_CENTER = 640; } +// ---- Construction ---- + DataLoadingState::DataLoadingState(data::DataContext &context, DestructFunction destructFunction, sys::threadpool::JobFunction function, @@ -20,6 +22,8 @@ DataLoadingState::DataLoadingState(data::DataContext &context, m_task = std::make_unique(function, taskData); } +// ---- Public functions ---- + void DataLoadingState::update() { BaseTask::update_loading_glyph(); @@ -44,6 +48,8 @@ void DataLoadingState::render() BaseTask::render_loading_glyph(); } +// ---- Private functions ---- + void DataLoadingState::initialize_static_members() { if (sm_jksvIcon) { return; } diff --git a/source/appstates/ExtrasMenuState.cpp b/source/appstates/ExtrasMenuState.cpp index 3972f8d..ad04f34 100644 --- a/source/appstates/ExtrasMenuState.cpp +++ b/source/appstates/ExtrasMenuState.cpp @@ -33,6 +33,8 @@ namespace // Definition at bottom. static void finish_reinitialization(); +// ---- Construction ---- + ExtrasMenuState::ExtrasMenuState() : m_renderTarget(sdl::TextureManager::load(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_TARGET)) , m_controlGuide(ui::ControlGuide::create(strings::get_by_name(strings::names::CONTROL_GUIDES, 5))) @@ -40,6 +42,8 @@ ExtrasMenuState::ExtrasMenuState() ExtrasMenuState::initialize_menu(); } +// ---- Public functions ---- + void ExtrasMenuState::update() { const bool hasFocus = BaseState::has_focus(); @@ -77,6 +81,8 @@ void ExtrasMenuState::render() m_controlGuide->render(sdl::Texture::Null, hasFocus); } +// ---- Private functions ---- + void ExtrasMenuState::initialize_menu() { if (!m_extrasMenu) { m_extrasMenu = ui::Menu::create(32, 10, 1000, 23, 555); } diff --git a/source/appstates/FadeState.cpp b/source/appstates/FadeState.cpp index 9d54232..f8e242a 100644 --- a/source/appstates/FadeState.cpp +++ b/source/appstates/FadeState.cpp @@ -10,6 +10,7 @@ namespace constexpr uint64_t TICKS_TIMER_TRIGGER = 1; } +// ---- Construction ---- FadeState::FadeState(sdl::Color baseColor, uint8_t startAlpha, uint8_t endAlpha, std::shared_ptr nextState) : m_baseColor(baseColor) , m_alpha(startAlpha) @@ -44,6 +45,8 @@ void FadeState::render() sdl::render_rect_fill(sdl::Texture::Null, 0, 0, 1280, 720, fadeColor); } +// ---- Private functions ---- + void FadeState::find_divisor() { m_divisor = math::Util::absolute_distance(m_alpha, m_endAlpha); diff --git a/source/appstates/FileModeState.cpp b/source/appstates/FileModeState.cpp index 5d0606b..34fa3af 100644 --- a/source/appstates/FileModeState.cpp +++ b/source/appstates/FileModeState.cpp @@ -11,6 +11,8 @@ #include +// ---- Construction ---- + FileModeState::FileModeState(std::string_view mountA, std::string_view mountB, int64_t journalSize, bool isSystem) : m_mountA(mountA) , m_mountB(mountB) @@ -24,6 +26,8 @@ FileModeState::FileModeState(std::string_view mountA, std::string_view mountB, i FileModeState::initialize_menus(); } +// ---- Public functions ---- + void FileModeState::update() { m_transition.update(); @@ -78,6 +82,8 @@ void FileModeState::render() sm_renderTarget->render(sdl::Texture::Null, 23, y + 12); } +// ---- Private functions ---- + void FileModeState::initialize_static_members() { static constexpr std::string_view RENDER_TARGET_NAME = "FMRenderTarget"; diff --git a/source/appstates/FileOptionState.cpp b/source/appstates/FileOptionState.cpp index f1cd0dc..de4d661 100644 --- a/source/appstates/FileOptionState.cpp +++ b/source/appstates/FileOptionState.cpp @@ -39,6 +39,8 @@ namespace // Defined at bottom. static std::string get_size_string(int64_t totalSize); +// ---- Construction ---- + FileOptionState::FileOptionState(FileModeState *spawningState) : m_spawningState(spawningState) , m_target(spawningState->m_target) @@ -57,6 +59,8 @@ FileOptionState::FileOptionState(FileModeState *spawningState) FileOptionState::initialize_data_struct(); } +// ---- Public functions ---- + void FileOptionState::update() { m_transition.update(); @@ -117,6 +121,8 @@ void FileOptionState::update_source() { m_updateSource = true; } void FileOptionState::update_destination() { m_updateDest = true; } +// ---- Private functions ---- + void FileOptionState::initialize_static_members() { if (sm_copyMenu && sm_dialog) @@ -430,6 +436,8 @@ void FileOptionState::deactivate_state() BaseState::deactivate(); } +// ---- Static definitions ---- + static std::string get_size_string(int64_t totalSize) { static constexpr int64_t THRESHOLD_BYTES = 0x400; diff --git a/source/appstates/MainMenuState.cpp b/source/appstates/MainMenuState.cpp index a0c077c..6338d07 100644 --- a/source/appstates/MainMenuState.cpp +++ b/source/appstates/MainMenuState.cpp @@ -21,6 +21,8 @@ #include "tasks/update.hpp" #include "ui/PopMessageManager.hpp" +// ---- Construction ---- + MainMenuState::MainMenuState() : m_renderTarget(sdl::TextureManager::load("mainMenuTarget", 200, 555, SDL_TEXTUREACCESS_TARGET)) , m_background(sdl::TextureManager::load("mainBackground", "romfs:/Textures/MenuBackground.png")) @@ -37,6 +39,8 @@ MainMenuState::MainMenuState() MainMenuState::check_for_update(); } +// ---- Public functions ---- + void MainMenuState::update() { const int selected = m_mainMenu->get_selected(); @@ -110,6 +114,8 @@ void MainMenuState::refresh_view_states() } } +// ---- Private functions ---- + void MainMenuState::initialize_settings_extras() { if (!sm_settingsState || !sm_extrasState) diff --git a/source/appstates/MessageState.cpp b/source/appstates/MessageState.cpp index 509b1e1..ca646db 100644 --- a/source/appstates/MessageState.cpp +++ b/source/appstates/MessageState.cpp @@ -6,6 +6,8 @@ #include "input.hpp" #include "strings/strings.hpp" +// ---- Construction ---- + MessageState::MessageState(std::string_view message) : m_message(message) , m_transition(0, 0, 32, 32, 0, 0, 720, 256, ui::Transition::DEFAULT_THRESHOLD) @@ -14,6 +16,8 @@ MessageState::MessageState(std::string_view message) sm_dialogPop->play(); } +// ---- Public functions ---- + void MessageState::update() { m_transition.update(); @@ -43,6 +47,8 @@ void MessageState::render() sdl::text::render(sdl::Texture::Null, sm_okX, y + 214, 22, sdl::text::NO_WRAP, colors::WHITE, sm_okText); } +// ---- Private functions ---- + void MessageState::initialize_static_members() { static constexpr int HALF_WIDTH = 640; diff --git a/source/appstates/ProgressState.cpp b/source/appstates/ProgressState.cpp index 2c6bfd6..2bdc5d4 100644 --- a/source/appstates/ProgressState.cpp +++ b/source/appstates/ProgressState.cpp @@ -21,6 +21,8 @@ namespace constexpr double SIZE_BAR_WIDTH = 688.0f; } +// ---- Construction ---- + ProgressState::ProgressState(sys::threadpool::JobFunction function, sys::Task::TaskData taskData) : m_transition(0, 0, 32, 32, 0, 0, 720, 256, ui::Transition::DEFAULT_THRESHOLD) { @@ -28,6 +30,8 @@ ProgressState::ProgressState(sys::threadpool::JobFunction function, sys::Task::T m_task = std::make_unique(function, taskData); } +// ---- Public functions ---- + void ProgressState::update() { BaseTask::update_loading_glyph(); @@ -80,6 +84,8 @@ void ProgressState::render() m_percentageString); } +// ---- Private functions ---- + void ProgressState::initialize_static_members() { static constexpr std::string_view BAR_EDGE_NAME = "BarEdges"; diff --git a/source/appstates/SaveCreateState.cpp b/source/appstates/SaveCreateState.cpp index ab3cebe..0471084 100644 --- a/source/appstates/SaveCreateState.cpp +++ b/source/appstates/SaveCreateState.cpp @@ -22,6 +22,8 @@ // This is the sorting function. static bool compare_info(data::TitleInfo *infoA, data::TitleInfo *infoB); +// ---- Construction ---- + SaveCreateState::SaveCreateState(data::User *user, TitleSelectCommon *titleSelect) : m_user(user) , m_titleSelect(titleSelect) @@ -34,6 +36,8 @@ SaveCreateState::SaveCreateState(data::User *user, TitleSelectCommon *titleSelec SaveCreateState::initialize_data_struct(); } +// ---- Public functions ---- + void SaveCreateState::update() { const bool hasFocus = BaseState::has_focus(); @@ -67,6 +71,8 @@ void SaveCreateState::render() void SaveCreateState::refresh_required() { m_refreshRequired.store(true); } +// ---- Private functions ---- + void SaveCreateState::initialize_static_members() { if (!sm_slidePanel) { sm_slidePanel = std::make_unique(640, ui::SlideOutPanel::Side::Right); } @@ -130,6 +136,8 @@ void SaveCreateState::deactivate_state() BaseState::deactivate(); } +// ---- Static functions ---- + static bool compare_info(data::TitleInfo *infoA, data::TitleInfo *infoB) { // Get pointers to both titles. diff --git a/source/appstates/SaveImportState.cpp b/source/appstates/SaveImportState.cpp index 5d009de..60c8e29 100644 --- a/source/appstates/SaveImportState.cpp +++ b/source/appstates/SaveImportState.cpp @@ -8,6 +8,8 @@ #include "stringutil.hpp" #include "tasks/saveimport.hpp" +// ---- Construction ---- + SaveImportState::SaveImportState(data::User *user) : m_user(user) , m_saveDir() @@ -16,6 +18,8 @@ SaveImportState::SaveImportState(data::User *user) SaveImportState::initialize_directory_menu(); } +// ---- Public functions ---- + void SaveImportState::update() { const bool hasFocus = BaseState::has_focus(); @@ -39,6 +43,8 @@ void SaveImportState::render() sm_slidePanel->render(sdl::Texture::Null, hasFocus); } +// ---- Private functions ---- + void SaveImportState::initialize_static_members() { static constexpr int SIZE_PANEL_WIDTH = 512; diff --git a/source/appstates/SettingsState.cpp b/source/appstates/SettingsState.cpp index c29daf7..d62c269 100644 --- a/source/appstates/SettingsState.cpp +++ b/source/appstates/SettingsState.cpp @@ -63,6 +63,8 @@ namespace CONFIG_KEY_NULL}; } // namespace +// ---- Construction ---- + 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))) @@ -73,6 +75,8 @@ SettingsState::SettingsState() SettingsState::update_menu_options(); } +// ---- Public functions ---- + void SettingsState::update() { const bool hasFocus = BaseState::has_focus(); @@ -102,6 +106,8 @@ void SettingsState::render() m_controlGuide->render(sdl::Texture::Null, hasFocus); } +// ---- Private functions ---- + void SettingsState::load_settings_menu() { for (int i = 0; const char *option = strings::get_by_name(strings::names::SETTINGS_MENU, i); i++) @@ -184,7 +190,9 @@ 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) { @@ -282,7 +290,9 @@ 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() diff --git a/source/appstates/TaskState.cpp b/source/appstates/TaskState.cpp index 9eb16ab..4906ea9 100644 --- a/source/appstates/TaskState.cpp +++ b/source/appstates/TaskState.cpp @@ -7,11 +7,15 @@ #include "strings/strings.hpp" #include "ui/PopMessageManager.hpp" +// ---- Construction ---- + TaskState::TaskState(sys::threadpool::JobFunction function, sys::Task::TaskData taskData) { m_task = std::make_unique(function, taskData); } +// ---- Public functions ---- + void TaskState::update() { BaseTask::pop_on_plus(); diff --git a/source/appstates/TextTitleSelectState.cpp b/source/appstates/TextTitleSelectState.cpp index 5bee565..0516854 100644 --- a/source/appstates/TextTitleSelectState.cpp +++ b/source/appstates/TextTitleSelectState.cpp @@ -20,6 +20,8 @@ namespace constexpr std::string_view SECONDARY_TARGET = "SecondaryTarget"; } // namespace +// ---- Construction ---- + TextTitleSelectState::TextTitleSelectState(data::User *user) : TitleSelectCommon() , m_user(user) @@ -29,6 +31,8 @@ TextTitleSelectState::TextTitleSelectState(data::User *user) TextTitleSelectState::refresh(); } +// ---- Public functions ---- + void TextTitleSelectState::update() { const bool hasFocus = BaseState::has_focus(); @@ -79,6 +83,8 @@ void TextTitleSelectState::refresh() } } +// ---- Private functions ---- + void TextTitleSelectState::create_backup_menu() { const int selected = m_titleSelectMenu->get_selected(); diff --git a/source/appstates/TitleInfoState.cpp b/source/appstates/TitleInfoState.cpp index 0f25607..4be4eb4 100644 --- a/source/appstates/TitleInfoState.cpp +++ b/source/appstates/TitleInfoState.cpp @@ -40,6 +40,8 @@ static inline std::shared_ptr create_new_field(std::string_view static inline std::shared_ptr create_new_field(std::string &text, int x, int y, sdl::Color clear); static bool is_a_best_game(uint64_t applicationID) noexcept; +// ---- Construction ---- + TitleInfoState::TitleInfoState(data::User *user, data::TitleInfo *titleInfo, const FsSaveDataInfo *saveInfo) : m_user(user) , m_titleInfo(titleInfo) @@ -60,6 +62,8 @@ TitleInfoState::TitleInfoState(data::User *user, data::TitleInfo *titleInfo, con sm_openChime->play(); } +// ---- Public functions ---- + void TitleInfoState::update() { // Grab this instead of calling the function over and over. @@ -94,6 +98,8 @@ void TitleInfoState::render() } } +// ---- Private functions ---- + void TitleInfoState::initialize_static_members() { static constexpr std::string_view CHIME_NAME = "TitleInfoChime"; @@ -395,6 +401,8 @@ void TitleInfoState::close() noexcept void TitleInfoState::deactivate_state() { BaseState::deactivate(); } +// ---- Static functions ---- + static inline std::shared_ptr 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); @@ -425,4 +433,4 @@ static bool is_a_best_game(uint64_t applicationID) noexcept 0x0100AC20128AC000}; return std::find(BESTEST_GAMES.begin(), BESTEST_GAMES.end(), applicationID) != BESTEST_GAMES.end(); -} \ No newline at end of file +} diff --git a/source/appstates/TitleOptionState.cpp b/source/appstates/TitleOptionState.cpp index 19cb5f0..a0d2af0 100644 --- a/source/appstates/TitleOptionState.cpp +++ b/source/appstates/TitleOptionState.cpp @@ -40,6 +40,8 @@ namespace }; } // namespace +// ---- Construction ---- + TitleOptionState::TitleOptionState(data::User *user, data::TitleInfo *titleInfo, const FsSaveDataInfo *saveInfo, @@ -54,6 +56,8 @@ TitleOptionState::TitleOptionState(data::User *user, TitleOptionState::initialize_data_struct(); } +// ---- Public functions ---- + void TitleOptionState::update() { const bool hasFocus = BaseState::has_focus(); @@ -110,6 +114,8 @@ void TitleOptionState::close_on_update() { m_exitRequired = true; } void TitleOptionState::refresh_required() { m_refreshRequired = true; } +// ---- Private functions ---- + void TitleOptionState::initialize_static_members() { if (sm_slidePanel && sm_titleOptionMenu) { return; } diff --git a/source/appstates/TitleSelectCommon.cpp b/source/appstates/TitleSelectCommon.cpp index 2c3f752..18808f8 100644 --- a/source/appstates/TitleSelectCommon.cpp +++ b/source/appstates/TitleSelectCommon.cpp @@ -4,13 +4,19 @@ #include "sdl.hpp" #include "strings/strings.hpp" +// ---- Construction ---- + TitleSelectCommon::TitleSelectCommon() { TitleSelectCommon::initialize_control_guide(); } +// ---- Public functions ---- + void TitleSelectCommon::sub_update() { sm_controlGuide->sub_update(); } +// ---- Private functions ---- + void TitleSelectCommon::initialize_control_guide() { if (sm_controlGuide) { return; } sm_controlGuide = ui::ControlGuide::create(strings::get_by_name(strings::names::CONTROL_GUIDES, 1)); -} \ No newline at end of file +} diff --git a/source/appstates/TitleSelectState.cpp b/source/appstates/TitleSelectState.cpp index 54489d9..be7c8f5 100644 --- a/source/appstates/TitleSelectState.cpp +++ b/source/appstates/TitleSelectState.cpp @@ -19,12 +19,17 @@ namespace constexpr std::string_view SECONDARY_TARGET = "SecondaryTarget"; } // namespace +// ---- Construction ---- + TitleSelectState::TitleSelectState(data::User *user) : TitleSelectCommon() , m_user(user) , m_renderTarget(sdl::TextureManager::load(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_TARGET)) , m_titleView(ui::TitleView::create(m_user)) {}; + +// ---- Public functions ---- + void TitleSelectState::update() { if (!TitleSelectState::title_count_check()) { return; } @@ -60,6 +65,8 @@ void TitleSelectState::render() void TitleSelectState::refresh() { m_titleView->refresh(); } +// ---- Private functions ---- + bool TitleSelectState::title_count_check() { const int titleCount = m_user->get_total_data_entries(); diff --git a/source/appstates/UserOptionState.cpp b/source/appstates/UserOptionState.cpp index 666a122..1b46a3c 100644 --- a/source/appstates/UserOptionState.cpp +++ b/source/appstates/UserOptionState.cpp @@ -34,6 +34,8 @@ namespace }; } // namespace +// ---- Construction ---- + UserOptionState::UserOptionState(data::User *user, TitleSelectCommon *titleSelect) : m_user(user) , m_titleSelect(titleSelect) @@ -45,6 +47,8 @@ UserOptionState::UserOptionState(data::User *user, TitleSelectCommon *titleSelec UserOptionState::initialize_data_struct(); } +// ---- Public functions ---- + void UserOptionState::update() { const bool hasFocus = BaseState::has_focus(); @@ -91,6 +95,8 @@ void UserOptionState::render() void UserOptionState::refresh_required() { m_refreshRequired = true; } +// ---- Private functions ---- + void UserOptionState::create_menu_panel() { static constexpr int SIZE_PANEL_WIDTH = 480; diff --git a/source/cmdargs.cpp b/source/cmdargs.cpp index 0b306f0..417743f 100644 --- a/source/cmdargs.cpp +++ b/source/cmdargs.cpp @@ -4,6 +4,7 @@ namespace { + /// @brief Stores pointers to the arguments passed to JKSV. std::vector s_args{}; }