mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-09-08 18:45:14 -05:00
File mode progress.
This commit is contained in:
@@ -16,6 +16,9 @@ class BaseState
|
||||
/// @brief Every derived class is required to have this function.
|
||||
virtual void update() = 0;
|
||||
|
||||
/// @brief Sub update routine. Meant to handle minor background tasks. Not meant for full update routines.
|
||||
virtual void sub_update() {};
|
||||
|
||||
/// @brief Every derived class is required to have this function.
|
||||
virtual void render() = 0;
|
||||
|
||||
|
||||
@@ -34,4 +34,22 @@ class ExtrasMenuState final : public BaseState
|
||||
|
||||
/// @brief This function is called when Reinitialize data is selected.
|
||||
void reinitialize_data();
|
||||
|
||||
/// @brief Opens an SD to SD file browser.
|
||||
void sd_to_sd_browser();
|
||||
|
||||
/// @brief Opens the prodinfo-f to sd.
|
||||
void prodinfof_to_sd();
|
||||
|
||||
/// @brief Opens the safe partition to SD.
|
||||
void safe_to_sd();
|
||||
|
||||
/// @brief Opens the system partition to SD.
|
||||
void system_to_sd();
|
||||
|
||||
/// @brief Opens the user partition to SD.
|
||||
void user_to_sd();
|
||||
|
||||
/// @brief Terminates a process.
|
||||
void terminate_process();
|
||||
};
|
||||
|
||||
172
include/appstates/FileModeState.hpp
Normal file
172
include/appstates/FileModeState.hpp
Normal file
@@ -0,0 +1,172 @@
|
||||
#pragma once
|
||||
#include "StateManager.hpp"
|
||||
#include "appstates/BaseState.hpp"
|
||||
#include "fslib.hpp"
|
||||
#include "sdl.hpp"
|
||||
#include "ui/ui.hpp"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
class FileModeState final : public BaseState
|
||||
{
|
||||
public:
|
||||
/// @brief Constructs a new FileModeState.
|
||||
FileModeState(std::string_view mountA, std::string_view mountB, int64_t journalSize = 0);
|
||||
|
||||
/// @brief Destructor. Closes the filesystems passed.
|
||||
~FileModeState() {};
|
||||
|
||||
static inline std::shared_ptr<FileModeState> create(std::string_view mountA,
|
||||
std::string_view mountB,
|
||||
int64_t journalSize = 0)
|
||||
{
|
||||
return std::make_shared<FileModeState>(mountA, mountB, journalSize);
|
||||
}
|
||||
|
||||
static inline std::shared_ptr<FileModeState> create_and_push(std::string_view mountA,
|
||||
std::string_view mountB,
|
||||
int64_t journalSize = 0)
|
||||
{
|
||||
auto newState = std::make_shared<FileModeState>(mountA, mountB, journalSize);
|
||||
StateManager::push_state(newState);
|
||||
return newState;
|
||||
}
|
||||
|
||||
/// @brief Update override.
|
||||
void update() override;
|
||||
|
||||
/// @brief Render override.
|
||||
void render() override;
|
||||
|
||||
/// @brief Returns the target/active bool.
|
||||
bool get_target() const noexcept;
|
||||
|
||||
/// @brief Returns the source path. This is used with the FileOptionState.
|
||||
fslib::Path get_source();
|
||||
|
||||
/// @brief Returns the destination path. This is used with the FileOptionState.
|
||||
fslib::Path get_destination();
|
||||
|
||||
/// @brief Returns whether or not committing the transfer is required to FileOptionState.
|
||||
bool commit_required() const noexcept;
|
||||
|
||||
/// @brief Returns the journaling size passed to this for FileOptionState.
|
||||
int64_t get_journal_size() const noexcept;
|
||||
|
||||
/// @brief Renders the control guide in the bottom right.
|
||||
void render_control_guide() noexcept;
|
||||
|
||||
private:
|
||||
/// @brief These store the mount points to close the filesystems upon construction.
|
||||
std::string m_mountA;
|
||||
std::string m_mountB;
|
||||
|
||||
/// @brief These are the actual target paths.
|
||||
fslib::Path m_pathA{};
|
||||
fslib::Path m_pathB{};
|
||||
|
||||
/// @brief Directory listings for each respective path.
|
||||
fslib::Directory m_dirA{};
|
||||
fslib::Directory m_dirB{};
|
||||
|
||||
/// @brief Menus for the directory listings.
|
||||
std::shared_ptr<ui::Menu> m_dirMenuA{};
|
||||
std::shared_ptr<ui::Menu> m_dirMenuB{};
|
||||
|
||||
/// @brief Controls which menu/filesystem is currently targetted.
|
||||
bool m_target{};
|
||||
|
||||
/// @brief Stores the size for committing data (if needed) to mountA.
|
||||
int64_t m_journalSize{};
|
||||
|
||||
/// @brief The beginning Y coord of the dialog.
|
||||
double m_y{720.0f};
|
||||
|
||||
/// @brief This is the targetY. Used for the opening and hiding effect.
|
||||
double m_targetY{91.0f};
|
||||
|
||||
/// @brief Config scaling for the "transition"
|
||||
double m_scaling{};
|
||||
|
||||
/// @brief Stores whether or not the dialog has reached its targetted position.
|
||||
bool m_inPlace{};
|
||||
|
||||
/// @brief Frame shared by all instances.
|
||||
static inline std::shared_ptr<ui::Frame> sm_frame{};
|
||||
|
||||
/// @brief This is the render target the browsers are rendered to.
|
||||
static inline sdl::SharedTexture sm_renderTarget{};
|
||||
|
||||
/// @brief Stores a pointer to the guide in the bottom-right corner.
|
||||
static inline const char *sm_controlGuide{};
|
||||
|
||||
/// @brief Calculated X coordinate of the control guide text.
|
||||
static inline int sm_controlGuideX{};
|
||||
|
||||
/// @brief Initializes the members shared by all instances of FileModeState.
|
||||
void initialize_static_members();
|
||||
|
||||
/// @brief Creates valid paths with the mounts passed.
|
||||
void initialize_paths();
|
||||
|
||||
/// @brief Ensures the menus are allocated and setup properly.
|
||||
void initialize_menus();
|
||||
|
||||
/// @brief Loads the current directory listings and menus.
|
||||
void initialize_directory_menu(const fslib::Path &path, fslib::Directory &directory, ui::Menu &menu);
|
||||
|
||||
/// @brief Updates the dialog's coordinates in the beginning.
|
||||
void update_y_coord() noexcept;
|
||||
|
||||
/// @brief Starts the dialog hiding process.
|
||||
void hide_dialog() noexcept;
|
||||
|
||||
/// @brief Returns whether or not the dialog is hidden.
|
||||
bool is_hidden() noexcept;
|
||||
|
||||
/// @brief Handles changing the current directory or opening the options.
|
||||
void enter_selected(fslib::Path &path, fslib::Directory &directory, ui::Menu &menu);
|
||||
|
||||
/// @brief Opens the little option pop-up thingy.
|
||||
void open_option_menu(fslib::Directory &directory, ui::Menu &menu);
|
||||
|
||||
/// @brief Changes the current target/controllable menu.
|
||||
void change_target() noexcept;
|
||||
|
||||
/// @brief Function executed when '..' is selected.
|
||||
void up_one_directory(fslib::Path &path, fslib::Directory &directory, ui::Menu &menu);
|
||||
|
||||
/// @brief Appends the entry passed to the path passed and "enters" the directory.
|
||||
/// @param path Working path.
|
||||
/// @param directory Working directory.
|
||||
/// @param menu Working menu.
|
||||
/// @param entry Target entry.
|
||||
void enter_directory(fslib::Path &path,
|
||||
fslib::Directory &directory,
|
||||
ui::Menu &menu,
|
||||
const fslib::DirectoryEntry &entry);
|
||||
|
||||
/// @brief Returns a reference to the currently active menu.
|
||||
ui::Menu &get_source_menu() noexcept;
|
||||
|
||||
/// @brief Returns a reference to the currently inactive menu.
|
||||
ui::Menu &get_destination_menu() noexcept;
|
||||
|
||||
/// @brief Returns a reference to the current "active" path.
|
||||
fslib::Path &get_source_path() noexcept;
|
||||
|
||||
/// @brief Returns a reference to the currently "inactive" path.
|
||||
fslib::Path &get_destination_path() noexcept;
|
||||
|
||||
/// @brief Returns a reference to the "active" directory.
|
||||
fslib::Directory &get_source_directory() noexcept;
|
||||
|
||||
/// @brief Returns a reference ot the currently "inactive" directory.
|
||||
fslib::Directory &get_destination_directory() noexcept;
|
||||
|
||||
/// @brief Returns whether or not a path is at the root.
|
||||
inline bool path_is_root(fslib::Path &path) const { return std::char_traits<char>::length(path.get_path()) <= 1; }
|
||||
|
||||
/// @brief Closes the filesystems passed and deactivates the state.
|
||||
void deactivate_state() noexcept;
|
||||
};
|
||||
110
include/appstates/FileOptionState.hpp
Normal file
110
include/appstates/FileOptionState.hpp
Normal file
@@ -0,0 +1,110 @@
|
||||
#pragma once
|
||||
#include "StateManager.hpp"
|
||||
#include "appstates/BaseState.hpp"
|
||||
#include "appstates/FileModeState.hpp"
|
||||
#include "fslib.hpp"
|
||||
#include "ui/ui.hpp"
|
||||
|
||||
class FileOptionState final : public BaseState
|
||||
{
|
||||
public:
|
||||
/// @brief FileOptionState.
|
||||
/// @param spawningState Pointer to spawning state to grab its goodies.
|
||||
FileOptionState(FileModeState *spawningState);
|
||||
|
||||
~FileOptionState() {};
|
||||
|
||||
/// @brief Inline creation function.
|
||||
static inline std::shared_ptr<FileOptionState> create(FileModeState *spawningState)
|
||||
{
|
||||
return std::make_shared<FileOptionState>(spawningState);
|
||||
}
|
||||
|
||||
/// @brief Same as above. Pushes state before returning it.
|
||||
static inline std::shared_ptr<FileOptionState> create_and_push(FileModeState *spawningState)
|
||||
{
|
||||
auto newState = FileOptionState::create(spawningState);
|
||||
StateManager::push_state(newState);
|
||||
return newState;
|
||||
}
|
||||
|
||||
/// @brief Update routine.
|
||||
void update() override;
|
||||
|
||||
/// @brief Render routine.
|
||||
void render() override;
|
||||
|
||||
// clang-format off
|
||||
struct DataStruct
|
||||
{
|
||||
fslib::Path sourcePath{};
|
||||
fslib::Path destPath{};
|
||||
int64_t journalSize{};
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
/// @brief This makes some other stuff easier to read and type.
|
||||
using TaskData = std::shared_ptr<FileOptionState::DataStruct>;
|
||||
|
||||
private:
|
||||
/// @brief Pointer to spawning FileMode state.
|
||||
FileModeState *m_spawningState{};
|
||||
|
||||
/// @brief Stores whether or not tasks require committing data and changes to the target.
|
||||
bool m_commitData{};
|
||||
|
||||
/// @brief Journal size for when committing is required.
|
||||
int64_t m_journalSize{};
|
||||
|
||||
/// @brief X coordinate. This is set at construction according to the target from the spawning state.
|
||||
int m_x{};
|
||||
|
||||
/// @brief X coordinate for the target to reach.
|
||||
int m_targetX{};
|
||||
|
||||
/// @brief Whether or not the dialog/menu is in place.
|
||||
bool m_inPlace{};
|
||||
|
||||
/// @brief Whether or not the state should be closed.
|
||||
bool m_close{};
|
||||
|
||||
/// @brief This holds the scaling in config.
|
||||
double m_scaling{};
|
||||
|
||||
/// @brief This is the data struct passed to tasks.
|
||||
std::shared_ptr<FileOptionState::DataStruct> m_dataStruct{};
|
||||
|
||||
/// @brief This is shared by all instances.
|
||||
static inline std::shared_ptr<ui::Menu> sm_copyMenu{};
|
||||
|
||||
/// @brief This is shared by all instances.
|
||||
static inline std::shared_ptr<ui::DialogBox> sm_dialog{};
|
||||
|
||||
/// @brief Ensures static members of all instances are allocated.
|
||||
void initialize_static_members();
|
||||
|
||||
/// @brief Sets whether the dialog/menu are positioned left or right depending on the menu active in the spawning state.
|
||||
void set_menu_side();
|
||||
|
||||
/// @brief Updates the Y coordinate
|
||||
void update_x_coord();
|
||||
|
||||
void copy_target();
|
||||
|
||||
void delete_target();
|
||||
|
||||
void rename_target();
|
||||
|
||||
void create_directory();
|
||||
|
||||
void get_show_target_properties();
|
||||
|
||||
/// @brief Closes and hides the state.
|
||||
void close();
|
||||
|
||||
/// @brief Returns whether or not the state is closed.
|
||||
bool is_closed();
|
||||
|
||||
/// @brief Sets the menu index back to 0 and deactivates the state.
|
||||
void deactivate_state();
|
||||
};
|
||||
@@ -39,6 +39,9 @@ class TitleOptionState final : public BaseState
|
||||
/// @brief Runs update routine.
|
||||
void update() override;
|
||||
|
||||
/// @brief Handles hiding the panel.
|
||||
void sub_update() override;
|
||||
|
||||
/// @brief Runs the render routine.
|
||||
void render() override;
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ class UserOptionState final : public BaseState
|
||||
/// @brief Runs the render routine.
|
||||
void update() override;
|
||||
|
||||
/// @brief Handles hiding the panel.
|
||||
void sub_update() override;
|
||||
|
||||
/// @brief Runs the render routine.
|
||||
void render() override;
|
||||
|
||||
|
||||
@@ -1,34 +1,31 @@
|
||||
#pragma once
|
||||
#include <string_view>
|
||||
|
||||
namespace config
|
||||
namespace config::keys
|
||||
{
|
||||
namespace keys
|
||||
{
|
||||
inline constexpr std::string_view WORKING_DIRECTORY = "WorkingDirectory";
|
||||
inline constexpr std::string_view INCLUDE_DEVICE_SAVES = "IncludeDeviceSaves";
|
||||
inline constexpr std::string_view AUTO_BACKUP_ON_RESTORE = "AutoBackupOnRestore";
|
||||
inline constexpr std::string_view AUTO_NAME_BACKUPS = "AutoNameBackups";
|
||||
inline constexpr std::string_view AUTO_UPLOAD = "AutoUploadToRemote";
|
||||
inline constexpr std::string_view USE_TITLE_IDS = "AlwaysUseTitleID";
|
||||
inline constexpr std::string_view HOLD_FOR_DELETION = "HoldForDeletion";
|
||||
inline constexpr std::string_view HOLD_FOR_RESTORATION = "HoldForRestoration";
|
||||
inline constexpr std::string_view HOLD_FOR_OVERWRITE = "HoldForOverWrite";
|
||||
inline constexpr std::string_view ONLY_LIST_MOUNTABLE = "OnlyListMountable";
|
||||
inline constexpr std::string_view LIST_ACCOUNT_SYS_SAVES = "ListAccountSystemSaves";
|
||||
inline constexpr std::string_view ALLOW_WRITING_TO_SYSTEM = "AllowSystemSaveWriting";
|
||||
inline constexpr std::string_view EXPORT_TO_ZIP = "ExportToZip";
|
||||
inline constexpr std::string_view ZIP_COMPRESSION_LEVEL = "ZipCompressionLevel";
|
||||
inline constexpr std::string_view TITLE_SORT_TYPE = "TitleSortType";
|
||||
inline constexpr std::string_view JKSM_TEXT_MODE = "JKSMTextMode";
|
||||
inline constexpr std::string_view FORCE_ENGLISH = "ForceEnglish";
|
||||
inline constexpr std::string_view SHOW_DEVICE_USER = "ShowDevice";
|
||||
inline constexpr std::string_view SHOW_BCAT_USER = "ShowBCAT";
|
||||
inline constexpr std::string_view SHOW_CACHE_USER = "ShowCache";
|
||||
inline constexpr std::string_view SHOW_SYSTEM_USER = "ShowSystem";
|
||||
inline constexpr std::string_view ENABLE_TRASH_BIN = "EnableTrash";
|
||||
inline constexpr std::string_view UI_ANIMATION_SCALE = "UIAnimationScaling";
|
||||
inline constexpr std::string_view FAVORITES = "Favorites";
|
||||
inline constexpr std::string_view BLACKLIST = "BlackList";
|
||||
} // namespace keys
|
||||
inline constexpr std::string_view WORKING_DIRECTORY = "WorkingDirectory";
|
||||
inline constexpr std::string_view INCLUDE_DEVICE_SAVES = "IncludeDeviceSaves";
|
||||
inline constexpr std::string_view AUTO_BACKUP_ON_RESTORE = "AutoBackupOnRestore";
|
||||
inline constexpr std::string_view AUTO_NAME_BACKUPS = "AutoNameBackups";
|
||||
inline constexpr std::string_view AUTO_UPLOAD = "AutoUploadToRemote";
|
||||
inline constexpr std::string_view USE_TITLE_IDS = "AlwaysUseTitleID";
|
||||
inline constexpr std::string_view HOLD_FOR_DELETION = "HoldForDeletion";
|
||||
inline constexpr std::string_view HOLD_FOR_RESTORATION = "HoldForRestoration";
|
||||
inline constexpr std::string_view HOLD_FOR_OVERWRITE = "HoldForOverWrite";
|
||||
inline constexpr std::string_view ONLY_LIST_MOUNTABLE = "OnlyListMountable";
|
||||
inline constexpr std::string_view LIST_ACCOUNT_SYS_SAVES = "ListAccountSystemSaves";
|
||||
inline constexpr std::string_view ALLOW_WRITING_TO_SYSTEM = "AllowSystemSaveWriting";
|
||||
inline constexpr std::string_view EXPORT_TO_ZIP = "ExportToZip";
|
||||
inline constexpr std::string_view ZIP_COMPRESSION_LEVEL = "ZipCompressionLevel";
|
||||
inline constexpr std::string_view TITLE_SORT_TYPE = "TitleSortType";
|
||||
inline constexpr std::string_view JKSM_TEXT_MODE = "JKSMTextMode";
|
||||
inline constexpr std::string_view FORCE_ENGLISH = "ForceEnglish";
|
||||
inline constexpr std::string_view SHOW_DEVICE_USER = "ShowDevice";
|
||||
inline constexpr std::string_view SHOW_BCAT_USER = "ShowBCAT";
|
||||
inline constexpr std::string_view SHOW_CACHE_USER = "ShowCache";
|
||||
inline constexpr std::string_view SHOW_SYSTEM_USER = "ShowSystem";
|
||||
inline constexpr std::string_view ENABLE_TRASH_BIN = "EnableTrash";
|
||||
inline constexpr std::string_view UI_ANIMATION_SCALE = "UIAnimationScaling";
|
||||
inline constexpr std::string_view FAVORITES = "Favorites";
|
||||
inline constexpr std::string_view BLACKLIST = "BlackList";
|
||||
}
|
||||
|
||||
@@ -25,13 +25,10 @@ namespace data
|
||||
/// @brief Initializes a TitleInfo instance using external (cached) NsApplicationControlData
|
||||
/// @param applicationID Application ID of the title loaded from cache.
|
||||
/// @param controlData Reference to the control data to init from.
|
||||
TitleInfo(uint64_t applicationID, std::unique_ptr<NsApplicationControlData> &controlData);
|
||||
TitleInfo(uint64_t applicationID, NsApplicationControlData &controlData);
|
||||
|
||||
/// @brief Move constructor and operator.
|
||||
TitleInfo(TitleInfo &&titleInfo);
|
||||
TitleInfo &operator=(TitleInfo &&TitleInfo);
|
||||
|
||||
// None of this nonesense around these parts.TitleInfo(const TitleInfo &) = delete;
|
||||
// None of this nonesense around these parts.
|
||||
TitleInfo(const TitleInfo &) = delete;
|
||||
TitleInfo &operator=(const TitleInfo &) = delete;
|
||||
|
||||
/// @brief Returns the application ID of the title.
|
||||
@@ -104,8 +101,8 @@ namespace data
|
||||
/// @brief Stores application ID for easier grabbing since JKSV is all pointers.
|
||||
uint64_t m_applicationID{};
|
||||
|
||||
/// @brief This contains the NACP and the icon.
|
||||
std::unique_ptr<NsApplicationControlData> m_data{};
|
||||
/// @brief Where all the good stuff is.
|
||||
NsApplicationControlData m_data{};
|
||||
|
||||
/// @brief Saves whether or not the title has control data.
|
||||
bool m_hasData{};
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace fs
|
||||
{
|
||||
class MiniUnzip
|
||||
class MiniUnzip final
|
||||
{
|
||||
public:
|
||||
MiniUnzip() = default;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace fs
|
||||
{
|
||||
class MiniZip
|
||||
class MiniZip final
|
||||
{
|
||||
public:
|
||||
MiniZip() = default;
|
||||
@@ -41,6 +41,9 @@ namespace fs
|
||||
/// @brief Stores whether or not the zipFile was opened successfully.
|
||||
bool m_isOpen{};
|
||||
|
||||
/// @brief Stores the compression level from config to avoid repeated calls.
|
||||
int m_level{};
|
||||
|
||||
/// @brief Underlying ZIP file.
|
||||
zipFile m_zip{};
|
||||
};
|
||||
|
||||
@@ -20,6 +20,6 @@ namespace fs
|
||||
|
||||
private:
|
||||
/// @brief Vector of paths to filter from deletion and backup.
|
||||
std::vector<std::string> m_paths{};
|
||||
std::vector<fslib::Path> m_paths{};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,9 +32,6 @@ namespace fs
|
||||
} __attribute__((packed));
|
||||
// clang-format on
|
||||
|
||||
// I didn't want a separate file for this.
|
||||
bool read_save_data_extra_info(const FsSaveDataInfo *saveInfo, FsSaveDataExtraData &dataOut);
|
||||
|
||||
/// @brief Didn't feel like a whole new file just for this. Fills an fs::SaveMetaData struct.
|
||||
bool fill_save_meta_data(const FsSaveDataInfo *saveInfo, SaveMetaData &meta);
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ namespace fs
|
||||
/// @param journalSize Size of the journal area of the save data.
|
||||
void copy_file_commit(const fslib::Path &source,
|
||||
const fslib::Path &destination,
|
||||
std::string_view device,
|
||||
int64_t journalSize,
|
||||
sys::ProgressTask *task = nullptr);
|
||||
|
||||
@@ -36,7 +35,6 @@ namespace fs
|
||||
/// @param journalSize Size of the journaling area of the save.
|
||||
void copy_directory_commit(const fslib::Path &source,
|
||||
const fslib::Path &destination,
|
||||
std::string_view device,
|
||||
int64_t journalSize,
|
||||
sys::ProgressTask *task = nullptr);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "data/data.hpp"
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
namespace fs
|
||||
@@ -27,4 +28,10 @@ namespace fs
|
||||
/// @return True if it is. False if it isn't.
|
||||
/// @note The config setting overrides this.
|
||||
bool is_system_save_data(const FsSaveDataInfo *saveInfo);
|
||||
|
||||
/// @brief Reads the extra info of the save container according to the FsSaveDataInfo passed.
|
||||
/// @param saveInfo Pointer to the save info to read.
|
||||
/// @param extraOut Reference to the FsSaveDataExtraData to read to.
|
||||
/// @return True on success. False on failure.
|
||||
bool read_save_extra_data(const FsSaveDataInfo *saveInfo, FsSaveDataExtraData &extraOut);
|
||||
} // namespace fs
|
||||
|
||||
@@ -18,7 +18,6 @@ namespace fs
|
||||
void copy_zip_to_directory(fs::MiniUnzip &source,
|
||||
const fslib::Path &dest,
|
||||
int64_t journalSize,
|
||||
std::string_view commitDevice,
|
||||
sys::ProgressTask *Task = nullptr);
|
||||
|
||||
/// @brief Returns whether or not zip has files inside besides the save meta.
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace colors
|
||||
inline constexpr sdl::Color PINK = {0xFF4444FF};
|
||||
inline constexpr sdl::Color BLUE_GREEN = {0x00FFC5FF};
|
||||
inline constexpr sdl::Color CLEAR_COLOR = {0x2D2D2DFF};
|
||||
inline constexpr sdl::Color CLEAR_PANEL = {0x0D0D0DFF};
|
||||
inline constexpr sdl::Color DIALOG_DARK = {0x505050FF};
|
||||
inline constexpr sdl::Color DIALOG_LIGHT = {0xDCDCDCFF};
|
||||
inline constexpr sdl::Color DIM_BACKGROUND = {0x00000088};
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
#pragma once
|
||||
#include <string_view>
|
||||
|
||||
namespace strings
|
||||
namespace strings::names
|
||||
{
|
||||
namespace names
|
||||
{
|
||||
inline constexpr std::string_view BACKUPMENU_MENU = "BackupMenu";
|
||||
inline constexpr std::string_view BACKUPMENU_CONFS = "BackupMenuConfirmations";
|
||||
inline constexpr std::string_view BACKUPMENU_POPS = "BackupMenuPops";
|
||||
inline constexpr std::string_view BACKUPMENU_STATUS = "BackupMenuStatus";
|
||||
inline constexpr std::string_view CONTROL_GUIDES = "ControlGuides";
|
||||
inline constexpr std::string_view DATA_LOADING_STATUS = "DataLoadingStatus";
|
||||
inline constexpr std::string_view EXTRASMENU_MENU = "ExtrasMenu";
|
||||
inline constexpr std::string_view EXTRASMENU_POPS = "ExtrasPops";
|
||||
inline constexpr std::string_view GENERAL_POPS = "GeneralPops";
|
||||
inline constexpr std::string_view GOOGLE_DRIVE = "GoogleDriveStrings";
|
||||
inline constexpr std::string_view HOLDING_STRINGS = "HoldingStrings";
|
||||
inline constexpr std::string_view IO_STATUSES = "IOStatuses";
|
||||
inline constexpr std::string_view IO_POPS = "IOPops";
|
||||
inline constexpr std::string_view KEYBOARD = "KeyboardStrings";
|
||||
inline constexpr std::string_view MAINMENU_CONFS = "MainMenuConfs";
|
||||
inline constexpr std::string_view MAINMENU_POPS = "MainMenuPops";
|
||||
inline constexpr std::string_view ON_OFF = "OnOff";
|
||||
inline constexpr std::string_view REMOTE_POPS = "RemotePops";
|
||||
inline constexpr std::string_view SAVECREATE_POPS = "SaveCreatePops";
|
||||
inline constexpr std::string_view SAVE_DATA_TYPES = "SaveDataTypes";
|
||||
inline constexpr std::string_view SETTINGS_DESCRIPTIONS = "SettingsDescriptions";
|
||||
inline constexpr std::string_view SETTINGS_MENU = "SettingsMenu";
|
||||
inline constexpr std::string_view SETTINGS_POPS = "SettingsPops";
|
||||
inline constexpr std::string_view SORT_TYPES = "SortTypes";
|
||||
inline constexpr std::string_view TITLEINFO = "TitleInfo";
|
||||
inline constexpr std::string_view TITLEOPTION_CONFS = "TitleOptionConfirmations";
|
||||
inline constexpr std::string_view TITLEOPTION_POPS = "TitleOptionPops";
|
||||
inline constexpr std::string_view TITLEOPTION_STATUS = "TitleOptionStatus";
|
||||
inline constexpr std::string_view TITLEOPTION = "TitleOptions";
|
||||
inline constexpr std::string_view TRANSLATION = "TranslationInfo";
|
||||
inline constexpr std::string_view USEROPTION_CONFS = "UserOptionConfirmations";
|
||||
inline constexpr std::string_view USEROPTION_STATUS = "UserOptionStatus";
|
||||
inline constexpr std::string_view USEROPTION_MENU = "UserOptions";
|
||||
inline constexpr std::string_view WEBDAV = "WebDavStrings";
|
||||
inline constexpr std::string_view YES_NO_OK = "YesNoOK";
|
||||
}
|
||||
inline constexpr std::string_view BACKUPMENU_MENU = "BackupMenu";
|
||||
inline constexpr std::string_view BACKUPMENU_CONFS = "BackupMenuConfirmations";
|
||||
inline constexpr std::string_view BACKUPMENU_POPS = "BackupMenuPops";
|
||||
inline constexpr std::string_view BACKUPMENU_STATUS = "BackupMenuStatus";
|
||||
inline constexpr std::string_view CONTROL_GUIDES = "ControlGuides";
|
||||
inline constexpr std::string_view DATA_LOADING_STATUS = "DataLoadingStatus";
|
||||
inline constexpr std::string_view EXTRASMENU_MENU = "ExtrasMenu";
|
||||
inline constexpr std::string_view EXTRASMENU_POPS = "ExtrasPops";
|
||||
inline constexpr std::string_view FILEOPTION_MENU = "FileOptionMenu";
|
||||
inline constexpr std::string_view FILEOPTION_CONFS = "FileOptionConfs";
|
||||
inline constexpr std::string_view FILEMODE_POPS = "FileModePops";
|
||||
inline constexpr std::string_view GENERAL_POPS = "GeneralPops";
|
||||
inline constexpr std::string_view GOOGLE_DRIVE = "GoogleDriveStrings";
|
||||
inline constexpr std::string_view HOLDING_STRINGS = "HoldingStrings";
|
||||
inline constexpr std::string_view IO_STATUSES = "IOStatuses";
|
||||
inline constexpr std::string_view IO_POPS = "IOPops";
|
||||
inline constexpr std::string_view KEYBOARD = "KeyboardStrings";
|
||||
inline constexpr std::string_view MAINMENU_CONFS = "MainMenuConfs";
|
||||
inline constexpr std::string_view MAINMENU_POPS = "MainMenuPops";
|
||||
inline constexpr std::string_view ON_OFF = "OnOff";
|
||||
inline constexpr std::string_view REMOTE_POPS = "RemotePops";
|
||||
inline constexpr std::string_view SAVECREATE_POPS = "SaveCreatePops";
|
||||
inline constexpr std::string_view SAVE_DATA_TYPES = "SaveDataTypes";
|
||||
inline constexpr std::string_view SETTINGS_DESCRIPTIONS = "SettingsDescriptions";
|
||||
inline constexpr std::string_view SETTINGS_MENU = "SettingsMenu";
|
||||
inline constexpr std::string_view SETTINGS_POPS = "SettingsPops";
|
||||
inline constexpr std::string_view SORT_TYPES = "SortTypes";
|
||||
inline constexpr std::string_view TITLEINFO = "TitleInfo";
|
||||
inline constexpr std::string_view TITLEOPTION_CONFS = "TitleOptionConfirmations";
|
||||
inline constexpr std::string_view TITLEOPTION_POPS = "TitleOptionPops";
|
||||
inline constexpr std::string_view TITLEOPTION_STATUS = "TitleOptionStatus";
|
||||
inline constexpr std::string_view TITLEOPTION = "TitleOptions";
|
||||
inline constexpr std::string_view TRANSLATION = "TranslationInfo";
|
||||
inline constexpr std::string_view USEROPTION_CONFS = "UserOptionConfirmations";
|
||||
inline constexpr std::string_view USEROPTION_STATUS = "UserOptionStatus";
|
||||
inline constexpr std::string_view USEROPTION_MENU = "UserOptions";
|
||||
inline constexpr std::string_view WEBDAV = "WebDavStrings";
|
||||
inline constexpr std::string_view YES_NO_OK = "YesNoOK";
|
||||
}
|
||||
|
||||
18
include/sys/DataTask.hpp
Normal file
18
include/sys/DataTask.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include "sys/Task.hpp"
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
namespace sys
|
||||
{
|
||||
class DataTask final : public sys::Task
|
||||
{
|
||||
public:
|
||||
DataTask(ThreadFunc function, bool clearCache);
|
||||
|
||||
~DataTask();
|
||||
|
||||
private
|
||||
Thread m_thread{};
|
||||
}
|
||||
}
|
||||
@@ -4,40 +4,37 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace tasks
|
||||
namespace tasks::backup
|
||||
{
|
||||
namespace backup
|
||||
{
|
||||
/// @brief Task/thread function executed when a new backup is created.
|
||||
void create_new_backup_local(sys::ProgressTask *task,
|
||||
data::User *user,
|
||||
data::TitleInfo *titleInfo,
|
||||
fslib::Path target,
|
||||
BackupMenuState *spawningState,
|
||||
bool killTask = true);
|
||||
void create_new_backup_remote(sys::ProgressTask *task,
|
||||
data::User *user,
|
||||
data::TitleInfo *titleInfo,
|
||||
std::string remoteName,
|
||||
BackupMenuState *spawningState,
|
||||
bool killTask = true);
|
||||
/// @brief Task/thread function executed when a new backup is created.
|
||||
void create_new_backup_local(sys::ProgressTask *task,
|
||||
data::User *user,
|
||||
data::TitleInfo *titleInfo,
|
||||
fslib::Path target,
|
||||
BackupMenuState *spawningState,
|
||||
bool killTask = true);
|
||||
void create_new_backup_remote(sys::ProgressTask *task,
|
||||
data::User *user,
|
||||
data::TitleInfo *titleInfo,
|
||||
std::string remoteName,
|
||||
BackupMenuState *spawningState,
|
||||
bool killTask = true);
|
||||
|
||||
/// @brief Overwrites a pre-existing backup.
|
||||
void overwrite_backup_local(sys::ProgressTask *task, BackupMenuState::TaskData taskData);
|
||||
void overwrite_backup_remote(sys::ProgressTask *task, BackupMenuState::TaskData taskData);
|
||||
/// @brief Overwrites a pre-existing backup.
|
||||
void overwrite_backup_local(sys::ProgressTask *task, BackupMenuState::TaskData taskData);
|
||||
void overwrite_backup_remote(sys::ProgressTask *task, BackupMenuState::TaskData taskData);
|
||||
|
||||
/// @brief Restores a backup
|
||||
void restore_backup_local(sys::ProgressTask *task, BackupMenuState::TaskData taskData);
|
||||
void restore_backup_remote(sys::ProgressTask *task, BackupMenuState::TaskData taskData);
|
||||
/// @brief Restores a backup
|
||||
void restore_backup_local(sys::ProgressTask *task, BackupMenuState::TaskData taskData);
|
||||
void restore_backup_remote(sys::ProgressTask *task, BackupMenuState::TaskData taskData);
|
||||
|
||||
/// @brief Deletes a backup
|
||||
void delete_backup_local(sys::Task *task, BackupMenuState::TaskData taskData);
|
||||
void delete_backup_remote(sys::Task *task, BackupMenuState::TaskData taskData);
|
||||
/// @brief Deletes a backup
|
||||
void delete_backup_local(sys::Task *task, BackupMenuState::TaskData taskData);
|
||||
void delete_backup_remote(sys::Task *task, BackupMenuState::TaskData taskData);
|
||||
|
||||
/// @brief Uploads a backup
|
||||
void upload_backup(sys::ProgressTask *task, BackupMenuState::TaskData taskData);
|
||||
/// @brief Uploads a backup
|
||||
void upload_backup(sys::ProgressTask *task, BackupMenuState::TaskData taskData);
|
||||
|
||||
/// @brief Patches a pre-existing backup on the remote storage.
|
||||
void patch_backup(sys::ProgressTask *task, BackupMenuState::TaskData taskData);
|
||||
}
|
||||
/// @brief Patches a pre-existing backup on the remote storage.
|
||||
void patch_backup(sys::ProgressTask *task, BackupMenuState::TaskData taskData);
|
||||
}
|
||||
|
||||
12
include/tasks/fileoptions.hpp
Normal file
12
include/tasks/fileoptions.hpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "appstates/FileOptionState.hpp"
|
||||
#include "sys/sys.hpp"
|
||||
|
||||
namespace tasks::fileoptions
|
||||
{
|
||||
/// @brief Copies the source to destination passed through taskData.
|
||||
void copy_source_to_destination(sys::ProgressTask *task, FileOptionState::TaskData taskData);
|
||||
|
||||
/// @brief Deletes the source path passed through taskData
|
||||
void delete_target(sys::Task *task, FileOptionState::TaskData taskData);
|
||||
}
|
||||
@@ -2,11 +2,8 @@
|
||||
#include "appstates/MainMenuState.hpp"
|
||||
#include "sys/sys.hpp"
|
||||
|
||||
namespace tasks
|
||||
namespace tasks::mainmenu
|
||||
{
|
||||
namespace mainmenu
|
||||
{
|
||||
void backup_all_for_all_local(sys::ProgressTask *task, MainMenuState::TaskData taskData);
|
||||
void backup_all_for_all_remote(sys::ProgressTask *task, MainMenuState::TaskData taskData);
|
||||
}
|
||||
void backup_all_for_all_local(sys::ProgressTask *task, MainMenuState::TaskData taskData);
|
||||
void backup_all_for_all_remote(sys::ProgressTask *task, MainMenuState::TaskData taskData);
|
||||
}
|
||||
|
||||
@@ -3,13 +3,7 @@
|
||||
#include "data/data.hpp"
|
||||
#include "sys/sys.hpp"
|
||||
|
||||
namespace tasks
|
||||
namespace tasks::savecreate
|
||||
{
|
||||
namespace savecreate
|
||||
{
|
||||
void create_save_data_for(sys::Task *task,
|
||||
data::User *user,
|
||||
data::TitleInfo *titleInfo,
|
||||
SaveCreateState *spawningState);
|
||||
}
|
||||
void create_save_data_for(sys::Task *task, data::User *user, data::TitleInfo *titleInfo, SaveCreateState *spawningState);
|
||||
}
|
||||
|
||||
@@ -3,26 +3,23 @@
|
||||
#include "appstates/TitleOptionState.hpp"
|
||||
#include "sys/sys.hpp"
|
||||
|
||||
namespace tasks
|
||||
namespace tasks::titleoptions
|
||||
{
|
||||
namespace titleoptions
|
||||
{
|
||||
/// @brief Adds a title to the blacklist. Needs to be task formatted to work with confirmations.
|
||||
void blacklist_title(sys::Task *task, TitleOptionState::TaskData taskData);
|
||||
/// @brief Adds a title to the blacklist. Needs to be task formatted to work with confirmations.
|
||||
void blacklist_title(sys::Task *task, TitleOptionState::TaskData taskData);
|
||||
|
||||
/// @brief Wipes deletes all local backups for the current title.
|
||||
void delete_all_local_backups_for_title(sys::Task *task, TitleOptionState::TaskData taskData);
|
||||
/// @brief Wipes deletes all local backups for the current title.
|
||||
void delete_all_local_backups_for_title(sys::Task *task, TitleOptionState::TaskData taskData);
|
||||
|
||||
/// @brief Deletes all backups found on the remote storage service.
|
||||
void delete_all_remote_backups_for_title(sys::Task *task, TitleOptionState::TaskData taskData);
|
||||
/// @brief Deletes all backups found on the remote storage service.
|
||||
void delete_all_remote_backups_for_title(sys::Task *task, TitleOptionState::TaskData taskData);
|
||||
|
||||
/// @brief Resets save data for the current title.
|
||||
void reset_save_data(sys::Task *task, TitleOptionState::TaskData taskData);
|
||||
/// @brief Resets save data for the current title.
|
||||
void reset_save_data(sys::Task *task, TitleOptionState::TaskData taskData);
|
||||
|
||||
/// @brief Deletes the save data from the system the same way Data Management does.
|
||||
void delete_save_data_from_system(sys::Task *task, TitleOptionState::TaskData taskData);
|
||||
/// @brief Deletes the save data from the system the same way Data Management does.
|
||||
void delete_save_data_from_system(sys::Task *task, TitleOptionState::TaskData taskData);
|
||||
|
||||
/// @brief Extends the save container for the current save info.
|
||||
void extend_save_data(sys::Task *task, TitleOptionState::TaskData taskData);
|
||||
}
|
||||
/// @brief Extends the save container for the current save info.
|
||||
void extend_save_data(sys::Task *task, TitleOptionState::TaskData taskData);
|
||||
}
|
||||
|
||||
@@ -2,13 +2,10 @@
|
||||
#include "appstates/UserOptionState.hpp"
|
||||
#include "sys/sys.hpp"
|
||||
|
||||
namespace tasks
|
||||
namespace tasks::useroptions
|
||||
{
|
||||
namespace useroptions
|
||||
{
|
||||
void backup_all_for_user_local(sys::ProgressTask *task, UserOptionState::TaskData taskData);
|
||||
void backup_all_for_user_remote(sys::ProgressTask *task, UserOptionState::TaskData taskData);
|
||||
void create_all_save_data_for_user(sys::Task *task, UserOptionState::TaskData taskData);
|
||||
void delete_all_save_data_for_user(sys::Task *task, UserOptionState::TaskData taskData);
|
||||
}
|
||||
void backup_all_for_user_local(sys::ProgressTask *task, UserOptionState::TaskData taskData);
|
||||
void backup_all_for_user_remote(sys::ProgressTask *task, UserOptionState::TaskData taskData);
|
||||
void create_all_save_data_for_user(sys::Task *task, UserOptionState::TaskData taskData);
|
||||
void delete_all_save_data_for_user(sys::Task *task, UserOptionState::TaskData taskData);
|
||||
}
|
||||
|
||||
@@ -43,14 +43,17 @@ namespace ui
|
||||
/// @param hasFocus This is ignored.
|
||||
void render(sdl::SharedTexture &target, bool hasFocus) override;
|
||||
|
||||
/// @brief Sets the X and coords for the dialog box.
|
||||
void set_xy(int x, int y);
|
||||
/// @brief Sets the X render coord.
|
||||
void set_x(int x);
|
||||
|
||||
/// @brief Sets the width and height of the dialog.
|
||||
void set_width_height(int width, int height);
|
||||
/// @brief Sets the X render coord.
|
||||
void set_y(int y);
|
||||
|
||||
/// @brief Pass with the set functions to not change.
|
||||
static inline constexpr int NO_SET = -1;
|
||||
/// @brief Sets the width.
|
||||
void set_width(int width);
|
||||
|
||||
/// @brief Sets the height.
|
||||
void set_height(int height);
|
||||
|
||||
private:
|
||||
/// @brief X render coord.
|
||||
|
||||
61
include/ui/Frame.hpp
Normal file
61
include/ui/Frame.hpp
Normal file
@@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
#include "sdl.hpp"
|
||||
#include "ui/Element.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace ui
|
||||
{
|
||||
class Frame final : public ui::Element
|
||||
{
|
||||
public:
|
||||
/// @brief Constructs a new frame.
|
||||
Frame(int x, int y, int width, int height);
|
||||
|
||||
/// @brief Doesn't need to do anything because modern C++.
|
||||
~Frame() {};
|
||||
|
||||
/// @brief Inline function to make constructing nicer.
|
||||
static inline std::shared_ptr<ui::Frame> create(int x, int y, int width, int height)
|
||||
{
|
||||
return std::make_shared<ui::Frame>(x, y, width, height);
|
||||
}
|
||||
|
||||
/// @brief Doesn't need to do anything for this.
|
||||
void update(bool hasFocus) override {};
|
||||
|
||||
/// @brief Renders the frame to the target passed.
|
||||
void render(sdl::SharedTexture &target, bool hasFocus) override;
|
||||
|
||||
/// @brief Sets the X coord.
|
||||
void set_x(int x);
|
||||
|
||||
/// @brief Sets the Y coord.
|
||||
void set_y(int y);
|
||||
|
||||
/// @brief Sets the width of the frame.
|
||||
void set_width(int width);
|
||||
|
||||
/// @brief Sets the height of the frame.
|
||||
void set_height(int height);
|
||||
|
||||
private:
|
||||
/// @brief X rendering coord.
|
||||
int m_x{};
|
||||
|
||||
/// @brief Y rendering coord.
|
||||
int m_y{};
|
||||
|
||||
/// @brief Rendering width.
|
||||
int m_width{};
|
||||
|
||||
/// @brief Rendering height.
|
||||
int m_height{};
|
||||
|
||||
/// @brief This texture is shared by all instances.
|
||||
static inline sdl::SharedTexture sm_frameCorners{};
|
||||
|
||||
/// @brief Ensures the texture is loading if it hasn't been.
|
||||
void initialize_static_members();
|
||||
};
|
||||
}
|
||||
@@ -61,6 +61,15 @@ namespace ui
|
||||
/// @param width New width of the menu in pixels.
|
||||
void set_width(int width);
|
||||
|
||||
/// @brief Updates the X render coordinate.
|
||||
void set_x(int x);
|
||||
|
||||
/// @brief Updates the Y render coordinate.
|
||||
void set_y(int y);
|
||||
|
||||
/// @brief Returns if the menu has no options.
|
||||
bool is_empty() const;
|
||||
|
||||
/// @brief Resets the menu and returns it to an empty, default state.
|
||||
void reset();
|
||||
|
||||
|
||||
@@ -35,6 +35,9 @@ namespace ui
|
||||
/// @param hasFocus Whether or not the calling state has focus.
|
||||
void update(bool hasFocus) override;
|
||||
|
||||
/// @brief Sub update routine. Allows the panel to hide and unhide itself even when not in focus.
|
||||
void sub_update();
|
||||
|
||||
/// @brief Runs the render routine.
|
||||
/// @param target Target to render to.
|
||||
/// @param hasFocus Whether or the the calling state has focus.
|
||||
@@ -49,6 +52,12 @@ namespace ui
|
||||
/// @brief Closes the panel.
|
||||
void close();
|
||||
|
||||
/// @brief Hides the panel temporarily.
|
||||
void hide();
|
||||
|
||||
/// @brief Unhides the panel.
|
||||
void unhide();
|
||||
|
||||
/// @brief Returns if the panel is fully open.
|
||||
/// @return If the panel is fully open.
|
||||
bool is_open() const;
|
||||
@@ -57,6 +66,9 @@ namespace ui
|
||||
/// @return If the panel is fully closed.
|
||||
bool is_closed();
|
||||
|
||||
/// @brief Returns whether or not the panel is hidden.
|
||||
bool is_hidden() const;
|
||||
|
||||
/// @brief Pushes a new element to the element vector.
|
||||
/// @param newElement New element to push.
|
||||
void push_new_element(std::shared_ptr<ui::Element> newElement);
|
||||
@@ -75,6 +87,9 @@ namespace ui
|
||||
/// @brief Whether or not to close panel.
|
||||
bool m_closePanel{};
|
||||
|
||||
/// @brief Whether or not to hide the panel.
|
||||
bool m_hidePanel{};
|
||||
|
||||
/// @brief Current X coordinate to render to. Panels are always 720 pixels in height so no Y is required.
|
||||
double m_x{};
|
||||
|
||||
@@ -93,10 +108,16 @@ namespace ui
|
||||
/// @brief Vector of elements.
|
||||
std::vector<std::shared_ptr<ui::Element>> m_elements{};
|
||||
|
||||
/// @brief Handles sliding out logic.
|
||||
void slide_out();
|
||||
|
||||
/// @brief Slides the panel out from the left side.
|
||||
void slide_out_left();
|
||||
|
||||
/// @brief Slides the panel out from the right side.
|
||||
void slide_out_right();
|
||||
|
||||
int get_absolute_x_distance();
|
||||
/// @brief Contains the logic for hiding/closing the panel.
|
||||
void close_hide_panel();
|
||||
};
|
||||
} // namespace ui
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "ui/ColorMod.hpp"
|
||||
#include "ui/DialogBox.hpp"
|
||||
#include "ui/Element.hpp"
|
||||
#include "ui/Frame.hpp"
|
||||
#include "ui/IconMenu.hpp"
|
||||
#include "ui/Menu.hpp"
|
||||
#include "ui/PopMessageManager.hpp"
|
||||
|
||||
Reference in New Issue
Block a user