SDL: Get a user-specified screenshotpath from ConfMan at the start

There are two ways the user can specify a screenshot path: by
editing the config file manually, or by passing it on the command
line. In the later case it is added to the transient domain that
is cleared when opening the launcher, so it only worked when also
specifying a game to start on the command line. With this change
a screenshot path specified on the command line will be used until
quitting ScummVM.

This could be confusing if the user had the ability to specify the
path in the ScummVM Options, as then we would probably want to use
the new specified path immediately. But since the path does not
appear in the options, this change should work fine.
This commit is contained in:
Thierry Crozat 2022-01-31 21:16:01 +00:00
parent 533693437d
commit f3dc1df7d8
2 changed files with 14 additions and 4 deletions

View file

@ -196,6 +196,13 @@ void OSystem_SDL::initBackend() {
_logger->open(logFile);
}
// In case the user specified the screenshot path, we get it here.
// That way if it was specified on the command line we will not lose it
// when the launcher is started (as it clears the ConfMan transient domain).
_userScreenshotPath = ConfMan.get("screenshotpath");
if (!_userScreenshotPath.empty() && !_userScreenshotPath.hasSuffix("/"))
_userScreenshotPath += "/";
#if SDL_VERSION_ATLEAST(2, 0, 0)
const char *sdlDriverName = SDL_GetCurrentVideoDriver();
// Allow the screen to turn off
@ -716,10 +723,7 @@ Common::SaveFileManager *OSystem_SDL::getSavefileManager() {
//Not specified in base class
Common::String OSystem_SDL::getScreenshotsPath() {
Common::String path = ConfMan.get("screenshotpath");
if (!path.empty() && !path.hasSuffix("/"))
path += "/";
return path;
return _userScreenshotPath;
}
#ifdef USE_OPENGL