Changeset 814

Show
Ignore:
Timestamp:
04/03/03 01:09:16 (6 years ago)
Author:
morris
Message:

clean up

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Nuku/trunk/Controller.h

    r812 r814  
    6767    IBOutlet NSButtonCell               *kanaZi; 
    6868 
    69     IBOutlet NSButton                 *linesA; 
     69       IBOutlet NSButton                      *linesA; 
    7070    IBOutlet NSButton                   *linesBa; 
    7171    IBOutlet NSButton                   *linesDa; 
     
    8080    IBOutlet NSButton                   *linesTa; 
    8181    IBOutlet NSButton                   *linesWa; 
    82     IBOutlet NSButton                 *linesYa; 
     82       IBOutlet NSButton                      *linesYa; 
    8383    IBOutlet NSButton                   *linesZa; 
    8484 
  • Nuku/trunk/Controller.m

    r812 r814  
    3434@implementation Controller 
    3535 
     36- (id)init { 
     37        self = [super init]; 
     38         
     39        tutor = [[Tutor alloc] init]; 
     40         
     41        return self; 
     42} 
     43         
     44 
    3645- (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 
    4147        [self updateSettings]; 
    4248} 
     
    4450 
    4551 
     52#pragma mark - 
     53 
    4654/* 
    4755        Called when the application receives a shutdown notice, i.e. the user quits. 
     
    4957 
    5058- (void)applicationWillTerminate:(NSNotification *)notification { 
    51         [Settings 
    52                 setObject:[windowTutor stringWithSavedFrame] 
    53                 forKey:kDefaultsTutorPosition]; 
     59        [Settings setObject:[windowTutor stringWithSavedFrame] 
     60                          forKey:kDefaultsTutorPosition]; 
    5461} 
    5562 
     
    6168 
    6269- (void)windowWillClose:(NSNotification *)notification { 
    63         [Settings 
    64                 setObject:[windowTutor stringWithSavedFrame] 
    65                 forKey:kDefaultsTutorPosition]; 
     70        [Settings setObject:[windowTutor stringWithSavedFrame] 
     71                          forKey:kDefaultsTutorPosition]; 
    6672 
    6773        [self resetTutor]; 
     
    111117        // --- lock down the Settings menu if we should 
    112118        if([[Settings objectForKey:kDefaultsLockSettings] boolValue]) 
    113                 state  = NO; 
     119                state = NO; 
    114120         
    115121        [menuSettings setAutoenablesItems:NO]; 
     
    117123        enumerator      = [menuItems objectEnumerator]; 
    118124         
    119         while(menuItem = [enumerator nextObject]) { 
     125        while(menuItem = [enumerator nextObject]) 
    120126                [menuItem setEnabled:state]; 
    121         } 
    122127         
    123128        // --- lock quiz/learning if we're in a limited session 
    124129        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]; 
    128132 
    129133                [itemQuizMode setState:NSOnState]; 
     
    135139         
    136140        // --- select our romanisation system 
    137         [tutor switchRomanisationStrings: 
    138                 [[Settings objectForKey:kDefaultsRomanisationSystem] intValue]]; 
     141        [tutor switchRomanisationStrings:[[Settings objectForKey:kDefaultsRomanisationSystem] intValue]]; 
    139142         
    140143        // --- update the buttons according to the romanisation system 
     
    166169        // --- install a timer that fires when our time is up if we're in a limited session 
    167170        if([[Settings objectForKey:kDefaultsSession] intValue] == kDefaultsSessionLimited && 
    168            [[Settings objectForKey:kDefaultsTimeLimit] intValue] > 0) 
    169                 timer = [NSTimer 
    170                         scheduledTimerWithTimeInterval:[[Settings objectForKey:kDefaultsTimeLimit] intValue] 
    171                         target:self 
    172                         selector:@selector(sessionShouldFinish) 
    173                         userInfo:NULL 
    174                        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        } 
    175178} 
    176179 
     
    208211                 
    209212        // --- get a timestamp 
    210         stopTime       = time(NULL); 
    211         diffTime       = stopTime - startTime; 
     213        stopTime = time(NULL); 
     214        diffTime = stopTime - startTime; 
    212215         
    213216        // --- close this window 
     
    802805- (IBAction)changeMode:(id)sender { 
    803806        // --- 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]; 
    807809         
    808810        // --- turn off everyone, then turn on the sender 
     
    830832- (IBAction)changeKanaType:(id)sender { 
    831833        // --- 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]; 
    835836         
    836837        // --- turn off everyone, then turn on the sender 
     
    854855         
    855856        // --- 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]; 
    859859 
    860860        // turn off everyone, then turn on the sender 
  • Nuku/trunk/Session.m

    r812 r814  
    3434@implementation Session 
    3535 
     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 
    3656- (void)awakeFromNib { 
    37         // --- initiate our classes 
    38         settings        = [[Settings alloc] init]; 
    39          
    4057        // --- start with a new session 
    4158        [self newSession:self]; 
     
    113130- (IBAction)start:(id)sender { 
    114131        // --- 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]; 
    134146         
    135147        // --- close the session window 
  • Nuku/trunk/Tutor.h

    r812 r814  
    3030#import <Cocoa/Cocoa.h> 
    3131 
    32 #define kPathHiraganaImages                                                     @"HiraganaImages
    33 #define kPathKatakanaImages                                                     @"KatakanaImages
     32#define kPathHiraganaImages                                                     @"Hiragana
     33#define kPathKatakanaImages                                                     @"Katakana
    3434 
    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" 
    3938 
    4039 
  • Nuku/trunk/Tutor.m

    r812 r814  
    7070         
    7171        // --- get our bundle 
    72         bundle                         = [NSBundle bundleForClass:[self class]]; 
     72        bundle          = [NSBundle bundleForClass:[self class]]; 
    7373 
    7474        // --- load all images 
    75         filePaths                      = [bundle pathsForResourcesOfType:@"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]; 
    7878         
    7979        // --- hiragana images 
     
    8282                fileName = [fileName lastPathComponent]; 
    8383 
    84                 [images 
    85                         setObject:[[NSImage alloc] initWithContentsOfFile:filePath] 
    86                         forKey:fileName]; 
     84                [images setObject:[[NSImage alloc] initWithContentsOfFile:filePath] 
     85                                forKey:fileName]; 
    8786        } 
    8887         
     
    9897- (void)loadKanaNames { 
    9998        NSBundle                        *bundle; 
    100         NSString                        *dirPath, *filePath; 
     99        NSString                        *path; 
    101100         
    102101        // --- get our bundle 
    103102        bundle                          = [NSBundle bundleForClass:[self class]]; 
    104103 
    105         // --- locate the images 
    106         dirPath                         = [[bundle resourcePath] stringByAppendingPathComponent:kPathRomanisationSystems]; 
    107          
    108104        // --- now load the files 
    109         filePath                       = [dirPath stringByAppendingPathComponent:kPathRomanisationSystemsHepburn]; 
    110         hepburnStrings          = [[NSDictionary dictionaryWithContentsOfFile:filePath] retain]; 
    111          
    112         filePath                       = [dirPath stringByAppendingPathComponent:kPathRomanisationSystemsKunreiSiki]; 
    113         kunreiSikiStrings       = [[NSDictionary dictionaryWithContentsOfFile:filePath] retain]; 
    114          
    115         filePath                       = [dirPath stringByAppendingPathComponent: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
    125121*/ 
    126122