Cocoa Port:

- Log when the app has been run for the first time.
- Improve the various behaviors of the File Migration window.
- Add the ability to select all files or select no files in the File Migration window.
This commit is contained in:
rogerman 2013-04-20 19:57:39 +00:00
parent 4d04bc009b
commit c7846262c9
12 changed files with 812 additions and 432 deletions

View File

@ -622,6 +622,10 @@
ABA03571169127C000817C69 /* troubleshootingWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABA0356F169127C000817C69 /* troubleshootingWindowDelegate.mm */; };
ABA03572169127C000817C69 /* troubleshootingWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABA0356F169127C000817C69 /* troubleshootingWindowDelegate.mm */; };
ABA03573169127C000817C69 /* troubleshootingWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABA0356F169127C000817C69 /* troubleshootingWindowDelegate.mm */; };
ABAAFBEA172122B6005DDDBE /* FileMigrationDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABAAFBE9172122B6005DDDBE /* FileMigrationDelegate.mm */; };
ABAAFBEB172122B6005DDDBE /* FileMigrationDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABAAFBE9172122B6005DDDBE /* FileMigrationDelegate.mm */; };
ABAAFBEC172122B6005DDDBE /* FileMigrationDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABAAFBE9172122B6005DDDBE /* FileMigrationDelegate.mm */; };
ABAAFBED172122B6005DDDBE /* FileMigrationDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABAAFBE9172122B6005DDDBE /* FileMigrationDelegate.mm */; };
ABAD0F7315ACE7A00000EC47 /* KeyNames.plist in Resources */ = {isa = PBXBuildFile; fileRef = AB02475B13886BF300E9F9AB /* KeyNames.plist */; };
ABAD0F7415ACE7A00000EC47 /* DefaultKeyMappings.plist in Resources */ = {isa = PBXBuildFile; fileRef = ABC719E1138CB25E002827A9 /* DefaultKeyMappings.plist */; };
ABAD0F7515ACE7A00000EC47 /* DefaultUserPrefs.plist in Resources */ = {isa = PBXBuildFile; fileRef = ABBC0F8C1394B1AA0028B6BD /* DefaultUserPrefs.plist */; };
@ -1015,6 +1019,8 @@
ABA0356F169127C000817C69 /* troubleshootingWindowDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = troubleshootingWindowDelegate.mm; sourceTree = "<group>"; };
ABA6574914511EC90077E5E9 /* cocoa_cheat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cocoa_cheat.h; sourceTree = "<group>"; };
ABA6574A14511EC90077E5E9 /* cocoa_cheat.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = cocoa_cheat.mm; sourceTree = "<group>"; };
ABAAFBE8172122B6005DDDBE /* FileMigrationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileMigrationDelegate.h; sourceTree = "<group>"; };
ABAAFBE9172122B6005DDDBE /* FileMigrationDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FileMigrationDelegate.mm; sourceTree = "<group>"; };
ABAD104915ACE7A00000EC47 /* DeSmuME (PPC).app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "DeSmuME (PPC).app"; sourceTree = BUILT_PRODUCTS_DIR; };
ABB97873144E89CC00793FA3 /* Icon_ActionReplay_32x32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_ActionReplay_32x32.png; path = Images/Icon_ActionReplay_32x32.png; sourceTree = "<group>"; };
ABB97874144E89CC00793FA3 /* Icon_CodeBreaker_32x32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_CodeBreaker_32x32.png; path = Images/Icon_CodeBreaker_32x32.png; sourceTree = "<group>"; };
@ -1516,6 +1522,7 @@
AB3ACB6814C2361100D7D192 /* cheatWindowDelegate.h */,
AB700DDC16CDE4C300FBD336 /* DisplayWindowController.h */,
AB6A187A16C9951C00384EED /* EmuControllerDelegate.h */,
ABAAFBE8172122B6005DDDBE /* FileMigrationDelegate.h */,
AB5A795616D5A56000ED84B7 /* InputManager.h */,
AB3ACB6E14C2361100D7D192 /* inputPrefsView.h */,
AB213D43170CB141006DDB0F /* InputProfileController.h */,
@ -1525,6 +1532,7 @@
AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */,
AB700DDD16CDE4C300FBD336 /* DisplayWindowController.mm */,
AB6A187B16C9951C00384EED /* EmuControllerDelegate.mm */,
ABAAFBE9172122B6005DDDBE /* FileMigrationDelegate.mm */,
AB5A795716D5A56000ED84B7 /* InputManager.mm */,
AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */,
AB213D44170CB141006DDB0F /* InputProfileController.mm */,
@ -2678,6 +2686,7 @@
AB2F56F11704C86900E28885 /* utilities.c in Sources */,
AB213D46170CB141006DDB0F /* InputProfileController.mm in Sources */,
AB2145241714DFF4006DDB0F /* audiosamplegenerator.cpp in Sources */,
ABAAFBEB172122B6005DDDBE /* FileMigrationDelegate.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2837,6 +2846,7 @@
AB2F56F01704C86900E28885 /* utilities.c in Sources */,
AB213D48170CB141006DDB0F /* InputProfileController.mm in Sources */,
AB2145261714DFF4006DDB0F /* audiosamplegenerator.cpp in Sources */,
ABAAFBEA172122B6005DDDBE /* FileMigrationDelegate.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2996,6 +3006,7 @@
AB2F56F31704C86900E28885 /* utilities.c in Sources */,
AB213D45170CB141006DDB0F /* InputProfileController.mm in Sources */,
AB2145251714DFF4006DDB0F /* audiosamplegenerator.cpp in Sources */,
ABAAFBED172122B6005DDDBE /* FileMigrationDelegate.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -3125,6 +3136,7 @@
AB2F56F21704C86900E28885 /* utilities.c in Sources */,
AB213D47170CB141006DDB0F /* InputProfileController.mm in Sources */,
AB2145231714DFF4006DDB0F /* audiosamplegenerator.cpp in Sources */,
ABAAFBEC172122B6005DDDBE /* FileMigrationDelegate.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -608,6 +608,8 @@
ABD1FF681345ACBF00AF11D1 /* vfat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FF4F1345ACBF00AF11D1 /* vfat.cpp */; };
ABD1FF691345ACBF00AF11D1 /* xstring.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FF511345ACBF00AF11D1 /* xstring.cpp */; };
ABD1FF9F1345ACFA00AF11D1 /* metaspu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FF771345ACFA00AF11D1 /* metaspu.cpp */; };
ABD42047172319D1006A9B46 /* FileMigrationDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD42046172319D1006A9B46 /* FileMigrationDelegate.mm */; };
ABD42048172319D1006A9B46 /* FileMigrationDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD42046172319D1006A9B46 /* FileMigrationDelegate.mm */; };
ABE5DE95143F781900835AD8 /* videofilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB817A35143EE2DB00A7DFE9 /* videofilter.cpp */; };
ABE5DFE5143FB1DA00835AD8 /* cocoa_videofilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */; };
ABE6702B1415DE6C00E8E4C9 /* tinystr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABE670251415DE6C00E8E4C9 /* tinystr.cpp */; };
@ -1042,6 +1044,8 @@
ABD1FF7A1345ACFA00AF11D1 /* SndOut.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SndOut.cpp; sourceTree = "<group>"; };
ABD1FF7B1345ACFA00AF11D1 /* SndOut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SndOut.h; sourceTree = "<group>"; };
ABD1FF9B1345ACFA00AF11D1 /* Timestretcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Timestretcher.cpp; sourceTree = "<group>"; };
ABD42045172319D1006A9B46 /* FileMigrationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileMigrationDelegate.h; sourceTree = "<group>"; };
ABD42046172319D1006A9B46 /* FileMigrationDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FileMigrationDelegate.mm; sourceTree = "<group>"; };
ABE5DFE3143FB1DA00835AD8 /* cocoa_videofilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cocoa_videofilter.h; sourceTree = "<group>"; };
ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = cocoa_videofilter.mm; sourceTree = "<group>"; };
ABE670251415DE6C00E8E4C9 /* tinystr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tinystr.cpp; sourceTree = "<group>"; };
@ -1263,6 +1267,7 @@
AB3ACB6814C2361100D7D192 /* cheatWindowDelegate.h */,
AB8967D716D2ED0700F826F1 /* DisplayWindowController.h */,
AB3A655C16CC5416001F5D4A /* EmuControllerDelegate.h */,
ABD42045172319D1006A9B46 /* FileMigrationDelegate.h */,
AB29B32F16D4BEBF000EF671 /* InputManager.h */,
AB3ACB6E14C2361100D7D192 /* inputPrefsView.h */,
AB01005C170D07AF00D70FBE /* InputProfileController.h */,
@ -1272,6 +1277,7 @@
AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */,
AB8967D816D2ED0700F826F1 /* DisplayWindowController.mm */,
AB3A655D16CC5421001F5D4A /* EmuControllerDelegate.mm */,
ABD42046172319D1006A9B46 /* FileMigrationDelegate.mm */,
AB29B33016D4BEBF000EF671 /* InputManager.mm */,
AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */,
AB01005D170D07B000D70FBE /* InputProfileController.mm */,
@ -2273,6 +2279,7 @@
AB01005F170D07B000D70FBE /* InputProfileController.mm in Sources */,
ABD10AE81715FCDD00B5729D /* audiosamplegenerator.cpp in Sources */,
ABD10AEB1715FCDD00B5729D /* mic_ext.cpp in Sources */,
ABD42048172319D1006A9B46 /* FileMigrationDelegate.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2433,6 +2440,7 @@
AB01005E170D07B000D70FBE /* InputProfileController.mm in Sources */,
ABD10AE71715FCDD00B5729D /* audiosamplegenerator.cpp in Sources */,
ABD10AEA1715FCDD00B5729D /* mic_ext.cpp in Sources */,
ABD42047172319D1006A9B46 /* FileMigrationDelegate.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -2,6 +2,34 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>VersionStrings</key>
<array>
<string>0.9.6</string>
<string>0.9.7</string>
<string>0.9.8</string>
<string>0.9.9</string>
</array>
<key>PortStrings</key>
<dict>
<key>0.9.6</key>
<array>
<string>GTK</string>
</array>
<key>0.9.7</key>
<array>
<string>Cocoa</string>
</array>
<key>0.9.8</key>
<array>
<string>Cocoa</string>
<string>OpenEmu</string>
</array>
<key>0.9.9</key>
<array>
<string>Cocoa</string>
<string>OpenEmu</string>
</array>
</dict>
<key>DefaultPaths</key>
<dict>
<key>0.9.6</key>

View File

@ -53,7 +53,7 @@
+ (NSString *) saveSlotFileName:(NSURL *)romURL slotNumber:(NSUInteger)slotNumber;
+ (NSString *) fileKindByURL:(NSURL *)fileURL;
+ (NSString *) fileKindByURL:(NSURL *)fileURL version:(NSString *)versionString port:(NSString *)portString;
+ (NSString *) fileVersion:(NSURL *)fileURL;
+ (NSString *) fileVersionByURL:(NSURL *)fileURL;
+ (BOOL) fileExistsForCurrent:(NSURL *)fileURL;
+ (NSURL *) fileURLFromRomURL:(NSURL *)romURL toKind:(NSString *)fileKind;
+ (NSURL *) fileURLFromRomURL:(NSURL *)romURL toKind:(NSString *)fileKind version:(NSString *)versionString port:(NSString *)portString;

View File

@ -639,7 +639,7 @@ static NSMutableDictionary *_gURLDictionary = nil;
return fileKind;
}
+ (NSString *) fileVersion:(NSURL *)fileURL
+ (NSString *) fileVersionByURL:(NSURL *)fileURL
{
NSString *fileVersion = @"Unknown Version";
@ -1208,10 +1208,10 @@ static NSMutableDictionary *_gURLDictionary = nil;
NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
NSDictionary *fileTypeInfoRootDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"FileTypeInfo" ofType:@"plist"]];
NSArray *versionList = [fileTypeInfoRootDict valueForKey:@"VersionStrings"];
NSDictionary *filePathsDict = (NSDictionary *)[fileTypeInfoRootDict valueForKey:@"DefaultPaths"];
NSArray *versionArray = [filePathsDict allKeys];
for (NSString *versionKey in versionArray)
for (NSString *versionKey in versionList)
{
if ([currentVersion isEqualToString:versionKey])
{
@ -1274,7 +1274,7 @@ static NSMutableDictionary *_gURLDictionary = nil;
NSNumber *willMigrate = [NSNumber numberWithBool:YES];
NSString *filePath = [directoryPath stringByAppendingPathComponent:fileName];
NSURL *fileURL = [NSURL fileURLWithPath:filePath];
NSString *fileVersion = [CocoaDSFile fileVersion:fileURL];
NSString *fileVersion = [CocoaDSFile fileVersionByURL:fileURL];
NSString *fileKind = [CocoaDSFile fileKindByURL:fileURL];
if (fileKind == nil ||

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,48 @@
/*
Copyright (C) 2013 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#import <Cocoa/Cocoa.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
@interface FileMigrationDelegate : NSObject <NSWindowDelegate, NSOutlineViewDelegate, NSOutlineViewDataSource>
#else
@interface FileMigrationDelegate : NSObject
#endif
{
NSObject *dummyObject;
NSWindow *window;
NSArrayController *fileListController;
NSArray *_versionList;
NSMutableDictionary *_portStringsDict;
//NSMutableDictionary *_fileTree;
BOOL filesPresent;
}
@property (readonly) IBOutlet NSObject *dummyObject;
@property (readonly) IBOutlet NSWindow *window;
@property (readonly) IBOutlet NSArrayController *fileListController;
@property (assign) BOOL filesPresent;
- (void) updateFileList;
- (IBAction) updateAndShowWindow:(id)sender;
- (IBAction) handleChoice:(id)sender;
- (IBAction) selectAll:(id)sender;
- (IBAction) selectNone:(id)sender;
@end

View File

@ -0,0 +1,336 @@
/*
Copyright (C) 2013 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#import "FileMigrationDelegate.h"
#import "cocoa_file.h"
#import "cocoa_globals.h"
@implementation FileMigrationDelegate
@synthesize dummyObject;
@synthesize window;
@synthesize fileListController;
@synthesize filesPresent;
- (id)init
{
self = [super init];
if(self == nil)
{
return nil;
}
NSDictionary *fileTypeInfoRootDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"FileTypeInfo" ofType:@"plist"]];
_versionList = [[NSArray alloc] initWithArray:[fileTypeInfoRootDict valueForKey:@"VersionStrings"]];
NSDictionary *portStrings = (NSDictionary *)[fileTypeInfoRootDict valueForKey:@"PortStrings"];
_portStringsDict = [[NSMutableDictionary alloc] initWithCapacity:[portStrings count]];
for (NSString *versionKey in portStrings)
{
NSArray *portStringsList = (NSArray *)[portStrings valueForKey:versionKey];
NSMutableArray *newPortStringsList = [NSMutableArray arrayWithCapacity:[portStringsList count]];
for (NSString *portString in portStringsList)
{
[newPortStringsList addObject:[NSMutableString stringWithString:portString]];
}
[_portStringsDict setObject:newPortStringsList forKey:versionKey];
}
//_fileTree = [[NSMutableDictionary alloc] initWithCapacity:100];
filesPresent = NO;
return self;
}
- (void)dealloc
{
[_versionList release];
[_portStringsDict release];
//[_fileTree release];
[super dealloc];
}
- (void) updateFileList
{
NSMutableArray *fileList = [CocoaDSFile completeFileList];
if (fileList != nil)
{
[self setFilesPresent:([fileList count] == 0) ? NO : YES];
}
[fileListController setContent:fileList];
// Refresh the file tree.
/*
NSDictionary *fileTypeInfoRootDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"FileTypeInfo" ofType:@"plist"]];
NSDictionary *defaultPaths = (NSDictionary *)[fileTypeInfoRootDict valueForKey:@"DefaultPaths"];
NSFileManager *fileManager = [[NSFileManager alloc] init];
[_fileTree removeAllObjects];
for (NSString *versionKey in _versionList)
{
NSArray *portStringsList = (NSArray *)[_portStringsDict valueForKey:versionKey];
if (portStringsList == nil || [portStringsList count] < 1)
{
continue;
}
NSMutableDictionary *newVersionTree = [NSMutableDictionary dictionaryWithCapacity:[portStringsList count]];
for (NSString *portKey in portStringsList)
{
NSDictionary *pathsDict = (NSDictionary *)[(NSDictionary *)[defaultPaths valueForKey:versionKey] valueForKey:portKey];
if (pathsDict == nil || [pathsDict count] < 1)
{
continue;
}
NSMutableArray *newPortTree = [NSMutableArray arrayWithCapacity:128];
for (NSString *pathKey in pathsDict)
{
NSString *pathString = (NSString *)[pathsDict valueForKey:pathKey];
NSArray *fileList = [fileManager contentsOfDirectoryAtPath:pathString error:nil];
for (NSString *filePath in fileList)
{
[newPortTree addObject:[NSMutableDictionary dictionaryWithObject:filePath forKey:@"FileName"]];
}
}
[newVersionTree setObject:newPortTree forKey:portKey];
}
[_fileTree setObject:newVersionTree forKey:versionKey];
}
[fileManager release];
*/
}
#pragma mark NSOutlineViewDelegate Protocol
- (BOOL)selectionShouldChangeInOutlineView:(NSOutlineView *)outlineView
{
return NO;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldTrackCell:(NSCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
if ([(NSString *)[tableColumn identifier] isEqualToString:@"FileWillMigrateColumn"])
{
return YES;
}
return NO;
}
- (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
NSString *columnID = (NSString *)[tableColumn identifier];
NSCell *outCell = [tableColumn dataCellForRow:[outlineView rowForItem:item]];
if ([columnID isEqualToString:@"FileNameColumn"])
{
if ([item isKindOfClass:[NSString class]])
{
NSFont *newFont = [[NSFontManager sharedFontManager] fontWithFamily:[[outCell font] familyName]
traits:NSBoldFontMask
weight:0
size:[[outCell font] pointSize]];
[outCell setFont:newFont];
}
}
return outCell;
}
#pragma mark NSOutlineViewDataSource Protocol
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
{
if (item == nil)
{
return [_versionList objectAtIndex:index];
}
else if ([item isKindOfClass:[NSString class]])
{
if ([_versionList containsObject:item])
{
return [(NSArray *)[_portStringsDict valueForKey:item] objectAtIndex:index];
}
else
{
NSString *versionKey = (NSString *)[outlineView parentForItem:item];
//return [(NSArray *)[(NSDictionary *)[_fileTree valueForKey:versionKey] valueForKey:item] objectAtIndex:index];
return nil;
}
}
return nil;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{
if ([item isKindOfClass:[NSString class]])
{
return YES;
}
return NO;
}
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
{
NSInteger numberChildren = 0;
if (item == nil)
{
numberChildren = [_versionList count];
}
else if ([item isKindOfClass:[NSString class]])
{
if ([_versionList containsObject:item])
{
return [[_portStringsDict valueForKey:item] count];
}
else
{
NSString *versionKey = (NSString *)[outlineView parentForItem:item];
//return [(NSArray *)[(NSDictionary *)[_fileTree valueForKey:versionKey] valueForKey:item] count];
return 0;
}
}
return numberChildren;
}
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
NSString *columnID = (NSString *)[tableColumn identifier];
if ([columnID isEqualToString:@"FileWillMigrateColumn"])
{
return nil;
}
else if ([columnID isEqualToString:@"FileNameColumn"])
{
if ([item isKindOfClass:[NSString class]])
{
return item;
}
else if ([item isKindOfClass:[NSDictionary class]])
{
NSString *fileName = [item valueForKey:@"FileName"];
return (fileName != nil) ? fileName : @"";
}
else
{
return @"";
}
}
else if ([columnID isEqualToString:@"FileKindColumn"])
{
if ([item isKindOfClass:[NSString class]])
{
return @"";
}
else if ([item isKindOfClass:[NSDictionary class]])
{
return @"";
}
else
{
return @"";
}
}
else if ([columnID isEqualToString:@"FileDateModifiedColumn"])
{
if ([item isKindOfClass:[NSString class]])
{
return @"";
}
else if ([item isKindOfClass:[NSDictionary class]])
{
return @"";
}
else
{
return @"";
}
}
return item;
}
#pragma mark IBActions
- (IBAction) updateAndShowWindow:(id)sender
{
[self updateFileList];
[window center];
[window makeKeyAndOrderFront:nil];
}
- (IBAction) handleChoice:(id)sender
{
const NSInteger option = [(NSControl *)sender tag];
NSMutableArray *fileList = [fileListController content];
switch (option)
{
case COCOA_DIALOG_DEFAULT:
[CocoaDSFile copyFileListToCurrent:fileList];
break;
case COCOA_DIALOG_OPTION:
[CocoaDSFile moveFileListToCurrent:fileList];
break;
default:
break;
}
[[(NSControl *)sender window] close];
}
- (IBAction) selectAll:(id)sender
{
NSMutableArray *fileList = [fileListController content];
for (NSMutableDictionary *fileAttr in fileList)
{
[fileAttr setValue:[NSNumber numberWithBool:YES] forKey:@"willMigrate"];
}
}
- (IBAction) selectNone:(id)sender
{
NSMutableArray *fileList = [fileListController content];
for (NSMutableDictionary *fileAttr in fileList)
{
[fileAttr setValue:[NSNumber numberWithBool:NO] forKey:@"willMigrate"];
}
}
@end

View File

@ -20,6 +20,7 @@
@class InputPrefsView;
@class InputManager;
@class FileMigrationDelegate;
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
@ -30,7 +31,6 @@
{
NSObject *dummyObject;
NSArrayController *fileMigrationList;
NSObjectController *aboutWindowController;
NSObjectController *emuControlController;
NSObjectController *cdsSoundController;
@ -38,12 +38,12 @@
NSObjectController *prefWindowController;
NSObjectController *cheatWindowController;
NSObjectController *cdsCoreController;
FileMigrationDelegate *migrationDelegate;
InputManager *inputManager;
NSWindow *prefWindow;
NSWindow *troubleshootingWindow;
NSWindow *cheatListWindow;
NSWindow *migrationWindow;
NSView *prefGeneralView;
InputPrefsView *inputPrefsView;
@ -56,13 +56,11 @@
NSBox *boxFileSystem;
NSBox *boxMisc;
BOOL migrationFilesPresent;
BOOL isAppRunningOnIntel;
}
@property (readonly) IBOutlet NSObject *dummyObject;
@property (readonly) IBOutlet NSArrayController *fileMigrationList;
@property (readonly) IBOutlet NSObjectController *aboutWindowController;
@property (readonly) IBOutlet NSObjectController *emuControlController;
@property (readonly) IBOutlet NSObjectController *cdsSoundController;
@ -70,11 +68,11 @@
@property (readonly) IBOutlet NSObjectController *prefWindowController;
@property (readonly) IBOutlet NSObjectController *cheatWindowController;
@property (readonly) IBOutlet NSObjectController *cdsCoreController;
@property (readonly) IBOutlet FileMigrationDelegate *migrationDelegate;
@property (readonly) IBOutlet InputManager *inputManager;
@property (readonly) IBOutlet NSWindow *prefWindow;
@property (readonly) IBOutlet NSWindow *troubleshootingWindow;
@property (readonly) IBOutlet NSWindow *cheatListWindow;
@property (readonly) IBOutlet NSWindow *migrationWindow;
@property (readonly) IBOutlet NSView *prefGeneralView;
@property (readonly) IBOutlet NSMenu *mLoadStateSlot;
@property (readonly) IBOutlet NSMenu *mSaveStateSlot;
@ -86,7 +84,6 @@
@property (readonly) IBOutlet NSBox *boxFileSystem;
@property (readonly) IBOutlet NSBox *boxMisc;
@property (assign) BOOL migrationFilesPresent;
@property (assign) BOOL isAppRunningOnIntel;
// Emulation Menu
@ -105,8 +102,6 @@
- (void) setupSlotMenuItems;
- (NSMenuItem *) addSlotMenuItem:(NSMenu *)menu slotNumber:(NSUInteger)slotNumber;
- (void) setupUserDefaults;
- (IBAction) showMigrationWindow:(id)sender;
- (IBAction) handleMigrationWindow:(id)sender;
- (void) setRomInfoPanelBoxTitleColors;
@end

View File

@ -19,6 +19,7 @@
#import "appDelegate.h"
#import "DisplayWindowController.h"
#import "EmuControllerDelegate.h"
#import "FileMigrationDelegate.h"
#import "preferencesWindowDelegate.h"
#import "troubleshootingWindowDelegate.h"
#import "cheatWindowDelegate.h"
@ -39,12 +40,10 @@
@synthesize prefWindow;
@synthesize troubleshootingWindow;
@synthesize cheatListWindow;
@synthesize migrationWindow;
@synthesize prefGeneralView;
@synthesize mLoadStateSlot;
@synthesize mSaveStateSlot;
@synthesize inputPrefsView;
@synthesize fileMigrationList;
@synthesize aboutWindowController;
@synthesize emuControlController;
@synthesize cdsSoundController;
@ -52,6 +51,7 @@
@synthesize prefWindowController;
@synthesize cdsCoreController;
@synthesize cheatWindowController;
@synthesize migrationDelegate;
@synthesize inputManager;
@synthesize boxGeneralInfo;
@ -60,7 +60,6 @@
@synthesize boxFileSystem;
@synthesize boxMisc;
@synthesize migrationFilesPresent;
@synthesize isAppRunningOnIntel;
@ -220,6 +219,24 @@
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content];
// Determine if the app was run for the first time.
NSMutableDictionary *appFirstTimeRunDict = [[NSMutableDictionary alloc] initWithDictionary:[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"General_AppFirstTimeRun"]];
NSString *bundleVersionString = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
BOOL isFirstTimeRun = NO;
NSNumber *isFirstTimeRunNumber = (NSNumber *)[appFirstTimeRunDict valueForKey:bundleVersionString];
if (isFirstTimeRunNumber == nil)
{
isFirstTimeRunNumber = [NSNumber numberWithBool:isFirstTimeRun];
}
isFirstTimeRun = [isFirstTimeRunNumber boolValue];
if (appFirstTimeRunDict == nil)
{
appFirstTimeRunDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:isFirstTimeRunNumber, bundleVersionString, nil];
}
// Load a new ROM on launch per user preferences.
const BOOL loadROMOnLaunch = [[NSUserDefaults standardUserDefaults] boolForKey:@"General_AutoloadROMOnLaunch"];
if (loadROMOnLaunch && [emuControl currentRom] == nil)
@ -251,11 +268,21 @@
[emuControl newDisplayWindow:nil];
// Present the file migration window to the user (if they haven't disabled it).
[self setMigrationFilesPresent:NO];
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"General_DoNotAskMigrate"])
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"General_DoNotAskMigrate"] || !isFirstTimeRun)
{
[self showMigrationWindow:nil];
[migrationDelegate updateFileList];
if ([migrationDelegate filesPresent])
{
[[migrationDelegate window] center];
[[migrationDelegate window] makeKeyAndOrderFront:nil];
}
}
// Set that the app has run for the first time.
isFirstTimeRun = YES;
[appFirstTimeRunDict setValue:[NSNumber numberWithBool:isFirstTimeRun] forKey:bundleVersionString];
[[NSUserDefaults standardUserDefaults] setObject:appFirstTimeRunDict forKey:@"General_AppFirstTimeRun"];
[appFirstTimeRunDict release];
}
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
@ -521,45 +548,6 @@
[emuControl setupUserDefaults];
}
- (IBAction) showMigrationWindow:(id)sender
{
NSMutableArray *fileList = [CocoaDSFile completeFileList];
if (fileList != nil)
{
[self setMigrationFilesPresent:([fileList count] == 0) ? NO : YES];
if (sender == nil && ![self migrationFilesPresent])
{
return;
}
}
[fileMigrationList setContent:fileList];
[migrationWindow center];
[migrationWindow makeKeyAndOrderFront:nil];
}
- (IBAction) handleMigrationWindow:(id)sender
{
const NSInteger option = [(NSControl *)sender tag];
NSMutableArray *fileList = [fileMigrationList content];
switch (option)
{
case COCOA_DIALOG_DEFAULT:
[CocoaDSFile copyFileListToCurrent:fileList];
break;
case COCOA_DIALOG_OPTION:
[CocoaDSFile moveFileListToCurrent:fileList];
break;
default:
break;
}
[[(NSControl *)sender window] close];
}
- (void) setRomInfoPanelBoxTitleColors
{
NSColor *boxTitleColor = [NSColor whiteColor];