Revisions, SVI import fix.

This commit is contained in:
J-D-K
2025-08-16 18:58:32 -04:00
parent 6054a3a1f6
commit 1caec25d2a
105 changed files with 1112 additions and 902 deletions

View File

@@ -32,7 +32,8 @@ include $(DEVKITPRO)/libnx/switch_rules
#---------------------------------------------------------------------------------
TARGET := JKSV
BUILD := build
SOURCES := source source/appstates source/ui source/data source/sys source/fs source/curl source/remote source/tasks
SOURCES := source source/appstates source/config source/curl source/data source/fs \
source/logging source/remote source/sys source/tasks source/ui
DATA := data
INCLUDES := include ./Libraries/FsLib/Switch/FsLib/include ./Libraries/SDLLib/SDL/include
EXEFS_SRC := exefs_src

View File

@@ -33,4 +33,13 @@ namespace json
{
return json_object_object_add(json.get(), key.data(), object) == 0;
}
/// @brief Returns the json string.
static inline const char *get_string(json::Object &json) { return json_object_get_string(json.get()); }
/// @brief Returns the beginning for iterating.
static inline json_object_iterator iter_begin(json::Object &json) { return json_object_iter_begin(json.get()); }
/// @brief Returns the end for iterating.
static inline json_object_iterator iter_end(json::Object &json) { return json_object_iter_end(json.get()); }
} // namespace json

View File

@@ -1,13 +1,12 @@
#pragma once
#include "StateManager.hpp"
#include "appstates/BaseState.hpp"
#include "data/data.hpp"
#include "fslib.hpp"
#include "remote/remote.hpp"
#include "sdl.hpp"
#include "sys/sys.hpp"
#include "ui/Menu.hpp"
#include "ui/SlideOutPanel.hpp"
#include "ui/TextScroll.hpp"
#include "ui/ui.hpp"
#include <memory>
@@ -25,10 +24,18 @@ class BackupMenuState final : public BaseState
~BackupMenuState();
/// @brief Creates and returns a new BackupMenuState.
static std::shared_ptr<BackupMenuState> create(data::User *user, data::TitleInfo *titleInfo);
static inline std::shared_ptr<BackupMenuState> create(data::User *user, data::TitleInfo *titleInfo)
{
return std::make_shared<BackupMenuState>(user, titleInfo);
}
/// @brief Creates and pushes a new BackupMenuState to the vector.
static std::shared_ptr<BackupMenuState> create_and_push(data::User *user, data::TitleInfo *titleInfo);
static inline std::shared_ptr<BackupMenuState> create_and_push(data::User *user, data::TitleInfo *titleInfo)
{
auto newState = BackupMenuState::create(user, titleInfo);
StateManager::push_state(newState);
return newState;
}
/// @brief Required. Inherited virtual function from AppState.
void update() override;
@@ -89,7 +96,7 @@ class BackupMenuState final : public BaseState
remote::Storage::DirectoryListing m_remoteListing{};
/// @brief This is the scrolling text at the top.
ui::TextScroll m_titleScroll{};
std::shared_ptr<ui::TextScroll> m_titleScroll{};
/// @brief Variable that saves whether or not the filesystem has data in it.
bool m_saveHasData{};
@@ -110,7 +117,7 @@ class BackupMenuState final : public BaseState
static inline std::shared_ptr<ui::Menu> sm_backupMenu{};
/// @brief The slide out panel used by all instances of BackupMenuState.
static inline std::unique_ptr<ui::SlideOutPanel> sm_slidePanel{};
static inline std::shared_ptr<ui::SlideOutPanel> sm_slidePanel{};
/// @brief Inner render target so the menu only renders to a certain area.
static inline sdl::SharedTexture sm_menuRenderTarget{};

View File

@@ -1,4 +1,5 @@
#pragma once
#include "StateManager.hpp"
#include "appstates/BaseState.hpp"
#include "ui/ui.hpp"
@@ -15,10 +16,15 @@ class BlacklistEditState final : public BaseState
~BlacklistEditState();
/// @brief Creates and returns a new state.
static std::shared_ptr<BlacklistEditState> create();
static inline std::shared_ptr<BlacklistEditState> create() { return std::make_shared<BlacklistEditState>(); }
/// @brief Creates, pushes, then returns a new blacklist edit states.
static std::shared_ptr<BlacklistEditState> create_and_push();
static inline std::shared_ptr<BlacklistEditState> create_and_push()
{
auto newState = BlacklistEditState::create();
StateManager::push_state(newState);
return newState;
}
/// @brief Update override.
void update() override;

View File

@@ -4,11 +4,11 @@
#include "appstates/FadeState.hpp"
#include "appstates/ProgressState.hpp"
#include "appstates/TaskState.hpp"
#include "colors.hpp"
#include "graphics/colors.hpp"
#include "input.hpp"
#include "logger.hpp"
#include "logging/logger.hpp"
#include "sdl.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include "sys/sys.hpp"
#include "ui/ui.hpp"
@@ -42,7 +42,7 @@ class ConfirmState final : public BaseState
/// @param function Function executed on confirmation.
/// @param dataStruct shared_ptr<StructType> that is passed to function. I tried templating this and it was a nightmare.
ConfirmState(std::string_view query, bool holdRequired, TaskFunction function, std::shared_ptr<StructType> dataStruct)
: BaseState{false}
: BaseState(false)
, m_query(query)
, m_yesText(strings::get_by_name(strings::names::YES_NO_OK, 0))
, m_noText(strings::get_by_name(strings::names::YES_NO_OK, 1))
@@ -60,19 +60,19 @@ class ConfirmState final : public BaseState
~ConfirmState() {};
/// @brief Returns a new ConfirmState. See constructor.
static std::shared_ptr<ConfirmState> create(std::string_view query,
bool holdRequired,
TaskFunction function,
std::shared_ptr<StructType> dataStruct)
static inline std::shared_ptr<ConfirmState> create(std::string_view query,
bool holdRequired,
TaskFunction function,
std::shared_ptr<StructType> dataStruct)
{
return std::make_shared<ConfirmState>(query, holdRequired, function, dataStruct);
}
/// @brief Creates and returns a new ConfirmState and pushes it.
static std::shared_ptr<ConfirmState> create_and_push(std::string_view query,
bool holdRequired,
TaskFunction function,
std::shared_ptr<StructType> dataStruct)
static inline std::shared_ptr<ConfirmState> create_and_push(std::string_view query,
bool holdRequired,
TaskFunction function,
std::shared_ptr<StructType> dataStruct)
{
// I'm gonna use a sneaky trick here. This shouldn't do this because it's confusing.
auto newState = create(query, holdRequired, function, dataStruct);

View File

@@ -27,19 +27,19 @@ class DataLoadingState final : public BaseTask
}
template <typename... Args>
static std::shared_ptr<DataLoadingState> create(data::DataContext &context,
DestructFunction destructFunction,
void (*function)(sys::Task *, Args...),
Args... args)
static inline std::shared_ptr<DataLoadingState> create(data::DataContext &context,
DestructFunction destructFunction,
void (*function)(sys::Task *, Args...),
Args... args)
{
return std::make_shared<DataLoadingState>(context, destructFunction, function, std::forward<Args>(args)...);
}
template <typename... Args>
static std::shared_ptr<DataLoadingState> create_and_push(data::DataContext &context,
DestructFunction destructFunction,
void (*function)(sys::Task *, Args...),
Args... args)
static inline std::shared_ptr<DataLoadingState> create_and_push(data::DataContext &context,
DestructFunction destructFunction,
void (*function)(sys::Task *, Args...),
Args... args)
{
auto newState = DataLoadingState::create(context, destructFunction, function, std::forward<Args>(args)...);
StateManager::push_state(newState);

View File

@@ -14,7 +14,7 @@ class ExtrasMenuState final : public BaseState
~ExtrasMenuState() {};
/// @brief Returns a new ExtrasMenuState
static std::shared_ptr<ExtrasMenuState> create();
static inline std::shared_ptr<ExtrasMenuState> create() { return std::make_shared<ExtrasMenuState>(); }
/// @brief Updates the menu.
void update() override;

View File

@@ -1,4 +1,5 @@
#pragma once
#include "StateManager.hpp"
#include "appstates/BaseState.hpp"
#include "sdl.hpp"
#include "sys/sys.hpp"
@@ -19,19 +20,28 @@ class FadeState final : public BaseState
/// @param nextState The next state to push after the the fade is finished.
FadeState(sdl::Color baseColor, uint8_t startAlpha, uint8_t endAlpha, std::shared_ptr<BaseState> nextState);
/// @brief Required destructor.
~FadeState() {};
/// @brief Returns a new fade in state. See constructor.
static std::shared_ptr<FadeState> create(sdl::Color baseColor,
uint8_t startAlpha,
uint8_t endAlpha,
std::shared_ptr<BaseState> nextState);
static inline std::shared_ptr<FadeState> create(sdl::Color baseColor,
uint8_t startAlpha,
uint8_t endAlpha,
std::shared_ptr<BaseState> nextState)
{
return std::make_shared<FadeState>(baseColor, startAlpha, endAlpha, nextState);
}
/// @brief Creates, returns and pushes a new FadeInState to the statemanager.
static std::shared_ptr<FadeState> create_and_push(sdl::Color baseColor,
uint8_t startAlpha,
uint8_t endAlpha,
std::shared_ptr<BaseState> nextState);
std::shared_ptr<BaseState> nextState)
{
auto newState = FadeState::create(baseColor, startAlpha, endAlpha, nextState);
StateManager::push_state(newState);
return newState;
}
/// @brief Update override.
void update() override;
@@ -48,8 +58,10 @@ class FadeState final : public BaseState
/// @brief Alpha value to destruct at.
uint8_t m_endAlpha{};
/// @brief Direction (in/out) of the fade. This is auto determined according to alpha values passed.
FadeState::Direction m_direction{};
/// @brief The divisor found to make sure alpha ends evenly.
uint8_t m_divisor{};
/// @brief Timer for fade.
@@ -58,8 +70,15 @@ class FadeState final : public BaseState
/// @brief Pointer to the next state to push.
std::shared_ptr<BaseState> m_nextState{};
/// @brief Finds the highest divisor for the fade to use.
void find_divisor();
/// @brief Decreases alpha by m_divisor.
void decrease_alpha();
/// @brief Increases alpha by m_divisor.
void increase_alpha();
/// @brief Completes the fade.
void completed();
};

View File

@@ -1,4 +1,5 @@
#pragma once
#include "StateManager.hpp"
#include "appstates/BaseState.hpp"
#include "data/data.hpp"
#include "sdl.hpp"
@@ -17,10 +18,15 @@ class MainMenuState final : public BaseState
~MainMenuState() {};
/// @brief Returns a new MainMenuState
static std::shared_ptr<MainMenuState> create();
static inline std::shared_ptr<MainMenuState> create() { return std::make_shared<MainMenuState>(); }
/// @brief Creates and returns a new MainMenuState. Pushes it automatically.
static std::shared_ptr<MainMenuState> create_and_push();
static inline std::shared_ptr<MainMenuState> create_and_push()
{
auto newState = MainMenuState::create();
StateManager::push_state(newState);
return newState;
}
/// @brief Runs update routine.
void update() override;
@@ -57,7 +63,7 @@ class MainMenuState final : public BaseState
sdl::SharedTexture m_extrasIcon{};
/// @brief Special menu type that uses icons.
ui::IconMenu m_mainMenu;
std::shared_ptr<ui::IconMenu> m_mainMenu{};
/// @brief Pointer to control guide string so I don't need to call string::getByName every loop.
const char *m_controlGuide{};

View File

@@ -1,5 +1,8 @@
#pragma once
#include "StateManager.hpp"
#include "appstates/BaseState.hpp"
#include "appstates/FadeState.hpp"
#include "graphics/colors.hpp"
#include "ui/DialogBox.hpp"
#include <memory>
@@ -16,13 +19,26 @@ class MessageState final : public BaseState
~MessageState();
/// @brief Creates and returns a new MessageState. See constructor.
static std::shared_ptr<MessageState> create(std::string_view message);
static inline std::shared_ptr<MessageState> create(std::string_view message)
{
return std::make_shared<MessageState>(message);
}
/// @brief Same as above, only pushed to the StateManager before return.
static std::shared_ptr<MessageState> create_and_push(std::string_view message);
static inline std::shared_ptr<MessageState> create_and_push(std::string_view message)
{
auto newState = MessageState::create(message);
StateManager::push_state(newState);
return newState;
}
/// @brief Same as above, but creates and pushes a transition fade in between.
static std::shared_ptr<MessageState> create_and_push_fade(std::string_view message);
static inline std::shared_ptr<MessageState> create_and_push_fade(std::string_view message)
{
auto newState = MessageState::create(message);
auto fadeState = FadeState::create_and_push(colors::DIM_BACKGROUND, 0x00, 0x88, newState);
return newState;
}
/// @brief Update override.
void update() override;

View File

