diff options
author | Thierry Crozat | 2017-04-24 00:30:28 +0100 |
---|---|---|
committer | Thierry Crozat | 2017-04-24 01:06:50 +0100 |
commit | 11dd33bb73c998116c2b862389b616fe9249579b (patch) | |
tree | 0b0b05bbd0b65828565bb29eb75de089d7004ab3 /backends/platform/sdl | |
parent | 438f23f2723b384098828fde3cf2b6b20fca9bc7 (diff) | |
download | scummvm-rg350-11dd33bb73c998116c2b862389b616fe9249579b.tar.gz scummvm-rg350-11dd33bb73c998116c2b862389b616fe9249579b.tar.bz2 scummvm-rg350-11dd33bb73c998116c2b862389b616fe9249579b.zip |
MACOSX: Create screenshot on Desktop
This is consistent with the OS shortcut (Crtl+Shift+3) to take a
screenshot.
Diffstat (limited to 'backends/platform/sdl')
-rw-r--r-- | backends/platform/sdl/macosx/macosx.cpp | 7 | ||||
-rw-r--r-- | backends/platform/sdl/macosx/macosx.h | 3 | ||||
-rw-r--r-- | backends/platform/sdl/macosx/macosx_wrapper.h | 1 | ||||
-rw-r--r-- | backends/platform/sdl/macosx/macosx_wrapper.mm | 16 |
4 files changed, 27 insertions, 0 deletions
diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index e90d459e67..500e438ec0 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -187,6 +187,13 @@ Common::String OSystem_MacOSX::getSystemLanguage() const { #endif // USE_DETECTLANG } +Common::String OSystem_MacOSX::getScreenshotsPath() { + Common::String path = getDesktopPathMacOSX(); + if (!path.empty() && !path.hasSuffix("/")) + path += "/"; + return path; +} + AudioCDManager *OSystem_MacOSX::createAudioCDManager() { return createMacOSXAudioCDManager(); } diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h index 72bb4a4787..ba07364681 100644 --- a/backends/platform/sdl/macosx/macosx.h +++ b/backends/platform/sdl/macosx/macosx.h @@ -44,6 +44,9 @@ public: virtual void initBackend(); virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); + //Screenshots + virtual Common::String getScreenshotsPath(); + protected: // Override createAudioCDManager() to get our Mac-specific // version. diff --git a/backends/platform/sdl/macosx/macosx_wrapper.h b/backends/platform/sdl/macosx/macosx_wrapper.h index 3b346fc486..84f0c1b2ba 100644 --- a/backends/platform/sdl/macosx/macosx_wrapper.h +++ b/backends/platform/sdl/macosx/macosx_wrapper.h @@ -27,5 +27,6 @@ bool hasTextInClipboardMacOSX(); Common::String getTextFromClipboardMacOSX(); +Common::String getDesktopPathMacOSX(); #endif diff --git a/backends/platform/sdl/macosx/macosx_wrapper.mm b/backends/platform/sdl/macosx/macosx_wrapper.mm index 8ec9eac5ac..5de3eb6bac 100644 --- a/backends/platform/sdl/macosx/macosx_wrapper.mm +++ b/backends/platform/sdl/macosx/macosx_wrapper.mm @@ -27,6 +27,8 @@ #include <AppKit/NSPasteboard.h> #include <Foundation/NSArray.h> +#include <Foundation/NSPathUtilities.h> +#include <AvailabilityMacros.h> bool hasTextInClipboardMacOSX() { return [[NSPasteboard generalPasteboard] availableTypeFromArray:[NSArray arrayWithObject:NSStringPboardType]] != nil; @@ -46,3 +48,17 @@ Common::String getTextFromClipboardMacOSX() { // we should use NSISOLatin1StringEncoding?). return Common::String([str cStringUsingEncoding:NSASCIIStringEncoding]); } + +Common::String getDesktopPathMacOSX() { + // The recommanded method is to use NSFileManager. + // NSUrl *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDesktopDirectory inDomains:NSUserDomainMask] firstObject]; + // However it is only available in OS X 10.6+. So use NSSearchPathForDirectoriesInDomains instead (available since OS X 10.0) + // [NSArray firstObject] is also only available in OS X 10.6+. So we need to use [NSArray count] and [NSArray objectAtIndex:] + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDesktopDirectory, NSUserDomainMask, NO); + if ([paths count] == 0) + return Common::String(); + NSString *path = [paths objectAtIndex:0]; + if (path == nil) + return Common::String(); + return Common::String([path cStringUsingEncoding:NSASCIIStringEncoding]); +}
\ No newline at end of file |