diff --git a/src/macosx/AboutBox.m b/src/macosx/AboutBox.m index 8af51887e..067011e7b 100644 --- a/src/macosx/AboutBox.m +++ b/src/macosx/AboutBox.m @@ -14,18 +14,17 @@ static AboutBox *sharedInstance = nil; + (AboutBox *)sharedInstance { - return sharedInstance ? sharedInstance : [[self alloc] init]; + return sharedInstance ? sharedInstance : [[self alloc] init]; } - (id)init { - if (sharedInstance) { - [self dealloc]; - } else { - sharedInstance = [super init]; - } + if (sharedInstance) + [self dealloc]; + else + sharedInstance = [super init]; - return sharedInstance; + return sharedInstance; } /*------------------------------------------------------------------------------ @@ -33,88 +32,79 @@ static AboutBox *sharedInstance = nil; *-----------------------------------------------------------------------------*/ - (IBAction)showPanel:(id)sender { - NSRect creditsBounds; - - if (!appNameField) + NSRect creditsBounds; + + if (!appNameField) + { + NSWindow *theWindow; + NSString *creditsPath; + NSAttributedString *creditsString; + NSString *appName; + NSString *versionString; + NSDictionary *infoDictionary; + CFBundleRef localInfoBundle; + NSDictionary *localInfoDict; + + if (![NSBundle loadNibNamed:@"AboutBox" owner:self]) { - NSWindow *theWindow; - NSString *creditsPath; - NSAttributedString *creditsString; - NSString *appName; - NSString *versionString; - NSDictionary *infoDictionary; - CFBundleRef localInfoBundle; - NSDictionary *localInfoDict; - - if (![NSBundle loadNibNamed:@"AboutBox" owner:self]) - { - NSLog( @"Failed to load AboutBox.nib" ); - NSBeep(); - return; - } - theWindow = [appNameField window]; - - // Get the info dictionary (Info.plist) - infoDictionary = [[NSBundle mainBundle] infoDictionary]; - - - // Get the localized info dictionary (InfoPlist.strings) - localInfoBundle = CFBundleGetMainBundle(); - localInfoDict = (NSDictionary *) - CFBundleGetLocalInfoDictionary( localInfoBundle ); - - // Setup the app name field - appName = @"StellaOSX"; - [appNameField setStringValue:appName]; - - // Set the about box window title - [theWindow setTitle:[NSString stringWithFormat:@"About %@", appName]]; - - // Setup the version field - versionString = [infoDictionary objectForKey:@"CFBundleVersion"]; - [versionField setStringValue:[NSString stringWithFormat:@"Version %@", - versionString]]; - - // Setup our credits - creditsPath = [[NSBundle mainBundle] pathForResource:@"Credits" - ofType:@"html"]; - - creditsString = [[NSAttributedString alloc] initWithPath:creditsPath - documentAttributes:nil]; - - [creditsField replaceCharactersInRange:NSMakeRange( 0, 0 ) - withRTF:[creditsString RTFFromRange: - NSMakeRange( 0, [creditsString length] ) - documentAttributes:nil]]; - - // Prepare some scroll info - creditsBounds = [creditsField bounds]; - maxScrollHeight = creditsBounds.size.height*2.75; - - // Setup the window - [theWindow setExcludedFromWindowsMenu:YES]; - [theWindow setMenu:nil]; - [theWindow center]; - + NSLog( @"Failed to load AboutBox.nib" ); + NSBeep(); + return; } + theWindow = [appNameField window]; + + // Get the info dictionary (Info.plist) + infoDictionary = [[NSBundle mainBundle] infoDictionary]; + + // Get the localized info dictionary (InfoPlist.strings) + localInfoBundle = CFBundleGetMainBundle(); + localInfoDict = (NSDictionary *) CFBundleGetLocalInfoDictionary( localInfoBundle ); + + // Setup the app name field + appName = @"StellaOSX"; + [appNameField setStringValue:appName]; + + // Set the about box window title + [theWindow setTitle:[NSString stringWithFormat:@"About %@", appName]]; + + // Setup the version field + versionString = [infoDictionary objectForKey:@"CFBundleVersion"]; + [versionField setStringValue:[NSString stringWithFormat:@"Version %@", versionString]]; + + // Setup our credits + creditsPath = [[NSBundle mainBundle] pathForResource:@"Credits" ofType:@"html"]; + creditsString = [[NSAttributedString alloc] initWithPath:creditsPath documentAttributes:nil]; + + [creditsField replaceCharactersInRange:NSMakeRange( 0, 0 ) + withRTF:[creditsString RTFFromRange: + NSMakeRange( 0, [creditsString length] ) + documentAttributes:nil]]; + + // Prepare some scroll info + creditsBounds = [creditsField bounds]; + maxScrollHeight = creditsBounds.size.height*2.75; + + // Setup the window + [theWindow setExcludedFromWindowsMenu:YES]; + [theWindow setMenu:nil]; + [theWindow center]; + } - if (![[appNameField window] isVisible]) - { - currentPosition = 0; - restartAtTop = NO; - [creditsField scrollPoint:NSMakePoint( 0, 0 )]; - } + if (![[appNameField window] isVisible]) + { + currentPosition = 0; + restartAtTop = NO; + [creditsField scrollPoint:NSMakePoint( 0, 0 )]; + } - // Show the window - [NSApp runModalForWindow:[appNameField window]]; - [[appNameField window] close]; - + // Show the window + [NSApp runModalForWindow:[appNameField window]]; + [[appNameField window] close]; } - (void)OK:(id)sender { - [NSApp stopModal]; + [NSApp stopModal]; } @end - diff --git a/src/macosx/Info-StellaOSX.plist b/src/macosx/Info-StellaOSX.plist index 53ddd2b9d..57d8f4c08 100644 --- a/src/macosx/Info-StellaOSX.plist +++ b/src/macosx/Info-StellaOSX.plist @@ -33,7 +33,7 @@ CFBundleExecutable StellaOSX CFBundleGetInfoString - StellaOSX 3.0 + StellaOSX CFBundleHelpBookFolder docs CFBundleHelpBookName @@ -45,13 +45,13 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - StellaOSX 3.0 + StellaOSX CFBundlePackageType APPL CFBundleSignature StLa CFBundleVersion - StellaOSX 3.0 + 3.0 NSMainNibFile SDLMain.nib NSPrincipalClass diff --git a/src/macosx/Preferences.h b/src/macosx/Preferences.h index 8d2bdd84b..a5d847d68 100755 --- a/src/macosx/Preferences.h +++ b/src/macosx/Preferences.h @@ -10,8 +10,9 @@ /* $Id$ */ #import -@interface Preferences : NSObject { - NSUserDefaults *defaults; /* Defaults pointer */ +@interface Preferences : NSObject +{ + NSUserDefaults *defaults; /* Defaults pointer */ } + (Preferences *)sharedInstance; diff --git a/src/macosx/Preferences.m b/src/macosx/Preferences.m index 9e995d52d..46f4e4c1f 100755 --- a/src/macosx/Preferences.m +++ b/src/macosx/Preferences.m @@ -15,38 +15,39 @@ void prefsSetString(const char* key, const char* value) { - [[Preferences sharedInstance] setString:key:value]; + [[Preferences sharedInstance] setString:key:value]; } void prefsGetString(const char* key, char* value, int size) { - [[Preferences sharedInstance] getString:key:value:size]; + [[Preferences sharedInstance] getString:key:value:size]; } void prefsSave(void) { - [[Preferences sharedInstance] save]; + [[Preferences sharedInstance] save]; } @implementation Preferences static Preferences *sharedInstance = nil; -+ (Preferences *)sharedInstance { - return sharedInstance ? sharedInstance : [[self alloc] init]; ++ (Preferences *)sharedInstance +{ + return sharedInstance ? sharedInstance : [[self alloc] init]; } - (id)init { - defaults = [NSUserDefaults standardUserDefaults]; - sharedInstance = self; - return(self); + defaults = [NSUserDefaults standardUserDefaults]; + sharedInstance = self; + return(self); } - (void)setString:(const char *)key:(const char *)value { NSString* theKey = [NSString stringWithCString:key encoding:NSASCIIStringEncoding]; - NSString* theValue = [NSString stringWithCString:value encoding:NSASCIIStringEncoding]; + NSString* theValue = [NSString stringWithCString:value encoding:NSASCIIStringEncoding]; [defaults setObject:theValue forKey:theKey]; [theKey release]; @@ -56,10 +57,10 @@ static Preferences *sharedInstance = nil; - (void)getString:(const char *)key:(char *)value:(int)size { NSString* theKey = [NSString stringWithCString:key encoding:NSASCIIStringEncoding]; - NSString* theValue = [defaults objectForKey:theKey]; - if (theValue != nil) + NSString* theValue = [defaults objectForKey:theKey]; + if (theValue != nil) strncpy(value, [theValue cStringUsingEncoding: NSASCIIStringEncoding], size); - else + else value[0] = 0; [theKey release]; @@ -68,9 +69,7 @@ static Preferences *sharedInstance = nil; - (void)save { - [defaults synchronize]; + [defaults synchronize]; } - - @end