reduce explicit calls to make_unique by having app::push and options::add call it for us.

this commit doesn't change the codegen. it just cleans up the code slightly.
This commit is contained in:
ITotalJustice
2025-06-25 19:17:01 +01:00
parent 38f19ec778
commit 4e3927bbd0
20 changed files with 466 additions and 461 deletions

View File

@@ -18,6 +18,7 @@
#include <string> #include <string>
#include <span> #include <span>
#include <optional> #include <optional>
#include <utility>
namespace sphaira { namespace sphaira {
@@ -58,7 +59,14 @@ public:
static void Exit(); static void Exit();
static void ExitRestart(); static void ExitRestart();
static auto GetVg() -> NVGcontext*; static auto GetVg() -> NVGcontext*;
static void Push(std::unique_ptr<ui::Widget>&&); static void Push(std::unique_ptr<ui::Widget>&&);
template<ui::DerivedFromWidget T, typename... Args>
static void Push(Args&&... args) {
Push(std::make_unique<T>(std::forward<Args>(args)...));
}
// pops all widgets above a menu // pops all widgets above a menu
static void PopToMenu(); static void PopToMenu();

View File

@@ -3,6 +3,8 @@
#include "ui/widget.hpp" #include "ui/widget.hpp"
#include "ui/list.hpp" #include "ui/list.hpp"
#include <memory> #include <memory>
#include <concepts>
#include <utility>
namespace sphaira::ui { namespace sphaira::ui {
@@ -15,6 +17,9 @@ protected:
std::string m_title; std::string m_title;
}; };
template<typename T>
concept DerivedFromSidebarBase = std::is_base_of_v<SidebarEntryBase, T>;
class SidebarEntryBool final : public SidebarEntryBase { class SidebarEntryBool final : public SidebarEntryBase {
public: public:
using Callback = std::function<void(bool&)>; using Callback = std::function<void(bool&)>;
@@ -110,17 +115,11 @@ public:
void Add(std::unique_ptr<SidebarEntryBase>&& entry); void Add(std::unique_ptr<SidebarEntryBase>&& entry);
template<typename T> template<DerivedFromSidebarBase T, typename... Args>
void AddMove(T entry) { void Add(Args&&... args) {
Add(std::move(entry)); Add(std::make_unique<T>(std::forward<Args>(args)...));
} }
// 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: private:
void SetIndex(s64 index); void SetIndex(s64 index);
void SetupButtons(); void SetupButtons();

View File

@@ -5,6 +5,7 @@
#include <memory> #include <memory>
#include <map> #include <map>
#include <unordered_map> #include <unordered_map>
#include <concepts>
namespace sphaira::ui { namespace sphaira::ui {
@@ -90,4 +91,7 @@ struct Widget : public Object {
bool m_pop{false}; bool m_pop{false};
}; };
template<typename T>
concept DerivedFromWidget = std::is_base_of_v<Widget, T>;
} // namespace sphaira::ui } // namespace sphaira::ui

View File

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

View File

@@ -342,16 +342,16 @@ void DumpGetLocation(const std::string& title, u32 location_flags, const OnLocat
} }
} }
App::Push(std::make_unique<ui::PopupList>( App::Push<ui::PopupList>(
title, items, [dump_entries, out, on_loc](auto op_index) mutable { title, items, [dump_entries, out, on_loc](auto op_index) mutable {
out.entry = dump_entries[*op_index]; out.entry = dump_entries[*op_index];
on_loc(out); on_loc(out);
} }
)); );
} }
void Dump(const std::shared_ptr<BaseSource>& source, const DumpLocation& location, const std::vector<fs::FsPath>& paths, const OnExit& on_exit) { 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 { App::Push<ui::ProgressBox>(0, "Dumping"_i18n, "", [source, paths, location](auto pbox) -> Result {
if (location.entry.type == DumpLocationType_Network) { if (location.entry.type == DumpLocationType_Network) {
R_TRY(DumpToNetwork(pbox, location.network[location.entry.index], source.get(), paths)); R_TRY(DumpToNetwork(pbox, location.network[location.entry.index], source.get(), paths));
} else if (location.entry.type == DumpLocationType_Stdio) { } else if (location.entry.type == DumpLocationType_Stdio) {
@@ -374,7 +374,7 @@ void Dump(const std::shared_ptr<BaseSource>& source, const DumpLocation& locatio
} }
on_exit(rc); on_exit(rc);
})); });
} }
void Dump(const std::shared_ptr<BaseSource>& source, const std::vector<fs::FsPath>& paths, const OnExit& on_exit, u32 location_flags) { void Dump(const std::shared_ptr<BaseSource>& source, const std::vector<fs::FsPath>& paths, const OnExit& on_exit, u32 location_flags) {

View File

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

View File

@@ -590,12 +590,12 @@ EntryMenu::EntryMenu(Entry& entry, const LazyImage& default_icon, Menu& menu)
auto options = std::make_unique<Sidebar>("Options"_i18n, Sidebar::Side::RIGHT); auto options = std::make_unique<Sidebar>("Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options))); ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_unique<SidebarEntryCallback>("More by Author"_i18n, [this](){ options->Add<SidebarEntryCallback>("More by Author"_i18n, [this](){
m_menu.SetAuthor(); m_menu.SetAuthor();
SetPop(); SetPop();
}, true)); }, true);
options->Add(std::make_unique<SidebarEntryCallback>("Leave Feedback"_i18n, [this](){ options->Add<SidebarEntryCallback>("Leave Feedback"_i18n, [this](){
std::string out; std::string out;
if (R_SUCCEEDED(swkbd::ShowText(out)) && !out.empty()) { if (R_SUCCEEDED(swkbd::ShowText(out)) && !out.empty()) {
const auto post = "name=" "switch_user" "&package=" + m_entry.name + "&message=" + out; const auto post = "name=" "switch_user" "&package=" + m_entry.name + "&message=" + out;
@@ -615,12 +615,12 @@ EntryMenu::EntryMenu(Entry& entry, const LazyImage& default_icon, Menu& menu)
} }
}); });
} }
}, true)); }, true);
if (App::IsApplication() && !m_entry.url.empty()) { if (App::IsApplication() && !m_entry.url.empty()) {
options->Add(std::make_unique<SidebarEntryCallback>("Visit Website"_i18n, [this](){ options->Add<SidebarEntryCallback>("Visit Website"_i18n, [this](){
WebShow(m_entry.url); WebShow(m_entry.url);
})); });
} }
}}), }}),
std::make_pair(Button::B, Action{"Back"_i18n, [this](){ std::make_pair(Button::B, Action{"Back"_i18n, [this](){
@@ -796,7 +796,7 @@ void EntryMenu::UpdateOptions() {
}; };
const auto install = [this](){ const auto install = [this](){
App::Push(std::make_unique<ProgressBox>(m_entry.image.image, "Downloading "_i18n, m_entry.title, [this](auto pbox){ App::Push<ProgressBox>(m_entry.image.image, "Downloading "_i18n, m_entry.title, [this](auto pbox){
return InstallApp(pbox, m_entry); return InstallApp(pbox, m_entry);
}, [this](Result rc){ }, [this](Result rc){
homebrew::SignalChange(); homebrew::SignalChange();
@@ -808,11 +808,11 @@ void EntryMenu::UpdateOptions() {
m_menu.SetDirty(); m_menu.SetDirty();
UpdateOptions(); UpdateOptions();
} }
})); });
}; };
const auto uninstall = [this](){ const auto uninstall = [this](){
App::Push(std::make_unique<ProgressBox>(m_entry.image.image, "Uninstalling "_i18n, m_entry.title, [this](auto pbox){ App::Push<ProgressBox>(m_entry.image.image, "Uninstalling "_i18n, m_entry.title, [this](auto pbox){
return UninstallApp(pbox, m_entry); return UninstallApp(pbox, m_entry);
}, [this](Result rc){ }, [this](Result rc){
homebrew::SignalChange(); homebrew::SignalChange();
@@ -824,7 +824,7 @@ void EntryMenu::UpdateOptions() {
m_menu.SetDirty(); m_menu.SetDirty();
UpdateOptions(); UpdateOptions();
} }
})); });
}; };
const Option install_option{"Install"_i18n, install}; const Option install_option{"Install"_i18n, install};
@@ -865,11 +865,11 @@ void EntryMenu::SetIndex(s64 index) {
SetAction(Button::A, Action{option.display_text, option.func}); SetAction(Button::A, Action{option.display_text, option.func});
} else { } else {
SetAction(Button::A, Action{option.display_text, [this, option](){ SetAction(Button::A, Action{option.display_text, [this, option](){
App::Push(std::make_unique<OptionBox>(option.confirm_text, "No"_i18n, "Yes"_i18n, 1, [this, option](auto op_index){ App::Push<OptionBox>(option.confirm_text, "No"_i18n, "Yes"_i18n, 1, [this, option](auto op_index){
if (op_index && *op_index) { if (op_index && *op_index) {
option.func(); option.func();
} }
})); });
}}); }});
} }
} }
@@ -915,7 +915,7 @@ 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()); // log_write("pushing A when empty: size: %zu count: %zu\n", repo_json.size(), m_entries_current.size());
return; return;
} }
App::Push(std::make_unique<EntryMenu>(m_entries[m_entries_current[m_index]], m_default_image, *this)); App::Push<EntryMenu>(m_entries[m_entries_current[m_index]], m_default_image, *this);
}}), }}),
std::make_pair(Button::X, Action{"Options"_i18n, [this](){ std::make_pair(Button::X, Action{"Options"_i18n, [this](){
auto options = std::make_unique<Sidebar>("AppStore Options"_i18n, Sidebar::Side::RIGHT); auto options = std::make_unique<Sidebar>("AppStore Options"_i18n, Sidebar::Side::RIGHT);
@@ -946,33 +946,33 @@ Menu::Menu(u32 flags) : grid::Menu{"AppStore"_i18n, flags} {
layout_items.push_back("Icon"_i18n); layout_items.push_back("Icon"_i18n);
layout_items.push_back("Grid"_i18n); layout_items.push_back("Grid"_i18n);
options->Add(std::make_unique<SidebarEntryArray>("Filter"_i18n, filter_items, [this](s64& index_out){ options->Add<SidebarEntryArray>("Filter"_i18n, filter_items, [this](s64& index_out){
m_filter.Set(index_out); m_filter.Set(index_out);
SetFilter(); SetFilter();
}, m_filter.Get())); }, m_filter.Get());
options->Add(std::make_unique<SidebarEntryArray>("Sort"_i18n, sort_items, [this](s64& index_out){ options->Add<SidebarEntryArray>("Sort"_i18n, sort_items, [this](s64& index_out){
m_sort.Set(index_out); m_sort.Set(index_out);
SortAndFindLastFile(); SortAndFindLastFile();
}, m_sort.Get())); }, m_sort.Get());
options->Add(std::make_unique<SidebarEntryArray>("Order"_i18n, order_items, [this](s64& index_out){ options->Add<SidebarEntryArray>("Order"_i18n, order_items, [this](s64& index_out){
m_order.Set(index_out); m_order.Set(index_out);
SortAndFindLastFile(); SortAndFindLastFile();
}, m_order.Get())); }, m_order.Get());
options->Add(std::make_unique<SidebarEntryArray>("Layout"_i18n, layout_items, [this](s64& index_out){ options->Add<SidebarEntryArray>("Layout"_i18n, layout_items, [this](s64& index_out){
m_layout.Set(index_out); m_layout.Set(index_out);
OnLayoutChange(); OnLayoutChange();
}, m_layout.Get())); }, m_layout.Get());
options->Add(std::make_unique<SidebarEntryCallback>("Search"_i18n, [this](){ options->Add<SidebarEntryCallback>("Search"_i18n, [this](){
std::string out; std::string out;
if (R_SUCCEEDED(swkbd::ShowText(out)) && !out.empty()) { if (R_SUCCEEDED(swkbd::ShowText(out)) && !out.empty()) {
SetSearch(out); SetSearch(out);
log_write("got %s\n", out.c_str()); log_write("got %s\n", out.c_str());
} }
})); });
}}) }})
); );

