X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=TargetController.m;h=1da2c99a6e7157f038ac8d13a5eb6fa8a6cacab3;hp=48119c20e45e28dea3b812590fdeb1b2d37c5bdb;hb=e2a4d830dd9817f6a515a3b1b6aa152d3bb98c2b;hpb=4a490c57151dd4ba9cb27cc34a0e33fc68fc4d24 diff --git a/TargetController.m b/TargetController.m index 48119c2..1da2c99 100644 --- a/TargetController.m +++ b/TargetController.m @@ -7,10 +7,10 @@ #import "TargetController.h" -#import "ConfigsController.h" -#import "Config.h" -#import "JSAction.h" -#import "JoystickController.h" +#import "NJMappingsController.h" +#import "NJMapping.h" +#import "NJInput.h" +#import "NJInputController.h" #import "NJKeyInputField.h" #import "TargetConfig.h" #import "TargetController.h" @@ -31,10 +31,10 @@ } if (row != 2) { - [configPopup selectItemAtIndex:-1]; - [configPopup resignIfFirstResponder]; - } else if (!configPopup.selectedItem) - [configPopup selectItemAtIndex:0]; + [mappingPopup selectItemAtIndex:-1]; + [mappingPopup resignIfFirstResponder]; + } else if (!mappingPopup.selectedItem) + [mappingPopup selectItemAtIndex:0]; if (row != 3) { mouseDirSelect.selectedSegment = -1; @@ -73,9 +73,9 @@ [self commit]; } -- (void)configChosen:(id)sender { +- (void)mappingChosen:(id)sender { [radioButtons selectCellAtRow:2 column:0]; - [configPopup.window makeFirstResponder:configPopup]; + [mappingPopup.window makeFirstResponder:mappingPopup]; [self commit]; } @@ -98,7 +98,7 @@ } - (Target *)currentTarget { - return configsController.currentConfig[joystickController.selectedAction]; + return mappingsController.currentMapping[joystickController.selectedInput]; } - (Target *)makeTarget { @@ -116,7 +116,7 @@ break; case 2: { TargetConfig *c = [[TargetConfig alloc] init]; - c.config = configsController.configs[configPopup.indexOfSelectedItem]; + c.mapping = mappingsController.mappings[mappingPopup.indexOfSelectedItem]; return c; } case 3: { @@ -145,8 +145,8 @@ - (void)commit { [self cleanUpInterface]; - configsController.currentConfig[joystickController.selectedAction] = [self makeTarget]; - [configsController save]; + mappingsController.currentMapping[joystickController.selectedInput] = [self makeTarget]; + [mappingsController save]; } - (BOOL)enabled { @@ -156,23 +156,23 @@ - (void)setEnabled:(BOOL)enabled { [radioButtons setEnabled:enabled]; [keyInput setEnabled:enabled]; - [configPopup setEnabled:enabled]; + [mappingPopup setEnabled:enabled]; [mouseDirSelect setEnabled:enabled]; [mouseBtnSelect setEnabled:enabled]; [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:@"%@ > %@", mappingsController.currentMapping.name, inpFullName]; } if ([target isKindOfClass:TargetKeyboard.class]) { @@ -180,13 +180,13 @@ keyInput.keyCode = [(TargetKeyboard*)target vk]; } else if ([target isKindOfClass:TargetConfig.class]) { [radioButtons selectCellAtRow:2 column:0]; - NSUInteger idx = [configsController.configs - indexOfObject:[(TargetConfig *)target config]]; + NSUInteger idx = [mappingsController.mappings + indexOfObject:[(TargetConfig *)target mapping]]; if (idx == NSNotFound) { [radioButtons selectCellAtRow:self.enabled ? 0 : -1 column:0]; - [configPopup selectItemAtIndex:-1]; + [mappingPopup selectItemAtIndex:-1]; } else - [configPopup selectItemAtIndex:idx]; + [mappingPopup selectItemAtIndex:idx]; } else if ([target isKindOfClass:TargetMouseMove.class]) { [radioButtons selectCellAtRow:3 column:0]; @@ -209,7 +209,7 @@ } - (void)loadCurrent { - [self loadTarget:self.currentTarget forAction:joystickController.selectedAction]; + [self loadTarget:self.currentTarget forInput:joystickController.selectedInput]; } - (void)focusKey { @@ -219,17 +219,17 @@ [keyInput resignIfFirstResponder]; } -- (void)refreshConfigs { - NSInteger initialIndex = configPopup.indexOfSelectedItem; - [configPopup.menu removeAllItems]; - for (Config *config in configsController.configs) { - NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:config.name - action:@selector(configChosen:) +- (void)refreshMappings { + NSInteger initialIndex = mappingPopup.indexOfSelectedItem; + [mappingPopup.menu removeAllItems]; + for (NJMapping *mapping in mappingsController.mappings) { + NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:mapping.name + action:@selector(mappingChosen:) keyEquivalent:@""]; item.target = self; - [configPopup.menu addItem:item]; + [mappingPopup.menu addItem:item]; } - [configPopup selectItemAtIndex:initialIndex]; + [mappingPopup selectItemAtIndex:initialIndex]; } @end