This commit is contained in:
J-D-K
2025-07-28 18:51:34 -04:00
parent b9b3acf7f2
commit e08984bb3f
4 changed files with 26 additions and 4 deletions

View File

@@ -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";

View File

@@ -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>"

View File

@@ -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<TitleSelectCommon *>(sm_states.at(selected).get());
TitleSelectCommon *titleSelect = static_cast<TitleSelectCommon *>(sm_states[selected].get());
auto userOptions = std::make_shared<UserOptionState>(user, titleSelect);
StateManager::push_state(userOptions);

View File

@@ -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());
}