X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=Classes%2FNJOutputController.m;h=22c387fc9490107a4bee3a0d89e8fc7ef23556bc;hp=4c8ce640afd36b75e238810d213c365d66425734;hb=6a8c6539cc3f7a4b32a9f226da6ae06074e4f0cb;hpb=79b05c3cf1c75bc4f7078acde43aaf4215c6408a diff --git a/Classes/NJOutputController.m b/Classes/NJOutputController.m index 4c8ce64..22c387f 100644 --- a/Classes/NJOutputController.m +++ b/Classes/NJOutputController.m @@ -20,7 +20,9 @@ #import "NJOutputMouseMove.h" #import "NJOutputMouseScroll.h" -@implementation NJOutputController +@implementation NJOutputController { + NJInput *_input; +} - (id)init { if ((self = [super init])) { @@ -53,8 +55,8 @@ if (row != 2) { [mappingPopup selectItemAtIndex:-1]; [mappingPopup resignIfFirstResponder]; - } else if (!mappingPopup.selectedItem) - [mappingPopup selectItemAtIndex:0]; + unknownMapping.hidden = YES; + } if (row != 3) { mouseDirSelect.selectedSegment = -1; @@ -108,6 +110,7 @@ - (void)mappingChosen:(id)sender { [radioButtons selectCellAtRow:2 column:0]; [mappingPopup.window makeFirstResponder:mappingPopup]; + unknownMapping.hidden = YES; [self commit]; } @@ -156,7 +159,7 @@ } - (NJOutput *)currentOutput { - return mappingsController.currentMapping[inputController.selectedInput]; + return mappingsController.currentMapping[_input]; } - (NJOutput *)makeOutput { @@ -166,7 +169,7 @@ case 1: if (keyInput.hasKeyCode) { NJOutputKeyPress *k = [[NJOutputKeyPress alloc] init]; - k.vk = keyInput.keyCode; + k.keyCode = keyInput.keyCode; return k; } else { return nil; @@ -174,7 +177,7 @@ break; case 2: { NJOutputMapping *c = [[NJOutputMapping alloc] init]; - c.mapping = mappingsController[mappingPopup.indexOfSelectedItem]; + c.mapping = mappingsController.mappings[mappingPopup.indexOfSelectedItem]; return c; } case 3: { @@ -202,7 +205,7 @@ - (void)commit { [self cleanUpInterface]; - mappingsController.currentMapping[inputController.selectedInput] = [self makeOutput]; + mappingsController.currentMapping[_input] = [self makeOutput]; [mappingsController save]; } @@ -220,6 +223,8 @@ scrollDirSelect.enabled = enabled; smoothCheck.enabled = enabled; scrollSpeedSlider.enabled = enabled && smoothCheck.state; + if (!enabled) + unknownMapping.hidden = YES; } - (void)loadOutput:(NJOutput *)output forInput:(NJInput *)input { @@ -229,7 +234,7 @@ } else { self.enabled = YES; NSString *inpFullName = input.name; - for (NJInputPathElement *cur = input.base; cur; cur = cur.base) { + for (NJInputPathElement *cur = input.parent; cur; cur = cur.parent) { inpFullName = [[NSString alloc] initWithFormat:@"%@ ▸ %@", cur.name, inpFullName]; } title.stringValue = inpFullName; @@ -237,13 +242,13 @@ if ([output isKindOfClass:NJOutputKeyPress.class]) { [radioButtons selectCellAtRow:1 column:0]; - keyInput.keyCode = [(NJOutputKeyPress*)output vk]; + keyInput.keyCode = [(NJOutputKeyPress*)output keyCode]; } else if ([output isKindOfClass:NJOutputMapping.class]) { [radioButtons selectCellAtRow:2 column:0]; - NSMenuItem *item = [mappingPopup itemWithRepresentedObject:[(NJOutputMapping *)output mapping]]; + NSMenuItem *item = [mappingPopup itemWithIdenticalRepresentedObject:[(NJOutputMapping *)output mapping]]; [mappingPopup selectItem:item]; - if (!item) - [radioButtons selectCellAtRow:self.enabled ? 0 : -1 column:0]; + unknownMapping.hidden = !!item; + unknownMapping.title = [(NJOutputMapping *)output mappingName]; } else if ([output isKindOfClass:NJOutputMouseMove.class]) { [radioButtons selectCellAtRow:3 column:0]; @@ -269,8 +274,9 @@ [self cleanUpInterface]; } -- (void)loadCurrent { - [self loadOutput:self.currentOutput forInput:inputController.selectedInput]; +- (void)loadInput:(NJInput *)input { + _input = input; + [self loadOutput:self.currentOutput forInput:input]; } - (void)focusKey { @@ -292,11 +298,11 @@ item.representedObject = mapping; [mappingPopup.menu addItem:item]; } - [mappingPopup selectItemWithRepresentedObject:current]; + [mappingPopup selectItemWithIdenticalRepresentedObject:current]; } - (void)mappingDidChange:(NSNotification *)note { - [self loadCurrent]; + [self loadInput:_input]; } @end