shithub: choc

Download patch

ref: c2f2fa12a68626a3d2a25231d0aa1c6146d555c3
parent: d109ab268f7c7d140bf76d30b4526ef836e070fe
author: Simon Howard <[email protected]>
date: Sat Jan 9 13:54:04 EST 2010

Initial code to identify file type by extension and add file to command
line.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 1793

--- a/pkg/osx/AppController.h
+++ b/pkg/osx/AppController.h
@@ -24,11 +24,12 @@
 #define LAUNCHER_APPCONTROLLER_H
 
 #include <AppKit/AppKit.h>
-// Uncomment if your application is Renaissance-based
-//#include <Renaissance/Renaissance.h>
 
+#include "LauncherManager.h"
+
 @interface AppController : NSObject
 {
+    LauncherManager *launcherManager;
 }
 
 + (void)initialize;
--- 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
--- a/pkg/osx/LauncherManager.h
+++ b/pkg/osx/LauncherManager.h
@@ -40,6 +40,9 @@
 - (void) launch: (id)sender;
 - (void) runSetup: (id)sender;
 - (void) awakeFromNib;
+- (void) addFileToCommandLine: (NSString *) fileName
+         forArgument: (NSString *) args;
+
 
 @end
 
--- a/pkg/osx/LauncherManager.m
+++ b/pkg/osx/LauncherManager.m
@@ -61,6 +61,12 @@
     }
 }
 
+- (void) addFileToCommandLine: (NSString *) fileName
+         forArgument: (NSString *) args
+{
+    // TODO
+}
+
 - (void) launch: (id)sender
 {
     NSString *iwad;