@@ -28,14 +28,17 @@ class ProgressState final : public BaseTask
/// @brief Required destructor.
~ProgressState();
/// @brief Creates and returns a new progress state.
template <typename... Args>
static std::shared_ptr<ProgressState> create(void (*function)(sys::ProgressTask *, Args...), Args... args)
static inline std::shared_ptr<ProgressState> create(void (*function)(sys::ProgressTask *, Args...), Args... args)
{
return std::make_shared<ProgressState>(function, std::forward<Args>(args)...);
}
/// @brief Creates, pushes, then returns a new ProgressState.
template <typename... Args>
static std::shared_ptr<ProgressState> create_and_push(void (*function)(sys::ProgressTask *, Args...), Args... args)
static inline std::shared_ptr<ProgressState> create_and_push(void (*function)(sys::ProgressTask *, Args...),
Args... args)
{
auto newState = ProgressState::create(function, std::forward<Args>(args)...);
StateManager::push_state(newState);

View File

@@ -1,9 +1,9 @@
#pragma once
#include "StateManager.hpp"
#include "appstates/BaseState.hpp"
#include "appstates/TitleSelectCommon.hpp"
#include "data/data.hpp"
#include "ui/Menu.hpp"
#include "ui/SlideOutPanel.hpp"
#include "ui/ui.hpp"
#include <atomic>
#include <memory>
@@ -21,10 +21,18 @@ class SaveCreateState final : public BaseState
~SaveCreateState();
/// @brief Returns a new SaveCreate state. See constructor for arguments.
static std::shared_ptr<SaveCreateState> create(data::User *user, TitleSelectCommon *titleSelect);
static inline std::shared_ptr<SaveCreateState> create(data::User *user, TitleSelectCommon *titleSelect)
{
return std::make_shared<SaveCreateState>(user, titleSelect);
}
/// @brief Creates, pushes, returns and new SaveCreateState.
static std::shared_ptr<SaveCreateState> create_and_push(data::User *user, TitleSelectCommon *titleSelect);
static inline std::shared_ptr<SaveCreateState> create_and_push(data::User *user, TitleSelectCommon *titleSelect)
{
auto newState = SaveCreateState::create(user, titleSelect);
StateManager::push_state(newState);
return newState;
}
/// @brief Runs the update routine.
void update() override;

View File

@@ -14,7 +14,7 @@ class SettingsState final : public BaseState
~SettingsState() {};
/// @brief Returns a new SettingsState.
std::shared_ptr<SettingsState> create();
static inline std::shared_ptr<SettingsState> create() { return std::make_shared<SettingsState>(); }
/// @brief Runs the update routine.
void update() override;
@@ -24,7 +24,7 @@ class SettingsState final : public BaseState
private:
/// @brief Menu for selecting and toggling settings.
ui::Menu m_settingsMenu;
std::shared_ptr<ui::Menu> m_settingsMenu{};
/// @brief Pointer to the control guide string.
const char *m_controlGuide{};

View File

@@ -23,14 +23,16 @@ class TaskState final : public BaseTask
/// @brief Required destructor.
~TaskState();
/// @brief Creates and returns a new TaskState.
template <typename... Args>
static std::shared_ptr<TaskState> create(void (*function)(sys::Task *, Args...), Args... args)
static inline std::shared_ptr<TaskState> create(void (*function)(sys::Task *, Args...), Args... args)
{
return std::make_shared<TaskState>(function, std::forward<Args>(args)...);
}
/// @brief Creates, pushes, then returns and new TaskState.
template <typename... Args>
static std::shared_ptr<TaskState> create_and_push(void (*function)(sys::Task *, Args...), Args... args)
static inline std::shared_ptr<TaskState> create_and_push(void (*function)(sys::Task *, Args...), Args... args)
{
auto newState = TaskState::create(function, std::forward<Args>(args)...);
StateManager::push_state(newState);

View File

@@ -1,4 +1,5 @@
#pragma once
#include "StateManager.hpp"
#include "appstates/TitleSelectCommon.hpp"
#include "data/data.hpp"
#include "sdl.hpp"
@@ -16,10 +17,18 @@ class TextTitleSelectState final : public TitleSelectCommon
~TextTitleSelectState() {};
/// @brief Creates and returns a new TextTitleSelect. See constructor.
static std::shared_ptr<TextTitleSelectState> create(data::User *user);
static inline std::shared_ptr<TextTitleSelectState> create(data::User *user)
{
return std::make_shared<TextTitleSelectState>(user);
}
/// @brief Creates, pushes, and returns a new TextTitleSelect.
static std::shared_ptr<TextTitleSelectState> create_and_push(data::User *user);
static std::shared_ptr<TextTitleSelectState> create_and_push(data::User *user)
{
auto newState = TextTitleSelectState::create(user);
StateManager::push_state(newState);
return newState;
}
/// @brief Runs update routine.
void update() override;
@@ -35,7 +44,7 @@ class TextTitleSelectState final : public TitleSelectCommon
data::User *m_user{};
/// @brief Menu to display titles to select from.
ui::Menu m_titleSelectMenu;
std::shared_ptr<ui::Menu> m_titleSelectMenu{};
/// @brief Target to render to.
sdl::SharedTexture m_renderTarget{};

View File

@@ -1,9 +1,9 @@
#pragma once
#include "StateManager.hpp"
#include "appstates/BaseState.hpp"
#include "data/data.hpp"
#include "sys/sys.hpp"
#include "ui/SlideOutPanel.hpp"
#include "ui/TextScroll.hpp"
#include "ui/ui.hpp"
#include <memory>
#include <string>
@@ -21,10 +21,18 @@ class TitleInfoState final : public BaseState
~TitleInfoState();
/// @brief Creates a new TitleInfoState.
static std::shared_ptr<TitleInfoState> create(data::User *user, data::TitleInfo *titleInfo);
static inline std::shared_ptr<TitleInfoState> create(data::User *user, data::TitleInfo *titleInfo)
{
return std::make_shared<TitleInfoState>(user, titleInfo);
}
/// @brief Creates, pushes, and returns a new TitleInfoState.
static std::shared_ptr<TitleInfoState> create_and_push(data::User *user, data::TitleInfo *titleInfo);
static inline std::shared_ptr<TitleInfoState> create_and_push(data::User *user, data::TitleInfo *titleInfo)
{
auto newState = TitleInfoState::create(user, titleInfo);
StateManager::push_state(newState);
return newState;
}
/// @brief Runs update routine.
void update() override;

View File

@@ -1,9 +1,9 @@
#pragma once
#include "StateManager.hpp"
#include "appstates/BaseState.hpp"
#include "appstates/TitleSelectCommon.hpp"
#include "data/data.hpp"
#include "ui/Menu.hpp"
#include "ui/SlideOutPanel.hpp"
#include "ui/ui.hpp"
#include <memory>
@@ -19,14 +19,22 @@ class TitleOptionState final : public BaseState
~TitleOptionState();
/// @brief Returns a new TitleOptionState. See constructor.
static std::shared_ptr<TitleOptionState> create(data::User *user,
data::TitleInfo *titleInfo,
TitleSelectCommon *titleSelect);
static inline std::shared_ptr<TitleOptionState> create(data::User *user,
data::TitleInfo *titleInfo,
TitleSelectCommon *titleSelect)
{
return std::make_shared<TitleOptionState>(user, titleInfo, titleSelect);
}
/// @brief Creates, pushes, and returns a new TitleOptionState
static std::shared_ptr<TitleOptionState> create_and_push(data::User *user,
data::TitleInfo *titleInfo,
TitleSelectCommon *titleSelect);
TitleSelectCommon *titleSelect)
{
auto newState = TitleOptionState::create(user, titleInfo, titleSelect);
StateManager::push_state(newState);
return newState;
}
/// @brief Runs update routine.
void update() override;

View File

@@ -1,4 +1,5 @@
#pragma once
#include "StateManager.hpp"
#include "appstates/TitleSelectCommon.hpp"
#include "data/data.hpp"
#include "sdl.hpp"
@@ -16,10 +17,18 @@ class TitleSelectState final : public TitleSelectCommon
~TitleSelectState() {};
/// @brief Returns a new TitleSelect state.
static std::shared_ptr<TitleSelectState> create(data::User *user);
static inline std::shared_ptr<TitleSelectState> create(data::User *user)
{
return std::make_shared<TitleSelectState>(user);
}
/// @brief Creates, pushes, and returns a new TitleSelectState.
static std::shared_ptr<TitleSelectState> create_and_push(data::User *user);
static inline std::shared_ptr<TitleSelectState> create_and_push(data::User *user)
{
auto newState = TitleSelectState::create(user);
StateManager::push_state(newState);
return newState;
}
/// @brief Runs the update routine.
void update() override;
@@ -38,7 +47,7 @@ class TitleSelectState final : public TitleSelectCommon
sdl::SharedTexture m_renderTarget{};
/// @brief Tiled title selection view.
ui::TitleView m_titleView;
std::shared_ptr<ui::TitleView> m_titleView{};
/// @brief Checks if the user still has any games left to list. This is a safety measure.
bool title_count_check();

View File

@@ -1,9 +1,9 @@
#pragma once
#include "StateManager.hpp"
#include "appstates/BaseState.hpp"
#include "appstates/TitleSelectCommon.hpp"
#include "data/data.hpp"
#include "ui/Menu.hpp"
#include "ui/SlideOutPanel.hpp"
#include "ui/ui.hpp"
#include <memory>
@@ -17,13 +17,21 @@ class UserOptionState final : public BaseState
UserOptionState(data::User *user, TitleSelectCommon *titleSelect);
/// @brief Required destructor.
~UserOptionState() {};
~UserOptionState();
/// @brief Returns a new UserOptionState. See constructor.
static std::shared_ptr<UserOptionState> create(data::User *user, TitleSelectCommon *titleSelect);
static inline std::shared_ptr<UserOptionState> create(data::User *user, TitleSelectCommon *titleSelect)
{
return std::make_shared<UserOptionState>(user, titleSelect);
}
/// @brief Creates, pushes, and returns a new UserOptionState.
static std::shared_ptr<UserOptionState> create_and_push(data::User *user, TitleSelectCommon *titleSelect);
static inline std::shared_ptr<UserOptionState> create_and_push(data::User *user, TitleSelectCommon *titleSelect)
{
auto newState = UserOptionState::create(user, titleSelect);
StateManager::push_state(newState);
return newState;
}
/// @brief Runs the render routine.
void update() override;
@@ -53,7 +61,7 @@ class UserOptionState final : public BaseState
TitleSelectCommon *m_titleSelect{};
/// @brief Menu that displays the options available.
ui::Menu m_userOptionMenu;
std::shared_ptr<ui::Menu> m_userOptionMenu{};
/// @brief Shared pointer to pass data to tasks and functions.
std::shared_ptr<UserOptionState::DataStruct> m_dataStruct{};
@@ -62,7 +70,7 @@ class UserOptionState final : public BaseState
bool m_refreshRequired{};
/// @brief Slide panel all instances shared.
static inline std::unique_ptr<ui::SlideOutPanel> sm_menuPanel{};
static inline std::shared_ptr<ui::SlideOutPanel> sm_menuPanel{};
/// @brief Creates the panel if it hasn't been yet.
void create_menu_panel();

View File

@@ -0,0 +1,111 @@
#pragma once
#include "fslib.hpp"
#include <json-c/json.h>
#include <map>
#include <vector>
namespace config
{
class ConfigContext
{
public:
using AppIDList = std::vector<uint64_t>;
ConfigContext() = default;
/// @brief Resets the config to its default state.
void reset();
/// @brief Saves the config to the file.
void save();
/// @brief Loads the config from SD.
void load();
/// @brief Retrieves the value of the key passed.
uint8_t get_by_key(std::string_view key);
/// @brief Toggles a basic setting by the key passed.
void toggle_by_key(std::string_view key);
/// @brief Sets the value of a key.
void set_by_key(std::string_view key, uint8_t value);
/// @brief Returns the current working directory for JKSV.
fslib::Path get_working_directory() const;
/// @brief Sets the current working directory for JKSV.
bool set_working_directory(std::string_view workDir);
/// @brief Returns the current UI transition scaling.
double get_animation_scaling() const;
/// @brief Sets the current UI transistion scaling.
void set_animation_scaling(double scaling);
/// @brief Adds a favorite to the list if it hasn't been already.
void add_favorite(uint64_t applicationID);
/// @brief Removes a favorite from the lift it it's there.
void remove_favorite(uint64_t applicationID);
/// @brief Returns whether or not the application ID passed is a favorite title.
bool is_favorite(uint64_t applicationID);
/// @brief Adds the application ID to the blacklist if it hasn't been already.
void add_to_blacklist(uint64_t applicationID);
/// @brief Removes the application ID passed from the blacklist.
void remove_from_blacklist(uint64_t applicationID);
/// @brief Gets an array of the currently blacklisted titles.
void get_blacklisted_titles(std::vector<uint64_t> &listOut);
/// @brief Returns whether or not the application ID passed is blacklisted.
bool is_blacklisted(uint64_t applicationID);
/// @brief Returns if the blacklist is empty.
bool blacklist_is_empty() const;
/// @brief Adds a custom output path.
void add_custom_path(uint64_t applicationID, std::string_view path);
/// @brief Returns whether or not the application ID has a custom output path.
bool has_custom_path(uint64_t applicationID);
/// @brief Gets the output path of the application ID passed.
void get_custom_path(uint64_t applicationID, char *pathBuffer, size_t bufferSize);
private:
/// @brief This is where most values are stored.
std::map<std::string, uint8_t> m_configMap{};
/// @brief This is the main directory JKSV uses.
fslib::Path m_workingDirectory{};
/// @brief The scaling of transitions.
double m_animationScaling{};
/// @brief Vector of favorites
ConfigContext::AppIDList m_favorites{};
/// @brief Vector of blacklisted title ids.
ConfigContext::AppIDList m_blacklist{};
/// @brief Map of custom output paths for titles.
std::map<uint64_t, std::string> m_pathMap;
/// @brief Reads an array from a json_object into the vector passed.
void read_array_to_vector(std::vector<uint64_t> &vector, json_object *array);
/// @brief Saves the custom paths set by the user.
void save_custom_paths();
/// @brief Searches for and returns an iterator to the application ID (if found);
ConfigContext::AppIDList::iterator find_favorite(uint64_t applicationID);
/// @brief Searches for and returns an iterator to the application ID (if found);
ConfigContext::AppIDList::iterator find_blacklist(uint64_t applicationID);
};
}

View File

@@ -1,4 +1,5 @@
#pragma once
#include "config/keys.hpp"
#include "fslib.hpp"
#include <string_view>
@@ -33,6 +34,9 @@ namespace config
/// @return Working directory.
fslib::Path get_working_directory();
/// @brief Sets JKSV's current working directory.
bool set_working_directory(std::string_view path);
/// @brief Returns the scaling speed of UI transitions and animations.
/// @return Scaling variable.
double get_animation_scaling();
@@ -81,31 +85,4 @@ namespace config
/// @param pathOut Buffer to write the path to.
/// @param pathOutSize Size of the buffer to write the path to.
void get_custom_path(uint64_t applicationID, char *pathOut, size_t pathOutSize);
// Names of keys. Note: Not all of these are retrievable with GetByKey. Some of these are purely for config reading and
// writing.
namespace keys
{
static constexpr std::string_view WORKING_DIRECTORY = "WorkingDirectory";
static constexpr std::string_view INCLUDE_DEVICE_SAVES = "IncludeDeviceSaves";
static constexpr std::string_view AUTO_BACKUP_ON_RESTORE = "AutoBackupOnRestore";
static constexpr std::string_view AUTO_NAME_BACKUPS = "AutoNameBackups";
static constexpr std::string_view AUTO_UPLOAD = "AutoUploadToRemote";
static constexpr std::string_view USE_TITLE_IDS = "AlwaysUseTitleID";
static constexpr std::string_view HOLD_FOR_DELETION = "HoldForDeletion";
static constexpr std::string_view HOLD_FOR_RESTORATION = "HoldForRestoration";
static constexpr std::string_view HOLD_FOR_OVERWRITE = "HoldForOverWrite";
static constexpr std::string_view ONLY_LIST_MOUNTABLE = "OnlyListMountable";
static constexpr std::string_view LIST_ACCOUNT_SYS_SAVES = "ListAccountSystemSaves";
static constexpr std::string_view ALLOW_WRITING_TO_SYSTEM = "AllowSystemSaveWriting";
static constexpr std::string_view EXPORT_TO_ZIP = "ExportToZip";
static constexpr std::string_view ZIP_COMPRESSION_LEVEL = "ZipCompressionLevel";
static constexpr std::string_view TITLE_SORT_TYPE = "TitleSortType";
static constexpr std::string_view JKSM_TEXT_MODE = "JKSMTextMode";
static constexpr std::string_view FORCE_ENGLISH = "ForceEnglish";
static constexpr std::string_view ENABLE_TRASH_BIN = "EnableTrash";
static constexpr std::string_view UI_ANIMATION_SCALE = "UIAnimationScaling";
static constexpr std::string_view FAVORITES = "Favorites";
static constexpr std::string_view BLACKLIST = "BlackList";
} // namespace keys
} // namespace config

30
include/config/keys.hpp Normal file
View File

@@ -0,0 +1,30 @@
#pragma once
#include <string_view>
namespace config
{
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 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
}

View File

@@ -11,13 +11,21 @@ namespace curl
// clang-format off
struct DownloadStruct
{
/// @brief Buffer mutex.
std::mutex lock{};
/// @brief Conditional for when the buffer is full.
std::condition_variable condition{};
/// @brief Shared buffer that is read into.
std::vector<sys::byte> sharedBuffer{};
/// @brief Bool to signal when the buffer is ready/empty.
bool bufferReady{};
/// @brief Destination file to write to.
fslib::File *dest{};
/// @brief Optional. Task to update with progress.
sys::ProgressTask *task{};
/// @brief Current offset in the file.
size_t offset{};
/// @brief Size of the file being downloaded.
int64_t fileSize{};
};
// clang-format on

View File

