X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=ApplicationController.m;h=445456526329370a5b8f3f2fc9f6b66e65848003;hp=a3ad5ed24955f095252f004086bf8835f1532761;hb=794561a4606fa9e31e3b2b077891f5b1e6084698;hpb=62aa5b73be6ec1e499e6b155cd0e7687c338cbaa diff --git a/ApplicationController.m b/ApplicationController.m index a3ad5ed..4454565 100644 --- a/ApplicationController.m +++ b/ApplicationController.m @@ -44,25 +44,29 @@ - (IBAction)toggleActivity:(id)sender { BOOL sendRealEvents = !self.jsController.sendingRealEvents; self.jsController.sendingRealEvents = sendRealEvents; - activeButton.label = sendRealEvents ? @"Stop" : @"Start"; activeButton.image = [NSImage imageNamed:sendRealEvents ? @"NSStopProgressFreestandingTemplate" : @"NSGoRightTemplate"]; activeMenuItem.state = sendRealEvents; } - (NSInteger)firstConfigMenuIndex { - NSInteger count = dockMenuBase.numberOfItems; - for (int i = 0; i < count; ++i) + for (NSInteger i = dockMenuBase.numberOfItems - 1; i >= 0; --i) if ([dockMenuBase itemAtIndex:i].isSeparatorItem) return i + 1; - return count; + return dockMenuBase.numberOfItems; } - (void)configsChanged { 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]; }