From e0e1a05f1e9e11ff2446d24858961c66ce8e374b Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 5 Apr 2021 10:05:08 +0200 Subject: [PATCH] A transition now always takes place to the System view when changing theme sets. Also fixed an issue where the camera would not move until after the menu was closed. --- es-app/src/guis/GuiMenu.cpp | 4 +++- es-core/src/Window.cpp | 12 +++++++++++- es-core/src/Window.h | 3 +++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index f566727b8..ea726b623 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -183,14 +183,16 @@ void GuiMenu::openUISettings() for (auto it = themeSets.cbegin(); it != themeSets.cend(); it++) theme_set->add(it->first, it->first, it == selectedSet); s->addWithLabel("THEME SET", theme_set); - s->addSaveFunc([theme_set, s] { + s->addSaveFunc([this, theme_set, s] { if (theme_set->getSelected() != Settings::getInstance()->getString("ThemeSet")) { Scripting::fireEvent("theme-changed", theme_set->getSelected(), Settings::getInstance()->getString("ThemeSet")); Settings::getInstance()->setString("ThemeSet", theme_set->getSelected()); CollectionSystemsManager::get()->updateSystemsList(); + mWindow->setChangedThemeSet(); s->setNeedsSaving(); s->setNeedsReloading(); + s->setNeedsGoToStart(); s->setInvalidateCachedBackground(); } }); diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index 0e29e27d0..c918dd002 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -38,7 +38,8 @@ Window::Window() mInvalidatedCachedBackground(false), mTopOpacity(0), mTopScale(0.5), - mListScrollOpacity(0) + mListScrollOpacity(0), + mChangedThemeSet(false) { mHelp = new HelpComponent(this); mBackgroundOverlay = new ImageComponent(this); @@ -292,6 +293,15 @@ void Window::update(int deltaTime) if (peekGui()) peekGui()->update(deltaTime); + // If the theme set changed, we need to update the background once so that the camera + // will be moved. This is required as theme set changes always makes a transition to + // the system view. If we wouldn't make this update, the camera movement would only + // take place once the menu has been closed. + if (mChangedThemeSet && mGuiStack.size() > 1) { + mGuiStack.front()->update(deltaTime); + mChangedThemeSet = false; + } + // Update the screensaver. if (mScreensaver) mScreensaver->update(deltaTime); diff --git a/es-core/src/Window.h b/es-core/src/Window.h index 43d9f3a8f..32d3c2560 100644 --- a/es-core/src/Window.h +++ b/es-core/src/Window.h @@ -106,6 +106,8 @@ public: void setAllowTextScrolling(bool setting) { mAllowTextScrolling = setting; }; bool getAllowTextScrolling() { return mAllowTextScrolling; }; + void setChangedThemeSet() { mChangedThemeSet = true; }; + private: void onSleep(); void onWake(); @@ -143,6 +145,7 @@ private: unsigned char mTopOpacity; float mTopScale; bool mRenderedHelpPrompts; + bool mChangedThemeSet; }; #endif // ES_CORE_WINDOW_H