SDL: Do not query directly ConfMan for the screenshotpath in Windows and macOS backends

Instead we call the OSystem_SDL implementation of getScreenshotsPath(),
as done in the POSIX backend. This change means that if we change how
we handle a user-specified screenshot path in the SDL backend, the
Windows and macOS backends will still get the correct path.
This commit is contained in:
Thierry Crozat 2022-01-31 21:12:34 +00:00
parent 54c84b8700
commit 533693437d
2 changed files with 17 additions and 9 deletions

View File

@ -269,12 +269,15 @@ Common::String OSystem_MacOSX::getDefaultLogFileName() {
} }
Common::String OSystem_MacOSX::getScreenshotsPath() { Common::String OSystem_MacOSX::getScreenshotsPath() {
Common::String path = ConfMan.get("screenshotpath"); // If the user has configured a screenshots path, use it
if (path.empty()) const Common::String path = OSystem_SDL::getScreenshotsPath();
path = getDesktopPathMacOSX(); if (!path.empty())
if (!path.empty() && !path.hasSuffix("/")) return path;
path += "/";
return path; Common::String desktopPath = getDesktopPathMacOSX();
if (!desktopPath.empty() && !desktopPath.hasSuffix("/"))
desktopPath += "/";
return desktopPath;
} }
AudioCDManager *OSystem_MacOSX::createAudioCDManager() { AudioCDManager *OSystem_MacOSX::createAudioCDManager() {

View File

@ -238,10 +238,15 @@ Common::String OSystem_Win32::getSystemLanguage() const {
} }
Common::String OSystem_Win32::getScreenshotsPath() { Common::String OSystem_Win32::getScreenshotsPath() {
Common::String screenshotsPath = ConfMan.get("screenshotpath"); // If the user has configured a screenshots path, use it
Common::String screenshotsPath = OSystem_SDL::getScreenshotsPath();
if (!screenshotsPath.empty()) { if (!screenshotsPath.empty()) {
if (!screenshotsPath.hasSuffix("\\") && !screenshotsPath.hasSuffix("/")) // OSystem_SDL may have appended a '/' at the end
screenshotsPath += "\\"; if (screenshotsPath.hasSuffix("/")) {
screenshotsPath.deleteLastChar();
if (!screenshotsPath.hasSuffix("\\") && !screenshotsPath.hasSuffix("/"))
screenshotsPath += "\\";
}
return screenshotsPath; return screenshotsPath;
} }