mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-25 08:13:44 +02:00
Allow empty keybinds in Cocoa menu
This commit is contained in:
parent
40ed422c3d
commit
89ebbd515a
1 changed files with 6 additions and 4 deletions
|
@ -302,6 +302,9 @@ if (!data.config.kbActionNames.value.empty()) bindingNames[@(Input::code)] = \
|
||||||
- (void) loadBinds {
|
- (void) loadBinds {
|
||||||
[nsbinds removeAllObjects];
|
[nsbinds removeAllObjects];
|
||||||
|
|
||||||
|
for (int i = 0; i < sizeof(inputMapRowToCode) / sizeof(Input::ButtonCode); i++)
|
||||||
|
nsbinds[@(inputMapRowToCode[i])] = [NSMutableArray new];
|
||||||
|
|
||||||
for (int i = 0; i < binds->size(); i++) {
|
for (int i = 0; i < binds->size(); i++) {
|
||||||
NSNumber *key = @(binds->at(i).target);
|
NSNumber *key = @(binds->at(i).target);
|
||||||
if (nsbinds[key] == nil) {
|
if (nsbinds[key] == nil) {
|
||||||
|
@ -395,7 +398,7 @@ if (!data.config.kbActionNames.value.empty()) bindingNames[@(Input::code)] = \
|
||||||
BindingIndexArray *nsbind = nsbinds[@(input)];
|
BindingIndexArray *nsbind = nsbinds[@(input)];
|
||||||
NSMutableArray<NSString*> *pnames = [NSMutableArray new];
|
NSMutableArray<NSString*> *pnames = [NSMutableArray new];
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
if (i > nsbind.count - 1) {
|
if (!nsbind.count || i > nsbind.count - 1) {
|
||||||
[pnames addObject:@"(Empty)"];
|
[pnames addObject:@"(Empty)"];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -417,15 +420,14 @@ if (!data.config.kbActionNames.value.empty()) bindingNames[@(Input::code)] = \
|
||||||
- (void)enableButtons:(bool)defaultSetting {
|
- (void)enableButtons:(bool)defaultSetting {
|
||||||
BindingIndexArray *currentBind = nsbinds[@(currentButtonCode)];
|
BindingIndexArray *currentBind = nsbinds[@(currentButtonCode)];
|
||||||
bindingButton1.enabled = defaultSetting;
|
bindingButton1.enabled = defaultSetting;
|
||||||
bindingButton2.enabled = defaultSetting;
|
bindingButton2.enabled = defaultSetting && currentBind.count > 0;
|
||||||
|
|
||||||
bindingButton3.enabled = defaultSetting && currentBind.count > 1;
|
bindingButton3.enabled = defaultSetting && currentBind.count > 1;
|
||||||
bindingButton4.enabled = defaultSetting && currentBind.count > 2;
|
bindingButton4.enabled = defaultSetting && currentBind.count > 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)binding1Clicked:(NSButton *)sender {
|
- (IBAction)binding1Clicked:(NSButton *)sender {
|
||||||
// Need at least one binding, for now
|
if (nsbinds[@(currentButtonCode)].count > 0) {
|
||||||
if (nsbinds[@(currentButtonCode)].count > 1) {
|
|
||||||
[self removeBinding:0 forInput:currentButtonCode];
|
[self removeBinding:0 forInput:currentButtonCode];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue