From 97085ef28230662bd486b2ee01074b0cbbe260c5 Mon Sep 17 00:00:00 2001 From: ITotalJustice <47043333+ITotalJustice@users.noreply.github.com> Date: Sat, 21 Dec 2024 18:01:57 +0000 Subject: [PATCH] add option in config to remove install warning prompt --- sphaira/include/app.hpp | 2 ++ sphaira/source/app.cpp | 4 ++++ sphaira/source/ui/menus/filebrowser.cpp | 27 +++++++++++++++---------- sphaira/source/ui/menus/homebrew.cpp | 18 ++++++++++------- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/sphaira/include/app.hpp b/sphaira/include/app.hpp index e4b9bc7..8a8c654 100644 --- a/sphaira/include/app.hpp +++ b/sphaira/include/app.hpp @@ -64,6 +64,7 @@ public: static auto GetLogEnable() -> bool; static auto GetReplaceHbmenuEnable() -> bool; static auto GetInstallSdEnable() -> bool; + static auto GetInstallPrompt() -> bool; static auto GetThemeShuffleEnable() -> bool; static auto GetThemeMusicEnable() -> bool; static auto GetLanguage() -> long; @@ -139,6 +140,7 @@ public: option::OptionBool m_log_enabled{INI_SECTION, "log_enabled", false}; option::OptionBool m_replace_hbmenu{INI_SECTION, "replace_hbmenu", 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}; option::OptionBool m_theme_music{INI_SECTION, "theme_music", true}; option::OptionLong m_language{INI_SECTION, "language", 0}; // auto diff --git a/sphaira/source/app.cpp b/sphaira/source/app.cpp index f731dab..65c2b02 100644 --- a/sphaira/source/app.cpp +++ b/sphaira/source/app.cpp @@ -367,6 +367,10 @@ auto App::GetInstallSdEnable() -> bool { return g_app->m_install_sd.Get(); } +auto App::GetInstallPrompt() -> bool { + return g_app->m_install_prompt.Get(); +} + auto App::GetThemeShuffleEnable() -> bool { return g_app->m_theme_shuffle.Get(); } diff --git a/sphaira/source/ui/menus/filebrowser.cpp b/sphaira/source/ui/menus/filebrowser.cpp index 87820d8..900dc2c 100644 --- a/sphaira/source/ui/menus/filebrowser.cpp +++ b/sphaira/source/ui/menus/filebrowser.cpp @@ -610,20 +610,18 @@ Menu::Menu(const std::vector& nro_entries) : MenuBase{"FileBrowser"_i1 if (m_entries_current.size()) { if (HasTypeInSelectedEntries(FsDirEntryType_File) && !m_selected_count && (GetEntry().GetExtension() == "nro" || !FindFileAssocFor().empty())) { options->Add(std::make_shared("Install Forwarder"_i18n, [this](){; - App::Push(std::make_shared( - "WARNING: Installing forwarders will lead to a ban!"_i18n, - "Back"_i18n, "Install"_i18n, 0, [this](auto op_index){ - if (op_index && *op_index) { - if (GetEntry().GetExtension() == "nro") { - if (R_FAILED(homebrew::Menu::InstallHomebrewFromPath(GetNewPathCurrent()))) { - log_write("failed to create forwarder\n"); - } - } else { + if (App::GetInstallPrompt()) { + App::Push(std::make_shared( + "WARNING: Installing forwarders will lead to a ban!"_i18n, + "Back"_i18n, "Install"_i18n, 0, [this](auto op_index){ + if (op_index && *op_index) { InstallForwarder(); } } - } - )); + )); + } else { + InstallForwarder(); + } })); } @@ -860,6 +858,13 @@ void Menu::SetIndex(std::size_t index) { } void Menu::InstallForwarder() { + if (GetEntry().GetExtension() == "nro") { + if (R_FAILED(homebrew::Menu::InstallHomebrewFromPath(GetNewPathCurrent()))) { + log_write("failed to create forwarder\n"); + } + return; + } + const auto assoc_list = FindFileAssocFor(); if (assoc_list.empty()) { log_write("failed to find assoc for: %s ext: %s\n", GetEntry().name, GetEntry().extension.c_str()); diff --git a/sphaira/source/ui/menus/homebrew.cpp b/sphaira/source/ui/menus/homebrew.cpp index 3760a89..e7e90fb 100644 --- a/sphaira/source/ui/menus/homebrew.cpp +++ b/sphaira/source/ui/menus/homebrew.cpp @@ -127,14 +127,18 @@ Menu::Menu() : MenuBase{"Homebrew"_i18n} { }, true)); options->Add(std::make_shared("Install Forwarder"_i18n, [this](){ - App::Push(std::make_shared( - "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::GetInstallPrompt()) { + App::Push(std::make_shared( + "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)); } }})