diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2011-12-04 06:09:59 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2011-12-04 06:09:59 +0000 |
| commit | 3bd6d16afd6b068de6b061a87cba955f5ca3ff88 (patch) | |
| tree | 77cd021219ac202826edf2ad857e210feffe6496 /macosx/ConfigurationController.m | |
| parent | c057388716aadb2f7d5d20c12da29ce89396402b (diff) | |
| download | pcsxr-3bd6d16afd6b068de6b061a87cba955f5ca3ff88.tar.gz | |
Made it so that opening a memory card on PCSXR for the Mac allows you to set which slot you want to put it in. Just ignore the "Could not open file" warning for now: It's wrong.
Added a class method to ConfigurationController that will set a memory card based on a path passed to it. Also made ConfigurationController listen for when a memory card is changed.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@72844 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/ConfigurationController.m')
| -rw-r--r-- | macosx/ConfigurationController.m | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/macosx/ConfigurationController.m b/macosx/ConfigurationController.m index 0faccc89..ab3dc22c 100644 --- a/macosx/ConfigurationController.m +++ b/macosx/ConfigurationController.m @@ -6,8 +6,24 @@ #include "psxcommon.h" #include "plugins.h" +NSString *memChangeNotifier = @"PcsxrMemoryCardDidChangeNotifier"; + + @implementation ConfigurationController ++ (void)setMemoryCard:(int)theCard toPath:(NSString *)theFile +{ + if (theCard == 1) { + [[NSUserDefaults standardUserDefaults] setObject:theFile forKey:@"Mcd1"]; + strcpy(Config.Mcd1, [theFile fileSystemRepresentation] ); + } else { + [[NSUserDefaults standardUserDefaults] setObject:theFile forKey:@"Mcd2"]; + strcpy(Config.Mcd2, [theFile fileSystemRepresentation] ); + } + + [[NSNotificationCenter defaultCenter] postNotificationName:memChangeNotifier object:nil]; +} + - (IBAction)setCheckbox:(id)sender { if ([sender isKindOfClass:[NSMatrix class]]) { @@ -58,14 +74,9 @@ if ([openDlg runModal] == NSFileHandlingPanelOKButton) { NSArray* urls = [openDlg URLs]; NSString *mcdPath = [[urls objectAtIndex:0] path]; - strcpy(mcd, (const char *)[mcdPath fileSystemRepresentation]); + [ConfigurationController setMemoryCard:tag toPath:mcdPath]; [label setTitleWithMnemonic:mcdPath]; - - if (tag == 1) - [[NSUserDefaults standardUserDefaults] setObject:mcdPath forKey:@"Mcd1"]; - else - [[NSUserDefaults standardUserDefaults] setObject:mcdPath forKey:@"Mcd2"]; } [openDlg release]; } @@ -90,15 +101,10 @@ if ([openDlg runModal] == NSFileHandlingPanelOKButton) { NSString *mcdPath = [[openDlg URL] path]; - strcpy(mcd, (const char *)[mcdPath fileSystemRepresentation]); + [ConfigurationController setMemoryCard:tag toPath:mcdPath]; [label setTitleWithMnemonic:mcdPath]; - if (tag == 1) - [[NSUserDefaults standardUserDefaults] setObject:mcdPath forKey:@"Mcd1"]; - else - [[NSUserDefaults standardUserDefaults] setObject:mcdPath forKey:@"Mcd2"]; - CreateMcd(mcd); } [openDlg release]; @@ -129,12 +135,22 @@ } } +- (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]; +} + - (void)awakeFromNib { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [[self window] center]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(memoryCardDidChangeNotification:) name:memChangeNotifier object:nil]; + // setup checkboxes checkBoxDefaults = [[NSMutableDictionary alloc] init]; @@ -201,6 +217,7 @@ - (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; [checkBoxDefaults release]; if (memCardEdit) { [memCardEdit release]; |
