mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-03-21 17:24:37 -05:00
tasks/backup.cpp fixes.
This commit is contained in:
parent
9c98aabdd4
commit
17410fd8a9
2
Makefile
2
Makefile
|
|
@ -39,7 +39,7 @@ INCLUDES := include ./Libraries/FsLib/Switch/FsLib/include ./Libraries/SDLLib/SD
|
|||
EXEFS_SRC := exefs_src
|
||||
APP_TITLE := JKSV
|
||||
APP_AUTHOR := JK
|
||||
APP_VERSION := 10.09.2025
|
||||
APP_VERSION := 10.10.2025
|
||||
ROMFS := romfs
|
||||
ICON := icon.jpg
|
||||
|
||||
|
|
|
|||
|
|
@ -104,9 +104,6 @@ class MainMenuState final : public BaseState
|
|||
/// @brief Silently checks for an update in the background.
|
||||
void check_for_update();
|
||||
|
||||
/// @brief Plays the little boot sound.
|
||||
void play_boot_sound();
|
||||
|
||||
/// @brief Pushes the target state to the vector.
|
||||
void push_target_state();
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@
|
|||
namespace builddate
|
||||
{
|
||||
inline constexpr int MONTH = 10;
|
||||
inline constexpr int DAY = 9;
|
||||
inline constexpr int DAY = 10;
|
||||
inline constexpr int YEAR = 2025;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,9 @@ namespace ui
|
|||
/// @brief Returns if the menu has no options.
|
||||
bool is_empty() const noexcept;
|
||||
|
||||
/// @brief Plays the cursor sound effect since it can be conditional.
|
||||
void play_sound() noexcept;
|
||||
|
||||
/// @brief Resets the menu and returns it to an empty, default state.
|
||||
void reset(bool full = true);
|
||||
|
||||
|
|
@ -140,7 +143,7 @@ namespace ui
|
|||
void initialize_ui_elements();
|
||||
|
||||
/// @brief Ensures the menu cursor sound is loaded.
|
||||
void initialize_cursor_sound();
|
||||
void initialize_sounds();
|
||||
|
||||
/// @brief Updates the text scroll for the currently highlighted option.
|
||||
void update_scroll_text();
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ namespace ui
|
|||
/// @brief Resets the view to its default, empty state.
|
||||
void reset();
|
||||
|
||||
/// @brief Plays the cursor sound.
|
||||
void play_sound() noexcept;
|
||||
|
||||
private:
|
||||
/// @brief Pointer to user passed.
|
||||
data::User *m_user{};
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 617 B After Width: | Height: | Size: 1.1 KiB |
|
|
@ -193,7 +193,7 @@ void BackupMenuState::save_data_check()
|
|||
void BackupMenuState::initialize_remote_storage()
|
||||
{
|
||||
remote::Storage *remote = remote::get_remote_storage();
|
||||
if (error::is_null(remote)) { return; }
|
||||
if (!remote) { return; }
|
||||
|
||||
const bool supportsUtf8 = remote->supports_utf8();
|
||||
const std::string_view remoteTitle = supportsUtf8 ? m_titleInfo->get_title() : m_titleInfo->get_path_safe_title();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ MainMenuState::MainMenuState()
|
|||
MainMenuState::initialize_view_states();
|
||||
MainMenuState::initialize_data_struct();
|
||||
MainMenuState::check_for_update();
|
||||
MainMenuState::play_boot_sound();
|
||||
}
|
||||
|
||||
void MainMenuState::update()
|
||||
|
|
@ -137,15 +136,6 @@ void MainMenuState::initialize_data_struct()
|
|||
|
||||
void MainMenuState::check_for_update() { sys::threadpool::push_job(tasks::update::check_for_update, m_dataStruct); }
|
||||
|
||||
void MainMenuState::play_boot_sound()
|
||||
{
|
||||
// static constexpr std::string_view BOOT_NAME = "BootSound";
|
||||
// static constexpr const char *BOOT_PATH = "romfs:/Sound/Boot.wav";
|
||||
|
||||
// sdl::SharedSound bootSound = sdl::SoundManager::load(BOOT_NAME, BOOT_PATH);
|
||||
// bootSound->play();
|
||||
}
|
||||
|
||||
void MainMenuState::push_target_state()
|
||||
{
|
||||
const int popTicks = ui::PopMessageManager::DEFAULT_TICKS;
|
||||
|
|
@ -169,6 +159,7 @@ void MainMenuState::push_target_state()
|
|||
auto &target = sm_states[selected];
|
||||
target->reactivate();
|
||||
StateManager::push_state(target);
|
||||
m_mainMenu->play_sound();
|
||||
}
|
||||
|
||||
void MainMenuState::create_user_options()
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ void TitleSelectState::create_backup_menu()
|
|||
|
||||
auto backupMenu = std::make_shared<BackupMenuState>(m_user, titleInfo, saveInfo);
|
||||
StateManager::push_state(backupMenu);
|
||||
m_titleView->play_sound();
|
||||
}
|
||||
|
||||
void TitleSelectState::create_title_option_menu()
|
||||
|
|
|
|||
|
|
@ -481,13 +481,9 @@ static void auto_backup(sys::ProgressTask *task, BackupMenuState::TaskData taskD
|
|||
remote::Storage *remote = remote::get_remote_storage();
|
||||
data::User *user = taskData->user;
|
||||
data::TitleInfo *titleInfo = taskData->titleInfo;
|
||||
const FsSaveDataInfo *saveInfo = taskData->saveInfo;
|
||||
fslib::Path &target = taskData->path;
|
||||
BackupMenuState *spawningState = taskData->spawningState;
|
||||
if (error::is_null(user) || error::is_null(titleInfo)) { return; }
|
||||
|
||||
const uint64_t applicationID = titleInfo->get_application_id();
|
||||
const FsSaveDataInfo *saveInfo = user->get_save_info_by_id(applicationID);
|
||||
if (error::is_null(saveInfo)) { return; }
|
||||
if (error::is_null(user) || error::is_null(titleInfo) || error::is_null(saveInfo)) { return; }
|
||||
|
||||
{
|
||||
fs::ScopedSaveMount testMount{fs::DEFAULT_SAVE_MOUNT, saveInfo, false};
|
||||
|
|
@ -504,18 +500,13 @@ static void auto_backup(sys::ProgressTask *task, BackupMenuState::TaskData taskD
|
|||
std::string backupName = stringutil::get_formatted_string("AUTO - %s - %s", safeNickname, dateString.c_str());
|
||||
if (zip) { backupName += STRING_ZIP_EXT; }
|
||||
|
||||
auto tempData = std::make_shared<BackupMenuState::DataStruct>();
|
||||
tempData->task = task;
|
||||
tempData->user = user;
|
||||
tempData->titleInfo = titleInfo;
|
||||
tempData->spawningState = spawningState;
|
||||
tempData->killTask = false;
|
||||
taskData->killTask = false;
|
||||
|
||||
if (autoUpload && remote)
|
||||
{
|
||||
tempData->remoteName = std::move(backupName);
|
||||
taskData->remoteName = std::move(backupName);
|
||||
|
||||
tasks::backup::create_new_backup_remote(tempData);
|
||||
tasks::backup::create_new_backup_remote(taskData);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -525,22 +516,25 @@ static void auto_backup(sys::ProgressTask *task, BackupMenuState::TaskData taskD
|
|||
|
||||
fslib::Path autoTarget{target.sub_path(lastSlash) / backupName};
|
||||
|
||||
tempData->path = std::move(autoTarget);
|
||||
// This is used to move and store the path before using the local auto path.
|
||||
fslib::Path storePath = std::move(taskData->path);
|
||||
// Swap em.
|
||||
taskData->path = std::move(autoTarget);
|
||||
|
||||
tasks::backup::create_new_backup_local(tempData);
|
||||
tasks::backup::create_new_backup_local(taskData);
|
||||
|
||||
// Swap em back.
|
||||
taskData->path = std::move(storePath);
|
||||
}
|
||||
}
|
||||
|
||||
static bool read_and_process_meta(const fslib::Path &targetDir, BackupMenuState::TaskData taskData, sys::ProgressTask *task)
|
||||
{
|
||||
data::User *user = taskData->user;
|
||||
data::TitleInfo *titleInfo = taskData->titleInfo;
|
||||
data::User *user = taskData->user;
|
||||
data::TitleInfo *titleInfo = taskData->titleInfo;
|
||||
const FsSaveDataInfo *saveInfo = taskData->saveInfo;
|
||||
if (error::is_null(task)) { return false; }
|
||||
else if (error::is_null(user) || error::is_null(titleInfo)) { return false; }
|
||||
|
||||
const uint64_t applicationID = titleInfo->get_application_id();
|
||||
const FsSaveDataInfo *saveInfo = user->get_save_info_by_id(applicationID);
|
||||
if (error::is_null(saveInfo)) { return false; }
|
||||
else if (error::is_null(user) || error::is_null(titleInfo) || error::is_null(saveInfo)) { return false; }
|
||||
|
||||
const int popTicks = ui::PopMessageManager::DEFAULT_TICKS;
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ ui::Menu::Menu(int x, int y, int width, int fontSize, int renderTargetHeight)
|
|||
Menu::initialize_transition();
|
||||
Menu::initialize_option_target();
|
||||
Menu::initialize_ui_elements();
|
||||
Menu::initialize_cursor_sound();
|
||||
Menu::initialize_sounds();
|
||||
}
|
||||
|
||||
void ui::Menu::update(bool hasFocus)
|
||||
|
|
@ -114,6 +114,8 @@ void ui::Menu::reset(bool full)
|
|||
|
||||
bool ui::Menu::is_empty() const noexcept { return m_options.empty(); }
|
||||
|
||||
void ui::Menu::play_sound() noexcept { sm_cursor->play(); }
|
||||
|
||||
void ui::Menu::calculate_alignments() noexcept
|
||||
{
|
||||
m_optionHeight = std::floor(static_cast<double>(m_fontSize) * 1.8f);
|
||||
|
|
@ -156,7 +158,7 @@ void ui::Menu::initialize_ui_elements()
|
|||
false);
|
||||
}
|
||||
|
||||
void ui::Menu::initialize_cursor_sound()
|
||||
void ui::Menu::initialize_sounds()
|
||||
{
|
||||
static constexpr std::string_view CURSOR_NAME = "MenuCursor";
|
||||
static constexpr const char *CURSOR_PATH = "romfs:/Sound/MenuCursor.wav";
|
||||
|
|
@ -194,7 +196,7 @@ void ui::Menu::handle_input()
|
|||
if (m_selected < 0) { m_selected = 0; }
|
||||
else if (m_selected >= optionsSize) { m_selected = optionsSize - 1; }
|
||||
|
||||
if (m_selected != previousSelected) { sm_cursor->play(); }
|
||||
if (m_selected != previousSelected) { Menu::play_sound(); }
|
||||
}
|
||||
|
||||
void ui::Menu::update_scrolling()
|
||||
|
|
|
|||
|
|
@ -112,6 +112,8 @@ void ui::TitleView::reset()
|
|||
for (ui::TitleTile ¤tTile : m_titleTiles) { currentTile.reset(); }
|
||||
}
|
||||
|
||||
void ui::TitleView::play_sound() noexcept { sm_cursor->play(); }
|
||||
|
||||
void ui::TitleView::initialize_static_members()
|
||||
{
|
||||
static constexpr std::string_view CURSOR_NAME = "MenuCursor";
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user