summaryrefslogtreecommitdiff
path: root/macosx/ConfigurationController.m
diff options
context:
space:
mode:
authorSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-06-26 00:53:22 +0000
committerSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-06-26 00:53:22 +0000
commit6349404da5984e6785574c96db3eb3a08a515b37 (patch)
tree321d3f7f201b3f1f79190744c1387dff95e01d06 /macosx/ConfigurationController.m
parentf51a15e84f8ec88c183ada3fab62dd4786ab9977 (diff)
downloadpcsxr-6349404da5984e6785574c96db3eb3a08a515b37.tar.gz
Even more work on the memory card management.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@85558 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/ConfigurationController.m')
-rwxr-xr-xmacosx/ConfigurationController.m93
1 files changed, 59 insertions, 34 deletions
diff --git a/macosx/ConfigurationController.m b/macosx/ConfigurationController.m
index 4490db87..270abc97 100755
--- a/macosx/ConfigurationController.m
+++ b/macosx/ConfigurationController.m
@@ -8,21 +8,30 @@
#include "plugins.h"
#import "ARCBridge.h"
-NSString *memChangeNotifier = @"PcsxrMemoryCardDidChangeNotifier";
+NSString *const memChangeNotifier = @"PcsxrMemoryCardDidChangeNotifier";
+NSString *const memCardChangeNumberKey = @"PcsxrMemoryCardThatChangedKey";
@implementation ConfigurationController
-+ (void)setMemoryCard:(int)theCard toPath:(NSString *)theFile
++ (void)setMemoryCard:(int)theCard toURL:(NSURL *)theURL;
{
if (theCard == 1) {
- [[NSUserDefaults standardUserDefaults] setObject:theFile forKey:@"Mcd1"];
- strlcpy(Config.Mcd1, [theFile fileSystemRepresentation], MAXPATHLEN );
+ [[NSUserDefaults standardUserDefaults] setURL:theURL forKey:@"Mcd1"];
+ strlcpy(Config.Mcd1, [[theURL path] fileSystemRepresentation], MAXPATHLEN );
} else {
- [[NSUserDefaults standardUserDefaults] setObject:theFile forKey:@"Mcd2"];
- strlcpy(Config.Mcd2, [theFile fileSystemRepresentation], MAXPATHLEN );
+ [[NSUserDefaults standardUserDefaults] setURL:theURL forKey:@"Mcd2"];
+ strlcpy(Config.Mcd2, [[theURL path] fileSystemRepresentation], MAXPATHLEN );
}
- [[NSNotificationCenter defaultCenter] postNotificationName:memChangeNotifier object:nil];
+ NSDictionary *userDict = [NSDictionary dictionaryWithObject:@(theCard) forKey:memCardChangeNumberKey];
+
+ [[NSNotificationCenter defaultCenter] postNotificationName:memChangeNotifier object:nil userInfo:userDict];
+
+}
+
++ (void)setMemoryCard:(int)theCard toPath:(NSString *)theFile
+{
+ [self setMemoryCard:theCard toURL:[NSURL fileURLWithPath:theFile isDirectory:NO]];
}
- (IBAction)setCheckbox:(id)sender
@@ -53,63 +62,72 @@ NSString *memChangeNotifier = @"PcsxrMemoryCardDidChangeNotifier";
- (IBAction)mcdChangeClicked:(id)sender
{
- int tag = [sender tag];
+ [ConfigurationController mcdChangeClicked:sender];
+}
+
+- (IBAction)mcdNewClicked:(id)sender
+{
+ [ConfigurationController mcdNewClicked:sender];
+}
+
++ (void)mcdChangeClicked:(id)sender
+{
+ NSInteger tag = [sender tag];
char *mcd;
- NSTextField *label;
NSOpenPanel *openDlg = RETAINOBJ([NSOpenPanel openPanel]);
NSString *path;
-
- if (tag == 1) { mcd = Config.Mcd1; label = mcd1Label; }
- else { mcd = Config.Mcd2; label = mcd2Label; }
-
+
+ if (tag == 1) { mcd = Config.Mcd1; }
+ else { mcd = Config.Mcd2; }
+
[openDlg setCanChooseFiles:YES];
[openDlg setCanChooseDirectories:NO];
[openDlg setAllowedFileTypes:[PcsxrMemCardHandler supportedUTIs]];
-
+
path = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:mcd length:strlen(mcd)];
[openDlg setDirectoryURL:[NSURL fileURLWithPath:[path stringByDeletingLastPathComponent]]];
[openDlg setNameFieldStringValue:[path lastPathComponent]];
-
+
if ([openDlg runModal] == NSFileHandlingPanelOKButton) {
NSArray* urls = [openDlg URLs];
- NSString *mcdPath = [[urls objectAtIndex:0] path];
+ NSURL *mcdURL = [urls objectAtIndex:0];
- [ConfigurationController setMemoryCard:tag toPath:mcdPath];
+ [ConfigurationController setMemoryCard:tag toURL:mcdURL];
}
- RELEASEOBJ(openDlg);
+ RELEASEOBJ(openDlg);
}
-- (IBAction)mcdNewClicked:(id)sender
++ (void)mcdNewClicked:(id)sender
{
- int tag = [sender tag];
+ NSInteger tag = [sender tag];
char *mcd;
- NSTextField *label;
NSSavePanel *openDlg = RETAINOBJ([NSSavePanel savePanel]);
NSString *path;
-
- if (tag == 1) { mcd = Config.Mcd1; label = mcd1Label; }
- else { mcd = Config.Mcd2; label = mcd2Label; }
-
+
+ if (tag == 1) { mcd = Config.Mcd1; }
+ else { mcd = Config.Mcd2; }
+
path = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:mcd length:strlen(mcd)];
-
+
[openDlg setDirectoryURL:[NSURL fileURLWithPath:[path stringByDeletingLastPathComponent]]];
[openDlg setNameFieldStringValue:@"New Memory Card File.mcr"];
[openDlg setAllowedFileTypes:[PcsxrMemCardHandler supportedUTIs]];
if ([openDlg runModal] == NSFileHandlingPanelOKButton) {
- NSString *mcdPath = [[openDlg URL] path];
+ NSURL *mcdURL = [openDlg URL];
//Workaround/kludge to make sure we create a memory card before posting a notification
- strlcpy(mcd, [mcdPath fileSystemRepresentation], MAXPATHLEN);
+ strlcpy(mcd, [[mcdURL path] fileSystemRepresentation], MAXPATHLEN);
CreateMcd(mcd);
-
- [ConfigurationController setMemoryCard:tag toPath:mcdPath];
+
+ [ConfigurationController setMemoryCard:tag toURL:mcdURL];
}
RELEASEOBJ(openDlg);
}
+
- (IBAction)setVideoType:(id)sender
{
int tag = [[sender selectedItem] tag];
@@ -136,10 +154,17 @@ NSString *memChangeNotifier = @"PcsxrMemoryCardDidChangeNotifier";
- (void)memoryCardDidChangeNotification:(NSNotification *)aNote
{
- NSString *path = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:Config.Mcd1 length:strlen(Config.Mcd1)];
- [mcd1Label setTitleWithMnemonic:path];
- path = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:Config.Mcd2 length:strlen(Config.Mcd2)];
- [mcd2Label setTitleWithMnemonic:path];
+ NSNumber *aNumber = [[aNote userInfo] objectForKey:memCardChangeNumberKey];
+ int iNum = [aNumber intValue];
+
+ if (iNum & 1) {
+ NSURL *path = [[NSUserDefaults standardUserDefaults] URLForKey:@"Mcd1"];
+ [mcd1Label setTitleWithMnemonic:[path path]];
+ }
+ if (iNum & 2) {
+ NSURL *path = [[NSUserDefaults standardUserDefaults] URLForKey:@"Mcd2"];
+ [mcd2Label setTitleWithMnemonic:[path path]];
+ }
}
- (void)awakeFromNib