// SPDX-License-Identifier: MIT // // EmulationStation Desktop Edition // GuiThemeDownloader.h // // Theme downloader. // #ifndef ES_APP_GUIS_GUI_THEME_DOWNLOADER_H #define ES_APP_GUIS_GUI_THEME_DOWNLOADER_H #include "GuiComponent.h" #include "components/BusyComponent.h" #include "components/ButtonComponent.h" #include "components/ComponentGrid.h" #include "components/ComponentList.h" #include "components/NinePatchComponent.h" #include "components/TextComponent.h" #include "renderers/Renderer.h" #include "views/ViewController.h" #include #include #include #include #include #include #include #include #include #include #include class GuiThemeDownloader : public GuiComponent { public: GuiThemeDownloader(); ~GuiThemeDownloader(); void update(int deltaTime) override; void render(const glm::mat4& parentTrans) override; void onSizeChanged() override; bool input(InputConfig* config, Input input) override; std::vector getHelpPrompts() override; HelpStyle getHelpStyle() override { return ViewController::getInstance()->getViewHelpStyle(); } private: struct Screenshot { std::string image; std::string caption; }; struct ThemeEntry { std::string name; std::string reponame; std::string url; std::string manualExtension; std::vector variants; std::vector colorSchemes; std::vector aspectRatios; std::vector transitions; std::vector screenshots; bool invalidRepository; bool manuallyDownloaded; bool hasLocalChanges; bool isCloned; ThemeEntry() : invalidRepository {false} , manuallyDownloaded {false} , hasLocalChanges {false} , isCloned {false} { } }; bool fetchThemesList(); bool fetchRepository(const std::string& repositoryName, const std::string& url, bool allowReset = false); bool cloneRepository(const std::string& repositoryName, const std::string& url); bool checkLocalChanges(git_repository* repository, bool hasFetched = false); void resetRepository(git_repository* repository); void makeInventory(); bool renameDirectory(const std::string& path); void parseThemesList(); void populateGUI(); void updateGUI(); Renderer* mRenderer; NinePatchComponent mBackground; ComponentGrid mGrid; std::shared_ptr mList; std::shared_ptr mButtons; BusyComponent mBusyAnim; struct ThemeGUIEntry { std::shared_ptr themeName; }; std::vector mThemeGUIEntries; enum class RepositoryError { NO_REPO_ERROR, MANUALLY_DOWNLOADED, NOT_A_REPOSITORY, INVALID_ORIGIN, HAS_DIVERGED, HAS_LOCAL_CHANGES }; RepositoryError mRepositoryError; std::string mErrorMessage; std::thread mFetchThread; std::promise mPromise; std::future mFuture; std::atomic mFetching; std::atomic mLatestThemesList; static inline std::atomic mReceivedObjectsProgress {0.0f}; static inline std::atomic mResolveDeltaProgress {0.0f}; std::shared_ptr mTitle; std::vector mThemeSets; }; #endif // ES_APP_GUIS_GUI_THEME_DOWNLOADER_H