View File

@@ -332,13 +332,13 @@ FsView::FsView(Menu* menu, const fs::FsPath& path, const FsEntry& entry, ViewSid
} }
if (IsSd() && m_is_update_folder && m_daybreak_path.has_value()) { if (IsSd() && m_is_update_folder && m_daybreak_path.has_value()) {
App::Push(std::make_unique<OptionBox>("Open with DayBreak?"_i18n, "No"_i18n, "Yes"_i18n, 1, [this](auto op_index){ App::Push<OptionBox>("Open with DayBreak?"_i18n, "No"_i18n, "Yes"_i18n, 1, [this](auto op_index){
if (op_index && *op_index) { if (op_index && *op_index) {
// daybreak uses native fs so do not use nro_add_arg_file // daybreak uses native fs so do not use nro_add_arg_file
// otherwise it'll fail to open the folder... // otherwise it'll fail to open the folder...
nro_launch(m_daybreak_path.value(), nro_add_arg(m_path)); nro_launch(m_daybreak_path.value(), nro_add_arg(m_path));
} }
})); });
return; return;
} }
@@ -349,12 +349,12 @@ FsView::FsView(Menu* menu, const fs::FsPath& path, const FsEntry& entry, ViewSid
} else { } else {
// special case for nro // special case for nro
if (IsSd() && entry.GetExtension() == "nro") { if (IsSd() && entry.GetExtension() == "nro") {
App::Push(std::make_unique<OptionBox>("Launch "_i18n + entry.GetName() + '?', App::Push<OptionBox>("Launch "_i18n + entry.GetName() + '?',
"No"_i18n, "Launch"_i18n, 1, [this](auto op_index){ "No"_i18n, "Launch"_i18n, 1, [this](auto op_index){
if (op_index && *op_index) { if (op_index && *op_index) {
nro_launch(GetNewPathCurrent()); nro_launch(GetNewPathCurrent());
} }
})); });
} else if (App::GetInstallEnable() && IsExtension(entry.GetExtension(), INSTALL_EXTENSIONS)) { } else if (App::GetInstallEnable() && IsExtension(entry.GetExtension(), INSTALL_EXTENSIONS)) {
InstallFiles(); InstallFiles();
} else if (IsSd()) { } else if (IsSd()) {
@@ -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; const auto title = "Launch option for: "_i18n + GetEntry().name;
App::Push(std::make_unique<PopupList>( App::Push<PopupList>(
title, items, [this, assoc_list](auto op_index){ title, items, [this, assoc_list](auto op_index){
if (op_index) { if (op_index) {
log_write("selected: %s\n", assoc_list[*op_index].name.c_str()); log_write("selected: %s\n", assoc_list[*op_index].name.c_str());
@@ -380,7 +380,7 @@ FsView::FsView(Menu* menu, const fs::FsPath& path, const FsEntry& entry, ViewSid
} }
} }
)); );
} else { } else {
log_write("assoc list is empty\n"); log_write("assoc list is empty\n");
} }
@@ -642,12 +642,12 @@ void FsView::InstallForwarder() {
} }
const auto title = std::string{"Select launcher for: "_i18n} + GetEntry().name; const auto title = std::string{"Select launcher for: "_i18n} + GetEntry().name;
App::Push(std::make_unique<PopupList>( App::Push<PopupList>(
title, items, [this, assoc_list](auto op_index){ title, items, [this, assoc_list](auto op_index){
if (op_index) { if (op_index) {
const auto assoc = assoc_list[*op_index]; const auto assoc = assoc_list[*op_index];
log_write("pushing it\n"); log_write("pushing it\n");
App::Push(std::make_unique<ProgressBox>(0, "Installing Forwarder"_i18n, GetEntry().name, [assoc, this](auto pbox) -> Result { App::Push<ProgressBox>(0, "Installing Forwarder"_i18n, GetEntry().name, [assoc, this](auto pbox) -> Result {
log_write("inside callback\n"); log_write("inside callback\n");
NroEntry nro{}; NroEntry nro{};
@@ -690,22 +690,22 @@ void FsView::InstallForwarder() {
App::PlaySoundEffect(SoundEffect_Install); App::PlaySoundEffect(SoundEffect_Install);
App::Notify("Installed!"_i18n); App::Notify("Installed!"_i18n);
} }
})); });
} else { } else {
log_write("pressed B to skip launch...\n"); log_write("pressed B to skip launch...\n");
} }
} }
)); );
} }
void FsView::InstallFiles() { void FsView::InstallFiles() {
const auto targets = GetSelectedEntries(); const auto targets = GetSelectedEntries();
App::Push(std::make_unique<OptionBox>("Install Selected files?"_i18n, "No"_i18n, "Yes"_i18n, 0, [this, targets](auto op_index){ App::Push<OptionBox>("Install Selected files?"_i18n, "No"_i18n, "Yes"_i18n, 0, [this, targets](auto op_index){
if (op_index && *op_index) { if (op_index && *op_index) {
App::PopToMenu(); App::PopToMenu();
App::Push(std::make_unique<ui::ProgressBox>(0, "Installing "_i18n, "", [this, targets](auto pbox) -> Result { App::Push<ui::ProgressBox>(0, "Installing "_i18n, "", [this, targets](auto pbox) -> Result {
for (auto& e : targets) { for (auto& e : targets) {
R_TRY(yati::InstallFromFile(pbox, m_fs.get(), GetNewPath(e))); R_TRY(yati::InstallFromFile(pbox, m_fs.get(), GetNewPath(e)));
App::Notify("Installed "_i18n + e.GetName()); App::Notify("Installed "_i18n + e.GetName());
@@ -714,9 +714,9 @@ void FsView::InstallFiles() {
R_SUCCEED(); R_SUCCEED();
}, [this](Result rc){ }, [this](Result rc){
App::PushErrorBox(rc, "File install failed!"_i18n); App::PushErrorBox(rc, "File install failed!"_i18n);
})); });
} }
})); });
} }
void FsView::UnzipFiles(fs::FsPath dir_path) { void FsView::UnzipFiles(fs::FsPath dir_path) {
@@ -727,7 +727,7 @@ void FsView::UnzipFiles(fs::FsPath dir_path) {
dir_path = m_path; dir_path = m_path;
} }
App::Push(std::make_unique<ui::ProgressBox>(0, "Extracting "_i18n, "", [this, dir_path, targets](auto pbox) -> Result { App::Push<ui::ProgressBox>(0, "Extracting "_i18n, "", [this, dir_path, targets](auto pbox) -> Result {
const auto is_hdd_fs = m_fs->Root().starts_with("ums"); const auto is_hdd_fs = m_fs->Root().starts_with("ums");
for (auto& e : targets) { for (auto& e : targets) {
@@ -746,7 +746,7 @@ void FsView::UnzipFiles(fs::FsPath dir_path) {
Scan(m_path); Scan(m_path);
log_write("did extract\n"); log_write("did extract\n");
})); });
} }
void FsView::ZipFiles(fs::FsPath zip_out) { void FsView::ZipFiles(fs::FsPath zip_out) {
@@ -785,7 +785,7 @@ void FsView::ZipFiles(fs::FsPath zip_out) {
} }
} }
App::Push(std::make_unique<ui::ProgressBox>(0, "Compressing "_i18n, "", [this, zip_out, targets](auto pbox) -> Result { App::Push<ui::ProgressBox>(0, "Compressing "_i18n, "", [this, zip_out, targets](auto pbox) -> Result {
const auto t = std::time(NULL); const auto t = std::time(NULL);
const auto tm = std::localtime(&t); const auto tm = std::localtime(&t);
const auto is_hdd_fs = m_fs->Root().starts_with("ums"); const auto is_hdd_fs = m_fs->Root().starts_with("ums");
@@ -859,7 +859,7 @@ void FsView::ZipFiles(fs::FsPath zip_out) {
Scan(m_path); Scan(m_path);
log_write("did compress\n"); log_write("did compress\n");
})); });
} }
void FsView::UploadFiles() { void FsView::UploadFiles() {
@@ -876,14 +876,14 @@ void FsView::UploadFiles() {
items.emplace_back(p.name); items.emplace_back(p.name);
} }
App::Push(std::make_unique<PopupList>( App::Push<PopupList>(
"Select upload location"_i18n, items, [this, network_locations](auto op_index){ "Select upload location"_i18n, items, [this, network_locations](auto op_index){
if (!op_index) { if (!op_index) {
return; return;
} }
const auto loc = network_locations[*op_index]; const auto loc = network_locations[*op_index];
App::Push(std::make_unique<ProgressBox>(0, "Uploading"_i18n, "", [this, loc](auto pbox) -> Result { App::Push<ProgressBox>(0, "Uploading"_i18n, "", [this, loc](auto pbox) -> Result {
auto targets = GetSelectedEntries(); auto targets = GetSelectedEntries();
const auto is_file_based_emummc = App::IsFileBaseEmummc(); const auto is_file_based_emummc = App::IsFileBaseEmummc();
@@ -965,9 +965,9 @@ void FsView::UploadFiles() {
App::Notify("Upload failed!"_i18n); App::Notify("Upload failed!"_i18n);
log_write("Upload failed!!!\n"); log_write("Upload failed!!!\n");
} }
})); });
} }
)); );
} }
auto FsView::Scan(const fs::FsPath& new_path, bool is_walk_up) -> Result { auto FsView::Scan(const fs::FsPath& new_path, bool is_walk_up) -> Result {
@@ -1166,7 +1166,7 @@ void FsView::OnDeleteCallback() {
m_menu->RefreshViews(); m_menu->RefreshViews();
log_write("did delete\n"); log_write("did delete\n");
} else { } else {
App::Push(std::make_unique<ProgressBox>(0, "Deleting"_i18n, "", [this](auto pbox) -> Result { App::Push<ProgressBox>(0, "Deleting"_i18n, "", [this](auto pbox) -> Result {
FsDirCollections collections; FsDirCollections collections;
auto& selected = m_menu->m_selected; auto& selected = m_menu->m_selected;
auto src_fs = selected.m_view->GetFs(); auto src_fs = selected.m_view->GetFs();
@@ -1189,7 +1189,7 @@ void FsView::OnDeleteCallback() {
m_menu->RefreshViews(); m_menu->RefreshViews();
log_write("did delete\n"); log_write("did delete\n");
})); });
} }
} }
@@ -1207,7 +1207,7 @@ void FsView::OnPasteCallback() {
m_menu->RefreshViews(); m_menu->RefreshViews();
} else { } else {
App::Push(std::make_unique<ProgressBox>(0, "Pasting"_i18n, "", [this](auto pbox) -> Result { App::Push<ProgressBox>(0, "Pasting"_i18n, "", [this](auto pbox) -> Result {
auto& selected = m_menu->m_selected; auto& selected = m_menu->m_selected;
auto src_fs = selected.m_view->GetFs(); auto src_fs = selected.m_view->GetFs();
const auto is_same_fs = selected.SameFs(this); const auto is_same_fs = selected.SameFs(this);
@@ -1327,7 +1327,7 @@ void FsView::OnPasteCallback() {
m_menu->RefreshViews(); m_menu->RefreshViews();
log_write("did paste\n"); log_write("did paste\n");
})); });
} }
} }
@@ -1530,7 +1530,7 @@ void FsView::DisplayHash(hash::Type type) {
static std::string hash_out; static std::string hash_out;
hash_out.clear(); hash_out.clear();
App::Push(std::make_unique<ProgressBox>(0, "Hashing"_i18n, GetEntry().name, [this, type](auto pbox) -> Result { App::Push<ProgressBox>(0, "Hashing"_i18n, GetEntry().name, [this, type](auto pbox) -> Result {
const auto full_path = GetNewPathCurrent(); const auto full_path = GetNewPathCurrent();
pbox->NewTransfer(full_path); pbox->NewTransfer(full_path);
R_TRY(hash::Hash(pbox, type, m_fs.get(), full_path, hash_out)); R_TRY(hash::Hash(pbox, type, m_fs.get(), full_path, hash_out));
@@ -1543,16 +1543,16 @@ void FsView::DisplayHash(hash::Type type) {
char buf[0x100]; 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\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()); std::snprintf(buf, sizeof(buf), "%s\n%s", hash::GetTypeStr(type), hash_out.c_str());
App::Push(std::make_unique<OptionBox>(buf, "OK"_i18n)); App::Push<OptionBox>(buf, "OK"_i18n);
} }
})); });
} }
void FsView::DisplayOptions() { void FsView::DisplayOptions() {
auto options = std::make_unique<Sidebar>("File Options"_i18n, Sidebar::Side::RIGHT); auto options = std::make_unique<Sidebar>("File Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options))); ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_unique<SidebarEntryCallback>("Sort By"_i18n, [this](){ options->Add<SidebarEntryCallback>("Sort By"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Sort Options"_i18n, Sidebar::Side::RIGHT); auto options = std::make_unique<Sidebar>("Sort Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options))); ON_SCOPE_EXIT(App::Push(std::move(options)));
@@ -1564,58 +1564,58 @@ void FsView::DisplayOptions() {
order_items.push_back("Descending"_i18n); order_items.push_back("Descending"_i18n);
order_items.push_back("Ascending"_i18n); order_items.push_back("Ascending"_i18n);
options->Add(std::make_unique<SidebarEntryArray>("Sort"_i18n, sort_items, [this](s64& index_out){ options->Add<SidebarEntryArray>("Sort"_i18n, sort_items, [this](s64& index_out){
m_menu->m_sort.Set(index_out); m_menu->m_sort.Set(index_out);
SortAndFindLastFile(); SortAndFindLastFile();
}, m_menu->m_sort.Get())); }, m_menu->m_sort.Get());
options->Add(std::make_unique<SidebarEntryArray>("Order"_i18n, order_items, [this](s64& index_out){ options->Add<SidebarEntryArray>("Order"_i18n, order_items, [this](s64& index_out){
m_menu->m_order.Set(index_out); m_menu->m_order.Set(index_out);
SortAndFindLastFile(); SortAndFindLastFile();
}, m_menu->m_order.Get())); }, m_menu->m_order.Get());
options->Add(std::make_unique<SidebarEntryBool>("Show Hidden"_i18n, m_menu->m_show_hidden.Get(), [this](bool& v_out){ options->Add<SidebarEntryBool>("Show Hidden"_i18n, m_menu->m_show_hidden.Get(), [this](bool& v_out){
m_menu->m_show_hidden.Set(v_out); m_menu->m_show_hidden.Set(v_out);
SortAndFindLastFile(); SortAndFindLastFile();
})); });
options->Add(std::make_unique<SidebarEntryBool>("Folders First"_i18n, m_menu->m_folders_first.Get(), [this](bool& v_out){ options->Add<SidebarEntryBool>("Folders First"_i18n, m_menu->m_folders_first.Get(), [this](bool& v_out){
m_menu->m_folders_first.Set(v_out); m_menu->m_folders_first.Set(v_out);
SortAndFindLastFile(); SortAndFindLastFile();
})); });
options->Add(std::make_unique<SidebarEntryBool>("Hidden Last"_i18n, m_menu->m_hidden_last.Get(), [this](bool& v_out){ options->Add<SidebarEntryBool>("Hidden Last"_i18n, m_menu->m_hidden_last.Get(), [this](bool& v_out){
m_menu->m_hidden_last.Set(v_out); m_menu->m_hidden_last.Set(v_out);
SortAndFindLastFile(); SortAndFindLastFile();
})); });
})); });
if (m_entries_current.size()) { if (m_entries_current.size()) {
options->Add(std::make_unique<SidebarEntryCallback>("Cut"_i18n, [this](){ options->Add<SidebarEntryCallback>("Cut"_i18n, [this](){
m_menu->AddSelectedEntries(SelectedType::Cut); m_menu->AddSelectedEntries(SelectedType::Cut);
}, true)); }, true);
options->Add(std::make_unique<SidebarEntryCallback>("Copy"_i18n, [this](){ options->Add<SidebarEntryCallback>("Copy"_i18n, [this](){
m_menu->AddSelectedEntries(SelectedType::Copy); m_menu->AddSelectedEntries(SelectedType::Copy);
}, true)); }, true);
} }
if (!m_menu->m_selected.Empty() && (m_menu->m_selected.Type() == SelectedType::Cut || m_menu->m_selected.Type() == SelectedType::Copy)) { if (!m_menu->m_selected.Empty() && (m_menu->m_selected.Type() == SelectedType::Cut || m_menu->m_selected.Type() == SelectedType::Copy)) {
options->Add(std::make_unique<SidebarEntryCallback>("Paste"_i18n, [this](){ options->Add<SidebarEntryCallback>("Paste"_i18n, [this](){
const std::string buf = "Paste file(s)?"_i18n; const std::string buf = "Paste file(s)?"_i18n;
App::Push(std::make_unique<OptionBox>( App::Push<OptionBox>(
buf, "No"_i18n, "Yes"_i18n, 0, [this](auto op_index){ buf, "No"_i18n, "Yes"_i18n, 0, [this](auto op_index){
if (op_index && *op_index) { if (op_index && *op_index) {
App::PopToMenu(); App::PopToMenu();
OnPasteCallback(); OnPasteCallback();
} }
})); });
})); });
} }
// can't rename more than 1 file // can't rename more than 1 file
if (m_entries_current.size() && !m_selected_count) { if (m_entries_current.size() && !m_selected_count) {
options->Add(std::make_unique<SidebarEntryCallback>("Rename"_i18n, [this](){ options->Add<SidebarEntryCallback>("Rename"_i18n, [this](){
std::string out; std::string out;
const auto& entry = GetEntry(); const auto& entry = GetEntry();
const auto name = entry.GetName(); const auto name = entry.GetName();
@@ -1639,24 +1639,24 @@ void FsView::DisplayOptions() {
App::PushErrorBox(rc, msg); App::PushErrorBox(rc, msg);
} }
} }
})); });
} }
if (m_entries_current.size()) { if (m_entries_current.size()) {
options->Add(std::make_unique<SidebarEntryCallback>("Delete"_i18n, [this](){ options->Add<SidebarEntryCallback>("Delete"_i18n, [this](){
m_menu->AddSelectedEntries(SelectedType::Delete); m_menu->AddSelectedEntries(SelectedType::Delete);
log_write("clicked on delete\n"); log_write("clicked on delete\n");
App::Push(std::make_unique<OptionBox>( App::Push<OptionBox>(
"Delete Selected files?"_i18n, "No"_i18n, "Yes"_i18n, 0, [this](auto op_index){ "Delete Selected files?"_i18n, "No"_i18n, "Yes"_i18n, 0, [this](auto op_index){
if (op_index && *op_index) { if (op_index && *op_index) {
App::PopToMenu(); App::PopToMenu();
OnDeleteCallback(); OnDeleteCallback();
} }
} }
)); );
log_write("pushed delete\n"); log_write("pushed delete\n");
})); });
} }
// returns true if all entries match the ext array. // returns true if all entries match the ext array.
@@ -1673,81 +1673,81 @@ void FsView::DisplayOptions() {
// if install is enabled, check if all currently selected files are installable. // if install is enabled, check if all currently selected files are installable.
if (m_entries_current.size() && App::GetInstallEnable()) { if (m_entries_current.size() && App::GetInstallEnable()) {
if (check_all_ext(INSTALL_EXTENSIONS)) { if (check_all_ext(INSTALL_EXTENSIONS)) {
options->Add(std::make_unique<SidebarEntryCallback>("Install"_i18n, [this](){ options->Add<SidebarEntryCallback>("Install"_i18n, [this](){
InstallFiles(); InstallFiles();
})); });
} }
} }
if (IsSd() && m_entries_current.size() && !m_selected_count) { if (IsSd() && m_entries_current.size() && !m_selected_count) {
if (App::GetInstallEnable() && GetEntry().IsFile() && (GetEntry().GetExtension() == "nro" || !m_menu->FindFileAssocFor().empty())) { if (App::GetInstallEnable() && GetEntry().IsFile() && (GetEntry().GetExtension() == "nro" || !m_menu->FindFileAssocFor().empty())) {
options->Add(std::make_unique<SidebarEntryCallback>("Install Forwarder"_i18n, [this](){; options->Add<SidebarEntryCallback>("Install Forwarder"_i18n, [this](){;
if (App::GetInstallPrompt()) { if (App::GetInstallPrompt()) {
App::Push(std::make_unique<OptionBox>( App::Push<OptionBox>(
"WARNING: Installing forwarders will lead to a ban!"_i18n, "WARNING: Installing forwarders will lead to a ban!"_i18n,
"Back"_i18n, "Install"_i18n, 0, [this](auto op_index){ "Back"_i18n, "Install"_i18n, 0, [this](auto op_index){
if (op_index && *op_index) { if (op_index && *op_index) {
InstallForwarder(); InstallForwarder();
} }
} }
)); );
} else { } else {
InstallForwarder(); InstallForwarder();
} }
})); });
} }
} }
if (m_entries_current.size()) { if (m_entries_current.size()) {
if (check_all_ext(ZIP_EXTENSIONS)) { if (check_all_ext(ZIP_EXTENSIONS)) {
options->Add(std::make_unique<SidebarEntryCallback>("Extract zip"_i18n, [this](){ options->Add<SidebarEntryCallback>("Extract zip"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Extract Options"_i18n, Sidebar::Side::RIGHT); auto options = std::make_unique<Sidebar>("Extract Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options))); ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_unique<SidebarEntryCallback>("Extract here"_i18n, [this](){ options->Add<SidebarEntryCallback>("Extract here"_i18n, [this](){
UnzipFiles(""); UnzipFiles("");
})); });
options->Add(std::make_unique<SidebarEntryCallback>("Extract to root"_i18n, [this](){ options->Add<SidebarEntryCallback>("Extract to root"_i18n, [this](){
App::Push(std::make_unique<OptionBox>("Are you sure you want to extract to root?"_i18n, App::Push<OptionBox>("Are you sure you want to extract to root?"_i18n,
"No"_i18n, "Yes"_i18n, 0, [this](auto op_index){ "No"_i18n, "Yes"_i18n, 0, [this](auto op_index){
if (op_index && *op_index) { if (op_index && *op_index) {
UnzipFiles(m_fs->Root()); UnzipFiles(m_fs->Root());
} }
})); });
})); });
options->Add(std::make_unique<SidebarEntryCallback>("Extract to..."_i18n, [this](){ options->Add<SidebarEntryCallback>("Extract to..."_i18n, [this](){
std::string out; std::string out;
if (R_SUCCEEDED(swkbd::ShowText(out, "Enter the path to the folder to extract into", fs::AppendPath(m_path, ""))) && !out.empty()) { if (R_SUCCEEDED(swkbd::ShowText(out, "Enter the path to the folder to extract into", fs::AppendPath(m_path, ""))) && !out.empty()) {
UnzipFiles(out); UnzipFiles(out);
} }
})); });
})); });
} }
if (!check_all_ext(ZIP_EXTENSIONS) || m_selected_count) { if (!check_all_ext(ZIP_EXTENSIONS) || m_selected_count) {
options->Add(std::make_unique<SidebarEntryCallback>("Compress to zip"_i18n, [this](){ options->Add<SidebarEntryCallback>("Compress to zip"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Compress Options"_i18n, Sidebar::Side::RIGHT); auto options = std::make_unique<Sidebar>("Compress Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options))); ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_unique<SidebarEntryCallback>("Compress"_i18n, [this](){ options->Add<SidebarEntryCallback>("Compress"_i18n, [this](){
ZipFiles(""); ZipFiles("");
})); });
options->Add(std::make_unique<SidebarEntryCallback>("Compress to..."_i18n, [this](){ options->Add<SidebarEntryCallback>("Compress to..."_i18n, [this](){
std::string out; std::string out;
if (R_SUCCEEDED(swkbd::ShowText(out, "Enter the path to the folder to extract into", m_path)) && !out.empty()) { if (R_SUCCEEDED(swkbd::ShowText(out, "Enter the path to the folder to extract into", m_path)) && !out.empty()) {
ZipFiles(out); ZipFiles(out);
} }
})); });
})); });
} }
} }
options->Add(std::make_unique<SidebarEntryCallback>("Advanced"_i18n, [this](){ options->Add<SidebarEntryCallback>("Advanced"_i18n, [this](){
DisplayAdvancedOptions(); DisplayAdvancedOptions();
})); });
} }
void FsView::DisplayAdvancedOptions() { void FsView::DisplayAdvancedOptions() {
@@ -1773,12 +1773,12 @@ void FsView::DisplayAdvancedOptions() {
mount_items.push_back(i18n::get(e.name)); mount_items.push_back(i18n::get(e.name));
} }
options->Add(std::make_unique<SidebarEntryArray>("Mount"_i18n, mount_items, [this, fs_entries](s64& index_out){ options->Add<SidebarEntryArray>("Mount"_i18n, mount_items, [this, fs_entries](s64& index_out){
App::PopToMenu(); App::PopToMenu();
SetFs(fs_entries[index_out].root, fs_entries[index_out]); SetFs(fs_entries[index_out].root, fs_entries[index_out]);
}, i18n::get(m_fs_entry.name))); }, i18n::get(m_fs_entry.name));
options->Add(std::make_unique<SidebarEntryCallback>("Create File"_i18n, [this](){ options->Add<SidebarEntryCallback>("Create File"_i18n, [this](){
std::string out; std::string out;
if (R_SUCCEEDED(swkbd::ShowText(out, "Set File Name"_i18n.c_str(), fs::AppendPath(m_path, ""))) && !out.empty()) { if (R_SUCCEEDED(swkbd::ShowText(out, "Set File Name"_i18n.c_str(), fs::AppendPath(m_path, ""))) && !out.empty()) {
App::PopToMenu(); App::PopToMenu();
@@ -1798,9 +1798,9 @@ void FsView::DisplayAdvancedOptions() {
log_write("failed to create file: %s\n", full_path.s); log_write("failed to create file: %s\n", full_path.s);
} }
} }
})); });
options->Add(std::make_unique<SidebarEntryCallback>("Create Folder"_i18n, [this](){ options->Add<SidebarEntryCallback>("Create Folder"_i18n, [this](){
std::string out; std::string out;
if (R_SUCCEEDED(swkbd::ShowText(out, "Set Folder Name"_i18n.c_str(), fs::AppendPath(m_path, ""))) && !out.empty()) { if (R_SUCCEEDED(swkbd::ShowText(out, "Set Folder Name"_i18n.c_str(), fs::AppendPath(m_path, ""))) && !out.empty()) {
App::PopToMenu(); App::PopToMenu();
@@ -1819,44 +1819,44 @@ void FsView::DisplayAdvancedOptions() {
log_write("failed to create dir: %s\n", full_path.s); log_write("failed to create dir: %s\n", full_path.s);
} }
} }
})); });
if (IsSd() && m_entries_current.size() && !m_selected_count && GetEntry().IsFile() && GetEntry().file_size < 1024*64) { if (IsSd() && m_entries_current.size() && !m_selected_count && GetEntry().IsFile() && GetEntry().file_size < 1024*64) {
options->Add(std::make_unique<SidebarEntryCallback>("View as text (unfinished)"_i18n, [this](){ options->Add<SidebarEntryCallback>("View as text (unfinished)"_i18n, [this](){
App::Push(std::make_unique<fileview::Menu>(GetNewPathCurrent())); App::Push<fileview::Menu>(GetNewPathCurrent());
})); });
} }
if (m_entries_current.size()) { if (m_entries_current.size()) {
options->Add(std::make_unique<SidebarEntryCallback>("Upload"_i18n, [this](){ options->Add<SidebarEntryCallback>("Upload"_i18n, [this](){
UploadFiles(); UploadFiles();
})); });
} }
if (m_entries_current.size() && !m_selected_count && GetEntry().IsFile()) { if (m_entries_current.size() && !m_selected_count && GetEntry().IsFile()) {
options->Add(std::make_unique<SidebarEntryCallback>("Hash"_i18n, [this](){ options->Add<SidebarEntryCallback>("Hash"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Hash Options"_i18n, Sidebar::Side::RIGHT); auto options = std::make_unique<Sidebar>("Hash Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options))); ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_unique<SidebarEntryCallback>("CRC32"_i18n, [this](){ options->Add<SidebarEntryCallback>("CRC32"_i18n, [this](){
DisplayHash(hash::Type::Crc32); DisplayHash(hash::Type::Crc32);
})); });
options->Add(std::make_unique<SidebarEntryCallback>("MD5"_i18n, [this](){ options->Add<SidebarEntryCallback>("MD5"_i18n, [this](){
DisplayHash(hash::Type::Md5); DisplayHash(hash::Type::Md5);
})); });
options->Add(std::make_unique<SidebarEntryCallback>("SHA1"_i18n, [this](){ options->Add<SidebarEntryCallback>("SHA1"_i18n, [this](){
DisplayHash(hash::Type::Sha1); DisplayHash(hash::Type::Sha1);
})); });
options->Add(std::make_unique<SidebarEntryCallback>("SHA256"_i18n, [this](){ options->Add<SidebarEntryCallback>("SHA256"_i18n, [this](){
DisplayHash(hash::Type::Sha256); DisplayHash(hash::Type::Sha256);
})); });
})); });
} }
options->Add(std::make_unique<SidebarEntryBool>("Ignore read only"_i18n, m_menu->m_ignore_read_only.Get(), [this](bool& v_out){ options->Add<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_menu->m_ignore_read_only.Set(v_out);
m_fs->SetIgnoreReadOnly(v_out); m_fs->SetIgnoreReadOnly(v_out);
})); });
} }
Menu::Menu(u32 flags) : MenuBase{"FileBrowser"_i18n, flags} { Menu::Menu(u32 flags) : MenuBase{"FileBrowser"_i18n, flags} {
@@ -2156,14 +2156,14 @@ void Menu::PromptIfShouldExit() {
return; return;
} }
App::Push(std::make_unique<ui::OptionBox>( App::Push<ui::OptionBox>(
"Close FileBrowser?"_i18n, "Close FileBrowser?"_i18n,
"No"_i18n, "Yes"_i18n, 1, [this](auto op_index){ "No"_i18n, "Yes"_i18n, 1, [this](auto op_index){
if (op_index && *op_index) { if (op_index && *op_index) {
SetPop(); SetPop();
} }
} }
)); );
} }
} // namespace sphaira::ui::menu::filebrowser } // namespace sphaira::ui::menu::filebrowser

