remote::Storage just barely working.

This commit is contained in:
J-D-K
2025-07-04 13:06:47 -04:00
parent e29db89706
commit e27e0c8e51
92 changed files with 2240 additions and 1044 deletions

View File

@@ -9,20 +9,20 @@ class JKSV
{
public:
/// @brief Initializes JKSV. Initializes services.
JKSV(void);
JKSV();
/// @brief Exits services.
~JKSV();
/// @brief Returns if initializing was successful and JKSV is running.
/// @return True or false.
bool is_running(void) const;
bool is_running() const;
/// @brief Runs JKSV's update routine.
void update(void);
void update();
/// @brief Runs JKSV's render routine.
void render(void);
void render();
private:
/// @brief Whether or not initialization was successful and JKSV is still running.

View File

@@ -13,13 +13,13 @@ class StateManager
StateManager &operator=(StateManager &&) = delete;
/// @brief Runs the state update routine.
static void update(void);
static void update();
/// @brief Runs the state rendering routine(s);
static void render(void);
static void render();
/// @brief Returns whether the back of the vector is a closable state.
static bool back_is_closable(void);
static bool back_is_closable();
/// @brief Pushes a new state to the state vector.
/// @param newState Shared_ptr to state to push.
@@ -27,11 +27,11 @@ class StateManager
private:
/// @brief Private constructor so no constructing.
StateManager(void) = default;
StateManager() = default;
/// @brief Returns a reference to the instance of StateManger.
/// @return Reference to state manager.
static StateManager &get_instance(void);
static StateManager &get_instance();
/// @brief This is the vector that holds the pointers to the states.
static inline std::vector<std::shared_ptr<AppState>> sm_stateVector;

View File

@@ -13,34 +13,34 @@ class AppState
virtual ~AppState();
/// @brief Every derived class is required to have this function.
virtual void update(void) = 0;
virtual void update() = 0;
/// @brief Every derived class is required to have this function.
virtual void render(void) = 0;
virtual void render() = 0;
/// @brief Deactivates state and allows JKSV to purge it from the vector.
void deactivate(void);
void deactivate();
/// @brief Allows a state to be reactivated and pushed to the vector.
void reactivate(void);
void reactivate();
/// @brief Returns if the state is still active.
/// @return Whether state is still active or can be purged.
bool is_active(void) const;
bool is_active() const;
/// @brief Tells the state it's at the back of the vector and has focus.
void give_focus(void);
void give_focus();
/// @brief Takes the focus away and tells the state it's no long back();
void take_focus(void);
void take_focus();
/// @brief Allows the state to know whether it has focus.
/// @return Whether state has focus or not.
bool has_focus(void) const;
bool has_focus() const;
/// @brief Returns whether or not JKSV should allow closing while state is active.
/// @return True if closable. False if not.
bool is_closable(void) const;
bool is_closable() const;
private:
/// @brief Stores whether or not the state is currently active.

View File

@@ -10,7 +10,7 @@
#include <memory>
/// @brief This is the state where the user can backup and restore saves.
class BackupMenuState : public AppState
class BackupMenuState final : public AppState
{
public:
/// @brief Creates a new backup selection state.
@@ -23,34 +23,34 @@ class BackupMenuState : public AppState
~BackupMenuState();
/// @brief Required. Inherited virtual function from AppState.
void update(void) override;
void update() override;
/// @brief Required. Inherited virtual function from AppState.
void render(void) override;
void render() override;
/// @brief Refreshes the directory listing and menu.
void refresh(void);
void refresh();
/// @brief Allows a spawned task to tell this class that it wrote save data to the system.
void save_data_written(void);
void save_data_written();
/// @brief Struct used for passing data to functions.
typedef struct
{
/// @brief Pointer to the target user.
data::User *m_user;
data::User *user;
/// @brief Data for the target title.
data::TitleInfo *m_titleInfo;
data::TitleInfo *titleInfo;
/// @brief Path of the target.
fslib::Path m_targetPath;
fslib::Path targetPath;
/// @brief Journal size for when a commit is needed.
uint64_t m_journalSize;
uint64_t journalSize;
/// @brief Pointer to >this spawning state.
BackupMenuState *m_spawningState;
BackupMenuState *spawningState;
} DataStruct;
private:
@@ -92,4 +92,16 @@ class BackupMenuState : public AppState
/// @brief The width of the panels. This is set according to the control guide text.
static inline int sm_panelWidth = 0;
/// @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();
};

View File

@@ -10,21 +10,21 @@ class BaseTask : public AppState
{
public:
/// @brief Constructor. Starts the glyph timer and sets AppState to not allow closing.
BaseTask(void);
BaseTask();
/// @brief Virtual destructor.
virtual ~BaseTask() {};
/// @brief Runs the update routine for rendering the loading glyph animation.
/// @param
void update(void) override;
void update() override;
/// @brief Virtual render function.
virtual void render(void) = 0;
virtual void render() = 0;
/// @brief This function renders the loading glyph in the bottom left corner.
/// @note This is mostly just so users don't think JKSV has frozen when operations take a long time.
void render_loading_glyph(void);
void render_loading_glyph();
private:
/// @brief This is the current frame of the loading glyph animation.

View File

@@ -24,7 +24,7 @@ namespace
/// @tparam StateType The state type spawned on confirmation. Ex: TaskState, ProgressState
/// @tparam StructType The type of struct passed to the state on confirmation.
template <typename TaskType, typename StateType, typename StructType>
class ConfirmState : public AppState
class ConfirmState final : public AppState
{
public:
/// @brief All functions passed to this state need to follow this signature: void function(<TaskType> *, std::shared_ptr<<StructType>>)
@@ -39,9 +39,8 @@ class ConfirmState : public AppState
bool holdRequired,
TaskFunction function,
std::shared_ptr<StructType> dataStruct)
: AppState(false), m_queryString(queryString.data()),
m_yesString(strings::get_by_name(strings::names::YES_NO, 0)), m_hold(holdRequired), m_function(function),
m_dataStruct(dataStruct)
: AppState(false), m_queryString(queryString), m_yesString(strings::get_by_name(strings::names::YES_NO, 0)),
m_hold(holdRequired), m_function(function), m_dataStruct(dataStruct)
{
// This is to make centering the Yes [A] string more accurate.
m_yesX = YES_X_CENTER_COORDINATE - (sdl::text::get_width(22, m_yesString.c_str()) / 2);
@@ -52,7 +51,7 @@ class ConfirmState : public AppState
~ConfirmState() {};
/// @brief Just updates the ConfirmState.
void update(void) override
void update() override
{
// This is to guard against the dialog being triggered right away. To do: Maybe figure out a better way to accomplish this?
if (input::button_pressed(HidNpadButton_A) && !m_triggerGuard)
@@ -109,7 +108,7 @@ class ConfirmState : public AppState
}
/// @brief Renders the state to screen.
void render(void) override
void render() override
{
// Dim background
sdl::render_rect_fill(NULL, 0, 0, 1280, 720, colors::DIM_BACKGROUND);

View File

@@ -4,20 +4,20 @@
#include "ui/Menu.hpp"
/// @brief Extras menu.
class ExtrasMenuState : public AppState
class ExtrasMenuState final : public AppState
{
public:
/// @brief Constructor.
ExtrasMenuState(void);
ExtrasMenuState();
/// @brief Required even if nothing happens.
~ExtrasMenuState() {};
/// @brief Updates the menu.
void update(void) override;
void update() override;
/// @brief Renders the menu to screen.
void render(void) override;
void render() override;
private:
/// @brief Menu

View File

@@ -6,26 +6,26 @@
#include <memory>
/// @brief The main
class MainMenuState : public AppState
class MainMenuState final : public AppState
{
public:
/// @brief Creates and initializes the main menu.
MainMenuState(void);
MainMenuState();
/// @brief Required even if it does nothing.
~MainMenuState() {};
/// @brief Runs update routine.
void update(void) override;
void update() override;
/// @brief Renders menu to screen.
void render(void) override;
void render() override;
/// @brief Signals to
static void initialize_view_states(void);
static void initialize_view_states();
/// @brief Calls refresh on on view states in the vector.
static void refresh_view_states(void);
static void refresh_view_states();
private:
/// @brief Render target this state renders to.

View File

@@ -5,7 +5,7 @@
#include <switch.h>
/// @brief State that shows progress of a task.
class ProgressState : public BaseTask
class ProgressState final : public BaseTask
{
public:
/// @brief Constructs a new ProgressState.
@@ -20,10 +20,10 @@ class ProgressState : public BaseTask
~ProgressState() {};
/// @brief Checks if the thread is finished and deactivates this state.
void update(void) override;
void update() override;
/// @brief Renders the current progress to screen.
void render(void) override;
void render() override;
private:
/// @brief Underlying task that has extra methods for tracking the progress of a task.

View File

@@ -7,7 +7,7 @@
#include <memory>
/// @brief This is the state that is spawned when CreateSaveData is selected from the user menu.
class SaveCreateState : public AppState
class SaveCreateState final : public AppState
{
public:
/// @brief Constructs a new SaveCreateState.
@@ -19,13 +19,13 @@ class SaveCreateState : public AppState
~SaveCreateState() {};
/// @brief Runs the update routine.
void update(void) override;
void update() override;
/// @brief Runs the render routine.
void render(void) override;
void render() override;
/// @brief This signals so data and the view can be refreshed on the next update() to avoid threading shenanigans.
void data_and_view_refresh_required(void);
void data_and_view_refresh_required();
private:
/// @brief Pointer to target user.

View File

@@ -4,20 +4,20 @@
#include "ui/Menu.hpp"
/// @brief The state for settings.
class SettingsState : public AppState
class SettingsState final : public AppState
{
public:
/// @brief Constructs a new settings state.
SettingsState(void);
SettingsState();
/// @brief Required destructor.
~SettingsState() {};
/// @brief Runs the update routine.
void update(void) override;
void update() override;
/// @brief Runs the render routine.
void render(void) override;
void render() override;
private:
/// @brief Menu for selecting and toggling settings.
@@ -30,8 +30,8 @@ class SettingsState : public AppState
int m_controlGuideX = 0;
/// @brief Runs a routine to update the menu strings for the menu.
void update_menu_options(void);
void update_menu_options();
/// @brief Toggles or executes the code to changed the selected menu option.
void toggle_options(void);
void toggle_options();
};

View File

@@ -4,7 +4,7 @@
#include <switch.h>
/// @brief State that spawns a task and allows updates to be printed to screen.
class TaskState : public BaseTask
class TaskState final : public BaseTask
{
public:
/// @brief Constructs and spawns a new TaskState.
@@ -19,11 +19,11 @@ class TaskState : public BaseTask
~TaskState() {};
/// @brief Runs update routine. Waits for thread function to signal finish and deactivates.
void update(void) override;
void update() override;
/// @brief Run render routine. Prints m_task's status string to screen, basically.
/// @param
void render(void) override;
void render() override;
private:
/// @brief Underlying task.

View File

@@ -5,7 +5,7 @@
#include "ui/Menu.hpp"
/// @brief Text menu title selection state.
class TextTitleSelectState : public TitleSelectCommon
class TextTitleSelectState final : public TitleSelectCommon
{
public:
/// @brief Constructs new text menu title selection state.
@@ -16,13 +16,13 @@ class TextTitleSelectState : public TitleSelectCommon
~TextTitleSelectState() {};
/// @brief Runs update routine.
void update(void) override;
void update() override;
/// @brief Runs render routine.
void render(void) override;
void render() override;
/// @brief Refreshes view for changes.
void refresh(void) override;
void refresh() override;
private:
/// @brief Pointer to user view "belongs" to.

View File

@@ -7,7 +7,7 @@
#include <memory>
#include <string>
class TitleInfoState : public AppState
class TitleInfoState final : public AppState
{
public:
/// @brief Constructs a new title info state.
@@ -19,10 +19,10 @@ class TitleInfoState : public AppState
~TitleInfoState();
/// @brief Runs update routine.
void update(void) override;
void update() override;
/// @brief Runs render routine.
void render(void) override;
void render() override;
private:
/// @brief Pointer to user.

View File

@@ -6,7 +6,7 @@
#include "ui/SlideOutPanel.hpp"
#include <memory>
class TitleOptionState : public AppState
class TitleOptionState final : public AppState
{
public:
/// @brief Constructs a new title option state.
@@ -18,16 +18,16 @@ class TitleOptionState : public AppState
~TitleOptionState() {};
/// @brief Runs update routine.
void update(void) override;
void update() override;
/// @brief Runs the render routine.
void render(void) override;
void render() override;
/// @brief This function allows tasks to signal to the spawning state to close itself on the next update() call.
void close_on_update(void);
void close_on_update();
/// @brief Signals to the main thread that a view refresh is required on the next update() call.
void refresh_required(void);
void refresh_required();
/// @brief This is the struct used to pass data to the thread functions.
typedef struct

View File

@@ -6,22 +6,22 @@ class TitleSelectCommon : public AppState
{
public:
/// @brief Constructs a new TitleSelectCommon. Basically just calculates the X coordinate of the control if it wasn't already.
TitleSelectCommon(void);
TitleSelectCommon();
/// @brief Required destructor.
virtual ~TitleSelectCommon() {};
/// @brief Required, inherited.
virtual void update(void) = 0;
virtual void update() = 0;
/// @brief Required, inherited.
virtual void render(void) = 0;
virtual void render() = 0;
/// @brief Both derived classes need this function.
virtual void refresh(void) = 0;
virtual void refresh() = 0;
/// @brief Renders the control guide string to the bottom right corner.
void render_control_guide(void);
void render_control_guide();
private:
/// @brief X coordinate the control guide is rendered at.

View File

@@ -5,7 +5,7 @@
#include "ui/TitleView.hpp"
/// @brief Title select state with icon tiles.
class TitleSelectState : public TitleSelectCommon
class TitleSelectState final : public TitleSelectCommon
{
public:
/// @brief Constructs new title select state.
@@ -16,13 +16,13 @@ class TitleSelectState : public TitleSelectCommon
~TitleSelectState() {};
/// @brief Runs the update routine.
void update(void) override;
void update() override;
/// @brief Runs the render routine.
void render(void) override;
void render() override;
/// @brief Refreshes the view.
void refresh(void) override;
void refresh() override;
private:
/// @brief Pointer to the user the view belongs to.

View File

@@ -7,7 +7,7 @@
#include <memory>
/// @brief State that allows certain actions to be taken for users.
class UserOptionState : public AppState
class UserOptionState final : public AppState
{
public:
/// @brief Constructs a new UserOptionState.
@@ -19,14 +19,14 @@ class UserOptionState : public AppState
~UserOptionState() {};
/// @brief Runs the render routine.
void update(void) override;
void update() override;
/// @brief Runs the render routine.
void render(void) override;
void render() override;
/// @brief Signals to the main update() function that a refresh is needed.
/// @note Like this to prevent threading headaches.
void data_and_view_refresh_required(void);
void data_and_view_refresh_required();
/// @brief Struct used for passing data to functions/tasks.
typedef struct

View File

@@ -5,13 +5,13 @@
namespace config
{
/// @brief Attempts to load config from file. If it fails, loads defaults.
void initialize(void);
void initialize();
/// @brief Resets config to default values.
void reset_to_default(void);
void reset_to_default();
/// @brief Saves config to file.
void save(void);
void save();
/// @brief Retrieves the config value according to the key passed.
/// @param key Key to retrieve. See config::keys
@@ -27,26 +27,13 @@ namespace config
/// @param value Value to set the key to.
void set_by_key(std::string_view key, uint8_t value);
/// @brief Retrieves value of config at index.
/// @param index Index of value to retrieve.
uint8_t get_by_index(int index);
/// @brief Toggles the key at index from 1 to 0 or vice-versa.
/// @param index Index of key to toggle.
void toggle_by_index(int index);
/// @brief Sets the config value at index to value.
/// @param index Index of value to set.
/// @param value Value to set index to.
void set_by_index(int index, uint8_t value);
/// @brief Returns the working directory.
/// @return Working directory.
fslib::Path get_working_directory(void);
fslib::Path get_working_directory();
/// @brief Returns the scaling speed of UI transitions and animations.
/// @return Scaling variable.
double get_animation_scaling(void);
double get_animation_scaling();
/// @brief Sets the UI animation scaling.
/// @param newScale New value to set the scaling to.

View File

@@ -1,6 +1,5 @@
#pragma once
#include "fslib.hpp"
#include "logger.hpp"
#include <curl/curl.h>
#include <memory>
#include <string>
@@ -10,7 +9,7 @@
namespace curl
{
/// @brief JKSV's user agent string.
static constexpr std::string_view USER_AGENT_STRING = "JKSV";
static const char *STRING_USER_AGENT = "JKSV";
/// @brief Self cleaning curl handle.
using Handle = std::unique_ptr<CURL, decltype(&curl_easy_cleanup)>;
@@ -23,10 +22,10 @@ namespace curl
/// @brief Initializes lib curl.
/// @return True on success. False on failure.
bool initialize(void);
bool initialize();
/// @brief Exits libcurl
void exit(void);
void exit();
/// @brief Inline templated function to wrap curl_easy_setopt and make using curl::Handle slightly easier.
/// @tparam Option Templated type of the option. This is a headache so let the compiler figure it out.
@@ -43,14 +42,14 @@ namespace curl
/// @brief Inline function that returns a self cleaning curl handle.
/// @return Curl handle.
static inline curl::Handle new_handle(void)
static inline curl::Handle new_handle()
{
return curl::Handle(curl_easy_init(), curl_easy_cleanup);
}
/// @brief Inline function that returns a nullptr'd self cleaning curl_list.
/// @return Self cleaning curl_slist.
static inline curl::HeaderList new_header_list(void)
static inline curl::HeaderList new_header_list()
{
return curl::HeaderList(nullptr, curl_slist_free_all);
}
@@ -59,41 +58,18 @@ namespace curl
/// @param curl curl::Handle to reset.
static inline void reset_handle(curl::Handle &curl)
{
// Reset the handle.
curl_easy_reset(curl.get());
// Set the user agent since basically everything needs it.
curl::set_option(curl, CURLOPT_USERAGENT, curl::USER_AGENT_STRING.data());
curl::set_option(curl, CURLOPT_USERAGENT, curl::STRING_USER_AGENT);
}
/// @brief Logged inline wrapper function for curl_easy_perform.
/// @param curl Handle to perform.
/// @return True on success. False on failure.
static inline bool perform(curl::Handle &curl)
{
// CURLCode is just an int anyway.
CURLcode error = curl_easy_perform(curl.get());
if (error != CURLE_OK)
{
logger::log("Error performing curl: %i.", error);
return false;
}
return true;
}
/// @param handle Handle to perform.
bool perform(curl::Handle &handle);
/// @brief Inline wrapper function to make adding to HeaderList simpler.
/// @param headerList Header list to append to.
/// @param header Header to append.
static inline void append_header(curl::HeaderList &headerList, std::string_view header)
{
// Release the current list and save the pointer to the head of it.
curl_slist *list = headerList.release();
// Append to it.
curl_slist_append(list, header.data());
// Reassign the unique_ptr to the new head.
headerList.reset(list);
}
void append_header(curl::HeaderList &list, std::string_view header);
/// @brief Curl callback function for reading data from a file.
/// @param buffer Incoming buffer from curl to read to.
@@ -131,9 +107,24 @@ namespace curl
/// @param array Array of headers to search.
/// @param header Header to search for.
/// @param valueOut String to write the value to.
/// @return True if the header was found and the value was successfully extracted.
bool get_header_value(const curl::HeaderArray &array, std::string_view header, std::string &valueOut);
/// @brief Gets the response code from the handle passed.
/// @param handle Handle to get the response code from.
long get_response_code(curl::Handle &handle);
/// @brief Calls curl_easy_escape using the passed curl::Handle.
/// @param handle Handle to use.
/// @param in String to escape.
/// @param out String to write the escaped text to.
bool escape_string(curl::Handle &handle, std::string_view in, std::string &out);
/// @brief Calls curl_easy_unescape using the passed curl::Handle.
/// @param handle Handle to use.
/// @param in String to unescape.
/// @param out String to write the escaped text to.
bool unescape_string(curl::Handle &handle, std::string_view in, std::string &out);
/// @brief Prepares the curl handle passed for a get request.
/// @param curl Handle to prepare for a get request.
void prepare_get(curl::Handle &curl);

View File

@@ -21,31 +21,30 @@ namespace data
/// @brief Returns the application ID of the title.
/// @return Title's application ID.
uint64_t get_application_id(void) const;
uint64_t get_application_id() const;
/// @brief Returns a pointer to the control data for the title.
/// @return Pointer to control data.
NsApplicationControlData *get_control_data(void);
NsApplicationControlData *get_control_data();
/// @brief Returns whether or not the title has control data.
/// @return Whether or not the title has control data.
bool has_control_data(void) const;
bool has_control_data() const;
/// @brief Returns the title of the title?
/// @return Title directly from the NACP.
const char *get_title(void);
const char *get_title();
/// @brief Returns the path safe version of the title for file system usage.
/// @return Path safe version of the title.
const char *get_path_safe_title(void);
const char *get_path_safe_title() const;
/// @brief Returns the publisher of the title.
/// @return Publisher string from NACP.
const char *get_publisher(void);
const char *get_publisher();
/// @brief Returns the owner ID of the save data.
/// @return Save data owner ID.
uint64_t get_save_data_owner_id(void) const;
uint64_t get_save_data_owner_id() const;
/// @brief Returns the save data container's base size.
/// @param saveType Type of save data to return.
@@ -70,11 +69,11 @@ namespace data
/// @brief Returns if a title uses the save type passed.
/// @param saveType Save type to check for.
/// @return True on success. False on failure.
bool has_save_data_type(uint8_t saveType);
bool has_save_data_type(uint8_t saveType) const;
/// @brief Returns a pointer to the icon texture.
/// @return Icon
sdl::SharedTexture get_icon(void) const;
sdl::SharedTexture get_icon() const;
/// @brief Allows the path safe title to be set to a new path.
/// @param newPathSafe Buffer containing the new safe path to use.
@@ -101,6 +100,6 @@ namespace data
sdl::SharedTexture m_icon = nullptr;
/// @brief Private function to get/create the path safe title.
void get_create_path_safe_title(void);
void get_create_path_safe_title();
};
} // namespace data

View File

@@ -39,34 +39,34 @@ namespace data
void add_data(const FsSaveDataInfo *saveInfo, const PdmPlayStatistics *playStats);
/// @brief Clears the user save info vector.
void clear_data_entries(void);
void clear_data_entries();
/// @brief Erases data at index.
/// @param index Index of save data info to erase.
void erase_data(int index);
/// @brief Runs the sort algo on the vector.
void sort_data(void);
void sort_data();
/// @brief Returns the account ID of the user.
/// @return AccountID
AccountUid get_account_id(void) const;
AccountUid get_account_id() const;
/// @brief Returns the save data type the account uses.
/// @return Save data type of the account.
FsSaveDataType get_account_save_type(void) const;
FsSaveDataType get_account_save_type() const;
/// @brief Returns the account's nickname.
/// @return Account nickname.
const char *get_nickname(void) const;
const char *get_nickname() const;
/// @brief Returns the path safe version of the nickname.
/// @return Path safe nickname.
const char *get_path_safe_nickname(void) const;
const char *get_path_safe_nickname() const;
/// @brief Returns the total number of entries in the data vector.
/// @return Total number of entries.
size_t get_total_data_entries(void) const;
size_t get_total_data_entries() const;
/// @brief Returns the application ID of the title at index.
/// @param index Index of title.
@@ -90,7 +90,7 @@ namespace data
/// @brief Returns a reference to the user save data info vector.
/// @return Reference to the user save info vector.
data::UserSaveInfoList &get_user_save_info_list(void);
data::UserSaveInfoList &get_user_save_info_list();
/// @brief Returns a pointer to the play statistics of applicationID
/// @param applicationID Application ID to search and fetch.
@@ -99,18 +99,18 @@ namespace data
/// @brief Returns raw SDL_Texture pointer of icon.
/// @return SDL_Texture of icon.
SDL_Texture *get_icon(void);
SDL_Texture *get_icon();
/// @brief Returns the shared texture of icon. Increasing reference count of it.
/// @return Shared icon texture.
sdl::SharedTexture get_shared_icon(void);
sdl::SharedTexture get_shared_icon();
/// @brief Erases a UserDataEntry according to the application ID passed.
/// @param applicationID ID of the save to erase.
void erase_save_info_by_id(uint64_t applicationID);
/// @brief Loads the save data info and play statistics for the current user using the information passed to the constructor.
void load_user_data(void);
void load_user_data();
private:
/// @brief Account's ID
@@ -137,7 +137,7 @@ namespace data
void load_account(AccountProfile &profile, AccountProfileBase &profileBase);
/// @brief Creates a placeholder since something went wrong.
void create_account(void);
void create_account();
/// @brief Opens a save data info reader according to the data passed to the user.
/// @param spaceID The FsSaveDataSpaceId to use when opening the reader.

View File

@@ -24,5 +24,6 @@ static inline bool operator==(AccountUid accountIDA, AccountUid accountIDB)
/// @note I'm not 100% sure which uint64_t in the AccountUid struct comes first. I don't know if it's [0][1] or [1][0]. To do: Figure that out.
static inline bool operator==(AccountUid accountIDA, u128 accountIDB)
{
return accountIDA.uid[0] == (accountIDB >> 64 & 0xFFFFFFFFFFFFFFFF) && accountIDA.uid[1] == (accountIDB & 0xFFFFFFFFFFFFFFFF);
return accountIDA.uid[0] == (accountIDB >> 64 & 0xFFFFFFFFFFFFFFFF) &&
accountIDA.uid[1] == (accountIDB & 0xFFFFFFFFFFFFFFFF);
}

View File

@@ -26,7 +26,7 @@ namespace data
/// @brief Returns a reference to the title info map.
/// @return Reference to TitleInfoMap.
std::unordered_map<uint64_t, data::TitleInfo> &get_title_info_map(void);
std::unordered_map<uint64_t, data::TitleInfo> &get_title_info_map();
/// @brief Uses the application ID passed to add/load a title to the map.
/// @param applicationID Application/System save data ID to add.

View File

@@ -4,10 +4,10 @@
namespace input
{
/// @brief Initializes PadState and input.
void initialize(void);
void initialize();
/// @brief Updates the PadState.
void update(void);
void update();
/// @brief Returns if a button was pressed the current frame, but not the previous.
/// @param button Button to check.

View File

@@ -3,7 +3,7 @@
namespace logger
{
/// @brief Creates and empties the log file
void initialize(void);
void initialize();
/// @brief Logs a formatted string.
/// @param format Format of string.

43
include/remote/Form.hpp Normal file
View File

@@ -0,0 +1,43 @@
#pragma once
#include <string>
namespace remote
{
/// @brief This is a class to build URL encoded form bodies and be more readable than snprintfs.
class Form
{
public:
Form() = default;
/// @brief Copy constructor
/// @param form Form to copy from.
Form(const Form &form);
/// @brief Move constructor.
/// @param form Form to copy from.
Form(Form &&form);
/// @brief = Operator.
/// @param form Form to copy.
Form &operator=(const Form &form);
/// @brief = Move operator.
/// @param form Form to rob of its life.
Form &operator=(Form &&form);
/// @brief Appends a parameter to the form/URL encoded text.
/// @param param Parameter to append.
/// @param value Value to append.
Form &append_parameter(std::string_view param, std::string_view value);
/// @brief Returns the C string of the form string.
const char *get() const;
/// @brief Returns m_form.length()
size_t length() const;
private:
/// @brief String containing the actual data posted.
std::string m_form{};
};
} // namespace remote

View File

@@ -8,116 +8,85 @@ namespace remote
class GoogleDrive final : public remote::Storage
{
public:
/// @brief Google Drive class constructor. Unlike PC prototype, the path to the client_secret is hardcoded.
/// @param
GoogleDrive(void);
/// @brief Loads the config from SD.
GoogleDrive();
/// @brief Changes the current parent directory.
/// @param id ID of the parent to target.
void change_directory(std::string_view id) override;
/// @brief Creates a new directory on Google Drive.
/// @brief Creates a directory on Google Drive.
/// @param name Name of the directory to create.
/// @return True on success. False on failure.
bool create_directory(std::string_view name) override;
/// @brief Deletes a directory from Google Drive.
/// @param id ID of the directory to delete.
/// @return True on success. False on failure.
bool delete_directory(std::string_view id) override;
/// @brief Uploads a file to Google Drive.
/// @param source Source path.
/// @return True on success. False on failure.
/// @brief Uploads the file from source. File name is used to name the file.
/// @param source Path to upload the file from.
bool upload_file(const fslib::Path &source) override;
/// @brief Patches or updates a file on Google Drive.
/// @param id ID of the file to patch.
/// @param source Source path of the updated file.
/// @return True on success. False on failure.
bool patch_file(std::string_view id, const fslib::Path &source) override;
/// @brief Deletes a file from Google Drive.
/// @param id ID of the file to delete.
/// @return True on success. False on failure.
bool delete_file(std::string_view id) override;
/// @brief Patches or updates the file on Google Drive.
/// @param file Pointer to the item containing the data needed to update the file.
/// @param source Source path to update from.
bool patch_file(remote::Item *file, const fslib::Path &source) override;
/// @brief Downloads a file from Google Drive.
/// @param id ID of the file to download.
/// @param destination Path with the destination to save the file to.
/// @return True on success. False on failure.
bool download_file(std::string_view id, const fslib::Path &destination) override;
/// @param file Pointer to the item containing data to download the file.
/// @param destination Location to write the downloaded file to.
bool download_file(const remote::Item *file, const fslib::Path &destination) override;
// Sign in related functions.
/// @brief Returns if a sign in is required for using Google Drive.
/// @return True if sign in is required. False if it isn't.
bool sign_in_required(void) const;
/// @brief Deletes an item from Google Drive.
/// @param item Pointer to item containing data to delete the item.
bool delete_item(const remote::Item *item) override;
/// @brief Gets the data needed to display and sign into Google.
/// @param code String to write the sign in code to.
/// @param expires std::time_t to write the expiration time to.
/// @param wait Time in seconds while pinging server.
/// @return True on success. False on failure.
bool get_sign_in_data(std::string &code, std::time_t &expires, int &wait);
/// @brief Returns whether or not a sign in is required to use drive. AKA the refresh token is missing.
bool sign_in_required() const;
/// @brief This function waits for the response from the server that the user signed in.
/// @return True on success. False on failure.
bool sign_in(void);
/// @brief Requests the the necessary data from Google to login.
/// @param message String to store the message to.
/// @param code String to store the device code from Google.
/// @param expiration time_t to store when the sign in window closes.
/// @param wait Int to store the time in seconds between server pings.
bool get_sign_in_data(std::string &message, std::string &code, std::time_t &expiration, int &wait);
/// @brief This is the function that pings the server to see if the user entered the code yet.
/// @param code The code Google reponded with for verification.
/// @return If the user signs in, true. If not, false;
bool poll_sign_in(std::string_view code);
private:
/// @brief Client ID.
/// @brief Google client ID.
std::string m_clientId;
/// @brief Client secret.
/// @brief Google client secret.
std::string m_clientSecret;
/// @brief Authorization token.
/// @brief Authentication token.
std::string m_token;
/// @brief Token refresh token.
/// @brief Token used for refreshing token when it expires.
std::string m_refreshToken;
/// @brief Authentication header string.
/// @brief This is to save the authentication header string instead of recreating it over and over.
std::string m_authHeader;
/// @brief Calculated time the token expires in.
/// @brief This is the calculate time when the auth token expires.
std::time_t m_tokenExpires;
/// @brief Gets and sets the root ID of Google Drive using V2 of the API.
/// @return True on success. False on failure.
bool get_set_root_id(void);
/// @brief Uses V2 of Drive's API to get the root directory ID from Google.
bool get_root_id();
/// @brief Returns whether or not the token is still valid with a grace period of 10 seconds.
/// @return True if the token is still valid. False if it isn't.
bool token_is_valid(void) const;
/// @brief Returns whether or not the auth token is still valid for use or needs to be refreshed.
bool token_is_valid() const;
/// @brief Forces a refresh of the access token.
/// @return True on success. False on failure.
bool refresh_token(void);
/// @brief Attempts to refresh the auth token if needed.
bool refresh_token();
/// @brief Requests a listing and processes it.
/// @return True on success. False on failure.
bool request_listing(void);
/// @brief Requests and processes the entire listing for JKSV.
bool request_listing();
/// @brief Processes a file list from Google Drive.
/// @param json Json object to process.
/// @return True on success. False on failure.
/// @brief Processes and listing
/// @param json Json object to use for parsing.
bool process_listing(json::Object &json);
/// @brief Tries to locate a directory according to its ID instead of its name.
/// @param id ID of the directory to search for.
/// @return Iterator to directory found. m_list.end() on failure.
remote::Storage::List::iterator find_directory_by_id(std::string_view id);
/// @brief Tries to locate a file according to its ID instead of its name.
/// @param id ID of the file to locate.
/// @return Iterator to the file on success. m_list.end() on failure.
remote::Storage::List::iterator find_file_by_id(std::string_view id);
/// @brief Checks for, logs, and returns if an error is detected within the json::Object passed.
/// @param json json::Object to check.
/// @return True if an error was found. False if one wasn't.
bool error_occurred(json::Object &json);
/// @brief Performs a quick check on the json object passed for errors.
/// @param json Json object to check.
/// @param log Whether or not to log the error.
/// @note This doesn't catch every error. Google's errors aren't consistent.
bool error_occurred(json::Object &json, bool log = true);
};
} // namespace remote

View File

@@ -16,23 +16,23 @@ namespace remote
/// @brief Returns the name of the item.
/// @return Name of the item.
std::string_view get_name(void) const;
std::string_view get_name() const;
/// @brief Returns the id of the item.
/// @return ID of the item.
std::string_view get_id(void) const;
std::string_view get_id() const;
/// @brief Returns the parent id of the item.
/// @return Parent ID of the item.
std::string_view get_parent_id(void) const;
std::string_view get_parent_id() const;
/// @brief Gets the size of the item.
/// @return Size of the item in bytes.
size_t get_size(void) const;
size_t get_size() const;
/// @brief Returns whether or not the item is a directory.
/// @return Whether or not the item is a directory.
bool is_directory(void) const;
bool is_directory() const;
/// @brief Sets the name of the item.
/// @param name New name of the item.

View File

@@ -8,102 +8,113 @@
namespace remote
{
/// @brief This is the base storage class.
class Storage
{
public:
// Definition for remote file listing.
/// @brief Definition to make things easier to type.
using DirectoryListing = std::vector<remote::Item *>;
/// @brief This makes writing some stuff for these classes way easier.
using List = std::vector<remote::Item>;
/// @brief Default storage constructor.
Storage(void) = default;
/// @brief This just allocates the curl::Handle.
Storage();
/// @brief Returns whether or not the storage type/driver was initialized successfully.
/// @return True if it was. False if it wasn't.
bool is_initialized(void) const;
/// @brief Returns whether or not the Storage type was successfully. initialized.
bool is_initialized() const;
// Directory functions.
/// @brief Returns whether or not a directory with name exists within the current parent.
/// @param name Name of the directory.
/// @return True if one was found. False if one wasn't.
/// @param name Name of the directory to search for.
bool directory_exists(std::string_view name);
/// @brief Tries to locate and get the ID of a directory within the current parent.
/// @param name Name of the directory to get.
/// @param idOut String to write the ID to if it's found.
/// @return True on success. False on failure.
bool get_directory_id(std::string_view name, std::string &idOut);
/// @brief Returns the parent to the root directory.
void return_to_root();
/// @brief Returns whether or not a file exists within the current parent directory.
/// @param name Name of the file to search for.
/// @return True if one is found. False if one isn't.
bool file_exists(std::string_view name);
/// @brief This allows the root to be set to something other than what it originally was at construction.
/// @param root Item to be used as the new root.
void set_root_directory(remote::Item *root);
/// @brief Tries to locate and get the ID of a file within the current parent directory.
/// @param name Name of the file to search for
/// @param idOut String it write the ID to.
/// @return True on success. False when no file is found.
bool get_file_id(std::string_view name, std::string &idOut);
/// @brief Changes the current parent directory.
/// @param Item Item to use as the current parent directory.
void change_directory(remote::Item *item);
/// @brief Virtual function to change the current parent/working directory.
/// @param name Name or ID of the directory to change to.
virtual void change_directory(std::string_view name) = 0;
/// @brief Virtual function to create a new directory within the current parent directory.
/// @brief Creates a directory in the current parent directory.
/// @param name Name of the directory to create.
/// @return True on success. False on failure.
virtual bool create_directory(std::string_view name) = 0;
/// @brief Virtual function to delete a directory from within the current parent directory.
/// @param name Name or ID of the directory to delete.
/// @return True on success. False on failure.
virtual bool delete_directory(std::string_view name) = 0;
/// @brief Searches the list for a directory matching name and the current parent.
/// @param name Name of the directory to search for.
/// @return Pointer to the item representing the directory on success. nullptr on failure/not found.
remote::Item *get_directory_by_name(std::string_view name);
/// @brief Virtual function to upload a file to remote storage.
/// @param source fslib::Path of the source file to upload.
/// @return True on success. False on failure.
/// @brief Retrieves a listing of the items in the current parent directory.
/// @param out List to fill.
remote::Storage::DirectoryListing get_directory_listing();
// File functions.
/// @brief Returns whether a file with name exists within the current directory.
/// @param name Name of the file.
bool file_exists(std::string_view name);
/// @brief Uploads a file from the SD card to the remote.
/// @param source Path to the file to upload.
virtual bool upload_file(const fslib::Path &source) = 0;
/// @brief Virtual function to patch or update a file.
/// @param name Name or ID of the file to update.
/// @param source Source path to upload from.
/// @return True on success. False on failure.
virtual bool patch_file(std::string_view name, const fslib::Path &source) = 0;
/// @brief Patches or updates a file on the remote.
/// @param item Item to be updated.
/// @param source Path to the file to update with.
virtual bool patch_file(remote::Item *file, const fslib::Path &source) = 0;
/// @brief Virtual function for downloading a file.
/// @param name Name or ID of the file.
/// @param destination fslib::Path containing the destination path.
/// @return True on success. False on failure.
virtual bool download_file(std::string_view name, const fslib::Path &destination) = 0;
/// @brief Downloads a file from the remote.
/// @param item Item to download.
/// @param destination Path to download the file to.
virtual bool download_file(const remote::Item *file, const fslib::Path &destination) = 0;
/// @brief Virtual function to delete a file from the remote storage.
/// @param name Name or ID of the file to delete.
/// @return True on success. False on failure.
virtual bool delete_file(std::string_view name) = 0;
/// @brief Searches the list for a file matching name and the current parent.
/// @param name Name of the file to search for.
/// @return Pointer to the item if located. nullptr if not.
remote::Item *get_file_by_name(std::string_view name);
// General functions that apply to both.
/// @brief Deletes a file or folder from the remote.
/// @param item Item to delete.
virtual bool delete_item(const remote::Item *item) = 0;
/// @brief Returns whether or not the remote storage type supports UTF-8 for names or requires path safe titles.
bool supports_utf8() const;
protected:
/// @brief Whether or not initialization of the remote storage service was successful.
/// @brief This is the size of the buffers used for snprintf'ing URLs together.
static constexpr size_t SIZE_URL_BUFFER = 0x401;
/// @brief This is the size used for uploads.
static constexpr size_t SIZE_UPLOAD_BUFFER = 0x10000;
/// @brief This allows JKSV to know whether or not the storage type supports UTF-8.
bool m_utf8Paths = false;
/// @brief This stores whether or not the instance was initialized successfully.
bool m_isInitialized = false;
/// @brief The root directory of the remote storage.
/// @brief This is the root directory of the remote storage.
std::string m_root;
/// @brief Current parent directory.
/// @brief This stores the current parent.
std::string m_parent;
/// @brief Current storage listing.
Storage::List m_list;
/// @brief CURL handle.
/// @brief Curl handle.
curl::Handle m_curl;
/// @brief Searches for a directory in the current parent directory.
/// @param name Name of the directory to search for.
/// @return Iterator to found directory or m_list.end() on failure.
Storage::List::iterator find_directory(std::string_view name);
/// @brief This is the main remote listing.
Storage::List m_list;
/// @brief Searches for a file named file within the current parent directory.
/// @brief Searches the list for a directory matching name and the current parent.
/// @param name Name to search for.
Storage::List::iterator find_directory_by_name(std::string_view name);
/// @brief Searches to find if a file with name exists within the current parent.
/// @param name Name of the file to search for.
/// @return Iterator to the file found. m_list.end() on failure.
Storage::List::iterator find_file(std::string_view name);
Storage::List::iterator find_file_by_name(std::string_view name);
};
} // namespace remote

60
include/remote/URL.hpp Normal file
View File

@@ -0,0 +1,60 @@
#pragma once
#include <string>
namespace remote
{
/// @brief This is a class to make URLs easier to build for Google Drive and WebDav.
/// @note Normally I don't go this route, but it makes things easier.
class URL final
{
public:
/// @brief Default
URL() = default;
/// @brief Constructs a URL with a base URL already in place.
/// @param base String_view containing the base URL.
URL(std::string_view base);
/// @brief Copy constructor.
/// @param url URL to copy.
URL(const URL &url);
/// @brief Move constructor.
/// @param url URL to move.
URL(URL &&url);
/// @brief Makes a copy of the URL passed.
/// @param url remote::URL instance to make a copy of.
URL &operator=(const URL &url);
/// @brief Move operator.
/// @param url URL to move.
URL &operator=(URL &&url);
/// @brief Sets the base URL. Basically resets the string back to square 0.
/// @param base Base URL to start with.
URL &set_base(std::string_view base);
/// @brief Appends the string passed as a path to the URL
/// @param path Path to append;
URL &append_path(std::string_view path);
/// @brief Appends a string parameter
/// @param param Parameter to append.
/// @param value Value of the parameter to append.
URL &append_parameter(std::string_view param, std::string_view value);
/// @brief Appends a trailing slash if needed.
URL &append_slash();
/// @brief Returns the C string of the url string.
const char *get() const;
private:
/// @brief This is where the actual URL is held.
std::string m_url;
/// @brief This checks and appends the necessary separator to the URL string.
void append_separator();
};
} // namespace remote

58
include/remote/WebDav.hpp Normal file
View File

@@ -0,0 +1,58 @@
#pragma once
#include "remote/Storage.hpp"
#include "remote/URL.hpp"
#include <string>
namespace remote
{
class WebDav final : public remote::Storage
{
public:
/// @brief Loads the WebDav config from the SD card and loads the listing.
WebDav();
/// @brief Creates a new directory on the WebDav server.
/// @param name Name of the directory to create.
bool create_directory(std::string_view name) override;
/// @brief Uploads a file to the webdav server. File name is retrieved from the path.
/// @param source Local path of the file to upload.
bool upload_file(const fslib::Path &source) override;
/// @brief Patches or updates a file on the WebDav server.
/// @param file Pointer to the file to update.
/// @param source Path of the source file to update with.
bool patch_file(remote::Item *file, const fslib::Path &source) override;
/// @brief Downloads the passed file from the WebDav server.
/// @param file Pointer to the file to download.
/// @param destination Path to write the downloaded data from.
bool download_file(const remote::Item *item, const fslib::Path &destination) override;
/// @brief Deletes the target item from the WebDav server.
/// @param item Item to delete.
bool delete_item(const remote::Item *item) override;
private:
/// @brief Origin or server address.
std::string m_origin;
/// @brief Username for curl requests.
std::string m_username;
/// @brief Password for curl requests.
std::string m_password;
/// @brief Appends the username and password to a WebDav curl request.
void append_credentials();
/// @brief Requests PROPFIND to the url passed.
/// @param url URL to PROPFIND with.
/// @param xml String to record XML response to.
bool prop_find(const remote::URL &url, std::string &xml);
/// @brief Processes a PROPFIND XML response.
/// @param xml XML response.
bool process_listing(std::string_view xml);
};
} // namespace remote

19
include/remote/remote.hpp Normal file
View File

@@ -0,0 +1,19 @@
#pragma once
#include "remote/Storage.hpp"
#include <memory>
namespace remote
{
// Both of these are needed in two different places.
static constexpr std::string_view PATH_GOOGLE_DRIVE_CONFIG = "sdmc:/config/JKSV/client_secret.json";
static constexpr std::string_view PATH_WEBDAV_CONFIG = "sdmc:/config/JKSV/WebDav.json";
/// @brief Initializes the Storage instance to Google Drive.
void initialize_google_drive();
/// @brief Initializes the Storage instance to WebDav
void initialize_webdav();
/// @brief Returns the pointer to the Storage instance.
remote::Storage *get_remote_storage();
} // namespace remote

View File

@@ -4,7 +4,7 @@
namespace strings
{
// Attempts to load strings from file in RomFS.
bool initialize(void);
bool initialize();
// Returns string with name and index. Returns nullptr if string doesn't exist.
const char *get_by_name(std::string_view name, int index);
@@ -41,5 +41,6 @@ namespace strings
static constexpr std::string_view POP_MESSAGES_SAVE_CREATE = "PopMessagesSaveCreate";
static constexpr std::string_view POP_MESSAGES_TITLE_OPTIONS = "PopMessagesTitleOptions";
static constexpr std::string_view GOOGLE_DRIVE_STRINGS = "GoogleDriveStrings";
static constexpr std::string_view WEBDAV_STRINGS = "WebDavStrings";
} // namespace names
} // namespace strings

View File

@@ -25,11 +25,11 @@ namespace sys
/// @brief Returns the goal value.
/// @return Goal
double get_goal(void) const;
double get_goal() const;
/// @brief Returns the current progress.
/// @return Current progress.
double get_current(void) const;
double get_current() const;
private:
// Current value and goal

View File

@@ -35,11 +35,11 @@ namespace sys
/// @brief Returns if the thread has signaled it's finished running.
/// @return True if the thread is still running. False if it isn't.
bool is_running(void) const;
bool is_running() const;
/// @brief Allows thread to signal it's finished.
/// @note Spawned task threads must call this when their work is finished.
void finished(void);
void finished();
/// @brief Sets the task/threads current status string. Thread safe.
/// @param format Format of string.
@@ -48,7 +48,7 @@ namespace sys
/// @brief Returns the status string. Thread safe.
/// @return Copy of the status string.
std::string get_status(void);
std::string get_status();
private:
// Whether task is still running.

View File

@@ -9,7 +9,7 @@ namespace sys
{
public:
/// @brief Default constructor.
Timer(void) = default;
Timer() = default;
/// @brief Constructs a new timer.
/// @param triggerTicks Number of ticks the timer is triggered at.
@@ -21,15 +21,16 @@ namespace sys
/// @brief Updates and returns if the timer was triggered.
/// @return True if timer is triggered. False if it isn't.
bool is_triggered(void);
bool is_triggered();
/// @brief Forces the timer to restart.
void restart(void);
void restart();
private:
// Beginning ticks.
/// @brief Tick count when the timer starts.
uint64_t m_startingTicks;
// How many ticks to trigger the timer.
/// @brief Number of ticks to trigger on.
uint64_t m_triggerTicks;
};
} // namespace sys

View File

@@ -9,14 +9,14 @@ namespace ui
{
public:
/// @brief Default constructor.
ColorMod(void) = default;
ColorMod() = default;
/// @brief Updates the color modification variable.
void update(void);
void update();
/// @brief Operator that allows using this as an sdl::Color directly.
/// @note Since all of these pulse the same color, no sense in not doing this.
operator sdl::Color(void) const;
operator sdl::Color() const;
private:
/// @brief Whether we're adding or subtracting from the color value.

View File

@@ -8,7 +8,7 @@ namespace ui
{
public:
/// @brief Default constructor.
Element(void) = default;
Element() = default;
/// @brief Virtual destructor.
virtual ~Element() {};

View File

@@ -8,7 +8,7 @@ namespace ui
{
public:
/// @brief Default constructor.
IconMenu(void) = default;
IconMenu() = default;
/// @brief This constructor calls initialize.
/// @param x X coordinate to render the menu to.

View File

@@ -41,7 +41,7 @@ namespace ui
/// @brief Returns the index of the currently selected menu option.
/// @return Index of currently selected option.
int get_selected(void) const;
int get_selected() const;
/// @brief Sets the selected item.
/// @param selected Value to set selected to.
@@ -52,7 +52,7 @@ namespace ui
void set_width(int width);
/// @brief Resets the menu and returns it to an empty, default state.
void reset(void);
void reset();
protected:
/// @brief X coordinate menu is rendered to.

View File

@@ -31,10 +31,10 @@ namespace ui
PopMessageManager &operator=(PopMessageManager &&) = delete;
/// @brief Updates and processes message queue.
static void update(void);
static void update();
/// @brief Renders messages to screen.
static void render(void);
static void render();
/// @brief Pushes a new message to the queue for processing.
/// @param displayTicks Number of ticks for the message to be displayed until it is purged.
@@ -47,9 +47,9 @@ namespace ui
private:
// Only one instance allowed.
PopMessageManager(void) = default;
PopMessageManager() = default;
// Returns the only instance.
static PopMessageManager &get_instance(void)
static PopMessageManager &get_instance()
{
static PopMessageManager manager;
return manager;

View File

@@ -33,32 +33,32 @@ namespace ui
void render(SDL_Texture *target, bool hasFocus);
/// @brief Clears the target to a semi-transparent black. To do: Maybe not hard coded color.
void clear_target(void);
void clear_target();
/// @brief Resets the panel back to its default state.
void reset(void);
void reset();
/// @brief Closes the panel.
void close(void);
void close();
/// @brief Returns if the panel is fully open.
/// @return If the panel is fully open.
bool is_open(void) const;
bool is_open() const;
/// @brief Returns if the panel is fully closed.
/// @return If the panel is fully closed.
bool is_closed(void) const;
bool is_closed() 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);
/// @brief Clears the element vector, freeing them in the process.
void clear_elements(void);
void clear_elements();
/// @brief Returns a pointer to the render target of the panel.
/// @return Raw SDL_Texture pointer to target.
SDL_Texture *get_target(void);
SDL_Texture *get_target();
private:
/// @brief Bool for whether panel is fully open or not.

View File

@@ -10,7 +10,7 @@ namespace ui
{
public:
/// @brief This is only here so I can get around the backup menu having static members.
TextScroll(void) = default;
TextScroll() = default;
/// @brief Constructor for TextScroll.
/// @param text Text to create the textscroll with.

View File

@@ -23,15 +23,15 @@ namespace ui
void render(SDL_Texture *target, int x, int y);
/// @brief Resets the width and height of the tile.
void reset(void);
void reset();
/// @brief Returns the render width in pixels.
/// @return Render width.
int get_width(void) const;
int get_width() const;
/// @brief Returns the render height in pixels.
/// @return Render height.
int get_height(void) const;
int get_height() const;
private:
/// @brief Width in pixels to render icon at.

View File

@@ -30,13 +30,13 @@ namespace ui
/// @brief Returns index of the currently selected tile.
/// @return Index of currently selected tile.
int get_selected(void) const;
int get_selected() const;
/// @brief Forces a refresh of the view.
void refresh(void);
void refresh();
/// @brief Resets the view to its default, empty state.
void reset(void);
void reset();
private:
/// @brief Pointer to user passed.