X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=TargetConfig.m;fp=TargetConfig.m;h=73d45633274291d58ddf068f916972be082d7494;hp=0000000000000000000000000000000000000000;hb=530009447c5bbd360ac5023979cffc6d32a28df3;hpb=5f07baa8cb03a2f6aa06338bfeb31dad3c3ca29f diff --git a/TargetConfig.m b/TargetConfig.m new file mode 100644 index 0000000..73d4563 --- /dev/null +++ b/TargetConfig.m @@ -0,0 +1,36 @@ +// +// TargetConfig.m +// Enjoy +// +// Created by Sam McCall on 6/05/09. +// + +#import "TargetConfig.h" + + +@implementation TargetConfig + +@synthesize config; + +-(NSString*) stringify { + return [[NSString alloc] initWithFormat: @"cfg~%@", [config name]]; +} + ++(TargetConfig*) unstringifyImpl: (NSArray*) comps withConfigList: (NSArray*) configs { + NSParameterAssert([comps count] == 2); + NSString* name = [comps objectAtIndex: 1]; + TargetConfig* target = [[TargetConfig alloc] init]; + for(int i=0; i<[configs count]; i++) + if([[[configs objectAtIndex:i] name] isEqualToString:name]) { + [target setConfig: [configs objectAtIndex:i]]; + return target; + } + NSLog(@"Warning: couldn't find matching config to restore from: %@",name); + return NULL; +} + +-(void) trigger { + [[[[NSApplication sharedApplication] delegate] configsController] activateConfig:config forApplication: NULL]; +} + +@end