diff --git a/.clang-format b/.clang-format index e58ed9e..8b5ab5e 100644 --- a/.clang-format +++ b/.clang-format @@ -49,7 +49,7 @@ BreakConstructorInitializersBeforeComma: false BreakConstructorInitializers: BeforeColon BreakAfterJavaFieldAnnotations: false BreakStringLiterals: true -ColumnLimit: 144 +ColumnLimit: 120 CommentPragmas: '^ IWYU pragma:' CompactNamespaces: false ConstructorInitializerAllOnOneLineOrOnePerLine: false diff --git a/Makefile b/Makefile index a1ae85a..c5466c8 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ ICON := icon.jpg ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE CFLAGS := $(INCLUDE) -D__SWITCH__ `sdl2-config --cflags` `freetype-config --cflags` \ - `curl-config --cflags` -g -Wall -Werror -O2 -ffunction-sections -ffast-math \ + `curl-config --cflags` -g -Wall -O2 -ffunction-sections -ffast-math \ $(ARCH) $(DEFINES) CXXFLAGS:= $(CFLAGS) -fno-rtti -fno-exceptions -std=c++23 diff --git a/include/JKSV.hpp b/include/JKSV.hpp index 77f39b1..e2d5407 100644 --- a/include/JKSV.hpp +++ b/include/JKSV.hpp @@ -16,7 +16,7 @@ class JKSV /// @brief Returns if initializing was successful and JKSV is running. /// @return True or false. - bool isRunning(void) const; + bool is_running(void) const; /// @brief Runs JKSV's update routine. void update(void); @@ -26,7 +26,7 @@ class JKSV /// @brief Pushes a new state to JKSV's state vector. /// @param newState State to push to vector. - static void pushState(std::shared_ptr newState); + static void push_state(std::shared_ptr newState); private: /// @brief Whether or not initialization was successful and JKSV is still running. @@ -38,5 +38,5 @@ class JKSV /// @brief Vector of states to update and render. static inline std::vector> sm_stateVector; /// @brief Purges and updates states in sm_stateVector. - static void updateStateVector(void); + static void update_state_vector(void); }; diff --git a/include/JSON.hpp b/include/JSON.hpp index 6b09ff3..5de0673 100644 --- a/include/JSON.hpp +++ b/include/JSON.hpp @@ -9,7 +9,7 @@ namespace json // Use this instead of json_object_from_x. Pass the function and its arguments instead. template - static inline json::Object newObject(json_object *(*function)(Args...), Args... args) + static inline json::Object new_object(json_object *(*function)(Args...), Args... args) { return json::Object((*function)(args...), json_object_put); } diff --git a/include/appstates/AppState.hpp b/include/appstates/AppState.hpp index 2bc3dd9..59c3e18 100644 --- a/include/appstates/AppState.hpp +++ b/include/appstates/AppState.hpp @@ -26,21 +26,21 @@ class AppState /// @brief Returns if the state is still active. /// @return Whether state is still active or can be purged. - bool isActive(void) const; + bool is_active(void) const; /// @brief Tells the state it's at the back of the vector and has focus. - void giveFocus(void); + void give_focus(void); /// @brief Takes the focus away and tells the state it's no long back(); - void takeFocus(void); + void take_focus(void); /// @brief Allows the state to know whether it has focus. /// @return Whether state has focus or not. - bool hasFocus(void) const; + bool has_focus(void) const; /// @brief Returns whether or not JKSV should allow closing while state is active. /// @return True if closable. False if not. - bool isClosable(void) const; + bool is_closable(void) const; private: /// @brief Stores whether or not the state is currently active. diff --git a/include/appstates/BackupMenuState.hpp b/include/appstates/BackupMenuState.hpp index e4f1caf..efb477d 100644 --- a/include/appstates/BackupMenuState.hpp +++ b/include/appstates/BackupMenuState.hpp @@ -31,7 +31,7 @@ class BackupMenuState : public AppState void refresh(void); /// @brief Allows a spawned task to tell this class that it wrote save data to the system. - void saveDataWritten(void); + void save_data_written(void); private: /// @brief Pointer to current user. diff --git a/include/appstates/ConfirmState.hpp b/include/appstates/ConfirmState.hpp index 7cf8d13..157e49a 100644 --- a/include/appstates/ConfirmState.hpp +++ b/include/appstates/ConfirmState.hpp @@ -35,13 +35,17 @@ class ConfirmState : public AppState /// @param holdRequired Whether or not confirmation requires holding A for three seconds. /// @param function Function executed on confirmation. /// @param dataStruct shared_ptr that is passed to function. I tried templating this and it was a nightmare. - ConfirmState(std::string_view queryString, bool holdRequired, TaskFunction function, std::shared_ptr dataStruct) - : AppState(false), m_queryString(queryString.data()), m_yesString(strings::getByName(strings::names::YES_NO, 0)), - m_hold(holdRequired), m_function(function), m_dataStruct(dataStruct) + ConfirmState(std::string_view queryString, + bool holdRequired, + TaskFunction function, + std::shared_ptr dataStruct) + : AppState(false), m_queryString(queryString.data()), + m_yesString(strings::get_by_name(strings::names::YES_NO, 0)), m_hold(holdRequired), m_function(function), + m_dataStruct(dataStruct) { // This is to make centering the Yes [A] string more accurate. m_yesX = YES_X_CENTER_COORDINATE - (sdl::text::getWidth(22, m_yesString.c_str()) / 2); - m_noX = 820 - (sdl::text::getWidth(22, strings::getByName(strings::names::YES_NO, 1)) / 2); + m_noX = 820 - (sdl::text::getWidth(22, strings::get_by_name(strings::names::YES_NO, 1)) / 2); } /// @brief Required even if it does nothing. @@ -51,23 +55,23 @@ class ConfirmState : public AppState void update(void) { // This is to guard against the dialog being triggered right away. To do: Maybe figure out a better way to accomplish this? - if (input::buttonPressed(HidNpadButton_A) && !m_triggerGuard) + if (input::button_pressed(HidNpadButton_A) && !m_triggerGuard) { m_triggerGuard = true; } - if (m_triggerGuard && input::buttonPressed(HidNpadButton_A) && !m_hold) + if (m_triggerGuard && input::button_pressed(HidNpadButton_A) && !m_hold) { AppState::deactivate(); - JKSV::pushState(std::make_shared(m_function, m_dataStruct)); + JKSV::push_state(std::make_shared(m_function, m_dataStruct)); } - else if (m_triggerGuard && input::buttonPressed(HidNpadButton_A) && m_hold) + else if (m_triggerGuard && input::button_pressed(HidNpadButton_A) && m_hold) { // Get the starting tick count and change the Yes string to the first holding string. m_startingTickCount = SDL_GetTicks64(); - m_yesString = strings::getByName(strings::names::HOLDING_STRINGS, 0); + m_yesString = strings::get_by_name(strings::names::HOLDING_STRINGS, 0); } - else if (m_triggerGuard && input::buttonHeld(HidNpadButton_A) && m_hold) + else if (m_triggerGuard && input::button_held(HidNpadButton_A) && m_hold) { uint64_t TickCount = SDL_GetTicks64() - m_startingTickCount; @@ -75,25 +79,25 @@ class ConfirmState : public AppState if (TickCount >= 3000) { AppState::deactivate(); - JKSV::pushState(std::make_shared(m_function, m_dataStruct)); + JKSV::push_state(std::make_shared(m_function, m_dataStruct)); } else if (TickCount >= 2000) { - m_yesString = strings::getByName(strings::names::HOLDING_STRINGS, 2); + m_yesString = strings::get_by_name(strings::names::HOLDING_STRINGS, 2); m_yesX = YES_X_CENTER_COORDINATE - (sdl::text::getWidth(22, m_yesString.c_str()) / 2); } else if (TickCount >= 1000) { - m_yesString = strings::getByName(strings::names::HOLDING_STRINGS, 1); + m_yesString = strings::get_by_name(strings::names::HOLDING_STRINGS, 1); m_yesX = YES_X_CENTER_COORDINATE - (sdl::text::getWidth(22, m_yesString.c_str()) / 2); } } - else if (input::buttonReleased(HidNpadButton_A)) + else if (input::button_released(HidNpadButton_A)) { - m_yesString = strings::getByName(strings::names::YES_NO, 0); + m_yesString = strings::get_by_name(strings::names::YES_NO, 0); m_yesX = YES_X_CENTER_COORDINATE - (sdl::text::getWidth(22, m_yesString.c_str()) / 2); } - else if (input::buttonPressed(HidNpadButton_B)) + else if (input::button_pressed(HidNpadButton_B)) { // Just deactivate and don't do anything. AppState::deactivate(); @@ -106,7 +110,7 @@ class ConfirmState : public AppState // Dim background sdl::renderRectFill(NULL, 0, 0, 1280, 720, colors::DIM_BACKGROUND); // Render dialog - ui::renderDialogBox(NULL, 280, 262, 720, 256); + ui::render_dialog_box(NULL, 280, 262, 720, 256); // Text sdl::text::render(NULL, 312, 288, 18, 656, colors::WHITE, m_queryString.c_str()); // Fake buttons. Maybe real later. @@ -114,7 +118,13 @@ class ConfirmState : public AppState sdl::renderLine(NULL, 640, 454, 640, 517, colors::WHITE); // To do: Position this better. Currently brought over from old code. sdl::text::render(NULL, m_yesX, 476, 22, sdl::text::NO_TEXT_WRAP, colors::WHITE, m_yesString.c_str()); - sdl::text::render(NULL, m_noX, 476, 22, sdl::text::NO_TEXT_WRAP, colors::WHITE, strings::getByName(strings::names::YES_NO, 1)); + sdl::text::render(NULL, + m_noX, + 476, + 22, + sdl::text::NO_TEXT_WRAP, + colors::WHITE, + strings::get_by_name(strings::names::YES_NO, 1)); } private: diff --git a/include/appstates/MainMenuState.hpp b/include/appstates/MainMenuState.hpp index 7dc9fc6..c4de825 100644 --- a/include/appstates/MainMenuState.hpp +++ b/include/appstates/MainMenuState.hpp @@ -21,7 +21,7 @@ class MainMenuState : public AppState void render(void); /// @brief This function allows other states to signal to this one to refresh the views on next call to update(); - static void refreshViewStates(void); + static void refresh_view_states(void); private: /// @brief Render target this state renders to. diff --git a/include/appstates/SettingsState.hpp b/include/appstates/SettingsState.hpp index 930ce08..a9012b6 100644 --- a/include/appstates/SettingsState.hpp +++ b/include/appstates/SettingsState.hpp @@ -27,7 +27,7 @@ class SettingsState : public AppState /// @brief X coordinate of the control guide in the bottom right corner. int m_controlGuideX = 0; /// @brief Runs a routine to update the menu strings for the menu. - void updateMenuOptions(void); + void update_menu_options(void); /// @brief Toggles or executes the code to changed the selected menu option. - void toggleOptions(void); + void toggle_options(void); }; diff --git a/include/appstates/TitleSelectCommon.hpp b/include/appstates/TitleSelectCommon.hpp index 606a578..e65d981 100644 --- a/include/appstates/TitleSelectCommon.hpp +++ b/include/appstates/TitleSelectCommon.hpp @@ -21,7 +21,7 @@ class TitleSelectCommon : public AppState virtual void refresh(void) = 0; /// @brief Renders the control guide string to the bottom right corner. - void renderControlGuide(void); + void render_control_guide(void); private: /// @brief X coordinate the control guide is rendered at. diff --git a/include/config.hpp b/include/config.hpp index 51a32d6..688cc55 100644 --- a/include/config.hpp +++ b/include/config.hpp @@ -8,7 +8,7 @@ namespace config void initialize(void); /// @brief Resets config to default values. - void resetToDefault(void); + void reset_to_default(void); /// @brief Saves config to file. void save(void); @@ -16,75 +16,75 @@ namespace config /// @brief Retrieves the config value according to the key passed. /// @param key Key to retrieve. See config::keys /// @return Key's value if found. 0 if it is not. - uint8_t getByKey(std::string_view key); + uint8_t get_by_key(std::string_view key); /// @brief Toggles the key. This is only for basic true or false settings. /// @param key Key to toggle. - void toggleByKey(std::string_view key); + void toggle_by_key(std::string_view key); /// @brief Sets the key according /// @param key Key to set. /// @param value Value to set the key to. - void setByKey(std::string_view key, uint8_t value); + void set_by_key(std::string_view key, uint8_t value); /// @brief Retrieves value of config at index. /// @param index Index of value to retrieve. - uint8_t getByIndex(int index); + uint8_t get_by_index(int index); /// @brief Toggles the key at index from 1 to 0 or vice-versa. /// @param index Index of key to toggle. - void toggleByIndex(int index); + void toggle_by_index(int index); /// @brief Sets the config value at index to value. /// @param index Index of value to set. /// @param value Value to set index to. - void setByIndex(int index, uint8_t value); + void set_by_index(int index, uint8_t value); /// @brief Returns the working directory. /// @return Working directory. - fslib::Path getWorkingDirectory(void); + fslib::Path get_working_directory(void); /// @brief Returns the scaling speed of UI transitions and animations. /// @return Scaling variable. - double getAnimationScaling(void); + double get_animation_scaling(void); /// @brief Sets the UI animation scaling. /// @param newScale New value to set the scaling to. - void setAnimationScaling(double newScale); + void set_animation_scaling(double newScale); /// @brief Adds or removes a title from the favorites list. /// @param applicationID Application ID of title to add or remove. - void addRemoveFavorite(uint64_t applicationID); + void add_remove_favorite(uint64_t applicationID); /// @brief Returns if the title is found in the favorites list. /// @param applicationID Application ID to search for. /// @return True if found. False if not. - bool isFavorite(uint64_t applicationID); + bool is_favorite(uint64_t applicationID); /// @brief Adds or removes title from blacklist. /// @param applicationID Application ID to add or remove. - void addRemoveBlacklist(uint64_t applicationID); + void add_remove_blacklist(uint64_t applicationID); /// @brief Returns if the title is found in the blacklist. /// @param applicationID Application ID to search for. /// @return True if found. False if not. - bool isBlacklisted(uint64_t applicationID); + bool is_blacklisted(uint64_t applicationID); /// @brief Adds a custom output path for the title. /// @param applicationID Application ID of title to add a path for. /// @param customPath Path to assign to the output. - void addCustomPath(uint64_t applicationID, std::string_view customPath); + void add_custom_path(uint64_t applicationID, std::string_view customPath); /// @brief Searches to see if the application ID passed has a custom output path. /// @param applicationID Application ID to check. /// @return True if it does. False if it doesn't. - bool hasCustomPath(uint64_t applicationID); + bool has_custom_path(uint64_t applicationID); /// @brief Gets the custom, defined path for the title. /// @param applicationID Application ID of title to get. /// @param pathOut Buffer to write the path to. /// @param pathOutSize Size of the buffer to write the path to. - void getCustomPath(uint64_t applicationID, char *pathOut, size_t pathOutSize); + void get_custom_path(uint64_t applicationID, char *pathOut, size_t pathOutSize); // Names of keys. Note: Not all of these are retrievable with GetByKey. Some of these are purely for config reading and writing. namespace keys diff --git a/include/data/TitleInfo.hpp b/include/data/TitleInfo.hpp index 672b494..a0aada0 100644 --- a/include/data/TitleInfo.hpp +++ b/include/data/TitleInfo.hpp @@ -15,57 +15,57 @@ namespace data /// @brief Returns the application ID of the title. /// @return Title's application ID. - uint64_t getApplicationID(void) const; + uint64_t get_application_id(void) const; /// @brief Returns the title of the title? /// @return Title directly from the NACP. - const char *getTitle(void); + const char *get_title(void); /// @brief Returns the path safe version of the title for file system usage. /// @return Path safe version of the title. - const char *getPathSafeTitle(void); + const char *get_path_safe_title(void); /// @brief Allows the path safe title to be set to a new path. /// @param newPathSafe Buffer containing the new safe path to use. /// @param newPathLength Size of the buffer passed. - void setPathSafeTitle(const char *newPathSafe, size_t newPathLength); + void set_path_safe_title(const char *newPathSafe, size_t newPathLength); /// @brief Returns the publisher of the title. /// @return Publisher string from NACP. - const char *getPublisher(void); + const char *get_publisher(void); /// @brief Returns the owner ID of the save data. /// @return Save data owner ID. - uint64_t getSaveDataOwnerID(void) const; + uint64_t get_save_data_owner_id(void) const; /// @brief Returns the save data container's base size. /// @param saveType Type of save data to return. /// @return Size of baseline save data if applicable. If not, 0. - int64_t getSaveDataSize(uint8_t saveType) const; + int64_t get_save_data_size(uint8_t saveType) const; /// @brief Returns the maximum size of the save data container. /// @param saveType Type of save data to return. /// @return Maximum size of the save container if applicable. If not, 0. - int64_t getSaveDataSizeMax(uint8_t saveType) const; + int64_t get_save_data_size_max(uint8_t saveType) const; /// @brief Returns the journaling size for the save type passed. /// @param saveType Save type to return. /// @return Journal size if applicable. If not, 0. - int64_t getJournalSize(uint8_t saveType) const; + int64_t get_journal_size(uint8_t saveType) const; /// @brief Returns the maximum journal size for the save type passed. /// @param saveType Save type to return. /// @return Maximum journal size if applicable. If not, 0. - int64_t getJournalSizeMax(uint8_t saveType) const; + int64_t get_journal_size_max(uint8_t saveType) const; /// @brief Returns if a title uses the save type passed. /// @param saveType Save type to check for. /// @return True on success. False on failure. - bool hasSaveDataType(uint8_t saveType); + bool has_save_data_type(uint8_t saveType); /// @brief Returns a pointer to the icon texture. /// @return Icon - sdl::SharedTexture getIcon(void) const; + sdl::SharedTexture get_icon(void) const; private: /// @brief Stores application ID for easier grabbing since JKSV is all pointers. diff --git a/include/data/User.hpp b/include/data/User.hpp index 29c7bd3..538b784 100644 --- a/include/data/User.hpp +++ b/include/data/User.hpp @@ -33,68 +33,67 @@ namespace data /// @brief Pushes data to m_userData /// @param saveInfo SaveDataInfo. /// @param playStats Play statistics. - void addData(const FsSaveDataInfo &saveInfo, const PdmPlayStatistics &playStats); - + void add_data(const FsSaveDataInfo &saveInfo, const PdmPlayStatistics &playStats); /// @brief Erases data at index. /// @param index Index of save data info to erase. - void eraseData(int index); + void erase_data(int index); /// @brief Runs the sort algo on the vector. - void sortData(void); + void sort_data(void); /// @brief Returns the account ID of the user. /// @return AccountID - AccountUid getAccountID(void) const; + AccountUid get_account_id(void) const; /// @brief Returns the save data type the account uses. /// @return Save data type of the account. - FsSaveDataType getAccountSaveType(void) const; + FsSaveDataType get_account_save_type(void) const; /// @brief Returns the account's nickname. /// @return Account nickname. - const char *getNickname(void) const; + const char *get_nickname(void) const; /// @brief Returns the path safe version of the nickname. /// @return Path safe nickname. - const char *getPathSafeNickname(void) const; + const char *get_path_safe_nickname(void) const; /// @brief Returns the total number of entries in the data vector. /// @return Total number of entries. - size_t getTotalDataEntries(void) const; + size_t get_total_data_entries(void) const; /// @brief Returns the application ID of the title at index. /// @param index Index of title. /// @return Application ID if index is valid. 0 if not. - uint64_t getApplicationIDAt(int index) const; + uint64_t get_application_id_at(int index) const; /// @brief Returns a pointer to the save data info at index. /// @param index Index of data to fetch. /// @return Pointer to info if valid. nullptr if out-of-bounds. - FsSaveDataInfo *getSaveInfoAt(int index); + FsSaveDataInfo *get_save_info_at(int index); /// @brief Returns a pointer to the play statistics at index. /// @param index Index of play statistics to fetch. /// @return Pointer to play statistics if index is value. nullptr if it's out of bounds. - PdmPlayStatistics *getPlayStatsAt(int index); + PdmPlayStatistics *get_play_stats_at(int index); /// @brief Returns a pointer to the save info of applicationID. /// @param applicationID Application ID to search and fetch for. /// @return Pointer to save info if found. nullptr if not. - FsSaveDataInfo *getSaveInfoByID(uint64_t applicationID); + FsSaveDataInfo *get_save_info_by_id(uint64_t applicationID); /// @brief Returns a pointer to the play statistics of applicationID /// @param applicationID Application ID to search and fetch. /// @return Pointer to play statistics if index is valid. nullptr if it isn't. - PdmPlayStatistics *getPlayStatsByID(uint64_t applicationID); + PdmPlayStatistics *get_play_stats_by_id(uint64_t applicationID); /// @brief Returns raw SDL_Texture pointer of icon. /// @return SDL_Texture of icon. - SDL_Texture *getIcon(void); + SDL_Texture *get_icon(void); /// @brief Returns the shared texture of icon. Increasing reference count of it. /// @return Shared icon texture. - sdl::SharedTexture getSharedIcon(void); + sdl::SharedTexture get_shared_icon(void); private: /// @brief Account's ID @@ -113,9 +112,9 @@ namespace data /// @brief Loads account structs from system. /// @param profile AccountProfile struct to write to. /// @param profileBase AccountProfileBase to write to. - void loadAccount(AccountProfile &profile, AccountProfileBase &profileBase); + void load_account(AccountProfile &profile, AccountProfileBase &profileBase); /// @brief Creates a placeholder since something went wrong. - void createAccount(void); + void create_account(void); }; } // namespace data diff --git a/include/data/data.hpp b/include/data/data.hpp index 236d57f..405b0bf 100644 --- a/include/data/data.hpp +++ b/include/data/data.hpp @@ -13,19 +13,19 @@ namespace data /// @brief Writes pointers to users to vectorOut /// @param vectorOut Vector to push the pointers to. - void getUsers(std::vector &vectorOut); + void get_users(std::vector &vectorOut); /// @brief Returns a pointer to the title mapped to applicationID. /// @param applicationID ApplicationID of title to retrieve. /// @return Pointer to data. nullptr if it's not found. - data::TitleInfo *getTitleInfoByID(uint64_t applicationID); + data::TitleInfo *get_title_info_by_id(uint64_t applicationID); /// @brief Returns a reference to the title info map. /// @return Reference to TitleInfoMap. - std::unordered_map &getTitleInfoMap(void); + std::unordered_map &get_title_info_map(void); /// @brief Gets a vector of pointers with all titles with saveType. /// @param saveType Save data type to check for. /// @param vectorOut Vector to push pointers to. - void getTitleInfoByType(FsSaveDataType saveType, std::vector &vectorOut); + void get_title_info_by_type(FsSaveDataType saveType, std::vector &vectorOut); } // namespace data diff --git a/include/fs/directoryFunctions.hpp b/include/fs/directoryFunctions.hpp index d4c9363..03f4bf1 100644 --- a/include/fs/directoryFunctions.hpp +++ b/include/fs/directoryFunctions.hpp @@ -5,10 +5,10 @@ namespace fs { /// @brief Retrieves the total size of the contents of the directory at targetPath. /// @param targetPath Directory to calculate. - uint64_t getDirectoryTotalSize(const fslib::Path &targetPath); + uint64_t get_directory_total_size(const fslib::Path &targetPath); /// @brief Checks if directory is empty. Didn't feel like this needs its own source file. /// @param directoryPath Path to directory to check. /// @return True if directory has files inside. - bool directoryHasContents(const fslib::Path &directoryPath); + bool directory_has_contents(const fslib::Path &directoryPath); } // namespace fs diff --git a/include/fs/io.hpp b/include/fs/io.hpp index a394735..293c7b1 100644 --- a/include/fs/io.hpp +++ b/include/fs/io.hpp @@ -11,11 +11,11 @@ namespace fs /// @param journalSize Optional. The size of the journal if data needs to be commited. /// @param commitDevice Optional. The device to commit to if it's needed. /// @param Task Optional. Progress tracking task to display progress of operation if needed. - void copyFile(const fslib::Path &source, - const fslib::Path &destination, - uint64_t journalSize = 0, - std::string_view commitDevice = {}, - sys::ProgressTask *Task = nullptr); + void copy_file(const fslib::Path &source, + const fslib::Path &destination, + uint64_t journalSize = 0, + std::string_view commitDevice = {}, + sys::ProgressTask *Task = nullptr); /// @brief Recursively copies source to destination. /// @param source Source path. @@ -23,9 +23,9 @@ namespace fs /// @param journalSize Optional. Journal size to be passed to copyFile if data needs to be commited to device. /// @param commitDevice Optional. Device to commit data to if needed. /// @param Task Option. Progress tracking task to be passed to copyFile to show progress of operation. - void copyDirectory(const fslib::Path &source, - const fslib::Path &destination, - uint64_t journalSize = 0, - std::string_view commitDevice = {}, - sys::ProgressTask *Task = nullptr); + void copy_directory(const fslib::Path &source, + const fslib::Path &destination, + uint64_t journalSize = 0, + std::string_view commitDevice = {}, + sys::ProgressTask *Task = nullptr); } // namespace fs diff --git a/include/fs/saveDataFunctions.hpp b/include/fs/saveDataFunctions.hpp index bc9ca49..7d141f3 100644 --- a/include/fs/saveDataFunctions.hpp +++ b/include/fs/saveDataFunctions.hpp @@ -8,10 +8,10 @@ namespace fs /// @param targetUser User to create save data for. /// @param titleInfo Title to create save data for. /// @return True on success. False on failure. - bool createSaveDataFor(data::User *targetUser, data::TitleInfo *titleInfo); + bool create_save_data_for(data::User *targetUser, data::TitleInfo *titleInfo); /// @brief Deletes the save data of the FsSaveDataInfo passed. /// @param saveInfo Save data to delete. /// @return True on success. False on failure. - bool deleteSaveData(const FsSaveDataInfo &saveInfo); + bool delete_save_data(const FsSaveDataInfo &saveInfo); } // namespace fs diff --git a/include/fs/zip.hpp b/include/fs/zip.hpp index fce402e..edf49d1 100644 --- a/include/fs/zip.hpp +++ b/include/fs/zip.hpp @@ -12,7 +12,7 @@ namespace fs /// @param source Source file to copy from. /// @param destination zipFile to write to. /// @param Task Optional. Task to pass to show progress. - void copyDirectoryToZip(const fslib::Path &source, zipFile destination, sys::ProgressTask *Task = nullptr); + void copy_directory_to_zip(const fslib::Path &source, zipFile destination, sys::ProgressTask *Task = nullptr); /// @brief Unzips source to destination. /// @param source Source zip file to read from. @@ -20,14 +20,14 @@ namespace fs /// @param journalSize Size of journal for committing data. This is used exclusively for save data. /// @param commitDevice Device to commit data to. /// @param task Optional. Task to update to show progress. - void copyZipToDirectory(unzFile source, - const fslib::Path &destination, - uint64_t journalSize, - std::string_view commitDevice, - sys::ProgressTask *Task = nullptr); + void copy_zip_to_directory(unzFile source, + const fslib::Path &destination, + uint64_t journalSize, + std::string_view commitDevice, + sys::ProgressTask *Task = nullptr); /// @brief Returns whether or not zip has files inside. /// @param zipPath Path to zip to check. /// @return True if at least one file is found. False if none. - bool zipHasContents(const fslib::Path &zipPath); + bool zip_has_contents(const fslib::Path &zipPath); } // namespace fs diff --git a/include/input.hpp b/include/input.hpp index ed227a5..163bd4d 100644 --- a/include/input.hpp +++ b/include/input.hpp @@ -12,15 +12,15 @@ namespace input /// @brief Returns if a button was pressed the current frame, but not the previous. /// @param button Button to check. /// @return True if button is pressed. False if it wasn't. - bool buttonPressed(HidNpadButton button); + bool button_pressed(HidNpadButton button); /// @brief Returns if the button was pressed or held the previous and current frame. /// @param button Button to check. /// @return True if button is held. False if it isn't. - bool buttonHeld(HidNpadButton button); + bool button_held(HidNpadButton button); /// @brief Returns if the button was pressed or held the previous frame, but not the current. /// @param button Button to check. /// @return True if the button was released. False if it wasn't. - bool buttonReleased(HidNpadButton button); + bool button_released(HidNpadButton button); } // namespace input diff --git a/include/keyboard.hpp b/include/keyboard.hpp index d56d72c..da79338 100644 --- a/include/keyboard.hpp +++ b/include/keyboard.hpp @@ -11,5 +11,9 @@ namespace keyboard /// @param stringOut Pointer to buffer to write to. /// @param stringLength Size of the buffer to write too. /// @return True if input was successful and valid. False if it wasn't. - bool getInput(SwkbdType keyboardType, std::string_view defaultText, std::string_view header, char *stringOut, size_t stringLength); + bool get_input(SwkbdType keyboardType, + std::string_view defaultText, + std::string_view header, + char *stringOut, + size_t stringLength); } // namespace keyboard diff --git a/include/strings.hpp b/include/strings.hpp index 3f4fe09..664426c 100644 --- a/include/strings.hpp +++ b/include/strings.hpp @@ -7,7 +7,7 @@ namespace strings bool initialize(void); // Returns string with name and index. Returns nullptr if string doesn't exist. - const char *getByName(std::string_view name, int index); + const char *get_by_name(std::string_view name, int index); // Names of strings to prevent typos. namespace names diff --git a/include/stringutil.hpp b/include/stringutil.hpp index fb29e89..4e31729 100644 --- a/include/stringutil.hpp +++ b/include/stringutil.hpp @@ -14,23 +14,23 @@ namespace stringutil /// @param format Format of string. /// @param arguments Arguments for string. /// @return Formatted C++ string. - std::string getFormattedString(const char *format, ...); + std::string get_formatted_string(const char *format, ...); /// @brief Replaces and sequence of characters in a string. /// @param target Target string. /// @param find Sequence to search for. /// @param replace What to replace the sequence with. - void replaceInString(std::string &target, std::string_view find, std::string_view replace); + void replace_in_string(std::string &target, std::string_view find, std::string_view replace); /// @brief Attempts to sanitize the string for use with the SD card. /// @param stringIn String to attempt to sanitize. /// @param stringOut Buffer to write result to. /// @param stringOutSize Size of buffer. /// @return True if the string was able to be sanitized. False if it's impossible. - bool sanitizeStringForPath(const char *stringIn, char *stringOut, size_t stringOutSize); + bool sanitize_string_for_path(const char *stringIn, char *stringOut, size_t stringOutSize); /// @brief Returns a date string. /// @param format Optional. Format to use. Default is Year_Month_Day-Time /// @return Date string. - std::string getDateString(stringutil::DateFormat format = stringutil::DateFormat::YearMonthDay); + std::string get_date_string(stringutil::DateFormat format = stringutil::DateFormat::YearMonthDay); } // namespace stringutil diff --git a/include/system/ProgressTask.hpp b/include/system/ProgressTask.hpp index e994c94..4295201 100644 --- a/include/system/ProgressTask.hpp +++ b/include/system/ProgressTask.hpp @@ -21,15 +21,15 @@ namespace sys /// @brief Updates the current progress. /// @param current The current progress value. - void updateCurrent(double current); + void update_current(double current); /// @brief Returns the goal value. /// @return Goal - double getGoal(void) const; + double get_goal(void) const; /// @brief Returns the current progress. /// @return Current progress. - double getCurrent(void) const; + double get_current(void) const; private: // Current value and goal diff --git a/include/system/Task.hpp b/include/system/Task.hpp index ebbaf38..1e62312 100644 --- a/include/system/Task.hpp +++ b/include/system/Task.hpp @@ -35,7 +35,7 @@ namespace sys /// @brief Returns if the thread has signaled it's finished running. /// @return True if the thread is still running. False if it isn't. - bool isRunning(void) const; + bool is_running(void) const; /// @brief Allows thread to signal it's finished. /// @note Spawned task threads must call this when their work is finished. @@ -44,11 +44,11 @@ namespace sys /// @brief Sets the task/threads current status string. Thread safe. /// @param format Format of string. /// @param args Arguments for string. - void setStatus(const char *format, ...); + void set_status(const char *format, ...); /// @brief Returns the status string. Thread safe. /// @return Copy of the status string. - std::string getStatus(void); + std::string get_status(void); private: // Whether task is still running. diff --git a/include/system/Timer.hpp b/include/system/Timer.hpp index bf69b8e..1f41bf4 100644 --- a/include/system/Timer.hpp +++ b/include/system/Timer.hpp @@ -26,7 +26,7 @@ namespace sys /// @brief Updates and returns if the timer was triggered. /// @return True if timer is triggered. False if it isn't. - bool isTriggered(void); + bool is_triggered(void); /// @brief Forces the timer to restart. void restart(void); diff --git a/include/ui/IconMenu.hpp b/include/ui/IconMenu.hpp index cb9ae36..70a0e3c 100644 --- a/include/ui/IconMenu.hpp +++ b/include/ui/IconMenu.hpp @@ -36,7 +36,7 @@ namespace ui /// @brief Adds a new icon to the menu. /// @param newOption Icon to add. - void addOption(sdl::SharedTexture newOption); + void add_option(sdl::SharedTexture newOption); private: /// @brief Vector of shared texture pointers to textures used. diff --git a/include/ui/Menu.hpp b/include/ui/Menu.hpp index 5cfb892..59eb786 100644 --- a/include/ui/Menu.hpp +++ b/include/ui/Menu.hpp @@ -33,23 +33,23 @@ namespace ui /// @brief Adds and option to the menu. /// @param newOption Option to add to menu. - void addOption(std::string_view newOption); + void add_option(std::string_view newOption); /// @brief Allows updating and editing the option. /// @param newOption Option to change text to. - void editOption(int index, std::string_view newOption); + void edit_option(int index, std::string_view newOption); /// @brief Returns the index of the currently selected menu option. /// @return Index of currently selected option. - int getSelected(void) const; + int get_selected(void) const; /// @brief Sets the selected item. /// @param selected Value to set selected to. - void setSelected(int selected); + void set_selected(int selected); /// @brief This is a workaround function until I find something better. /// @param width New width of the menu in pixels. - void setWidth(int width); + void set_width(int width); /// @brief Resets the menu and returns it to an empty, default state. void reset(void); diff --git a/include/ui/PopMessageManager.hpp b/include/ui/PopMessageManager.hpp index 5b8ff4b..598dd5d 100644 --- a/include/ui/PopMessageManager.hpp +++ b/include/ui/PopMessageManager.hpp @@ -40,7 +40,7 @@ namespace ui /// @param displayTicks Number of ticks for the message to be displayed until it is purged. /// @param format Format of message. /// @param args Arguments for message. - static void pushMessage(int displayTicks, const char *format, ...); + static void push_message(int displayTicks, const char *format, ...); /// @brief The default duration of ticks for messages to be shown. static constexpr int DEFAULT_MESSAGE_TICKS = 2500; @@ -49,7 +49,7 @@ namespace ui // Only one instance allowed. PopMessageManager(void) = default; // Returns the only instance. - static PopMessageManager &getInstance(void) + static PopMessageManager &get_instance(void) { static PopMessageManager manager; return manager; diff --git a/include/ui/SlideOutPanel.hpp b/include/ui/SlideOutPanel.hpp index a84c3bf..6a9dc3e 100644 --- a/include/ui/SlideOutPanel.hpp +++ b/include/ui/SlideOutPanel.hpp @@ -33,7 +33,7 @@ namespace ui void render(SDL_Texture *target, bool hasFocus); /// @brief Clears the target to a semi-transparent black. To do: Maybe not hard coded color. - void clearTarget(void); + void clear_target(void); /// @brief Resets the panel back to its default state. void reset(void); @@ -43,18 +43,18 @@ namespace ui /// @brief Returns if the panel is fully open. /// @return If the panel is fully open. - bool isOpen(void) const; + bool is_open(void) const; /// @brief Returns if the panel is fully closed. /// @return If the panel is fully closed. - bool isClosed(void) const; + bool is_closed(void) const; /// @brief Pushes a new element to the element vector. /// @param newElement New element to push. - void pushNewElement(std::shared_ptr newElement); + void push_new_element(std::shared_ptr newElement); /// @brief Clears the element vector, freeing them in the process. - void clearElements(void); + void clear_elements(void); /// @brief Returns a pointer to the render target of the panel. /// @return Raw SDL_Texture pointer to target. diff --git a/include/ui/TitleTile.hpp b/include/ui/TitleTile.hpp index 4681bd7..57e5458 100644 --- a/include/ui/TitleTile.hpp +++ b/include/ui/TitleTile.hpp @@ -27,11 +27,11 @@ namespace ui /// @brief Returns the render width in pixels. /// @return Render width. - int getWidth(void) const; + int get_width(void) const; /// @brief Returns the render height in pixels. /// @return Render height. - int getHeight(void) const; + int get_height(void) const; private: /// @brief Width in pixels to render icon at. diff --git a/include/ui/TitleView.hpp b/include/ui/TitleView.hpp index 0b64985..f0c6927 100644 --- a/include/ui/TitleView.hpp +++ b/include/ui/TitleView.hpp @@ -30,7 +30,7 @@ namespace ui /// @brief Returns index of the currently selected tile. /// @return Index of currently selected tile. - int getSelected(void) const; + int get_selected(void) const; /// @brief Forces a refresh of the view. void refresh(void); diff --git a/include/ui/renderFunctions.hpp b/include/ui/renderFunctions.hpp index a8addf7..580b8ec 100644 --- a/include/ui/renderFunctions.hpp +++ b/include/ui/renderFunctions.hpp @@ -10,7 +10,7 @@ namespace ui /// @param y Y coordinate to render to. /// @param width Width of dialog box in pixels. /// @param height Height of dialog box in pixels. - void renderDialogBox(SDL_Texture *target, int x, int y, int width, int height); + void render_dialog_box(SDL_Texture *target, int x, int y, int width, int height); /// @brief Renders a bounding box. /// @param target Target to render to. @@ -19,5 +19,5 @@ namespace ui /// @param width Width of dialog box in pixels. /// @param height Height of dialog box in pixels. /// @param colorMod Color to multiply in rendering. - void renderBoundingBox(SDL_Texture *target, int x, int y, int width, int height, uint8_t colorMod); + void render_bounding_box(SDL_Texture *target, int x, int y, int width, int height, uint8_t colorMod); } // namespace ui diff --git a/source/JKSV.cpp b/source/JKSV.cpp index 6405c48..12dfa13 100644 --- a/source/JKSV.cpp +++ b/source/JKSV.cpp @@ -11,10 +11,10 @@ #include "ui/PopMessageManager.hpp" #include -#define ABORT_ON_FAILURE(x) \ - if (!x) \ - { \ - return; \ +#define ABORT_ON_FAILURE(x) \ + if (!x) \ + { \ + return; \ } namespace @@ -25,7 +25,7 @@ namespace } // namespace template -static bool initializeService(Result (*function)(Args...), const char *serviceName, Args... args) +static bool initialize_service(Result (*function)(Args...), const char *serviceName, Args... args) { Result error = (*function)(args...); if (R_FAILED(error)) @@ -45,7 +45,7 @@ JKSV::JKSV(void) logger::initialize(); // Need to init RomFS here for now until I update FsLib to take care of this. - ABORT_ON_FAILURE(initializeService(romfsInit, "RomFS")); + ABORT_ON_FAILURE(initialize_service(romfsInit, "RomFS")); // Let FsLib take care of calls to SDMC instead of fs_dev ABORT_ON_FAILURE(fslib::dev::initializeSDMC()); @@ -56,14 +56,14 @@ JKSV::JKSV(void) // Services. // Using administrator so JKSV can still run in Applet mode. - ABORT_ON_FAILURE(initializeService(accountInitialize, "Account", AccountServiceType_Administrator)); - ABORT_ON_FAILURE(initializeService(nsInitialize, "NS")); - ABORT_ON_FAILURE(initializeService(pdmqryInitialize, "PDMQry")); - ABORT_ON_FAILURE(initializeService(plInitialize, "PL", PlServiceType_User)); - ABORT_ON_FAILURE(initializeService(pmshellInitialize, "PMShell")); - ABORT_ON_FAILURE(initializeService(setInitialize, "Set")); - ABORT_ON_FAILURE(initializeService(setsysInitialize, "SetSys")); - ABORT_ON_FAILURE(initializeService(socketInitializeDefault, "Socket")); + ABORT_ON_FAILURE(initialize_service(accountInitialize, "Account", AccountServiceType_Administrator)); + ABORT_ON_FAILURE(initialize_service(nsInitialize, "NS")); + ABORT_ON_FAILURE(initialize_service(pdmqryInitialize, "PDMQry")); + ABORT_ON_FAILURE(initialize_service(plInitialize, "PL", PlServiceType_User)); + ABORT_ON_FAILURE(initialize_service(pmshellInitialize, "PMShell")); + ABORT_ON_FAILURE(initialize_service(setInitialize, "Set")); + ABORT_ON_FAILURE(initialize_service(setsysInitialize, "SetSys")); + ABORT_ON_FAILURE(initialize_service(socketInitializeDefault, "Socket")); // Input doesn't have anything to return. input::initialize(); @@ -72,7 +72,7 @@ JKSV::JKSV(void) config::initialize(); // Get and create working directory. There isn't much of an FS anymore. - fslib::Path workingDirectory = config::getWorkingDirectory(); + fslib::Path workingDirectory = config::get_working_directory(); if (!fslib::directoryExists(workingDirectory) && !fslib::createDirectoriesRecursively(workingDirectory)) { logger::log("Error creating working directory: %s", fslib::getErrorString()); @@ -96,13 +96,14 @@ JKSV::JKSV(void) sdl::text::addColorCharacter(L'^', colors::PINK); // This is to check whether the author wanted credit for their work. - m_showTranslationInfo = std::char_traits::compare(strings::getByName(strings::names::TRANSLATION_INFO, 1), "NULL", 4) != 0; + m_showTranslationInfo = + std::char_traits::compare(strings::get_by_name(strings::names::TRANSLATION_INFO, 1), "NULL", 4) != 0; // This can't be in an initializer list because it needs SDL initialized. m_headerIcon = sdl::TextureManager::createLoadTexture("HeaderIcon", "romfs:/Textures/HeaderIcon.png"); // Push initial main menu state. - JKSV::pushState(std::make_shared()); + JKSV::push_state(std::make_shared()); m_isRunning = true; } @@ -125,7 +126,7 @@ JKSV::~JKSV() fslib::exit(); } -bool JKSV::isRunning(void) const +bool JKSV::is_running(void) const { return m_isRunning; } @@ -134,12 +135,12 @@ void JKSV::update(void) { input::update(); - if (input::buttonPressed(HidNpadButton_Plus) && !sm_stateVector.empty() && sm_stateVector.back()->isClosable()) + if (input::button_pressed(HidNpadButton_Plus) && !sm_stateVector.empty() && sm_stateVector.back()->is_closable()) { m_isRunning = false; } - JKSV::updateStateVector(); + JKSV::update_state_vector(); // Update pop messages. ui::PopMessageManager::update(); @@ -164,11 +165,20 @@ void JKSV::render(void) 14, sdl::text::NO_TEXT_WRAP, colors::WHITE, - strings::getByName(strings::names::TRANSLATION_INFO, 0), - strings::getByName(strings::names::TRANSLATION_INFO, 1)); + strings::get_by_name(strings::names::TRANSLATION_INFO, 0), + strings::get_by_name(strings::names::TRANSLATION_INFO, 1)); } // Build date - sdl::text::render(NULL, 8, 700, 14, sdl::text::NO_TEXT_WRAP, colors::WHITE, "v. %02d.%02d.%04d", BUILD_MON, BUILD_DAY, BUILD_YEAR); + sdl::text::render(NULL, + 8, + 700, + 14, + sdl::text::NO_TEXT_WRAP, + colors::WHITE, + "v. %02d.%02d.%04d", + BUILD_MON, + BUILD_DAY, + BUILD_YEAR); // State render loop. if (!sm_stateVector.empty()) @@ -185,17 +195,17 @@ void JKSV::render(void) sdl::frameEnd(); } -void JKSV::pushState(std::shared_ptr newState) +void JKSV::push_state(std::shared_ptr newState) { if (!sm_stateVector.empty()) { - sm_stateVector.back()->takeFocus(); + sm_stateVector.back()->take_focus(); } - newState->giveFocus(); + newState->give_focus(); sm_stateVector.push_back(newState); } -void JKSV::updateStateVector(void) +void JKSV::update_state_vector(void) { if (sm_stateVector.empty()) { @@ -205,18 +215,18 @@ void JKSV::updateStateVector(void) // Check for and purge deactivated states. for (size_t i = 0; i < sm_stateVector.size(); i++) { - if (!sm_stateVector.at(i)->isActive()) + if (!sm_stateVector.at(i)->is_active()) { // This is a just in case thing. Some states are never actually purged. - sm_stateVector.at(i)->takeFocus(); + sm_stateVector.at(i)->take_focus(); sm_stateVector.erase(sm_stateVector.begin() + i); } } // Make sure the back has focus. - if (!sm_stateVector.back()->hasFocus()) + if (!sm_stateVector.back()->has_focus()) { - sm_stateVector.back()->giveFocus(); + sm_stateVector.back()->give_focus(); } // Only update the back most state. diff --git a/source/TitleInfoState.cpp b/source/TitleInfoState.cpp index 0df0083..76811d7 100644 --- a/source/TitleInfoState.cpp +++ b/source/TitleInfoState.cpp @@ -3,7 +3,8 @@ #include "input.hpp" #include "sdl.hpp" -TitleInfoState::TitleInfoState(data::User *user, data::TitleInfo *titleInfo) : m_user(user), m_titleInfo(titleInfo), m_titleScrollTimer(3000) +TitleInfoState::TitleInfoState(data::User *user, data::TitleInfo *titleInfo) + : m_user(user), m_titleInfo(titleInfo), m_titleScrollTimer(3000) { if (!sm_initialized) { @@ -13,7 +14,7 @@ TitleInfoState::TitleInfoState(data::User *user, data::TitleInfo *titleInfo) : m } // Check if the title is too large to fit within the target. - m_titleWidth = sdl::text::getWidth(32, m_titleInfo->getTitle()); + m_titleWidth = sdl::text::getWidth(32, m_titleInfo->get_title()); if (m_titleWidth > 480) { // Just set this to 8 and we'll scroll the title. @@ -30,17 +31,17 @@ TitleInfoState::TitleInfoState(data::User *user, data::TitleInfo *titleInfo) : m void TitleInfoState::update(void) { // Update slide panel. - sm_slidePanel->update(AppState::hasFocus()); + sm_slidePanel->update(AppState::has_focus()); - if (input::buttonPressed(HidNpadButton_B)) + if (input::button_pressed(HidNpadButton_B)) { sm_slidePanel->close(); } - else if (sm_slidePanel->isClosed()) + else if (sm_slidePanel->is_closed()) { sm_slidePanel->reset(); } - else if (m_titleScrolling && m_titleScrollTimer.isTriggered()) + else if (m_titleScrolling && m_titleScrollTimer.is_triggered()) { m_titleX -= 2; m_titleScrollTriggered = true; @@ -60,7 +61,7 @@ void TitleInfoState::update(void) void TitleInfoState::render(void) { // Grab the panel's target and clear it. To do: This how I originally intended to. - sm_slidePanel->clearTarget(); + sm_slidePanel->clear_target(); // SDL_Texture *panelTarget = sm_slidePanel->get(); // If the title doesn't need to be scrolled, just render it. diff --git a/source/appstates/AppState.cpp b/source/appstates/AppState.cpp index 7db5723..37e7889 100644 --- a/source/appstates/AppState.cpp +++ b/source/appstates/AppState.cpp @@ -27,27 +27,27 @@ void AppState::reactivate(void) m_isActive = true; } -bool AppState::isActive(void) const +bool AppState::is_active(void) const { return m_isActive; } -void AppState::giveFocus(void) +void AppState::give_focus(void) { m_hasFocus = true; } -void AppState::takeFocus(void) +void AppState::take_focus() { m_hasFocus = false; } -bool AppState::hasFocus(void) const +bool AppState::has_focus(void) const { return m_hasFocus; } -bool AppState::isClosable(void) const +bool AppState::is_closable(void) const { return m_isClosable; } diff --git a/source/appstates/BackupMenuState.cpp b/source/appstates/BackupMenuState.cpp index 43c8ffa..fc7806b 100644 --- a/source/appstates/BackupMenuState.cpp +++ b/source/appstates/BackupMenuState.cpp @@ -34,39 +34,42 @@ struct TargetStruct // Declarations here. Definitions after class. // Create new backup in targetPath -static void createNewBackup(sys::ProgressTask *task, - data::User *user, - data::TitleInfo *titleInfo, - fslib::Path targetPath, - BackupMenuState *spawningState); - +static void create_new_backup(sys::ProgressTask *task, + data::User *user, + data::TitleInfo *titleInfo, + fslib::Path targetPath, + BackupMenuState *spawningState); // Overwrites and existing backup. -static void overwriteBackup(sys::ProgressTask *task, std::shared_ptr dataStruct); +static void overwrite_backup(sys::ProgressTask *task, std::shared_ptr dataStruct); // Restores a backup and requires confirmation to do so. Takes a shared_ptr to a TargetStruct. -static void restoreBackup(sys::ProgressTask *task, std::shared_ptr dataStruct); +static void restore_backup(sys::ProgressTask *task, std::shared_ptr dataStruct); // Deletes a backup and requires confirmation to do so. Takes a shared_ptr to a TargetStruct. -static void deleteBackup(sys::Task *task, std::shared_ptr dataStruct); +static void delete_backup(sys::Task *task, std::shared_ptr dataStruct); BackupMenuState::BackupMenuState(data::User *user, data::TitleInfo *titleInfo, FsSaveDataType saveType) : m_user(user), m_titleInfo(titleInfo), m_saveType(saveType), - m_directoryPath(config::getWorkingDirectory() / m_titleInfo->getPathSafeTitle()) + m_directoryPath(config::get_working_directory() / m_titleInfo->get_path_safe_title()) { if (!sm_isInitialized) { - sm_panelWidth = sdl::text::getWidth(22, strings::getByName(strings::names::CONTROL_GUIDES, 2)) + 64; + sm_panelWidth = sdl::text::getWidth(22, strings::get_by_name(strings::names::CONTROL_GUIDES, 2)) + 64; // To do: Give classes an alternate so they don't have to be constructed. sm_backupMenu = std::make_shared(8, 8, sm_panelWidth - 14, 24, 600); sm_slidePanel = std::make_unique(sm_panelWidth, ui::SlideOutPanel::Side::Right); sm_menuRenderTarget = - sdl::TextureManager::createLoadTexture("backupMenuTarget", sm_panelWidth, 600, SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET); + sdl::TextureManager::createLoadTexture("backupMenuTarget", + sm_panelWidth, + 600, + SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET); sm_isInitialized = true; } // String for the top of the panel. - std::string panelString = stringutil::getFormattedString("`%s` - %s", m_user->getNickname(), m_titleInfo->getTitle()); + std::string panelString = + stringutil::get_formatted_string("`%s` - %s", m_user->get_nickname(), m_titleInfo->get_title()); // This needs sm_panelWidth or it'd be in the initializer list. - sm_slidePanel->pushNewElement(std::make_shared(panelString, 22, sm_panelWidth, 8, colors::WHITE)); + sm_slidePanel->push_new_element(std::make_shared(panelString, 22, sm_panelWidth, 8, colors::WHITE)); fslib::Directory saveCheck(fs::DEFAULT_SAVE_PATH); @@ -77,105 +80,121 @@ BackupMenuState::BackupMenuState(data::User *user, data::TitleInfo *titleInfo, F BackupMenuState::~BackupMenuState() { - sm_slidePanel->clearElements(); + sm_slidePanel->clear_elements(); } void BackupMenuState::update(void) { - if (input::buttonPressed(HidNpadButton_A) && sm_backupMenu->getSelected() == 0 && m_saveHasData) + if (input::button_pressed(HidNpadButton_A) && sm_backupMenu->get_selected() == 0 && m_saveHasData) { // get name for backup. char backupName[0x81] = {0}; // Set backup to default. - std::snprintf(backupName, 0x80, "%s - %s", m_user->getPathSafeNickname(), stringutil::getDateString().c_str()); + std::snprintf(backupName, + 0x80, + "%s - %s", + m_user->get_path_safe_nickname(), + stringutil::get_date_string().c_str()); - if (!input::buttonHeld(HidNpadButton_ZR) && - !keyboard::getInput(SwkbdType_QWERTY, backupName, strings::getByName(strings::names::KEYBOARD_STRINGS, 0), backupName, 0x80)) + if (!input::button_held(HidNpadButton_ZR) && + !keyboard::get_input(SwkbdType_QWERTY, + backupName, + strings::get_by_name(strings::names::KEYBOARD_STRINGS, 0), + backupName, + 0x80)) { return; } // To do: This isn't a good way to check for this... Check to make sure zip has zip extension. - if (config::getByKey(config::keys::EXPORT_TO_ZIP) && std::strstr(backupName, ".zip") == NULL) + if (config::get_by_key(config::keys::EXPORT_TO_ZIP) && std::strstr(backupName, ".zip") == NULL) { // To do: I should check this. std::strcat(backupName, ".zip"); } - else if (!config::getByKey(config::keys::EXPORT_TO_ZIP) && !std::strstr(backupName, ".zip") && - !fslib::directoryExists(m_directoryPath / backupName) && !fslib::createDirectory(m_directoryPath / backupName)) + else if (!config::get_by_key(config::keys::EXPORT_TO_ZIP) && !std::strstr(backupName, ".zip") && + !fslib::directoryExists(m_directoryPath / backupName) && + !fslib::createDirectory(m_directoryPath / backupName)) { return; } // Push the task. - JKSV::pushState(std::make_shared(createNewBackup, m_user, m_titleInfo, m_directoryPath / backupName, this)); + JKSV::push_state(std::make_shared(create_new_backup, + m_user, + m_titleInfo, + m_directoryPath / backupName, + this)); } - else if (input::buttonPressed(HidNpadButton_A) && sm_backupMenu->getSelected() == 0 && !m_saveHasData) + else if (input::button_pressed(HidNpadButton_A) && sm_backupMenu->get_selected() == 0 && !m_saveHasData) { - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::POP_MESSAGES_BACKUP_MENU, 0)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::POP_MESSAGES_BACKUP_MENU, 0)); } - else if (input::buttonPressed(HidNpadButton_A) && m_saveHasData && sm_backupMenu->getSelected() > 0) + else if (input::button_pressed(HidNpadButton_A) && m_saveHasData && sm_backupMenu->get_selected() > 0) { - int selected = sm_backupMenu->getSelected() - 1; + int selected = sm_backupMenu->get_selected() - 1; std::string queryString = - stringutil::getFormattedString(strings::getByName(strings::names::BACKUPMENU_CONFIRMATIONS, 0), m_directoryListing[selected]); + stringutil::get_formatted_string(strings::get_by_name(strings::names::BACKUPMENU_CONFIRMATIONS, 0), + m_directoryListing[selected]); std::shared_ptr dataStruct(new TargetStruct); dataStruct->m_targetPath = m_directoryPath / m_directoryListing[selected]; - JKSV::pushState( - std::make_shared>(queryString, - config::getByKey(config::keys::HOLD_FOR_OVERWRITE), - overwriteBackup, - dataStruct)); + JKSV::push_state(std::make_shared>( + queryString, + config::get_by_key(config::keys::HOLD_FOR_OVERWRITE), + overwrite_backup, + dataStruct)); } - else if (input::buttonPressed(HidNpadButton_A) && !m_saveHasData && sm_backupMenu->getSelected() > 0) + else if (input::button_pressed(HidNpadButton_A) && !m_saveHasData && sm_backupMenu->get_selected() > 0) { - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::POP_MESSAGES_BACKUP_MENU, 0)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::POP_MESSAGES_BACKUP_MENU, 0)); } - else if (input::buttonPressed(HidNpadButton_Y) && sm_backupMenu->getSelected() > 0 && - (m_saveType != FsSaveDataType_System || config::getByKey(config::keys::ALLOW_WRITING_TO_SYSTEM))) + else if (input::button_pressed(HidNpadButton_Y) && sm_backupMenu->get_selected() > 0 && + (m_saveType != FsSaveDataType_System || config::get_by_key(config::keys::ALLOW_WRITING_TO_SYSTEM))) { // Need to account for new at the top. - int selected = sm_backupMenu->getSelected() - 1; + int selected = sm_backupMenu->get_selected() - 1; // Gonna need to test this quick. fslib::Path targetPath = m_directoryPath / m_directoryListing[selected]; // This is a quick check to avoid restoring blanks. - if (fslib::directoryExists(targetPath) && !fs::directoryHasContents(targetPath)) + if (fslib::directoryExists(targetPath) && !fs::directory_has_contents(targetPath)) { - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::POP_MESSAGES_BACKUP_MENU, 1)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::POP_MESSAGES_BACKUP_MENU, 1)); return; } - else if (fslib::fileExists(targetPath) && std::strcmp("zip", targetPath.getExtension()) == 0 && !fs::zipHasContents(targetPath)) + else if (fslib::fileExists(targetPath) && std::strcmp("zip", targetPath.getExtension()) == 0 && + !fs::zip_has_contents(targetPath)) { - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::POP_MESSAGES_BACKUP_MENU, 1)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::POP_MESSAGES_BACKUP_MENU, 1)); return; } std::shared_ptr dataStruct(new TargetStruct); dataStruct->m_targetPath = m_directoryPath / m_directoryListing[selected]; - dataStruct->m_journalSize = m_titleInfo->getJournalSize(m_saveType); + dataStruct->m_journalSize = m_titleInfo->get_journal_size(m_saveType); dataStruct->m_spawningState = this; std::string queryString = - stringutil::getFormattedString(strings::getByName(strings::names::BACKUPMENU_CONFIRMATIONS, 1), m_directoryListing[selected]); + stringutil::get_formatted_string(strings::get_by_name(strings::names::BACKUPMENU_CONFIRMATIONS, 1), + m_directoryListing[selected]); - JKSV::pushState( - std::make_shared>(queryString, - config::getByKey(config::keys::HOLD_FOR_RESTORATION), - restoreBackup, - dataStruct)); + JKSV::push_state(std::make_shared>( + queryString, + config::get_by_key(config::keys::HOLD_FOR_RESTORATION), + restore_backup, + dataStruct)); } - else if (input::buttonPressed(HidNpadButton_X) && sm_backupMenu->getSelected() > 0) + else if (input::button_pressed(HidNpadButton_X) && sm_backupMenu->get_selected() > 0) { // Selected needs to be offset by one to account for New - int selected = sm_backupMenu->getSelected() - 1; + int selected = sm_backupMenu->get_selected() - 1; // Create struct to pass. std::shared_ptr dataStruct(new TargetStruct); @@ -184,50 +203,58 @@ void BackupMenuState::update(void) // get the string. std::string queryString = - stringutil::getFormattedString(strings::getByName(strings::names::BACKUPMENU_CONFIRMATIONS, 2), m_directoryListing[selected]); + stringutil::get_formatted_string(strings::get_by_name(strings::names::BACKUPMENU_CONFIRMATIONS, 2), + m_directoryListing[selected]); // Create/push new state. - JKSV::pushState(std::make_shared>(queryString, - config::getByKey(config::keys::HOLD_FOR_DELETION), - deleteBackup, - dataStruct)); + JKSV::push_state(std::make_shared>( + queryString, + config::get_by_key(config::keys::HOLD_FOR_DELETION), + delete_backup, + dataStruct)); } - else if (input::buttonPressed(HidNpadButton_B)) + else if (input::button_pressed(HidNpadButton_B)) { fslib::closeFileSystem(fs::DEFAULT_SAVE_MOUNT); sm_slidePanel->close(); } - else if (sm_slidePanel->isClosed()) + else if (sm_slidePanel->is_closed()) { sm_slidePanel->reset(); AppState::deactivate(); } // Update panel. - sm_slidePanel->update(AppState::hasFocus()); + sm_slidePanel->update(AppState::has_focus()); // This state bypasses the Slideout panel's normal behavior because it kind of has to. - sm_backupMenu->update(AppState::hasFocus()); + sm_backupMenu->update(AppState::has_focus()); } void BackupMenuState::render(void) { // Clear panel target. - sm_slidePanel->clearTarget(); + sm_slidePanel->clear_target(); // Grab the render target. SDL_Texture *slideTarget = sm_slidePanel->get(); sdl::renderLine(slideTarget, 10, 42, sm_panelWidth - 10, 42, colors::WHITE); sdl::renderLine(slideTarget, 10, 648, sm_panelWidth - 10, 648, colors::WHITE); - sdl::text::render(slideTarget, 32, 673, 22, sdl::text::NO_TEXT_WRAP, colors::WHITE, strings::getByName(strings::names::CONTROL_GUIDES, 2)); + sdl::text::render(slideTarget, + 32, + 673, + 22, + sdl::text::NO_TEXT_WRAP, + colors::WHITE, + strings::get_by_name(strings::names::CONTROL_GUIDES, 2)); // Clear menu target. sm_menuRenderTarget->clear(colors::TRANSPARENT); // render menu to it. - sm_backupMenu->render(sm_menuRenderTarget->get(), AppState::hasFocus()); + sm_backupMenu->render(sm_menuRenderTarget->get(), AppState::has_focus()); // render it to panel target. sm_menuRenderTarget->render(sm_slidePanel->get(), 0, 43); - sm_slidePanel->render(NULL, AppState::hasFocus()); + sm_slidePanel->render(NULL, AppState::has_focus()); } void BackupMenuState::refresh(void) @@ -239,14 +266,14 @@ void BackupMenuState::refresh(void) } sm_backupMenu->reset(); - sm_backupMenu->addOption(strings::getByName(strings::names::BACKUP_MENU, 0)); + sm_backupMenu->add_option(strings::get_by_name(strings::names::BACKUP_MENU, 0)); for (int64_t i = 0; i < m_directoryListing.getCount(); i++) { - sm_backupMenu->addOption(m_directoryListing[i]); + sm_backupMenu->add_option(m_directoryListing[i]); } } -void BackupMenuState::saveDataWritten(void) +void BackupMenuState::save_data_written(void) { if (!m_saveHasData) { @@ -255,29 +282,29 @@ void BackupMenuState::saveDataWritten(void) } // This is the function to create new backups. -static void createNewBackup(sys::ProgressTask *task, - data::User *user, - data::TitleInfo *titleInfo, - fslib::Path targetPath, - BackupMenuState *spawningState) +static void create_new_backup(sys::ProgressTask *task, + data::User *user, + data::TitleInfo *titleInfo, + fslib::Path targetPath, + BackupMenuState *spawningState) { // SaveMeta - FsSaveDataInfo *saveInfo = user->getSaveInfoByID(titleInfo->getApplicationID()); + FsSaveDataInfo *saveInfo = user->get_save_info_by_id(titleInfo->get_application_id()); // I got tired of typing out the cast. fs::SaveMetaData saveMeta = {.m_magic = fs::SAVE_META_MAGIC, - .m_applicationID = titleInfo->getApplicationID(), + .m_applicationID = titleInfo->get_application_id(), .m_saveType = saveInfo->save_data_type, .m_saveRank = saveInfo->save_data_rank, .m_saveSpaceID = saveInfo->save_data_space_id, - .m_saveDataSize = titleInfo->getSaveDataSize(saveInfo->save_data_type), - .m_saveDataSizeMax = titleInfo->getSaveDataSizeMax(saveInfo->save_data_type), - .m_journalSize = titleInfo->getJournalSize(saveInfo->save_data_type), - .m_journalSizeMax = titleInfo->getSaveDataSizeMax(saveInfo->save_data_type), - .m_totalSaveSize = fs::getDirectoryTotalSize(fs::DEFAULT_SAVE_PATH)}; + .m_saveDataSize = titleInfo->get_save_data_size(saveInfo->save_data_type), + .m_saveDataSizeMax = titleInfo->get_save_data_size_max(saveInfo->save_data_type), + .m_journalSize = titleInfo->get_journal_size(saveInfo->save_data_type), + .m_journalSizeMax = titleInfo->get_journal_size_max(saveInfo->save_data_type), + .m_totalSaveSize = fs::get_directory_total_size(fs::DEFAULT_SAVE_PATH)}; // This extension search is lazy and needs to be revised. - if (config::getByKey(config::keys::EXPORT_TO_ZIP) || std::strcmp("zip", targetPath.getExtension()) == 0) + if (config::get_by_key(config::keys::EXPORT_TO_ZIP) || std::strcmp("zip", targetPath.getExtension()) == 0) { zipFile newBackup = zipOpen64(targetPath.cString(), APPEND_STATUS_CREATE); if (!newBackup) @@ -297,7 +324,7 @@ static void createNewBackup(sys::ProgressTask *task, 0, NULL, Z_DEFLATED, - config::getByKey(config::keys::ZIP_COMPRESSION_LEVEL), + config::get_by_key(config::keys::ZIP_COMPRESSION_LEVEL), 0); if (zipError == ZIP_OK) { @@ -305,7 +332,7 @@ static void createNewBackup(sys::ProgressTask *task, zipCloseFileInZip(newBackup); } - fs::copyDirectoryToZip(fs::DEFAULT_SAVE_PATH, newBackup, task); + fs::copy_directory_to_zip(fs::DEFAULT_SAVE_PATH, newBackup, task); zipClose(newBackup, NULL); } else @@ -320,22 +347,24 @@ static void createNewBackup(sys::ProgressTask *task, } } - fs::copyDirectory(fs::DEFAULT_SAVE_PATH, targetPath, 0, {}, task); + fs::copy_directory(fs::DEFAULT_SAVE_PATH, targetPath, 0, {}, task); } spawningState->refresh(); task->finished(); } -static void overwriteBackup(sys::ProgressTask *task, std::shared_ptr dataStruct) +static void overwrite_backup(sys::ProgressTask *task, std::shared_ptr dataStruct) { // DirectoryExists can also be used to check if the target is a directory. - if (fslib::directoryExists(dataStruct->m_targetPath) && !fslib::deleteDirectoryRecursively(dataStruct->m_targetPath)) + if (fslib::directoryExists(dataStruct->m_targetPath) && + !fslib::deleteDirectoryRecursively(dataStruct->m_targetPath)) { logger::log("Error overwriting backup: %s", fslib::getErrorString()); task->finished(); return; } // This has an added check for the zip extension so it can't try to overwrite files that aren't supposed to be zip. - else if (fslib::fileExists(dataStruct->m_targetPath) && std::strcmp("zip", dataStruct->m_targetPath.getExtension()) == 0 && + else if (fslib::fileExists(dataStruct->m_targetPath) && + std::strcmp("zip", dataStruct->m_targetPath.getExtension()) == 0 && !fslib::deleteFile(dataStruct->m_targetPath)) { logger::log("Error overwriting backup: %s", fslib::getErrorString()); @@ -346,75 +375,88 @@ static void overwriteBackup(sys::ProgressTask *task, std::shared_ptrm_targetPath.getExtension())) { zipFile backupZip = zipOpen64(dataStruct->m_targetPath.cString(), APPEND_STATUS_CREATE); - fs::copyDirectoryToZip(fs::DEFAULT_SAVE_PATH, backupZip, task); + fs::copy_directory_to_zip(fs::DEFAULT_SAVE_PATH, backupZip, task); zipClose(backupZip, NULL); } // I hope this check works for making sure this is a folder else if (dataStruct->m_targetPath.getExtension() == nullptr && fslib::createDirectory(dataStruct->m_targetPath)) { - fs::copyDirectory(fs::DEFAULT_SAVE_PATH, dataStruct->m_targetPath, 0, {}, task); + fs::copy_directory(fs::DEFAULT_SAVE_PATH, dataStruct->m_targetPath, 0, {}, task); } task->finished(); } -static void restoreBackup(sys::ProgressTask *task, std::shared_ptr dataStruct) +static void restore_backup(sys::ProgressTask *task, std::shared_ptr dataStruct) { // Wipe the save root first. if (!fslib::deleteDirectoryRecursively(fs::DEFAULT_SAVE_PATH)) { logger::log("Error restoring save: %s", fslib::getErrorString()); - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::POP_MESSAGES_BACKUP_MENU, 2)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::POP_MESSAGES_BACKUP_MENU, 2)); task->finished(); return; } if (fslib::directoryExists(dataStruct->m_targetPath)) { - fs::copyDirectory(dataStruct->m_targetPath, fs::DEFAULT_SAVE_PATH, dataStruct->m_journalSize, fs::DEFAULT_SAVE_MOUNT, task); + fs::copy_directory(dataStruct->m_targetPath, + fs::DEFAULT_SAVE_PATH, + dataStruct->m_journalSize, + fs::DEFAULT_SAVE_MOUNT, + task); } else if (std::strstr(dataStruct->m_targetPath.cString(), ".zip") != NULL) { unzFile targetZip = unzOpen64(dataStruct->m_targetPath.cString()); if (!targetZip) { - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::POP_MESSAGES_BACKUP_MENU, 3)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::POP_MESSAGES_BACKUP_MENU, 3)); logger::log("Error opening zip for reading."); task->finished(); return; } - fs::copyZipToDirectory(targetZip, fs::DEFAULT_SAVE_PATH, dataStruct->m_journalSize, fs::DEFAULT_SAVE_MOUNT, task); + fs::copy_zip_to_directory(targetZip, + fs::DEFAULT_SAVE_PATH, + dataStruct->m_journalSize, + fs::DEFAULT_SAVE_MOUNT, + task); unzClose(targetZip); } else { - fs::copyFile(dataStruct->m_targetPath, fs::DEFAULT_SAVE_PATH, dataStruct->m_journalSize, fs::DEFAULT_SAVE_MOUNT, task); + fs::copy_file(dataStruct->m_targetPath, + fs::DEFAULT_SAVE_PATH, + dataStruct->m_journalSize, + fs::DEFAULT_SAVE_MOUNT, + task); } // Update this just in case. - dataStruct->m_spawningState->saveDataWritten(); + dataStruct->m_spawningState->save_data_written(); task->finished(); } -static void deleteBackup(sys::Task *task, std::shared_ptr dataStruct) +static void delete_backup(sys::Task *task, std::shared_ptr dataStruct) { if (task) { - task->setStatus(strings::getByName(strings::names::DELETING_FILES, 0), dataStruct->m_targetPath.cString()); + task->set_status(strings::get_by_name(strings::names::DELETING_FILES, 0), dataStruct->m_targetPath.cString()); } - if (fslib::directoryExists(dataStruct->m_targetPath) && !fslib::deleteDirectoryRecursively(dataStruct->m_targetPath)) + if (fslib::directoryExists(dataStruct->m_targetPath) && + !fslib::deleteDirectoryRecursively(dataStruct->m_targetPath)) { logger::log("Error deleting folder backup: %s", fslib::getErrorString()); - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::POP_MESSAGES_BACKUP_MENU, 4)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::POP_MESSAGES_BACKUP_MENU, 4)); } else if (!fslib::deleteFile(dataStruct->m_targetPath)) { logger::log("Error deleting backup: %s", fslib::getErrorString()); - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::POP_MESSAGES_BACKUP_MENU, 4)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::POP_MESSAGES_BACKUP_MENU, 4)); } dataStruct->m_spawningState->refresh(); task->finished(); diff --git a/source/appstates/ExtrasMenuState.cpp b/source/appstates/ExtrasMenuState.cpp index 59d67e7..5e52077 100644 --- a/source/appstates/ExtrasMenuState.cpp +++ b/source/appstates/ExtrasMenuState.cpp @@ -12,21 +12,24 @@ namespace ExtrasMenuState::ExtrasMenuState(void) : m_extrasMenu(32, 8, 1000, 24, 555), - m_renderTarget(sdl::TextureManager::createLoadTexture(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET)) + m_renderTarget(sdl::TextureManager::createLoadTexture(SECONDARY_TARGET, + 1080, + 555, + SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET)) { const char *extrasString = nullptr; int currentString = 0; - while ((extrasString = strings::getByName(strings::names::EXTRAS_MENU, currentString++)) != nullptr) + while ((extrasString = strings::get_by_name(strings::names::EXTRAS_MENU, currentString++)) != nullptr) { - m_extrasMenu.addOption(extrasString); + m_extrasMenu.add_option(extrasString); } } void ExtrasMenuState::update(void) { - m_extrasMenu.update(AppState::hasFocus()); + m_extrasMenu.update(AppState::has_focus()); - if (input::buttonPressed(HidNpadButton_B)) + if (input::button_pressed(HidNpadButton_B)) { AppState::deactivate(); } @@ -35,6 +38,6 @@ void ExtrasMenuState::update(void) void ExtrasMenuState::render(void) { m_renderTarget->clear(colors::TRANSPARENT); - m_extrasMenu.render(m_renderTarget->get(), AppState::hasFocus()); + m_extrasMenu.render(m_renderTarget->get(), AppState::has_focus()); m_renderTarget->render(NULL, 201, 91); } diff --git a/source/appstates/MainMenuState.cpp b/source/appstates/MainMenuState.cpp index a820d0a..c334ec3 100644 --- a/source/appstates/MainMenuState.cpp +++ b/source/appstates/MainMenuState.cpp @@ -14,19 +14,23 @@ #include "strings.hpp" MainMenuState::MainMenuState(void) - : m_renderTarget(sdl::TextureManager::createLoadTexture("MainMenuTarget", 200, 555, SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET)), - m_background(sdl::TextureManager::createLoadTexture("MainMenuBackground", "romfs:/Textures/MenuBackground.png")), m_mainMenu(50, 15, 555), - m_controlGuide(strings::getByName(strings::names::CONTROL_GUIDES, 0)), m_controlGuideX(1220 - sdl::text::getWidth(22, m_controlGuide)) + : m_renderTarget(sdl::TextureManager::createLoadTexture("MainMenuTarget", + 200, + 555, + SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET)), + m_background(sdl::TextureManager::createLoadTexture("MainMenuBackground", "romfs:/Textures/MenuBackground.png")), + m_mainMenu(50, 15, 555), m_controlGuide(strings::get_by_name(strings::names::CONTROL_GUIDES, 0)), + m_controlGuideX(1220 - sdl::text::getWidth(22, m_controlGuide)) { // Fetch user list. - data::getUsers(sm_users); + data::get_users(sm_users); // Loop through add user's icon to menu and create states. for (size_t i = 0; i < sm_users.size(); i++) { - m_mainMenu.addOption(sm_users.at(i)->getSharedIcon()); + m_mainMenu.add_option(sm_users.at(i)->get_shared_icon()); - if (config::getByKey(config::keys::JKSM_TEXT_MODE)) + if (config::get_by_key(config::keys::JKSM_TEXT_MODE)) { sm_states.push_back(std::make_shared(sm_users.at(i))); } @@ -44,34 +48,34 @@ MainMenuState::MainMenuState(void) m_extrasIcon = sdl::TextureManager::createLoadTexture("ExtrasIcon", "romfs:/Textures/ExtrasIcon.png"); // Finally add them to the end. - m_mainMenu.addOption(m_settingsIcon); - m_mainMenu.addOption(m_extrasIcon); + m_mainMenu.add_option(m_settingsIcon); + m_mainMenu.add_option(m_extrasIcon); } void MainMenuState::update(void) { - m_mainMenu.update(AppState::hasFocus()); + m_mainMenu.update(AppState::has_focus()); - int selected = m_mainMenu.getSelected(); + int selected = m_mainMenu.get_selected(); - if (input::buttonPressed(HidNpadButton_A) && selected < static_cast(sm_users.size()) && - sm_users.at(selected)->getTotalDataEntries() > 0) + if (input::button_pressed(HidNpadButton_A) && selected < static_cast(sm_users.size()) && + sm_users.at(selected)->get_total_data_entries() > 0) { sm_states.at(selected)->reactivate(); - JKSV::pushState(sm_states.at(selected)); + JKSV::push_state(sm_states.at(selected)); } - else if (input::buttonPressed(HidNpadButton_A) && selected >= static_cast(sm_users.size())) + else if (input::button_pressed(HidNpadButton_A) && selected >= static_cast(sm_users.size())) { sm_states.at(selected)->reactivate(); - JKSV::pushState(sm_states.at(selected)); + JKSV::push_state(sm_states.at(selected)); } - else if (input::buttonPressed(HidNpadButton_X) && selected < static_cast(sm_users.size())) + else if (input::button_pressed(HidNpadButton_X) && selected < static_cast(sm_users.size())) { // Get pointers to data the user option state needs. data::User *targetUser = sm_users.at(selected); TitleSelectCommon *targetTitleSelect = reinterpret_cast(sm_states.at(selected).get()); - JKSV::pushState(std::make_shared(targetUser, targetTitleSelect)); + JKSV::push_state(std::make_shared(targetUser, targetTitleSelect)); } } @@ -80,23 +84,23 @@ void MainMenuState::render(void) // Clear render target by rendering background to it. m_background->render(m_renderTarget->get(), 0, 0); // render menu. - m_mainMenu.render(m_renderTarget->get(), AppState::hasFocus()); + m_mainMenu.render(m_renderTarget->get(), AppState::has_focus()); // render target to screen. m_renderTarget->render(NULL, 0, 91); // render next state for current user and control guide if this state has focus. - if (AppState::hasFocus()) + if (AppState::has_focus()) { - sm_states.at(m_mainMenu.getSelected())->render(); + sm_states.at(m_mainMenu.get_selected())->render(); sdl::text::render(NULL, m_controlGuideX, 673, 22, sdl::text::NO_TEXT_WRAP, colors::WHITE, m_controlGuide); } } -void MainMenuState::refreshViewStates(void) +void MainMenuState::refresh_view_states(void) { for (size_t i = 0; i < sm_users.size(); i++) { - sm_users.at(i)->sortData(); + sm_users.at(i)->sort_data(); std::static_pointer_cast(sm_states.at(i))->refresh(); } } diff --git a/source/appstates/ProgressState.cpp b/source/appstates/ProgressState.cpp index a680283..3c0c3e7 100644 --- a/source/appstates/ProgressState.cpp +++ b/source/appstates/ProgressState.cpp @@ -10,19 +10,19 @@ void ProgressState::update(void) { - if (m_task.isRunning() && input::buttonPressed(HidNpadButton_Plus)) + if (m_task.is_running() && input::button_pressed(HidNpadButton_Plus)) { - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::POP_MESSAGES_BACKUP_MENU, 0)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::POP_MESSAGES_BACKUP_MENU, 0)); } - else if (!m_task.isRunning()) + else if (!m_task.is_running()) { AppState::deactivate(); } - m_progressBarWidth = std::ceil(656.0f * m_task.getCurrent()); - m_progress = std::ceil(m_task.getCurrent() * 100); - m_percentageString = stringutil::getFormattedString("%u", m_progress); + m_progressBarWidth = std::ceil(656.0f * m_task.get_current()); + m_progress = std::ceil(m_task.get_current() * 100); + m_percentageString = stringutil::get_formatted_string("%u", m_progress); m_percentageX = 640 - (sdl::text::getWidth(18, m_percentageString.c_str())); } @@ -32,9 +32,16 @@ void ProgressState::render(void) sdl::renderRectFill(NULL, 0, 0, 1280, 720, colors::DIM_BACKGROUND); // Render the dialog and little loading bar thingy. - ui::renderDialogBox(NULL, 280, 262, 720, 256); - sdl::text::render(NULL, 312, 288, 18, 648, colors::WHITE, m_task.getStatus().c_str()); + ui::render_dialog_box(NULL, 280, 262, 720, 256); + sdl::text::render(NULL, 312, 288, 18, 648, colors::WHITE, m_task.get_status().c_str()); sdl::renderRectFill(NULL, 312, 462, 656, 32, colors::BLACK); sdl::renderRectFill(NULL, 312, 462, m_progressBarWidth, 32, colors::GREEN); - sdl::text::render(NULL, m_percentageX, 468, 18, sdl::text::NO_TEXT_WRAP, colors::WHITE, "%s%%", m_percentageString.c_str()); + sdl::text::render(NULL, + m_percentageX, + 468, + 18, + sdl::text::NO_TEXT_WRAP, + colors::WHITE, + "%s%%", + m_percentageString.c_str()); } diff --git a/source/appstates/SaveCreateState.cpp b/source/appstates/SaveCreateState.cpp index b4536e0..56468ba 100644 --- a/source/appstates/SaveCreateState.cpp +++ b/source/appstates/SaveCreateState.cpp @@ -14,10 +14,10 @@ #include // This sorts the vector alphabetically so stuff is easier to find -static bool compareInfo(data::TitleInfo *infoA, data::TitleInfo *infoB) +static bool compare_info(data::TitleInfo *infoA, data::TitleInfo *infoB) { - const char *titleA = infoA->getTitle(); - const char *titleB = infoB->getTitle(); + const char *titleA = infoA->get_title(); + const char *titleB = infoB->get_title(); size_t titleALength = std::char_traits::length(titleA); size_t titleBLength = std::char_traits::length(titleB); @@ -48,7 +48,7 @@ static bool compareInfo(data::TitleInfo *infoA, data::TitleInfo *infoB) } // Declarations here. Definitions under class. -static void createSaveData(sys::Task *task, data::User *targetUser, data::TitleInfo *titleInfo); +static void create_save_data(sys::Task *task, data::User *targetUser, data::TitleInfo *titleInfo); SaveCreateState::SaveCreateState(data::User *targetUser, TitleSelectCommon *titleSelect) : m_user(targetUser), m_titleSelect(titleSelect), m_saveMenu(8, 8, 624, 22, 720) @@ -61,32 +61,32 @@ SaveCreateState::SaveCreateState(data::User *targetUser, TitleSelectCommon *titl } // Get title info vector and copy titles to menu. - data::getTitleInfoByType(m_user->getAccountSaveType(), m_titleInfoVector); + data::get_title_info_by_type(m_user->get_account_save_type(), m_titleInfoVector); // Sort it by alpha - std::sort(m_titleInfoVector.begin(), m_titleInfoVector.end(), compareInfo); + std::sort(m_titleInfoVector.begin(), m_titleInfoVector.end(), compare_info); for (size_t i = 0; i < m_titleInfoVector.size(); i++) { - m_saveMenu.addOption(m_titleInfoVector.at(i)->getTitle()); + m_saveMenu.add_option(m_titleInfoVector.at(i)->get_title()); } } void SaveCreateState::update(void) { - m_saveMenu.update(AppState::hasFocus()); - sm_slidePanel->update(AppState::hasFocus()); + m_saveMenu.update(AppState::has_focus()); + sm_slidePanel->update(AppState::has_focus()); - if (input::buttonPressed(HidNpadButton_A)) + if (input::button_pressed(HidNpadButton_A)) { - data::TitleInfo *targetTitle = m_titleInfoVector.at(m_saveMenu.getSelected()); - JKSV::pushState(std::make_shared(createSaveData, m_user, targetTitle)); + data::TitleInfo *targetTitle = m_titleInfoVector.at(m_saveMenu.get_selected()); + JKSV::push_state(std::make_shared(create_save_data, m_user, targetTitle)); } - else if (input::buttonPressed(HidNpadButton_B)) + else if (input::button_pressed(HidNpadButton_B)) { sm_slidePanel->close(); } - else if (sm_slidePanel->isClosed()) + else if (sm_slidePanel->is_closed()) { sm_slidePanel->reset(); AppState::deactivate(); @@ -96,26 +96,26 @@ void SaveCreateState::update(void) void SaveCreateState::render(void) { // Clear slide target, render menu, render slide to frame buffer. - sm_slidePanel->clearTarget(); - m_saveMenu.render(sm_slidePanel->get(), AppState::hasFocus()); - sm_slidePanel->render(NULL, AppState::hasFocus()); + sm_slidePanel->clear_target(); + m_saveMenu.render(sm_slidePanel->get(), AppState::has_focus()); + sm_slidePanel->render(NULL, AppState::has_focus()); } -static void createSaveData(sys::Task *task, data::User *targetUser, data::TitleInfo *titleInfo) +static void create_save_data(sys::Task *task, data::User *targetUser, data::TitleInfo *titleInfo) { // Set status. We'll just borrow the string from the other group. - task->setStatus(strings::getByName(strings::names::USER_OPTION_STATUS, 0), titleInfo->getTitle()); + task->set_status(strings::get_by_name(strings::names::USER_OPTION_STATUS, 0), titleInfo->get_title()); - if (fs::createSaveDataFor(targetUser, titleInfo)) + if (fs::create_save_data_for(targetUser, titleInfo)) { - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::POP_MESSAGES_SAVE_CREATE, 0), - titleInfo->getTitle()); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::POP_MESSAGES_SAVE_CREATE, 0), + titleInfo->get_title()); } else { - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::POP_MESSAGES_SAVE_CREATE, 1)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::POP_MESSAGES_SAVE_CREATE, 1)); } task->finished(); } diff --git a/source/appstates/SettingsState.cpp b/source/appstates/SettingsState.cpp index 024546b..e61715f 100644 --- a/source/appstates/SettingsState.cpp +++ b/source/appstates/SettingsState.cpp @@ -15,35 +15,38 @@ namespace } // namespace // Declarations. Definitions after class members. -static const char *getValueText(uint8_t value); -static const char *getSortTypeText(uint8_t value); +static const char *get_value_text(uint8_t value); +static const char *get_sort_type_text(uint8_t value); SettingsState::SettingsState(void) : m_settingsMenu(32, 8, 1000, 24, 555), - m_renderTarget(sdl::TextureManager::createLoadTexture(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET)), - m_controlGuideX(1220 - sdl::text::getWidth(22, strings::getByName(strings::names::CONTROL_GUIDES, 3))) + m_renderTarget(sdl::TextureManager::createLoadTexture(SECONDARY_TARGET, + 1080, + 555, + SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET)), + m_controlGuideX(1220 - sdl::text::getWidth(22, strings::get_by_name(strings::names::CONTROL_GUIDES, 3))) { // Loop and allocation the strings and menu options. int currentString = 0; const char *settingsString = nullptr; - while ((settingsString = strings::getByName(strings::names::SETTINGS_MENU, currentString++)) != nullptr) + while ((settingsString = strings::get_by_name(strings::names::SETTINGS_MENU, currentString++)) != nullptr) { - m_settingsMenu.addOption(settingsString); + m_settingsMenu.add_option(settingsString); } // Run the update routine so they're right. - SettingsState::updateMenuOptions(); + SettingsState::update_menu_options(); } void SettingsState::update(void) { - m_settingsMenu.update(AppState::hasFocus()); + m_settingsMenu.update(AppState::has_focus()); - if (input::buttonPressed(HidNpadButton_A)) + if (input::button_pressed(HidNpadButton_A)) { - SettingsState::toggleOptions(); + SettingsState::toggle_options(); } - else if (input::buttonPressed(HidNpadButton_B)) + else if (input::button_pressed(HidNpadButton_B)) { AppState::deactivate(); } @@ -52,10 +55,10 @@ void SettingsState::update(void) void SettingsState::render(void) { m_renderTarget->clear(colors::TRANSPARENT); - m_settingsMenu.render(m_renderTarget->get(), AppState::hasFocus()); + m_settingsMenu.render(m_renderTarget->get(), AppState::has_focus()); m_renderTarget->render(NULL, 201, 91); - if (AppState::hasFocus()) + if (AppState::has_focus()) { sdl::text::render(NULL, m_controlGuideX, @@ -63,91 +66,94 @@ void SettingsState::render(void) 22, sdl::text::NO_TEXT_WRAP, colors::WHITE, - strings::getByName(strings::names::CONTROL_GUIDES, 3)); + strings::get_by_name(strings::names::CONTROL_GUIDES, 3)); } } -void SettingsState::updateMenuOptions(void) +void SettingsState::update_menu_options(void) { // These can be looped, so screw it. for (int i = 2; i < 13; i++) { std::string updatedOption = - stringutil::getFormattedString(strings::getByName(strings::names::SETTINGS_MENU, i), getValueText(config::getByIndex(i - 2))); - m_settingsMenu.editOption(i, updatedOption); + stringutil::get_formatted_string(strings::get_by_name(strings::names::SETTINGS_MENU, i), + get_value_text(config::get_by_index(i - 2))); + m_settingsMenu.edit_option(i, updatedOption); } // This just displays the value. The config value is offset to account for the first two settings options. - m_settingsMenu.editOption(13, - stringutil::getFormattedString(strings::getByName(strings::names::SETTINGS_MENU, 13), config::getByIndex(11))); + m_settingsMenu.edit_option(13, + stringutil::get_formatted_string(strings::get_by_name(strings::names::SETTINGS_MENU, 13), + config::get_by_index(11))); // This gets the type according to the value. - m_settingsMenu.editOption( - 14, - stringutil::getFormattedString(strings::getByName(strings::names::SETTINGS_MENU, 14), getSortTypeText(config::getByIndex(12)))); + m_settingsMenu.edit_option(14, + stringutil::get_formatted_string(strings::get_by_name(strings::names::SETTINGS_MENU, 14), + get_sort_type_text(config::get_by_index(12)))); // Loop again. for (int i = 15; i < 18; i++) { std::string updatedOption = - stringutil::getFormattedString(strings::getByName(strings::names::SETTINGS_MENU, i), getValueText(config::getByIndex(i - 2))); - m_settingsMenu.editOption(i, updatedOption); + stringutil::get_formatted_string(strings::get_by_name(strings::names::SETTINGS_MENU, i), + get_value_text(config::get_by_index(i - 2))); + m_settingsMenu.edit_option(i, updatedOption); } // Animating scaling. - m_settingsMenu.editOption( - 18, - stringutil::getFormattedString(strings::getByName(strings::names::SETTINGS_MENU, 18), config::getAnimationScaling())); + m_settingsMenu.edit_option(18, + stringutil::get_formatted_string(strings::get_by_name(strings::names::SETTINGS_MENU, 18), + config::get_animation_scaling())); } -void SettingsState::toggleOptions(void) +void SettingsState::toggle_options(void) { - int selected = m_settingsMenu.getSelected(); + int selected = m_settingsMenu.get_selected(); // These are just true or false more or less. if ((selected >= 2 && selected <= 12) || (selected >= 14 && selected <= 17)) { - config::toggleByIndex(selected - 2); + config::toggle_by_index(selected - 2); } else if (selected == 13) { // This is the zip compression level. - uint8_t zipLevel = config::getByKey(config::keys::ZIP_COMPRESSION_LEVEL); + uint8_t zipLevel = config::get_by_key(config::keys::ZIP_COMPRESSION_LEVEL); if (++zipLevel > 9) { zipLevel = 0; } - config::setByKey(config::keys::ZIP_COMPRESSION_LEVEL, zipLevel); + config::set_by_key(config::keys::ZIP_COMPRESSION_LEVEL, zipLevel); } else if (selected == 14) { // This is the title sorting type. - uint8_t sortType = config::getByKey(config::keys::TITLE_SORT_TYPE); + uint8_t sortType = config::get_by_key(config::keys::TITLE_SORT_TYPE); if (++sortType > 2) { sortType = 0; } - config::setByKey(config::keys::TITLE_SORT_TYPE, sortType); + config::set_by_key(config::keys::TITLE_SORT_TYPE, sortType); } else if (selected == 18) { // This is the animation scaling. - double scaling = config::getAnimationScaling(); + double scaling = config::get_animation_scaling(); if ((scaling += 0.25f) > 4.0f) { scaling = 1.0f; } - config::setAnimationScaling(scaling); + config::set_animation_scaling(scaling); } // Toggle the update routine. - SettingsState::updateMenuOptions(); + SettingsState::update_menu_options(); } -static const char *getValueText(uint8_t value) +static const char *get_value_text(uint8_t value) { - return value ? strings::getByName(strings::names::ON_OFF, 1) : strings::getByName(strings::names::ON_OFF, 0); + return value ? strings::get_by_name(strings::names::ON_OFF, 1) : strings::get_by_name(strings::names::ON_OFF, 0); } -static const char *getSortTypeText(uint8_t value) +static const char *get_sort_type_text(uint8_t value) { switch (value) { diff --git a/source/appstates/TaskState.cpp b/source/appstates/TaskState.cpp index 8d931f4..5f2ad2a 100644 --- a/source/appstates/TaskState.cpp +++ b/source/appstates/TaskState.cpp @@ -7,13 +7,13 @@ void TaskState::update(void) { - if (m_task.isRunning() && input::buttonPressed(HidNpadButton_Plus)) + if (m_task.is_running() && input::button_pressed(HidNpadButton_Plus)) { // Throw the message. - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::POP_MESSAGES_GENERAL, 0)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::POP_MESSAGES_GENERAL, 0)); } - if (!m_task.isRunning()) + if (!m_task.is_running()) { AppState::deactivate(); } @@ -22,7 +22,7 @@ void TaskState::update(void) void TaskState::render(void) { // Grab task string. - std::string status = m_task.getStatus(); + std::string status = m_task.get_status(); // Center so it looks perty int statusX = 640 - (sdl::text::getWidth(24, status.c_str()) / 2); // Dim the background states. diff --git a/source/appstates/TextTitleSelectState.cpp b/source/appstates/TextTitleSelectState.cpp index e3ef7b0..814ccf7 100644 --- a/source/appstates/TextTitleSelectState.cpp +++ b/source/appstates/TextTitleSelectState.cpp @@ -14,21 +14,24 @@ namespace TextTitleSelectState::TextTitleSelectState(data::User *user) : TitleSelectCommon(), m_user(user), m_titleSelectMenu(32, 8, 1000, 20, 555), - m_renderTarget(sdl::TextureManager::createLoadTexture(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET)) + m_renderTarget(sdl::TextureManager::createLoadTexture(SECONDARY_TARGET, + 1080, + 555, + SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET)) { TextTitleSelectState::refresh(); } void TextTitleSelectState::update(void) { - m_titleSelectMenu.update(AppState::hasFocus()); + m_titleSelectMenu.update(AppState::has_focus()); - if (input::buttonPressed(HidNpadButton_Y)) + if (input::button_pressed(HidNpadButton_Y)) { - config::addRemoveFavorite(m_user->getApplicationIDAt(m_titleSelectMenu.getSelected())); - MainMenuState::refreshViewStates(); + config::add_remove_favorite(m_user->get_application_id_at(m_titleSelectMenu.get_selected())); + MainMenuState::refresh_view_states(); } - else if (input::buttonPressed(HidNpadButton_B)) + else if (input::button_pressed(HidNpadButton_B)) { AppState::deactivate(); } @@ -37,20 +40,20 @@ void TextTitleSelectState::update(void) void TextTitleSelectState::render(void) { m_renderTarget->clear(colors::TRANSPARENT); - m_titleSelectMenu.render(m_renderTarget->get(), AppState::hasFocus()); - TitleSelectCommon::renderControlGuide(); + m_titleSelectMenu.render(m_renderTarget->get(), AppState::has_focus()); + TitleSelectCommon::render_control_guide(); m_renderTarget->render(NULL, 201, 91); } void TextTitleSelectState::refresh(void) { m_titleSelectMenu.reset(); - for (size_t i = 0; i < m_user->getTotalDataEntries(); i++) + for (size_t i = 0; i < m_user->get_total_data_entries(); i++) { std::string option; - uint64_t applicationID = m_user->getApplicationIDAt(i); - const char *title = data::getTitleInfoByID(applicationID)->getTitle(); - if (config::isFavorite(applicationID)) + uint64_t applicationID = m_user->get_application_id_at(i); + const char *title = data::get_title_info_by_id(applicationID)->get_title(); + if (config::is_favorite(applicationID)) { option = std::string("^\uE017^ ") + title; } @@ -58,6 +61,6 @@ void TextTitleSelectState::refresh(void) { option = title; } - m_titleSelectMenu.addOption(option.c_str()); + m_titleSelectMenu.add_option(option.c_str()); } } diff --git a/source/appstates/TitleOptionState.cpp b/source/appstates/TitleOptionState.cpp index 7232e1d..a4aeedb 100644 --- a/source/appstates/TitleOptionState.cpp +++ b/source/appstates/TitleOptionState.cpp @@ -28,7 +28,7 @@ namespace EXPORT_SVI }; // Error string template thingies. - const char ERROR_RESETTING_SAVE = "Error resetting save data: %s"; + static const char *ERROR_RESETTING_SAVE = "Error resetting save data: %s"; } // namespace // Struct to send data to functions that require confirmation. @@ -40,13 +40,14 @@ typedef struct // Declarations. Definitions after class. // I don't like this, but it needs to be like this to be usable with confirmation. -static void blacklistTitle(sys::Task *task, std::shared_ptr dataStruct); -static void deleteAllBackupsForTitle(sys::Task *task, std::shared_ptr dataStruct); -static void resetSaveData(sys::Task *task, std::shared_ptr dataStruct); -static void deleteSaveDataFromSystem(sys::Task *task, std::shared_ptr dataStruct); -static void changeOutputPath(data::TitleInfo *targetTitle); +static void blacklist_title(sys::Task *task, std::shared_ptr dataStruct); +static void delete_all_backups_for_title(sys::Task *task, std::shared_ptr dataStruct); +static void reset_save_data(sys::Task *task, std::shared_ptr dataStruct); +static void delete_save_data_from_system(sys::Task *task, std::shared_ptr dataStruct); +static void change_output_path(data::TitleInfo *targetTitle); -TitleOptionState::TitleOptionState(data::User *user, data::TitleInfo *titleInfo) : m_targetUser(user), m_titleInfo(titleInfo) +TitleOptionState::TitleOptionState(data::User *user, data::TitleInfo *titleInfo) + : m_targetUser(user), m_titleInfo(titleInfo) { // Create panel if needed. if (!sm_initialized) @@ -58,9 +59,9 @@ TitleOptionState::TitleOptionState(data::User *user, data::TitleInfo *titleInfo) // Populate menu. int stringIndex = 0; const char *currentString = nullptr; - while ((currentString = strings::getByName(strings::names::TITLE_OPTIONS, stringIndex++)) != nullptr) + while ((currentString = strings::get_by_name(strings::names::TITLE_OPTIONS, stringIndex++)) != nullptr) { - sm_titleOptionMenu->addOption(currentString); + sm_titleOptionMenu->add_option(currentString); } // Only do this once. sm_initialized = true; @@ -70,13 +71,18 @@ TitleOptionState::TitleOptionState(data::User *user, data::TitleInfo *titleInfo) void TitleOptionState::update(void) { // Update panel and menu. - sm_slidePanel->update(AppState::hasFocus()); - sm_titleOptionMenu->update(AppState::hasFocus()); + sm_slidePanel->update(AppState::has_focus()); + sm_titleOptionMenu->update(AppState::has_focus()); - if (input::buttonPressed(HidNpadButton_A)) + if (input::button_pressed(HidNpadButton_A)) { - switch (sm_titleOptionMenu->getSelected()) + switch (sm_titleOptionMenu->get_selected()) { + case INFORMATION: + { + } + break; + case BLACKLIST: { } @@ -84,74 +90,102 @@ void TitleOptionState::update(void) case CHANGE_OUTPUT: { - changeOutputPath(m_titleInfo); + change_output_path(m_titleInfo); + } + break; + + case FILE_MODE: + { } break; case DELETE_ALL_BACKUPS: { } + break; + + case RESET_SAVE_DATA: + { + } + break; + + case DELETE_SAVE_FROM_SYSTEM: + { + } + break; + + case EXTEND_CONTAINER: + { + } + break; + + case EXPORT_SVI: + { + } + break; } } - else if (input::buttonPressed(HidNpadButton_B)) + else if (input::button_pressed(HidNpadButton_B)) { sm_slidePanel->close(); } - else if (sm_slidePanel->isClosed()) + else if (sm_slidePanel->is_closed()) { // Reset static members. sm_slidePanel->reset(); - sm_titleOptionMenu->setSelected(0); + sm_titleOptionMenu->set_selected(0); AppState::deactivate(); } } void TitleOptionState::render(void) { - sm_slidePanel->clearTarget(); - sm_titleOptionMenu->render(sm_slidePanel->get(), AppState::hasFocus()); - sm_slidePanel->render(NULL, AppState::hasFocus()); + sm_slidePanel->clear_target(); + sm_titleOptionMenu->render(sm_slidePanel->get(), AppState::has_focus()); + sm_slidePanel->render(NULL, AppState::has_focus()); } -static void blacklistTitle(sys::Task *task, std::shared_ptr dataStruct) +static void blacklist_title(sys::Task *task, std::shared_ptr dataStruct) { // We're not gonna bother with a status for this. It'll flicker, but be barely noticeable. - config::addRemoveBlacklist(dataStruct->m_targetTitle->getApplicationID()); + config::add_remove_blacklist(dataStruct->m_targetTitle->get_application_id()); task->finished(); } -static void deleteAllBackupsForTitle(sys::Task *task, std::shared_ptr dataStruct) +static void delete_all_backups_for_title(sys::Task *task, std::shared_ptr dataStruct) { // Get the path. - fslib::Path titlePath = config::getWorkingDirectory() / dataStruct->m_targetTitle->getPathSafeTitle(); + fslib::Path titlePath = config::get_working_directory() / dataStruct->m_targetTitle->get_path_safe_title(); // Set the status. - task->setStatus(strings::getByName(strings::names::TITLE_OPTION_STATUS, 0), dataStruct->m_targetTitle->getTitle()); + task->set_status(strings::get_by_name(strings::names::TITLE_OPTION_STATUS, 0), + dataStruct->m_targetTitle->get_title()); // Just call this and nuke the folder. if (!fslib::deleteDirectoryRecursively(titlePath)) { - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::TITLE_OPTION_POPS, 1)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::TITLE_OPTION_POPS, 1)); } else { - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::TITLE_OPTION_POPS, 0), - dataStruct->m_targetTitle->getTitle()); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::TITLE_OPTION_POPS, 0), + dataStruct->m_targetTitle->get_title()); } task->finished(); } -static void resetSaveData(sys::Task *task, std::shared_ptr dataStruct) +static void reset_save_data(sys::Task *task, std::shared_ptr dataStruct) { // Attempt to mount save. - if (!fslib::openSaveFileSystemWithSaveDataInfo(fs::DEFAULT_SAVE_MOUNT, - *dataStruct->m_targetUser->getSaveInfoByID(dataStruct->m_targetTitle->getApplicationID()))) + if (!fslib::openSaveFileSystemWithSaveDataInfo( + fs::DEFAULT_SAVE_MOUNT, + *dataStruct->m_targetUser->get_save_info_by_id(dataStruct->m_targetTitle->get_application_id()))) { logger::log(ERROR_RESETTING_SAVE, fslib::getErrorString()); - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::TITLE_OPTION_POPS, 2)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::TITLE_OPTION_POPS, 2)); task->finished(); return; } @@ -161,8 +195,8 @@ static void resetSaveData(sys::Task *task, std::shared_ptr dataStr { fslib::closeFileSystem(fs::DEFAULT_SAVE_MOUNT); logger::log(ERROR_RESETTING_SAVE, fslib::getErrorString()); - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::TITLE_OPTION_POPS, 2)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::TITLE_OPTION_POPS, 2)); task->finished(); return; } @@ -171,50 +205,54 @@ static void resetSaveData(sys::Task *task, std::shared_ptr dataStr if (!fslib::commitDataToFileSystem(fs::DEFAULT_SAVE_MOUNT)) { fslib::closeFileSystem(fs::DEFAULT_SAVE_MOUNT); - logger(ERROR_RESETTING_SAVE, fslib::getErrorString()); - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::TITLE_OPTION_POPS, 2)); + logger::log(ERROR_RESETTING_SAVE, fslib::getErrorString()); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::TITLE_OPTION_POPS, 2)); task->finished(); return; } // Should be good to go. fslib::closeFileSystem(fs::DEFAULT_SAVE_MOUNT); - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, strings::getByName(strings::names::TITLE_OPTION_POPS, 3)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::TITLE_OPTION_POPS, 3)); task->finished(); } -static void deleteSaveDataFromSystem(sys::Task *task, std::shared_ptr dataStruct) +static void delete_save_data_from_system(sys::Task *task, std::shared_ptr dataStruct) { // Set status. We're going to borrow this string from the other state's strings. - task->setStatus(strings::getByName(strings::names::USER_OPTION_STATUS, 1), dataStruct->m_targetTitle->getTitle()); + task->set_status(strings::get_by_name(strings::names::USER_OPTION_STATUS, 1), + dataStruct->m_targetTitle->get_title()); } -static void changeOutputPath(data::TitleInfo *targetTitle) +static void change_output_path(data::TitleInfo *targetTitle) { // This is where we're writing the path. char pathBuffer[0x200] = {0}; // Header string. - std::string headerString = stringutil::getFormattedString(strings::getByName(strings::names::KEYBOARD_STRINGS, 7), targetTitle->getTitle()); + std::string headerString = + stringutil::get_formatted_string(strings::get_by_name(strings::names::KEYBOARD_STRINGS, 7), + targetTitle->get_title()); // Try to get input. - if (!keyboard::getInput(SwkbdType_QWERTY, targetTitle->getPathSafeTitle(), headerString, pathBuffer, 0x200)) + if (!keyboard::get_input(SwkbdType_QWERTY, targetTitle->get_path_safe_title(), headerString, pathBuffer, 0x200)) { return; } // Try to make sure it will work. - if (!stringutil::sanitizeStringForPath(pathBuffer, pathBuffer, 0x200)) + if (!stringutil::sanitize_string_for_path(pathBuffer, pathBuffer, 0x200)) { - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::POP_MESSAGES_TITLE_OPTIONS, 0)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::POP_MESSAGES_TITLE_OPTIONS, 0)); return; } // Rename folder to match so there are no issues. - fslib::Path oldPath = config::getWorkingDirectory() / targetTitle->getPathSafeTitle(); - fslib::Path newPath = config::getWorkingDirectory() / pathBuffer; + fslib::Path oldPath = config::get_working_directory() / targetTitle->get_path_safe_title(); + fslib::Path newPath = config::get_working_directory() / pathBuffer; if (fslib::directoryExists(oldPath) && !fslib::renameDirectory(oldPath, newPath)) { // Bail if this fails, because something is really wrong. @@ -223,11 +261,11 @@ static void changeOutputPath(data::TitleInfo *targetTitle) } // Add it to config and set target title to use it. - targetTitle->setPathSafeTitle(pathBuffer, std::strlen(pathBuffer)); - config::addCustomPath(targetTitle->getApplicationID(), pathBuffer); + targetTitle->set_path_safe_title(pathBuffer, std::strlen(pathBuffer)); + config::add_custom_path(targetTitle->get_application_id(), pathBuffer); // Pop so we know stuff happened. - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::POP_MESSAGES_TITLE_OPTIONS, 1), - pathBuffer); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::POP_MESSAGES_TITLE_OPTIONS, 1), + pathBuffer); } diff --git a/source/appstates/TitleSelectCommon.cpp b/source/appstates/TitleSelectCommon.cpp index 6a33f74..dc6620a 100644 --- a/source/appstates/TitleSelectCommon.cpp +++ b/source/appstates/TitleSelectCommon.cpp @@ -7,13 +7,13 @@ TitleSelectCommon::TitleSelectCommon(void) { if (m_titleControlsX == 0) { - m_titleControlsX = 1220 - sdl::text::getWidth(22, strings::getByName(strings::names::CONTROL_GUIDES, 1)); + m_titleControlsX = 1220 - sdl::text::getWidth(22, strings::get_by_name(strings::names::CONTROL_GUIDES, 1)); } } -void TitleSelectCommon::renderControlGuide(void) +void TitleSelectCommon::render_control_guide(void) { - if (AppState::hasFocus()) + if (AppState::has_focus()) { sdl::text::render(NULL, m_titleControlsX, @@ -21,6 +21,6 @@ void TitleSelectCommon::renderControlGuide(void) 22, sdl::text::NO_TEXT_WRAP, colors::WHITE, - strings::getByName(strings::names::CONTROL_GUIDES, 1)); + strings::get_by_name(strings::names::CONTROL_GUIDES, 1)); } } diff --git a/source/appstates/TitleSelectState.cpp b/source/appstates/TitleSelectState.cpp index 846816f..f1fd85f 100644 --- a/source/appstates/TitleSelectState.cpp +++ b/source/appstates/TitleSelectState.cpp @@ -21,59 +21,64 @@ namespace TitleSelectState::TitleSelectState(data::User *user) : TitleSelectCommon(), m_user(user), - m_renderTarget(sdl::TextureManager::createLoadTexture(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET)), + m_renderTarget(sdl::TextureManager::createLoadTexture(SECONDARY_TARGET, + 1080, + 555, + SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET)), m_titleView(m_user) {}; void TitleSelectState::update(void) { - m_titleView.update(AppState::hasFocus()); + m_titleView.update(AppState::has_focus()); - if (input::buttonPressed(HidNpadButton_A)) + if (input::button_pressed(HidNpadButton_A)) { // Get data needed to mount save. - uint64_t applicationID = m_user->getApplicationIDAt(m_titleView.getSelected()); - FsSaveDataInfo *saveInfo = m_user->getSaveInfoByID(applicationID); - data::TitleInfo *titleInfo = data::getTitleInfoByID(applicationID); + uint64_t applicationID = m_user->get_application_id_at(m_titleView.get_selected()); + FsSaveDataInfo *saveInfo = m_user->get_save_info_by_id(applicationID); + data::TitleInfo *titleInfo = data::get_title_info_by_id(applicationID); // Path to output to. - fslib::Path targetPath = config::getWorkingDirectory() / titleInfo->getPathSafeTitle(); + fslib::Path targetPath = config::get_working_directory() / titleInfo->get_path_safe_title(); if ((fslib::directoryExists(targetPath) || fslib::createDirectory(targetPath)) && fslib::openSaveFileSystemWithSaveDataInfo(fs::DEFAULT_SAVE_MOUNT, *saveInfo)) { - JKSV::pushState(std::make_shared(m_user, titleInfo, static_cast(saveInfo->save_data_type))); + JKSV::push_state(std::make_shared(m_user, + titleInfo, + static_cast(saveInfo->save_data_type))); } else { logger::log("%s", fslib::getErrorString()); } } - else if (input::buttonPressed(HidNpadButton_X)) + else if (input::button_pressed(HidNpadButton_X)) { - uint64_t applicationID = m_user->getApplicationIDAt(m_titleView.getSelected()); - data::TitleInfo *titleInfo = data::getTitleInfoByID(applicationID); + uint64_t applicationID = m_user->get_application_id_at(m_titleView.get_selected()); + data::TitleInfo *titleInfo = data::get_title_info_by_id(applicationID); - JKSV::pushState(std::make_shared(m_user, titleInfo)); + JKSV::push_state(std::make_shared(m_user, titleInfo)); } - else if (input::buttonPressed(HidNpadButton_B)) + else if (input::button_pressed(HidNpadButton_B)) { // This will reset all the tiles so they're 128x128. m_titleView.reset(); AppState::deactivate(); } - else if (input::buttonPressed(HidNpadButton_Y)) + else if (input::button_pressed(HidNpadButton_Y)) { - config::addRemoveFavorite(m_user->getApplicationIDAt(m_titleView.getSelected())); + config::add_remove_favorite(m_user->get_application_id_at(m_titleView.get_selected())); // MainMenuState has all the Users and views, so have it refresh. - MainMenuState::refreshViewStates(); + MainMenuState::refresh_view_states(); } } void TitleSelectState::render(void) { m_renderTarget->clear(colors::TRANSPARENT); - m_titleView.render(m_renderTarget->get(), AppState::hasFocus()); - TitleSelectCommon::renderControlGuide(); + m_titleView.render(m_renderTarget->get(), AppState::has_focus()); + TitleSelectCommon::render_control_guide(); m_renderTarget->render(NULL, 201, 91); } diff --git a/source/appstates/UserOptionState.cpp b/source/appstates/UserOptionState.cpp index 5285e35..5427f38 100644 --- a/source/appstates/UserOptionState.cpp +++ b/source/appstates/UserOptionState.cpp @@ -35,11 +35,11 @@ typedef struct // Declarations here. Defintions after class. // Backs up all save data for the target user. -static void backupAllForUser(sys::ProgressTask *task, std::shared_ptr dataStruct); +static void backup_all_for_user(sys::ProgressTask *task, std::shared_ptr dataStruct); // // Creates all save data for the current user. -static void createAllSaveDataForUser(sys::Task *task, std::shared_ptr dataStruct); +static void create_all_save_data_for_user(sys::Task *task, std::shared_ptr dataStruct); // // Deletes all save data from the system for the target user. -static void deleteAllSaveDataForUser(sys::Task *task, std::shared_ptr dataStruct); +static void delete_all_save_data_for_user(sys::Task *task, std::shared_ptr dataStruct); UserOptionState::UserOptionState(data::User *user, TitleSelectCommon *titleSelect) : m_user(user), m_titleSelect(titleSelect), m_userOptionMenu(8, 8, 460, 22, 720) @@ -52,91 +52,100 @@ UserOptionState::UserOptionState(data::User *user, TitleSelectCommon *titleSelec int currentStringIndex = 0; const char *currentString = nullptr; - while ((currentString = strings::getByName(strings::names::USER_OPTIONS, currentStringIndex++)) != nullptr) + while ((currentString = strings::get_by_name(strings::names::USER_OPTIONS, currentStringIndex++)) != nullptr) { - m_userOptionMenu.addOption(stringutil::getFormattedString(currentString, m_user->getNickname())); + m_userOptionMenu.add_option(stringutil::get_formatted_string(currentString, m_user->get_nickname())); } } void UserOptionState::update(void) { - m_menuPanel->update(AppState::hasFocus()); + m_menuPanel->update(AppState::has_focus()); - if (input::buttonPressed(HidNpadButton_A) && m_user->getAccountSaveType() != FsSaveDataType_System) + if (input::button_pressed(HidNpadButton_A) && m_user->get_account_save_type() != FsSaveDataType_System) { - switch (m_userOptionMenu.getSelected()) + switch (m_userOptionMenu.get_selected()) { case BACKUP_ALL: { // This is broken down to make it easier to read. std::string queryString = - stringutil::getFormattedString(strings::getByName(strings::names::USER_OPTION_CONFIRMATIONS, 0), m_user->getNickname()); + stringutil::get_formatted_string(strings::get_by_name(strings::names::USER_OPTION_CONFIRMATIONS, 0), + m_user->get_nickname()); // Data to send if confirmed. std::shared_ptr dataStruct(new UserStruct); dataStruct->m_targetUser = m_user; // State to push - std::shared_ptr> confirmBackupAll = + auto confirmBackupAll = std::make_shared>(queryString, false, - backupAllForUser, + backup_all_for_user, dataStruct); - JKSV::pushState(confirmBackupAll); + JKSV::push_state(confirmBackupAll); } break; case CREATE_SAVE: { // This just pushes the state with the menu to select. - JKSV::pushState(std::make_shared(m_user, m_titleSelect)); + JKSV::push_state(std::make_shared(m_user, m_titleSelect)); } break; case CREATE_ALL_SAVE: { std::string queryString = - stringutil::getFormattedString(strings::getByName(strings::names::USER_OPTION_CONFIRMATIONS, 1), m_user->getNickname()); + stringutil::get_formatted_string(strings::get_by_name(strings::names::USER_OPTION_CONFIRMATIONS, 1), + m_user->get_nickname()); std::shared_ptr dataStruct(new UserStruct); dataStruct->m_targetUser = m_user; - std::shared_ptr> confirmCreateAll = - std::make_shared>(queryString, true, createAllSaveDataForUser, dataStruct); + auto confirmCreateAll = + std::make_shared>(queryString, + true, + create_all_save_data_for_user, + dataStruct); // Done? - JKSV::pushState(confirmCreateAll); + JKSV::push_state(confirmCreateAll); } break; case DELETE_ALL_SAVE: { std::string queryString = - stringutil::getFormattedString(strings::getByName(strings::names::USER_OPTION_CONFIRMATIONS, 2), m_user->getNickname()); + stringutil::get_formatted_string(strings::get_by_name(strings::names::USER_OPTION_CONFIRMATIONS, 2), + m_user->get_nickname()); std::shared_ptr dataStruct(new UserStruct); dataStruct->m_targetUser = m_user; - std::shared_ptr> confirmDeleteAll = - std::make_shared>(queryString, true, deleteAllSaveDataForUser, dataStruct); + auto confirmDeleteAll = + std::make_shared>(queryString, + true, + delete_all_save_data_for_user, + dataStruct); - JKSV::pushState(confirmDeleteAll); + JKSV::push_state(confirmDeleteAll); } break; } } - else if (input::buttonPressed(HidNpadButton_B)) + else if (input::button_pressed(HidNpadButton_B)) { m_menuPanel->close(); } - else if (m_menuPanel->isClosed()) + else if (m_menuPanel->is_closed()) { AppState::deactivate(); m_menuPanel->reset(); } - m_userOptionMenu.update(AppState::hasFocus()); + m_userOptionMenu.update(AppState::has_focus()); } void UserOptionState::render(void) @@ -145,20 +154,20 @@ void UserOptionState::render(void) m_titleSelect->render(); // Render panel. - m_menuPanel->clearTarget(); - m_userOptionMenu.render(m_menuPanel->get(), AppState::hasFocus()); - m_menuPanel->render(NULL, AppState::hasFocus()); + m_menuPanel->clear_target(); + m_userOptionMenu.render(m_menuPanel->get(), AppState::has_focus()); + m_menuPanel->render(NULL, AppState::has_focus()); } -static void backupAllForUser(sys::ProgressTask *task, std::shared_ptr dataStruct) +static void backup_all_for_user(sys::ProgressTask *task, std::shared_ptr dataStruct) { data::User *targetUser = dataStruct->m_targetUser; - for (size_t i = 0; i < targetUser->getTotalDataEntries(); i++) + for (size_t i = 0; i < targetUser->get_total_data_entries(); i++) { // This should be safe like this.... - FsSaveDataInfo *currentSaveInfo = targetUser->getSaveInfoAt(i); - data::TitleInfo *currentTitle = data::getTitleInfoByID(currentSaveInfo->application_id); + FsSaveDataInfo *currentSaveInfo = targetUser->get_save_info_at(i); + data::TitleInfo *currentTitle = data::get_title_info_by_id(currentSaveInfo->application_id); if (!currentSaveInfo || !currentTitle) { @@ -166,14 +175,15 @@ static void backupAllForUser(sys::ProgressTask *task, std::shared_ptrgetPathSafeTitle(); + fslib::Path gameFolder = config::get_working_directory() / currentTitle->get_path_safe_title(); if (!fslib::directoryExists(gameFolder) && !fslib::createDirectory(gameFolder)) { continue; } // Try to mount save data. - bool saveMounted = fslib::openSaveFileSystemWithSaveDataInfo(fs::DEFAULT_SAVE_MOUNT, *targetUser->getSaveInfoAt(i)); + bool saveMounted = + fslib::openSaveFileSystemWithSaveDataInfo(fs::DEFAULT_SAVE_MOUNT, *targetUser->get_save_info_at(i)); // Check to make sure the save actually has data to avoid blanks. { @@ -181,17 +191,18 @@ static void backupAllForUser(sys::ProgressTask *task, std::shared_ptrgetPathSafeTitle() / targetUser->getPathSafeNickname() + - " - " + stringutil::getDateString() + ".zip"; + fslib::Path targetPath = config::get_working_directory() / currentTitle->get_path_safe_title() / + targetUser->get_path_safe_nickname() + + " - " + stringutil::get_date_string() + ".zip"; zipFile targetZip = zipOpen64(targetPath.cString(), APPEND_STATUS_CREATE); if (!targetZip) @@ -199,20 +210,21 @@ static void backupAllForUser(sys::ProgressTask *task, std::shared_ptrgetPathSafeTitle() / targetUser->getPathSafeNickname() + - " - " + stringutil::getDateString(); + fslib::Path targetPath = config::get_working_directory() / currentTitle->get_path_safe_title() / + targetUser->get_path_safe_nickname() + + " - " + stringutil::get_date_string(); if (!fslib::createDirectory(targetPath)) { logger::log("Error creating backup directory: %s", fslib::getErrorString()); continue; } - fs::copyDirectory(fs::DEFAULT_SAVE_PATH, targetPath, 0, {}, task); + fs::copy_directory(fs::DEFAULT_SAVE_PATH, targetPath, 0, {}, task); } if (saveMounted) @@ -223,50 +235,50 @@ static void backupAllForUser(sys::ProgressTask *task, std::shared_ptrfinished(); } -static void createAllSaveDataForUser(sys::Task *task, std::shared_ptr dataStruct) +static void create_all_save_data_for_user(sys::Task *task, std::shared_ptr dataStruct) { data::User *targetUser = dataStruct->m_targetUser; // Get title info map. - auto &titleInfoMap = data::getTitleInfoMap(); + auto &titleInfoMap = data::get_title_info_map(); // Iterate through it. for (auto &[applicationID, titleInfo] : titleInfoMap) { - if (!titleInfo.hasSaveDataType(targetUser->getAccountSaveType())) + if (!titleInfo.has_save_data_type(targetUser->get_account_save_type())) { continue; } // Set status. - task->setStatus(strings::getByName(strings::names::USER_OPTION_STATUS, 0), titleInfo.getTitle()); + task->set_status(strings::get_by_name(strings::names::USER_OPTION_STATUS, 0), titleInfo.get_title()); - if (!fs::createSaveDataFor(targetUser, &titleInfo)) + if (!fs::create_save_data_for(targetUser, &titleInfo)) { // Function should log error too. - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::POP_MESSAGES_SAVE_CREATE, 2)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::POP_MESSAGES_SAVE_CREATE, 2)); } } task->finished(); } -static void deleteAllSaveDataForUser(sys::Task *task, std::shared_ptr dataStruct) +static void delete_all_save_data_for_user(sys::Task *task, std::shared_ptr dataStruct) { data::User *targetUser = dataStruct->m_targetUser; - for (size_t i = 0; i < targetUser->getTotalDataEntries(); i++) + for (size_t i = 0; i < targetUser->get_total_data_entries(); i++) { // Grab title for title. - const char *targetTitle = data::getTitleInfoByID(targetUser->getApplicationIDAt(i))->getTitle(); + const char *target_title = data::get_title_info_by_id(targetUser->get_application_id_at(i))->get_title(); // Update thread task. - task->setStatus(strings::getByName(strings::names::USER_OPTION_STATUS, 1), targetTitle); + task->set_status(strings::get_by_name(strings::names::USER_OPTION_STATUS, 1), target_title); - if (!fs::deleteSaveData(*targetUser->getSaveInfoAt(i))) + if (!fs::delete_save_data(*targetUser->get_save_info_at(i))) { - ui::PopMessageManager::pushMessage(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, - strings::getByName(strings::names::POP_MESSAGES_SAVE_CREATE, 2)); + ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, + strings::get_by_name(strings::names::POP_MESSAGES_SAVE_CREATE, 2)); } } task->finished(); diff --git a/source/config.cpp b/source/config.cpp index a297df5..01054f7 100644 --- a/source/config.cpp +++ b/source/config.cpp @@ -33,7 +33,7 @@ namespace std::unordered_map s_pathMap; } // namespace -static void readArrayToVector(std::vector &vector, json_object *array) +static void read_array_to_vector(std::vector &vector, json_object *array) { // Just in case. Shouldn't happen though. vector.clear(); @@ -55,15 +55,15 @@ void config::initialize(void) if (!fslib::directoryExists(CONFIG_FOLDER) && !fslib::createDirectoriesRecursively(CONFIG_FOLDER)) { logger::log("Error creating config folder: %s.", fslib::getErrorString()); - config::resetToDefault(); + config::reset_to_default(); return; } - json::Object configJSON = json::newObject(json_object_from_file, CONFIG_PATH); + json::Object configJSON = json::new_object(json_object_from_file, CONFIG_PATH); if (!configJSON) { logger::log("Error opening config for reading: %s", fslib::getErrorString()); - config::resetToDefault(); + config::reset_to_default(); return; } @@ -85,11 +85,11 @@ void config::initialize(void) } else if (std::strcmp(keyName, config::keys::FAVORITES.data()) == 0) { - readArrayToVector(s_favorites, configValue); + read_array_to_vector(s_favorites, configValue); } else if (std::strcmp(keyName, config::keys::BLACKLIST.data()) == 0) { - readArrayToVector(s_blacklist, configValue); + read_array_to_vector(s_blacklist, configValue); } else { @@ -105,7 +105,7 @@ void config::initialize(void) return; } - json::Object pathsJSON = json::newObject(json_object_from_file, PATHS_PATH); + json::Object pathsJSON = json::new_object(json_object_from_file, PATHS_PATH); if (!pathsJSON) { return; @@ -126,7 +126,7 @@ void config::initialize(void) } } -void config::resetToDefault(void) +void config::reset_to_default(void) { s_workingDirectory = "sdmc:/JKSV"; s_configVector.push_back(std::make_pair(config::keys::INCLUDE_DEVICE_SAVES.data(), 0)); @@ -151,7 +151,7 @@ void config::resetToDefault(void) void config::save(void) { { - json::Object configJSON = json::newObject(json_object_new_object); + json::Object configJSON = json::new_object(json_object_new_object); // Add working directory first. json_object *workingDirectory = json_object_new_string(s_workingDirectory.cString()); @@ -173,7 +173,8 @@ void config::save(void) for (uint64_t &titleID : s_favorites) { // Need to do it like this or json-c does decimal instead of hex. - json_object *newFavorite = json_object_new_string(stringutil::getFormattedString("%016lX", titleID).c_str()); + json_object *newFavorite = + json_object_new_string(stringutil::get_formatted_string("%016lX", titleID).c_str()); json_object_array_add(favoritesArray, newFavorite); } json_object_object_add(configJSON.get(), config::keys::FAVORITES.data(), favoritesArray); @@ -182,13 +183,16 @@ void config::save(void) json_object *blacklistArray = json_object_new_array(); for (uint64_t &titleID : s_blacklist) { - json_object *newBlacklist = json_object_new_string(stringutil::getFormattedString("%016lX", titleID).c_str()); + json_object *newBlacklist = + json_object_new_string(stringutil::get_formatted_string("%016lX", titleID).c_str()); json_object_array_add(blacklistArray, newBlacklist); } json_object_object_add(configJSON.get(), config::keys::BLACKLIST.data(), blacklistArray); // Write config file - fslib::File configFile(CONFIG_PATH, FsOpenMode_Create | FsOpenMode_Write, std::strlen(json_object_get_string(configJSON.get()))); + fslib::File configFile(CONFIG_PATH, + FsOpenMode_Create | FsOpenMode_Write, + std::strlen(json_object_get_string(configJSON.get()))); if (configFile) { configFile << json_object_get_string(configJSON.get()); @@ -198,12 +202,12 @@ void config::save(void) if (!s_pathMap.empty()) { // Paths file. - json::Object pathsJSON = json::newObject(json_object_new_object); + json::Object pathsJSON = json::new_object(json_object_new_object); // Loop through map and write stuff. for (auto &[applicationID, path] : s_pathMap) { // Get ID as hex string. - std::string idHex = stringutil::getFormattedString("%016llX", applicationID); + std::string idHex = stringutil::get_formatted_string("%016llX", applicationID); // path json_object *pathObject = json_object_new_string(path.c_str()); @@ -211,7 +215,9 @@ void config::save(void) json_object_object_add(pathsJSON.get(), idHex.c_str(), pathObject); } // Write it. - fslib::File pathsFile(PATHS_PATH, FsOpenMode_Create | FsOpenMode_Write, std::strlen(json_object_get_string(pathsJSON.get()))); + fslib::File pathsFile(PATHS_PATH, + FsOpenMode_Create | FsOpenMode_Write, + std::strlen(json_object_get_string(pathsJSON.get()))); if (pathsFile) { pathsFile << json_object_get_string(pathsJSON.get()); @@ -219,10 +225,11 @@ void config::save(void) } } -uint8_t config::getByKey(std::string_view key) +uint8_t config::get_by_key(std::string_view key) { - auto findKey = - std::find_if(s_configVector.begin(), s_configVector.end(), [key](const auto &configPair) { return key == configPair.first; }); + auto findKey = std::find_if(s_configVector.begin(), s_configVector.end(), [key](const auto &configPair) { + return key == configPair.first; + }); if (findKey == s_configVector.end()) { return 0; @@ -230,11 +237,12 @@ uint8_t config::getByKey(std::string_view key) return findKey->second; } -void config::toggleByKey(std::string_view key) +void config::toggle_by_key(std::string_view key) { // Make sure the key exists first. - auto findKey = - std::find_if(s_configVector.begin(), s_configVector.end(), [key](const auto &configPair) { return key == configPair.first; }); + auto findKey = std::find_if(s_configVector.begin(), s_configVector.end(), [key](const auto &configPair) { + return key == configPair.first; + }); if (findKey == s_configVector.end()) { return; @@ -242,10 +250,11 @@ void config::toggleByKey(std::string_view key) findKey->second = findKey->second ? 0 : 1; } -void config::setByKey(std::string_view key, uint8_t value) +void config::set_by_key(std::string_view key, uint8_t value) { - auto findKey = - std::find_if(s_configVector.begin(), s_configVector.end(), [key](const auto &configPair) { return key == configPair.first; }); + auto findKey = std::find_if(s_configVector.begin(), s_configVector.end(), [key](const auto &configPair) { + return key == configPair.first; + }); if (findKey == s_configVector.end()) { return; @@ -254,7 +263,7 @@ void config::setByKey(std::string_view key, uint8_t value) } -uint8_t config::getByIndex(int index) +uint8_t config::get_by_index(int index) { if (index < 0 || index >= static_cast(s_configVector.size())) { @@ -263,7 +272,7 @@ uint8_t config::getByIndex(int index) return s_configVector.at(index).second; } -void config::toggleByIndex(int index) +void config::toggle_by_index(int index) { if (index < 0 || index >= static_cast(s_configVector.size())) { @@ -272,7 +281,7 @@ void config::toggleByIndex(int index) s_configVector[index].second = s_configVector[index].second ? 0 : 1; } -void config::setByIndex(int index, uint8_t value) +void config::set_by_index(int index, uint8_t value) { if (index < 0 || index >= static_cast(s_configVector.size())) { @@ -281,22 +290,22 @@ void config::setByIndex(int index, uint8_t value) s_configVector[index].second = value; } -fslib::Path config::getWorkingDirectory(void) +fslib::Path config::get_working_directory(void) { return s_workingDirectory; } -double config::getAnimationScaling(void) +double config::get_animation_scaling(void) { return s_uiAnimationScaling; } -void config::setAnimationScaling(double newScale) +void config::set_animation_scaling(double newScale) { s_uiAnimationScaling = newScale; } -void config::addRemoveFavorite(uint64_t applicationID) +void config::add_remove_favorite(uint64_t applicationID) { auto findTitle = std::find(s_favorites.begin(), s_favorites.end(), applicationID); if (findTitle == s_favorites.end()) @@ -309,7 +318,7 @@ void config::addRemoveFavorite(uint64_t applicationID) } } -bool config::isFavorite(uint64_t applicationID) +bool config::is_favorite(uint64_t applicationID) { if (std::find(s_favorites.begin(), s_favorites.end(), applicationID) == s_favorites.end()) { @@ -318,7 +327,7 @@ bool config::isFavorite(uint64_t applicationID) return true; } -void config::addRemoveBlacklist(uint64_t applicationID) +void config::add_remove_blacklist(uint64_t applicationID) { auto findTitle = std::find(s_blacklist.begin(), s_blacklist.end(), applicationID); if (findTitle == s_blacklist.end()) @@ -331,7 +340,7 @@ void config::addRemoveBlacklist(uint64_t applicationID) } } -bool config::isBlacklisted(uint64_t applicationID) +bool config::is_blacklisted(uint64_t applicationID) { if (std::find(s_blacklist.begin(), s_blacklist.end(), applicationID) == s_blacklist.end()) { @@ -340,12 +349,12 @@ bool config::isBlacklisted(uint64_t applicationID) return true; } -void config::addCustomPath(uint64_t applicationID, std::string_view customPath) +void config::add_custom_path(uint64_t applicationID, std::string_view customPath) { s_pathMap[applicationID] = customPath.data(); } -bool config::hasCustomPath(uint64_t applicationID) +bool config::has_custom_path(uint64_t applicationID) { if (s_pathMap.find(applicationID) == s_pathMap.end()) { @@ -354,7 +363,7 @@ bool config::hasCustomPath(uint64_t applicationID) return true; } -void config::getCustomPath(uint64_t applicationID, char *pathOut, size_t pathOutSize) +void config::get_custom_path(uint64_t applicationID, char *pathOut, size_t pathOutSize) { if (s_pathMap.find(applicationID) == s_pathMap.end()) { diff --git a/source/data/TitleInfo.cpp b/source/data/TitleInfo.cpp index d952ce8..67c066b 100644 --- a/source/data/TitleInfo.cpp +++ b/source/data/TitleInfo.cpp @@ -22,7 +22,7 @@ data::TitleInfo::TitleInfo(uint64_t applicationID) : m_applicationID(application if (R_FAILED(nsError) || nsAppControlSize < sizeof(nsControlData.nacp)) { - std::string applicationIDHex = stringutil::getFormattedString("%04X", m_applicationID & 0xFFFF); + std::string applicationIDHex = stringutil::get_formatted_string("%04X", m_applicationID & 0xFFFF); // Blank the nacp just to be sure. std::memset(&m_nacp, 0x00, sizeof(NacpStruct)); @@ -31,9 +31,9 @@ data::TitleInfo::TitleInfo(uint64_t applicationID) : m_applicationID(application snprintf(m_nacp.lang[SetLanguage_ENUS].name, 0x200, "%016lX", m_applicationID); // Path safe version of title. - if (config::hasCustomPath(m_applicationID)) + if (config::has_custom_path(m_applicationID)) { - config::getCustomPath(m_applicationID, m_pathSafeTitle, 0x200); + config::get_custom_path(m_applicationID, m_pathSafeTitle, 0x200); } else { @@ -42,9 +42,18 @@ data::TitleInfo::TitleInfo(uint64_t applicationID) : m_applicationID(application // Create a place holder icon. int textX = 128 - (sdl::text::getWidth(48, applicationIDHex.c_str()) / 2); - m_icon = sdl::TextureManager::createLoadTexture(applicationIDHex, 256, 256, SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET); + m_icon = sdl::TextureManager::createLoadTexture(applicationIDHex, + 256, + 256, + SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET); m_icon->clear(colors::DIALOG_BOX); - sdl::text::render(m_icon->get(), textX, 104, 48, sdl::text::NO_TEXT_WRAP, colors::WHITE, applicationIDHex.c_str()); + sdl::text::render(m_icon->get(), + textX, + 104, + 48, + sdl::text::NO_TEXT_WRAP, + colors::WHITE, + applicationIDHex.c_str()); } else if (R_SUCCEEDED(nsError) && R_SUCCEEDED(nacpGetLanguageEntry(&nsControlData.nacp, &languageEntry))) { @@ -53,26 +62,28 @@ data::TitleInfo::TitleInfo(uint64_t applicationID) : m_applicationID(application // Get a path safe version of the title. - if (config::hasCustomPath(m_applicationID)) + if (config::has_custom_path(m_applicationID)) { - config::getCustomPath(m_applicationID, m_pathSafeTitle, 0x200); + config::get_custom_path(m_applicationID, m_pathSafeTitle, 0x200); } - else if (!stringutil::sanitizeStringForPath(languageEntry->name, m_pathSafeTitle, 0x200)) + else if (!stringutil::sanitize_string_for_path(languageEntry->name, m_pathSafeTitle, 0x200)) { std::snprintf(m_pathSafeTitle, 0x200, "%016lX", applicationID); } // Load the icon. - m_icon = sdl::TextureManager::createLoadTexture(languageEntry->name, nsControlData.icon, nsAppControlSize - sizeof(NacpStruct)); + m_icon = sdl::TextureManager::createLoadTexture(languageEntry->name, + nsControlData.icon, + nsAppControlSize - sizeof(NacpStruct)); } } -uint64_t data::TitleInfo::getApplicationID(void) const +uint64_t data::TitleInfo::get_application_id(void) const { return m_applicationID; } -const char *data::TitleInfo::getTitle(void) +const char *data::TitleInfo::get_title(void) { NacpLanguageEntry *entry = nullptr; if (R_FAILED(nacpGetLanguageEntry(&m_nacp, &entry))) @@ -82,12 +93,12 @@ const char *data::TitleInfo::getTitle(void) return entry->name; } -const char *data::TitleInfo::getPathSafeTitle(void) +const char *data::TitleInfo::get_path_safe_title(void) { return m_pathSafeTitle; } -void data::TitleInfo::setPathSafeTitle(const char *newPathSafe, size_t newPathLength) +void data::TitleInfo::set_path_safe_title(const char *newPathSafe, size_t newPathLength) { if (newPathLength >= 0x200) { @@ -98,7 +109,7 @@ void data::TitleInfo::setPathSafeTitle(const char *newPathSafe, size_t newPathLe std::memcpy(m_pathSafeTitle, newPathSafe, newPathLength); } -const char *data::TitleInfo::getPublisher(void) +const char *data::TitleInfo::get_publisher(void) { NacpLanguageEntry *Entry = nullptr; if (R_FAILED(nacpGetLanguageEntry(&m_nacp, &Entry))) @@ -108,12 +119,12 @@ const char *data::TitleInfo::getPublisher(void) return Entry->author; } -uint64_t data::TitleInfo::getSaveDataOwnerID(void) const +uint64_t data::TitleInfo::get_save_data_owner_id(void) const { return m_nacp.save_data_owner_id; } -int64_t data::TitleInfo::getSaveDataSize(uint8_t saveType) const +int64_t data::TitleInfo::get_save_data_size(uint8_t saveType) const { switch (saveType) { @@ -156,14 +167,15 @@ int64_t data::TitleInfo::getSaveDataSize(uint8_t saveType) const return 0; } -int64_t data::TitleInfo::getSaveDataSizeMax(uint8_t saveType) const +int64_t data::TitleInfo::get_save_data_size_max(uint8_t saveType) const { switch (saveType) { case FsSaveDataType_Account: { - return m_nacp.user_account_save_data_size_max > m_nacp.user_account_save_data_size ? m_nacp.user_account_save_data_size_max - : m_nacp.user_account_save_data_size; + return m_nacp.user_account_save_data_size_max > m_nacp.user_account_save_data_size + ? m_nacp.user_account_save_data_size_max + : m_nacp.user_account_save_data_size; } break; @@ -188,8 +200,9 @@ int64_t data::TitleInfo::getSaveDataSizeMax(uint8_t saveType) const case FsSaveDataType_Cache: { - return m_nacp.cache_storage_data_and_journal_size_max > m_nacp.cache_storage_size ? m_nacp.cache_storage_data_and_journal_size_max - : m_nacp.cache_storage_size; + return m_nacp.cache_storage_data_and_journal_size_max > m_nacp.cache_storage_size + ? m_nacp.cache_storage_data_and_journal_size_max + : m_nacp.cache_storage_size; } break; @@ -202,7 +215,7 @@ int64_t data::TitleInfo::getSaveDataSizeMax(uint8_t saveType) const return 0; } -int64_t data::TitleInfo::getJournalSize(uint8_t saveType) const +int64_t data::TitleInfo::get_journal_size(uint8_t saveType) const { switch (saveType) { @@ -247,7 +260,7 @@ int64_t data::TitleInfo::getJournalSize(uint8_t saveType) const return 0; } -int64_t data::TitleInfo::getJournalSizeMax(uint8_t saveType) const +int64_t data::TitleInfo::get_journal_size_max(uint8_t saveType) const { switch (saveType) { @@ -267,8 +280,9 @@ int64_t data::TitleInfo::getJournalSizeMax(uint8_t saveType) const case FsSaveDataType_Device: { - return m_nacp.device_save_data_journal_size_max > m_nacp.device_save_data_journal_size ? m_nacp.device_save_data_journal_size_max - : m_nacp.device_save_data_journal_size; + return m_nacp.device_save_data_journal_size_max > m_nacp.device_save_data_journal_size + ? m_nacp.device_save_data_journal_size_max + : m_nacp.device_save_data_journal_size; } break; @@ -295,7 +309,7 @@ int64_t data::TitleInfo::getJournalSizeMax(uint8_t saveType) const return 0; } -bool data::TitleInfo::hasSaveDataType(uint8_t saveType) +bool data::TitleInfo::has_save_data_type(uint8_t saveType) { switch (saveType) { @@ -332,7 +346,7 @@ bool data::TitleInfo::hasSaveDataType(uint8_t saveType) return false; } -sdl::SharedTexture data::TitleInfo::getIcon(void) const +sdl::SharedTexture data::TitleInfo::get_icon(void) const { return m_icon; } diff --git a/source/data/User.cpp b/source/data/User.cpp index c8f65db..5b40cf3 100644 --- a/source/data/User.cpp +++ b/source/data/User.cpp @@ -23,21 +23,21 @@ static bool sortUserData(const data::UserDataEntry &entryA, const data::UserData auto &[saveInfoB, playStatsB] = dataB; // Favorites over all. - if (config::isFavorite(applicationIDA) != config::isFavorite(applicationIDB)) + if (config::is_favorite(applicationIDA) != config::is_favorite(applicationIDB)) { - return config::isFavorite(applicationIDA); + return config::is_favorite(applicationIDA); } - data::TitleInfo *titleInfoA = data::getTitleInfoByID(applicationIDA); - data::TitleInfo *titleInfoB = data::getTitleInfoByID(applicationIDB); - switch (config::getByKey(config::keys::TITLE_SORT_TYPE)) + data::TitleInfo *titleInfoA = data::get_title_info_by_id(applicationIDA); + data::TitleInfo *titleInfoB = data::get_title_info_by_id(applicationIDB); + switch (config::get_by_key(config::keys::TITLE_SORT_TYPE)) { // Alpha case 0: { // Get titles - const char *titleA = titleInfoA->getTitle(); - const char *titleB = titleInfoB->getTitle(); + const char *titleA = titleInfoA->get_title(); + const char *titleB = titleInfoB->get_title(); // Get the shortest of the two. size_t titleALength = std::char_traits::length(titleA); @@ -93,11 +93,11 @@ data::User::User(AccountUid accountID, FsSaveDataType saveType) : m_accountID(ac Result profileBaseError = accountProfileGet(&profile, NULL, &profileBase); if (R_FAILED(profileError) || R_FAILED(profileBaseError)) { - User::createAccount(); + User::create_account(); } else { - User::loadAccount(profile, profileBase); + User::load_account(profile, profileBase); } accountProfileClose(&profile); } @@ -107,56 +107,57 @@ data::User::User(AccountUid accountID, std::string_view pathSafeNickname, std::string_view iconPath, FsSaveDataType saveType) - : m_accountID(accountID), m_saveType(saveType), m_icon(sdl::TextureManager::createLoadTexture(pathSafeNickname, iconPath.data())) + : m_accountID(accountID), m_saveType(saveType), + m_icon(sdl::TextureManager::createLoadTexture(pathSafeNickname, iconPath.data())) { // We're just gonna use this for both. std::memcpy(m_nickname, nickname.data(), nickname.length()); std::memcpy(m_pathSafeNickname, pathSafeNickname.data(), pathSafeNickname.length()); } -void data::User::addData(const FsSaveDataInfo &saveInfo, const PdmPlayStatistics &playStats) +void data::User::add_data(const FsSaveDataInfo &saveInfo, const PdmPlayStatistics &playStats) { uint64_t applicationID = saveInfo.application_id == 0 ? saveInfo.system_save_data_id : saveInfo.application_id; m_userData.push_back(std::make_pair(applicationID, std::make_pair(saveInfo, playStats))); } -void data::User::eraseData(int index) +void data::User::erase_data(int index) { m_userData.erase(m_userData.begin() + index); } -void data::User::sortData(void) +void data::User::sort_data(void) { std::sort(m_userData.begin(), m_userData.end(), sortUserData); } -AccountUid data::User::getAccountID(void) const +AccountUid data::User::get_account_id(void) const { return m_accountID; } -FsSaveDataType data::User::getAccountSaveType(void) const +FsSaveDataType data::User::get_account_save_type(void) const { return m_saveType; } -const char *data::User::getNickname(void) const +const char *data::User::get_nickname(void) const { return m_nickname; } -const char *data::User::getPathSafeNickname(void) const +const char *data::User::get_path_safe_nickname(void) const { return m_pathSafeNickname; } -size_t data::User::getTotalDataEntries(void) const +size_t data::User::get_total_data_entries(void) const { return m_userData.size(); } -uint64_t data::User::getApplicationIDAt(int index) const +uint64_t data::User::get_application_id_at(int index) const { if (index < 0 || index >= static_cast(m_userData.size())) { @@ -165,7 +166,7 @@ uint64_t data::User::getApplicationIDAt(int index) const return m_userData.at(index).first; } -FsSaveDataInfo *data::User::getSaveInfoAt(int index) +FsSaveDataInfo *data::User::get_save_info_at(int index) { if (index < 0 || index >= static_cast(m_userData.size())) { @@ -174,7 +175,7 @@ FsSaveDataInfo *data::User::getSaveInfoAt(int index) return &m_userData.at(index).second.first; } -PdmPlayStatistics *data::User::getPlayStatsAt(int index) +PdmPlayStatistics *data::User::get_play_stats_at(int index) { if (index < 0 || index >= static_cast(m_userData.size())) { @@ -183,7 +184,7 @@ PdmPlayStatistics *data::User::getPlayStatsAt(int index) return &m_userData.at(index).second.second; } -FsSaveDataInfo *data::User::getSaveInfoByID(uint64_t applicationID) +FsSaveDataInfo *data::User::get_save_info_by_id(uint64_t applicationID) { auto findTitle = std::find_if(m_userData.begin(), m_userData.end(), [applicationID](data::UserDataEntry &entry) { return entry.first == applicationID; @@ -196,7 +197,7 @@ FsSaveDataInfo *data::User::getSaveInfoByID(uint64_t applicationID) return &findTitle->second.first; } -PdmPlayStatistics *data::User::getPlayStatsByID(uint64_t applicationID) +PdmPlayStatistics *data::User::get_play_stats_by_id(uint64_t applicationID) { auto findTitle = std::find_if(m_userData.begin(), m_userData.end(), [applicationID](data::UserDataEntry &entry) { return entry.first == applicationID; @@ -209,17 +210,17 @@ PdmPlayStatistics *data::User::getPlayStatsByID(uint64_t applicationID) return &findTitle->second.second; } -SDL_Texture *data::User::getIcon(void) +SDL_Texture *data::User::get_icon(void) { return m_icon->get(); } -sdl::SharedTexture data::User::getSharedIcon(void) +sdl::SharedTexture data::User::get_shared_icon(void) { return m_icon; } -void data::User::loadAccount(AccountProfile &profile, AccountProfileBase &profileBase) +void data::User::load_account(AccountProfile &profile, AccountProfileBase &profileBase) { // Try to load icon. uint32_t iconSize = 0; @@ -227,7 +228,7 @@ void data::User::loadAccount(AccountProfile &profile, AccountProfileBase &profil if (R_FAILED(accError)) { logger::log("Error getting user icon size: 0x%X.", accError); - User::createAccount(); + User::create_account(); return; } @@ -236,7 +237,7 @@ void data::User::loadAccount(AccountProfile &profile, AccountProfileBase &profil if (R_FAILED(accError)) { logger::log("Error loading user icon: 0x%08X.", accError); - User::createAccount(); + User::create_account(); return; } @@ -246,21 +247,24 @@ void data::User::loadAccount(AccountProfile &profile, AccountProfileBase &profil // Memcpy the nickname. std::memcpy(m_nickname, &profileBase.nickname, 0x20); - if (!stringutil::sanitizeStringForPath(m_nickname, m_pathSafeNickname, 0x20)) + if (!stringutil::sanitize_string_for_path(m_nickname, m_pathSafeNickname, 0x20)) { - std::string accountIDString = stringutil::getFormattedString("Account_%08X", m_accountID.uid[0] & 0xFFFFFFFF); + std::string accountIDString = stringutil::get_formatted_string("Account_%08X", m_accountID.uid[0] & 0xFFFFFFFF); std::memcpy(m_pathSafeNickname, accountIDString.c_str(), accountIDString.length()); } } -void data::User::createAccount(void) +void data::User::create_account(void) { // This is needed a lot here. - std::string accountIDString = stringutil::getFormattedString("Acc_%08X", m_accountID.uid[0] & 0xFFFFFFFF); + std::string accountIDString = stringutil::get_formatted_string("Acc_%08X", m_accountID.uid[0] & 0xFFFFFFFF); // Create icon int textX = 128 - (sdl::text::getWidth(ICON_FONT_SIZE, accountIDString.c_str()) / 2); - m_icon = sdl::TextureManager::createLoadTexture(accountIDString, 256, 256, SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET); + m_icon = sdl::TextureManager::createLoadTexture(accountIDString, + 256, + 256, + SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET); sdl::text::render(m_icon->get(), textX, 128 - (ICON_FONT_SIZE / 2), diff --git a/source/data/data.cpp b/source/data/data.cpp index c7c0687..e17a7b4 100644 --- a/source/data/data.cpp +++ b/source/data/data.cpp @@ -60,22 +60,25 @@ bool data::initialize(void) // Push them to the user vector. Clang-format makes this look weird... s_userVector.push_back(std::make_pair(deviceID, data::User(deviceID, - strings::getByName(strings::names::SAVE_DATA_TYPES, 3), + strings::get_by_name(strings::names::SAVE_DATA_TYPES, 3), "Device", "romfs:/Textures/SystemSaves.png", FsSaveDataType_Device))); - s_userVector.push_back(std::make_pair( - bcatID, - data::User(bcatID, strings::getByName(strings::names::SAVE_DATA_TYPES, 2), "BCAT", "romfs:/Textures/BCAT.png", FsSaveDataType_Bcat))); + s_userVector.push_back(std::make_pair(bcatID, + data::User(bcatID, + strings::get_by_name(strings::names::SAVE_DATA_TYPES, 2), + "BCAT", + "romfs:/Textures/BCAT.png", + FsSaveDataType_Bcat))); s_userVector.push_back(std::make_pair(cacheID, data::User(cacheID, - strings::getByName(strings::names::SAVE_DATA_TYPES, 5), + strings::get_by_name(strings::names::SAVE_DATA_TYPES, 5), "Cache", "romfs:/Textures/Cache.png", FsSaveDataType_Cache))); s_userVector.push_back(std::make_pair(systemID, data::User(systemID, - strings::getByName(strings::names::SAVE_DATA_TYPES, 0), + strings::get_by_name(strings::names::SAVE_DATA_TYPES, 0), "System", "romfs:/Textures/SystemSaves.png", FsSaveDataType_System))); @@ -84,7 +87,8 @@ bool data::initialize(void) int entryCount = 0, entryOffset = 0; while (R_SUCCEEDED(nsListApplicationRecord(¤tRecord, 1, entryOffset++, &entryCount)) && entryCount > 0) { - s_titleInfoMap.emplace(std::make_pair(currentRecord.application_id, data::TitleInfo(currentRecord.application_id))); + s_titleInfoMap.emplace( + std::make_pair(currentRecord.application_id, data::TitleInfo(currentRecord.application_id))); } for (int i = 0; i < 7; i++) @@ -101,8 +105,8 @@ bool data::initialize(void) FsSaveDataInfo &saveInfo = saveInfoReader.get(); // This will filter out the account system saves unless the config is set to show them. - if (!config::getByKey(config::keys::LIST_ACCOUNT_SYS_SAVES) && saveInfo.save_data_type == FsSaveDataType_System && - saveInfo.uid != 0) + if (!config::get_by_key(config::keys::LIST_ACCOUNT_SYS_SAVES) && + saveInfo.save_data_type == FsSaveDataType_System && saveInfo.uid != 0) { continue; } @@ -136,7 +140,7 @@ bool data::initialize(void) break; } - if (config::getByKey(config::keys::ONLY_LIST_MOUNTABLE) && + if (config::get_by_key(config::keys::ONLY_LIST_MOUNTABLE) && !fslib::openSaveFileSystemWithSaveDataInfo(fs::DEFAULT_SAVE_MOUNT, saveInfo)) { // Continue the loop since mounting failed. @@ -145,9 +149,10 @@ bool data::initialize(void) fslib::closeFileSystem(fs::DEFAULT_SAVE_MOUNT); // Find the user with the ID. - auto findUser = std::find_if(s_userVector.begin(), s_userVector.end(), [accountID](const UserIDPair &userPair) { - return accountID == userPair.second.getAccountID(); - }); + auto findUser = + std::find_if(s_userVector.begin(), s_userVector.end(), [accountID](const UserIDPair &userPair) { + return accountID == userPair.second.get_account_id(); + }); if (findUser == s_userVector.end()) { @@ -156,7 +161,8 @@ bool data::initialize(void) } // This is for system save data since it has no application ID. - uint64_t applicationID = (saveInfo.save_data_type == FsSaveDataType_System || saveInfo.save_data_type == FsSaveDataType_SystemBcat) + uint64_t applicationID = (saveInfo.save_data_type == FsSaveDataType_System || + saveInfo.save_data_type == FsSaveDataType_SystemBcat) ? saveInfo.system_save_data_id : saveInfo.application_id; @@ -166,28 +172,31 @@ bool data::initialize(void) } PdmPlayStatistics playStats = {0}; - Result pdmError = pdmqryQueryPlayStatisticsByApplicationIdAndUserAccountId(applicationID, saveInfo.uid, false, &playStats); + Result pdmError = pdmqryQueryPlayStatisticsByApplicationIdAndUserAccountId(applicationID, + saveInfo.uid, + false, + &playStats); if (R_FAILED(pdmError)) { // Logged, but not fatal. logger::log("Error getting play stats for %016llX: 0x%X", applicationID, pdmError); } // Push it to user. - findUser->second.addData(saveInfo, playStats); + findUser->second.add_data(saveInfo, playStats); } } // Sort data for users. for (auto &[accountID, user] : s_userVector) { - user.sortData(); + user.sort_data(); } // Wew return true; } -void data::getUsers(std::vector &vectorOut) +void data::get_users(std::vector &vectorOut) { vectorOut.clear(); for (auto &[accountID, userData] : s_userVector) @@ -196,7 +205,7 @@ void data::getUsers(std::vector &vectorOut) } } -data::TitleInfo *data::getTitleInfoByID(uint64_t applicationID) +data::TitleInfo *data::get_title_info_by_id(uint64_t applicationID) { if (s_titleInfoMap.find(applicationID) == s_titleInfoMap.end()) { @@ -205,12 +214,12 @@ data::TitleInfo *data::getTitleInfoByID(uint64_t applicationID) return &s_titleInfoMap.at(applicationID); } -std::unordered_map &data::getTitleInfoMap(void) +std::unordered_map &data::get_title_info_map(void) { return s_titleInfoMap; } -void data::getTitleInfoByType(FsSaveDataType saveType, std::vector &vectorOut) +void data::get_title_info_by_type(FsSaveDataType saveType, std::vector &vectorOut) { // Clear vector JIC vectorOut.clear(); @@ -218,7 +227,7 @@ void data::getTitleInfoByType(FsSaveDataType saveType, std::vectorm_bufferCondition.notify_one(); // Wait for other thread to signal buffer is empty. Lock is released immediately, but it works and that's what matters. std::unique_lock m_bufferLock(sharedData->m_bufferLock); - sharedData->m_bufferCondition.wait(m_bufferLock, [&sharedData]() { return sharedData->m_bufferIsFull == false; }); + sharedData->m_bufferCondition.wait(m_bufferLock, + [&sharedData]() { return sharedData->m_bufferIsFull == false; }); } } -void fs::copyFile(const fslib::Path &source, - const fslib::Path &destination, - uint64_t journalSize, - std::string_view commitDevice, - sys::ProgressTask *task) +void fs::copy_file(const fslib::Path &source, + const fslib::Path &destination, + uint64_t journalSize, + std::string_view commitDevice, + sys::ProgressTask *task) { fslib::File sourceFile(source, FsOpenMode_Read); fslib::File destinationFile(destination, FsOpenMode_Create | FsOpenMode_Write, sourceFile.getSize()); @@ -65,7 +66,7 @@ void fs::copyFile(const fslib::Path &source, // Set status if task pointer was passed. if (task) { - task->setStatus(strings::getByName(strings::names::COPYING_FILES, 0), source.cString()); + task->set_status(strings::get_by_name(strings::names::COPYING_FILES, 0), source.cString()); } // Shared struct both threads use @@ -123,18 +124,18 @@ void fs::copyFile(const fslib::Path &source, // Update task if passed. if (task) { - task->updateCurrent(static_cast(writeCount)); + task->update_current(static_cast(writeCount)); } } // Wait for read thread and free it. readThread.join(); } -void fs::copyDirectory(const fslib::Path &source, - const fslib::Path &destination, - uint64_t journalSize, - std::string_view commitDevice, - sys::ProgressTask *task) +void fs::copy_directory(const fslib::Path &source, + const fslib::Path &destination, + uint64_t journalSize, + std::string_view commitDevice, + sys::ProgressTask *task) { fslib::Directory sourceDir(source); if (!sourceDir) @@ -156,13 +157,13 @@ void fs::copyDirectory(const fslib::Path &source, continue; } - fs::copyDirectory(newSource, newDestination, journalSize, commitDevice, task); + fs::copy_directory(newSource, newDestination, journalSize, commitDevice, task); } else { fslib::Path fullSource = source / sourceDir[i]; fslib::Path fullDestination = destination / sourceDir[i]; - fs::copyFile(fullSource, fullDestination, journalSize, commitDevice, task); + fs::copy_file(fullSource, fullDestination, journalSize, commitDevice, task); } } } diff --git a/source/fs/saveDataFunctions.cpp b/source/fs/saveDataFunctions.cpp index ae8a0eb..8a131b2 100644 --- a/source/fs/saveDataFunctions.cpp +++ b/source/fs/saveDataFunctions.cpp @@ -1,22 +1,24 @@ #include "fs/saveDataFunctions.hpp" #include "logger.hpp" -bool fs::createSaveDataFor(data::User *targetUser, data::TitleInfo *titleInfo) +bool fs::create_save_data_for(data::User *targetUser, data::TitleInfo *titleInfo) { // Attributes. - FsSaveDataAttribute saveAttributes = {.application_id = titleInfo->getApplicationID(), - .uid = targetUser->getAccountSaveType() == FsSaveDataType_Account ? targetUser->getAccountID() - : data::BLANK_ACCOUNT_ID, + FsSaveDataAttribute saveAttributes = {.application_id = titleInfo->get_application_id(), + .uid = targetUser->get_account_save_type() == FsSaveDataType_Account + ? targetUser->get_account_id() + : data::BLANK_ACCOUNT_ID, .system_save_data_id = 0, - .save_data_type = targetUser->getAccountSaveType(), + .save_data_type = targetUser->get_account_save_type(), .save_data_rank = FsSaveDataRank_Primary, .save_data_index = 0}; FsSaveDataCreationInfo saveCreation = { - .save_data_size = titleInfo->getSaveDataSize(targetUser->getAccountSaveType()), - .journal_size = titleInfo->getJournalSize(targetUser->getAccountSaveType()), + .save_data_size = titleInfo->get_save_data_size(targetUser->get_account_save_type()), + .journal_size = titleInfo->get_journal_size(targetUser->get_account_save_type()), .available_size = 0x4000, - .owner_id = targetUser->getAccountSaveType() == FsSaveDataType_Bcat ? 0x010000000000000C : titleInfo->getSaveDataOwnerID(), + .owner_id = targetUser->get_account_save_type() == FsSaveDataType_Bcat ? 0x010000000000000C + : titleInfo->get_save_data_owner_id(), .flags = 0, .save_data_space_id = FsSaveDataSpaceId_User}; @@ -26,13 +28,13 @@ bool fs::createSaveDataFor(data::User *targetUser, data::TitleInfo *titleInfo) Result fsError = fsCreateSaveDataFileSystem(&saveAttributes, &saveCreation, &saveMeta); if (R_FAILED(fsError)) { - logger::log("Error creating save data for %016llX: 0x%X.", titleInfo->getApplicationID(), fsError); + logger::log("Error creating save data for %016llX: 0x%X.", titleInfo->get_application_id(), fsError); return false; } return true; } -bool fs::deleteSaveData(const FsSaveDataInfo &saveInfo) +bool fs::delete_save_data(const FsSaveDataInfo &saveInfo) { // I'm not allowing this at all. if (saveInfo.save_data_type == FsSaveDataType_System || saveInfo.save_data_type == FsSaveDataType_SystemBcat) @@ -50,7 +52,8 @@ bool fs::deleteSaveData(const FsSaveDataInfo &saveInfo) .save_data_index = saveInfo.save_data_index}; Result fsError = - fsDeleteSaveDataFileSystemBySaveDataAttribute(static_cast(saveInfo.save_data_space_id), &saveAttributes); + fsDeleteSaveDataFileSystemBySaveDataAttribute(static_cast(saveInfo.save_data_space_id), + &saveAttributes); if (R_FAILED(fsError)) { logger::log("Error deleting save data: 0x%X.", fsError); diff --git a/source/fs/zip.cpp b/source/fs/zip.cpp index 121efd3..09b732c 100644 --- a/source/fs/zip.cpp +++ b/source/fs/zip.cpp @@ -45,7 +45,8 @@ static void zipReadThreadFunction(fslib::File &source, std::shared_ptrm_bufferCondition.notify_one(); // Wait for other thread to release lock on buffer so this thread can read again. std::unique_lock m_bufferLock(sharedData->m_bufferLock); - sharedData->m_bufferCondition.wait(m_bufferLock, [&sharedData]() { return sharedData->m_bufferIsFull == false; }); + sharedData->m_bufferCondition.wait(m_bufferLock, + [&sharedData]() { return sharedData->m_bufferIsFull == false; }); } } @@ -63,11 +64,12 @@ static void unzipReadThreadFunction(unzFile source, int64_t fileSize, std::share sharedData->m_bufferCondition.notify_one(); std::unique_lock m_bufferLock(sharedData->m_bufferLock); - sharedData->m_bufferCondition.wait(m_bufferLock, [&sharedData]() { return sharedData->m_bufferIsFull == false; }); + sharedData->m_bufferCondition.wait(m_bufferLock, + [&sharedData]() { return sharedData->m_bufferIsFull == false; }); } } -void fs::copyDirectoryToZip(const fslib::Path &source, zipFile destination, sys::ProgressTask *task) +void fs::copy_directory_to_zip(const fslib::Path &source, zipFile destination, sys::ProgressTask *task) { fslib::Directory sourceDir(source); if (!sourceDir) @@ -81,7 +83,7 @@ void fs::copyDirectoryToZip(const fslib::Path &source, zipFile destination, sys: if (sourceDir.isDirectory(i)) { fslib::Path newSource = source / sourceDir[i]; - fs::copyDirectoryToZip(newSource, destination, task); + fs::copy_directory_to_zip(newSource, destination, task); } else { @@ -119,7 +121,7 @@ void fs::copyDirectoryToZip(const fslib::Path &source, zipFile destination, sys: 0, NULL, Z_DEFLATED, - config::getByKey(config::keys::ZIP_COMPRESSION_LEVEL), + config::get_by_key(config::keys::ZIP_COMPRESSION_LEVEL), 1); if (zipError != ZIP_OK) { @@ -137,7 +139,7 @@ void fs::copyDirectoryToZip(const fslib::Path &source, zipFile destination, sys: // Update task if passed. if (task) { - task->setStatus(strings::getByName(strings::names::COPYING_FILES, 1), fullSource.cString()); + task->set_status(strings::get_by_name(strings::names::COPYING_FILES, 1), fullSource.cString()); task->reset(static_cast(sourceFile.getSize())); } @@ -149,7 +151,8 @@ void fs::copyDirectoryToZip(const fslib::Path &source, zipFile destination, sys: { // Wait for buffer signal std::unique_lock m_bufferLock(sharedData->m_bufferLock); - sharedData->m_bufferCondition.wait(m_bufferLock, [&sharedData]() { return sharedData->m_bufferIsFull; }); + sharedData->m_bufferCondition.wait(m_bufferLock, + [&sharedData]() { return sharedData->m_bufferIsFull; }); // Save read count, copy shared to local. readCount = sharedData->m_readCount; @@ -169,7 +172,7 @@ void fs::copyDirectoryToZip(const fslib::Path &source, zipFile destination, sys: writeCount += readCount; if (task) { - task->updateCurrent(static_cast(writeCount)); + task->update_current(static_cast(writeCount)); } } // Wait for thread @@ -180,11 +183,11 @@ void fs::copyDirectoryToZip(const fslib::Path &source, zipFile destination, sys: } } -void fs::copyZipToDirectory(unzFile source, - const fslib::Path &destination, - uint64_t journalSize, - std::string_view commitDevice, - sys::ProgressTask *task) +void fs::copy_zip_to_directory(unzFile source, + const fslib::Path &destination, + uint64_t journalSize, + std::string_view commitDevice, + sys::ProgressTask *task) { int zipError = unzGoToFirstFile(source); if (zipError != UNZ_OK) @@ -216,7 +219,9 @@ void fs::copyZipToDirectory(unzFile source, continue; } - fslib::File destinationFile(fullDestination, FsOpenMode_Create | FsOpenMode_Write, currentFileInfo.uncompressed_size); + fslib::File destinationFile(fullDestination, + FsOpenMode_Create | FsOpenMode_Write, + currentFileInfo.uncompressed_size); if (!destinationFile) { logger::log("Error creating file from zip: %s", fslib::getErrorString()); @@ -236,16 +241,18 @@ void fs::copyZipToDirectory(unzFile source, // Set status if (task) { - task->setStatus(strings::getByName(strings::names::COPYING_FILES, 3), filename); + task->set_status(strings::get_by_name(strings::names::COPYING_FILES, 3), filename); task->reset(static_cast(currentFileInfo.uncompressed_size)); } - for (int64_t writeCount = 0, readCount = 0, journalCount = 0; writeCount < static_cast(currentFileInfo.uncompressed_size);) + for (int64_t writeCount = 0, readCount = 0, journalCount = 0; + writeCount < static_cast(currentFileInfo.uncompressed_size);) { { // Wait for buffer. std::unique_lock m_bufferLock(sharedData->m_bufferLock); - sharedData->m_bufferCondition.wait(m_bufferLock, [&sharedData]() { return sharedData->m_bufferIsFull; }); + sharedData->m_bufferCondition.wait(m_bufferLock, + [&sharedData]() { return sharedData->m_bufferIsFull; }); // Save read count for later readCount = sharedData->m_readCount; @@ -282,7 +289,7 @@ void fs::copyZipToDirectory(unzFile source, // Update status if (task) { - task->updateCurrent(writeCount); + task->update_current(writeCount); } } // Close file and commit again just for good measure. @@ -294,7 +301,7 @@ void fs::copyZipToDirectory(unzFile source, } while (unzGoToNextFile(source) != UNZ_END_OF_LIST_OF_FILE); } -bool fs::zipHasContents(const fslib::Path &zipPath) +bool fs::zip_has_contents(const fslib::Path &zipPath) { unzFile testZip = unzOpen(zipPath.cString()); if (!testZip) diff --git a/source/input.cpp b/source/input.cpp index 26cbc3a..6d58e0d 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -16,17 +16,17 @@ void input::update(void) padUpdate(&s_gamepad); } -bool input::buttonPressed(HidNpadButton button) +bool input::button_pressed(HidNpadButton button) { return (s_gamepad.buttons_cur & button) && !(s_gamepad.buttons_old & button); } -bool input::buttonHeld(HidNpadButton button) +bool input::button_held(HidNpadButton button) { return (s_gamepad.buttons_cur & button) && (s_gamepad.buttons_old & button); } -bool input::buttonReleased(HidNpadButton button) +bool input::button_released(HidNpadButton button) { return (s_gamepad.buttons_old & button) && !(s_gamepad.buttons_cur & button); } diff --git a/source/keyboard.cpp b/source/keyboard.cpp index e81547f..8966564 100644 --- a/source/keyboard.cpp +++ b/source/keyboard.cpp @@ -1,18 +1,24 @@ #include "keyboard.hpp" #include -bool keyboard::getInput(SwkbdType keyboardType, std::string_view defaultText, std::string_view header, char *stringOut, size_t stringLength) +bool keyboard::get_input(SwkbdType keyboardType, + std::string_view defaultText, + std::string_view header, + char *stringOut, + size_t stringLength) { // Setup keyboard. SwkbdConfig keyboard; - swkbdCreate(&keyboard, 0); // Old JKSV actually used dictionary words, but I don't feel like implementing them again. + swkbdCreate(&keyboard, + 0); // Old JKSV actually used dictionary words, but I don't feel like implementing them again. swkbdConfigSetBlurBackground(&keyboard, true); swkbdConfigSetInitialText(&keyboard, defaultText.data()); swkbdConfigSetHeaderText(&keyboard, header.data()); swkbdConfigSetGuideText(&keyboard, header.data()); swkbdConfigSetType(&keyboard, keyboardType); swkbdConfigSetStringLenMax(&keyboard, stringLength); - swkbdConfigSetKeySetDisableBitmask(&keyboard, SwkbdKeyDisableBitmask_ForwardSlash | SwkbdKeyDisableBitmask_Backslash); + swkbdConfigSetKeySetDisableBitmask(&keyboard, + SwkbdKeyDisableBitmask_ForwardSlash | SwkbdKeyDisableBitmask_Backslash); // If it fails, just return. if (R_FAILED(swkbdShow(&keyboard, stringOut, stringLength))) diff --git a/source/main.cpp b/source/main.cpp index ea8f2de..b94a5bf 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -5,7 +5,7 @@ int main(void) { JKSV jksv{}; - while (appletMainLoop() && jksv.isRunning()) + while (appletMainLoop() && jksv.is_running()) { jksv.update(); jksv.render(); diff --git a/source/strings.cpp b/source/strings.cpp index a0ce77e..856390d 100644 --- a/source/strings.cpp +++ b/source/strings.cpp @@ -32,7 +32,7 @@ namespace } // namespace // This returns the language file to use depending on the system's language. -static fslib::Path getFilePath(void) +static fslib::Path get_file_path(void) { fslib::Path returnPath = "romfs:/Text"; @@ -52,32 +52,32 @@ static fslib::Path getFilePath(void) return returnPath / s_fileMap.at(language); } -static void replaceButtonsInString(std::string &target) +static void replace_buttons_in_string(std::string &target) { - stringutil::replaceInString(target, "[A]", "\ue0e0"); - stringutil::replaceInString(target, "[B]", "\ue0e1"); - stringutil::replaceInString(target, "[X]", "\ue0e2"); - stringutil::replaceInString(target, "[Y]", "\ue0e3"); - stringutil::replaceInString(target, "[L]", "\ue0e4"); - stringutil::replaceInString(target, "[R]", "\ue0e5"); - stringutil::replaceInString(target, "[ZL]", "\ue0e6"); - stringutil::replaceInString(target, "[ZR]", "\ue0e7"); - stringutil::replaceInString(target, "[SL]", "\ue0e8"); - stringutil::replaceInString(target, "[SR]", "\ue0e9"); - stringutil::replaceInString(target, "[DPAD]", "\ue0ea"); - stringutil::replaceInString(target, "[DUP]", "\ue0eb"); - stringutil::replaceInString(target, "[DDOWN]", "\ue0ec"); - stringutil::replaceInString(target, "[DLEFT]", "\ue0ed"); - stringutil::replaceInString(target, "[DRIGHT]", "\ue0ee"); - stringutil::replaceInString(target, "[+]", "\ue0ef"); - stringutil::replaceInString(target, "[-]", "\ue0f0"); + stringutil::replace_in_string(target, "[A]", "\ue0e0"); + stringutil::replace_in_string(target, "[B]", "\ue0e1"); + stringutil::replace_in_string(target, "[X]", "\ue0e2"); + stringutil::replace_in_string(target, "[Y]", "\ue0e3"); + stringutil::replace_in_string(target, "[L]", "\ue0e4"); + stringutil::replace_in_string(target, "[R]", "\ue0e5"); + stringutil::replace_in_string(target, "[ZL]", "\ue0e6"); + stringutil::replace_in_string(target, "[ZR]", "\ue0e7"); + stringutil::replace_in_string(target, "[SL]", "\ue0e8"); + stringutil::replace_in_string(target, "[SR]", "\ue0e9"); + stringutil::replace_in_string(target, "[DPAD]", "\ue0ea"); + stringutil::replace_in_string(target, "[DUP]", "\ue0eb"); + stringutil::replace_in_string(target, "[DDOWN]", "\ue0ec"); + stringutil::replace_in_string(target, "[DLEFT]", "\ue0ed"); + stringutil::replace_in_string(target, "[DRIGHT]", "\ue0ee"); + stringutil::replace_in_string(target, "[+]", "\ue0ef"); + stringutil::replace_in_string(target, "[-]", "\ue0f0"); } bool strings::initialize() { - fslib::Path filePath = getFilePath(); + fslib::Path filePath = get_file_path(); - json::Object stringJSON = json::newObject(json_object_from_file, filePath.cString()); + json::Object stringJSON = json::new_object(json_object_from_file, filePath.cString()); if (!stringJSON) { return false; @@ -104,13 +104,13 @@ bool strings::initialize() // Loop through entire map and replace the buttons. for (auto &[key, string] : s_stringMap) { - replaceButtonsInString(string); + replace_buttons_in_string(string); } return true; } -const char *strings::getByName(std::string_view name, int index) +const char *strings::get_by_name(std::string_view name, int index) { if (s_stringMap.find(std::make_pair(name.data(), index)) == s_stringMap.end()) { diff --git a/source/stringutil.cpp b/source/stringutil.cpp index 9ef1b64..753b946 100644 --- a/source/stringutil.cpp +++ b/source/stringutil.cpp @@ -15,7 +15,7 @@ namespace {L',', L'/', L'\\', L'<', L'>', L':', L'"', L'|', L'?', L'*', L'™', L'©', L'®'}; } // namespace -std::string stringutil::getFormattedString(const char *format, ...) +std::string stringutil::get_formatted_string(const char *format, ...) { char vaBuffer[VA_BUFFER_SIZE] = {0}; @@ -27,7 +27,7 @@ std::string stringutil::getFormattedString(const char *format, ...) return std::string(vaBuffer); } -void stringutil::replaceInString(std::string &target, std::string_view find, std::string_view replace) +void stringutil::replace_in_string(std::string &target, std::string_view find, std::string_view replace) { size_t stringPosition = 0; while ((stringPosition = target.find(find, stringPosition)) != target.npos) @@ -36,7 +36,7 @@ void stringutil::replaceInString(std::string &target, std::string_view find, std } } -bool stringutil::sanitizeStringForPath(const char *stringIn, char *stringOut, size_t stringOutSize) +bool stringutil::sanitize_string_for_path(const char *stringIn, char *stringOut, size_t stringOutSize) { uint32_t codepoint = 0; size_t stringLength = std::strlen(stringIn); @@ -55,7 +55,8 @@ bool stringutil::sanitizeStringForPath(const char *stringIn, char *stringOut, si } // replace forbidden with spaces. - if (std::find(FORBIDDEN_PATH_CHARACTERS.begin(), FORBIDDEN_PATH_CHARACTERS.end(), codepoint) != FORBIDDEN_PATH_CHARACTERS.end()) + if (std::find(FORBIDDEN_PATH_CHARACTERS.begin(), FORBIDDEN_PATH_CHARACTERS.end(), codepoint) != + FORBIDDEN_PATH_CHARACTERS.end()) { stringOut[stringOutOffset++] = 0x20; } @@ -81,7 +82,7 @@ bool stringutil::sanitizeStringForPath(const char *stringIn, char *stringOut, si return true; } -std::string stringutil::getDateString(stringutil::DateFormat format) +std::string stringutil::get_date_string(stringutil::DateFormat format) { char stringBuffer[0x80] = {0}; diff --git a/source/system/ProgressTask.cpp b/source/system/ProgressTask.cpp index aa2526c..539b28c 100644 --- a/source/system/ProgressTask.cpp +++ b/source/system/ProgressTask.cpp @@ -6,17 +6,17 @@ void sys::ProgressTask::reset(double goal) m_goal = goal; } -void sys::ProgressTask::updateCurrent(double current) +void sys::ProgressTask::update_current(double current) { m_current = current; } -double sys::ProgressTask::getGoal(void) const +double sys::ProgressTask::get_goal(void) const { return m_goal; } -double sys::ProgressTask::getCurrent(void) const +double sys::ProgressTask::get_current(void) const { return m_current / m_goal; } diff --git a/source/system/Task.cpp b/source/system/Task.cpp index 5ce91ee..bbfdc2c 100644 --- a/source/system/Task.cpp +++ b/source/system/Task.cpp @@ -12,7 +12,7 @@ sys::Task::~Task() m_thread.join(); } -bool sys::Task::isRunning(void) const +bool sys::Task::is_running(void) const { return m_isRunning; } @@ -22,7 +22,7 @@ void sys::Task::finished(void) m_isRunning = false; } -void sys::Task::setStatus(const char *format, ...) +void sys::Task::set_status(const char *format, ...) { char vaBuffer[VA_BUFFER_SIZE] = {0}; @@ -35,7 +35,7 @@ void sys::Task::setStatus(const char *format, ...) m_status = vaBuffer; } -std::string sys::Task::getStatus(void) +std::string sys::Task::get_status(void) { std::scoped_lock StatusLock(m_statusLock); return m_status; diff --git a/source/system/Timer.cpp b/source/system/Timer.cpp index 949f91d..09b2a8d 100644 --- a/source/system/Timer.cpp +++ b/source/system/Timer.cpp @@ -18,7 +18,7 @@ void sys::Timer::start(uint64_t triggerTicks) m_triggerTicks = triggerTicks; } -bool sys::Timer::isTriggered(void) +bool sys::Timer::is_triggered(void) { uint64_t currentTicks = SDL_GetTicks64(); diff --git a/source/ui/IconMenu.cpp b/source/ui/IconMenu.cpp index b3b6a76..fc15340 100644 --- a/source/ui/IconMenu.cpp +++ b/source/ui/IconMenu.cpp @@ -24,7 +24,7 @@ void ui::IconMenu::render(SDL_Texture *target, bool hasFocus) { if (hasFocus) { - ui::renderBoundingBox(target, m_x - 8, tempY - 8, 152, 146, m_colorMod); + ui::render_bounding_box(target, m_x - 8, tempY - 8, 152, 146, m_colorMod); } sdl::renderRectFill(m_optionTarget->get(), 0, 0, 4, 130, {0x00FFC5FF}); } @@ -34,9 +34,9 @@ void ui::IconMenu::render(SDL_Texture *target, bool hasFocus) } } -void ui::IconMenu::addOption(sdl::SharedTexture newOption) +void ui::IconMenu::add_option(sdl::SharedTexture newOption) { // Parent needs a text option to work correctly. - Menu::addOption("ICON"); + Menu::add_option("ICON"); m_options.push_back(newOption); } diff --git a/source/ui/Menu.cpp b/source/ui/Menu.cpp index ea0ec09..6a638b8 100644 --- a/source/ui/Menu.cpp +++ b/source/ui/Menu.cpp @@ -6,14 +6,16 @@ #include ui::Menu::Menu(int x, int y, int width, int fontSize, int renderTargetHeight) - : m_x(x), m_y(y), m_optionHeight(std::ceil(static_cast(fontSize) * 1.8f)), m_originalY(y), m_targetY(y), m_width(width), - m_fontSize(fontSize), m_renderTargetHeight(renderTargetHeight) + : m_x(x), m_y(y), m_optionHeight(std::ceil(static_cast(fontSize) * 1.8f)), m_originalY(y), m_targetY(y), + m_width(width), m_fontSize(fontSize), m_renderTargetHeight(renderTargetHeight) { // Create render target for options static int MENU_ID = 0; std::string menuTargetName = "MENU_" + std::to_string(MENU_ID++); - m_optionTarget = - sdl::TextureManager::createLoadTexture(menuTargetName, m_width, m_optionHeight, SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET); + m_optionTarget = sdl::TextureManager::createLoadTexture(menuTargetName, + m_width, + m_optionHeight, + SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET); // Calculate around how many options can be shown on the render target at once. m_maxDisplayOptions = (renderTargetHeight - m_originalY) / m_optionHeight; @@ -29,27 +31,27 @@ void ui::Menu::update(bool hasFocus) } int optionsSize = m_options.size(); - if (input::buttonPressed(HidNpadButton_AnyUp) && --m_selected < 0) + if (input::button_pressed(HidNpadButton_AnyUp) && --m_selected < 0) { m_selected = optionsSize - 1; } - else if (input::buttonPressed(HidNpadButton_AnyDown) && ++m_selected >= optionsSize) + else if (input::button_pressed(HidNpadButton_AnyDown) && ++m_selected >= optionsSize) { m_selected = 0; } - else if (input::buttonPressed(HidNpadButton_AnyLeft) && (m_selected -= m_scrollLength) < 0) + else if (input::button_pressed(HidNpadButton_AnyLeft) && (m_selected -= m_scrollLength) < 0) { m_selected = 0; } - else if (input::buttonPressed(HidNpadButton_AnyRight) && (m_selected += m_scrollLength) >= optionsSize) + else if (input::button_pressed(HidNpadButton_AnyRight) && (m_selected += m_scrollLength) >= optionsSize) { m_selected = optionsSize - 1; } - else if (input::buttonPressed(HidNpadButton_L) && (m_selected -= m_scrollLength * 3) < 0) + else if (input::button_pressed(HidNpadButton_L) && (m_selected -= m_scrollLength * 3) < 0) { m_selected = 0; } - else if (input::buttonPressed(HidNpadButton_R) && (m_selected += m_scrollLength * 3) >= optionsSize) + else if (input::button_pressed(HidNpadButton_R) && (m_selected += m_scrollLength * 3) >= optionsSize) { m_selected = optionsSize - 1; } @@ -75,7 +77,7 @@ void ui::Menu::update(bool hasFocus) if (m_y != m_targetY) { - m_y += std::ceil((m_targetY - m_y) / config::getAnimationScaling()); + m_y += std::ceil((m_targetY - m_y) / config::get_animation_scaling()); } } @@ -111,7 +113,7 @@ void ui::Menu::render(SDL_Texture *target, bool hasFocus) if (hasFocus) { // render the bounding box - ui::renderBoundingBox(target, m_x - 4, tempY - 4, m_width + 8, m_optionHeight + 8, m_colorMod); + ui::render_bounding_box(target, m_x - 4, tempY - 4, m_width + 8, m_optionHeight + 8, m_colorMod); } // render the little rectangle. sdl::renderRectFill(m_optionTarget->get(), 8, 8, 4, m_optionHeight - 16, colors::BLUE_GREEN); @@ -129,12 +131,12 @@ void ui::Menu::render(SDL_Texture *target, bool hasFocus) } } -void ui::Menu::addOption(std::string_view newOption) +void ui::Menu::add_option(std::string_view newOption) { m_options.push_back(newOption.data()); } -void ui::Menu::editOption(int index, std::string_view newOption) +void ui::Menu::edit_option(int index, std::string_view newOption) { if (index < 0 || index >= static_cast(m_options.size())) { @@ -143,17 +145,17 @@ void ui::Menu::editOption(int index, std::string_view newOption) m_options[index] = newOption.data(); } -int ui::Menu::getSelected(void) const +int ui::Menu::get_selected(void) const { return m_selected; } -void ui::Menu::setSelected(int selected) +void ui::Menu::set_selected(int selected) { m_selected = selected; } -void ui::Menu::setWidth(int width) +void ui::Menu::set_width(int width) { m_width = width; } diff --git a/source/ui/PopMessageManager.cpp b/source/ui/PopMessageManager.cpp index 6aa17b4..5f85919 100644 --- a/source/ui/PopMessageManager.cpp +++ b/source/ui/PopMessageManager.cpp @@ -16,7 +16,7 @@ namespace void ui::PopMessageManager::update(void) { // Grab instance. - PopMessageManager &manager = PopMessageManager::getInstance(); + PopMessageManager &manager = PopMessageManager::get_instance(); // Bail if the queue is empty. if (!manager.m_messageQueue.empty()) @@ -38,14 +38,14 @@ void ui::PopMessageManager::update(void) // Update all the messages. // This is the first Y position a message should be displayed at.; double currentY = 594.0f; - double animationScaling = config::getAnimationScaling(); + double animationScaling = config::get_animation_scaling(); for (size_t i = 0; i < manager.m_messages.size(); i++) { // Save myself a shit load of typing. ui::PopMessage ¤tMessage = manager.m_messages.at(i); // Purge it and continue if needed. - if (currentMessage.m_timer.isTriggered()) + if (currentMessage.m_timer.is_triggered()) { manager.m_messages.erase(manager.m_messages.begin() + i); continue; @@ -68,19 +68,25 @@ void ui::PopMessageManager::update(void) void ui::PopMessageManager::render(void) { // Get instance. - PopMessageManager &manager = PopMessageManager::getInstance(); + PopMessageManager &manager = PopMessageManager::get_instance(); // Loop and render. for (auto &popMessage : manager.m_messages) { // Render a dialog box around it. - ui::renderDialogBox(NULL, 20, popMessage.m_y - 6, popMessage.m_width, 52); + ui::render_dialog_box(NULL, 20, popMessage.m_y - 6, popMessage.m_width, 52); // Render the actual text. - sdl::text::render(NULL, 36, popMessage.m_y, 32, sdl::text::NO_TEXT_WRAP, colors::WHITE, popMessage.m_message.c_str()); + sdl::text::render(NULL, + 36, + popMessage.m_y, + 32, + sdl::text::NO_TEXT_WRAP, + colors::WHITE, + popMessage.m_message.c_str()); } } -void ui::PopMessageManager::pushMessage(int displayTicks, const char *format, ...) +void ui::PopMessageManager::push_message(int displayTicks, const char *format, ...) { // VA args. char vaBuffer[VA_BUFFER_SIZE] = {0}; @@ -91,7 +97,7 @@ void ui::PopMessageManager::pushMessage(int displayTicks, const char *format, .. va_end(vaList); // Get instance. - PopMessageManager &manager = PopMessageManager::getInstance(); + PopMessageManager &manager = PopMessageManager::get_instance(); // Make sure we're not pushing two of the same message. if (!manager.m_messages.empty() && manager.m_messages.back().m_message.compare(vaBuffer) == 0) diff --git a/source/ui/SlideOutPanel.cpp b/source/ui/SlideOutPanel.cpp index 6c5456b..6fbf792 100644 --- a/source/ui/SlideOutPanel.cpp +++ b/source/ui/SlideOutPanel.cpp @@ -4,16 +4,20 @@ #include ui::SlideOutPanel::SlideOutPanel(int width, Side side) - : m_x(side == Side::Left ? -width : 1280), m_width(width), m_targetX(side == Side::Left ? 0 : 1280 - m_width), m_side(side) + : m_x(side == Side::Left ? -width : 1280), m_width(width), m_targetX(side == Side::Left ? 0 : 1280 - m_width), + m_side(side) { static int slidePanelTargetID = 0; std::string panelTargetName = "PanelTarget_" + std::to_string(slidePanelTargetID++); - m_renderTarget = sdl::TextureManager::createLoadTexture(panelTargetName, width, 720, SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET); + m_renderTarget = sdl::TextureManager::createLoadTexture(panelTargetName, + width, + 720, + SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET); } void ui::SlideOutPanel::update(bool hasFocus) { - double scaling = config::getAnimationScaling(); + double scaling = config::get_animation_scaling(); // The first two conditions are just a workaround because my math keeps leaving two pixels. if (!m_isOpen && m_side == Side::Left && m_x >= -4) @@ -55,7 +59,7 @@ void ui::SlideOutPanel::render(SDL_Texture *Target, bool hasFocus) m_renderTarget->render(NULL, m_x, 0); } -void ui::SlideOutPanel::clearTarget(void) +void ui::SlideOutPanel::clear_target(void) { m_renderTarget->clear(colors::SLIDE_PANEL_CLEAR); } @@ -72,22 +76,22 @@ void ui::SlideOutPanel::close(void) m_closePanel = true; } -bool ui::SlideOutPanel::isOpen(void) const +bool ui::SlideOutPanel::is_open(void) const { return m_isOpen; } -bool ui::SlideOutPanel::isClosed(void) const +bool ui::SlideOutPanel::is_closed(void) const { return m_closePanel && (m_side == Side::Left ? m_x > -(m_width) : m_x < 1280); } -void ui::SlideOutPanel::pushNewElement(std::shared_ptr newElement) +void ui::SlideOutPanel::push_new_element(std::shared_ptr newElement) { m_elements.push_back(newElement); } -void ui::SlideOutPanel::clearElements(void) +void ui::SlideOutPanel::clear_elements(void) { m_elements.clear(); } diff --git a/source/ui/TextScroll.cpp b/source/ui/TextScroll.cpp index 2d3f0c2..4c2d542 100644 --- a/source/ui/TextScroll.cpp +++ b/source/ui/TextScroll.cpp @@ -37,7 +37,7 @@ ui::TextScroll &ui::TextScroll::operator=(const ui::TextScroll &textScroll) void ui::TextScroll::update(bool hasFocus) { // I don't think needs to care about having focus. - if (m_textScrolling && m_scrollTimer.isTriggered()) + if (m_textScrolling && m_scrollTimer.is_triggered()) { m_x -= 2; m_textScrollTriggered = true; @@ -66,6 +66,12 @@ void ui::TextScroll::render(SDL_Texture *target, bool hasFocus) { // We're going to render text twice so it looks like it's scrolling and doesn't end. Ever. sdl::text::render(target, m_x, m_y, m_fontSize, sdl::text::NO_TEXT_WRAP, m_textColor, m_text.c_str()); - sdl::text::render(target, m_x + m_textWidth + 24, m_y, m_fontSize, sdl::text::NO_TEXT_WRAP, m_textColor, m_text.c_str()); + sdl::text::render(target, + m_x + m_textWidth + 24, + m_y, + m_fontSize, + sdl::text::NO_TEXT_WRAP, + m_textColor, + m_text.c_str()); } } diff --git a/source/ui/TitleTile.cpp b/source/ui/TitleTile.cpp index 65e8061..364f5ee 100644 --- a/source/ui/TitleTile.cpp +++ b/source/ui/TitleTile.cpp @@ -36,12 +36,12 @@ void ui::TitleTile::reset(void) m_renderHeight = 128; } -int ui::TitleTile::getWidth(void) const +int ui::TitleTile::get_width(void) const { return m_renderWidth; } -int ui::TitleTile::getHeight(void) const +int ui::TitleTile::get_height(void) const { return m_renderHeight; } diff --git a/source/ui/TitleView.cpp b/source/ui/TitleView.cpp index 8a01393..40b46bb 100644 --- a/source/ui/TitleView.cpp +++ b/source/ui/TitleView.cpp @@ -31,32 +31,32 @@ void ui::TitleView::update(bool hasFocus) // Input. int totalTiles = m_titleTiles.size() - 1; - if (input::buttonPressed(HidNpadButton_AnyUp) && (m_selected -= ICON_ROW_SIZE) < 0) + if (input::button_pressed(HidNpadButton_AnyUp) && (m_selected -= ICON_ROW_SIZE) < 0) { m_selected = 0; } - else if (input::buttonPressed(HidNpadButton_AnyDown) && (m_selected += ICON_ROW_SIZE) > totalTiles) + else if (input::button_pressed(HidNpadButton_AnyDown) && (m_selected += ICON_ROW_SIZE) > totalTiles) { m_selected = totalTiles; } - else if (input::buttonPressed(HidNpadButton_AnyLeft) && m_selected > 0) + else if (input::button_pressed(HidNpadButton_AnyLeft) && m_selected > 0) { --m_selected; } - else if (input::buttonPressed(HidNpadButton_AnyRight) && m_selected < totalTiles) + else if (input::button_pressed(HidNpadButton_AnyRight) && m_selected < totalTiles) { ++m_selected; } - else if (input::buttonPressed(HidNpadButton_L) && (m_selected -= 21) < 0) + else if (input::button_pressed(HidNpadButton_L) && (m_selected -= 21) < 0) { m_selected = 0; } - else if (input::buttonPressed(HidNpadButton_R) && (m_selected += 21) > totalTiles) + else if (input::button_pressed(HidNpadButton_R) && (m_selected += 21) > totalTiles) { m_selected = totalTiles; } - double scaling = config::getAnimationScaling(); + double scaling = config::get_animation_scaling(); if (m_selectedY > 388.0f) { m_y += std::ceil((388.0f - m_selectedY) / scaling); @@ -104,12 +104,12 @@ void ui::TitleView::render(SDL_Texture *target, bool hasFocus) if (hasFocus) { sdl::renderRectFill(target, m_selectedX - 23, m_selectedY - 23, 174, 174, colors::CLEAR_COLOR); - ui::renderBoundingBox(target, m_selectedX - 24, m_selectedY - 24, 176, 176, m_colorMod); + ui::render_bounding_box(target, m_selectedX - 24, m_selectedY - 24, 176, 176, m_colorMod); } m_titleTiles.at(m_selected).render(target, m_selectedX, m_selectedY); } -int ui::TitleView::getSelected(void) const +int ui::TitleView::get_selected(void) const { return m_selected; } @@ -117,12 +117,12 @@ int ui::TitleView::getSelected(void) const void ui::TitleView::refresh(void) { m_titleTiles.clear(); - for (size_t i = 0; i < m_user->getTotalDataEntries(); i++) + for (size_t i = 0; i < m_user->get_total_data_entries(); i++) { // Get pointer to data from user save index I. - data::TitleInfo *currentTitleInfo = data::getTitleInfoByID(m_user->getApplicationIDAt(i)); + data::TitleInfo *currentTitleInfo = data::get_title_info_by_id(m_user->get_application_id_at(i)); // Emplace is faster than push - m_titleTiles.emplace_back(config::isFavorite(m_user->getApplicationIDAt(i)), currentTitleInfo->getIcon()); + m_titleTiles.emplace_back(config::is_favorite(m_user->get_application_id_at(i)), currentTitleInfo->get_icon()); } } diff --git a/source/ui/renderFunctions.cpp b/source/ui/renderFunctions.cpp index 5a3c5cb..1e11e8b 100644 --- a/source/ui/renderFunctions.cpp +++ b/source/ui/renderFunctions.cpp @@ -7,7 +7,7 @@ namespace sdl::SharedTexture s_menuBoundingCorners = nullptr; } // namespace -void ui::renderDialogBox(SDL_Texture *target, int x, int y, int width, int height) +void ui::render_dialog_box(SDL_Texture *target, int x, int y, int width, int height) { if (!s_dialogCorners) { @@ -26,11 +26,12 @@ void ui::renderDialogBox(SDL_Texture *target, int x, int y, int width, int heigh s_dialogCorners->renderPart(NULL, (x + width) - 16, (y + height) - 16, 16, 16, 16, 16); } -void ui::renderBoundingBox(SDL_Texture *target, int x, int y, int width, int height, uint8_t colorMod) +void ui::render_bounding_box(SDL_Texture *target, int x, int y, int width, int height, uint8_t colorMod) { if (!s_menuBoundingCorners) { - s_menuBoundingCorners = sdl::TextureManager::createLoadTexture("MenuBoundingCorners", "romfs:/Textures/MenuBounding.png"); + s_menuBoundingCorners = + sdl::TextureManager::createLoadTexture("MenuBoundingCorners", "romfs:/Textures/MenuBounding.png"); } // Setup color.