#pragma once #include #include #include #include #include #include #include #include namespace hex::plugin::builtin { enum class RequestStatus { NotAttempted, InProgress, Failed, Succeeded, }; struct StoreEntry { std::string name; std::string description; std::vector authors; std::string fileName; std::string link; std::string hash; bool isFolder; bool downloading; bool installed; bool hasUpdate; bool system; }; struct StoreCategory { UnlocalizedString unlocalizedName; std::string requestName; fs::ImHexPath path; std::vector entries; std::function downloadCallback; }; class ViewStore : public View::Floating { public: ViewStore(); ~ViewStore() override = default; void drawContent() override; [[nodiscard]] bool shouldDraw() const override { return true; } [[nodiscard]] bool hasViewMenuItemEntry() const override { return false; } [[nodiscard]] ImVec2 getMinSize() const override { return scaled({ 600, 400 }); } [[nodiscard]] ImVec2 getMaxSize() const override { return scaled({ 900, 700 }); } private: void drawStore(); void drawTab(StoreCategory &category); void handleDownloadFinished(const StoreCategory &category, StoreEntry &entry); void refresh(); void parseResponse(); void addCategory(const UnlocalizedString &unlocalizedName, const std::string &requestName, fs::ImHexPath path, std::function downloadCallback = []{}); bool download(fs::ImHexPath pathType, const std::string &fileName, const std::string &url); bool remove(fs::ImHexPath pathType, const std::string &fileName); private: HttpRequest m_httpRequest = HttpRequest("GET", ""); std::future> m_apiRequest; std::future> m_download; std::fs::path m_downloadPath; RequestStatus m_requestStatus = RequestStatus::NotAttempted; std::vector m_categories; TaskHolder m_updateAllTask; std::atomic m_updateCount = 0; }; }