Make the frontend check both the current bundle as well as the default install location

0110
This commit is contained in:
Six 2009-03-22 00:24:40 +00:00
parent 673e7543c1
commit ba6fb02319
3 changed files with 20 additions and 22 deletions

View file

@ -9,12 +9,12 @@
#import "Controller.h" #import "Controller.h"
#import "ErrorWindow.h" #import "ErrorWindow.h"
#define IOQ3_BUNDLE @"/Applications/ioquake3/ioquake3.app"
#define IOQ3_BIN @"ioquake3.ub" #define IOQ3_BIN @"ioquake3.ub"
@implementation Controller @implementation Controller
- (id)init - (id)init {
{
[super init]; [super init];
quakeData = [[NSMutableData alloc] initWithCapacity:1.0]; quakeData = [[NSMutableData alloc] initWithCapacity:1.0];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(readPipe:) name:NSFileHandleReadCompletionNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(readPipe:) name:NSFileHandleReadCompletionNotification object:nil];
@ -22,14 +22,16 @@
return self; return self;
} }
- (void)dealloc - (void)dealloc {
{
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc]; [super dealloc];
} }
- (IBAction)launch:(id)sender - (IBAction)launch:(id)sender {
{ NSString *ioQuake3Path = [[NSBundle mainBundle] pathForAuxiliaryExecutable:IOQ3_BIN];
if (!ioQuake3Path)
ioQuake3Path = [[NSBundle bundleWithPath:IOQ3_BUNDLE] pathForAuxiliaryExecutable:IOQ3_BIN];
NSPipe *pipe = [NSPipe pipe]; NSPipe *pipe = [NSPipe pipe];
quakeOut = [pipe fileHandleForReading]; quakeOut = [pipe fileHandleForReading];
[quakeOut readInBackgroundAndNotify]; [quakeOut readInBackgroundAndNotify];
@ -41,13 +43,12 @@
NSString *args = [argsTextField stringValue]; NSString *args = [argsTextField stringValue];
if ([args length]) if ([args length])
[quakeTask setArguments:[args componentsSeparatedByString:@" "]]; [quakeTask setArguments:[args componentsSeparatedByString:@" "]];
// tiger sucks // [quakeTask setArguments:[args componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]]; // tiger
//[quakeTask setArguments:[args componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]];
BOOL die = NO; BOOL die = NO;
@try { @try {
[quakeTask setLaunchPath:[[NSBundle mainBundle] pathForAuxiliaryExecutable:IOQ3_BIN]]; [quakeTask setLaunchPath:ioQuake3Path];
[quakeTask launch]; [quakeTask launch];
} }
@catch (NSException *e) { @catch (NSException *e) {
@ -56,7 +57,9 @@
defaultButton:NSLocalizedString(@"OK", @"OK") defaultButton:NSLocalizedString(@"OK", @"OK")
alternateButton:nil alternateButton:nil
otherButton:nil otherButton:nil
informativeTextWithFormat:NSLocalizedString(@"Something is probably wrong with the actual ioquake3 binary.", @"launch failed text")] // informativeTextWithFormat:NSLocalizedString(@"Something is probably wrong with the actual ioquake3 binary.", @"launch failed text")]
// informativeTextWithFormat:NSLocalizedString([@"Unable to find the Quake binary at:\n" stringByAppendingString:ioQuake3Path], @"launch failed text")]
informativeTextWithFormat:NSLocalizedString([[[e reason] stringByAppendingString:@"\n\nExecutable path was:\n"] stringByAppendingString:ioQuake3Path], @"launch failed text")]
runModal]; runModal];
die = YES; die = YES;
} }
@ -69,8 +72,7 @@
return; return;
} }
- (void)readPipe:(NSNotification *)note - (void)readPipe:(NSNotification *)note {
{
if ([note object] == quakeOut) { if ([note object] == quakeOut) {
NSData *outputData = [[note userInfo] objectForKey:NSFileHandleNotificationDataItem]; NSData *outputData = [[note userInfo] objectForKey:NSFileHandleNotificationDataItem];
if ([outputData length]) if ([outputData length])
@ -80,18 +82,16 @@
} }
} }
- (void)taskNote:(NSNotification *)note - (void)taskNote:(NSNotification *)note {
{
if ([note object] == quakeTask) { if ([note object] == quakeTask) {
if ([quakeTask isRunning] == NO) { if ([quakeTask isRunning] == NO) {
if ([quakeTask terminationStatus] != 0) { if ([quakeTask terminationStatus] != 0) {
ErrorWindow *ew = [[[ErrorWindow alloc] init] autorelease]; ErrorWindow *ew = [[[ErrorWindow alloc] init] autorelease];
[ew bitch:[[[NSString alloc] initWithData:quakeData encoding:NSUTF8StringEncoding] autorelease]]; [ew bitch:[[[NSString alloc] initWithData:quakeData encoding:NSUTF8StringEncoding] autorelease]];
} else { }
else
[NSApp terminate:self]; [NSApp terminate:self];
} }
} }
}
} }
@end @end

View file

@ -2,8 +2,7 @@
@implementation ErrorWindow @implementation ErrorWindow
- (void)bitch:(NSString *)errorlog - (void)bitch:(NSString *)errorlog {
{
NSLog(errorlog); NSLog(errorlog);
NSNib *nib = [[NSNib alloc] initWithNibNamed:@"ErrorWindow.nib" bundle:[NSBundle mainBundle]]; NSNib *nib = [[NSNib alloc] initWithNibNamed:@"ErrorWindow.nib" bundle:[NSBundle mainBundle]];

View file

@ -12,8 +12,7 @@
// yes, a whole class just so the fucking app will quit // yes, a whole class just so the fucking app will quit
- (BOOL)windowShouldClose:(id)sender - (BOOL)windowShouldClose:(id)sender {
{
[NSApp terminate:self]; [NSApp terminate:self];
return YES; return YES;
} }