From 327367b6bdc495eef7b2a42d2ac5832602ec6841 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Wed, 28 May 2014 11:31:58 -0500 Subject: [PATCH] Renamed "dim" to "screensaver". Added "screensaver behavior" option, which can be "dim" or "black". --- src/Settings.cpp | 3 ++- src/guis/GuiMenu.cpp | 20 +++++++++++++++----- src/main.cpp | 6 ++++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Settings.cpp b/src/Settings.cpp index c82cf72df..96053a431 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -41,7 +41,7 @@ void Settings::setDefaults() mBoolMap["DebugGrid"] = false; mBoolMap["DebugText"] = false; - mIntMap["DimTime"] = 120*1000; + mIntMap["ScreenSaverTime"] = 5*60*1000; // 5 minutes mIntMap["ScraperResizeWidth"] = 400; mIntMap["ScraperResizeHeight"] = 0; @@ -49,6 +49,7 @@ void Settings::setDefaults() mStringMap["TransitionStyle"] = "fade"; mStringMap["ThemeSet"] = ""; + mStringMap["ScreenSaverBehavior"] = "dim"; mScraper = std::shared_ptr(new GamesDBScraper()); } diff --git a/src/guis/GuiMenu.cpp b/src/guis/GuiMenu.cpp index df56a96cb..ce1597788 100644 --- a/src/guis/GuiMenu.cpp +++ b/src/guis/GuiMenu.cpp @@ -93,11 +93,21 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN [this] { auto s = new GuiSettings(mWindow, "UI SETTINGS"); - // dim time - auto dim_time = std::make_shared(mWindow, 0.f, 30.f, 1.f, "m"); - dim_time->setValue((float)(Settings::getInstance()->getInt("DimTime") / (1000 * 60))); - s->addWithLabel("DIM SCREEN AFTER", dim_time); - s->addSaveFunc([dim_time] { Settings::getInstance()->setInt("DimTime", (int)round(dim_time->getValue()) * (1000 * 60)); }); + // screensaver time + auto screensaver_time = std::make_shared(mWindow, 0.f, 30.f, 1.f, "m"); + screensaver_time->setValue((float)(Settings::getInstance()->getInt("ScreenSaverTime") / (1000 * 60))); + s->addWithLabel("SCREENSAVER AFTER", screensaver_time); + s->addSaveFunc([screensaver_time] { Settings::getInstance()->setInt("ScreenSaverTime", (int)round(screensaver_time->getValue()) * (1000 * 60)); }); + + // screensaver behavior + auto screensaver_behavior = std::make_shared< OptionListComponent >(mWindow, "TRANSITION STYLE", false); + std::vector screensavers; + screensavers.push_back("dim"); + screensavers.push_back("black"); + for(auto it = screensavers.begin(); it != screensavers.end(); it++) + screensaver_behavior->add(*it, *it, Settings::getInstance()->getString("ScreenSaverBehavior") == *it); + s->addWithLabel("SCREENSAVER BEHAVIOR", screensaver_behavior); + s->addSaveFunc([screensaver_behavior] { Settings::getInstance()->setString("ScreenSaverBehavior", screensaver_behavior->getSelected()); }); // framerate auto framerate = std::make_shared(mWindow); diff --git a/src/main.cpp b/src/main.cpp index ccd4bfc8f..9edcce994 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -259,12 +259,14 @@ int main(int argc, char* argv[]) //sleeping entails setting a flag to start skipping frames //and initially drawing a black semi-transparent rect to dim the screen timeSinceLastEvent += deltaTime; - if(timeSinceLastEvent >= (unsigned int)Settings::getInstance()->getInt("DimTime") && Settings::getInstance()->getInt("DimTime") != 0 && window.getAllowSleep()) + if(timeSinceLastEvent >= (unsigned int)Settings::getInstance()->getInt("ScreenSaverTime") && Settings::getInstance()->getInt("ScreenSaverTime") != 0 && window.getAllowSleep()) { sleeping = true; timeSinceLastEvent = 0; Renderer::setMatrix(Eigen::Affine3f::Identity()); - Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000A0); + + unsigned char opacity = Settings::getInstance()->getString("ScreenSaverBehavior") == "dim" ? 0xA0 : 0xFF; + Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x00000000 | opacity); } Renderer::swapBuffers();