43#import "MyOpenGLView.h"
68#define CUSTOM_VIEW_ROTATE_SPEED 1.0
69#define CUSTOM_VIEW_ZOOM_SPEED 5.0
70#define CUSTOM_VIEW_SPEED_REDUCTION_FACTOR 0.3
107#if OO_RESOLUTION_OPTION
110#if OOLITE_SPEECH_SYNTH
111static BOOL speech_settings_pressed;
113static BOOL speechVoiceSelectKeyPressed;
114static BOOL speechGenderSelectKeyPressed;
167@interface PlayerEntity (OOControlsPrivate)
169- (void) pollFlightControls:(
double) delta_t;
170- (void) pollFlightArrowKeyControls:(
double) delta_t;
171- (void) pollGuiArrowKeyControls:(
double) delta_t;
180- (void) pollGuiScreenControlsWithFKeyAlias:(BOOL)fKeyAlias;
183- (void) pollGameOverControls:(
double) delta_t;
184- (void) pollAutopilotControls:(
double) delta_t;
185- (void) pollDockedControls:(
double) delta_t;
186- (void) pollDemoControls:(
double) delta_t;
190- (void) switchToThisView:(
OOViewID)viewDirection;
191- (void) switchToThisView:(
OOViewID)viewDirection andProcessWeaponFacing:(BOOL)processWeaponFacing;
192- (void) switchToThisView:(
OOViewID)viewDirection fromView:(
OOViewID)oldViewDirection andProcessWeaponFacing:(BOOL)processWeaponFacing justNotify:(BOOL)justNotify;
194- (void) handleAutopilotOn:(BOOL)fastDocking;
202@implementation PlayerEntity (Controls)
206 [keyCodeLookups release];
208 keyCodeLookups = [[NSDictionary alloc] initWithObjectsAndKeys:
209 [NSNumber numberWithUnsignedShort:gvArrowKeyLeft], @"arrowleft",
210 [NSNumber numberWithUnsignedShort:gvArrowKeyLeft], @"leftarrow",
211 [NSNumber numberWithUnsignedShort:gvArrowKeyLeft], @"left",
212 [NSNumber numberWithUnsignedShort:gvArrowKeyRight], @"arrowright",
213 [NSNumber numberWithUnsignedShort:gvArrowKeyRight], @"rightarrow",
214 [NSNumber numberWithUnsignedShort:gvArrowKeyRight], @"right",
215 [NSNumber numberWithUnsignedShort:gvArrowKeyUp], @"arrowup",
216 [NSNumber numberWithUnsignedShort:gvArrowKeyUp], @"uparrow",
217 [NSNumber numberWithUnsignedShort:gvArrowKeyUp], @"up",
218 [NSNumber numberWithUnsignedShort:gvArrowKeyDown], @"arrowdown",
219 [NSNumber numberWithUnsignedShort:gvArrowKeyDown], @"downarrow",
220 [NSNumber numberWithUnsignedShort:gvArrowKeyDown], @"down",
221 [NSNumber numberWithUnsignedShort:gvPageUpKey], @"pageup",
222 [NSNumber numberWithUnsignedShort:gvPageDownKey], @"pagedown",
223 [NSNumber numberWithUnsignedShort:13], @"enter",
224 [NSNumber numberWithUnsignedShort:13], @"return",
225 [NSNumber numberWithUnsignedShort:27], @"escape",
226 [NSNumber numberWithUnsignedShort:27], @"esc",
227 [NSNumber numberWithUnsignedShort:9], @"tab",
228 [NSNumber numberWithUnsignedShort:32], @"space",
229 [NSNumber numberWithUnsignedShort:32], @"spc",
230 [NSNumber numberWithUnsignedShort:gvHomeKey], @"home",
231 [NSNumber numberWithUnsignedShort:gvEndKey], @"end",
232 [NSNumber numberWithUnsignedShort:gvDeleteKey], @"delete",
233 [NSNumber numberWithUnsignedShort:gvDeleteKey], @"del",
234 [NSNumber numberWithUnsignedShort:gvBackspaceKey], @"backspace",
235 [NSNumber numberWithUnsignedShort:gvBackspaceKey], @"backspc",
236 [NSNumber numberWithUnsignedShort:gvBackspaceKey], @"bkspace",
237 [NSNumber numberWithUnsignedShort:gvBackspaceKey], @"bkspc",
238 [NSNumber numberWithUnsignedShort:gvInsertKey], @"insert",
239 [NSNumber numberWithUnsignedShort:gvInsertKey], @"ins",
240 [NSNumber numberWithUnsignedShort:gvFunctionKey1], @"f1",
241 [NSNumber numberWithUnsignedShort:gvFunctionKey2], @"f2",
242 [NSNumber numberWithUnsignedShort:gvFunctionKey3], @"f3",
243 [NSNumber numberWithUnsignedShort:gvFunctionKey4], @"f4",
244 [NSNumber numberWithUnsignedShort:gvFunctionKey5], @"f5",
245 [NSNumber numberWithUnsignedShort:gvFunctionKey6], @"f6",
246 [NSNumber numberWithUnsignedShort:gvFunctionKey7], @"f7",
247 [NSNumber numberWithUnsignedShort:gvFunctionKey8], @"f8",
248 [NSNumber numberWithUnsignedShort:gvFunctionKey9], @"f9",
249 [NSNumber numberWithUnsignedShort:gvFunctionKey10], @"f10",
250 [NSNumber numberWithUnsignedShort:gvFunctionKey11], @"f11",
251 [NSNumber numberWithUnsignedShort:gvPauseKey], @"pause",
252 [NSNumber numberWithUnsignedShort:gvPrintScreenKey], @"printscreen",
253 [NSNumber numberWithUnsignedShort:gvPrintScreenKey], @"prtscrn",
254 [NSNumber numberWithUnsignedShort:gvPrintScreenKey], @"prntscrn",
255 [NSNumber numberWithUnsignedShort:gvPrintScreenKey], @"prtscn",
256 [NSNumber numberWithUnsignedShort:gvNumberPadKey0], @"numpad0",
257 [NSNumber numberWithUnsignedShort:gvNumberPadKey1], @"numpad1",
258 [NSNumber numberWithUnsignedShort:gvNumberPadKey2], @"numpad2",
259 [NSNumber numberWithUnsignedShort:gvNumberPadKey3], @"numpad3",
260 [NSNumber numberWithUnsignedShort:gvNumberPadKey4], @"numpad4",
261 [NSNumber numberWithUnsignedShort:gvNumberPadKey5], @"numpad5",
262 [NSNumber numberWithUnsignedShort:gvNumberPadKey6], @"numpad6",
263 [NSNumber numberWithUnsignedShort:gvNumberPadKey7], @"numpad7",
264 [NSNumber numberWithUnsignedShort:gvNumberPadKey8], @"numpad8",
265 [NSNumber numberWithUnsignedShort:gvNumberPadKey9], @"numpad9",
266 [NSNumber numberWithUnsignedShort:gvNumberPadKeyDivide], @"numpad/",
267 [NSNumber numberWithUnsignedShort:gvNumberPadKeyDivide], @"numpaddivide",
268 [NSNumber numberWithUnsignedShort:gvNumberPadKeyMultiply], @"numpad*",
269 [NSNumber numberWithUnsignedShort:gvNumberPadKeyMultiply], @"numpadmultiply",
270 [NSNumber numberWithUnsignedShort:gvNumberPadKeyMinus], @"numpad-",
271 [NSNumber numberWithUnsignedShort:gvNumberPadKeyMinus], @"numpadminus",
272 [NSNumber numberWithUnsignedShort:gvNumberPadKeyPlus], @"numpad+",
273 [NSNumber numberWithUnsignedShort:gvNumberPadKeyPlus], @"numpadplus",
274 [NSNumber numberWithUnsignedShort:gvNumberPadKeyPeriod], @"numpad.",
275 [NSNumber numberWithUnsignedShort:gvNumberPadKeyPeriod], @"numpadperiod",
276 [NSNumber numberWithUnsignedShort:gvNumberPadKeyEquals], @"numpad=",
277 [NSNumber numberWithUnsignedShort:gvNumberPadKeyEquals], @"numpadequals",
278 [NSNumber numberWithUnsignedShort:gvNumberPadKeyEnter], @"numpadenter", nil];
280 keyShiftText = [DESC(@"oolite-keyconfig-shift") retain];
281 keyMod1Text = [DESC(@"oolite-keyconfig-mod1") retain];
283 keyMod2Text = [DESC(@"oolite-keyconfig-mod2-mac") retain];
285 keyMod2Text = [DESC(@"oolite-keyconfig-mod2-pc") retain];
294- (void) initKeyConfigSettings
297 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
298 NSString *kbd = [defaults oo_stringForKey:@"keyboard-code" defaultValue:@"default"];
299 NSMutableDictionary *kdic2 = [NSMutableDictionary dictionaryWithDictionary:[kdicmaster objectForKey:kbd]];
304 NSArray *def_list =
nil;
306 keys = [kdic2 allKeys];
307 for (i = 0; i < [keys count]; i++)
309 key = [keys objectAtIndex:i];
310 if ([[kdic2 objectForKey:key] isKindOfClass:[NSArray class]])
312 def_list = (NSArray*)[kdic2 objectForKey: key];
313 [kdic2 setObject:[
self processKeyCode:def_list] forKey:key];
318 [customEquipActivation release];
321 NSArray *temp = [defaults arrayForKey:KEYCONFIG_CUSTOMEQUIP];
322 customEquipActivation = [[NSMutableArray arrayWithArray:temp] retain];
326 customEquipActivation = [[NSMutableArray alloc] init];
328 [customActivatePressed release];
329 [customModePressed release];
330 customActivatePressed = [[NSMutableArray alloc] init];
331 customModePressed = [[NSMutableArray alloc] init];
332 for (i = 0; i < [customEquipActivation count]; i++)
334 [customActivatePressed addObject:[NSNumber numberWithBool:NO]];
335 [customModePressed addObject:[NSNumber numberWithBool:NO]];
338 NSMutableArray *keyDef =
nil;
339 NSString *lookup =
nil;
341 NSDictionary *key1 =
nil;
342 NSDictionary *key2 =
nil;
345 NSDictionary *dict = [defaults objectForKey:KEYCONFIG_OVERRIDES];
347 keys = [dict allKeys];
348 for (i = 0; i < [keys count]; i++)
350 key = [keys objectAtIndex:i];
351 [kdic2 setObject:[dict objectForKey:key] forKey:key];
356#define LOAD_KEY_SETTING2(name, default_1, shift_1, mod1_1, default_2, shift_2, mod1_2) \
357 lookup = [@#name substringFromIndex:2]; \
358 curr = (NSArray*)[[kdic2 objectForKey:lookup] copy]; \
359 key1 = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithUnsignedShort:default_1], @"key", [NSNumber numberWithBool:shift_1], @"shift", [NSNumber numberWithBool:mod1_1], @"mod1", [NSNumber numberWithBool:NO], @"mod2", nil]; \
360 [keyDef addObject:key1]; \
363 key2 = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithUnsignedShort:default_2], @"key", [NSNumber numberWithBool:shift_2], @"shift", [NSNumber numberWithBool:mod1_2], @"mod1", [NSNumber numberWithBool:NO], @"mod2", nil]; \
364 [keyDef addObject:key2]; \
366 name = curr?:keyDef; \
367 [kdic2 setObject:curr?:keyDef forKey:lookup]; \
500#if OO_FOV_INFLIGHT_CONTROL_ENABLED
516 [keyconfig2_settings release];
517 keyconfig2_settings = [[NSDictionary alloc] initWithDictionary:kdic2 copyItems:YES];
521- (NSArray*) processKeyCode:(NSArray*)key_def
524 id key =
nil, value =
nil;
526 unsigned char keychar;
527 NSString *keystring =
nil;
528 NSDictionary *def =
nil;
529 NSMutableArray *newList = [[NSMutableArray alloc] init];
531 for (i = 0; i < [key_def count]; i++)
533 def = [key_def objectAtIndex:i];
534 if ([def
count] == 0)
continue;
535 value = [def objectForKey:@"key"];
536 iValue = [value intValue];
540 NSMutableDictionary *defNew = [[NSMutableDictionary alloc] init];
541 if ([def objectForKey:
@"shift"]) [defNew setObject:[def objectForKey:
@"shift"] forKey:
@"shift"];
else [defNew setObject:[NSNumber numberWithBool:NO] forKey:@"shift"];
542 if ([def objectForKey:
@"mod1"]) [defNew setObject:[def objectForKey:
@"mod1"] forKey:
@"mod1"];
else [defNew setObject:[NSNumber numberWithBool:NO] forKey:@"mod1"];
543 if ([def objectForKey:
@"mod2"]) [defNew setObject:[def objectForKey:
@"mod2"] forKey:
@"mod2"];
else [defNew setObject:[NSNumber numberWithBool:NO] forKey:@"mod2"];
548 if ([value isKindOfClass:[NSString class]] && (iValue < 10))
553 if ([keystring length] != 0)
556 checkVal = [[keyCodeLookups objectForKey:[keystring lowercaseString]] intValue];
560 [defNew setObject:[NSNumber numberWithUnsignedShort:iValue] forKey:@"key"];
561 [newList addObject:defNew];
567 if ([keystring length] == 1 || (iValue == 0 && [keystring length] != 0))
569 keychar = [keystring characterAtIndex:0] & 0x00ff;
571 else if (iValue <= 0xFF) keychar = iValue;
573 OOLogWARN(
@"testing",
@"continue hit for key %@.", key);
574 [defNew setObject:[def objectForKey:@"key"] forKey:@"key"];
575 [newList addObject:defNew];
580 [defNew setObject:[NSNumber numberWithUnsignedShort:keychar] forKey:@"key"];
581 [newList addObject:defNew];
586 [defNew setObject:[def objectForKey:@"key"] forKey:@"key"];
587 [newList addObject:defNew];
597- (BOOL) checkNavKeyPress:(NSArray*)key_def
601 for (i = 0; i < [key_def count]; i++)
603 NSDictionary *def = [key_def objectAtIndex:i];
604 if ([gameView isDown:[[def objectForKey:
@"key"] intValue]]) return YES;
610- (BOOL) checkKeyPress:(NSArray*)key_def
612 return [
self checkKeyPress:key_def fKey_only:NO ignore_ctrl:NO];
616- (BOOL) checkKeyPress:(NSArray*)key_def fKey_only:(BOOL)fKey_only
618 return [
self checkKeyPress:key_def fKey_only:fKey_only ignore_ctrl:NO];
622- (BOOL) checkKeyPress:(NSArray*)key_def ignore_ctrl:(BOOL)ignore_ctrl
624 return [
self checkKeyPress:key_def fKey_only:NO ignore_ctrl:ignore_ctrl];
628- (BOOL) checkKeyPress:(NSArray*)key_def fKey_only:(BOOL)fKey_only ignore_ctrl:(BOOL)ignore_ctrl
632 for (i = 0; i < [key_def count]; i++)
634 NSDictionary *def = [key_def objectAtIndex:i];
635 int keycode = [[def objectForKey:@"key"] intValue];
642 if (fKey_only == YES && (keycode < gvFunctionKey1 || keycode >
gvFunctionKey11))
continue;
643 if ([gameView isDown:keycode]
644 && ([[def objectForKey:
@"shift"] boolValue] == [gameView isShiftDown])
645 && (ignore_ctrl || ([[def objectForKey:
@"mod1"] boolValue] == [gameView isCtrlDown]))
646 && ([[def objectForKey:
@"mod2"] boolValue] == [gameView isOptDown])
653- (
int) getFirstKeyCode:(NSArray*)key_def
655 NSDictionary *def = [key_def objectAtIndex:0];
656 return [[def objectForKey:@"key"] intValue];
660- (void) pollControls:(
double)delta_t
663 NSString *exceptionContext =
@"setup";
670 exceptionContext =
@"pollApplicationControls";
671 [
self pollApplicationControls];
672 switch ([
self status])
674 case STATUS_WITCHSPACE_COUNTDOWN:
675 case STATUS_IN_FLIGHT:
676 exceptionContext =
@"pollFlightControls";
677 [
self pollFlightControls:delta_t];
681 exceptionContext =
@"pollGameOverControls";
682 [
self pollGameOverControls:delta_t];
685 case STATUS_AUTOPILOT_ENGAGED:
686 exceptionContext =
@"pollAutopilotControls";
687 [
self pollAutopilotControls:delta_t];
691 exceptionContext =
@"pollDockedControls";
692 [
self pollDockedControls:delta_t];
695 case STATUS_START_GAME:
696 exceptionContext =
@"pollDemoControls";
697 [
self pollDemoControls:delta_t];
706 @catch (NSException *exception)
708 OOLog(
kOOLogException,
@"***** Exception checking controls [%@]: %@ : %@", exceptionContext, [exception name], [exception reason]);
713- (BOOL) handleGUIUpDownArrowKeys
718 BOOL arrow_up = [
self checkKeyPress:n_key_gui_arrow_up];
719 BOOL arrow_down = [
self checkKeyPress:n_key_gui_arrow_down];
720 BOOL mouse_click = [gameView
isDown:gvMouseLeftButton];
721 BOOL mouse_dbl_click = [gameView
isDown:gvMouseDoubleClick];
727 if ([gui setNextRow: +1])
733 if ([gui setFirstSelectableRow]) result = YES;
736 if (result && [gui selectableRange].length > 1) [
self playMenuNavigationDown];
737 else [
self playMenuNavigationNot];
747 if ([gui setNextRow: -1])
753 if ([gui setLastSelectableRow]) result = YES;
756 if (result && [gui selectableRange].length > 1) [
self playMenuNavigationUp];
757 else [
self playMenuNavigationNot];
770 if ([gui setSelectedRow:click_row])
781 if ([gui setSelectedRow:click_row])
801- (void) targetNewSystem:(
int) direction whileTyping:(BOOL) whileTyping
803 target_system_id = [[UNIVERSE gui] targetNextFoundSystem:direction];
804 [
self setInfoSystemID: target_system_id moveChart: YES];
805 cursor_coordinates = [[UNIVERSE systemManager] getCoordinatesForSystem:target_system_id inGalaxy:galaxy_number];
807 found_system_id = target_system_id;
810 [
self clearPlanetSearchString];
816- (void) clearPlanetSearchString
818 [[UNIVERSE gameView] resetTypedString];
819 if (planetSearchString) [planetSearchString release];
820 planetSearchString =
nil;
824- (void) targetNewSystem:(
int) direction
826 [
self targetNewSystem:direction whileTyping:NO];
830- (void) switchToMainView
833 gui_screen = GUI_SCREEN_MAIN;
836 [
self setShowDemoShips: NO];
837 [UNIVERSE removeDemoShips];
839 [(
MyOpenGLView *)[UNIVERSE gameView] allowStringInput:NO];
840 if ([
self isMouseControlOn]) [[UNIVERSE gameView] resetMouse];
841 [UNIVERSE enterGUIViewModeWithMouseInteraction:NO];
842 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
848 [
self switchToThisView:toView fromView:fromView andProcessWeaponFacing:NO justNotify:YES];
853-(void) beginWitchspaceCountdown:(
int)spin_time
855 if ([
self hasHyperspaceMotor])
859 witchspaceCountdown = hyperspaceMotorSpinTime;
863#ifndef OO_DUMP_PLANETINFO
866 witchspaceCountdown = 5;
871 witchspaceCountdown = spin_time;
874 [
self setStatus:STATUS_WITCHSPACE_COUNTDOWN];
875 [
self playStandardHyperspace];
877 [UNIVERSE clearPreviousMessage];
878 int seconds = round(witchspaceCountdown);
879 NSString *destination = [UNIVERSE getSystemName:[
self nextHopTargetSystemID]];
880 [UNIVERSE displayCountdownMessage:OOExpandKey(@"witch-to-x-in-y-seconds", seconds, destination) forCount:1.0];
881 [
self doScriptEvent:OOJSID("playerStartedJumpCountdown")
882 withArguments:[NSArray arrayWithObjects:@"standard", [NSNumber numberWithFloat:witchspaceCountdown], nil]];
883 [UNIVERSE preloadPlanetTexturesForSystem:target_system_id];
888-(void) beginWitchspaceCountdown
890 if ([
self hasHyperspaceMotor]) {
891 [
self beginWitchspaceCountdown:hyperspaceMotorSpinTime];
896-(void) cancelWitchspaceCountdown
898 if ([
self status] == STATUS_WITCHSPACE_COUNTDOWN) {
899 [
self setStatus:STATUS_IN_FLIGHT];
900 [
self playHyperspaceAborted];
903 [UNIVERSE clearPreviousMessage];
904 [
self doScriptEvent:OOJSID("playerCancelledJumpCountdown")];
910@implementation PlayerEntity (OOControlsPrivate)
912- (void) pollApplicationControls
914 if (!pollControls)
return;
916 NSString *exceptionContext =
@"setup";
922 BOOL onTextEntryScreen = (gui_screen == GUI_SCREEN_LONG_RANGE_CHART) || (gui_screen == GUI_SCREEN_MISSION) ||
923 (gui_screen == GUI_SCREEN_SAVE) || (gui_screen == GUI_SCREEN_OXZMANAGER || (gui_screen == GUI_SCREEN_KEYBOARD_ENTRY));
928 #if !OOLITE_MAC_OS_X || !OOLITE_64_BIT
929 if ([gameController inFullScreenMode])
931 exceptionContext =
@"command key controls";
932 if ([gameView isCommandFDown])
936 if (mouse_control_on)
938 [UNIVERSE addMessage:DESC(@"mouse-off") forCount:3.0];
939 mouse_control_on = NO;
943 if ([gameView isCommandQDown])
951 if ([
self status] == STATUS_HANDLING_ERROR)
953 exceptionContext =
@"error handling mode";
954 if ([gameView isDown:113]||[gameView isDown:81]||[gameView isDown:27])
960 if ([gameController isGamePaused])
963 switch ([
self status])
965 case STATUS_WITCHSPACE_COUNTDOWN:
966 case STATUS_IN_FLIGHT:
967 case STATUS_AUTOPILOT_ENGAGED:
979 [UNIVERSE clearPreviousMessage];
991 if (([
self checkKeyPress:n_key_snapshot] || joyButtonState[
BUTTON_SNAPSHOT]) &&
995 exceptionContext =
@"snapshot";
1008 if (!onTextEntryScreen && [
self checkKeyPress:n_key_show_fps])
1010 exceptionContext =
@"toggle FPS";
1011 if (!
f_key_pressed) [UNIVERSE setDisplayFPS:![UNIVERSE displayFPS]];
1020 if ([
self checkKeyPress:n_key_bloom_toggle])
1024 BOOL oldBloom = [UNIVERSE bloom];
1025 [UNIVERSE setBloom:!oldBloom];
1035 BOOL allowMouseControl;
1037 allowMouseControl = YES;
1040 [[NSUserDefaults standardUserDefaults] boolForKey:@"mouse-control-in-windowed-mode"];
1043 if (allowMouseControl)
1045 exceptionContext =
@"mouse control";
1046 if (!onTextEntryScreen && ([
self checkKeyPress:n_key_mouse_control_roll] || [
self checkKeyPress:n_key_mouse_control_yaw]))
1050 mouse_control_on = !mouse_control_on;
1051 if (mouse_control_on)
1053 [UNIVERSE addMessage:DESC(@"mouse-on") forCount:3.0];
1059 if ([[NSUserDefaults standardUserDefaults] boolForKey:
@"grab-mouse-on-mouse-control"])
1066 keyboardPitchOverride = NO;
1067 keyboardYawOverride = !keyboardRollOverride;
1071 [UNIVERSE addMessage:DESC(@"mouse-off") forCount:3.0];
1090 if (mouse_control_on)
1092 mouse_control_on = NO;
1093 [UNIVERSE addMessage:DESC(@"mouse-off") forCount:3.0];
1106 if (([
self checkKeyPress:n_key_hud_toggle] || joyButtonState[
BUTTON_TOGGLEHUD]) && [gameController isGamePaused] && !onTextEntryScreen)
1108 exceptionContext =
@"toggle HUD";
1113 if (gui_screen == GUI_SCREEN_STATUS)
1116 [
self setGuiToStatusScreen];
1126 @catch (NSException *exception)
1128 OOLog(
kOOLogException,
@"***** Exception in pollApplicationControls [%@]: %@ : %@", exceptionContext, [exception name], [exception reason]);
1133- (void) pollFlightControls:(
double)delta_t
1137 NSString *exceptionContext =
@"setup";
1141 exceptionContext =
@"joystick handling";
1144 BOOL paused = [[UNIVERSE gameController] isGamePaused];
1147 if (!paused && gui_screen == GUI_SCREEN_MISSION)
1149 exceptionContext =
@"mission screen";
1152 NSPoint virtualView = NSZeroPoint;
1153 double view_threshold = 0.5;
1155 if ([stickHandler joystickCount])
1157 virtualView = [stickHandler
viewAxis];
1159 virtualView.y = 0.0;
1161 virtualView.x = 0.0;
1162 if (fabs(virtualView.y) >= fabs(virtualView.x))
1163 virtualView.x = 0.0;
1165 virtualView.y = 0.0;
1168 if ([
self checkKeyPress:n_key_view_forward] || (virtualView.
y < -view_threshold) || joyButtonState[
BUTTON_VIEWFORWARD])
1170 view = VIEW_FORWARD;
1172 if ([
self checkKeyPress:n_key_view_aft]|(virtualView.
y > view_threshold)||joyButtonState[
BUTTON_VIEWAFT])
1176 if ([
self checkKeyPress:n_key_view_port]||(virtualView.
x < -view_threshold)||joyButtonState[
BUTTON_VIEWPORT])
1180 if ([
self checkKeyPress:n_key_view_starboard]||(virtualView.
x > view_threshold)||joyButtonState[
BUTTON_VIEWSTARBOARD])
1182 view = VIEW_STARBOARD;
1184 if (view == VIEW_NONE)
1187 [
self pollDemoControls: delta_t];
1191 [[UNIVERSE gui] clearBackground];
1192 [
self switchToThisView:view];
1193 if (_missionWithCallback)
1195 [
self doMissionCallback];
1198 [
self doWorldEventUntilMissionScreen:OOJSID("missionScreenEnded")];
1203 exceptionContext =
@"arrow keys";
1206 [
self pollGuiArrowKeyControls:delta_t];
1208 [
self pollFlightArrowKeyControls:delta_t];
1211 [
self pollViewControls];
1215 exceptionContext =
@"afterburner";
1216 if ((joyButtonState[
BUTTON_FUELINJECT] || [
self checkKeyPress:n_key_inject_fuel]) &&
1217 [
self hasFuelInjection] &&
1218 !hyperspeed_engaged)
1220 if (fuel > 0 && !afterburner_engaged)
1222 [UNIVERSE addMessage:DESC(@"fuel-inject-on") forCount:1.5];
1223 afterburner_engaged = YES;
1224 [
self startAfterburnerSound];
1229 [UNIVERSE addMessage:DESC(@"fuel-out") forCount:1.5];
1231 afterburner_engaged = (fuel > 0);
1234 afterburner_engaged = NO;
1236 if ((!afterburner_engaged)&&(afterburnerSoundLooping))
1237 [
self stopAfterburnerSound];
1239 exceptionContext =
@"thrust";
1241 double reqSpeed=[stickHandler
getAxisState: AXIS_THRUST];
1242 float mouseWheelDeltaFactor = mouse_control_on ? fabs([gameView mouseWheelDelta]) : 1.0f;
1243 if (mouseWheelDeltaFactor == 0.0f) mouseWheelDeltaFactor = 1.0f;
1245 if (([
self checkKeyPress:n_key_increase_speed] ||
1247 ((mouse_control_on)&&([gameView mouseWheelState] ==
gvMouseWheelUp) && ([
UNIVERSE viewDirection] <= VIEW_STARBOARD || ![gameView isCapsLockOn])))
1248 && (flightSpeed < maxFlightSpeed) && (!afterburner_engaged))
1250 flightSpeed += speed_delta * delta_t * mouseWheelDeltaFactor;
1253 if (([
self checkKeyPress:n_key_decrease_speed] ||
1255 ((mouse_control_on)&&([gameView mouseWheelState] ==
gvMouseWheelDown) && ([
UNIVERSE viewDirection] <= VIEW_STARBOARD || ![gameView isCapsLockOn])))
1256 && (!afterburner_engaged))
1258 flightSpeed -= speed_delta * delta_t * mouseWheelDeltaFactor;
1260 hyperspeed_engaged = NO;
1263 NSDictionary *functionForThrustAxis = [[stickHandler
axisFunctions] oo_dictionaryForKey:[[NSNumber numberWithInt:AXIS_THRUST] stringValue]];
1264 if([stickHandler joystickCount] != 0 && functionForThrustAxis !=
nil)
1266 if (flightSpeed < maxFlightSpeed * reqSpeed)
1268 flightSpeed += speed_delta * delta_t;
1270 if (flightSpeed > maxFlightSpeed * reqSpeed)
1272 flightSpeed -= speed_delta * delta_t;
1276 if (!afterburner_engaged && ![
self atHyperspeed] && !hyperspeed_engaged)
1278 flightSpeed = OOClamp_0_max_f(flightSpeed, maxFlightSpeed);
1281 exceptionContext =
@"hyperspeed";
1287 if (!hyperspeed_engaged)
1289 hyperspeed_locked = [
self massLocked];
1290 hyperspeed_engaged = !hyperspeed_locked;
1291 if (hyperspeed_locked)
1293 [
self playJumpMassLocked];
1294 [UNIVERSE addMessage:DESC(@"jump-mass-locked") forCount:1.5];
1299 hyperspeed_engaged = NO;
1309 exceptionContext =
@"shoot";
1311 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))
1313 if ([
self fireMainWeapon])
1315 [
self playLaserHit:([
self shipHitByLaser] != nil) offset:[[
self currentLaserOffset] oo_vectorAtIndex:0] weaponIdentifier:[[
self currentWeapon] identifier]];
1319 exceptionContext =
@"weapons online toggle";
1325 NSString* weaponsOnlineToggleMsg;
1327 [
self setWeaponsOnline:![
self weaponsOnline]];
1328 weaponsOnlineToggleMsg = [
self weaponsOnline] ?
DESC(
@"weapons-systems-online") :
DESC(
@"weapons-systems-offline");
1329 if ([
self weaponsOnline])
1331 [
self playWeaponsOnline];
1335 [
self playWeaponsOffline];
1337 [UNIVERSE addMessage:weaponsOnlineToggleMsg forCount:2.0];
1338 [
self doScriptEvent:OOJSID("weaponsSystemsToggled") withArgument:[NSNumber numberWithBool:[
self weaponsOnline]]];
1344 exceptionContext =
@"missile fire";
1357 exceptionContext =
@"next missile";
1363 [
self playNextMissileSelected];
1364 [
self selectNextMissile];
1370 exceptionContext =
@"next target";
1372 if ([
self checkKeyPress:n_key_next_target] || joyButtonState[
BUTTON_NEXTTARGET])
1376 [
self moveTargetMemoryBy:+1];
1382 exceptionContext =
@"previous target";
1384 if ([
self checkKeyPress:n_key_previous_target] || joyButtonState[
BUTTON_PREVTARGET])
1388 [
self moveTargetMemoryBy:-1];
1394 exceptionContext =
@"ident R";
1396 if ([
self checkKeyPress:n_key_ident_system] || joyButtonState[
BUTTON_ID])
1401 [
self handleButtonIdent];
1407 exceptionContext =
@"prime equipment";
1416 NSUInteger c = [eqScripts count];
1424 if (primedEquipment > c) primedEquipment = 0;
1428 if (primedEquipment > 0) primedEquipment--;
1429 else primedEquipment = c;
1432 NSString *eqKey =
@"";
1434 if (primedEquipment == c)
1438 [
self playNextEquipmentSelected];
1439 [UNIVERSE addMessage:DESC(@"equipment-primed-none") forCount:2.0];
1441 else [UNIVERSE addMessage:DESC(@"equipment-primed-none-available") forCount:2.0];
1445 [
self playNextEquipmentSelected];
1447 eqKey = [[eqScripts oo_arrayAtIndex:primedEquipment] oo_stringAtIndex:0];
1448 [UNIVERSE addMessage:OOExpandKey(@"equipment-primed", equipmentName) forCount:2.0];
1450 [
self doScriptEvent:OOJSID("playerChangedPrimedEquipment") withArgument:eqKey];
1457 exceptionContext =
@"activate equipment";
1463 [
self activatePrimableEquipment:primedEquipment withMode:OOPRIMEDEQUIP_ACTIVATED];
1469 exceptionContext =
@"mode equipment";
1475 [
self activatePrimableEquipment:primedEquipment withMode:OOPRIMEDEQUIP_MODE];
1481 exceptionContext =
@"fast equipment A";
1482 if ([
self checkKeyPress:n_key_fastactivate_equipment_a] || joyButtonState[
BUTTON_CLOAK])
1486 [
self activatePrimableEquipment:[
self eqScriptIndexForKey:[
self fastEquipmentA]] withMode:OOPRIMEDEQUIP_ACTIVATED];
1492 exceptionContext =
@"fast equipment B";
1493 if ([
self checkKeyPress:n_key_fastactivate_equipment_b] || joyButtonState[
BUTTON_ENERGYBOMB])
1497 [
self activatePrimableEquipment:[
self eqScriptIndexForKey:[
self fastEquipmentB]] withMode:OOPRIMEDEQUIP_ACTIVATED];
1503 exceptionContext =
@"custom equipment";
1507 for (i = 0; i < [customEquipActivation count]; i++)
1509 item = [customEquipActivation objectAtIndex:i];
1511 if ([
self hasOneEquipmentItem:[item oo_stringForKey:
CUSTOMEQUIP_EQUIPKEY] includeWeapons:NO whileLoading:NO])
1513 NSArray *key_act = [item oo_arrayForKey:CUSTOMEQUIP_KEYACTIVATE];
1514 NSArray *key_mod = [item oo_arrayForKey:CUSTOMEQUIP_KEYMODE];
1515 NSDictionary *but_act = [item oo_dictionaryForKey:CUSTOMEQUIP_BUTTONACTIVATE];
1516 NSDictionary *but_mod = [item oo_dictionaryForKey:CUSTOMEQUIP_BUTTONMODE];
1521 if (![[customActivatePressed objectAtIndex:i] boolValue])
1524 [
self activatePrimableEquipment:[
self eqScriptIndexForKey:[item oo_stringForKey:CUSTOMEQUIP_EQUIPKEY]] withMode:OOPRIMEDEQUIP_ACTIVATED];
1526 [customActivatePressed replaceObjectAtIndex:i withObject:[NSNumber numberWithBool:YES]];
1528 else [customActivatePressed replaceObjectAtIndex:i withObject:[NSNumber numberWithBool:NO]];
1533 if (![[customModePressed objectAtIndex:i] boolValue])
1536 [
self activatePrimableEquipment:[
self eqScriptIndexForKey:[item oo_stringForKey:CUSTOMEQUIP_EQUIPKEY]] withMode:OOPRIMEDEQUIP_MODE];
1538 [customModePressed replaceObjectAtIndex:i withObject:[NSNumber numberWithBool:YES]];
1540 else [customModePressed replaceObjectAtIndex:i withObject:[NSNumber numberWithBool:NO]];
1544 exceptionContext =
@"incoming missile T";
1550 [
self targetNearestIncomingMissile];
1556 exceptionContext =
@"missile T";
1558 if (([
self checkKeyPress:n_key_target_missile] || joyButtonState[
BUTTON_ARMMISSILE])&&(missile_entity[activeMissile]))
1563 [
self handleButtonTargetMissile];
1569 exceptionContext =
@"missile U";
1571 if ([
self checkKeyPress:n_key_untarget_missile] || joyButtonState[
BUTTON_UNARM])
1576 if ([
self primaryTarget] !=
nil) [
self noteLostTarget];
1578 [
self safeAllMissiles];
1579 if (!ident_engaged && [
self weaponsOnline])
1581 [UNIVERSE addMessage:DESC(@"missile-safe") forCount:2.0];
1582 [
self playMissileSafe];
1586 [UNIVERSE addMessage:DESC(@"ident-off") forCount:2.0];
1587 [
self playIdentOff];
1595 exceptionContext =
@"ECM";
1597 if (([
self checkKeyPress:n_key_ecm] || joyButtonState[
BUTTON_ECM]) && [
self hasECM])
1599 if (!ecm_in_operation)
1601 if ([
self weaponsOnline] && [
self fireECM])
1603 [
self playFiredECMSound];
1604 [UNIVERSE addMessage:DESC(@"ecm-on") forCount:3.0];
1610 exceptionContext =
@"escape pod";
1614 if (([
self checkKeyPress:n_key_launch_escapepod] || joyButtonState[
BUTTON_ESCAPE]) && [
self hasEscapePod])
1616 BOOL goodToLaunch = [[NSUserDefaults standardUserDefaults] boolForKey:@"escape-pod-activation-immediate"];
1627 [gameView
clearKey:[
self getFirstKeyCode:n_key_launch_escapepod]];
1628 if ([stickHandler joystickCount])
1635 OOTimeDelta timeNow = [NSDate timeIntervalSinceReferenceDate];
1637 if (timeNow < escapePodKeyResetTime) goodToLaunch = YES;
1642 [
self launchEscapeCapsule];
1646 exceptionContext =
@"dump cargo";
1648 if (([
self checkKeyPress:n_key_dump_cargo] || joyButtonState[
BUTTON_JETTISON]) && [cargo
count] > 0)
1653 exceptionContext =
@"rotate cargo";
1664 exceptionContext =
@"autopilot C";
1666 if ([
self checkKeyPress:n_key_autopilot] || joyButtonState[
BUTTON_DOCKCPU])
1670 [
self handleAutopilotOn:false];
1677 exceptionContext =
@"autopilot shift-C";
1683 [
self handleAutopilotOn:true];
1692 exceptionContext =
@"docking clearance request";
1698 Entity *primeTarget = [
self primaryTarget];
1699 [
self performDockingRequest:(StationEntity*)primeTarget];
1708 exceptionContext =
@"hyperspace";
1710 if ( ([
self checkKeyPress:n_key_hyperspace] || joyButtonState[
BUTTON_HYPERDRIVE]) &&
1711 [
self hasHyperspaceMotor] )
1715 if ([
self status] == STATUS_WITCHSPACE_COUNTDOWN)
1717 [
self cancelWitchspaceCountdown];
1718 if (galactic_witchjump)
1720 galactic_witchjump = NO;
1721 [UNIVERSE addMessage:DESC(@"witch-user-galactic-abort") forCount:3.0];
1725 [UNIVERSE addMessage:DESC(@"witch-user-abort") forCount:3.0];
1728 else if ([
self witchJumpChecklist:false])
1730 [
self beginWitchspaceCountdown:hyperspaceMotorSpinTime];
1738 exceptionContext =
@"galactic hyperspace";
1740 if (([
self checkKeyPress:n_key_galactic_hyperspace] || joyButtonState[
BUTTON_GALACTICDRIVE]) &&
1741 ([
self hasEquipmentItemProviding:
@"EQ_GAL_DRIVE"]))
1745 if ([
self status] == STATUS_WITCHSPACE_COUNTDOWN)
1747 [
self cancelWitchspaceCountdown];
1748 if (galactic_witchjump)
1750 galactic_witchjump = NO;
1751 [UNIVERSE addMessage:DESC(@"witch-user-galactic-abort") forCount:3.0];
1755 [UNIVERSE addMessage:DESC(@"witch-user-abort") forCount:3.0];
1760 galactic_witchjump = YES;
1763 if(
EXPECT([
self hasHyperspaceMotor])) witchspaceCountdown = hyperspaceMotorSpinTime;
1766 [
self setStatus:STATUS_WITCHSPACE_COUNTDOWN];
1767 [
self playGalacticHyperspace];
1769 [UNIVERSE addMessage:[NSString stringWithFormat:DESC(@"witch-galactic-in-f-seconds"), witchspaceCountdown] forCount:1.0];
1772 [
self doScriptEvent:OOJSID("playerStartedJumpCountdown")
1773 withArguments:[NSArray arrayWithObjects:@"galactic", [NSNumber numberWithFloat:witchspaceCountdown], nil]];
1783#if OO_FOV_INFLIGHT_CONTROL_ENABLED
1787 if (([
self checkKeyPress:n_key_inc_field_of_view] || joyButtonState[BUTTON_INC_FIELD_OF_VIEW]) && (fieldOfView <
MAX_FOV))
1789 fieldOfView *= pow(fov_delta, delta_t);
1793 if (([
self checkKeyPress:n_key_dec_field_of_view] || joyButtonState[BUTTON_DEC_FIELD_OF_VIEW]) && (fieldOfView >
MIN_FOV))
1795 fieldOfView /= pow(fov_delta, delta_t);
1799 NSDictionary *functionForFovAxis = [[stickHandler
axisFunctions] oo_dictionaryForKey:[[NSNumber numberWithInt:AXIS_FIELD_OF_VIEW] stringValue]];
1800 if ([stickHandler joystickCount] != 0 && functionForFovAxis !=
nil)
1803 double reqFov = [stickHandler
getAxisState: AXIS_FIELD_OF_VIEW];
1804 if (fieldOfView < maxFieldOfView * reqFov)
1806 fieldOfView *= pow(fov_delta, delta_t);
1809 if (fieldOfView > maxFieldOfView * reqFov)
1811 fieldOfView /= pow(fov_delta, delta_t);
1819 exceptionContext =
@"dump target state";
1820 if ([
self checkKeyPress:n_key_dump_target_state])
1825 id target = [
self primaryTarget];
1826 if (target ==
nil) target =
self;
1834 exceptionContext =
@"pollGuiScreenControls";
1835 [
self pollGuiScreenControls];
1841 exceptionContext =
@"options menu";
1842 if (([
self checkKeyPress:n_key_gui_screen_options]) && (gui_screen != GUI_SCREEN_OPTIONS) && ![gameView allowingStringInput])
1845 [
self setGuiToLoadSaveScreen];
1848 #if (ALLOW_CUSTOM_VIEWS_WHILE_PAUSED)
1849 [
self pollCustomViewControls];
1852 if (gui_screen == GUI_SCREEN_OPTIONS || gui_screen == GUI_SCREEN_GAMEOPTIONS || gui_screen == GUI_SCREEN_STICKMAPPER ||
1853 gui_screen == GUI_SCREEN_STICKPROFILE || gui_screen == GUI_SCREEN_KEYBOARD || gui_screen == GUI_SCREEN_KEYBOARD_CONFIRMCLEAR ||
1854 gui_screen == GUI_SCREEN_KEYBOARD_CONFIG || gui_screen == GUI_SCREEN_KEYBOARD_ENTRY || gui_screen == GUI_SCREEN_KEYBOARD_LAYOUT)
1856 if ([
UNIVERSE pauseMessageVisible]) [[UNIVERSE messageGUI] leaveLastLine];
1857 else [[UNIVERSE messageGUI] clear];
1858 NSTimeInterval time_this_frame = [NSDate timeIntervalSinceReferenceDate];
1871 script_time += time_delta;
1872 [
self pollGuiArrowKeyControls:time_delta];
1875 exceptionContext =
@"debug keys";
1878 if ([
self checkKeyPress:n_key_dump_entity_list] && ![gameView allowingStringInput])
1882 [UNIVERSE debugDumpEntities];
1884 [UNIVERSE addMessage:@"Entity List dumped. Debugging OFF" forCount:3];
1892 if ([
self checkKeyPress:n_key_debug_full] && ![gameView allowingStringInput])
1895 [UNIVERSE addMessage:@"Full debug ON" forCount:3];
1898 if ([
self checkKeyPress:n_key_debug_collision] && ![gameView allowingStringInput])
1901 [UNIVERSE addMessage:@"Collision debug ON" forCount:3];
1904 if ([
self checkKeyPress:n_key_debug_console_connect] && ![[
OODebugMonitor sharedDebugMonitor] usingPlugInController] && ![gameView allowingStringInput])
1913 [UNIVERSE addMessage:@"Connected to debug console." forCount:3];
1918 [UNIVERSE addMessage:@"Disconnected from debug console." forCount:3];
1926 if ([
self checkKeyPress:n_key_debug_bounding_boxes] && ![gameView allowingStringInput])
1929 [UNIVERSE addMessage:@"Bounding box debug ON" forCount:3];
1932 if ([
self checkKeyPress:n_key_debug_shaders] && ![gameView allowingStringInput])
1935 [UNIVERSE addMessage:@"Shader debug ON" forCount:3];
1938 if (([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_arrow_right]) && gui_screen != GUI_SCREEN_GAMEOPTIONS && [
UNIVERSE displayFPS] && ![gameView allowingStringInput])
1942 float newTimeAccelerationFactor = [
self checkKeyPress:n_key_gui_arrow_left] ?
1945 [UNIVERSE setTimeAccelerationFactor:newTimeAccelerationFactor];
1953 if ([
self checkKeyPress:n_key_debug_off] && ![gameView allowingStringInput])
1956 [UNIVERSE addMessage:@"All debug flags OFF" forCount:3];
1962 exceptionContext =
@"pause";
1964 if (([
self checkKeyPress:n_key_pausebutton] || joyButtonState[
BUTTON_PAUSE]) && gui_screen != GUI_SCREEN_LONG_RANGE_CHART && gui_screen != GUI_SCREEN_MISSION && ![gameView allowingStringInput])
1976 case GUI_SCREEN_STATUS:
1977 [
self setGuiToStatusScreen];
1979 case GUI_SCREEN_LONG_RANGE_CHART:
1980 [
self setGuiToLongRangeChartScreen];
1982 case GUI_SCREEN_SHORT_RANGE_CHART:
1983 [
self setGuiToShortRangeChartScreen];
1985 case GUI_SCREEN_MANIFEST:
1986 [
self setGuiToManifestScreen];
1988 case GUI_SCREEN_MARKET:
1989 [
self setGuiToMarketScreen];
1991 case GUI_SCREEN_MARKETINFO:
1992 [
self setGuiToMarketInfoScreen];
1994 case GUI_SCREEN_SYSTEM_DATA:
1996 if (gui_screen != GUI_SCREEN_SYSTEM_DATA)
1997 [
self setGuiToSystemDataScreen];
2004 [UNIVERSE clearPreviousMessage];
2005 [UNIVERSE setViewDirection:saved_view_direction];
2008 if (
saved_gui_screen == GUI_SCREEN_SYSTEM_DATA) [UNIVERSE setMainLightPosition:_sysInfoLight];
2009 [[UNIVERSE gui] setForegroundTextureKey:@"overlay"];
2010 [[UNIVERSE gameController] setGamePaused:NO];
2018 [UNIVERSE pauseGame];
2028 @catch (NSException *exception)
2030 OOLog(
kOOLogException,
@"***** Exception in pollFlightControls [%@]: %@ : %@", exceptionContext, [exception name], [exception reason]);
2035- (void) pollGuiArrowKeyControls:(
double) delta_t
2040 double cursor_speed = ([gameView
isCtrlDown] ? 20.0 : 10.0)* chart_zoom;
2046 if (gui_screen == GUI_SCREEN_LONG_RANGE_CHART)
2050 else if (gui_screen == GUI_SCREEN_SAVE)
2054 else if (gui_screen == GUI_SCREEN_MISSION && _missionTextEntry)
2058 else if (gui_screen == GUI_SCREEN_KEYBOARD_ENTRY)
2065 else if (gui_screen == GUI_SCREEN_OXZMANAGER && [[
OOOXZManager sharedManager] isAcceptingTextInput])
2075 if (afterburner_engaged && ![
self checkKeyPress:n_key_inject_fuel])
2077 afterburner_engaged = NO;
2084 case GUI_SCREEN_LONG_RANGE_CHART:
2086 if ([
self status] != STATUS_WITCHSPACE_COUNTDOWN)
2088 if ([[gameView typedString] length] > 0)
2090 planetSearchString = [[[gameView
typedString] lowercaseString] retain];
2091 NSPoint search_coords = [UNIVERSE findSystemCoordinatesWithPrefix:planetSearchString];
2092 if ((search_coords.x >= 0.0)&&(search_coords.y >= 0.0))
2095 if ([planetSearchString length] == 1) [[UNIVERSE gui] targetNextFoundSystem:0];
2098 [
self targetNewSystem:0 whileTyping:YES];
2102 found_system_id = -1;
2103 [
self clearPlanetSearchString];
2110 found_system_id = -1;
2111 [UNIVERSE findSystemCoordinatesWithPrefix:@""];
2113 if (planetSearchString) [planetSearchString release];
2114 planetSearchString =
nil;
2121 case GUI_SCREEN_SHORT_RANGE_CHART:
2123 if ([
self checkKeyPress:n_key_chart_highlight])
2128 if (
mode != OOLRC_MODE_TECHLEVEL)
2130 [
self setLongRangeChartMode:mode+1];
2134 [
self setLongRangeChartMode:OOLRC_MODE_SUNCOLOR];
2136 [
self doScriptEvent:OOJSID("chartHighlightModeChanged") withArgument:OOStringFromLongRangeChartMode([
self longRangeChartMode])];
2149 show_info_flag = !show_info_flag;
2158 if ([
self status] != STATUS_WITCHSPACE_COUNTDOWN)
2160 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
2162 if ([
self checkKeyPress:n_key_advanced_nav_array_next] || [
self checkKeyPress:n_key_advanced_nav_array_previous])
2166 if ([
self checkKeyPress:n_key_advanced_nav_array_previous])
2186 [
self setInfoSystemID: target_system_id moveChart: NO];
2205 [
self noteGUIWillChangeTo:GUI_SCREEN_SYSTEM_DATA];
2206 showingLongRangeChart = (gui_screen == GUI_SCREEN_LONG_RANGE_CHART);
2207 [
self setGuiToSystemDataScreen];
2218 NSPoint centre = [
self adjusted_chart_centre];
2221 chart_focus_coordinates.x = OOClamp_0_max_f(centre.x + (maus.x *
MAIN_GUI_PIXEL_WIDTH) / hscale, 256.0);
2222 chart_focus_coordinates.y = OOClamp_0_max_f(centre.y + (maus.y *
MAIN_GUI_PIXEL_HEIGHT + vadjust) / vscale, 256.0);
2223 target_chart_focus = chart_focus_coordinates;
2230 target_chart_centre = chart_centre_coordinates;
2233 if (gui_screen == GUI_SCREEN_LONG_RANGE_CHART)
2243 cursor_coordinates = chart_focus_coordinates;
2252 if ([
self checkKeyPress:n_key_map_home])
2254 if ([gameView isOptDown])
2256 [
self homeInfoSystem];
2257 target_chart_focus = galaxy_coordinates;
2262 cursor_coordinates = galaxy_coordinates;
2263 target_chart_focus = cursor_coordinates;
2264 target_chart_centre = galaxy_coordinates;
2265 found_system_id = -1;
2266 [UNIVERSE findSystemCoordinatesWithPrefix:@""];
2270 if ([
self checkKeyPress:n_key_map_end])
2272 [
self targetInfoSystem];
2273 target_chart_focus = cursor_coordinates;
2275 if ([
self checkKeyPress:n_key_map_zoom_in] || [gameView mouseWheelState] ==
gvMouseWheelDown)
2279 saved_chart_zoom = target_chart_zoom;
2281 if ([
self checkKeyPress:n_key_map_zoom_out] || [gameView mouseWheelState] ==
gvMouseWheelUp)
2283 if (gui_screen == GUI_SCREEN_LONG_RANGE_CHART)
2286 [
self setGuiToShortRangeChartScreen];
2289 if (target_chart_zoom < 1.0) target_chart_zoom = 1.0;
2290 saved_chart_zoom = target_chart_zoom;
2292 target_chart_focus = target_chart_centre;
2296 BOOL nextSystemOnRoute = [gameView
isOptDown];
2298 if ([
self checkNavKeyPress:n_key_gui_arrow_left])
2300 if ((nextSystem || nextSystemOnRoute) &&
pressedArrow != 1)
2304 [
self targetNewSystem:-1];
2305 target_chart_focus = cursor_coordinates;
2309 [
self clearPlanetSearchString];
2310 [
self previousInfoSystem];
2311 target_chart_focus = [[UNIVERSE systemManager] getCoordinatesForSystem:info_system_id inGalaxy:galaxy_number];
2315 else if (!nextSystem && !nextSystemOnRoute)
2318 cursor_coordinates.x -= cursor_speed*delta_t;
2319 if (cursor_coordinates.x < 0.0) cursor_coordinates.x = 0.0;
2321 target_chart_focus = cursor_coordinates;
2327 if ([
self checkNavKeyPress:n_key_gui_arrow_right])
2329 if ((nextSystem || nextSystemOnRoute) &&
pressedArrow != 2)
2333 [
self targetNewSystem:+1];
2334 target_chart_focus = cursor_coordinates;
2338 [
self clearPlanetSearchString];
2339 [
self nextInfoSystem];
2340 target_chart_focus = [[UNIVERSE systemManager] getCoordinatesForSystem:info_system_id inGalaxy:galaxy_number];
2344 else if (!nextSystem && !nextSystemOnRoute)
2347 cursor_coordinates.x += cursor_speed*delta_t;
2348 if (cursor_coordinates.x > 256.0) cursor_coordinates.x = 256.0;
2350 target_chart_focus = cursor_coordinates;
2356 if ([
self checkNavKeyPress:n_key_gui_arrow_down])
2360 [
self targetNewSystem:+1];
2363 else if (!nextSystem)
2366 cursor_coordinates.y += cursor_speed*delta_t*2.0;
2367 if (cursor_coordinates.y > 256.0) cursor_coordinates.y = 256.0;
2370 target_chart_focus = cursor_coordinates;
2375 if ([
self checkNavKeyPress:n_key_gui_arrow_up])
2379 [
self targetNewSystem:-1];
2382 else if (!nextSystem)
2385 cursor_coordinates.y -= cursor_speed*delta_t*2.0;
2386 if (cursor_coordinates.y < 0.0) cursor_coordinates.y = 0.0;
2389 target_chart_focus = cursor_coordinates;
2395 if (found_system_id == -1)
2397 target_system_id = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxy:galaxy_number includingHidden:NO];
2398 [
self setInfoSystemID: target_system_id moveChart: YES];
2403 NSPoint fpos = [[UNIVERSE systemManager] getCoordinatesForSystem:found_system_id inGalaxy:galaxy_number];
2404 if (fpos.x != cursor_coordinates.x && fpos.y != cursor_coordinates.y)
2406 target_system_id = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxy:galaxy_number includingHidden:NO];
2407 [
self setInfoSystemID: target_system_id moveChart: YES];
2410 cursor_coordinates = [[UNIVERSE systemManager] getCoordinatesForSystem:target_system_id inGalaxy:galaxy_number];
2412 if (chart_focus_coordinates.x - target_chart_centre.x <= -
CHART_SCROLL_AT_X*chart_zoom)
2414 target_chart_centre.x = chart_focus_coordinates.x +
CHART_SCROLL_AT_X*chart_zoom;
2416 else if (chart_focus_coordinates.x - target_chart_centre.x >=
CHART_SCROLL_AT_X*chart_zoom)
2418 target_chart_centre.x = chart_focus_coordinates.x -
CHART_SCROLL_AT_X*chart_zoom;
2420 if (chart_focus_coordinates.y - target_chart_centre.y <= -
CHART_SCROLL_AT_Y*chart_zoom)
2422 target_chart_centre.y = chart_focus_coordinates.y +
CHART_SCROLL_AT_Y*chart_zoom;
2424 else if (chart_focus_coordinates.y - target_chart_centre.y >=
CHART_SCROLL_AT_Y*chart_zoom)
2426 target_chart_centre.y = chart_focus_coordinates.y -
CHART_SCROLL_AT_Y*chart_zoom;
2428 chart_centre_coordinates.x = (3.0*chart_centre_coordinates.x + target_chart_centre.
x)/4.0;
2429 chart_centre_coordinates.y = (3.0*chart_centre_coordinates.y + target_chart_centre.
y)/4.0;
2430 chart_zoom = (3.0*chart_zoom + target_chart_zoom)/4.0;
2431 chart_focus_coordinates.x = (3.0*chart_focus_coordinates.x + target_chart_focus.
x)/4.0;
2432 chart_focus_coordinates.y = (3.0*chart_focus_coordinates.y + target_chart_focus.
y)/4.0;
2433 if (
cursor_moving || dragging) [
self setGuiToChartScreenFrom: gui_screen];
2438 case GUI_SCREEN_SYSTEM_DATA:
2439 if ([
self checkKeyPress:n_key_system_next_system])
2443 [
self nextInfoSystem];
2451 if ([
self checkKeyPress:n_key_system_previous_system])
2455 [
self previousInfoSystem];
2463 if ([
self checkKeyPress:n_key_system_home])
2467 [
self homeInfoSystem];
2475 if ([
self checkKeyPress:n_key_system_end])
2479 [
self targetInfoSystem];
2489#if OO_USE_CUSTOM_LOAD_SAVE
2491 case GUI_SCREEN_LOAD:
2493 NSString *commanderFile = [
self commanderSelector];
2500 [
self loadPlayerFromFile:commanderFile asNew:NO];
2505 case GUI_SCREEN_SAVE:
2506 [
self pollGuiScreenControlsWithFKeyAlias:NO];
2509 if ([
self checkKeyPress:n_key_launch_ship fKey_only:YES]) [
self handleUndockControl];
2510 if (gui_screen == GUI_SCREEN_SAVE)
2512 [
self saveCommanderInputHandler];
2514 else pollControls = YES;
2517 case GUI_SCREEN_SAVE_OVERWRITE:
2518 [
self overwriteCommanderInputHandler];
2522 case GUI_SCREEN_STICKMAPPER:
2523 [
self handleStickMapperScreenKeys];
2526 case GUI_SCREEN_STICKPROFILE:
2527 [
self stickProfileInputHandler: gui view: gameView];
2530 case GUI_SCREEN_GAMEOPTIONS:
2531 [
self handleGameOptionsScreenKeys];
2534 case GUI_SCREEN_KEYBOARD:
2535 [
self handleKeyMapperScreenKeys];
2542 case GUI_SCREEN_KEYBOARD_CONFIRMCLEAR:
2543 [
self handleKeyMapperConfirmClearKeys:gui view:gameView];
2546 case GUI_SCREEN_KEYBOARD_CONFIG:
2547 [
self handleKeyConfigKeys:gui view:gameView];
2550 case GUI_SCREEN_KEYBOARD_ENTRY:
2551 [
self handleKeyConfigEntryKeys:gui view:gameView];
2554 case GUI_SCREEN_KEYBOARD_LAYOUT:
2555 [
self handleKeyboardLayoutKeys];
2558 case GUI_SCREEN_SHIPLIBRARY:
2559 if ([gameView isDown:
' '])
2562 [
self setGuiToInterfacesScreen:0];
2564 if ([
self checkKeyPress:n_key_gui_arrow_up])
2567 [UNIVERSE selectIntro2Previous];
2569 if ([
self checkKeyPress:n_key_gui_arrow_down])
2572 [UNIVERSE selectIntro2Next];
2574 upDownKeyPressed = (([
self checkKeyPress:n_key_gui_arrow_up])||([
self checkKeyPress:n_key_gui_arrow_down]));
2576 if ([
self checkKeyPress:n_key_gui_arrow_left])
2579 [UNIVERSE selectIntro2PreviousCategory];
2581 if ([
self checkKeyPress:n_key_gui_arrow_right])
2584 [UNIVERSE selectIntro2NextCategory];
2586 leftRightKeyPressed = (([
self checkKeyPress:n_key_gui_arrow_left])||([
self checkKeyPress:n_key_gui_arrow_right]));
2589 case GUI_SCREEN_OPTIONS:
2590 [
self handleGUIUpDownArrowKeys];
2592 BOOL selectKeyPress = ([
self checkKeyPress:n_key_gui_select]||[gameView
isDown:gvMouseDoubleClick]);
2601 [
self quicksavePlayer];
2603 @catch (NSException *exception)
2605 OOLog(
kOOLogException,
@"\n\n***** Handling exception: %@ : %@ *****\n\n",[exception name], [exception reason]);
2606 if ([[exception name] isEqual:
@"GameNotSavedException"])
2609 if ([controller inFullScreenMode])
2628 if (![
self loadPlayer])
2631 [
self setGuiToStatusScreen];
2639 [UNIVERSE setUseAddOns:SCENARIO_OXP_DEFINITION_ALL fromSaveGame:NO forceReinit:YES];
2643 [gameView clearMouse];
2654 if ((guiSelectedRow ==
GUI_ROW(,QUIT)) && selectKeyPress)
2656 [[UNIVERSE gameController] exitAppWithContext:@"Exit Game selected on options screen"];
2660 if ((guiSelectedRow ==
GUI_ROW(,GAMEOPTIONS)) && selectKeyPress)
2663 [
self setGuiToGameOptionsScreen];
2668 case GUI_SCREEN_EQUIP_SHIP:
2669 if ([
self handleGUIUpDownArrowKeys])
2679 if (weaponType !=
nil)
2683 if ([[weaponType identifier] isEqualToString:
@"EQ_WEAPON_NONE"]) itemText =
DESC(
@"no-weapon-enter-to-install");
2687 if (sameAs) itemText = [NSString stringWithFormat:DESC(@"weapon-installed-@"), weaponName];
2688 else itemText = [NSString stringWithFormat:DESC(@"weapon-@-enter-to-replace"), weaponName];
2691 [
self showInformationForSelectedUpgradeWithFormatString:itemText];
2694 [
self showInformationForSelectedUpgrade];
2697 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
2703 [
self playMenuPagePrevious];
2705 [
self buySelectedItem];
2710 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
2716 [
self playMenuPageNext];
2717 [gui
setSelectedRow:GUI_ROW_EQUIPMENT_START + GUI_MAX_ROWS_EQUIPMENT - 1];
2718 [
self buySelectedItem];
2723 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];
2734 [
self buySelectedItem];
2744 case GUI_SCREEN_INTERFACES:
2745 if ([
self handleGUIUpDownArrowKeys])
2747 [
self showInformationForSelectedInterface];
2749 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
2755 [
self playMenuPagePrevious];
2757 [
self activateSelectedInterface];
2762 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
2768 [
self playMenuPageNext];
2769 [gui
setSelectedRow:GUI_ROW_INTERFACES_START + GUI_MAX_ROWS_INTERFACES - 1];
2770 [
self activateSelectedInterface];
2775 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];
2785 [
self activateSelectedInterface];
2796 case GUI_SCREEN_MARKETINFO:
2797 [
self pollMarketScreenControls];
2800 case GUI_SCREEN_MARKET:
2801 [
self pollMarketScreenControls];
2803 if ([
self checkKeyPress:n_key_market_filter_cycle] || [
self checkKeyPress:n_key_market_sorter_cycle])
2808 if ([
self checkKeyPress:n_key_market_filter_cycle])
2830 [
self playChangedOption];
2831 [
self setGuiToMarketScreen];
2841 case GUI_SCREEN_REPORT:
2842 if ([gameView isDown:32])
2846 BOOL reportEnded = ([dockingReport length] == 0);
2847 [
self playDismissedReportScreen];
2850 [
self setGuiToStatusScreen];
2851 [
self doScriptEvent:OOJSID("reportScreenEnded")];
2852 [
self doWorldEventUntilMissionScreen:OOJSID("missionScreenOpportunity")];
2856 [
self setGuiToDockingReportScreen];
2865 case GUI_SCREEN_STATUS:
2866 [
self handleGUIUpDownArrowKeys];
2867 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
2875 [
self playMenuPagePrevious];
2877 [
self setGuiToStatusScreen];
2882 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
2891 [
self playMenuPageNext];
2893 [
self setGuiToStatusScreen];
2898 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];
2910 [
self setGuiToStatusScreen];
2921 case GUI_SCREEN_MANIFEST:
2922 [
self handleGUIUpDownArrowKeys];
2923 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
2931 [
self playMenuPagePrevious];
2933 [
self setGuiToManifestScreen];
2938 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
2941 if ([[
self hud] isHidden] || [[
self hud] allowBigGui])
2947 if ([[gui keyForRow:nextRow] isEqual:
GUI_KEY_OK])
2950 [
self playMenuPageNext];
2952 [
self setGuiToManifestScreen];
2957 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];
2969 [
self setGuiToManifestScreen];
2981 case GUI_SCREEN_SHIPYARD:
2982 if ([
self handleGUIUpDownArrowKeys])
2984 [
self showShipyardInfoForSelection];
2987 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
2993 [
self playMenuPagePrevious];
2995 [
self buySelectedShip];
3000 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
3006 [
self playMenuPageNext];
3007 [gui
setSelectedRow:GUI_ROW_SHIPYARD_START + MAX_ROWS_SHIPS_FOR_SALE - 1];
3008 [
self buySelectedShip];
3013 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];
3015 if ([
self checkKeyPress:n_key_gui_select])
3022 if (![key hasPrefix:
@"More:"])
3024 shipprice = [
self priceForShipKey:key];
3027 if ([
self buySelectedShip])
3029 if (![key hasPrefix:
@"More:"])
3031 [UNIVERSE removeDemoShips];
3032 [
self setGuiToStatusScreen];
3034 [
self doScriptEvent:OOJSID("playerBoughtNewShip") withArgument:self andArgument:[NSNumber numberWithUnsignedLongLong:shipprice]];
3039 [
self playCantBuyShip];
3052 [
self playMenuPageNext];
3053 [gui
setSelectedRow:GUI_ROW_SHIPYARD_START + MAX_ROWS_SHIPS_FOR_SALE - 1];
3054 [
self buySelectedShip];
3058 [
self playMenuPagePrevious];
3060 [
self buySelectedShip];
3072 NSArray *keys = [extraGuiScreenKeys objectForKey:[NSString stringWithFormat:@"%d", gui_screen]];
3074 NSInteger kc = [keys count];
3076 NSDictionary *keydefs =
nil;
3077 NSString *key =
nil;
3079 definition = [keys objectAtIndex:kc];
3081 foreach (key, [keydefs allKeys])
3083 if ([
self checkKeyPress:[keydefs objectForKey:key]])
3090 [[UNIVERSE gameView] clearKeys];
3095 OOLog(
@"interface.missingCallback",
@"Unable to find callback definition for %@ using key %@", [definition name], key);
3107 if (flightRoll > 0.0)
3109 if (flightRoll > delta_t) [
self decrease_flight_roll:delta_t];
3110 else flightRoll = 0.0;
3112 if (flightRoll < 0.0)
3114 if (flightRoll < -delta_t) [
self increase_flight_roll:delta_t];
3115 else flightRoll = 0.0;
3117 if (flightPitch > 0.0)
3119 if (flightPitch > delta_t) [
self decrease_flight_pitch:delta_t];
3120 else flightPitch = 0.0;
3122 if (flightPitch < 0.0)
3124 if (flightPitch < -delta_t) [
self increase_flight_pitch:delta_t];
3125 else flightPitch = 0.0;
3127 if (flightYaw > 0.0)
3129 if (flightYaw > delta_t) [
self decrease_flight_yaw:delta_t];
3130 else flightYaw = 0.0;
3132 if (flightYaw < 0.0)
3134 if (flightYaw < -delta_t) [
self increase_flight_yaw:delta_t];
3135 else flightYaw = 0.0;
3140- (void) pollMarketScreenControls
3145 if (gui_screen == GUI_SCREEN_MARKET)
3147 [
self handleGUIUpDownArrowKeys];
3148 DESTROY(marketSelectedCommodity);
3151 BOOL page_up = [
self checkKeyPress:n_key_gui_page_up];
3152 BOOL page_down = [
self checkKeyPress:n_key_gui_page_down];
3153 if (page_up || page_down)
3158 NSArray *goods = [
self applyMarketSorter:[
self applyMarketFilter:[localMarket
goods] onMarket:localMarket] onMarket:localMarket];
3159 if ([goods
count] > 0)
3161 NSInteger goodsIndex = [goods indexOfObject:marketSelectedCommodity];
3162 NSInteger offset1 = 0;
3163 NSInteger offset2 = 0;
3168 [
self playMenuPagePrevious];
3170 if (goodsIndex - 16 <= 0)
3175 if (offset1 == 1 && offset2 == 0 && goodsIndex < (NSInteger)[goods
count] - 1 && goodsIndex - 15 > 0) offset2 = 1;
3176 goodsIndex -= (16 - (offset1 + offset2));
3177 if (goodsIndex < 0) goodsIndex = 0;
3178 if ([goods
count] <= 17) goodsIndex = 0;
3182 [
self playMenuPageNext];
3184 if (offset1 == 0 && offset2 == 1 && goodsIndex > 1) offset1 = 1;
3185 if (offset2 == 1 && goodsIndex + 15 == (NSInteger)[goods
count] - 1) offset2 = 0;
3186 goodsIndex += (16 - (offset1 + offset2));
3187 if (goodsIndex > ((NSInteger)[goods
count] - 1) || [goods
count] <= 17) goodsIndex = (NSInteger)[goods
count] - 1;
3189 DESTROY(marketSelectedCommodity);
3190 marketSelectedCommodity = [[goods oo_stringAtIndex:goodsIndex] retain];
3191 [
self setGuiToMarketScreen];
3204 BOOL arrow_up = [
self checkKeyPress:n_key_gui_arrow_up];
3205 BOOL arrow_down = [
self checkKeyPress:n_key_gui_arrow_down];
3206 if (arrow_up || arrow_down)
3211 NSArray *goods = [
self applyMarketSorter:[
self applyMarketFilter:[localMarket
goods] onMarket:localMarket] onMarket:localMarket];
3212 if ([goods
count] > 0)
3214 NSInteger goodsIndex = [goods indexOfObject:marketSelectedCommodity];
3225 goodsIndex = [goods count]-1;
3227 else if (goodsIndex >= (NSInteger)[goods
count])
3231 DESTROY(marketSelectedCommodity);
3232 marketSelectedCommodity = [[goods oo_stringAtIndex:goodsIndex] retain];
3233 [
self setGuiToMarketInfoScreen];
3245 BOOL isdocked = [
self isDocked];
3247 if (([
self checkNavKeyPress:n_key_gui_arrow_right])||([
self checkNavKeyPress:n_key_gui_arrow_left])||([
self checkKeyPress:n_key_gui_select]||[gameView isDown:
gvMouseDoubleClick]))
3249 if ([
self checkNavKeyPress:n_key_gui_arrow_right])
3253 if (isdocked && [
self tryBuyingCommodity:marketSelectedCommodity all:[gameView isShiftDown]])
3255 [
self playBuyCommodity];
3256 if (gui_screen == GUI_SCREEN_MARKET)
3258 [
self setGuiToMarketScreen];
3262 [
self setGuiToMarketInfoScreen];
3267 if ([[gui selectedRowKey] isEqualToString:
@">>>"])
3269 [
self playMenuNavigationDown];
3270 [
self setGuiToMarketScreen];
3272 else if ([[gui selectedRowKey] isEqualToString:
@"<<<"])
3274 [
self playMenuNavigationUp];
3275 [
self setGuiToMarketScreen];
3279 [
self playCantBuyCommodity];
3285 if ([
self checkNavKeyPress:n_key_gui_arrow_left])
3289 if (isdocked && [
self trySellingCommodity:marketSelectedCommodity all:[gameView isShiftDown]])
3291 [
self playSellCommodity];
3292 if (gui_screen == GUI_SCREEN_MARKET)
3294 [
self setGuiToMarketScreen];
3298 [
self setGuiToMarketInfoScreen];
3303 if ([[gui selectedRowKey] isEqualToString:
@">>>"])
3305 [
self playMenuNavigationDown];
3306 [
self setGuiToMarketScreen];
3308 else if ([[gui selectedRowKey] isEqualToString:
@"<<<"])
3310 [
self playMenuNavigationUp];
3311 [
self setGuiToMarketScreen];
3315 [
self playCantSellCommodity];
3322 if ((gui_screen == GUI_SCREEN_MARKET && [gameView isDown:
gvMouseDoubleClick]) || [
self checkKeyPress:n_key_gui_select])
3333 if ([item isEqualToString:
@">>>"])
3335 [
self tryBuyingCommodity:item all:YES];
3336 [
self setGuiToMarketScreen];
3338 else if ([item isEqualToString:
@"<<<"])
3340 [
self trySellingCommodity:item all:YES];
3341 [
self setGuiToMarketScreen];
3343 else if (isdocked && [gameView isShiftDown] && [
self tryBuyingCommodity:item all:YES])
3345 [
self playBuyCommodity];
3346 if (gui_screen == GUI_SCREEN_MARKET)
3348 [
self setGuiToMarketScreen];
3352 [
self setGuiToMarketInfoScreen];
3355 else if (isdocked && (yours > 0) && [
self trySellingCommodity:item all:YES])
3357 [
self playSellCommodity];
3358 if (gui_screen == GUI_SCREEN_MARKET)
3360 [
self setGuiToMarketScreen];
3364 [
self setGuiToMarketInfoScreen];
3367 else if (isdocked && [
self tryBuyingCommodity:item all:YES])
3369 [
self playBuyCommodity];
3370 if (gui_screen == GUI_SCREEN_MARKET)
3372 [
self setGuiToMarketScreen];
3376 [
self setGuiToMarketInfoScreen];
3381 [
self playCantBuyCommodity];
3397- (void) handleGameOptionsScreenKeys
3403 [
self handleGUIUpDownArrowKeys];
3405 BOOL selectKeyPress = ([
self checkKeyPress:n_key_gui_select]||[gameView
isDown:gvMouseDoubleClick]);
3408 if ((guiSelectedRow ==
GUI_ROW(GAME,STICKMAPPER)) && selectKeyPress)
3411 [
self resetStickFunctions];
3412 [
self setGuiToStickMapperScreen: 0 resetCurrentRow: YES];
3414 if ((guiSelectedRow ==
GUI_ROW(GAME,KEYMAPPER)) && selectKeyPress)
3417 [
self resetKeyFunctions];
3418 [
self setGuiToKeyMapperScreen: 0 resetCurrentRow: YES];
3423 if ([gameView hdrOutput])
3425 if ((guiSelectedRow ==
GUI_ROW(GAME,HDRMAXBRIGHTNESS))&&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3429 int direction = ([
self checkKeyPress:n_key_gui_arrow_right]) ? 1 : -1;
3430 NSArray *brightnesses = [[UNIVERSE descriptions] oo_arrayForKey: @"hdr_maxBrightness_array"];
3431 int brightnessIdx = [brightnesses indexOfObject:[NSString stringWithFormat:@"%d", (int)[gameView hdrMaxBrightness]]];
3433 if (brightnessIdx == NSNotFound)
3435 OOLogWARN(
@"hdr.maxBrightness.notFound",
@"%@",
@"couldn't find current max brightness setting, switching to lowest.");
3439 brightnessIdx += direction;
3440 int count = [brightnesses count];
3441 if (brightnessIdx < 0)
3442 brightnessIdx =
count - 1;
3443 if (brightnessIdx >=
count)
3446 int brightnessValue = [brightnesses oo_intAtIndex:brightnessIdx];
3453 [gameView setHDRMaxBrightness:(float)brightnessValue];
3454 NSString *maxBrightnessString =
OOExpandKey(
@"gameoptions-hdr-maxbrightness", brightnessValue);
3456 [gui
setText:maxBrightnessString
forRow:GUI_ROW(GAME,HDRMAXBRIGHTNESS)
align:GUI_ALIGN_CENTER];
3467#if OO_RESOLUTION_OPTION
3469 guiSelectedRow ==
GUI_ROW(GAME,DISPLAY) &&
3470 ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_arrow_left]))
3473 int direction = ([
self checkKeyPress:n_key_gui_arrow_right]) ? 1 : -1;
3477 if (displayModeIndex == (NSInteger)NSNotFound)
3479 OOLogWARN(
@"graphics.mode.notFound",
@"%@",
@"couldn't find current fullscreen setting, switching to default.");
3480 displayModeIndex = 0;
3483 displayModeIndex = displayModeIndex + direction;
3484 int count = [modes count];
3485 if (displayModeIndex < 0)
3486 displayModeIndex =
count - 1;
3487 if (displayModeIndex >=
count)
3488 displayModeIndex = 0;
3490 NSDictionary *
mode = [modes objectAtIndex:displayModeIndex];
3491 int modeWidth = [mode oo_intForKey:kOODisplayWidth];
3492 int modeHeight = [mode oo_intForKey:kOODisplayHeight];
3493 int modeRefresh = [mode oo_intForKey:kOODisplayRefreshRate];
3496 NSString *displayModeString = [
self screenModeStringForWidth:modeWidth height:modeHeight refreshRate:modeRefresh];
3498 [
self playChangedOption];
3509 if (
switching_resolution && ![
self checkKeyPress:n_key_gui_arrow_right] && ![
self checkKeyPress:n_key_gui_arrow_left] && !selectKeyPress)
3515#if OOLITE_SPEECH_SYNTH
3517 if ((guiSelectedRow ==
GUI_ROW(GAME,SPEECH))&&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3519 if (!speech_settings_pressed)
3524 [
self playChangedOption];
3525 speech_settings_pressed = YES;
3529 speech_settings_pressed = YES;
3531 [
self playChangedOption];
3533 if (speech_settings_pressed)
3535 NSString *message =
nil;
3539 message =
DESC(
@"gameoptions-spoken-messages-no");
3542 message =
DESC(
@"gameoptions-spoken-messages-comms");
3545 message =
DESC(
@"gameoptions-spoken-messages-yes");
3552 [UNIVERSE stopSpeaking];
3553 [UNIVERSE startSpeakingString:message];
3560 speech_settings_pressed = NO;
3563 if (guiSelectedRow ==
GUI_ROW(GAME,SPEECH_LANGUAGE))
3565 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_arrow_left])
3569 [
self playChangedOption];
3570 if ([
self checkKeyPress:n_key_gui_arrow_right])
3571 voice_no = [
UNIVERSE nextVoice: voice_no];
3573 voice_no = [UNIVERSE prevVoice: voice_no];
3574 [UNIVERSE setVoice: voice_no withGenderM:voice_gender_m];
3575 NSString *voiceName = [UNIVERSE voiceName:voice_no];
3576 NSString *message =
OOExpandKey(
@"gameoptions-voice-name", voiceName);
3580 [UNIVERSE stopSpeaking];
3581 [UNIVERSE startSpeakingString:[UNIVERSE voiceName: voice_no]];
3585 speechVoiceSelectKeyPressed = YES;
3588 speechVoiceSelectKeyPressed = NO;
3591 if (guiSelectedRow ==
GUI_ROW(GAME,SPEECH_GENDER))
3593 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_arrow_left])
3595 if (!speechGenderSelectKeyPressed)
3597 [
self playChangedOption];
3598 BOOL m = [
self checkKeyPress:n_key_gui_arrow_right];
3599 if (m != voice_gender_m)
3602 [UNIVERSE setVoice:voice_no withGenderM:voice_gender_m];
3603 NSString *message = [NSString stringWithFormat:@"%@", DESC(voice_gender_m ? @"gameoptions-voice-M" : @"gameoptions-voice-F")];
3607 [UNIVERSE stopSpeaking];
3608 [UNIVERSE startSpeakingString:[UNIVERSE voiceName: voice_no]];
3612 speechGenderSelectKeyPressed = YES;
3615 speechGenderSelectKeyPressed = NO;
3620 if ((guiSelectedRow ==
GUI_ROW(GAME,MUSIC))&&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3625 int initialMode = [musicController
mode];
3626 int mode = initialMode;
3628 if ([
self checkKeyPress:n_key_gui_arrow_right])
mode++;
3629 if ([
self checkKeyPress:n_key_gui_arrow_left])
mode--;
3631 [musicController
setMode:MAX(mode, 0)];
3633 if ((
int)[musicController
mode] != initialMode)
3635 [
self playChangedOption];
3637 NSString *message =
OOExpandKey(
@"gameoptions-music-mode", musicMode);
3645 if ((guiSelectedRow ==
GUI_ROW(GAME,AUTOSAVE))&&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3647 if ([
self checkKeyPress:n_key_gui_arrow_right] != [
UNIVERSE autoSave])
3648 [
self playChangedOption];
3649 [UNIVERSE setAutoSave:[
self checkKeyPress:n_key_gui_arrow_right]];
3653 [UNIVERSE setAutoSaveNow:YES];
3654 [gui
setText:DESC(@"gameoptions-autosave-yes")
forRow:GUI_ROW(GAME,AUTOSAVE)
align:GUI_ALIGN_CENTER];
3658 [UNIVERSE setAutoSaveNow:NO];
3659 [gui
setText:DESC(@"gameoptions-autosave-no")
forRow:GUI_ROW(GAME,AUTOSAVE)
align:GUI_ALIGN_CENTER];
3663 if ((guiSelectedRow ==
GUI_ROW(GAME,VOLUME))
3664 &&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left]))
3665 &&[
OOSound respondsToSelector:@selector(masterVolume)])
3669 BOOL rightKeyDown = [
self checkKeyPress:n_key_gui_arrow_right];
3670 BOOL leftKeyDown = [
self checkKeyPress:n_key_gui_arrow_left];
3672 int vol = (volume / 5.0 + 0.5);
3673 if (rightKeyDown) vol++;
3674 if (leftKeyDown) vol--;
3677 [
self playChangedOption];
3679 espeak_SetParameter(espeakVOLUME, vol * 5, 0);
3683 NSString* soundVolumeWordDesc =
DESC(
@"gameoptions-sound-volume");
3684 NSString* v1_string =
@"|||||||||||||||||||||||||";
3685 NSString* v0_string =
@".........................";
3686 v1_string = [v1_string substringToIndex:vol];
3687 v0_string = [v0_string substringToIndex:20 - vol];
3688 [gui
setText:[NSString stringWithFormat:@"%@%@%@ ", soundVolumeWordDesc, v1_string, v0_string]
3689 forRow:GUI_ROW(GAME,VOLUME)
3690 align:GUI_ALIGN_CENTER];
3693 [gui
setText:DESC(@"gameoptions-sound-volume-mute")
forRow:GUI_ROW(GAME,VOLUME)
align:GUI_ALIGN_CENTER];
3701 if ((guiSelectedRow ==
GUI_ROW(GAME,FOV))
3702 &&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3706 BOOL rightKeyDown = [
self checkKeyPress:n_key_gui_arrow_right];
3707 BOOL leftKeyDown = [
self checkKeyPress:n_key_gui_arrow_left];
3708 float fov = [gameView
fov:NO];
3711 fovStep : 0.0f) - ((leftKeyDown && (fov >
MIN_FOV_DEG)) ? fovStep : 0.0f));
3715 fieldOfView = [gameView
fov:YES];
3717 NSString* fovWordDesc =
DESC(
@"gameoptions-fov-value");
3718 NSString* v1_string =
@"|||||||||||||||||||||||||";
3719 NSString* v0_string =
@".........................";
3720 v1_string = [v1_string substringToIndex:fovTicks];
3721 v0_string = [v0_string substringToIndex:20 - fovTicks];
3722 [gui
setText:[NSString stringWithFormat:@"%@%@%@ (%d%c) ", fovWordDesc, v1_string, v0_string, (int)fov, 176 ]
forRow:GUI_ROW(GAME,FOV)
align:GUI_ALIGN_CENTER];
3723 [[NSUserDefaults standardUserDefaults] setFloat:[gameView
fov:NO] forKey:@"fov-value"];
3733 if ((guiSelectedRow ==
GUI_ROW(GAME,COLORBLINDMODE))&&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3737 int colorblindMode = [UNIVERSE colorblindMode];
3738 if ([
self checkKeyPress:n_key_gui_arrow_right])
3740 [UNIVERSE setCurrentPostFX:[UNIVERSE nextColorblindMode:colorblindMode]];
3744 [UNIVERSE setCurrentPostFX:[UNIVERSE prevColorblindMode:colorblindMode]];
3746 colorblindMode = [UNIVERSE colorblindMode];
3747 NSString *colorblindModeDesc = [[[UNIVERSE descriptions] oo_arrayForKey: @"colorblind_mode"] oo_stringAtIndex:[UNIVERSE useShaders] ? colorblindMode : 0];
3748 NSString *colorblindModeMsg =
OOExpandKey(
@"gameoptions-colorblind-mode", colorblindModeDesc);
3749 [gui
setText:colorblindModeMsg
forRow:GUI_ROW(GAME,COLORBLINDMODE)
align:GUI_ALIGN_CENTER];
3757 if (![gameView hdrOutput])
3759 if ((guiSelectedRow ==
GUI_ROW(GAME,WIREFRAMEGRAPHICS))&&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3761 if ([
self checkKeyPress:n_key_gui_arrow_right] != [
UNIVERSE wireframeGraphics])
3762 [
self playChangedOption];
3763 [UNIVERSE setWireframeGraphics:[
self checkKeyPress:n_key_gui_arrow_right]];
3765 [gui
setText:DESC(@"gameoptions-wireframe-graphics-yes")
forRow:GUI_ROW(GAME,WIREFRAMEGRAPHICS)
align:GUI_ALIGN_CENTER];
3767 [gui
setText:DESC(@"gameoptions-wireframe-graphics-no")
forRow:GUI_ROW(GAME,WIREFRAMEGRAPHICS)
align:GUI_ALIGN_CENTER];
3773 if ((guiSelectedRow ==
GUI_ROW(GAME,HDRPAPERWHITE))
3774 &&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3778 BOOL rightKeyDown = [
self checkKeyPress:n_key_gui_arrow_right];
3779 BOOL leftKeyDown = [
self checkKeyPress:n_key_gui_arrow_left];
3780 float paperWhite = [gameView hdrPaperWhiteBrightness];
3784 [gameView setHDRPaperWhiteBrightness:paperWhite];
3786 NSString* paperWhiteWordDesc =
DESC(
@"gameoptions-hdr-paperwhite");
3787 NSString* v1_string =
@"|||||||||||||||||||||||||";
3788 NSString* v0_string =
@".........................";
3789 v1_string = [v1_string substringToIndex:paperWhiteNorm];
3790 v0_string = [v0_string substringToIndex:20 - paperWhiteNorm];
3791 [gui
setText:[NSString stringWithFormat:@"%@%@%@ (%d) ", paperWhiteWordDesc, v1_string, v0_string, (int)paperWhite]
forRow:GUI_ROW(GAME,HDRPAPERWHITE)
align:GUI_ALIGN_CENTER];
3801 if ((guiSelectedRow ==
GUI_ROW(GAME,PROCEDURALLYTEXTUREDPLANETS))&&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3803 if ([
self checkKeyPress:n_key_gui_arrow_right] != [
UNIVERSE doProcedurallyTexturedPlanets])
3805 [UNIVERSE setDoProcedurallyTexturedPlanets:[
self checkKeyPress:n_key_gui_arrow_right]];
3806 [
self playChangedOption];
3809 [UNIVERSE setUpPlanet];
3812 if ([
UNIVERSE doProcedurallyTexturedPlanets])
3813 [gui
setText:DESC(@"gameoptions-procedurally-textured-planets-yes")
forRow:GUI_ROW(GAME,PROCEDURALLYTEXTUREDPLANETS)
align:GUI_ALIGN_CENTER];
3815 [gui
setText:DESC(@"gameoptions-procedurally-textured-planets-no")
forRow:GUI_ROW(GAME,PROCEDURALLYTEXTUREDPLANETS)
align:GUI_ALIGN_CENTER];
3819 if (guiSelectedRow ==
GUI_ROW(GAME,SHADEREFFECTS) && ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_arrow_left]))
3823 int direction = ([
self checkKeyPress:n_key_gui_arrow_right]) ? 1 : -1;
3848 [UNIVERSE setDetailLevel:detailLevel];
3849 detailLevel = [UNIVERSE detailLevel];
3851 NSString *shaderEffectsOptionsString =
OOExpand(
@"gameoptions-detaillevel-[detailLevel]", detailLevel);
3852 [gui
setText:OOExpandKey(shaderEffectsOptionsString)
forRow:GUI_ROW(GAME,SHADEREFFECTS)
align:GUI_ALIGN_CENTER];
3853 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW(GAME,SHADEREFFECTS)];
3859 [
self setGuiToGameOptionsScreen];
3867 if ((guiSelectedRow ==
GUI_ROW(GAME,DISPLAYSTYLE)) && selectKeyPress)
3871 [
self setGuiToGameOptionsScreen];
3875 if ((guiSelectedRow ==
GUI_ROW(GAME,DOCKINGCLEARANCE))&&(([
self checkKeyPress:n_key_gui_arrow_right])||([
self checkKeyPress:n_key_gui_arrow_left])))
3877 if ([
self checkKeyPress:n_key_gui_arrow_right] != [
UNIVERSE dockingClearanceProtocolActive])
3878 [
self playChangedOption];
3879 [UNIVERSE setDockingClearanceProtocolActive:[
self checkKeyPress:n_key_gui_arrow_right]];
3880 if ([
UNIVERSE dockingClearanceProtocolActive])
3881 [gui
setText:DESC(@"gameoptions-docking-clearance-yes")
forRow:GUI_ROW(GAME,DOCKINGCLEARANCE)
align:GUI_ALIGN_CENTER];
3883 [gui
setText:DESC(@"gameoptions-docking-clearance-no")
forRow:GUI_ROW(GAME,DOCKINGCLEARANCE)
align:GUI_ALIGN_CENTER];
3886 if ((guiSelectedRow ==
GUI_ROW(GAME,BACK)) && selectKeyPress)
3889 [
self setGuiToLoadSaveScreen];
3894- (void) handleKeyMapperScreenKeys
3899 [
self keyMapperInputHandler: gui view: gameView];
3900 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];
3904 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
3906 key = [gui
keyForRow:GUI_ROW_KC_FUNCEND];
3908 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
3910 key = [gui
keyForRow:GUI_ROW_KC_FUNCSTART];
3912 int from_function = 0;
3913 NSArray *keyComponents = [key componentsSeparatedByString:@":"];
3914 if ([keyComponents
count] > 1)
3916 from_function = [keyComponents oo_intAtIndex:1];
3917 if (from_function < 0) from_function = 0;
3919 [
self setGuiToKeyMapperScreen:from_function resetCurrentRow: YES];
3922 [[UNIVERSE gui] setSelectedRow: GUI_ROW_KC_FUNCSTART];
3924 if (from_function == 0)
3926 [[UNIVERSE gui] setSelectedRow: GUI_ROW_KC_FUNCSTART + MAX_ROWS_KC_FUNCTIONS - 1];
3933- (void) handleKeyboardLayoutKeys
3938 [
self handleKeyboardLayoutEntryKeys: gui view: gameView];
3939 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];
3943 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
3945 key = [gui
keyForRow:GUI_ROW_KC_FUNCEND];
3947 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
3949 key = [gui
keyForRow:GUI_ROW_KC_FUNCSTART];
3951 int from_function = 0;
3952 NSArray *keyComponents = [key componentsSeparatedByString:@":"];
3953 if ([keyComponents
count] > 1)
3955 from_function = [keyComponents oo_intAtIndex:1];
3956 if (from_function < 0) from_function = 0;
3958 [
self setGuiToKeyboardLayoutScreen:from_function resetCurrentRow:YES];
3961 [[UNIVERSE gui] setSelectedRow: GUI_ROW_KC_FUNCSTART];
3963 if (from_function == 0)
3965 [[UNIVERSE gui] setSelectedRow: GUI_ROW_KC_FUNCSTART + MAX_ROWS_KC_FUNCTIONS - 1];
3972- (void) handleStickMapperScreenKeys
3977 [
self stickMapperInputHandler: gui view: gameView];
3978 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];
3982 if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
3986 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
3988 key = [gui
keyForRow:GUI_ROW_FUNCSTART];
3990 int from_function = 0;
3991 NSArray *keyComponents = [key componentsSeparatedByString:@":"];
3992 if ([keyComponents
count] > 1)
3994 from_function = [keyComponents oo_intAtIndex:1];
3995 if (from_function < 0) from_function = 0;
3997 [
self setGuiToStickMapperScreen:from_function resetCurrentRow: YES];
4000 [[UNIVERSE gui] setSelectedRow: GUI_ROW_FUNCSTART];
4002 if (from_function == 0)
4004 [[UNIVERSE gui] setSelectedRow: GUI_ROW_FUNCSTART + MAX_ROWS_FUNCTIONS - 1];
4008 if([gameView isDown:
' ']) [
self setGuiToGameOptionsScreen];
4012- (void) pollCustomViewControls
4014 static Quaternion viewQuaternion;
4015 static Vector viewOffset;
4016 static Vector rotationCenter;
4018 static Vector right;
4019 static BOOL mouse_clicked = NO;
4020 static NSPoint mouse_clicked_position;
4021 static BOOL shift_down;
4022 static BOOL caps_on = NO;
4023 static NSTimeInterval last_time = 0.0;
4029 if (!
customView_pressed && [_customViews
count] != 0 && gui_screen != GUI_SCREEN_LONG_RANGE_CHART && ![gameView allowingStringInput])
4031 if ([
UNIVERSE viewDirection] == VIEW_CUSTOM)
4034 _customViewIndex = (_customViewIndex + 1) % [_customViews
count];
4037 [
self setCustomViewDataFromDictionary:[_customViews oo_dictionaryAtIndex:_customViewIndex] withScaling:YES];
4039 [
self switchToThisView:VIEW_CUSTOM andProcessWeaponFacing:NO];
4045 NSTimeInterval this_time = [NSDate timeIntervalSinceReferenceDate];
4046 if ([
UNIVERSE viewDirection] > VIEW_STARBOARD && [gameView isCapsLockOn])
4052 if (!caps_on) caps_on = YES;
4055 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)
4057 [
self customViewZoomOut: pow(customViewZoomSpeed, delta_t)];
4059 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)
4061 [
self customViewZoomIn: pow(customViewZoomSpeed, delta_t)];
4063 if ([
self checkKeyPress:n_key_custom_view_roll_left ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_roll_right ignore_ctrl:YES])
4065 [
self customViewRollLeft:customViewRotateSpeed * delta_t];
4067 if ([
self checkKeyPress:n_key_custom_view_pan_left ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_pan_right ignore_ctrl:YES])
4069 [
self customViewPanLeft:customViewRotateSpeed * delta_t];
4071 if ([
self checkKeyPress:n_key_custom_view_roll_right ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_roll_left ignore_ctrl:YES])
4073 [
self customViewRollRight:customViewRotateSpeed * delta_t];
4075 if ([
self checkKeyPress:n_key_custom_view_pan_right ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_pan_left ignore_ctrl:YES])
4077 [
self customViewPanRight:customViewRotateSpeed * delta_t];
4079 if ([
self checkKeyPress:n_key_custom_view_rotate_up ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_rotate_down ignore_ctrl:YES])
4081 [
self customViewRotateUp:customViewRotateSpeed * delta_t];
4083 if ([
self checkKeyPress:n_key_custom_view_pan_down ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_pan_up ignore_ctrl:YES])
4085 [
self customViewPanDown:customViewRotateSpeed * delta_t];
4087 if ([
self checkKeyPress:n_key_custom_view_rotate_down ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_rotate_up ignore_ctrl:YES])
4089 [
self customViewRotateDown:customViewRotateSpeed * delta_t];
4091 if ([
self checkKeyPress:n_key_custom_view_pan_up ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_pan_down ignore_ctrl:YES])
4093 [
self customViewPanUp:customViewRotateSpeed * delta_t];
4095 if ([
self checkKeyPress:n_key_custom_view_rotate_left ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_rotate_right ignore_ctrl:YES])
4097 [
self customViewRotateLeft:customViewRotateSpeed * delta_t];
4099 if ([
self checkKeyPress:n_key_custom_view_rotate_right ignore_ctrl:YES] && ![
self checkKeyPress:n_key_custom_view_rotate_left ignore_ctrl:YES])
4101 [
self customViewRotateRight:customViewRotateSpeed * delta_t];
4105 if(!mouse_clicked || shift_down != [gameView isShiftDown])
4107 mouse_clicked = YES;
4108 viewQuaternion = [PLAYER customViewQuaternion];
4109 viewOffset = [PLAYER customViewOffset];
4110 rotationCenter = [PLAYER customViewRotationCenter];
4111 up = [PLAYER customViewUpVector];
4112 right = [PLAYER customViewRightVector];
4117 Vector axis = vector_add(vector_multiply_scalar(up, mouse_position.x - mouse_clicked_position.x),
4118 vector_multiply_scalar(right, mouse_position.y - mouse_clicked_position.y));
4119 float angle = magnitude(axis);
4120 axis = vector_normal(axis);
4121 Quaternion newViewQuaternion = viewQuaternion;
4122 if ([gameView isShiftDown])
4125 [PLAYER setCustomViewQuaternion: newViewQuaternion];
4126 [PLAYER setCustomViewRotationCenter: vector_subtract(viewOffset,
4127 vector_multiply_scalar([PLAYER customViewForwardVector],
4128 dot_product([PLAYER customViewForwardVector], viewOffset)))];
4133 OOScalar m = magnitude(vector_subtract(viewOffset, rotationCenter));
4134 [PLAYER setCustomViewQuaternion: newViewQuaternion];
4135 Vector
offset = vector_flip([
PLAYER customViewForwardVector]);
4137 [PLAYER setCustomViewOffset:vector_add(offset, rotationCenter)];
4151 if ([
self isMouseControlOn]) [gameView
resetMouse];
4154 last_time = this_time;
4158- (void) pollViewControls
4166 NSPoint virtualView = NSZeroPoint;
4167 double view_threshold = 0.5;
4169 if ([stickHandler joystickCount])
4171 virtualView = [stickHandler
viewAxis];
4173 virtualView.y = 0.0;
4175 virtualView.x = 0.0;
4176 if (fabs(virtualView.y) >= fabs(virtualView.x))
4177 virtualView.x = 0.0;
4179 virtualView.y = 0.0;
4185 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]))
4187 [
self switchToThisView:VIEW_FORWARD];
4189 if (([
self checkKeyPress:n_key_view_aft])||(virtualView.
y > view_threshold)||joyButtonState[
BUTTON_VIEWAFT])
4191 [
self switchToThisView:VIEW_AFT];
4193 if (([
self checkKeyPress:n_key_view_port])||(virtualView.
x < -view_threshold)||joyButtonState[
BUTTON_VIEWPORT])
4195 [
self switchToThisView:VIEW_PORT];
4197 if (([
self checkKeyPress:n_key_view_starboard])||(virtualView.
x > view_threshold)||joyButtonState[
BUTTON_VIEWSTARBOARD])
4199 [
self switchToThisView:VIEW_STARBOARD];
4202 [
self pollCustomViewControls];
4207 if (!scanner_zoom_rate)
4209 if ([hud scannerZoom] < 5.0)
4228 if ((!scanner_zoom_rate)&&([hud scannerZoom] > 1.0))
4232 if (
EXPECT([[
self hud] isCompassActive]))
4238 [
self setPrevCompassMode];
4246 if ([
self checkKeyPress:n_key_next_compass_mode] || joyButtonState[
BUTTON_COMPASSMODE])
4249 [
self setNextCompassMode];
4264 if (![
self checkKeyPress:n_key_cycle_previous_mfd] || joyButtonState[
BUTTON_MFDCYCLEPREV])
4266 [
self cycleNextMultiFunctionDisplay:activeMFD];
4270 [
self cyclePreviousMultiFunctionDisplay:activeMFD];
4283 if ([[
self hud] mfdCount] > 1)
4290 [
self selectNextMultiFunctionDisplay];
4294 [
self selectPreviousMultiFunctionDisplay];
4307 if ([
self checkKeyPress:n_key_comms_log])
4309 [UNIVERSE showCommsLog: 1.5];
4310 [hud refreshLastTransmitter];
4315- (void) pollFlightArrowKeyControls:(
double)delta_t
4320 NSPoint virtualStick = NSZeroPoint;
4321 double reqYaw = 0.0;
4327 if (mouse_control_on)
4330 double sensitivity = 2.0;
4331 virtualStick.x *= sensitivity;
4332 virtualStick.y *= sensitivity;
4333 reqYaw = virtualStick.x;
4335 else if (numSticks > 0)
4344 else if(virtualStick.x != 0)
4347 keyboardRollOverride=NO;
4355 else if(virtualStick.y != 0)
4358 keyboardPitchOverride=NO;
4367 else if(reqYaw != 0)
4370 keyboardYawOverride=NO;
4377 BOOL capsLockCustomView = [UNIVERSE viewDirection] == VIEW_CUSTOM && [gameView
isCapsLockOn];
4381 double flightArrowKeyPrecisionFactor = [[NSUserDefaults standardUserDefaults] oo_doubleForKey:@"flight-arrow-key-precision-factor" defaultValue:0.5];
4382 if (flightArrowKeyPrecisionFactor < 0.05) flightArrowKeyPrecisionFactor = 0.05;
4383 if (flightArrowKeyPrecisionFactor > 1.0) flightArrowKeyPrecisionFactor = 1.0;
4389 if ([
self checkNavKeyPress:n_key_roll_left] && [
self checkNavKeyPress:n_key_roll_right])
4391 keyboardRollOverride = YES;
4394 else if ([
self checkNavKeyPress:n_key_roll_left] && !capsLockCustomView)
4396 keyboardRollOverride=YES;
4397 if (flightRoll > 0.0) flightRoll = 0.0;
4398 [
self decrease_flight_roll:isCtrlDown ? flightArrowKeyPrecisionFactor*roll_dampner*roll_delta : delta_t*roll_delta];
4401 else if ([
self checkNavKeyPress:n_key_roll_right] && !capsLockCustomView)
4403 keyboardRollOverride=YES;
4404 if (flightRoll < 0.0) flightRoll = 0.0;
4405 [
self increase_flight_roll:isCtrlDown ? flightArrowKeyPrecisionFactor*roll_dampner*roll_delta : delta_t*roll_delta];
4409 if(((mouse_control_on && !
mouse_x_axis_map_to_yaw) || numSticks) && !keyboardRollOverride && !capsLockCustomView)
4411 stick_roll = max_flight_roll * virtualStick.x;
4412 if (flightRoll < stick_roll)
4414 [
self increase_flight_roll:delta_t*roll_delta];
4415 if (flightRoll > stick_roll)
4416 flightRoll = stick_roll;
4418 if (flightRoll > stick_roll)
4420 [
self decrease_flight_roll:delta_t*roll_delta];
4421 if (flightRoll < stick_roll)
4422 flightRoll = stick_roll;
4424 rolling = (fabs(virtualStick.x) > 0.0);
4428 if (flightRoll > 0.0)
4430 if (flightRoll > roll_dampner) [
self decrease_flight_roll:roll_dampner];
4431 else flightRoll = 0.0;
4433 if (flightRoll < 0.0)
4435 if (flightRoll < -roll_dampner) [
self increase_flight_roll:roll_dampner];
4436 else flightRoll = 0.0;
4442 if (!mouse_control_on)
4444 if ([
self checkNavKeyPress:n_key_pitch_back] && [
self checkNavKeyPress:n_key_pitch_forward])
4446 keyboardPitchOverride=YES;
4449 else if ([
self checkNavKeyPress:n_key_pitch_back] && !capsLockCustomView)
4451 keyboardPitchOverride=YES;
4452 if (flightPitch < 0.0) flightPitch = 0.0;
4453 [
self increase_flight_pitch:isCtrlDown ? flightArrowKeyPrecisionFactor*pitch_dampner*pitch_delta : delta_t*pitch_delta];
4456 else if ([
self checkNavKeyPress:n_key_pitch_forward] && !capsLockCustomView)
4458 keyboardPitchOverride=YES;
4459 if (flightPitch > 0.0) flightPitch = 0.0;
4460 [
self decrease_flight_pitch:isCtrlDown ? flightArrowKeyPrecisionFactor*pitch_dampner*pitch_delta : delta_t*pitch_delta];
4464 if((mouse_control_on || (numSticks && !keyboardPitchOverride)) && !capsLockCustomView)
4466 stick_pitch = max_flight_pitch * virtualStick.y;
4467 if (flightPitch < stick_pitch)
4469 [
self increase_flight_pitch:delta_t*pitch_delta];
4470 if (flightPitch > stick_pitch)
4471 flightPitch = stick_pitch;
4473 if (flightPitch > stick_pitch)
4475 [
self decrease_flight_pitch:delta_t*pitch_delta];
4476 if (flightPitch < stick_pitch)
4477 flightPitch = stick_pitch;
4479 pitching = (fabs(virtualStick.y) > 0.0);
4483 if (flightPitch > 0.0)
4485 if (flightPitch > pitch_dampner) [
self decrease_flight_pitch:pitch_dampner];
4486 else flightPitch = 0.0;
4488 if (flightPitch < 0.0)
4490 if (flightPitch < -pitch_dampner) [
self increase_flight_pitch:pitch_dampner];
4491 else flightPitch = 0.0;
4499 if ([
self checkNavKeyPress:n_key_yaw_left] && [
self checkNavKeyPress:n_key_yaw_right])
4501 keyboardYawOverride=YES;
4504 else if ([
self checkNavKeyPress:n_key_yaw_left] && !capsLockCustomView)
4506 keyboardYawOverride=YES;
4507 if (flightYaw < 0.0) flightYaw = 0.0;
4508 [
self increase_flight_yaw:isCtrlDown ? flightArrowKeyPrecisionFactor*yaw_dampner*yaw_delta : delta_t*yaw_delta];
4511 else if ([
self checkNavKeyPress:n_key_yaw_right] && !capsLockCustomView)
4513 keyboardYawOverride=YES;
4514 if (flightYaw > 0.0) flightYaw = 0.0;
4515 [
self decrease_flight_yaw:isCtrlDown ? flightArrowKeyPrecisionFactor*yaw_dampner*yaw_delta : delta_t*yaw_delta];
4519 if(((mouse_control_on &&
mouse_x_axis_map_to_yaw) || numSticks) && !keyboardYawOverride && !capsLockCustomView)
4523 stick_yaw = max_flight_yaw * (-reqYaw);
4524 if (flightYaw < stick_yaw)
4526 [
self increase_flight_yaw:delta_t*yaw_delta];
4527 if (flightYaw > stick_yaw)
4528 flightYaw = stick_yaw;
4530 if (flightYaw > stick_yaw)
4532 [
self decrease_flight_yaw:delta_t*yaw_delta];
4533 if (flightYaw < stick_yaw)
4534 flightYaw = stick_yaw;
4536 yawing = (fabs(reqYaw) > 0.0);
4540 if (flightYaw > 0.0)
4542 if (flightYaw > yaw_dampner) [
self decrease_flight_yaw:yaw_dampner];
4543 else flightYaw = 0.0;
4545 if (flightYaw < 0.0)
4547 if (flightYaw < -yaw_dampner) [
self increase_flight_yaw:yaw_dampner];
4548 else flightYaw = 0.0;
4555- (void) pollGuiScreenControls
4557 [
self pollGuiScreenControlsWithFKeyAlias:YES];
4561- (void) pollGuiScreenControlsWithFKeyAlias:(BOOL)fKeyAlias
4563 if(!pollControls && fKeyAlias)
4568 BOOL docked_okay = ([
self status] == STATUS_DOCKED);
4571 if ([
self checkKeyPress:n_key_gui_screen_status fKey_only:!fKeyAlias])
4576 if (gui_screen == GUI_SCREEN_STATUS)
4578 [
self noteGUIWillChangeTo:GUI_SCREEN_MANIFEST];
4579 [
self setGuiToManifestScreen];
4582 [
self setGuiToStatusScreen];
4591 if ([
self checkKeyPress:n_key_gui_chart_screens fKey_only:!fKeyAlias])
4599 if (
EXPECT_NOT([
self status] == STATUS_WITCHSPACE_COUNTDOWN && gui_screen == GUI_SCREEN_SHORT_RANGE_CHART))
4604 else if (gui_screen == GUI_SCREEN_SHORT_RANGE_CHART || (gui_screen == GUI_SCREEN_SYSTEM_DATA && showingLongRangeChart))
4608 saved_chart_zoom = target_chart_zoom;
4611 [
self noteGUIWillChangeTo:GUI_SCREEN_LONG_RANGE_CHART];
4612 [
self setGuiToLongRangeChartScreen];
4618 target_chart_zoom = saved_chart_zoom;
4621 [
self noteGUIWillChangeTo:GUI_SCREEN_SHORT_RANGE_CHART];
4622 [
self setGuiToShortRangeChartScreen];
4631 if ([
self checkKeyPress:n_key_gui_system_data fKey_only:!fKeyAlias])
4633 if (gui_screen != GUI_SCREEN_SYSTEM_DATA)
4635 showingLongRangeChart = (gui_screen == GUI_SCREEN_LONG_RANGE_CHART);
4636 [
self noteGUIWillChangeTo:GUI_SCREEN_SYSTEM_DATA];
4637 [
self setGuiToSystemDataScreen];
4641 if ([
self checkKeyPress:n_key_gui_market fKey_only:!fKeyAlias])
4643 if (gui_screen != GUI_SCREEN_MARKET)
4647 [
self noteGUIWillChangeTo:GUI_SCREEN_MARKET];
4648 [
self setGuiToMarketScreen];
4654 [
self noteGUIWillChangeTo:GUI_SCREEN_MARKETINFO];
4655 [
self setGuiToMarketInfoScreen];
4662 if (([
self checkKeyPress:n_key_gui_screen_options fKey_only:!fKeyAlias]) && (gui_screen != GUI_SCREEN_OPTIONS))
4665 [
self setGuiToLoadSaveScreen];
4668 if ([
self checkKeyPress:n_key_gui_screen_equipship fKey_only:!fKeyAlias])
4672 if ([
self dockedStation] ==
nil) [
self setDockedAtMainStation];
4675 if ((gui_screen == GUI_SCREEN_EQUIP_SHIP) && [[
self dockedStation] hasShipyard])
4678 [
self noteGUIWillChangeTo:GUI_SCREEN_SHIPYARD];
4680 [
self setGuiToShipyardScreen:0];
4682 [
self showShipyardInfoForSelection];
4687 [
self noteGUIWillChangeTo:GUI_SCREEN_EQUIP_SHIP];
4689 [
self setGuiToEquipShipScreen:0];
4693 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
4702 if ([
self checkKeyPress:n_key_gui_screen_interfaces fKey_only:!fKeyAlias])
4706 [
self setGuiToInterfacesScreen:0];
4720- (void) pollGameOverControls:(
double)delta_t
4723 if ([gameView isDown:32])
4727 [UNIVERSE displayMessage:@"" forCount:1.0];
4741- (void) pollAutopilotControls:(
double)delta_t
4744 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;
4749 if (![[
UNIVERSE gameController] isGamePaused])
4760 if ([
self checkKeyPress:n_key_autopilot] || joyButtonState[BUTTON_DOCKCPU]
4761 || [
self checkKeyPress:n_key_autodock] || joyButtonState[BUTTON_DOCKCPUFAST])
4766 [UNIVERSE addMessage:DESC(@"autopilot-off") forCount:4.5];
4769 if ([
self checkKeyPress:n_key_autodock] || joyButtonState[BUTTON_DOCKCPUFAST])
4780 if (([
self checkKeyPress:n_key_docking_music] || joyButtonState[BUTTON_DOCKINGMUSIC]))
4793 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)
4813 if ([
self checkKeyPress:n_key_pausebutton] || joyButtonState[BUTTON_PAUSE])
4831- (void) pollDockedControls:(
double)delta_t
4836 NSString *exceptionContext =
@"setup";
4841 exceptionContext =
@"pause key";
4842 if (([
self checkKeyPress:n_key_pausebutton] || joyButtonState[
BUTTON_PAUSE]) && (gui_screen != GUI_SCREEN_LONG_RANGE_CHART &&
4843 gui_screen != GUI_SCREEN_REPORT &&
4844 gui_screen != GUI_SCREEN_SAVE && gui_screen != GUI_SCREEN_KEYBOARD_ENTRY) )
4846 BOOL isMissionScreenWithTextEntry = gui_screen == GUI_SCREEN_MISSION && _missionTextEntry;
4849 if ([gameController isGamePaused])
4853 if ([
UNIVERSE pauseMessageVisible])
4855 [UNIVERSE clearPreviousMessage];
4857 [[UNIVERSE gui] setForegroundTextureKey:@"docked_overlay"];
4862 if (!isMissionScreenWithTextEntry)
4865 [[UNIVERSE messageGUI] clear];
4867 [UNIVERSE pauseGame];
4871 if (!isMissionScreenWithTextEntry)
4881 if ([gameController isGamePaused])
return;
4885 exceptionContext =
@"undock";
4886 if ([
self checkKeyPress:n_key_launch_ship])
4888 if (
EXPECT((gui_screen != GUI_SCREEN_MISSION || _missionAllowInterrupt) && gui_screen != GUI_SCREEN_KEYBOARD_ENTRY))
4890 [
self handleUndockControl];
4897 exceptionContext =
@"GUI keys";
4898 if (gui_screen == GUI_SCREEN_MISSION || gui_screen == GUI_SCREEN_KEYBOARD_ENTRY)
4900 [
self pollDemoControls: delta_t];
4904 if (gui_screen != GUI_SCREEN_REPORT)[
self pollGuiScreenControls];
4907 [
self pollGuiArrowKeyControls:delta_t];
4909 @catch (NSException *exception)
4911 OOLog(
kOOLogException,
@"***** Exception in pollDockedControls [%@]: %@ : %@", exceptionContext, [exception name], [exception reason]);
4916- (void) handleUndockControl
4919 [UNIVERSE setUpUniverseFromStation];
4920 if ([
self dockedStation] ==
nil) [
self setDockedAtMainStation];
4925 [
self autosavePlayer];
4927 [
self launchFromStation];
4931- (void) pollDemoControls:(
double)delta_t
4935 NSUInteger end_row = 21;
4940 case GUI_SCREEN_INTRO1:
4941 [
self handleGUIUpDownArrowKeys];
4948 if (([gameView isDown:
gvMouseDoubleClick] || [
self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 2+row_zero)
4951 [UNIVERSE removeDemoShips];
4953 if (![
self loadPlayer])
4955 [
self setGuiToIntroFirstGo:YES];
4960 if (([gameView isDown:
gvMouseDoubleClick] || [
self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 1+row_zero)
4963 [
self setGuiToScenarioScreen:0];
4965 else if (([gameView isDown:
gvMouseDoubleClick] || [
self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 3+row_zero)
4967 [
self setGuiToIntroFirstGo:NO];
4969 else if (([gameView isDown:
gvMouseDoubleClick] || [
self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 4+row_zero)
4971 [
self setGuiToGameOptionsScreen];
4973 else if (([gameView isDown:
gvMouseDoubleClick] || [
self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 5+row_zero)
4975 [
self setGuiToOXZManager];
4977 else if (([gameView isDown:
gvMouseDoubleClick] || [
self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 6+row_zero)
4979 [[UNIVERSE gameController] exitAppWithContext:@"Exit Game selected on start screen"];
4993 case GUI_SCREEN_GAMEOPTIONS:
4994 [
self handleGameOptionsScreenKeys];
4997 case GUI_SCREEN_KEYBOARD:
5002 [
self handleKeyMapperScreenKeys];
5005 case GUI_SCREEN_KEYBOARD_CONFIRMCLEAR:
5006 [
self handleKeyMapperConfirmClearKeys:gui view:gameView];
5009 case GUI_SCREEN_KEYBOARD_CONFIG:
5010 [
self handleKeyConfigKeys:gui view:gameView];
5013 case GUI_SCREEN_KEYBOARD_ENTRY:
5014 [
self handleKeyConfigEntryKeys:gui view:gameView];
5017 case GUI_SCREEN_KEYBOARD_LAYOUT:
5018 [
self handleKeyboardLayoutKeys];
5021 case GUI_SCREEN_STICKMAPPER:
5022 [
self handleStickMapperScreenKeys];
5025 case GUI_SCREEN_STICKPROFILE:
5026 [
self stickProfileInputHandler:gui view:gameView];
5029 case GUI_SCREEN_SHIPLIBRARY:
5030 if ([gameView isDown:
' '])
5033 [
self setGuiToIntroFirstGo:YES];
5035 if ([
self checkKeyPress:n_key_gui_arrow_up])
5038 [UNIVERSE selectIntro2Previous];
5040 if ([
self checkKeyPress:n_key_gui_arrow_down])
5043 [UNIVERSE selectIntro2Next];
5045 upDownKeyPressed = (([
self checkKeyPress:n_key_gui_arrow_up])||([
self checkKeyPress:n_key_gui_arrow_down]));
5047 if ([
self checkKeyPress:n_key_gui_arrow_left])
5050 [UNIVERSE selectIntro2PreviousCategory];
5052 if ([
self checkKeyPress:n_key_gui_arrow_right])
5055 [UNIVERSE selectIntro2NextCategory];
5057 leftRightKeyPressed = (([
self checkKeyPress:n_key_gui_arrow_left])||([
self checkKeyPress:n_key_gui_arrow_right]));
5062 case GUI_SCREEN_NEWGAME:
5063 if ([
self handleGUIUpDownArrowKeys])
5065 [
self showScenarioDetails];
5070 if ([
self checkKeyPress:n_key_gui_page_up])
5077 [
self startScenario];
5082 else if ([
self checkKeyPress:n_key_gui_page_down])
5089 [
self startScenario];
5094 pageUpDownKeyPressed = [
self checkKeyPress:n_key_gui_page_down]|[
self checkKeyPress:n_key_gui_page_up];
5100 if (![
self startScenario])
5102 [UNIVERSE removeDemoShips];
5103 [
self setGuiToIntroFirstGo:YES];
5114 case GUI_SCREEN_OXZMANAGER:
5117 if (
EXPECT(![oxzmanager isRestarting]))
5119 if ([oxzmanager isAcceptingGUIInput])
5121 if ([oxzmanager isAcceptingTextInput])
5130 if ([
self handleGUIUpDownArrowKeys])
5135 if ([
self checkKeyPress:n_key_gui_arrow_left] || [
self checkKeyPress:n_key_gui_page_up])
5142 else if ([
self checkKeyPress:n_key_gui_arrow_right] || [
self checkKeyPress:n_key_gui_page_down])
5149 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];
5155 if ([oxzmanager isAcceptingTextInput])
5171 if ([
self checkKeyPress:n_key_oxzmanager_setfilter] ||
5172 [
self checkKeyPress:n_key_oxzmanager_showinfo] ||
5173 [
self checkKeyPress:n_key_oxzmanager_extract])
5178 if ([
self checkKeyPress:n_key_oxzmanager_setfilter])
5182 else if ([
self checkKeyPress:n_key_oxzmanager_showinfo])
5186 else if ([
self checkKeyPress:n_key_oxzmanager_extract])
5202 case GUI_SCREEN_MISSION:
5203 if ([[
self hud] allowBigGui])
5207 if (_missionTextEntry)
5209 [
self refreshMissionScreenTextEntry];
5212 [
self setMissionChoice:[gameView
typedString] keyPress:@"enter"];
5214 [
self playDismissedMissionScreen];
5216 [
self handleMissionCallback];
5226 [
self pollMissionInterruptControls];
5229 else if ([[gui keyForRow:end_row] isEqual:
@"spacebar"])
5231 if ([gameView isDown:32])
5236 [
self handleMissionCallback];
5244 [
self pollMissionInterruptControls];
5249 [
self handleGUIUpDownArrowKeys];
5250 NSString *extraKey =
@"";
5251 if (extraMissionKeys)
5253 NSString *key =
nil;
5254 foreach (key, [extraMissionKeys allKeys])
5256 if ([
self checkKeyPress:[extraMissionKeys oo_arrayForKey:key]]) {
5259 extraKey = [key copy];
5267 if ([
self checkKeyPress:n_key_gui_select] || [gameView isDown:
gvMouseDoubleClick] || [extraKey length] > 0)
5276 if ([extraKey length] == 0) extraKey =
@"enter";
5279 [
self playDismissedMissionScreen];
5281 [
self handleMissionCallback];
5290 [
self pollMissionInterruptControls];
5296#if OO_USE_CUSTOM_LOAD_SAVE
5298 case GUI_SCREEN_LOAD:
5300 NSString *commanderFile = [
self commanderSelector];
5307 [
self loadPlayerFromFile:commanderFile asNew:NO];
5319- (void) pollMissionInterruptControls
5321 if (_missionAllowInterrupt)
5323 if (gui_screen == GUI_SCREEN_MISSION && _missionTextEntry)
5325 [
self pollGuiScreenControlsWithFKeyAlias:NO];
5328 [
self pollGuiScreenControls];
5330 if (gui_screen != GUI_SCREEN_MISSION)
5332 if (gui_screen != GUI_SCREEN_SYSTEM_DATA)
5334 [UNIVERSE removeDemoShips];
5336 [
self endMissionScreenAndNoteOpportunity];
5342- (void) handleMissionCallback
5344 [UNIVERSE removeDemoShips];
5345 [[UNIVERSE gui] clearBackground];
5347 [
self setGuiToMissionEndScreen];
5349 if ([
self status] != STATUS_DOCKED) [
self switchToThisView:VIEW_FORWARD];
5351 if (_missionWithCallback)
5353 [
self doMissionCallback];
5356 if ([
self status] != STATUS_DOCKED)
5359 [
self doWorldEventUntilMissionScreen:OOJSID("missionScreenEnded")];
5363 if (gui_screen != GUI_SCREEN_MISSION)
5366 [
self setGuiToMissionEndScreen];
5367 [
self endMissionScreenAndNoteOpportunity];
5373- (void) setGuiToMissionEndScreen
5377 if ([
self status] != STATUS_DOCKED)
5380 [
self setGuiToStatusScreen];
5383 switch (_missionExitScreen)
5385 case GUI_SCREEN_MANIFEST:
5386 [
self noteGUIWillChangeTo:GUI_SCREEN_MANIFEST];
5387 [
self setGuiToManifestScreen];
5389 case GUI_SCREEN_EQUIP_SHIP:
5390 [
self noteGUIWillChangeTo:GUI_SCREEN_EQUIP_SHIP];
5391 [
self setGuiToEquipShipScreen:0];
5393 case GUI_SCREEN_SHIPYARD:
5394 if ([[
self dockedStation] hasShipyard])
5396 [
self noteGUIWillChangeTo:GUI_SCREEN_SHIPYARD];
5397 [
self setGuiToShipyardScreen:0];
5398 [[UNIVERSE gui] setSelectedRow:GUI_ROW_SHIPYARD_START];
5399 [
self showShipyardInfoForSelection];
5404 [
self setGuiToStatusScreen];
5407 case GUI_SCREEN_LONG_RANGE_CHART:
5408 [
self setGuiToLongRangeChartScreen];
5410 case GUI_SCREEN_SHORT_RANGE_CHART:
5411 [
self setGuiToShortRangeChartScreen];
5413 case GUI_SCREEN_SYSTEM_DATA:
5414 [
self noteGUIWillChangeTo:GUI_SCREEN_SYSTEM_DATA];
5415 [
self setGuiToSystemDataScreen];
5417 case GUI_SCREEN_MARKET:
5418 [
self noteGUIWillChangeTo:GUI_SCREEN_MARKET];
5419 [
self setGuiToMarketScreen];
5421 case GUI_SCREEN_MARKETINFO:
5422 [
self noteGUIWillChangeTo:GUI_SCREEN_MARKETINFO];
5423 [
self setGuiToMarketInfoScreen];
5425 case GUI_SCREEN_INTERFACES:
5426 [
self setGuiToInterfacesScreen:0];
5428 case GUI_SCREEN_STATUS:
5430 [
self setGuiToStatusScreen];
5435- (void) switchToThisView:(
OOViewID)viewDirection
5437 [
self switchToThisView:viewDirection andProcessWeaponFacing:YES];
5441- (void) switchToThisView:(
OOViewID)viewDirection andProcessWeaponFacing:(BOOL)processWeaponFacing
5443 [
self switchToThisView:viewDirection fromView:[UNIVERSE viewDirection] andProcessWeaponFacing:processWeaponFacing justNotify:NO];
5447- (void) switchToThisView:(
OOViewID)viewDirection fromView:(
OOViewID)oldViewDirection andProcessWeaponFacing:(BOOL)processWeaponFacing justNotify:(BOOL)justNotify
5451 if ([
UNIVERSE displayGUI]) [
self switchToMainView];
5452 [UNIVERSE setViewDirection:viewDirection];
5454 if (processWeaponFacing)
5457 switch (viewDirection)
5471 case VIEW_STARBOARD:
5481 currentWeaponFacing = facing;
5482 [
self currentWeaponStats];
5489 if ((oldViewDirection != viewDirection || viewDirection == VIEW_CUSTOM) && ![[
UNIVERSE gameController] isGamePaused])
5499- (void) handleAutopilotOn:(BOOL)fastDocking
5501 NSString *message =
nil;
5507 [
self playAutopilotCannotDockWithTarget];
5512 Entity *target = [
self primaryTarget];
5514 if (![target isStation])
5521 for (i = 0; i < uni->
n_entities && nStations < 2; i++)
5523 if (entities[i]->isStation && [entities[i] isKindOfClass:[
StationEntity class]] &&
5527 target = entities[i];
5534 if ([
self withinStationAegis] && legalStatus <= 50)
5536 target = [UNIVERSE station];
5538 else if (nStations != 1)
5542 [
self playAutopilotOutOfRange];
5547 [
self playAutopilotCannotDockWithTarget];
5548 message =
OOExpandKey(
@"autopilot-multiple-targets");
5560 if (![ts allowsAutoDocking])
5562 [
self playAutopilotCannotDockWithTarget];
5563 message =
OOExpandKey(
@"autopilot-station-does-not-allow-autodocking", stationName);
5566 else if ((legalStatus > 50 && ts == [
UNIVERSE station]) || [ts isHostileTo:
self])
5568 [
self playAutopilotCannotDockWithTarget];
5569 message =
OOExpandKey((ts == [
UNIVERSE station]) ?
@"autopilot-denied" :
@"autopilot-target-docking-instructions-denied", stationName);
5572 else if (fastDocking && [ts allowsFastDocking])
5575 NSEnumerator *subEnum =
nil;
5577 for (subEnum = [ts dockSubEntityEnumerator]; (sub = [subEnum nextObject]); )
5580 if([[sub canAcceptShipForDocking:
self] isEqualToString:
@"TOO_BIG_TO_DOCK"])
5582 message =
OOExpandKey((ts == [
UNIVERSE station]) ?
@"autopilot-denied" :
@"autopilot-target-docking-instructions-denied", stationName);
5587 if (legalStatus > 0)
5591 int government = 1 + [[
UNIVERSE currentSystemData] oo_intForKey:KEY_GOVERNMENT];
5592 if ([
UNIVERSE inInterstellarSpace]) government = 2;
5593 fine_chance /= government;
5594 if (fine_chance < legalStatus)
5596 [
self markForFines];
5600 [
self setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_GRANTED];
5602 [UNIVERSE forceWitchspaceEntries];
5603 ship_clock_adjust += 1200.0;
5605 [
self safeAllMissiles];
5606 [UNIVERSE setViewDirection:VIEW_FORWARD];
5607 [
self enterDock:ts];
5612 [
self engageAutopilotToStation:ts];
5618 if (message !=
nil) [UNIVERSE addMessage:message forCount:4.5];
5623- (void) handleButtonIdent
5626 if (ident_engaged) [
self noteLostTarget];
5628 [
self safeAllMissiles];
5629 ident_engaged = YES;
5630 if ([
self primaryTarget] ==
nil)
5633 [UNIVERSE addMessage:OOExpandKey(@"ident-on") forCount:2.0];
5637 [
self playIdentLockedOn];
5638 [
self printIdentLockedOnForMissile:NO];
5643- (void) handleButtonTargetMissile
5645 if (![
self weaponsOnline])
5647 [
self handleButtonIdent];
5654 [
self noteLostTarget];
5659 if ([missile_entity[activeMissile] isMissile])
5661 if ([[
self primaryTarget] isShip])
5664 [missile_entity[activeMissile] addTarget:[
self primaryTarget]];
5665 [
self printIdentLockedOnForMissile:YES];
5666 [
self playMissileLockedOn];
5671 if ([
self primaryTarget] !=
nil)
5673 [
self noteLostTarget];
5675 [missile_entity[activeMissile] noteLostTarget];
5676 NSString *weaponName = [missile_entity[activeMissile] name];
5677 [UNIVERSE addMessage:OOExpandKey(@"missile-armed", weaponName) forCount:2.0];
5678 [
self playMissileArmed];
5681 else if ([missile_entity[activeMissile] isMine])
5683 NSString *weaponName = [missile_entity[activeMissile] name];
5684 [UNIVERSE addMessage:OOExpandKey(@"mine-armed", weaponName) forCount:2.0];
5685 [
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 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 switching_interface_screens
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)
BOOL setDisplayWidth:Height:Refresh:(unsigned int d_width,[Height] unsigned int d_height,[Refresh] unsigned int d_refresh)
void exitAppWithContext:(NSString *context)
void exitFullScreenMode()
void setMouseInteractionModeForFlight()
NSUInteger indexOfCurrentDisplayMode()
void pauseFullScreenModeToPerform:onTarget:(SEL selector,[onTarget] id target)
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)
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)
BOOL checkKeyPress:(NSArray *key_def)
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