mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 15:15:37 +00:00
Some cosmetic code cleanup.
This commit is contained in:
parent
83799f2208
commit
75430f210a
|
@ -21,17 +21,17 @@ GuiInfoPopup::GuiInfoPopup(
|
||||||
: GuiComponent(window),
|
: GuiComponent(window),
|
||||||
mMessage(message),
|
mMessage(message),
|
||||||
mDuration(duration),
|
mDuration(duration),
|
||||||
running(true)
|
mRunning(true)
|
||||||
{
|
{
|
||||||
mFrame = new NinePatchComponent(window);
|
mFrame = new NinePatchComponent(window);
|
||||||
float maxWidth = Renderer::getScreenWidth() * 0.9f;
|
float maxWidth = Renderer::getScreenWidth() * 0.9f;
|
||||||
float maxHeight = Renderer::getScreenHeight() * 0.2f;
|
float maxHeight = Renderer::getScreenHeight() * 0.2f;
|
||||||
|
|
||||||
std::shared_ptr<TextComponent> s = std::make_shared<TextComponent>(mWindow, "",
|
std::shared_ptr<TextComponent> s = std::make_shared<TextComponent>(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.
|
// 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);
|
s->setText(message);
|
||||||
mSize = s->getSize();
|
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.
|
// We use Identity() as we want to render on a specific window position, not on the view.
|
||||||
Transform4x4f trans = getTransform() * Transform4x4f::Identity();
|
Transform4x4f trans = getTransform() * Transform4x4f::Identity();
|
||||||
if (running && updateState()) {
|
if (mRunning && updateState()) {
|
||||||
// If we're still supposed to be rendering it.
|
// If we're still supposed to be rendering it.
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
|
@ -97,27 +97,27 @@ bool GuiInfoPopup::updateState()
|
||||||
// Compute fade-in effect.
|
// Compute fade-in effect.
|
||||||
if (curTime - mStartTime > mDuration) {
|
if (curTime - mStartTime > mDuration) {
|
||||||
// We're past the popup duration, no need to render.
|
// We're past the popup duration, no need to render.
|
||||||
running = false;
|
mRunning = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (curTime < mStartTime) {
|
else if (curTime < mStartTime) {
|
||||||
// If SDL reset.
|
// If SDL reset.
|
||||||
running = false;
|
mRunning = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (curTime - mStartTime <= 500) {
|
else if (curTime - mStartTime <= 500) {
|
||||||
alpha = ((curTime - mStartTime) * 255 / 500);
|
mAlpha = ((curTime - mStartTime) * 255 / 500);
|
||||||
}
|
}
|
||||||
else if (curTime - mStartTime < mDuration - 500) {
|
else if (curTime - mStartTime < mDuration - 500) {
|
||||||
alpha = 255;
|
mAlpha = 255;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
alpha = ((-(curTime - mStartTime - mDuration) * 255) / 500);
|
mAlpha = ((-(curTime - mStartTime - mDuration) * 255) / 500);
|
||||||
}
|
}
|
||||||
mGrid->setOpacity(static_cast<unsigned char>(alpha));
|
mGrid->setOpacity(static_cast<unsigned char>(mAlpha));
|
||||||
|
|
||||||
// Apply fade-in effect to popup frame.
|
// Apply fade-in effect to popup frame.
|
||||||
mFrame->setEdgeColor(0xFFFFFF00 | static_cast<unsigned char>(alpha));
|
mFrame->setEdgeColor(0xFFFFFF00 | static_cast<unsigned char>(mAlpha));
|
||||||
mFrame->setCenterColor(0xFFFFFF00 | static_cast<unsigned char>(alpha));
|
mFrame->setCenterColor(0xFFFFFF00 | static_cast<unsigned char>(mAlpha));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,18 +20,21 @@ class GuiInfoPopup : public GuiComponent, public Window::InfoPopup
|
||||||
public:
|
public:
|
||||||
GuiInfoPopup(Window* window, std::string message, int duration);
|
GuiInfoPopup(Window* window, std::string message, int duration);
|
||||||
~GuiInfoPopup();
|
~GuiInfoPopup();
|
||||||
|
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const Transform4x4f& parentTrans) override;
|
||||||
inline void stop() override { running = false; };
|
inline void stop() override { mRunning = false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string mMessage;
|
|
||||||
int mDuration;
|
|
||||||
int alpha;
|
|
||||||
bool updateState();
|
bool updateState();
|
||||||
int mStartTime;
|
|
||||||
ComponentGrid* mGrid;
|
ComponentGrid* mGrid;
|
||||||
NinePatchComponent* mFrame;
|
NinePatchComponent* mFrame;
|
||||||
bool running;
|
|
||||||
|
std::string mMessage;
|
||||||
|
int mDuration;
|
||||||
|
int mAlpha;
|
||||||
|
int mStartTime;
|
||||||
|
bool mRunning;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_APP_GUIS_GUI_INFO_POPUP_H
|
#endif // ES_APP_GUIS_GUI_INFO_POPUP_H
|
||||||
|
|
|
@ -407,7 +407,7 @@ bool GuiComponent::finishAnimation(unsigned char slot)
|
||||||
if (anim) {
|
if (anim) {
|
||||||
// Skip to animation's end.
|
// Skip to animation's end.
|
||||||
const bool done = anim->update(anim->getAnimation()->getDuration() - anim->getTime());
|
const bool done = anim->update(anim->getAnimation()->getDuration() - anim->getTime());
|
||||||
if(done) {
|
if (done) {
|
||||||
mAnimationMap[slot] = nullptr;
|
mAnimationMap[slot] = nullptr;
|
||||||
delete anim; // Will also call finishedCallback.
|
delete anim; // Will also call finishedCallback.
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,12 +141,6 @@ void Window::deinit()
|
||||||
Renderer::deinit();
|
Renderer::deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::textInput(const std::string& text)
|
|
||||||
{
|
|
||||||
if (peekGui())
|
|
||||||
peekGui()->textInput(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Window::input(InputConfig* config, Input input)
|
void Window::input(InputConfig* config, Input input)
|
||||||
{
|
{
|
||||||
mTimeSinceLastInput = 0;
|
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)
|
void Window::logInput(InputConfig* config, Input input)
|
||||||
{
|
{
|
||||||
std::string mapname = "";
|
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)
|
void Window::renderLoadingScreen(std::string text)
|
||||||
{
|
{
|
||||||
Transform4x4f trans = Transform4x4f::Identity();
|
Transform4x4f trans = Transform4x4f::Identity();
|
||||||
|
@ -671,46 +656,6 @@ void Window::stopInfoPopup()
|
||||||
mInfoPopup->stop();
|
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()
|
void Window::startScreensaver()
|
||||||
{
|
{
|
||||||
if (mScreensaver && !mRenderScreensaver) {
|
if (mScreensaver && !mRenderScreensaver) {
|
||||||
|
@ -788,3 +733,43 @@ int Window::getVideoPlayerCount()
|
||||||
mVideoCountMutex.unlock();
|
mVideoCountMutex.unlock();
|
||||||
return videoPlayerCount;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -80,20 +80,20 @@ public:
|
||||||
GuiComponent* peekGui();
|
GuiComponent* peekGui();
|
||||||
inline int getGuiStackSize() { return static_cast<int>(mGuiStack.size()); }
|
inline int getGuiStackSize() { return static_cast<int>(mGuiStack.size()); }
|
||||||
|
|
||||||
void textInput(const std::string& text);
|
bool init();
|
||||||
|
void deinit();
|
||||||
|
|
||||||
void input(InputConfig* config, Input input);
|
void input(InputConfig* config, Input input);
|
||||||
|
void textInput(const std::string& text);
|
||||||
void logInput(InputConfig* config, Input input);
|
void logInput(InputConfig* config, Input input);
|
||||||
void update(int deltaTime);
|
void update(int deltaTime);
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
bool init();
|
void normalizeNextUpdate() { mNormalizeNextUpdate = true; }
|
||||||
void deinit();
|
|
||||||
|
|
||||||
void normalizeNextUpdate();
|
|
||||||
|
|
||||||
|
bool getAllowSleep() { return mAllowSleep; }
|
||||||
|
void setAllowSleep(bool sleep) { mAllowSleep = sleep; }
|
||||||
inline bool isSleeping() const { return mSleeping; }
|
inline bool isSleeping() const { return mSleeping; }
|
||||||
bool getAllowSleep();
|
|
||||||
void setAllowSleep(bool sleep);
|
|
||||||
|
|
||||||
void renderLoadingScreen(std::string text);
|
void renderLoadingScreen(std::string text);
|
||||||
// The list scroll overlay is triggered from IList when the highest scrolling tier is reached.
|
// 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<HelpPrompt>& prompts, const HelpStyle& style);
|
void setHelpPrompts(const std::vector<HelpPrompt>& prompts, const HelpStyle& style);
|
||||||
void reloadHelpPrompts();
|
void reloadHelpPrompts();
|
||||||
|
|
||||||
void setScreensaver(Screensaver* screensaver) { mScreensaver = screensaver; }
|
|
||||||
void setInfoPopup(InfoPopup* infoPopup);
|
void setInfoPopup(InfoPopup* infoPopup);
|
||||||
void stopInfoPopup();
|
void stopInfoPopup();
|
||||||
|
|
||||||
void startScreensaver();
|
void startScreensaver();
|
||||||
bool stopScreensaver();
|
bool stopScreensaver();
|
||||||
void renderScreensaver();
|
void renderScreensaver();
|
||||||
void screensaverTriggerNextGame() { mScreensaver->triggerNextGame(); };
|
void screensaverTriggerNextGame() { mScreensaver->triggerNextGame(); }
|
||||||
bool isScreensaverActive() { return mRenderScreensaver; };
|
void setScreensaver(Screensaver* screensaver) { mScreensaver = screensaver; }
|
||||||
|
bool isScreensaverActive() { return mRenderScreensaver; }
|
||||||
|
|
||||||
void startMediaViewer(FileData* game);
|
void startMediaViewer(FileData* game);
|
||||||
void stopMediaViewer();
|
void stopMediaViewer();
|
||||||
void setMediaViewer(MediaViewer* mediaViewer) { mMediaViewer = mediaViewer; }
|
void setMediaViewer(MediaViewer* mediaViewer) { mMediaViewer = mediaViewer; }
|
||||||
bool isMediaViewerActive() { return mRenderMediaViewer; };
|
bool isMediaViewerActive() { return mRenderMediaViewer; }
|
||||||
|
|
||||||
void increaseVideoPlayerCount();
|
void increaseVideoPlayerCount();
|
||||||
void decreaseVideoPlayerCount();
|
void decreaseVideoPlayerCount();
|
||||||
|
@ -126,11 +126,11 @@ public:
|
||||||
void unsetLaunchedGame();
|
void unsetLaunchedGame();
|
||||||
void invalidateCachedBackground();
|
void invalidateCachedBackground();
|
||||||
|
|
||||||
bool getGameLaunchedState() { return mGameLaunchedState; };
|
bool getGameLaunchedState() { return mGameLaunchedState; }
|
||||||
void setAllowTextScrolling(bool setting) { mAllowTextScrolling = setting; };
|
void setAllowTextScrolling(bool setting) { mAllowTextScrolling = setting; }
|
||||||
bool getAllowTextScrolling() { return mAllowTextScrolling; };
|
bool getAllowTextScrolling() { return mAllowTextScrolling; }
|
||||||
|
|
||||||
void setChangedThemeSet() { mChangedThemeSet = true; };
|
void setChangedThemeSet() { mChangedThemeSet = true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onSleep();
|
void onSleep();
|
||||||
|
|
|
@ -547,7 +547,7 @@ void VideoFFmpegComponent::readFrames()
|
||||||
if (mVideoCodecContext && mFormatContext) {
|
if (mVideoCodecContext && mFormatContext) {
|
||||||
if (mVideoFrameQueue.size() < mVideoTargetQueueSize || (mAudioStreamIndex >= 0 &&
|
if (mVideoFrameQueue.size() < mVideoTargetQueueSize || (mAudioStreamIndex >= 0 &&
|
||||||
mAudioFrameQueue.size() < mAudioTargetQueueSize)) {
|
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 (mPacket->stream_index == mVideoStreamIndex) {
|
||||||
if (!avcodec_send_packet(mVideoCodecContext, mPacket) &&
|
if (!avcodec_send_packet(mVideoCodecContext, mPacket) &&
|
||||||
!avcodec_receive_frame(mVideoCodecContext, mVideoFrame)) {
|
!avcodec_receive_frame(mVideoCodecContext, mVideoFrame)) {
|
||||||
|
|
|
@ -195,7 +195,7 @@ namespace Renderer
|
||||||
windowFlags = getWindowFlags();
|
windowFlags = getWindowFlags();
|
||||||
}
|
}
|
||||||
else if (Settings::getInstance()->getString("FullscreenMode") == "borderless") {
|
else if (Settings::getInstance()->getString("FullscreenMode") == "borderless") {
|
||||||
if(!userResolution)
|
if (!userResolution)
|
||||||
windowFlags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALWAYS_ON_TOP | getWindowFlags();
|
windowFlags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALWAYS_ON_TOP | getWindowFlags();
|
||||||
else
|
else
|
||||||
// If the user has changed the resolution from the command line, then add a
|
// If the user has changed the resolution from the command line, then add a
|
||||||
|
|
Loading…
Reference in a new issue