From 6921f30a44e0bdf1c3a2f8982e4a8cd290c22462 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 4 Jan 2010 22:01:32 +0000 Subject: Import OS X launcher code to trunk. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1784 --- pkg/osx/AppController.m | 87 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 pkg/osx/AppController.m (limited to 'pkg/osx/AppController.m') diff --git a/pkg/osx/AppController.m b/pkg/osx/AppController.m new file mode 100644 index 00000000..81dc56a9 --- /dev/null +++ b/pkg/osx/AppController.m @@ -0,0 +1,87 @@ +/* ... */ +//----------------------------------------------------------------------------- +// +// Copyright(C) 2009 Simon Howard +// +// This program 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 program 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 this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +//----------------------------------------------------------------------------- + +#include "AppController.h" + +@implementation AppController + ++ (void)initialize +{ + NSMutableDictionary *defaults = [NSMutableDictionary dictionary]; + + /* + * Register your app's defaults here by adding objects to the + * dictionary, eg + * + * [defaults setObject:anObject forKey:keyForThatObject]; + * + */ + + [[NSUserDefaults standardUserDefaults] registerDefaults:defaults]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + +- (id)init +{ + if ((self = [super init])) + { + } + + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +- (void)awakeFromNib +{ + [[NSApp mainMenu] setTitle:@"ChocolateDoom"]; +} + +- (void)applicationDidFinishLaunching:(NSNotification *)aNotif +{ +// Uncomment if your application is Renaissance-based +// [NSBundle loadGSMarkupNamed:@"Main" owner:self]; +} + +- (BOOL)applicationShouldTerminate:(id)sender +{ + return YES; +} + +- (void)applicationWillTerminate:(NSNotification *)aNotif +{ +} + +- (BOOL)application:(NSApplication *)application openFile:(NSString *)fileName +{ + return NO; +} + +- (void)showPrefPanel:(id)sender +{ +} + +@end + -- cgit v1.2.3 From d109ab268f7c7d140bf76d30b4526ef836e070fe Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 9 Jan 2010 18:38:48 +0000 Subject: Hook in AppController as delegate for application, add file associations to property list file. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1792 --- pkg/osx/AppController.m | 1 + 1 file changed, 1 insertion(+) (limited to 'pkg/osx/AppController.m') diff --git a/pkg/osx/AppController.m b/pkg/osx/AppController.m index 81dc56a9..bf72af63 100644 --- a/pkg/osx/AppController.m +++ b/pkg/osx/AppController.m @@ -76,6 +76,7 @@ - (BOOL)application:(NSApplication *)application openFile:(NSString *)fileName { + printf("File selected to open: '%s'\n", [fileName UTF8String]); return NO; } -- cgit v1.2.3 From c2f2fa12a68626a3d2a25231d0aa1c6146d555c3 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 9 Jan 2010 18:54:04 +0000 Subject: Initial code to identify file type by extension and add file to command line. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1793 --- pkg/osx/AppController.m | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'pkg/osx/AppController.m') diff --git a/pkg/osx/AppController.m b/pkg/osx/AppController.m index bf72af63..03a5965b 100644 --- a/pkg/osx/AppController.m +++ b/pkg/osx/AppController.m @@ -74,10 +74,29 @@ { } -- (BOOL)application:(NSApplication *)application openFile:(NSString *)fileName +- (BOOL) application:(NSApplication *) application + openFile:(NSString *) fileName { - printf("File selected to open: '%s'\n", [fileName UTF8String]); - return NO; + NSString *extension; + + extension = [fileName pathExtension]; + + if (![extension caseInsensitiveCompare: @"wad"]) + { + [self->launcherManager addFileToCommandLine: fileName + forArgument: @"-merge"]; + } + else if (![extension caseInsensitiveCompare: @"deh"]) + { + [self->launcherManager addFileToCommandLine: fileName + forArgument: @"-deh"]; + } + else + { + return NO; + } + + return YES; } - (void)showPrefPanel:(id)sender -- cgit v1.2.3 From 160ff32f2fb8ba7112938790044684c61a0b07b1 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 11 Jan 2010 19:10:42 +0000 Subject: Insert new files into the command line at the correct location, allowing multiple files to be opened at once. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1803 --- pkg/osx/AppController.m | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'pkg/osx/AppController.m') diff --git a/pkg/osx/AppController.m b/pkg/osx/AppController.m index 03a5965b..32afd9c4 100644 --- a/pkg/osx/AppController.m +++ b/pkg/osx/AppController.m @@ -46,6 +46,8 @@ { } + self->filesAdded = NO; + return self; } @@ -79,6 +81,17 @@ { NSString *extension; + // 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). + + if (!self->filesAdded) + { + [self->launcherManager clearCommandLine]; + } + + // Add file with appropriate command line option based on extension: + extension = [fileName pathExtension]; if (![extension caseInsensitiveCompare: @"wad"]) @@ -96,6 +109,8 @@ return NO; } + self->filesAdded = YES; + return YES; } -- cgit v1.2.3 From d1b0870951eaba66da1e11716898b65cbc96302a Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 12 Jan 2010 20:09:54 +0000 Subject: Set main menu title based on package name, not fixed string. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1807 --- pkg/osx/AppController.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'pkg/osx/AppController.m') diff --git a/pkg/osx/AppController.m b/pkg/osx/AppController.m index 32afd9c4..a26a7c9e 100644 --- a/pkg/osx/AppController.m +++ b/pkg/osx/AppController.m @@ -22,6 +22,8 @@ #include "AppController.h" +#include "config.h" + @implementation AppController + (void)initialize @@ -58,7 +60,7 @@ - (void)awakeFromNib { - [[NSApp mainMenu] setTitle:@"ChocolateDoom"]; + [[NSApp mainMenu] setTitle:@PACKAGE_NAME]; } - (void)applicationDidFinishLaunching:(NSNotification *)aNotif -- cgit v1.2.3