From 6349404da5984e6785574c96db3eb3a08a515b37 Mon Sep 17 00:00:00 2001 From: "SND\\MaddTheSane_cp" Date: Wed, 26 Jun 2013 00:53:22 +0000 Subject: Even more work on the memory card management. git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@85558 e17a0e51-4ae3-4d35-97c3-1a29b211df97 --- macosx/ConfigurationController.h | 9 +- macosx/ConfigurationController.m | 93 +++--- macosx/English.lproj/MemCardManager.xib | 503 ++++++++++++++++---------------- macosx/PcsxrController.m | 24 +- macosx/PcsxrFreezeStateHandler.m | 3 +- macosx/PcsxrMemCardController.m | 118 +++----- macosx/PcsxrMemCardHandler.m | 3 +- macosx/PcsxrMemoryObject.m | 4 +- macosx/PcsxrPluginHandler.m | 2 +- plugins/dfinput/sdljoy.c | 2 +- 10 files changed, 391 insertions(+), 370 deletions(-) diff --git a/macosx/ConfigurationController.h b/macosx/ConfigurationController.h index e55cfb0a..badc93c0 100755 --- a/macosx/ConfigurationController.h +++ b/macosx/ConfigurationController.h @@ -5,7 +5,8 @@ #import "HotkeyController.h" #import "PluginList.h" -extern NSString *memChangeNotifier; +extern NSString *const memChangeNotifier; +extern NSString *const memCardChangeNumberKey; @class PcsxrMemCardController; @@ -53,7 +54,11 @@ extern NSString *memChangeNotifier; - (BOOL)isMemoryCardWindowVisible; - (NSString *)keyForSender:(id)sender; -+ (void)setMemoryCard:(int)theCard toPath:(NSString *)theFile; ++ (void)setMemoryCard:(int)theCard toPath:(NSString *)theFile DEPRECATED_ATTRIBUTE; ++ (void)setMemoryCard:(int)theCard toURL:(NSURL *)theURL; + ++ (void)mcdNewClicked:(id)sender; ++ (void)mcdChangeClicked:(id)sender; - (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem; 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 diff --git a/macosx/English.lproj/MemCardManager.xib b/macosx/English.lproj/MemCardManager.xib index 1ac73c77..402f5d9f 100644 --- a/macosx/English.lproj/MemCardManager.xib +++ b/macosx/English.lproj/MemCardManager.xib @@ -265,7 +265,7 @@ {{1, 144}, {233, 15}} - + _NS:3374 NO 1 @@ -390,7 +390,7 @@ NO - + 268 {{14, 296}, {80, 32}} @@ -400,13 +400,13 @@ _NS:9 1 YES - + 67108864 134217728 New… _NS:9 - + -2038284288 129 @@ -416,23 +416,23 @@ NO - + 268 {{106, 296}, {101, 32}} - + _NS:9 1 YES - + 67108864 134217728 Change… _NS:9 - + -2038284288 129 @@ -442,22 +442,22 @@ NO - + 268 {{17, 332}, {187, 17}} - + _NS:1535 YES - + 68157504 272630784 Label _NS:1535 - + 6 @@ -471,22 +471,23 @@ NO - + 268 {{262, 296}, {80, 32}} + _NS:9 2 YES - + 67108864 134217728 New… _NS:9 - + -2038284288 129 @@ -496,22 +497,23 @@ NO - + 268 {{354, 296}, {101, 32}} + _NS:9 2 YES - + 67108864 134217728 Change… _NS:9 - + -2038284288 129 @@ -521,22 +523,22 @@ NO - + 268 {{265, 332}, {187, 17}} - + _NS:1535 YES - + 68157504 272630784 Label _NS:1535 - + @@ -546,7 +548,7 @@ {469, 351} - + {{0, 0}, {1920, 1058}} {469, 373} @@ -817,7 +819,7 @@ memCard1Label - + 196 @@ -825,33 +827,41 @@ memCard2Label - + 197 - newMemCard: + changeMemCard: + + + + 207 + + + + changeMemCard: - + - 203 + 208 newMemCard: - + - 204 + 209 - changeMemCard: + newMemCard: - + - 206 + 210 @@ -1072,8 +1082,8 @@ - - + + 4 0 @@ -1089,7 +1099,7 @@ 29 3 - + 6 0 @@ -1105,7 +1115,7 @@ 29 3 - + 4 0 @@ -1121,7 +1131,7 @@ 29 3 - + 5 0 @@ -1137,11 +1147,11 @@ 24 2 - - + + 11 0 - + 11 1 @@ -1153,11 +1163,11 @@ 24 2 - + 6 0 - + 6 1 @@ -1169,7 +1179,7 @@ 29 3 - + 4 0 @@ -1185,7 +1195,7 @@ 29 3 - + 6 0 @@ -1201,7 +1211,7 @@ 24 2 - + 4 0 @@ -1217,7 +1227,7 @@ 9 3 - + 5 0 @@ -1233,7 +1243,7 @@ 24 3 - + 4 0 @@ -1249,7 +1259,7 @@ 29 3 - + 5 0 @@ -1265,7 +1275,7 @@ 29 3 - + 4 0 @@ -1281,7 +1291,7 @@ 24 2 - + 5 0 @@ -1297,7 +1307,7 @@ 24 3 - + 5 0 @@ -1313,7 +1323,7 @@ 24 3 - + 6 0 @@ -1329,11 +1339,11 @@ 29 3 - - + + 11 0 - + 11 1 @@ -1345,8 +1355,8 @@ 24 2 - - + + 3 0 @@ -1361,11 +1371,11 @@ 9 3 - + 6 0 - + 6 1 @@ -1377,11 +1387,11 @@ 29 3 - - + + 11 0 - + 11 1 @@ -1393,8 +1403,8 @@ 24 2 - - + + 5 0 @@ -1409,11 +1419,11 @@ 24 2 - - + + 5 0 - + 5 1 @@ -1425,7 +1435,7 @@ 24 2 - + 5 0 @@ -1441,7 +1451,7 @@ 24 3 - + 3 0 @@ -1457,7 +1467,7 @@ 9 3 - + 9 0 @@ -1473,11 +1483,11 @@ 22 2 - - + + 11 0 - + 11 1 @@ -1489,8 +1499,8 @@ 24 2 - - + + 6 0 @@ -1505,7 +1515,7 @@ 24 2 - + 5 0 @@ -1521,7 +1531,7 @@ 29 3 - + 3 0 @@ -1537,7 +1547,7 @@ 9 3 - + 3 0 @@ -1553,7 +1563,7 @@ 24 2 - + 4 0 @@ -1569,11 +1579,11 @@ 9 3 - - + + 3 0 - + 4 1 @@ -1585,8 +1595,8 @@ 24 3 - - + + 5 0 @@ -1601,8 +1611,8 @@ 29 3 - - + + 5 0 @@ -1617,11 +1627,11 @@ 29 3 - - + + 6 0 - + 6 1 @@ -1633,11 +1643,11 @@ 24 2 - - - - - + + + + + @@ -1646,7 +1656,7 @@ - + 7 0 @@ -1719,7 +1729,7 @@ - + 6 0 @@ -1735,7 +1745,7 @@ 29 3 - + 5 0 @@ -1751,7 +1761,7 @@ 9 3 - + 3 0 @@ -1767,7 +1777,7 @@ 29 3 - + 4 0 @@ -1833,7 +1843,7 @@ - + 3 0 @@ -1849,7 +1859,7 @@ 24 3 - + 3 0 @@ -1865,7 +1875,7 @@ 9 3 - + 9 0 @@ -1881,7 +1891,7 @@ 24 2 - + 3 0 @@ -1897,7 +1907,7 @@ 24 3 - + 5 0 @@ -1913,7 +1923,7 @@ 24 2 - + 6 0 @@ -1929,7 +1939,7 @@ 24 2 - + 5 0 @@ -1945,7 +1955,7 @@ 9 3 - + 6 0 @@ -1961,7 +1971,7 @@ 24 2 - + 3 0 @@ -1977,7 +1987,7 @@ 24 3 - + 5 0 @@ -2001,7 +2011,7 @@ - + 7 0 @@ -2017,7 +2027,7 @@ 9 1 - + 8 0 @@ -2046,7 +2056,7 @@ - + 7 0 @@ -2150,345 +2160,345 @@ 131 - + - + 132 - - + + 133 - + - + 134 - - + + 135 - + - + 136 - - + + 137 - + - + 138 - + - + 139 - + - + 140 - - + + 141 - - + + 142 - - + + 143 - + 144 - + 145 - + 146 - + 148 - + 149 - + 150 - + 151 - + 152 - + 153 - + 154 - + 155 - + 156 - + 157 - + 158 - + 161 - + 162 - + 163 - + 164 - + 165 - + 166 - + 167 - + 168 - + 169 - + 170 - + 171 - + 172 - + 173 - + 174 - + 176 - + 177 - + 178 - + 179 - + 180 - + 181 - + 182 - + 183 - + 184 - + 185 - + 186 - + 187 - + 188 - + 189 - + 190 - + 191 - + 192 - + 193 - + 194 - + 195 - + 198 - + 200 - + 201 - + 202 - + @@ -2576,48 +2586,48 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin - - - - + + + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -2629,14 +2639,14 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - - + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin @@ -2647,16 +2657,16 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - - - - - - - - - - + + + + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin @@ -2673,7 +2683,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin @@ -2688,7 +2698,7 @@ - 206 + 210 @@ -2730,6 +2740,7 @@ id id id + id @@ -2752,6 +2763,10 @@ newMemCard: id + + showWindow: + id + NSTextField diff --git a/macosx/PcsxrController.m b/macosx/PcsxrController.m index 9c122a4c..889c87ff 100755 --- a/macosx/PcsxrController.m +++ b/macosx/PcsxrController.m @@ -16,6 +16,7 @@ NSDictionary *prefStringKeys; NSDictionary *prefByteKeys; +NSDictionary *prefURLKeys; NSMutableArray *biosList; NSString *saveStatePath; @@ -437,7 +438,7 @@ otherblock();\ hasParsedAnArgument = YES; NSString *path = FileTestBlock(); runtimeBlock = [^{ - [self runURL:[NSURL fileURLWithPath:path]]; + [self runURL:[NSURL fileURLWithPath:path isDirectory:NO]]; } copy]; }; @@ -573,10 +574,10 @@ otherblock();\ } } - str = [[defaults stringForKey:@"Mcd1"] fileSystemRepresentation]; + str = [[[defaults URLForKey:@"Mcd1"] path] fileSystemRepresentation]; if (str) strlcpy(Config.Mcd1, str, MAXPATHLEN); - str = [[defaults stringForKey:@"Mcd2"] fileSystemRepresentation]; + str = [[[defaults URLForKey:@"Mcd2"] path] fileSystemRepresentation]; if (str) strlcpy(Config.Mcd2, str, MAXPATHLEN); if ([defaults boolForKey:@"UseHLE"] || 0 == [biosList count]) { @@ -608,6 +609,16 @@ otherblock();\ [defaults setObject:tmpNSStr forKey:defaultKey]; return; } + + str = (char *)[[prefURLKeys objectForKey:defaultKey] pointerValue]; + if (str) { + NSString *tmpNSStr = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:str length:strlen(str)]; + if (!tmpNSStr) { + tmpNSStr = [NSString stringWithCString:str encoding:NSUTF8StringEncoding]; + } + [defaults setURL:[NSURL fileURLWithPath:tmpNSStr isDirectory:NO] forKey:defaultKey]; + return; + } u8 *val = (u8 *)[[prefByteKeys objectForKey:defaultKey] pointerValue]; if (val) { @@ -644,9 +655,12 @@ otherblock();\ [NSValue valueWithPointer:Config.Pad1], @"PluginPAD", [NSValue valueWithPointer:Config.Cdr], @"PluginCDR", [NSValue valueWithPointer:Config.Net], @"PluginNET", - [NSValue valueWithPointer:Config.Mcd1], @"Mcd1", - [NSValue valueWithPointer:Config.Mcd2], @"Mcd2", nil]; + + prefURLKeys = [[NSDictionary alloc] initWithObjectsAndKeys: + [NSValue valueWithPointer:Config.Mcd1], @"Mcd1", + [NSValue valueWithPointer:Config.Mcd2], @"Mcd2", + nil]; prefByteKeys = [[NSDictionary alloc] initWithObjectsAndKeys: [NSValue valueWithPointer:&Config.Xa], @"NoXaAudio", diff --git a/macosx/PcsxrFreezeStateHandler.m b/macosx/PcsxrFreezeStateHandler.m index 8ecafae6..4fbb49f0 100755 --- a/macosx/PcsxrFreezeStateHandler.m +++ b/macosx/PcsxrFreezeStateHandler.m @@ -8,6 +8,7 @@ #import "PcsxrFreezeStateHandler.h" #import "EmuThread.h" +#import "ARCBridge.h" #include "misc.h" @implementation PcsxrFreezeStateHandler @@ -16,7 +17,7 @@ { static NSArray *utisupport = nil; if (utisupport == nil) { - utisupport = [[NSArray alloc] initWithObjects:@"com.codeplex.pcsxr.freeze", nil]; + utisupport = RETAINOBJ([NSArray arrayWithObject:@"com.codeplex.pcsxr.freeze"]); } return utisupport; } diff --git a/macosx/PcsxrMemCardController.m b/macosx/PcsxrMemCardController.m index 5e585aa7..a79d2bf6 100755 --- a/macosx/PcsxrMemCardController.m +++ b/macosx/PcsxrMemCardController.m @@ -34,31 +34,40 @@ static inline void CopyMemcardData(char *from, char *to, int srci, int dsti, cha //memCard1Array KVO functions -- (void)setupValues +- (void)setupValues:(int)theCards { - LoadMcds(Config.Mcd1, Config.Mcd2); + NSParameterAssert(theCards < 4 && theCards > 0); + if (theCards == 3) { + LoadMcds(Config.Mcd1, Config.Mcd2); + } else { + LoadMcd(theCards, theCards == 1 ? Config.Mcd1 : Config.Mcd2); + } NSFileManager *fm = [NSFileManager defaultManager]; - NSString *fileName1 = nil; - NSString *fileName2 = nil; - NSString *fullPath1 = [fm stringWithFileSystemRepresentation:Config.Mcd1 length:sizeof(Config.Mcd1)]; - NSString *fullPath2 = [fm stringWithFileSystemRepresentation:Config.Mcd2 length:sizeof(Config.Mcd2)]; -#if 0 - //For some odd reason, Cocoa complains about being passed a URL with no scheme. - fileName1 = [fm displayNameAtPath:fullPath1]; - fileName2 = [fm displayNameAtPath:fullPath2]; -#else - fileName1 = [fullPath1 lastPathComponent]; - fileName2 = [fullPath2 lastPathComponent]; -#endif - [memCard1Label setTitleWithMnemonic:fileName1]; - [memCard2Label setTitleWithMnemonic:fileName2]; - - [memCard1Label setToolTip:fullPath1]; - [memCard2Label setToolTip:fullPath2]; + NSString *fullPath = nil; + NSString *fileName = nil; - [self loadMemoryCardInfoForCard:1]; - [self loadMemoryCardInfoForCard:2]; + if (theCards & 1) { + fullPath = [[[NSUserDefaults standardUserDefaults] URLForKey:@"Mcd1"] path]; + fileName = [fm displayNameAtPath:fullPath]; + + [memCard1Label setTitleWithMnemonic:fileName]; + + [memCard1Label setToolTip:fullPath]; + + [self loadMemoryCardInfoForCard:1]; + } + + if (theCards & 2) { + fullPath = [[[NSUserDefaults standardUserDefaults] URLForKey:@"Mcd2"] path]; + fileName = [fm displayNameAtPath:fullPath]; + + [memCard2Label setTitleWithMnemonic:fileName]; + + [memCard2Label setToolTip:fullPath]; + + [self loadMemoryCardInfoForCard:2]; + } } -(void)insertObject:(PcsxrMemoryObject *)p inMemCard1ArrayAtIndex:(NSUInteger)index @@ -178,7 +187,9 @@ static inline void CopyMemcardData(char *from, char *to, int srci, int dsti, cha - (void)memoryCardDidChangeNotification:(NSNotification *)aNote { - [self setupValues]; + NSDictionary *dict = [aNote userInfo]; + NSNumber *theNum = [dict objectForKey:memCardChangeNumberKey]; + [self setupValues:[theNum intValue]]; } - (void)windowDidLoad @@ -202,7 +213,7 @@ static inline void CopyMemcardData(char *from, char *to, int srci, int dsti, cha - (IBAction)showWindow:(id)sender { [super showWindow:sender]; - [self setupValues]; + [self setupValues:3]; } - (int)findFreeMemCardBlockInCard:(int)target_card length:(int)len @@ -436,63 +447,14 @@ static inline void CopyMemcardData(char *from, char *to, int srci, int dsti, cha } } -- (IBAction)newMemCard:(id)sender { - int tag = [sender tag]; - char *mcd; - NSTextField *label; - NSOpenPanel *openDlg = RETAINOBJ([NSOpenPanel openPanel]); - NSString *path; - - if (tag == 1) { mcd = Config.Mcd1; label = memCard1Label; } - else { mcd = Config.Mcd2; label = memCard2Label; } - - [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]; - - [ConfigurationController setMemoryCard:tag toPath:mcdPath]; - } - RELEASEOBJ(openDlg); - +- (IBAction)changeMemCard:(id)sender +{ + [ConfigurationController mcdChangeClicked:sender]; } -- (IBAction)changeMemCard:(id)sender { - int tag = [sender tag]; - char *mcd; - NSTextField *label; - NSSavePanel *openDlg = RETAINOBJ([NSSavePanel savePanel]); - NSString *path; - - if (tag == 1) { mcd = Config.Mcd1; label = memCard1Label; } - else { mcd = Config.Mcd2; label = memCard2Label; } - - 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]; - - //Workaround/kludge to make sure we create a memory card before posting a notification - strlcpy(mcd, [mcdPath fileSystemRepresentation], MAXPATHLEN); - - CreateMcd(mcd); - - [ConfigurationController setMemoryCard:tag toPath:mcdPath]; - } - RELEASEOBJ(openDlg); - +- (IBAction)newMemCard:(id)sender +{ + [ConfigurationController mcdNewClicked:sender]; } - (void)dealloc diff --git a/macosx/PcsxrMemCardHandler.m b/macosx/PcsxrMemCardHandler.m index 7d043049..21a96869 100755 --- a/macosx/PcsxrMemCardHandler.m +++ b/macosx/PcsxrMemCardHandler.m @@ -8,6 +8,7 @@ #import "PcsxrMemCardHandler.h" #import "ConfigurationController.h" +#import "ARCBridge.h" @implementation PcsxrMemCardHandler @@ -15,7 +16,7 @@ { static NSArray *utisupport = nil; if (utisupport == nil) { - utisupport = [[NSArray alloc] initWithObjects:@"com.codeplex.pcsxr.memcard", nil]; + utisupport = RETAINOBJ([NSArray arrayWithObject:@"com.codeplex.pcsxr.memcard"]); } return utisupport; } diff --git a/macosx/PcsxrMemoryObject.m b/macosx/PcsxrMemoryObject.m index 8455a367..b48d13ac 100755 --- a/macosx/PcsxrMemoryObject.m +++ b/macosx/PcsxrMemoryObject.m @@ -83,9 +83,7 @@ NSString *const memoryAnimateTimerKey = @"PCSXR Memory Card Image Animate"; if (self = [super init]) { self.englishName = [NSString stringWithCString:infoBlock->Title encoding:NSASCIIStringEncoding]; self.sjisName = [NSString stringWithCString:infoBlock->sTitle encoding:NSShiftJISStringEncoding]; - @autoreleasepool { - self.memImages = [PcsxrMemoryObject imagesFromMcd:infoBlock]; - } + self.memImages = [PcsxrMemoryObject imagesFromMcd:infoBlock]; if ([memImages count] == 0) { self.memImage = [PcsxrMemoryObject blankImage]; } else { diff --git a/macosx/PcsxrPluginHandler.m b/macosx/PcsxrPluginHandler.m index 17873cf3..7fde32c9 100755 --- a/macosx/PcsxrPluginHandler.m +++ b/macosx/PcsxrPluginHandler.m @@ -15,7 +15,7 @@ { static NSArray *utisupport = nil; if (utisupport == nil) { - utisupport = [[NSArray alloc] initWithObjects:@"com.codeplex.pcsxr.plugin", nil]; + utisupport = RETAINOBJ([NSArray arrayWithObject:@"com.codeplex.pcsxr.plugin"]); } return utisupport; } diff --git a/plugins/dfinput/sdljoy.c b/plugins/dfinput/sdljoy.c index 92db9f4a..7d0dad71 100755 --- a/plugins/dfinput/sdljoy.c +++ b/plugins/dfinput/sdljoy.c @@ -19,7 +19,7 @@ #include "pad.h" #if SDL_VERSION_ATLEAST(1,3,0) -//static SDL_HapticEffect haptic_rumbleEffect; +static SDL_HapticEffect haptic_rumbleEffect; #endif void JoyInitHaptic() -- cgit v1.2.3