@@ -7,7 +7,9 @@ namespace curl
// clang-format off
struct UploadStruct
{
/// @brief Source file to upload from.
fslib::File *source{};
/// @brief Optional. Task to update with progress.
sys::ProgressTask *task{};
};
// clang-format on

View File

@@ -1,4 +1,6 @@
#pragma once
#include "fslib.hpp"
#include <string>
#include <vector>
@@ -7,12 +9,17 @@ namespace fs
class PathFilter
{
public:
PathFilter(std::string_view filterPath);
/// @brief Loads a path filter JSON file.
PathFilter(const fslib::Path &filterPath);
bool is_filtered(std::string_view path);
/// @brief Returns whether or not the filter has valid paths.
bool has_paths() const;
/// @brief Returns whether or not the path passed is filtered.
bool is_filtered(const fslib::Path &path);
private:
/// @brief Vector of paths to filter from deletion and backup.
std::vector<std::string> m_paths{};
};
}

View File

@@ -1,5 +1,6 @@
#pragma once
#include "sdl.hpp"
#include <string_view>
// This file contains basic graphics functions various parts of JKSV use.
@@ -7,12 +8,9 @@ namespace gfxutil
{
/// @brief Generates a generic icon for saves and titles that lack one.
/// @param text Text to be centered and rendered to the icon.
/// @param fontSize
/// @param fontSize Size of the font to use.
/// @param background Background color to use.
/// @param foreground Color to use to render the text.
/// @return sdl::SharedTexture of the icon.
sdl::SharedTexture create_generic_icon(std::string_view text,
int fontSize,
sdl::Color background,
sdl::Color foreground);
sdl::SharedTexture create_generic_icon(std::string_view text, int fontSize, sdl::Color background, sdl::Color foreground);
} // namespace gfxutil

View File

@@ -1,51 +0,0 @@
#pragma once
#include <string_view>
namespace strings
{
// Attempts to load strings from file in RomFS.
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);
// Names of strings to prevent typos.
namespace names
{
static constexpr std::string_view BACKUPMENU_MENU = "BackupMenu";
static constexpr std::string_view BACKUPMENU_CONFS = "BackupMenuConfirmations";
static constexpr std::string_view BACKUPMENU_POPS = "BackupMenuPops";
static constexpr std::string_view BACKUPMENU_STATUS = "BackupMenuStatus";
static constexpr std::string_view CONTROL_GUIDES = "ControlGuides";
static constexpr std::string_view DATA_LOADING_STATUS = "DataLoadingStatus";
static constexpr std::string_view EXTRASMENU_MENU = "ExtrasMenu";
static constexpr std::string_view EXTRASMENU_POPS = "ExtrasPops";
static constexpr std::string_view GENERAL_POPS = "GeneralPops";
static constexpr std::string_view GOOGLE_DRIVE = "GoogleDriveStrings";
static constexpr std::string_view HOLDING_STRINGS = "HoldingStrings";
static constexpr std::string_view IO_STATUSES = "IOStatuses";
static constexpr std::string_view IO_POPS = "IOPops";
static constexpr std::string_view KEYBOARD = "KeyboardStrings";
static constexpr std::string_view MAINMENU_CONFS = "MainMenuConfs";
static constexpr std::string_view MAINMENU_POPS = "MainMenuPops";
static constexpr std::string_view ON_OFF = "OnOff";
static constexpr std::string_view REMOTE_POPS = "RemotePops";
static constexpr std::string_view SAVECREATE_POPS = "SaveCreatePops";
static constexpr std::string_view SAVE_DATA_TYPES = "SaveDataTypes";
static constexpr std::string_view SETTINGS_DESCRIPTIONS = "SettingsDescriptions";
static constexpr std::string_view SETTINGS_MENU = "SettingsMenu";
static constexpr std::string_view SETTINGS_POPS = "SettingsPops";
static constexpr std::string_view SORT_TYPES = "SortTypes";
static constexpr std::string_view TITLEINFO = "TitleInfo";
static constexpr std::string_view TITLEOPTION_CONFS = "TitleOptionConfirmations";
static constexpr std::string_view TITLEOPTION_POPS = "TitleOptionPops";
static constexpr std::string_view TITLEOPTION_STATUS = "TitleOptionStatus";
static constexpr std::string_view TITLEOPTION = "TitleOptions";
static constexpr std::string_view TRANSLATION = "TranslationInfo";
static constexpr std::string_view USEROPTION_CONFS = "UserOptionConfirmations";
static constexpr std::string_view USEROPTION_STATUS = "UserOptionStatus";
static constexpr std::string_view USEROPTION_MENU = "UserOptions";
static constexpr std::string_view WEBDAV = "WebDavStrings";
static constexpr std::string_view YES_NO_OK = "YesNoOK";
} // namespace names
} // namespace strings

44
include/strings/names.hpp Normal file
View File

@@ -0,0 +1,44 @@
#pragma once
#include <string_view>
namespace strings
{
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";
}
}

View File

@@ -0,0 +1,13 @@
#pragma once
#include "strings/names.hpp"
#include <string_view>
namespace strings
{
// Attempts to load strings from file in RomFS.
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);
} // namespace strings

View File

@@ -21,7 +21,10 @@ namespace ui
~BoundingBox() {};
/// @brief Creates a returns a new BoundingBox. See constructor.
static std::shared_ptr<ui::BoundingBox> create(int x, int y, int width, int height);
static inline std::shared_ptr<ui::BoundingBox> create(int x, int y, int width, int height)
{
return std::make_shared<ui::BoundingBox>(x, y, width, height);
}
/// @brief Update override.
void update(bool hasFocus) override;

View File

@@ -26,11 +26,14 @@ namespace ui
~DialogBox() {};
/// @brief Creates and returns a new DialogBox instance. See constructor.
static std::shared_ptr<ui::DialogBox> create(int x,
int y,
int width,
int height,
DialogBox::Type type = DialogBox::Type::Dark);
static inline std::shared_ptr<ui::DialogBox> create(int x,
int y,
int width,
int height,
DialogBox::Type type = DialogBox::Type::Dark)
{
return std::make_shared<ui::DialogBox>(x, y, width, height, type);
}
/// @brief Update override. This does NOTHING!
void update(bool hasFocus) override {};

View File

@@ -21,7 +21,11 @@ namespace ui
/// @brief Required destructor.
~IconMenu() {};
std::shared_ptr<ui::IconMenu> create(int x, int y, int renderTargetHeight);
/// @brief Creates and returns a new IconMenu instance.
static inline std::shared_ptr<ui::IconMenu> create(int x, int y, int renderTargetHeight)
{
return std::make_shared<ui::IconMenu>(x, y, renderTargetHeight);
}
/// @brief Initializes the menu.
/// @param x X coordinate to render the menu to.

View File

@@ -26,7 +26,11 @@ namespace ui
/// @brief Required destructor.
~Menu() {};
static std::shared_ptr<ui::Menu> create(int x, int y, int width, int fontSize, int renderTargetHeight);
/// @brief Creates and returns a new ui::Menu instance.
static inline std::shared_ptr<ui::Menu> create(int x, int y, int width, int fontSize, int renderTargetHeight)
{
return std::make_shared<ui::Menu>(x, y, width, fontSize, renderTargetHeight);
}
/// @brief Runs the update routine.
/// @param hasFocus Whether or not the calling state has focus.

View File

@@ -25,7 +25,11 @@ namespace ui
/// @brief Required destructor.
~SlideOutPanel() {};
std::shared_ptr<ui::SlideOutPanel> create(int width, SlideOutPanel::Side side);
/// @brief Creates and returns and new ui::SlideOutPanel instance.
static inline std::shared_ptr<ui::SlideOutPanel> create(int width, SlideOutPanel::Side side)
{
return std::make_shared<ui::SlideOutPanel>(width, side);
}
/// @brief Runs the update routine.
/// @param hasFocus Whether or not the calling state has focus.

View File

@@ -36,15 +36,18 @@ namespace ui
~TextScroll() {};
/// @brief Creates and returns a new TextScroll. See constructor.
static std::shared_ptr<ui::TextScroll> create(std::string_view text,
int x,
int y,
int width,
int height,
int fontSize,
sdl::Color textColor,
sdl::Color clearColor,
bool center = true);
static inline std::shared_ptr<ui::TextScroll> create(std::string_view text,
int x,
int y,
int width,
int height,
int fontSize,
sdl::Color textColor,
sdl::Color clearColor,
bool center = true)
{
return std::make_shared<ui::TextScroll>(text, x, y, width, height, fontSize, textColor, clearColor, center);
}
/// @brief Creates/sets the text and parameters for TextScroll.
/// @param text Text to display/scroll.

View File

@@ -21,6 +21,11 @@ namespace ui
/// @brief Required destructor.
~TitleView() {};
static inline std::shared_ptr<ui::TitleView> create(data::User *user)
{
return std::make_shared<ui::TitleView>(user);
}
/// @brief Runs the update routine.
/// @param hasFocus Whether the calling state has focus.
void update(bool hasFocus) override;

View File

@@ -3,17 +3,17 @@
#include "StateManager.hpp"
#include "appstates/MainMenuState.hpp"
#include "appstates/TaskState.hpp"
#include "colors.hpp"
#include "config.hpp"
#include "config/config.hpp"
#include "curl/curl.hpp"
#include "data/data.hpp"
#include "error.hpp"
#include "fslib.hpp"
#include "graphics/colors.hpp"
#include "input.hpp"
#include "logger.hpp"
#include "logging/error.hpp"
#include "logging/logger.hpp"
#include "remote/remote.hpp"
#include "sdl.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
#include "ui/PopMessageManager.hpp"
@@ -159,7 +159,7 @@ bool JKSV::initialize_sdl()
{
bool sdlInit = sdl::initialize("JKSV", 1280, 720);
sdlInit = sdlInit && sdl::text::initialize();
m_headerIcon = sdl::TextureManager::create_load_texture("headerIcon", "romfs:/Textures/HeaderIcon.png");
m_headerIcon = sdl::TextureManager::load("headerIcon", "romfs:/Textures/HeaderIcon.png");
JKSV::add_color_chars();
return sdlInit && m_headerIcon;
}

View File

@@ -1,7 +1,5 @@
#include "StateManager.hpp"
#include "logger.hpp"
void StateManager::update()
{
// Grab the instance.

View File

@@ -4,15 +4,15 @@
#include "appstates/ConfirmState.hpp"
#include "appstates/FadeState.hpp"
#include "appstates/ProgressState.hpp"
#include "colors.hpp"
#include "config.hpp"
#include "error.hpp"
#include "config/config.hpp"
#include "fs/fs.hpp"
#include "fslib.hpp"
#include "graphics/colors.hpp"
#include "input.hpp"
#include "keyboard.hpp"
#include "logging/error.hpp"
#include "sdl.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
#include "sys/sys.hpp"
#include "tasks/backup.hpp"
@@ -55,18 +55,6 @@ BackupMenuState::~BackupMenuState()
if (remote) { remote->return_to_root(); }
}
std::shared_ptr<BackupMenuState> BackupMenuState::create(data::User *user, data::TitleInfo *titleInfo)
{
return std::make_shared<BackupMenuState>(user, titleInfo);
}
std::shared_ptr<BackupMenuState> BackupMenuState::create_and_push(data::User *user, data::TitleInfo *titleInfo)
{
auto newState = BackupMenuState::create(user, titleInfo);
StateManager::push_state(newState);
return newState;
}
void BackupMenuState::update()
{
const bool hasFocus = BaseState::has_focus();
@@ -98,7 +86,6 @@ void BackupMenuState::update()
else if (bPressed) { sm_slidePanel->close(); }
else if (sm_slidePanel->is_closed()) { BaseState::deactivate(); }
m_titleScroll.update(hasFocus);
sm_backupMenu->update(hasFocus);
}
@@ -108,7 +95,6 @@ void BackupMenuState::render()
sdl::SharedTexture &target = sm_slidePanel->get_target();
sm_slidePanel->clear_target();
m_titleScroll.render(target, hasFocus);
sdl::render_line(target, 10, 42, sm_panelWidth - 10, 42, colors::WHITE);
sdl::render_line(target, 10, 648, sm_panelWidth - 10, 648, colors::WHITE);
@@ -125,6 +111,7 @@ void BackupMenuState::refresh()
{
const bool autoUpload = config::get_by_key(config::keys::AUTO_UPLOAD);
remote::Storage *remote = remote::get_remote_storage();
m_directoryListing.open(m_directoryPath);
if (!autoUpload && !m_directoryListing.is_open()) { return; }
sm_backupMenu->reset();
@@ -166,11 +153,10 @@ void BackupMenuState::initialize_static_members()
{
if (sm_backupMenu && sm_slidePanel && sm_menuRenderTarget && sm_panelWidth) { return; }
sm_panelWidth = sdl::text::get_width(22, m_controlGuide) + 64;
sm_backupMenu = std::make_shared<ui::Menu>(8, 8, sm_panelWidth - 16, 24, 600);
sm_slidePanel = std::make_unique<ui::SlideOutPanel>(sm_panelWidth, ui::SlideOutPanel::Side::Right);
sm_menuRenderTarget =
sdl::TextureManager::create_load_texture("backupMenuTarget", sm_panelWidth, 600, SDL_TEXTUREACCESS_TARGET);
sm_panelWidth = sdl::text::get_width(22, m_controlGuide) + 64;
sm_backupMenu = ui::Menu::create(8, 8, sm_panelWidth - 16, 24, 600);
sm_slidePanel = ui::SlideOutPanel::create(sm_panelWidth, ui::SlideOutPanel::Side::Right);
sm_menuRenderTarget = sdl::TextureManager::load("backupMenuTarget", sm_panelWidth, 600, SDL_TEXTUREACCESS_TARGET);
}
void BackupMenuState::ensure_target_directory()
@@ -199,8 +185,9 @@ void BackupMenuState::initialize_info_string()
const char *nickname = m_user->get_nickname();
const char *title = m_titleInfo->get_title();
const std::string infoString = stringutil::get_formatted_string("`%s` - %s", nickname, title);
m_titleScroll = ui::TextScroll::create(infoString, 8, 8, sm_panelWidth - 16, 30, 22, colors::WHITE, colors::TRANSPARENT);
m_titleScroll.initialize(infoString, 8, 8, sm_panelWidth - 16, 30, 22, colors::WHITE, colors::TRANSPARENT);
sm_slidePanel->push_new_element(m_titleScroll);
}
void BackupMenuState::save_data_check()

View File

@@ -1,6 +1,6 @@
#include "appstates/BaseState.hpp"
#include "error.hpp"
#include "logging/error.hpp"
#include <switch.h>

View File

@@ -1,8 +1,8 @@
#include "appstates/BaseTask.hpp"
#include "colors.hpp"
#include "graphics/colors.hpp"
#include "input.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include "ui/PopMessageManager.hpp"
namespace

View File

