X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=ApplicationController.m;h=b86a5f2067f8ebc36e09e8bdc58bd90eda2b70ff;hp=6a34916400c52691039436c05003fc94ed94357d;hb=5de694150d275d27119d344cbb1d61bc31d75268;hpb=15a3aec049658f4a1c3c6e8c9f8a549fb8de0782 diff --git a/ApplicationController.m b/ApplicationController.m index 6a34916..b86a5f2 100644 --- a/ApplicationController.m +++ b/ApplicationController.m @@ -49,8 +49,8 @@ activeMenuItem.state = sendRealEvents; } -- (NSUInteger)firstConfigMenuIndex { - NSUInteger count = dockMenuBase.numberOfItems; +- (NSInteger)firstConfigMenuIndex { + NSInteger count = dockMenuBase.numberOfItems; for (int i = 0; i < count; ++i) if ([dockMenuBase itemAtIndex:i].isSeparatorItem) return i + 1; @@ -58,16 +58,23 @@ } - (void)configsChanged { - NSUInteger removeFrom = [self firstConfigMenuIndex]; + NSInteger removeFrom = [self firstConfigMenuIndex]; while (dockMenuBase.numberOfItems > removeFrom) [dockMenuBase removeItemAtIndex:dockMenuBase.numberOfItems - 1]; - for (Config *config in self.configsController.configs) - [dockMenuBase addItemWithTitle:config.name action:@selector(chooseConfig:) keyEquivalent:@""]; + int added = 0; + for (Config *config in self.configsController.configs) { + NSString *keyEquiv = ++added < 10 ? @(added).stringValue : @""; + [dockMenuBase addItemWithTitle:config.name + action:@selector(chooseConfig:) + keyEquivalent:keyEquiv]; + + } + [_targetController refreshConfigs]; [self configChanged]; } - (void)configChanged { - NSUInteger firstConfig = [self firstConfigMenuIndex]; + NSInteger firstConfig = [self firstConfigMenuIndex]; Config *current = self.configsController.currentConfig; NSArray *configs = self.configsController.configs; for (int i = 0; i < configs.count; ++i) @@ -75,7 +82,7 @@ } - (void)chooseConfig:(id)sender { - int idx = [dockMenuBase indexOfItem:sender] - [self firstConfigMenuIndex]; + NSInteger idx = [dockMenuBase indexOfItem:sender] - [self firstConfigMenuIndex]; Config *chosen = self.configsController.configs[idx]; [_configsController activateConfig:chosen]; }