rt300@29
|
1 //
|
rt300@29
|
2 // TimedSessionController.m
|
rt300@29
|
3 // sonicZoom
|
rt300@29
|
4 //
|
rt300@29
|
5 // Created by Robert Tubb on 18/02/2013.
|
rt300@29
|
6 //
|
rt300@29
|
7 //
|
rt300@29
|
8 #import "testApp.h"
|
rt300@29
|
9 #import "TimedSessionController.h"
|
rt300@29
|
10 @interface TimedSessionController()
|
rt300@29
|
11 // private stuff
|
rt300@29
|
12 @end
|
rt300@29
|
13
|
rt300@29
|
14 @implementation TimedSessionController
|
rt300@29
|
15
|
rt300@29
|
16 int orders[6][3] = {{0,1,2},{0,2,1},{1,0,2},{1,2,0},{2,0,1},{2,1,0}};
|
rt300@29
|
17 int theOrder;
|
rt300@29
|
18 int scount;
|
rt300@29
|
19
|
rt300@29
|
20 NSArray *alertMessages = [NSArray arrayWithObjects:
|
rt300@29
|
21 @"Thanks, now try the sliders only",
|
rt300@29
|
22 @"Thanks, now try the sliders and the Zoomer together",
|
rt300@29
|
23 @"Thanks, now try the zoomer only",
|
rt300@29
|
24 @"Thanks, now please take the questionnaire",nil];
|
rt300@29
|
25
|
rt300@29
|
26 // nicer if it was initWithAppRef ?
|
rt300@29
|
27 - (void)setAppRef:(id)theOFApp{
|
rt300@29
|
28 self.theOFAppRef = theOFApp;
|
rt300@29
|
29 theOrder = arc4random() % 6;
|
rt300@29
|
30 NSLog(@"the order: %d", theOrder);
|
rt300@29
|
31
|
rt300@29
|
32 scount = 0;
|
rt300@29
|
33 }
|
rt300@29
|
34 -(void)startTimer{
|
rt300@29
|
35 // SHOW FIRST PROMPT
|
rt300@29
|
36 NSString *themessage;
|
rt300@29
|
37 themessage = [alertMessages objectAtIndex:orders[theOrder][0]];
|
rt300@29
|
38 UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Thanks!"
|
rt300@29
|
39 message:themessage
|
rt300@29
|
40 delegate:self
|
rt300@29
|
41 cancelButtonTitle:@"Continue"
|
rt300@29
|
42 otherButtonTitles:nil];
|
rt300@29
|
43 alert.alertViewStyle = UIAlertViewStyleDefault;
|
rt300@29
|
44 [alert show];
|
rt300@29
|
45 [alert release];
|
rt300@29
|
46
|
rt300@29
|
47 }
|
rt300@29
|
48 -(void)resetTime:(int)newTime{
|
rt300@29
|
49
|
rt300@29
|
50 }
|
rt300@29
|
51
|
rt300@29
|
52 // ALERT
|
rt300@29
|
53
|
rt300@29
|
54
|
rt300@29
|
55 -(void)showNextPrompt{
|
rt300@29
|
56 NSString *themessage;
|
rt300@29
|
57 scount++;
|
rt300@30
|
58 ((testApp *)self.theOFAppRef)->moveVel = TwoVector(); // stops movement
|
rt300@29
|
59 if(scount < 3){
|
rt300@29
|
60 themessage = [alertMessages objectAtIndex:orders[theOrder][scount] ];
|
rt300@29
|
61 }else{
|
rt300@29
|
62 themessage = [alertMessages objectAtIndex:3 ];
|
rt300@29
|
63 }
|
rt300@29
|
64 UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Thanks!"
|
rt300@29
|
65 message:themessage
|
rt300@29
|
66 delegate:self
|
rt300@29
|
67 cancelButtonTitle:@"Continue"
|
rt300@29
|
68 otherButtonTitles:nil];
|
rt300@29
|
69 alert.alertViewStyle = UIAlertViewStyleDefault;
|
rt300@29
|
70 [alert show];
|
rt300@29
|
71 [alert release];
|
rt300@29
|
72
|
rt300@29
|
73 }
|
rt300@29
|
74
|
rt300@29
|
75 -(void)cancelTimers{
|
rt300@29
|
76 scount = 0;
|
rt300@29
|
77 if(self.theCurrentTimer){
|
rt300@29
|
78 [self.theCurrentTimer invalidate];
|
rt300@29
|
79 self.theCurrentTimer = nil;
|
rt300@29
|
80 }
|
rt300@29
|
81 }
|
rt300@29
|
82 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
|
rt300@29
|
83
|
rt300@29
|
84 NSLog(@"OK TO NEXT VIEW");
|
rt300@29
|
85
|
rt300@29
|
86 if(scount < 3){
|
rt300@29
|
87 NSInteger next = orders[theOrder][scount];
|
rt300@30
|
88
|
rt300@29
|
89 ((testApp *)self.theOFAppRef)->interfaceSelected(next);
|
rt300@29
|
90
|
rt300@29
|
91 self.theCurrentTimer = [NSTimer scheduledTimerWithTimeInterval:SECONDS_PER_INTERFACE target:self selector:@selector(showNextPrompt) userInfo:nil repeats:NO];
|
rt300@29
|
92
|
rt300@29
|
93 }else{
|
rt300@29
|
94 ((testApp *)self.theOFAppRef)->showQuestionnaire();
|
rt300@29
|
95 scount = 0; // incase we try again
|
rt300@29
|
96 self.theCurrentTimer = nil;
|
rt300@29
|
97 }
|
rt300@29
|
98
|
rt300@29
|
99 }
|
rt300@29
|
100
|
rt300@29
|
101
|
rt300@29
|
102 @end
|