@@ -2,10 +2,10 @@
#include "StateManager.hpp"
#include "appstates/MainMenuState.hpp"
#include "config.hpp"
#include "config/config.hpp"
#include "data/data.hpp"
#include "error.hpp"
#include "input.hpp"
#include "logging/error.hpp"
BlacklistEditState::BlacklistEditState()
: BaseState()
@@ -22,15 +22,6 @@ BlacklistEditState::~BlacklistEditState()
sm_slidePanel->reset();
}
std::shared_ptr<BlacklistEditState> BlacklistEditState::create() { return std::make_shared<BlacklistEditState>(); }
std::shared_ptr<BlacklistEditState> BlacklistEditState::create_and_push()
{
auto newState = std::make_shared<BlacklistEditState>();
StateManager::push_state(newState);
return newState;
}
void BlacklistEditState::update()
{
const bool hasFocus = BaseState::has_focus();

View File

@@ -1,7 +1,7 @@
#include "appstates/DataLoadingState.hpp"
#include "colors.hpp"
#include "logger.hpp"
#include "graphics/colors.hpp"
#include "logging/logger.hpp"
namespace
{
@@ -43,5 +43,5 @@ void DataLoadingState::initialize_static_members()
{
if (sm_jksvIcon) { return; }
sm_jksvIcon = sdl::TextureManager::create_load_texture("LoadingIcon", "romfs:/Textures/LoadingIcon.png");
sm_jksvIcon = sdl::TextureManager::load("LoadingIcon", "romfs:/Textures/LoadingIcon.png");
}

View File

@@ -1,11 +1,11 @@
#include "appstates/ExtrasMenuState.hpp"
#include "appstates/MainMenuState.hpp"
#include "colors.hpp"
#include "data/data.hpp"
#include "graphics/colors.hpp"
#include "input.hpp"
#include "keyboard.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include "ui/PopMessageManager.hpp"
#include <string_view>
@@ -33,13 +33,11 @@ static void finish_reinitialization();
ExtrasMenuState::ExtrasMenuState()
: m_extrasMenu(32, 8, 1000, 24, 555)
, m_renderTarget(sdl::TextureManager::create_load_texture(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_TARGET))
, m_renderTarget(sdl::TextureManager::load(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_TARGET))
{
ExtrasMenuState::initialize_menu();
}
std::shared_ptr<ExtrasMenuState> create() { return std::make_shared<ExtrasMenuState>(); }
void ExtrasMenuState::update()
{
const bool hasFocus = BaseState::has_focus();

View File

@@ -1,7 +1,7 @@
#include "appstates/FadeState.hpp"
#include "StateManager.hpp"
#include "logger.hpp"
#include "logging/logger.hpp"
#include "mathutil.hpp"
#include "sdl.hpp"
@@ -22,24 +22,6 @@ FadeState::FadeState(sdl::Color baseColor, uint8_t startAlpha, uint8_t endAlpha,
m_fadeTimer.start(TICKS_TIMER_TRIGGER);
}
std::shared_ptr<FadeState> FadeState::create(sdl::Color baseColor,
uint8_t startAlpha,
uint8_t endAlpha,
std::shared_ptr<BaseState> nextState)
{
return std::make_shared<FadeState>(baseColor, startAlpha, endAlpha, nextState);
}
std::shared_ptr<FadeState> FadeState::create_and_push(sdl::Color baseColor,
uint8_t startAlpha,
uint8_t endAlpha,
std::shared_ptr<BaseState> nextState)
{
auto newState = std::make_shared<FadeState>(baseColor, startAlpha, endAlpha, nextState);
StateManager::push_state(newState);
return newState;
}
void FadeState::update()
{
if (m_alpha == m_endAlpha)

View File

@@ -8,13 +8,13 @@
#include "appstates/TitleSelectCommon.hpp"
#include "appstates/TitleSelectState.hpp"
#include "appstates/UserOptionState.hpp"
#include "colors.hpp"
#include "config.hpp"
#include "config/config.hpp"
#include "graphics/colors.hpp"
#include "input.hpp"
#include "logger.hpp"
#include "logging/logger.hpp"
#include "remote/remote.hpp"
#include "sdl.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
#include "tasks/mainmenu.hpp"
#include "ui/PopMessageManager.hpp"
@@ -25,11 +25,11 @@ namespace
}
MainMenuState::MainMenuState()
: m_renderTarget(sdl::TextureManager::create_load_texture("mainMenuTarget", 200, 555, SDL_TEXTUREACCESS_TARGET))
, m_background(sdl::TextureManager::create_load_texture("mainBackground", "romfs:/Textures/MenuBackground.png"))
, m_settingsIcon(sdl::TextureManager::create_load_texture("settingsIcon", "romfs:/Textures/SettingsIcon.png"))
, m_extrasIcon(sdl::TextureManager::create_load_texture("extrasIcon", "romfs:/Textures/ExtrasIcon.png"))
, m_mainMenu(50, 15, 555)
: m_renderTarget(sdl::TextureManager::load("mainMenuTarget", 200, 555, SDL_TEXTUREACCESS_TARGET))
, m_background(sdl::TextureManager::load("mainBackground", "romfs:/Textures/MenuBackground.png"))
, m_settingsIcon(sdl::TextureManager::load("settingsIcon", "romfs:/Textures/SettingsIcon.png"))
, m_extrasIcon(sdl::TextureManager::load("extrasIcon", "romfs:/Textures/ExtrasIcon.png"))
, m_mainMenu(ui::IconMenu::create(50, 15, 555))
, m_controlGuide(strings::get_by_name(strings::names::CONTROL_GUIDES, 0))
, m_controlGuideX(1220 - sdl::text::get_width(22, m_controlGuide))
, m_dataStruct(std::make_shared<MainMenuState::DataStruct>())
@@ -40,18 +40,9 @@ MainMenuState::MainMenuState()
MainMenuState::initialize_data_struct();
}
std::shared_ptr<MainMenuState> MainMenuState::create() { return std::make_shared<MainMenuState>(); }
std::shared_ptr<MainMenuState> MainMenuState::create_and_push()
{
auto newState = MainMenuState::create();
StateManager::push_state(newState);
return newState;
}
void MainMenuState::update()
{
const int selected = m_mainMenu.get_selected();
const int selected = m_mainMenu->get_selected();
const bool hasFocus = BaseState::has_focus();
const bool aPressed = input::button_pressed(HidNpadButton_A);
const bool xPressed = input::button_pressed(HidNpadButton_X);
@@ -63,23 +54,23 @@ void MainMenuState::update()
else if (toUserOptions) { MainMenuState::create_user_options(); }
else if (yPressed) { MainMenuState::backup_all_for_all(); }
m_mainMenu.update(hasFocus);
m_mainMenu->update(hasFocus);
}
void MainMenuState::render()
{
const bool hasFocus = BaseState::has_focus();
const int selected = m_mainMenu.get_selected();
const int selected = m_mainMenu->get_selected();
m_background->render(m_renderTarget, 0, 0);
m_mainMenu.render(m_renderTarget, hasFocus);
m_mainMenu->render(m_renderTarget, hasFocus);
m_renderTarget->render(sdl::Texture::Null, 0, 91);
if (hasFocus)
{
BaseState *target = sm_states.at(selected).get();
target->render();
BaseState *target = sm_states[selected].get();
target->render();
sdl::text::render(sdl::Texture::Null, m_controlGuideX, 673, 22, sdl::text::NO_WRAP, colors::WHITE, m_controlGuide);
}
}
@@ -92,8 +83,10 @@ void MainMenuState::initialize_view_states()
for (data::User *user : sm_users)
{
std::shared_ptr<BaseState> state{};
if (jksmMode) { state = std::make_shared<TextTitleSelectState>(user); }
else { state = std::make_shared<TitleSelectState>(user); }
if (jksmMode) { state = TextTitleSelectState::create(user); }
else { state = TitleSelectState::create(user); }
sm_states.push_back(state);
}
sm_states.push_back(sm_settingsState);
@@ -113,8 +106,8 @@ void MainMenuState::initialize_settings_extras()
{
if (!sm_settingsState || !sm_extrasState)
{
sm_settingsState = std::make_shared<SettingsState>();
sm_extrasState = std::make_shared<ExtrasMenuState>();
sm_settingsState = SettingsState::create();
sm_extrasState = ExtrasMenuState::create();
}
}
@@ -122,9 +115,9 @@ void MainMenuState::initialize_menu()
{
data::get_users(sm_users);
sm_userCount = sm_users.size();
for (data::User *user : sm_users) { m_mainMenu.add_option(user->get_icon()); }
m_mainMenu.add_option(m_settingsIcon);
m_mainMenu.add_option(m_extrasIcon);
for (data::User *user : sm_users) { m_mainMenu->add_option(user->get_icon()); }
m_mainMenu->add_option(m_settingsIcon);
m_mainMenu->add_option(m_extrasIcon);
}
void MainMenuState::initialize_data_struct() { m_dataStruct->userList = sm_users; }
@@ -134,7 +127,7 @@ void MainMenuState::push_target_state()
const int popTicks = ui::PopMessageManager::DEFAULT_TICKS;
const char *popNoSaveFormat = strings::get_by_name(strings::names::MAINMENU_POPS, 0);
const int selected = m_mainMenu.get_selected();
const int selected = m_mainMenu->get_selected();
const int userCount = sm_users.size();
if (selected < userCount)
{
@@ -156,8 +149,8 @@ void MainMenuState::push_target_state()
void MainMenuState::create_user_options()
{
const int selected = m_mainMenu.get_selected();
data::User *user = sm_users.at(selected);
const int selected = m_mainMenu->get_selected();
data::User *user = sm_users[selected];
TitleSelectCommon *titleSelect = static_cast<TitleSelectCommon *>(sm_states[selected].get());
UserOptionState::create_and_push(user, titleSelect);

View File

@@ -2,9 +2,9 @@
#include "StateManager.hpp"
#include "appstates/FadeState.hpp"
#include "colors.hpp"
#include "graphics/colors.hpp"
#include "input.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
MessageState::MessageState(std::string_view message)
: m_message(message)
@@ -17,22 +17,6 @@ MessageState::~MessageState()
FadeState::create_and_push(colors::DIM_BACKGROUND, colors::ALPHA_FADE_END, colors::ALPHA_FADE_BEGIN, nullptr);
}
std::shared_ptr<MessageState> MessageState::create(std::string_view message) { return std::make_shared<MessageState>(message); }
std::shared_ptr<MessageState> MessageState::create_and_push(std::string_view message)
{
auto newState = MessageState::create(message);
StateManager::push_state(newState);
return newState;
}
std::shared_ptr<MessageState> MessageState::create_and_push_fade(std::string_view message)
{
auto newState = MessageState::create(message);
FadeState::create_and_push(colors::DIM_BACKGROUND, 0x00, 0x88, newState);
return newState;
}
void MessageState::update()
{
// To do: I only use this in one place right now. I'm not sure this guards correctly here?

View File

@@ -1,10 +1,10 @@
#include "appstates/ProgressState.hpp"
#include "appstates/FadeState.hpp"
#include "colors.hpp"
#include "graphics/colors.hpp"
#include "input.hpp"
#include "sdl.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
#include "ui/PopMessageManager.hpp"

View File

@@ -3,11 +3,11 @@
#include "StateManager.hpp"
#include "appstates/TaskState.hpp"
#include "data/data.hpp"
#include "error.hpp"
#include "fs/fs.hpp"
#include "input.hpp"
#include "logger.hpp"
#include "strings.hpp"
#include "logging/error.hpp"
#include "logging/logger.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
#include "sys/sys.hpp"
#include "tasks/savecreate.hpp"
@@ -37,18 +37,6 @@ SaveCreateState::~SaveCreateState()
sm_slidePanel->reset();
}
std::shared_ptr<SaveCreateState> SaveCreateState::create(data::User *user, TitleSelectCommon *titleSelect)
{
return std::make_shared<SaveCreateState>(user, titleSelect);
}
std::shared_ptr<SaveCreateState> SaveCreateState::create_and_push(data::User *user, TitleSelectCommon *titleSelect)
{
auto newState = SaveCreateState::create(user, titleSelect);
StateManager::push_state(newState);
return newState;
}
void SaveCreateState::update()
{
const bool hasFocus = BaseState::has_focus();

View File

@@ -3,14 +3,14 @@
#include "appstates/BlacklistEditState.hpp"
#include "appstates/MainMenuState.hpp"
#include "appstates/MessageState.hpp"
#include "colors.hpp"
#include "config.hpp"
#include "config/config.hpp"
#include "data/data.hpp"
#include "fslib.hpp"
#include "graphics/colors.hpp"
#include "input.hpp"
#include "keyboard.hpp"
#include "logger.hpp"
#include "strings.hpp"
#include "logging/logger.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
#include <array>
@@ -56,18 +56,16 @@ namespace
} // namespace
SettingsState::SettingsState()
: m_settingsMenu(32, 8, 1000, 24, 555)
: m_settingsMenu(ui::Menu::create(32, 8, 1000, 24, 555))
, m_controlGuide(strings::get_by_name(strings::names::CONTROL_GUIDES, 3))
, m_controlGuideX(1220 - sdl::text::get_width(22, m_controlGuide))
, m_renderTarget(sdl::TextureManager::create_load_texture(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_TARGET))
, m_renderTarget(sdl::TextureManager::load(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_TARGET))
{
SettingsState::load_settings_menu();
SettingsState::load_extra_strings();
SettingsState::update_menu_options();
}
std::shared_ptr<SettingsState> SettingsState::create() { return std::make_shared<SettingsState>(); }
void SettingsState::update()
{
const bool hasFocus = BaseState::has_focus();
@@ -75,7 +73,7 @@ void SettingsState::update()
const bool bPressed = input::button_pressed(HidNpadButton_B);
const bool minusPressed = input::button_pressed(HidNpadButton_Minus);
m_settingsMenu.update(hasFocus);
m_settingsMenu->update(hasFocus);
if (aPressed) { SettingsState::toggle_options(); }
else if (minusPressed) { SettingsState::create_push_description_message(); }
else if (bPressed) { BaseState::deactivate(); }
@@ -86,7 +84,7 @@ void SettingsState::render()
const bool hasFocus = BaseState::has_focus();
m_renderTarget->clear(colors::TRANSPARENT);
m_settingsMenu.render(m_renderTarget, hasFocus);
m_settingsMenu->render(m_renderTarget, hasFocus);
m_renderTarget->render(sdl::Texture::Null, 201, 91);
if (hasFocus)
@@ -99,7 +97,7 @@ void SettingsState::load_settings_menu()
{
for (int i = 0; const char *option = strings::get_by_name(strings::names::SETTINGS_MENU, i); i++)
{
m_settingsMenu.add_option(option);
m_settingsMenu->add_option(option);
}
}
@@ -120,14 +118,14 @@ void SettingsState::update_menu_options()
const uint8_t value = config::get_by_key(CONFIG_KEY_ARRAY[i]);
const char *status = SettingsState::get_status_text(value);
const std::string option = stringutil::get_formatted_string(optionTemplate, status);
m_settingsMenu.edit_option(i, option);
m_settingsMenu->edit_option(i, option);
}
{
const char *zipCompTemplate = strings::get_by_name(strings::names::SETTINGS_MENU, 14);
const uint8_t zipLevel = config::get_by_key(CONFIG_KEY_ARRAY[14]);
const std::string zipOption = stringutil::get_formatted_string(zipCompTemplate, zipLevel);
m_settingsMenu.edit_option(14, zipOption);
m_settingsMenu->edit_option(14, zipOption);
}
{
@@ -135,14 +133,14 @@ void SettingsState::update_menu_options()
const uint8_t sortType = config::get_by_key(CONFIG_KEY_ARRAY[15]);
const char *typeText = SettingsState::get_sort_type_text(sortType);
const std::string sortTypeOption = stringutil::get_formatted_string(titleSortTemplate, typeText);
m_settingsMenu.edit_option(15, sortTypeOption);
m_settingsMenu->edit_option(15, sortTypeOption);
}
{
const char *scalingTemplate = strings::get_by_name(strings::names::SETTINGS_MENU, 19);
const double scaling = config::get_animation_scaling();
const std::string scalingOption = stringutil::get_formatted_string(scalingTemplate, scaling);
m_settingsMenu.edit_option(19, scalingOption);
m_settingsMenu->edit_option(19, scalingOption);
}
}
@@ -164,7 +162,7 @@ void SettingsState::create_push_blacklist_edit()
void SettingsState::toggle_options()
{
const int selected = m_settingsMenu.get_selected();
const int selected = m_settingsMenu->get_selected();
switch (selected)
{
case CHANGE_WORK_DIR: SettingsState::change_working_directory(); break;
@@ -181,7 +179,7 @@ void SettingsState::toggle_options()
void SettingsState::create_push_description_message()
{
const int selected = m_settingsMenu.get_selected();
const int selected = m_settingsMenu->get_selected();
const char *description = strings::get_by_name(strings::names::SETTINGS_DESCRIPTIONS, selected);
MessageState::create_and_push_fade(description);

View File

@@ -1,10 +1,10 @@
#include "appstates/TaskState.hpp"
#include "appstates/FadeState.hpp"
#include "colors.hpp"
#include "graphics/colors.hpp"
#include "input.hpp"
#include "sdl.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include "ui/PopMessageManager.hpp"
TaskState::~TaskState() { FadeState::create_and_push(colors::DIM_BACKGROUND, 0x88, 0x00, nullptr); }

View File

@@ -4,12 +4,12 @@
#include "appstates/BackupMenuState.hpp"
#include "appstates/MainMenuState.hpp"
#include "appstates/TitleOptionState.hpp"
#include "colors.hpp"
#include "config.hpp"
#include "config/config.hpp"
#include "fs/save_mount.hpp"
#include "fslib.hpp"
#include "graphics/colors.hpp"
#include "input.hpp"
#include "logger.hpp"
#include "logging/logger.hpp"
#include "sdl.hpp"
#include <string_view>
@@ -23,24 +23,12 @@ namespace
TextTitleSelectState::TextTitleSelectState(data::User *user)
: TitleSelectCommon()
, m_user(user)
, m_titleSelectMenu(32, 8, 1000, 20, 555)
, m_renderTarget(sdl::TextureManager::create_load_texture(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_TARGET))
, m_titleSelectMenu(ui::Menu::create(32, 8, 1000, 20, 555))
, m_renderTarget(sdl::TextureManager::load(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_TARGET))
{
TextTitleSelectState::refresh();
}
std::shared_ptr<TextTitleSelectState> TextTitleSelectState::create(data::User *user)
{
return std::make_shared<TextTitleSelectState>(user);
}
std::shared_ptr<TextTitleSelectState> TextTitleSelectState::create_and_push(data::User *user)
{
auto newState = TextTitleSelectState::create(user);
StateManager::push_state(newState);
return newState;
}
void TextTitleSelectState::update()
{
const bool hasFocus = BaseState::has_focus();
@@ -49,7 +37,7 @@ void TextTitleSelectState::update()
const bool xPressed = input::button_pressed(HidNpadButton_X);
const bool yPressed = input::button_pressed(HidNpadButton_Y);
m_titleSelectMenu.update(hasFocus);
m_titleSelectMenu->update(hasFocus);
if (aPressed) { TextTitleSelectState::create_backup_menu(); }
else if (xPressed) { TextTitleSelectState::create_title_option_menu(); }
@@ -60,7 +48,7 @@ void TextTitleSelectState::update()
void TextTitleSelectState::render()
{
m_renderTarget->clear(colors::TRANSPARENT);
m_titleSelectMenu.render(m_renderTarget, BaseState::has_focus());
m_titleSelectMenu->render(m_renderTarget, BaseState::has_focus());
TitleSelectCommon::render_control_guide();
m_renderTarget->render(sdl::Texture::Null, 201, 91);
}
@@ -69,7 +57,7 @@ void TextTitleSelectState::refresh()
{
static constexpr const char *STRING_HEART = "^\uE017^ ";
m_titleSelectMenu.reset();
m_titleSelectMenu->reset();
const size_t totalEntries = m_user->get_total_data_entries();
for (size_t i = 0; i < totalEntries; i++)
@@ -82,13 +70,14 @@ void TextTitleSelectState::refresh()
std::string option{};
if (favorite) { option = std::string{STRING_HEART} + title; }
else { option = title; }
m_titleSelectMenu.add_option(option);
m_titleSelectMenu->add_option(option);
}
}
void TextTitleSelectState::create_backup_menu()
{
const int selected = m_titleSelectMenu.get_selected();
const int selected = m_titleSelectMenu->get_selected();
const uint64_t applicationID = m_user->get_application_id_at(selected);
data::TitleInfo *titleInfo = data::get_title_info_by_id(applicationID);
@@ -98,7 +87,7 @@ void TextTitleSelectState::create_backup_menu()
void TextTitleSelectState::create_title_option_menu()
{
const int selected = m_titleSelectMenu.get_selected();
const int selected = m_titleSelectMenu->get_selected();
const uint64_t applicationID = m_user->get_application_id_at(selected);
data::TitleInfo *titleInfo = data::get_title_info_by_id(applicationID);
@@ -108,7 +97,7 @@ void TextTitleSelectState::create_title_option_menu()
void TextTitleSelectState::add_remove_favorite()
{
const int selected = m_titleSelectMenu.get_selected();
const int selected = m_titleSelectMenu->get_selected();
const uint64_t applicationID = m_user->get_application_id_at(selected);
config::add_remove_favorite(applicationID);
@@ -125,7 +114,7 @@ void TextTitleSelectState::add_remove_favorite()
const uint64_t appIDAt = m_user->get_application_id_at(i);
if (appIDAt == applicationID) { break; }
}
m_titleSelectMenu.set_selected(i);
m_titleSelectMenu->set_selected(i);
MainMenuState::refresh_view_states();
}

View File

@@ -1,11 +1,11 @@
#include "appstates/TitleInfoState.hpp"
#include "StateManager.hpp"
#include "colors.hpp"
#include "error.hpp"
#include "graphics/colors.hpp"
#include "input.hpp"
#include "logging/error.hpp"
#include "sdl.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
#include <ctime>
@@ -40,18 +40,6 @@ TitleInfoState::~TitleInfoState()
sm_slidePanel->clear_elements();
}
std::shared_ptr<TitleInfoState> TitleInfoState::create(data::User *user, data::TitleInfo *titleInfo)
{
return std::make_shared<TitleInfoState>(user, titleInfo);
}
std::shared_ptr<TitleInfoState> TitleInfoState::create_and_push(data::User *user, data::TitleInfo *titleInfo)
{
auto newState = TitleInfoState::create(user, titleInfo);
StateManager::push_state(newState);
return newState;
}
void TitleInfoState::update()
{
// Grab this instead of calling the function over and over.
@@ -154,15 +142,15 @@ void TitleInfoState::create_info_scrolls()
std::shared_ptr<ui::TextScroll> TitleInfoState::create_new_scroll(std::string_view text, int y)
{
static constexpr int SIZE_FIELD_WIDTH = SIZE_PANEL_WIDTH - SIZE_PANEL_SUB;
auto textFieldScroll = std::make_shared<ui::TextScroll>(text,
8,
y,
SIZE_FIELD_WIDTH,
SIZE_TEXT_TARGET_HEIGHT,
SIZE_FONT,
colors::WHITE,
m_fieldClear ? colors::CLEAR_COLOR : colors::DIALOG_DARK,
false);
auto textFieldScroll = ui::TextScroll::create(text,
8,
y,
SIZE_FIELD_WIDTH,
SIZE_TEXT_TARGET_HEIGHT,
SIZE_FONT,
colors::WHITE,
m_fieldClear ? colors::CLEAR_COLOR : colors::DIALOG_DARK,
false);
m_fieldClear = m_fieldClear ? false : true;
return textFieldScroll;
}

View File

@@ -4,16 +4,16 @@
#include "appstates/ConfirmState.hpp"
#include "appstates/MainMenuState.hpp"
#include "appstates/TitleInfoState.hpp"
#include "colors.hpp"
#include "config.hpp"
#include "error.hpp"
#include "config/config.hpp"
#include "fs/fs.hpp"
#include "fslib.hpp"
#include "graphics/colors.hpp"
#include "input.hpp"
#include "keyboard.hpp"
#include "logger.hpp"
#include "logging/error.hpp"
#include "logging/logger.hpp"
#include "remote/remote.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
#include "sys/sys.hpp"
#include "tasks/titleoptions.hpp"
@@ -58,22 +58,6 @@ TitleOptionState::~TitleOptionState()
sm_titleOptionMenu->set_selected(0);
}
std::shared_ptr<TitleOptionState> TitleOptionState::create(data::User *user,
data::TitleInfo *titleInfo,
TitleSelectCommon *titleSelect)
{
return std::make_shared<TitleOptionState>(user, titleInfo, titleSelect);
}
std::shared_ptr<TitleOptionState> TitleOptionState::create_and_push(data::User *user,
data::TitleInfo *titleInfo,
TitleSelectCommon *titleSelect)
{
auto newState = TitleOptionState::create(user, titleInfo, titleSelect);
StateManager::push_state(newState);
return newState;
}
void TitleOptionState::update()
{
const bool hasFocus = BaseState::has_focus();

View File

@@ -1,8 +1,8 @@
#include "appstates/TitleSelectCommon.hpp"
#include "colors.hpp"
#include "graphics/colors.hpp"
#include "sdl.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
TitleSelectCommon::TitleSelectCommon()
{

View File

@@ -4,14 +4,12 @@
#include "appstates/BackupMenuState.hpp"
#include "appstates/MainMenuState.hpp"
#include "appstates/TitleOptionState.hpp"
#include "colors.hpp"
#include "config.hpp"
#include "fs/fs.hpp"
#include "fslib.hpp"
#include "config/config.hpp"
#include "graphics/colors.hpp"
#include "input.hpp"
#include "logger.hpp"
#include "logging/logger.hpp"
#include "sdl.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include <string_view>
@@ -24,20 +22,8 @@ namespace
TitleSelectState::TitleSelectState(data::User *user)
: TitleSelectCommon()
, m_user(user)
, m_renderTarget(sdl::TextureManager::create_load_texture(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_TARGET))
, m_titleView(m_user) {};
std::shared_ptr<TitleSelectState> TitleSelectState::create(data::User *user)
{
return std::make_shared<TitleSelectState>(user);
}
std::shared_ptr<TitleSelectState> TitleSelectState::create_and_push(data::User *user)
{
auto newState = TitleSelectState::create(user);
StateManager::push_state(newState);
return newState;
}
, m_renderTarget(sdl::TextureManager::load(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_TARGET))
, m_titleView(ui::TitleView::create(m_user)) {};
void TitleSelectState::update()
{
@@ -54,7 +40,7 @@ void TitleSelectState::update()
else if (yPressed) { TitleSelectState::add_remove_favorite(); }
else if (bPressed) { TitleSelectState::deactivate_state(); }
m_titleView.update(hasFocus);
m_titleView->update(hasFocus);
}
void TitleSelectState::render()
@@ -62,12 +48,12 @@ void TitleSelectState::render()
const bool hasFocus = BaseState::has_focus();
m_renderTarget->clear(colors::TRANSPARENT);
m_titleView.render(m_renderTarget, hasFocus);
m_titleView->render(m_renderTarget, hasFocus);
TitleSelectCommon::render_control_guide();
m_renderTarget->render(sdl::Texture::Null, 201, 91);
}
void TitleSelectState::refresh() { m_titleView.refresh(); }
void TitleSelectState::refresh() { m_titleView->refresh(); }
bool TitleSelectState::title_count_check()
{
@@ -83,7 +69,7 @@ bool TitleSelectState::title_count_check()
void TitleSelectState::create_backup_menu()
{
const int selected = m_titleView.get_selected();
const int selected = m_titleView->get_selected();
const uint64_t applicationID = m_user->get_application_id_at(selected);
data::TitleInfo *titleInfo = data::get_title_info_by_id(applicationID);
@@ -93,7 +79,7 @@ void TitleSelectState::create_backup_menu()
void TitleSelectState::create_title_option_menu()
{
const int selected = m_titleView.get_selected();
const int selected = m_titleView->get_selected();
const uint64_t applicationID = m_user->get_application_id_at(selected);
data::TitleInfo *titleInfo = data::get_title_info_by_id(applicationID);
@@ -103,13 +89,13 @@ void TitleSelectState::create_title_option_menu()
void TitleSelectState::deactivate_state()
{
m_titleView.reset();
m_titleView->reset();
BaseState::deactivate();
}
void TitleSelectState::add_remove_favorite()
{
const int selected = m_titleView.get_selected();
const int selected = m_titleView->get_selected();
const uint64_t applicationID = m_user->get_application_id_at(selected);
config::add_remove_favorite(applicationID);
@@ -127,7 +113,7 @@ void TitleSelectState::add_remove_favorite()
const uint64_t appIDAt = m_user->get_application_id_at(i);
if (appIDAt == applicationID) { break; }
}
m_titleView.set_selected(i);
m_titleView->set_selected(i);
MainMenuState::refresh_view_states();
}

View File

@@ -6,15 +6,15 @@
#include "appstates/ProgressState.hpp"
#include "appstates/SaveCreateState.hpp"
#include "appstates/TaskState.hpp"
#include "config.hpp"
#include "config/config.hpp"
#include "data/data.hpp"
#include "error.hpp"
#include "fs/fs.hpp"
#include "fslib.hpp"
#include "input.hpp"
#include "logger.hpp"
#include "logging/error.hpp"
#include "logging/logger.hpp"
#include "remote/remote.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
#include "sys/sys.hpp"
#include "tasks/useroptions.hpp"
@@ -31,15 +31,15 @@ namespace
DELETE_ALL_SAVE
};
// These make things easier to type later.
using TaskConfirm = ConfirmState<sys::Task, TaskState, UserOptionState::DataStruct>;
using ProgressConfirm = ConfirmState<sys::ProgressTask, ProgressState, UserOptionState::DataStruct>;
} // namespace
UserOptionState::UserOptionState(data::User *user, TitleSelectCommon *titleSelect)
: m_user(user)
, m_titleSelect(titleSelect)
, m_userOptionMenu(8, 8, 460, 22, 720)
, m_userOptionMenu(ui::Menu::create(8, 8, 460, 22, 720))
, m_dataStruct(std::make_shared<UserOptionState::DataStruct>())
{
UserOptionState::create_menu_panel();
@@ -47,30 +47,20 @@ UserOptionState::UserOptionState(data::User *user, TitleSelectCommon *titleSelec
UserOptionState::initialize_data_struct();
}
std::shared_ptr<UserOptionState> UserOptionState::create(data::User *user, TitleSelectCommon *titleSelect)
UserOptionState::~UserOptionState()
{
return std::make_shared<UserOptionState>(user, titleSelect);
}
std::shared_ptr<UserOptionState> UserOptionState::create_and_push(data::User *user, TitleSelectCommon *titleSelect)
{
auto newState = UserOptionState::create(user, titleSelect);
StateManager::push_state(newState);
return newState;
sm_menuPanel->clear_elements();
sm_menuPanel->reset();
}
void UserOptionState::update()
{
const bool hasFocus = BaseState::has_focus();
sm_menuPanel->update(hasFocus);
const bool isOpen = sm_menuPanel->is_open();
if (!isOpen) { return; }
const bool aPressed = input::button_pressed(HidNpadButton_A);
const bool bPressed = input::button_pressed(HidNpadButton_B);
// See if this needs to be done.
sm_menuPanel->update(hasFocus);
if (m_refreshRequired)
{
m_user->load_user_data();
@@ -80,7 +70,7 @@ void UserOptionState::update()
if (aPressed)
{
const int selected = m_userOptionMenu.get_selected();
const int selected = m_userOptionMenu->get_selected();
switch (selected)
{
@@ -91,24 +81,16 @@ void UserOptionState::update()
}
}
else if (bPressed) { sm_menuPanel->close(); }
else if (sm_menuPanel->is_closed())
{
BaseState::deactivate();
sm_menuPanel->reset();
}
m_userOptionMenu.update(BaseState::has_focus());
else if (sm_menuPanel->is_closed()) { BaseState::deactivate(); }
}
void UserOptionState::render()
{
// Render target user's title selection screen.
m_titleSelect->render();
sdl::SharedTexture &panelTarget = sm_menuPanel->get_target();
// Render panel.
sm_menuPanel->clear_target();
m_userOptionMenu.render(panelTarget, BaseState::has_focus());
sm_menuPanel->render(sdl::Texture::Null, BaseState::has_focus());
}
@@ -117,7 +99,9 @@ void UserOptionState::refresh_required() { m_refreshRequired = true; }
void UserOptionState::create_menu_panel()
{
static constexpr int SIZE_PANEL_WIDTH = 480;
if (!sm_menuPanel) { sm_menuPanel = std::make_unique<ui::SlideOutPanel>(SIZE_PANEL_WIDTH, ui::SlideOutPanel::Side::Right); }
if (sm_menuPanel) { return; }
sm_menuPanel = ui::SlideOutPanel::create(SIZE_PANEL_WIDTH, ui::SlideOutPanel::Side::Right);
}
void UserOptionState::load_menu_strings()
@@ -127,8 +111,9 @@ void UserOptionState::load_menu_strings()
for (int i = 0; const char *format = strings::get_by_name(strings::names::USEROPTION_MENU, i); i++)
{
const std::string option = stringutil::get_formatted_string(format, nickname);
m_userOptionMenu.add_option(option);
m_userOptionMenu->add_option(option);
}
sm_menuPanel->push_new_element(m_userOptionMenu);
}
void UserOptionState::initialize_data_struct()

View File

@@ -1,293 +0,0 @@
#include "config.hpp"
#include "JSON.hpp"
#include "error.hpp"
#include "logger.hpp"
#include "stringutil.hpp"
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <map>
#include <string>
#include <vector>
namespace
{
/// @brief This is the default working directory path.
constexpr std::string_view PATH_DEFAULT_WORK_DIR = "sdmc:/JKSV";
// Folder path.
constexpr std::string_view PATH_CONFIG_FOLDER = "sdmc:/config/JKSV";
// Paths file. Funny name too.
constexpr const char *PATH_PATHS_PATH = "sdmc:/config/JKSV/Paths.json";
// Actual config path.
constexpr const char *PATH_CONFIG_FILE = "sdmc:/config/JKSV/JKSV.json";
/// @brief This map holds the majority of config values.
std::map<std::string, uint8_t> s_configMap;
// Working directory
fslib::Path s_workingDirectory;
// UI animation scaling.
double s_uiAnimationScaling;
// Vector of favorite title ids
std::vector<uint64_t> s_favorites;
// Vector of titles to ignore.
std::vector<uint64_t> s_blacklist;
// Map of paths.
std::map<uint64_t, std::string> s_pathMap;
} // namespace
// Definitions at bottom.
static void read_array_to_vector(std::vector<uint64_t> &vector, json_object *array);
static void save_custom_paths();
void config::initialize()
{
// This is so we don't constantly construct new Paths
const fslib::Path configDir{PATH_CONFIG_FOLDER};
const bool configDirExists = fslib::directory_exists(configDir);
const bool configDirError = !configDirExists && error::fslib(fslib::create_directories_recursively(configDir));
if (!configDirExists && configDirError)
{
config::reset_to_default();
return;
}
json::Object configJSON = json::new_object(json_object_from_file, PATH_CONFIG_FILE);
if (!configJSON)
{
logger::log("Error opening config for reading: %s", fslib::error::get_string());
config::reset_to_default();
return;
}
json_object_iterator configIterator = json_object_iter_begin(configJSON.get());
json_object_iterator configEnd = json_object_iter_end(configJSON.get());
while (!json_object_iter_equal(&configIterator, &configEnd))
{
const char *keyName = json_object_iter_peek_name(&configIterator);
json_object *configValue = json_object_iter_peek_value(&configIterator);
// These are exemptions.
const bool workingDirectory = std::strcmp(keyName, config::keys::WORKING_DIRECTORY.data()) == 0;
const bool animationScaling = std::strcmp(keyName, config::keys::UI_ANIMATION_SCALE.data()) == 0;
const bool favorites = std::strcmp(keyName, config::keys::FAVORITES.data()) == 0;
const bool blacklist = std::strcmp(keyName, config::keys::BLACKLIST.data()) == 0;
if (workingDirectory) { s_workingDirectory = json_object_get_string(configValue); }
else if (animationScaling) { s_uiAnimationScaling = json_object_get_double(configValue); }
else if (favorites) { read_array_to_vector(s_favorites, configValue); }
else if (blacklist) { read_array_to_vector(s_blacklist, configValue); }
else { s_configMap[keyName] = json_object_get_uint64(configValue); }
json_object_iter_next(&configIterator);
}
// Load custom output paths.
if (!fslib::file_exists(PATH_PATHS_PATH))
{
// Just bail.
return;
}
json::Object pathsJSON = json::new_object(json_object_from_file, PATH_PATHS_PATH);
if (!pathsJSON) { return; }
json_object_iterator pathsIterator = json_object_iter_begin(pathsJSON.get());
json_object_iterator pathsEnd = json_object_iter_end(pathsJSON.get());
while (!json_object_iter_equal(&pathsIterator, &pathsEnd))
{
const char *idString = json_object_iter_peek_name(&pathsIterator);
json_object *pathObject = json_object_iter_peek_value(&pathsIterator);
const uint64_t applicationID = std::strtoull(idString, nullptr, 16);
const char *path = json_object_get_string(pathObject);
s_pathMap[applicationID] = path;
json_object_iter_next(&pathsIterator);
}
}
void config::reset_to_default()
{
s_workingDirectory = PATH_DEFAULT_WORK_DIR;
s_configMap[config::keys::INCLUDE_DEVICE_SAVES.data()] = 0;
s_configMap[config::keys::AUTO_BACKUP_ON_RESTORE.data()] = 1;
s_configMap[config::keys::AUTO_NAME_BACKUPS.data()] = 0;
s_configMap[config::keys::AUTO_UPLOAD.data()] = 0;
s_configMap[config::keys::USE_TITLE_IDS.data()] = 0;
s_configMap[config::keys::HOLD_FOR_DELETION.data()] = 1;
s_configMap[config::keys::HOLD_FOR_RESTORATION.data()] = 1;
s_configMap[config::keys::HOLD_FOR_OVERWRITE.data()] = 1;
s_configMap[config::keys::ONLY_LIST_MOUNTABLE.data()] = 1;
s_configMap[config::keys::LIST_ACCOUNT_SYS_SAVES.data()] = 0;
s_configMap[config::keys::ALLOW_WRITING_TO_SYSTEM.data()] = 0;
s_configMap[config::keys::EXPORT_TO_ZIP.data()] = 1;
s_configMap[config::keys::ZIP_COMPRESSION_LEVEL.data()] = 6;
s_configMap[config::keys::TITLE_SORT_TYPE.data()] = 0;
s_configMap[config::keys::JKSM_TEXT_MODE.data()] = 0;
s_configMap[config::keys::FORCE_ENGLISH.data()] = 0;
s_configMap[config::keys::ENABLE_TRASH_BIN.data()] = 0;
s_uiAnimationScaling = 2.5f;
}
void config::save()
{
{
json::Object configJSON = json::new_object(json_object_new_object);
json_object *workingDirectory = json_object_new_string(s_workingDirectory.full_path());
json::add_object(configJSON, config::keys::WORKING_DIRECTORY.data(), workingDirectory);
for (const auto &[key, value] : s_configMap)
{
json_object *jsonValue = json_object_new_uint64(value);
json::add_object(configJSON, key.c_str(), jsonValue);
}
json_object *scaling = json_object_new_double(s_uiAnimationScaling);
json::add_object(configJSON, config::keys::UI_ANIMATION_SCALE.data(), scaling);
json_object *favoritesArray = json_object_new_array();
for (const uint64_t &titleID : s_favorites)
{
const std::string idHex = stringutil::get_formatted_string("%016llX", titleID);
json_object *newFavorite = json_object_new_string(idHex.c_str());
json_object_array_add(favoritesArray, newFavorite);
}
json::add_object(configJSON, config::keys::FAVORITES.data(), favoritesArray);
json_object *blacklistArray = json_object_new_array();
for (const uint64_t &titleID : s_blacklist)
{
const std::string idHex = stringutil::get_formatted_string("%016llX", titleID);
json_object *newBlacklist = json_object_new_string(idHex.c_str());
json_object_array_add(blacklistArray, newBlacklist);
}
json::add_object(configJSON, config::keys::BLACKLIST.data(), blacklistArray);
const char *jsonString = json_object_get_string(configJSON.get());
const int64_t configLength = std::char_traits<char>::length(jsonString);
fslib::File configFile{PATH_CONFIG_FILE, FsOpenMode_Create | FsOpenMode_Write, configLength};
if (configFile) { configFile << jsonString; }
}
}
uint8_t config::get_by_key(std::string_view key)
{
// See if the key can be found.
auto findKey = s_configMap.find(key.data());
if (findKey == s_configMap.end()) { return 0; }
return findKey->second;
}
void config::toggle_by_key(std::string_view key)
{
auto findKey = s_configMap.find(key.data());
if (findKey == s_configMap.end()) { return; }
findKey->second = findKey->second ? 0 : 1;
}
void config::set_by_key(std::string_view key, uint8_t value)
{
auto findKey = s_configMap.find(key.data());
if (findKey == s_configMap.end()) { return; }
findKey->second = value;
}
fslib::Path config::get_working_directory() { return s_workingDirectory; }
double config::get_animation_scaling() { return s_uiAnimationScaling; }
void config::set_animation_scaling(double newScale) { s_uiAnimationScaling = newScale; }
void config::add_remove_favorite(uint64_t applicationID)
{
auto findTitle = std::find(s_favorites.begin(), s_favorites.end(), applicationID);
if (findTitle == s_favorites.end()) { s_favorites.push_back(applicationID); }
else { s_favorites.erase(findTitle); }
config::save();
}
bool config::is_favorite(uint64_t applicationID)
{
return std::find(s_favorites.begin(), s_favorites.end(), applicationID) != s_favorites.end();
}
void config::add_remove_blacklist(uint64_t applicationID)
{
auto findTitle = std::find(s_blacklist.begin(), s_blacklist.end(), applicationID);
if (findTitle == s_blacklist.end()) { s_blacklist.push_back(applicationID); }
else { s_blacklist.erase(findTitle); }
config::save();
}
void config::get_blacklisted_titles(std::vector<uint64_t> &listOut)
{
listOut.clear();
listOut.assign(s_blacklist.begin(), s_blacklist.end());
}
bool config::is_blacklisted(uint64_t applicationID)
{
return std::find(s_blacklist.begin(), s_blacklist.end(), applicationID) != s_blacklist.end();
}
bool config::blacklist_is_empty() { return s_blacklist.size() <= 0; }
void config::add_custom_path(uint64_t applicationID, std::string_view customPath)
{
s_pathMap[applicationID] = customPath.data();
save_custom_paths();
}
bool config::has_custom_path(uint64_t applicationID) { return s_pathMap.find(applicationID) != s_pathMap.end(); }
void config::get_custom_path(uint64_t applicationID, char *pathOut, size_t pathOutSize)
{
const auto findPath = s_pathMap.find(applicationID);
if (findPath == s_pathMap.end()) { return; }
std::memcpy(pathOut, s_pathMap[applicationID].c_str(), s_pathMap[applicationID].length());
}
static void read_array_to_vector(std::vector<uint64_t> &vector, json_object *array)
{
// Just in case. Shouldn't happen though.
vector.clear();
const size_t arrayLength = json_object_array_length(array);
for (size_t i = 0; i < arrayLength; i++)
{
json_object *arrayEntry = json_object_array_get_idx(array, i);
if (!arrayEntry) { continue; }
vector.push_back(std::strtoull(json_object_get_string(arrayEntry), NULL, 16));
}
}
static void save_custom_paths()
{
json::Object pathsJson = json::new_object(json_object_new_object);
if (!pathsJson) { return; }
for (const auto &[applicationId, path] : s_pathMap)
{
const std::string titleIdHex = stringutil::get_formatted_string("%016llX", applicationId);
json_object *jsonPath = json_object_new_string(path.c_str());
json::add_object(pathsJson, titleIdHex, jsonPath);
}
const char *jsonString = json_object_get_string(pathsJson.get());
const int64_t jsonLength = std::char_traits<char>::length(jsonString);
fslib::File pathsFile{PATH_PATHS_PATH, FsOpenMode_Create | FsOpenMode_Write, jsonLength};
if (error::fslib(pathsFile)) { return; }
pathsFile << jsonString;
}

View File

@@ -0,0 +1,282 @@
#include "config/ConfigContext.hpp"
#include "JSON.hpp"
#include "config/keys.hpp"
#include "logging/error.hpp"
#include "stringutil.hpp"
#include <cstring>
namespace
{
constexpr std::string_view PATH_DEFAULT_WORK_DIR = "sdmc:/JKSV";
constexpr const char *PATH_PATHS_PATH = "sdmc:/config/JKSV/Paths.json";
constexpr const char *PATH_CONFIG_FILE = "sdmc:/config/JKSV/JKSV.json";
constexpr const char *STRING_APP_ID_FORMAT = "%016llX";
}
void config::ConfigContext::reset()
{
m_workingDirectory = PATH_DEFAULT_WORK_DIR;
m_configMap[config::keys::INCLUDE_DEVICE_SAVES.data()] = 0;
m_configMap[config::keys::AUTO_BACKUP_ON_RESTORE.data()] = 1;
m_configMap[config::keys::AUTO_NAME_BACKUPS.data()] = 0;
m_configMap[config::keys::AUTO_UPLOAD.data()] = 0;
m_configMap[config::keys::USE_TITLE_IDS.data()] = 0;
m_configMap[config::keys::HOLD_FOR_DELETION.data()] = 1;
m_configMap[config::keys::HOLD_FOR_RESTORATION.data()] = 1;
m_configMap[config::keys::HOLD_FOR_OVERWRITE.data()] = 1;
m_configMap[config::keys::ONLY_LIST_MOUNTABLE.data()] = 1;
m_configMap[config::keys::LIST_ACCOUNT_SYS_SAVES.data()] = 0;
m_configMap[config::keys::ALLOW_WRITING_TO_SYSTEM.data()] = 0;
m_configMap[config::keys::EXPORT_TO_ZIP.data()] = 1;
m_configMap[config::keys::ZIP_COMPRESSION_LEVEL.data()] = 6;
m_configMap[config::keys::TITLE_SORT_TYPE.data()] = 0;
m_configMap[config::keys::JKSM_TEXT_MODE.data()] = 0;
m_configMap[config::keys::FORCE_ENGLISH.data()] = 0;
m_configMap[config::keys::ENABLE_TRASH_BIN.data()] = 0;
m_animationScaling = 2.5f;
}
void config::ConfigContext::save()
{
json::Object configJSON = json::new_object(json_object_new_object);
if (!configJSON) { return; }
json_object *workDir = json_object_new_string(m_workingDirectory.full_path());
json::add_object(configJSON, config::keys::WORKING_DIRECTORY.data(), workDir);
for (const auto &[key, value] : m_configMap)
{
json_object *valueObject = json_object_new_uint64(value);
json::add_object(configJSON, key.c_str(), valueObject);
}
json_object *scaling = json_object_new_double(m_animationScaling);
json::add_object(configJSON, config::keys::UI_ANIMATION_SCALE.data(), scaling);
json_object *favoritesArray = json_object_new_array();
for (const uint64_t &applicationID : m_favorites)
{
const std::string appIDHex = stringutil::get_formatted_string(STRING_APP_ID_FORMAT, applicationID);
json_object *newFavorite = json_object_new_string(appIDHex.c_str());
json_object_array_add(favoritesArray, newFavorite);
}
json::add_object(configJSON, config::keys::FAVORITES.data(), favoritesArray);
json_object *blacklistArray = json_object_new_array();
for (const uint64_t &applicationID : m_blacklist)
{
const std::string appIDHex = stringutil::get_formatted_string(STRING_APP_ID_FORMAT, applicationID);
json_object *newBlacklist = json_object_new_string(appIDHex.c_str());
json_object_array_add(blacklistArray, newBlacklist);
}
json::add_object(configJSON, config::keys::BLACKLIST.data(), blacklistArray);
const char *configString = json::get_string(configJSON);
const int64_t configLength = std::char_traits<char>::length(configString);
fslib::File configFile{PATH_CONFIG_FILE, FsOpenMode_Create | FsOpenMode_Write, configLength};
if (configFile.is_open()) { configFile << configString; }
}
void config::ConfigContext::load()
{
json::Object configJSON = json::new_object(json_object_from_file, PATH_CONFIG_FILE);
if (!configJSON)
{
error::fslib(false); // This seems weird, but it should catch the problem.
return;
}
json_object_iterator configIter = json::iter_begin(configJSON);
json_object_iterator configEnd = json::iter_end(configJSON);
while (!json_object_iter_equal(&configIter, &configEnd))
{
const char *key = json_object_iter_peek_name(&configIter);
json_object *value = json_object_iter_peek_value(&configIter);
const bool workingDir = std::strcmp(config::keys::WORKING_DIRECTORY.data(), key) == 0;
const bool scaling = std::strcmp(config::keys::UI_ANIMATION_SCALE.data(), key) == 0;
const bool favorites = std::strcmp(config::keys::FAVORITES.data(), key) == 0;
const bool blacklist = std::strcmp(config::keys::BLACKLIST.data(), key) == 0;
if (workingDir) { m_workingDirectory = json_object_get_string(value); }
else if (scaling) { m_animationScaling = json_object_get_double(value); }
else if (favorites) { ConfigContext::read_array_to_vector(m_favorites, value); }
else if (blacklist) { ConfigContext::read_array_to_vector(m_blacklist, value); }
else { m_configMap[key] = json_object_get_uint64(value); }
json_object_iter_next(&configIter);
}
const fslib::Path pathsPath{PATH_PATHS_PATH};
const bool pathsExists = fslib::file_exists(pathsPath);
if (!pathsExists) { return; }
json::Object pathsJSON = json::new_object(json_object_from_file, pathsPath.full_path());
if (!pathsJSON)
{
error::fslib(false);
return;
}
json_object_iterator pathsIter = json::iter_begin(configJSON);
json_object_iterator pathsEnd = json::iter_end(configJSON);
while (!json_object_iter_equal(&pathsIter, &pathsEnd))
{
const char *appIDString = json_object_iter_peek_name(&pathsIter);
json_object *pathObject = json_object_iter_peek_value(&pathsIter);
const uint64_t applicationID = std::strtoull(appIDString, nullptr, 16);
const char *path = json_object_get_string(pathObject);
m_pathMap[applicationID] = path;
json_object_iter_next(&pathsIter);
}
}
uint8_t config::ConfigContext::get_by_key(std::string_view key)
{
auto findKey = m_configMap.find(key.data());
if (findKey == m_configMap.end()) { return 0; }
return findKey->second;
}
void config::ConfigContext::toggle_by_key(std::string_view key)
{
auto findKey = m_configMap.find(key.data());
if (findKey == m_configMap.end()) { return; }
findKey->second = findKey->second ? 0 : 1;
}
void config::ConfigContext::set_by_key(std::string_view key, uint8_t value)
{
auto findKey = m_configMap.find(key.data());
if (findKey == m_configMap.end()) { return; }
findKey->second = value;
}
fslib::Path config::ConfigContext::get_working_directory() const { return m_workingDirectory; }
bool config::ConfigContext::set_working_directory(std::string_view path)
{
fslib::Path testPath{path};
if (!testPath.is_valid()) { return false; }
m_workingDirectory = std::move(testPath);
return true;
}
double config::ConfigContext::get_animation_scaling() const { return m_animationScaling; }
void config::ConfigContext::set_animation_scaling(double scaling) { m_animationScaling = scaling; }
void config::ConfigContext::add_favorite(uint64_t applicationID)
{
auto findID = ConfigContext::find_favorite(applicationID);
if (findID != m_favorites.end()) { return; }
m_favorites.push_back(applicationID);
}
void config::ConfigContext::remove_favorite(uint64_t applicationID)
{
auto findID = ConfigContext::find_favorite(applicationID);
if (findID == m_favorites.end()) { return; }
m_favorites.erase(findID);
}
bool config::ConfigContext::is_favorite(uint64_t applicationID)
{
return ConfigContext::find_favorite(applicationID) != m_favorites.end();
}
void config::ConfigContext::add_to_blacklist(uint64_t applicationID)
{
auto findID = ConfigContext::find_blacklist(applicationID);
if (findID != m_blacklist.end()) { return; }
m_blacklist.push_back(applicationID);
}
void config::ConfigContext::remove_from_blacklist(uint64_t applicationID)
{
auto findID = ConfigContext::find_blacklist(applicationID);
if (findID == m_blacklist.end()) { return; }
m_blacklist.erase(findID);
}
void config::ConfigContext::get_blacklisted_titles(std::vector<uint64_t> &listOut)
{
listOut.clear();
listOut.assign(m_blacklist.begin(), m_blacklist.end());
}
bool config::ConfigContext::is_blacklisted(uint64_t applicationID)
{
return ConfigContext::find_blacklist(applicationID) != m_blacklist.end();
}
bool config::ConfigContext::blacklist_is_empty() const { return m_blacklist.empty(); }
void config::ConfigContext::add_custom_path(uint64_t applicationID, std::string_view path)
{
m_pathMap[applicationID] = path.data();
ConfigContext::save_custom_paths();
}
bool config::ConfigContext::has_custom_path(uint64_t applicationID) { return m_pathMap.find(applicationID) != m_pathMap.end(); }
void config::ConfigContext::get_custom_path(uint64_t applicationID, char *pathBuffer, size_t bufferSize)
{
if (!ConfigContext::has_custom_path(applicationID)) { return; }
const std::string &path = m_pathMap[applicationID];
if (path.length() > bufferSize) { return; }
std::memset(pathBuffer, 0x00, bufferSize);
std::memcpy(pathBuffer, path.c_str(), path.length());
}
void config::ConfigContext::read_array_to_vector(std::vector<uint64_t> &vector, json_object *array)
{
const int arrayLength = json_object_array_length(array);
for (int i = 0; i < arrayLength; i++)
{
json_object *arrayElement = json_object_array_get_idx(array, i);
if (!arrayElement) { break; }
const char *appIDStr = json_object_get_string(arrayElement);
const uint64_t applicationID = std::strtoull(appIDStr, nullptr, 16);
vector.push_back(applicationID);
}
}
void config::ConfigContext::save_custom_paths()
{
json::Object pathsJSON = json::new_object(json_object_new_object);
for (auto &[applicationID, outputPath] : m_pathMap)
{
const std::string appIDHex = stringutil::get_formatted_string(STRING_APP_ID_FORMAT, applicationID);
const char *path = outputPath.c_str();
json_object *outputString = json_object_new_string(path);
json::add_object(pathsJSON, appIDHex, outputString);
}
const char *pathsString = json::get_string(pathsJSON);
const int64_t pathsLength = std::char_traits<char>::length(pathsString);
fslib::File pathsFile{PATH_PATHS_PATH, FsOpenMode_Create | FsOpenMode_Write, pathsLength};
if (pathsFile.is_open()) { pathsFile << pathsString; };
}
config::ConfigContext::AppIDList::iterator config::ConfigContext::find_favorite(uint64_t applicationID)
{
return std::find(m_favorites.begin(), m_favorites.end(), applicationID);
}
config::ConfigContext::AppIDList::iterator config::ConfigContext::find_blacklist(uint64_t applicationID)
{
return std::find(m_blacklist.begin(), m_blacklist.end(), applicationID);
}

88
source/config/config.cpp Normal file
View File

@@ -0,0 +1,88 @@
#include "config/config.hpp"
#include "config/ConfigContext.hpp"
#include "logging/error.hpp"
namespace
{
config::ConfigContext s_context{};
constexpr std::string_view PATH_CONFIG_FOLDER = "sdmc:/config/JKSV";
constexpr const char *PATH_CONFIG_FILE = "sdmc:/config/JKSV/JKSV.json";
} // namespace
void config::initialize()
{
// This is so we don't constantly construct new Paths
const fslib::Path configDir{PATH_CONFIG_FOLDER};
const fslib::Path configFile{PATH_CONFIG_FILE};
const bool configDirExists = fslib::directory_exists(configDir);
const bool configDirError = !configDirExists && error::fslib(fslib::create_directories_recursively(configDir));
if (!configDirExists && configDirError)
{
s_context.reset();
return;
}
const bool configExists = fslib::file_exists(configFile);
if (!configExists)
{
s_context.reset();
return;
}
s_context.load();
}
void config::reset_to_default() { s_context.reset(); }
void config::save() { s_context.save(); }
uint8_t config::get_by_key(std::string_view key) { return s_context.get_by_key(key); }
void config::toggle_by_key(std::string_view key) { s_context.toggle_by_key(key); }
void config::set_by_key(std::string_view key, uint8_t value) { s_context.set_by_key(key, value); }
fslib::Path config::get_working_directory() { return s_context.get_working_directory(); }
bool config::set_working_directory(std::string_view path) { return s_context.set_working_directory(path); }
double config::get_animation_scaling() { return s_context.get_animation_scaling(); }
void config::set_animation_scaling(double newScale) { s_context.set_animation_scaling(newScale); }
void config::add_remove_favorite(uint64_t applicationID)
{
if (s_context.is_favorite(applicationID)) { s_context.remove_favorite(applicationID); }
else { s_context.add_favorite(applicationID); }
s_context.save();
}
bool config::is_favorite(uint64_t applicationID) { return s_context.is_favorite(applicationID); }
void config::add_remove_blacklist(uint64_t applicationID)
{
if (s_context.is_blacklisted(applicationID)) { s_context.remove_from_blacklist(applicationID); }
else { s_context.add_to_blacklist(applicationID); }
s_context.save();
}
void config::get_blacklisted_titles(std::vector<uint64_t> &listOut) { s_context.get_blacklisted_titles(listOut); }
bool config::is_blacklisted(uint64_t applicationID) { return s_context.is_blacklisted(applicationID); }
bool config::blacklist_is_empty() { return s_context.blacklist_is_empty(); }
void config::add_custom_path(uint64_t applicationID, std::string_view customPath)
{
s_context.add_custom_path(applicationID, customPath);
}
bool config::has_custom_path(uint64_t applicationID) { return s_context.has_custom_path(applicationID); }
void config::get_custom_path(uint64_t applicationID, char *pathOut, size_t pathOutSize)
{
s_context.get_custom_path(applicationID, pathOut, pathOutSize);
}

View File

@@ -1,7 +1,7 @@
#include "curl/curl.hpp"
#include "error.hpp"
#include "logger.hpp"
#include "logging/error.hpp"
#include "logging/logger.hpp"
#include "stringutil.hpp"
#include <cstring>

View File

@@ -1,10 +1,10 @@
#include "data/DataContext.hpp"
#include "config.hpp"
#include "error.hpp"
#include "config/config.hpp"
#include "fs/fs.hpp"
#include "logger.hpp"
#include "strings.hpp"
#include "logging/error.hpp"
#include "logging/logger.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
namespace
@@ -152,8 +152,9 @@ void data::DataContext::get_title_info_list_by_type(FsSaveDataType type, data::T
void data::DataContext::import_svi_files(sys::Task *task)
{
static constexpr size_t SIZE_UINT32 = sizeof(uint32_t);
static constexpr size_t SIZE_UINT64 = sizeof(uint64_t);
static constexpr size_t SIZE_SVI = SIZE_UINT64 + SIZE_CTRL_DATA;
static constexpr size_t SIZE_SVI = SIZE_UINT32 + SIZE_UINT64 + SIZE_CTRL_DATA;
if (error::is_null(task)) { return; }
@@ -174,11 +175,13 @@ void data::DataContext::import_svi_files(sys::Task *task)
const bool goodSvi = sviFile.is_open() && sviFile.get_size() == SIZE_SVI;
if (!goodSvi) { continue; }
uint32_t magic{};
uint64_t applicationID{};
auto controlData = std::make_unique<NsApplicationControlData>();
const bool idRead = sviFile.read(&applicationID, SIZE_UINT64) == SIZE_UINT64;
const bool dataRead = sviFile.read(controlData.get(), SIZE_CTRL_DATA) == SIZE_CTRL_DATA;
if (!idRead || !dataRead) { continue; }
auto controlData = std::make_unique<NsApplicationControlData>();
const bool magicRead = sviFile.read(&magic, SIZE_UINT32) == SIZE_UINT32;
const bool idRead = sviFile.read(&applicationID, SIZE_UINT64) == SIZE_UINT64;
const bool dataRead = sviFile.read(controlData.get(), SIZE_CTRL_DATA) == SIZE_CTRL_DATA;
if (!magicRead || magic != fs::SAVE_META_MAGIC || !idRead || !dataRead) { continue; }
const bool exists = DataContext::title_is_loaded(applicationID);
if (exists) { continue; }

View File

@@ -1,10 +1,10 @@
#include "data/TitleInfo.hpp"
#include "colors.hpp"
#include "config.hpp"
#include "error.hpp"
#include "gfxutil.hpp"
#include "logger.hpp"
#include "config/config.hpp"
#include "graphics/colors.hpp"
#include "graphics/gfxutil.hpp"
#include "logging/error.hpp"
#include "logging/logger.hpp"
#include "stringutil.hpp"
#include <cstring>
@@ -215,7 +215,7 @@ void data::TitleInfo::load_icon()
if (m_hasData)
{
const std::string textureName = stringutil::get_formatted_string("%016llX", m_applicationID);
m_icon = sdl::TextureManager::create_load_texture(textureName, m_data->icon, SIZE_ICON);
m_icon = sdl::TextureManager::load(textureName, m_data->icon, SIZE_ICON);
}
else
{

View File

@@ -1,12 +1,12 @@
#include "data/User.hpp"
#include "colors.hpp"
#include "config.hpp"
#include "config/config.hpp"
#include "data/data.hpp"
#include "error.hpp"
#include "fs/fs.hpp"
#include "gfxutil.hpp"
#include "logger.hpp"
#include "graphics/colors.hpp"
#include "graphics/gfxutil.hpp"
#include "logging/error.hpp"
#include "logging/logger.hpp"
#include "sdl.hpp"
#include "stringutil.hpp"
@@ -221,7 +221,7 @@ void data::User::load_icon()
if (loadError) { return; }
accountProfileClose(&profile);
m_icon = sdl::TextureManager::create_load_texture(m_nickname, iconBuffer.get(), iconSize);
m_icon = sdl::TextureManager::load(m_nickname, iconBuffer.get(), iconSize);
}
else { m_icon = gfxutil::create_generic_icon(m_nickname, SIZE_ICON_FONT, colors::DIALOG_DARK, colors::WHITE); }
}

View File

@@ -2,8 +2,8 @@
#include "appstates/DataLoadingState.hpp"
#include "data/DataContext.hpp"
#include "error.hpp"
#include "strings.hpp"
#include "logging/error.hpp"
#include "strings/strings.hpp"
#include <switch.h>
@@ -44,6 +44,7 @@ static void data_initialize_task(sys::Task *task, bool clearCache)
if (clearCache) { s_context.delete_cache(); }
s_context.read_cache(task);
s_context.load_application_records(task);
s_context.import_svi_files(task);
s_context.load_create_users(task);
s_context.load_user_save_info(task);
s_context.write_cache(task);

View File

@@ -1,7 +1,7 @@
#include "fs/MiniUnzip.hpp"
#include "error.hpp"
#include "logger.hpp"
#include "logging/error.hpp"
#include "logging/logger.hpp"
fs::MiniUnzip::MiniUnzip(const fslib::Path &path) { MiniUnzip::open(path); }

View File

@@ -1,7 +1,7 @@
#include "fs/MiniZip.hpp"
#include "config.hpp"
#include "error.hpp"
#include "config/config.hpp"
#include "logging/error.hpp"
#include <ctime>

29
source/fs/PathFilter.cpp Normal file
View File

@@ -0,0 +1,29 @@
#include "fs/PathFilter.hpp"
#include "JSON.hpp"
fs::PathFilter::PathFilter(const fslib::Path &filePath)
{
json::Object filterJSON = json::new_object(json_object_from_file, filePath.full_path());
if (!filterJSON) { return; }
json_object *filter = json::get_object(filterJSON, "filters");
if (!filter) { return; }
const size_t arrayLength = json_object_array_length(filter);
for (size_t i = 0; i < arrayLength; i++)
{
json_object *pathObject = json_object_array_get_idx(filter, i);
if (!pathObject) { break; }
const char *path = json_object_get_string(pathObject);
m_paths.emplace_back(path);
}
}
bool fs::PathFilter::has_paths() const { return !m_paths.empty(); }
bool fs::PathFilter::is_filtered(const fslib::Path &path)
{
return std::find(m_paths.begin(), m_paths.end(), path.full_path()) != m_paths.end();
}

View File

@@ -1,10 +1,10 @@
#include "fs/SaveMetaData.hpp"
#include "error.hpp"
#include "fs/directory_functions.hpp"
#include "fs/save_data_functions.hpp"
#include "fs/save_mount.hpp"
#include "fslib.hpp"
#include "logging/error.hpp"
namespace
{

View File

@@ -1,7 +1,7 @@
#include "fs/ScopedSaveMount.hpp"
#include "error.hpp"
#include "fslib.hpp"
#include "logging/error.hpp"
fs::ScopedSaveMount::ScopedSaveMount(std::string_view mount, const FsSaveDataInfo *saveInfo, bool log)
: m_mountPoint(mount)

View File

@@ -1,9 +1,9 @@
#include "fs/io.hpp"
#include "error.hpp"
#include "fs/SaveMetaData.hpp"
#include "fslib.hpp"
#include "strings.hpp"
#include "logging/error.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
#include "sys/sys.hpp"
#include "ui/PopMessageManager.hpp"

View File

@@ -1,7 +1,7 @@
#include "fs/save_data_functions.hpp"
#include "error.hpp"
#include "logger.hpp"
#include "logging/error.hpp"
#include "logging/logger.hpp"
bool fs::create_save_data_for(data::User *targetUser, data::TitleInfo *titleInfo)
{

View File

@@ -1,10 +1,10 @@
#include "fs/zip.hpp"
#include "config.hpp"
#include "error.hpp"
#include "config/config.hpp"
#include "fs/SaveMetaData.hpp"
#include "logger.hpp"
#include "strings.hpp"
#include "logging/error.hpp"
#include "logging/logger.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
#include "sys/sys.hpp"
#include "ui/PopMessageManager.hpp"

View File

@@ -1,4 +1,4 @@
#include "gfxutil.hpp"
#include "graphics/gfxutil.hpp"
namespace
{
@@ -15,7 +15,7 @@ sdl::SharedTexture gfxutil::create_generic_icon(std::string_view text,
sdl::Color foreground)
{
// Create base icon texture.
sdl::SharedTexture icon = sdl::TextureManager::create_load_texture(text, 256, 256, SDL_TEXTUREACCESS_TARGET);
sdl::SharedTexture icon = sdl::TextureManager::load(text, 256, 256, SDL_TEXTUREACCESS_TARGET);
// Get the centered X and Y coordinates.
const int textX = (SIZE_ICON_WIDTH / 2) - (sdl::text::get_width(fontSize, text) / 2);

View File

@@ -1,6 +1,6 @@
#include "keyboard.hpp"
#include "error.hpp"
#include "logging/error.hpp"
#include <string>

View File

@@ -1,7 +1,7 @@
#include "error.hpp"
#include "logging/error.hpp"
#include "fslib.hpp"
#include "logger.hpp"
#include "logging/logger.hpp"
#include <cstdio>
#include <string_view>

View File

@@ -1,6 +1,6 @@
#include "logger.hpp"
#include "logging/logger.hpp"
#include "config.hpp"
#include "config/config.hpp"
#include "fslib.hpp"
#include <array>

View File

@@ -1,5 +1,4 @@
#include "JKSV.hpp"
#include "config.hpp"
#include <switch.h>

View File

@@ -1,10 +1,10 @@
#include "remote/GoogleDrive.hpp"
#include "logger.hpp"
#include "logging/logger.hpp"
#include "remote/Form.hpp"
#include "remote/URL.hpp"
#include "remote/remote.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
#include <algorithm>

View File

@@ -1,6 +1,6 @@
#include "remote/Item.hpp"
#include "logger.hpp"
#include "logging/logger.hpp"
remote::Item::Item(std::string_view name, std::string_view id, std::string_view parent, size_t size, bool directory)
: m_name{name}

View File

@@ -1,6 +1,6 @@
#include "remote/Storage.hpp"
#include "logger.hpp"
#include "logging/logger.hpp"
#include <algorithm>
#include <cstring>

View File

@@ -2,10 +2,10 @@
#include "JSON.hpp"
#include "curl/curl.hpp"
#include "error.hpp"
#include "logger.hpp"
#include "logging/error.hpp"
#include "logging/logger.hpp"
#include "remote/remote.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
#include "ui/PopMessageManager.hpp"

View File

@@ -2,11 +2,11 @@
#include "StateManager.hpp"
#include "appstates/TaskState.hpp"
#include "error.hpp"
#include "logger.hpp"
#include "logging/error.hpp"
#include "logging/logger.hpp"
#include "remote/GoogleDrive.hpp"
#include "remote/WebDav.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include "ui/PopMessageManager.hpp"
#include <chrono>

View File

@@ -1,8 +1,8 @@
#include "strings.hpp"
#include "strings/strings.hpp"
#include "JSON.hpp"
#include "error.hpp"
#include "fslib.hpp"
#include "logging/error.hpp"
#include "stringutil.hpp"
#include <map>
@@ -44,8 +44,8 @@ bool strings::initialize()
json::Object stringJSON = json::new_object(json_object_from_file, filePath.full_path());
if (!stringJSON) { return false; }
json_object_iterator stringIterator = json_object_iter_begin(stringJSON.get());
json_object_iterator stringEnd = json_object_iter_end(stringJSON.get());
json_object_iterator stringIterator = json::iter_begin(stringJSON);
json_object_iterator stringEnd = json::iter_end(stringJSON);
while (!json_object_iter_equal(&stringIterator, &stringEnd))
{
// Get name of string(s) and pointer to array

View File

@@ -1,6 +1,6 @@
#include "sys/Task.hpp"
#include "logger.hpp"
#include "logging/logger.hpp"
sys::Task::~Task() { m_thread.join(); }

View File

@@ -1,6 +1,6 @@
#include "sys/Timer.hpp"
#include "logger.hpp"
#include "logging/logger.hpp"
#include <SDL2/SDL.h>

View File

@@ -1,11 +1,11 @@
#include "tasks/backup.hpp"
#include "config.hpp"
#include "error.hpp"
#include "config/config.hpp"
#include "fs/fs.hpp"
#include "logger.hpp"
#include "logging/error.hpp"
#include "logging/logger.hpp"
#include "remote/remote.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
#include "ui/PopMessageManager.hpp"

View File

@@ -1,9 +1,9 @@
#include "tasks/mainmenu.hpp"
#include "config.hpp"
#include "config/config.hpp"
#include "data/data.hpp"
#include "error.hpp"
#include "fs/fs.hpp"
#include "logging/error.hpp"
#include "remote/remote.hpp"
#include "stringutil.hpp"
#include "tasks/backup.hpp"

View File

@@ -1,8 +1,8 @@
#include "tasks/savecreate.hpp"
#include "error.hpp"
#include "fs/fs.hpp"
#include "strings.hpp"
#include "logging/error.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
#include "ui/PopMessageManager.hpp"

View File

@@ -1,13 +1,13 @@
#include "tasks/titleoptions.hpp"
#include "config.hpp"
#include "config/config.hpp"
#include "data/data.hpp"
#include "error.hpp"
#include "fs/fs.hpp"
#include "keyboard.hpp"
#include "logger.hpp"
#include "logging/error.hpp"
#include "logging/logger.hpp"
#include "remote/remote.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
#include "ui/ui.hpp"

View File

@@ -1,10 +1,10 @@
#include "tasks/useroptions.hpp"
#include "config.hpp"
#include "error.hpp"
#include "config/config.hpp"
#include "fs/fs.hpp"
#include "logging/error.hpp"
#include "remote/remote.hpp"
#include "strings.hpp"
#include "strings/strings.hpp"
#include "stringutil.hpp"
#include "tasks/backup.hpp"
#include "ui/ui.hpp"

View File

@@ -18,11 +18,6 @@ ui::BoundingBox::BoundingBox(int x, int y, int width, int height)
BoundingBox::initialize_static_members();
}
std::shared_ptr<ui::BoundingBox> ui::BoundingBox::create(int x, int y, int width, int height)
{
return std::make_shared<ui::BoundingBox>(x, y, width, height);
}
void ui::BoundingBox::update(bool hasFocus) { m_colorMod.update(); }
void ui::BoundingBox::render(sdl::SharedTexture &target, bool hasFocus)
@@ -66,5 +61,5 @@ void ui::BoundingBox::set_width_height(int width, int height)
void ui::BoundingBox::initialize_static_members()
{
if (sm_corners) { return; }
sm_corners = sdl::TextureManager::create_load_texture("menuCorners", "romfs:/Textures/MenuBounding.png");
sm_corners = sdl::TextureManager::load("menuCorners", "romfs:/Textures/MenuBounding.png");
}

View File

@@ -1,6 +1,6 @@
#include "ui/DialogBox.hpp"
#include "colors.hpp"
#include "graphics/colors.hpp"
namespace
{
@@ -18,11 +18,6 @@ ui::DialogBox::DialogBox(int x, int y, int width, int height, ui::DialogBox::Typ
ui::DialogBox::initialize_static_members();
}
std::shared_ptr<ui::DialogBox> ui::DialogBox::create(int x, int y, int width, int height, ui::DialogBox::Type type)
{
return std::make_shared<ui::DialogBox>(x, y, width, height, type);
}
void ui::DialogBox::render(sdl::SharedTexture &target, bool hasFocus)
{
const bool darkDialog = m_type == DialogBox::Type::Dark;
@@ -70,6 +65,6 @@ void ui::DialogBox::initialize_static_members()
{
if (sm_darkCorners && sm_lightCorners) { return; }
sm_darkCorners = sdl::TextureManager::create_load_texture("darkCorners", "romfs:/Textures/DialogCornersDark.png");
sm_lightCorners = sdl::TextureManager::create_load_texture("lightCorners", "romfs:/Textures/DialogCornersLight.png");
sm_darkCorners = sdl::TextureManager::load("darkCorners", "romfs:/Textures/DialogCornersDark.png");
sm_lightCorners = sdl::TextureManager::load("lightCorners", "romfs:/Textures/DialogCornersLight.png");
}

View File

@@ -1,6 +1,6 @@
#include "ui/IconMenu.hpp"
#include "colors.hpp"
#include "graphics/colors.hpp"
namespace
{
@@ -18,11 +18,6 @@ ui::IconMenu::IconMenu(int x, int y, int renderTargetHeight)
m_boundingBox->set_width_height(152, 146);
}
std::shared_ptr<ui::IconMenu> ui::IconMenu::create(int x, int y, int renderTargetHeight)
{
return std::make_shared<ui::IconMenu>(x, y, renderTargetHeight);
}
void ui::IconMenu::update(bool hasFocus) { Menu::update(hasFocus); }
void ui::IconMenu::render(sdl::SharedTexture &target, bool hasFocus)

View File

@@ -1,7 +1,7 @@
#include "ui/Menu.hpp"
#include "colors.hpp"
#include "config.hpp"
#include "config/config.hpp"
#include "graphics/colors.hpp"
#include "input.hpp"
#include "mathutil.hpp"
#include "ui/BoundingBox.hpp"
@@ -19,13 +19,12 @@ ui::Menu::Menu(int x, int y, int width, int fontSize, int renderTargetHeight)
, m_textY((m_optionHeight / 2) - (m_fontSize / 2)) // This seems to be the best alignment.
, m_renderTargetHeight(renderTargetHeight)
, m_optionScroll(
ui::TextScroll::create("temp", 16, 0, m_width, m_optionHeight, m_fontSize, colors::BLUE_GREEN, colors::TRANSPARENT))
ui::TextScroll::create("", 16, 0, m_width, m_optionHeight, m_fontSize, colors::BLUE_GREEN, colors::TRANSPARENT))
{
// Create render target for options
static int MENU_ID = 0;
std::string menuTargetName = "MENU_" + std::to_string(MENU_ID++);
m_optionTarget =
sdl::TextureManager::create_load_texture(menuTargetName, m_width, m_optionHeight, SDL_TEXTUREACCESS_TARGET);
m_optionTarget = sdl::TextureManager::load(menuTargetName, m_width, m_optionHeight, SDL_TEXTUREACCESS_TARGET);
// Outside the initializer list because I'm tired and don't wanna deal with the headache.
m_boundingBox = ui::BoundingBox::create(0, 0, m_width + 12, m_optionHeight + 12);
@@ -35,11 +34,6 @@ ui::Menu::Menu(int x, int y, int width, int fontSize, int renderTargetHeight)
m_scrollLength = std::floor(static_cast<double>(m_maxDisplayOptions) / 2.0f);
}
std::shared_ptr<ui::Menu> ui::Menu::create(int x, int y, int width, int fontSize, int renderTargetHeight)
{
return std::make_shared<ui::Menu>(x, y, width, fontSize, renderTargetHeight);
}
void ui::Menu::update(bool hasFocus)
{
if (m_options.empty()) { return; }

View File

@@ -1,7 +1,7 @@
#include "ui/PopMessage.hpp"
#include "colors.hpp"
#include "config.hpp"
#include "config/config.hpp"
#include "graphics/colors.hpp"
#include "mathutil.hpp"
#include "sdl.hpp"

Some files were not shown because too many files have changed in this diff Show More