mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-03-06 14:27:43 +00:00
PowerSaver updates:
- Video Screensaver to skip fade in/out if Instant - Video Previews to skip fade in/out if Instant - Added Pause/Resume methods to PS for better description - Added basic documentation to PS header file - Added trailing after waking up from SS - Added proper timing offsets after PS is triggered - PS set to Disabled by default - some whitespace edits
This commit is contained in:
parent
244bf47779
commit
90cd10b421
|
@ -59,8 +59,10 @@ void SystemScreenSaver::startScreenSaver()
|
|||
{
|
||||
if (!mVideoScreensaver && (Settings::getInstance()->getString("ScreenSaverBehavior") == "random video"))
|
||||
{
|
||||
// Configure to fade out the windows
|
||||
mState = STATE_FADE_OUT_WINDOW;
|
||||
// Configure to fade out the windows, Skip Fading if Instant mode
|
||||
mState = PowerSaver::getMode() == PowerSaver::INSTANT
|
||||
? STATE_SCREENSAVER_ACTIVE
|
||||
: STATE_FADE_OUT_WINDOW;
|
||||
mOpacity = 0.0f;
|
||||
|
||||
// Load a random video
|
||||
|
@ -316,9 +318,9 @@ void SystemScreenSaver::launchGame()
|
|||
// launching Game
|
||||
ViewController::get()->goToGameList(mCurrentGame->getSystem());
|
||||
IGameListView* view = ViewController::get()->getGameListView(mCurrentGame->getSystem()).get();
|
||||
view->setCursor(mCurrentGame);
|
||||
if (Settings::getInstance()->getBool("ScreenSaverControls"))
|
||||
{
|
||||
view->launch(mCurrentGame);
|
||||
}
|
||||
view->setCursor(mCurrentGame);
|
||||
if (Settings::getInstance()->getBool("ScreenSaverControls"))
|
||||
{
|
||||
view->launch(mCurrentGame);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,25 +9,25 @@
|
|||
#include "PowerSaver.h"
|
||||
#include "Settings.h"
|
||||
|
||||
GuiGameScraper::GuiGameScraper(Window* window, ScraperSearchParams params, std::function<void(const ScraperSearchResult&)> doneFunc) : GuiComponent(window),
|
||||
mGrid(window, Eigen::Vector2i(1, 7)),
|
||||
GuiGameScraper::GuiGameScraper(Window* window, ScraperSearchParams params, std::function<void(const ScraperSearchResult&)> doneFunc) : GuiComponent(window),
|
||||
mGrid(window, Eigen::Vector2i(1, 7)),
|
||||
mBox(window, ":/frame.png"),
|
||||
mSearchParams(params),
|
||||
mClose(false)
|
||||
{
|
||||
PowerSaver::setState(false);
|
||||
PowerSaver::pause();
|
||||
addChild(&mBox);
|
||||
addChild(&mGrid);
|
||||
|
||||
// row 0 is a spacer
|
||||
|
||||
mGameName = std::make_shared<TextComponent>(mWindow, strToUpper(mSearchParams.game->getPath().filename().generic_string()),
|
||||
mGameName = std::make_shared<TextComponent>(mWindow, strToUpper(mSearchParams.game->getPath().filename().generic_string()),
|
||||
Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mGameName, Eigen::Vector2i(0, 1), false, true);
|
||||
|
||||
// row 2 is a spacer
|
||||
|
||||
mSystemName = std::make_shared<TextComponent>(mWindow, strToUpper(mSearchParams.system->getFullName()), Font::get(FONT_SIZE_SMALL),
|
||||
mSystemName = std::make_shared<TextComponent>(mWindow, strToUpper(mSearchParams.system->getFullName()), Font::get(FONT_SIZE_SMALL),
|
||||
0x888888FF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mSystemName, Eigen::Vector2i(0, 3), false, true);
|
||||
|
||||
|
@ -40,9 +40,9 @@ GuiGameScraper::GuiGameScraper(Window* window, ScraperSearchParams params, std::
|
|||
// buttons
|
||||
std::vector< std::shared_ptr<ButtonComponent> > buttons;
|
||||
|
||||
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "INPUT", "search", [&] {
|
||||
mSearch->openInputScreen(mSearchParams);
|
||||
mGrid.resetCursor();
|
||||
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "INPUT", "search", [&] {
|
||||
mSearch->openInputScreen(mSearchParams);
|
||||
mGrid.resetCursor();
|
||||
}));
|
||||
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "CANCEL", "cancel", [&] { delete this; }));
|
||||
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
||||
|
@ -98,7 +98,7 @@ bool GuiGameScraper::input(InputConfig* config, Input input)
|
|||
{
|
||||
if(config->isMappedTo("b", input) && input.value)
|
||||
{
|
||||
PowerSaver::setState(true);
|
||||
PowerSaver::resume();
|
||||
delete this;
|
||||
return true;
|
||||
}
|
||||
|
@ -122,4 +122,4 @@ std::vector<HelpPrompt> GuiGameScraper::getHelpPrompts()
|
|||
void GuiGameScraper::close()
|
||||
{
|
||||
mClose = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,16 +13,16 @@
|
|||
|
||||
using namespace Eigen;
|
||||
|
||||
GuiScraperMulti::GuiScraperMulti(Window* window, const std::queue<ScraperSearchParams>& searches, bool approveResults) :
|
||||
GuiComponent(window), mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 5)),
|
||||
GuiScraperMulti::GuiScraperMulti(Window* window, const std::queue<ScraperSearchParams>& searches, bool approveResults) :
|
||||
GuiComponent(window), mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 5)),
|
||||
mSearchQueue(searches)
|
||||
{
|
||||
assert(mSearchQueue.size());
|
||||
|
||||
PowerSaver::setState(false);
|
||||
addChild(&mBackground);
|
||||
addChild(&mGrid);
|
||||
|
||||
PowerSaver::pause();
|
||||
mIsProcessing = true;
|
||||
|
||||
mTotalGames = mSearchQueue.size();
|
||||
|
@ -40,7 +40,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window, const std::queue<ScraperSearchP
|
|||
mSubtitle = std::make_shared<TextComponent>(mWindow, "subtitle text", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mSubtitle, Vector2i(0, 2), false, true);
|
||||
|
||||
mSearchComp = std::make_shared<ScraperSearchComponent>(mWindow,
|
||||
mSearchComp = std::make_shared<ScraperSearchComponent>(mWindow,
|
||||
approveResults ? ScraperSearchComponent::ALWAYS_ACCEPT_MATCHING_CRC : ScraperSearchComponent::ALWAYS_ACCEPT_FIRST_RESULT);
|
||||
mSearchComp->setAcceptCallback(std::bind(&GuiScraperMulti::acceptResult, this, std::placeholders::_1));
|
||||
mSearchComp->setSkipCallback(std::bind(&GuiScraperMulti::skip, this));
|
||||
|
@ -51,9 +51,9 @@ GuiScraperMulti::GuiScraperMulti(Window* window, const std::queue<ScraperSearchP
|
|||
|
||||
if(approveResults)
|
||||
{
|
||||
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "INPUT", "search", [&] {
|
||||
mSearchComp->openInputScreen(mSearchQueue.front());
|
||||
mGrid.resetCursor();
|
||||
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "INPUT", "search", [&] {
|
||||
mSearchComp->openInputScreen(mSearchQueue.front());
|
||||
mGrid.resetCursor();
|
||||
}));
|
||||
|
||||
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "SKIP", "skip", [&] {
|
||||
|
@ -95,7 +95,6 @@ void GuiScraperMulti::doNextSearch()
|
|||
{
|
||||
if(mSearchQueue.empty())
|
||||
{
|
||||
PowerSaver::setState(true);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
@ -146,10 +145,11 @@ void GuiScraperMulti::finish()
|
|||
ss << "\n" << mTotalSkipped << " GAME" << ((mTotalSkipped > 1) ? "S" : "") << " SKIPPED.";
|
||||
}
|
||||
|
||||
mWindow->pushGui(new GuiMsgBox(mWindow, ss.str(),
|
||||
mWindow->pushGui(new GuiMsgBox(mWindow, ss.str(),
|
||||
"OK", [&] { delete this; }));
|
||||
|
||||
mIsProcessing = false;
|
||||
PowerSaver::resume();
|
||||
}
|
||||
|
||||
std::vector<HelpPrompt> GuiScraperMulti::getHelpPrompts()
|
||||
|
|
|
@ -335,7 +335,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
} while(SDL_PollEvent(&event));
|
||||
|
||||
// triggered if exiting from SDL_WaitEvent
|
||||
// triggered if exiting from SDL_WaitEvent due to event
|
||||
if (ps_standby)
|
||||
// show as if continuing from last event
|
||||
lastTime = SDL_GetTicks();
|
||||
|
@ -343,6 +343,12 @@ int main(int argc, char* argv[])
|
|||
// reset counter
|
||||
ps_time = SDL_GetTicks();
|
||||
}
|
||||
else if (ps_standby)
|
||||
{
|
||||
// If exitting SDL_WaitEventTimeout due to timeout. Trail considering
|
||||
// timeout as an event
|
||||
ps_time = SDL_GetTicks();
|
||||
}
|
||||
|
||||
if(window.isSleeping())
|
||||
{
|
||||
|
@ -355,8 +361,8 @@ int main(int argc, char* argv[])
|
|||
int deltaTime = curTime - lastTime;
|
||||
lastTime = curTime;
|
||||
|
||||
// cap deltaTime
|
||||
if((deltaTime > PowerSaver::getTimeout() && PowerSaver::getTimeout() > 0) || deltaTime < 0)
|
||||
// cap deltaTime if it ever goes negative
|
||||
if(deltaTime < 0)
|
||||
deltaTime = 1000;
|
||||
|
||||
window.update(deltaTime);
|
||||
|
|
|
@ -12,20 +12,20 @@ PowerSaver::mode PowerSaver::mMode = PowerSaver::DISABLED;
|
|||
void PowerSaver::init()
|
||||
{
|
||||
setState(true);
|
||||
updateTimeouts();
|
||||
updateMode();
|
||||
}
|
||||
|
||||
int PowerSaver::getTimeout()
|
||||
{
|
||||
// Used only for SDL_WaitEventTimeout. Use `getMode()` for modes.
|
||||
return mRunningScreenSaver ? mPlayNextTimeout : mScreenSaverTimeout;
|
||||
}
|
||||
|
||||
void PowerSaver::updateTimeouts()
|
||||
{
|
||||
mScreenSaverTimeout = (unsigned int) Settings::getInstance()->getInt("ScreenSaverTime");
|
||||
mScreenSaverTimeout = mScreenSaverTimeout > 0 ? mScreenSaverTimeout - 100 : -1;
|
||||
mPlayNextTimeout = 30000;
|
||||
mScreenSaverTimeout = mScreenSaverTimeout > 0 ? mScreenSaverTimeout - getMode() : -1;
|
||||
mPlayNextTimeout = 30000 - getMode();
|
||||
}
|
||||
|
||||
PowerSaver::mode PowerSaver::getMode()
|
||||
|
@ -46,6 +46,7 @@ void PowerSaver::updateMode()
|
|||
} else {
|
||||
mMode = DEFAULT;
|
||||
}
|
||||
updateTimeouts();
|
||||
}
|
||||
|
||||
bool PowerSaver::getState()
|
||||
|
@ -63,3 +64,8 @@ void PowerSaver::runningScreenSaver(bool state)
|
|||
{
|
||||
mRunningScreenSaver = state;
|
||||
}
|
||||
|
||||
bool PowerSaver::isScreenSaverActive()
|
||||
{
|
||||
return mRunningScreenSaver;
|
||||
}
|
||||
|
|
|
@ -3,18 +3,32 @@ class PowerSaver
|
|||
public:
|
||||
enum mode : int { DISABLED = -1, INSTANT = 200, ENHANCED = 3000, DEFAULT = 10000 };
|
||||
|
||||
// Call when you want PS to reload all state and settings
|
||||
static void init();
|
||||
|
||||
// Get timeout to wake up from for the next event
|
||||
static int getTimeout();
|
||||
// Update currently set timeouts after User changes Timeout settings
|
||||
static void updateTimeouts();
|
||||
|
||||
// Use this to check which mode you are in or get the mode timeout
|
||||
static mode getMode();
|
||||
// Called when user changes mode from Settings
|
||||
static void updateMode();
|
||||
|
||||
// Get current state of PS. Not to be confused with Mode
|
||||
static bool getState();
|
||||
// State is used to temporarily pause and resume PS
|
||||
static void setState(bool state);
|
||||
|
||||
// Paired calls when you want to pause PS briefly till you finish animating
|
||||
// or processing over cycles
|
||||
static void pause() { setState(false); }
|
||||
static void resume() { setState(true); }
|
||||
|
||||
// This is used by ScreenSaver to let PS know when to switch to SS timeouts
|
||||
static void runningScreenSaver(bool state);
|
||||
static bool isScreenSaverActive();
|
||||
|
||||
private:
|
||||
static bool mState;
|
||||
|
|
|
@ -82,7 +82,7 @@ void Settings::setDefaults()
|
|||
mBoolMap["ScreenSaverControls"] = true;
|
||||
mStringMap["ScreenSaverGameInfo"] = "never";
|
||||
mBoolMap["StretchVideoOnScreenSaver"] = false;
|
||||
mStringMap["PowerSaverMode"] = "default";
|
||||
mStringMap["PowerSaverMode"] = "disabled";
|
||||
|
||||
// This setting only applies to raspberry pi but set it for all platforms so
|
||||
// we don't get a warning if we encounter it on a different platform
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "ThemeData.h"
|
||||
#include "Util.h"
|
||||
#include "Window.h"
|
||||
#include "PowerSaver.h"
|
||||
#ifdef WIN32
|
||||
#include <codecvt>
|
||||
#endif
|
||||
|
@ -264,7 +265,7 @@ void VideoComponent::startVideoWithDelay()
|
|||
// Set the video that we are going to be playing so we don't attempt to restart it
|
||||
mPlayingVideoPath = mVideoPath;
|
||||
|
||||
if (mConfig.startDelay == 0)
|
||||
if (mConfig.startDelay == 0 || PowerSaver::getMode() == PowerSaver::INSTANT)
|
||||
{
|
||||
// No delay. Just start the video
|
||||
mStartDelayed = false;
|
||||
|
|
|
@ -330,7 +330,7 @@ void VideoVlcComponent::startVideo()
|
|||
}
|
||||
}
|
||||
#endif
|
||||
PowerSaver::setState(false);
|
||||
PowerSaver::pause();
|
||||
setupContext();
|
||||
|
||||
// Setup the media player
|
||||
|
@ -361,12 +361,11 @@ void VideoVlcComponent::stopVideo()
|
|||
// Release the media player so it stops calling back to us
|
||||
if (mMediaPlayer)
|
||||
{
|
||||
PowerSaver::setState(true);
|
||||
libvlc_media_player_stop(mMediaPlayer);
|
||||
libvlc_media_player_release(mMediaPlayer);
|
||||
libvlc_media_release(mMedia);
|
||||
mMediaPlayer = NULL;
|
||||
freeContext();
|
||||
PowerSaver::resume();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue