Mercurial > hg > soniczoomios
view TimedSessionController.mm @ 49:178642d134a7 tip
xtra files
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Wed, 01 May 2013 17:34:33 +0100 |
parents | 92dba082d957 |
children |
line wrap: on
line source
// // TimedSessionController.m // sonicZoom // // Created by Robert Tubb on 18/02/2013. // // #import "testApp.h" #import "TimedSessionController.h" @interface TimedSessionController() // private stuff @end @implementation TimedSessionController int orders[6][3] = {{0,1,2},{0,2,1},{1,0,2},{1,2,0},{2,0,1},{2,1,0}}; int theOrder; int scount; NSArray *alertMessages = [NSArray arrayWithObjects: @"Now try the sliders only.", @"Now try the sliders and the Zoomer together.", @"Now try the zoomer only.", @"Now please take the questionnaire.",nil]; // nicer if it was initWithAppRef ? - (void)setAppRef:(id)theOFApp{ self.theOFAppRef = theOFApp; theOrder = arc4random() % 6; scount = 0; } -(void)startTimer{ // SHOW FIRST PROMPT NSString *themessage; themessage = [alertMessages objectAtIndex:orders[theOrder][0]]; UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Thanks!" message:[themessage stringByAppendingString:@" Press play to start sound."] delegate:self cancelButtonTitle:@"Continue" otherButtonTitles:nil]; alert.alertViewStyle = UIAlertViewStyleDefault; [alert show]; [alert release]; } -(void)resetTime:(int)newTime{ } // ALERT -(void)showNextPrompt{ NSString *themessage; scount++; ((testApp *)self.theOFAppRef)->moveVel = TwoVector(); // stops movement if(scount < 3){ themessage = [alertMessages objectAtIndex:orders[theOrder][scount] ]; }else{ themessage = [alertMessages objectAtIndex:3 ]; } NSString * topmsg; if(scount == 0){ topmsg = @"OK"; }else{ topmsg = @"Thanks!"; } UIAlertView * alert = [[UIAlertView alloc] initWithTitle:topmsg message:themessage delegate:self cancelButtonTitle:@"Continue" otherButtonTitles:nil]; alert.alertViewStyle = UIAlertViewStyleDefault; [alert show]; [alert release]; } -(void)cancelTimers{ scount = 0; if(self.theCurrentTimer){ [self.theCurrentTimer invalidate]; self.theCurrentTimer = nil; } } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ NSLog(@"OK TO NEXT VIEW"); if(scount < 3){ NSInteger next = orders[theOrder][scount]; ((testApp *)self.theOFAppRef)->interfaceSelected(next); self.theCurrentTimer = [NSTimer scheduledTimerWithTimeInterval:SECONDS_PER_INTERFACE target:self selector:@selector(showNextPrompt) userInfo:nil repeats:NO]; }else{ ((testApp *)self.theOFAppRef)->showQuestionnaire(); scount = 0; // incase we try again self.theCurrentTimer = nil; } } @end