X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=TargetController.m;h=074c4876ff8717ffac5ed1f3f8b7966314f7d850;hp=9b075a15945ca851b8f5aa679d42952738cbd7ac;hb=25dd74a4a34f4ba7ec797360bd8f92cbd7bc758e;hpb=a71f9eae29ac9df72aa15c2de80f6a82b5aca44e diff --git a/TargetController.m b/TargetController.m index 9b075a1..074c487 100644 --- a/TargetController.m +++ b/TargetController.m @@ -15,7 +15,17 @@ [[[NSApplication sharedApplication] mainWindow] makeFirstResponder: sender]; [self commit]; } +-(IBAction)mdirChanged:(id)sender { + [radioButtons setState: 1 atRow: 3 column: 0]; + [[[NSApplication sharedApplication] mainWindow] makeFirstResponder: sender]; + [self commit]; +} -(IBAction)mbtnChanged:(id)sender { + [radioButtons setState: 1 atRow: 4 column: 0]; + [[[NSApplication sharedApplication] mainWindow] makeFirstResponder: sender]; + [self commit]; +} +-(IBAction)sdirChanged:(id)sender { [radioButtons setState: 1 atRow: 5 column: 0]; [[[NSApplication sharedApplication] mainWindow] makeFirstResponder: sender]; [self commit]; @@ -27,7 +37,7 @@ case 0: // none return NULL; case 1: // key - if([keyInput hasKey]) { + if(keyInput.hasKey) { TargetKeyboard* k = [[TargetKeyboard alloc] init]; [k setVk: [keyInput vk]]; [k setDescr: [keyInput descr]]; @@ -37,22 +47,16 @@ case 2: { TargetConfig* c = [[TargetConfig alloc] init]; - [c setConfig: [[configsController configs] objectAtIndex: [configPopup indexOfSelectedItem]]]; + [c setConfig: [configsController configs][[configPopup indexOfSelectedItem]]]; return c; } case 3: { - // mouse X + // mouse X/Y TargetMouseMove *mm = [[TargetMouseMove alloc] init]; - [mm setDir: 0]; + [mm setDir: [mouseDirSelect selectedSegment]]; return mm; } case 4: { - // mouse Y - TargetMouseMove *mm = [[TargetMouseMove alloc] init]; - [mm setDir: 1]; - return mm; - } - case 5: { // mouse button TargetMouseBtn *mb = [[TargetMouseBtn alloc] init]; if ([mouseBtnSelect selectedSegment] == 0) { @@ -63,6 +67,22 @@ } return mb; } + case 5: { + // scroll + TargetMouseScroll *ms = [[TargetMouseScroll alloc] init]; + if ([scrollDirSelect selectedSegment] == 0) { + [ms setHowMuch: -1]; + } + else { + [ms setHowMuch: 1]; + } + return ms; + } + case 6: { + // toggle mouse scope + TargetToggleMouseScope *tms = [[TargetToggleMouseScope alloc] init]; + return tms; + } } return NULL; } @@ -73,17 +93,18 @@ } -(void) commit { - id action = [joystickController selectedAction]; - if(action) { - Target* target = [self state]; - [[configsController currentConfig] setTarget: target forAction: action]; + JSAction *action = [joystickController selectedAction]; + if (action) { + configsController.currentConfig[action] = self.state; } } -(void) reset { [keyInput clear]; [radioButtons setState: 1 atRow: 0 column: 0]; + [mouseDirSelect setSelectedSegment: 0]; [mouseBtnSelect setSelectedSegment: 0]; + [scrollDirSelect setSelectedSegment: 0]; [self refreshConfigsPreservingSelection: NO]; } @@ -91,7 +112,9 @@ [radioButtons setEnabled: enabled]; [keyInput setEnabled: enabled]; [configPopup setEnabled: enabled]; + [mouseDirSelect setEnabled: enabled]; [mouseBtnSelect setEnabled: enabled]; + [scrollDirSelect setEnabled: enabled]; } -(BOOL) enabled { return [radioButtons isEnabled]; @@ -107,7 +130,7 @@ } else { [self setEnabled: YES]; } - Target* target = [[configsController currentConfig] getTargetForAction: jsaction]; + Target* target = configsController.currentConfig[jsaction]; id act = jsaction; NSString* actFullName = [act name]; @@ -127,17 +150,25 @@ [configPopup selectItemAtIndex: [[configsController configs] indexOfObject: [(TargetConfig*)target config]]]; } else if ([target isKindOfClass: [TargetMouseMove class]]) { - if ([(TargetMouseMove *)target dir] == 0) - [radioButtons setState:1 atRow: 3 column: 0]; - else - [radioButtons setState:1 atRow: 4 column: 0]; + [radioButtons setState:1 atRow: 3 column: 0]; + [mouseDirSelect setSelectedSegment: [(TargetMouseMove *)target dir]]; } else if ([target isKindOfClass: [TargetMouseBtn class]]) { - [radioButtons setState: 1 atRow: 5 column: 0]; + [radioButtons setState: 1 atRow: 4 column: 0]; if ([(TargetMouseBtn *)target which] == kCGMouseButtonLeft) [mouseBtnSelect setSelectedSegment: 0]; else [mouseBtnSelect setSelectedSegment: 1]; + } + else if ([target isKindOfClass: [TargetMouseScroll class]]) { + [radioButtons setState: 1 atRow: 5 column: 0]; + if ([(TargetMouseScroll *)target howMuch] < 0) + [scrollDirSelect setSelectedSegment: 0]; + else + [scrollDirSelect setSelectedSegment: 1]; + } + else if ([target isKindOfClass: [TargetToggleMouseScope class]]) { + [radioButtons setState: 1 atRow: 6 column: 0]; } else { [NSException raise:@"Unknown target subclass" format:@"Unknown target subclass"]; } @@ -153,7 +184,7 @@ NSArray* configs = [configsController configs]; [configPopup removeAllItems]; for(int i=0; i<[configs count]; i++) { - [configPopup addItemWithTitle: [[configs objectAtIndex:i]name]]; + [configPopup addItemWithTitle: [configs[i]name]]; } if(preserve) [configPopup selectItemAtIndex:initialIndex];