From 36f2f623051751cbfcb529d8ebb3a92c20747bab Mon Sep 17 00:00:00 2001 From: "SND\\MaddTheSane_cp" Date: Mon, 12 Dec 2011 03:32:21 +0000 Subject: Renaming com.codeplex.pcsxr.mdfdisc to com.alcohol-soft.mdfdisc, since the format appears to have originated from the Alcohol 120% software. Added support for bin/cue by opening the cue file, then getting the .bin file name from the .cue. Added handling of freeze states and disc images. git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@73179 e17a0e51-4ae3-4d35-97c3-1a29b211df97 --- macosx/Info.plist | 29 +++++++++++++++++++++++++---- macosx/PcsxrController.m | 38 +++++++++++++++++++++++++++++--------- macosx/PcsxrDiscHandler.h | 14 ++++++++++++++ macosx/PcsxrDiscHandler.m | 23 +++++++++++++++++++++++ macosx/PcsxrFreezeStateHandler.h | 14 ++++++++++++++ macosx/PcsxrFreezeStateHandler.m | 26 ++++++++++++++++++++++++++ macosx/PcsxrMemCardHandler.m | 9 +++------ macosx/PcsxrPluginHandler.m | 9 +++------ 8 files changed, 137 insertions(+), 25 deletions(-) create mode 100644 macosx/PcsxrDiscHandler.h create mode 100644 macosx/PcsxrDiscHandler.m create mode 100644 macosx/PcsxrFreezeStateHandler.h create mode 100644 macosx/PcsxrFreezeStateHandler.m diff --git a/macosx/Info.plist b/macosx/Info.plist index c7a63a03..faeab05d 100644 --- a/macosx/Info.plist +++ b/macosx/Info.plist @@ -110,8 +110,9 @@ Viewer LSItemContentTypes - com.codeplex.pcsxr.mdfdisc + com.alcohol-soft.mdfdisc com.apple.disk-image-ndif + com.codeplex.pcsxr.cuefile public.iso-image @@ -147,8 +148,25 @@ PCSXR NSPrincipalClass NSApplication - UTExportedTypeDeclarations + UTImportedTypeDeclarations + + UTTypeConformsTo + + + + UTTypeIdentifier + com.codeplex.pcsxr.cuefile + UTTypeDescription + bin/cue Disc Image + UTTypeTagSpecification + + public.filename-extension + + cue + + + UTTypeConformsTo @@ -157,9 +175,9 @@ public.data UTTypeDescription - PlayStation Disc + Alcohol Disc Image UTTypeIdentifier - com.codeplex.pcsxr.mdfdisc + com.alcohol-soft.mdfdisc UTTypeTagSpecification public.filename-extension @@ -168,6 +186,9 @@ + + UTExportedTypeDeclarations + UTTypeConformsTo diff --git a/macosx/PcsxrController.m b/macosx/PcsxrController.m index d284354d..5a635f2f 100644 --- a/macosx/PcsxrController.m +++ b/macosx/PcsxrController.m @@ -4,6 +4,8 @@ #import "EmuThread.h" #import "PcsxrMemCardHandler.h" #import "PcsxrPluginHandler.h" +#import "PcsxrDiscHandler.h" +#import "PcsxrFreezeStateHandler.h" #include "psxcommon.h" #include "plugins.h" #include "misc.h" @@ -14,6 +16,20 @@ NSDictionary *prefByteKeys; NSMutableArray *biosList; NSString *saveStatePath; +static NSString *HandleBinCue(NSString *toHandle) +{ + NSURL *tempURL = [[NSURL alloc] initWithString:toHandle]; + NSString *extension = [tempURL pathExtension]; + NSString *newName = toHandle; + if ([extension caseInsensitiveCompare:@"cue"] == NSOrderedSame) { + NSURL *temp1 = [tempURL URLByDeletingPathExtension]; + //TODO: handle case-sensitive filesystems + NSURL *temp2 = [tempURL URLByAppendingPathExtension:@"bin"]; + newName = [temp2 path]; + } + return newName; +} + @implementation PcsxrController - (IBAction)ejectCD:(id)sender @@ -35,12 +51,12 @@ NSString *saveStatePath; [openDlg setCanChooseFiles:YES]; [openDlg setCanChooseDirectories:NO]; - [openDlg setAllowedFileTypes:[NSArray arrayWithObjects:@"com.codeplex.pcsxr.mdfdisc", @"bin", @"com.apple.disk-image-ndif", @"public.iso-image", nil]]; + [openDlg setAllowedFileTypes:[NSArray arrayWithObjects:@"com.alcohol-soft.mdfdisc", @"com.codeplex.pcsxr.cuefile", @"com.apple.disk-image-ndif", @"public.iso-image", nil]]; if ([openDlg runModal] == NSFileHandlingPanelOKButton) { NSArray* files = [openDlg URLs]; SetCdOpenCaseTime(time(NULL) + 2); - SetIsoFile((const char *)[[[files objectAtIndex:0] path] fileSystemRepresentation]); + SetIsoFile((const char *)[HandleBinCue([[files objectAtIndex:0] path]) fileSystemRepresentation]); } [openDlg release]; } else { @@ -115,11 +131,11 @@ NSString *saveStatePath; [openDlg setCanChooseFiles:YES]; [openDlg setCanChooseDirectories:NO]; - [openDlg setAllowedFileTypes:[NSArray arrayWithObjects:@"com.codeplex.pcsxr.mdfdisc", @"bin", @"com.apple.disk-image-ndif", @"public.iso-image", nil]]; + [openDlg setAllowedFileTypes:[NSArray arrayWithObjects:@"com.alcohol-soft.mdfdisc", @"com.codeplex.pcsxr.cuefile", @"com.apple.disk-image-ndif", @"public.iso-image", nil]]; if ([openDlg runModal] == NSFileHandlingPanelOKButton) { NSArray* urls = [openDlg URLs]; - SetIsoFile((const char *)[[[urls objectAtIndex:0] path] fileSystemRepresentation]); + SetIsoFile((const char *)[HandleBinCue([[urls objectAtIndex:0] path]) fileSystemRepresentation]); [EmuThread run]; } [openDlg release]; @@ -463,11 +479,15 @@ NSString *saveStatePath; [hand release]; return isHandled; } else if(UTTypeEqual((CFStringRef)@"com.codeplex.pcsxr.freeze", (CFStringRef)utiFile)) { - //TODO: handle freeze states - return NO; - } else if(UTTypeEqual((CFStringRef)@"com.codeplex.pcsxr.mdfdisc", (CFStringRef)utiFile) || UTTypeEqual((CFStringRef)@"com.apple.disk-image-ndif", (CFStringRef)utiFile) || UTTypeEqual((CFStringRef)@"public.iso-image", (CFStringRef)utiFile)) { - //TODO: handle ISOs and family - return NO; + PcsxrFreezeStateHandler *hand = [[PcsxrFreezeStateHandler alloc] init]; + BOOL isHandled = [hand handleFile:filename]; + [hand release]; + return isHandled; + } else if(UTTypeEqual(CFSTR("com.alcohol-soft.mdfdisc"), (CFStringRef)utiFile) || UTTypeEqual(CFSTR("com.apple.disk-image-ndif"), (CFStringRef)utiFile) || UTTypeEqual(CFSTR("public.iso-image"), (CFStringRef)utiFile) || UTTypeEqual(CFSTR("com.codeplex.pcsxr.cuefile"), (CFStringRef)utiFile)) { + PcsxrDiscHandler *hand = [[PcsxrDiscHandler alloc] init]; + BOOL isHandled = [hand handleFile:HandleBinCue(filename)]; + [hand release]; + return isHandled; } else { return NO; } diff --git a/macosx/PcsxrDiscHandler.h b/macosx/PcsxrDiscHandler.h new file mode 100644 index 00000000..933d7799 --- /dev/null +++ b/macosx/PcsxrDiscHandler.h @@ -0,0 +1,14 @@ +// +// PcsxrDiscHandler.h +// Pcsxr +// +// Created by Charles Betts on 12/11/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import +#import "PcsxrFileHandle.h" + +@interface PcsxrDiscHandler : NSObject + +@end diff --git a/macosx/PcsxrDiscHandler.m b/macosx/PcsxrDiscHandler.m new file mode 100644 index 00000000..16a9582f --- /dev/null +++ b/macosx/PcsxrDiscHandler.m @@ -0,0 +1,23 @@ +// +// PcsxrDiscHandler.m +// Pcsxr +// +// Created by Charles Betts on 12/11/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import "PcsxrDiscHandler.h" +#import "EmuThread.h" +#include "psxcommon.h" +#include "plugins.h" + +@implementation PcsxrDiscHandler + +- (BOOL)handleFile:(NSString *)theFile +{ + SetIsoFile([theFile fileSystemRepresentation]); + [EmuThread run]; + return YES; +} + +@end diff --git a/macosx/PcsxrFreezeStateHandler.h b/macosx/PcsxrFreezeStateHandler.h new file mode 100644 index 00000000..ca50f533 --- /dev/null +++ b/macosx/PcsxrFreezeStateHandler.h @@ -0,0 +1,14 @@ +// +// PcsxrFreezeStateHandler.h +// Pcsxr +// +// Created by Charles Betts on 12/11/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import +#import "PcsxrFileHandle.h" + +@interface PcsxrFreezeStateHandler : NSObject + +@end diff --git a/macosx/PcsxrFreezeStateHandler.m b/macosx/PcsxrFreezeStateHandler.m new file mode 100644 index 00000000..9bb6659a --- /dev/null +++ b/macosx/PcsxrFreezeStateHandler.m @@ -0,0 +1,26 @@ +// +// PcsxrFreezeStateHandler.m +// Pcsxr +// +// Created by Charles Betts on 12/11/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import "PcsxrFreezeStateHandler.h" +#import "EmuThread.h" +#include "misc.h" + +@implementation PcsxrFreezeStateHandler + +- (BOOL)handleFile:(NSString *)theFile +{ + if (CheckState([theFile fileSystemRepresentation]) != 0) { + return NO; + } + if ([EmuThread active]) { + [EmuThread run]; + } + [EmuThread defrostAt:theFile]; +} + +@end diff --git a/macosx/PcsxrMemCardHandler.m b/macosx/PcsxrMemCardHandler.m index 4cfcb513..2d4e1080 100644 --- a/macosx/PcsxrMemCardHandler.m +++ b/macosx/PcsxrMemCardHandler.m @@ -15,17 +15,15 @@ { self = [super initWithWindow:window]; if (self) { - // Initialization code here. - } + memChosen = 0; + } return self; } - (id)init { - if (self = [super initWithWindowNibName:@"PcsxrMemCardDocument"]) { - memChosen = 0; - } + self = [super initWithWindowNibName:@"PcsxrMemCardDocument"]; return self; } @@ -53,7 +51,6 @@ [NSApp runModalForWindow:[self window]]; - [NSApp endSheet:[self window]]; [[self window] orderOut:self]; if (memChosen != 0) { diff --git a/macosx/PcsxrPluginHandler.m b/macosx/PcsxrPluginHandler.m index 84919c56..7ab00161 100644 --- a/macosx/PcsxrPluginHandler.m +++ b/macosx/PcsxrPluginHandler.m @@ -14,7 +14,7 @@ { self = [super initWithWindow:window]; if (self) { - // Initialization code here. + moveOK = NO; } return self; @@ -22,9 +22,7 @@ - (id)init { - if (self = [super initWithWindowNibName:@"AddPluginSheet"]) { - moveOK = NO; - } + self = [super initWithWindowNibName:@"AddPluginSheet"]; return self; } @@ -53,8 +51,7 @@ [pluginName setObjectValue:[[NSURL fileURLWithPath:theFile] lastPathComponent]]; [NSApp runModalForWindow:[self window]]; - // Sheet is up here. - [NSApp endSheet:[self window]]; + [[self window] orderOut:self]; if (moveOK == YES) { NSFileWrapper *wrapper = [[NSFileWrapper alloc] initWithPath:theFile]; -- cgit v1.2.3