mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-04-13 20:36:12 -05:00
110 lines
3.8 KiB
C++
110 lines
3.8 KiB
C++
#pragma once
|
|
#include "appstates/BaseState.hpp"
|
|
#include "data/data.hpp"
|
|
#include "fslib.hpp"
|
|
#include "sdl.hpp"
|
|
#include "system/Timer.hpp"
|
|
#include "ui/Menu.hpp"
|
|
#include "ui/SlideOutPanel.hpp"
|
|
#include "ui/TextScroll.hpp"
|
|
|
|
#include <memory>
|
|
|
|
/// @brief This is the state where the user can backup and restore saves.
|
|
class BackupMenuState final : public BaseState
|
|
{
|
|
public:
|
|
/// @brief Creates a new backup selection state.
|
|
/// @param user Pointer to currently selected user.
|
|
/// @param titleInfo Pointer to titleInfo of selected title.
|
|
/// @param saveType Save data type we're working with.
|
|
BackupMenuState(data::User *user, data::TitleInfo *titleInfo, FsSaveDataType saveType);
|
|
|
|
/// @brief Destructor. This is required even if it doesn't free or do anything.
|
|
~BackupMenuState();
|
|
|
|
/// @brief Required. Inherited virtual function from AppState.
|
|
void update() override;
|
|
|
|
/// @brief Required. Inherited virtual function from AppState.
|
|
void render() override;
|
|
|
|
/// @brief Refreshes the directory listing and menu.
|
|
void refresh();
|
|
|
|
/// @brief Allows a spawned task to tell this class that it wrote save data to the system.
|
|
void save_data_written();
|
|
|
|
/// @brief Struct used for passing data to functions.
|
|
typedef struct
|
|
{
|
|
/// @brief Pointer to the target user.
|
|
data::User *user;
|
|
|
|
/// @brief Data for the target title.
|
|
data::TitleInfo *titleInfo;
|
|
|
|
/// @brief Path of the target.
|
|
fslib::Path targetPath;
|
|
|
|
/// @brief Journal size for when a commit is needed.
|
|
uint64_t journalSize;
|
|
|
|
/// @brief Pointer to >this spawning state.
|
|
BackupMenuState *spawningState;
|
|
} DataStruct;
|
|
|
|
private:
|
|
/// @brief Pointer to current user.
|
|
data::User *m_user{};
|
|
|
|
/// @brief Pointer to data for selected title.
|
|
data::TitleInfo *m_titleInfo{};
|
|
|
|
/// @brief Save data type we're working with.
|
|
FsSaveDataType m_saveType{};
|
|
|
|
/// @brief Path to the target directory of the title.
|
|
fslib::Path m_directoryPath{};
|
|
|
|
/// @brief Directory listing of the above.
|
|
fslib::Directory m_directoryListing{};
|
|
|
|
/// @brief This is the scrolling text at the top.
|
|
ui::TextScroll m_titleScroll{};
|
|
|
|
/// @brief Variable that saves whether or not the filesystem has data in it.
|
|
bool m_saveHasData{};
|
|
|
|
/// @brief Data struct passed to functions.
|
|
std::shared_ptr<BackupMenuState::DataStruct> m_dataStruct{};
|
|
|
|
/// @brief Whether or not anything beyond this point needs to be init'd. Everything here is static and shared by all
|
|
/// instances.
|
|
static inline bool sm_isInitialized{};
|
|
|
|
/// @brief The menu used by all instances of BackupMenuState.
|
|
static inline std::shared_ptr<ui::Menu> sm_backupMenu{};
|
|
|
|
/// @brief The slide out panel used by all instances of BackupMenuState.
|
|
static inline std::unique_ptr<ui::SlideOutPanel> sm_slidePanel{};
|
|
|
|
/// @brief Inner render target so the menu only renders to a certain area.
|
|
static inline sdl::SharedTexture sm_menuRenderTarget{};
|
|
|
|
/// @brief The width of the panels. This is set according to the control guide text.
|
|
static inline int sm_panelWidth{};
|
|
|
|
/// @brief This is the function called when New Backup is selected.
|
|
void name_and_create_backup();
|
|
|
|
/// @brief This is the function called when a backup is selected to be overwritten.
|
|
void confirm_backup_overwrite();
|
|
|
|
/// @brief This function is called to confirm restoring a backup.
|
|
void confirm_restore();
|
|
|
|
/// @brief Function called to confirm deleting a backup.
|
|
void confirm_delete();
|
|
};
|