46@interface PlayerEntity (KeyMapperInternal)
49- (void)updateKeyDefinition:(NSString *)keystring index:(NSUInteger)index;
50- (void)updateShiftKeyDefinition:(NSString *)key index:(NSUInteger)index;
51- (void)displayKeyFunctionList:(
GuiDisplayGen *)gui skip:(NSUInteger)skip;
52- (NSString *)keyboardDescription:(NSString *)kbd;
53- (void)displayKeyboardLayoutList:(
GuiDisplayGen *)gui skip:(NSUInteger)skip;
54- (BOOL)entryIsIndexCustomEquip:(NSUInteger)idx;
55- (BOOL)entryIsDictCustomEquip:(NSDictionary *)dict;
56- (BOOL)entryIsCustomEquip:(NSString *)entry;
57- (NSArray *)getCustomEquipArray:(NSString *)key_def;
58- (NSString *)getCustomEquipKeyDefType:(NSString *)key_def;
61- (NSString *)searchArrayForMatch:(NSArray *)search_list key:(NSString *)key checkKeys:(NSArray *)check_keys;
62- (NSUInteger)getCustomEquipIndex:(NSString *)key_def;
63- (BOOL)entryIsEqualToDefault:(NSString *)key;
64- (BOOL)compareKeyEntries:(NSDictionary *)first second:(NSDictionary *)second;
65- (void)saveKeySetting:(NSString *)key;
66- (void)unsetKeySetting:(NSString *)key;
67- (void)deleteKeySetting:(NSString *)key;
74@implementation PlayerEntity (KeyMapper)
77- (void) initCheckingDictionary
80 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
81 NSString *kbd = [defaults oo_stringForKey:@"keyboard-code" defaultValue:@"default"];
82 NSMutableDictionary *kdic = [NSMutableDictionary dictionaryWithDictionary:[kdicmaster objectForKey:kbd]];
87 NSArray *def_list =
nil;
89 keys = [kdic allKeys];
90 for (i = 0; i < [keys count]; i++)
92 key = [keys objectAtIndex:i];
94 if ([[kdic objectForKey: key] isKindOfClass:[NSArray
class]])
96 def_list = (NSArray*)[kdic objectForKey: key];
100 [kdic_check release];
101 kdic_check = [[NSDictionary alloc] initWithDictionary:kdic];
105 nav_keys = [[NSArray alloc] initWithObjects:@"key_roll_left", @"key_roll_right", @"key_pitch_forward", @"key_pitch_back", @"key_yaw_left", @"key_yaw_right",
106 @"key_fire_lasers", @"key_gui_arrow_up", @"key_gui_arrow_down", @"key_gui_arrow_right", @"key_gui_arrow_left", nil];
108 [camera_keys release];
109 camera_keys = [[NSArray alloc] initWithObjects:@"key_custom_view_zoom_out", @"key_custom_view_zoom_in", @"key_custom_view_roll_left", @"key_custom_view_roll_right",
110 @"key_custom_view_pan_left", @"key_custom_view_pan_right", @"key_custom_view_rotate_up", @"key_custom_view_rotate_down", @"key_custom_view_pan_down",
111 @"key_custom_view_pan_up", @"key_custom_view_rotate_left", @"key_custom_view_rotate_right", nil];
115- (void) resetKeyFunctions
117 [keyFunctions release];
122- (void) setGuiToKeyMapperScreen:(
unsigned)skip
124 [
self setGuiToKeyMapperScreen:skip resetCurrentRow:NO];
127- (void) setGuiToKeyMapperScreen:(
unsigned)skip resetCurrentRow:(BOOL)resetCurrentRow
129 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
130 NSString *kbd = [defaults oo_stringForKey:@"keyboard-code" defaultValue:@"default"];
141 if (!
kdic_check) [
self initCheckingDictionary];
143 gui_screen = GUI_SCREEN_KEYBOARD;
144 BOOL guiChanged = (oldScreen != gui_screen);
145 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
148 [gui
setTitle:[NSString stringWithFormat:@"Configure Keyboard"]];
151 [gui
setArray:[NSArray arrayWithObjects:DESC(@"oolite-keyconfig-keyboard"), [
self keyboardDescription:kbd], nil]
forRow:GUI_ROW_KC_SELECTKBD];
152 [gui
setKey:[NSString stringWithFormat:@"kbd:%@", kbd]
forRow:GUI_ROW_KC_SELECTKBD];
155 [
self displayKeyFunctionList:gui skip:skip];
158 if ([[
self validateAllKeys]
count] > 0)
161 [gui
setText:DESC(@"oolite-keyconfig-validation-error")
forRow:GUI_ROW_KC_ERROR
align:GUI_ALIGN_CENTER];
165 [gui
setArray:[NSArray arrayWithObject:DESC(@"oolite-keyconfig-initial-info-1")]
forRow:GUI_ROW_KC_INSTRUCT];
166 [gui
setText:DESC(@"oolite-keyconfig-initial-info-2")
forRow:GUI_ROW_KC_INSTRUCT+1
align:GUI_ALIGN_CENTER];
169 [gui
setText:DESC(@"oolite-keyconfig-initial-error")
forRow:GUI_ROW_KC_INSTRUCT+2
align:GUI_ALIGN_CENTER];
173 [gui
setText:DESC(@"oolite-keyconfig-initial-info-3")
forRow:GUI_ROW_KC_INSTRUCT+2
align:GUI_ALIGN_CENTER];
192 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
194 if (guiChanged) [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
200 [
self handleGUIUpDownArrowKeys];
201 BOOL selectKeyPress = ([
self checkKeyPress:n_key_gui_select] || [gameView
isDown:gvMouseDoubleClick]);
205 if ([key hasPrefix:
@"Index:"])
206 selFunctionIdx=[[[key componentsSeparatedByString:@":"] objectAtIndex:1] intValue];
212 if ([key hasPrefix:
@"More:"])
214 int from_function = [[[key componentsSeparatedByString:@":"] objectAtIndex:1] intValue];
215 if (from_function < 0) from_function = 0;
219 [
self setGuiToKeyMapperScreen:from_function];
223 if ([key hasPrefix:
@"kbd:"])
225 [
self setGuiToKeyboardLayoutScreen:0];
234 key_list = [[NSMutableArray alloc] initWithArray:(NSArray *)[keyconfig2_settings objectForKey:[selected_entry objectForKey:KEY_KC_DEFINITION]] copyItems:YES];
238 key_list = [[NSMutableArray alloc] initWithArray:[
self getCustomEquipArray:[selected_entry oo_stringForKey:KEY_KC_DEFINITION]]];
241 [
self setGuiToKeyConfigScreen:YES];
244 if ([gameView isDown:
'u'])
247 if ([key hasPrefix:
@"More:"])
return;
250 [
self unsetKeySetting:[[keyFunctions objectAtIndex:selFunctionIdx] objectForKey:KEY_KC_DEFINITION]];
254 if ([gameView isDown:
'r'])
257 if (![gameView isCtrlDown])
260 if ([key hasPrefix:
@"More:"])
return;
264 NSString *delkey = [[keyFunctions objectAtIndex:selFunctionIdx] objectForKey:KEY_KC_DEFINITION];
265 [
self deleteKeySetting:delkey];
267 if ([
self entryIsCustomEquip:delkey])
269 int idx = [
self getCustomEquipIndex:delkey];
271 NSString *lookupKey =
nil;
274 if ([delkey hasPrefix:
@"activate_"])
276 eq = [delkey stringByReplacingOccurrencesOfString:@"activate_" withString:@""];
279 if ([delkey hasPrefix:
@"mode_"])
281 eq = [delkey stringByReplacingOccurrencesOfString:@"mode_" withString:@""];
289 [[customEquipActivation objectAtIndex:idx] setObject:[item
defaultActivateKey] forKey:lookupKey];
294 [[customEquipActivation objectAtIndex:idx] setObject:[item
defaultModeKey] forKey:lookupKey];
300 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
301 [defaults setObject:customEquipActivation forKey:KEYCONFIG_CUSTOMEQUIP];
309 [
self setGuiToConfirmClearScreen];
312 if ([gameView isDown:
' '] && !
has_error) [
self setGuiToGameOptionsScreen];
316- (BOOL) entryIsIndexCustomEquip:(NSUInteger)idx
318 return [
self entryIsCustomEquip:[[keyFunctions objectAtIndex:idx] oo_stringForKey:KEY_KC_DEFINITION]];
322- (BOOL) entryIsDictCustomEquip:(NSDictionary *)dict
324 return [
self entryIsCustomEquip:[dict oo_stringForKey:KEY_KC_DEFINITION]];
327- (BOOL) entryIsCustomEquip:(NSString *)entry
330 if ([entry hasPrefix:
@"activate_"] || [entry hasPrefix:
@"mode_"])
335- (NSArray *) getCustomEquipArray:(NSString *)key_def
340 if ([key_def hasPrefix:
@"activate_"])
342 eq = [key_def stringByReplacingOccurrencesOfString:@"activate_" withString:@""];
345 if ([key_def hasPrefix:
@"mode_"])
347 eq = [key_def stringByReplacingOccurrencesOfString:@"mode_" withString:@""];
350 if (eq ==
nil)
return nil;
351 for (i = 0; i < [customEquipActivation count]; i++)
353 if ([[[customEquipActivation objectAtIndex:i] oo_stringForKey:
CUSTOMEQUIP_EQUIPKEY] isEqualToString:eq])
355 return [[customEquipActivation objectAtIndex:i] oo_arrayForKey:key];
362- (NSUInteger) getCustomEquipIndex:(NSString *)key_def
366 if ([key_def hasPrefix:
@"activate_"])
368 eq = [key_def stringByReplacingOccurrencesOfString:@"activate_" withString:@""];
370 if ([key_def hasPrefix:
@"mode_"])
372 eq = [key_def stringByReplacingOccurrencesOfString:@"mode_" withString:@""];
374 if (eq ==
nil)
return -1;
375 for (i = 0; i < [customEquipActivation count]; i++)
377 if ([[[customEquipActivation objectAtIndex:i] oo_stringForKey:
CUSTOMEQUIP_EQUIPKEY] isEqualToString:eq])
386- (NSString *) getCustomEquipKeyDefType:(NSString *)key_def
388 if ([key_def hasPrefix:
@"activate_"])
392 if ([key_def hasPrefix:
@"mode_"])
400- (void) setGuiToKeyConfigScreen
402 [
self setGuiToKeyConfigScreen:NO];
406- (void) setGuiToKeyConfigScreen:(BOOL)resetSelectedRow
416 gui_screen = GUI_SCREEN_KEYBOARD_CONFIG;
417 BOOL guiChanged = (oldScreen != gui_screen);
419 [gui
setTitle:[NSString stringWithFormat:@"%@", DESC(@"oolite-keyconfig-update-title")]];
421 [gui
setArray: [NSArray arrayWithObjects:
422 DESC(@"oolite-keyconfig-update-function"), [selected_entry objectForKey: KEY_KC_GUIDESC], nil]
423 forRow: GUI_ROW_KC_UPDATE_FUNCNAME];
426 NSString *keystring =
nil;
427 NSString *keyshift =
nil;
428 NSString *keymod1 =
nil;
429 NSString *keymod2 =
nil;
431 NSDictionary *def =
nil;
436 for (i = 0; i <= 1; i++)
438 keystring =
DESC(
@"oolite-keycode-unset");
439 keyshift =
DESC(
@"oolite-keyconfig-modkey-off");
440 keymod1 =
DESC(
@"oolite-keyconfig-modkey-off");
441 keymod2 =
DESC(
@"oolite-keyconfig-modkey-off");
445 def = [key_list objectAtIndex:i];
446 key = [def objectForKey:@"key"];
450 keystring = [
self keyCodeDescription:k_int];
451 if ([[def objectForKey:
@"shift"] boolValue] == YES) keyshift =
DESC(
@"oolite-keyconfig-modkey-on");
452 if ([[def objectForKey:
@"mod1"] boolValue] == YES) keymod1 =
DESC(
@"oolite-keyconfig-modkey-on");
453 if ([[def objectForKey:
@"mod2"] boolValue] == YES) keymod2 =
DESC(
@"oolite-keyconfig-modkey-on");
457 [
self outputKeyDefinition:keystring shift:keyshift mod1:keymod1 mod2:keymod2 skiprows:(i * 5)];
460 NSString *helper =
DESC(
@"oolite-keyconfig-update-helper");
462 helper = [NSString stringWithFormat:@"%@ %@", helper, DESC(@"oolite-keyconfig-update-navkeys")];
464 helper = [NSString stringWithFormat:@"%@ %@", helper, DESC(@"oolite-keyconfig-update-camkeys")];
469 [gui
setText:DESC(@"oolite-keyconfig-update-save")
forRow:GUI_ROW_KC_SAVE
align:GUI_ALIGN_CENTER];
472 [gui
setText:DESC(@"oolite-keyconfig-update-cancel")
forRow:GUI_ROW_KC_CANCEL
align:GUI_ALIGN_CENTER];
475 [gui
setSelectableRange: NSMakeRange(GUI_ROW_KC_KEY, (GUI_ROW_KC_CANCEL - GUI_ROW_KC_KEY) + 1)];
477 NSString *validate = [
self validateKey:[selected_entry objectForKey:KEY_KC_DEFINITION] checkKeys:key_list];
480 for (i = 0; i < [keyFunctions count]; i++)
482 if ([[[keyFunctions objectAtIndex:i] objectForKey:
KEY_KC_DEFINITION] isEqualToString:validate])
484 [gui
setText:[NSString stringWithFormat:DESC(@"oolite-keyconfig-update-validation-@"), (NSString *)[[keyFunctions objectAtIndex:i] objectForKey:KEY_KC_GUIDESC]]
485 forRow:GUI_ROW_KC_VALIDATION
align:GUI_ALIGN_CENTER];
492 if (resetSelectedRow)
499 [[UNIVERSE gameView] clearMouse];
500 [[UNIVERSE gameView] clearKeys];
501 if (guiChanged) [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
505- (void) outputKeyDefinition:(NSString *)key shift:(NSString *)shift mod1:(NSString *)mod1 mod2:(NSString *)mod2 skiprows:(NSUInteger)skiprows
509 [gui
setArray:[NSArray arrayWithObjects:
510 (skiprows == 0 ? DESC(@"oolite-keyconfig-update-key") : DESC(@"oolite-keyconfig-update-alternate")), key, nil]
511 forRow:GUI_ROW_KC_KEY + skiprows];
512 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW_KC_KEY + skiprows];
515 if (![key isEqualToString:
DESC(
@"oolite-keycode-unset")])
517 [gui
setArray:[NSArray arrayWithObjects:
518 DESC(@"oolite-keyconfig-update-shift"), shift, nil]
519 forRow:GUI_ROW_KC_SHIFT + skiprows];
520 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW_KC_SHIFT + skiprows];
524 [gui
setArray:[NSArray arrayWithObjects:
525 DESC(@"oolite-keyconfig-update-mod1"), mod1, nil]
526 forRow:GUI_ROW_KC_MOD1 + skiprows];
527 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW_KC_MOD1 + skiprows];
531 [gui
setArray:[NSArray arrayWithObjects:
532 DESC(@"oolite-keyconfig-update-mod1"), DESC(@"not-applicable"), nil]
533 forRow:GUI_ROW_KC_MOD1 + skiprows];
537 [gui
setArray:[NSArray arrayWithObjects:
538 DESC(@"oolite-keyconfig-update-mod2-mac"), mod2, nil]
539 forRow:GUI_ROW_KC_MOD2 + skiprows];
541 [gui
setArray:[NSArray arrayWithObjects:
542 DESC(@"oolite-keyconfig-update-mod2-pc"), mod2, nil]
543 forRow: GUI_ROW_KC_MOD2 + skiprows];
545 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW_KC_MOD2 + skiprows];
553 [
self handleGUIUpDownArrowKeys];
554 BOOL selectKeyPress = ([
self checkKeyPress:n_key_gui_select]||[gameView
isDown:gvMouseDoubleClick]);
560 [
self setGuiToKeyConfigEntryScreen];
565 [
self updateShiftKeyDefinition:@"shift" index:([gui
selectedRow] == GUI_ROW_KC_SHIFT ? 0 : 1)];
566 [
self setGuiToKeyConfigScreen];
570 [
self updateShiftKeyDefinition:@"mod1" index:([gui
selectedRow] == GUI_ROW_KC_MOD1 ? 0 : 1)];
571 [
self setGuiToKeyConfigScreen];
575 [
self updateShiftKeyDefinition:@"mod2" index:([gui
selectedRow] == GUI_ROW_KC_MOD2 ? 0 : 1)];
576 [
self setGuiToKeyConfigScreen];
581 [
self saveKeySetting:[selected_entry objectForKey: KEY_KC_DEFINITION]];
585 if ((selectKeyPress && [gui selectedRow] ==
GUI_ROW_KC_CANCEL) || [gameView isDown:27])
593- (void) setGuiToKeyConfigEntryScreen
598 gui_screen = GUI_SCREEN_KEYBOARD_ENTRY;
599 BOOL guiChanged = (oldScreen != gui_screen);
605 NSMutableDictionary *key1 = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"", @"key", [NSNumber numberWithBool:NO], @"shift", [NSNumber numberWithBool:NO], @"mod1", [NSNumber numberWithBool:NO], @"mod2", nil];
606 [key_list addObject:key1];
609 NSDictionary *def = [key_list objectAtIndex:key_index];
610 NSString *key = [def objectForKey:@"key"];
614 [gameView
setTypedString:(k_int != 0 ? [
self keyCodeDescriptionShort:k_int] : @"")];
618 [gui
setTitle:[NSString stringWithFormat:@"%@", DESC(@"oolite-keyconfig-update-entry-title")]];
620 NSUInteger end_row = 21;
621 if ([[
self hud] allowBigGui])
637 [UNIVERSE enterGUIViewModeWithMouseInteraction:NO];
641 if (guiChanged) [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
647 NSUInteger end_row = 21;
648 if ([[
self hud] allowBigGui])
653 [
self handleGUIUpDownArrowKeys];
654 if ([gameView lastKeyWasShifted])
last_shift = YES;
657 [NSString stringWithFormat:DESC(@"Key: %@"), [gameView
typedString]]
661 if ([
self checkKeyPress:n_key_gui_select])
665 [
self updateKeyDefinition:[gameView
typedString] index:key_index];
667 [
self setGuiToKeyConfigScreen:YES];
669 if ([gameView isDown:27])
673 [
self setGuiToKeyConfigScreen:YES];
678- (void) updateKeyDefinition:(NSString *)keystring index:(NSUInteger)index
680 NSMutableDictionary *key_def = [[NSMutableDictionary alloc] initWithDictionary:(NSDictionary *)[key_list objectAtIndex:index] copyItems:YES];
681 [key_def setObject:keystring forKey:@"key"];
686 [key_def setObject:[NSNumber numberWithBool:YES] forKey:@"shift"];
690 [key_def setObject:[NSNumber numberWithBool:NO] forKey:@"shift"];
695 [key_list insertObject:key_def atIndex:index];
699 [key_list replaceObjectAtIndex:index withObject:key_def];
702 NSArray *new_array = [
self processKeyCode:key_list];
704 key_list = [[NSMutableArray alloc] initWithArray:new_array copyItems:YES];
710- (void) updateShiftKeyDefinition:(NSString *)key index:(NSUInteger)index
712 NSMutableDictionary *key_def = [[NSMutableDictionary alloc] initWithDictionary:(NSDictionary *)[key_list objectAtIndex:index] copyItems:YES];
713 BOOL current = [[key_def objectForKey:key] boolValue];
714 BOOL keycode_changed = NO;
716 [key_def setObject:[NSNumber numberWithBool:current] forKey:key];
717 if ([key isEqualToString:
@"shift"])
720 NSString* keycode = [key_def objectForKey:@"key"];
721 NSInteger k_int = (
OOKeyCode)[keycode integerValue];
724 NSString* keystring = [
self keyCodeDescription:k_int];
726 if ([keystring length] == 1)
731 newstring = [keystring uppercaseString];
735 newstring = [keystring lowercaseString];
737 if (![newstring isEqualToString:keystring])
739 [key_def setObject:newstring forKey:@"key"];
740 keycode_changed = YES;
747 [key_list insertObject:key_def atIndex:index];
751 [key_list replaceObjectAtIndex:index withObject:key_def];
756 NSArray *new_array = [
self processKeyCode:key_list];
758 key_list = [[NSMutableArray alloc] initWithArray:new_array copyItems:YES];
764- (void) setGuiToConfirmClearScreen
769 gui_screen = GUI_SCREEN_KEYBOARD_CONFIRMCLEAR;
770 BOOL guiChanged = (oldScreen != gui_screen);
773 [gui
setTitle:[NSString stringWithFormat:@"%@", DESC(@"oolite-keyconfig-clear-overrides-title")]];
775 [gui
addLongText:[NSString stringWithFormat:@"%@", DESC(@"oolite-keyconfig-clear-overrides")]
778 [gui
setText:DESC(@"oolite-keyconfig-clear-yes")
forRow: GUI_ROW_KC_CONFIRMCLEAR_YES
align:GUI_ALIGN_CENTER];
779 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW_KC_CONFIRMCLEAR_YES];
781 [gui
setText:DESC(@"oolite-keyconfig-clear-no")
forRow:GUI_ROW_KC_CONFIRMCLEAR_NO
align:GUI_ALIGN_CENTER];
782 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW_KC_CONFIRMCLEAR_NO];
790 [[UNIVERSE gameView] clearMouse];
791 [[UNIVERSE gameView] clearKeys];
792 if (guiChanged) [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
798 [
self handleGUIUpDownArrowKeys];
800 BOOL selectKeyPress = ([
self checkKeyPress:n_key_gui_select]||[gameView
isDown:gvMouseDoubleClick]);
804 id valueYes = [[[UNIVERSE descriptions] oo_stringForKey:@"load-previous-commander-yes" defaultValue:@"y"] lowercaseString];
805 id valueNo = [[[UNIVERSE descriptions] oo_stringForKey:@"load-previous-commander-no" defaultValue:@"n"] lowercaseString];
806 unsigned char cYes, cNo;
808 cYes = [valueYes characterAtIndex: 0] & 0x00ff;
809 cNo = [valueNo characterAtIndex: 0] & 0x00ff;
813 [
self deleteAllKeySettings];
815 [
self setGuiToKeyMapperScreen:0 resetCurrentRow:YES];
818 if ((selectKeyPress && ([gui selectedRow] ==
GUI_ROW_KC_CONFIRMCLEAR_NO))||[gameView isDown:27]||[gameView isDown:cNo]||[gameView isDown:cNo - 32])
822 [
self setGuiToKeyMapperScreen:0 resetCurrentRow:YES];
827- (void) displayKeyFunctionList:(
GuiDisplayGen *)gui skip:(NSUInteger)skip
830 [gui
setArray:[NSArray arrayWithObjects:
831 @"Function", @"Assigned to", @"Overrides", nil]
832 forRow:GUI_ROW_KC_HEADING];
834 NSDictionary *overrides = [
self loadKeySettings];
838 keyFunctions = [[
self keyFunctionList] retain];
841 NSUInteger i, n_functions = [keyFunctions count];
842 NSInteger n_rows, start_row, previous = 0;
843 NSString *validate =
nil;
845 if (skip >= n_functions)
846 skip = n_functions - 1;
875 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @" <-- ", nil]
forRow:GUI_ROW_KC_FUNCSTART];
876 [gui
setKey:[NSString stringWithFormat:@"More:%ld", previous]
forRow:GUI_ROW_KC_FUNCSTART];
879 for(i = 0; i < (n_functions - skip) && (
int)i < n_rows; i++)
881 NSDictionary *entry = [keyFunctions objectAtIndex:i + skip];
883 NSString *header = [entry objectForKey:KEY_KC_HEADER];
884 [gui
setArray:[NSArray arrayWithObjects:header, @"", @"", nil]
forRow:i + start_row];
889 NSString *assignment =
nil;
890 NSString *
override =
nil;
891 if (![
self entryIsDictCustomEquip:entry])
894 assignment = [PLAYER keyBindingDescription2:[entry objectForKey:KEY_KC_DEFINITION]];
895 override = ([overrides objectForKey:[entry objectForKey:KEY_KC_DEFINITION]] ?
@"Yes" :
@"");
896 validate = [
self validateKey:[entry objectForKey:KEY_KC_DEFINITION] checkKeys:(NSArray *)[keyconfig2_settings objectForKey:[entry objectForKey:KEY_KC_DEFINITION]]];
900 NSString *custom_keytype = [
self getCustomEquipKeyDefType:[entry oo_stringForKey:KEY_KC_DEFINITION]];
901 NSUInteger idx = [
self getCustomEquipIndex:[entry oo_stringForKey:KEY_KC_DEFINITION]];
902 assignment = [PLAYER getKeyBindingDescription:[[customEquipActivation objectAtIndex:idx] oo_arrayForKey:custom_keytype]];
906 NSArray *defArray =
nil;
907 NSArray *compArray =
nil;
912 compArray = [[customEquipActivation objectAtIndex:idx] oo_arrayForKey:custom_keytype];
917 compArray = [[customEquipActivation objectAtIndex:idx] oo_arrayForKey:custom_keytype];
919 for (j = 0; j < [defArray count]; j++)
921 for (k = 0; k < [compArray count]; k++)
923 if (![
self compareKeyEntries:[defArray objectAtIndex:j] second:[compArray objectAtIndex:k]])
929 if (result ==
false)
break;
932 override = (!result ?
@"Yes" :
@"");
933 validate = [
self validateKey:[entry objectForKey:KEY_KC_DEFINITION] checkKeys:(NSArray *)[[customEquipActivation objectAtIndex:idx] oo_arrayForKey:custom_keytype]];
935 if (assignment ==
nil)
940 [gui
setArray:[NSArray arrayWithObjects:
941 [entry objectForKey:KEY_KC_GUIDESC], assignment, override, nil]
943 [gui
setKey:[NSString stringWithFormat:@"Index:%ld", i + skip]
forRow:i + start_row];
950 if (i < n_functions - skip)
953 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-more"), @" --> ", nil]
forRow:start_row + i];
954 [gui
setKey:[NSString stringWithFormat:@"More:%ld", n_rows + skip]
forRow:start_row + i];
958 [gui
setSelectableRange:NSMakeRange(GUI_ROW_KC_SELECTKBD, (i + start_row - GUI_ROW_KC_FUNCSTART) + (GUI_ROW_KC_FUNCSTART - GUI_ROW_KC_SELECTKBD))];
963- (NSArray *)keyFunctionList
965 NSMutableArray *funcList = [NSMutableArray array];
967 [funcList addObject:[
self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-screen-access")]];
968 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_launch_ship") keyDef:@"key_launch_ship"]];
969 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_screen_options") keyDef:@"key_gui_screen_options"]];
970 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_screen_equipship") keyDef:@"key_gui_screen_equipship"]];
971 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_screen_interfaces") keyDef:@"key_gui_screen_interfaces"]];
972 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_screen_status") keyDef:@"key_gui_screen_status"]];
973 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_chart_screens") keyDef:@"key_gui_chart_screens"]];
974 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_system_data") keyDef:@"key_gui_system_data"]];
975 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_market") keyDef:@"key_gui_market"]];
977 [funcList addObject:[
self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-propulsion")]];
978 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_roll_left") keyDef:@"key_roll_left"]];
979 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_roll_right") keyDef:@"key_roll_right"]];
980 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_pitch_forward") keyDef:@"key_pitch_forward"]];
981 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_pitch_back") keyDef:@"key_pitch_back"]];
982 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_yaw_left") keyDef:@"key_yaw_left"]];
983 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_yaw_right") keyDef:@"key_yaw_right"]];
985 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_increase_speed") keyDef:@"key_increase_speed"]];
986 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_decrease_speed") keyDef:@"key_decrease_speed"]];
987 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_inject_fuel") keyDef:@"key_inject_fuel"]];
988 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_jumpdrive") keyDef:@"key_jumpdrive"]];
989 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_hyperspace") keyDef:@"key_hyperspace"]];
990 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_galactic_hyperspace") keyDef:@"key_galactic_hyperspace"]];
992 [funcList addObject:[
self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-navigation")]];
993 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_next_compass_mode") keyDef:@"key_next_compass_mode"]];
994 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_prev_compass_mode") keyDef:@"key_prev_compass_mode"]];
995 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_scanner_zoom") keyDef:@"key_scanner_zoom"]];
996 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_scanner_unzoom") keyDef:@"key_scanner_unzoom"]];
997 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_view_forward") keyDef:@"key_view_forward"]];
998 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_view_aft") keyDef:@"key_view_aft"]];
999 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_view_port") keyDef:@"key_view_port"]];
1000 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_view_starboard") keyDef:@"key_view_starboard"]];
1001 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_ident_system") keyDef:@"key_ident_system"]];
1003 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_docking_clearance_request") keyDef:@"key_docking_clearance_request"]];
1004 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_autopilot") keyDef:@"key_autopilot"]];
1005 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_autodock") keyDef:@"key_autodock"]];
1006 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_docking_music") keyDef:@"key_docking_music"]];
1008 [funcList addObject:[
self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-offensive")]];
1009 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_weapons_online_toggle") keyDef:@"key_weapons_online_toggle"]];
1010 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_fire_lasers") keyDef:@"key_fire_lasers"]];
1011 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_launch_missile") keyDef:@"key_launch_missile"]];
1012 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_target_missile") keyDef:@"key_target_missile"]];
1013 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_untarget_missile") keyDef:@"key_untarget_missile"]];
1014 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_target_incoming_missile") keyDef:@"key_target_incoming_missile"]];
1015 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_next_missile") keyDef:@"key_next_missile"]];
1016 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_next_target") keyDef:@"key_next_target"]];
1017 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_previous_target") keyDef:@"key_previous_target"]];
1019 [funcList addObject:[
self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-defensive")]];
1020 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_ecm") keyDef:@"key_ecm"]];
1021 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_dump_cargo") keyDef:@"key_dump_cargo"]];
1022 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_rotate_cargo") keyDef:@"key_rotate_cargo"]];
1023 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_launch_escapepod") keyDef:@"key_launch_escapepod"]];
1025 [funcList addObject:[
self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-special-equip")]];
1026 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_cycle_next_mfd") keyDef:@"key_cycle_next_mfd"]];
1027 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_cycle_previous_mfd") keyDef:@"key_cycle_previous_mfd"]];
1028 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_switch_next_mfd") keyDef:@"key_switch_next_mfd"]];
1029 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_switch_previous_mfd") keyDef:@"key_switch_previous_mfd"]];
1031 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_prime_next_equipment") keyDef:@"key_prime_next_equipment"]];
1032 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_prime_previous_equipment") keyDef:@"key_prime_previous_equipment"]];
1033 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_activate_equipment") keyDef:@"key_activate_equipment"]];
1034 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_mode_equipment") keyDef:@"key_mode_equipment"]];
1035 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_fastactivate_equipment_a") keyDef:@"key_fastactivate_equipment_a"]];
1036 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_fastactivate_equipment_b") keyDef:@"key_fastactivate_equipment_b"]];
1038 [funcList addObject:[
self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-chart-screen")]];
1039 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_advanced_nav_array_next") keyDef:@"key_advanced_nav_array_next"]];
1040 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_advanced_nav_array_previous") keyDef:@"key_advanced_nav_array_previous"]];
1041 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_map_home") keyDef:@"key_map_home"]];
1042 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_map_end") keyDef:@"key_map_end"]];
1043 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_map_info") keyDef:@"key_map_info"]];
1044 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_map_zoom_in") keyDef:@"key_map_zoom_in"]];
1045 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_map_zoom_out") keyDef:@"key_map_zoom_out"]];
1046 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_map_next_system") keyDef:@"key_map_next_system"]];
1047 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_map_previous_system") keyDef:@"key_map_previous_system"]];
1048 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_chart_highlight") keyDef:@"key_chart_highlight"]];
1050 [funcList addObject:[
self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-planet-info-screen")]];
1051 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_system_home") keyDef:@"key_system_home"]];
1052 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_system_end") keyDef:@"key_system_end"]];
1053 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_system_next_system") keyDef:@"key_system_next_system"]];
1054 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_system_previous_system") keyDef:@"key_system_previous_system"]];
1056 [funcList addObject:[
self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-market-screen")]];
1057 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_market_filter_cycle") keyDef:@"key_market_filter_cycle"]];
1058 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_market_sorter_cycle") keyDef:@"key_market_sorter_cycle"]];
1059 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_market_buy_one") keyDef:@"key_market_buy_one"]];
1060 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_market_sell_one") keyDef:@"key_market_sell_one"]];
1061 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_market_buy_max") keyDef:@"key_market_buy_max"]];
1062 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_market_sell_max") keyDef:@"key_market_sell_max"]];
1064 [funcList addObject:[
self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-misc")]];
1065 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_snapshot") keyDef:@"key_snapshot"]];
1066 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_pausebutton") keyDef:@"key_pausebutton"]];
1067 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_show_fps") keyDef:@"key_show_fps"]];
1069 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_mouse_control_roll") keyDef:@"key_mouse_control_roll"]];
1070 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_mouse_control_yaw") keyDef:@"key_mouse_control_yaw"]];
1071 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_hud_toggle") keyDef:@"key_hud_toggle"]];
1072#if OO_FOV_INFLIGHT_CONTROL_ENABLED
1073 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_inc_field_of_view") keyDef:@"key_inc_field_of_view"]];
1074 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_dec_field_of_view") keyDef:@"key_dec_field_of_view"]];
1076 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_comms_log") keyDef:@"key_comms_log"]];
1078 [funcList addObject:[
self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-custom-view")]];
1079 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view") keyDef:@"key_custom_view"]];
1080 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_zoom_in") keyDef:@"key_custom_view_zoom_in"]];
1081 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_zoom_out") keyDef:@"key_custom_view_zoom_out"]];
1082 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_roll_left") keyDef:@"key_custom_view_roll_left"]];
1083 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_roll_right") keyDef:@"key_custom_view_roll_right"]];
1084 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_pan_left") keyDef:@"key_custom_view_pan_left"]];
1085 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_pan_right") keyDef:@"key_custom_view_pan_right"]];
1086 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_pan_up") keyDef:@"key_custom_view_pan_up"]];
1087 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_pan_down") keyDef:@"key_custom_view_pan_down"]];
1088 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_rotate_left") keyDef:@"key_custom_view_rotate_left"]];
1089 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_rotate_right") keyDef:@"key_custom_view_rotate_right"]];
1090 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_rotate_up") keyDef:@"key_custom_view_rotate_up"]];
1091 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_rotate_down") keyDef:@"key_custom_view_rotate_down"]];
1093 [funcList addObject:[
self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-oxz-manager")]];
1094 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_oxzmanager_setfilter") keyDef:@"key_oxzmanager_setfilter"]];
1095 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_oxzmanager_showinfo") keyDef:@"key_oxzmanager_showinfo"]];
1096 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_oxzmanager_extract") keyDef:@"key_oxzmanager_extract"]];
1098 [funcList addObject:[
self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-gui")]];
1099 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_arrow_left") keyDef:@"key_gui_arrow_left"]];
1100 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_arrow_right") keyDef:@"key_gui_arrow_right"]];
1101 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_arrow_up") keyDef:@"key_gui_arrow_up"]];
1102 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_arrow_down") keyDef:@"key_gui_arrow_down"]];
1103 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_page_down") keyDef:@"key_gui_page_down"]];
1104 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_page_up") keyDef:@"key_gui_page_up"]];
1105 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_select") keyDef:@"key_gui_select"]];
1107 [funcList addObject:[
self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-debug")]];
1108 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_dump_target_state") keyDef:@"key_dump_target_state"]];
1109 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_dump_entity_list") keyDef:@"key_dump_entity_list"]];
1110 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_debug_full") keyDef:@"key_debug_full"]];
1111 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_debug_collision") keyDef:@"key_debug_collision"]];
1112 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_debug_console_connect") keyDef:@"key_debug_console_connect"]];
1113 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_debug_bounding_boxes") keyDef:@"key_debug_bounding_boxes"]];
1114 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_debug_shaders") keyDef:@"key_debug_shaders"]];
1115 [funcList addObject:[
self makeKeyGuiDict:DESC(@"oolite-keydesc-key_debug_off") keyDef:@"key_debug_off"]];
1117 if ([customEquipActivation
count] > 0)
1119 [funcList addObject:[
self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-oxp-equip")]];
1121 for (i = 0; i < [customEquipActivation count]; i++)
1123 [funcList addObject:[
self makeKeyGuiDict:[NSString stringWithFormat: @"Activate '%@'", [[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPNAME]]
1124 keyDef:[NSString stringWithFormat:@"activate_%@", [[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPKEY]]]];
1125 [funcList addObject:[
self makeKeyGuiDict:[NSString stringWithFormat: @"Mode '%@'", [[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPNAME]]
1126 keyDef:[NSString stringWithFormat:@"mode_%@", [[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPKEY]]]];
1133- (NSDictionary *)makeKeyGuiDict:(NSString *)what keyDef:(NSString*)key_def
1135 NSMutableDictionary *guiDict = [NSMutableDictionary dictionary];
1136 if ([what length] > 50) what = [[what substringToIndex:48] stringByAppendingString:@"..."];
1137 [guiDict setObject:what forKey:KEY_KC_GUIDESC];
1138 [guiDict setObject:key_def forKey:KEY_KC_DEFINITION];
1143- (NSDictionary *)makeKeyGuiDictHeader:(NSString *)header
1145 NSMutableDictionary *guiDict = [NSMutableDictionary dictionary];
1146 [guiDict setObject:header forKey:KEY_KC_HEADER];
1147 [guiDict setObject:@"" forKey:KEY_KC_GUIDESC];
1148 [guiDict setObject:@"" forKey:KEY_KC_DEFINITION];
1153- (void) setGuiToKeyboardLayoutScreen:(
unsigned)skip
1155 [
self setGuiToKeyboardLayoutScreen:skip resetCurrentRow:NO];
1159- (void) setGuiToKeyboardLayoutScreen:(
unsigned)skip resetCurrentRow:(BOOL)resetCurrentRow
1169 gui_screen = GUI_SCREEN_KEYBOARD_LAYOUT;
1170 BOOL guiChanged = (oldScreen != gui_screen);
1172 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
1175 [gui
setTitle:[NSString stringWithFormat:@"Select Keyboard Layout"]];
1177 [
self displayKeyboardLayoutList:gui skip:skip];
1179 [gui
setArray:[NSArray arrayWithObject:DESC(@"oolite-keyconfig-keyboard-info")]
forRow:GUI_ROW_KC_INSTRUCT];
1188 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
1190 if (guiChanged) [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
1196 [
self handleGUIUpDownArrowKeys];
1197 BOOL selectKeyPress = ([
self checkKeyPress:n_key_gui_select] || [gameView
isDown:gvMouseDoubleClick]);
1203 if ([key hasPrefix:
@"More:"])
1205 int from_function = [[[key componentsSeparatedByString:@":"] objectAtIndex:1] intValue];
1206 if (from_function < 0) from_function = 0;
1210 [
self setGuiToKeyboardLayoutScreen:from_function];
1216 NSUInteger idx =[[[key componentsSeparatedByString:@":"] objectAtIndex:1] intValue];
1217 NSString *kbd = [[kbdLayouts objectAtIndex:idx] objectForKey:@"key"];
1218 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
1219 [defaults setObject:kbd forKey:@"keyboard-code"];
1220 [
self initKeyConfigSettings];
1221 [
self initCheckingDictionary];
1224 [
self setGuiToKeyMapperScreen:0 resetCurrentRow:YES];
1226 if ([gameView isDown:27])
1229 [
self setGuiToKeyMapperScreen:0 resetCurrentRow:YES];
1234- (NSString *)keyboardDescription:(NSString *)kbd
1236 NSString *map =
@"";
1238 map =
@"keymappings_windows.plist";
1241 map =
@"keymappings_linux.plist";
1244 map =
@"keymappings_mac.plist";
1247 NSDictionary *sect = [kmap objectForKey:kbd];
1248 return [sect objectForKey:@"description"];
1252- (NSArray *)keyboardLayoutList
1254 NSString *map =
@"";
1256 map =
@"keymappings_windows.plist";
1259 map =
@"keymappings_linux.plist";
1262 map =
@"keymappings_mac.plist";
1265 NSMutableArray *kbdList = [NSMutableArray array];
1266 NSArray *keys = [kmap allKeys];
1268 NSDictionary *def =
nil;
1270 for (i = 0; i < [keys count]; i++)
1272 if (![[keys objectAtIndex:i] isEqualToString:
@"default"])
1274 [kbdList addObject:[[NSDictionary alloc] initWithObjectsAndKeys:[keys objectAtIndex:i], @"key",
1275 [
self keyboardDescription:[keys objectAtIndex:i]], @"description",
1282 def = [[NSDictionary alloc] initWithObjectsAndKeys:[keys objectAtIndex:i], @"key",
1283 [
self keyboardDescription:[keys objectAtIndex:i]], @"description",
1289 NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"description" ascending:YES];
1290 NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
1291 NSMutableArray *sorted = [NSMutableArray arrayWithArray:[kbdList sortedArrayUsingDescriptors:sortDescriptors]];
1292 [sorted insertObject:def atIndex:0];
1294 [sortDescriptor release];
1300- (void) displayKeyboardLayoutList:(
GuiDisplayGen *)gui skip:(NSUInteger)skip
1303 [gui
setArray:[NSArray arrayWithObjects:@"Keyboard layout", nil]
forRow:GUI_ROW_KC_HEADING];
1305 if (!kbdLayouts) kbdLayouts = [[
self keyboardLayoutList] retain];
1307 NSUInteger i, n_functions = [kbdLayouts count];
1308 NSInteger n_rows, start_row, previous = 0;
1310 if (skip >= n_functions)
1311 skip = n_functions - 1;
1335 if (n_functions > 0)
1340 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @" <-- ", nil]
forRow:GUI_ROW_KC_FUNCSTART];
1341 [gui
setKey:[NSString stringWithFormat:@"More:%ld", previous]
forRow:GUI_ROW_KC_FUNCSTART];
1344 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
1345 NSString *kbd = [defaults oo_stringForKey:@"keyboard-code" defaultValue:@"default"];
1347 for(i = 0; i < (n_functions - skip) && (
int)i < n_rows; i++)
1349 NSDictionary *entry = [kbdLayouts objectAtIndex:i + skip];
1350 NSString *desc = [entry objectForKey:@"description"];
1351 NSString *selected =
@"";
1352 if ([[entry objectForKey:
@"key"] isEqualToString:kbd]) selected =
@"Current";
1353 [gui
setArray:[NSArray arrayWithObjects:desc, selected, nil]
forRow:i + start_row];
1354 [gui
setKey:[NSString stringWithFormat:@"Index:%ld", i + skip]
forRow:i + start_row];
1356 if (i < n_functions - skip)
1359 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-more"), @" --> ", nil]
forRow:start_row + i];
1360 [gui
setKey:[NSString stringWithFormat:@"More:%ld", n_rows + skip]
forRow:start_row + i];
1364 [gui
setSelectableRange:NSMakeRange(GUI_ROW_KC_FUNCSTART, i + start_row - GUI_ROW_KC_FUNCSTART)];
1371- (NSArray *) validateAllKeys
1373 NSMutableArray *failed = [[NSMutableArray alloc] init];
1374 NSString *validate =
nil;
1377 for (i = 0; i < [keyFunctions count]; i++)
1379 NSDictionary *entry = [keyFunctions objectAtIndex:i];
1380 validate = [
self validateKey:[entry objectForKey:KEY_KC_DEFINITION] checkKeys:(NSArray *)[keyconfig2_settings objectForKey:[entry objectForKey:KEY_KC_DEFINITION]]];
1383 [failed addObject:validate];
1386 return [failed copy];
1391- (NSString *) validateKey:(NSString *)key checkKeys:(NSArray *)check_keys
1393 NSString *result =
nil;
1396 NSArray *gui_keys = [NSArray arrayWithObjects:@"key_gui_arrow_left", @"key_gui_arrow_right", @"key_gui_arrow_up", @"key_gui_arrow_down", @"key_gui_page_up",
1397 @"key_gui_page_down", @"key_gui_select", nil];
1399 if ([gui_keys containsObject:key])
1401 result = [
self searchArrayForMatch:gui_keys key:key checkKeys:check_keys];
1402 if (result)
return result;
1405 NSArray *debug_keys = [NSArray arrayWithObjects:
1406 @"key_dump_target_state", @"key_dump_entity_list", @"key_debug_full", @"key_debug_collision", @"key_debug_console_connect", @"key_debug_bounding_boxes",
1407 @"key_debug_shaders", @"key_debug_off", nil];
1409 if ([debug_keys containsObject:key])
1411 result = [
self searchArrayForMatch:debug_keys key:key checkKeys:check_keys];
1412 if (result)
return result;
1415 NSArray *customview_keys = [NSArray arrayWithObjects:
1416 @"key_custom_view", @"key_custom_view_zoom_out", @"key_custom_view_zoom_in", @"key_custom_view_roll_left", @"key_custom_view_pan_left",
1417 @"key_custom_view_roll_right", @"key_custom_view_pan_right", @"key_custom_view_rotate_up", @"key_custom_view_pan_up", @"key_custom_view_rotate_down",
1418 @"key_custom_view_pan_down", @"key_custom_view_rotate_left", @"key_custom_view_rotate_right", nil];
1420 if ([customview_keys containsObject:key])
1422 result = [
self searchArrayForMatch:customview_keys key:key checkKeys:check_keys];
1423 if (result)
return result;
1426 NSMutableArray *inflight_keys = [NSMutableArray arrayWithObjects:
1427 @"key_roll_left", @"key_roll_right", @"key_pitch_forward", @"key_pitch_back", @"key_yaw_left", @"key_yaw_right", @"key_view_forward", @"key_view_aft",
1428 @"key_view_port", @"key_view_starboard", @"key_increase_speed", @"key_decrease_speed", @"key_inject_fuel", @"key_fire_lasers", @"key_weapons_online_toggle",
1429 @"key_launch_missile", @"key_next_missile", @"key_ecm", @"key_prime_next_equipment", @"key_prime_previous_equipment", @"key_activate_equipment",
1430 @"key_mode_equipment", @"key_fastactivate_equipment_a", @"key_fastactivate_equipment_b", @"key_target_incoming_missile", @"key_target_missile",
1431 @"key_untarget_missile", @"key_ident_system", @"key_scanner_zoom", @"key_scanner_unzoom", @"key_launch_escapepod", @"key_galactic_hyperspace",
1432 @"key_hyperspace", @"key_jumpdrive", @"key_dump_cargo", @"key_rotate_cargo", @"key_autopilot", @"key_autodock", @"key_docking_clearance_request",
1433 @"key_snapshot", @"key_cycle_next_mfd", @"key_cycle_previous_mfd", @"key_switch_next_mfd", @"key_switch_previous_mfd",
1434 @"key_next_target", @"key_previous_target", @"key_comms_log", @"key_prev_compass_mode", @"key_next_compass_mode", @"key_custom_view",
1435#if OO_FOV_INFLIGHT_CONTROL_ENABLED
1436 @"key_inc_field_of_view", @"key_dec_field_of_view",
1438 @"key_pausebutton", @"key_dump_target_state", nil];
1440 if ([
self entryIsCustomEquip:key]) {
1442 for (i = 0; i < [customEquipActivation count]; i++)
1444 [inflight_keys addObject:[NSString stringWithFormat:@"activate_%@", [[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPKEY]]];
1445 [inflight_keys addObject:[NSString stringWithFormat:@"mode_%@", [[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPKEY]]];
1449 if ([inflight_keys containsObject:key])
1451 result = [
self searchArrayForMatch:inflight_keys key:key checkKeys:check_keys];
1452 if (result)
return result;
1455 NSArray *docking_keys = [NSArray arrayWithObjects:
1456 @"key_docking_music", @"key_autopilot", @"key_pausebutton", nil];
1458 if ([docking_keys containsObject:key])
1460 result = [
self searchArrayForMatch:docking_keys key:key checkKeys:check_keys];
1461 if (result)
return result;
1464 NSArray *docked_keys = [
1465 [NSArray arrayWithObjects:@"key_launch_ship", @"key_gui_screen_options", @"key_gui_screen_equipship", @"key_gui_screen_interfaces", @"key_gui_screen_status",
1466 @"key_gui_chart_screens", @"key_gui_system_data", @"key_gui_market", nil]
1467 arrayByAddingObjectsFromArray:gui_keys];
1469 if ([docked_keys containsObject:key])
1471 result = [
self searchArrayForMatch:docked_keys key:key checkKeys:check_keys];
1472 if (result)
return result;
1475 NSArray *paused_keys = [[
1476 [NSArray arrayWithObjects:@"key_pausebutton", @"key_gui_screen_options", @"key_hud_toggle", @"key_show_fps", @"key_mouse_control_roll",
1477 @"key_mouse_control_yaw", nil]
1478 arrayByAddingObjectsFromArray:debug_keys]
1479 arrayByAddingObjectsFromArray:customview_keys];
1481 if ([paused_keys containsObject:key])
1483 result = [
self searchArrayForMatch:paused_keys key:key checkKeys:check_keys];
1484 if (result)
return result;
1487 NSArray *chart_keys = [NSArray arrayWithObjects:
1488 @"key_advanced_nav_array_next", @"key_advanced_nav_array_previous", @"key_map_home", @"key_map_end", @"key_map_info",
1489 @"key_map_zoom_in", @"key_map_zoom_out", @"key_map_next_system", @"key_map_previous_system", @"key_chart_highlight",
1490 @"key_launch_ship", @"key_gui_screen_options", @"key_gui_screen_equipship", @"key_gui_screen_interfaces", @"key_gui_screen_status",
1491 @"key_gui_chart_screens", @"key_gui_system_data", @"key_gui_market", nil];
1493 if ([chart_keys containsObject:key])
1495 result = [
self searchArrayForMatch:chart_keys key:key checkKeys:check_keys];
1496 if (result)
return result;
1499 NSArray *sysinfo_keys = [NSArray arrayWithObjects:
1500 @"key_system_home", @"key_system_end", @"key_system_next_system", @"key_system_previous_system",
1501 @"key_launch_ship", @"key_gui_screen_options", @"key_gui_screen_equipship", @"key_gui_screen_interfaces", @"key_gui_screen_status",
1502 @"key_gui_chart_screens", @"key_gui_system_data", @"key_gui_market", nil];
1504 if ([sysinfo_keys containsObject:key])
1506 result = [
self searchArrayForMatch:sysinfo_keys key:key checkKeys:check_keys];
1507 if (result)
return result;
1510 NSArray *market_keys = [NSArray arrayWithObjects:
1511 @"key_market_filter_cycle", @"key_market_sorter_cycle", @"key_market_buy_one", @"key_market_sell_one", @"key_market_buy_max",
1512 @"key_market_sell_max", @"key_launch_ship", @"key_gui_screen_options", @"key_gui_screen_equipship", @"key_gui_screen_interfaces", @"key_gui_screen_status",
1513 @"key_gui_chart_screens", @"key_gui_system_data", @"key_gui_market", @"key_gui_arrow_up", @"key_gui_arrow_down", @"key_gui_page_up",
1514 @"key_gui_page_down", @"key_gui_select", nil];
1516 if ([market_keys containsObject:key])
1518 result = [
self searchArrayForMatch:market_keys key:key checkKeys:check_keys];
1519 if (result)
return result;
1529- (NSString *) searchArrayForMatch:(NSArray *)search_list key:(NSString *)key checkKeys:(NSArray *)check_keys
1531 NSString *search =
nil;
1533 for (i = 0; i < [search_list count]; i++)
1535 search = (NSString*)[search_list objectAtIndex:i];
1537 if (![search isEqualToString:key])
1541 NSArray *current =
nil;
1542 if (![
self entryIsCustomEquip:search])
1544 current = (NSArray *)[keyconfig2_settings objectForKey:search];
1548 NSUInteger idx = [
self getCustomEquipIndex:search];
1549 NSString *keytype = [
self getCustomEquipKeyDefType:search];
1550 current = (NSArray *)[[customEquipActivation objectAtIndex:idx] objectForKey:keytype];
1552 for (j = 0; j < [current count]; j++)
1554 for (k = 0; k < [check_keys count]; k++)
1556 if ([
self compareKeyEntries:[current objectAtIndex:j] second:[check_keys objectAtIndex:k]])
return search;
1566- (BOOL) entryIsEqualToDefault:(NSString*)key
1568 NSArray *def = (NSArray *)[
kdic_check objectForKey:key];
1572 for (i = 0; i < [key_list count]; i++)
1574 NSDictionary *orig = (NSDictionary *)[def objectAtIndex:i];
1575 NSDictionary *entrd = (NSDictionary *)[
key_list objectAtIndex:i];
1576 if (![
self compareKeyEntries:orig second:entrd])
return NO;
1583- (BOOL) compareKeyEntries:(NSDictionary*)first second:(NSDictionary*)second
1585 if ([(NSString *)[first objectForKey:
@"key"] integerValue] == [(NSString *)[second objectForKey:
@"key"] integerValue])
1587 if ([[first objectForKey:
@"shift"] boolValue] == [[second objectForKey:
@"shift"] boolValue] &&
1588 [[first objectForKey:
@"mod1"] boolValue] == [[second objectForKey:
@"mod1"] boolValue] &&
1589 [[first objectForKey:
@"mod2"] boolValue] == [[second objectForKey:
@"mod2"] boolValue])