diff --git a/sphaira/include/ui/menus/themezer.hpp b/sphaira/include/ui/menus/themezer.hpp index 7ff6368..533b16e 100644 --- a/sphaira/include/ui/menus/themezer.hpp +++ b/sphaira/include/ui/menus/themezer.hpp @@ -138,6 +138,7 @@ struct Menu final : MenuBase { void Draw(NVGcontext* vg, Theme* theme) override; void OnFocusGained() override; +private: void SetIndex(s64 index) { m_index = index; if (!m_index) { @@ -147,7 +148,7 @@ struct Menu final : MenuBase { void InvalidateAllPages(); void PackListDownload(); - void OnPackListDownload(); + void DisplayOptions(); private: static constexpr inline const char* INI_SECTION = "themezer"; diff --git a/sphaira/source/ui/menus/themezer.cpp b/sphaira/source/ui/menus/themezer.cpp index 8c7e55c..8f01afe 100644 --- a/sphaira/source/ui/menus/themezer.cpp +++ b/sphaira/source/ui/menus/themezer.cpp @@ -397,59 +397,7 @@ Menu::Menu(u32 flags) : MenuBase{"Themezer"_i18n, flags} { ); }}), std::make_pair(Button::X, Action{"Options"_i18n, [this](){ - auto options = std::make_unique("Themezer Options"_i18n, Sidebar::Side::RIGHT); - ON_SCOPE_EXIT(App::Push(std::move(options))); - - SidebarEntryArray::Items sort_items; - sort_items.push_back("Downloads"_i18n); - sort_items.push_back("Updated"_i18n); - sort_items.push_back("Likes"_i18n); - sort_items.push_back("ID"_i18n); - - SidebarEntryArray::Items order_items; - order_items.push_back("Descending (down)"_i18n); - order_items.push_back("Ascending (Up)"_i18n); - - options->Add("Nsfw"_i18n, m_nsfw.Get(), [this](bool& v_out){ - m_nsfw.Set(v_out); - InvalidateAllPages(); - }); - - options->Add("Sort"_i18n, sort_items, [this, sort_items](s64& index_out){ - if (m_sort.Get() != index_out) { - m_sort.Set(index_out); - InvalidateAllPages(); - } - }, m_sort.Get()); - - options->Add("Order"_i18n, order_items, [this, order_items](s64& index_out){ - if (m_order.Get() != index_out) { - m_order.Set(index_out); - InvalidateAllPages(); - } - }, m_order.Get()); - - options->Add("Page"_i18n, [this](){ - s64 out; - if (R_SUCCEEDED(swkbd::ShowNumPad(out, "Enter Page Number"_i18n.c_str(), nullptr, -1, 3))) { - if (out < m_page_index_max) { - m_page_index = out; - PackListDownload(); - } else { - log_write("invalid page number\n"); - App::Notify("Bad Page"_i18n); - } - } - }); - - options->Add("Search"_i18n, [this](){ - std::string out; - if (R_SUCCEEDED(swkbd::ShowText(out)) && !out.empty()) { - m_search = out; - // PackListDownload(); - InvalidateAllPages(); - } - }); + DisplayOptions(); }}), std::make_pair(Button::R2, Action{"Next"_i18n, [this](){ m_page_index++; @@ -711,4 +659,67 @@ void Menu::PackListDownload() { }); } +void Menu::DisplayOptions() { + auto options = std::make_unique("Themezer Options"_i18n, Sidebar::Side::RIGHT); + ON_SCOPE_EXIT(App::Push(std::move(options))); + + SidebarEntryArray::Items sort_items; + sort_items.push_back("Downloads"_i18n); + sort_items.push_back("Updated"_i18n); + sort_items.push_back("Likes"_i18n); + sort_items.push_back("ID"_i18n); + + SidebarEntryArray::Items order_items; + order_items.push_back("Descending (down)"_i18n); + order_items.push_back("Ascending (Up)"_i18n); + + options->Add("Nsfw"_i18n, m_nsfw.Get(), [this](bool& v_out){ + m_nsfw.Set(v_out); + InvalidateAllPages(); + }); + + options->Add("Sort"_i18n, sort_items, [this, sort_items](s64& index_out){ + if (m_sort.Get() != index_out) { + m_sort.Set(index_out); + InvalidateAllPages(); + } + }, m_sort.Get()); + + options->Add("Order"_i18n, order_items, [this, order_items](s64& index_out){ + if (m_order.Get() != index_out) { + m_order.Set(index_out); + InvalidateAllPages(); + } + }, m_order.Get()); + + options->Add("Page"_i18n, [this](){ + s64 out; + if (R_SUCCEEDED(swkbd::ShowNumPad(out, "Enter Page Number"_i18n.c_str(), nullptr, -1, 3))) { + if (out < m_page_index_max) { + m_page_index = out; + PackListDownload(); + } else { + log_write("invalid page number\n"); + App::Notify("Bad Page"_i18n); + } + } + }); + + options->Add("Search"_i18n, [this](){ + std::string out; + if (R_SUCCEEDED(swkbd::ShowText(out)) && !out.empty()) { + m_search = out; + // PackListDownload(); + InvalidateAllPages(); + } + }); + + if (HasNro()) { + options->Add("Launch NXthemes_Installer.nro"_i18n, [](){ + const auto rc = nro_launch(GetNroPath()); + App::PushErrorBox(rc, "Failed to launch NXthemes_Installer.nro"_i18n); + }); + } +} + } // namespace sphaira::ui::menu::themezer