View File

@@ -172,9 +172,9 @@ private:
Result Notify(Result rc, const std::string& error_message) { Result Notify(Result rc, const std::string& error_message) {
if (R_FAILED(rc)) { if (R_FAILED(rc)) {
App::Push(std::make_unique<ui::ErrorBox>(rc, App::Push<ui::ErrorBox>(rc,
i18n::get(error_message) i18n::get(error_message)
)); );
} else { } else {
App::Notify("Success"_i18n); App::Notify("Success"_i18n);
} }
@@ -477,7 +477,7 @@ Menu::Menu(u32 flags) : grid::Menu{"Games"_i18n, flags} {
ON_SCOPE_EXIT(App::Push(std::move(options))); ON_SCOPE_EXIT(App::Push(std::move(options)));
if (m_entries.size()) { if (m_entries.size()) {
options->Add(std::make_unique<SidebarEntryCallback>("Sort By"_i18n, [this](){ options->Add<SidebarEntryCallback>("Sort By"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Sort Options"_i18n, Sidebar::Side::RIGHT); auto options = std::make_unique<Sidebar>("Sort Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options))); ON_SCOPE_EXIT(App::Push(std::move(options)));
@@ -493,55 +493,55 @@ Menu::Menu(u32 flags) : grid::Menu{"Games"_i18n, flags} {
layout_items.push_back("Icon"_i18n); layout_items.push_back("Icon"_i18n);
layout_items.push_back("Grid"_i18n); layout_items.push_back("Grid"_i18n);
options->Add(std::make_unique<SidebarEntryArray>("Sort"_i18n, sort_items, [this](s64& index_out){ options->Add<SidebarEntryArray>("Sort"_i18n, sort_items, [this](s64& index_out){
m_sort.Set(index_out); m_sort.Set(index_out);
SortAndFindLastFile(false); SortAndFindLastFile(false);
}, m_sort.Get())); }, m_sort.Get());
options->Add(std::make_unique<SidebarEntryArray>("Order"_i18n, order_items, [this](s64& index_out){ options->Add<SidebarEntryArray>("Order"_i18n, order_items, [this](s64& index_out){
m_order.Set(index_out); m_order.Set(index_out);
SortAndFindLastFile(false); SortAndFindLastFile(false);
}, m_order.Get())); }, m_order.Get());
options->Add(std::make_unique<SidebarEntryArray>("Layout"_i18n, layout_items, [this](s64& index_out){ options->Add<SidebarEntryArray>("Layout"_i18n, layout_items, [this](s64& index_out){
m_layout.Set(index_out); m_layout.Set(index_out);
OnLayoutChange(); OnLayoutChange();
}, m_layout.Get())); }, m_layout.Get());
options->Add(std::make_unique<SidebarEntryBool>("Hide forwarders"_i18n, m_hide_forwarders.Get(), [this](bool& v_out){ options->Add<SidebarEntryBool>("Hide forwarders"_i18n, m_hide_forwarders.Get(), [this](bool& v_out){
m_hide_forwarders.Set(v_out); m_hide_forwarders.Set(v_out);
m_dirty = true; m_dirty = true;
})); });
})); });
#if 0 #if 0
options->Add(std::make_unique<SidebarEntryCallback>("Info"_i18n, [this](){ options->Add<SidebarEntryCallback>("Info"_i18n, [this](){
})); });
#endif #endif
options->Add(std::make_unique<SidebarEntryCallback>("Launch random game"_i18n, [this](){ options->Add<SidebarEntryCallback>("Launch random game"_i18n, [this](){
const auto random_index = randomGet64() % std::size(m_entries); const auto random_index = randomGet64() % std::size(m_entries);
auto& e = m_entries[random_index]; auto& e = m_entries[random_index];
LoadControlEntry(e, true); LoadControlEntry(e, true);
App::Push(std::make_unique<OptionBox>( App::Push<OptionBox>(
"Launch "_i18n + e.GetName(), "Launch "_i18n + e.GetName(),
"Back"_i18n, "Launch"_i18n, 1, [this, &e](auto op_index){ "Back"_i18n, "Launch"_i18n, 1, [this, &e](auto op_index){
if (op_index && *op_index) { if (op_index && *op_index) {
LaunchEntry(e); LaunchEntry(e);
} }
}, e.image }, e.image
)); );
})); });
options->Add(std::make_unique<SidebarEntryCallback>("List meta records"_i18n, [this](){ options->Add<SidebarEntryCallback>("List meta records"_i18n, [this](){
title::MetaEntries meta_entries; title::MetaEntries meta_entries;
const auto rc = GetMetaEntries(m_entries[m_index], meta_entries); const auto rc = GetMetaEntries(m_entries[m_index], meta_entries);
if (R_FAILED(rc)) { if (R_FAILED(rc)) {
App::Push(std::make_unique<ui::ErrorBox>(rc, App::Push<ui::ErrorBox>(rc,
i18n::get("Failed to list application meta entries") i18n::get("Failed to list application meta entries")
)); );
return; return;
} }
@@ -557,7 +557,7 @@ Menu::Menu(u32 flags) : grid::Menu{"Games"_i18n, flags} {
items.emplace_back(buf); items.emplace_back(buf);
} }
App::Push(std::make_unique<PopupList>( App::Push<PopupList>(
"Entries"_i18n, items, [this, meta_entries](auto op_index){ "Entries"_i18n, items, [this, meta_entries](auto op_index){
#if 0 #if 0
if (op_index) { if (op_index) {
@@ -565,88 +565,88 @@ Menu::Menu(u32 flags) : grid::Menu{"Games"_i18n, flags} {
} }
#endif #endif
} }
)); );
})); });
options->Add(std::make_unique<SidebarEntryCallback>("Dump"_i18n, [this](){ options->Add<SidebarEntryCallback>("Dump"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Select content to dump"_i18n, Sidebar::Side::RIGHT); auto options = std::make_unique<Sidebar>("Select content to dump"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options))); ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_unique<SidebarEntryCallback>("Dump All"_i18n, [this](){ options->Add<SidebarEntryCallback>("Dump All"_i18n, [this](){
DumpGames(title::ContentFlag_All); DumpGames(title::ContentFlag_All);
}, true)); }, true);
options->Add(std::make_unique<SidebarEntryCallback>("Dump Application"_i18n, [this](){ options->Add<SidebarEntryCallback>("Dump Application"_i18n, [this](){
DumpGames(title::ContentFlag_Application); DumpGames(title::ContentFlag_Application);
}, true)); }, true);
options->Add(std::make_unique<SidebarEntryCallback>("Dump Patch"_i18n, [this](){ options->Add<SidebarEntryCallback>("Dump Patch"_i18n, [this](){
DumpGames(title::ContentFlag_Patch); DumpGames(title::ContentFlag_Patch);
}, true)); }, true);
options->Add(std::make_unique<SidebarEntryCallback>("Dump AddOnContent"_i18n, [this](){ options->Add<SidebarEntryCallback>("Dump AddOnContent"_i18n, [this](){
DumpGames(title::ContentFlag_AddOnContent); DumpGames(title::ContentFlag_AddOnContent);
}, true)); }, true);
options->Add(std::make_unique<SidebarEntryCallback>("Dump DataPatch"_i18n, [this](){ options->Add<SidebarEntryCallback>("Dump DataPatch"_i18n, [this](){
DumpGames(title::ContentFlag_DataPatch); DumpGames(title::ContentFlag_DataPatch);
}, true)); }, true);
}, true)); }, true);
options->Add(std::make_unique<SidebarEntryCallback>("Dump options"_i18n, [this](){ options->Add<SidebarEntryCallback>("Dump options"_i18n, [this](){
App::DisplayDumpOptions(false); App::DisplayDumpOptions(false);
})); });
// completely deletes the application record and all data. // completely deletes the application record and all data.
options->Add(std::make_unique<SidebarEntryCallback>("Delete"_i18n, [this](){ options->Add<SidebarEntryCallback>("Delete"_i18n, [this](){
const auto buf = "Are you sure you want to delete "_i18n + m_entries[m_index].GetName() + "?"; const auto buf = "Are you sure you want to delete "_i18n + m_entries[m_index].GetName() + "?";
App::Push(std::make_unique<OptionBox>( App::Push<OptionBox>(
buf, buf,
"Back"_i18n, "Delete"_i18n, 0, [this](auto op_index){ "Back"_i18n, "Delete"_i18n, 0, [this](auto op_index){
if (op_index && *op_index) { if (op_index && *op_index) {
DeleteGames(); DeleteGames();
} }
}, m_entries[m_index].image }, m_entries[m_index].image
)); );
}, true)); }, true);
} }
options->Add(std::make_unique<SidebarEntryCallback>("Advanced options"_i18n, [this](){ options->Add<SidebarEntryCallback>("Advanced options"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Advanced Options"_i18n, Sidebar::Side::RIGHT); auto options = std::make_unique<Sidebar>("Advanced Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options))); ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_unique<SidebarEntryCallback>("Refresh"_i18n, [this](){ options->Add<SidebarEntryCallback>("Refresh"_i18n, [this](){
m_dirty = true; m_dirty = true;
App::PopToMenu(); App::PopToMenu();
})); });
options->Add(std::make_unique<SidebarEntryCallback>("Create contents folder"_i18n, [this](){ options->Add<SidebarEntryCallback>("Create contents folder"_i18n, [this](){
const auto rc = fs::FsNativeSd().CreateDirectory(title::GetContentsPath(m_entries[m_index].app_id)); const auto rc = fs::FsNativeSd().CreateDirectory(title::GetContentsPath(m_entries[m_index].app_id));
App::PushErrorBox(rc, "Folder create failed!"_i18n); App::PushErrorBox(rc, "Folder create failed!"_i18n);
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
App::Notify("Folder created!"_i18n); App::Notify("Folder created!"_i18n);
} }
})); });
options->Add(std::make_unique<SidebarEntryCallback>("Create save"_i18n, [this](){ options->Add<SidebarEntryCallback>("Create save"_i18n, [this](){
ui::PopupList::Items items{}; ui::PopupList::Items items{};
const auto accounts = App::GetAccountList(); const auto accounts = App::GetAccountList();
for (auto& p : accounts) { for (auto& p : accounts) {
items.emplace_back(p.nickname); items.emplace_back(p.nickname);
} }
App::Push(std::make_unique<ui::PopupList>( App::Push<ui::PopupList>(
"Select user to create save for"_i18n, items, [this, accounts](auto op_index){ "Select user to create save for"_i18n, items, [this, accounts](auto op_index){
if (op_index) { if (op_index) {
CreateSaves(accounts[*op_index].uid); CreateSaves(accounts[*op_index].uid);
} }
} }
)); );
})); });
options->Add(std::make_unique<SidebarEntryBool>("Title cache"_i18n, m_title_cache.Get(), [this](bool& v_out){ options->Add<SidebarEntryBool>("Title cache"_i18n, m_title_cache.Get(), [this](bool& v_out){
m_title_cache.Set(v_out); m_title_cache.Set(v_out);
})); });
options->Add(std::make_unique<SidebarEntryCallback>("Delete title cache"_i18n, [this](){ options->Add<SidebarEntryCallback>("Delete title cache"_i18n, [this](){
App::Push(std::make_unique<OptionBox>( App::Push<OptionBox>(
"Are you sure you want to delete the title cache?"_i18n, "Are you sure you want to delete the title cache?"_i18n,
"Back"_i18n, "Delete"_i18n, 0, [this](auto op_index){ "Back"_i18n, "Delete"_i18n, 0, [this](auto op_index){
if (op_index && *op_index) { if (op_index && *op_index) {
@@ -655,9 +655,9 @@ Menu::Menu(u32 flags) : grid::Menu{"Games"_i18n, flags} {
App::PopToMenu(); App::PopToMenu();
} }
} }
)); );
})); });
})); });
}}) }})
); );
@@ -876,7 +876,7 @@ void Menu::OnLayoutChange() {
} }
void Menu::DeleteGames() { void Menu::DeleteGames() {
App::Push(std::make_unique<ProgressBox>(0, "Deleting"_i18n, "", [this](auto pbox) -> Result { App::Push<ProgressBox>(0, "Deleting"_i18n, "", [this](auto pbox) -> Result {
auto targets = GetSelectedEntries(); auto targets = GetSelectedEntries();
for (s64 i = 0; i < std::size(targets); i++) { for (s64 i = 0; i < std::size(targets); i++) {
@@ -898,7 +898,7 @@ void Menu::DeleteGames() {
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
App::Notify("Delete successfull!"_i18n); App::Notify("Delete successfull!"_i18n);
} }
})); });
} }
void Menu::DumpGames(u32 flags) { void Menu::DumpGames(u32 flags) {
@@ -921,7 +921,7 @@ void Menu::DumpGames(u32 flags) {
} }
void Menu::CreateSaves(AccountUid uid) { void Menu::CreateSaves(AccountUid uid) {
App::Push(std::make_unique<ProgressBox>(0, "Creating"_i18n, "", [this, uid](auto pbox) -> Result { App::Push<ProgressBox>(0, "Creating"_i18n, "", [this, uid](auto pbox) -> Result {
auto targets = GetSelectedEntries(); auto targets = GetSelectedEntries();
for (s64 i = 0; i < std::size(targets); i++) { for (s64 i = 0; i < std::size(targets); i++) {
@@ -948,7 +948,7 @@ void Menu::CreateSaves(AccountUid uid) {
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
App::Notify("Save create successfull!"_i18n); App::Notify("Save create successfull!"_i18n);
} }
})); });
} }
} // namespace sphaira::ui::menu::game } // namespace sphaira::ui::menu::game

View File

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

View File

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

View File

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

View File

@@ -142,7 +142,7 @@ void Menu::Update(Controller* controller, TouchInfo* touch) {
if (m_state == State::Connected) { if (m_state == State::Connected) {
m_state = State::Progress; m_state = State::Progress;
App::Push(std::make_unique<ui::ProgressBox>(0, "Installing "_i18n, m_source->GetPath(), [this](auto pbox) -> Result { App::Push<ui::ProgressBox>(0, "Installing "_i18n, m_source->GetPath(), [this](auto pbox) -> Result {
INSTALL_STATE = InstallState::Progress; INSTALL_STATE = InstallState::Progress;
const auto rc = yati::InstallFromSource(pbox, m_source.get(), m_source->GetPath()); const auto rc = yati::InstallFromSource(pbox, m_source.get(), m_source->GetPath());
INSTALL_STATE = InstallState::Finished; INSTALL_STATE = InstallState::Finished;
@@ -165,7 +165,7 @@ void Menu::Update(Controller* controller, TouchInfo* touch) {
m_state = State::Failed; m_state = State::Failed;
OnDisableInstallMode(); OnDisableInstallMode();
} }
})); });
} }
} }

