mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-29 19:55:37 +00:00
Added GuiThemeDownloader to the main menu and added a callback to reload the menu on theme updates
This commit is contained in:
parent
3c6fff8a18
commit
8cdedd945f
|
@ -113,17 +113,17 @@ void GuiMenu::openUIOptions()
|
|||
auto themeSet =
|
||||
std::make_shared<OptionListComponent<std::string>>(getHelpStyle(), "THEME SET", false);
|
||||
|
||||
// TODO: Enable and possibly move somewhere else when the theme downloader is implemented.
|
||||
// ComponentListRow themeDownloaderInputRow;
|
||||
// themeDownloaderInputRow.elements.clear();
|
||||
// themeDownloaderInputRow.addElement(std::make_shared<TextComponent>("THEME DOWNLOADER",
|
||||
// Font::get(FONT_SIZE_MEDIUM),
|
||||
// 0x777777FF),
|
||||
// true);
|
||||
// themeDownloaderInputRow.addElement(makeArrow(), false);
|
||||
// themeDownloaderInputRow.makeAcceptInputHandler(
|
||||
// std::bind(&GuiMenu::openThemeDownloader, this, s));
|
||||
// s->addRow(themeDownloaderInputRow);
|
||||
ComponentListRow themeDownloaderInputRow;
|
||||
themeDownloaderInputRow.elements.clear();
|
||||
themeDownloaderInputRow.addElement(
|
||||
std::make_shared<TextComponent>("THEME DOWNLOADER (EXPERIMENTAL)",
|
||||
Font::get(FONT_SIZE_MEDIUM), 0x777777FF),
|
||||
true);
|
||||
themeDownloaderInputRow.addElement(makeArrow(), false);
|
||||
|
||||
themeDownloaderInputRow.makeAcceptInputHandler(
|
||||
std::bind(&GuiMenu::openThemeDownloader, this, s));
|
||||
s->addRow(themeDownloaderInputRow);
|
||||
|
||||
// Theme set.
|
||||
if (!themeSets.empty()) {
|
||||
|
@ -1793,7 +1793,13 @@ void GuiMenu::addVersionInfo()
|
|||
|
||||
void GuiMenu::openThemeDownloader(GuiSettings* settings)
|
||||
{
|
||||
mWindow->pushGui(new GuiThemeDownloader());
|
||||
auto updateFunc = [&, settings]() {
|
||||
LOG(LogDebug) << "GuiMenu::openThemeDownloader(): Theme sets were updated, reloading menu";
|
||||
delete settings;
|
||||
openUIOptions();
|
||||
};
|
||||
|
||||
mWindow->pushGui(new GuiThemeDownloader(updateFunc));
|
||||
}
|
||||
|
||||
void GuiMenu::openMediaViewerOptions()
|
||||
|
|
|
@ -18,10 +18,11 @@
|
|||
|
||||
#define DEBUG_CLONING false
|
||||
|
||||
GuiThemeDownloader::GuiThemeDownloader()
|
||||
GuiThemeDownloader::GuiThemeDownloader(std::function<void()> updateCallback)
|
||||
: mRenderer {Renderer::getInstance()}
|
||||
, mBackground {":/graphics/frame.svg"}
|
||||
, mGrid {glm::ivec2 {2, 4}}
|
||||
, mUpdateCallback(updateCallback)
|
||||
, mRepositoryError {RepositoryError::NO_REPO_ERROR}
|
||||
, mFetching {false}
|
||||
, mLatestThemesList {false}
|
||||
|
@ -179,6 +180,9 @@ GuiThemeDownloader::~GuiThemeDownloader()
|
|||
if (mHasThemeUpdates) {
|
||||
LOG(LogInfo) << "GuiThemeDownloader: There are updates, repopulating theme sets";
|
||||
ThemeData::populateThemeSets();
|
||||
ViewController::getInstance()->reloadAll();
|
||||
if (mUpdateCallback)
|
||||
mUpdateCallback();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1104,8 +1108,10 @@ bool GuiThemeDownloader::cloneRepository(const std::string& repositoryName, cons
|
|||
return true;
|
||||
}
|
||||
|
||||
if (repositoryName != "themes-list")
|
||||
if (repositoryName != "themes-list") {
|
||||
LOG(LogInfo) << "GuiThemeDownloader: Downloaded theme \"" << repositoryName << "\"";
|
||||
mHasThemeUpdates = true;
|
||||
}
|
||||
|
||||
mLatestThemesList = true;
|
||||
mPromise.set_value(true);
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
class GuiThemeDownloader : public GuiComponent
|
||||
{
|
||||
public:
|
||||
GuiThemeDownloader();
|
||||
GuiThemeDownloader(std::function<void()> updateCallback);
|
||||
~GuiThemeDownloader();
|
||||
|
||||
void update(int deltaTime) override;
|
||||
|
@ -105,6 +105,7 @@ private:
|
|||
std::shared_ptr<ComponentList> mList;
|
||||
std::shared_ptr<ComponentGrid> mButtons;
|
||||
BusyComponent mBusyAnim;
|
||||
std::function<void()> mUpdateCallback;
|
||||
|
||||
struct ThemeGUIEntry {
|
||||
std::shared_ptr<TextComponent> themeName;
|
||||
|
|
Loading…
Reference in a new issue