aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
Diffstat (limited to 'backends')
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.cpp12
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp16
-rw-r--r--backends/platform/sdl/sdl.cpp5
-rw-r--r--backends/platform/sdl/sdl.h3
-rw-r--r--backends/platform/sdl/win32/win32.cpp20
-rw-r--r--backends/platform/sdl/win32/win32.h2
6 files changed, 50 insertions, 8 deletions
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 860173a3c6..9b25f43f39 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -22,6 +22,7 @@
#include "backends/graphics/openglsdl/openglsdl-graphics.h"
#include "backends/events/sdl/sdl-events.h"
+#include "backends/platform/sdl/sdl.h"
#include "common/textconsole.h"
#include "common/config-manager.h"
@@ -620,25 +621,30 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
return true;
}
+ // Alt-s creates a screenshot
if (event.kbd.keycode == Common::KEYCODE_s) {
- // Alt-s creates a screenshot
Common::String filename;
+ Common::String screenshotsPath = ((OSystem_SDL *)g_system)->getScreenshotsPath();
+
for (int n = 0;; n++) {
SDL_RWops *file;
filename = Common::String::format("scummvm%05d.bmp", n);
- file = SDL_RWFromFile(filename.c_str(), "r");
+
+ file = SDL_RWFromFile((screenshotsPath + filename).c_str(), "r");
+
if (!file)
break;
SDL_RWclose(file);
}
- saveScreenshot(filename.c_str());
+ saveScreenshot((screenshotsPath + filename).c_str());
debug("Saved screenshot '%s'", filename.c_str());
return true;
}
+
} else if (event.kbd.hasFlags(Common::KBD_CTRL | Common::KBD_ALT)) {
if ( event.kbd.keycode == Common::KEYCODE_PLUS || event.kbd.keycode == Common::KEYCODE_MINUS
|| event.kbd.keycode == Common::KEYCODE_KP_PLUS || event.kbd.keycode == Common::KEYCODE_KP_MINUS) {
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 690e9a360e..047941cb43 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -2524,21 +2524,27 @@ bool SurfaceSdlGraphicsManager::notifyEvent(const Common::Event &event) {
// Alt-S: Create a screenshot
if (event.kbd.hasFlags(Common::KBD_ALT) && event.kbd.keycode == 's') {
- char filename[20];
+ Common::String filename;
+
+ Common::String screenshotsPath = ((OSystem_SDL *)g_system)->getScreenshotsPath();
for (int n = 0;; n++) {
SDL_RWops *file;
- sprintf(filename, "scummvm%05d.bmp", n);
- file = SDL_RWFromFile(filename, "r");
+ filename = Common::String::format("scummvm%05d.bmp", n);
+
+ file = SDL_RWFromFile((screenshotsPath + filename).c_str(), "r");
+
if (!file)
break;
SDL_RWclose(file);
}
- if (saveScreenshot(filename))
- debug("Saved screenshot '%s'", filename);
+
+ if (saveScreenshot((screenshotsPath + filename).c_str()))
+ debug("Saved screenshot '%s'", filename.c_str());
else
warning("Could not save screenshot");
+
return true;
}
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 <windows.h>
#undef ARRAYSIZE // winnt.h defines ARRAYSIZE, but we want our own one...
#include <shellapi.h>
+#include <ShlObj.h>
#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.