View File

@@ -126,44 +126,44 @@ Menu::Menu(u32 flags) : MenuBase{"Irs"_i18n, flags} {
format_str.emplace_back("20\u00D715"); format_str.emplace_back("20\u00D715");
} }
options->Add(std::make_unique<SidebarEntryArray>("Controller"_i18n, controller_str, [this](s64& index){ options->Add<SidebarEntryArray>("Controller"_i18n, controller_str, [this](s64& index){
irsStopImageProcessor(m_entries[m_index].m_handle); irsStopImageProcessor(m_entries[m_index].m_handle);
m_index = index; m_index = index;
UpdateConfig(&m_config); UpdateConfig(&m_config);
}, m_index)); }, m_index);
options->Add(std::make_unique<SidebarEntryArray>("Rotation"_i18n, rotation_str, [this](s64& index){ options->Add<SidebarEntryArray>("Rotation"_i18n, rotation_str, [this](s64& index){
m_rotation = (Rotation)index; m_rotation = (Rotation)index;
}, m_rotation)); }, m_rotation);
options->Add(std::make_unique<SidebarEntryArray>("Colour"_i18n, colour_str, [this](s64& index){ options->Add<SidebarEntryArray>("Colour"_i18n, colour_str, [this](s64& index){
m_colour = (Colour)index; m_colour = (Colour)index;
updateColourArray(); updateColourArray();
}, m_colour)); }, m_colour);
options->Add(std::make_unique<SidebarEntryArray>("Light Target"_i18n, light_target_str, [this](s64& index){ options->Add<SidebarEntryArray>("Light Target"_i18n, light_target_str, [this](s64& index){
m_config.light_target = index; m_config.light_target = index;
UpdateConfig(&m_config); UpdateConfig(&m_config);
}, m_config.light_target)); }, m_config.light_target);
options->Add(std::make_unique<SidebarEntryArray>("Gain"_i18n, gain_str, [this](s64& index){ options->Add<SidebarEntryArray>("Gain"_i18n, gain_str, [this](s64& index){
m_config.gain = GAIN_MIN + index; m_config.gain = GAIN_MIN + index;
UpdateConfig(&m_config); UpdateConfig(&m_config);
}, m_config.gain - GAIN_MIN)); }, m_config.gain - GAIN_MIN);
options->Add(std::make_unique<SidebarEntryArray>("Negative Image"_i18n, is_negative_image_used_str, [this](s64& index){ options->Add<SidebarEntryArray>("Negative Image"_i18n, is_negative_image_used_str, [this](s64& index){
m_config.is_negative_image_used = index; m_config.is_negative_image_used = index;
UpdateConfig(&m_config); UpdateConfig(&m_config);
}, m_config.is_negative_image_used)); }, m_config.is_negative_image_used);
options->Add(std::make_unique<SidebarEntryArray>("Format"_i18n, format_str, [this](s64& index){ options->Add<SidebarEntryArray>("Format"_i18n, format_str, [this](s64& index){
m_config.orig_format = index; m_config.orig_format = index;
m_config.trimming_format = index; m_config.trimming_format = index;
UpdateConfig(&m_config); UpdateConfig(&m_config);
}, m_config.orig_format)); }, m_config.orig_format);
if (hosversionAtLeast(4,0,0)) { if (hosversionAtLeast(4,0,0)) {
options->Add(std::make_unique<SidebarEntryArray>("Trimming Format"_i18n, format_str, [this](s64& index){ options->Add<SidebarEntryArray>("Trimming Format"_i18n, format_str, [this](s64& index){
// you cannot set trim a larger region than the source // you cannot set trim a larger region than the source
if (index < m_config.orig_format) { if (index < m_config.orig_format) {
index = m_config.orig_format; index = m_config.orig_format;
@@ -171,17 +171,17 @@ Menu::Menu(u32 flags) : MenuBase{"Irs"_i18n, flags} {
m_config.trimming_format = index; m_config.trimming_format = index;
UpdateConfig(&m_config); UpdateConfig(&m_config);
} }
}, m_config.orig_format)); }, m_config.orig_format);
options->Add(std::make_unique<SidebarEntryBool>("External Light Filter"_i18n, m_config.is_external_light_filter_enabled, [this](bool& enable){ options->Add<SidebarEntryBool>("External Light Filter"_i18n, m_config.is_external_light_filter_enabled, [this](bool& enable){
m_config.is_external_light_filter_enabled = enable; m_config.is_external_light_filter_enabled = enable;
UpdateConfig(&m_config); UpdateConfig(&m_config);
})); });
} }
options->Add(std::make_unique<SidebarEntryCallback>("Load Default"_i18n, [this](){ options->Add<SidebarEntryCallback>("Load Default"_i18n, [this](){
LoadDefaultConfig(); LoadDefaultConfig();
}, true)); }, true);
}}); }});
if (R_FAILED(m_init_rc = irsInitialize())) { if (R_FAILED(m_init_rc = irsInitialize())) {

View File

@@ -255,17 +255,17 @@ MainMenu::MainMenu() {
language_items.push_back("Vietnamese"_i18n); language_items.push_back("Vietnamese"_i18n);
language_items.push_back("Ukrainian"_i18n); language_items.push_back("Ukrainian"_i18n);
options->Add(std::make_unique<SidebarEntryCallback>("Theme"_i18n, [](){ options->Add<SidebarEntryCallback>("Theme"_i18n, [](){
App::DisplayThemeOptions(); App::DisplayThemeOptions();
})); });
options->Add(std::make_unique<SidebarEntryCallback>("Network"_i18n, [this](){ options->Add<SidebarEntryCallback>("Network"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Network Options"_i18n, Sidebar::Side::LEFT); auto options = std::make_unique<Sidebar>("Network Options"_i18n, Sidebar::Side::LEFT);
ON_SCOPE_EXIT(App::Push(std::move(options))); ON_SCOPE_EXIT(App::Push(std::move(options)));
if (m_update_state == UpdateState::Update) { if (m_update_state == UpdateState::Update) {
options->Add(std::make_unique<SidebarEntryCallback>("Download update: "_i18n + m_update_version, [this](){ options->Add<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 { App::Push<ProgressBox>(0, "Downloading "_i18n, "Sphaira v" + m_update_version, [this](auto pbox) -> Result {
return InstallUpdate(pbox, m_update_url, m_update_version); return InstallUpdate(pbox, m_update_url, m_update_version);
}, [this](Result rc){ }, [this](Result rc){
App::PushErrorBox(rc, "Failed to download update"_i18n); App::PushErrorBox(rc, "Failed to download update"_i18n);
@@ -273,50 +273,50 @@ MainMenu::MainMenu() {
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
m_update_state = UpdateState::None; m_update_state = UpdateState::None;
App::Notify("Updated to "_i18n + m_update_version); App::Notify("Updated to "_i18n + m_update_version);
App::Push(std::make_unique<OptionBox>( App::Push<OptionBox>(
"Press OK to restart Sphaira"_i18n, "OK"_i18n, [](auto){ "Press OK to restart Sphaira"_i18n, "OK"_i18n, [](auto){
App::ExitRestart(); App::ExitRestart();
} }
)); );
} }
})); });
})); });
} }
options->Add(std::make_unique<SidebarEntryBool>("Ftp"_i18n, App::GetFtpEnable(), [](bool& enable){ options->Add<SidebarEntryBool>("Ftp"_i18n, App::GetFtpEnable(), [](bool& enable){
App::SetFtpEnable(enable); App::SetFtpEnable(enable);
})); });
options->Add(std::make_unique<SidebarEntryBool>("Mtp"_i18n, App::GetMtpEnable(), [](bool& enable){ options->Add<SidebarEntryBool>("Mtp"_i18n, App::GetMtpEnable(), [](bool& enable){
App::SetMtpEnable(enable); App::SetMtpEnable(enable);
})); });
options->Add(std::make_unique<SidebarEntryBool>("Nxlink"_i18n, App::GetNxlinkEnable(), [](bool& enable){ options->Add<SidebarEntryBool>("Nxlink"_i18n, App::GetNxlinkEnable(), [](bool& enable){
App::SetNxlinkEnable(enable); App::SetNxlinkEnable(enable);
})); });
options->Add(std::make_unique<SidebarEntryBool>("Hdd"_i18n, App::GetHddEnable(), [](bool& enable){ options->Add<SidebarEntryBool>("Hdd"_i18n, App::GetHddEnable(), [](bool& enable){
App::SetHddEnable(enable); App::SetHddEnable(enable);
})); });
options->Add(std::make_unique<SidebarEntryBool>("Hdd write protect"_i18n, App::GetWriteProtect(), [](bool& enable){ options->Add<SidebarEntryBool>("Hdd write protect"_i18n, App::GetWriteProtect(), [](bool& enable){
App::SetWriteProtect(enable); App::SetWriteProtect(enable);
})); });
})); });
options->Add(std::make_unique<SidebarEntryArray>("Language"_i18n, language_items, [](s64& index_out){ options->Add<SidebarEntryArray>("Language"_i18n, language_items, [](s64& index_out){
App::SetLanguage(index_out); App::SetLanguage(index_out);
}, (s64)App::GetLanguage())); }, (s64)App::GetLanguage());
options->Add(std::make_unique<SidebarEntryCallback>("Misc"_i18n, [](){ options->Add<SidebarEntryCallback>("Misc"_i18n, [](){
App::DisplayMiscOptions(); App::DisplayMiscOptions();
})); });
options->Add(std::make_unique<SidebarEntryCallback>("Advanced"_i18n, [](){ options->Add<SidebarEntryCallback>("Advanced"_i18n, [](){
App::DisplayAdvancedOptions(); App::DisplayAdvancedOptions();
})); });
}}) }}
); ));
m_centre_menu = std::make_unique<homebrew::Menu>(); m_centre_menu = std::make_unique<homebrew::Menu>();
m_current_menu = m_centre_menu.get(); m_current_menu = m_centre_menu.get();

