X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=Target.m;h=9666c8a80f27280f02d1d3219e45dd3180ccfd5b;hp=e7ea673885798d5461d4c1acffc4ae13e15678d2;hb=51d43664909060e85c943c4d63cc3cff307ceb1d;hpb=724979785b445dcba8a9861c2531ae0308bdf40a diff --git a/Target.m b/Target.m index e7ea673..9666c8a 100644 --- a/Target.m +++ b/Target.m @@ -5,16 +5,21 @@ // Created by Sam McCall on 5/05/09. // -@implementation Target +@implementation Target { + BOOL running; +} + +@synthesize magnitude; +// TODO: Should just be NSCoding? Or like a dictionary? +(Target*) unstringify: (NSString*) str withConfigList: (NSArray*) configs { - NSArray* components = [str componentsSeparatedByString:@"~"]; - NSParameterAssert([components count]); - NSString* typeTag = components[0]; - if([typeTag isEqualToString:@"key"]) - return [TargetKeyboard unstringifyImpl:components]; - if([typeTag isEqualToString:@"cfg"]) - return [TargetConfig unstringifyImpl:components withConfigList:configs]; + NSArray* components = [str componentsSeparatedByString:@"~"]; + NSParameterAssert([components count]); + NSString* typeTag = components[0]; + if([typeTag isEqualToString:@"key"]) + return [TargetKeyboard unstringifyImpl:components]; + if([typeTag isEqualToString:@"cfg"]) + return [TargetConfig unstringifyImpl:components withConfigList:configs]; if([typeTag isEqualToString:@"mmove"]) return [TargetMouseMove unstringifyImpl:components]; if([typeTag isEqualToString:@"mbtn"]) @@ -23,32 +28,43 @@ return [TargetMouseScroll unstringifyImpl:components]; if([typeTag isEqualToString:@"mtoggle"]) return [TargetToggleMouseScope unstringifyImpl:components]; - - NSParameterAssert(NO); - return NULL; + + NSParameterAssert(NO); + return NULL; } --(NSString*) stringify { - [self doesNotRecognizeSelector:_cmd]; - return NULL; +- (NSString *)stringify { + [self doesNotRecognizeSelector:_cmd]; + return NULL; } --(void) trigger: (JoystickController *)jc { - [self doesNotRecognizeSelector:_cmd]; +- (void)trigger { } --(void) untrigger: (JoystickController *)jc { - // no-op by default +- (void)untrigger { } - (BOOL)update:(JoystickController *)jc { return NO; } --(BOOL) isContinuous { - return false; +- (BOOL)isContinuous { + return NO; +} + +- (BOOL)running { + return running; +} + +- (void)setRunning:(BOOL)newRunning { + if (running != newRunning) { + running = newRunning; + if (running) + [self trigger]; + else + [self untrigger]; + } } -@synthesize inputValue, running; @end