Merge branch 'unstable'

This commit is contained in:
Aloshi 2014-11-23 09:44:56 -06:00
commit 396cf1bde9
6 changed files with 36 additions and 9 deletions

View file

@ -111,6 +111,7 @@ You can use `--help` or `-h` to view a list of command-line options. Briefly out
--no-exit - do not display 'exit' in the ES menu. --no-exit - do not display 'exit' in the ES menu.
--debug - print additional output to the console, primarily about input. --debug - print additional output to the console, primarily about input.
--windowed - run ES in a window, works best in conjunction with --resolution [w] [h]. --windowed - run ES in a window, works best in conjunction with --resolution [w] [h].
--vsync [0/1] - turn vsync on or off (default is on), only works in fullscreen.
--scrape - run the interactive command-line metadata scraper. --scrape - run the interactive command-line metadata scraper.
``` ```

View file

@ -61,14 +61,13 @@ SystemData::~SystemData()
delete mRootFolder; delete mRootFolder;
} }
std::string strreplace(std::string& str, std::string replace, std::string with) std::string strreplace(std::string str, const std::string& replace, const std::string& with)
{ {
size_t pos = str.find(replace); size_t pos;
while((pos = str.find(replace)) != std::string::npos)
if(pos != std::string::npos) str = str.replace(pos, replace.length(), with.c_str(), with.length());
return str.replace(pos, replace.length(), with.c_str(), with.length());
else return str;
return str;
} }
std::string escapePath(const boost::filesystem::path& path) std::string escapePath(const boost::filesystem::path& path)

View file

@ -57,6 +57,10 @@ bool parseArgs(int argc, char* argv[], unsigned int* width, unsigned int* height
}else if(strcmp(argv[i], "--windowed") == 0) }else if(strcmp(argv[i], "--windowed") == 0)
{ {
Settings::getInstance()->setBool("Windowed", true); Settings::getInstance()->setBool("Windowed", true);
}else if(strcmp(argv[i], "--vsync") == 0)
{
Settings::getInstance()->setBool("VSync", atoi(argv[i + 1]));
i++; // skip vsync value
}else if(strcmp(argv[i], "--scrape") == 0) }else if(strcmp(argv[i], "--scrape") == 0)
{ {
scrape_cmdline = true; scrape_cmdline = true;
@ -75,6 +79,7 @@ bool parseArgs(int argc, char* argv[], unsigned int* width, unsigned int* height
"--debug even more logging\n" "--debug even more logging\n"
"--scrape scrape using command line interface\n" "--scrape scrape using command line interface\n"
"--windowed not fullscreen, should be used with --resolution\n" "--windowed not fullscreen, should be used with --resolution\n"
"--vsync [0/1] turn vsync on or off (default is on)\n"
"--help, -h summon a sentient, angry tuba\n\n" "--help, -h summon a sentient, angry tuba\n\n"
"More information available in README.md.\n"; "More information available in README.md.\n";
return false; //exit after printing help return false; //exit after printing help

View file

@ -49,7 +49,6 @@ namespace Renderer
#ifdef USE_OPENGL_ES #ifdef USE_OPENGL_ES
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
#endif #endif
//SDL_GL_SetSwapInterval(1); //0 for immediate updates, 1 for updates synchronized with the vertical retrace, -1 for late swap tearing
SDL_DisplayMode dispMode; SDL_DisplayMode dispMode;
SDL_GetDesktopDisplayMode(0, &dispMode); SDL_GetDesktopDisplayMode(0, &dispMode);
@ -96,6 +95,19 @@ namespace Renderer
sdlContext = SDL_GL_CreateContext(sdlWindow); sdlContext = SDL_GL_CreateContext(sdlWindow);
// vsync
if(Settings::getInstance()->getBool("VSync"))
{
// SDL_GL_SetSwapInterval(0) for immediate updates (no vsync, default),
// 1 for updates synchronized with the vertical retrace,
// or -1 for late swap tearing.
// SDL_GL_SetSwapInterval returns 0 on success, -1 on error.
// if vsync is requested, try late swap tearing; if that doesn't work, try normal vsync
// if that doesn't work, report an error
if(SDL_GL_SetSwapInterval(-1) != 0 && SDL_GL_SetSwapInterval(1) != 0)
LOG(LogWarning) << "Tried to enable vsync, but failed! (" << SDL_GetError() << ")";
}
//hide mouse cursor //hide mouse cursor
initialCursorState = SDL_ShowCursor(0) == 1; initialCursorState = SDL_ShowCursor(0) == 1;

View file

@ -16,6 +16,7 @@ std::vector<const char*> settings_dont_save = boost::assign::list_of
("ParseGamelistOnly") ("ParseGamelistOnly")
("ShowExit") ("ShowExit")
("Windowed") ("Windowed")
("VSync")
("IgnoreGamelist"); ("IgnoreGamelist");
Settings::Settings() Settings::Settings()
@ -41,6 +42,15 @@ void Settings::setDefaults()
mBoolMap["DrawFramerate"] = false; mBoolMap["DrawFramerate"] = false;
mBoolMap["ShowExit"] = true; mBoolMap["ShowExit"] = true;
mBoolMap["Windowed"] = false; mBoolMap["Windowed"] = false;
#ifdef _RPI_
// don't enable VSync by default on the Pi, since it already
// has trouble trying to render things at 60fps in certain menus
mBoolMap["VSync"] = false;
#else
mBoolMap["VSync"] = true;
#endif
mBoolMap["EnableSounds"] = true; mBoolMap["EnableSounds"] = true;
mBoolMap["ShowHelpPrompts"] = true; mBoolMap["ShowHelpPrompts"] = true;
mBoolMap["ScrapeRatings"] = true; mBoolMap["ScrapeRatings"] = true;

View file

@ -111,7 +111,7 @@ void Sound::play()
if(mSampleData == NULL) if(mSampleData == NULL)
return; return;
if(Settings::getInstance()->getBool("EnableSounds")) if(!Settings::getInstance()->getBool("EnableSounds"))
return; return;
SDL_LockAudio(); SDL_LockAudio();