2023-02-13 19:38:23 +00:00
|
|
|
// 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"
|
2023-03-21 18:01:44 +00:00
|
|
|
#include "components/BusyComponent.h"
|
2023-03-22 19:56:48 +00:00
|
|
|
#include "components/ButtonComponent.h"
|
2023-02-13 19:38:23 +00:00
|
|
|
#include "components/ComponentGrid.h"
|
2023-03-22 19:56:48 +00:00
|
|
|
#include "components/ComponentList.h"
|
2023-02-13 19:38:23 +00:00
|
|
|
#include "components/NinePatchComponent.h"
|
|
|
|
#include "components/TextComponent.h"
|
|
|
|
#include "renderers/Renderer.h"
|
|
|
|
#include "views/ViewController.h"
|
|
|
|
|
2023-03-21 18:01:44 +00:00
|
|
|
#include <git2/clone.h>
|
|
|
|
#include <git2/errors.h>
|
|
|
|
#include <git2/global.h>
|
|
|
|
#include <git2/merge.h>
|
|
|
|
#include <git2/reset.h>
|
|
|
|
#include <git2/revparse.h>
|
|
|
|
#include <git2/status.h>
|
2023-03-22 19:56:48 +00:00
|
|
|
#include <git2/version.h>
|
2023-03-21 18:01:44 +00:00
|
|
|
|
|
|
|
#include <atomic>
|
|
|
|
#include <future>
|
|
|
|
#include <thread>
|
|
|
|
|
2023-02-13 19:38:23 +00:00
|
|
|
class GuiThemeDownloader : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GuiThemeDownloader();
|
2023-03-21 18:01:44 +00:00
|
|
|
~GuiThemeDownloader();
|
2023-02-13 19:38:23 +00:00
|
|
|
|
2023-03-21 18:01:44 +00:00
|
|
|
bool fetchRepository(std::pair<std::string, std::string> repoInfo, bool allowReset = false);
|
|
|
|
bool renameDirectory(const std::string& path);
|
2023-02-13 19:38:23 +00:00
|
|
|
void parseThemesList();
|
|
|
|
|
2023-03-22 19:56:48 +00:00
|
|
|
void populateGUI();
|
|
|
|
|
2023-03-21 18:01:44 +00:00
|
|
|
void update(int deltaTime) override;
|
|
|
|
void render(const glm::mat4& parentTrans) override;
|
|
|
|
|
2023-02-13 19:38:23 +00:00
|
|
|
void onSizeChanged() override;
|
|
|
|
bool input(InputConfig* config, Input input) override;
|
|
|
|
|
|
|
|
std::vector<HelpPrompt> getHelpPrompts() override;
|
|
|
|
HelpStyle getHelpStyle() override { return ViewController::getInstance()->getViewHelpStyle(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Renderer* mRenderer;
|
|
|
|
NinePatchComponent mBackground;
|
|
|
|
ComponentGrid mGrid;
|
2023-03-22 19:56:48 +00:00
|
|
|
std::shared_ptr<ComponentList> mList;
|
|
|
|
std::shared_ptr<ComponentGrid> mButtons;
|
|
|
|
BusyComponent mBusyAnim;
|
2023-02-13 19:38:23 +00:00
|
|
|
|
2023-03-21 18:01:44 +00:00
|
|
|
std::string mErrorMessage;
|
|
|
|
std::thread mFetchThread;
|
|
|
|
std::promise<bool> mPromise;
|
|
|
|
std::future<bool> mFuture;
|
|
|
|
std::atomic<bool> mFetching;
|
|
|
|
std::atomic<bool> mLatestThemesList;
|
|
|
|
bool mHasLocalChanges;
|
|
|
|
static inline std::atomic<float> mReceivedObjectsProgress {0.0f};
|
|
|
|
static inline std::atomic<float> mResolveDeltaProgress {0.0f};
|
|
|
|
|
2023-02-13 19:38:23 +00:00
|
|
|
struct Screenshot {
|
|
|
|
std::string image;
|
|
|
|
std::string caption;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ThemeEntry {
|
|
|
|
std::string name;
|
|
|
|
std::string reponame;
|
|
|
|
std::string url;
|
|
|
|
std::vector<std::string> variants;
|
|
|
|
std::vector<std::string> colorSchemes;
|
|
|
|
std::vector<std::string> aspectRatios;
|
|
|
|
std::vector<std::string> transitions;
|
|
|
|
std::vector<Screenshot> screenshots;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::shared_ptr<TextComponent> mTitle;
|
|
|
|
std::vector<ThemeEntry> mThemeSets;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ES_APP_GUIS_GUI_THEME_DOWNLOADER_H
|