option to hide homebrew.

This commit is contained in:
ITotalJustice
2025-07-31 18:47:41 +01:00
parent 25e19b22f7
commit 3ebb3bd055
6 changed files with 180 additions and 140 deletions

View File

@@ -11,6 +11,7 @@ namespace sphaira {
struct Hbini {
u64 timestamp{}; // timestamp of last launch
bool hidden{};
};
struct MiniNacp {
@@ -61,7 +62,7 @@ auto nro_parse(const fs::FsPath& path, NroEntry& entry) -> Result;
* nro found.
* this does nothing if nested=false.
*/
auto nro_scan(const fs::FsPath& path, std::vector<NroEntry>& nros, bool hide_spahira, bool nested = true, bool scan_all_dir = true) -> Result;
auto nro_scan(const fs::FsPath& path, std::vector<NroEntry>& nros, bool nested = true, bool scan_all_dir = true) -> Result;
auto nro_get_icon(const fs::FsPath& path, u64 size, u64 offset) -> std::vector<u8>;
auto nro_get_icon(const fs::FsPath& path) -> std::vector<u8>;

View File

@@ -8,6 +8,12 @@
namespace sphaira::ui::menu::homebrew {
enum Filter {
Filter_All,
Filter_HideHidden,
Filter_MAX,
};
enum SortType {
SortType_Updated,
SortType_Alphabetical,
@@ -43,6 +49,14 @@ struct Menu final : grid::Menu {
static Result InstallHomebrew(const fs::FsPath& path, const std::vector<u8>& icon);
static Result InstallHomebrewFromPath(const fs::FsPath& path);
auto GetEntry(s64 i) -> NroEntry& {
return m_entries[m_entries_current[i]];
}
auto GetEntry() -> NroEntry& {
return GetEntry(m_index);
}
private:
void SetIndex(s64 index);
void InstallHomebrew();
@@ -51,6 +65,7 @@ private:
void SortAndFindLastFile(bool scan = false);
void FreeEntries();
void OnLayoutChange();
void DisplayOptions();
auto IsStarEnabled() -> bool {
return m_sort.Get() >= SortType_UpdatedStar;
@@ -60,6 +75,9 @@ private:
static constexpr inline const char* INI_SECTION = "homebrew";
std::vector<NroEntry> m_entries{};
std::vector<u32> m_entries_index[Filter_MAX]{};
std::span<u32> m_entries_current{};
s64 m_index{}; // where i am in the array
std::unique_ptr<List> m_list{};
bool m_dirty{};
@@ -67,7 +85,7 @@ private:
option::OptionLong m_sort{INI_SECTION, "sort", SortType::SortType_AlphabeticalStar};
option::OptionLong m_order{INI_SECTION, "order", OrderType::OrderType_Descending};
option::OptionLong m_layout{INI_SECTION, "layout", LayoutType::LayoutType_GridDetail};
option::OptionBool m_hide_sphaira{INI_SECTION, "hide_sphaira", false};
option::OptionBool m_show_hidden{INI_SECTION, "show_hidden", false};
};
} // namespace sphaira::ui::menu::homebrew