From 3849a3e90e6e679e35f8ec4517ce38d2a0c5d098 Mon Sep 17 00:00:00 2001 From: Pala Date: Fri, 24 Mar 2017 22:25:46 +0100 Subject: WINDOWS: Change location where screenshot are saved This fixes bug #9701: WINDOWS: Flow of taking screenshots on Windows is broken --- backends/platform/sdl/sdl.cpp | 5 +++++ backends/platform/sdl/sdl.h | 3 +++ backends/platform/sdl/win32/win32.cpp | 20 ++++++++++++++++++++ backends/platform/sdl/win32/win32.h | 2 ++ 4 files changed, 30 insertions(+) (limited to 'backends/platform') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 1c5a7c2cbf..09268f3a53 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -571,6 +571,11 @@ Common::SaveFileManager *OSystem_SDL::getSavefileManager() { #endif } +//Not specified in base class +Common::String OSystem_SDL::getScreenshotsPath() { + return Common::String(); +} + #ifdef USE_OPENGL const OSystem::GraphicsMode *OSystem_SDL::getSupportedGraphicsModes() const { diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 17b4e9b001..bc4292be0b 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -84,6 +84,9 @@ public: virtual Common::TimerManager *getTimerManager(); virtual Common::SaveFileManager *getSavefileManager(); + //Screenshots + virtual Common::String getScreenshotsPath(); + protected: bool _inited; bool _initedSDL; diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index 99c71a49e0..02ad225749 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -29,6 +29,7 @@ #include #undef ARRAYSIZE // winnt.h defines ARRAYSIZE, but we want our own one... #include +#include #include "common/scummsys.h" #include "common/config-manager.h" @@ -145,6 +146,25 @@ bool OSystem_Win32::openUrl(const Common::String &url) { return true; } +Common::String OSystem_Win32::getScreenshotsPath() { + char picturesPath[MAXPATHLEN]; + + // Use the My Pictures folder. + if (SHGetFolderPath(NULL, CSIDL_MYPICTURES, NULL, SHGFP_TYPE_CURRENT, picturesPath) != S_OK) + error("Unable to access My Pictures directory"); + + Common::String screenshotsPath = Common::String(picturesPath) + "\\ScummVM Screenshots\\"; + + // If the directory already exists (as it should in most cases), + // we don't want to fail, but we need to stop on other errors (such as ERROR_PATH_NOT_FOUND) + if (!CreateDirectory(screenshotsPath.c_str(), NULL)) { + if (GetLastError() != ERROR_ALREADY_EXISTS) + error("Cannot create ScummVM Screenshots folder"); + } + + return screenshotsPath; +} + Common::String OSystem_Win32::getDefaultConfigFileName() { char configFile[MAXPATHLEN]; diff --git a/backends/platform/sdl/win32/win32.h b/backends/platform/sdl/win32/win32.h index 636ebae88f..6764a7fe49 100644 --- a/backends/platform/sdl/win32/win32.h +++ b/backends/platform/sdl/win32/win32.h @@ -38,6 +38,8 @@ public: virtual bool openUrl(const Common::String &url); + virtual Common::String getScreenshotsPath(); + protected: /** * The path of the currently open log file, if any. -- cgit v1.2.3