| 1 |
/* $Id$ */ |
|---|
| 2 |
|
|---|
| 3 |
/* |
|---|
| 4 |
* Copyright (c) 2000-2006 Axel Andersson |
|---|
| 5 |
* All rights reserved. |
|---|
| 6 |
* |
|---|
| 7 |
* Redistribution and use in source and binary forms, with or without |
|---|
| 8 |
* modification, are permitted provided that the following conditions |
|---|
| 9 |
* are met: |
|---|
| 10 |
* 1. Redistributions of source code must retain the above copyright |
|---|
| 11 |
* notice, this list of conditions and the following disclaimer. |
|---|
| 12 |
* 2. Redistributions in binary form must reproduce the above copyright |
|---|
| 13 |
* notice, this list of conditions and the following disclaimer in the |
|---|
| 14 |
* documentation and/or other materials provided with the distribution. |
|---|
| 15 |
* |
|---|
| 16 |
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND |
|---|
| 17 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 18 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|---|
| 19 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE |
|---|
| 20 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|---|
| 21 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|---|
| 22 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|---|
| 23 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|---|
| 24 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|---|
| 25 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|---|
| 26 |
* SUCH DAMAGE. |
|---|
| 27 |
*/ |
|---|
| 28 |
|
|---|
| 29 |
#import "Controller.h" |
|---|
| 30 |
#import "Settings.h" |
|---|
| 31 |
#import "Session.h" |
|---|
| 32 |
#import "Tutor.h" |
|---|
| 33 |
|
|---|
| 34 |
@implementation Controller |
|---|
| 35 |
|
|---|
| 36 |
- (id)init { |
|---|
| 37 |
self = [super init]; |
|---|
| 38 |
|
|---|
| 39 |
_tutor = [[Tutor alloc] init]; |
|---|
| 40 |
|
|---|
| 41 |
return self; |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
- (void)dealloc { |
|---|
| 46 |
[_tutor release]; |
|---|
| 47 |
|
|---|
| 48 |
[super dealloc]; |
|---|
| 49 |
} |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
#pragma mark - |
|---|
| 54 |
|
|---|
| 55 |
- (void)awakeFromNib { |
|---|
| 56 |
// --- update the settings menu from prefs |
|---|
| 57 |
[self updateSettings]; |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
/* |
|---|
| 63 |
Called when the application receives a shutdown notice, i.e. the user quits. |
|---|
| 64 |
*/ |
|---|
| 65 |
|
|---|
| 66 |
- (void)applicationWillTerminate:(NSNotification *)notification { |
|---|
| 67 |
[Settings setObject:[windowTutor stringWithSavedFrame] |
|---|
| 68 |
forKey:kDefaultsTutorPosition]; |
|---|
| 69 |
} |
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
/* |
|---|
| 74 |
Called when the tutor window is about to be closed. |
|---|
| 75 |
*/ |
|---|
| 76 |
|
|---|
| 77 |
- (void)windowWillClose:(NSNotification *)notification { |
|---|
| 78 |
[Settings setObject:[windowTutor stringWithSavedFrame] |
|---|
| 79 |
forKey:kDefaultsTutorPosition]; |
|---|
| 80 |
|
|---|
| 81 |
[self resetTutor]; |
|---|
| 82 |
} |
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
/* |
|---|
| 87 |
Called when the user wrote a char to the text field. Prevents more than |
|---|
| 88 |
3 characters from passing through. |
|---|
| 89 |
*/ |
|---|
| 90 |
|
|---|
| 91 |
- (void)controlTextDidChange:(NSNotification *)notification { |
|---|
| 92 |
NSString *string; |
|---|
| 93 |
|
|---|
| 94 |
string = [fieldKana stringValue]; |
|---|
| 95 |
|
|---|
| 96 |
if([string length] > 3) |
|---|
| 97 |
[fieldKana setStringValue:[string substringToIndex:3]]; |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
#pragma mark - |
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
/* |
|---|
| 106 |
Opens the tutor window and prepares it. |
|---|
| 107 |
*/ |
|---|
| 108 |
|
|---|
| 109 |
- (void)openTutor { |
|---|
| 110 |
NSArray *menuItems; |
|---|
| 111 |
NSEnumerator *enumerator; |
|---|
| 112 |
NSMenuItem *menuItem; |
|---|
| 113 |
NSString *windowPosition; |
|---|
| 114 |
bool state = YES; |
|---|
| 115 |
|
|---|
| 116 |
// --- off by default |
|---|
| 117 |
_waitingForUser = NO; |
|---|
| 118 |
|
|---|
| 119 |
// --- clear all fields |
|---|
| 120 |
[textCorrect setStringValue:@""]; |
|---|
| 121 |
[textAnswer setStringValue:@""]; |
|---|
| 122 |
[fieldKana setStringValue:@""]; |
|---|
| 123 |
[self setImageByKanaName:NULL]; |
|---|
| 124 |
|
|---|
| 125 |
// --- lock down the Settings menu if we should |
|---|
| 126 |
if([[Settings objectForKey:kDefaultsLockSettings] boolValue]) |
|---|
| 127 |
state = NO; |
|---|
| 128 |
|
|---|
| 129 |
[menuSettings setAutoenablesItems:NO]; |
|---|
| 130 |
menuItems = [menuSettings itemArray]; |
|---|
| 131 |
enumerator = [menuItems objectEnumerator]; |
|---|
| 132 |
|
|---|
| 133 |
while((menuItem = [enumerator nextObject])) |
|---|
| 134 |
[menuItem setEnabled:state]; |
|---|
| 135 |
|
|---|
| 136 |
// --- lock quiz/learning if we're in a limited session |
|---|
| 137 |
if([[Settings objectForKey:kDefaultsSession] intValue] == kDefaultsSessionLimited) { |
|---|
| 138 |
[Settings setObject:[NSNumber numberWithInt:kDefaultsModeQuiz] |
|---|
| 139 |
forKey:kDefaultsMode]; |
|---|
| 140 |
|
|---|
| 141 |
[itemQuizMode setState:NSOnState]; |
|---|
| 142 |
[itemLearningMode setState:NSOffState]; |
|---|
| 143 |
|
|---|
| 144 |
[itemQuizMode setEnabled:NO]; |
|---|
| 145 |
[itemLearningMode setEnabled:NO]; |
|---|
| 146 |
} |
|---|
| 147 |
|
|---|
| 148 |
// --- select our romanisation system |
|---|
| 149 |
[_tutor switchRomanisationStrings:[[Settings objectForKey:kDefaultsRomanisationSystem] intValue]]; |
|---|
| 150 |
|
|---|
| 151 |
// --- update the buttons according to the romanisation system |
|---|
| 152 |
[self updateButtonTitles]; |
|---|
| 153 |
|
|---|
| 154 |
// --- update the buttons according to our Lines settings |
|---|
| 155 |
[self updateButtons]; |
|---|
| 156 |
|
|---|
| 157 |
// --- set these to 0 |
|---|
| 158 |
[_tutor setCorrect:0]; |
|---|
| 159 |
[_tutor setQuestions:0]; |
|---|
| 160 |
[self updateScore]; |
|---|
| 161 |
|
|---|
| 162 |
// --- move to saved position |
|---|
| 163 |
windowPosition = [Settings objectForKey:kDefaultsTutorPosition]; |
|---|
| 164 |
|
|---|
| 165 |
if([windowPosition isEqualTo:@""]) |
|---|
| 166 |
[windowTutor center]; |
|---|
| 167 |
else |
|---|
| 168 |
[windowTutor setFrameFromString:windowPosition]; |
|---|
| 169 |
|
|---|
| 170 |
// --- show the window |
|---|
| 171 |
[windowTutor makeKeyAndOrderFront:self]; |
|---|
| 172 |
|
|---|
| 173 |
// --- get a timestamp |
|---|
| 174 |
_startTime = time(NULL); |
|---|
| 175 |
_stopTime = 0; |
|---|
| 176 |
|
|---|
| 177 |
// --- install a timer that fires when our time is up if we're in a limited session |
|---|
| 178 |
if([[Settings objectForKey:kDefaultsSession] intValue] == kDefaultsSessionLimited && |
|---|
| 179 |
[[Settings objectForKey:kDefaultsTimeLimit] intValue] > 0) { |
|---|
| 180 |
_timer = [NSTimer scheduledTimerWithTimeInterval:[[Settings objectForKey:kDefaultsTimeLimit] intValue] |
|---|
| 181 |
target:self |
|---|
| 182 |
selector:@selector(sessionShouldFinish) |
|---|
| 183 |
userInfo:NULL |
|---|
| 184 |
repeats:NO]; |
|---|
| 185 |
} |
|---|
| 186 |
} |
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 |
/* |
|---|
| 192 |
Resets the tutor to its original state, possibly for a new session. |
|---|
| 193 |
*/ |
|---|
| 194 |
|
|---|
| 195 |
- (void)resetTutor { |
|---|
| 196 |
NSArray *menuItems; |
|---|
| 197 |
NSEnumerator *enumerator; |
|---|
| 198 |
NSMenuItem *menuItem; |
|---|
| 199 |
|
|---|
| 200 |
// --- re-enable the settings menu |
|---|
| 201 |
menuItems = [menuSettings itemArray]; |
|---|
| 202 |
enumerator = [menuItems objectEnumerator]; |
|---|
| 203 |
|
|---|
| 204 |
while((menuItem = [enumerator nextObject])) |
|---|
| 205 |
[menuItem setEnabled:YES]; |
|---|
| 206 |
|
|---|
| 207 |
// --- kill the timer |
|---|
| 208 |
if(_timer) { |
|---|
| 209 |
[_timer invalidate]; |
|---|
| 210 |
|
|---|
| 211 |
_timer = NULL; |
|---|
| 212 |
} |
|---|
| 213 |
} |
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 |
|
|---|
| 217 |
|
|---|
| 218 |
- (void)sessionShouldFinish { |
|---|
| 219 |
// --- we don't want to do this if we've already finished |
|---|
| 220 |
if([sessionOutlet isDone]) |
|---|
| 221 |
return; |
|---|
| 222 |
|
|---|
| 223 |
// --- get a timestamp |
|---|
| 224 |
_stopTime = time(NULL); |
|---|
| 225 |
_diffTime = _stopTime - _startTime; |
|---|
| 226 |
|
|---|
| 227 |
// --- close this window |
|---|
| 228 |
[windowTutor close]; |
|---|
| 229 |
|
|---|
| 230 |
// --- mark as finished |
|---|
| 231 |
[sessionOutlet done]; |
|---|
| 232 |
|
|---|
| 233 |
// --- open the next |
|---|
| 234 |
[sessionOutlet showReport]; |
|---|
| 235 |
} |
|---|
| 236 |
|
|---|
| 237 |
|
|---|
| 238 |
|
|---|
| 239 |
#pragma mark - |
|---|
| 240 |
|
|---|
| 241 |
/* |
|---|
| 242 |
Called when the user clicks a kana button. |
|---|
| 243 |
*/ |
|---|
| 244 |
|
|---|
| 245 |
- (IBAction)clickKana:(NSMatrix *)sender { |
|---|
| 246 |
NSString *currentKana, *clickedKana, *infoString; |
|---|
| 247 |
NSButton *clickedButton; |
|---|
| 248 |
|
|---|
| 249 |
switch([[Settings objectForKey:kDefaultsMode] intValue]) { |
|---|
| 250 |
case kDefaultsModeQuiz: |
|---|
| 251 |
// --- if we're waiting for the user to click the mouse and she |
|---|
| 252 |
// clicked a button, confirm this as a click |
|---|
| 253 |
if(_waitingForUser) { |
|---|
| 254 |
[self userConfirmed]; |
|---|
| 255 |
|
|---|
| 256 |
return; |
|---|
| 257 |
} |
|---|
| 258 |
|
|---|
| 259 |
// --- update number of questions |
|---|
| 260 |
[_tutor setQuestions:[_tutor getQuestions] + 1]; |
|---|
| 261 |
|
|---|
| 262 |
// --- get the name of the selected button and the correct name |
|---|
| 263 |
clickedButton = [sender cellAtRow:[sender selectedRow] column:[sender selectedColumn]]; |
|---|
| 264 |
clickedKana = [clickedButton title]; |
|---|
| 265 |
currentKana = [_tutor getCurrentKanaName]; |
|---|
| 266 |
[_tutor setCurrentKanaName:currentKana]; |
|---|
| 267 |
|
|---|
| 268 |
if([clickedKana isEqualToString:[_tutor getExpandedKanaName:currentKana]]) |
|---|
| 269 |
[self userWasCorrect:clickedKana]; |
|---|
| 270 |
else |
|---|
| 271 |
[self userWasIncorrect:clickedKana]; |
|---|
| 272 |
|
|---|
| 273 |
// --- update the scoreboard |
|---|
| 274 |
[self updateScore]; |
|---|
| 275 |
break; |
|---|
| 276 |
|
|---|
| 277 |
case kDefaultsModeLearning: |
|---|
| 278 |
// --- get the name of the selected button |
|---|
| 279 |
clickedButton = [sender |
|---|
| 280 |
cellAtRow:[sender selectedRow] |
|---|
| 281 |
column:[sender selectedColumn]]; |
|---|
| 282 |
currentKana = [clickedButton alternateTitle]; |
|---|
| 283 |
|
|---|
| 284 |
// --- set our internal name to it |
|---|
| 285 |
[_tutor setCurrentKanaName:currentKana]; |
|---|
| 286 |
|
|---|
| 287 |
// --- display the correct kana image |
|---|
| 288 |
[self setImageByKanaName:currentKana]; |
|---|
| 289 |
|
|---|
| 290 |
// --- and display the name of it, as we're in learning mode |
|---|
| 291 |
infoString = [NSString stringWithFormat:@"'%@'", |
|---|
| 292 |
[_tutor getExpandedKanaName:currentKana]]; |
|---|
| 293 |
[textCorrect setTextColor:[NSColor blackColor]]; |
|---|
| 294 |
[textCorrect setStringValue:infoString]; |
|---|
| 295 |
break; |
|---|
| 296 |
} |
|---|
| 297 |
|
|---|
| 298 |
// --- drop out if we're done |
|---|
| 299 |
if([[Settings objectForKey:kDefaultsKanaLimit] intValue] == [_tutor getQuestions] && |
|---|
| 300 |
[[Settings objectForKey:kDefaultsSession] intValue] == kDefaultsSessionLimited) |
|---|
| 301 |
[self sessionShouldFinish]; |
|---|
| 302 |
} |
|---|
| 303 |
|
|---|
| 304 |
|
|---|
| 305 |
|
|---|
| 306 |
/* |
|---|
| 307 |
Called when the user clicks the OK button. |
|---|
| 308 |
*/ |
|---|
| 309 |
|
|---|
| 310 |
- (IBAction)writeKana:(NSButton *)sender { |
|---|
| 311 |
NSString *currentKana, *writtenKana, *infoString; |
|---|
| 312 |
NSArray *keys; |
|---|
| 313 |
|
|---|
| 314 |
switch([[Settings objectForKey:kDefaultsMode] intValue]) { |
|---|
| 315 |
case kDefaultsModeQuiz: |
|---|
| 316 |
// --- if we're waiting for the user to click the mouse and she |
|---|
| 317 |
// clicked a button, confirm this as a click |
|---|
| 318 |
if(_waitingForUser) { |
|---|
| 319 |
[self userConfirmed]; |
|---|
| 320 |
|
|---|
| 321 |
return; |
|---|
| 322 |
} |
|---|
| 323 |
|
|---|
| 324 |
// --- update number of questions |
|---|
| 325 |
[_tutor setQuestions:[_tutor getQuestions] + 1]; |
|---|
| 326 |
|
|---|
| 327 |
// --- get the name of the selected button and the correct name |
|---|
| 328 |
writtenKana = [fieldKana stringValue]; |
|---|
| 329 |
currentKana = [_tutor getCurrentKanaName]; |
|---|
| 330 |
[_tutor setCurrentKanaName:currentKana]; |
|---|
| 331 |
|
|---|
| 332 |
if([writtenKana isEqualToString:[_tutor getExpandedKanaName:currentKana]]) |
|---|
| 333 |
[self userWasCorrect:currentKana]; |
|---|
| 334 |
else |
|---|
| 335 |
[self userWasIncorrect:writtenKana]; |
|---|
| 336 |
|
|---|
| 337 |
// --- update the scoreboard |
|---|
| 338 |
[self updateScore]; |
|---|
| 339 |
break; |
|---|
| 340 |
|
|---|
| 341 |
case kDefaultsModeLearning: |
|---|
| 342 |
// --- get the kana |
|---|
| 343 |
writtenKana = [fieldKana stringValue]; |
|---|
| 344 |
keys = [[_tutor getCurrentStrings] allKeysForObject:writtenKana]; |
|---|
| 345 |
|
|---|
| 346 |
if([keys count] > 0) { |
|---|
| 347 |
currentKana = [keys objectAtIndex:0]; |
|---|
| 348 |
|
|---|
| 349 |
// --- set our internal name to it |
|---|
| 350 |
[_tutor setCurrentKanaName:currentKana]; |
|---|
| 351 |
|
|---|
| 352 |
// --- display the correct kana image |
|---|
| 353 |
[self setImageByKanaName:currentKana]; |
|---|
| 354 |
|
|---|
| 355 |
// --- and display the name of it, as we're in learning mode |
|---|
| 356 |
infoString = [NSString stringWithFormat:@"'%@'", writtenKana]; |
|---|
| 357 |
[textCorrect setTextColor:[NSColor blackColor]]; |
|---|
| 358 |
[textCorrect setStringValue:infoString]; |
|---|
| 359 |
} |
|---|
| 360 |
break; |
|---|
| 361 |
} |
|---|
| 362 |
|
|---|
| 363 |
// --- drop out if we're done |
|---|
| 364 |
if([[Settings objectForKey:kDefaultsKanaLimit] intValue] == [_tutor getQuestions] && |
|---|
| 365 |
[[Settings objectForKey:kDefaultsSession] intValue] == kDefaultsSessionLimited) |
|---|
| 366 |
[self sessionShouldFinish]; |
|---|
| 367 |
} |
|---|
| 368 |
|
|---|
| 369 |
|
|---|
| 370 |
|
|---|
| 371 |
/* |
|---|
| 372 |
Increase score, tell the user she was correct, and start on a new kana. |
|---|
| 373 |
*/ |
|---|
| 374 |
|
|---|
| 375 |
- (void)userWasCorrect:(NSString *)kana { |
|---|
| 376 |
NSString *infoString, *currentKana, *outKana; |
|---|
| 377 |
|
|---|
| 378 |
// --- display correct message in green - according to testers, |
|---|
| 379 |
// plain greenColor is a tad too light, so we darken it a bit |
|---|
| 380 |
outKana = [_tutor getExpandedKanaName:kana]; |
|---|
| 381 |
infoString = [NSString stringWithFormat:NSLocalizedString(@"'%@' is correct.", @""), outKana]; |
|---|
| 382 |
[textCorrect setTextColor:[NSColor colorWithDeviceRed:0.05 green:0.9 blue:0.05 alpha:1.0]]; |
|---|
| 383 |
[textCorrect setStringValue:infoString]; |
|---|
| 384 |
|
|---|
| 385 |
// --- this should say nothing here |
|---|
| 386 |
[textAnswer setStringValue:@""]; |
|---|
| 387 |
|
|---|
| 388 |
[_tutor setCorrect:[_tutor getCorrect] + 1]; |
|---|
| 389 |
|
|---|
| 390 |
// --- get a random kana name and display its image |
|---|
| 391 |
currentKana = [_tutor getRandomKanaName]; |
|---|
| 392 |
[_tutor setCurrentKanaName:currentKana]; |
|---|
| 393 |
[self setImageByKanaName:currentKana]; |
|---|
| 394 |
} |
|---|
| 395 |
|
|---|
| 396 |
|
|---|
| 397 |
|
|---|
| 398 |
/* |
|---|
| 399 |
Tell the user she was incorrect, waiting for her to confirm it if we should. |
|---|
| 400 |
*/ |
|---|
| 401 |
|
|---|
| 402 |
- (void)userWasIncorrect:(NSString *)kana { |
|---|
| 403 |
NSString *infoString, *currentKana, *outKana; |
|---|
| 404 |
|
|---|
| 405 |
// --- display incorrect message in red |
|---|
| 406 |
[textCorrect setTextColor:[NSColor redColor]]; |
|---|
| 407 |
|
|---|
| 408 |
// --- the user may have written something that isn't even a kana name |
|---|
| 409 |
outKana = [_tutor getExpandedKanaName:kana]; |
|---|
| 410 |
if(!outKana) |
|---|
| 411 |
outKana = kana; |
|---|
| 412 |
|
|---|
| 413 |
// --- tell the user what the correct answer should have been |
|---|
| 414 |
infoString = [NSString stringWithFormat:NSLocalizedString(@"The correct answer was '%@'.", @""), |
|---|
| 415 |
[_tutor getExpandedKanaName:[_tutor getCurrentKanaName]]]; |
|---|
| 416 |
[textAnswer setStringValue:infoString]; |
|---|
| 417 |
|
|---|
| 418 |
if([[Settings objectForKey:kDefaultsMouseDownOnIncorrect] boolValue]) { |
|---|
| 419 |
// --- wait for the user to confirm her mistake |
|---|
| 420 |
infoString = [NSString stringWithFormat:NSLocalizedString(@"'%@' is incorrect. Click to continue.", @""), |
|---|
| 421 |
outKana]; |
|---|
| 422 |
[textCorrect setStringValue:infoString]; |
|---|
| 423 |
|
|---|
| 424 |
// --- this will get cleared in userDidMouseDown |
|---|
| 425 |
_waitingForUser = YES; |
|---|
| 426 |
} else { |
|---|
| 427 |
// --- just say that it's incorrect and continue |
|---|
| 428 |
infoString = [NSString stringWithFormat:NSLocalizedString(@"'%@' is incorrect.", @""), outKana]; |
|---|
| 429 |
[textCorrect setStringValue:infoString]; |
|---|
| 430 |
|
|---|
| 431 |
// --- get a random kana name and display its image |
|---|
| 432 |
currentKana = [_tutor getRandomKanaName]; |
|---|
| 433 |
[_tutor setCurrentKanaName:currentKana]; |
|---|
| 434 |
[self setImageByKanaName:currentKana]; |
|---|
| 435 |
} |
|---|
| 436 |
} |
|---|
| 437 |
|
|---|
| 438 |
|
|---|
| 439 |
|
|---|
| 440 |
#pragma mark - |
|---|
| 441 |
|
|---|
| 442 |
/* |
|---|
| 443 |
Called when the user selects "Lines To Test" from the Settings menu. |
|---|
| 444 |
*/ |
|---|
| 445 |
|
|---|
| 446 |
- (IBAction)openLines:(id)sender { |
|---|
| 447 |
int lines; |
|---|
| 448 |
|
|---|
| 449 |
// --- get our bit field |
|---|
| 450 |
lines = [[Settings objectForKey:kDefaultsLines] intValue]; |
|---|
| 451 |
|
|---|
| 452 |
// --- mark the checkboxes accordingly |
|---|
| 453 |
if(lines & kDefaultsLinesA) |
|---|
| 454 |
[linesA setState:NSOnState]; |
|---|
| 455 |
if(lines & kDefaultsLinesBa) |
|---|
| 456 |
[linesBa setState:NSOnState]; |
|---|
| 457 |
if(lines & kDefaultsLinesDa) |
|---|
| 458 |
[linesDa setState:NSOnState]; |
|---|
| 459 |
if(lines & kDefaultsLinesGa) |
|---|
| 460 |
[linesGa setState:NSOnState]; |
|---|
| 461 |
if(lines & kDefaultsLinesHa) |
|---|
| 462 |
[linesHa setState:NSOnState]; |
|---|
| 463 |
if(lines & kDefaultsLinesKa) |
|---|
| 464 |
[linesKa setState:NSOnState]; |
|---|
| 465 |
if(lines & kDefaultsLinesMa) |
|---|
| 466 |
[linesMa setState:NSOnState]; |
|---|
| 467 |
if(lines & kDefaultsLinesNa) |
|---|
| 468 |
[linesNa setState:NSOnState]; |
|---|
| 469 |
if(lines & kDefaultsLinesPa) |
|---|
| 470 |
[linesPa setState:NSOnState]; |
|---|
| 471 |
if(lines & kDefaultsLinesRa) |
|---|
| 472 |
[linesRa setState:NSOnState]; |
|---|
| 473 |
if(lines & kDefaultsLinesSa) |
|---|
| 474 |
[linesSa setState:NSOnState]; |
|---|
| 475 |
if(lines & kDefaultsLinesTa) |
|---|
| 476 |
[linesTa setState:NSOnState]; |
|---|
| 477 |
if(lines & kDefaultsLinesWa) |
|---|
| 478 |
[linesWa setState:NSOnState]; |
|---|
| 479 |
if(lines & kDefaultsLinesYa) |
|---|
| 480 |
[linesYa setState:NSOnState]; |
|---|
| 481 |
if(lines & kDefaultsLinesZa) |
|---|
| 482 |
[linesZa setState:NSOnState]; |
|---|
| 483 |
|
|---|
| 484 |
// --- show the window |
|---|
| 485 |
[windowLines center]; |
|---|
| 486 |
[windowLines makeKeyAndOrderFront:self]; |
|---|
| 487 |
} |
|---|
| 488 |
|
|---|
| 489 |
|
|---|
| 490 |
|
|---|
| 491 |
/* |
|---|
| 492 |
Called when the user clicks the OK button in the Lines dialog. |
|---|
| 493 |
*/ |
|---|
| 494 |
|
|---|
| 495 |
- (IBAction)linesOK:(NSButton *)sender { |
|---|
| 496 |
NSString *currentKana; |
|---|
| 497 |
int lines = kDefaultsLinesEmpty; |
|---|
| 498 |
|
|---|
| 499 |
// --- update the bit field |
|---|
| 500 |
if([linesA state] == NSOnState) |
|---|
| 501 |
lines |= kDefaultsLinesA; |
|---|
| 502 |
if([linesBa state] == NSOnState) |
|---|
| 503 |
lines |= kDefaultsLinesBa; |
|---|
| 504 |
if([linesDa state] == NSOnState) |
|---|
| 505 |
lines |= kDefaultsLinesDa; |
|---|
| 506 |
if([linesGa state] == NSOnState) |
|---|
| 507 |
lines |= kDefaultsLinesGa; |
|---|
| 508 |
if([linesHa state] == NSOnState) |
|---|
| 509 |
lines |= kDefaultsLinesHa; |
|---|
| 510 |
if([linesKa state] == NSOnState) |
|---|
| 511 |
lines |= kDefaultsLinesKa; |
|---|
| 512 |
if([linesMa state] == NSOnState) |
|---|
| 513 |
lines |= kDefaultsLinesMa; |
|---|
| 514 |
if([linesNa state] == NSOnState) |
|---|
| 515 |
lines |= kDefaultsLinesNa; |
|---|
| 516 |
if([linesPa state] == NSOnState) |
|---|
| 517 |
lines |= kDefaultsLinesPa; |
|---|
| 518 |
if([linesRa state] == NSOnState) |
|---|
| 519 |
lines |= kDefaultsLinesRa; |
|---|
| 520 |
if([linesSa state] == NSOnState) |
|---|
| 521 |
lines |= kDefaultsLinesSa; |
|---|
| 522 |
if([linesTa state] == NSOnState) |
|---|
| 523 |
lines |= kDefaultsLinesTa; |
|---|
| 524 |
if([linesWa state] == NSOnState) |
|---|
| 525 |
lines |= kDefaultsLinesWa; |
|---|
| 526 |
if([linesYa state] == NSOnState) |
|---|
| 527 |
lines |= kDefaultsLinesYa; |
|---|
| 528 |
if([linesZa state] == NSOnState) |
|---|
| 529 |
lines |= kDefaultsLinesZa; |
|---|
| 530 |
|
|---|
| 531 |
// --- update the settings |
|---|
| 532 |
[Settings setObject:[NSNumber numberWithInt:lines] forKey:kDefaultsLines]; |
|---|
| 533 |
|
|---|
| 534 |
// --- re-initiate the currentStrings dict so we can starting |
|---|
| 535 |
// reducing from from a fresh one |
|---|
| 536 |
[_tutor switchRomanisationStrings: |
|---|
| 537 |
[[Settings objectForKey:kDefaultsRomanisationSystem] intValue]]; |
|---|
| 538 |
|
|---|
| 539 |
// --- update the Tutor window |
|---|
| 540 |
[self updateButtons]; |
|---|
| 541 |
|
|---|
| 542 |
if([[Settings objectForKey:kDefaultsMode] intValue] == kDefaultsModeQuiz) { |
|---|
| 543 |
// --- we might have an old kana in the well |
|---|
| 544 |
currentKana = [_tutor getRandomKanaName]; |
|---|
| 545 |
[_tutor setCurrentKanaName:currentKana]; |
|---|
| 546 |
[self setImageByKanaName:currentKana]; |
|---|
| 547 |
} |
|---|
| 548 |
|
|---|
| 549 |
// --- and close |
|---|
| 550 |
[windowLines close]; |
|---|
| 551 |
} |
|---|
| 552 |
|
|---|
| 553 |
|
|---|
| 554 |
|
|---|
| 555 |
/* |
|---|
| 556 |
Called when the user click the "Select All" button in the Lines dialog. |
|---|
| 557 |
*/ |
|---|
| 558 |
|
|---|
| 559 |
- (IBAction)linesSelectAll:(NSButton *)sender { |
|---|
| 560 |
[linesA setState:NSOnState]; |
|---|
| 561 |
[linesBa setState:NSOnState]; |
|---|
| 562 |
[linesDa setState:NSOnState]; |
|---|
| 563 |
[linesGa setState:NSOnState]; |
|---|
| 564 |
[linesHa setState:NSOnState]; |
|---|
| 565 |
[linesKa setState:NSOnState]; |
|---|
| 566 |
[linesMa setState:NSOnState]; |
|---|
| 567 |
[linesNa setState:NSOnState]; |
|---|
| 568 |
[linesPa setState:NSOnState]; |
|---|
| 569 |
[linesRa setState:NSOnState]; |
|---|
| 570 |
[linesSa setState:NSOnState]; |
|---|
| 571 |
[linesTa setState:NSOnState]; |
|---|
| 572 |
[linesWa setState:NSOnState]; |
|---|
| 573 |
[linesYa setState:NSOnState]; |
|---|
| 574 |
[linesZa setState:NSOnState]; |
|---|
| 575 |
} |
|---|
| 576 |
|
|---|
| 577 |
|
|---|
| 578 |
|
|---|
| 579 |
|
|---|
| 580 |
|
|---|
| 581 |
#pragma mark - |
|---|
| 582 |
|
|---|
| 583 |
/* |
|---|
| 584 |
Set up a new quiz/learning. |
|---|
| 585 |
*/ |
|---|
| 586 |
|
|---|
| 587 |
- (void)start { |
|---|
| 588 |
// --- go nuku go |
|---|
| 589 |
switch([[Settings objectForKey:kDefaultsMode] intValue]) { |
|---|
| 590 |
case kDefaultsModeQuiz: |
|---|
| 591 |
[self startNewQuiz]; |
|---|
| 592 |
break; |
|---|
| 593 |
|
|---|
| 594 |
case kDefaultsModeLearning: |
|---|
| 595 |
[self startNewLearning]; |
|---|
| 596 |
break; |
|---|
| 597 |
} |
|---|
| 598 |
} |
|---|
| 599 |
|
|---|
| 600 |
|
|---|
| 601 |
|
|---|
| 602 |
/* |
|---|
| 603 |
Set up a new quiz, zero out the score table and kick it off. |
|---|
| 604 |
*/ |
|---|
| 605 |
|
|---|
| 606 |
- (void)startNewQuiz { |
|---|
| 607 |
NSString *currentKana; |
|---|
| 608 |
|
|---|
| 609 |
[windowTutor setTitle:NSLocalizedString(@"Nuku - Quiz Mode", @"")]; |
|---|
| 610 |
|
|---|
| 611 |
// --- clear all fields |
|---|
| 612 |
[textCorrect setStringValue:@""]; |
|---|
| 613 |
[textAnswer setStringValue:@""]; |
|---|
| 614 |
[fieldKana setStringValue:@""]; |
|---|
| 615 |
|
|---|
| 616 |
// --- set these to 0 |
|---|
| 617 |
[_tutor setCorrect:0]; |
|---|
| 618 |
[_tutor setQuestions:0]; |
|---|
| 619 |
|
|---|
| 620 |
// --- display the score |
|---|
| 621 |
[self updateScore]; |
|---|
| 622 |
|
|---|
| 623 |
// --- get a random kana and display it, kicking off the quiz |
|---|
| 624 |
currentKana = [_tutor getRandomKanaName]; |
|---|
| 625 |
[_tutor setCurrentKanaName:currentKana]; |
|---|
| 626 |
[self setImageByKanaName:currentKana]; |
|---|
| 627 |
} |
|---|
| 628 |
|
|---|
| 629 |
|
|---|
| 630 |
|
|---|
| 631 |
/* |
|---|
| 632 |
Prepare for learning mode, clear score and image out. |
|---|
| 633 |
*/ |
|---|
| 634 |
|
|---|
| 635 |
- (void)startNewLearning { |
|---|
| 636 |
[windowTutor setTitle:NSLocalizedString(@"Nuku - Learning Mode", @"")]; |
|---|
| 637 |
|
|---|
| 638 |
// --- clear all fields |
|---|
| 639 |
[textCorrect setStringValue:@""]; |
|---|
| 640 |
[textAnswer setStringValue:@""]; |
|---|
| 641 |
[fieldKana setStringValue:@""]; |
|---|
| 642 |
[self setImageByKanaName:NULL]; |
|---|
| 643 |
|
|---|
| 644 |
// --- set these to 0 |
|---|
| 645 |
[_tutor setCorrect:0]; |
|---|
| 646 |
[_tutor setQuestions:0]; |
|---|
| 647 |
|
|---|
| 648 |
// --- display the score |
|---|
| 649 |
[self updateScore]; |
|---|
| 650 |
} |
|---|
| 651 |
|
|---|
| 652 |
|
|---|
| 653 |
|
|---|
| 654 |
#pragma mark - |
|---|
| 655 |
|
|---|
| 656 |
/* |
|---|
| 657 |
Updates the Settings menu from prefs. |
|---|
| 658 |
*/ |
|---|
| 659 |
|
|---|
| 660 |
- (void)updateSettings { |
|---|
| 661 |
// --- set up initial kana type |
|---|
| 662 |
switch([[Settings objectForKey:kDefaultsKanaType] intValue]) { |
|---|
| 663 |
case kDefaultsKanaTypeHiragana: |
|---|
| 664 |
[itemHiragana setState:NSOnState]; |
|---|
| 665 |
break; |
|---|
| 666 |
|
|---|
| 667 |
case kDefaultsKanaTypeKatakana: |
|---|
| 668 |
[itemKatakana setState:NSOnState]; |
|---|
| 669 |
break; |
|---|
| 670 |
|
|---|
| 671 |
case kDefaultsKanaTypeMixed: |
|---|
| 672 |
[itemMixed setState:NSOnState]; |
|---|
| 673 |
break; |
|---|
| 674 |
} |
|---|
| 675 |
|
|---|
| 676 |
// --- set up initial romanisation system |
|---|
| 677 |
switch([[Settings objectForKey:kDefaultsRomanisationSystem] intValue]) { |
|---|
| 678 |
case kDefaultsRomanisationSystemHepburn: |
|---|
| 679 |
[itemHepburn setState:NSOnState]; |
|---|
| 680 |
break; |
|---|
| 681 |
|
|---|
| 682 |
case kDefaultsRomanisationSystemKunreiSiki: |
|---|
| 683 |
[itemKunreiSiki setState:NSOnState]; |
|---|
| 684 |
break; |
|---|
| 685 |
|
|---|
| 686 |
case kDefaultsRomanisationSystemNihonSiki: |
|---|
| 687 |
[itemNihonSiki setState:NSOnState]; |
|---|
| 688 |
break; |
|---|
| 689 |
} |
|---|
| 690 |
|
|---|
| 691 |
// --- set up initial mode |
|---|
| 692 |
switch([[Settings objectForKey:kDefaultsMode] intValue]) { |
|---|
| 693 |
case kDefaultsModeQuiz: |
|---|
| 694 |
[itemQuizMode setState:NSOnState]; |
|---|
| 695 |
break; |
|---|
| 696 |
|
|---|
| 697 |
case kDefaultsModeLearning: |
|---|
| 698 |
[itemLearningMode setState:NSOnState]; |
|---|
| 699 |
break; |
|---|
| 700 |
} |
|---|
| 701 |
} |
|---|
| 702 |
|
|---|
| 703 |
|
|---|
| 704 |
|
|---|
| 705 |
/* |
|---|
| 706 |
Update the scoreboard and set the scores accordingly. |
|---|
| 707 |
*/ |
|---|
| 708 |
|
|---|
| 709 |
- (void)updateScore { |
|---|
| 710 |
int correct, questions; |
|---|
| 711 |
float percent; |
|---|
| 712 |
|
|---|
| 713 |
correct = [_tutor getCorrect]; |
|---|
| 714 |
questions = [_tutor getQuestions]; |
|---|
| 715 |
|
|---|
| 716 |
if(questions == 0) |
|---|
| 717 |
percent = 0; |
|---|
| 718 |
else |
|---|
| 719 |
percent = ((float) correct / (float) questions) * 100; |
|---|
| 720 |
|
|---|
| 721 |
[textScore setStringValue:[NSString stringWithFormat:@"%d/%d", correct, questions]]; |
|---|
| 722 |
[textPercent setFloatValue:percent]; |
|---|
| 723 |
} |
|---|
| 724 |
|
|---|
| 725 |
|
|---|
| 726 |
|
|---|
| 727 |
/* |
|---|
| 728 |
Update the buttons that have different names between the romanisation systems. |
|---|
| 729 |
*/ |
|---|
| 730 |
|
|---|
| 731 |
- (void)updateButtonTitles { |
|---|
| 732 |
[kanaSi setTitle:[_tutor getExpandedKanaName:[kanaSi alternateTitle]]]; |
|---|
| 733 |
[kanaZi setTitle:[_tutor getExpandedKanaName:[kanaZi alternateTitle]]]; |
|---|
| 734 |
[kanaTi setTitle:[_tutor getExpandedKanaName:[kanaTi alternateTitle]]]; |
|---|
| 735 |
[kanaTu setTitle:[_tutor getExpandedKanaName:[kanaTu alternateTitle]]]; |
|---|
| 736 |
[kanaDi setTitle:[_tutor getExpandedKanaName:[kanaDi alternateTitle]]]; |
|---|
| 737 |
[kanaDu setTitle:[_tutor getExpandedKanaName:[kanaDu alternateTitle]]]; |
|---|
| 738 |
[kanaHu setTitle:[_tutor getExpandedKanaName:[kanaHu alternateTitle]]]; |
|---|
| 739 |
} |
|---|
| 740 |
|
|---|
| 741 |
|
|---|
| 742 |
|
|---|
| 743 |
/* |
|---|
| 744 |
Update the buttons according to the Lines settings. |
|---|
| 745 |
*/ |
|---|
| 746 |
|
|---|
| 747 |
- (void)updateButtons { |
|---|
| 748 |
int i, j, lines; |
|---|
| 749 |
NSButton *button; |
|---|
| 750 |
|
|---|
| 751 |
// --- get our bit field |
|---|
| 752 |
lines = [[Settings objectForKey:kDefaultsLines] intValue]; |
|---|
| 753 |
|
|---|
| 754 |
for(i = 0; i < 15; i++) { |
|---|
| 755 |
for(j = 0; j < 5; j++) { |
|---|
| 756 |
button = [buttonsKana cellAtRow:j column:i]; |
|---|
| 757 |
|
|---|
| 758 |
// --- we store the bit mask in the tag of the button |
|---|
| 759 |
if(lines & [button tag]) |
|---|
| 760 |
[button setEnabled: YES]; |
|---|
| 761 |
else { |
|---|
| 762 |
[_tutor reduceRomanisationStrings:[button alternateTitle]]; |
|---|
| 763 |
[button setEnabled: NO]; |
|---|
| 764 |
} |
|---|
| 765 |
} |
|---|
| 766 |
} |
|---|
| 767 |
} |
|---|
| 768 |
|
|---|
| 769 |
|
|---|
| 770 |
|
|---|
| 771 |
#pragma mark - |
|---|
| 772 |
|
|---|
| 773 |
/* |
|---|
| 774 |
Set the image well to display the kana provided. |
|---|
| 775 |
*/ |
|---|
| 776 |
|
|---|
| 777 |
- (void)setImageByKanaName:(NSString *)kanaName { |
|---|
| 778 |
[imageKana setImage:[_tutor getKanaImageByName:kanaName]]; |
|---|
| 779 |
} |
|---|
| 780 |
|
|---|
| 781 |
|
|---|
| 782 |
|
|---|
| 783 |
/* |
|---|
| 784 |
Get a new random kana and clear the waitingForUser flag to determine |
|---|
| 785 |
that the user has confirmed. |
|---|
| 786 |
*/ |
|---|
| 787 |
|
|---|
| 788 |
- (void)userConfirmed { |
|---|
| 789 |
NSString *currentKana; |
|---|
| 790 |
|
|---|
| 791 |
if(_waitingForUser) { |
|---|
| 792 |
// --- clear these |
|---|
| 793 |
[textCorrect setStringValue:@""]; |
|---|
| 794 |
[textAnswer setStringValue:@""]; |
|---|
| 795 |
|
|---|
| 796 |
// --- get a random kana name and display its image |
|---|
| 797 |
currentKana = [_tutor getRandomKanaName]; |
|---|
| 798 |
[_tutor setCurrentKanaName:currentKana]; |
|---|
| 799 |
[self setImageByKanaName:currentKana]; |
|---|
| 800 |
|
|---|
| 801 |
_waitingForUser = NO; |
|---|
| 802 |
} |
|---|
| 803 |
} |
|---|
| 804 |
|
|---|
| 805 |
|
|---|
| 806 |
|
|---|
| 807 |
#pragma mark - |
|---|
| 808 |
|
|---|
| 809 |
/* |
|---|
| 810 |
Called when user switches between quiz and learning mode. |
|---|
| 811 |
*/ |
|---|
| 812 |
|
|---|
| 813 |
- (IBAction)changeMode:(id)sender { |
|---|
| 814 |
// --- store value in settings for later retrieval |
|---|
| 815 |
[Settings setObject:[NSNumber numberWithInt:[sender tag]] |
|---|
| 816 |
forKey:kDefaultsMode]; |
|---|
| 817 |
|
|---|
| 818 |
// --- turn off everyone, then turn on the sender |
|---|
| 819 |
[itemQuizMode setState:NSOffState]; |
|---|
| 820 |
[itemLearningMode setState:NSOffState]; |
|---|
| 821 |
[sender setState:NSOnState]; |
|---|
| 822 |
|
|---|
| 823 |
switch([[Settings objectForKey:kDefaultsMode] intValue]) { |
|---|
| 824 |
case kDefaultsModeQuiz: |
|---|
| 825 |
[self startNewQuiz]; |
|---|
| 826 |
break; |
|---|
| 827 |
|
|---|
| 828 |
case kDefaultsModeLearning: |
|---|
| 829 |
[self startNewLearning]; |
|---|
| 830 |
break; |
|---|
| 831 |
} |
|---|
| 832 |
} |
|---|
| 833 |
|
|---|
| 834 |
|
|---|
| 835 |
|
|---|
| 836 |
/* |
|---|
| 837 |
Called when user changes kana type. |
|---|
| 838 |
*/ |
|---|
| 839 |
|
|---|
| 840 |
- (IBAction)changeKanaType:(id)sender { |
|---|
| 841 |
// --- store value in settings for later retrieval |
|---|
| 842 |
[Settings setObject:[NSNumber numberWithInt:[sender tag]] |
|---|
| 843 |
forKey:kDefaultsKanaType]; |
|---|
| 844 |
|
|---|
| 845 |
// --- turn off everyone, then turn on the sender |
|---|
| 846 |
[itemHiragana setState:NSOffState]; |
|---|
| 847 |
[itemKatakana setState:NSOffState]; |
|---|
| 848 |
[itemMixed setState:NSOffState]; |
|---|
| 849 |
[sender setState:NSOnState]; |
|---|
| 850 |
|
|---|
| 851 |
// --- update the image |
|---|
| 852 |
[self setImageByKanaName:[_tutor getCurrentKanaName]]; |
|---|
| 853 |
} |
|---|
| 854 |
|
|---|
| 855 |
|
|---|
| 856 |
|
|---|
| 857 |
/* |
|---|
| 858 |
Called when user switches romanisation system. |
|---|
| 859 |
*/ |
|---|
| 860 |
|
|---|
| 861 |
- (IBAction)changeRomanisationSystem:(id)sender { |
|---|
| 862 |
NSString *currentKana, *infoString; |
|---|
| 863 |
|
|---|
| 864 |
// --- store value in settings for later retrieval |
|---|
| 865 |
[Settings setObject:[NSNumber numberWithInt:[sender tag]] |
|---|
| 866 |
forKey:kDefaultsRomanisationSystem]; |
|---|
| 867 |
|
|---|
| 868 |
// turn off everyone, then turn on the sender |
|---|
| 869 |
[itemHepburn setState:NSOffState]; |
|---|
| 870 |
[itemKunreiSiki setState:NSOffState]; |
|---|
| 871 |
[itemNihonSiki setState:NSOffState]; |
|---|
| 872 |
[sender setState:NSOnState]; |
|---|
| 873 |
|
|---|
| 874 |
// --- update the current strings |
|---|
| 875 |
[_tutor switchRomanisationStrings:[sender tag]]; |
|---|
| 876 |
|
|---|
| 877 |
// --- update the current display if we're in learning mode |
|---|
| 878 |
currentKana = [_tutor getCurrentKanaName]; |
|---|
| 879 |
|
|---|
| 880 |
if([[Settings objectForKey:kDefaultsMode] intValue] == kDefaultsModeLearning && |
|---|
| 881 |
currentKana != NULL) { |
|---|
| 882 |
// --- 'kana' |
|---|
| 883 |
infoString = [NSString stringWithFormat:@"'%@'", |
|---|
| 884 |
[_tutor getExpandedKanaName:currentKana]]; |
|---|
| 885 |
[textCorrect setStringValue:infoString]; |
|---|
| 886 |
} |
|---|
| 887 |
|
|---|
| 888 |
// --- update the button titles |
|---|
| 889 |
[self updateButtonTitles]; |
|---|
| 890 |
|
|---|
| 891 |
// --- update the buttons |
|---|
| 892 |
[self updateButtons]; |
|---|
| 893 |
} |
|---|
| 894 |
|
|---|
| 895 |
|
|---|
| 896 |
|
|---|
| 897 |
#pragma mark - |
|---|
| 898 |
|
|---|
| 899 |
/* |
|---|
| 900 |
Get the number of questions. |
|---|
| 901 |
*/ |
|---|
| 902 |
|
|---|
| 903 |
- (int)getQuestions { |
|---|
| 904 |
return [_tutor getQuestions]; |
|---|
| 905 |
} |
|---|
| 906 |
|
|---|
| 907 |
|
|---|
| 908 |
|
|---|
| 909 |
/* |
|---|
| 910 |
Get the number of corrects. |
|---|
| 911 |
*/ |
|---|
| 912 |
|
|---|
| 913 |
- (int)getCorrect { |
|---|
| 914 |
return [_tutor getCorrect]; |
|---|
| 915 |
} |
|---|
| 916 |
|
|---|
| 917 |
|
|---|
| 918 |
|
|---|
| 919 |
/* |
|---|
| 920 |
Get the elapsed time. |
|---|
| 921 |
*/ |
|---|
| 922 |
|
|---|
| 923 |
- (int)getTime { |
|---|
| 924 |
return _diffTime; |
|---|
| 925 |
} |
|---|
| 926 |
|
|---|
| 927 |
|
|---|
| 928 |
@end |
|---|