X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=TargetController.m;h=2e539179dbe3ac5149f9955984959017967dc941;hp=1f285ec5ada026baa3aad49aa3d9b61cdb369677;hb=f864d363128de19fc6591b77ae9226b34166d715;hpb=0238d141f06420e1a73eccd14ca73a7e29ad2a69 diff --git a/TargetController.m b/TargetController.m index 1f285ec..2e53917 100644 --- a/TargetController.m +++ b/TargetController.m @@ -9,9 +9,9 @@ #import "ConfigsController.h" #import "Config.h" -#import "JSAction.h" -#import "JoystickController.h" -#import "KeyInputTextView.h" +#import "NJInput.h" +#import "NJInputController.h" +#import "NJKeyInputField.h" #import "TargetConfig.h" #import "TargetController.h" #import "TargetKeyboard.h" @@ -26,7 +26,7 @@ NSInteger row = radioButtons.selectedRow; if (row != 1) { - keyInput.vk = -1; + keyInput.keyCode = -1; [keyInput resignIfFirstResponder]; } @@ -62,12 +62,17 @@ [self commit]; } -- (void)keyChanged { +- (void)keyInputField:(NJKeyInputField *)keyInput didChangeKey:(CGKeyCode)keyCode { [radioButtons selectCellAtRow:1 column:0]; [radioButtons.window makeFirstResponder:radioButtons]; [self commit]; } +- (void)keyInputFieldDidClear:(NJKeyInputField *)keyInput { + [radioButtons selectCellAtRow:0 column:0]; + [self commit]; +} + - (void)configChosen:(id)sender { [radioButtons selectCellAtRow:2 column:0]; [configPopup.window makeFirstResponder:configPopup]; @@ -93,7 +98,7 @@ } - (Target *)currentTarget { - return configsController.currentConfig[joystickController.selectedAction]; + return configsController.currentConfig[joystickController.selectedInput]; } - (Target *)makeTarget { @@ -101,9 +106,9 @@ case 0: return nil; case 1: - if (keyInput.hasKey) { + if (keyInput.hasKeyCode) { TargetKeyboard *k = [[TargetKeyboard alloc] init]; - k.vk = keyInput.vk; + k.vk = keyInput.keyCode; return k; } else { return nil; @@ -140,7 +145,7 @@ - (void)commit { [self cleanUpInterface]; - configsController.currentConfig[joystickController.selectedAction] = [self makeTarget]; + configsController.currentConfig[joystickController.selectedInput] = [self makeTarget]; [configsController save]; } @@ -157,22 +162,22 @@ [scrollDirSelect setEnabled:enabled]; } -- (void)loadTarget:(Target *)target forAction:(JSAction *)action { - if (!action) { +- (void)loadTarget:(Target *)target forInput:(NJInput *)input { + if (!input) { self.enabled = NO; title.stringValue = @""; } else { self.enabled = YES; - NSString *actFullName = action.name; - for (id cur = action.base; cur; cur = cur.base) { - actFullName = [[NSString alloc] initWithFormat:@"%@ > %@", cur.name, actFullName]; + NSString *inpFullName = input.name; + for (id cur = input.base; cur; cur = cur.base) { + inpFullName = [[NSString alloc] initWithFormat:@"%@ > %@", cur.name, inpFullName]; } - title.stringValue = [[NSString alloc] initWithFormat:@"%@ > %@", configsController.currentConfig.name, actFullName]; + title.stringValue = [[NSString alloc] initWithFormat:@"%@ > %@", configsController.currentConfig.name, inpFullName]; } if ([target isKindOfClass:TargetKeyboard.class]) { [radioButtons selectCellAtRow:1 column:0]; - keyInput.vk = [(TargetKeyboard*)target vk]; + keyInput.keyCode = [(TargetKeyboard*)target vk]; } else if ([target isKindOfClass:TargetConfig.class]) { [radioButtons selectCellAtRow:2 column:0]; NSUInteger idx = [configsController.configs @@ -204,7 +209,7 @@ } - (void)loadCurrent { - [self loadTarget:self.currentTarget forAction:joystickController.selectedAction]; + [self loadTarget:self.currentTarget forInput:joystickController.selectedInput]; } - (void)focusKey {