-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRyderController.m
97 lines (77 loc) · 2.63 KB
/
RyderController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Ryder.app
//
// (c) 2008-2009 Liam Cooke
// MIT Licensed -- see LICENSE.txt
#import "RyderController.h"
#import "RyderNamer.h"
//static NSString *speakNames = @"speakNames";
@implementation RyderController
@synthesize window;
-(id)init
{
self = [super init];
if (self) {
ryder = [[RyderNamer alloc] init];
speechEnabled = NO; //[[NSUserDefaults standardUserDefaults] boolForKey:speakNames];
speechSynth = [NSSpeechSynthesizer new];
voices = [NSArray arrayWithObjects:
@"com.apple.speech.synthesis.voice.Alex",
@"com.apple.speech.synthesis.voice.Alex",
@"com.apple.speech.synthesis.voice.Alex",
@"com.apple.speech.synthesis.voice.Bruce",
@"com.apple.speech.synthesis.voice.Bruce",
nil];
}
return self;
}
-(IBAction)newName:(id)sender
{
NSMutableArray *nameParts = [[ryder name] mutableCopy];
nameView.name = [nameParts componentsJoinedByString:@""];
[nameView display];
if (speechEnabled) {
if ([speechSynth isSpeaking])
[speechSynth stopSpeaking];
if ([[nameParts objectAtIndex:1] isEqualToString:@" Mc"])
[nameParts replaceObjectAtIndex:1 withObject:@" [[inpt PHON]] ~mAXk [[inpt TEXT]] [[emph +]] "];
else
[nameParts replaceObjectAtIndex:1 withObject:@" [[slnc 40]] [[emph +]] "];
NSString *last = [[[nameParts objectAtIndex:2]
stringByReplacingOccurrencesOfString:@"-" withString:@""]
stringByReplacingOccurrencesOfString:@"." withString:@" [[emph -]] "];
[nameParts replaceObjectAtIndex:2 withObject:last];
NSString *speakName = [nameParts componentsJoinedByString:@""];
speakName = [speakName stringByReplacingOccurrencesOfString:@"-" withString:@" "];
speakName = [speakName stringByAppendingString:(random()%3==0 ? @"!" : @".")];
//NSLog(@"Speaking: %@", speakName);
[speechSynth setVoice:[voices objectAtIndex:random() % [voices count]]];
[speechSynth startSpeakingString:speakName];
}
}
-(IBAction)enableSpeech:(NSButton*)sender
{
speechEnabled = [sender state] ? YES : NO;
//[[NSUserDefaults standardUserDefaults] setBool:speechEnabled forKey:speakNames];
}
-(void)awakeFromNib
{
[window setDelegate:self];
[window center];
}
-(void)applicationWillFinishLaunching:(NSNotification*)notification
{
PFMoveToApplicationsFolderIfNecessary();
[window setAlphaValue:0.0];
[window makeKeyAndOrderFront:self];
[window.animator setAlphaValue:1.0];
}
-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication
{
return YES;
}
-(BOOL)windowShouldClose:(id)theWindow
{
//[window.animator setAlphaValue:0.0];
return YES;
}
@end