diff options
author | Simon Howard | 2011-05-08 18:29:46 +0000 |
---|---|---|
committer | Simon Howard | 2011-05-08 18:29:46 +0000 |
commit | 351c1be33154d12b55e658cfb8f3101858fba63c (patch) | |
tree | 7e7a7ba0d4d26380be88ee8852a7bc54ec3d9fab /pkg | |
parent | 6e9294e05572d46d3897744d78f4604b412ceb65 (diff) | |
download | chocolate-doom-351c1be33154d12b55e658cfb8f3101858fba63c.tar.gz chocolate-doom-351c1be33154d12b55e658cfb8f3101858fba63c.tar.bz2 chocolate-doom-351c1be33154d12b55e658cfb8f3101858fba63c.zip |
Allow IWAD files to be double-clicked in the finder to set the IWAD
configuration.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2334
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/osx/AppController.m | 8 | ||||
-rw-r--r-- | pkg/osx/IWADController.h | 1 | ||||
-rw-r--r-- | pkg/osx/IWADController.m | 39 | ||||
-rw-r--r-- | pkg/osx/LauncherManager.h | 1 | ||||
-rw-r--r-- | pkg/osx/LauncherManager.m | 5 |
5 files changed, 54 insertions, 0 deletions
diff --git a/pkg/osx/AppController.m b/pkg/osx/AppController.m index a26a7c9e..ba8dae9b 100644 --- a/pkg/osx/AppController.m +++ b/pkg/osx/AppController.m @@ -83,6 +83,14 @@ { NSString *extension; + // This may be an IWAD. If so, add it to the IWAD configuration; + // don't add it like a PWAD. + + if ([self->launcherManager addIWADPath: fileName]) + { + return YES; + } + // If this is the first file added, clear out the existing // command line. This allows us to select multiple files // in the finder and open them all together (for TCs, etc). diff --git a/pkg/osx/IWADController.h b/pkg/osx/IWADController.h index 90f44667..7464af9f 100644 --- a/pkg/osx/IWADController.h +++ b/pkg/osx/IWADController.h @@ -47,6 +47,7 @@ - (void) saveConfig; - (char *) doomWadPath; - (void) setEnvironment; +- (BOOL) addIWADPath: (NSString *) path; @end diff --git a/pkg/osx/IWADController.m b/pkg/osx/IWADController.m index 3c596850..0c55b3f5 100644 --- a/pkg/osx/IWADController.m +++ b/pkg/osx/IWADController.m @@ -343,5 +343,44 @@ static NSString *IWADFilenames[NUM_IWAD_TYPES + 1] = //free(env); } +// Examine a path to a WAD and determine whether it is an IWAD file. +// If so, it is added to the IWAD configuration, and true is returned. + +- (BOOL) addIWADPath: (NSString *) path +{ + IWADLocation *iwadList[NUM_IWAD_TYPES]; + NSArray *pathComponents; + NSString *filename; + unsigned int i; + + [self getIWADList: iwadList]; + + // Find an IWAD file that matches the filename in the path that we + // have been given. + + pathComponents = [path pathComponents]; + filename = [pathComponents objectAtIndex: [pathComponents count] - 1]; + + for (i = 0; i < NUM_IWAD_TYPES; ++i) + { + if ([filename caseInsensitiveCompare: IWADFilenames[i]] == 0) + { + // Configure this IWAD. + + [iwadList[i] setLocation: path]; + + // Rebuild dropdown list and select the new IWAD. + + [self setDropdownList]; + [self->iwadSelector selectItemWithTitle:IWADLabels[i]]; + return YES; + } + } + + // No IWAD found with this name. + + return NO; +} + @end diff --git a/pkg/osx/LauncherManager.h b/pkg/osx/LauncherManager.h index 712bc093..1c8a5187 100644 --- a/pkg/osx/LauncherManager.h +++ b/pkg/osx/LauncherManager.h @@ -41,6 +41,7 @@ - (void) runSetup: (id)sender; - (void) awakeFromNib; - (void) clearCommandLine; +- (BOOL) addIWADPath: (NSString *) path; - (void) addFileToCommandLine: (NSString *) fileName forArgument: (NSString *) args; - (void) openTerminal: (id) sender; diff --git a/pkg/osx/LauncherManager.m b/pkg/osx/LauncherManager.m index df1ad18e..937c0d98 100644 --- a/pkg/osx/LauncherManager.m +++ b/pkg/osx/LauncherManager.m @@ -358,5 +358,10 @@ static NSString *AppendQuotedFilename(NSString *str, NSString *fileName) [self setConfig]; } +- (BOOL) addIWADPath: (NSString *) path +{ + return [self->iwadController addIWADPath: path]; +} + @end |