diff --git a/es-app/src/guis/GuiInfoPopup.cpp b/es-app/src/guis/GuiInfoPopup.cpp index a1f30baa0..2802a2975 100644 --- a/es-app/src/guis/GuiInfoPopup.cpp +++ b/es-app/src/guis/GuiInfoPopup.cpp @@ -21,17 +21,17 @@ GuiInfoPopup::GuiInfoPopup( : GuiComponent(window), mMessage(message), mDuration(duration), - running(true) + mRunning(true) { mFrame = new NinePatchComponent(window); float maxWidth = Renderer::getScreenWidth() * 0.9f; float maxHeight = Renderer::getScreenHeight() * 0.2f; std::shared_ptr s = std::make_shared(mWindow, "", - Font::get(FONT_SIZE_MINI), 0x444444FF, ALIGN_CENTER); + Font::get(FONT_SIZE_MINI), 0x444444FF, ALIGN_CENTER); // We do this to force the text container to resize and return the actual expected popup size. - s->setSize(0,0); + s->setSize(0.0f, 0.0f); s->setText(message); mSize = s->getSize(); @@ -79,7 +79,7 @@ void GuiInfoPopup::render(const Transform4x4f& /*parentTrans*/) { // We use Identity() as we want to render on a specific window position, not on the view. Transform4x4f trans = getTransform() * Transform4x4f::Identity(); - if (running && updateState()) { + if (mRunning && updateState()) { // If we're still supposed to be rendering it. Renderer::setMatrix(trans); renderChildren(trans); @@ -97,27 +97,27 @@ bool GuiInfoPopup::updateState() // Compute fade-in effect. if (curTime - mStartTime > mDuration) { // We're past the popup duration, no need to render. - running = false; + mRunning = false; return false; } else if (curTime < mStartTime) { // If SDL reset. - running = false; + mRunning = false; return false; } else if (curTime - mStartTime <= 500) { - alpha = ((curTime - mStartTime) * 255 / 500); + mAlpha = ((curTime - mStartTime) * 255 / 500); } else if (curTime - mStartTime < mDuration - 500) { - alpha = 255; + mAlpha = 255; } else { - alpha = ((-(curTime - mStartTime - mDuration) * 255) / 500); + mAlpha = ((-(curTime - mStartTime - mDuration) * 255) / 500); } - mGrid->setOpacity(static_cast(alpha)); + mGrid->setOpacity(static_cast(mAlpha)); // Apply fade-in effect to popup frame. - mFrame->setEdgeColor(0xFFFFFF00 | static_cast(alpha)); - mFrame->setCenterColor(0xFFFFFF00 | static_cast(alpha)); + mFrame->setEdgeColor(0xFFFFFF00 | static_cast(mAlpha)); + mFrame->setCenterColor(0xFFFFFF00 | static_cast(mAlpha)); return true; } diff --git a/es-app/src/guis/GuiInfoPopup.h b/es-app/src/guis/GuiInfoPopup.h index e24194522..87b381864 100644 --- a/es-app/src/guis/GuiInfoPopup.h +++ b/es-app/src/guis/GuiInfoPopup.h @@ -20,18 +20,21 @@ class GuiInfoPopup : public GuiComponent, public Window::InfoPopup public: GuiInfoPopup(Window* window, std::string message, int duration); ~GuiInfoPopup(); + void render(const Transform4x4f& parentTrans) override; - inline void stop() override { running = false; }; + inline void stop() override { mRunning = false; } private: - std::string mMessage; - int mDuration; - int alpha; bool updateState(); - int mStartTime; + ComponentGrid* mGrid; NinePatchComponent* mFrame; - bool running; + + std::string mMessage; + int mDuration; + int mAlpha; + int mStartTime; + bool mRunning; }; #endif // ES_APP_GUIS_GUI_INFO_POPUP_H diff --git a/es-core/src/GuiComponent.cpp b/es-core/src/GuiComponent.cpp index 0f57567c9..66f5e1ea6 100644 --- a/es-core/src/GuiComponent.cpp +++ b/es-core/src/GuiComponent.cpp @@ -407,7 +407,7 @@ bool GuiComponent::finishAnimation(unsigned char slot) if (anim) { // Skip to animation's end. const bool done = anim->update(anim->getAnimation()->getDuration() - anim->getTime()); - if(done) { + if (done) { mAnimationMap[slot] = nullptr; delete anim; // Will also call finishedCallback. } diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index 14ff2d306..2759ac08d 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -141,12 +141,6 @@ void Window::deinit() Renderer::deinit(); } -void Window::textInput(const std::string& text) -{ - if (peekGui()) - peekGui()->textInput(text); -} - void Window::input(InputConfig* config, Input input) { mTimeSinceLastInput = 0; @@ -244,6 +238,12 @@ void Window::input(InputConfig* config, Input input) } } +void Window::textInput(const std::string& text) +{ + if (peekGui()) + peekGui()->textInput(text); +} + void Window::logInput(InputConfig* config, Input input) { std::string mapname = ""; @@ -529,21 +529,6 @@ void Window::render() } } -void Window::normalizeNextUpdate() -{ - mNormalizeNextUpdate = true; -} - -bool Window::getAllowSleep() -{ - return mAllowSleep; -} - -void Window::setAllowSleep(bool sleep) -{ - mAllowSleep = sleep; -} - void Window::renderLoadingScreen(std::string text) { Transform4x4f trans = Transform4x4f::Identity(); @@ -671,46 +656,6 @@ void Window::stopInfoPopup() mInfoPopup->stop(); } -void Window::onSleep() -{ - Scripting::fireEvent("sleep"); -} - -void Window::onWake() -{ - Scripting::fireEvent("wake"); -} - -bool Window::isProcessing() -{ - return count_if (mGuiStack.cbegin(), mGuiStack.cend(), - [](GuiComponent* c) { return c->isProcessing(); }) > 0; -} - -void Window::setLaunchedGame() -{ - // Tell the GUI components that a game has been launched. - for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); it++) - (*it)->onGameLaunchedActivate(); - - mGameLaunchedState = true; -} - -void Window::unsetLaunchedGame() -{ - // Tell the GUI components that the user is back in ES-DE again. - for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); it++) - (*it)->onGameLaunchedDeactivate(); - - mGameLaunchedState = false; -} - -void Window::invalidateCachedBackground() -{ - mCachedBackground = false; - mInvalidatedCachedBackground = true; -} - void Window::startScreensaver() { if (mScreensaver && !mRenderScreensaver) { @@ -788,3 +733,43 @@ int Window::getVideoPlayerCount() mVideoCountMutex.unlock(); return videoPlayerCount; }; + +void Window::setLaunchedGame() +{ + // Tell the GUI components that a game has been launched. + for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); it++) + (*it)->onGameLaunchedActivate(); + + mGameLaunchedState = true; +} + +void Window::unsetLaunchedGame() +{ + // Tell the GUI components that the user is back in ES-DE again. + for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); it++) + (*it)->onGameLaunchedDeactivate(); + + mGameLaunchedState = false; +} + +void Window::invalidateCachedBackground() +{ + mCachedBackground = false; + mInvalidatedCachedBackground = true; +} + +void Window::onSleep() +{ + Scripting::fireEvent("sleep"); +} + +void Window::onWake() +{ + Scripting::fireEvent("wake"); +} + +bool Window::isProcessing() +{ + return count_if (mGuiStack.cbegin(), mGuiStack.cend(), [](GuiComponent* c) { + return c->isProcessing(); }) > 0; +} diff --git a/es-core/src/Window.h b/es-core/src/Window.h index ee8ec5115..2ccaa778a 100644 --- a/es-core/src/Window.h +++ b/es-core/src/Window.h @@ -80,20 +80,20 @@ public: GuiComponent* peekGui(); inline int getGuiStackSize() { return static_cast(mGuiStack.size()); } - void textInput(const std::string& text); + bool init(); + void deinit(); + void input(InputConfig* config, Input input); + void textInput(const std::string& text); void logInput(InputConfig* config, Input input); void update(int deltaTime); void render(); - bool init(); - void deinit(); - - void normalizeNextUpdate(); + void normalizeNextUpdate() { mNormalizeNextUpdate = true; } + bool getAllowSleep() { return mAllowSleep; } + void setAllowSleep(bool sleep) { mAllowSleep = sleep; } inline bool isSleeping() const { return mSleeping; } - bool getAllowSleep(); - void setAllowSleep(bool sleep); void renderLoadingScreen(std::string text); // The list scroll overlay is triggered from IList when the highest scrolling tier is reached. @@ -103,20 +103,20 @@ public: void setHelpPrompts(const std::vector& prompts, const HelpStyle& style); void reloadHelpPrompts(); - void setScreensaver(Screensaver* screensaver) { mScreensaver = screensaver; } void setInfoPopup(InfoPopup* infoPopup); void stopInfoPopup(); void startScreensaver(); bool stopScreensaver(); void renderScreensaver(); - void screensaverTriggerNextGame() { mScreensaver->triggerNextGame(); }; - bool isScreensaverActive() { return mRenderScreensaver; }; + void screensaverTriggerNextGame() { mScreensaver->triggerNextGame(); } + void setScreensaver(Screensaver* screensaver) { mScreensaver = screensaver; } + bool isScreensaverActive() { return mRenderScreensaver; } void startMediaViewer(FileData* game); void stopMediaViewer(); void setMediaViewer(MediaViewer* mediaViewer) { mMediaViewer = mediaViewer; } - bool isMediaViewerActive() { return mRenderMediaViewer; }; + bool isMediaViewerActive() { return mRenderMediaViewer; } void increaseVideoPlayerCount(); void decreaseVideoPlayerCount(); @@ -126,11 +126,11 @@ public: void unsetLaunchedGame(); void invalidateCachedBackground(); - bool getGameLaunchedState() { return mGameLaunchedState; }; - void setAllowTextScrolling(bool setting) { mAllowTextScrolling = setting; }; - bool getAllowTextScrolling() { return mAllowTextScrolling; }; + bool getGameLaunchedState() { return mGameLaunchedState; } + void setAllowTextScrolling(bool setting) { mAllowTextScrolling = setting; } + bool getAllowTextScrolling() { return mAllowTextScrolling; } - void setChangedThemeSet() { mChangedThemeSet = true; }; + void setChangedThemeSet() { mChangedThemeSet = true; } private: void onSleep(); diff --git a/es-core/src/components/VideoFFmpegComponent.cpp b/es-core/src/components/VideoFFmpegComponent.cpp index eaf0c5e30..79b70e9ec 100644 --- a/es-core/src/components/VideoFFmpegComponent.cpp +++ b/es-core/src/components/VideoFFmpegComponent.cpp @@ -547,7 +547,7 @@ void VideoFFmpegComponent::readFrames() if (mVideoCodecContext && mFormatContext) { if (mVideoFrameQueue.size() < mVideoTargetQueueSize || (mAudioStreamIndex >= 0 && mAudioFrameQueue.size() < mAudioTargetQueueSize)) { - while((readFrameReturn = av_read_frame(mFormatContext, mPacket)) >= 0) { + while ((readFrameReturn = av_read_frame(mFormatContext, mPacket)) >= 0) { if (mPacket->stream_index == mVideoStreamIndex) { if (!avcodec_send_packet(mVideoCodecContext, mPacket) && !avcodec_receive_frame(mVideoCodecContext, mVideoFrame)) { diff --git a/es-core/src/renderers/Renderer.cpp b/es-core/src/renderers/Renderer.cpp index 7a8b09b88..9a6d2a70e 100644 --- a/es-core/src/renderers/Renderer.cpp +++ b/es-core/src/renderers/Renderer.cpp @@ -195,7 +195,7 @@ namespace Renderer windowFlags = getWindowFlags(); } else if (Settings::getInstance()->getString("FullscreenMode") == "borderless") { - if(!userResolution) + if (!userResolution) windowFlags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALWAYS_ON_TOP | getWindowFlags(); else // If the user has changed the resolution from the command line, then add a