Begin BackupMenuState Refactor.

This commit is contained in:
J-D-K
2025-07-18 16:53:22 -04:00
parent d0c032710d
commit 3d5ddc8679
5 changed files with 146 additions and 220 deletions

View File

@@ -1,4 +1,5 @@
#include "appstates/TextTitleSelectState.hpp"
#include "StateManager.hpp"
#include "appstates/BackupMenuState.hpp"
#include "appstates/MainMenuState.hpp"
@@ -10,6 +11,7 @@
#include "input.hpp"
#include "logger.hpp"
#include "sdl.hpp"
#include <string_view>
namespace
@@ -19,8 +21,10 @@ namespace
} // namespace
TextTitleSelectState::TextTitleSelectState(data::User *user)
: TitleSelectCommon(), m_user(user), m_titleSelectMenu(32, 8, 1000, 20, 555),
m_renderTarget(sdl::TextureManager::create_load_texture(SECONDARY_TARGET,
: TitleSelectCommon()
, m_user(user)
, m_titleSelectMenu(32, 8, 1000, 20, 555)
, m_renderTarget(sdl::TextureManager::create_load_texture(SECONDARY_TARGET,
1080,
555,
SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET))
@@ -39,8 +43,8 @@ void TextTitleSelectState::update()
int selected = m_titleSelectMenu.get_selected();
// Grab what we need to continue.
uint64_t applicationID = m_user->get_application_id_at(selected);
FsSaveDataInfo *saveInfo = m_user->get_save_info_by_id(applicationID);
uint64_t applicationID = m_user->get_application_id_at(selected);
FsSaveDataInfo *saveInfo = m_user->get_save_info_by_id(applicationID);
data::TitleInfo *titleInfo = data::get_title_info_by_id(m_user->get_application_id_at(selected));
// Output path.
@@ -50,23 +54,17 @@ void TextTitleSelectState::update()
fslib::open_save_data_with_save_info(fs::DEFAULT_SAVE_MOUNT, *saveInfo))
{
// State
auto backupMenuState =
std::make_shared<BackupMenuState>(m_user,
titleInfo,
static_cast<FsSaveDataType>(saveInfo->save_data_type));
auto backupMenuState = std::make_shared<BackupMenuState>(m_user, titleInfo);
StateManager::push_state(backupMenuState);
}
else
{
logger::log(fslib::error::get_string());
}
else { logger::log(fslib::error::get_string()); }
}
else if (input::button_pressed(HidNpadButton_X))
{
int selected = m_titleSelectMenu.get_selected();
uint64_t applicationID = m_user->get_application_id_at(selected);
uint64_t applicationID = m_user->get_application_id_at(selected);
data::TitleInfo *titleInfo = data::get_title_info_by_id(applicationID);
auto titleOptionState = std::make_shared<TitleOptionState>(m_user, titleInfo, this);
@@ -82,18 +80,12 @@ void TextTitleSelectState::update()
// We need to resort all users, not just this one.
data::UserList list;
data::get_users(list);
for (data::User *user : list)
{
user->sort_data();
}
for (data::User *user : list) { user->sort_data(); }
// Let the main menu state take care of this.
MainMenuState::refresh_view_states();
}
else if (input::button_pressed(HidNpadButton_B))
{
BaseState::deactivate();
}
else if (input::button_pressed(HidNpadButton_B)) { BaseState::deactivate(); }
}
void TextTitleSelectState::render()
@@ -111,15 +103,9 @@ void TextTitleSelectState::refresh()
{
std::string option;
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;
}
else
{
option = title;
}
const char *title = data::get_title_info_by_id(applicationID)->get_title();
if (config::is_favorite(applicationID)) { option = std::string("^\uE017^ ") + title; }
else { option = title; }
m_titleSelectMenu.add_option(option.c_str());
}
}