Changeset 752 for trunk/macosx/Controller.m
- Timestamp:
- Aug 11, 2006, 10:58:14 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Controller.m
r750 r752 306 306 name: @"RatioGlobalChange" object: nil]; 307 307 308 [nc addObserver: self selector: @selector(autoSpeedLimit:) 309 name: @"AutoSpeedLimitChange" object: nil]; 310 308 311 [nc addObserver: self selector: @selector(autoImportChange:) 309 312 name: @"AutoImportSettingChange" object: nil]; … … 352 355 353 356 //timer to auto toggle speed limit 357 [self autoSpeedLimit: nil]; 354 358 fSpeedLimitTimer = [NSTimer scheduledTimerWithTimeInterval: AUTO_SPEED_LIMIT_SECONDS target: self 355 359 selector: @selector(autoSpeedLimit:) userInfo: nil repeats: YES]; … … 1252 1256 } 1253 1257 1254 - (void) autoSpeedLimit: (NSTimer *) timer 1255 { 1256 BOOL autoOn, autoOff; 1257 if (!(autoOn = [fDefaults boolForKey: @"SpeedLimitAutoOn"]) 1258 && !(autoOff = [fDefaults boolForKey: @"SpeedLimitAutoOff"])) 1258 - (void) autoSpeedLimit: (id) sender 1259 { 1260 if (![fDefaults boolForKey: @"SpeedLimitAuto"]) 1259 1261 return; 1260 1262 … … 1262 1264 int onHour, offHour; 1263 1265 if ((onHour = [fDefaults integerForKey: @"SpeedLimitAutoOnHour"]) 1264 == (offHour = [fDefaults integerForKey: @"SpeedLimitAutoOffHour"]) && autoOn && autoOff)1266 == (offHour = [fDefaults integerForKey: @"SpeedLimitAutoOffHour"])) 1265 1267 return; 1266 1268 1267 NSCalendarDate * currentDate = [NSCalendarDate calendarDate]; 1268 //toggle if within first few seconds of hour 1269 if ([currentDate minuteOfHour] == 0 && [currentDate secondOfMinute] < AUTO_SPEED_LIMIT_SECONDS 1270 && [currentDate hourOfDay] == (fSpeedLimitEnabled ? offHour : onHour)) 1269 BOOL rangeForOn = onHour < offHour; 1270 int min, max; 1271 if (rangeForOn) 1272 { 1273 min = onHour; 1274 max = offHour; 1275 } 1276 else 1277 { 1278 min = offHour; 1279 max = onHour; 1280 } 1281 1282 int hour = [[NSCalendarDate calendarDate] hourOfDay]; 1283 BOOL inRange = hour >= min && hour < max; 1284 1285 if ((!fSpeedLimitEnabled && (rangeForOn == inRange)) || (fSpeedLimitEnabled && (rangeForOn != inRange))) 1271 1286 { 1272 1287 [self toggleSpeedLimit: nil];
Note: See TracChangeset
for help on using the changeset viewer.