43#import "MyOpenGLView.h"
69#define CUSTOM_VIEW_ROTATE_SPEED 1.0
70#define CUSTOM_VIEW_ZOOM_SPEED 5.0
71#define CUSTOM_VIEW_SPEED_REDUCTION_FACTOR 0.3
108#if OO_RESOLUTION_OPTION
111#if OOLITE_SPEECH_SYNTH
114static BOOL speechVoiceSelectKeyPressed;
115static BOOL speechGenderSelectKeyPressed;
125static BOOL gammaControlPressed;
170@interface PlayerEntity (OOControlsPrivate)
172- (void) pollFlightControls:(
double) delta_t;
173- (void) pollFlightArrowKeyControls:(
double) delta_t;
174- (void) pollGuiArrowKeyControls:(
double) delta_t;
183- (void) pollGuiScreenControlsWithFKeyAlias:(BOOL)fKeyAlias;
186- (void) pollGameOverControls:(
double) delta_t;
187- (void) pollAutopilotControls:(
double) delta_t;
188- (void) pollDockedControls:(
double) delta_t;
189- (void) pollDemoControls:(
double) delta_t;
193- (void) switchToThisView:(
OOViewID)viewDirection;
194- (void) switchToThisView:(
OOViewID)viewDirection andProcessWeaponFacing:(BOOL)processWeaponFacing;
195- (void) switchToThisView:(
OOViewID)viewDirection fromView:(
OOViewID)oldViewDirection andProcessWeaponFacing:(BOOL)processWeaponFacing justNotify:(BOOL)justNotify;
197- (void) handleAutopilotOn:(BOOL)fastDocking;
205@implementation PlayerEntity (Controls)
209 [keyCodeLookups release];
211 keyCodeLookups = [[NSDictionary alloc] initWithObjectsAndKeys:
212 [NSNumber numberWithUnsignedShort:gvArrowKeyLeft], @"arrowleft",
213 [NSNumber numberWithUnsignedShort:gvArrowKeyLeft], @"leftarrow",
214 [NSNumber numberWithUnsignedShort:gvArrowKeyLeft], @"left",
215 [NSNumber numberWithUnsignedShort:gvArrowKeyRight], @"arrowright",
216 [NSNumber numberWithUnsignedShort:gvArrowKeyRight], @"rightarrow",
217 [NSNumber numberWithUnsignedShort:gvArrowKeyRight], @"right",
218 [NSNumber numberWithUnsignedShort:gvArrowKeyUp], @"arrowup",
219 [NSNumber numberWithUnsignedShort:gvArrowKeyUp], @"uparrow",
220 [NSNumber numberWithUnsignedShort:gvArrowKeyUp], @"up",
221 [NSNumber numberWithUnsignedShort:gvArrowKeyDown], @"arrowdown",
222 [NSNumber numberWithUnsignedShort:gvArrowKeyDown], @"downarrow",
223 [NSNumber numberWithUnsignedShort:gvArrowKeyDown], @"down",
224 [NSNumber numberWithUnsignedShort:gvPageUpKey], @"pageup",
225 [NSNumber numberWithUnsignedShort:gvPageDownKey], @"pagedown",
226 [NSNumber numberWithUnsignedShort:13], @"enter",
227 [NSNumber numberWithUnsignedShort:13], @"return",
228 [NSNumber numberWithUnsignedShort:27], @"escape",
229 [NSNumber numberWithUnsignedShort:27], @"esc",
230 [NSNumber numberWithUnsignedShort:9], @"tab",
231 [NSNumber numberWithUnsignedShort:32], @"space",
232 [NSNumber numberWithUnsignedShort:32], @"spc",
233 [NSNumber numberWithUnsignedShort:gvHomeKey], @"home",
234 [NSNumber numberWithUnsignedShort:gvEndKey], @"end",
235 [NSNumber numberWithUnsignedShort:gvDeleteKey], @"delete",
236 [NSNumber numberWithUnsignedShort:gvDeleteKey], @"del",
237 [NSNumber numberWithUnsignedShort:gvBackspaceKey], @"backspace",
238 [NSNumber numberWithUnsignedShort:gvBackspaceKey], @"backspc",
239 [NSNumber numberWithUnsignedShort:gvBackspaceKey], @"bkspace",
240 [NSNumber numberWithUnsignedShort:gvBackspaceKey], @"bkspc",
241 [NSNumber numberWithUnsignedShort:gvInsertKey], @"insert",
242 [NSNumber numberWithUnsignedShort:gvInsertKey], @"ins",
243 [NSNumber numberWithUnsignedShort:gvFunctionKey1], @"f1",
244 [NSNumber numberWithUnsignedShort:gvFunctionKey2], @"f2",
245 [NSNumber numberWithUnsignedShort:gvFunctionKey3], @"f3",
246 [NSNumber numberWithUnsignedShort:gvFunctionKey4], @"f4",
247 [NSNumber numberWithUnsignedShort:gvFunctionKey5], @"f5",
248 [NSNumber numberWithUnsignedShort:gvFunctionKey6], @"f6",
249 [NSNumber numberWithUnsignedShort:gvFunctionKey7], @"f7",
250 [NSNumber numberWithUnsignedShort:gvFunctionKey8], @"f8",
251 [NSNumber numberWithUnsignedShort:gvFunctionKey9], @"f9",
252 [NSNumber numberWithUnsignedShort:gvFunctionKey10], @"f10",
253 [NSNumber numberWithUnsignedShort:gvFunctionKey11], @"f11",
254 [NSNumber numberWithUnsignedShort:gvPauseKey], @"pause",
255 [NSNumber numberWithUnsignedShort:gvPrintScreenKey], @"printscreen",
256 [NSNumber numberWithUnsignedShort:gvPrintScreenKey], @"prtscrn",
257 [NSNumber numberWithUnsignedShort:gvPrintScreenKey], @"prntscrn",
258 [NSNumber numberWithUnsignedShort:gvPrintScreenKey], @"prtscn",
259 [NSNumber numberWithUnsignedShort:gvNumberPadKey0], @"numpad0",
260 [NSNumber numberWithUnsignedShort:gvNumberPadKey1], @"numpad1",
261 [NSNumber numberWithUnsignedShort:gvNumberPadKey2], @"numpad2",
262 [NSNumber numberWithUnsignedShort:gvNumberPadKey3], @"numpad3",
263 [NSNumber numberWithUnsignedShort:gvNumberPadKey4], @"numpad4",
264 [NSNumber numberWithUnsignedShort:gvNumberPadKey5], @"numpad5",
265 [NSNumber numberWithUnsignedShort:gvNumberPadKey6], @"numpad6",
266 [NSNumber numberWithUnsignedShort:gvNumberPadKey7], @"numpad7",
267 [NSNumber numberWithUnsignedShort:gvNumberPadKey8], @"numpad8",
268 [NSNumber numberWithUnsignedShort:gvNumberPadKey9], @"numpad9",
269 [NSNumber numberWithUnsignedShort:gvNumberPadKeyDivide], @"numpad/",
270 [NSNumber numberWithUnsignedShort:gvNumberPadKeyDivide], @"numpaddivide",
271 [NSNumber numberWithUnsignedShort:gvNumberPadKeyMultiply], @"numpad*",
272 [NSNumber numberWithUnsignedShort:gvNumberPadKeyMultiply], @"numpadmultiply",
273 [NSNumber numberWithUnsignedShort:gvNumberPadKeyMinus], @"numpad-",
274 [NSNumber numberWithUnsignedShort:gvNumberPadKeyMinus], @"numpadminus",
275 [NSNumber numberWithUnsignedShort:gvNumberPadKeyPlus], @"numpad+",
276 [NSNumber numberWithUnsignedShort:gvNumberPadKeyPlus], @"numpadplus",
277 [NSNumber numberWithUnsignedShort:gvNumberPadKeyPeriod], @"numpad.",
278 [NSNumber numberWithUnsignedShort:gvNumberPadKeyPeriod], @"numpadperiod",
279 [NSNumber numberWithUnsignedShort:gvNumberPadKeyEquals], @"numpad=",
280 [NSNumber numberWithUnsignedShort:gvNumberPadKeyEquals], @"numpadequals",
281 [NSNumber numberWithUnsignedShort:gvNumberPadKeyEnter], @"numpadenter", nil];
283 keyShiftText = [DESC(@"oolite-keyconfig-shift") retain];
284 keyMod1Text = [DESC(@"oolite-keyconfig-mod1") retain];
286 keyMod2Text = [DESC(@"oolite-keyconfig-mod2-mac") retain];
288 keyMod2Text = [DESC(@"oolite-keyconfig-mod2-pc") retain];
297- (void) initKeyConfigSettings
300 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
301 NSString *kbd = [defaults oo_stringForKey:@"keyboard-code" defaultValue:@"default"];
302 NSMutableDictionary *kdic2 = [NSMutableDictionary dictionaryWithDictionary:[kdicmaster objectForKey:kbd]];
307 NSArray *def_list =
nil;
309 keys = [kdic2 allKeys];
310 for (i = 0; i < [keys count]; i++)
312 key = [keys objectAtIndex:i];
313 if ([[kdic2 objectForKey:key] isKindOfClass:[NSArray
class]])
315 def_list = (NSArray*)[kdic2 objectForKey: key];
316 [kdic2 setObject:[
self processKeyCode:def_list] forKey:key];
321 [customEquipActivation release];
324 NSArray *temp = [defaults arrayForKey:KEYCONFIG_CUSTOMEQUIP];
325 customEquipActivation = [[NSMutableArray arrayWithArray:temp] retain];
329 customEquipActivation = [[NSMutableArray alloc] init];
331 [customActivatePressed release];
332 [customModePressed release];
333 customActivatePressed = [[NSMutableArray alloc] init];
334 customModePressed = [[NSMutableArray alloc] init];
335 for (i = 0; i < [customEquipActivation count]; i++)
337 [customActivatePressed addObject:[NSNumber numberWithBool:NO]];
338 [customModePressed addObject:[NSNumber numberWithBool:NO]];
341 NSMutableArray *keyDef =
nil;
342 NSString *lookup =
nil;
344 NSDictionary *key1 =
nil;
345 NSDictionary *key2 =
nil;
348 NSDictionary *dict = [defaults objectForKey:KEYCONFIG_OVERRIDES];
350 keys = [dict allKeys];
351 for (i = 0; i < [keys count]; i++)
353 key = [keys objectAtIndex:i];
354 [kdic2 setObject:[dict objectForKey:key] forKey:key];
359#define LOAD_KEY_SETTING2(name, default_1, shift_1, mod1_1, default_2, shift_2, mod1_2) \
360 lookup = [@#name substringFromIndex:2]; \
361 curr = (NSArray*)[[kdic2 objectForKey:lookup] copy]; \
362 key1 = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithUnsignedShort:default_1], @"key", [NSNumber numberWithBool:shift_1], @"shift", [NSNumber numberWithBool:mod1_1], @"mod1", [NSNumber numberWithBool:NO], @"mod2", nil]; \
363 [keyDef addObject:key1]; \
366 key2 = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithUnsignedShort:default_2], @"key", [NSNumber numberWithBool:shift_2], @"shift", [NSNumber numberWithBool:mod1_2], @"mod1", [NSNumber numberWithBool:NO], @"mod2", nil]; \
367 [keyDef addObject:key2]; \
369 name = curr?:keyDef; \
370 [kdic2 setObject:curr?:keyDef forKey:lookup]; \
503#if OO_FOV_INFLIGHT_CONTROL_ENABLED
519 [keyconfig2_settings release];
520 keyconfig2_settings = [[NSDictionary alloc] initWithDictionary:kdic2 copyItems:YES];
524- (NSArray*) processKeyCode:(NSArray*)key_def
527 id key =
nil, value =
nil;
529 unsigned char keychar;
530 NSString *keystring =
nil;
531 NSDictionary *def =
nil;
532 NSMutableArray *newList = [[NSMutableArray alloc] init];
534 for (i = 0; i < [key_def count]; i++)
536 def = [key_def objectAtIndex:i];
537 if ([def
count] == 0)
continue;
538 value = [def objectForKey:@"key"];
539 iValue = [value intValue];
543 NSMutableDictionary *defNew = [[NSMutableDictionary alloc] init];
544 if ([def objectForKey:
@"shift"]) [defNew setObject:[def objectForKey:
@"shift"] forKey:
@"shift"];
else [defNew setObject:[NSNumber numberWithBool:NO] forKey:@"shift"];
545 if ([def objectForKey:
@"mod1"]) [defNew setObject:[def objectForKey:
@"mod1"] forKey:
@"mod1"];
else [defNew setObject:[NSNumber numberWithBool:NO] forKey:@"mod1"];
546 if ([def objectForKey:
@"mod2"]) [defNew setObject:[def objectForKey:
@"mod2"] forKey:
@"mod2"];
else [defNew setObject:[NSNumber numberWithBool:NO] forKey:@"mod2"];
551 if ([value isKindOfClass:[NSString
class]] && (iValue < 10))
556 if ([keystring length] != 0)
559 checkVal = [[keyCodeLookups objectForKey:[keystring lowercaseString]] intValue];
563 [defNew setObject:[NSNumber numberWithUnsignedShort:iValue] forKey:@"key"];
564 [newList addObject:defNew];
570 if ([keystring length] == 1 || (iValue == 0 && [keystring length] != 0))
572 keychar = [keystring characterAtIndex:0] & 0x00ff;
574 else if (iValue <= 0xFF) keychar = iValue;
576 OOLogWARN(
@"testing",
@"continue hit for key %@.", key);
577 [defNew setObject:[def objectForKey:@"key"] forKey:@"key"];
578 [newList addObject:defNew];
583 [defNew setObject:[NSNumber numberWithUnsignedShort:keychar] forKey:@"key"];
584 [newList addObject:defNew];
589 [defNew setObject:[def objectForKey:@"key"] forKey:@"key"];
590 [newList addObject:defNew];
600- (BOOL) checkNavKeyPress:(NSArray*)key_def
604 for (i = 0; i < [key_def count]; i++)
606 NSDictionary *def = [key_def objectAtIndex:i];
607 if ([gameView isDown:[[def objectForKey:
@"key"] intValue]])
return YES;
613- (BOOL) checkKeyPress:(NSArray*)key_def
615 return [
self checkKeyPress:key_def fKey_only:NO ignore_ctrl:NO];
619- (BOOL) checkKeyPress:(NSArray*)key_def fKey_only:(BOOL)fKey_only
621 return [
self checkKeyPress:key_def fKey_only:fKey_only ignore_ctrl:NO];
625- (BOOL) checkKeyPress:(NSArray*)key_def ignore_ctrl:(BOOL)ignore_ctrl
627 return [
self checkKeyPress:key_def fKey_only:NO ignore_ctrl:ignore_ctrl];
631- (BOOL) checkKeyPress:(NSArray*)key_def fKey_only:(BOOL)fKey_only ignore_ctrl:(BOOL)ignore_ctrl
635 for (i = 0; i < [key_def count]; i++)
637 NSDictionary *def = [key_def objectAtIndex:i];
638 int keycode = [[def objectForKey:@"key"] intValue];
645 if (fKey_only == YES && (keycode < gvFunctionKey1 || keycode >
gvFunctionKey11))
continue;
646 if ([gameView isDown:keycode]
647 && ([[def objectForKey:
@"shift"] boolValue] == [gameView isShiftDown])
648 && (ignore_ctrl || ([[def objectForKey:
@"mod1"] boolValue] == [gameView isCtrlDown]))
649 && ([[def objectForKey:
@"mod2"] boolValue] == [gameView isOptDown])
656- (
int) getFirstKeyCode:(NSArray*)key_def
658 NSDictionary *def = [key_def objectAtIndex:0];
659 return [[def objectForKey:@"key"] intValue];
663- (void) pollControls:(
double)delta_t
666 NSString *exceptionContext =
@"setup";
673 exceptionContext =
@"pollApplicationControls";
674 [
self pollApplicationControls];
675 switch ([
self status])
677 case STATUS_WITCHSPACE_COUNTDOWN:
678 case STATUS_IN_FLIGHT:
679 exceptionContext =
@"pollFlightControls";
680 [
self pollFlightControls:delta_t];
684 exceptionContext =
@"pollGameOverControls";
685 [
self pollGameOverControls:delta_t];
688 case STATUS_AUTOPILOT_ENGAGED:
689 exceptionContext =
@"pollAutopilotControls";
690 [
self pollAutopilotControls:delta_t];
694 exceptionContext =
@"pollDockedControls";
695 [
self pollDockedControls:delta_t];
698 case STATUS_START_GAME:
699 exceptionContext =
@"pollDemoControls";
700 [
self pollDemoControls:delta_t];
709 @catch (NSException *exception)
711 OOLog(
kOOLogException,
@"***** Exception checking controls [%@]: %@ : %@", exceptionContext, [exception name], [exception reason]);
716- (BOOL) handleGUIUpDownArrowKeys
721 BOOL arrow_up = [
self checkKeyPress:n_key_gui_arrow_up];
722 BOOL arrow_down = [
self checkKeyPress:n_key_gui_arrow_down];
723 BOOL mouse_click = [gameView
isDown:gvMouseLeftButton];
724 BOOL mouse_dbl_click = [gameView
isDown:gvMouseDoubleClick];
730 if ([gui setNextRow: +1])
736 if ([gui setFirstSelectableRow]) result = YES;
739 if (result && [gui selectableRange].length > 1) [
self playMenuNavigationDown];
740 else [
self playMenuNavigationNot];
750 if ([gui setNextRow: -1])
756 if ([gui setLastSelectableRow]) result = YES;
759 if (result && [gui selectableRange].length > 1) [
self playMenuNavigationUp];
760 else [
self playMenuNavigationNot];
773 if ([gui setSelectedRow:click_row])
784 if ([gui setSelectedRow:click_row])
804- (void) targetNewSystem:(
int) direction whileTyping:(BOOL) whileTyping
806 target_system_id = [[UNIVERSE gui] targetNextFoundSystem:direction];
807 [
self setInfoSystemID: target_system_id moveChart: YES];
808 cursor_coordinates = [[UNIVERSE systemManager] getCoordinatesForSystem:target_system_id inGalaxy:galaxy_number];
810 found_system_id = target_system_id;
813 [
self clearPlanetSearchString];
819- (void) clearPlanetSearchString
821 [[UNIVERSE gameView] resetTypedString];
822 if (planetSearchString) [planetSearchString release];
823 planetSearchString =
nil;
827- (void) targetNewSystem:(
int) direction
829 [
self targetNewSystem:direction whileTyping:NO];
833- (void) switchToMainView
836 gui_screen = GUI_SCREEN_MAIN;
839 [
self setShowDemoShips: NO];
840 [UNIVERSE removeDemoShips];
842 [(
MyOpenGLView *)[UNIVERSE gameView] allowStringInput:NO];
843 if ([
self isMouseControlOn]) [[
UNIVERSE gameView] resetMouse];
844 [UNIVERSE enterGUIViewModeWithMouseInteraction:NO];
845 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
851 [
self switchToThisView:toView fromView:fromView andProcessWeaponFacing:NO justNotify:YES];
856-(void) beginWitchspaceCountdown:(
int)spin_time
858 if ([
self hasHyperspaceMotor])
862 witchspaceCountdown = hyperspaceMotorSpinTime;
866#ifndef OO_DUMP_PLANETINFO
869 witchspaceCountdown = 5;
874 witchspaceCountdown = spin_time;
877 [
self setStatus:STATUS_WITCHSPACE_COUNTDOWN];
878 [
self playStandardHyperspace];
880 [UNIVERSE clearPreviousMessage];
881 int seconds = round(witchspaceCountdown);
882 NSString *destination = [UNIVERSE getSystemName:[
self nextHopTargetSystemID]];
883 [UNIVERSE displayCountdownMessage:OOExpandKey(@"witch-to-x-in-y-seconds", seconds, destination) forCount:1.0];
884 [
self doScriptEvent:OOJSID("playerStartedJumpCountdown")
885 withArguments:[NSArray arrayWithObjects:@"standard", [NSNumber numberWithFloat:witchspaceCountdown], nil]];
886 [UNIVERSE preloadPlanetTexturesForSystem:target_system_id];
891-(void) beginWitchspaceCountdown
893 if ([
self hasHyperspaceMotor]) {
894 [
self beginWitchspaceCountdown:hyperspaceMotorSpinTime];
899-(void) cancelWitchspaceCountdown
901 if ([
self status] == STATUS_WITCHSPACE_COUNTDOWN) {
902 [
self setStatus:STATUS_IN_FLIGHT];
903 [
self playHyperspaceAborted];
906 [UNIVERSE clearPreviousMessage];
907 [
self doScriptEvent:OOJSID("playerCancelledJumpCountdown")];
913@implementation PlayerEntity (OOControlsPrivate)
917 if (!pollControls)
return;
919 NSString *exceptionContext =
@"setup";
925 BOOL onTextEntryScreen = (gui_screen == GUI_SCREEN_LONG_RANGE_CHART) || (gui_screen == GUI_SCREEN_MISSION) ||
926 (gui_screen == GUI_SCREEN_SAVE) || (gui_screen == GUI_SCREEN_OXZMANAGER || (gui_screen == GUI_SCREEN_KEYBOARD_ENTRY));
931 #if !OOLITE_MAC_OS_X || !OOLITE_64_BIT
932 if ([gameController inFullScreenMode])
934 exceptionContext =
@"command key controls";
935 if ([gameView isCommandFDown])
939 if (mouse_control_on)
941 [UNIVERSE addMessage:DESC(@"mouse-off") forCount:3.0];
942 mouse_control_on = NO;
946 if ([gameView isCommandQDown])
954 if ([
self status] == STATUS_HANDLING_ERROR)
956 exceptionContext =
@"error handling mode";
957 if ([gameView isDown:113]||[gameView isDown:81]||[gameView isDown:27])
963 if ([gameController isGamePaused])
966 switch ([
self status])
968 case STATUS_WITCHSPACE_COUNTDOWN:
969 case STATUS_IN_FLIGHT:
970 case STATUS_AUTOPILOT_ENGAGED:
982 [UNIVERSE clearPreviousMessage];
994 if (([
self checkKeyPress:n_key_snapshot] || joyButtonState[
BUTTON_SNAPSHOT]) &&
998 exceptionContext =
@"snapshot";
1011 if (!onTextEntryScreen && [
self checkKeyPress:n_key_show_fps])
1013 exceptionContext =
@"toggle FPS";
1014 if (!
f_key_pressed) [UNIVERSE setDisplayFPS:![UNIVERSE displayFPS]];
1023 if ([
self checkKeyPress:n_key_bloom_toggle])
1027 BOOL oldBloom = [UNIVERSE bloom];
1028 [UNIVERSE setBloom:!oldBloom];
1038 BOOL allowMouseControl;
1040 allowMouseControl = YES;
1043 [[NSUserDefaults standardUserDefaults] boolForKey:@"mouse-control-in-windowed-mode"];
1046 if (allowMouseControl)
1048 exceptionContext =
@"mouse control";
1049 if (!onTextEntryScreen && ([
self checkKeyPress:n_key_mouse_control_roll] || [
self checkKeyPress:n_key_mouse_control_yaw]))
1053 mouse_control_on = !mouse_control_on;
1054 if (mouse_control_on)
1056 [UNIVERSE addMessage:DESC(@"mouse-on") forCount:3.0];
1062 if ([[NSUserDefaults standardUserDefaults] boolForKey:
@"grab-mouse-on-mouse-control"])
1069 keyboardPitchOverride = NO;
1070 keyboardYawOverride = !keyboardRollOverride;
1074 [UNIVERSE addMessage:DESC(@"mouse-off") forCount:3.0];
1093 if (mouse_control_on)
1095 mouse_control_on = NO;
1096 [UNIVERSE addMessage:DESC(@"mouse-off") forCount:3.0];
1109 if (([
self checkKeyPress:n_key_hud_toggle] || joyButtonState[
BUTTON_TOGGLEHUD]) && [gameController isGamePaused] && !onTextEntryScreen)
1111 exceptionContext =
@"toggle HUD";
1116 if (gui_screen == GUI_SCREEN_STATUS)
1119 [
self setGuiToStatusScreen];
1129 @catch (NSException *exception)
1131 OOLog(
kOOLogException,
@"***** Exception in pollApplicationControls [%@]: %@ : %@", exceptionContext, [exception name], [exception reason]);
1136- (void) pollFlightControls:(
double)delta_t
1140 NSString *exceptionContext =
@"setup";
1144 exceptionContext =
@"joystick handling";
1147 BOOL paused = [[UNIVERSE gameController] isGamePaused];
1150 if (!paused && gui_screen == GUI_SCREEN_MISSION)
1152 exceptionContext =
@"mission screen";
1155 NSPoint virtualView = NSZeroPoint;
1156 double view_threshold = 0.5;
1158 if ([stickHandler joystickCount])
1160 virtualView = [stickHandler
viewAxis];
1162 virtualView.y = 0.0;
1164 virtualView.x = 0.0;
1165 if (fabs(virtualView.y) >= fabs(virtualView.x))
1166 virtualView.x = 0.0;
1168 virtualView.y = 0.0;
1171 if ([
self checkKeyPress:n_key_view_forward] || (virtualView.y < -view_threshold) || joyButtonState[
BUTTON_VIEWFORWARD])
1173 view = VIEW_FORWARD;
1175 if ([
self checkKeyPress:n_key_view_aft]|(virtualView.y > view_threshold)||joyButtonState[
BUTTON_VIEWAFT])
1179 if ([
self checkKeyPress:n_key_view_port]||(virtualView.x < -view_threshold)||joyButtonState[
BUTTON_VIEWPORT])
1183 if ([
self checkKeyPress:n_key_view_starboard]||(virtualView.x > view_threshold)||joyButtonState[
BUTTON_VIEWSTARBOARD])
1185 view = VIEW_STARBOARD;
1187 if (view == VIEW_NONE)
1190 [
self pollDemoControls: delta_t];
1194 [[UNIVERSE gui] clearBackground];
1195 [
self switchToThisView:view];
1196 if (_missionWithCallback)
1198 [
self doMissionCallback];
1201 [
self doWorldEventUntilMissionScreen:OOJSID("missionScreenEnded")];
1206 exceptionContext =
@"arrow keys";
1209 [
self pollGuiArrowKeyControls:delta_t];
1211 [
self pollFlightArrowKeyControls:delta_t];
1214 [
self pollViewControls];
1218 exceptionContext =
@"afterburner";
1219 if ((joyButtonState[
BUTTON_FUELINJECT] || [
self checkKeyPress:n_key_inject_fuel]) &&
1220 [
self hasFuelInjection] &&
1221 !hyperspeed_engaged)
1223 if (fuel > 0 && !afterburner_engaged)
1225 [UNIVERSE addMessage:DESC(@"fuel-inject-on") forCount:1.5];
1226 afterburner_engaged = YES;
1227 [
self startAfterburnerSound];
1232 [UNIVERSE addMessage:DESC(@"fuel-out") forCount:1.5];
1234 afterburner_engaged = (fuel > 0);
1237 afterburner_engaged = NO;
1239 if ((!afterburner_engaged)&&(afterburnerSoundLooping))
1240 [
self stopAfterburnerSound];
1242 exceptionContext =
@"thrust";
1244 double reqSpeed=[stickHandler
getAxisState: AXIS_THRUST];
1245 float mouseWheelDeltaFactor = mouse_control_on ? fabs([gameView mouseWheelDelta]) : 1.0f;
1246 if (mouseWheelDeltaFactor == 0.0f) mouseWheelDeltaFactor = 1.0f;
1248 if (([
self checkKeyPress:n_key_increase_speed] ||
1250 ((mouse_control_on)&&([gameView mouseWheelState] ==
gvMouseWheelUp) && ([
UNIVERSE viewDirection] <= VIEW_STARBOARD || ![gameView isCapsLockOn])))
1251 && (flightSpeed < maxFlightSpeed) && (!afterburner_engaged))
1253 flightSpeed += speed_delta * delta_t * mouseWheelDeltaFactor;
1256 if (([
self checkKeyPress:n_key_decrease_speed] ||
1258 ((mouse_control_on)&&([gameView mouseWheelState] ==
gvMouseWheelDown) && ([
UNIVERSE viewDirection] <= VIEW_STARBOARD || ![gameView isCapsLockOn])))
1259 && (!afterburner_engaged))
1261 flightSpeed -= speed_delta * delta_t * mouseWheelDeltaFactor;
1263 hyperspeed_engaged = NO;
1266 NSDictionary *functionForThrustAxis = [[stickHandler
axisFunctions] oo_dictionaryForKey:[[NSNumber numberWithInt:AXIS_THRUST] stringValue]];
1267 if([stickHandler joystickCount] != 0 && functionForThrustAxis !=
nil)
1269 if (flightSpeed < maxFlightSpeed * reqSpeed)
1271 flightSpeed += speed_delta * delta_t;
1273 if (flightSpeed > maxFlightSpeed * reqSpeed)
1275 flightSpeed -= speed_delta * delta_t;
1279 if (!afterburner_engaged && ![
self atHyperspeed] && !hyperspeed_engaged)
1281 flightSpeed = OOClamp_0_max_f(flightSpeed, maxFlightSpeed);
1284 exceptionContext =
@"hyperspeed";
1290 if (!hyperspeed_engaged)
1292 hyperspeed_locked = [
self massLocked];
1293 hyperspeed_engaged = !hyperspeed_locked;
1294 if (hyperspeed_locked)
1296 [
self playJumpMassLocked];
1297 [UNIVERSE addMessage:DESC(@"jump-mass-locked") forCount:1.5];
1302 hyperspeed_engaged = NO;
1312 exceptionContext =
@"shoot";
1314 if ((([
self checkNavKeyPress:n_key_fire_lasers])||((mouse_control_on)&&([gameView isDown:
gvMouseLeftButton]) && ([
UNIVERSE viewDirection] <= VIEW_STARBOARD || ![gameView isCapsLockOn]))||joyButtonState[
BUTTON_FIRE])&&(shot_time > weapon_recharge_rate))
1316 if ([
self fireMainWeapon])
1318 [
self playLaserHit:([
self shipHitByLaser] != nil) offset:[[
self currentLaserOffset] oo_vectorAtIndex:0] weaponIdentifier:[[
self currentWeapon] identifier]];
1322 exceptionContext =
@"weapons online toggle";
1328 NSString* weaponsOnlineToggleMsg;
1330 [
self setWeaponsOnline:![
self weaponsOnline]];
1331 weaponsOnlineToggleMsg = [
self weaponsOnline] ?
DESC(
@"weapons-systems-online") :
DESC(
@"weapons-systems-offline");
1332 if ([
self weaponsOnline])
1334 [
self playWeaponsOnline];
1338 [
self playWeaponsOffline];
1340 [UNIVERSE addMessage:weaponsOnlineToggleMsg forCount:2.0];
1341 [
self doScriptEvent:OOJSID("weaponsSystemsToggled") withArgument:[NSNumber numberWithBool:[
self weaponsOnline]]];
1347 exceptionContext =
@"missile fire";
1360 exceptionContext =
@"next missile";
1366 [
self playNextMissileSelected];
1367 [
self selectNextMissile];
1373 exceptionContext =
@"next target";
1375 if ([
self checkKeyPress:n_key_next_target] || joyButtonState[
BUTTON_NEXTTARGET])
1379 [
self moveTargetMemoryBy:+1];
1385 exceptionContext =
@"previous target";
1387 if ([
self checkKeyPress:n_key_previous_target] || joyButtonState[
BUTTON_PREVTARGET])
1391 [
self moveTargetMemoryBy:-1];
1397 exceptionContext =
@"ident R";
1399 if ([
self checkKeyPress:n_key_ident_system] || joyButtonState[
BUTTON_ID])
1404 [
self handleButtonIdent];
1410 exceptionContext =
@"prime equipment";
1419 NSUInteger c = [eqScripts count];
1427 if (primedEquipment > c) primedEquipment = 0;
1431 if (primedEquipment > 0) primedEquipment--;
1432 else primedEquipment = c;
1435 NSString *eqKey =
@"";
1437 if (primedEquipment == c)
1441 [
self playNextEquipmentSelected];
1442 [UNIVERSE addMessage:DESC(@"equipment-primed-none") forCount:2.0];
1444 else [UNIVERSE addMessage:DESC(@"equipment-primed-none-available") forCount:2.0];
1448 [
self playNextEquipmentSelected];
1450 eqKey = [[eqScripts oo_arrayAtIndex:primedEquipment] oo_stringAtIndex:0];
1451 [UNIVERSE addMessage:OOExpandKey(@"equipment-primed", equipmentName) forCount:2.0];
1453 [
self doScriptEvent:OOJSID("playerChangedPrimedEquipment") withArgument:eqKey];
1460 exceptionContext =
@"activate equipment";
1466 [
self activatePrimableEquipment:primedEquipment withMode:OOPRIMEDEQUIP_ACTIVATED];
1472 exceptionContext =
@"mode equipment";
1478 [
self activatePrimableEquipment:primedEquipment withMode:OOPRIMEDEQUIP_MODE];
1484 exceptionContext =
@"fast equipment A";
1485 if ([
self checkKeyPress:n_key_fastactivate_equipment_a] || joyButtonState[
BUTTON_CLOAK])
1489 [
self activatePrimableEquipment:[
self eqScriptIndexForKey:[
self fastEquipmentA]] withMode:OOPRIMEDEQUIP_ACTIVATED];
1495 exceptionContext =
@"fast equipment B";
1496 if ([
self checkKeyPress:n_key_fastactivate_equipment_b] || joyButtonState[
BUTTON_ENERGYBOMB])
1500 [
self activatePrimableEquipment:[
self eqScriptIndexForKey:[
self fastEquipmentB]] withMode:OOPRIMEDEQUIP_ACTIVATED];
1506 exceptionContext =
@"custom equipment";
1510 for (i = 0; i < [customEquipActivation count]; i++)
1512 item = [customEquipActivation objectAtIndex:i];
1514 if ([
self hasOneEquipmentItem:[item oo_stringForKey:
CUSTOMEQUIP_EQUIPKEY] includeWeapons:NO whileLoading:NO])
1516 NSArray *key_act = [item oo_arrayForKey:CUSTOMEQUIP_KEYACTIVATE];
1517 NSArray *key_mod = [item oo_arrayForKey:CUSTOMEQUIP_KEYMODE];
1518 NSDictionary *but_act = [item oo_dictionaryForKey:CUSTOMEQUIP_BUTTONACTIVATE];
1519 NSDictionary *but_mod = [item oo_dictionaryForKey:CUSTOMEQUIP_BUTTONMODE];
1524 if (![[customActivatePressed objectAtIndex:i] boolValue])
1527 [
self activatePrimableEquipment:[
self eqScriptIndexForKey:[item oo_stringForKey:CUSTOMEQUIP_EQUIPKEY]] withMode:OOPRIMEDEQUIP_ACTIVATED];
1529 [customActivatePressed replaceObjectAtIndex:i withObject:[NSNumber numberWithBool:YES]];
1531 else [customActivatePressed replaceObjectAtIndex:i withObject:[NSNumber numberWithBool:NO]];
1536 if (![[customModePressed objectAtIndex:i] boolValue])
1539 [
self activatePrimableEquipment:[
self eqScriptIndexForKey:[item oo_stringForKey:CUSTOMEQUIP_EQUIPKEY]] withMode:OOPRIMEDEQUIP_MODE];
1541 [customModePressed replaceObjectAtIndex:i withObject:[NSNumber numberWithBool:YES]];
1543 else [customModePressed replaceObjectAtIndex:i withObject:[NSNumber numberWithBool:NO]];
1547 exceptionContext =
@"incoming missile T";
1553 [
self targetNearestIncomingMissile];
1559 exceptionContext =
@"missile T";
1561 if (([
self checkKeyPress:n_key_target_missile] || joyButtonState[
BUTTON_ARMMISSILE])&&(missile_entity[activeMissile]))
1566 [
self handleButtonTargetMissile];
1572 exceptionContext =
@"missile U";
1574 if ([
self checkKeyPress:n_key_untarget_missile] || joyButtonState[
BUTTON_UNARM])
1579 if ([
self primaryTarget] !=
nil) [
self noteLostTarget];
1581 [
self safeAllMissiles];
1582 if (!ident_engaged && [
self weaponsOnline])
1584 [UNIVERSE addMessage:DESC(@"missile-safe") forCount:2.0];
1585 [
self playMissileSafe];
1589 [UNIVERSE addMessage:DESC(@"ident-off") forCount:2.0];
1590 [
self playIdentOff];
1598 exceptionContext =
@"ECM";
1600 if (([
self checkKeyPress:n_key_ecm] || joyButtonState[
BUTTON_ECM]) && [
self hasECM])
1602 if (!ecm_in_operation)
1606 [
self playFiredECMSound];
1607 [UNIVERSE addMessage:DESC(@"ecm-on") forCount:3.0];
1613 exceptionContext =
@"escape pod";
1617 if (([
self checkKeyPress:n_key_launch_escapepod] || joyButtonState[
BUTTON_ESCAPE]) && [
self hasEscapePod])
1619 BOOL goodToLaunch = [[NSUserDefaults standardUserDefaults] boolForKey:@"escape-pod-activation-immediate"];
1630 [gameView
clearKey:[
self getFirstKeyCode:n_key_launch_escapepod]];
1631 if ([stickHandler joystickCount])
1638 OOTimeDelta timeNow = [NSDate timeIntervalSinceReferenceDate];
1640 if (timeNow < escapePodKeyResetTime) goodToLaunch = YES;
1645 [
self launchEscapeCapsule];
1649 exceptionContext =
@"dump cargo";
1651 if (([
self checkKeyPress:n_key_dump_cargo] || joyButtonState[
BUTTON_JETTISON]) && [cargo
count] > 0)
1656 exceptionContext =
@"rotate cargo";
1667 exceptionContext =
@"autopilot C";
1669 if ([
self checkKeyPress:n_key_autopilot] || joyButtonState[
BUTTON_DOCKCPU])
1673 [
self handleAutopilotOn:false];
1680 exceptionContext =
@"autopilot shift-C";
1686 [
self handleAutopilotOn:true];
1695 exceptionContext =
@"docking clearance request";
1701 Entity *primeTarget = [
self primaryTarget];
1702 [
self performDockingRequest:(StationEntity*)primeTarget];
1711 exceptionContext =
@"hyperspace";
1713 if ( ([
self checkKeyPress:n_key_hyperspace] || joyButtonState[
BUTTON_HYPERDRIVE]) &&
1714 [
self hasHyperspaceMotor] )
1718 if ([
self status] == STATUS_WITCHSPACE_COUNTDOWN)
1720 [
self cancelWitchspaceCountdown];
1721 if (galactic_witchjump)
1723 galactic_witchjump = NO;
1724 [UNIVERSE addMessage:DESC(@"witch-user-galactic-abort") forCount:3.0];
1728 [UNIVERSE addMessage:DESC(@"witch-user-abort") forCount:3.0];
1731 else if ([
self witchJumpChecklist:
false])
1733 [
self beginWitchspaceCountdown:hyperspaceMotorSpinTime];
1741 exceptionContext =
@"galactic hyperspace";
1743 if (([
self checkKeyPress:n_key_galactic_hyperspace] || joyButtonState[
BUTTON_GALACTICDRIVE]) &&
1744 ([
self hasEquipmentItemProviding:
@"EQ_GAL_DRIVE"]))
1748 if ([
self status] == STATUS_WITCHSPACE_COUNTDOWN)
1750 [
self cancelWitchspaceCountdown];
1751 if (galactic_witchjump)
1753 galactic_witchjump = NO;
1754 [UNIVERSE addMessage:DESC(@"witch-user-galactic-abort") forCount:3.0];
1758 [UNIVERSE addMessage:DESC(@"witch-user-abort") forCount:3.0];
1763 galactic_witchjump = YES;
1766 if(
EXPECT([
self hasHyperspaceMotor])) witchspaceCountdown = hyperspaceMotorSpinTime;
1769 [
self setStatus:STATUS_WITCHSPACE_COUNTDOWN];
1770 [
self playGalacticHyperspace];
1772 [UNIVERSE addMessage:[NSString stringWithFormat:DESC(@"witch-galactic-in-f-seconds"), witchspaceCountdown] forCount:1.0];
1775 [
self doScriptEvent:OOJSID("playerStartedJumpCountdown")
1776 withArguments:[NSArray arrayWithObjects:@"galactic", [NSNumber numberWithFloat:witchspaceCountdown], nil]];
1786#if OO_FOV_INFLIGHT_CONTROL_ENABLED
1790 if (([
self checkKeyPress:n_key_inc_field_of_view] || joyButtonState[BUTTON_INC_FIELD_OF_VIEW]) && (fieldOfView <
MAX_FOV))
1792 fieldOfView *= pow(fov_delta, delta_t);
1796 if (([
self checkKeyPress:n_key_dec_field_of_view] || joyButtonState[BUTTON_DEC_FIELD_OF_VIEW]) && (fieldOfView >
MIN_FOV))
1798 fieldOfView /= pow(fov_delta, delta_t);
1802 NSDictionary *functionForFovAxis = [[stickHandler
axisFunctions] oo_dictionaryForKey:[[NSNumber numberWithInt:AXIS_FIELD_OF_VIEW] stringValue]];
1803 if ([stickHandler joystickCount] != 0 && functionForFovAxis !=
nil)
1806 double reqFov = [stickHandler
getAxisState: AXIS_FIELD_OF_VIEW];
1807 if (fieldOfView < maxFieldOfView * reqFov)
1809 fieldOfView *= pow(fov_delta, delta_t);
1812 if (fieldOfView > maxFieldOfView * reqFov)
1814 fieldOfView /= pow(fov_delta, delta_t);
1822 exceptionContext =
@"dump target state";
1823 if ([
self checkKeyPress:n_key_dump_target_state])
1828 id target = [
self primaryTarget];
1829 if (target ==
nil) target =
self;
1837 exceptionContext =
@"pollGuiScreenControls";
1838 [
self pollGuiScreenControls];
1844 exceptionContext =
@"options menu";
1845 if (([
self checkKeyPress:n_key_gui_screen_options]) && (gui_screen != GUI_SCREEN_OPTIONS) && ![gameView allowingStringInput])
1848 [
self setGuiToLoadSaveScreen];
1851 #if (ALLOW_CUSTOM_VIEWS_WHILE_PAUSED)
1852 [
self pollCustomViewControls];
1855 if (gui_screen == GUI_SCREEN_OPTIONS || gui_screen == GUI_SCREEN_GAMEOPTIONS || gui_screen == GUI_SCREEN_STICKMAPPER ||
1856 gui_screen == GUI_SCREEN_STICKPROFILE || gui_screen == GUI_SCREEN_KEYBOARD || gui_screen == GUI_SCREEN_KEYBOARD_CONFIRMCLEAR ||
1857 gui_screen == GUI_SCREEN_KEYBOARD_CONFIG || gui_screen == GUI_SCREEN_KEYBOARD_ENTRY || gui_screen == GUI_SCREEN_KEYBOARD_LAYOUT)
1859 if ([
UNIVERSE pauseMessageVisible]) [[UNIVERSE messageGUI] leaveLastLine];
1860 else [[UNIVERSE messageGUI] clear];
1861 NSTimeInterval time_this_frame = [NSDate timeIntervalSinceReferenceDate];
1874 script_time += time_delta;
1875 [
self pollGuiArrowKeyControls:time_delta];
1878 exceptionContext =
@"debug keys";
1881 if ([
self checkKeyPress:n_key_dump_entity_list] && ![gameView allowingStringInput])
1885 [UNIVERSE debugDumpEntities];
1887 [UNIVERSE addMessage:@"Entity List dumped. Debugging OFF" forCount:3];
1895 if ([
self checkKeyPress:n_key_debug_full] && ![gameView allowingStringInput])
1898 [UNIVERSE addMessage:@"Full debug ON" forCount:3];
1901 if ([
self checkKeyPress:n_key_debug_collision] && ![gameView allowingStringInput])
1904 [UNIVERSE addMessage:@"Collision debug ON" forCount:3];
1907 if ([
self checkKeyPress:n_key_debug_console_connect] && ![[
OODebugMonitor sharedDebugMonitor] usingPlugInController] && ![gameView allowingStringInput])
1916 [UNIVERSE addMessage:@"Connected to debug console." forCount:3];
1921 [UNIVERSE addMessage:@"Disconnected from debug console." forCount:3];
1929 if ([
self checkKeyPress:n_key_debug_bounding_boxes] && ![gameView allowingStringInput])
1932 [UNIVERSE addMessage:@"Bounding box debug ON" forCount:3];
1935 if ([
self checkKeyPress:n_key_debug_shaders] && ![gameView allowingStringInput])
1938 [UNIVERSE addMessage:@"Shader debug ON" forCount:3];
1941 if (([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_arrow_right]) && gui_screen != GUI_SCREEN_GAMEOPTIONS && [
UNIVERSE displayFPS] && ![gameView allowingStringInput])
1945 float newTimeAccelerationFactor = [
self checkKeyPress:n_key_gui_arrow_left] ?
1948 [UNIVERSE setTimeAccelerationFactor:newTimeAccelerationFactor];
1956 if ([
self checkKeyPress:n_key_debug_off] && ![gameView allowingStringInput])
1959 [UNIVERSE addMessage:@"All debug flags OFF" forCount:3];
1965 exceptionContext =
@"pause";
1967 if (([
self checkKeyPress:n_key_pausebutton] || joyButtonState[
BUTTON_PAUSE]) && gui_screen != GUI_SCREEN_LONG_RANGE_CHART && gui_screen != GUI_SCREEN_MISSION && ![gameView allowingStringInput])
1979 case GUI_SCREEN_STATUS:
1980 [
self setGuiToStatusScreen];
1982 case GUI_SCREEN_LONG_RANGE_CHART:
1983 [
self setGuiToLongRangeChartScreen];
1985 case GUI_SCREEN_SHORT_RANGE_CHART:
1986 [
self setGuiToShortRangeChartScreen];
1988 case GUI_SCREEN_MANIFEST:
1989 [
self setGuiToManifestScreen];
1991 case GUI_SCREEN_MARKET:
1992 [
self setGuiToMarketScreen];
1994 case GUI_SCREEN_MARKETINFO:
1995 [
self setGuiToMarketInfoScreen];
1997 case GUI_SCREEN_SYSTEM_DATA:
1999 if (gui_screen != GUI_SCREEN_SYSTEM_DATA)
2000 [
self setGuiToSystemDataScreen];
2007 [UNIVERSE clearPreviousMessage];
2008 [UNIVERSE setViewDirection:saved_view_direction];
2011 if (
saved_gui_screen == GUI_SCREEN_SYSTEM_DATA) [UNIVERSE setMainLightPosition:_sysInfoLight];
2012 [[UNIVERSE gui] setForegroundTextureKey:@"overlay"];
2013 [[UNIVERSE gameController] setGamePaused:NO];
2021 [UNIVERSE pauseGame];
2031 @catch (NSException *exception)
2033 OOLog(
kOOLogException,
@"***** Exception in pollFlightControls [%@]: %@ : %@", exceptionContext, [exception name], [exception reason]);
2038- (void) pollGuiArrowKeyControls:(
double) delta_t
2043 double cursor_speed = ([gameView
isCtrlDown] ? 20.0 : 10.0)* chart_zoom;
2049 if (gui_screen == GUI_SCREEN_LONG_RANGE_CHART)
2053 else if (gui_screen == GUI_SCREEN_SAVE)
2057 else if (gui_screen == GUI_SCREEN_MISSION && _missionTextEntry)
2061 else if (gui_screen == GUI_SCREEN_KEYBOARD_ENTRY)
2068 else if (gui_screen == GUI_SCREEN_OXZMANAGER && [[
OOOXZManager sharedManager] isAcceptingTextInput])
2078 if (afterburner_engaged && ![
self checkKeyPress:n_key_inject_fuel])
2080 afterburner_engaged = NO;
2087 case GUI_SCREEN_LONG_RANGE_CHART:
2089 if ([
self status] != STATUS_WITCHSPACE_COUNTDOWN)
2091 if ([[gameView typedString] length] > 0)
2093 planetSearchString = [[[gameView
typedString] lowercaseString] retain];
2094 NSPoint search_coords = [UNIVERSE findSystemCoordinatesWithPrefix:planetSearchString];
2095 if ((search_coords.x >= 0.0)&&(search_coords.y >= 0.0))
2098 if ([planetSearchString length] == 1) [[UNIVERSE gui] targetNextFoundSystem:0];
2101 [
self targetNewSystem:0 whileTyping:YES];
2105 found_system_id = -1;
2106 [
self clearPlanetSearchString];
2113 found_system_id = -1;
2114 [UNIVERSE findSystemCoordinatesWithPrefix:@""];
2116 if (planetSearchString) [planetSearchString release];
2117 planetSearchString =
nil;
2124 case GUI_SCREEN_SHORT_RANGE_CHART:
2126 if ([
self checkKeyPress:n_key_chart_highlight])
2131 if (
mode != OOLRC_MODE_TECHLEVEL)
2133 [
self setLongRangeChartMode:mode+1];
2137 [
self setLongRangeChartMode:OOLRC_MODE_SUNCOLOR];
2139 [
self doScriptEvent:OOJSID("chartHighlightModeChanged") withArgument:OOStringFromLongRangeChartMode([
self longRangeChartMode])];
2152 show_info_flag = !show_info_flag;
2161 if ([
self status] != STATUS_WITCHSPACE_COUNTDOWN)
2163 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
2165 if ([
self checkKeyPress:n_key_advanced_nav_array_next] || [
self checkKeyPress:n_key_advanced_nav_array_previous])
2169 if ([
self checkKeyPress:n_key_advanced_nav_array_previous])
2189 [
self setInfoSystemID: target_system_id moveChart: NO];
2208 [
self noteGUIWillChangeTo:GUI_SCREEN_SYSTEM_DATA];
2209 showingLongRangeChart = (gui_screen == GUI_SCREEN_LONG_RANGE_CHART);
2210 [
self setGuiToSystemDataScreen];
2221 NSPoint centre = [
self adjusted_chart_centre];
2224 chart_focus_coordinates.x = OOClamp_0_max_f(centre.x + (maus.x *
MAIN_GUI_PIXEL_WIDTH) / hscale, 256.0);
2225 chart_focus_coordinates.y = OOClamp_0_max_f(centre.y + (maus.y *
MAIN_GUI_PIXEL_HEIGHT + vadjust) / vscale, 256.0);
2226 target_chart_focus = chart_focus_coordinates;
2233 target_chart_centre = chart_centre_coordinates;
2236 if (gui_screen == GUI_SCREEN_LONG_RANGE_CHART)
2246 cursor_coordinates = chart_focus_coordinates;
2255 if ([
self checkKeyPress:n_key_map_home])
2257 if ([gameView isOptDown])
2259 [
self homeInfoSystem];
2260 target_chart_focus = galaxy_coordinates;
2265 cursor_coordinates = galaxy_coordinates;
2266 target_chart_focus = cursor_coordinates;
2267 target_chart_centre = galaxy_coordinates;
2268 found_system_id = -1;
2269 [UNIVERSE findSystemCoordinatesWithPrefix:@""];
2273 if ([
self checkKeyPress:n_key_map_end])
2275 [
self targetInfoSystem];
2276 target_chart_focus = cursor_coordinates;
2278 if ([
self checkKeyPress:n_key_map_zoom_in] || [gameView mouseWheelState] ==
gvMouseWheelDown)
2282 saved_chart_zoom = target_chart_zoom;
2284 if ([
self checkKeyPress:n_key_map_zoom_out] || [gameView mouseWheelState] ==
gvMouseWheelUp)
2286 if (gui_screen == GUI_SCREEN_LONG_RANGE_CHART)
2289 [
self setGuiToShortRangeChartScreen];
2292 if (target_chart_zoom < 1.0) target_chart_zoom = 1.0;
2293 saved_chart_zoom = target_chart_zoom;
2295 target_chart_focus = target_chart_centre;
2299 BOOL nextSystemOnRoute = [gameView
isOptDown];
2301 if ([
self checkNavKeyPress:n_key_gui_arrow_left])
2303 if ((nextSystem || nextSystemOnRoute) &&
pressedArrow != 1)
2307 [
self targetNewSystem:-1];
2308 target_chart_focus = cursor_coordinates;
2312 [
self clearPlanetSearchString];
2313 [
self previousInfoSystem];
2314 target_chart_focus = [[UNIVERSE systemManager] getCoordinatesForSystem:info_system_id inGalaxy:galaxy_number];
2318 else if (!nextSystem && !nextSystemOnRoute)
2321 cursor_coordinates.x -= cursor_speed*delta_t;
2322 if (cursor_coordinates.x < 0.0) cursor_coordinates.x = 0.0;
2324 target_chart_focus = cursor_coordinates;
2330 if ([
self checkNavKeyPress:n_key_gui_arrow_right])
2332 if ((nextSystem || nextSystemOnRoute) &&
pressedArrow != 2)
2336 [
self targetNewSystem:+1];
2337 target_chart_focus = cursor_coordinates;
2341 [
self clearPlanetSearchString];
2342 [
self nextInfoSystem];
2343 target_chart_focus = [[UNIVERSE systemManager] getCoordinatesForSystem:info_system_id inGalaxy:galaxy_number];
2347 else if (!nextSystem && !nextSystemOnRoute)
2350 cursor_coordinates.x += cursor_speed*delta_t;
2351 if (cursor_coordinates.x > 256.0) cursor_coordinates.x = 256.0;
2353 target_chart_focus = cursor_coordinates;
2359 if ([
self checkNavKeyPress:n_key_gui_arrow_down])
2363 [
self targetNewSystem:+1];
2366 else if (!nextSystem)
2369 cursor_coordinates.y += cursor_speed*delta_t*2.0;
2370 if (cursor_coordinates.y > 256.0) cursor_coordinates.y = 256.0;
2373 target_chart_focus = cursor_coordinates;
2378 if ([
self checkNavKeyPress:n_key_gui_arrow_up])
2382 [
self targetNewSystem:-1];
2385 else if (!nextSystem)
2388 cursor_coordinates.y -= cursor_speed*delta_t*2.0;
2389 if (cursor_coordinates.y < 0.0) cursor_coordinates.y = 0.0;
2392 target_chart_focus = cursor_coordinates;
2398 if (found_system_id == -1)
2400 target_system_id = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxy:galaxy_number includingHidden:NO];
2401 [
self setInfoSystemID: target_system_id moveChart: YES];
2406 NSPoint fpos = [[UNIVERSE systemManager] getCoordinatesForSystem:found_system_id inGalaxy:galaxy_number];
2407 if (fpos.x != cursor_coordinates.x && fpos.y != cursor_coordinates.y)
2409 target_system_id = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxy:galaxy_number includingHidden:NO];
2410 [
self setInfoSystemID: target_system_id moveChart: YES];
2413 cursor_coordinates = [[UNIVERSE systemManager] getCoordinatesForSystem:target_system_id inGalaxy:galaxy_number];
2415 if (chart_focus_coordinates.x - target_chart_centre.x <= -
CHART_SCROLL_AT_X*chart_zoom)
2417 target_chart_centre.x = chart_focus_coordinates.x +
CHART_SCROLL_AT_X*chart_zoom;
2419 else if (chart_focus_coordinates.x - target_chart_centre.x >=
CHART_SCROLL_AT_X*chart_zoom)
2421 target_chart_centre.x = chart_focus_coordinates.x -
CHART_SCROLL_AT_X*chart_zoom;
2423 if (chart_focus_coordinates.y - target_chart_centre.y <= -
CHART_SCROLL_AT_Y*chart_zoom)
2425 target_chart_centre.y = chart_focus_coordinates.y +
CHART_SCROLL_AT_Y*chart_zoom;
2427 else if (chart_focus_coordinates.y - target_chart_centre.y >=
CHART_SCROLL_AT_Y*chart_zoom)
2429 target_chart_centre.y = chart_focus_coordinates.y -
CHART_SCROLL_AT_Y*chart_zoom;
2431 chart_centre_coordinates.x = (3.0*chart_centre_coordinates.x + target_chart_centre.
x)/4.0;
2432 chart_centre_coordinates.y = (3.0*chart_centre_coordinates.y + target_chart_centre.
y)/4.0;
2433 chart_zoom = (3.0*chart_zoom + target_chart_zoom)/4.0;
2434 chart_focus_coordinates.x = (3.0*chart_focus_coordinates.x + target_chart_focus.
x)/4.0;
2435 chart_focus_coordinates.y = (3.0*chart_focus_coordinates.y + target_chart_focus.
y)/4.0;
2436 if (
cursor_moving || dragging) [
self setGuiToChartScreenFrom: gui_screen];
2441 case GUI_SCREEN_SYSTEM_DATA:
2442 if ([
self checkKeyPress:n_key_system_next_system])
2446 [
self nextInfoSystem];
2454 if ([
self checkKeyPress:n_key_system_previous_system])
2458 [
self previousInfoSystem];
2466 if ([
self checkKeyPress:n_key_system_home])
2470 [
self homeInfoSystem];
2478 if ([
self checkKeyPress:n_key_system_end])
2482 [
self targetInfoSystem];
2492#if OO_USE_CUSTOM_LOAD_SAVE
2494 case GUI_SCREEN_LOAD:
2496 NSString *commanderFile = [
self commanderSelector];
2503 [
self loadPlayerFromFile:commanderFile asNew:NO];
2508 case GUI_SCREEN_SAVE:
2509 [
self pollGuiScreenControlsWithFKeyAlias:NO];
2513 if (gui_screen == GUI_SCREEN_SAVE)
2515 [
self saveCommanderInputHandler];
2517 else pollControls = YES;
2520 case GUI_SCREEN_SAVE_OVERWRITE:
2521 [
self overwriteCommanderInputHandler];
2525 case GUI_SCREEN_STICKMAPPER:
2526 [
self handleStickMapperScreenKeys];
2529 case GUI_SCREEN_STICKPROFILE:
2530 [
self stickProfileInputHandler: gui view: gameView];
2533 case GUI_SCREEN_GAMEOPTIONS:
2534 [
self handleGameOptionsScreenKeys];
2537 case GUI_SCREEN_KEYBOARD:
2538 [
self handleKeyMapperScreenKeys];
2545 case GUI_SCREEN_KEYBOARD_CONFIRMCLEAR:
2546 [
self handleKeyMapperConfirmClearKeys:gui view:gameView];
2549 case GUI_SCREEN_KEYBOARD_CONFIG:
2550 [
self handleKeyConfigKeys:gui view:gameView];
2553 case GUI_SCREEN_KEYBOARD_ENTRY:
2554 [
self handleKeyConfigEntryKeys:gui view:gameView];
2557 case GUI_SCREEN_KEYBOARD_LAYOUT:
2558 [
self handleKeyboardLayoutKeys];
2561 case GUI_SCREEN_SHIPLIBRARY:
2562 if ([gameView isDown:
' '])
2565 [
self setGuiToInterfacesScreen:0];
2567 if ([
self checkKeyPress:n_key_gui_arrow_up])
2570 [UNIVERSE selectIntro2Previous];
2572 if ([
self checkKeyPress:n_key_gui_arrow_down])
2575 [UNIVERSE selectIntro2Next];
2577 upDownKeyPressed = (([
self checkKeyPress:n_key_gui_arrow_up])||([
self checkKeyPress:n_key_gui_arrow_down]));
2579 if ([
self checkKeyPress:n_key_gui_arrow_left])
2582 [UNIVERSE selectIntro2PreviousCategory];
2584 if ([
self checkKeyPress:n_key_gui_arrow_right])
2587 [UNIVERSE selectIntro2NextCategory];
2589 leftRightKeyPressed = (([
self checkKeyPress:n_key_gui_arrow_left])||([
self checkKeyPress:n_key_gui_arrow_right]));
2592 case GUI_SCREEN_OPTIONS:
2593 [
self handleGUIUpDownArrowKeys];
2595 BOOL selectKeyPress = ([
self checkKeyPress:n_key_gui_select]||[gameView
isDown:gvMouseDoubleClick]);
2604 [
self quicksavePlayer];
2606 @catch (NSException *exception)
2608 OOLog(
kOOLogException,
@"\n\n***** Handling exception: %@ : %@ *****\n\n",[exception name], [exception reason]);
2609 if ([[exception name] isEqual:
@"GameNotSavedException"])
2612 if ([controller inFullScreenMode])
2631 if (![
self loadPlayer])
2634 [
self setGuiToStatusScreen];
2642 [UNIVERSE setUseAddOns:SCENARIO_OXP_DEFINITION_ALL fromSaveGame:NO forceReinit:YES];
2657 if ((guiSelectedRow ==
GUI_ROW(,QUIT)) && selectKeyPress)
2659 [[UNIVERSE gameController] exitAppWithContext:@"Exit Game selected on options screen"];
2663 if ((guiSelectedRow ==
GUI_ROW(,GAMEOPTIONS)) && selectKeyPress)
2666 [
self setGuiToGameOptionsScreen];
2671 case GUI_SCREEN_EQUIP_SHIP:
2672 if ([
self handleGUIUpDownArrowKeys])
2682 if (weaponType !=
nil)
2686 if ([[weaponType identifier] isEqualToString:
@"EQ_WEAPON_NONE"]) itemText =
DESC(
@"no-weapon-enter-to-install");
2690 if (sameAs) itemText = [NSString stringWithFormat:DESC(@"weapon-installed-@"), weaponName];
2691 else itemText = [NSString stringWithFormat:DESC(@"weapon-@-enter-to-replace"), weaponName];
2694 [
self showInformationForSelectedUpgradeWithFormatString:itemText];
2697 [
self showInformationForSelectedUpgrade];
2700 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
2706 [
self playMenuPagePrevious];
2708 [
self buySelectedItem];
2713 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
2719 [
self playMenuPageNext];
2720 [gui
setSelectedRow:GUI_ROW_EQUIPMENT_START + GUI_MAX_ROWS_EQUIPMENT - 1];
2721 [
self buySelectedItem];
2726 leftRightKeyPressed = [
self checkKeyPress:n_key_gui_arrow_right]|[
self checkKeyPress:n_key_gui_arrow_left]|[
self checkKeyPress:n_key_gui_page_down]|[
self checkKeyPress:n_key_gui_page_up];
2737 [
self buySelectedItem];
2747 case GUI_SCREEN_INTERFACES:
2748 if ([
self handleGUIUpDownArrowKeys])
2750 [
self showInformationForSelectedInterface];
2752 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
2758 [
self playMenuPagePrevious];
2760 [
self activateSelectedInterface];
2765 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
2771 [
self playMenuPageNext];
2772 [gui
setSelectedRow:GUI_ROW_INTERFACES_START + GUI_MAX_ROWS_INTERFACES - 1];
2773 [
self activateSelectedInterface];
2778 leftRightKeyPressed = [
self checkKeyPress:n_key_gui_arrow_right]|[
self checkKeyPress:n_key_gui_arrow_left]|[
self checkKeyPress:n_key_gui_page_down]|[
self checkKeyPress:n_key_gui_page_up];
2788 [
self activateSelectedInterface];
2799 case GUI_SCREEN_MARKETINFO:
2800 [
self pollMarketScreenControls];
2803 case GUI_SCREEN_MARKET:
2804 [
self pollMarketScreenControls];
2806 if ([
self checkKeyPress:n_key_market_filter_cycle] || [
self checkKeyPress:n_key_market_sorter_cycle])
2811 if ([
self checkKeyPress:n_key_market_filter_cycle])
2833 [
self playChangedOption];
2834 [
self setGuiToMarketScreen];
2844 case GUI_SCREEN_REPORT:
2845 if ([gameView isDown:32])
2849 BOOL reportEnded = ([dockingReport length] == 0);
2850 [
self playDismissedReportScreen];
2853 [
self setGuiToStatusScreen];
2854 [
self doScriptEvent:OOJSID("reportScreenEnded")];
2855 [
self doWorldEventUntilMissionScreen:OOJSID("missionScreenOpportunity")];
2859 [
self setGuiToDockingReportScreen];
2868 case GUI_SCREEN_STATUS:
2869 [
self handleGUIUpDownArrowKeys];
2870 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
2878 [
self playMenuPagePrevious];
2880 [
self setGuiToStatusScreen];
2885 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
2894 [
self playMenuPageNext];
2896 [
self setGuiToStatusScreen];
2901 leftRightKeyPressed = [
self checkKeyPress:n_key_gui_arrow_right]|[
self checkKeyPress:n_key_gui_arrow_left]|[
self checkKeyPress:n_key_gui_page_down]|[
self checkKeyPress:n_key_gui_page_up];
2913 [
self setGuiToStatusScreen];
2924 case GUI_SCREEN_MANIFEST:
2925 [
self handleGUIUpDownArrowKeys];
2926 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
2934 [
self playMenuPagePrevious];
2936 [
self setGuiToManifestScreen];
2941 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
2944 if ([[
self hud] isHidden] || [[
self hud] allowBigGui])
2950 if ([[gui keyForRow:nextRow] isEqual:
GUI_KEY_OK])
2953 [
self playMenuPageNext];
2955 [
self setGuiToManifestScreen];
2960 leftRightKeyPressed = [
self checkKeyPress:n_key_gui_arrow_right]|[
self checkKeyPress:n_key_gui_arrow_left]|[
self checkKeyPress:n_key_gui_page_down]|[
self checkKeyPress:n_key_gui_page_up];
2972 [
self setGuiToManifestScreen];
2984 case GUI_SCREEN_SHIPYARD:
2985 if ([
self handleGUIUpDownArrowKeys])
2987 [
self showShipyardInfoForSelection];
2990 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
2996 [
self playMenuPagePrevious];
2998 [
self buySelectedShip];
3003 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
3009 [
self playMenuPageNext];
3010 [gui
setSelectedRow:GUI_ROW_SHIPYARD_START + MAX_ROWS_SHIPS_FOR_SALE - 1];
3011 [
self buySelectedShip];
3016 leftRightKeyPressed = [
self checkKeyPress:n_key_gui_arrow_right]|[
self checkKeyPress:n_key_gui_arrow_left]|[
self checkKeyPress:n_key_gui_page_down]|[
self checkKeyPress:n_key_gui_page_up];
3018 if ([
self checkKeyPress:n_key_gui_select])
3025 if (![key hasPrefix:
@"More:"])
3027 shipprice = [
self priceForShipKey:key];
3030 if ([
self buySelectedShip])
3032 if (![key hasPrefix:
@"More:"])
3034 [UNIVERSE removeDemoShips];
3035 [
self setGuiToStatusScreen];
3037 [
self doScriptEvent:OOJSID("playerBoughtNewShip") withArgument:self andArgument:[NSNumber numberWithUnsignedLongLong:shipprice]];
3042 [
self playCantBuyShip];
3055 [
self playMenuPageNext];
3056 [gui
setSelectedRow:GUI_ROW_SHIPYARD_START + MAX_ROWS_SHIPS_FOR_SALE - 1];
3057 [
self buySelectedShip];
3061 [
self playMenuPagePrevious];
3063 [
self buySelectedShip];
3075 NSArray *keys = [extraGuiScreenKeys objectForKey:[NSString stringWithFormat:@"%d", gui_screen]];
3077 NSInteger kc = [keys count];
3079 NSDictionary *keydefs =
nil;
3080 NSString *key =
nil;
3082 definition = [keys objectAtIndex:kc];
3084 foreach (key, [keydefs allKeys])
3086 if ([
self checkKeyPress:[keydefs objectForKey:key]])
3093 [[UNIVERSE gameView] clearKeys];
3098 OOLog(
@"interface.missingCallback",
@"Unable to find callback definition for %@ using key %@", [definition name], key);
3110 if (flightRoll > 0.0)
3112 if (flightRoll > delta_t) [
self decrease_flight_roll:delta_t];
3113 else flightRoll = 0.0;
3115 if (flightRoll < 0.0)
3117 if (flightRoll < -delta_t) [
self increase_flight_roll:delta_t];
3118 else flightRoll = 0.0;
3120 if (flightPitch > 0.0)
3122 if (flightPitch > delta_t) [
self decrease_flight_pitch:delta_t];
3123 else flightPitch = 0.0;
3125 if (flightPitch < 0.0)
3127 if (flightPitch < -delta_t) [
self increase_flight_pitch:delta_t];
3128 else flightPitch = 0.0;
3130 if (flightYaw > 0.0)
3132 if (flightYaw > delta_t) [
self decrease_flight_yaw:delta_t];
3133 else flightYaw = 0.0;
3135 if (flightYaw < 0.0)
3137 if (flightYaw < -delta_t) [
self increase_flight_yaw:delta_t];
3138 else flightYaw = 0.0;
3148 if (gui_screen == GUI_SCREEN_MARKET)
3150 [
self handleGUIUpDownArrowKeys];
3151 DESTROY(marketSelectedCommodity);
3154 BOOL page_up = [
self checkKeyPress:n_key_gui_page_up];
3155 BOOL page_down = [
self checkKeyPress:n_key_gui_page_down];
3156 if (page_up || page_down)
3161 NSArray *goods = [
self applyMarketSorter:[
self applyMarketFilter:[localMarket
goods] onMarket:localMarket] onMarket:localMarket];
3162 if ([goods
count] > 0)
3164 NSInteger goodsIndex = [goods indexOfObject:marketSelectedCommodity];
3165 NSInteger offset1 = 0;
3166 NSInteger offset2 = 0;
3171 [
self playMenuPagePrevious];
3173 if (goodsIndex - 16 <= 0)
3178 if (offset1 == 1 && offset2 == 0 && goodsIndex < (NSInteger)[goods
count] - 1 && goodsIndex - 15 > 0) offset2 = 1;
3179 goodsIndex -= (16 - (offset1 + offset2));
3180 if (goodsIndex < 0) goodsIndex = 0;
3181 if ([goods
count] <= 17) goodsIndex = 0;
3185 [
self playMenuPageNext];
3187 if (offset1 == 0 && offset2 == 1 && goodsIndex > 1) offset1 = 1;
3188 if (offset2 == 1 && goodsIndex + 15 == (NSInteger)[goods
count] - 1) offset2 = 0;
3189 goodsIndex += (16 - (offset1 + offset2));
3190 if (goodsIndex > ((NSInteger)[goods
count] - 1) || [goods
count] <= 17) goodsIndex = (NSInteger)[goods
count] - 1;
3192 DESTROY(marketSelectedCommodity);
3193 marketSelectedCommodity = [[goods oo_stringAtIndex:goodsIndex] retain];
3194 [
self setGuiToMarketScreen];
3207 BOOL arrow_up = [
self checkKeyPress:n_key_gui_arrow_up];
3208 BOOL arrow_down = [
self checkKeyPress:n_key_gui_arrow_down];
3209 if (arrow_up || arrow_down)
3214 NSArray *goods = [
self applyMarketSorter:[
self applyMarketFilter:[localMarket
goods] onMarket:localMarket] onMarket:localMarket];
3215 if ([goods
count] > 0)
3217 NSInteger goodsIndex = [goods indexOfObject:marketSelectedCommodity];
3228 goodsIndex = [goods count]-1;
3230 else if (goodsIndex >= (NSInteger)[goods
count])
3234 DESTROY(marketSelectedCommodity);
3235 marketSelectedCommodity = [[goods oo_stringAtIndex:goodsIndex] retain];
3236 [
self setGuiToMarketInfoScreen];
3248 BOOL isdocked = [
self isDocked];
3250 if (([
self checkNavKeyPress:n_key_gui_arrow_right])||([
self checkNavKeyPress:n_key_gui_arrow_left])||([
self checkKeyPress:n_key_gui_select]||[gameView isDown:
gvMouseDoubleClick]))
3252 if ([
self checkNavKeyPress:n_key_gui_arrow_right])
3256 if (isdocked && [
self tryBuyingCommodity:marketSelectedCommodity all:[gameView isShiftDown]])
3258 [
self playBuyCommodity];
3259 if (gui_screen == GUI_SCREEN_MARKET)
3261 [
self setGuiToMarketScreen];
3265 [
self setGuiToMarketInfoScreen];
3270 if ([[gui selectedRowKey] isEqualToString:
@">>>"])
3272 [
self playMenuNavigationDown];
3273 [
self setGuiToMarketScreen];
3275 else if ([[gui selectedRowKey] isEqualToString:
@"<<<"])
3277 [
self playMenuNavigationUp];
3278 [
self setGuiToMarketScreen];
3282 [
self playCantBuyCommodity];
3288 if ([
self checkNavKeyPress:n_key_gui_arrow_left])
3292 if (isdocked && [
self trySellingCommodity:marketSelectedCommodity all:[gameView isShiftDown]])
3294 [
self playSellCommodity];
3295 if (gui_screen == GUI_SCREEN_MARKET)
3297 [
self setGuiToMarketScreen];
3301 [
self setGuiToMarketInfoScreen];
3306 if ([[gui selectedRowKey] isEqualToString:
@">>>"])
3308 [
self playMenuNavigationDown];
3309 [
self setGuiToMarketScreen];
3311 else if ([[gui selectedRowKey] isEqualToString:
@"<<<"])
3313 [
self playMenuNavigationUp];
3314 [
self setGuiToMarketScreen];
3318 [
self playCantSellCommodity];
3325 if ((gui_screen == GUI_SCREEN_MARKET && [gameView isDown:
gvMouseDoubleClick]) || [
self checkKeyPress:n_key_gui_select])
3336 if ([item isEqualToString:
@">>>"])
3338 [
self tryBuyingCommodity:item all:YES];
3339 [
self setGuiToMarketScreen];
3341 else if ([item isEqualToString:
@"<<<"])
3343 [
self trySellingCommodity:item all:YES];
3344 [
self setGuiToMarketScreen];
3346 else if (isdocked && [gameView isShiftDown] && [
self tryBuyingCommodity:item all:YES])
3348 [
self playBuyCommodity];
3349 if (gui_screen == GUI_SCREEN_MARKET)
3351 [
self setGuiToMarketScreen];
3355 [
self setGuiToMarketInfoScreen];
3358 else if (isdocked && (yours > 0) && [
self trySellingCommodity:item all:YES])
3360 [
self playSellCommodity];
3361 if (gui_screen == GUI_SCREEN_MARKET)
3363 [
self setGuiToMarketScreen];
3367 [
self setGuiToMarketInfoScreen];
3370 else if (isdocked && [
self tryBuyingCommodity:item all:YES])
3372 [
self playBuyCommodity];
3373 if (gui_screen == GUI_SCREEN_MARKET)
3375 [
self setGuiToMarketScreen];
3379 [
self setGuiToMarketInfoScreen];
3384 [
self playCantBuyCommodity];
3406 [
self handleGUIUpDownArrowKeys];
3408 BOOL selectKeyPress = ([
self checkKeyPress:n_key_gui_select]||[gameView
isDown:gvMouseDoubleClick]);
3411 if ((guiSelectedRow ==
GUI_ROW(GAME,STICKMAPPER)) && selectKeyPress)
3414 [
self resetStickFunctions];
3415 [
self setGuiToStickMapperScreen: 0 resetCurrentRow: YES];
3417 if ((guiSelectedRow ==
GUI_ROW(GAME,KEYMAPPER)) && selectKeyPress)
3420 [
self resetKeyFunctions];
3421 [
self setGuiToKeyMapperScreen: 0 resetCurrentRow: YES];
3426 if ([gameView hdrOutput])
3428 if ((guiSelectedRow ==
GUI_ROW(GAME,HDRMAXBRIGHTNESS))&&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3432 int direction = ([
self checkKeyPress:n_key_gui_arrow_right]) ? 1 : -1;
3433 NSArray *brightnesses = [[UNIVERSE descriptions] oo_arrayForKey: @"hdr_maxBrightness_array"];
3434 int brightnessIdx = [brightnesses indexOfObject:[NSString stringWithFormat:@"%d", (int)[gameView hdrMaxBrightness]]];
3436 if (brightnessIdx == NSNotFound)
3438 OOLogWARN(
@"hdr.maxBrightness.notFound",
@"%@",
@"couldn't find current max brightness setting, switching to lowest.");
3442 brightnessIdx += direction;
3443 int count = [brightnesses count];
3444 if (brightnessIdx < 0)
3445 brightnessIdx =
count - 1;
3446 if (brightnessIdx >=
count)
3449 int brightnessValue = [brightnesses oo_intAtIndex:brightnessIdx];
3456 [gameView setHDRMaxBrightness:(float)brightnessValue];
3457 NSString *maxBrightnessString =
OOExpandKey(
@"gameoptions-hdr-maxbrightness", brightnessValue);
3459 [gui
setText:maxBrightnessString
forRow:GUI_ROW(GAME,HDRMAXBRIGHTNESS)
align:GUI_ALIGN_CENTER];
3470#if OO_RESOLUTION_OPTION
3472 guiSelectedRow ==
GUI_ROW(GAME,DISPLAY) &&
3473 ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_arrow_left]))
3476 int direction = ([
self checkKeyPress:n_key_gui_arrow_right]) ? 1 : -1;
3480 if (displayModeIndex == (NSInteger)NSNotFound)
3482 OOLogWARN(
@"graphics.mode.notFound",
@"%@",
@"couldn't find current fullscreen setting, switching to default.");
3483 displayModeIndex = 0;
3486 displayModeIndex = displayModeIndex + direction;
3487 int count = [modes count];
3488 if (displayModeIndex < 0)
3489 displayModeIndex =
count - 1;
3490 if (displayModeIndex >=
count)
3491 displayModeIndex = 0;
3493 NSDictionary *
mode = [modes objectAtIndex:displayModeIndex];
3494 int modeWidth = [mode oo_intForKey:kOODisplayWidth];
3495 int modeHeight = [mode oo_intForKey:kOODisplayHeight];
3496 int modeRefresh = [mode oo_intForKey:kOODisplayRefreshRate];
3499 NSString *displayModeString = [
self screenModeStringForWidth:modeWidth height:modeHeight refreshRate:modeRefresh];
3501 [
self playChangedOption];
3512 if (
switching_resolution && ![
self checkKeyPress:n_key_gui_arrow_right] && ![
self checkKeyPress:n_key_gui_arrow_left] && !selectKeyPress)
3518#if OOLITE_SPEECH_SYNTH
3520 if ((guiSelectedRow ==
GUI_ROW(GAME,SPEECH))&&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3527 [
self playChangedOption];
3534 [
self playChangedOption];
3538 NSString *message =
nil;
3542 message =
DESC(
@"gameoptions-spoken-messages-no");
3545 message =
DESC(
@"gameoptions-spoken-messages-comms");
3548 message =
DESC(
@"gameoptions-spoken-messages-yes");
3555 [UNIVERSE stopSpeaking];
3556 [UNIVERSE startSpeakingString:message];
3566 if (guiSelectedRow ==
GUI_ROW(GAME,SPEECH_LANGUAGE))
3568 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_arrow_left])
3572 [
self playChangedOption];
3573 if ([
self checkKeyPress:n_key_gui_arrow_right])
3574 voice_no = [UNIVERSE nextVoice: voice_no];
3576 voice_no = [UNIVERSE prevVoice: voice_no];
3577 [UNIVERSE setVoice: voice_no withGenderM:voice_gender_m];
3578 NSString *voiceName = [UNIVERSE voiceName:voice_no];
3579 NSString *message =
OOExpandKey(
@"gameoptions-voice-name", voiceName);
3583 [UNIVERSE stopSpeaking];
3584 [UNIVERSE startSpeakingString:[UNIVERSE voiceName: voice_no]];
3588 speechVoiceSelectKeyPressed = YES;
3591 speechVoiceSelectKeyPressed = NO;
3594 if (guiSelectedRow ==
GUI_ROW(GAME,SPEECH_GENDER))
3596 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_arrow_left])
3598 if (!speechGenderSelectKeyPressed)
3600 [
self playChangedOption];
3601 BOOL m = [
self checkKeyPress:n_key_gui_arrow_right];
3602 if (m != voice_gender_m)
3605 [UNIVERSE setVoice:voice_no withGenderM:voice_gender_m];
3606 NSString *message = [NSString stringWithFormat:DESC(voice_gender_m ? @"gameoptions-voice-M" : @"gameoptions-voice-F")];
3610 [UNIVERSE stopSpeaking];
3611 [UNIVERSE startSpeakingString:[UNIVERSE voiceName: voice_no]];
3615 speechGenderSelectKeyPressed = YES;
3618 speechGenderSelectKeyPressed = NO;
3623 if ((guiSelectedRow ==
GUI_ROW(GAME,MUSIC))&&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3628 int initialMode = [musicController
mode];
3629 int mode = initialMode;
3631 if ([
self checkKeyPress:n_key_gui_arrow_right])
mode++;
3632 if ([
self checkKeyPress:n_key_gui_arrow_left])
mode--;
3634 [musicController
setMode:MAX(mode, 0)];
3636 if ((
int)[musicController
mode] != initialMode)
3638 [
self playChangedOption];
3640 NSString *message =
OOExpandKey(
@"gameoptions-music-mode", musicMode);
3648 if ((guiSelectedRow ==
GUI_ROW(GAME,AUTOSAVE))&&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3650 if ([
self checkKeyPress:n_key_gui_arrow_right] != [
UNIVERSE autoSave])
3651 [
self playChangedOption];
3652 [UNIVERSE setAutoSave:[
self checkKeyPress:n_key_gui_arrow_right]];
3656 [UNIVERSE setAutoSaveNow:YES];
3657 [gui
setText:DESC(@"gameoptions-autosave-yes")
forRow:GUI_ROW(GAME,AUTOSAVE)
align:GUI_ALIGN_CENTER];
3661 [UNIVERSE setAutoSaveNow:NO];
3662 [gui
setText:DESC(@"gameoptions-autosave-no")
forRow:GUI_ROW(GAME,AUTOSAVE)
align:GUI_ALIGN_CENTER];
3666 if ((guiSelectedRow ==
GUI_ROW(GAME,VOLUME))
3667 &&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left]))
3668 &&[
OOSound respondsToSelector:
@selector(masterVolume)])
3672 BOOL rightKeyDown = [
self checkKeyPress:n_key_gui_arrow_right];
3673 BOOL leftKeyDown = [
self checkKeyPress:n_key_gui_arrow_left];
3675 int vol = (volume / 5.0 + 0.5);
3676 if (rightKeyDown) vol++;
3677 if (leftKeyDown) vol--;
3680 [
self playChangedOption];
3682 espeak_SetParameter(espeakVOLUME, vol * 5, 0);
3686 NSString* soundVolumeWordDesc =
DESC(
@"gameoptions-sound-volume");
3687 NSString* v1_string =
@"|||||||||||||||||||||||||";
3688 NSString* v0_string =
@".........................";
3689 v1_string = [v1_string substringToIndex:vol];
3690 v0_string = [v0_string substringToIndex:20 - vol];
3691 [gui
setText:[NSString stringWithFormat:@"%@%@%@ ", soundVolumeWordDesc, v1_string, v0_string]
3692 forRow:GUI_ROW(GAME,VOLUME)
3693 align:GUI_ALIGN_CENTER];
3696 [gui
setText:DESC(@"gameoptions-sound-volume-mute")
forRow:GUI_ROW(GAME,VOLUME)
align:GUI_ALIGN_CENTER];
3705 if ((guiSelectedRow ==
GUI_ROW(GAME,GAMMA))
3706 &&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3708 if (!gammaControlPressed)
3710 BOOL rightKeyDown = [
self checkKeyPress:n_key_gui_arrow_right];
3711 BOOL leftKeyDown = [
self checkKeyPress:n_key_gui_arrow_left];
3713 gamma += (((rightKeyDown && (gamma < 4.0f)) ? 0.2f : 0.0f) - ((leftKeyDown && (gamma > 0.2f)) ? 0.2f : 0.0f));
3714 if (gamma > 3.95f) gamma = 4.0f;
3715 if (gamma < 0.25f) gamma = 0.2f;
3717 int gamma5 = gamma * 5;
3718 NSString* gammaWordDesc =
DESC(
@"gameoptions-gamma-value");
3719 NSString* v1_string =
@"|||||||||||||||||||||||||";
3720 NSString* v0_string =
@".........................";
3721 v1_string = [v1_string substringToIndex:gamma5];
3722 v0_string = [v0_string substringToIndex:20 - gamma5];
3723 [gui
setText:[NSString stringWithFormat:@"%@%@%@ (%.1f) ", gammaWordDesc, v1_string, v0_string, gamma]
forRow:GUI_ROW(GAME,GAMMA)
align:GUI_ALIGN_CENTER];
3725 gammaControlPressed = YES;
3728 gammaControlPressed = NO;
3732 if ((guiSelectedRow ==
GUI_ROW(GAME,FOV))
3733 &&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3737 BOOL rightKeyDown = [
self checkKeyPress:n_key_gui_arrow_right];
3738 BOOL leftKeyDown = [
self checkKeyPress:n_key_gui_arrow_left];
3739 float fov = [gameView
fov:NO];
3742 fovStep : 0.0f) - ((leftKeyDown && (fov >
MIN_FOV_DEG)) ? fovStep : 0.0f));
3746 fieldOfView = [gameView
fov:YES];
3748 NSString* fovWordDesc =
DESC(
@"gameoptions-fov-value");
3749 NSString* v1_string =
@"|||||||||||||||||||||||||";
3750 NSString* v0_string =
@".........................";
3751 v1_string = [v1_string substringToIndex:fovTicks];
3752 v0_string = [v0_string substringToIndex:20 - fovTicks];
3753 [gui
setText:[NSString stringWithFormat:@"%@%@%@ (%d%c) ", fovWordDesc, v1_string, v0_string, (int)fov, 176 ]
forRow:GUI_ROW(GAME,FOV)
align:GUI_ALIGN_CENTER];
3754 [[NSUserDefaults standardUserDefaults] setFloat:[gameView
fov:NO] forKey:@"fov-value"];
3764 if ((guiSelectedRow ==
GUI_ROW(GAME,COLORBLINDMODE))&&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3768 int colorblindMode = [UNIVERSE colorblindMode];
3769 if ([
self checkKeyPress:n_key_gui_arrow_right])
3771 [UNIVERSE setCurrentPostFX:[UNIVERSE nextColorblindMode:colorblindMode]];
3775 [UNIVERSE setCurrentPostFX:[UNIVERSE prevColorblindMode:colorblindMode]];
3777 colorblindMode = [UNIVERSE colorblindMode];
3778 NSString *colorblindModeDesc = [[[UNIVERSE descriptions] oo_arrayForKey: @"colorblind_mode"] oo_stringAtIndex:[UNIVERSE useShaders] ? colorblindMode : 0];
3779 NSString *colorblindModeMsg =
OOExpandKey(
@"gameoptions-colorblind-mode", colorblindModeDesc);
3780 [gui
setText:colorblindModeMsg
forRow:GUI_ROW(GAME,COLORBLINDMODE)
align:GUI_ALIGN_CENTER];
3788 if (![gameView hdrOutput])
3790 if ((guiSelectedRow ==
GUI_ROW(GAME,WIREFRAMEGRAPHICS))&&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3792 if ([
self checkKeyPress:n_key_gui_arrow_right] != [
UNIVERSE wireframeGraphics])
3793 [
self playChangedOption];
3794 [UNIVERSE setWireframeGraphics:[
self checkKeyPress:n_key_gui_arrow_right]];
3796 [gui
setText:DESC(@"gameoptions-wireframe-graphics-yes")
forRow:GUI_ROW(GAME,WIREFRAMEGRAPHICS)
align:GUI_ALIGN_CENTER];
3798 [gui
setText:DESC(@"gameoptions-wireframe-graphics-no")
forRow:GUI_ROW(GAME,WIREFRAMEGRAPHICS)
align:GUI_ALIGN_CENTER];
3804 if ((guiSelectedRow ==
GUI_ROW(GAME,HDRPAPERWHITE))
3805 &&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3809 BOOL rightKeyDown = [
self checkKeyPress:n_key_gui_arrow_right];
3810 BOOL leftKeyDown = [
self checkKeyPress:n_key_gui_arrow_left];
3811 float paperWhite = [gameView hdrPaperWhiteBrightness];
3815 [gameView setHDRPaperWhiteBrightness:paperWhite];
3817 NSString* paperWhiteWordDesc =
DESC(
@"gameoptions-hdr-paperwhite");
3818 NSString* v1_string =
@"|||||||||||||||||||||||||";
3819 NSString* v0_string =
@".........................";
3820 v1_string = [v1_string substringToIndex:paperWhiteNorm];
3821 v0_string = [v0_string substringToIndex:20 - paperWhiteNorm];
3822 [gui
setText:[NSString stringWithFormat:@"%@%@%@ (%d) ", paperWhiteWordDesc, v1_string, v0_string, (int)paperWhite]
forRow:GUI_ROW(GAME,HDRPAPERWHITE)
align:GUI_ALIGN_CENTER];
3832 if ((guiSelectedRow ==
GUI_ROW(GAME,PROCEDURALLYTEXTUREDPLANETS))&&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3834 if ([
self checkKeyPress:n_key_gui_arrow_right] != [
UNIVERSE doProcedurallyTexturedPlanets])
3836 [UNIVERSE setDoProcedurallyTexturedPlanets:[
self checkKeyPress:n_key_gui_arrow_right]];
3837 [
self playChangedOption];
3840 [UNIVERSE setUpPlanet];
3843 if ([
UNIVERSE doProcedurallyTexturedPlanets])
3844 [gui
setText:DESC(@"gameoptions-procedurally-textured-planets-yes")
forRow:GUI_ROW(GAME,PROCEDURALLYTEXTUREDPLANETS)
align:GUI_ALIGN_CENTER];
3846 [gui
setText:DESC(@"gameoptions-procedurally-textured-planets-no")
forRow:GUI_ROW(GAME,PROCEDURALLYTEXTUREDPLANETS)
align:GUI_ALIGN_CENTER];
3850 if (guiSelectedRow ==
GUI_ROW(GAME,SHADEREFFECTS) && ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_arrow_left]))
3854 int direction = ([
self checkKeyPress:n_key_gui_arrow_right]) ? 1 : -1;
3879 [UNIVERSE setDetailLevel:detailLevel];
3880 detailLevel = [UNIVERSE detailLevel];
3882 NSString *shaderEffectsOptionsString =
OOExpand(
@"gameoptions-detaillevel-[detailLevel]", detailLevel);
3883 [gui
setText:OOExpandKey(shaderEffectsOptionsString)
forRow:GUI_ROW(GAME,SHADEREFFECTS)
align:GUI_ALIGN_CENTER];
3884 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW(GAME,SHADEREFFECTS)];
3890 [
self setGuiToGameOptionsScreen];
3898 if ((guiSelectedRow ==
GUI_ROW(GAME,DISPLAYSTYLE)) && selectKeyPress)
3902 [
self setGuiToGameOptionsScreen];
3906 if ((guiSelectedRow ==
GUI_ROW(GAME,DOCKINGCLEARANCE))&&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3908 if ([
self checkKeyPress:n_key_gui_arrow_right] != [
UNIVERSE dockingClearanceProtocolActive])
3909 [
self playChangedOption];
3910 [UNIVERSE setDockingClearanceProtocolActive:[
self checkKeyPress:n_key_gui_arrow_right]];
3911 if ([
UNIVERSE dockingClearanceProtocolActive])
3912 [gui
setText:DESC(@"gameoptions-docking-clearance-yes")
forRow:GUI_ROW(GAME,DOCKINGCLEARANCE)
align:GUI_ALIGN_CENTER];
3914 [gui
setText:DESC(@"gameoptions-docking-clearance-no")
forRow:GUI_ROW(GAME,DOCKINGCLEARANCE)
align:GUI_ALIGN_CENTER];
3917 if ((guiSelectedRow ==
GUI_ROW(GAME,BACK)) && selectKeyPress)
3920 [
self setGuiToLoadSaveScreen];
3930 [
self keyMapperInputHandler: gui view: gameView];
3931 leftRightKeyPressed = [
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up] || [
self checkKeyPress:n_key_gui_page_down];
3935 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
3937 key = [gui
keyForRow:GUI_ROW_KC_FUNCEND];
3939 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
3941 key = [gui
keyForRow:GUI_ROW_KC_FUNCSTART];
3943 int from_function = 0;
3944 NSArray *keyComponents = [key componentsSeparatedByString:@":"];
3945 if ([keyComponents
count] > 1)
3947 from_function = [keyComponents oo_intAtIndex:1];
3948 if (from_function < 0) from_function = 0;
3950 [
self setGuiToKeyMapperScreen:from_function resetCurrentRow: YES];
3953 [[UNIVERSE gui] setSelectedRow: GUI_ROW_KC_FUNCSTART];
3955 if (from_function == 0)
3957 [[UNIVERSE gui] setSelectedRow: GUI_ROW_KC_FUNCSTART + MAX_ROWS_KC_FUNCTIONS - 1];
3969 [
self handleKeyboardLayoutEntryKeys: gui view: gameView];
3970 leftRightKeyPressed = [
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up] || [
self checkKeyPress:n_key_gui_page_down];
3974 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
3976 key = [gui
keyForRow:GUI_ROW_KC_FUNCEND];
3978 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
3980 key = [gui
keyForRow:GUI_ROW_KC_FUNCSTART];
3982 int from_function = 0;
3983 NSArray *keyComponents = [key componentsSeparatedByString:@":"];
3984 if ([keyComponents
count] > 1)
3986 from_function = [keyComponents oo_intAtIndex:1];
3987 if (from_function < 0) from_function = 0;
3989 [
self setGuiToKeyboardLayoutScreen:from_function resetCurrentRow:YES];
3992 [[UNIVERSE gui] setSelectedRow: GUI_ROW_KC_FUNCSTART];
3994 if (from_function == 0)
3996 [[UNIVERSE gui] setSelectedRow: GUI_ROW_KC_FUNCSTART + MAX_ROWS_KC_FUNCTIONS - 1];
4008 [
self stickMapperInputHandler: gui view: gameView];
4009 leftRightKeyPressed = [
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up] || [
self checkKeyPress:n_key_gui_page_down];
4013 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
4017 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
4019 key = [gui
keyForRow:GUI_ROW_FUNCSTART];
4021 int from_function = 0;
4022 NSArray *keyComponents = [key componentsSeparatedByString:@":"];
4023 if ([keyComponents
count] > 1)
4025 from_function = [keyComponents oo_intAtIndex:1];
4026 if (from_function < 0) from_function = 0;
4028 [
self setGuiToStickMapperScreen:from_function resetCurrentRow: YES];
4031 [[UNIVERSE gui] setSelectedRow: GUI_ROW_FUNCSTART];
4033 if (from_function == 0)
4035 [[UNIVERSE gui] setSelectedRow: GUI_ROW_FUNCSTART + MAX_ROWS_FUNCTIONS - 1];
4039 if([gameView isDown:
' ']) [
self setGuiToGameOptionsScreen];
4045 static Quaternion viewQuaternion;
4046 static Vector viewOffset;
4047 static Vector rotationCenter;
4049 static Vector right;
4050 static BOOL mouse_clicked = NO;
4051 static NSPoint mouse_clicked_position;
4052 static BOOL shift_down;
4053 static BOOL caps_on = NO;
4054 static NSTimeInterval last_time = 0.0;
4060 if (!
customView_pressed && [_customViews
count] != 0 && gui_screen != GUI_SCREEN_LONG_RANGE_CHART && ![gameView allowingStringInput])
4062 if ([
UNIVERSE viewDirection] == VIEW_CUSTOM)
4065 _customViewIndex = (_customViewIndex + 1) % [_customViews
count];
4068 [
self setCustomViewDataFromDictionary:[_customViews oo_dictionaryAtIndex:_customViewIndex] withScaling:YES];
4070 [
self switchToThisView:VIEW_CUSTOM andProcessWeaponFacing:NO];
4076 NSTimeInterval this_time = [NSDate timeIntervalSinceReferenceDate];
4077 if ([
UNIVERSE viewDirection] > VIEW_STARBOARD && [gameView isCapsLockOn])
4083 if (!caps_on) caps_on = YES;
4086 if (([
self checkKeyPress:n_key_custom_view_zoom_out ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_zoom_in ignore_ctrl:YES]) || [gameView mouseWheelState] ==
gvMouseWheelDown)
4088 [
self customViewZoomOut: pow(customViewZoomSpeed, delta_t)];
4090 if (([
self checkKeyPress:n_key_custom_view_zoom_in ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_zoom_out ignore_ctrl:YES]) || [gameView mouseWheelState] ==
gvMouseWheelUp)
4092 [
self customViewZoomIn: pow(customViewZoomSpeed, delta_t)];
4094 if ([
self checkKeyPress:n_key_custom_view_roll_left ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_roll_right ignore_ctrl:YES])
4096 [
self customViewRollLeft:customViewRotateSpeed * delta_t];
4098 if ([
self checkKeyPress:n_key_custom_view_pan_left ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_pan_right ignore_ctrl:YES])
4100 [
self customViewPanLeft:customViewRotateSpeed * delta_t];
4102 if ([
self checkKeyPress:n_key_custom_view_roll_right ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_roll_left ignore_ctrl:YES])
4104 [
self customViewRollRight:customViewRotateSpeed * delta_t];
4106 if ([
self checkKeyPress:n_key_custom_view_pan_right ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_pan_left ignore_ctrl:YES])
4108 [
self customViewPanRight:customViewRotateSpeed * delta_t];
4110 if ([
self checkKeyPress:n_key_custom_view_rotate_up ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_rotate_down ignore_ctrl:YES])
4112 [
self customViewRotateUp:customViewRotateSpeed * delta_t];
4114 if ([
self checkKeyPress:n_key_custom_view_pan_down ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_pan_up ignore_ctrl:YES])
4116 [
self customViewPanDown:customViewRotateSpeed * delta_t];
4118 if ([
self checkKeyPress:n_key_custom_view_rotate_down ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_rotate_up ignore_ctrl:YES])
4120 [
self customViewRotateDown:customViewRotateSpeed * delta_t];
4122 if ([
self checkKeyPress:n_key_custom_view_pan_up ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_pan_down ignore_ctrl:YES])
4124 [
self customViewPanUp:customViewRotateSpeed * delta_t];
4126 if ([
self checkKeyPress:n_key_custom_view_rotate_left ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_rotate_right ignore_ctrl:YES])
4128 [
self customViewRotateLeft:customViewRotateSpeed * delta_t];
4130 if ([
self checkKeyPress:n_key_custom_view_rotate_right ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_rotate_left ignore_ctrl:YES])
4132 [
self customViewRotateRight:customViewRotateSpeed * delta_t];
4136 if(!mouse_clicked || shift_down != [gameView isShiftDown])
4138 mouse_clicked = YES;
4139 viewQuaternion = [PLAYER customViewQuaternion];
4140 viewOffset = [PLAYER customViewOffset];
4141 rotationCenter = [PLAYER customViewRotationCenter];
4142 up = [PLAYER customViewUpVector];
4143 right = [PLAYER customViewRightVector];
4148 Vector axis = vector_add(vector_multiply_scalar(up, mouse_position.x - mouse_clicked_position.x),
4149 vector_multiply_scalar(right, mouse_position.y - mouse_clicked_position.y));
4150 float angle = magnitude(axis);
4151 axis = vector_normal(axis);
4152 Quaternion newViewQuaternion = viewQuaternion;
4153 if ([gameView isShiftDown])
4156 [PLAYER setCustomViewQuaternion: newViewQuaternion];
4157 [PLAYER setCustomViewRotationCenter: vector_subtract(viewOffset,
4158 vector_multiply_scalar([PLAYER customViewForwardVector],
4159 dot_product([PLAYER customViewForwardVector], viewOffset)))];
4164 OOScalar m = magnitude(vector_subtract(viewOffset, rotationCenter));
4165 [PLAYER setCustomViewQuaternion: newViewQuaternion];
4166 Vector
offset = vector_flip([
PLAYER customViewForwardVector]);
4168 [PLAYER setCustomViewOffset:vector_add(offset, rotationCenter)];
4182 if ([
self isMouseControlOn]) [gameView
resetMouse];
4185 last_time = this_time;
4197 NSPoint virtualView = NSZeroPoint;
4198 double view_threshold = 0.5;
4200 if ([stickHandler joystickCount])
4202 virtualView = [stickHandler
viewAxis];
4204 virtualView.y = 0.0;
4206 virtualView.x = 0.0;
4207 if (fabs(virtualView.y) >= fabs(virtualView.x))
4208 virtualView.x = 0.0;
4210 virtualView.y = 0.0;
4216 if (([
self checkKeyPress:n_key_view_forward]) || (virtualView.y < -view_threshold)||joyButtonState[
BUTTON_VIEWFORWARD] || ((([
self checkKeyPress:n_key_hyperspace] && gui_screen != GUI_SCREEN_LONG_RANGE_CHART) || joyButtonState[
BUTTON_HYPERDRIVE]) && [
UNIVERSE displayGUI]))
4218 [
self switchToThisView:VIEW_FORWARD];
4220 if (([
self checkKeyPress:n_key_view_aft])||(virtualView.y > view_threshold)||joyButtonState[
BUTTON_VIEWAFT])
4222 [
self switchToThisView:VIEW_AFT];
4224 if (([
self checkKeyPress:n_key_view_port])||(virtualView.x < -view_threshold)||joyButtonState[
BUTTON_VIEWPORT])
4226 [
self switchToThisView:VIEW_PORT];
4228 if (([
self checkKeyPress:n_key_view_starboard])||(virtualView.x > view_threshold)||joyButtonState[
BUTTON_VIEWSTARBOARD])
4230 [
self switchToThisView:VIEW_STARBOARD];
4233 [
self pollCustomViewControls];
4238 if (!scanner_zoom_rate)
4240 if ([hud scannerZoom] < 5.0)
4259 if ((!scanner_zoom_rate)&&([hud scannerZoom] > 1.0))
4263 if (
EXPECT([[
self hud] isCompassActive]))
4269 [
self setPrevCompassMode];
4277 if ([
self checkKeyPress:n_key_next_compass_mode] || joyButtonState[
BUTTON_COMPASSMODE])
4280 [
self setNextCompassMode];
4295 if (![
self checkKeyPress:n_key_cycle_previous_mfd] || joyButtonState[
BUTTON_MFDCYCLEPREV])
4297 [
self cycleNextMultiFunctionDisplay:activeMFD];
4301 [
self cyclePreviousMultiFunctionDisplay:activeMFD];
4314 if ([[
self hud] mfdCount] > 1)
4321 [
self selectNextMultiFunctionDisplay];
4325 [
self selectPreviousMultiFunctionDisplay];
4338 if ([
self checkKeyPress:n_key_comms_log])
4340 [UNIVERSE showCommsLog: 1.5];
4341 [hud refreshLastTransmitter];
4346- (void) pollFlightArrowKeyControls:(
double)delta_t
4351 NSPoint virtualStick = NSZeroPoint;
4352 double reqYaw = 0.0;
4358 if (mouse_control_on)
4361 double sensitivity = 2.0;
4362 virtualStick.x *= sensitivity;
4363 virtualStick.y *= sensitivity;
4364 reqYaw = virtualStick.x;
4366 else if (numSticks > 0)
4375 else if(virtualStick.x != 0)
4378 keyboardRollOverride=NO;
4386 else if(virtualStick.y != 0)
4389 keyboardPitchOverride=NO;
4398 else if(reqYaw != 0)
4401 keyboardYawOverride=NO;
4408 BOOL capsLockCustomView = [UNIVERSE viewDirection] == VIEW_CUSTOM && [gameView
isCapsLockOn];
4412 double flightArrowKeyPrecisionFactor = [[NSUserDefaults standardUserDefaults] oo_doubleForKey:@"flight-arrow-key-precision-factor" defaultValue:0.5];
4413 if (flightArrowKeyPrecisionFactor < 0.05) flightArrowKeyPrecisionFactor = 0.05;
4414 if (flightArrowKeyPrecisionFactor > 1.0) flightArrowKeyPrecisionFactor = 1.0;
4420 if ([
self checkNavKeyPress:n_key_roll_left] && [
self checkNavKeyPress:n_key_roll_right])
4422 keyboardRollOverride = YES;
4425 else if ([
self checkNavKeyPress:n_key_roll_left] && !capsLockCustomView)
4427 keyboardRollOverride=YES;
4428 if (flightRoll > 0.0) flightRoll = 0.0;
4429 [
self decrease_flight_roll:isCtrlDown ? flightArrowKeyPrecisionFactor*roll_dampner*roll_delta : delta_t*roll_delta];
4432 else if ([
self checkNavKeyPress:n_key_roll_right] && !capsLockCustomView)
4434 keyboardRollOverride=YES;
4435 if (flightRoll < 0.0) flightRoll = 0.0;
4436 [
self increase_flight_roll:isCtrlDown ? flightArrowKeyPrecisionFactor*roll_dampner*roll_delta : delta_t*roll_delta];
4440 if(((mouse_control_on && !
mouse_x_axis_map_to_yaw) || numSticks) && !keyboardRollOverride && !capsLockCustomView)
4442 stick_roll = max_flight_roll * virtualStick.x;
4443 if (flightRoll < stick_roll)
4445 [
self increase_flight_roll:delta_t*roll_delta];
4446 if (flightRoll > stick_roll)
4447 flightRoll = stick_roll;
4449 if (flightRoll > stick_roll)
4451 [
self decrease_flight_roll:delta_t*roll_delta];
4452 if (flightRoll < stick_roll)
4453 flightRoll = stick_roll;
4455 rolling = (fabs(virtualStick.x) > 0.0);
4459 if (flightRoll > 0.0)
4461 if (flightRoll > roll_dampner) [
self decrease_flight_roll:roll_dampner];
4462 else flightRoll = 0.0;
4464 if (flightRoll < 0.0)
4466 if (flightRoll < -roll_dampner) [
self increase_flight_roll:roll_dampner];
4467 else flightRoll = 0.0;
4473 if (!mouse_control_on)
4475 if ([
self checkNavKeyPress:n_key_pitch_back] && [
self checkNavKeyPress:n_key_pitch_forward])
4477 keyboardPitchOverride=YES;
4480 else if ([
self checkNavKeyPress:n_key_pitch_back] && !capsLockCustomView)
4482 keyboardPitchOverride=YES;
4483 if (flightPitch < 0.0) flightPitch = 0.0;
4484 [
self increase_flight_pitch:isCtrlDown ? flightArrowKeyPrecisionFactor*pitch_dampner*pitch_delta : delta_t*pitch_delta];
4487 else if ([
self checkNavKeyPress:n_key_pitch_forward] && !capsLockCustomView)
4489 keyboardPitchOverride=YES;
4490 if (flightPitch > 0.0) flightPitch = 0.0;
4491 [
self decrease_flight_pitch:isCtrlDown ? flightArrowKeyPrecisionFactor*pitch_dampner*pitch_delta : delta_t*pitch_delta];
4495 if((mouse_control_on || (numSticks && !keyboardPitchOverride)) && !capsLockCustomView)
4497 stick_pitch = max_flight_pitch * virtualStick.y;
4498 if (flightPitch < stick_pitch)
4500 [
self increase_flight_pitch:delta_t*pitch_delta];
4501 if (flightPitch > stick_pitch)
4502 flightPitch = stick_pitch;
4504 if (flightPitch > stick_pitch)
4506 [
self decrease_flight_pitch:delta_t*pitch_delta];
4507 if (flightPitch < stick_pitch)
4508 flightPitch = stick_pitch;
4510 pitching = (fabs(virtualStick.y) > 0.0);
4514 if (flightPitch > 0.0)
4516 if (flightPitch > pitch_dampner) [
self decrease_flight_pitch:pitch_dampner];
4517 else flightPitch = 0.0;
4519 if (flightPitch < 0.0)
4521 if (flightPitch < -pitch_dampner) [
self increase_flight_pitch:pitch_dampner];
4522 else flightPitch = 0.0;
4530 if ([
self checkNavKeyPress:n_key_yaw_left] && [
self checkNavKeyPress:n_key_yaw_right])
4532 keyboardYawOverride=YES;
4535 else if ([
self checkNavKeyPress:n_key_yaw_left] && !capsLockCustomView)
4537 keyboardYawOverride=YES;
4538 if (flightYaw < 0.0) flightYaw = 0.0;
4539 [
self increase_flight_yaw:isCtrlDown ? flightArrowKeyPrecisionFactor*yaw_dampner*yaw_delta : delta_t*yaw_delta];
4542 else if ([
self checkNavKeyPress:n_key_yaw_right] && !capsLockCustomView)
4544 keyboardYawOverride=YES;
4545 if (flightYaw > 0.0) flightYaw = 0.0;
4546 [
self decrease_flight_yaw:isCtrlDown ? flightArrowKeyPrecisionFactor*yaw_dampner*yaw_delta : delta_t*yaw_delta];
4550 if(((mouse_control_on &&
mouse_x_axis_map_to_yaw) || numSticks) && !keyboardYawOverride && !capsLockCustomView)
4554 stick_yaw = max_flight_yaw * (-reqYaw);
4555 if (flightYaw < stick_yaw)
4557 [
self increase_flight_yaw:delta_t*yaw_delta];
4558 if (flightYaw > stick_yaw)
4559 flightYaw = stick_yaw;
4561 if (flightYaw > stick_yaw)
4563 [
self decrease_flight_yaw:delta_t*yaw_delta];
4564 if (flightYaw < stick_yaw)
4565 flightYaw = stick_yaw;
4567 yawing = (fabs(reqYaw) > 0.0);
4571 if (flightYaw > 0.0)
4573 if (flightYaw > yaw_dampner) [
self decrease_flight_yaw:yaw_dampner];
4574 else flightYaw = 0.0;
4576 if (flightYaw < 0.0)
4578 if (flightYaw < -yaw_dampner) [
self increase_flight_yaw:yaw_dampner];
4579 else flightYaw = 0.0;
4588 [
self pollGuiScreenControlsWithFKeyAlias:YES];
4592- (void) pollGuiScreenControlsWithFKeyAlias:(BOOL)fKeyAlias
4594 if(!pollControls && fKeyAlias)
4599 BOOL docked_okay = ([
self status] == STATUS_DOCKED);
4602 if ([
self checkKeyPress:n_key_gui_screen_status fKey_only:!fKeyAlias])
4607 if (gui_screen == GUI_SCREEN_STATUS)
4609 [
self noteGUIWillChangeTo:GUI_SCREEN_MANIFEST];
4610 [
self setGuiToManifestScreen];
4613 [
self setGuiToStatusScreen];
4622 if ([
self checkKeyPress:n_key_gui_chart_screens fKey_only:!fKeyAlias])
4630 if (
EXPECT_NOT([
self status] == STATUS_WITCHSPACE_COUNTDOWN && gui_screen == GUI_SCREEN_SHORT_RANGE_CHART))
4635 else if (gui_screen == GUI_SCREEN_SHORT_RANGE_CHART || (gui_screen == GUI_SCREEN_SYSTEM_DATA && showingLongRangeChart))
4639 saved_chart_zoom = target_chart_zoom;
4642 [
self noteGUIWillChangeTo:GUI_SCREEN_LONG_RANGE_CHART];
4643 [
self setGuiToLongRangeChartScreen];
4649 target_chart_zoom = saved_chart_zoom;
4652 [
self noteGUIWillChangeTo:GUI_SCREEN_SHORT_RANGE_CHART];
4653 [
self setGuiToShortRangeChartScreen];
4662 if ([
self checkKeyPress:n_key_gui_system_data fKey_only:!fKeyAlias])
4664 if (gui_screen != GUI_SCREEN_SYSTEM_DATA)
4666 showingLongRangeChart = (gui_screen == GUI_SCREEN_LONG_RANGE_CHART);
4667 [
self noteGUIWillChangeTo:GUI_SCREEN_SYSTEM_DATA];
4668 [
self setGuiToSystemDataScreen];
4672 if ([
self checkKeyPress:n_key_gui_market fKey_only:!fKeyAlias])
4674 if (gui_screen != GUI_SCREEN_MARKET)
4677 [
self noteGUIWillChangeTo:GUI_SCREEN_MARKET];
4678 [
self setGuiToMarketScreen];
4683 [
self noteGUIWillChangeTo:GUI_SCREEN_MARKETINFO];
4684 [
self setGuiToMarketInfoScreen];
4691 if (([
self checkKeyPress:n_key_gui_screen_options fKey_only:!fKeyAlias]) && (gui_screen != GUI_SCREEN_OPTIONS))
4694 [
self setGuiToLoadSaveScreen];
4697 if ([
self checkKeyPress:n_key_gui_screen_equipship fKey_only:!fKeyAlias])
4701 if ([
self dockedStation] ==
nil) [
self setDockedAtMainStation];
4704 if ((gui_screen == GUI_SCREEN_EQUIP_SHIP) && [[
self dockedStation] hasShipyard])
4707 [
self noteGUIWillChangeTo:GUI_SCREEN_SHIPYARD];
4708 [
self setGuiToShipyardScreen:0];
4710 [
self showShipyardInfoForSelection];
4715 [
self noteGUIWillChangeTo:GUI_SCREEN_EQUIP_SHIP];
4716 [
self setGuiToEquipShipScreen:0];
4720 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
4729 if ([
self checkKeyPress:n_key_gui_screen_interfaces fKey_only:!fKeyAlias])
4731 [
self setGuiToInterfacesScreen:0];
4739- (void) pollGameOverControls:(
double)delta_t
4742 if ([gameView isDown:32])
4746 [UNIVERSE displayMessage:@"" forCount:1.0];
4760- (void) pollAutopilotControls:(
double)delta_t
4763 if (gui_screen == GUI_SCREEN_KEYBOARD_ENTRY || gui_screen == GUI_SCREEN_KEYBOARD_CONFIG || gui_screen == GUI_SCREEN_KEYBOARD_LAYOUT || gui_screen == GUI_SCREEN_KEYBOARD || gui_screen == GUI_SCREEN_KEYBOARD_CONFIRMCLEAR)
return;
4768 if (![[
UNIVERSE gameController] isGamePaused])
4779 if ([
self checkKeyPress:n_key_autopilot] || joyButtonState[
BUTTON_DOCKCPU]
4785 [UNIVERSE addMessage:DESC(@"autopilot-off") forCount:4.5];
4812 if (([
self checkKeyPress:n_key_pausebutton] || joyButtonState[
BUTTON_PAUSE]) && gui_screen != GUI_SCREEN_SHORT_RANGE_CHART && gui_screen != GUI_SCREEN_MISSION && gui_screen != GUI_SCREEN_KEYBOARD_ENTRY)
4832 if ([
self checkKeyPress:n_key_pausebutton] || joyButtonState[
BUTTON_PAUSE])
4850- (void) pollDockedControls:(
double)delta_t
4855 NSString *exceptionContext =
@"setup";
4860 exceptionContext =
@"pause key";
4861 if (([
self checkKeyPress:n_key_pausebutton] || joyButtonState[
BUTTON_PAUSE]) && (gui_screen != GUI_SCREEN_LONG_RANGE_CHART &&
4862 gui_screen != GUI_SCREEN_MISSION && gui_screen != GUI_SCREEN_REPORT &&
4863 gui_screen != GUI_SCREEN_SAVE && gui_screen != GUI_SCREEN_KEYBOARD_ENTRY) )
4867 if ([gameController isGamePaused])
4871 if ([
UNIVERSE pauseMessageVisible])
4873 [UNIVERSE clearPreviousMessage];
4875 [[UNIVERSE gui] setForegroundTextureKey:@"docked_overlay"];
4881 [[UNIVERSE messageGUI] clear];
4883 [UNIVERSE pauseGame];
4893 if ([gameController isGamePaused])
return;
4897 exceptionContext =
@"undock";
4898 if ([
self checkKeyPress:n_key_launch_ship])
4900 if (
EXPECT((gui_screen != GUI_SCREEN_MISSION || _missionAllowInterrupt) && gui_screen != GUI_SCREEN_KEYBOARD_ENTRY))
4902 [
self handleUndockControl];
4909 exceptionContext =
@"GUI keys";
4910 if (gui_screen == GUI_SCREEN_MISSION || gui_screen == GUI_SCREEN_KEYBOARD_ENTRY)
4912 [
self pollDemoControls: delta_t];
4916 if (gui_screen != GUI_SCREEN_REPORT)[
self pollGuiScreenControls];
4919 [
self pollGuiArrowKeyControls:delta_t];
4921 @catch (NSException *exception)
4923 OOLog(
kOOLogException,
@"***** Exception in pollDockedControls [%@]: %@ : %@", exceptionContext, [exception name], [exception reason]);
4931 [UNIVERSE setUpUniverseFromStation];
4932 if ([
self dockedStation] ==
nil) [
self setDockedAtMainStation];
4937 [
self autosavePlayer];
4939 [
self launchFromStation];
4943- (void) pollDemoControls:(
double)delta_t
4947 NSUInteger end_row = 21;
4952 case GUI_SCREEN_INTRO1:
4953 [
self handleGUIUpDownArrowKeys];
4960 if (([gameView isDown:
gvMouseDoubleClick] || [
self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 2+row_zero)
4963 [UNIVERSE removeDemoShips];
4965 if (![
self loadPlayer])
4967 [
self setGuiToIntroFirstGo:YES];
4972 if (([gameView isDown:
gvMouseDoubleClick] || [
self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 1+row_zero)
4975 [
self setGuiToScenarioScreen:0];
4977 else if (([gameView isDown:
gvMouseDoubleClick] || [
self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 3+row_zero)
4979 [
self setGuiToIntroFirstGo:NO];
4981 else if (([gameView isDown:
gvMouseDoubleClick] || [
self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 4+row_zero)
4983 [
self setGuiToGameOptionsScreen];
4985 else if (([gameView isDown:
gvMouseDoubleClick] || [
self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 5+row_zero)
4987 [
self setGuiToOXZManager];
4989 else if (([gameView isDown:
gvMouseDoubleClick] || [
self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 6+row_zero)
4991 [[UNIVERSE gameController] exitAppWithContext:@"Exit Game selected on start screen"];
5005 case GUI_SCREEN_GAMEOPTIONS:
5006 [
self handleGameOptionsScreenKeys];
5009 case GUI_SCREEN_KEYBOARD:
5014 [
self handleKeyMapperScreenKeys];
5017 case GUI_SCREEN_KEYBOARD_CONFIRMCLEAR:
5018 [
self handleKeyMapperConfirmClearKeys:gui view:gameView];
5021 case GUI_SCREEN_KEYBOARD_CONFIG:
5022 [
self handleKeyConfigKeys:gui view:gameView];
5025 case GUI_SCREEN_KEYBOARD_ENTRY:
5026 [
self handleKeyConfigEntryKeys:gui view:gameView];
5029 case GUI_SCREEN_KEYBOARD_LAYOUT:
5030 [
self handleKeyboardLayoutKeys];
5033 case GUI_SCREEN_STICKMAPPER:
5034 [
self handleStickMapperScreenKeys];
5037 case GUI_SCREEN_STICKPROFILE:
5038 [
self stickProfileInputHandler:gui view:gameView];
5041 case GUI_SCREEN_SHIPLIBRARY:
5042 if ([gameView isDown:
' '])
5045 [
self setGuiToIntroFirstGo:YES];
5047 if ([
self checkKeyPress:n_key_gui_arrow_up])
5050 [UNIVERSE selectIntro2Previous];
5052 if ([
self checkKeyPress:n_key_gui_arrow_down])
5055 [UNIVERSE selectIntro2Next];
5057 upDownKeyPressed = (([
self checkKeyPress:n_key_gui_arrow_up])||([
self checkKeyPress:n_key_gui_arrow_down]));
5059 if ([
self checkKeyPress:n_key_gui_arrow_left])
5062 [UNIVERSE selectIntro2PreviousCategory];
5064 if ([
self checkKeyPress:n_key_gui_arrow_right])
5067 [UNIVERSE selectIntro2NextCategory];
5069 leftRightKeyPressed = (([
self checkKeyPress:n_key_gui_arrow_left])||([
self checkKeyPress:n_key_gui_arrow_right]));
5074 case GUI_SCREEN_NEWGAME:
5075 if ([
self handleGUIUpDownArrowKeys])
5077 [
self showScenarioDetails];
5082 if ([
self checkKeyPress:n_key_gui_page_up])
5089 [
self startScenario];
5094 else if ([
self checkKeyPress:n_key_gui_page_down])
5101 [
self startScenario];
5106 pageUpDownKeyPressed = [
self checkKeyPress:n_key_gui_page_down]|[
self checkKeyPress:n_key_gui_page_up];
5112 if (![
self startScenario])
5114 [UNIVERSE removeDemoShips];
5115 [
self setGuiToIntroFirstGo:YES];
5126 case GUI_SCREEN_OXZMANAGER:
5129 if (
EXPECT(![oxzmanager isRestarting]))
5131 if ([oxzmanager isAcceptingGUIInput])
5133 if ([oxzmanager isAcceptingTextInput])
5142 if ([
self handleGUIUpDownArrowKeys])
5147 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
5154 else if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
5161 leftRightKeyPressed = [
self checkKeyPress:n_key_gui_arrow_right]|[
self checkKeyPress:n_key_gui_arrow_left]|[
self checkKeyPress:n_key_gui_page_down]|[
self checkKeyPress:n_key_gui_page_up];
5167 if ([oxzmanager isAcceptingTextInput])
5183 if ([
self checkKeyPress:n_key_oxzmanager_setfilter] ||
5184 [
self checkKeyPress:n_key_oxzmanager_showinfo] ||
5185 [
self checkKeyPress:n_key_oxzmanager_extract])
5190 if ([
self checkKeyPress:n_key_oxzmanager_setfilter])
5194 else if ([
self checkKeyPress:n_key_oxzmanager_showinfo])
5198 else if ([
self checkKeyPress:n_key_oxzmanager_extract])
5214 case GUI_SCREEN_MISSION:
5215 if ([[
self hud] allowBigGui])
5219 if (_missionTextEntry)
5221 [
self refreshMissionScreenTextEntry];
5224 [
self setMissionChoice:[gameView
typedString] keyPress:@"enter"];
5226 [
self playDismissedMissionScreen];
5228 [
self handleMissionCallback];
5238 [
self pollMissionInterruptControls];
5241 else if ([[gui keyForRow:end_row] isEqual:
@"spacebar"])
5243 if ([gameView isDown:32])
5248 [
self handleMissionCallback];
5256 [
self pollMissionInterruptControls];
5261 [
self handleGUIUpDownArrowKeys];
5262 NSString *extraKey =
@"";
5263 if (extraMissionKeys)
5265 NSString *key =
nil;
5266 foreach (key, [extraMissionKeys allKeys])
5268 if ([
self checkKeyPress:[extraMissionKeys oo_arrayForKey:key]]) {
5271 extraKey = [key copy];
5279 if ([
self checkKeyPress:n_key_gui_select] || [gameView isDown:
gvMouseDoubleClick] || [extraKey length] > 0)
5288 if ([extraKey length] == 0) extraKey =
@"enter";
5291 [
self playDismissedMissionScreen];
5293 [
self handleMissionCallback];
5302 [
self pollMissionInterruptControls];
5308#if OO_USE_CUSTOM_LOAD_SAVE
5310 case GUI_SCREEN_LOAD:
5312 NSString *commanderFile = [
self commanderSelector];
5319 [
self loadPlayerFromFile:commanderFile asNew:NO];
5333 if (_missionAllowInterrupt)
5335 if (gui_screen == GUI_SCREEN_MISSION && _missionTextEntry)
5337 [
self pollGuiScreenControlsWithFKeyAlias:NO];
5340 [
self pollGuiScreenControls];
5342 if (gui_screen != GUI_SCREEN_MISSION)
5344 if (gui_screen != GUI_SCREEN_SYSTEM_DATA)
5346 [UNIVERSE removeDemoShips];
5348 [
self endMissionScreenAndNoteOpportunity];
5356 [UNIVERSE removeDemoShips];
5357 [[UNIVERSE gui] clearBackground];
5359 [
self setGuiToMissionEndScreen];
5361 if ([
self status] != STATUS_DOCKED) [
self switchToThisView:VIEW_FORWARD];
5363 if (_missionWithCallback)
5365 [
self doMissionCallback];
5368 if ([
self status] != STATUS_DOCKED)
5371 [
self doWorldEventUntilMissionScreen:OOJSID("missionScreenEnded")];
5375 if (gui_screen != GUI_SCREEN_MISSION)
5378 [
self setGuiToMissionEndScreen];
5379 [
self endMissionScreenAndNoteOpportunity];
5389 if ([
self status] != STATUS_DOCKED)
5392 [
self setGuiToStatusScreen];
5395 switch (_missionExitScreen)
5397 case GUI_SCREEN_MANIFEST:
5398 [
self noteGUIWillChangeTo:GUI_SCREEN_MANIFEST];
5399 [
self setGuiToManifestScreen];
5401 case GUI_SCREEN_EQUIP_SHIP:
5402 [
self noteGUIWillChangeTo:GUI_SCREEN_EQUIP_SHIP];
5403 [
self setGuiToEquipShipScreen:0];
5405 case GUI_SCREEN_SHIPYARD:
5406 if ([[
self dockedStation] hasShipyard])
5408 [
self noteGUIWillChangeTo:GUI_SCREEN_SHIPYARD];
5409 [
self setGuiToShipyardScreen:0];
5410 [[UNIVERSE gui] setSelectedRow:GUI_ROW_SHIPYARD_START];
5411 [
self showShipyardInfoForSelection];
5416 [
self setGuiToStatusScreen];
5419 case GUI_SCREEN_LONG_RANGE_CHART:
5420 [
self setGuiToLongRangeChartScreen];
5422 case GUI_SCREEN_SHORT_RANGE_CHART:
5423 [
self setGuiToShortRangeChartScreen];
5425 case GUI_SCREEN_SYSTEM_DATA:
5426 [
self noteGUIWillChangeTo:GUI_SCREEN_SYSTEM_DATA];
5427 [
self setGuiToSystemDataScreen];
5429 case GUI_SCREEN_MARKET:
5430 [
self noteGUIWillChangeTo:GUI_SCREEN_MARKET];
5431 [
self setGuiToMarketScreen];
5433 case GUI_SCREEN_MARKETINFO:
5434 [
self noteGUIWillChangeTo:GUI_SCREEN_MARKETINFO];
5435 [
self setGuiToMarketInfoScreen];
5437 case GUI_SCREEN_INTERFACES:
5438 [
self setGuiToInterfacesScreen:0];
5440 case GUI_SCREEN_STATUS:
5442 [
self setGuiToStatusScreen];
5447- (void) switchToThisView:(
OOViewID)viewDirection
5449 [
self switchToThisView:viewDirection andProcessWeaponFacing:YES];
5453- (void) switchToThisView:(
OOViewID)viewDirection andProcessWeaponFacing:(BOOL)processWeaponFacing
5455 [
self switchToThisView:viewDirection fromView:[UNIVERSE viewDirection] andProcessWeaponFacing:processWeaponFacing justNotify:NO];
5459- (void) switchToThisView:(
OOViewID)viewDirection fromView:(
OOViewID)oldViewDirection andProcessWeaponFacing:(BOOL)processWeaponFacing justNotify:(BOOL)justNotify
5463 if ([
UNIVERSE displayGUI]) [
self switchToMainView];
5464 [UNIVERSE setViewDirection:viewDirection];
5466 if (processWeaponFacing)
5469 switch (viewDirection)
5483 case VIEW_STARBOARD:
5493 currentWeaponFacing = facing;
5494 [
self currentWeaponStats];
5501 if ((oldViewDirection != viewDirection || viewDirection == VIEW_CUSTOM) && ![[
UNIVERSE gameController] isGamePaused])
5511- (void) handleAutopilotOn:(BOOL)fastDocking
5513 NSString *message =
nil;
5519 [
self playAutopilotCannotDockWithTarget];
5524 Entity *target = [
self primaryTarget];
5526 if (![target isStation])
5533 for (i = 0; i < uni->
n_entities && nStations < 2; i++)
5535 if (entities[i]->isStation && [entities[i] isKindOfClass:[
StationEntity class]] &&
5539 target = entities[i];
5546 if ([
self withinStationAegis] && legalStatus <= 50)
5548 target = [UNIVERSE station];
5550 else if (nStations != 1)
5554 [
self playAutopilotOutOfRange];
5559 [
self playAutopilotCannotDockWithTarget];
5560 message =
OOExpandKey(
@"autopilot-multiple-targets");
5572 if (![ts allowsAutoDocking])
5574 [
self playAutopilotCannotDockWithTarget];
5575 message =
OOExpandKey(
@"autopilot-station-does-not-allow-autodocking", stationName);
5578 else if ((legalStatus > 50 && ts == [
UNIVERSE station]) || [ts isHostileTo:
self])
5580 [
self playAutopilotCannotDockWithTarget];
5581 message =
OOExpandKey((ts == [
UNIVERSE station]) ?
@"autopilot-denied" :
@"autopilot-target-docking-instructions-denied", stationName);
5584 else if (fastDocking && [ts allowsFastDocking])
5587 NSEnumerator *subEnum =
nil;
5589 for (subEnum = [ts dockSubEntityEnumerator]; (sub = [subEnum nextObject]); )
5592 if([[sub canAcceptShipForDocking:
self] isEqualToString:
@"TOO_BIG_TO_DOCK"])
5594 message =
OOExpandKey((ts == [
UNIVERSE station]) ?
@"autopilot-denied" :
@"autopilot-target-docking-instructions-denied", stationName);
5599 if (legalStatus > 0)
5603 int government = 1 + [[
UNIVERSE currentSystemData] oo_intForKey:KEY_GOVERNMENT];
5604 if ([
UNIVERSE inInterstellarSpace]) government = 2;
5605 fine_chance /= government;
5606 if (fine_chance < legalStatus)
5608 [
self markForFines];
5612 [
self setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_GRANTED];
5614 [UNIVERSE forceWitchspaceEntries];
5615 ship_clock_adjust += 1200.0;
5617 [
self safeAllMissiles];
5618 [UNIVERSE setViewDirection:VIEW_FORWARD];
5619 [
self enterDock:ts];
5624 [
self engageAutopilotToStation:ts];
5630 if (message !=
nil) [UNIVERSE addMessage:message forCount:4.5];
5638 if (ident_engaged) [
self noteLostTarget];
5640 [
self safeAllMissiles];
5641 ident_engaged = YES;
5642 if ([
self primaryTarget] ==
nil)
5645 [UNIVERSE addMessage:OOExpandKey(@"ident-on") forCount:2.0];
5649 [
self playIdentLockedOn];
5650 [
self printIdentLockedOnForMissile:NO];
5657 if (![
self weaponsOnline])
5659 [
self handleButtonIdent];
5666 [
self noteLostTarget];
5671 if ([missile_entity[activeMissile] isMissile])
5673 if ([[
self primaryTarget] isShip])
5676 [missile_entity[activeMissile] addTarget:[
self primaryTarget]];
5677 [
self printIdentLockedOnForMissile:YES];
5678 [
self playMissileLockedOn];
5683 if ([
self primaryTarget] !=
nil)
5685 [
self noteLostTarget];
5687 [missile_entity[activeMissile] noteLostTarget];
5688 NSString *weaponName = [missile_entity[activeMissile] name];
5689 [UNIVERSE addMessage:OOExpandKey(@"missile-armed", weaponName) forCount:2.0];
5690 [
self playMissileArmed];
5693 else if ([missile_entity[activeMissile] isMine])
5695 NSString *weaponName = [missile_entity[activeMissile] name];
5696 [UNIVERSE addMessage:OOExpandKey(@"mine-armed", weaponName) forCount:2.0];
5697 [
self playMineArmed];
#define SCANNER_MAX_RANGE2
#define MINIMUM_GAME_TICK
#define MAIN_GUI_PIXEL_WIDTH
#define MAIN_GUI_PIXEL_HEIGHT
OOINLINE jsval OOJSValueFromViewID(JSContext *context, OOViewID value)
void OOInitDebugSupport(void)
OOINLINE JSContext * OOJSAcquireContext(void)
OOINLINE void OOJSRelinquishContext(JSContext *context)
@ BUTTON_DOCKINGCLEARANCE
@ BUTTON_TARGETINCOMINGMISSILE
@ BUTTON_ACTIVATEEQUIPMENT
@ BUTTON_WEAPONSONLINETOGGLE
@ BUTTON_COMPASSMODE_PREV
@ BUTTON_PRIMEEQUIPMENT_PREV
#define STICK_AXISUNASSIGNED
#define OOLogWARN(class, format,...)
#define OOLogERR(class, format,...)
NSString *const kOOLogException
#define OOLog(class, format,...)
NSString *const kOOLogParameterError
void OOLogSetDisplayMessagesInClass(NSString *inClass, BOOL inFlag)
BOOL OOMouseInteractionModeIsFlightMode(OOMouseInteractionMode mode)
void quaternion_rotate_about_axis(Quaternion *quat, Vector axis, OOScalar angle)
#define OOExpandKey(key,...)
#define OOExpand(string,...)
NSString * OOCommodityType
uint64_t OOCreditsQuantity
@ WEAPON_FACING_STARBOARD
#define MAX_ROWS_SHIPS_FOR_SALE
#define GUI_ROW_SHIPYARD_START
static BOOL speech_settings_pressed
static BOOL musicModeKeyPressed
static BOOL cycleMFD_pressed
static BOOL extra_gui_key_pressed
static BOOL selectPressed
static NSPoint centre_at_mouse_click
static BOOL shaderSelectKeyPressed
static BOOL prime_equipment_pressed
static BOOL pageUpDownKeyPressed
static BOOL ident_pressed
static BOOL chartInfoPressed
static BOOL dump_target_state_pressed
static BOOL next_target_pressed
static BOOL rotateCargo_pressed
static BOOL taking_snapshot
static BOOL switching_chart_screens
static BOOL upDownKeyPressed
static BOOL previous_target_pressed
static BOOL next_planet_info_pressed
static BOOL m_key_pressed
static NSTimeInterval time_last_frame
static OOWeaponFacing saved_weapon_facing
static BOOL mode_equipment_pressed
#define CUSTOM_VIEW_SPEED_REDUCTION_FACTOR
static BOOL fire_missile_pressed
static BOOL autopilot_pause
static BOOL safety_pressed
static BOOL target_incoming_missile_pressed
static BOOL switching_equipship_screens
static BOOL galhyperspace_pressed
static int saved_gui_screen
static BOOL target_info_pressed
static BOOL wait_for_key_up
static BOOL next_missile_pressed
static BOOL weaponsOnlineToggle_pressed
static BOOL home_info_pressed
static BOOL switching_status_screens
static BOOL f_key_pressed
static BOOL hyperspace_pressed
static BOOL volumeControlPressed
static BOOL fast_autopilot_key_pressed
static BOOL hdrPaperWhiteControlPressed
#define CUSTOM_VIEW_ZOOM_SPEED
static BOOL leftRightKeyPressed
static BOOL fastactivate_a_pressed
static BOOL fovControlPressed
static BOOL previous_planet_info_pressed
static BOOL switchMFD_pressed
static BOOL extra_key_pressed
static BOOL hide_hud_pressed
static int saved_view_direction
static BOOL mouse_left_down
static BOOL pause_pressed
#define LOAD_KEY_SETTING2(name, default_1, shift_1, mod1_1, default_2, shift_2, mod1_2)
static BOOL escapePodKey_pressed
static BOOL next_compass_mode_pressed
static BOOL activate_equipment_pressed
static BOOL disc_operation_in_progress
static BOOL oxz_manager_pressed
static BOOL pling_pressed
#define CUSTOM_VIEW_ROTATE_SPEED
static BOOL prev_compass_mode_pressed
static BOOL customView_pressed
static BOOL f9_key_pressed
static NSUInteger searchStringLength
static double saved_script_time
static BOOL colorblindModeControlPressed
static BOOL dump_entity_list_pressed
static BOOL toggling_music
static NSPoint mouse_click_position
static BOOL playing_music
static BOOL fastactivate_b_pressed
static BOOL target_missile_pressed
static BOOL cursor_moving
static BOOL mouse_x_axis_map_to_yaw
static BOOL autopilot_key_pressed
static BOOL docking_clearance_request_key_pressed
static BOOL switching_resolution
static double timeLastKeyPress
static BOOL hdrMaxBrightnessControlPressed
#define GUI_ROW_KC_FUNCSTART
#define GUI_ROW_FUNCSTART
#define CHART_SCREEN_VERTICAL_CENTRE
@ STATUS_EQUIPMENT_FIRST_ROW
@ GUI_ROW_SCENARIOS_START
@ STATUS_EQUIPMENT_MAX_ROWS
@ GUI_ROW_EQUIPMENT_START
@ STATUS_EQUIPMENT_BIGGUI_EXTRA_ROWS
@ GUI_ROW_INTERFACES_START
@ GUI_MAX_ROWS_INTERFACES
#define PORT_FACING_STRING
#define CHART_ZOOM_SHOW_LABELS
#define YAW_DAMPING_FACTOR
#define ROLL_DAMPING_FACTOR
#define MANIFEST_SCREEN_ROW_BACK
#define SCANNER_ZOOM_RATE_DOWN
#define FORWARD_FACING_STRING
#define AFT_FACING_STRING
#define KEY_REPEAT_INTERVAL
#define CHART_ZOOM_SPEED_FACTOR
#define MANIFEST_SCREEN_ROW_NEXT
#define GUI_ROW_INIT(GUI)
#define SCANNER_ZOOM_RATE_UP
#define GUI_ROW(GROUP, ITEM)
#define STARBOARD_FACING_STRING
#define CUSTOMEQUIP_EQUIPKEY
#define CHART_SCROLL_AT_Y
#define CHART_SCROLL_AT_X
@ MISSILE_STATUS_TARGET_LOCKED
#define KEYCONFIG_CUSTOMEQUIP
#define PITCH_DAMPING_FACTOR
#define MIN_HDR_MAXBRIGHTNESS
#define MIN_HDR_PAPERWHITE
#define MAX_HDR_MAXBRIGHTNESS
#define MAX_HDR_PAPERWHITE
#define INITIAL_SHOT_TIME
#define DEFAULT_HYPERSPACE_SPIN_TIME
OOWeaponType OOWeaponTypeFromEquipmentIdentifierSloppy(NSString *string) PURE_FUNC
#define SHIP_THRUST_FACTOR
#define ShipScriptEvent(context, ship, event,...)
#define TIME_ACCELERATION_FACTOR_MAX
#define TIME_ACCELERATION_FACTOR_MIN
void setGuiToMissionEndScreen()
void handleKeyboardLayoutKeys()
void handleGameOptionsScreenKeys()
void handleStickMapperScreenKeys()
void pollMissionInterruptControls()
void pollMarketScreenControls()
void handleKeyMapperScreenKeys()
void pollGuiScreenControls()
void handleButtonTargetMissile()
void handleUndockControl()
void handleMissionCallback()
void pollCustomViewControls()
void pollApplicationControls()
void setGamePaused:(BOOL value)
void exitAppWithContext:(NSString *context)
void exitFullScreenMode()
void setMouseInteractionModeForFlight()
NSUInteger indexOfCurrentDisplayMode()
void pauseFullScreenModeToPerform:onTarget:(SEL selector,[onTarget] id target)
BOOL setDisplayWidth:Height:Refresh:(unsigned int d_width,[Height] unsigned int d_height,[Refresh] unsigned int d_refresh)
BOOL setSelectedRow:(OOGUIRow row)
void setStatusPage:(NSInteger pageNum)
NSString * selectedRowText()
void setText:forRow:align:(NSString *str,[forRow] OOGUIRow row,[align] OOGUIAlignment alignment)
NSString * selectedRowKey()
NSString * keyForRow:(OOGUIRow row)
void setKey:forRow:(NSString *str,[forRow] OOGUIRow row)
void setHidden:(BOOL newValue)
void grabMouseInsideGameWindow:(BOOL value)
void clearKey:(int theKey)
void setFov:fromFraction:(float value,[fromFraction] BOOL fromFraction)
void setGammaValue:(float value)
NSMutableString * typedString
void setScreenSize:(int sizeIndex)
NSPoint virtualJoystickPosition
float fov:(BOOL inFraction)
void allowStringInput:(BOOL value)
void setStringInput:(enum StringInput value)
BOOL snapShot:(NSString *filename)
BOOL setDebugger:(id< OODebuggerInterface > debugger)
OODebugMonitor * sharedDebugMonitor()
OOEquipmentType * equipmentTypeWithIdentifier:(NSString *identifier)
void runCallback:(NSString *key)
NSDictionary * registerKeys()
NSDictionary * axisFunctions()
const BOOL * getAllButtonStates()
double getAxisState:(int function)
NSUInteger joystickCount()
void clearStickButtonState:(int stickButton)
void toggleDockingMusic()
OOMusicController * sharedController()
void setMode:(OOMusicMode mode)
void processOptionsNext()
void processTextInput:(NSString *input)
void processOptionsPrev()
OOOXZManager * sharedManager()
void refreshTextInput:(NSString *input)
void processShowInfoKey()
void setMasterVolume:(float fraction)
void pollGuiArrowKeyControls:(double delta_t)
void pollFlightControls:(double delta_t)
void pollGuiScreenControls()
void disengageAutopilot()
void initKeyConfigSettings()
NSDictionary * dictionaryFromFilesNamed:inFolder:mergeMode:cache:(NSString *fileName,[inFolder] NSString *folderName,[mergeMode] OOResourceMergeMode mergeMode,[cache] BOOL useCache)
Entity * sortedEntities[UNIVERSE_MAX_ENTITIES+1]
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque