replace almost all uses of shared_ptr with unique_ptr.

This commit is contained in:
ITotalJustice
2025-06-23 20:02:04 +01:00
parent aa724e12ba
commit 2ff2923d39
37 changed files with 446 additions and 442 deletions

View File

@@ -150,6 +150,7 @@ target_compile_options(sphaira PRIVATE
-Wimplicit-fallthrough=5
-Wsuggest-final-types
-Wuninitialized
-fdiagnostics-all-candidates
)
include(FetchContent)

View File

@@ -58,7 +58,7 @@ public:
static void Exit();
static void ExitRestart();
static auto GetVg() -> NVGcontext*;
static void Push(std::shared_ptr<ui::Widget>);
static void Push(std::unique_ptr<ui::Widget>&&);
// pops all widgets above a menu
static void PopToMenu();
@@ -260,7 +260,7 @@ public:
Vec2 m_scale{1, 1};
std::vector<std::shared_ptr<ui::Widget>> m_widgets;
std::vector<std::unique_ptr<ui::Widget>> m_widgets;
u32 m_pop_count{};
ui::NotifMananger m_notif_manager{};

View File

@@ -55,10 +55,10 @@ using OnExit = std::function<void(Result rc)>;
using OnLocation = std::function<void(const DumpLocation& loc)>;
// prompts the user to select dump location, calls on_loc on success with the selected location.
void DumpGetLocation(const std::string& title, u32 location_flags, OnLocation on_loc);
void DumpGetLocation(const std::string& title, u32 location_flags, const OnLocation& on_loc);
// dumps to a fetched location using DumpGetLocation().
void Dump(std::shared_ptr<BaseSource> source, const DumpLocation& location, const std::vector<fs::FsPath>& paths, OnExit on_exit);
void Dump(const std::shared_ptr<BaseSource>& source, const DumpLocation& location, const std::vector<fs::FsPath>& paths, const OnExit& on_exit);
// DumpGetLocation() + Dump() all in one.
void Dump(std::shared_ptr<BaseSource> source, const std::vector<fs::FsPath>& paths, OnExit on_exit = [](Result){}, u32 location_flags = DumpLocationFlag_All);
void Dump(const std::shared_ptr<BaseSource>& source, const std::vector<fs::FsPath>& paths, const OnExit& on_exit = [](Result){}, u32 location_flags = DumpLocationFlag_All);
} // namespace sphaira::dump

View File

@@ -25,7 +25,7 @@ struct BaseSource {
auto GetTypeStr(Type type) -> const char*;
// returns the hash string.
Result Hash(ui::ProgressBox* pbox, Type type, std::shared_ptr<BaseSource> source, std::string& out);
Result Hash(ui::ProgressBox* pbox, Type type, BaseSource* source, std::string& out);
Result Hash(ui::ProgressBox* pbox, Type type, fs::Fs* fs, const fs::FsPath& path, std::string& out);
Result Hash(ui::ProgressBox* pbox, Type type, std::span<const u8> data, std::string& out);

View File

@@ -60,9 +60,9 @@ void Clear();
// adds new entry to queue.
void PushAsync(u64 app_id);
// gets entry without removing it from the queue.
auto GetAsync(u64 app_id) -> std::shared_ptr<ThreadResultData>;
auto GetAsync(u64 app_id) -> ThreadResultData*;
// single threaded title info fetch.
auto Get(u64 app_id, bool* cached = nullptr) -> std::shared_ptr<ThreadResultData>;
auto Get(u64 app_id, bool* cached = nullptr) -> ThreadResultData*;
auto GetNcmCs(u8 storage_id) -> NcmContentStorage&;
auto GetNcmDb(u8 storage_id) -> NcmContentMetaDatabase&;

View File

@@ -105,9 +105,9 @@ private:
LazyImage m_banner{};
std::unique_ptr<List> m_list{};
std::shared_ptr<ScrollableText> m_details{};
std::shared_ptr<ScrollableText> m_changelog{};
std::shared_ptr<ScrollableText> m_detail_changelog{};
std::unique_ptr<ScrollableText> m_details{};
std::unique_ptr<ScrollableText> m_changelog{};
ScrollableText* m_detail_changelog{};
std::unique_ptr<ScrollableText> m_manifest_list{};
bool m_show_changlog{};

View File

@@ -300,7 +300,7 @@ private:
// contains all selected files for a command, such as copy, delete, cut etc.
struct SelectedStash {
void Add(std::shared_ptr<FsView> view, SelectedType type, const std::vector<FileEntry>& files, const fs::FsPath& path) {
void Add(FsView* view, SelectedType type, const std::vector<FileEntry>& files, const fs::FsPath& path) {
if (files.empty()) {
Reset();
} else {
@@ -335,7 +335,7 @@ struct SelectedStash {
}
// private:
std::shared_ptr<FsView> m_view{};
FsView* m_view{};
std::vector<FileEntry> m_files{};
fs::FsPath m_path{};
SelectedType m_type{SelectedType::None};
@@ -389,9 +389,9 @@ private:
private:
static constexpr inline const char* INI_SECTION = "filebrowser";
std::shared_ptr<FsView> view{};
std::shared_ptr<FsView> view_left{};
std::shared_ptr<FsView> view_right{};
FsView* view{};
std::unique_ptr<FsView> view_left{};
std::unique_ptr<FsView> view_right{};
std::vector<FileAssocEntry> m_assoc_entries{};
SelectedStash m_selected{};

View File

@@ -16,8 +16,6 @@ struct Entry {
NacpLanguageEntry lang{};
int image{};
bool selected{};
std::shared_ptr<title::ThreadResultData> info{};
title::NacpLoadStatus status{title::NacpLoadStatus::None};
auto GetName() const -> const char* {

View File

@@ -55,7 +55,7 @@ protected:
void OnInstallClose();
private:
std::shared_ptr<Stream> m_source{};
std::unique_ptr<Stream> m_source{};
Thread m_thread{};
Mutex m_mutex{};
State m_state{State::None};

View File

@@ -17,7 +17,7 @@ enum class UpdateState {
Error,
};
using MiscMenuFunction = std::function<std::shared_ptr<ui::menu::MenuBase>(u32 flags)>;
using MiscMenuFunction = std::function<std::unique_ptr<MenuBase>(u32 flags)>;
enum MiscMenuFlag : u8 {
// can be set as the rightside menu.
@@ -58,14 +58,14 @@ struct MainMenu final : Widget {
}
private:
void OnLRPress(std::shared_ptr<MenuBase> menu, Button b);
void OnLRPress(MenuBase* menu, Button b);
void AddOnLRPress();
private:
std::shared_ptr<MenuBase> m_centre_menu{};
std::shared_ptr<MenuBase> m_left_menu{};
std::shared_ptr<MenuBase> m_right_menu{};
std::shared_ptr<MenuBase> m_current_menu{};
std::unique_ptr<MenuBase> m_centre_menu{};
std::unique_ptr<MenuBase> m_left_menu{};
std::unique_ptr<MenuBase> m_right_menu{};
MenuBase* m_current_menu{};
std::string m_update_url{};
std::string m_update_version{};

View File

@@ -16,8 +16,6 @@ struct Entry final : FsSaveDataInfo {
NacpLanguageEntry lang{};
int image{};
bool selected{};
std::shared_ptr<title::ThreadResultData> info{};
title::NacpLoadStatus status{title::NacpLoadStatus::None};
auto GetName() const -> const char* {

View File

@@ -31,7 +31,7 @@ struct Menu final : MenuBase {
// this should be private
// private:
std::shared_ptr<yati::source::Usb> m_usb_source{};
std::unique_ptr<yati::source::Usb> m_usb_source{};
bool m_was_mtp_enabled{};
Thread m_thread{};

View File

@@ -95,7 +95,7 @@ private:
class Sidebar final : public Widget {
public:
enum class Side { LEFT, RIGHT };
using Items = std::vector<std::shared_ptr<SidebarEntryBase>>;
using Items = std::vector<std::unique_ptr<SidebarEntryBase>>;
public:
Sidebar(std::string title, Side side, Items&& items);
@@ -108,7 +108,18 @@ public:
auto OnFocusGained() noexcept -> void override;
auto OnFocusLost() noexcept -> void override;
void Add(std::shared_ptr<SidebarEntryBase> entry);
void Add(std::unique_ptr<SidebarEntryBase>&& entry);
template<typename T>
void AddMove(T entry) {
Add(std::move(entry));
}
// template<typename _Tp>
// [[nodiscrad,gnu::always_inline]]
// constexpr typename std::remove_reference<_Tp>::type&&
// move(_Tp&& t) noexcept
// { return static_cast<typename std::remove_reference<_Tp>::type&&>(t); }
private:
void SetIndex(s64 index);

View File

@@ -29,7 +29,7 @@ using Collections = std::vector<CollectionEntry>;
struct Base {
using Source = source::Base;
Base(std::shared_ptr<Source> source) : m_source{source} { }
Base(Source* source) : m_source{source} { }
virtual ~Base() = default;
virtual Result GetCollections(Collections& out) = 0;
auto GetSource() const {
@@ -37,7 +37,7 @@ struct Base {
}
protected:
std::shared_ptr<Source> m_source;
Source* m_source;
};
} // namespace sphaira::yati::container

View File

@@ -79,8 +79,8 @@ struct ConfigOverride {
};
Result InstallFromFile(ui::ProgressBox* pbox, fs::Fs* fs, const fs::FsPath& path, const ConfigOverride& override = {});
Result InstallFromSource(ui::ProgressBox* pbox, std::shared_ptr<source::Base> source, const fs::FsPath& path, const ConfigOverride& override = {});
Result InstallFromContainer(ui::ProgressBox* pbox, std::shared_ptr<container::Base> container, const ConfigOverride& override = {});
Result InstallFromCollections(ui::ProgressBox* pbox, std::shared_ptr<source::Base> source, const container::Collections& collections, const ConfigOverride& override = {});
Result InstallFromSource(ui::ProgressBox* pbox, source::Base* source, const fs::FsPath& path, const ConfigOverride& override = {});
Result InstallFromContainer(ui::ProgressBox* pbox, container::Base* container, const ConfigOverride& override = {});
Result InstallFromCollections(ui::ProgressBox* pbox, source::Base* source, const container::Collections& collections, const ConfigOverride& override = {});
} // namespace sphaira::yati

View File

@@ -51,7 +51,7 @@ constexpr const u8 DEFAULT_IMAGE_DATA[]{
};
void download_default_music() {
App::Push(std::make_shared<ui::ProgressBox>(0, "Downloading "_i18n, "default_music.bfstm", [](auto pbox) -> Result {
App::Push(std::make_unique<ui::ProgressBox>(0, "Downloading "_i18n, "default_music.bfstm", [](auto pbox) -> Result {
const auto result = curl::Api().ToFile(
curl::Url{DEFAULT_MUSIC_URL},
curl::Path{DEFAULT_MUSIC_PATH},
@@ -500,7 +500,7 @@ void App::Loop() {
}
}
auto App::Push(std::shared_ptr<ui::Widget> widget) -> void {
auto App::Push(std::unique_ptr<ui::Widget>&& widget) -> void {
log_write("[Mui] pushing widget\n");
if (!g_app->m_widgets.empty()) {
@@ -508,7 +508,7 @@ auto App::Push(std::shared_ptr<ui::Widget> widget) -> void {
}
log_write("doing focus gained\n");
g_app->m_widgets.emplace_back(widget)->OnFocusGained();
g_app->m_widgets.emplace_back(std::forward<decltype(widget)>(widget))->OnFocusGained();
log_write("did it\n");
}
@@ -570,7 +570,7 @@ void App::NotifyFlashLed() {
Result App::PushErrorBox(Result rc, const std::string& message) {
if (R_FAILED(rc)) {
App::Push(std::make_shared<ui::ErrorBox>(rc, message));
App::Push(std::make_unique<ui::ErrorBox>(rc, message));
}
return rc;
}
@@ -733,7 +733,7 @@ void App::SetReplaceHbmenuEnable(bool enable) {
}
// ask user if they want to restore hbmenu
App::Push(std::make_shared<ui::OptionBox>(
App::Push(std::make_unique<ui::OptionBox>(
"Restore hbmenu?"_i18n,
"Back"_i18n, "Restore"_i18n, 1, [hbmenu_nacp](auto op_index){
if (!op_index || *op_index == 0) {
@@ -742,7 +742,7 @@ void App::SetReplaceHbmenuEnable(bool enable) {
NacpStruct actual_hbmenu_nacp;
if (R_FAILED(nro_get_nacp("/switch/hbmenu.nro", actual_hbmenu_nacp))) {
App::Push(std::make_shared<ui::OptionBox>(
App::Push(std::make_unique<ui::OptionBox>(
"Failed to find /switch/hbmenu.nro\n"
"Use the Appstore to re-install hbmenu"_i18n,
"OK"_i18n
@@ -792,7 +792,7 @@ void App::SetReplaceHbmenuEnable(bool enable) {
"Failed to restore hbmenu, please re-download hbmenu"_i18n
);
} else {
App::Push(std::make_shared<ui::OptionBox>(
App::Push(std::make_unique<ui::OptionBox>(
"Failed to restore hbmenu, using sphaira instead"_i18n,
"OK"_i18n
));
@@ -805,7 +805,7 @@ void App::SetReplaceHbmenuEnable(bool enable) {
// if we were hbmenu, exit now (as romfs is gone).
if (IsHbmenu()) {
App::Push(std::make_shared<ui::OptionBox>(
App::Push(std::make_unique<ui::OptionBox>(
"Restored hbmenu, closing sphaira"_i18n,
"OK"_i18n, [](auto) {
App::Exit();
@@ -872,7 +872,7 @@ void App::SetLanguage(long index) {
g_app->m_language.Set(index);
on_i18n_change();
App::Push(std::make_shared<ui::OptionBox>(
App::Push(std::make_unique<ui::OptionBox>(
"Restart Sphaira?"_i18n,
"Back"_i18n, "Restart"_i18n, 1, [](auto op_index){
if (op_index && *op_index) {
@@ -888,7 +888,7 @@ void App::SetTextScrollSpeed(long index) {
}
auto App::Install(OwoConfig& config) -> Result {
App::Push(std::make_shared<ui::ProgressBox>(0, "Installing Forwarder"_i18n, config.name, [config](auto pbox) mutable -> Result {
App::Push(std::make_unique<ui::ProgressBox>(0, "Installing Forwarder"_i18n, config.name, [config](auto pbox) mutable -> Result {
return Install(pbox, config);
}, [](Result rc){
App::PushErrorBox(rc, "Failed to install forwarder"_i18n);
@@ -1569,7 +1569,7 @@ App::App(const char* argv0) {
// load default image
m_default_image = nvgCreateImageMem(vg, 0, DEFAULT_IMAGE_DATA, std::size(DEFAULT_IMAGE_DATA));
App::Push(std::make_shared<ui::menu::main::MainMenu>());
App::Push(std::make_unique<ui::menu::main::MainMenu>());
log_write("\n\tfinished app constructor, time taken: %.2fs %zums\n\n", ts.GetSecondsD(), ts.GetMs());
}
@@ -1593,25 +1593,25 @@ void App::DisplayThemeOptions(bool left_side) {
theme_items.emplace_back(p.name);
}
auto options = std::make_shared<ui::Sidebar>("Theme Options"_i18n, left_side ? ui::Sidebar::Side::LEFT : ui::Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
auto options = std::make_unique<ui::Sidebar>("Theme Options"_i18n, left_side ? ui::Sidebar::Side::LEFT : ui::Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_shared<ui::SidebarEntryArray>("Select Theme"_i18n, theme_items, [](s64& index_out){
options->Add(std::make_unique<ui::SidebarEntryArray>("Select Theme"_i18n, theme_items, [](s64& index_out){
App::SetTheme(index_out);
}, App::GetThemeIndex()));
options->Add(std::make_shared<ui::SidebarEntryBool>("Music"_i18n, App::GetThemeMusicEnable(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Music"_i18n, App::GetThemeMusicEnable(), [](bool& enable){
App::SetThemeMusicEnable(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("12 Hour Time"_i18n, App::Get12HourTimeEnable(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("12 Hour Time"_i18n, App::Get12HourTimeEnable(), [](bool& enable){
App::Set12HourTimeEnable(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryCallback>("Download Default Music"_i18n, [](){
options->Add(std::make_unique<ui::SidebarEntryCallback>("Download Default Music"_i18n, [](){
// check if we already have music
if (fs::FileExists(DEFAULT_MUSIC_PATH)) {
App::Push(std::make_shared<ui::OptionBox>(
App::Push(std::make_unique<ui::OptionBox>(
"Overwrite current default music?"_i18n,
"No"_i18n, "Yes"_i18n, 0, [](auto op_index){
if (op_index && *op_index) {
@@ -1631,8 +1631,8 @@ void App::DisplayNetworkOptions(bool left_side) {
}
void App::DisplayMiscOptions(bool left_side) {
auto options = std::make_shared<ui::Sidebar>("Misc Options"_i18n, left_side ? ui::Sidebar::Side::LEFT : ui::Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
auto options = std::make_unique<ui::Sidebar>("Misc Options"_i18n, left_side ? ui::Sidebar::Side::LEFT : ui::Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
for (auto& e : ui::menu::main::GetMiscMenuEntries()) {
if (e.name == g_app->m_left_menu.Get()) {
@@ -1643,13 +1643,13 @@ void App::DisplayMiscOptions(bool left_side) {
continue;
}
options->Add(std::make_shared<ui::SidebarEntryCallback>(i18n::get(e.title), [e](){
options->Add(std::make_unique<ui::SidebarEntryCallback>(i18n::get(e.title), [e](){
App::Push(e.func(ui::menu::MenuFlag_None));
}));
}
if (App::IsApplication()) {
options->Add(std::make_shared<ui::SidebarEntryCallback>("Web"_i18n, [](){
options->Add(std::make_unique<ui::SidebarEntryCallback>("Web"_i18n, [](){
// add some default entries, will use a config file soon so users can set their own.
ui::PopupList::Items items;
items.emplace_back("https://lite.duckduckgo.com/lite");
@@ -1658,7 +1658,7 @@ void App::DisplayMiscOptions(bool left_side) {
items.emplace_back("https://github.com/ITotalJustice/sphaira/wiki");
items.emplace_back("Enter custom URL"_i18n);
App::Push(std::make_shared<ui::PopupList>(
App::Push(std::make_unique<ui::PopupList>(
"Select URL"_i18n, items, [items](auto op_index){
if (op_index) {
const auto index = *op_index;
@@ -1678,8 +1678,8 @@ void App::DisplayMiscOptions(bool left_side) {
}
void App::DisplayAdvancedOptions(bool left_side) {
auto options = std::make_shared<ui::Sidebar>("Advanced Options"_i18n, left_side ? ui::Sidebar::Side::LEFT : ui::Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
auto options = std::make_unique<ui::Sidebar>("Advanced Options"_i18n, left_side ? ui::Sidebar::Side::LEFT : ui::Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
ui::SidebarEntryArray::Items text_scroll_speed_items;
text_scroll_speed_items.push_back("Slow"_i18n);
@@ -1701,23 +1701,23 @@ void App::DisplayAdvancedOptions(bool left_side) {
menu_items.push_back(i18n::get(e.name));
}
options->Add(std::make_shared<ui::SidebarEntryBool>("Logging"_i18n, App::GetLogEnable(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Logging"_i18n, App::GetLogEnable(), [](bool& enable){
App::SetLogEnable(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Replace hbmenu on exit"_i18n, App::GetReplaceHbmenuEnable(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Replace hbmenu on exit"_i18n, App::GetReplaceHbmenuEnable(), [](bool& enable){
App::SetReplaceHbmenuEnable(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Boost CPU during transfer"_i18n, App::GetApp()->m_progress_boost_mode.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Boost CPU during transfer"_i18n, App::GetApp()->m_progress_boost_mode.Get(), [](bool& enable){
App::GetApp()->m_progress_boost_mode.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryArray>("Text scroll speed"_i18n, text_scroll_speed_items, [](s64& index_out){
options->Add(std::make_unique<ui::SidebarEntryArray>("Text scroll speed"_i18n, text_scroll_speed_items, [](s64& index_out){
App::SetTextScrollSpeed(index_out);
}, App::GetTextScrollSpeed()));
options->Add(std::make_shared<ui::SidebarEntryArray>("Set left-side menu"_i18n, menu_items, [menu_names](s64& index_out){
options->Add(std::make_unique<ui::SidebarEntryArray>("Set left-side menu"_i18n, menu_items, [menu_names](s64& index_out){
const auto e = menu_names[index_out];
if (g_app->m_left_menu.Get() != e) {
// swap menus around.
@@ -1726,7 +1726,7 @@ void App::DisplayAdvancedOptions(bool left_side) {
}
g_app->m_left_menu.Set(e);
App::Push(std::make_shared<ui::OptionBox>(
App::Push(std::make_unique<ui::OptionBox>(
"Press OK to restart Sphaira"_i18n, "OK"_i18n, [](auto){
App::ExitRestart();
}
@@ -1734,7 +1734,7 @@ void App::DisplayAdvancedOptions(bool left_side) {
}
}, i18n::get(g_app->m_left_menu.Get())));
options->Add(std::make_shared<ui::SidebarEntryArray>("Set right-side menu"_i18n, menu_items, [menu_names](s64& index_out){
options->Add(std::make_unique<ui::SidebarEntryArray>("Set right-side menu"_i18n, menu_items, [menu_names](s64& index_out){
const auto e = menu_names[index_out];
if (g_app->m_right_menu.Get() != e) {
// swap menus around.
@@ -1743,7 +1743,7 @@ void App::DisplayAdvancedOptions(bool left_side) {
}
g_app->m_right_menu.Set(e);
App::Push(std::make_shared<ui::OptionBox>(
App::Push(std::make_unique<ui::OptionBox>(
"Press OK to restart Sphaira"_i18n, "OK"_i18n, [](auto){
App::ExitRestart();
}
@@ -1751,129 +1751,129 @@ void App::DisplayAdvancedOptions(bool left_side) {
}
}, i18n::get(g_app->m_right_menu.Get())));
options->Add(std::make_shared<ui::SidebarEntryCallback>("Install options"_i18n, [left_side](){
options->Add(std::make_unique<ui::SidebarEntryCallback>("Install options"_i18n, [left_side](){
App::DisplayInstallOptions(left_side);
}));
options->Add(std::make_shared<ui::SidebarEntryCallback>("Dump options"_i18n, [left_side](){
options->Add(std::make_unique<ui::SidebarEntryCallback>("Dump options"_i18n, [left_side](){
App::DisplayDumpOptions(left_side);
}));
}
void App::DisplayInstallOptions(bool left_side) {
auto options = std::make_shared<ui::Sidebar>("Install Options"_i18n, left_side ? ui::Sidebar::Side::LEFT : ui::Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
auto options = std::make_unique<ui::Sidebar>("Install Options"_i18n, left_side ? ui::Sidebar::Side::LEFT : ui::Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
ui::SidebarEntryArray::Items install_items;
install_items.push_back("System memory"_i18n);
install_items.push_back("microSD card"_i18n);
options->Add(std::make_shared<ui::SidebarEntryBool>("Enable sysmmc"_i18n, App::GetInstallSysmmcEnable(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Enable sysmmc"_i18n, App::GetInstallSysmmcEnable(), [](bool& enable){
App::SetInstallSysmmcEnable(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Enable emummc"_i18n, App::GetInstallEmummcEnable(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Enable emummc"_i18n, App::GetInstallEmummcEnable(), [](bool& enable){
App::SetInstallEmummcEnable(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Show install warning"_i18n, App::GetApp()->m_install_prompt.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Show install warning"_i18n, App::GetApp()->m_install_prompt.Get(), [](bool& enable){
App::GetApp()->m_install_prompt.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryArray>("Install location"_i18n, install_items, [](s64& index_out){
options->Add(std::make_unique<ui::SidebarEntryArray>("Install location"_i18n, install_items, [](s64& index_out){
App::SetInstallSdEnable(index_out);
}, (s64)App::GetInstallSdEnable()));
options->Add(std::make_shared<ui::SidebarEntryBool>("Allow downgrade"_i18n, App::GetApp()->m_allow_downgrade.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Allow downgrade"_i18n, App::GetApp()->m_allow_downgrade.Get(), [](bool& enable){
App::GetApp()->m_allow_downgrade.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Skip if already installed"_i18n, App::GetApp()->m_skip_if_already_installed.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Skip if already installed"_i18n, App::GetApp()->m_skip_if_already_installed.Get(), [](bool& enable){
App::GetApp()->m_skip_if_already_installed.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Ticket only"_i18n, App::GetApp()->m_ticket_only.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Ticket only"_i18n, App::GetApp()->m_ticket_only.Get(), [](bool& enable){
App::GetApp()->m_ticket_only.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Skip base"_i18n, App::GetApp()->m_skip_base.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Skip base"_i18n, App::GetApp()->m_skip_base.Get(), [](bool& enable){
App::GetApp()->m_skip_base.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Skip patch"_i18n, App::GetApp()->m_skip_patch.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Skip patch"_i18n, App::GetApp()->m_skip_patch.Get(), [](bool& enable){
App::GetApp()->m_skip_patch.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Skip dlc"_i18n, App::GetApp()->m_skip_addon.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Skip dlc"_i18n, App::GetApp()->m_skip_addon.Get(), [](bool& enable){
App::GetApp()->m_skip_addon.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Skip data patch"_i18n, App::GetApp()->m_skip_data_patch.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Skip data patch"_i18n, App::GetApp()->m_skip_data_patch.Get(), [](bool& enable){
App::GetApp()->m_skip_data_patch.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Skip ticket"_i18n, App::GetApp()->m_skip_ticket.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Skip ticket"_i18n, App::GetApp()->m_skip_ticket.Get(), [](bool& enable){
App::GetApp()->m_skip_ticket.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Skip NCA hash verify"_i18n, App::GetApp()->m_skip_nca_hash_verify.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Skip NCA hash verify"_i18n, App::GetApp()->m_skip_nca_hash_verify.Get(), [](bool& enable){
App::GetApp()->m_skip_nca_hash_verify.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Skip RSA header verify"_i18n, App::GetApp()->m_skip_rsa_header_fixed_key_verify.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Skip RSA header verify"_i18n, App::GetApp()->m_skip_rsa_header_fixed_key_verify.Get(), [](bool& enable){
App::GetApp()->m_skip_rsa_header_fixed_key_verify.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Skip RSA NPDM verify"_i18n, App::GetApp()->m_skip_rsa_npdm_fixed_key_verify.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Skip RSA NPDM verify"_i18n, App::GetApp()->m_skip_rsa_npdm_fixed_key_verify.Get(), [](bool& enable){
App::GetApp()->m_skip_rsa_npdm_fixed_key_verify.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Ignore distribution bit"_i18n, App::GetApp()->m_ignore_distribution_bit.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Ignore distribution bit"_i18n, App::GetApp()->m_ignore_distribution_bit.Get(), [](bool& enable){
App::GetApp()->m_ignore_distribution_bit.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Convert to common ticket"_i18n, App::GetApp()->m_convert_to_common_ticket.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Convert to common ticket"_i18n, App::GetApp()->m_convert_to_common_ticket.Get(), [](bool& enable){
App::GetApp()->m_convert_to_common_ticket.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Convert to standard crypto"_i18n, App::GetApp()->m_convert_to_standard_crypto.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Convert to standard crypto"_i18n, App::GetApp()->m_convert_to_standard_crypto.Get(), [](bool& enable){
App::GetApp()->m_convert_to_standard_crypto.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Lower master key"_i18n, App::GetApp()->m_lower_master_key.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Lower master key"_i18n, App::GetApp()->m_lower_master_key.Get(), [](bool& enable){
App::GetApp()->m_lower_master_key.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Lower system version"_i18n, App::GetApp()->m_lower_system_version.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Lower system version"_i18n, App::GetApp()->m_lower_system_version.Get(), [](bool& enable){
App::GetApp()->m_lower_system_version.Set(enable);
}));
}
void App::DisplayDumpOptions(bool left_side) {
auto options = std::make_shared<ui::Sidebar>("Dump Options"_i18n, left_side ? ui::Sidebar::Side::LEFT : ui::Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
auto options = std::make_unique<ui::Sidebar>("Dump Options"_i18n, left_side ? ui::Sidebar::Side::LEFT : ui::Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_shared<ui::SidebarEntryBool>("Created nested folder"_i18n, App::GetApp()->m_dump_app_folder.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Created nested folder"_i18n, App::GetApp()->m_dump_app_folder.Get(), [](bool& enable){
App::GetApp()->m_dump_app_folder.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Append folder with .xci"_i18n, App::GetApp()->m_dump_append_folder_with_xci.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Append folder with .xci"_i18n, App::GetApp()->m_dump_append_folder_with_xci.Get(), [](bool& enable){
App::GetApp()->m_dump_append_folder_with_xci.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Trim XCI"_i18n, App::GetApp()->m_dump_trim_xci.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Trim XCI"_i18n, App::GetApp()->m_dump_trim_xci.Get(), [](bool& enable){
App::GetApp()->m_dump_trim_xci.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Label trimmed XCI"_i18n, App::GetApp()->m_dump_label_trim_xci.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Label trimmed XCI"_i18n, App::GetApp()->m_dump_label_trim_xci.Get(), [](bool& enable){
App::GetApp()->m_dump_label_trim_xci.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Multi-threaded USB transfer"_i18n, App::GetApp()->m_dump_usb_transfer_stream.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Multi-threaded USB transfer"_i18n, App::GetApp()->m_dump_usb_transfer_stream.Get(), [](bool& enable){
App::GetApp()->m_dump_usb_transfer_stream.Set(enable);
}));
options->Add(std::make_shared<ui::SidebarEntryBool>("Convert to common ticket"_i18n, App::GetApp()->m_dump_convert_to_common_ticket.Get(), [](bool& enable){
options->Add(std::make_unique<ui::SidebarEntryBool>("Convert to common ticket"_i18n, App::GetApp()->m_dump_convert_to_common_ticket.Get(), [](bool& enable){
App::GetApp()->m_dump_convert_to_common_ticket.Set(enable);
}));
}

View File

@@ -314,7 +314,7 @@ Result DumpToNetwork(ui::ProgressBox* pbox, const location::Entry& loc, BaseSour
} // namespace
void DumpGetLocation(const std::string& title, u32 location_flags, OnLocation on_loc) {
void DumpGetLocation(const std::string& title, u32 location_flags, const OnLocation& on_loc) {
DumpLocation out;
ui::PopupList::Items items;
std::vector<DumpEntry> dump_entries;
@@ -342,7 +342,7 @@ void DumpGetLocation(const std::string& title, u32 location_flags, OnLocation on
}
}
App::Push(std::make_shared<ui::PopupList>(
App::Push(std::make_unique<ui::PopupList>(
title, items, [dump_entries, out, on_loc](auto op_index) mutable {
out.entry = dump_entries[*op_index];
on_loc(out);
@@ -350,8 +350,8 @@ void DumpGetLocation(const std::string& title, u32 location_flags, OnLocation on
));
}
void Dump(std::shared_ptr<BaseSource> source, const DumpLocation& location, const std::vector<fs::FsPath>& paths, OnExit on_exit) {
App::Push(std::make_shared<ui::ProgressBox>(0, "Dumping"_i18n, "", [source, paths, location](auto pbox) -> Result {
void Dump(const std::shared_ptr<BaseSource>& source, const DumpLocation& location, const std::vector<fs::FsPath>& paths, const OnExit& on_exit) {
App::Push(std::make_unique<ui::ProgressBox>(0, "Dumping"_i18n, "", [source, paths, location](auto pbox) -> Result {
if (location.entry.type == DumpLocationType_Network) {
R_TRY(DumpToNetwork(pbox, location.network[location.entry.index], source.get(), paths));
} else if (location.entry.type == DumpLocationType_Stdio) {
@@ -377,8 +377,8 @@ void Dump(std::shared_ptr<BaseSource> source, const DumpLocation& location, cons
}));
}
void Dump(std::shared_ptr<BaseSource> source, const std::vector<fs::FsPath>& paths, OnExit on_exit, u32 location_flags) {
DumpGetLocation("Select dump location"_i18n, location_flags, [source, paths, on_exit](const DumpLocation& loc){
void Dump(const std::shared_ptr<BaseSource>& source, const std::vector<fs::FsPath>& paths, const OnExit& on_exit, u32 location_flags) {
DumpGetLocation("Select dump location"_i18n, location_flags, [source, paths, on_exit](const DumpLocation& loc) {
Dump(source, loc, paths, on_exit);
});
}

View File

@@ -156,7 +156,7 @@ private:
Sha256Context m_ctx{};
};
Result Hash(ui::ProgressBox* pbox, std::unique_ptr<HashSource> hash, std::shared_ptr<BaseSource> source, std::string& out) {
Result Hash(ui::ProgressBox* pbox, std::unique_ptr<HashSource> hash, BaseSource* source, std::string& out) {
s64 file_size;
R_TRY(source->Size(&file_size));
@@ -186,7 +186,7 @@ auto GetTypeStr(Type type) -> const char* {
return "";
}
Result Hash(ui::ProgressBox* pbox, Type type, std::shared_ptr<BaseSource> source, std::string& out) {
Result Hash(ui::ProgressBox* pbox, Type type, BaseSource* source, std::string& out) {
switch (type) {
case Type::Crc32: return Hash(pbox, std::make_unique<HashCrc32>(), source, out);
case Type::Md5: return Hash(pbox, std::make_unique<HashMd5>(), source, out);
@@ -197,13 +197,13 @@ Result Hash(ui::ProgressBox* pbox, Type type, std::shared_ptr<BaseSource> source
}
Result Hash(ui::ProgressBox* pbox, Type type, fs::Fs* fs, const fs::FsPath& path, std::string& out) {
auto source = std::make_shared<FileSource>(fs, path);
return Hash(pbox, type, source, out);
auto source = std::make_unique<FileSource>(fs, path);
return Hash(pbox, type, source.get(), out);
}
Result Hash(ui::ProgressBox* pbox, Type type, std::span<const u8> data, std::string& out) {
auto source = std::make_shared<MemSource>(data);
return Hash(pbox, type, source, out);
auto source = std::make_unique<MemSource>(data);
return Hash(pbox, type, source.get(), out);
}
} // namespace sphaira::has

View File

@@ -87,8 +87,9 @@ protected:
};
struct FsProxy final : FsProxyBase {
FsProxy(std::shared_ptr<fs::Fs> fs, const char* name, const char* display_name) : FsProxyBase{name, display_name} {
m_fs = fs;
FsProxy(std::unique_ptr<fs::Fs>&& fs, const char* name, const char* display_name)
: FsProxyBase{name, display_name}
, m_fs{std::forward<decltype(fs)>(fs)} {
}
~FsProxy() {
@@ -229,7 +230,7 @@ struct FsProxy final : FsProxyBase {
}
private:
std::shared_ptr<fs::Fs> m_fs{};
std::unique_ptr<fs::Fs> m_fs{};
};
// fake fs that allows for files to create r/w on the root.
@@ -558,9 +559,9 @@ bool Init() {
return false;
}
g_fs_entries.emplace_back(std::make_shared<FsProxy>(std::make_shared<fs::FsNativeSd>(), "", "microSD card"));
g_fs_entries.emplace_back(std::make_shared<FsProxy>(std::make_shared<fs::FsNativeImage>(FsImageDirectoryId_Nand), "image_nand", "Image nand"));
g_fs_entries.emplace_back(std::make_shared<FsProxy>(std::make_shared<fs::FsNativeImage>(FsImageDirectoryId_Sd), "image_sd", "Image sd"));
g_fs_entries.emplace_back(std::make_shared<FsProxy>(std::make_unique<fs::FsNativeSd>(), "", "microSD card"));
g_fs_entries.emplace_back(std::make_shared<FsProxy>(std::make_unique<fs::FsNativeImage>(FsImageDirectoryId_Nand), "image_nand", "Image nand"));
g_fs_entries.emplace_back(std::make_shared<FsProxy>(std::make_unique<fs::FsNativeImage>(FsImageDirectoryId_Sd), "image_sd", "Image sd"));
g_fs_entries.emplace_back(std::make_shared<FsDevNullProxy>("DevNull", "DevNull (Speed Test)"));
g_fs_entries.emplace_back(std::make_shared<FsInstallProxy>("install", "Install (NSP, XCI, NSZ, XCZ)"));

View File

@@ -1020,7 +1020,7 @@ auto install_forwarder(ui::ProgressBox* pbox, OwoConfig& config, NcmStorageId st
}
auto install_forwarder(OwoConfig& config, NcmStorageId storage_id) -> Result {
App::Push(std::make_shared<ui::ProgressBox>(0, "Installing Forwarder"_i18n, config.name, [config, storage_id](auto pbox) mutable -> Result {
App::Push(std::make_unique<ui::ProgressBox>(0, "Installing Forwarder"_i18n, config.name, [config, storage_id](auto pbox) mutable -> Result {
return install_forwarder(pbox, config, storage_id);
}));
R_SUCCEED();

View File

@@ -28,8 +28,8 @@ struct ThreadData {
void Clear();
void PushAsync(u64 id);
auto GetAsync(u64 app_id) -> std::shared_ptr<ThreadResultData>;
auto Get(u64 app_id, bool* cached = nullptr) -> std::shared_ptr<ThreadResultData>;
auto GetAsync(u64 app_id) -> ThreadResultData*;
auto Get(u64 app_id, bool* cached = nullptr) -> ThreadResultData*;
auto IsRunning() const -> bool {
return m_running;
@@ -49,7 +49,7 @@ private:
// app_ids pushed to the queue, signal uevent when pushed.
std::vector<u64> m_ids{};
// control data pushed to the queue.
std::vector<std::shared_ptr<ThreadResultData>> m_result{};
std::vector<std::unique_ptr<ThreadResultData>> m_result{};
std::atomic_bool m_running{};
};
@@ -109,14 +109,14 @@ auto& GetNcmEntry(u8 storage_id) {
}
// also sets the status to error.
void FakeNacpEntry(std::shared_ptr<ThreadResultData>& e) {
void FakeNacpEntry(ThreadResultData* e) {
e->status = NacpLoadStatus::Error;
// fake the nacp entry
std::strcpy(e->lang.name, "Corrupted");
std::strcpy(e->lang.author, "Corrupted");
}
Result LoadControlManual(u64 id, NacpStruct& nacp, std::shared_ptr<ThreadResultData>& data) {
Result LoadControlManual(u64 id, NacpStruct& nacp, ThreadResultData* data) {
TimeStamp ts;
MetaEntries entries;
@@ -208,19 +208,19 @@ void ThreadData::PushAsync(u64 id) {
}
}
auto ThreadData::GetAsync(u64 app_id) -> std::shared_ptr<ThreadResultData> {
auto ThreadData::GetAsync(u64 app_id) -> ThreadResultData* {
SCOPED_MUTEX(&m_mutex_result);
for (s64 i = 0; i < std::size(m_result); i++) {
if (app_id == m_result[i]->id) {
return m_result[i];
return m_result[i].get();
}
}
return {};
}
auto ThreadData::Get(u64 app_id, bool* cached) -> std::shared_ptr<ThreadResultData> {
auto ThreadData::Get(u64 app_id, bool* cached) -> ThreadResultData* {
// try and fetch from results first, before manually loading.
if (auto data = GetAsync(app_id)) {
if (cached) {
@@ -230,7 +230,7 @@ auto ThreadData::Get(u64 app_id, bool* cached) -> std::shared_ptr<ThreadResultDa
}
TimeStamp ts;
auto result = std::make_shared<ThreadResultData>(app_id);
auto result = std::make_unique<ThreadResultData>(app_id);
result->status = NacpLoadStatus::Error;
if (auto data = nxtcGetApplicationMetadataEntryById(app_id)) {
@@ -264,7 +264,7 @@ auto ThreadData::Get(u64 app_id, bool* cached) -> std::shared_ptr<ThreadResultDa
}
if (manual_load) {
manual_load = R_SUCCEEDED(LoadControlManual(app_id, control->nacp, result));
manual_load = R_SUCCEEDED(LoadControlManual(app_id, control->nacp, result.get()));
}
Result rc{};
@@ -276,14 +276,14 @@ auto ThreadData::Get(u64 app_id, bool* cached) -> std::shared_ptr<ThreadResultDa
}
if (R_FAILED(rc)) {
FakeNacpEntry(result);
FakeNacpEntry(result.get());
} else {
bool valid = true;
NacpLanguageEntry* lang;
if (R_SUCCEEDED(nsGetApplicationDesiredLanguage(&control->nacp, &lang))) {
result->lang = *lang;
} else {
FakeNacpEntry(result);
FakeNacpEntry(result.get());
valid = false;
}
@@ -350,8 +350,7 @@ auto ThreadData::Get(u64 app_id, bool* cached) -> std::shared_ptr<ThreadResultDa
}
SCOPED_MUTEX(&m_mutex_result);
m_result.emplace_back(result);
return result;
return m_result.emplace_back(std::move(result)).get();
}
void ThreadFunc(void* user) {
@@ -429,7 +428,7 @@ void PushAsync(u64 app_id) {
}
}
auto GetAsync(u64 app_id) -> std::shared_ptr<ThreadResultData> {
auto GetAsync(u64 app_id) -> ThreadResultData* {
SCOPED_MUTEX(&g_mutex);
if (g_thread_data) {
return g_thread_data->GetAsync(app_id);
@@ -437,7 +436,7 @@ auto GetAsync(u64 app_id) -> std::shared_ptr<ThreadResultData> {
return {};
}
auto Get(u64 app_id, bool* cached) -> std::shared_ptr<ThreadResultData> {
auto Get(u64 app_id, bool* cached) -> ThreadResultData* {
SCOPED_MUTEX(&g_mutex);
if (g_thread_data) {
return g_thread_data->Get(app_id, cached);

View File

@@ -587,15 +587,15 @@ EntryMenu::EntryMenu(Entry& entry, const LazyImage& default_icon, Menu& menu)
}
}}),
std::make_pair(Button::X, Action{"Options"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
auto options = std::make_unique<Sidebar>("Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_shared<SidebarEntryCallback>("More by Author"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("More by Author"_i18n, [this](){
m_menu.SetAuthor();
SetPop();
}, true));
options->Add(std::make_shared<SidebarEntryCallback>("Leave Feedback"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Leave Feedback"_i18n, [this](){
std::string out;
if (R_SUCCEEDED(swkbd::ShowText(out)) && !out.empty()) {
const auto post = "name=" "switch_user" "&package=" + m_entry.name + "&message=" + out;
@@ -618,7 +618,7 @@ EntryMenu::EntryMenu(Entry& entry, const LazyImage& default_icon, Menu& menu)
}, true));
if (App::IsApplication() && !m_entry.url.empty()) {
options->Add(std::make_shared<SidebarEntryCallback>("Visit Website"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Visit Website"_i18n, [this](){
WebShow(m_entry.url);
}));
}
@@ -659,8 +659,8 @@ EntryMenu::EntryMenu(Entry& entry, const LazyImage& default_icon, Menu& menu)
SetTitleSubHeading("by " + m_entry.author);
m_details = std::make_shared<ScrollableText>(m_entry.details, 0, 374, 250, 768, 18);
m_changelog = std::make_shared<ScrollableText>(m_entry.changelog, 0, 374, 250, 768, 18);
m_details = std::make_unique<ScrollableText>(m_entry.details, 0, 374, 250, 768, 18);
m_changelog = std::make_unique<ScrollableText>(m_entry.changelog, 0, 374, 250, 768, 18);
m_show_changlog ^= 1;
ShowChangelogAction();
@@ -781,13 +781,12 @@ void EntryMenu::ShowChangelogAction() {
m_show_changlog ^= 1;
m_show_file_list = false;
if (m_show_changlog) {
SetAction(Button::L, Action{"Details"_i18n, func});
m_detail_changelog = m_changelog;
m_detail_changelog = m_changelog.get();
} else {
SetAction(Button::L, Action{"Changelog"_i18n, func});
m_detail_changelog = m_details;
m_detail_changelog = m_details.get();
}
}
@@ -797,7 +796,7 @@ void EntryMenu::UpdateOptions() {
};
const auto install = [this](){
App::Push(std::make_shared<ProgressBox>(m_entry.image.image, "Downloading "_i18n, m_entry.title, [this](auto pbox){
App::Push(std::make_unique<ProgressBox>(m_entry.image.image, "Downloading "_i18n, m_entry.title, [this](auto pbox){
return InstallApp(pbox, m_entry);
}, [this](Result rc){
homebrew::SignalChange();
@@ -813,7 +812,7 @@ void EntryMenu::UpdateOptions() {
};
const auto uninstall = [this](){
App::Push(std::make_shared<ProgressBox>(m_entry.image.image, "Uninstalling "_i18n, m_entry.title, [this](auto pbox){
App::Push(std::make_unique<ProgressBox>(m_entry.image.image, "Uninstalling "_i18n, m_entry.title, [this](auto pbox){
return UninstallApp(pbox, m_entry);
}, [this](Result rc){
homebrew::SignalChange();
@@ -866,7 +865,7 @@ void EntryMenu::SetIndex(s64 index) {
SetAction(Button::A, Action{option.display_text, option.func});
} else {
SetAction(Button::A, Action{option.display_text, [this, option](){
App::Push(std::make_shared<OptionBox>(option.confirm_text, "No"_i18n, "Yes"_i18n, 1, [this, option](auto op_index){
App::Push(std::make_unique<OptionBox>(option.confirm_text, "No"_i18n, "Yes"_i18n, 1, [this, option](auto op_index){
if (op_index && *op_index) {
option.func();
}
@@ -916,11 +915,11 @@ Menu::Menu(u32 flags) : grid::Menu{"AppStore"_i18n, flags} {
// log_write("pushing A when empty: size: %zu count: %zu\n", repo_json.size(), m_entries_current.size());
return;
}
App::Push(std::make_shared<EntryMenu>(m_entries[m_entries_current[m_index]], m_default_image, *this));
App::Push(std::make_unique<EntryMenu>(m_entries[m_entries_current[m_index]], m_default_image, *this));
}}),
std::make_pair(Button::X, Action{"Options"_i18n, [this](){
auto options = std::make_shared<Sidebar>("AppStore Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
auto options = std::make_unique<Sidebar>("AppStore Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
SidebarEntryArray::Items filter_items;
filter_items.push_back("All"_i18n);
@@ -947,27 +946,27 @@ Menu::Menu(u32 flags) : grid::Menu{"AppStore"_i18n, flags} {
layout_items.push_back("Icon"_i18n);
layout_items.push_back("Grid"_i18n);
options->Add(std::make_shared<SidebarEntryArray>("Filter"_i18n, filter_items, [this](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Filter"_i18n, filter_items, [this](s64& index_out){
m_filter.Set(index_out);
SetFilter();
}, m_filter.Get()));
options->Add(std::make_shared<SidebarEntryArray>("Sort"_i18n, sort_items, [this](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Sort"_i18n, sort_items, [this](s64& index_out){
m_sort.Set(index_out);
SortAndFindLastFile();
}, m_sort.Get()));
options->Add(std::make_shared<SidebarEntryArray>("Order"_i18n, order_items, [this](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Order"_i18n, order_items, [this](s64& index_out){
m_order.Set(index_out);
SortAndFindLastFile();
}, m_order.Get()));
options->Add(std::make_shared<SidebarEntryArray>("Layout"_i18n, layout_items, [this](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Layout"_i18n, layout_items, [this](s64& index_out){
m_layout.Set(index_out);
OnLayoutChange();
}, m_layout.Get()));
options->Add(std::make_shared<SidebarEntryCallback>("Search"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Search"_i18n, [this](){
std::string out;
if (R_SUCCEEDED(swkbd::ShowText(out)) && !out.empty()) {
SetSearch(out);

View File

@@ -332,7 +332,7 @@ FsView::FsView(Menu* menu, const fs::FsPath& path, const FsEntry& entry, ViewSid
}
if (IsSd() && m_is_update_folder && m_daybreak_path.has_value()) {
App::Push(std::make_shared<OptionBox>("Open with DayBreak?"_i18n, "No"_i18n, "Yes"_i18n, 1, [this](auto op_index){
App::Push(std::make_unique<OptionBox>("Open with DayBreak?"_i18n, "No"_i18n, "Yes"_i18n, 1, [this](auto op_index){
if (op_index && *op_index) {
// daybreak uses native fs so do not use nro_add_arg_file
// otherwise it'll fail to open the folder...
@@ -349,7 +349,7 @@ FsView::FsView(Menu* menu, const fs::FsPath& path, const FsEntry& entry, ViewSid
} else {
// special case for nro
if (IsSd() && entry.GetExtension() == "nro") {
App::Push(std::make_shared<OptionBox>("Launch "_i18n + entry.GetName() + '?',
App::Push(std::make_unique<OptionBox>("Launch "_i18n + entry.GetName() + '?',
"No"_i18n, "Launch"_i18n, 1, [this](auto op_index){
if (op_index && *op_index) {
nro_launch(GetNewPathCurrent());
@@ -370,7 +370,7 @@ FsView::FsView(Menu* menu, const fs::FsPath& path, const FsEntry& entry, ViewSid
}
const auto title = "Launch option for: "_i18n + GetEntry().name;
App::Push(std::make_shared<PopupList>(
App::Push(std::make_unique<PopupList>(
title, items, [this, assoc_list](auto op_index){
if (op_index) {
log_write("selected: %s\n", assoc_list[*op_index].name.c_str());
@@ -642,12 +642,12 @@ void FsView::InstallForwarder() {
}
const auto title = std::string{"Select launcher for: "_i18n} + GetEntry().name;
App::Push(std::make_shared<PopupList>(
App::Push(std::make_unique<PopupList>(
title, items, [this, assoc_list](auto op_index){
if (op_index) {
const auto assoc = assoc_list[*op_index];
log_write("pushing it\n");
App::Push(std::make_shared<ProgressBox>(0, "Installing Forwarder"_i18n, GetEntry().name, [assoc, this](auto pbox) -> Result {
App::Push(std::make_unique<ProgressBox>(0, "Installing Forwarder"_i18n, GetEntry().name, [assoc, this](auto pbox) -> Result {
log_write("inside callback\n");
NroEntry nro{};
@@ -701,11 +701,11 @@ void FsView::InstallForwarder() {
void FsView::InstallFiles() {
const auto targets = GetSelectedEntries();
App::Push(std::make_shared<OptionBox>("Install Selected files?"_i18n, "No"_i18n, "Yes"_i18n, 0, [this, targets](auto op_index){
App::Push(std::make_unique<OptionBox>("Install Selected files?"_i18n, "No"_i18n, "Yes"_i18n, 0, [this, targets](auto op_index){
if (op_index && *op_index) {
App::PopToMenu();
App::Push(std::make_shared<ui::ProgressBox>(0, "Installing "_i18n, "", [this, targets](auto pbox) -> Result {
App::Push(std::make_unique<ui::ProgressBox>(0, "Installing "_i18n, "", [this, targets](auto pbox) -> Result {
for (auto& e : targets) {
R_TRY(yati::InstallFromFile(pbox, m_fs.get(), GetNewPath(e)));
App::Notify("Installed "_i18n + e.GetName());
@@ -727,7 +727,7 @@ void FsView::UnzipFiles(fs::FsPath dir_path) {
dir_path = m_path;
}
App::Push(std::make_shared<ui::ProgressBox>(0, "Extracting "_i18n, "", [this, dir_path, targets](auto pbox) -> Result {
App::Push(std::make_unique<ui::ProgressBox>(0, "Extracting "_i18n, "", [this, dir_path, targets](auto pbox) -> Result {
const auto is_hdd_fs = m_fs->Root().starts_with("ums");
for (auto& e : targets) {
@@ -785,7 +785,7 @@ void FsView::ZipFiles(fs::FsPath zip_out) {
}
}
App::Push(std::make_shared<ui::ProgressBox>(0, "Compressing "_i18n, "", [this, zip_out, targets](auto pbox) -> Result {
App::Push(std::make_unique<ui::ProgressBox>(0, "Compressing "_i18n, "", [this, zip_out, targets](auto pbox) -> Result {
const auto t = std::time(NULL);
const auto tm = std::localtime(&t);
const auto is_hdd_fs = m_fs->Root().starts_with("ums");
@@ -876,14 +876,14 @@ void FsView::UploadFiles() {
items.emplace_back(p.name);
}
App::Push(std::make_shared<PopupList>(
App::Push(std::make_unique<PopupList>(
"Select upload location"_i18n, items, [this, network_locations](auto op_index){
if (!op_index) {
return;
}
const auto loc = network_locations[*op_index];
App::Push(std::make_shared<ProgressBox>(0, "Uploading"_i18n, "", [this, loc](auto pbox) -> Result {
App::Push(std::make_unique<ProgressBox>(0, "Uploading"_i18n, "", [this, loc](auto pbox) -> Result {
auto targets = GetSelectedEntries();
const auto is_file_based_emummc = App::IsFileBaseEmummc();
@@ -1166,7 +1166,7 @@ void FsView::OnDeleteCallback() {
m_menu->RefreshViews();
log_write("did delete\n");
} else {
App::Push(std::make_shared<ProgressBox>(0, "Deleting"_i18n, "", [this](auto pbox) -> Result {
App::Push(std::make_unique<ProgressBox>(0, "Deleting"_i18n, "", [this](auto pbox) -> Result {
FsDirCollections collections;
auto& selected = m_menu->m_selected;
auto src_fs = selected.m_view->GetFs();
@@ -1207,7 +1207,7 @@ void FsView::OnPasteCallback() {
m_menu->RefreshViews();
} else {
App::Push(std::make_shared<ProgressBox>(0, "Pasting"_i18n, "", [this](auto pbox) -> Result {
App::Push(std::make_unique<ProgressBox>(0, "Pasting"_i18n, "", [this](auto pbox) -> Result {
auto& selected = m_menu->m_selected;
auto src_fs = selected.m_view->GetFs();
const auto is_same_fs = selected.SameFs(this);
@@ -1530,7 +1530,7 @@ void FsView::DisplayHash(hash::Type type) {
static std::string hash_out;
hash_out.clear();
App::Push(std::make_shared<ProgressBox>(0, "Hashing"_i18n, GetEntry().name, [this, type](auto pbox) -> Result {
App::Push(std::make_unique<ProgressBox>(0, "Hashing"_i18n, GetEntry().name, [this, type](auto pbox) -> Result {
const auto full_path = GetNewPathCurrent();
pbox->NewTransfer(full_path);
R_TRY(hash::Hash(pbox, type, m_fs.get(), full_path, hash_out));
@@ -1543,18 +1543,18 @@ void FsView::DisplayHash(hash::Type type) {
char buf[0x100];
// std::snprintf(buf, sizeof(buf), "%s\n%s\n%s", hash::GetTypeStr(type), hash_out.c_str(), GetEntry().GetName());
std::snprintf(buf, sizeof(buf), "%s\n%s", hash::GetTypeStr(type), hash_out.c_str());
App::Push(std::make_shared<OptionBox>(buf, "OK"_i18n));
App::Push(std::make_unique<OptionBox>(buf, "OK"_i18n));
}
}));
}
void FsView::DisplayOptions() {
auto options = std::make_shared<Sidebar>("File Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
auto options = std::make_unique<Sidebar>("File Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_shared<SidebarEntryCallback>("Sort By"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Sort Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
options->Add(std::make_unique<SidebarEntryCallback>("Sort By"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Sort Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
SidebarEntryArray::Items sort_items;
sort_items.push_back("Size"_i18n);
@@ -1564,46 +1564,46 @@ void FsView::DisplayOptions() {
order_items.push_back("Descending"_i18n);
order_items.push_back("Ascending"_i18n);
options->Add(std::make_shared<SidebarEntryArray>("Sort"_i18n, sort_items, [this](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Sort"_i18n, sort_items, [this](s64& index_out){
m_menu->m_sort.Set(index_out);
SortAndFindLastFile();
}, m_menu->m_sort.Get()));
options->Add(std::make_shared<SidebarEntryArray>("Order"_i18n, order_items, [this](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Order"_i18n, order_items, [this](s64& index_out){
m_menu->m_order.Set(index_out);
SortAndFindLastFile();
}, m_menu->m_order.Get()));
options->Add(std::make_shared<SidebarEntryBool>("Show Hidden"_i18n, m_menu->m_show_hidden.Get(), [this](bool& v_out){
options->Add(std::make_unique<SidebarEntryBool>("Show Hidden"_i18n, m_menu->m_show_hidden.Get(), [this](bool& v_out){
m_menu->m_show_hidden.Set(v_out);
SortAndFindLastFile();
}));
options->Add(std::make_shared<SidebarEntryBool>("Folders First"_i18n, m_menu->m_folders_first.Get(), [this](bool& v_out){
options->Add(std::make_unique<SidebarEntryBool>("Folders First"_i18n, m_menu->m_folders_first.Get(), [this](bool& v_out){
m_menu->m_folders_first.Set(v_out);
SortAndFindLastFile();
}));
options->Add(std::make_shared<SidebarEntryBool>("Hidden Last"_i18n, m_menu->m_hidden_last.Get(), [this](bool& v_out){
options->Add(std::make_unique<SidebarEntryBool>("Hidden Last"_i18n, m_menu->m_hidden_last.Get(), [this](bool& v_out){
m_menu->m_hidden_last.Set(v_out);
SortAndFindLastFile();
}));
}));
if (m_entries_current.size()) {
options->Add(std::make_shared<SidebarEntryCallback>("Cut"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Cut"_i18n, [this](){
m_menu->AddSelectedEntries(SelectedType::Cut);
}, true));
options->Add(std::make_shared<SidebarEntryCallback>("Copy"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Copy"_i18n, [this](){
m_menu->AddSelectedEntries(SelectedType::Copy);
}, true));
}
if (!m_menu->m_selected.Empty() && (m_menu->m_selected.Type() == SelectedType::Cut || m_menu->m_selected.Type() == SelectedType::Copy)) {
options->Add(std::make_shared<SidebarEntryCallback>("Paste"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Paste"_i18n, [this](){
const std::string buf = "Paste file(s)?"_i18n;
App::Push(std::make_shared<OptionBox>(
App::Push(std::make_unique<OptionBox>(
buf, "No"_i18n, "Yes"_i18n, 0, [this](auto op_index){
if (op_index && *op_index) {
App::PopToMenu();
@@ -1615,7 +1615,7 @@ void FsView::DisplayOptions() {
// can't rename more than 1 file
if (m_entries_current.size() && !m_selected_count) {
options->Add(std::make_shared<SidebarEntryCallback>("Rename"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Rename"_i18n, [this](){
std::string out;
const auto& entry = GetEntry();
const auto name = entry.GetName();
@@ -1643,11 +1643,11 @@ void FsView::DisplayOptions() {
}
if (m_entries_current.size()) {
options->Add(std::make_shared<SidebarEntryCallback>("Delete"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Delete"_i18n, [this](){
m_menu->AddSelectedEntries(SelectedType::Delete);
log_write("clicked on delete\n");
App::Push(std::make_shared<OptionBox>(
App::Push(std::make_unique<OptionBox>(
"Delete Selected files?"_i18n, "No"_i18n, "Yes"_i18n, 0, [this](auto op_index){
if (op_index && *op_index) {
App::PopToMenu();
@@ -1673,7 +1673,7 @@ void FsView::DisplayOptions() {
// if install is enabled, check if all currently selected files are installable.
if (m_entries_current.size() && App::GetInstallEnable()) {
if (check_all_ext(INSTALL_EXTENSIONS)) {
options->Add(std::make_shared<SidebarEntryCallback>("Install"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Install"_i18n, [this](){
InstallFiles();
}));
}
@@ -1681,9 +1681,9 @@ void FsView::DisplayOptions() {
if (IsSd() && m_entries_current.size() && !m_selected_count) {
if (App::GetInstallEnable() && GetEntry().IsFile() && (GetEntry().GetExtension() == "nro" || !m_menu->FindFileAssocFor().empty())) {
options->Add(std::make_shared<SidebarEntryCallback>("Install Forwarder"_i18n, [this](){;
options->Add(std::make_unique<SidebarEntryCallback>("Install Forwarder"_i18n, [this](){;
if (App::GetInstallPrompt()) {
App::Push(std::make_shared<OptionBox>(
App::Push(std::make_unique<OptionBox>(
"WARNING: Installing forwarders will lead to a ban!"_i18n,
"Back"_i18n, "Install"_i18n, 0, [this](auto op_index){
if (op_index && *op_index) {
@@ -1700,16 +1700,16 @@ void FsView::DisplayOptions() {
if (m_entries_current.size()) {
if (check_all_ext(ZIP_EXTENSIONS)) {
options->Add(std::make_shared<SidebarEntryCallback>("Extract zip"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Extract Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
options->Add(std::make_unique<SidebarEntryCallback>("Extract zip"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Extract Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_shared<SidebarEntryCallback>("Extract here"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Extract here"_i18n, [this](){
UnzipFiles("");
}));
options->Add(std::make_shared<SidebarEntryCallback>("Extract to root"_i18n, [this](){
App::Push(std::make_shared<OptionBox>("Are you sure you want to extract to root?"_i18n,
options->Add(std::make_unique<SidebarEntryCallback>("Extract to root"_i18n, [this](){
App::Push(std::make_unique<OptionBox>("Are you sure you want to extract to root?"_i18n,
"No"_i18n, "Yes"_i18n, 0, [this](auto op_index){
if (op_index && *op_index) {
UnzipFiles(m_fs->Root());
@@ -1717,7 +1717,7 @@ void FsView::DisplayOptions() {
}));
}));
options->Add(std::make_shared<SidebarEntryCallback>("Extract to..."_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Extract to..."_i18n, [this](){
std::string out;
if (R_SUCCEEDED(swkbd::ShowText(out, "Enter the path to the folder to extract into", fs::AppendPath(m_path, ""))) && !out.empty()) {
UnzipFiles(out);
@@ -1727,15 +1727,15 @@ void FsView::DisplayOptions() {
}
if (!check_all_ext(ZIP_EXTENSIONS) || m_selected_count) {
options->Add(std::make_shared<SidebarEntryCallback>("Compress to zip"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Compress Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
options->Add(std::make_unique<SidebarEntryCallback>("Compress to zip"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Compress Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_shared<SidebarEntryCallback>("Compress"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Compress"_i18n, [this](){
ZipFiles("");
}));
options->Add(std::make_shared<SidebarEntryCallback>("Compress to..."_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Compress to..."_i18n, [this](){
std::string out;
if (R_SUCCEEDED(swkbd::ShowText(out, "Enter the path to the folder to extract into", m_path)) && !out.empty()) {
ZipFiles(out);
@@ -1745,14 +1745,14 @@ void FsView::DisplayOptions() {
}
}
options->Add(std::make_shared<SidebarEntryCallback>("Advanced"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Advanced"_i18n, [this](){
DisplayAdvancedOptions();
}));
}
void FsView::DisplayAdvancedOptions() {
auto options = std::make_shared<Sidebar>("Advanced Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
auto options = std::make_unique<Sidebar>("Advanced Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
SidebarEntryArray::Items mount_items;
std::vector<FsEntry> fs_entries;
@@ -1773,12 +1773,12 @@ void FsView::DisplayAdvancedOptions() {
mount_items.push_back(i18n::get(e.name));
}
options->Add(std::make_shared<SidebarEntryArray>("Mount"_i18n, mount_items, [this, fs_entries](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Mount"_i18n, mount_items, [this, fs_entries](s64& index_out){
App::PopToMenu();
SetFs(fs_entries[index_out].root, fs_entries[index_out]);
}, i18n::get(m_fs_entry.name)));
options->Add(std::make_shared<SidebarEntryCallback>("Create File"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Create File"_i18n, [this](){
std::string out;
if (R_SUCCEEDED(swkbd::ShowText(out, "Set File Name"_i18n.c_str(), fs::AppendPath(m_path, ""))) && !out.empty()) {
App::PopToMenu();
@@ -1800,7 +1800,7 @@ void FsView::DisplayAdvancedOptions() {
}
}));
options->Add(std::make_shared<SidebarEntryCallback>("Create Folder"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Create Folder"_i18n, [this](){
std::string out;
if (R_SUCCEEDED(swkbd::ShowText(out, "Set Folder Name"_i18n.c_str(), fs::AppendPath(m_path, ""))) && !out.empty()) {
App::PopToMenu();
@@ -1822,38 +1822,38 @@ void FsView::DisplayAdvancedOptions() {
}));
if (IsSd() && m_entries_current.size() && !m_selected_count && GetEntry().IsFile() && GetEntry().file_size < 1024*64) {
options->Add(std::make_shared<SidebarEntryCallback>("View as text (unfinished)"_i18n, [this](){
App::Push(std::make_shared<fileview::Menu>(GetNewPathCurrent()));
options->Add(std::make_unique<SidebarEntryCallback>("View as text (unfinished)"_i18n, [this](){
App::Push(std::make_unique<fileview::Menu>(GetNewPathCurrent()));
}));
}
if (m_entries_current.size()) {
options->Add(std::make_shared<SidebarEntryCallback>("Upload"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Upload"_i18n, [this](){
UploadFiles();
}));
}
if (m_entries_current.size() && !m_selected_count && GetEntry().IsFile()) {
options->Add(std::make_shared<SidebarEntryCallback>("Hash"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Hash Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
options->Add(std::make_unique<SidebarEntryCallback>("Hash"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Hash Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_shared<SidebarEntryCallback>("CRC32"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("CRC32"_i18n, [this](){
DisplayHash(hash::Type::Crc32);
}));
options->Add(std::make_shared<SidebarEntryCallback>("MD5"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("MD5"_i18n, [this](){
DisplayHash(hash::Type::Md5);
}));
options->Add(std::make_shared<SidebarEntryCallback>("SHA1"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("SHA1"_i18n, [this](){
DisplayHash(hash::Type::Sha1);
}));
options->Add(std::make_shared<SidebarEntryCallback>("SHA256"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("SHA256"_i18n, [this](){
DisplayHash(hash::Type::Sha256);
}));
}));
}
options->Add(std::make_shared<SidebarEntryBool>("Ignore read only"_i18n, m_menu->m_ignore_read_only.Get(), [this](bool& v_out){
options->Add(std::make_unique<SidebarEntryBool>("Ignore read only"_i18n, m_menu->m_ignore_read_only.Get(), [this](bool& v_out){
m_menu->m_ignore_read_only.Set(v_out);
m_fs->SetIgnoreReadOnly(v_out);
}));
@@ -1870,7 +1870,8 @@ Menu::Menu(u32 flags) : MenuBase{"FileBrowser"_i18n, flags} {
}});
}
view = view_left = std::make_shared<FsView>(this, ViewSide::Left);
view_left = std::make_unique<FsView>(this, ViewSide::Left);
view = view_left.get();
ueventCreate(&g_change_uevent, true);
}
@@ -1910,7 +1911,7 @@ void Menu::Draw(NVGcontext* vg, Theme* theme) {
view_left->Draw(vg, theme);
view_right->Draw(vg, theme);
if (view == view_left) {
if (view == view_left.get()) {
gfx::drawRect(vg, view_right->GetPos(), theme->GetColour(ThemeEntryID_FOCUS), 5);
} else {
gfx::drawRect(vg, view_left->GetPos(), theme->GetColour(ThemeEntryID_FOCUS), 5);
@@ -2102,7 +2103,7 @@ void Menu::SetSplitScreen(bool enable) {
m_split_screen = enable;
if (m_split_screen) {
const auto change_view = [this](auto new_view){
const auto change_view = [this](FsView* new_view){
if (view != new_view) {
view->OnFocusLost();
view = new_view;
@@ -2114,19 +2115,22 @@ void Menu::SetSplitScreen(bool enable) {
// load second screen as a copy of the left side.
view->SetSide(ViewSide::Left);
view_right = std::make_shared<FsView>(this, view->m_path, view->GetFsEntry(), ViewSide::Right);
change_view(view_right);
view_right = std::make_unique<FsView>(this, view->m_path, view->GetFsEntry(), ViewSide::Right);
change_view(view_right.get());
SetAction(Button::LEFT, Action{[this, change_view](){
change_view(view_left);
change_view(view_left.get());
}});
SetAction(Button::RIGHT, Action{[this, change_view](){
change_view(view_right);
change_view(view_right.get());
}});
} else {
view_left = {};
if (view == view_right.get()) {
view_left = std::move(view_right);
}
view_right = {};
view_left = view;
view = view_left.get();
view->SetSide(ViewSide::Left);
RemoveAction(Button::LEFT);
@@ -2152,7 +2156,7 @@ void Menu::PromptIfShouldExit() {
return;
}
App::Push(std::make_shared<ui::OptionBox>(
App::Push(std::make_unique<ui::OptionBox>(
"Close FileBrowser?"_i18n,
"No"_i18n, "Yes"_i18n, 1, [this](auto op_index){
if (op_index && *op_index) {

View File

@@ -172,7 +172,7 @@ private:
Result Notify(Result rc, const std::string& error_message) {
if (R_FAILED(rc)) {
App::Push(std::make_shared<ui::ErrorBox>(rc,
App::Push(std::make_unique<ui::ErrorBox>(rc,
i18n::get(error_message)
));
} else {
@@ -185,12 +185,10 @@ Result GetMetaEntries(const Entry& e, title::MetaEntries& out, u32 flags = title
return title::GetMetaEntries(e.app_id, out, flags);
}
bool LoadControlImage(Entry& e) {
if (!e.image && e.info && !e.info->icon.empty()) {
ON_SCOPE_EXIT(e.info.reset());
bool LoadControlImage(Entry& e, title::ThreadResultData* result) {
if (!e.image && result && !result->icon.empty()) {
TimeStamp ts;
const auto image = ImageLoadFromMemory(e.info->icon, ImageFlag_JPEG);
const auto image = ImageLoadFromMemory(result->icon, ImageFlag_JPEG);
if (!image.data.empty()) {
e.image = nvgCreateImageRGBA(App::GetVg(), image.w, image.h, 0, image.data.data());
log_write("\t[image load] time taken: %.2fs %zums\n", ts.GetSecondsD(), ts.GetMs());
@@ -201,11 +199,12 @@ bool LoadControlImage(Entry& e) {
return false;
}
void LoadResultIntoEntry(Entry& e, const std::shared_ptr<title::ThreadResultData>& result) {
e.info = result;
e.status = result->status;
e.lang = result->lang;
e.status = result->status;
void LoadResultIntoEntry(Entry& e, title::ThreadResultData* result) {
if (result) {
e.status = result->status;
e.lang = result->lang;
e.status = result->status;
}
}
void LoadControlEntry(Entry& e, bool force_image_load = false) {
@@ -214,7 +213,7 @@ void LoadControlEntry(Entry& e, bool force_image_load = false) {
}
if (force_image_load && e.status == title::NacpLoadStatus::Loaded) {
LoadControlImage(e);
LoadControlImage(e, title::Get(e.app_id));
}
}
@@ -474,13 +473,13 @@ Menu::Menu(u32 flags) : grid::Menu{"Games"_i18n, flags} {
LaunchEntry(m_entries[m_index]);
}}),
std::make_pair(Button::X, Action{"Options"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Game Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
auto options = std::make_unique<Sidebar>("Game Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
if (m_entries.size()) {
options->Add(std::make_shared<SidebarEntryCallback>("Sort By"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Sort Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
options->Add(std::make_unique<SidebarEntryCallback>("Sort By"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Sort Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
SidebarEntryArray::Items sort_items;
sort_items.push_back("Updated"_i18n);
@@ -494,39 +493,39 @@ Menu::Menu(u32 flags) : grid::Menu{"Games"_i18n, flags} {
layout_items.push_back("Icon"_i18n);
layout_items.push_back("Grid"_i18n);
options->Add(std::make_shared<SidebarEntryArray>("Sort"_i18n, sort_items, [this](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Sort"_i18n, sort_items, [this](s64& index_out){
m_sort.Set(index_out);
SortAndFindLastFile(false);
}, m_sort.Get()));
options->Add(std::make_shared<SidebarEntryArray>("Order"_i18n, order_items, [this](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Order"_i18n, order_items, [this](s64& index_out){
m_order.Set(index_out);
SortAndFindLastFile(false);
}, m_order.Get()));
options->Add(std::make_shared<SidebarEntryArray>("Layout"_i18n, layout_items, [this](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Layout"_i18n, layout_items, [this](s64& index_out){
m_layout.Set(index_out);
OnLayoutChange();
}, m_layout.Get()));
options->Add(std::make_shared<SidebarEntryBool>("Hide forwarders"_i18n, m_hide_forwarders.Get(), [this](bool& v_out){
options->Add(std::make_unique<SidebarEntryBool>("Hide forwarders"_i18n, m_hide_forwarders.Get(), [this](bool& v_out){
m_hide_forwarders.Set(v_out);
m_dirty = true;
}));
}));
#if 0
options->Add(std::make_shared<SidebarEntryCallback>("Info"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Info"_i18n, [this](){
}));
#endif
options->Add(std::make_shared<SidebarEntryCallback>("Launch random game"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Launch random game"_i18n, [this](){
const auto random_index = randomGet64() % std::size(m_entries);
auto& e = m_entries[random_index];
LoadControlEntry(e, true);
App::Push(std::make_shared<OptionBox>(
App::Push(std::make_unique<OptionBox>(
"Launch "_i18n + e.GetName(),
"Back"_i18n, "Launch"_i18n, 1, [this, &e](auto op_index){
if (op_index && *op_index) {
@@ -536,11 +535,11 @@ Menu::Menu(u32 flags) : grid::Menu{"Games"_i18n, flags} {
));
}));
options->Add(std::make_shared<SidebarEntryCallback>("List meta records"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("List meta records"_i18n, [this](){
title::MetaEntries meta_entries;
const auto rc = GetMetaEntries(m_entries[m_index], meta_entries);
if (R_FAILED(rc)) {
App::Push(std::make_shared<ui::ErrorBox>(rc,
App::Push(std::make_unique<ui::ErrorBox>(rc,
i18n::get("Failed to list application meta entries")
));
return;
@@ -558,7 +557,7 @@ Menu::Menu(u32 flags) : grid::Menu{"Games"_i18n, flags} {
items.emplace_back(buf);
}
App::Push(std::make_shared<PopupList>(
App::Push(std::make_unique<PopupList>(
"Entries"_i18n, items, [this, meta_entries](auto op_index){
#if 0
if (op_index) {
@@ -569,35 +568,35 @@ Menu::Menu(u32 flags) : grid::Menu{"Games"_i18n, flags} {
));
}));
options->Add(std::make_shared<SidebarEntryCallback>("Dump"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Select content to dump"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
options->Add(std::make_unique<SidebarEntryCallback>("Dump"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Select content to dump"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_shared<SidebarEntryCallback>("Dump All"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Dump All"_i18n, [this](){
DumpGames(title::ContentFlag_All);
}, true));
options->Add(std::make_shared<SidebarEntryCallback>("Dump Application"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Dump Application"_i18n, [this](){
DumpGames(title::ContentFlag_Application);
}, true));
options->Add(std::make_shared<SidebarEntryCallback>("Dump Patch"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Dump Patch"_i18n, [this](){
DumpGames(title::ContentFlag_Patch);
}, true));
options->Add(std::make_shared<SidebarEntryCallback>("Dump AddOnContent"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Dump AddOnContent"_i18n, [this](){
DumpGames(title::ContentFlag_AddOnContent);
}, true));
options->Add(std::make_shared<SidebarEntryCallback>("Dump DataPatch"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Dump DataPatch"_i18n, [this](){
DumpGames(title::ContentFlag_DataPatch);
}, true));
}, true));
options->Add(std::make_shared<SidebarEntryCallback>("Dump options"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Dump options"_i18n, [this](){
App::DisplayDumpOptions(false);
}));
// completely deletes the application record and all data.
options->Add(std::make_shared<SidebarEntryCallback>("Delete"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Delete"_i18n, [this](){
const auto buf = "Are you sure you want to delete "_i18n + m_entries[m_index].GetName() + "?";
App::Push(std::make_shared<OptionBox>(
App::Push(std::make_unique<OptionBox>(
buf,
"Back"_i18n, "Delete"_i18n, 0, [this](auto op_index){
if (op_index && *op_index) {
@@ -608,16 +607,16 @@ Menu::Menu(u32 flags) : grid::Menu{"Games"_i18n, flags} {
}, true));
}
options->Add(std::make_shared<SidebarEntryCallback>("Advanced options"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Advanced Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
options->Add(std::make_unique<SidebarEntryCallback>("Advanced options"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Advanced Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_shared<SidebarEntryCallback>("Refresh"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Refresh"_i18n, [this](){
m_dirty = true;
App::PopToMenu();
}));
options->Add(std::make_shared<SidebarEntryCallback>("Create contents folder"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Create contents folder"_i18n, [this](){
const auto rc = fs::FsNativeSd().CreateDirectory(title::GetContentsPath(m_entries[m_index].app_id));
App::PushErrorBox(rc, "Folder create failed!"_i18n);
@@ -626,14 +625,14 @@ Menu::Menu(u32 flags) : grid::Menu{"Games"_i18n, flags} {
}
}));
options->Add(std::make_shared<SidebarEntryCallback>("Create save"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Create save"_i18n, [this](){
ui::PopupList::Items items{};
const auto accounts = App::GetAccountList();
for (auto& p : accounts) {
items.emplace_back(p.nickname);
}
App::Push(std::make_shared<ui::PopupList>(
App::Push(std::make_unique<ui::PopupList>(
"Select user to create save for"_i18n, items, [this, accounts](auto op_index){
if (op_index) {
CreateSaves(accounts[*op_index].uid);
@@ -642,12 +641,12 @@ Menu::Menu(u32 flags) : grid::Menu{"Games"_i18n, flags} {
));
}));
options->Add(std::make_shared<SidebarEntryBool>("Title cache"_i18n, m_title_cache.Get(), [this](bool& v_out){
options->Add(std::make_unique<SidebarEntryBool>("Title cache"_i18n, m_title_cache.Get(), [this](bool& v_out){
m_title_cache.Set(v_out);
}));
options->Add(std::make_shared<SidebarEntryCallback>("Delete title cache"_i18n, [this](){
App::Push(std::make_shared<OptionBox>(
options->Add(std::make_unique<SidebarEntryCallback>("Delete title cache"_i18n, [this](){
App::Push(std::make_unique<OptionBox>(
"Are you sure you want to delete the title cache?"_i18n,
"Back"_i18n, "Delete"_i18n, 0, [this](auto op_index){
if (op_index && *op_index) {
@@ -714,14 +713,12 @@ void Menu::Draw(NVGcontext* vg, Theme* theme) {
title::PushAsync(e.app_id);
e.status = title::NacpLoadStatus::Progress;
} else if (e.status == title::NacpLoadStatus::Progress) {
if (const auto data = title::GetAsync(e.app_id)) {
LoadResultIntoEntry(e, data);
}
LoadResultIntoEntry(e, title::GetAsync(e.app_id));
}
// lazy load image
if (image_load_count < image_load_max) {
if (LoadControlImage(e)) {
if (LoadControlImage(e, title::GetAsync(e.app_id))) {
image_load_count++;
}
}
@@ -879,7 +876,7 @@ void Menu::OnLayoutChange() {
}
void Menu::DeleteGames() {
App::Push(std::make_shared<ProgressBox>(0, "Deleting"_i18n, "", [this](auto pbox) -> Result {
App::Push(std::make_unique<ProgressBox>(0, "Deleting"_i18n, "", [this](auto pbox) -> Result {
auto targets = GetSelectedEntries();
for (s64 i = 0; i < std::size(targets); i++) {
@@ -924,7 +921,7 @@ void Menu::DumpGames(u32 flags) {
}
void Menu::CreateSaves(AccountUid uid) {
App::Push(std::make_shared<ProgressBox>(0, "Creating"_i18n, "", [this, uid](auto pbox) -> Result {
App::Push(std::make_unique<ProgressBox>(0, "Creating"_i18n, "", [this, uid](auto pbox) -> Result {
auto targets = GetSelectedEntries();
for (s64 i = 0; i < std::size(targets); i++) {

View File

@@ -376,16 +376,16 @@ Menu::Menu(u32 flags) : MenuBase{"GameCard"_i18n, flags} {
if (m_option_index == 0) {
if (!App::GetInstallEnable()) {
App::Push(std::make_shared<ui::OptionBox>(
App::Push(std::make_unique<ui::OptionBox>(
"Install disabled...\n"
"Please enable installing via the install options."_i18n,
"OK"_i18n
));
} else {
log_write("[GC] doing install A\n");
App::Push(std::make_shared<ui::ProgressBox>(m_icon, "Installing "_i18n, m_entries[m_entry_index].lang_entry.name, [this](auto pbox) -> Result {
auto source = std::make_shared<GcSource>(m_entries[m_entry_index], m_fs.get());
return yati::InstallFromCollections(pbox, source, source->m_collections, source->m_config);
App::Push(std::make_unique<ui::ProgressBox>(m_icon, "Installing "_i18n, m_entries[m_entry_index].lang_entry.name, [this](auto pbox) -> Result {
auto source = std::make_unique<GcSource>(m_entries[m_entry_index], m_fs.get());
return yati::InstallFromCollections(pbox, source.get(), source->m_collections, source->m_config);
}, [this](Result rc){
App::PushErrorBox(rc, "Gc install failed!"_i18n);
@@ -395,11 +395,11 @@ Menu::Menu(u32 flags) : MenuBase{"GameCard"_i18n, flags} {
}));
}
} else {
auto options = std::make_shared<Sidebar>("Select content to dump"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
auto options = std::make_unique<Sidebar>("Select content to dump"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
const auto add = [&](const std::string& name, u32 flags){
options->Add(std::make_shared<SidebarEntryCallback>(name, [this, flags](){
options->Add(std::make_unique<SidebarEntryCallback>(name, [this, flags](){
DumpGames(flags);
m_dirty = true;
}, true));
@@ -419,14 +419,14 @@ Menu::Menu(u32 flags) : MenuBase{"GameCard"_i18n, flags} {
SetPop();
}}),
std::make_pair(Button::X, Action{"Options"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Game Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
auto options = std::make_unique<Sidebar>("Game Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_shared<SidebarEntryCallback>("Install options"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Install options"_i18n, [this](){
App::DisplayInstallOptions(false);
}));
options->Add(std::make_shared<SidebarEntryCallback>("Dump options"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Dump options"_i18n, [this](){
App::DisplayDumpOptions(false);
}));
}})
@@ -982,7 +982,7 @@ Result Menu::DumpGames(u32 flags) {
// if trimmed and the user wants to dump the full xci, error.
if ((flags & DumpFileFlag_XCI) && is_trimmed && App::GetApp()->m_dump_trim_xci.Get()) {
App::Push(std::make_shared<ui::OptionBox>(
App::Push(std::make_unique<ui::OptionBox>(
"WARNING: GameCard is already trimmed!"_i18n,
"Back"_i18n, "Continue"_i18n, 0, [&](auto op_index){
if (op_index && *op_index) {

View File

@@ -166,7 +166,7 @@ Menu::Menu(u32 flags) : MenuBase{"GitHub"_i18n, flags} {
static GhApiEntry gh_entry;
gh_entry = {};
App::Push(std::make_shared<ProgressBox>(0, "Downloading "_i18n, GetEntry().repo, [this](auto pbox) -> Result {
App::Push(std::make_unique<ProgressBox>(0, "Downloading "_i18n, GetEntry().repo, [this](auto pbox) -> Result {
return DownloadAssetJson(pbox, GenerateApiUrl(GetEntry()), gh_entry);
}, [this](Result rc){
App::PushErrorBox(rc, "Failed to download json"_i18n);
@@ -199,7 +199,7 @@ Menu::Menu(u32 flags) : MenuBase{"GitHub"_i18n, flags} {
}
}
App::Push(std::make_shared<PopupList>("Select asset to download for "_i18n + GetEntry().repo, asset_items, [this, api_assets, asset_ptr](auto op_index){
App::Push(std::make_unique<PopupList>("Select asset to download for "_i18n + GetEntry().repo, asset_items, [this, api_assets, asset_ptr](auto op_index){
if (!op_index) {
return;
}
@@ -216,7 +216,7 @@ Menu::Menu(u32 flags) : MenuBase{"GitHub"_i18n, flags} {
}
const auto func = [this, &asset_entry, ptr](){
App::Push(std::make_shared<ProgressBox>(0, "Downloading "_i18n, GetEntry().repo, [this, &asset_entry, ptr](auto pbox) -> Result {
App::Push(std::make_unique<ProgressBox>(0, "Downloading "_i18n, GetEntry().repo, [this, &asset_entry, ptr](auto pbox) -> Result {
return DownloadApp(pbox, asset_entry, ptr);
}, [this, ptr](Result rc){
homebrew::SignalChange();
@@ -230,14 +230,14 @@ Menu::Menu(u32 flags) : MenuBase{"GitHub"_i18n, flags} {
}
if (!post_install_message.empty()) {
App::Push(std::make_shared<OptionBox>(post_install_message, "OK"_i18n));
App::Push(std::make_unique<OptionBox>(post_install_message, "OK"_i18n));
}
}
}));
};
if (!pre_install_message.empty()) {
App::Push(std::make_shared<OptionBox>(
App::Push(std::make_unique<OptionBox>(
pre_install_message,
"Back"_i18n, "Download"_i18n, 1, [this, func](auto op_index){
if (op_index && *op_index) {

View File

@@ -56,13 +56,13 @@ Menu::Menu() : grid::Menu{"Homebrew"_i18n, MenuFlag_Tab} {
nro_launch(m_entries[m_index].path);
}}),
std::make_pair(Button::X, Action{"Options"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Homebrew Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
auto options = std::make_unique<Sidebar>("Homebrew Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
if (m_entries.size()) {
options->Add(std::make_shared<SidebarEntryCallback>("Sort By"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Sort Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
options->Add(std::make_unique<SidebarEntryCallback>("Sort By"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Sort Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
SidebarEntryArray::Items sort_items;
sort_items.push_back("Updated"_i18n);
@@ -81,35 +81,35 @@ Menu::Menu() : grid::Menu{"Homebrew"_i18n, MenuFlag_Tab} {
layout_items.push_back("Icon"_i18n);
layout_items.push_back("Grid"_i18n);
options->Add(std::make_shared<SidebarEntryArray>("Sort"_i18n, sort_items, [this, sort_items](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Sort"_i18n, sort_items, [this, sort_items](s64& index_out){
m_sort.Set(index_out);
SortAndFindLastFile();
}, m_sort.Get()));
options->Add(std::make_shared<SidebarEntryArray>("Order"_i18n, order_items, [this, order_items](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Order"_i18n, order_items, [this, order_items](s64& index_out){
m_order.Set(index_out);
SortAndFindLastFile();
}, m_order.Get()));
options->Add(std::make_shared<SidebarEntryArray>("Layout"_i18n, layout_items, [this](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Layout"_i18n, layout_items, [this](s64& index_out){
m_layout.Set(index_out);
OnLayoutChange();
}, m_layout.Get()));
options->Add(std::make_shared<SidebarEntryBool>("Hide Sphaira"_i18n, m_hide_sphaira.Get(), [this](bool& enable){
options->Add(std::make_unique<SidebarEntryBool>("Hide Sphaira"_i18n, m_hide_sphaira.Get(), [this](bool& enable){
m_hide_sphaira.Set(enable);
}));
}));
#if 0
options->Add(std::make_shared<SidebarEntryCallback>("Info"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Info"_i18n, [this](){
}));
#endif
options->Add(std::make_shared<SidebarEntryCallback>("Delete"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Delete"_i18n, [this](){
const auto buf = "Are you sure you want to delete "_i18n + m_entries[m_index].path.toString() + "?";
App::Push(std::make_shared<OptionBox>(
App::Push(std::make_unique<OptionBox>(
buf,
"Back"_i18n, "Delete"_i18n, 1, [this](auto op_index){
if (op_index && *op_index) {
@@ -124,9 +124,9 @@ Menu::Menu() : grid::Menu{"Homebrew"_i18n, MenuFlag_Tab} {
}, true));
if (App::GetInstallEnable()) {
options->Add(std::make_shared<SidebarEntryCallback>("Install Forwarder"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Install Forwarder"_i18n, [this](){
if (App::GetInstallPrompt()) {
App::Push(std::make_shared<OptionBox>(
App::Push(std::make_unique<OptionBox>(
"WARNING: Installing forwarders will lead to a ban!"_i18n,
"Back"_i18n, "Install"_i18n, 0, [this](auto op_index){
if (op_index && *op_index) {

View File

@@ -142,9 +142,9 @@ void Menu::Update(Controller* controller, TouchInfo* touch) {
if (m_state == State::Connected) {
m_state = State::Progress;
App::Push(std::make_shared<ui::ProgressBox>(0, "Installing "_i18n, m_source->GetPath(), [this](auto pbox) -> Result {
App::Push(std::make_unique<ui::ProgressBox>(0, "Installing "_i18n, m_source->GetPath(), [this](auto pbox) -> Result {
INSTALL_STATE = InstallState::Progress;
const auto rc = yati::InstallFromSource(pbox, m_source, m_source->GetPath());
const auto rc = yati::InstallFromSource(pbox, m_source.get(), m_source->GetPath());
INSTALL_STATE = InstallState::Finished;
if (R_FAILED(rc)) {
@@ -234,7 +234,7 @@ bool Menu::OnInstallStart(const char* path) {
SCOPED_MUTEX(&m_mutex);
m_source = std::make_shared<Stream>(path, GetToken());
m_source = std::make_unique<Stream>(path, GetToken());
INSTALL_STATE = InstallState::None;
m_state = State::Connected;
log_write("[Menu::OnInstallStart] exiting\n");

View File

@@ -81,8 +81,8 @@ Menu::Menu(u32 flags) : MenuBase{"Irs"_i18n, flags} {
}});
SetAction(Button::X, Action{"Options"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
auto options = std::make_unique<Sidebar>("Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
SidebarEntryArray::Items controller_str;
for (u32 i = 0; i < IRS_MAX_CAMERAS; i++) {
@@ -126,44 +126,44 @@ Menu::Menu(u32 flags) : MenuBase{"Irs"_i18n, flags} {
format_str.emplace_back("20\u00D715");
}
options->Add(std::make_shared<SidebarEntryArray>("Controller"_i18n, controller_str, [this](s64& index){
options->Add(std::make_unique<SidebarEntryArray>("Controller"_i18n, controller_str, [this](s64& index){
irsStopImageProcessor(m_entries[m_index].m_handle);
m_index = index;
UpdateConfig(&m_config);
}, m_index));
options->Add(std::make_shared<SidebarEntryArray>("Rotation"_i18n, rotation_str, [this](s64& index){
options->Add(std::make_unique<SidebarEntryArray>("Rotation"_i18n, rotation_str, [this](s64& index){
m_rotation = (Rotation)index;
}, m_rotation));
options->Add(std::make_shared<SidebarEntryArray>("Colour"_i18n, colour_str, [this](s64& index){
options->Add(std::make_unique<SidebarEntryArray>("Colour"_i18n, colour_str, [this](s64& index){
m_colour = (Colour)index;
updateColourArray();
}, m_colour));
options->Add(std::make_shared<SidebarEntryArray>("Light Target"_i18n, light_target_str, [this](s64& index){
options->Add(std::make_unique<SidebarEntryArray>("Light Target"_i18n, light_target_str, [this](s64& index){
m_config.light_target = index;
UpdateConfig(&m_config);
}, m_config.light_target));
options->Add(std::make_shared<SidebarEntryArray>("Gain"_i18n, gain_str, [this](s64& index){
options->Add(std::make_unique<SidebarEntryArray>("Gain"_i18n, gain_str, [this](s64& index){
m_config.gain = GAIN_MIN + index;
UpdateConfig(&m_config);
}, m_config.gain - GAIN_MIN));
options->Add(std::make_shared<SidebarEntryArray>("Negative Image"_i18n, is_negative_image_used_str, [this](s64& index){
options->Add(std::make_unique<SidebarEntryArray>("Negative Image"_i18n, is_negative_image_used_str, [this](s64& index){
m_config.is_negative_image_used = index;
UpdateConfig(&m_config);
}, m_config.is_negative_image_used));
options->Add(std::make_shared<SidebarEntryArray>("Format"_i18n, format_str, [this](s64& index){
options->Add(std::make_unique<SidebarEntryArray>("Format"_i18n, format_str, [this](s64& index){
m_config.orig_format = index;
m_config.trimming_format = index;
UpdateConfig(&m_config);
}, m_config.orig_format));
if (hosversionAtLeast(4,0,0)) {
options->Add(std::make_shared<SidebarEntryArray>("Trimming Format"_i18n, format_str, [this](s64& index){
options->Add(std::make_unique<SidebarEntryArray>("Trimming Format"_i18n, format_str, [this](s64& index){
// you cannot set trim a larger region than the source
if (index < m_config.orig_format) {
index = m_config.orig_format;
@@ -173,13 +173,13 @@ Menu::Menu(u32 flags) : MenuBase{"Irs"_i18n, flags} {
}
}, m_config.orig_format));
options->Add(std::make_shared<SidebarEntryBool>("External Light Filter"_i18n, m_config.is_external_light_filter_enabled, [this](bool& enable){
options->Add(std::make_unique<SidebarEntryBool>("External Light Filter"_i18n, m_config.is_external_light_filter_enabled, [this](bool& enable){
m_config.is_external_light_filter_enabled = enable;
UpdateConfig(&m_config);
}));
}
options->Add(std::make_shared<SidebarEntryCallback>("Load Default"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Load Default"_i18n, [this](){
LoadDefaultConfig();
}, true));
}});

View File

@@ -44,7 +44,7 @@ constexpr const fs::FsPath SPHAIRA_PATHS[]{
template<typename T>
auto MiscMenuFuncGenerator(u32 flags) {
return std::make_shared<T>(flags);
return std::make_unique<T>(flags);
}
const MiscMenuEntry MISC_MENU_ENTRIES[] = {
@@ -122,7 +122,7 @@ auto InstallUpdate(ProgressBox* pbox, const std::string url, const std::string v
R_SUCCEED();
}
auto CreateLeftSideMenu(std::string& name_out) -> std::shared_ptr<MenuBase> {
auto CreateLeftSideMenu(std::string& name_out) -> std::unique_ptr<MenuBase> {
const auto name = App::GetApp()->m_left_menu.Get();
for (auto& e : GetMiscMenuEntries()) {
@@ -133,20 +133,20 @@ auto CreateLeftSideMenu(std::string& name_out) -> std::shared_ptr<MenuBase> {
}
name_out = "FileBrowser";
return std::make_shared<ui::menu::filebrowser::Menu>(MenuFlag_Tab);
return std::make_unique<ui::menu::filebrowser::Menu>(MenuFlag_Tab);
}
auto CreateRightSideMenu(std::string_view left_name) -> std::shared_ptr<MenuBase> {
auto CreateRightSideMenu(std::string_view left_name) -> std::unique_ptr<MenuBase> {
const auto name = App::GetApp()->m_right_menu.Get();
// handle if the user tries to mount the same menu twice.
if (name == left_name) {
// check if we can mount the default.
if (left_name != "AppStore") {
return std::make_shared<ui::menu::appstore::Menu>(MenuFlag_Tab);
return std::make_unique<ui::menu::appstore::Menu>(MenuFlag_Tab);
} else {
// otherwise, fallback to left side default.
return std::make_shared<ui::menu::filebrowser::Menu>(MenuFlag_Tab);
return std::make_unique<ui::menu::filebrowser::Menu>(MenuFlag_Tab);
}
}
@@ -156,7 +156,7 @@ auto CreateRightSideMenu(std::string_view left_name) -> std::shared_ptr<MenuBase
}
}
return std::make_shared<ui::menu::appstore::Menu>(MenuFlag_Tab);
return std::make_unique<ui::menu::appstore::Menu>(MenuFlag_Tab);
}
} // namespace
@@ -235,8 +235,8 @@ MainMenu::MainMenu() {
std::make_pair(Button::START, Action{App::Exit}),
std::make_pair(Button::SELECT, Action{App::DisplayMiscOptions}),
std::make_pair(Button::Y, Action{"Menu"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Menu Options"_i18n, "v" APP_VERSION_HASH, Sidebar::Side::LEFT);
ON_SCOPE_EXIT(App::Push(options));
auto options = std::make_unique<Sidebar>("Menu Options"_i18n, "v" APP_VERSION_HASH, Sidebar::Side::LEFT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
SidebarEntryArray::Items language_items;
language_items.push_back("Auto"_i18n);
@@ -255,17 +255,17 @@ MainMenu::MainMenu() {
language_items.push_back("Vietnamese"_i18n);
language_items.push_back("Ukrainian"_i18n);
options->Add(std::make_shared<SidebarEntryCallback>("Theme"_i18n, [](){
options->Add(std::make_unique<SidebarEntryCallback>("Theme"_i18n, [](){
App::DisplayThemeOptions();
}));
options->Add(std::make_shared<SidebarEntryCallback>("Network"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Network Options"_i18n, Sidebar::Side::LEFT);
ON_SCOPE_EXIT(App::Push(options));
options->Add(std::make_unique<SidebarEntryCallback>("Network"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Network Options"_i18n, Sidebar::Side::LEFT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
if (m_update_state == UpdateState::Update) {
options->Add(std::make_shared<SidebarEntryCallback>("Download update: "_i18n + m_update_version, [this](){
App::Push(std::make_shared<ProgressBox>(0, "Downloading "_i18n, "Sphaira v" + m_update_version, [this](auto pbox) -> Result {
options->Add(std::make_unique<SidebarEntryCallback>("Download update: "_i18n + m_update_version, [this](){
App::Push(std::make_unique<ProgressBox>(0, "Downloading "_i18n, "Sphaira v" + m_update_version, [this](auto pbox) -> Result {
return InstallUpdate(pbox, m_update_url, m_update_version);
}, [this](Result rc){
App::PushErrorBox(rc, "Failed to download update"_i18n);
@@ -273,7 +273,7 @@ MainMenu::MainMenu() {
if (R_SUCCEEDED(rc)) {
m_update_state = UpdateState::None;
App::Notify("Updated to "_i18n + m_update_version);
App::Push(std::make_shared<OptionBox>(
App::Push(std::make_unique<OptionBox>(
"Press OK to restart Sphaira"_i18n, "OK"_i18n, [](auto){
App::ExitRestart();
}
@@ -283,44 +283,43 @@ MainMenu::MainMenu() {
}));
}
options->Add(std::make_shared<SidebarEntryBool>("Ftp"_i18n, App::GetFtpEnable(), [](bool& enable){
options->Add(std::make_unique<SidebarEntryBool>("Ftp"_i18n, App::GetFtpEnable(), [](bool& enable){
App::SetFtpEnable(enable);
}));
options->Add(std::make_shared<SidebarEntryBool>("Mtp"_i18n, App::GetMtpEnable(), [](bool& enable){
options->Add(std::make_unique<SidebarEntryBool>("Mtp"_i18n, App::GetMtpEnable(), [](bool& enable){
App::SetMtpEnable(enable);
}));
options->Add(std::make_shared<SidebarEntryBool>("Nxlink"_i18n, App::GetNxlinkEnable(), [](bool& enable){
options->Add(std::make_unique<SidebarEntryBool>("Nxlink"_i18n, App::GetNxlinkEnable(), [](bool& enable){
App::SetNxlinkEnable(enable);
}));
options->Add(std::make_shared<SidebarEntryBool>("Hdd"_i18n, App::GetHddEnable(), [](bool& enable){
options->Add(std::make_unique<SidebarEntryBool>("Hdd"_i18n, App::GetHddEnable(), [](bool& enable){
App::SetHddEnable(enable);
}));
options->Add(std::make_shared<SidebarEntryBool>("Hdd write protect"_i18n, App::GetWriteProtect(), [](bool& enable){
options->Add(std::make_unique<SidebarEntryBool>("Hdd write protect"_i18n, App::GetWriteProtect(), [](bool& enable){
App::SetWriteProtect(enable);
}));
}));
options->Add(std::make_shared<SidebarEntryArray>("Language"_i18n, language_items, [](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Language"_i18n, language_items, [](s64& index_out){
App::SetLanguage(index_out);
}, (s64)App::GetLanguage()));
options->Add(std::make_shared<SidebarEntryCallback>("Misc"_i18n, [](){
options->Add(std::make_unique<SidebarEntryCallback>("Misc"_i18n, [](){
App::DisplayMiscOptions();
}));
options->Add(std::make_shared<SidebarEntryCallback>("Advanced"_i18n, [](){
options->Add(std::make_unique<SidebarEntryCallback>("Advanced"_i18n, [](){
App::DisplayAdvancedOptions();
}));
}})
);
m_centre_menu = std::make_shared<homebrew::Menu>();
m_current_menu = m_centre_menu;
m_centre_menu = std::make_unique<homebrew::Menu>();
m_current_menu = m_centre_menu.get();
std::string left_side_name;
m_left_menu = CreateLeftSideMenu(left_side_name);
@@ -355,13 +354,13 @@ void MainMenu::OnFocusLost() {
m_current_menu->OnFocusLost();
}
void MainMenu::OnLRPress(std::shared_ptr<MenuBase> menu, Button b) {
void MainMenu::OnLRPress(MenuBase* menu, Button b) {
m_current_menu->OnFocusLost();
if (m_current_menu == m_centre_menu) {
if (m_current_menu == m_centre_menu.get()) {
m_current_menu = menu;
RemoveAction(b);
} else {
m_current_menu = m_centre_menu;
m_current_menu = m_centre_menu.get();
}
AddOnLRPress();
@@ -373,17 +372,17 @@ void MainMenu::OnLRPress(std::shared_ptr<MenuBase> menu, Button b) {
}
void MainMenu::AddOnLRPress() {
if (m_current_menu != m_left_menu) {
const auto label = m_current_menu == m_centre_menu ? m_left_menu->GetShortTitle() : m_centre_menu->GetShortTitle();
if (m_current_menu != m_left_menu.get()) {
const auto label = m_current_menu == m_centre_menu.get() ? m_left_menu->GetShortTitle() : m_centre_menu->GetShortTitle();
SetAction(Button::L, Action{i18n::get(label), [this]{
OnLRPress(m_left_menu, Button::L);
OnLRPress(m_left_menu.get(), Button::L);
}});
}
if (m_current_menu != m_right_menu) {
const auto label = m_current_menu == m_centre_menu ? m_right_menu->GetShortTitle() : m_centre_menu->GetShortTitle();
if (m_current_menu != m_right_menu.get()) {
const auto label = m_current_menu == m_centre_menu.get() ? m_right_menu->GetShortTitle() : m_centre_menu->GetShortTitle();
SetAction(Button::R, Action{i18n::get(label), [this]{
OnLRPress(m_right_menu, Button::R);
OnLRPress(m_right_menu.get(), Button::R);
}});
}
}

View File

@@ -215,15 +215,12 @@ void FakeNacpEntryForSystem(Entry& e) {
// fake the nacp entry
std::snprintf(e.lang.name, sizeof(e.lang.name), "%s | %016lX", GetSystemSaveName(e.system_save_data_id), e.system_save_data_id);
std::strcpy(e.lang.author, "Nintendo");
e.info.reset();
}
bool LoadControlImage(Entry& e) {
if (!e.image && e.info && !e.info->icon.empty()) {
ON_SCOPE_EXIT(e.info.reset());
bool LoadControlImage(Entry& e, title::ThreadResultData* result) {
if (!e.image && result && !result->icon.empty()) {
TimeStamp ts;
const auto image = ImageLoadFromMemory(e.info->icon, ImageFlag_JPEG);
const auto image = ImageLoadFromMemory(result->icon, ImageFlag_JPEG);
if (!image.data.empty()) {
e.image = nvgCreateImageRGBA(App::GetVg(), image.w, image.h, 0, image.data.data());
log_write("\t[image load] time taken: %.2fs %zums\n", ts.GetSecondsD(), ts.GetMs());
@@ -234,8 +231,7 @@ bool LoadControlImage(Entry& e) {
return false;
}
void LoadResultIntoEntry(Entry& e, const std::shared_ptr<title::ThreadResultData>& result) {
e.info = result;
void LoadResultIntoEntry(Entry& e, title::ThreadResultData* result) {
e.status = result->status;
e.lang = result->lang;
e.status = result->status;
@@ -251,7 +247,7 @@ void LoadControlEntry(Entry& e, bool force_image_load = false) {
}
if (force_image_load && e.status == title::NacpLoadStatus::Loaded) {
LoadControlImage(e);
LoadControlImage(e, title::Get(e.application_id));
}
}
@@ -330,8 +326,8 @@ Menu::Menu(u32 flags) : grid::Menu{"Saves"_i18n, flags} {
SetPop();
}}),
std::make_pair(Button::X, Action{"Options"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Save Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
auto options = std::make_unique<Sidebar>("Save Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
SidebarEntryArray::Items account_items;
for (const auto& e : m_accounts) {
@@ -347,9 +343,9 @@ Menu::Menu(u32 flags) : grid::Menu{"Saves"_i18n, flags} {
data_type_items.emplace_back("Cache"_i18n);
data_type_items.emplace_back("System BCAT"_i18n);
options->Add(std::make_shared<SidebarEntryCallback>("Sort By"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Sort Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
options->Add(std::make_unique<SidebarEntryCallback>("Sort By"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Sort Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
SidebarEntryArray::Items sort_items;
sort_items.push_back("Updated"_i18n);
@@ -363,36 +359,36 @@ Menu::Menu(u32 flags) : grid::Menu{"Saves"_i18n, flags} {
layout_items.push_back("Icon"_i18n);
layout_items.push_back("Grid"_i18n);
options->Add(std::make_shared<SidebarEntryArray>("Sort"_i18n, sort_items, [this](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Sort"_i18n, sort_items, [this](s64& index_out){
m_sort.Set(index_out);
SortAndFindLastFile(false);
}, m_sort.Get()));
options->Add(std::make_shared<SidebarEntryArray>("Order"_i18n, order_items, [this](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Order"_i18n, order_items, [this](s64& index_out){
m_order.Set(index_out);
SortAndFindLastFile(false);
}, m_order.Get()));
options->Add(std::make_shared<SidebarEntryArray>("Layout"_i18n, layout_items, [this](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Layout"_i18n, layout_items, [this](s64& index_out){
m_layout.Set(index_out);
OnLayoutChange();
}, m_layout.Get()));
}));
options->Add(std::make_shared<SidebarEntryArray>("Account"_i18n, account_items, [this](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Account"_i18n, account_items, [this](s64& index_out){
m_account_index = index_out;
m_dirty = true;
App::PopToMenu();
}, m_account_index));
options->Add(std::make_shared<SidebarEntryArray>("Data Type"_i18n, data_type_items, [this](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Data Type"_i18n, data_type_items, [this](s64& index_out){
m_data_type = index_out;
m_dirty = true;
App::PopToMenu();
}, m_data_type));
if (m_entries.size()) {
options->Add(std::make_shared<SidebarEntryCallback>("Backup"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Backup"_i18n, [this](){
std::vector<std::reference_wrapper<Entry>> entries;
if (m_selected_count) {
for (auto& e : m_entries) {
@@ -408,21 +404,21 @@ Menu::Menu(u32 flags) : grid::Menu{"Saves"_i18n, flags} {
}, true));
if (m_entries[m_index].save_data_type == FsSaveDataType_Account || m_entries[m_index].save_data_type == FsSaveDataType_Bcat) {
options->Add(std::make_shared<SidebarEntryCallback>("Restore"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Restore"_i18n, [this](){
RestoreSave();
}, true));
}
}
options->Add(std::make_shared<SidebarEntryCallback>("Advanced"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Advanced Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
options->Add(std::make_unique<SidebarEntryCallback>("Advanced"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Advanced Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_shared<SidebarEntryBool>("Auto backup on restore"_i18n, m_auto_backup_on_restore.Get(), [this](bool& v_out){
options->Add(std::make_unique<SidebarEntryBool>("Auto backup on restore"_i18n, m_auto_backup_on_restore.Get(), [this](bool& v_out){
m_auto_backup_on_restore.Set(v_out);
}));
options->Add(std::make_shared<SidebarEntryBool>("Compress backup"_i18n, m_compress_save_backup.Get(), [this](bool& v_out){
options->Add(std::make_unique<SidebarEntryBool>("Compress backup"_i18n, m_compress_save_backup.Get(), [this](bool& v_out){
m_compress_save_backup.Set(v_out);
}));
}));
@@ -507,14 +503,12 @@ void Menu::Draw(NVGcontext* vg, Theme* theme) {
FakeNacpEntryForSystem(e);
}
} else if (e.status == title::NacpLoadStatus::Progress) {
if (const auto data = title::GetAsync(e.application_id)) {
LoadResultIntoEntry(e, data);
}
LoadResultIntoEntry(e, title::GetAsync(e.application_id));
}
// lazy load image
if (image_load_count < image_load_max) {
if (LoadControlImage(e)) {
if (LoadControlImage(e, title::GetAsync(e.application_id))) {
image_load_count++;
}
}
@@ -683,7 +677,7 @@ void Menu::OnLayoutChange() {
void Menu::BackupSaves(std::vector<std::reference_wrapper<Entry>>& entries) {
dump::DumpGetLocation("Select backup location"_i18n, dump::DumpLocationFlag_SdCard|dump::DumpLocationFlag_Stdio, [this, entries](const dump::DumpLocation& location){
App::Push(std::make_shared<ProgressBox>(0, "Backup"_i18n, "", [this, entries, location](auto pbox) -> Result {
App::Push(std::make_unique<ProgressBox>(0, "Backup"_i18n, "", [this, entries, location](auto pbox) -> Result {
for (auto& e : entries) {
// the entry may not have loaded yet.
LoadControlEntry(e);
@@ -734,7 +728,7 @@ void Menu::RestoreSave() {
}
if (paths.empty()) {
App::Push(std::make_shared<ui::OptionBox>(
App::Push(std::make_unique<ui::OptionBox>(
"No saves found in "_i18n + fs::AppendPath(fs->Root(), BuildSaveBasePath(m_entries[m_index])).toString(),
"OK"_i18n
));
@@ -742,7 +736,7 @@ void Menu::RestoreSave() {
}
const auto title = "Restore save for: "_i18n + m_entries[m_index].GetName();
App::Push(std::make_shared<PopupList>(
App::Push(std::make_unique<PopupList>(
title, items, [this, paths, items, location](auto op_index){
if (!op_index) {
return;
@@ -751,11 +745,11 @@ void Menu::RestoreSave() {
const auto file_name = items[*op_index];
const auto file_path = paths[*op_index];
App::Push(std::make_shared<OptionBox>(
App::Push(std::make_unique<OptionBox>(
"Are you sure you want to restore "_i18n + file_name + "?",
"Back"_i18n, "Restore"_i18n, 0, [this, file_path, location](auto op_index){
if (op_index && *op_index) {
App::Push(std::make_shared<ProgressBox>(0, "Restore"_i18n, "", [this, file_path, location](auto pbox) -> Result {
App::Push(std::make_unique<ProgressBox>(0, "Restore"_i18n, "", [this, file_path, location](auto pbox) -> Result {
// the entry may not have loaded yet.
LoadControlEntry(m_entries[m_index]);
@@ -813,8 +807,8 @@ Result Menu::RestoreSaveInternal(ProgressBox* pbox, const Entry& e, const fs::Fs
pbox->SetTitle(e.GetName());
if (e.image) {
pbox->SetImage(e.image);
} else if (e.info && !e.info->icon.empty()) {
pbox->SetImageDataConst(e.info->icon);
} else if (auto data = title::Get(e.application_id); data && !data->icon.empty()) {
pbox->SetImageDataConst(data->icon);
} else {
pbox->SetImage(0);
}
@@ -940,8 +934,8 @@ Result Menu::BackupSaveInternal(ProgressBox* pbox, const dump::DumpLocation& loc
pbox->SetTitle(e.GetName());
if (e.image) {
pbox->SetImage(e.image);
} else if (e.info && !e.info->icon.empty()) {
pbox->SetImageDataConst(e.info->icon);
} else if (auto data = title::Get(e.application_id); data && !data->icon.empty()) {
pbox->SetImageDataConst(data->icon);
} else {
pbox->SetImage(0);
}

View File

@@ -306,7 +306,7 @@ Menu::Menu(u32 flags) : MenuBase{"Themezer"_i18n, flags} {
this->SetActions(
std::make_pair(Button::A, Action{"Download"_i18n, [this](){
App::Push(std::make_shared<OptionBox>(
App::Push(std::make_unique<OptionBox>(
"Download theme?"_i18n,
"Back"_i18n, "Download"_i18n, 1, [this](auto op_index){
if (op_index && *op_index) {
@@ -315,7 +315,7 @@ Menu::Menu(u32 flags) : MenuBase{"Themezer"_i18n, flags} {
const auto& entry = page.m_packList[m_index];
const auto url = apiBuildUrlDownloadPack(entry);
App::Push(std::make_shared<ProgressBox>(entry.themes[0].preview.lazy_image.image, "Downloading "_i18n, entry.details.name, [this, &entry](auto pbox) -> Result {
App::Push(std::make_unique<ProgressBox>(entry.themes[0].preview.lazy_image.image, "Downloading "_i18n, entry.details.name, [this, &entry](auto pbox) -> Result {
return InstallTheme(pbox, entry);
}, [this, &entry](Result rc){
App::PushErrorBox(rc, "Failed to download theme"_i18n);
@@ -330,8 +330,8 @@ Menu::Menu(u32 flags) : MenuBase{"Themezer"_i18n, flags} {
));
}}),
std::make_pair(Button::X, Action{"Options"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Themezer Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(options));
auto options = std::make_unique<Sidebar>("Themezer Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options)));
SidebarEntryArray::Items sort_items;
sort_items.push_back("Downloads"_i18n);
@@ -343,26 +343,26 @@ Menu::Menu(u32 flags) : MenuBase{"Themezer"_i18n, flags} {
order_items.push_back("Descending (down)"_i18n);
order_items.push_back("Ascending (Up)"_i18n);
options->Add(std::make_shared<SidebarEntryBool>("Nsfw"_i18n, m_nsfw.Get(), [this](bool& v_out){
options->Add(std::make_unique<SidebarEntryBool>("Nsfw"_i18n, m_nsfw.Get(), [this](bool& v_out){
m_nsfw.Set(v_out);
InvalidateAllPages();
}));
options->Add(std::make_shared<SidebarEntryArray>("Sort"_i18n, sort_items, [this, sort_items](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Sort"_i18n, sort_items, [this, sort_items](s64& index_out){
if (m_sort.Get() != index_out) {
m_sort.Set(index_out);
InvalidateAllPages();
}
}, m_sort.Get()));
options->Add(std::make_shared<SidebarEntryArray>("Order"_i18n, order_items, [this, order_items](s64& index_out){
options->Add(std::make_unique<SidebarEntryArray>("Order"_i18n, order_items, [this, order_items](s64& index_out){
if (m_order.Get() != index_out) {
m_order.Set(index_out);
InvalidateAllPages();
}
}, m_order.Get()));
options->Add(std::make_shared<SidebarEntryCallback>("Page"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Page"_i18n, [this](){
s64 out;
if (R_SUCCEEDED(swkbd::ShowNumPad(out, "Enter Page Number"_i18n.c_str(), nullptr, -1, 3))) {
if (out < m_page_index_max) {
@@ -375,7 +375,7 @@ Menu::Menu(u32 flags) : MenuBase{"Themezer"_i18n, flags} {
}
}));
options->Add(std::make_shared<SidebarEntryCallback>("Search"_i18n, [this](){
options->Add(std::make_unique<SidebarEntryCallback>("Search"_i18n, [this](){
std::string out;
if (R_SUCCEEDED(swkbd::ShowText(out)) && !out.empty()) {
m_search = out;

View File

@@ -68,7 +68,7 @@ Menu::Menu(u32 flags) : MenuBase{"USB"_i18n, flags} {
}
// 3 second timeout for transfers.
m_usb_source = std::make_shared<yati::source::Usb>(TRANSFER_TIMEOUT);
m_usb_source = std::make_unique<yati::source::Usb>(TRANSFER_TIMEOUT);
if (R_FAILED(m_usb_source->GetOpenResult())) {
log_write("usb init open\n");
m_state = State::Failed;
@@ -109,13 +109,13 @@ void Menu::Update(Controller* controller, TouchInfo* touch) {
log_write("set to progress\n");
m_state = State::Progress;
log_write("got connection\n");
App::Push(std::make_shared<ui::ProgressBox>(0, "Installing "_i18n, "", [this](auto pbox) -> Result {
App::Push(std::make_unique<ui::ProgressBox>(0, "Installing "_i18n, "", [this](auto pbox) -> Result {
ON_SCOPE_EXIT(m_usb_source->Finished(FINISHED_TIMEOUT));
log_write("inside progress box\n");
for (const auto& file_name : m_names) {
m_usb_source->SetFileNameForTranfser(file_name);
const auto rc = yati::InstallFromSource(pbox, m_usb_source, file_name);
const auto rc = yati::InstallFromSource(pbox, m_usb_source.get(), file_name);
if (R_FAILED(rc)) {
m_usb_source->SignalCancel();
log_write("exiting usb install\n");

View File

@@ -25,7 +25,7 @@ ProgressBox::ProgressBox(int image, const std::string& action, const std::string
}
SetAction(Button::B, Action{"Back"_i18n, [this](){
App::Push(std::make_shared<OptionBox>("Are you sure you wish to cancel?"_i18n, "No"_i18n, "Yes"_i18n, 1, [this](auto op_index){
App::Push(std::make_unique<OptionBox>("Are you sure you wish to cancel?"_i18n, "No"_i18n, "Yes"_i18n, 1, [this](auto op_index){
if (op_index && *op_index) {
RequestExit();
SetPop();

View File

@@ -26,7 +26,7 @@ auto DistanceBetweenY(Vec4 va, Vec4 vb) -> Vec4 {
} // namespace
SidebarEntryBase::SidebarEntryBase(std::string&& title)
: m_title{std::forward<std::string>(title)} {
: m_title{std::forward<decltype(title)>(title)} {
}
@@ -114,13 +114,13 @@ SidebarEntryArray::SidebarEntryArray(std::string title, Items items, std::string
}
m_list_callback = [&index, this]() {
App::Push(std::make_shared<PopupList>(
App::Push(std::make_unique<PopupList>(
m_title, m_items, index, m_index
));
};
// m_callback = [&index, this](auto& idx) {
// App::Push(std::make_shared<PopupList>(
// App::Push(std::make_unique<PopupList>(
// m_title, m_items, index, idx
// ));
// };
@@ -136,13 +136,13 @@ SidebarEntryArray::SidebarEntryArray(std::string title, Items items, Callback cb
}
SidebarEntryArray::SidebarEntryArray(std::string title, Items items, Callback cb, s64 index)
: SidebarEntryBase{std::forward<std::string>(title)}
: SidebarEntryBase{std::forward<decltype(title)>(title)}
, m_items{std::move(items)}
, m_callback{cb}
, m_index{index} {
m_list_callback = [this]() {
App::Push(std::make_shared<PopupList>(
App::Push(std::make_unique<PopupList>(
m_title, m_items, [this](auto op_idx){
if (op_idx) {
m_index = *op_idx;
@@ -219,7 +219,7 @@ auto SidebarEntryArray::OnFocusLost() noexcept -> void {
}
Sidebar::Sidebar(std::string title, Side side, Items&& items)
: Sidebar{std::move(title), "", side, std::forward<Items>(items)} {
: Sidebar{std::move(title), "", side, std::forward<decltype(items)>(items)} {
}
Sidebar::Sidebar(std::string title, Side side)
@@ -230,7 +230,7 @@ Sidebar::Sidebar(std::string title, std::string sub, Side side, Items&& items)
: m_title{std::move(title)}
, m_sub{std::move(sub)}
, m_side{side}
, m_items{std::forward<Items>(items)} {
, m_items{std::forward<decltype(items)>(items)} {
switch (m_side) {
case Side::LEFT:
SetPos(Vec4{0.f, 0.f, 450.f, 720.f});
@@ -313,8 +313,8 @@ auto Sidebar::OnFocusLost() noexcept -> void {
SetHidden(true);
}
void Sidebar::Add(std::shared_ptr<SidebarEntryBase> entry) {
m_items.emplace_back(entry);
void Sidebar::Add(std::unique_ptr<SidebarEntryBase>&& entry) {
m_items.emplace_back(std::forward<decltype(entry)>(entry));
m_items.back()->SetPos(m_base_pos);
// give focus to first entry.

View File

@@ -62,12 +62,12 @@ Result Hfs0GetPartition(source::Base* source, s64 off, Hfs0& out) {
Result Xci::GetCollections(Collections& out) {
Hfs0 root{};
R_TRY(Hfs0GetPartition(m_source.get(), HFS0_HEADER_OFFSET, root));
R_TRY(Hfs0GetPartition(m_source, HFS0_HEADER_OFFSET, root));
for (u32 i = 0; i < root.header.total_files; i++) {
if (root.string_table[i] == "secure") {
Hfs0 secure{};
R_TRY(Hfs0GetPartition(m_source.get(), root.data_offset + root.file_table[i].data_offset, secure));
R_TRY(Hfs0GetPartition(m_source, root.data_offset + root.file_table[i].data_offset, secure));
for (u32 i = 0; i < secure.header.total_files; i++) {
CollectionEntry entry;

View File

@@ -252,7 +252,7 @@ struct ThreadData {
};
struct Yati {
Yati(ui::ProgressBox*, std::shared_ptr<source::Base>);
Yati(ui::ProgressBox*, source::Base*);
~Yati();
Result Setup(const ConfigOverride& override);
@@ -274,7 +274,7 @@ struct Yati {
// private:
ui::ProgressBox* pbox{};
std::shared_ptr<source::Base> source{};
source::Base* source{};
// for all content storages
NcmContentStorage ncm_cs[2]{};
@@ -793,7 +793,7 @@ struct BufHelper {
u64 offset{};
};
Yati::Yati(ui::ProgressBox* _pbox, std::shared_ptr<source::Base> _source) : pbox{_pbox}, source{_source} {
Yati::Yati(ui::ProgressBox* _pbox, source::Base* _source) : pbox{_pbox}, source{_source} {
App::SetAutoSleepDisabled(true);
}
@@ -1293,7 +1293,7 @@ Result Yati::RegisterNcasAndPushRecord(const CnmtCollection& cnmt, u32 latest_ve
R_SUCCEED();
}
Result InstallInternal(ui::ProgressBox* pbox, std::shared_ptr<source::Base> source, const container::Collections& collections, const ConfigOverride& override) {
Result InstallInternal(ui::ProgressBox* pbox, source::Base* source, const container::Collections& collections, const ConfigOverride& override) {
auto yati = std::make_unique<Yati>(pbox, source);
R_TRY(yati->Setup(override));
@@ -1343,7 +1343,7 @@ Result InstallInternal(ui::ProgressBox* pbox, std::shared_ptr<source::Base> sour
R_SUCCEED();
}
Result InstallInternalStream(ui::ProgressBox* pbox, std::shared_ptr<source::Base> source, container::Collections collections, const ConfigOverride& override) {
Result InstallInternalStream(ui::ProgressBox* pbox, source::Base* source, container::Collections collections, const ConfigOverride& override) {
auto yati = std::make_unique<Yati>(pbox, source);
R_TRY(yati->Setup(override));
@@ -1442,30 +1442,33 @@ Result InstallInternalStream(ui::ProgressBox* pbox, std::shared_ptr<source::Base
} // namespace
Result InstallFromFile(ui::ProgressBox* pbox, fs::Fs* fs, const fs::FsPath& path, const ConfigOverride& override) {
return InstallFromSource(pbox, std::make_shared<source::File>(fs, path), path, override);
// return InstallFromSource(pbox, std::make_shared<source::StreamFile>(fs, path), path, override);
auto source = std::make_unique<source::File>(fs, path);
// auto source = std::make_unique<source::StreamFile>(fs, path); // enable for testing.
return InstallFromSource(pbox, source.get(), path, override);
}
Result InstallFromSource(ui::ProgressBox* pbox, std::shared_ptr<source::Base> source, const fs::FsPath& path, const ConfigOverride& override) {
Result InstallFromSource(ui::ProgressBox* pbox, source::Base* source, const fs::FsPath& path, const ConfigOverride& override) {
const auto ext = std::strrchr(path.s, '.');
R_UNLESS(ext, Result_YatiContainerNotFound);
std::unique_ptr<container::Base> container;
if (!strcasecmp(ext, ".nsp") || !strcasecmp(ext, ".nsz")) {
return InstallFromContainer(pbox, std::make_unique<container::Nsp>(source), override);
container = std::make_unique<container::Nsp>(source);
} else if (!strcasecmp(ext, ".xci") || !strcasecmp(ext, ".xcz")) {
return InstallFromContainer(pbox, std::make_unique<container::Xci>(source), override);
container = std::make_unique<container::Xci>(source);
}
R_THROW(Result_YatiContainerNotFound);
R_UNLESS(container, Result_YatiContainerNotFound);
return InstallFromContainer(pbox, container.get(), override);
}
Result InstallFromContainer(ui::ProgressBox* pbox, std::shared_ptr<container::Base> container, const ConfigOverride& override) {
Result InstallFromContainer(ui::ProgressBox* pbox, container::Base* container, const ConfigOverride& override) {
container::Collections collections;
R_TRY(container->GetCollections(collections));
return InstallFromCollections(pbox, container->GetSource(), collections);
}
Result InstallFromCollections(ui::ProgressBox* pbox, std::shared_ptr<source::Base> source, const container::Collections& collections, const ConfigOverride& override) {
Result InstallFromCollections(ui::ProgressBox* pbox, source::Base* source, const container::Collections& collections, const ConfigOverride& override) {
if (source->IsStream()) {
return InstallInternalStream(pbox, source, collections, override);
} else {