From d4f5b2d20d8f164e44f7762936a354f57603d57b Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Thu, 17 Sep 2020 22:00:07 +0200 Subject: [PATCH] Text scrolling now stops when launching a game and when the screensaver starts. Also did some additional code cleanup. --- NEWS.md | 2 +- es-app/src/FileData.cpp | 17 +++-- es-app/src/FileData.h | 9 ++- es-app/src/SystemScreenSaver.h | 1 - es-app/src/views/ViewController.cpp | 3 + es-app/src/views/ViewController.h | 11 +-- es-core/src/Window.cpp | 29 +++++--- es-core/src/Window.h | 29 ++++---- es-core/src/components/IList.h | 18 +++-- .../src/components/ScrollableContainer.cpp | 17 ++++- es-core/src/components/ScrollableContainer.h | 3 +- es-core/src/components/TextListComponent.h | 67 +++++++++++-------- es-core/src/components/VideoComponent.cpp | 24 ++++++- 13 files changed, 147 insertions(+), 83 deletions(-) diff --git a/NEWS.md b/NEWS.md index c1fafff4e..592c479c7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -56,7 +56,7 @@ Many bugs have been fixed, and numerous features that were only partially implem * Refactoring, cleanup and documentation of the source code, removal of deprecated files etc. * All required fonts bundled with the application, no dependencies on the OS to provide them any longer * Made pugixml an external dependency instead of bundling it -* Decreased CPU usage dramatically by only rendering the currently visible view (previously every view were always rendered) +* Decreased CPU usage dramatically by only rendering the currently visible view (previously all views were always rendered) * Updated the CMake/CPack install and package build script to work as expected (it can now generate .deb, .rpm, .dmg and NSIS installation packages) * Added support for Clang/LLVM, made the application build with no errors or warnings using this compiler (Unix and macOS only) * License files included for all the libraries and resources that are bundled with the application diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 1c98412e4..5588e6fb2 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -1,4 +1,6 @@ +// SPDX-License-Identifier: MIT // +// EmulationStation Desktop Edition // FileData.cpp // // Provides game file data structures and functions to access and sort this information. @@ -39,7 +41,7 @@ FileData::FileData( mParent(nullptr), mOnlyFolders(false), mDeletionFlag(false), - // Metadata is REALLY set in the constructor! + // Metadata is set in the constructor. metadata(type == GAME ? GAME_METADATA : FOLDER_METADATA) { // Metadata needs at least a name field (since that's what getName() will return). @@ -382,12 +384,10 @@ std::string FileData::getKey() { const bool FileData::isArcadeAsset() { const std::string stem = Utils::FileSystem::getStem(mPath); - return ( - (mSystem && (mSystem->hasPlatformId(PlatformIds::ARCADE) || - mSystem->hasPlatformId(PlatformIds::NEOGEO))) && - (MameNames::getInstance()->isBios(stem) || - MameNames::getInstance()->isDevice(stem)) - ); + return ((mSystem && (mSystem->hasPlatformId(PlatformIds::ARCADE) || + mSystem->hasPlatformId(PlatformIds::NEOGEO))) && + (MameNames::getInstance()->isBios(stem) || + MameNames::getInstance()->isDevice(stem))); } FileData* FileData::getSourceFileData() @@ -756,6 +756,9 @@ void FileData::launchGame(Window* window) Scripting::fireEvent("game-end", rom, getSourceFileData()->metadata.get("name")); + // Re-enable the text scrolling that was disabled in ViewController on game launch. + window->setAllowTextScrolling(true); + // Update number of times the game has been launched. FileData* gameToUpdate = getSourceFileData(); diff --git a/es-app/src/FileData.h b/es-app/src/FileData.h index fa3097645..5a9da003c 100644 --- a/es-app/src/FileData.h +++ b/es-app/src/FileData.h @@ -1,4 +1,6 @@ +// SPDX-License-Identifier: MIT // +// EmulationStation Desktop Edition // FileData.h // // Provides game file data structures and functions to access and sort this information. @@ -6,12 +8,12 @@ // (launching initiated in ViewController). // -#pragma once #ifndef ES_APP_FILE_DATA_H #define ES_APP_FILE_DATA_H #include "utils/FileSystemUtil.h" #include "MetaData.h" + #include class SystemData; @@ -111,7 +113,8 @@ public: bool ascending; std::string description; - SortType(ComparisonFunction* sortFunction, + SortType( + ComparisonFunction* sortFunction, bool sortAscending, const std::string& sortDescription) : comparisonFunction(sortFunction), @@ -145,7 +148,6 @@ private: bool mOnlyFolders; // Used for flagging a game for deletion from its gamelist.xml file. bool mDeletionFlag; - const std::string FAVORITE_CHAR = "\uF005"; }; @@ -158,6 +160,7 @@ public: void refreshMetadata(); FileData* getSourceFileData(); std::string getKey(); + private: // Needs to be updated when metadata changes. std::string mCollectionFileName; diff --git a/es-app/src/SystemScreenSaver.h b/es-app/src/SystemScreenSaver.h index 7c458b267..1392642c4 100644 --- a/es-app/src/SystemScreenSaver.h +++ b/es-app/src/SystemScreenSaver.h @@ -53,7 +53,6 @@ private: STATE_SCREENSAVER_ACTIVE }; -private: bool mVideosCounted; unsigned long mVideoCount; VideoComponent* mVideoScreensaver; diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index 5069d0f71..804dc972c 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -306,6 +306,9 @@ void ViewController::launch(FileData* game, Vector3f center) if (mCurrentView) mCurrentView->onPauseVideo(); + // Disable text scrolling. It will be enabled again in FileData upon returning from the game. + mWindow->setAllowTextScrolling(false); + stopAnimation(1); // Make sure the fade in isn't still playing. mWindow->stopInfoPopup(); // Make sure we disable any existing info popup. mLockInput = true; diff --git a/es-app/src/views/ViewController.h b/es-app/src/views/ViewController.h index cf5f99103..0d4d2f508 100644 --- a/es-app/src/views/ViewController.h +++ b/es-app/src/views/ViewController.h @@ -86,11 +86,14 @@ public: ViewMode viewing; inline SystemData* getSystem() const - { assert(viewing == GAME_LIST || viewing == SYSTEM_SELECT); return system; } + { + assert(viewing == GAME_LIST || viewing == SYSTEM_SELECT); + return system; + } - private: - friend ViewController; - SystemData* system; + private: + friend ViewController; + SystemData* system; }; inline const State& getState() const { return mState; } diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index 0f45508d9..7e560ed53 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -20,17 +20,18 @@ #include Window::Window() - : mNormalizeNextUpdate(false), + : mScreenSaver(nullptr), + mInfoPopup(nullptr), + mNormalizeNextUpdate(false), mFrameTimeElapsed(0), mFrameCountElapsed(0), mAverageDeltaTime(10), mAllowSleep(true), mSleeping(false), mTimeSinceLastInput(0), - mScreenSaver(nullptr), mRenderScreenSaver(false), mGameLaunchedState(false), - mInfoPopup(nullptr), + mAllowTextScrolling(true), mCachedBackground(false), mSaturationAmount(1.0), mTopOpacity(0), @@ -106,8 +107,8 @@ bool Window::init() } mBackgroundOverlay->setImage(":/graphics/scroll_gradient.png"); - mBackgroundOverlay->setResize((float)Renderer::getScreenWidth(), - (float)Renderer::getScreenHeight()); + mBackgroundOverlay->setResize(static_cast(Renderer::getScreenWidth()), + static_cast(Renderer::getScreenHeight())); // Update our help because font sizes probably changed. if (peekGui()) @@ -222,6 +223,7 @@ void Window::update(int deltaTime) { if (mNormalizeNextUpdate) { mNormalizeNextUpdate = false; + mTimeSinceLastInput = 0; if (deltaTime > mAverageDeltaTime) deltaTime = mAverageDeltaTime; } @@ -236,9 +238,11 @@ void Window::update(int deltaTime) // FPS. ss << std::fixed << std::setprecision(1) << - (1000.0f * (float)mFrameCountElapsed / (float)mFrameTimeElapsed) << " FPS ("; + (1000.0f * static_cast(mFrameCountElapsed) / + static_cast(mFrameTimeElapsed)) << " FPS ("; ss << std::fixed << std::setprecision(2) << - ((float)mFrameTimeElapsed / (float)mFrameCountElapsed) << " ms)"; + (static_cast(mFrameTimeElapsed) / + static_cast(mFrameCountElapsed)) << " ms)"; // The following calculations are not accurate, and the font calculation is completely // broken. For now, still report the figures as it's somehow useful to locate memory @@ -280,6 +284,11 @@ void Window::render() auto& bottom = mGuiStack.front(); auto& top = mGuiStack.back(); + if (mRenderScreenSaver) { + bottom->cancelAllAnimations(); + bottom->stopAllAnimations(); + } + bottom->render(transform); if (bottom != top) { #if defined(USE_OPENGL_21) @@ -343,7 +352,8 @@ void Window::render() if (!mRenderedHelpPrompts) mHelp->render(transform); - unsigned int screensaverTime = (unsigned int)Settings::getInstance()->getInt("ScreenSaverTime"); + unsigned int screensaverTime = + static_cast(Settings::getInstance()->getInt("ScreenSaverTime")); // If a game has been launched, reset the screensaver timer when it's been reached as we // don't want to start the screensaver in the background when running a game. if (mTimeSinceLastInput >= screensaverTime && screensaverTime != 0) { @@ -501,7 +511,7 @@ void Window::setHelpPrompts(const std::vector& prompts, const HelpSt } else { // No, it hasn't! - mappedToSeenMap.emplace(it->second, (int)addPrompts.size()); + mappedToSeenMap.emplace(it->second, static_cast(addPrompts.size())); addPrompts.push_back(*it); } } @@ -578,6 +588,7 @@ void Window::startScreenSaver() for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); it++) (*it)->onScreenSaverActivate(); + stopInfoPopup(); mScreenSaver->startScreenSaver(); mRenderScreenSaver = true; } diff --git a/es-core/src/Window.h b/es-core/src/Window.h index 0b0e3f1c2..035d185f6 100644 --- a/es-core/src/Window.h +++ b/es-core/src/Window.h @@ -60,7 +60,7 @@ public: void pushGui(GuiComponent* gui); void removeGui(GuiComponent* gui); GuiComponent* peekGui(); - inline int getGuiStackSize() { return (int)mGuiStack.size(); } + inline int getGuiStackSize() { return static_cast(mGuiStack.size()); } void textInput(const char* text); void input(InputConfig* config, Input input); @@ -94,6 +94,8 @@ public: void setLaunchedGame(); void unsetLaunchedGame(); bool getGameLaunchedState() { return mGameLaunchedState; }; + void setAllowTextScrolling(bool setting) { mAllowTextScrolling = setting; }; + bool getAllowTextScrolling() { return mAllowTextScrolling; }; void invalidateCachedBackground() { mCachedBackground = false; }; @@ -108,30 +110,27 @@ private: ImageComponent* mBackgroundOverlay; ScreenSaver* mScreenSaver; InfoPopup* mInfoPopup; - bool mRenderScreenSaver; - bool mGameLaunchedState; - std::vector mGuiStack; - std::vector> mDefaultFonts; - - int mFrameTimeElapsed; - int mFrameCountElapsed; - int mAverageDeltaTime; - std::unique_ptr mFrameDataText; bool mNormalizeNextUpdate; + int mFrameTimeElapsed; + int mFrameCountElapsed; + int mAverageDeltaTime; + bool mAllowSleep; + bool mSleeping; + unsigned int mTimeSinceLastInput; + + bool mRenderScreenSaver; + bool mGameLaunchedState; + bool mAllowTextScrolling; + bool mCachedBackground; float mSaturationAmount; unsigned char mTopOpacity; float mTopScale; float mDimValue; - bool mCachedBackground; - bool mAllowSleep; - bool mSleeping; - unsigned int mTimeSinceLastInput; - bool mRenderedHelpPrompts; }; diff --git a/es-core/src/components/IList.h b/es-core/src/components/IList.h index f5a07896e..c2b330cde 100644 --- a/es-core/src/components/IList.h +++ b/es-core/src/components/IList.h @@ -1,4 +1,6 @@ +// SPDX-License-Identifier: MIT // +// EmulationStation Desktop Edition // IList.h // // Gamelist base class. @@ -10,6 +12,7 @@ #include "components/ImageComponent.h" #include "resources/Font.h" #include "PowerSaver.h" +#include "Window.h" enum CursorState { CURSOR_STOPPED, @@ -63,10 +66,8 @@ public: protected: int mCursor; - int mScrollTier; int mScrollVelocity; - int mScrollTierAccumulator; int mScrollCursorAccumulator; @@ -79,6 +80,7 @@ protected: const ListLoopType mLoopType; std::vector mEntries; + Window* mWindow; public: IList( @@ -88,7 +90,8 @@ public: : GuiComponent(window), mGradient(window), mTierList(tierList), - mLoopType(loopType) + mLoopType(loopType), + mWindow(window) { mCursor = 0; mScrollTier = 0; @@ -98,7 +101,8 @@ public: mTitleOverlayOpacity = 0x00; mTitleOverlayColor = 0xFFFFFF00; - mGradient.setResize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight()); + mGradient.setResize(static_cast(Renderer::getScreenWidth()), + static_cast(Renderer::getScreenHeight())); mGradient.setImage(":/graphics/scroll_gradient.png"); mTitleOverlayFont = Font::get(FONT_SIZE_LARGE); } @@ -164,7 +168,7 @@ public: { for (auto it = mEntries.cbegin(); it != mEntries.cend(); it++) { if ((*it).object == obj) { - mCursor = (int)(it - mEntries.cbegin()); + mCursor = static_cast(it - mEntries.cbegin()); onCursorChanged(CURSOR_STOPPED); return true; } @@ -191,7 +195,7 @@ public: return false; } - inline int size() const { return (int)mEntries.size(); } + inline int size() const { return static_cast(mEntries.size()); } protected: void remove(typename std::vector::const_iterator& it) @@ -247,7 +251,7 @@ protected: else if (op <= 0) mTitleOverlayOpacity = 0; else - mTitleOverlayOpacity = (unsigned char)op; + mTitleOverlayOpacity = static_cast(op); if (mScrollVelocity == 0 || size() < 2) return; diff --git a/es-core/src/components/ScrollableContainer.cpp b/es-core/src/components/ScrollableContainer.cpp index 577e2ab28..99f625140 100644 --- a/es-core/src/components/ScrollableContainer.cpp +++ b/es-core/src/components/ScrollableContainer.cpp @@ -1,4 +1,6 @@ +// SPDX-License-Identifier: MIT // +// EmulationStation Desktop Edition // ScrollableContainer.cpp // // Area containing scrollable information, for example the game description @@ -9,6 +11,7 @@ #include "math/Vector2i.h" #include "renderers/Renderer.h" +#include "Window.h" #define AUTO_SCROLL_RESET_DELAY 3000 // ms to reset to top after we reach the bottom. #define AUTO_SCROLL_DELAY 2000 // ms to wait before we start to scroll. @@ -33,11 +36,12 @@ void ScrollableContainer::render(const Transform4x4f& parentTrans) Transform4x4f trans = parentTrans * getTransform(); - Vector2i clipPos((int)trans.translation().x(), (int)trans.translation().y()); + Vector2i clipPos(static_cast(trans.translation().x()), + static_cast(trans.translation().y())); Vector3f dimScaled = trans * Vector3f(mSize.x(), mSize.y(), 0); - Vector2i clipDim((int)(dimScaled.x() - trans.translation().x()), - (int)(dimScaled.y() - trans.translation().y())); + Vector2i clipDim(static_cast((dimScaled.x()) - trans.translation().x()), + static_cast((dimScaled.y()) - trans.translation().y())); Renderer::pushClipRect(clipPos, clipDim); @@ -76,6 +80,13 @@ void ScrollableContainer::setScrollPos(const Vector2f& pos) void ScrollableContainer::update(int deltaTime) { + // Don't scroll if the screensaver is active or text scrolling is disabled; + if (mWindow->isScreenSaverActive() || !mWindow->getAllowTextScrolling()) { + if (mScrollPos != 0) + reset(); + return; + } + if (mAutoScrollSpeed != 0) { mAutoScrollAccumulator += deltaTime; diff --git a/es-core/src/components/ScrollableContainer.h b/es-core/src/components/ScrollableContainer.h index 307d29186..3418349ac 100644 --- a/es-core/src/components/ScrollableContainer.h +++ b/es-core/src/components/ScrollableContainer.h @@ -1,11 +1,12 @@ +// SPDX-License-Identifier: MIT // +// EmulationStation Desktop Edition // ScrollableContainer.h // // Area containing scrollable information, for example the game description // text container in the detailed, video and grid views. // -#pragma once #ifndef ES_CORE_COMPONENTS_SCROLLABLE_CONTAINER_H #define ES_CORE_COMPONENTS_SCROLLABLE_CONTAINER_H diff --git a/es-core/src/components/TextListComponent.h b/es-core/src/components/TextListComponent.h index 4794b3c69..db9b3ba6a 100644 --- a/es-core/src/components/TextListComponent.h +++ b/es-core/src/components/TextListComponent.h @@ -1,4 +1,6 @@ +// SPDX-License-Identifier: MIT // +// EmulationStation Desktop Edition // TextListComponent.h // // Used for displaying and navigating the gamelists. @@ -12,6 +14,7 @@ #include "utils/StringUtil.h" #include "Log.h" #include "Sound.h" + #include class TextCache; @@ -33,6 +36,7 @@ protected: using IList::getTransform; using IList::mSize; using IList::mCursor; + using IList::mWindow; // The following change is required for compilation with Clang. // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2070 // using IList::Entry; @@ -90,7 +94,7 @@ public: protected: virtual void onScroll() override { - NavigationSounds::getInstance()->playThemeNavigationSound(SCROLLSOUND); } + NavigationSounds::getInstance()->playThemeNavigationSound(SCROLLSOUND); } virtual void onCursorChanged(const CursorState& state) override; private: @@ -120,7 +124,7 @@ private: template TextListComponent::TextListComponent(Window* window) : - IList(window), mSelectorImage(window) + IList(window), mSelectorImage(window) { mMarqueeOffset = 0; mMarqueeOffset2 = 0; @@ -152,12 +156,13 @@ void TextListComponent::render(const Transform4x4f& parentTrans) if (size() == 0) return; - const float entrySize = Math::max(font->getHeight(1.0), (float)font->getSize()) * mLineSpacing; + const float entrySize = Math::max(font->getHeight(1.0), + static_cast(font->getSize())) * mLineSpacing; int startEntry = 0; // Number of entries that can fit on the screen simultaneously. - int screenCount = (int)(mSize.y() / entrySize + 0.5f); + int screenCount = static_cast(mSize.y() / entrySize + 0.5f); if (size() >= screenCount) { startEntry = mCursor - screenCount/2; @@ -197,12 +202,12 @@ void TextListComponent::render(const Transform4x4f& parentTrans) // Clip to inside margins. Vector3f dim(mSize.x(), mSize.y(), 0); dim = trans * dim - trans.translation(); - Renderer::pushClipRect(Vector2i((int)(trans.translation().x() + mHorizontalMargin), - (int)trans.translation().y()), Vector2i((int)(dim.x() - mHorizontalMargin*2), - (int)dim.y())); + Renderer::pushClipRect(Vector2i(static_cast(trans.translation().x() + + mHorizontalMargin), static_cast(trans.translation().y())), + Vector2i(static_cast(dim.x() - mHorizontalMargin*2), static_cast(dim.y()))); for (int i = startEntry; i < listCutoff; i++) { - typename IList::Entry& entry = mEntries.at((unsigned int)i); + typename IList::Entry& entry = mEntries.at(static_cast(i)); unsigned int color; if (mCursor == i && mSelectedColor) @@ -211,12 +216,12 @@ void TextListComponent::render(const Transform4x4f& parentTrans) color = mColors[entry.data.colorId]; if (!entry.data.textCache) - entry.data.textCache = std::unique_ptr - (font->buildTextCache(mUppercase ? + entry.data.textCache = std::unique_ptr( + font->buildTextCache(mUppercase ? Utils::String::toUpper(entry.name) : entry.name, 0, 0, 0x000000FF)); - // If a game is marked as hidden, lower the text opacity quite a lot. - // For games marked not to be counted, lower the opacity moderately. + // If a game is marked as hidden, lower the text opacity a lot. + // If a game is marked to not be counted, lower the opacity a moderate amount. if (entry.object->getHidden()) entry.data.textCache->setColor(color & 0xFFFFFF44); else if (!entry.object->getCountAsGame()) @@ -231,7 +236,7 @@ void TextListComponent::render(const Transform4x4f& parentTrans) offset[0] = mHorizontalMargin; break; case ALIGN_CENTER: - offset[0] = (int)((mSize.x() - entry.data.textCache->metrics.size.x()) / 2); + offset[0] = static_cast((mSize.x() - entry.data.textCache->metrics.size.x()) / 2); if (offset[0] < mHorizontalMargin) offset[0] = mHorizontalMargin; break; @@ -248,7 +253,7 @@ void TextListComponent::render(const Transform4x4f& parentTrans) // Currently selected item text might be scrolling. if ((mCursor == i) && (mMarqueeOffset > 0)) - drawTrans.translate(offset - Vector3f((float)mMarqueeOffset, 0, 0)); + drawTrans.translate(offset - Vector3f(static_cast(mMarqueeOffset), 0, 0)); else drawTrans.translate(offset); @@ -259,11 +264,10 @@ void TextListComponent::render(const Transform4x4f& parentTrans) // scrolled far enough for it to repeat. if ((mCursor == i) && (mMarqueeOffset2 < 0)) { drawTrans = trans; - drawTrans.translate(offset - Vector3f((float)mMarqueeOffset2, 0, 0)); + drawTrans.translate(offset - Vector3f(static_cast(mMarqueeOffset2), 0, 0)); Renderer::setMatrix(drawTrans); font->renderTextCache(entry.data.textCache.get()); } - y += entrySize; } @@ -323,35 +327,39 @@ void TextListComponent::update(int deltaTime) { listUpdate(deltaTime); + if (mWindow->isScreenSaverActive() || !mWindow->getAllowTextScrolling()) + stopScrolling(); + if (!isScrolling() && size() > 0) { // Always reset the marquee offsets. mMarqueeOffset = 0; mMarqueeOffset2 = 0; // If we're not scrolling and this object's text goes outside our size, marquee it! - const float textLength = mFont->sizeText(mEntries.at((unsigned int)mCursor).name).x(); - const float limit = mSize.x() - mHorizontalMargin * 2; + const float textLength = mFont->sizeText( + mEntries.at(static_cast(mCursor)).name).x(); + const float limit = mSize.x() - mHorizontalMargin * 2; if (textLength > limit) { // Loop. // Pixels per second (based on nes-mini font at 1920x1080 to produce a speed of 200). - const float speed = mFont->sizeText("ABCDEFGHIJKLMNOPQRSTUVWXYZ").x() * 0.247f; - const float delay = 3000; + const float speed = mFont->sizeText("ABCDEFGHIJKLMNOPQRSTUVWXYZ").x() * 0.247f; + const float delay = 3000; const float scrollLength = textLength; const float returnLength = speed * 1.5f; - const float scrollTime = (scrollLength * 1000) / speed; - const float returnTime = (returnLength * 1000) / speed; - const int maxTime = (int)(delay + scrollTime + returnTime); + const float scrollTime = (scrollLength * 1000) / speed; + const float returnTime = (returnLength * 1000) / speed; + const int maxTime = static_cast(delay + scrollTime + returnTime); mMarqueeTime += deltaTime; while (mMarqueeTime > maxTime) mMarqueeTime -= maxTime; - mMarqueeOffset = (int)(Math::Scroll::loop(delay, scrollTime + returnTime, - (float)mMarqueeTime, scrollLength + returnLength)); + mMarqueeOffset = static_cast(Math::Scroll::loop(delay, scrollTime + returnTime, + static_cast(mMarqueeTime), scrollLength + returnLength)); if (mMarqueeOffset > (scrollLength - (limit - returnLength))) - mMarqueeOffset2 = (int)(mMarqueeOffset - (scrollLength + returnLength)); + mMarqueeOffset2 = static_cast(mMarqueeOffset - (scrollLength + returnLength)); } } @@ -413,7 +421,7 @@ void TextListComponent::applyTheme(const std::shared_ptr& theme, setFont(Font::getFromTheme(elem, properties, mFont)); const float selectorHeight = Math::max(mFont->getHeight(1.0), - (float)mFont->getSize()) * mLineSpacing; + static_cast(mFont->getSize())) * mLineSpacing; setSelectorHeight(selectorHeight); if (properties & ALIGNMENT) { @@ -431,7 +439,7 @@ void TextListComponent::applyTheme(const std::shared_ptr& theme, if (elem->has("horizontalMargin")) { mHorizontalMargin = elem->get("horizontalMargin") * (this->mParent ? this->mParent->getSize().x() : - (float)Renderer::getScreenWidth()); + static_cast(Renderer::getScreenWidth())); } } @@ -444,7 +452,8 @@ void TextListComponent::applyTheme(const std::shared_ptr& theme, if (elem->has("selectorHeight")) setSelectorHeight(elem->get("selectorHeight") * Renderer::getScreenHeight()); if (elem->has("selectorOffsetY")) { - float scale = this->mParent ? this->mParent->getSize().y() : (float)Renderer::getScreenHeight(); + float scale = this->mParent ? this->mParent->getSize().y() : + static_cast(Renderer::getScreenHeight()); setSelectorOffsetY(elem->get("selectorOffsetY") * scale); } else { diff --git a/es-core/src/components/VideoComponent.cpp b/es-core/src/components/VideoComponent.cpp index c39c79b97..ed92f4f60 100644 --- a/es-core/src/components/VideoComponent.cpp +++ b/es-core/src/components/VideoComponent.cpp @@ -373,13 +373,20 @@ void VideoComponent::onPauseVideo() void VideoComponent::onScreenSaverActivate() { - mScreensaverActive = true; + mBlockPlayer = true; + mPause = true; + if (Settings::getInstance()->getString("ScreenSaverBehavior") == "dim") + stopVideo(); manageState(); } void VideoComponent::onScreenSaverDeactivate() { - mScreensaverActive = false; + mBlockPlayer = false; +// mPause = false; + // Stop video when deactivating the screensaver to force a reload of the + // static image (if the theme is configured as such). + stopVideo(); manageState(); } @@ -398,6 +405,17 @@ void VideoComponent::onGameLaunchedDeactivate() void VideoComponent::topWindow(bool isTop) { - mDisable = !isTop; + + if (isTop) { + mBlockPlayer = false; + mPause = false; + // Stop video when closing the menu to force a reload of the + // static image (if the theme is configured as such). + stopVideo(); + } + else { + mBlockPlayer = true; + mPause = true; + } manageState(); }