- (NSDictionary *)serialize {
NSMutableDictionary* cfgEntries = [[NSMutableDictionary alloc] initWithCapacity:_entries.count];
- for (id key in _entries)
- cfgEntries[key] = [_entries[key] serialize];
+ for (id key in _entries) {
+ id serialized = [_entries[key] serialize];
+ if (serialized)
+ cfgEntries[key] = serialized;
+ }
return @{ @"name": _name, @"entries": cfgEntries };
}
[(ApplicationController *)[[NSApplication sharedApplication] delegate] configsChanged];
[tableView reloadData];
+ [self save];
}
-(void)tableViewSelectionDidChange:(NSNotification *)notify {
for (unsigned i = 0; i < storedConfigs.count; ++i) {
NSDictionary *entries = storedConfigs[i][@"entries"];
Config *config = newConfigs[i];
- for (id key in entries)
- config.entries[key] = [Target targetDeserialize:entries[key]
- withConfigs:newConfigs];
+ for (id key in entries) {
+ Target *target = [Target targetDeserialize:entries[key]
+ withConfigs:newConfigs];
+ if (target)
+ config.entries[key] = target;
+ }
}
if (newConfigs.count) {
- (NSDictionary *)serialize {
return _config
? @{ @"type": @"cfg", @"name": _config.name }
- : @{};
+ : nil;
}
+ (TargetConfig *)targetDeserialize:(NSDictionary *)serialization
keyInput.vk = [(TargetKeyboard*)target vk];
} else if ([target isKindOfClass:[TargetConfig class]]) {
[radioButtons selectCellAtRow:2 column:0];
- [configPopup selectItemAtIndex:[configsController.configs
- indexOfObject:[(TargetConfig *)target config]]];
+ NSUInteger idx = [configsController.configs
+ indexOfObject:[(TargetConfig *)target config]];
+ if (idx == NSNotFound) {
+ [radioButtons selectCellAtRow:self.enabled ? 0 : -1 column:0];
+ [configPopup selectItemAtIndex:-1];
+ } else
+ [configPopup selectItemAtIndex:idx];
}
else if ([target isKindOfClass:[TargetMouseMove class]]) {
[radioButtons selectCellAtRow:3 column:0];