Changeset 757


Ignore:
Timestamp:
Aug 12, 2006, 8:36:17 PM (15 years ago)
Author:
livings124
Message:

Some changes for the last commit plus don't allow the same time for turning speed limit on and off.

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r756 r757  
    12611261        return;
    12621262 
    1263     //do nothing if time to turn on and off are equal
    1264     int onHour, offHour;
    1265     if ((onHour = [fDefaults integerForKey: @"SpeedLimitAutoOnHour"])
    1266             == (offHour = [fDefaults integerForKey: @"SpeedLimitAutoOffHour"]))
    1267         return;
    1268    
     1263    int onHour = [fDefaults integerForKey: @"SpeedLimitAutoOnHour"],
     1264        offHour = [fDefaults integerForKey: @"SpeedLimitAutoOffHour"];
     1265   
     1266    //check if should be on if within range
    12691267    BOOL shouldBeOn;
    12701268    int hour = [[NSCalendarDate calendarDate] hourOfDay];
     
    12801278- (void) autoSpeedLimit: (NSTimer *) timer
    12811279{
    1282     BOOL autoOn, autoOff;
    1283     if (!(autoOn = [fDefaults boolForKey: @"SpeedLimitAutoOn"])
    1284             && !(autoOff = [fDefaults boolForKey: @"SpeedLimitAutoOff"]))
     1280    if (![fDefaults boolForKey: @"SpeedLimitAuto"])
    12851281        return;
    12861282 
    1287     //do nothing if time to turn on and off are equal
    1288     int onHour, offHour;
    1289     if ((onHour = [fDefaults integerForKey: @"SpeedLimitAutoOnHour"])
    1290             == (offHour = [fDefaults integerForKey: @"SpeedLimitAutoOffHour"]) && autoOn && autoOff)
    1291         return;
    1292    
     1283    //toggle if within first few seconds of hour
    12931284    NSCalendarDate * currentDate = [NSCalendarDate calendarDate];
    1294     //toggle if within first few seconds of hour
    12951285    if ([currentDate minuteOfHour] == 0 && [currentDate secondOfMinute] < AUTO_SPEED_LIMIT_SECONDS
    1296             && [currentDate hourOfDay] == (fSpeedLimitEnabled ? offHour : onHour))
     1286            && [currentDate hourOfDay] == (fSpeedLimitEnabled ? [fDefaults integerForKey: @"SpeedLimitAutoOffHour"]
     1287                                            : [fDefaults integerForKey: @"SpeedLimitAutoOnHour"]))
    12971288    {
    12981289        [self toggleSpeedLimit: nil];
  • trunk/macosx/PrefsController.m

    r752 r757  
    513513
    514514    int hour = [sender intValue];
    515     if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", hour]] || hour < 0 || hour > 23)
     515    if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", hour]] || hour < 0 || hour > 23
     516        || [fSpeedLimitAutoOnField intValue] == [fSpeedLimitAutoOffField intValue])
    516517    {
    517518        NSBeep();
Note: See TracChangeset for help on using the changeset viewer.