add option to change the right-side menu.
This commit is contained in:
@@ -846,13 +846,42 @@ void EntryMenu::SetIndex(s64 index) {
|
||||
}
|
||||
}
|
||||
|
||||
Menu::Menu(const std::vector<NroEntry>& nro_entries) : MenuBase{"AppStore"_i18n}, m_nro_entries{nro_entries} {
|
||||
Menu::Menu() : MenuBase{"AppStore"_i18n} {
|
||||
fs::FsNativeSd fs;
|
||||
fs.CreateDirectoryRecursively("/switch/sphaira/cache/appstore/icons");
|
||||
fs.CreateDirectoryRecursively("/switch/sphaira/cache/appstore/banners");
|
||||
fs.CreateDirectoryRecursively("/switch/sphaira/cache/appstore/screens");
|
||||
|
||||
this->SetActions(
|
||||
std::make_pair(Button::B, Action{"Back"_i18n, [this](){
|
||||
if (m_is_author) {
|
||||
m_is_author = false;
|
||||
if (m_is_search) {
|
||||
SetSearch(m_search_term);
|
||||
} else {
|
||||
SetFilter(m_filter);
|
||||
}
|
||||
|
||||
SetIndex(m_entry_author_jump_back);
|
||||
if (m_entry_author_jump_back >= 9) {
|
||||
m_list->SetYoff((((m_entry_author_jump_back - 9) + 3) / 3) * m_list->GetMaxY());
|
||||
} else {
|
||||
m_list->SetYoff(0);
|
||||
}
|
||||
} else if (m_is_search) {
|
||||
m_is_search = false;
|
||||
SetFilter(m_filter);
|
||||
SetIndex(m_entry_search_jump_back);
|
||||
if (m_entry_search_jump_back >= 9) {
|
||||
m_list->SetYoff(0);
|
||||
m_list->SetYoff((((m_entry_search_jump_back - 9) + 3) / 3) * m_list->GetMaxY());
|
||||
} else {
|
||||
m_list->SetYoff(0);
|
||||
}
|
||||
} else {
|
||||
SetPop();
|
||||
}
|
||||
}}),
|
||||
std::make_pair(Button::A, Action{"Info"_i18n, [this](){
|
||||
if (m_entries_current.empty()) {
|
||||
// log_write("pushing A when empty: size: %zu count: %zu\n", repo_json.size(), m_entries_current.size());
|
||||
@@ -1264,7 +1293,6 @@ void Menu::Sort() {
|
||||
void Menu::SetFilter(Filter filter) {
|
||||
m_is_search = false;
|
||||
m_is_author = false;
|
||||
RemoveAction(Button::B);
|
||||
|
||||
m_filter = filter;
|
||||
m_entries_current = m_entries_index[m_filter];
|
||||
@@ -1303,17 +1331,6 @@ void Menu::SetSearch(const std::string& term) {
|
||||
}
|
||||
}
|
||||
|
||||
SetAction(Button::B, Action{"Back"_i18n, [this](){
|
||||
SetFilter(m_filter);
|
||||
SetIndex(m_entry_search_jump_back);
|
||||
if (m_entry_search_jump_back >= 9) {
|
||||
m_list->SetYoff(0);
|
||||
m_list->SetYoff((((m_entry_search_jump_back - 9) + 3) / 3) * m_list->GetMaxY());
|
||||
} else {
|
||||
m_list->SetYoff(0);
|
||||
}
|
||||
}});
|
||||
|
||||
m_is_search = true;
|
||||
m_entries_current = m_entries_index_search;
|
||||
SetIndex(0);
|
||||
@@ -1336,21 +1353,6 @@ void Menu::SetAuthor() {
|
||||
}
|
||||
}
|
||||
|
||||
SetAction(Button::B, Action{"Back"_i18n, [this](){
|
||||
if (m_is_search) {
|
||||
SetSearch(m_search_term);
|
||||
} else {
|
||||
SetFilter(m_filter);
|
||||
}
|
||||
|
||||
SetIndex(m_entry_author_jump_back);
|
||||
if (m_entry_author_jump_back >= 9) {
|
||||
m_list->SetYoff((((m_entry_author_jump_back - 9) + 3) / 3) * m_list->GetMaxY());
|
||||
} else {
|
||||
m_list->SetYoff(0);
|
||||
}
|
||||
}});
|
||||
|
||||
m_is_author = true;
|
||||
m_entries_current = m_entries_index_author;
|
||||
SetIndex(0);
|
||||
|
||||
@@ -204,17 +204,6 @@ Menu::Menu() : MenuBase{"Irs"_i18n} {
|
||||
PollCameraStatus(true);
|
||||
// load default config
|
||||
LoadDefaultConfig();
|
||||
// poll to get first available handle.
|
||||
PollCameraStatus(false);
|
||||
|
||||
// find the first available entry and connect to that.
|
||||
for (s64 i = 0; i < std::size(m_entries); i++) {
|
||||
if (m_entries[i].status == IrsIrCameraStatus_Available) {
|
||||
m_index = i;
|
||||
UpdateConfig(&m_config);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Menu::~Menu() {
|
||||
@@ -307,6 +296,20 @@ void Menu::Draw(NVGcontext* vg, Theme* theme) {
|
||||
|
||||
void Menu::OnFocusGained() {
|
||||
MenuBase::OnFocusGained();
|
||||
|
||||
if (m_entries[m_index].status != IrsIrCameraStatus_Available) {
|
||||
// poll to get first available handle.
|
||||
PollCameraStatus(false);
|
||||
|
||||
// find the first available entry and connect to that.
|
||||
for (s64 i = 0; i < std::size(m_entries); i++) {
|
||||
if (m_entries[i].status == IrsIrCameraStatus_Available) {
|
||||
m_index = i;
|
||||
UpdateConfig(&m_config);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::PollCameraStatus(bool statup) {
|
||||
|
||||
@@ -6,12 +6,20 @@
|
||||
#include "ui/progress_box.hpp"
|
||||
#include "ui/error_box.hpp"
|
||||
|
||||
#include "ui/menus/irs_menu.hpp"
|
||||
#include "ui/menus/themezer.hpp"
|
||||
#include "ui/menus/ghdl.hpp"
|
||||
#include "ui/menus/usb_menu.hpp"
|
||||
#include "ui/menus/ftp_menu.hpp"
|
||||
#include "ui/menus/gc_menu.hpp"
|
||||
#include "ui/menus/game_menu.hpp"
|
||||
#include "ui/menus/appstore.hpp"
|
||||
|
||||
#include "app.hpp"
|
||||
#include "log.hpp"
|
||||
#include "download.hpp"
|
||||
#include "defines.hpp"
|
||||
#include "i18n.hpp"
|
||||
#include "ui/menus/usb_menu.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <minizip/unzip.h>
|
||||
@@ -140,6 +148,30 @@ auto InstallUpdate(ProgressBox* pbox, const std::string url, const std::string v
|
||||
return true;
|
||||
}
|
||||
|
||||
auto CreateRightSideMenu() -> std::shared_ptr<MenuBase> {
|
||||
const auto name = App::GetApp()->m_right_side_menu.Get();
|
||||
|
||||
if ("Games" == name) {
|
||||
return std::make_shared<ui::menu::game::Menu>();
|
||||
}/*else if ("Themezer" == name) {
|
||||
return std::make_shared<ui::menu::themezer::Menu>();
|
||||
}*/else if ("GitHub" == name) {
|
||||
return std::make_shared<ui::menu::gh::Menu>();
|
||||
} else if ("IRS" == name) {
|
||||
return std::make_shared<ui::menu::irs::Menu>();
|
||||
} else if (App::GetInstallEnable()) {
|
||||
// if ("FTP" == name) {
|
||||
// return std::make_shared<ui::menu::ftp::Menu>();
|
||||
// } else if ("USB" == name) {
|
||||
// return std::make_shared<ui::menu::usb::Menu>();
|
||||
// } else if ("GameCard" == name) {
|
||||
// return std::make_shared<ui::menu::gc::Menu>();
|
||||
// }
|
||||
}
|
||||
|
||||
return std::make_shared<ui::menu::appstore::Menu>();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
MainMenu::MainMenu() {
|
||||
@@ -289,7 +321,7 @@ MainMenu::MainMenu() {
|
||||
|
||||
m_homebrew_menu = std::make_shared<homebrew::Menu>();
|
||||
m_filebrowser_menu = std::make_shared<filebrowser::Menu>(m_homebrew_menu->GetHomebrewList());
|
||||
m_app_store_menu = std::make_shared<appstore::Menu>(m_homebrew_menu->GetHomebrewList());
|
||||
m_right_side_menu = CreateRightSideMenu();
|
||||
m_current_menu = m_homebrew_menu;
|
||||
|
||||
AddOnLRPress();
|
||||
@@ -340,16 +372,16 @@ void MainMenu::OnLRPress(std::shared_ptr<MenuBase> menu, Button b) {
|
||||
|
||||
void MainMenu::AddOnLRPress() {
|
||||
if (m_current_menu != m_filebrowser_menu) {
|
||||
const auto label = m_current_menu == m_homebrew_menu ? "Files" : "Apps";
|
||||
const auto label = m_current_menu == m_homebrew_menu ? m_filebrowser_menu->GetShortTitle() : m_homebrew_menu->GetShortTitle();
|
||||
SetAction(Button::L, Action{i18n::get(label), [this]{
|
||||
OnLRPress(m_filebrowser_menu, Button::L);
|
||||
}});
|
||||
}
|
||||
|
||||
if (m_current_menu != m_app_store_menu) {
|
||||
const auto label = m_current_menu == m_homebrew_menu ? "Store" : "Apps";
|
||||
if (m_current_menu != m_right_side_menu) {
|
||||
const auto label = m_current_menu == m_homebrew_menu ? m_right_side_menu->GetShortTitle() : m_homebrew_menu->GetShortTitle();
|
||||
SetAction(Button::R, Action{i18n::get(label), [this]{
|
||||
OnLRPress(m_app_store_menu, Button::R);
|
||||
OnLRPress(m_right_side_menu, Button::R);
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user