Skip to content

Commit

Permalink
disable install by default, enabled via advanced menu. disable web br…
Browse files Browse the repository at this point in the history
…owser if applet.
  • Loading branch information
ITotalJustice committed Dec 21, 2024
1 parent 986ffdc commit 4a058d3
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 26 deletions.
4 changes: 4 additions & 0 deletions sphaira/include/app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class App {
static auto GetNxlinkEnable() -> bool;
static auto GetLogEnable() -> bool;
static auto GetReplaceHbmenuEnable() -> bool;
static auto GetInstallEnable() -> bool;
static auto GetInstallSdEnable() -> bool;
static auto GetInstallPrompt() -> bool;
static auto GetThemeShuffleEnable() -> bool;
Expand All @@ -72,7 +73,9 @@ class App {
static void SetNxlinkEnable(bool enable);
static void SetLogEnable(bool enable);
static void SetReplaceHbmenuEnable(bool enable);
static void SetInstallEnable(bool enable);
static void SetInstallSdEnable(bool enable);
static void SetInstallPrompt(bool enable);
static void SetThemeShuffleEnable(bool enable);
static void SetThemeMusicEnable(bool enable);
static void SetLanguage(long index);
Expand Down Expand Up @@ -139,6 +142,7 @@ class App {
option::OptionBool m_nxlink_enabled{INI_SECTION, "nxlink_enabled", true};
option::OptionBool m_log_enabled{INI_SECTION, "log_enabled", false};
option::OptionBool m_replace_hbmenu{INI_SECTION, "replace_hbmenu", false};
option::OptionBool m_install{INI_SECTION, "install", false};
option::OptionBool m_install_sd{INI_SECTION, "install_sd", true};
option::OptionLong m_install_prompt{INI_SECTION, "install_prompt", true};
option::OptionBool m_theme_shuffle{INI_SECTION, "theme_shuffle", false};
Expand Down
12 changes: 12 additions & 0 deletions sphaira/source/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@ auto App::GetReplaceHbmenuEnable() -> bool {
return g_app->m_replace_hbmenu.Get();
}

auto App::GetInstallEnable() -> bool {
return g_app->m_install.Get();
}

auto App::GetInstallSdEnable() -> bool {
return g_app->m_install_sd.Get();
}
Expand Down Expand Up @@ -409,10 +413,18 @@ void App::SetReplaceHbmenuEnable(bool enable) {
g_app->m_replace_hbmenu.Set(enable);
}

void App::SetInstallEnable(bool enable) {
g_app->m_install.Set(enable);
}

void App::SetInstallSdEnable(bool enable) {
g_app->m_install_sd.Set(enable);
}

void App::SetInstallPrompt(bool enable) {
g_app->m_install_prompt.Set(enable);
}

void App::SetThemeShuffleEnable(bool enable) {
g_app->m_theme_shuffle.Set(enable);
}
Expand Down
2 changes: 1 addition & 1 deletion sphaira/source/ui/menus/filebrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ Menu::Menu(const std::vector<NroEntry>& nro_entries) : MenuBase{"FileBrowser"_i1
}

if (m_entries_current.size()) {
if (HasTypeInSelectedEntries(FsDirEntryType_File) && !m_selected_count && (GetEntry().GetExtension() == "nro" || !FindFileAssocFor().empty())) {
if (App::GetInstallEnable() && HasTypeInSelectedEntries(FsDirEntryType_File) && !m_selected_count && (GetEntry().GetExtension() == "nro" || !FindFileAssocFor().empty())) {
options->Add(std::make_shared<SidebarEntryCallback>("Install Forwarder"_i18n, [this](){;
if (App::GetInstallPrompt()) {
App::Push(std::make_shared<OptionBox>(
Expand Down
28 changes: 15 additions & 13 deletions sphaira/source/ui/menus/homebrew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,22 @@ Menu::Menu() : MenuBase{"Homebrew"_i18n} {
));
}, true));

options->Add(std::make_shared<SidebarEntryCallback>("Install Forwarder"_i18n, [this](){
if (App::GetInstallPrompt()) {
App::Push(std::make_shared<OptionBox>(
"WARNING: Installing forwarders will lead to a ban!"_i18n,
"Back"_i18n, "Install"_i18n, 0, [this](auto op_index){
if (op_index && *op_index) {
InstallHomebrew();
if (App::GetInstallEnable()) {
options->Add(std::make_shared<SidebarEntryCallback>("Install Forwarder"_i18n, [this](){
if (App::GetInstallPrompt()) {
App::Push(std::make_shared<OptionBox>(
"WARNING: Installing forwarders will lead to a ban!"_i18n,
"Back"_i18n, "Install"_i18n, 0, [this](auto op_index){
if (op_index && *op_index) {
InstallHomebrew();
}
}
}
));
} else {
InstallHomebrew();
}
}, true));
));
} else {
InstallHomebrew();
}
}, true));
}
}
}})
);
Expand Down
49 changes: 37 additions & 12 deletions sphaira/source/ui/menus/main_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ MainMenu::MainMenu() {

SidebarEntryArray::Items language_items;
language_items.push_back("Auto"_i18n);

language_items.push_back("English"_i18n);
language_items.push_back("Japanese"_i18n);
language_items.push_back("French"_i18n);
Expand Down Expand Up @@ -266,30 +265,56 @@ MainMenu::MainMenu() {
}
}));

options->Add(std::make_shared<SidebarEntryArray>("Language"_i18n, language_items, [this, language_items](std::size_t& index_out){
options->Add(std::make_shared<SidebarEntryArray>("Language"_i18n, language_items, [this](std::size_t& index_out){
App::SetLanguage(index_out);
}, (std::size_t)App::GetLanguage()));

options->Add(std::make_shared<SidebarEntryBool>("Logging"_i18n, App::GetLogEnable(), [this](bool& enable){
App::SetLogEnable(enable);
}, "Enabled"_i18n, "Disabled"_i18n));
options->Add(std::make_shared<SidebarEntryBool>("Replace hbmenu on exit"_i18n, App::GetReplaceHbmenuEnable(), [this](bool& enable){
App::SetReplaceHbmenuEnable(enable);
}, "Enabled"_i18n, "Disabled"_i18n));

options->Add(std::make_shared<SidebarEntryCallback>("Misc"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Misc Options"_i18n, Sidebar::Side::LEFT);
ON_SCOPE_EXIT(App::Push(options));

options->Add(std::make_shared<SidebarEntryCallback>("Themezer"_i18n, [](){
App::Push(std::make_shared<menu::themezer::Menu>());
}));

options->Add(std::make_shared<SidebarEntryCallback>("Irs"_i18n, [](){
App::Push(std::make_shared<menu::irs::Menu>());
}));
options->Add(std::make_shared<SidebarEntryCallback>("Web"_i18n, [](){
WebShow("https://lite.duckduckgo.com/lite");
}));

if (App::IsApplication()) {
options->Add(std::make_shared<SidebarEntryCallback>("Web"_i18n, [](){
WebShow("https://lite.duckduckgo.com/lite");
}));
}
}));

options->Add(std::make_shared<SidebarEntryCallback>("Advanced"_i18n, [this](){
auto options = std::make_shared<Sidebar>("Advanced Options"_i18n, Sidebar::Side::LEFT);
ON_SCOPE_EXIT(App::Push(options));

SidebarEntryArray::Items install_items;
install_items.push_back("System memory"_i18n);
install_items.push_back("microSD card"_i18n);

options->Add(std::make_shared<SidebarEntryBool>("Logging"_i18n, App::GetLogEnable(), [this](bool& enable){
App::SetLogEnable(enable);
}, "Enabled"_i18n, "Disabled"_i18n));

options->Add(std::make_shared<SidebarEntryBool>("Replace hbmenu on exit"_i18n, App::GetReplaceHbmenuEnable(), [this](bool& enable){
App::SetReplaceHbmenuEnable(enable);
}, "Enabled"_i18n, "Disabled"_i18n));

options->Add(std::make_shared<SidebarEntryBool>("Install forwarders"_i18n, App::GetInstallEnable(), [this](bool& enable){
App::SetInstallEnable(enable);
}, "Enabled"_i18n, "Disabled"_i18n));

options->Add(std::make_shared<SidebarEntryArray>("Install location"_i18n, install_items, [this](std::size_t& index_out){
App::SetInstallSdEnable(index_out);
}, (std::size_t)App::GetInstallSdEnable()));

options->Add(std::make_shared<SidebarEntryBool>("Show install warning"_i18n, App::GetInstallPrompt(), [this](bool& enable){
App::SetInstallPrompt(enable);
}, "Enabled"_i18n, "Disabled"_i18n));
}));
}})
);
Expand Down

0 comments on commit 4a058d3

Please sign in to comment.