summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2014-07-22 02:13:38 +0000
committerSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2014-07-22 02:13:38 +0000
commitd801c00dc645ff2745e06958f0a0971700296424 (patch)
treeada4dbfd4cf26322953130ed975be72e7a25b789
parentaf3fc7e2a047dff37690d041489db41e8cf02eee (diff)
downloadpcsxr-d801c00dc645ff2745e06958f0a0971700296424.tar.gz
OS X: Generate a thumbnail image for a memory card file.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@91028 e17a0e51-4ae3-4d35-97c3-1a29b211df97
-rw-r--r--macosx/Pcsxr-QL/GenerateThumbnailForURL.m65
-rw-r--r--macosx/Pcsxr.xcodeproj/project.pbxproj6
-rw-r--r--macosx/Pcsxr.xcodeproj/xcshareddata/xcschemes/Pcsxr-QL.xcscheme6
-rw-r--r--macosx/Psx-Memcard/en.lproj/InfoPlist.strings1
4 files changed, 74 insertions, 4 deletions
diff --git a/macosx/Pcsxr-QL/GenerateThumbnailForURL.m b/macosx/Pcsxr-QL/GenerateThumbnailForURL.m
index 2e84f4a6..3a61afb9 100644
--- a/macosx/Pcsxr-QL/GenerateThumbnailForURL.m
+++ b/macosx/Pcsxr-QL/GenerateThumbnailForURL.m
@@ -13,6 +13,8 @@
This function's job is to create thumbnail for designated file as fast as possible
----------------------------------------------------------------------------- */
+#define ImageDivider 16
+
static OSStatus GenerateThumbnailForFreeze(void *thisInterface, QLThumbnailRequestRef preview, NSURL *url, NSDictionary *options, CGSize maxSize);
static OSStatus GenerateThumbnailForMemCard(void *thisInterface, QLThumbnailRequestRef preview, NSURL *url, NSDictionary *options, CGSize maxSize);
@@ -92,8 +94,69 @@ OSStatus GenerateThumbnailForFreeze(void *thisInterface, QLThumbnailRequestRef t
#endif
}
+static NSImage *MemoryImageAtIndex(NSArray *memArray, NSInteger my)
+{
+ NSInteger i = 0;
+ for (PcsxrMemoryObject *obj in memArray) {
+ NSIndexSet *idxSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(i, obj.blockSize)];
+ if ([idxSet containsIndex:my]) {
+ return obj.firstMemImage;
+ }
+ i += obj.blockSize;
+ }
+
+ return nil;
+}
+
OSStatus GenerateThumbnailForMemCard(void *thisInterface, QLThumbnailRequestRef thumbnail, NSURL *url, NSDictionary *options, CGSize maxSize)
{
- //NSArray *memCards = CreateArrayByEnumeratingMemoryCardAtURL(url);
+ NSArray *memCards = CreateArrayByEnumeratingMemoryCardAtURL(url);
+ if (!memCards) {
+ return noErr;
+ }
+
+ NSBundle *Bundle;
+ {
+ CFBundleRef cfbundle = QLThumbnailRequestGetGeneratorBundle(thumbnail);
+ NSURL *bundURL = CFBridgingRelease(CFBundleCopyBundleURL(cfbundle));
+ Bundle = [[NSBundle alloc] initWithURL:bundURL];
+ }
+
+ NSRect imageRect = NSMakeRect(0, 0, ImageDivider, ImageDivider);
+ NSImage *blankImage = [[NSImage alloc] initWithSize:imageRect.size];
+ [blankImage lockFocus];
+ [[NSColor blackColor] set];
+ [NSBezierPath fillRect:imageRect];
+ [blankImage unlockFocus];
+
+ NSImage *memImages = [[NSImage alloc] initWithSize:NSMakeSize((4 * ImageDivider), (4 * ImageDivider))];
+
+ NSInteger allMems = 0;
+ for (PcsxrMemoryObject *obj in memCards) {
+ allMems += obj.blockSize;
+ }
+ [memImages lockFocus];
+ [[NSColor clearColor] set];
+ [NSBezierPath fillRect:NSMakeRect(0, 0, (4 * ImageDivider), (4 * ImageDivider))];
+ for (int i = 1; i < 16; i++) {
+ NSInteger x = (i % 4) * ImageDivider, y = (3 * ImageDivider) - ((i / 4) * ImageDivider);
+ NSImage *curImage;
+ if (i < allMems) {
+ curImage = MemoryImageAtIndex(memCards, i - 1);
+ } else {
+ curImage = blankImage;
+ }
+ [curImage drawInRect:NSMakeRect(x, y, ImageDivider, ImageDivider) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
+ }
+ NSURL *psxMemURL = [Bundle URLForResource:@"pcsxrmemcard" withExtension:@"icns"];
+ NSImage *psxMemIcon = [[NSImage alloc] initByReferencingURL:psxMemURL];
+ psxMemIcon.size = NSMakeSize(ImageDivider, ImageDivider);
+ [psxMemIcon drawInRect:NSMakeRect(0, 3 * ImageDivider, ImageDivider, ImageDivider) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
+
+ [memImages unlockFocus];
+
+ NSData *data = [memImages TIFFRepresentation];
+ QLThumbnailRequestSetImageWithData(thumbnail, (__bridge CFDataRef)(data), NULL);
+
return noErr;
}
diff --git a/macosx/Pcsxr.xcodeproj/project.pbxproj b/macosx/Pcsxr.xcodeproj/project.pbxproj
index 3e80b2b9..820f2555 100644
--- a/macosx/Pcsxr.xcodeproj/project.pbxproj
+++ b/macosx/Pcsxr.xcodeproj/project.pbxproj
@@ -204,6 +204,7 @@
559366D012B694DF004ACC1E /* ix86_sse.c in Sources */ = {isa = PBXBuildFile; fileRef = 559366C812B694DF004ACC1E /* ix86_sse.c */; };
55A90220147D7C380037E18F /* PcsxrMemCardController.m in Sources */ = {isa = PBXBuildFile; fileRef = 55A9021F147D7C380037E18F /* PcsxrMemCardController.m */; };
55A90229147D89380037E18F /* PcsxrMemoryObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 55A90228147D89380037E18F /* PcsxrMemoryObject.m */; };
+ 55AF2A69197DF6A700EB2560 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5557769917EBE7D60019D008 /* Media.xcassets */; };
55B13FBD18C4F9CC00ACD9AC /* SPUPluginController.h in Headers */ = {isa = PBXBuildFile; fileRef = 551A755317868BEC0052D185 /* SPUPluginController.h */; };
55B13FBE18C4F9D800ACD9AC /* NamedSlider.h in Headers */ = {isa = PBXBuildFile; fileRef = 551A754F17868BEC0052D185 /* NamedSlider.h */; };
55BBA693149455E1003B2CEC /* PcsxrMemCardHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBA692149455E1003B2CEC /* PcsxrMemCardHandler.m */; };
@@ -1165,10 +1166,10 @@
550E343E18E6293D00A1AD21 /* Supporting Files */ = {
isa = PBXGroup;
children = (
- 550E343F18E6293D00A1AD21 /* Pcsxr-QL-Info.plist */,
+ 556C37B1197DBFD1001A4265 /* template.html */,
550E344018E6293D00A1AD21 /* InfoPlist.strings */,
+ 550E343F18E6293D00A1AD21 /* Pcsxr-QL-Info.plist */,
550E344918E6293D00A1AD21 /* Pcsxr-QL-Prefix.pch */,
- 556C37B1197DBFD1001A4265 /* template.html */,
);
name = "Supporting Files";
sourceTree = "<group>";
@@ -2111,6 +2112,7 @@
buildActionMask = 2147483647;
files = (
550E344218E6293D00A1AD21 /* InfoPlist.strings in Resources */,
+ 55AF2A69197DF6A700EB2560 /* Media.xcassets in Resources */,
556C37B2197DBFD1001A4265 /* template.html in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
diff --git a/macosx/Pcsxr.xcodeproj/xcshareddata/xcschemes/Pcsxr-QL.xcscheme b/macosx/Pcsxr.xcodeproj/xcshareddata/xcschemes/Pcsxr-QL.xcscheme
index 39e97aed..015cad2a 100644
--- a/macosx/Pcsxr.xcodeproj/xcshareddata/xcschemes/Pcsxr-QL.xcscheme
+++ b/macosx/Pcsxr.xcodeproj/xcshareddata/xcschemes/Pcsxr-QL.xcscheme
@@ -59,10 +59,14 @@
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
- argument = "-p /Users/cwbetts/Library/&quot;Application Support&quot;/Pcsxr/&quot;Memory Cards&quot;/&quot;descent max.mcr&quot;"
+ argument = "-t /Users/cwbetts/Library/&quot;Application Support&quot;/Pcsxr/&quot;Memory Cards&quot;/&quot;descent max.mcr&quot;"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
+ argument = "-p /Users/cwbetts/Library/&quot;Application Support&quot;/Pcsxr/&quot;Memory Cards&quot;/&quot;descent max.mcr&quot;"
+ isEnabled = "NO">
+ </CommandLineArgument>
+ <CommandLineArgument
argument = "-p /Users/cwbetts/Library/Application\ Support/Pcsxr/Save\ States/SCUS94555-000.pcsxrstate"
isEnabled = "NO">
</CommandLineArgument>
diff --git a/macosx/Psx-Memcard/en.lproj/InfoPlist.strings b/macosx/Psx-Memcard/en.lproj/InfoPlist.strings
index 477b28ff..1de7259d 100644
--- a/macosx/Psx-Memcard/en.lproj/InfoPlist.strings
+++ b/macosx/Psx-Memcard/en.lproj/InfoPlist.strings
@@ -1,2 +1,3 @@
/* Localized versions of Info.plist keys */
+NSHumanReadableCopyright = "Copyright © 2014 Pcsx Reloaded team";