of bundles that have executable code in them. Bleh.
*/
+#import <TargetConditionals.h>
#import "SaverRunner.h"
#import "SaverListController.h"
#import "XScreenSaverGLView.h"
-#import <TargetConditionals.h>
+#import "yarandom.h"
#ifdef USE_IPHONE
}
-- (void) openPreferences: (id) sender
+- (void) openPreferences: (NSString *) saver
{
- NSString *saver = [listController selected];
- if (! saver) return;
-
[self loadSaver:saver launch:NO];
if (! saverView) return;
+ NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
+ [prefs setObject:saver forKey:@"selectedSaverName"];
+ [prefs synchronize];
+
[rootViewController pushViewController: [saverView configureView]
animated:YES];
}
-- (void) loadSaverMenu: (id) sender
-{
- NSString *saver = [listController selected];
- NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
- if (saver) {
- [prefs setObject:saver forKey:@"selectedSaverName"];
- } else {
- [prefs removeObjectForKey:@"selectedSaverName"];
- }
- [self saveScreenshot];
- [self selectedSaverDidChange:nil];
-}
-
#endif // USE_IPHONE
# else // USE_IPHONE
+ NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
+ [prefs setObject:name forKey:@"selectedSaverName"];
+ [prefs synchronize];
+
if (saverName && [saverName isEqualToString: name]) {
- if (launch && ![saverView isAnimating]) {
- [window addSubview: saverView];
- [saverView startAnimation];
- }
- return;
+ if ([saverView isAnimating])
+ return;
+ else
+ goto LAUNCH;
}
saverName = name;
selector:@selector(didRotate:)
name:UIDeviceOrientationDidChangeNotification object:nil];
+ LAUNCH:
if (launch) {
+ [self saveScreenshot];
[window addSubview: saverView];
+ [saverView becomeFirstResponder];
[saverView startAnimation];
}
# endif // USE_IPHONE
}
+# ifndef USE_IPHONE
+
- (void)aboutPanel:(id)sender
{
-# ifndef USE_IPHONE
NSDictionary *bd = [saverBundle infoDictionary];
NSMutableDictionary *d = [NSMutableDictionary dictionaryWithCapacity:20];
[[NSApplication sharedApplication]
orderFrontStandardAboutPanelWithOptions:d];
-
-# else // USE_IPHONE
-
- NSDictionary *bd = [[NSBundle mainBundle] infoDictionary];
- NSString *body = [bd objectForKey:@"CFBundleGetInfoString"];
-
- body = [body stringByReplacingOccurrencesOfString:@", " withString:@",\n"];
- body = [body stringByAppendingString:
- @"\n\n"
- "Double-tap to run.\n\n"
- "Double-tap again to\n"
- "return to this list."];
-
- [[[UIAlertView alloc] initWithTitle: @""
- message: body
- delegate: nil
- cancelButtonTitle: @"OK"
- otherButtonTitles: nil]
- show];
+}
# endif // USE_IPHONE
-}
}
-- (UIViewController *) makeMenu
-{
- listController = [[[SaverListController alloc]
- initWithNames:saverNames
- descriptions:[self makeDescTable]]
- retain];
- UIBarButtonItem *run = [[[UIBarButtonItem alloc]
- initWithTitle:@"Run"
- style: UIBarButtonItemStylePlain
- target: self
- action: @selector(loadSaverMenu:)]
- autorelease];
- UIBarButtonItem *about = [[[UIBarButtonItem alloc]
- initWithTitle: @"About"
- style: UIBarButtonItemStylePlain
- target: self
- action: @selector(aboutPanel:)]
- autorelease];
- UIBarButtonItem *pref = [[[UIBarButtonItem alloc]
- initWithTitle:@"Settings"
- style: UIBarButtonItemStylePlain
- target: self
- action: @selector(openPreferences:)]
- autorelease];
- NSArray *a = [NSArray arrayWithObjects: pref, about, nil];
-
- [run setEnabled:NO];
- [about setEnabled:YES];
- [pref setEnabled:NO];
- listController.navigationItem.leftBarButtonItem = run;
- listController.navigationItem.rightBarButtonItems = a;
-
- return listController;
-}
-
#endif // USE_IPHONE
rootViewController = [[[RotateyViewController alloc] init] retain];
[window setRootViewController: rootViewController];
- [rootViewController pushViewController:[self makeMenu]
- animated:YES];
+
+ SaverListController *menu = [[SaverListController alloc]
+ initWithNames:saverNames
+ descriptions:[self makeDescTable]];
+ [rootViewController pushViewController:menu animated:YES];
+ [menu becomeFirstResponder];
[window makeKeyAndVisible];
[window setAutoresizesSubviews:YES];
(UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight)];
- // Has to be after the list window is up, or we get black.
- [self saveScreenshot];
+ application.applicationSupportsShakeToEdit = YES;
# endif // USE_IPHONE
# ifdef USE_IPHONE
NSString *prev = [prefs stringForKey:@"selectedSaverName"];
+
if (forced)
prev = forced;
prev = [saverNames objectAtIndex: (random() % [saverNames count])];
if (prev)
- [listController scrollTo: prev];
+ [menu scrollTo: prev];
# endif // USE_IPHONE
if (forced)