X-Git-Url: https://git.yukkurigames.com/?a=blobdiff_plain;f=ConfigsController.m;h=f6770cc78dbffbfb365188f47a67cc36ff465e55;hb=912756bc7342b277d9648a4a128dbfc1a3d53d77;hp=43c92d33b65fa6722e380e413740aa60eaeb1b31;hpb=530009447c5bbd360ac5023979cffc6d32a28df3;p=enjoyable.git diff --git a/ConfigsController.m b/ConfigsController.m index 43c92d3..f6770cc 100644 --- a/ConfigsController.m +++ b/ConfigsController.m @@ -23,10 +23,6 @@ -(void) restoreNeutralConfig { if(!neutralConfig) return; - if([configs indexOfObject:neutralConfig] < 0) {// deleted, keep what we have - neutralConfig = NULL; - return; - } [self activateConfig: neutralConfig forApplication: NULL]; } @@ -48,17 +44,17 @@ currentConfig = config; [removeButton setEnabled: ![config protect]]; [targetController load]; - [[[NSApplication sharedApplication] delegate] configChanged]; - [tableView selectRow: [configs indexOfObject: config] byExtendingSelection: NO]; + [(ApplicationController *)[[NSApplication sharedApplication] delegate] configChanged]; + [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:[configs indexOfObject:config]] byExtendingSelection:NO]; } -(IBAction) addPressed: (id)sender { Config* newConfig = [[Config alloc] init]; [newConfig setName: @"untitled"]; [configs addObject: newConfig]; - [[[NSApplication sharedApplication] delegate] configsChanged]; + [(ApplicationController *)[[NSApplication sharedApplication] delegate] configsChanged]; [tableView reloadData]; - [tableView selectRow: ([configs count]-1) byExtendingSelection: NO]; + [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:configs.count - 1] byExtendingSelection:NO]; [tableView editColumn: 0 row:([configs count]-1) withEvent:nil select:YES]; } -(IBAction) removePressed: (id)sender { @@ -78,13 +74,14 @@ [entries removeObjectForKey: key]; } } - [[[NSApplication sharedApplication] delegate] configsChanged]; + [(ApplicationController *)[[NSApplication sharedApplication] delegate] configsChanged]; [tableView reloadData]; } -(void)tableViewSelectionDidChange:(NSNotification*) notify { - [self activateConfig: (Config*)[configs objectAtIndex:[tableView selectedRow]] forApplication: NULL]; + if (tableView.selectedRow < configs.count) + [self activateConfig: (Config*)[configs objectAtIndex:[tableView selectedRow]] forApplication: NULL]; } -(id) tableView: (NSTableView*)view objectValueForTableColumn: (NSTableColumn*) column row: (int) index { @@ -99,7 +96,7 @@ [(Config*)[configs objectAtIndex: index] setName: newName]; [targetController refreshConfigsPreservingSelection:YES]; [tableView reloadData]; - [[[NSApplication sharedApplication] delegate] configsChanged]; + [(ApplicationController *)[[NSApplication sharedApplication] delegate] configsChanged]; } -(int)numberOfRowsInTableView: (NSTableView*)table { @@ -161,7 +158,7 @@ for(int i=0; i<[ary count]; i++) { NSDictionary* dict = [[ary objectAtIndex:i] objectForKey:@"entries"]; for(id key in dict) { - [[[newConfigs objectAtIndex:i] entries] + [[[newConfigs objectAtIndex:i] entries] setObject: [Target unstringify: [dict objectForKey: key] withConfigList: newConfigs] forKey: key]; } @@ -170,10 +167,11 @@ configs = newConfigs; [tableView reloadData]; currentConfig = NULL; - [[[NSApplication sharedApplication] delegate] configsChanged]; + [(ApplicationController *)[[NSApplication sharedApplication] delegate] configsChanged]; int index = [[envelope objectForKey: @"selectedIndex"] intValue]; - [self activateConfig: [configs objectAtIndex:index] forApplication: NULL]; + if (index < configs.count) + [self activateConfig: [configs objectAtIndex:index] forApplication: NULL]; } -(void) applicationSwitchedTo: (NSString*) name withPsn: (ProcessSerialNumber) psn {