Changeset 814
- Timestamp:
- 04/03/03 01:09:16 (6 years ago)
- Files:
-
- Nuku/trunk/Controller.h (modified) (2 diffs)
- Nuku/trunk/Controller.m (modified) (12 diffs)
- Nuku/trunk/Session.m (modified) (2 diffs)
- Nuku/trunk/Tutor.h (modified) (1 diff)
- Nuku/trunk/Tutor.m (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Nuku/trunk/Controller.h
r812 r814 67 67 IBOutlet NSButtonCell *kanaZi; 68 68 69 IBOutlet NSButton *linesA;69 IBOutlet NSButton *linesA; 70 70 IBOutlet NSButton *linesBa; 71 71 IBOutlet NSButton *linesDa; … … 80 80 IBOutlet NSButton *linesTa; 81 81 IBOutlet NSButton *linesWa; 82 IBOutlet NSButton *linesYa;82 IBOutlet NSButton *linesYa; 83 83 IBOutlet NSButton *linesZa; 84 84 Nuku/trunk/Controller.m
r812 r814 34 34 @implementation Controller 35 35 36 - (id)init { 37 self = [super init]; 38 39 tutor = [[Tutor alloc] init]; 40 41 return self; 42 } 43 44 36 45 - (void)awakeFromNib { 37 // --- initiate our classes 38 tutor = [[Tutor alloc] init]; 39 40 // --- update the Settings menu from prefs 46 // --- update the settings menu from prefs 41 47 [self updateSettings]; 42 48 } … … 44 50 45 51 52 #pragma mark - 53 46 54 /* 47 55 Called when the application receives a shutdown notice, i.e. the user quits. … … 49 57 50 58 - (void)applicationWillTerminate:(NSNotification *)notification { 51 [Settings 52 setObject:[windowTutor stringWithSavedFrame] 53 forKey:kDefaultsTutorPosition]; 59 [Settings setObject:[windowTutor stringWithSavedFrame] 60 forKey:kDefaultsTutorPosition]; 54 61 } 55 62 … … 61 68 62 69 - (void)windowWillClose:(NSNotification *)notification { 63 [Settings 64 setObject:[windowTutor stringWithSavedFrame] 65 forKey:kDefaultsTutorPosition]; 70 [Settings setObject:[windowTutor stringWithSavedFrame] 71 forKey:kDefaultsTutorPosition]; 66 72 67 73 [self resetTutor]; … … 111 117 // --- lock down the Settings menu if we should 112 118 if([[Settings objectForKey:kDefaultsLockSettings] boolValue]) 113 state = NO;119 state = NO; 114 120 115 121 [menuSettings setAutoenablesItems:NO]; … … 117 123 enumerator = [menuItems objectEnumerator]; 118 124 119 while(menuItem = [enumerator nextObject]) {125 while(menuItem = [enumerator nextObject]) 120 126 [menuItem setEnabled:state]; 121 }122 127 123 128 // --- lock quiz/learning if we're in a limited session 124 129 if([[Settings objectForKey:kDefaultsSession] intValue] == kDefaultsSessionLimited) { 125 [Settings 126 setObject:[NSNumber numberWithInt:kDefaultsModeQuiz] 127 forKey:kDefaultsMode]; 130 [Settings setObject:[NSNumber numberWithInt:kDefaultsModeQuiz] 131 forKey:kDefaultsMode]; 128 132 129 133 [itemQuizMode setState:NSOnState]; … … 135 139 136 140 // --- select our romanisation system 137 [tutor switchRomanisationStrings: 138 [[Settings objectForKey:kDefaultsRomanisationSystem] intValue]]; 141 [tutor switchRomanisationStrings:[[Settings objectForKey:kDefaultsRomanisationSystem] intValue]]; 139 142 140 143 // --- update the buttons according to the romanisation system … … 166 169 // --- install a timer that fires when our time is up if we're in a limited session 167 170 if([[Settings objectForKey:kDefaultsSession] intValue] == kDefaultsSessionLimited && 168 [[Settings objectForKey:kDefaultsTimeLimit] intValue] > 0) 169 timer = [NSTimer 170 scheduledTimerWithTimeInterval:[[Settings objectForKey:kDefaultsTimeLimit] intValue]171 target:self172 selector:@selector(sessionShouldFinish)173 userInfo:NULL174 repeats:NO];171 [[Settings objectForKey:kDefaultsTimeLimit] intValue] > 0) { 172 timer = [NSTimer scheduledTimerWithTimeInterval:[[Settings objectForKey:kDefaultsTimeLimit] intValue] 173 target:self 174 selector:@selector(sessionShouldFinish) 175 userInfo:NULL 176 repeats:NO]; 177 } 175 178 } 176 179 … … 208 211 209 212 // --- get a timestamp 210 stopTime = time(NULL);211 diffTime = stopTime - startTime;213 stopTime = time(NULL); 214 diffTime = stopTime - startTime; 212 215 213 216 // --- close this window … … 802 805 - (IBAction)changeMode:(id)sender { 803 806 // --- store value in settings for later retrieval 804 [Settings 805 setObject:[NSNumber numberWithInt:[sender tag]] 806 forKey:kDefaultsMode]; 807 [Settings setObject:[NSNumber numberWithInt:[sender tag]] 808 forKey:kDefaultsMode]; 807 809 808 810 // --- turn off everyone, then turn on the sender … … 830 832 - (IBAction)changeKanaType:(id)sender { 831 833 // --- store value in settings for later retrieval 832 [Settings 833 setObject:[NSNumber numberWithInt:[sender tag]] 834 forKey:kDefaultsKanaType]; 834 [Settings setObject:[NSNumber numberWithInt:[sender tag]] 835 forKey:kDefaultsKanaType]; 835 836 836 837 // --- turn off everyone, then turn on the sender … … 854 855 855 856 // --- store value in settings for later retrieval 856 [Settings 857 setObject:[NSNumber numberWithInt:[sender tag]] 858 forKey:kDefaultsRomanisationSystem]; 857 [Settings setObject:[NSNumber numberWithInt:[sender tag]] 858 forKey:kDefaultsRomanisationSystem]; 859 859 860 860 // turn off everyone, then turn on the sender Nuku/trunk/Session.m
r812 r814 34 34 @implementation Session 35 35 36 - (id)init { 37 self = [super init]; 38 39 settings = [[Settings alloc] init]; 40 41 return self; 42 } 43 44 45 46 - (void)dealloc { 47 [settings release]; 48 49 [super dealloc]; 50 } 51 52 53 54 #pragma mark - 55 36 56 - (void)awakeFromNib { 37 // --- initiate our classes38 settings = [[Settings alloc] init];39 40 57 // --- start with a new session 41 58 [self newSession:self]; … … 113 130 - (IBAction)start:(id)sender { 114 131 // --- save all settings in prefs 115 [Settings 116 setObject:[NSNumber numberWithInt:[[selectSession selectedItem] tag]] 117 forKey:kDefaultsSession]; 118 119 [Settings 120 setObject:[NSNumber numberWithBool:[boxAwait state]] 121 forKey:kDefaultsMouseDownOnIncorrect]; 122 123 [Settings 124 setObject:[NSNumber numberWithBool:[boxLock state]] 125 forKey:kDefaultsLockSettings]; 126 127 [Settings 128 setObject:[NSNumber numberWithInt:[stepperTime intValue]] 129 forKey:kDefaultsTimeLimit]; 130 131 [Settings 132 setObject:[NSNumber numberWithInt:[stepperKana intValue]] 133 forKey:kDefaultsKanaLimit]; 132 [Settings setObject:[NSNumber numberWithInt:[[selectSession selectedItem] tag]] 133 forKey:kDefaultsSession]; 134 135 [Settings setObject:[NSNumber numberWithBool:[boxAwait state]] 136 forKey:kDefaultsMouseDownOnIncorrect]; 137 138 [Settings setObject:[NSNumber numberWithBool:[boxLock state]] 139 forKey:kDefaultsLockSettings]; 140 141 [Settings setObject:[NSNumber numberWithInt:[stepperTime intValue]] 142 forKey:kDefaultsTimeLimit]; 143 144 [Settings setObject:[NSNumber numberWithInt:[stepperKana intValue]] 145 forKey:kDefaultsKanaLimit]; 134 146 135 147 // --- close the session window Nuku/trunk/Tutor.h
r812 r814 30 30 #import <Cocoa/Cocoa.h> 31 31 32 #define kPathHiraganaImages @"Hiragana Images"33 #define kPathKatakanaImages @"Katakana Images"32 #define kPathHiraganaImages @"Hiragana" 33 #define kPathKatakanaImages @"Katakana" 34 34 35 #define kPathRomanisationSystems @"RomanisationSystems" 36 #define kPathRomanisationSystemsHepburn @"Hepburn.plist" 37 #define kPathRomanisationSystemsKunreiSiki @"KunreiSiki.plist" 38 #define kPathRomanisationSystemsNihonSiki @"NihonSiki.plist" 35 #define kPathRomanisationSystemsHepburn @"Hepburn.plist" 36 #define kPathRomanisationSystemsKunreiSiki @"KunreiSiki.plist" 37 #define kPathRomanisationSystemsNihonSiki @"NihonSiki.plist" 39 38 40 39 Nuku/trunk/Tutor.m
r812 r814 70 70 71 71 // --- get our bundle 72 bundle = [NSBundle bundleForClass:[self class]];72 bundle = [NSBundle bundleForClass:[self class]]; 73 73 74 74 // --- load all images 75 filePaths = [bundlepathsForResourcesOfType:@"gif" inDirectory:which];76 images = [[NSMutableDictionary alloc] initWithCapacity:[filePaths count]];77 enumerator = [filePaths objectEnumerator];75 filePaths = [[NSBundle mainBundle] pathsForResourcesOfType:@"gif" inDirectory:which]; 76 images = [[NSMutableDictionary alloc] initWithCapacity:[filePaths count]]; 77 enumerator = [filePaths objectEnumerator]; 78 78 79 79 // --- hiragana images … … 82 82 fileName = [fileName lastPathComponent]; 83 83 84 [images 85 setObject:[[NSImage alloc] initWithContentsOfFile:filePath] 86 forKey:fileName]; 84 [images setObject:[[NSImage alloc] initWithContentsOfFile:filePath] 85 forKey:fileName]; 87 86 } 88 87 … … 98 97 - (void)loadKanaNames { 99 98 NSBundle *bundle; 100 NSString * dirPath, *filePath;99 NSString *path; 101 100 102 101 // --- get our bundle 103 102 bundle = [NSBundle bundleForClass:[self class]]; 104 103 105 // --- locate the images106 dirPath = [[bundle resourcePath] stringByAppendingPathComponent:kPathRomanisationSystems];107 108 104 // --- now load the files 109 filePath = [dirPathstringByAppendingPathComponent:kPathRomanisationSystemsHepburn];110 hepburnStrings = [[NSDictionary dictionaryWithContentsOfFile: filePath] retain];111 112 filePath = [dirPathstringByAppendingPathComponent:kPathRomanisationSystemsKunreiSiki];113 kunreiSikiStrings = [[NSDictionary dictionaryWithContentsOfFile: filePath] retain];114 115 filePath = [dirPathstringByAppendingPathComponent:kPathRomanisationSystemsNihonSiki];116 nihonSikiStrings = [[NSDictionary dictionaryWithContentsOfFile: filePath] retain];117 } 118 119 120 121 #pragma mark - 122 123 /* 124 Switch the internal set of kana names and reduce it according to our lines mask.105 path = [[bundle resourcePath] stringByAppendingPathComponent:kPathRomanisationSystemsHepburn]; 106 hepburnStrings = [[NSDictionary dictionaryWithContentsOfFile:path] retain]; 107 108 path = [[bundle resourcePath] stringByAppendingPathComponent:kPathRomanisationSystemsKunreiSiki]; 109 kunreiSikiStrings = [[NSDictionary dictionaryWithContentsOfFile:path] retain]; 110 111 path = [[bundle resourcePath] stringByAppendingPathComponent:kPathRomanisationSystemsNihonSiki]; 112 nihonSikiStrings = [[NSDictionary dictionaryWithContentsOfFile:path] retain]; 113 } 114 115 116 117 #pragma mark - 118 119 /* 120 Switch the internal set of kana names. 125 121 */ 126 122
