add GitHub downloader, fix yyjson helper missing break, hide popup list when out of focus

This commit is contained in:
ITotalJustice
2024-12-26 18:11:03 +00:00
parent adf0a3b2cd
commit ec7caabdbd
12 changed files with 649 additions and 4 deletions

View File

@@ -0,0 +1,67 @@
#pragma once
#include "ui/menus/menu_base.hpp"
#include "fs.hpp"
#include "option.hpp"
#include <vector>
#include <string>
namespace sphaira::ui::menu::gh {
struct AssetEntry {
std::string name;
std::string path;
};
struct Entry {
fs::FsPath json_path;
std::string name;
std::string url;
std::vector<AssetEntry> assets;
};
struct GhApiAsset {
std::string name;
std::string content_type;
u64 size;
u64 download_count;
std::string browser_download_url;
};
struct GhApiEntry {
std::string tag_name;
std::string name;
std::vector<GhApiAsset> assets;
};
struct Menu final : MenuBase {
Menu();
~Menu();
void Update(Controller* controller, TouchInfo* touch) override;
void Draw(NVGcontext* vg, Theme* theme) override;
void OnFocusGained() override;
private:
void SetIndex(std::size_t index);
void Scan();
void LoadEntriesFromPath(const fs::FsPath& path);
auto GetEntry() -> Entry& {
return m_entries[m_index];
}
auto GetEntry() const -> const Entry& {
return m_entries[m_index];
}
void Sort();
void UpdateSubheading();
private:
std::vector<Entry> m_entries;
std::size_t m_index{};
std::size_t m_index_offset{};
};
} // namespace sphaira::ui::menu::gh

View File

@@ -21,6 +21,8 @@ public:
auto Update(Controller* controller, TouchInfo* touch) -> void override;
auto OnLayoutChange() -> void override;
auto Draw(NVGcontext* vg, Theme* theme) -> void override;
auto OnFocusGained() noexcept -> void override;
auto OnFocusLost() noexcept -> void override;
private:
static constexpr Vec2 m_title_pos{70.f, 28.f};