diff --git a/include/strings.hpp b/include/strings.hpp index a332cef..584714a 100644 --- a/include/strings.hpp +++ b/include/strings.hpp @@ -25,6 +25,7 @@ namespace strings static constexpr std::string_view IO_STATUSES = "IOStatuses"; static constexpr std::string_view IO_POPS = "IOPops"; static constexpr std::string_view KEYBOARD = "KeyboardStrings"; + static constexpr std::string_view MAINMENU_POPS = "MainMenuPops"; static constexpr std::string_view ON_OFF = "OnOff"; static constexpr std::string_view SAVECREATE_POPS = "SaveCreatePops"; static constexpr std::string_view SAVE_DATA_TYPES = "SaveDataTypes"; diff --git a/romfs/Text/ENUS.json b/romfs/Text/ENUS.json index c57e2b0..7d06ba0 100644 --- a/romfs/Text/ENUS.json +++ b/romfs/Text/ENUS.json @@ -81,6 +81,9 @@ "7: Enter a new output folder name for %s.", "8: Enter how much to expand (in MB)." ], + "MainMenuPops": [ + "0: `%s` has no save data!" + ], "OnOff": [ "0: Off", "1: >On>" diff --git a/source/appstates/MainMenuState.cpp b/source/appstates/MainMenuState.cpp index 2812b8c..072d824 100644 --- a/source/appstates/MainMenuState.cpp +++ b/source/appstates/MainMenuState.cpp @@ -13,6 +13,8 @@ #include "logger.hpp" #include "sdl.hpp" #include "strings.hpp" +#include "stringutil.hpp" +#include "ui/PopMessageManager.hpp" MainMenuState::MainMenuState() : m_renderTarget{sdl::TextureManager::create_load_texture("mainMenuTarget", @@ -109,9 +111,25 @@ void MainMenuState::initialize_menu() void MainMenuState::push_target_state() { - const int selected = m_mainMenu.get_selected(); - auto &target = sm_states.at(selected); + const int popTicks = ui::PopMessageManager::DEFAULT_TICKS; + const char *popNoSaveFormat = strings::get_by_name(strings::names::MAINMENU_POPS, 0); + const int selected = m_mainMenu.get_selected(); + const int userCount = sm_users.size(); + if (selected < userCount) + { + const data::User *user = sm_users[selected]; + const int titleCount = user->get_total_data_entries(); + if (titleCount <= 0) + { + const char *nickname = user->get_nickname(); + const std::string popError = stringutil::get_formatted_string(popNoSaveFormat, nickname); + ui::PopMessageManager::push_message(popTicks, popError); + return; + } + } + + auto &target = sm_states[selected]; target->reactivate(); StateManager::push_state(target); } @@ -120,7 +138,7 @@ void MainMenuState::create_user_options() { const int selected = m_mainMenu.get_selected(); data::User *user = sm_users.at(selected); - TitleSelectCommon *titleSelect = static_cast(sm_states.at(selected).get()); + TitleSelectCommon *titleSelect = static_cast(sm_states[selected].get()); auto userOptions = std::make_shared(user, titleSelect); StateManager::push_state(userOptions); diff --git a/source/config.cpp b/source/config.cpp index 4ac6e4c..80081cc 100644 --- a/source/config.cpp +++ b/source/config.cpp @@ -256,7 +256,7 @@ bool config::has_custom_path(uint64_t applicationID) void config::get_custom_path(uint64_t applicationID, char *pathOut, size_t pathOutSize) { const auto findPath = s_pathMap.find(applicationID); - if (s_pathMap.find(applicationID) == s_pathMap.end()) { return; } + if (findPath == s_pathMap.end()) { return; } std::memcpy(pathOut, s_pathMap[applicationID].c_str(), s_pathMap[applicationID].length()); }