mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 09:35:39 +00:00
commit
244bf47779
|
@ -4,6 +4,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include "components/VideoVlcComponent.h"
|
#include "components/VideoVlcComponent.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
#include "PowerSaver.h"
|
||||||
#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "SystemData.h"
|
#include "SystemData.h"
|
||||||
|
@ -100,6 +101,7 @@ void SystemScreenSaver::startScreenSaver()
|
||||||
mVideoScreensaver->setVideo(path);
|
mVideoScreensaver->setVideo(path);
|
||||||
mVideoScreensaver->setScreensaverMode(true);
|
mVideoScreensaver->setScreensaverMode(true);
|
||||||
mVideoScreensaver->onShow();
|
mVideoScreensaver->onShow();
|
||||||
|
PowerSaver::runningScreenSaver(true);
|
||||||
mTimer = 0;
|
mTimer = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -114,6 +116,7 @@ void SystemScreenSaver::stopScreenSaver()
|
||||||
delete mVideoScreensaver;
|
delete mVideoScreensaver;
|
||||||
mVideoScreensaver = NULL;
|
mVideoScreensaver = NULL;
|
||||||
mState = STATE_INACTIVE;
|
mState = STATE_INACTIVE;
|
||||||
|
PowerSaver::runningScreenSaver(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemScreenSaver::renderScreenSaver()
|
void SystemScreenSaver::renderScreenSaver()
|
||||||
|
@ -318,4 +321,4 @@ void SystemScreenSaver::launchGame()
|
||||||
{
|
{
|
||||||
view->launch(mCurrentGame);
|
view->launch(mCurrentGame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,5 +45,5 @@ private:
|
||||||
int mTimer;
|
int mTimer;
|
||||||
FileData* mCurrentGame;
|
FileData* mCurrentGame;
|
||||||
std::string mGameName;
|
std::string mGameName;
|
||||||
std::string mSystemName;
|
std::string mSystemName;
|
||||||
};
|
};
|
||||||
|
|
|
@ -88,7 +88,7 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN
|
||||||
for(auto it = transitions.begin(); it != transitions.end(); it++)
|
for(auto it = transitions.begin(); it != transitions.end(); it++)
|
||||||
vol_dev->add(*it, *it, Settings::getInstance()->getString("AudioDevice") == *it);
|
vol_dev->add(*it, *it, Settings::getInstance()->getString("AudioDevice") == *it);
|
||||||
s->addWithLabel("AUDIO DEVICE", vol_dev);
|
s->addWithLabel("AUDIO DEVICE", vol_dev);
|
||||||
s->addSaveFunc([vol_dev] {
|
s->addSaveFunc([vol_dev] {
|
||||||
Settings::getInstance()->setString("AudioDevice", vol_dev->getSelected());
|
Settings::getInstance()->setString("AudioDevice", vol_dev->getSelected());
|
||||||
VolumeControl::getInstance()->deinit();
|
VolumeControl::getInstance()->deinit();
|
||||||
VolumeControl::getInstance()->init();
|
VolumeControl::getInstance()->init();
|
||||||
|
@ -136,7 +136,10 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN
|
||||||
auto screensaver_time = std::make_shared<SliderComponent>(mWindow, 0.f, 30.f, 1.f, "m");
|
auto screensaver_time = std::make_shared<SliderComponent>(mWindow, 0.f, 30.f, 1.f, "m");
|
||||||
screensaver_time->setValue((float)(Settings::getInstance()->getInt("ScreenSaverTime") / (1000 * 60)));
|
screensaver_time->setValue((float)(Settings::getInstance()->getInt("ScreenSaverTime") / (1000 * 60)));
|
||||||
s->addWithLabel("SCREENSAVER AFTER", screensaver_time);
|
s->addWithLabel("SCREENSAVER AFTER", screensaver_time);
|
||||||
s->addSaveFunc([screensaver_time] { Settings::getInstance()->setInt("ScreenSaverTime", (int)round(screensaver_time->getValue()) * (1000 * 60)); });
|
s->addSaveFunc([screensaver_time] {
|
||||||
|
Settings::getInstance()->setInt("ScreenSaverTime", (int)round(screensaver_time->getValue()) * (1000 * 60));
|
||||||
|
PowerSaver::updateTimeouts();
|
||||||
|
});
|
||||||
|
|
||||||
// screensaver behavior
|
// screensaver behavior
|
||||||
auto screensaver_behavior = std::make_shared< OptionListComponent<std::string> >(mWindow, "SCREENSAVER BEHAVIOR", false);
|
auto screensaver_behavior = std::make_shared< OptionListComponent<std::string> >(mWindow, "SCREENSAVER BEHAVIOR", false);
|
||||||
|
@ -179,7 +182,7 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN
|
||||||
s->addSaveFunc([move_carousel] {
|
s->addSaveFunc([move_carousel] {
|
||||||
if (move_carousel->getState()
|
if (move_carousel->getState()
|
||||||
&& !Settings::getInstance()->getBool("MoveCarousel")
|
&& !Settings::getInstance()->getBool("MoveCarousel")
|
||||||
&& PowerSaver::ps_instant == PowerSaver::getTimeout())
|
&& PowerSaver::getMode() == PowerSaver::INSTANT)
|
||||||
{
|
{
|
||||||
Settings::getInstance()->setString("PowerSaverMode", "default");
|
Settings::getInstance()->setString("PowerSaverMode", "default");
|
||||||
PowerSaver::init();
|
PowerSaver::init();
|
||||||
|
@ -199,7 +202,7 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN
|
||||||
s->addSaveFunc([transition_style] {
|
s->addSaveFunc([transition_style] {
|
||||||
if (Settings::getInstance()->getString("TransitionStyle") == "instant"
|
if (Settings::getInstance()->getString("TransitionStyle") == "instant"
|
||||||
&& transition_style->getSelected() != "instant"
|
&& transition_style->getSelected() != "instant"
|
||||||
&& PowerSaver::ps_instant == PowerSaver::getTimeout())
|
&& PowerSaver::getMode() == PowerSaver::INSTANT)
|
||||||
{
|
{
|
||||||
Settings::getInstance()->setString("PowerSaverMode", "default");
|
Settings::getInstance()->setString("PowerSaverMode", "default");
|
||||||
PowerSaver::init();
|
PowerSaver::init();
|
||||||
|
@ -266,7 +269,7 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN
|
||||||
addEntry("GAME COLLECTION SETTINGS", 0x777777FF, true,
|
addEntry("GAME COLLECTION SETTINGS", 0x777777FF, true,
|
||||||
[this] { openCollectionSystemSettings();
|
[this] { openCollectionSystemSettings();
|
||||||
});
|
});
|
||||||
|
|
||||||
addEntry("OTHER SETTINGS", 0x777777FF, true,
|
addEntry("OTHER SETTINGS", 0x777777FF, true,
|
||||||
[this] {
|
[this] {
|
||||||
auto s = new GuiSettings(mWindow, "OTHER SETTINGS");
|
auto s = new GuiSettings(mWindow, "OTHER SETTINGS");
|
||||||
|
@ -288,21 +291,14 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN
|
||||||
power_saver->add(*it, *it, Settings::getInstance()->getString("PowerSaverMode") == *it);
|
power_saver->add(*it, *it, Settings::getInstance()->getString("PowerSaverMode") == *it);
|
||||||
s->addWithLabel("POWER SAVER MODES", power_saver);
|
s->addWithLabel("POWER SAVER MODES", power_saver);
|
||||||
s->addSaveFunc([this, power_saver] {
|
s->addSaveFunc([this, power_saver] {
|
||||||
if (Settings::getInstance()->getString("PowerSaverMode") != "instant" && power_saver->getSelected() == "instant"){
|
if (Settings::getInstance()->getString("PowerSaverMode") != "instant" && power_saver->getSelected() == "instant") {
|
||||||
mWindow->pushGui(new GuiMsgBox(mWindow, "Setting Power Saver to Instant Mode disables Carousel transition and sets Transition Style to Instant. Would you like to continue?"
|
Settings::getInstance()->setString("TransitionStyle", "instant");
|
||||||
, "YES", [] {
|
Settings::getInstance()->setBool("MoveCarousel", false);
|
||||||
Settings::getInstance()->setString("TransitionStyle", "instant");
|
|
||||||
Settings::getInstance()->setString("PowerSaverMode", "instant");
|
|
||||||
Settings::getInstance()->setBool("MoveCarousel", false);
|
|
||||||
PowerSaver::init();
|
|
||||||
}, "NO", nullptr)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
Settings::getInstance()->setString("PowerSaverMode", power_saver->getSelected());
|
|
||||||
PowerSaver::init();
|
|
||||||
}
|
}
|
||||||
|
Settings::getInstance()->setString("PowerSaverMode", power_saver->getSelected());
|
||||||
|
PowerSaver::init();
|
||||||
});
|
});
|
||||||
|
|
||||||
// gamelists
|
// gamelists
|
||||||
auto save_gamelists = std::make_shared<SwitchComponent>(mWindow);
|
auto save_gamelists = std::make_shared<SwitchComponent>(mWindow);
|
||||||
save_gamelists->setState(Settings::getInstance()->getBool("SaveGamelistsOnExit"));
|
save_gamelists->setState(Settings::getInstance()->getBool("SaveGamelistsOnExit"));
|
||||||
|
|
|
@ -54,7 +54,7 @@ bool parseArgs(int argc, char* argv[], unsigned int* width, unsigned int* height
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
}else if(strcmp(argv[i], "--show-hidden-files") == 0)
|
}else if(strcmp(argv[i], "--show-hidden-files") == 0)
|
||||||
{
|
{
|
||||||
Settings::getInstance()->setBool("ShowHiddenFiles", true);
|
Settings::getInstance()->setBool("ShowHiddenFiles", true);
|
||||||
#endif
|
#endif
|
||||||
}else if(strcmp(argv[i], "--draw-framerate") == 0)
|
}else if(strcmp(argv[i], "--draw-framerate") == 0)
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ bool parseArgs(int argc, char* argv[], unsigned int* width, unsigned int* height
|
||||||
AttachConsole(ATTACH_PARENT_PROCESS);
|
AttachConsole(ATTACH_PARENT_PROCESS);
|
||||||
freopen("CONOUT$", "wb", stdout);
|
freopen("CONOUT$", "wb", stdout);
|
||||||
#endif
|
#endif
|
||||||
std::cout <<
|
std::cout <<
|
||||||
"EmulationStation, a graphical front-end for ROM browsing.\n"
|
"EmulationStation, a graphical front-end for ROM browsing.\n"
|
||||||
"Written by Alec \"Aloshi\" Lofquist.\n"
|
"Written by Alec \"Aloshi\" Lofquist.\n"
|
||||||
"Version " << PROGRAM_VERSION_STRING << ", built " << PROGRAM_BUILT_STRING << "\n\n"
|
"Version " << PROGRAM_VERSION_STRING << ", built " << PROGRAM_BUILT_STRING << "\n\n"
|
||||||
|
@ -139,7 +139,7 @@ bool verifyHomeFolderExists()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if everything is OK,
|
// Returns true if everything is OK,
|
||||||
bool loadSystemConfigFile(const char** errorString)
|
bool loadSystemConfigFile(const char** errorString)
|
||||||
{
|
{
|
||||||
*errorString = NULL;
|
*errorString = NULL;
|
||||||
|
@ -187,8 +187,8 @@ int main(int argc, char* argv[])
|
||||||
// only show the console on Windows if HideConsole is false
|
// only show the console on Windows if HideConsole is false
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
// MSVC has a "SubSystem" option, with two primary options: "WINDOWS" and "CONSOLE".
|
// MSVC has a "SubSystem" option, with two primary options: "WINDOWS" and "CONSOLE".
|
||||||
// In "WINDOWS" mode, no console is automatically created for us. This is good,
|
// In "WINDOWS" mode, no console is automatically created for us. This is good,
|
||||||
// because we can choose to only create the console window if the user explicitly
|
// because we can choose to only create the console window if the user explicitly
|
||||||
// asks for it, preventing it from flashing open and then closing.
|
// asks for it, preventing it from flashing open and then closing.
|
||||||
// In "CONSOLE" mode, a console is always automatically created for us before we
|
// In "CONSOLE" mode, a console is always automatically created for us before we
|
||||||
// enter main. In this case, we can only hide the console after the fact, which
|
// enter main. In this case, we can only hide the console after the fact, which
|
||||||
|
@ -210,7 +210,7 @@ int main(int argc, char* argv[])
|
||||||
}else{
|
}else{
|
||||||
// we want to hide the console
|
// we want to hide the console
|
||||||
// if we're compiled with the "WINDOWS" subsystem, this is already done.
|
// if we're compiled with the "WINDOWS" subsystem, this is already done.
|
||||||
// if we're compiled with the "CONSOLE" subsystem, a console is already created;
|
// if we're compiled with the "CONSOLE" subsystem, a console is already created;
|
||||||
// it'll flash open, but we hide it nearly immediately
|
// it'll flash open, but we hide it nearly immediately
|
||||||
if(GetConsoleWindow()) // should only pass in "CONSOLE" mode
|
if(GetConsoleWindow()) // should only pass in "CONSOLE" mode
|
||||||
ShowWindow(GetConsoleWindow(), SW_HIDE);
|
ShowWindow(GetConsoleWindow(), SW_HIDE);
|
||||||
|
@ -266,7 +266,7 @@ int main(int argc, char* argv[])
|
||||||
// we can't handle es_systems.cfg file problems inside ES itself, so display the error message then quit
|
// we can't handle es_systems.cfg file problems inside ES itself, so display the error message then quit
|
||||||
window.pushGui(new GuiMsgBox(&window,
|
window.pushGui(new GuiMsgBox(&window,
|
||||||
errorMsg,
|
errorMsg,
|
||||||
"QUIT", [] {
|
"QUIT", [] {
|
||||||
SDL_Event* quit = new SDL_Event();
|
SDL_Event* quit = new SDL_Event();
|
||||||
quit->type = SDL_QUIT;
|
quit->type = SDL_QUIT;
|
||||||
SDL_PushEvent(quit);
|
SDL_PushEvent(quit);
|
||||||
|
@ -302,19 +302,16 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
int lastTime = SDL_GetTicks();
|
int lastTime = SDL_GetTicks();
|
||||||
int ps_time = SDL_GetTicks();
|
int ps_time = SDL_GetTicks();
|
||||||
|
|
||||||
bool running = true;
|
bool running = true;
|
||||||
bool ps_standby = false;
|
bool ps_standby = false;
|
||||||
|
|
||||||
// assuming screensaver timeout is not updated regularly.
|
|
||||||
int timeout = (unsigned int) Settings::getInstance()->getInt("ScreenSaverTime");
|
|
||||||
|
|
||||||
while(running)
|
while(running)
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
bool ps_standby = PowerSaver::getState() && SDL_GetTicks() - ps_time > PowerSaver::getTimeout();
|
bool ps_standby = PowerSaver::getState() && SDL_GetTicks() - ps_time > PowerSaver::getMode();
|
||||||
|
|
||||||
if(ps_standby ? SDL_WaitEventTimeout(&event, timeout - 100) : SDL_PollEvent(&event))
|
if(ps_standby ? SDL_WaitEventTimeout(&event, PowerSaver::getTimeout()) : SDL_PollEvent(&event))
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -337,12 +334,12 @@ int main(int argc, char* argv[])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while(SDL_PollEvent(&event));
|
} while(SDL_PollEvent(&event));
|
||||||
|
|
||||||
// triggered if exiting from SDL_WaitEvent
|
// triggered if exiting from SDL_WaitEvent
|
||||||
if (ps_standby)
|
if (ps_standby)
|
||||||
// show as if continuing from last event
|
// show as if continuing from last event
|
||||||
lastTime = SDL_GetTicks();
|
lastTime = SDL_GetTicks();
|
||||||
|
|
||||||
// reset counter
|
// reset counter
|
||||||
ps_time = SDL_GetTicks();
|
ps_time = SDL_GetTicks();
|
||||||
}
|
}
|
||||||
|
@ -359,7 +356,7 @@ int main(int argc, char* argv[])
|
||||||
lastTime = curTime;
|
lastTime = curTime;
|
||||||
|
|
||||||
// cap deltaTime
|
// cap deltaTime
|
||||||
if(deltaTime > timeout || deltaTime < 0)
|
if((deltaTime > PowerSaver::getTimeout() && PowerSaver::getTimeout() > 0) || deltaTime < 0)
|
||||||
deltaTime = 1000;
|
deltaTime = 1000;
|
||||||
|
|
||||||
window.update(deltaTime);
|
window.update(deltaTime);
|
||||||
|
|
|
@ -2,32 +2,49 @@
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
bool PowerSaver::mState = true;
|
bool PowerSaver::mState = false;
|
||||||
int PowerSaver::mTimeout = PowerSaver::ps_default;
|
bool PowerSaver::mRunningScreenSaver = false;
|
||||||
|
|
||||||
void PowerSaver::init(bool state)
|
int PowerSaver::mPlayNextTimeout = -1;
|
||||||
|
int PowerSaver::mScreenSaverTimeout = -1;
|
||||||
|
PowerSaver::mode PowerSaver::mMode = PowerSaver::DISABLED;
|
||||||
|
|
||||||
|
void PowerSaver::init()
|
||||||
{
|
{
|
||||||
setState(true);
|
setState(true);
|
||||||
updateTimeout();
|
updateTimeouts();
|
||||||
|
updateMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
int PowerSaver::getTimeout()
|
int PowerSaver::getTimeout()
|
||||||
{
|
{
|
||||||
return mTimeout;
|
return mRunningScreenSaver ? mPlayNextTimeout : mScreenSaverTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PowerSaver::updateTimeout()
|
void PowerSaver::updateTimeouts()
|
||||||
|
{
|
||||||
|
mScreenSaverTimeout = (unsigned int) Settings::getInstance()->getInt("ScreenSaverTime");
|
||||||
|
mScreenSaverTimeout = mScreenSaverTimeout > 0 ? mScreenSaverTimeout - 100 : -1;
|
||||||
|
mPlayNextTimeout = 30000;
|
||||||
|
}
|
||||||
|
|
||||||
|
PowerSaver::mode PowerSaver::getMode()
|
||||||
|
{
|
||||||
|
return mMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerSaver::updateMode()
|
||||||
{
|
{
|
||||||
std::string mode = Settings::getInstance()->getString("PowerSaverMode");
|
std::string mode = Settings::getInstance()->getString("PowerSaverMode");
|
||||||
|
|
||||||
if (mode == "disabled") {
|
if (mode == "disabled") {
|
||||||
mTimeout = ps_disabled;
|
mMode = DISABLED;
|
||||||
} else if (mode == "instant") {
|
} else if (mode == "instant") {
|
||||||
mTimeout = ps_instant;
|
mMode = INSTANT;
|
||||||
} else if (mode == "enhanced") {
|
} else if (mode == "enhanced") {
|
||||||
mTimeout = ps_enhanced;
|
mMode = ENHANCED;
|
||||||
} else { // default
|
} else {
|
||||||
mTimeout = ps_default;
|
mMode = DEFAULT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,3 +59,7 @@ void PowerSaver::setState(bool state)
|
||||||
mState = ps_enabled && state;
|
mState = ps_enabled && state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PowerSaver::runningScreenSaver(bool state)
|
||||||
|
{
|
||||||
|
mRunningScreenSaver = state;
|
||||||
|
}
|
||||||
|
|
|
@ -1,17 +1,26 @@
|
||||||
class PowerSaver
|
class PowerSaver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum ps_state : int { ps_disabled = -1, ps_instant = 200, ps_enhanced = 3000, ps_default = 10000 };
|
enum mode : int { DISABLED = -1, INSTANT = 200, ENHANCED = 3000, DEFAULT = 10000 };
|
||||||
|
|
||||||
static void init(bool state = true);
|
static void init();
|
||||||
|
|
||||||
static int getTimeout();
|
static int getTimeout();
|
||||||
static void updateTimeout();
|
static void updateTimeouts();
|
||||||
|
|
||||||
|
static mode getMode();
|
||||||
|
static void updateMode();
|
||||||
|
|
||||||
static bool getState();
|
static bool getState();
|
||||||
static void setState(bool state);
|
static void setState(bool state);
|
||||||
|
|
||||||
|
static void runningScreenSaver(bool state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool mState;
|
static bool mState;
|
||||||
static int mTimeout;
|
static bool mRunningScreenSaver;
|
||||||
|
|
||||||
|
static mode mMode;
|
||||||
|
static int mPlayNextTimeout;
|
||||||
|
static int mScreenSaverTimeout;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue