Renamed "dim" to "screensaver".

Added "screensaver behavior" option, which can be "dim" or "black".
This commit is contained in:
Aloshi 2014-05-28 11:31:58 -05:00
parent 7250d0b00b
commit 327367b6bd
3 changed files with 21 additions and 8 deletions

View file

@ -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<Scraper>(new GamesDBScraper());
}

View file

@ -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<SliderComponent>(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<SliderComponent>(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<std::string> >(mWindow, "TRANSITION STYLE", false);
std::vector<std::string> 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<SwitchComponent>(mWindow);

View file

@ -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();