View File

@@ -343,7 +343,7 @@ Menu::Menu(u32 flags) : grid::Menu{"Saves"_i18n, flags} {
data_type_items.emplace_back("Cache"_i18n); data_type_items.emplace_back("Cache"_i18n);
data_type_items.emplace_back("System BCAT"_i18n); data_type_items.emplace_back("System BCAT"_i18n);
options->Add(std::make_unique<SidebarEntryCallback>("Sort By"_i18n, [this](){ options->Add<SidebarEntryCallback>("Sort By"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Sort Options"_i18n, Sidebar::Side::RIGHT); auto options = std::make_unique<Sidebar>("Sort Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options))); ON_SCOPE_EXIT(App::Push(std::move(options)));
@@ -359,36 +359,36 @@ Menu::Menu(u32 flags) : grid::Menu{"Saves"_i18n, flags} {
layout_items.push_back("Icon"_i18n); layout_items.push_back("Icon"_i18n);
layout_items.push_back("Grid"_i18n); layout_items.push_back("Grid"_i18n);
options->Add(std::make_unique<SidebarEntryArray>("Sort"_i18n, sort_items, [this](s64& index_out){ options->Add<SidebarEntryArray>("Sort"_i18n, sort_items, [this](s64& index_out){
m_sort.Set(index_out); m_sort.Set(index_out);
SortAndFindLastFile(false); SortAndFindLastFile(false);
}, m_sort.Get())); }, m_sort.Get());
options->Add(std::make_unique<SidebarEntryArray>("Order"_i18n, order_items, [this](s64& index_out){ options->Add<SidebarEntryArray>("Order"_i18n, order_items, [this](s64& index_out){
m_order.Set(index_out); m_order.Set(index_out);
SortAndFindLastFile(false); SortAndFindLastFile(false);
}, m_order.Get())); }, m_order.Get());
options->Add(std::make_unique<SidebarEntryArray>("Layout"_i18n, layout_items, [this](s64& index_out){ options->Add<SidebarEntryArray>("Layout"_i18n, layout_items, [this](s64& index_out){
m_layout.Set(index_out); m_layout.Set(index_out);
OnLayoutChange(); OnLayoutChange();
}, m_layout.Get())); }, m_layout.Get());
})); });
options->Add(std::make_unique<SidebarEntryArray>("Account"_i18n, account_items, [this](s64& index_out){ options->Add<SidebarEntryArray>("Account"_i18n, account_items, [this](s64& index_out){
m_account_index = index_out; m_account_index = index_out;
m_dirty = true; m_dirty = true;
App::PopToMenu(); App::PopToMenu();
}, m_account_index)); }, m_account_index);
options->Add(std::make_unique<SidebarEntryArray>("Data Type"_i18n, data_type_items, [this](s64& index_out){ options->Add<SidebarEntryArray>("Data Type"_i18n, data_type_items, [this](s64& index_out){
m_data_type = index_out; m_data_type = index_out;
m_dirty = true; m_dirty = true;
App::PopToMenu(); App::PopToMenu();
}, m_data_type)); }, m_data_type);
if (m_entries.size()) { if (m_entries.size()) {
options->Add(std::make_unique<SidebarEntryCallback>("Backup"_i18n, [this](){ options->Add<SidebarEntryCallback>("Backup"_i18n, [this](){
std::vector<std::reference_wrapper<Entry>> entries; std::vector<std::reference_wrapper<Entry>> entries;
if (m_selected_count) { if (m_selected_count) {
for (auto& e : m_entries) { for (auto& e : m_entries) {
@@ -401,27 +401,27 @@ Menu::Menu(u32 flags) : grid::Menu{"Saves"_i18n, flags} {
} }
BackupSaves(entries); BackupSaves(entries);
}, true)); }, true);
if (m_entries[m_index].save_data_type == FsSaveDataType_Account || m_entries[m_index].save_data_type == FsSaveDataType_Bcat) { if (m_entries[m_index].save_data_type == FsSaveDataType_Account || m_entries[m_index].save_data_type == FsSaveDataType_Bcat) {
options->Add(std::make_unique<SidebarEntryCallback>("Restore"_i18n, [this](){ options->Add<SidebarEntryCallback>("Restore"_i18n, [this](){
RestoreSave(); RestoreSave();
}, true)); }, true);
} }
} }
options->Add(std::make_unique<SidebarEntryCallback>("Advanced"_i18n, [this](){ options->Add<SidebarEntryCallback>("Advanced"_i18n, [this](){
auto options = std::make_unique<Sidebar>("Advanced Options"_i18n, Sidebar::Side::RIGHT); auto options = std::make_unique<Sidebar>("Advanced Options"_i18n, Sidebar::Side::RIGHT);
ON_SCOPE_EXIT(App::Push(std::move(options))); ON_SCOPE_EXIT(App::Push(std::move(options)));
options->Add(std::make_unique<SidebarEntryBool>("Auto backup on restore"_i18n, m_auto_backup_on_restore.Get(), [this](bool& v_out){ options->Add<SidebarEntryBool>("Auto backup on restore"_i18n, m_auto_backup_on_restore.Get(), [this](bool& v_out){
m_auto_backup_on_restore.Set(v_out); m_auto_backup_on_restore.Set(v_out);
})); });
options->Add(std::make_unique<SidebarEntryBool>("Compress backup"_i18n, m_compress_save_backup.Get(), [this](bool& v_out){ options->Add<SidebarEntryBool>("Compress backup"_i18n, m_compress_save_backup.Get(), [this](bool& v_out){
m_compress_save_backup.Set(v_out); m_compress_save_backup.Set(v_out);
})); });
})); });
}}) }})
); );
@@ -677,7 +677,7 @@ void Menu::OnLayoutChange() {
void Menu::BackupSaves(std::vector<std::reference_wrapper<Entry>>& entries) { 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){ dump::DumpGetLocation("Select backup location"_i18n, dump::DumpLocationFlag_SdCard|dump::DumpLocationFlag_Stdio, [this, entries](const dump::DumpLocation& location){
App::Push(std::make_unique<ProgressBox>(0, "Backup"_i18n, "", [this, entries, location](auto pbox) -> Result { App::Push<ProgressBox>(0, "Backup"_i18n, "", [this, entries, location](auto pbox) -> Result {
for (auto& e : entries) { for (auto& e : entries) {
// the entry may not have loaded yet. // the entry may not have loaded yet.
LoadControlEntry(e); LoadControlEntry(e);
@@ -690,7 +690,7 @@ void Menu::BackupSaves(std::vector<std::reference_wrapper<Entry>>& entries) {
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
App::Notify("Backup successfull!"_i18n); App::Notify("Backup successfull!"_i18n);
} }
})); });
}); });
} }
@@ -728,15 +728,15 @@ void Menu::RestoreSave() {
} }
if (paths.empty()) { if (paths.empty()) {
App::Push(std::make_unique<ui::OptionBox>( App::Push<ui::OptionBox>(
"No saves found in "_i18n + fs::AppendPath(fs->Root(), BuildSaveBasePath(m_entries[m_index])).toString(), "No saves found in "_i18n + fs::AppendPath(fs->Root(), BuildSaveBasePath(m_entries[m_index])).toString(),
"OK"_i18n "OK"_i18n
)); );
return; return;
} }
const auto title = "Restore save for: "_i18n + m_entries[m_index].GetName(); const auto title = "Restore save for: "_i18n + m_entries[m_index].GetName();
App::Push(std::make_unique<PopupList>( App::Push<PopupList>(
title, items, [this, paths, items, location](auto op_index){ title, items, [this, paths, items, location](auto op_index){
if (!op_index) { if (!op_index) {
return; return;
@@ -745,11 +745,11 @@ void Menu::RestoreSave() {
const auto file_name = items[*op_index]; const auto file_name = items[*op_index];
const auto file_path = paths[*op_index]; const auto file_path = paths[*op_index];
App::Push(std::make_unique<OptionBox>( App::Push<OptionBox>(
"Are you sure you want to restore "_i18n + file_name + "?", "Are you sure you want to restore "_i18n + file_name + "?",
"Back"_i18n, "Restore"_i18n, 0, [this, file_path, location](auto op_index){ "Back"_i18n, "Restore"_i18n, 0, [this, file_path, location](auto op_index){
if (op_index && *op_index) { if (op_index && *op_index) {
App::Push(std::make_unique<ProgressBox>(0, "Restore"_i18n, "", [this, file_path, location](auto pbox) -> Result { App::Push<ProgressBox>(0, "Restore"_i18n, "", [this, file_path, location](auto pbox) -> Result {
// the entry may not have loaded yet. // the entry may not have loaded yet.
LoadControlEntry(m_entries[m_index]); LoadControlEntry(m_entries[m_index]);
@@ -766,12 +766,12 @@ void Menu::RestoreSave() {
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
App::Notify("Restore successfull!"_i18n); App::Notify("Restore successfull!"_i18n);
} }
})); });
} }
}, m_entries[m_index].image }, m_entries[m_index].image
)); );
} }
)); );
}); });
} }

View File

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

View File

@@ -109,7 +109,7 @@ void Menu::Update(Controller* controller, TouchInfo* touch) {
log_write("set to progress\n"); log_write("set to progress\n");
m_state = State::Progress; m_state = State::Progress;
log_write("got connection\n"); log_write("got connection\n");
App::Push(std::make_unique<ui::ProgressBox>(0, "Installing "_i18n, "", [this](auto pbox) -> Result { App::Push<ui::ProgressBox>(0, "Installing "_i18n, "", [this](auto pbox) -> Result {
ON_SCOPE_EXIT(m_usb_source->Finished(FINISHED_TIMEOUT)); ON_SCOPE_EXIT(m_usb_source->Finished(FINISHED_TIMEOUT));
log_write("inside progress box\n"); log_write("inside progress box\n");
@@ -136,7 +136,7 @@ void Menu::Update(Controller* controller, TouchInfo* touch) {
} else { } else {
m_state = State::Failed; m_state = State::Failed;
} }
})); });
} }
} }

View File

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

View File

@@ -114,16 +114,10 @@ SidebarEntryArray::SidebarEntryArray(std::string title, Items items, std::string
} }
m_list_callback = [&index, this]() { m_list_callback = [&index, this]() {
App::Push(std::make_unique<PopupList>( App::Push<PopupList>(
m_title, m_items, index, m_index m_title, m_items, index, m_index
)); );
}; };
// m_callback = [&index, this](auto& idx) {
// App::Push(std::make_unique<PopupList>(
// m_title, m_items, index, idx
// ));
// };
} }
SidebarEntryArray::SidebarEntryArray(std::string title, Items items, Callback cb, std::string index) SidebarEntryArray::SidebarEntryArray(std::string title, Items items, Callback cb, std::string index)
@@ -142,14 +136,14 @@ SidebarEntryArray::SidebarEntryArray(std::string title, Items items, Callback cb
, m_index{index} { , m_index{index} {
m_list_callback = [this]() { m_list_callback = [this]() {
App::Push(std::make_unique<PopupList>( App::Push<PopupList>(
m_title, m_items, [this](auto op_idx){ m_title, m_items, [this](auto op_idx){
if (op_idx) { if (op_idx) {
m_index = *op_idx; m_index = *op_idx;
m_callback(m_index); m_callback(m_index);
} }
}, m_index }, m_index
)); );
}; };
SetAction(Button::A, Action{"OK"_i18n, [this](){ SetAction(Button::A, Action{"OK"_i18n, [this](){