Oolite
Loading...
Searching...
No Matches
PlayerEntity(OOControlsPrivate) Category Reference

Instance Methods

(void) - pollFlightControls:
 
(void) - pollFlightArrowKeyControls:
 
(void) - pollGuiArrowKeyControls:
 
(void) - handleGameOptionsScreenKeys
 
(void) - handleKeyMapperScreenKeys
 
(void) - handleKeyboardLayoutKeys
 
(void) - handleStickMapperScreenKeys
 
(void) - pollApplicationControls
 
(void) - pollCustomViewControls
 
(void) - pollViewControls
 
(void) - pollGuiScreenControls
 
(void) - pollGuiScreenControlsWithFKeyAlias:
 
(void) - pollMarketScreenControls
 
(void) - handleUndockControl
 
(void) - pollGameOverControls:
 
(void) - pollAutopilotControls:
 
(void) - pollDockedControls:
 
(void) - pollDemoControls:
 
(void) - pollMissionInterruptControls
 
(void) - handleMissionCallback
 
(void) - setGuiToMissionEndScreen
 
(void) - switchToThisView:
 
(void) - switchToThisView:andProcessWeaponFacing:
 
(void) - switchToThisView:fromView:andProcessWeaponFacing:justNotify:
 
(void) - handleAutopilotOn:
 
(void) - handleButtonIdent
 
(void) - handleButtonTargetMissile
 

Detailed Description

Definition at line 167 of file PlayerEntityControls.m.

Method Documentation

◆ handleAutopilotOn:

- (void) handleAutopilotOn: (BOOL)  fastDocking

Definition at line 4739 of file PlayerEntityControls.m.

5499 :(BOOL)fastDocking
5500{
5501 NSString *message = nil;
5502
5503 // Check alert condition - on red alert, abort
5504 // -- but only for fast docking
5505 if (fastDocking && ([self alertCondition] == ALERT_CONDITION_RED))
5506 {
5507 [self playAutopilotCannotDockWithTarget];
5508 message = OOExpandKey(@"autopilot-red-alert");
5509 goto abort;
5510 }
5511
5512 Entity *target = [self primaryTarget];
5513 // If target isn't dockable, check for nearby stations
5514 if (![target isStation])
5515 {
5516 Universe *uni = UNIVERSE;
5517 Entity **entities = uni->sortedEntities; // grab the public sorted list
5518 int nStations = 0;
5519 unsigned i;
5520
5521 for (i = 0; i < uni->n_entities && nStations < 2; i++)
5522 {
5523 if (entities[i]->isStation && [entities[i] isKindOfClass:[StationEntity class]] &&
5524 entities[i]->zero_distance <= SCANNER_MAX_RANGE2)
5525 {
5526 nStations++;
5527 target = entities[i];
5528 }
5529 }
5530 // If inside the Aegis, dock with the main station.
5531 // If we found one target, dock with it.
5532 // If outside the Aegis and we found multiple targets, abort.
5533
5534 if ([self withinStationAegis] && legalStatus <= 50)
5535 {
5536 target = [UNIVERSE station];
5537 }
5538 else if (nStations != 1)
5539 {
5540 if (nStations == 0)
5541 {
5542 [self playAutopilotOutOfRange];
5543 message = OOExpandKey(@"autopilot-out-of-range");
5544 }
5545 else
5546 {
5547 [self playAutopilotCannotDockWithTarget];
5548 message = OOExpandKey(@"autopilot-multiple-targets");
5549 }
5550 goto abort;
5551 }
5552 }
5553
5554 // We found a dockable, check whether we can dock with it
5555 // NSAssert([target isKindOfClass:[StationEntity class]], @"Expected entity with isStation flag set to be a station."); // no need for asserts. Tested enough already.
5556 StationEntity *ts = (StationEntity *)target;
5557 NSString *stationName = [ts displayName];
5558
5559 // If station is not transmitting docking instructions, we cannot use autopilot.
5560 if (![ts allowsAutoDocking])
5561 {
5562 [self playAutopilotCannotDockWithTarget];
5563 message = OOExpandKey(@"autopilot-station-does-not-allow-autodocking", stationName);
5564 }
5565 // Deny if station is hostile or player is a fugitive trying to dock at the main station.
5566 else if ((legalStatus > 50 && ts == [UNIVERSE station]) || [ts isHostileTo:self])
5567 {
5568 [self playAutopilotCannotDockWithTarget];
5569 message = OOExpandKey((ts == [UNIVERSE station]) ? @"autopilot-denied" : @"autopilot-target-docking-instructions-denied", stationName);
5570 }
5571 // If we're fast-docking, perform the docking logic
5572 else if (fastDocking && [ts allowsFastDocking])
5573 {
5574 // check whether there are docks that do not accept docking - even one such dock will result in rejection
5575 NSEnumerator *subEnum = nil;
5576 DockEntity* sub = nil;
5577 for (subEnum = [ts dockSubEntityEnumerator]; (sub = [subEnum nextObject]); )
5578 {
5579 // TOO_BIG_TO_DOCK issued when docks are scripted to reject docking
5580 if([[sub canAcceptShipForDocking:self] isEqualToString:@"TOO_BIG_TO_DOCK"])
5581 {
5582 message = OOExpandKey((ts == [UNIVERSE station]) ? @"autopilot-denied" : @"autopilot-target-docking-instructions-denied", stationName);
5583 goto abort;
5584 }
5585 }
5586
5587 if (legalStatus > 0)
5588 {
5589 // there's a slight chance you'll be fined for your past offences when autodocking
5590 int fine_chance = ranrot_rand() & 0x03ff; // 0..1023
5591 int government = 1 + [[UNIVERSE currentSystemData] oo_intForKey:KEY_GOVERNMENT]; // 1..8
5592 if ([UNIVERSE inInterstellarSpace]) government = 2; // equivalent to Feudal. I'm assuming any station in interstellar space is military. -- Ahruman 2008-05-29
5593 fine_chance /= government;
5594 if (fine_chance < legalStatus)
5595 {
5596 [self markForFines];
5597 }
5598 }
5599
5600 [self setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_GRANTED];
5601
5602 [UNIVERSE forceWitchspaceEntries];
5603 ship_clock_adjust += 1200.0; // 20 minutes penalty to enter dock
5604 ident_engaged = NO;
5605 [self safeAllMissiles];
5606 [UNIVERSE setViewDirection:VIEW_FORWARD];
5607 [self enterDock:ts];
5608 }
5609 else
5610 {
5611 // Standard docking - engage autopilot
5612 [self engageAutopilotToStation:ts];
5613 message = OOExpandKey(@"autopilot-on");
5614 }
5615
5616abort:
5617 // Clean-up code
5618 if (message != nil) [UNIVERSE addMessage:message forCount:4.5];
5619 return;
5620}
#define SCANNER_MAX_RANGE2
Definition Entity.h:52
return self
return nil
#define OOExpandKey(key,...)
@ ALERT_CONDITION_RED
Definition ShipEntity.h:178
#define UNIVERSE
Definition Universe.h:842
NSString * displayName
Definition ShipEntity.h:330
unsigned n_entities
Definition Universe.h:192
Entity * sortedEntities[UNIVERSE_MAX_ENTITIES+1]
Definition Universe.h:191
#define ranrot_rand()

References autopilot_key_pressed, autopilot_pause, PlayerEntity::checkKeyPress:, PlayerEntity::disengageAutopilot, fast_autopilot_key_pressed, OOJoystickManager::getAllButtonStates, OOMusicController::isPlaying, pause_pressed, playing_music, PlayerEntity::pollFlightControls:, PlayerEntity::pollGuiArrowKeyControls:, PlayerEntity::pollGuiScreenControls, PlayerEntity::pollViewControls, OOMusicController::sharedController, OOJoystickManager::sharedStickHandler, OOMusicController::toggleDockingMusic, toggling_music, and UNIVERSE.

+ Here is the call graph for this function:

◆ handleButtonIdent

- (void) handleButtonIdent

Definition at line 4739 of file PlayerEntityControls.m.

5624{
5625 // Clear current target if we're already in Ident mode
5626 if (ident_engaged) [self noteLostTarget];
5627
5628 [self safeAllMissiles];
5629 ident_engaged = YES;
5630 if ([self primaryTarget] == nil)
5631 {
5632 [self playIdentOn];
5633 [UNIVERSE addMessage:OOExpandKey(@"ident-on") forCount:2.0];
5634 }
5635 else
5636 {
5637 [self playIdentLockedOn];
5638 [self printIdentLockedOnForMissile:NO];
5639 }
5640}

◆ handleButtonTargetMissile

- (void) handleButtonTargetMissile

Definition at line 4739 of file PlayerEntityControls.m.

5644{
5645 if (![self weaponsOnline])
5646 {
5647 [self handleButtonIdent];
5648 return;
5649 }
5650
5651 // Clear current target if we're already in Missile Targeting mode
5652 if (missile_status != MISSILE_STATUS_SAFE)
5653 {
5654 [self noteLostTarget];
5655 }
5656
5657 // Arm missile and check for missile lock
5658 missile_status = MISSILE_STATUS_ARMED;
5659 if ([missile_entity[activeMissile] isMissile])
5660 {
5661 if ([[self primaryTarget] isShip])
5662 {
5663 missile_status = MISSILE_STATUS_TARGET_LOCKED;
5664 [missile_entity[activeMissile] addTarget:[self primaryTarget]];
5665 [self printIdentLockedOnForMissile:YES];
5666 [self playMissileLockedOn];
5667 }
5668 else
5669 {
5670 // if it's nil, that means it was lost earlier
5671 if ([self primaryTarget] != nil)
5672 {
5673 [self noteLostTarget];
5674 }
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];
5679 }
5680 }
5681 else if ([missile_entity[activeMissile] isMine])
5682 {
5683 NSString *weaponName = [missile_entity[activeMissile] name];
5684 [UNIVERSE addMessage:OOExpandKey(@"mine-armed", weaponName) forCount:2.0];
5685 [self playMineArmed];
5686 }
5687 ident_engaged = NO;
5688}
@ MISSILE_STATUS_TARGET_LOCKED
@ MISSILE_STATUS_ARMED
@ MISSILE_STATUS_SAFE

◆ handleGameOptionsScreenKeys

- (void) handleGameOptionsScreenKeys

Definition at line 164 of file PlayerEntityControls.m.

3398{
3399 MyOpenGLView *gameView = [UNIVERSE gameView];
3400 GuiDisplayGen *gui = [UNIVERSE gui];
3401 GUI_ROW_INIT(gui);
3402
3403 [self handleGUIUpDownArrowKeys];
3404 OOGUIRow guiSelectedRow = [gui selectedRow];
3405 BOOL selectKeyPress = ([self checkKeyPress:n_key_gui_select]||[gameView isDown:gvMouseDoubleClick]);
3406 if ([gameView isDown:gvMouseDoubleClick]) [gameView clearMouse];
3407
3408 if ((guiSelectedRow == GUI_ROW(GAME,STICKMAPPER)) && selectKeyPress)
3409 {
3410 selFunctionIdx = 0;
3411 [self resetStickFunctions]; // reset the list of stick functions, so changes in oxp equipment are reflected
3412 [self setGuiToStickMapperScreen: 0 resetCurrentRow: YES];
3413 }
3414 if ((guiSelectedRow == GUI_ROW(GAME,KEYMAPPER)) && selectKeyPress)
3415 {
3416 selFunctionIdx = 0;
3417 [self resetKeyFunctions]; // reset the list of key functions, so changes in oxp equipment are reflected
3418 [self setGuiToKeyMapperScreen: 0 resetCurrentRow: YES];
3419 }
3420
3421
3422#if OOLITE_WINDOWS
3423 if ([gameView hdrOutput])
3424 {
3425 if ((guiSelectedRow == GUI_ROW(GAME,HDRMAXBRIGHTNESS))&&(([self checkKeyPress:n_key_gui_arrow_right])||([self checkKeyPress:n_key_gui_arrow_left])))
3426 {
3428 {
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]]];
3432
3433 if (brightnessIdx == NSNotFound)
3434 {
3435 OOLogWARN(@"hdr.maxBrightness.notFound", @"%@", @"couldn't find current max brightness setting, switching to lowest.");
3436 brightnessIdx = 0;
3437 }
3438
3439 brightnessIdx += direction;
3440 int count = [brightnesses count];
3441 if (brightnessIdx < 0)
3442 brightnessIdx = count - 1;
3443 if (brightnessIdx >= count)
3444 brightnessIdx = 0;
3445
3446 int brightnessValue = [brightnesses oo_intAtIndex:brightnessIdx];
3447
3448 // warp if the value we got is out of expected limits; can be the case if user has
3449 // manually modified the hdr_maxBrightness_array in descriptions.plist
3450 if (brightnessValue < MIN_HDR_MAXBRIGHTNESS) brightnessValue = direction == -1 ? MAX_HDR_MAXBRIGHTNESS : MIN_HDR_MAXBRIGHTNESS;
3451 if (brightnessValue > MAX_HDR_MAXBRIGHTNESS) brightnessValue = direction == 1 ? MIN_HDR_MAXBRIGHTNESS : MAX_HDR_MAXBRIGHTNESS;
3452
3453 [gameView setHDRMaxBrightness:(float)brightnessValue];
3454 NSString *maxBrightnessString = OOExpandKey(@"gameoptions-hdr-maxbrightness", brightnessValue);
3455
3456 [gui setText:maxBrightnessString forRow:GUI_ROW(GAME,HDRMAXBRIGHTNESS) align:GUI_ALIGN_CENTER];
3457
3459 }
3460 }
3461 else
3463 }
3464#endif
3465
3466
3467#if OO_RESOLUTION_OPTION
3468 if (!switching_resolution &&
3469 guiSelectedRow == GUI_ROW(GAME,DISPLAY) &&
3470 ([self checkKeyPress:n_key_gui_arrow_right] || [self checkKeyPress:n_key_gui_arrow_left]))
3471 {
3472 GameController *controller = [UNIVERSE gameController];
3473 int direction = ([self checkKeyPress:n_key_gui_arrow_right]) ? 1 : -1;
3474 NSInteger displayModeIndex = [controller indexOfCurrentDisplayMode];
3475 NSArray *modes = [controller displayModes];
3476
3477 if (displayModeIndex == (NSInteger)NSNotFound)
3478 {
3479 OOLogWARN(@"graphics.mode.notFound", @"%@", @"couldn't find current fullscreen setting, switching to default.");
3480 displayModeIndex = 0;
3481 }
3482
3483 displayModeIndex = displayModeIndex + direction;
3484 int count = [modes count];
3485 if (displayModeIndex < 0)
3486 displayModeIndex = count - 1;
3487 if (displayModeIndex >= count)
3488 displayModeIndex = 0;
3489
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];
3494 [controller setDisplayWidth:modeWidth Height:modeHeight Refresh:modeRefresh];
3495
3496 NSString *displayModeString = [self screenModeStringForWidth:modeWidth height:modeHeight refreshRate:modeRefresh];
3497
3498 [self playChangedOption];
3499 [gui setText:displayModeString forRow:GUI_ROW(GAME,DISPLAY) align:GUI_ALIGN_CENTER];
3501
3502#if OOLITE_SDL
3503 /* TODO: The gameView for the SDL game currently holds and
3504 sets the actual screen resolution (controller just stores
3505 it). This probably ought to change. */
3506 [gameView setScreenSize: displayModeIndex]; // changes fullscreen mode immediately
3507#endif
3508 }
3509 if (switching_resolution && ![self checkKeyPress:n_key_gui_arrow_right] && ![self checkKeyPress:n_key_gui_arrow_left] && !selectKeyPress)
3510 {
3512 }
3513#endif // OO_RESOLUTION_OPTION
3514
3515#if OOLITE_SPEECH_SYNTH
3516
3517 if ((guiSelectedRow == GUI_ROW(GAME,SPEECH))&&(([self checkKeyPress:n_key_gui_arrow_right])||([self checkKeyPress:n_key_gui_arrow_left])))
3518 {
3519 if (!speech_settings_pressed)
3520 {
3521 if ([self checkKeyPress:n_key_gui_arrow_right] && isSpeechOn < OOSPEECHSETTINGS_ALL)
3522 {
3523 ++isSpeechOn;
3524 [self playChangedOption];
3525 speech_settings_pressed = YES;
3526 }
3527 else if ([self checkKeyPress:n_key_gui_arrow_left] && isSpeechOn > OOSPEECHSETTINGS_OFF)
3528 {
3529 speech_settings_pressed = YES;
3530 --isSpeechOn;
3531 [self playChangedOption];
3532 }
3533 if (speech_settings_pressed)
3534 {
3535 NSString *message = nil;
3536 switch (isSpeechOn)
3537 {
3539 message = DESC(@"gameoptions-spoken-messages-no");
3540 break;
3542 message = DESC(@"gameoptions-spoken-messages-comms");
3543 break;
3545 message = DESC(@"gameoptions-spoken-messages-yes");
3546 break;
3547 }
3548 [gui setText:message forRow:GUI_ROW(GAME,SPEECH) align:GUI_ALIGN_CENTER];
3549
3550 if (isSpeechOn == OOSPEECHSETTINGS_ALL)
3551 {
3552 [UNIVERSE stopSpeaking];
3553 [UNIVERSE startSpeakingString:message];
3554 }
3555 }
3556 }
3557 }
3558 else
3559 {
3560 speech_settings_pressed = NO;
3561 }
3562#if OOLITE_ESPEAK
3563 if (guiSelectedRow == GUI_ROW(GAME,SPEECH_LANGUAGE))
3564 {
3565 if ([self checkKeyPress:n_key_gui_arrow_right] || [self checkKeyPress:n_key_gui_arrow_left])
3566 {
3567 if (!speechVoiceSelectKeyPressed || script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL)
3568 {
3569 [self playChangedOption];
3570 if ([self checkKeyPress:n_key_gui_arrow_right])
3571 voice_no = [UNIVERSE nextVoice: voice_no];
3572 else
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);
3577 [gui setText:message forRow:GUI_ROW(GAME,SPEECH_LANGUAGE) align:GUI_ALIGN_CENTER];
3578 if (isSpeechOn == OOSPEECHSETTINGS_ALL)
3579 {
3580 [UNIVERSE stopSpeaking];
3581 [UNIVERSE startSpeakingString:[UNIVERSE voiceName: voice_no]];
3582 }
3583 timeLastKeyPress = script_time;
3584 }
3585 speechVoiceSelectKeyPressed = YES;
3586 }
3587 else
3588 speechVoiceSelectKeyPressed = NO;
3589 }
3590
3591 if (guiSelectedRow == GUI_ROW(GAME,SPEECH_GENDER))
3592 {
3593 if ([self checkKeyPress:n_key_gui_arrow_right] || [self checkKeyPress:n_key_gui_arrow_left])
3594 {
3595 if (!speechGenderSelectKeyPressed)
3596 {
3597 [self playChangedOption];
3598 BOOL m = [self checkKeyPress:n_key_gui_arrow_right];
3599 if (m != voice_gender_m)
3600 {
3601 voice_gender_m = 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")];
3604 [gui setText:message forRow:GUI_ROW(GAME,SPEECH_GENDER) align:GUI_ALIGN_CENTER];
3605 if (isSpeechOn == OOSPEECHSETTINGS_ALL)
3606 {
3607 [UNIVERSE stopSpeaking];
3608 [UNIVERSE startSpeakingString:[UNIVERSE voiceName: voice_no]];
3609 }
3610 }
3611 }
3612 speechGenderSelectKeyPressed = YES;
3613 }
3614 else
3615 speechGenderSelectKeyPressed = NO;
3616 }
3617#endif
3618#endif
3619
3620 if ((guiSelectedRow == GUI_ROW(GAME,MUSIC))&&(([self checkKeyPress:n_key_gui_arrow_right])||([self checkKeyPress:n_key_gui_arrow_left])))
3621 {
3623 {
3625 int initialMode = [musicController mode];
3626 int mode = initialMode;
3627
3628 if ([self checkKeyPress:n_key_gui_arrow_right]) mode++;
3629 if ([self checkKeyPress:n_key_gui_arrow_left]) mode--;
3630
3631 [musicController setMode:MAX(mode, 0)];
3632
3633 if ((int)[musicController mode] != initialMode)
3634 {
3635 [self playChangedOption];
3636 NSString *musicMode = [UNIVERSE descriptionForArrayKey:@"music-mode" index:[[OOMusicController sharedController] mode]];
3637 NSString *message = OOExpandKey(@"gameoptions-music-mode", musicMode);
3638 [gui setText:message forRow:GUI_ROW(GAME,MUSIC) align:GUI_ALIGN_CENTER];
3639 }
3640 }
3641 musicModeKeyPressed = YES;
3642 }
3643 else musicModeKeyPressed = NO;
3644
3645 if ((guiSelectedRow == GUI_ROW(GAME,AUTOSAVE))&&(([self checkKeyPress:n_key_gui_arrow_right])||([self checkKeyPress:n_key_gui_arrow_left])))
3646 {
3647 if ([self checkKeyPress:n_key_gui_arrow_right] != [UNIVERSE autoSave])
3648 [self playChangedOption];
3649 [UNIVERSE setAutoSave:[self checkKeyPress:n_key_gui_arrow_right]];
3650 if ([UNIVERSE autoSave])
3651 {
3652 // if just enabled, we want to autosave immediately
3653 [UNIVERSE setAutoSaveNow:YES];
3654 [gui setText:DESC(@"gameoptions-autosave-yes") forRow:GUI_ROW(GAME,AUTOSAVE) align:GUI_ALIGN_CENTER];
3655 }
3656 else
3657 {
3658 [UNIVERSE setAutoSaveNow:NO];
3659 [gui setText:DESC(@"gameoptions-autosave-no") forRow:GUI_ROW(GAME,AUTOSAVE) align:GUI_ALIGN_CENTER];
3660 }
3661 }
3662
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)])
3666 {
3668 {
3669 BOOL rightKeyDown = [self checkKeyPress:n_key_gui_arrow_right];
3670 BOOL leftKeyDown = [self checkKeyPress:n_key_gui_arrow_left];
3671 double volume = 100.0 * [OOSound masterVolume];
3672 int vol = (volume / 5.0 + 0.5);
3673 if (rightKeyDown) vol++;
3674 if (leftKeyDown) vol--;
3675 vol = (int)OOClampInteger(vol, 0, 20);
3676 [OOSound setMasterVolume: 0.05 * vol];
3677 [self playChangedOption];
3678#if OOLITE_ESPEAK
3679 espeak_SetParameter(espeakVOLUME, vol * 5, 0);
3680#endif
3681 if (vol > 0)
3682 {
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];
3691 }
3692 else
3693 [gui setText:DESC(@"gameoptions-sound-volume-mute") forRow:GUI_ROW(GAME,VOLUME) align:GUI_ALIGN_CENTER];
3694 timeLastKeyPress = script_time;
3695 }
3697 }
3698 else
3700
3701 if ((guiSelectedRow == GUI_ROW(GAME,FOV))
3702 &&(([self checkKeyPress:n_key_gui_arrow_right])||([self checkKeyPress:n_key_gui_arrow_left])))
3703 {
3705 {
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];
3709 float fovStep = (MAX_FOV_DEG - MIN_FOV_DEG) / 20.0f;
3710 fov += (((rightKeyDown && (fov < MAX_FOV_DEG)) ?
3711 fovStep : 0.0f) - ((leftKeyDown && (fov > MIN_FOV_DEG)) ? fovStep : 0.0f));
3712 if (fov > MAX_FOV_DEG) fov = MAX_FOV_DEG;
3713 if (fov < MIN_FOV_DEG) fov = MIN_FOV_DEG;
3714 [gameView setFov:fov fromFraction:NO];
3715 fieldOfView = [gameView fov:YES];
3716 int fovTicks = (int)((fov - MIN_FOV_DEG) / fovStep);
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 /*176 is the degrees symbol ASCII code*/] forRow:GUI_ROW(GAME,FOV) align:GUI_ALIGN_CENTER];
3723 [[NSUserDefaults standardUserDefaults] setFloat:[gameView fov:NO] forKey:@"fov-value"];
3724 timeLastKeyPress = script_time;
3725 }
3726 fovControlPressed = YES;
3727 }
3728 else
3729 fovControlPressed = NO;
3730
3731
3732 // color blind mode
3733 if ((guiSelectedRow == GUI_ROW(GAME,COLORBLINDMODE))&&(([self checkKeyPress:n_key_gui_arrow_right])||([self checkKeyPress:n_key_gui_arrow_left])))
3734 {
3736 {
3737 int colorblindMode = [UNIVERSE colorblindMode];
3738 if ([self checkKeyPress:n_key_gui_arrow_right])
3739 {
3740 [UNIVERSE setCurrentPostFX:[UNIVERSE nextColorblindMode:colorblindMode]];
3741 }
3742 else
3743 {
3744 [UNIVERSE setCurrentPostFX:[UNIVERSE prevColorblindMode:colorblindMode]];
3745 }
3746 colorblindMode = [UNIVERSE colorblindMode]; // get the updated value
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];
3750 }
3752 }
3753 else
3755
3756
3757 if (![gameView hdrOutput])
3758 {
3759 if ((guiSelectedRow == GUI_ROW(GAME,WIREFRAMEGRAPHICS))&&(([self checkKeyPress:n_key_gui_arrow_right])||([self checkKeyPress:n_key_gui_arrow_left])))
3760 {
3761 if ([self checkKeyPress:n_key_gui_arrow_right] != [UNIVERSE wireframeGraphics])
3762 [self playChangedOption];
3763 [UNIVERSE setWireframeGraphics:[self checkKeyPress:n_key_gui_arrow_right]];
3764 if ([UNIVERSE wireframeGraphics])
3765 [gui setText:DESC(@"gameoptions-wireframe-graphics-yes") forRow:GUI_ROW(GAME,WIREFRAMEGRAPHICS) align:GUI_ALIGN_CENTER];
3766 else
3767 [gui setText:DESC(@"gameoptions-wireframe-graphics-no") forRow:GUI_ROW(GAME,WIREFRAMEGRAPHICS) align:GUI_ALIGN_CENTER];
3768 }
3769 }
3770#if OOLITE_WINDOWS
3771 else
3772 {
3773 if ((guiSelectedRow == GUI_ROW(GAME,HDRPAPERWHITE))
3774 &&(([self checkKeyPress:n_key_gui_arrow_right])||([self checkKeyPress:n_key_gui_arrow_left])))
3775 {
3777 {
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];
3781 paperWhite += (((rightKeyDown && (paperWhite < MAX_HDR_PAPERWHITE)) ? 10.0f : 0.0f) - ((leftKeyDown && (paperWhite > MIN_HDR_PAPERWHITE)) ? 10.0f : 0.0f));
3782 if (paperWhite > MAX_HDR_PAPERWHITE) paperWhite = MAX_HDR_PAPERWHITE;
3783 if (paperWhite < MIN_HDR_PAPERWHITE) paperWhite = MIN_HDR_PAPERWHITE;
3784 [gameView setHDRPaperWhiteBrightness:paperWhite];
3785 int paperWhiteNorm = (int)((paperWhite - MIN_HDR_PAPERWHITE) * 20 / (MAX_HDR_PAPERWHITE - MIN_HDR_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];
3792 }
3794 }
3795 else
3797 }
3798#endif
3799
3800#if !NEW_PLANETS
3801 if ((guiSelectedRow == GUI_ROW(GAME,PROCEDURALLYTEXTUREDPLANETS))&&(([self checkKeyPress:n_key_gui_arrow_right])||([self checkKeyPress:n_key_gui_arrow_left])))
3802 {
3803 if ([self checkKeyPress:n_key_gui_arrow_right] != [UNIVERSE doProcedurallyTexturedPlanets])
3804 {
3805 [UNIVERSE setDoProcedurallyTexturedPlanets:[self checkKeyPress:n_key_gui_arrow_right]];
3806 [self playChangedOption];
3807 if ([UNIVERSE planet])
3808 {
3809 [UNIVERSE setUpPlanet];
3810 }
3811 }
3812 if ([UNIVERSE doProcedurallyTexturedPlanets])
3813 [gui setText:DESC(@"gameoptions-procedurally-textured-planets-yes") forRow:GUI_ROW(GAME,PROCEDURALLYTEXTUREDPLANETS) align:GUI_ALIGN_CENTER];
3814 else
3815 [gui setText:DESC(@"gameoptions-procedurally-textured-planets-no") forRow:GUI_ROW(GAME,PROCEDURALLYTEXTUREDPLANETS) align:GUI_ALIGN_CENTER];
3816 }
3817#endif
3818
3819 if (guiSelectedRow == GUI_ROW(GAME,SHADEREFFECTS) && ([self checkKeyPress:n_key_gui_arrow_right] || [self checkKeyPress:n_key_gui_arrow_left]))
3820 {
3822 {
3823 int direction = ([self checkKeyPress:n_key_gui_arrow_right]) ? 1 : -1;
3824
3825 /* (Getafix - 2015/05/07)
3826 Fix bug coincidentally resulting in Graphics Detail value cycling
3827 when left arrow is pressed.
3828
3829 OOGraphicsDetail is an enum type and as such it will never go
3830 negative. The following code adjusts "direction" to avoid illegal
3831 detailLevel values.
3832
3833 Perhaps a more elegant solution could be set in place, restructuring
3834 in Universe.m the logic behing setDetailLevelDirectly and
3835 setDetailLevel, not forgetting to consider Graphic Detail assigned
3836 from various sources (i.e. menu, user prefs file, javascript, etc.).
3837 This is postponed in order not to risk the recently announced
3838 plans for v1.82 release.
3839
3840 Generally we should decide whether the menu values should cycle or
3841 not and apply it for all menu entries.
3842 */
3843 if ((([UNIVERSE detailLevel] == DETAIL_LEVEL_MINIMUM) && (direction == -1)) ||
3844 (([UNIVERSE detailLevel] == DETAIL_LEVEL_MAXIMUM) && (direction == 1)))
3845 direction = 0;
3846
3847 OOGraphicsDetail detailLevel = [UNIVERSE detailLevel] + direction;
3848 [UNIVERSE setDetailLevel:detailLevel];
3849 detailLevel = [UNIVERSE detailLevel];
3850
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)];
3854
3855 timeLastKeyPress = script_time;
3856
3857 // changing detail level may result in changes to other settings too
3858 // (e.g. colorblind mode status), so refresh the page
3859 [self setGuiToGameOptionsScreen];
3860 [gui setSelectedRow:GUI_ROW(GAME,SHADEREFFECTS)];
3861 }
3863 }
3864 else shaderSelectKeyPressed = NO;
3865
3866#if OOLITE_SDL
3867 if ((guiSelectedRow == GUI_ROW(GAME,DISPLAYSTYLE)) && selectKeyPress)
3868 {
3869 [gameView toggleScreenMode];
3870 // redraw GUI
3871 [self setGuiToGameOptionsScreen];
3872 }
3873#endif
3874
3875 if ((guiSelectedRow == GUI_ROW(GAME,DOCKINGCLEARANCE))&&(([self checkKeyPress:n_key_gui_arrow_right])||([self checkKeyPress:n_key_gui_arrow_left])))
3876 {
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];
3882 else
3883 [gui setText:DESC(@"gameoptions-docking-clearance-no") forRow:GUI_ROW(GAME,DOCKINGCLEARANCE) align:GUI_ALIGN_CENTER];
3884 }
3885
3886 if ((guiSelectedRow == GUI_ROW(GAME,BACK)) && selectKeyPress)
3887 {
3888 [gameView clearKeys];
3889 [self setGuiToLoadSaveScreen];
3890 }
3891}
@ gvMouseDoubleClick
#define MIN_FOV_DEG
#define MAX_FOV_DEG
NSInteger OOGUIRow
OOINLINE long long OOClampInteger(long long value, long long minValue, long long maxValue) ALWAYS_INLINE_FUNC
#define OOLogWARN(class, format,...)
Definition OOLogging.h:113
unsigned count
#define OOExpand(string,...)
OOGraphicsDetail
Definition OOTypes.h:243
@ DETAIL_LEVEL_MAXIMUM
Definition OOTypes.h:251
@ DETAIL_LEVEL_MINIMUM
Definition OOTypes.h:244
static BOOL musicModeKeyPressed
static BOOL shaderSelectKeyPressed
static BOOL volumeControlPressed
static BOOL hdrPaperWhiteControlPressed
static BOOL fovControlPressed
static BOOL colorblindModeControlPressed
static BOOL switching_resolution
static double timeLastKeyPress
static BOOL hdrMaxBrightnessControlPressed
@ OOSPEECHSETTINGS_ALL
@ OOSPEECHSETTINGS_OFF
@ OOSPEECHSETTINGS_COMMS
#define KEY_REPEAT_INTERVAL
#define GUI_ROW_INIT(GUI)
#define GUI_ROW(GROUP, ITEM)
#define MIN_HDR_MAXBRIGHTNESS
#define MIN_HDR_PAPERWHITE
#define MAX_HDR_MAXBRIGHTNESS
#define MAX_HDR_PAPERWHITE
#define DESC(key)
Definition Universe.h:848
BOOL setDisplayWidth:Height:Refresh:(unsigned int d_width,[Height] unsigned int d_height,[Refresh] unsigned int d_refresh)
BOOL setSelectedRow:(OOGUIRow row)
void setText:forRow:align:(NSString *str,[forRow] OOGUIRow row,[align] OOGUIAlignment alignment)
OOGUIRow selectedRow
void setKey:forRow:(NSString *str,[forRow] OOGUIRow row)
void setFov:fromFraction:(float value,[fromFraction] BOOL fromFraction)
BOOL isDown:(int key)
void toggleScreenMode()
void setScreenSize:(int sizeIndex)
float fov:(BOOL inFraction)
OOMusicController * sharedController()
void setMode:(OOMusicMode mode)
void setMasterVolume:(float fraction)
Definition OOALSound.m:64
float masterVolume()
Definition OOALSound.m:80
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
const char int mode
Definition ioapi.h:133

◆ handleKeyboardLayoutKeys

- (void) handleKeyboardLayoutKeys

Definition at line 164 of file PlayerEntityControls.m.

3934{
3935 MyOpenGLView *gameView = [UNIVERSE gameView];
3936 GuiDisplayGen *gui = [UNIVERSE gui];
3937
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];
3941 {
3942 NSString *key = [gui keyForRow: [gui selectedRow]];
3943 if ([self checkKeyPress:n_key_gui_arrow_right] || [self checkKeyPress:n_key_gui_page_down])
3944 {
3945 key = [gui keyForRow:GUI_ROW_KC_FUNCEND];
3946 }
3947 if ([self checkKeyPress:n_key_gui_arrow_left] || [self checkKeyPress:n_key_gui_page_up])
3948 {
3949 key = [gui keyForRow:GUI_ROW_KC_FUNCSTART];
3950 }
3951 int from_function = 0;
3952 NSArray *keyComponents = [key componentsSeparatedByString:@":"];
3953 if ([keyComponents count] > 1)
3954 {
3955 from_function = [keyComponents oo_intAtIndex:1];
3956 if (from_function < 0) from_function = 0;
3957
3958 [self setGuiToKeyboardLayoutScreen:from_function resetCurrentRow:YES];
3959 if ([[UNIVERSE gui] selectedRow] < GUI_ROW_KC_FUNCSTART)
3960 {
3961 [[UNIVERSE gui] setSelectedRow: GUI_ROW_KC_FUNCSTART];
3962 }
3963 if (from_function == 0)
3964 {
3965 [[UNIVERSE gui] setSelectedRow: GUI_ROW_KC_FUNCSTART + MAX_ROWS_KC_FUNCTIONS - 1];
3966 }
3967 }
3968 }
3969}
static BOOL leftRightKeyPressed
#define GUI_ROW_KC_FUNCSTART
NSString * keyForRow:(OOGUIRow row)

◆ handleKeyMapperScreenKeys

- (void) handleKeyMapperScreenKeys

Definition at line 164 of file PlayerEntityControls.m.

3895{
3896 MyOpenGLView *gameView = [UNIVERSE gameView];
3897 GuiDisplayGen *gui = [UNIVERSE gui];
3898
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];
3902 {
3903 NSString *key = [gui keyForRow: [gui selectedRow]];
3904 if ([self checkKeyPress:n_key_gui_arrow_right] || [self checkKeyPress:n_key_gui_page_down])
3905 {
3906 key = [gui keyForRow:GUI_ROW_KC_FUNCEND];
3907 }
3908 if ([self checkKeyPress:n_key_gui_arrow_left] || [self checkKeyPress:n_key_gui_page_up])
3909 {
3910 key = [gui keyForRow:GUI_ROW_KC_FUNCSTART];
3911 }
3912 int from_function = 0;
3913 NSArray *keyComponents = [key componentsSeparatedByString:@":"];
3914 if ([keyComponents count] > 1)
3915 {
3916 from_function = [keyComponents oo_intAtIndex:1];
3917 if (from_function < 0) from_function = 0;
3918
3919 [self setGuiToKeyMapperScreen:from_function resetCurrentRow: YES];
3920 if ([[UNIVERSE gui] selectedRow] < GUI_ROW_KC_FUNCSTART)
3921 {
3922 [[UNIVERSE gui] setSelectedRow: GUI_ROW_KC_FUNCSTART];
3923 }
3924 if (from_function == 0)
3925 {
3926 [[UNIVERSE gui] setSelectedRow: GUI_ROW_KC_FUNCSTART + MAX_ROWS_KC_FUNCTIONS - 1];
3927 }
3928 }
3929 }
3930}

◆ handleMissionCallback

- (void) handleMissionCallback

Definition at line 4739 of file PlayerEntityControls.m.

5343{
5344 [UNIVERSE removeDemoShips];
5345 [[UNIVERSE gui] clearBackground];
5346
5347 [self setGuiToMissionEndScreen]; // need this to find out if we call a new mission screen inside callback.
5348
5349 if ([self status] != STATUS_DOCKED) [self switchToThisView:VIEW_FORWARD];
5350
5351 if (_missionWithCallback)
5352 {
5353 [self doMissionCallback];
5354 }
5355
5356 if ([self status] != STATUS_DOCKED) // did we launch inside callback? / are we in flight?
5357 {
5358 // TODO: This is no longer doing anything because of an 'isDocked' check inside the function. ***** Probably remove it for 1.76
5359 [self doWorldEventUntilMissionScreen:OOJSID("missionScreenEnded")]; // no opportunity events.
5360 }
5361 else
5362 {
5363 if (gui_screen != GUI_SCREEN_MISSION) // did we call a new mission screen inside callback?
5364 {
5365 // note that this might not be the same end screen as last time...
5366 [self setGuiToMissionEndScreen]; // if not, update status screen with callback changes, if any.
5367 [self endMissionScreenAndNoteOpportunity]; // missionScreenEnded, plus opportunity events.
5368 }
5369 }
5370}

◆ handleStickMapperScreenKeys

- (void) handleStickMapperScreenKeys

Definition at line 164 of file PlayerEntityControls.m.

3973{
3974 MyOpenGLView *gameView = [UNIVERSE gameView];
3975 GuiDisplayGen *gui = [UNIVERSE gui];
3976
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];
3980 {
3981 NSString *key = [gui keyForRow: [gui selectedRow]];
3982 if ([self checkKeyPress:n_key_gui_arrow_right] || [self checkKeyPress:n_key_gui_page_down])
3983 {
3984 key = [gui keyForRow:GUI_ROW_FUNCEND];
3985 }
3986 if ([self checkKeyPress:n_key_gui_arrow_left] || [self checkKeyPress:n_key_gui_page_up])
3987 {
3988 key = [gui keyForRow:GUI_ROW_FUNCSTART];
3989 }
3990 int from_function = 0;
3991 NSArray *keyComponents = [key componentsSeparatedByString:@":"];
3992 if ([keyComponents count] > 1)
3993 {
3994 from_function = [keyComponents oo_intAtIndex:1];
3995 if (from_function < 0) from_function = 0;
3996
3997 [self setGuiToStickMapperScreen:from_function resetCurrentRow: YES];
3998 if ([[UNIVERSE gui] selectedRow] < GUI_ROW_FUNCSTART)
3999 {
4000 [[UNIVERSE gui] setSelectedRow: GUI_ROW_FUNCSTART];
4001 }
4002 if (from_function == 0)
4003 {
4004 [[UNIVERSE gui] setSelectedRow: GUI_ROW_FUNCSTART + MAX_ROWS_FUNCTIONS - 1];
4005 }
4006 }
4007 }
4008 if([gameView isDown:' ']) [self setGuiToGameOptionsScreen];
4009}
#define GUI_ROW_FUNCSTART

◆ handleUndockControl

- (void) handleUndockControl

Definition at line 4739 of file PlayerEntityControls.m.

4917{
4918 // FIXME: should this not be in leaveDock:? (Note: leaveDock: is also called from script method launchFromStation and -[StationEntity becomeExplosion]) -- Ahruman 20080308
4919 [UNIVERSE setUpUniverseFromStation]; // player pre-launch
4920 if ([self dockedStation] == nil) [self setDockedAtMainStation];
4921
4922 StationEntity *dockedStation = [self dockedStation];
4923 if (dockedStation == [UNIVERSE station] && [UNIVERSE autoSaveNow] && !([[UNIVERSE sun] goneNova] || [[UNIVERSE sun] willGoNova]))
4924 {
4925 [self autosavePlayer];
4926 }
4927 [self launchFromStation];
4928}

◆ pollApplicationControls

- (void) pollApplicationControls

Definition at line 164 of file PlayerEntityControls.m.

913{
914 if (!pollControls) return;
915
916 NSString *exceptionContext = @"setup";
917
918 // does fullscreen / quit / snapshot
919 MyOpenGLView *gameView = [UNIVERSE gameView];
920 GameController *gameController = [UNIVERSE gameController];
921
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));
924
925 @try
926 {
927 // command-key controls
928 #if !OOLITE_MAC_OS_X || !OOLITE_64_BIT // On 64-bit Macs, these are handled by normal menu shortcuts.
929 if ([gameController inFullScreenMode])
930 {
931 exceptionContext = @"command key controls";
932 if ([gameView isCommandFDown])
933 {
934 [gameView clearCommandF];
935 [gameController exitFullScreenMode];
936 if (mouse_control_on)
937 {
938 [UNIVERSE addMessage:DESC(@"mouse-off") forCount:3.0];
939 mouse_control_on = NO;
940 }
941 }
942
943 if ([gameView isCommandQDown])
944 {
945 [gameController pauseFullScreenModeToPerform:@selector(exitAppCommandQ) onTarget:gameController];
946 }
947 }
948 #endif
949
950 // handle pressing Q or [esc] in error-handling mode
951 if ([self status] == STATUS_HANDLING_ERROR)
952 {
953 exceptionContext = @"error handling mode";
954 if ([gameView isDown:113]||[gameView isDown:81]||[gameView isDown:27]) // 'q' | 'Q' | esc
955 {
956 [gameController exitAppWithContext:@"Q or escape pressed in error handling mode"];
957 }
958 }
959
960 if ([gameController isGamePaused])
961 {
962 // What's the status?
963 switch ([self status])
964 {
965 case STATUS_WITCHSPACE_COUNTDOWN:
966 case STATUS_IN_FLIGHT:
967 case STATUS_AUTOPILOT_ENGAGED:
968 case STATUS_DOCKED:
969 // Pause is handled inside their pollControls, no need to unpause.
970 break;
971
972 default:
973 {
974 // In all other cases we can't handle pause. Unpause immediately.
975 script_time = saved_script_time;
976 [gameView allowStringInput:NO];
977 if ([UNIVERSE pauseMessageVisible])
978 {
979 [UNIVERSE clearPreviousMessage]; // remove the 'paused' message.
980 }
981 [gameController setGamePaused:NO];
982 }
983 break;
984 }
985
986 }
987
988 // snapshot
989 const BOOL *joyButtonState = [[OOJoystickManager sharedStickHandler] getAllButtonStates];
990
991 if (([self checkKeyPress:n_key_snapshot] || joyButtonState[BUTTON_SNAPSHOT]) &&
992 ([gameView allowingStringInput] <= gvStringInputAlpha) && // not while entering text on the keyboard config screens
993 ![[OOOXZManager sharedManager] isAcceptingTextInput]) // '*' key but not while filtering inside OXZ Manager
994 {
995 exceptionContext = @"snapshot";
996 if (!taking_snapshot)
997 {
998 taking_snapshot = YES;
999 [gameView snapShot:nil]; // nil filename so that the program auto-names the snapshot
1000 }
1001 }
1002 else
1003 {
1004 taking_snapshot = NO;
1005 }
1006
1007 // FPS display
1008 if (!onTextEntryScreen && [self checkKeyPress:n_key_show_fps]) // 'F' key
1009 {
1010 exceptionContext = @"toggle FPS";
1011 if (!f_key_pressed) [UNIVERSE setDisplayFPS:![UNIVERSE displayFPS]];
1012 f_key_pressed = YES;
1013 }
1014 else
1015 {
1016 f_key_pressed = NO;
1017 }
1018
1019 // bloom toggle
1020 if ([self checkKeyPress:n_key_bloom_toggle])
1021 {
1022 if (!f9_key_pressed)
1023 {
1024 BOOL oldBloom = [UNIVERSE bloom];
1025 [UNIVERSE setBloom:!oldBloom];
1026 }
1027 f9_key_pressed = YES;
1028 }
1029 else
1030 {
1031 f9_key_pressed = NO;
1032 }
1033
1034 // Mouse control
1035 BOOL allowMouseControl;
1036 #if OO_DEBUG
1037 allowMouseControl = YES;
1038 #else
1039 allowMouseControl = [gameController inFullScreenMode] ||
1040 [[NSUserDefaults standardUserDefaults] boolForKey:@"mouse-control-in-windowed-mode"];
1041 #endif
1042
1043 if (allowMouseControl)
1044 {
1045 exceptionContext = @"mouse control";
1046 if (!onTextEntryScreen && ([self checkKeyPress:n_key_mouse_control_roll] || [self checkKeyPress:n_key_mouse_control_yaw])) // 'M' key
1047 {
1048 if (!m_key_pressed)
1049 {
1050 mouse_control_on = !mouse_control_on;
1051 if (mouse_control_on)
1052 {
1053 [UNIVERSE addMessage:DESC(@"mouse-on") forCount:3.0];
1054 /* Ensure the keyboard pitch override (intended to lock
1055 out the joystick if the player runs to the keyboard)
1056 is reset */
1057 #if OOLITE_GNUSTEP
1058 [gameView resetMouse];
1059 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"grab-mouse-on-mouse-control"])
1060 {
1061 [gameView grabMouseInsideGameWindow:YES];
1062 }
1063 #endif
1064 mouse_x_axis_map_to_yaw = [self checkKeyPress:n_key_mouse_control_yaw];
1065 keyboardRollOverride = mouse_x_axis_map_to_yaw; // Getafix: set keyboardRollOverride to TRUE only if yaw is mapped to mouse x-axis
1066 keyboardPitchOverride = NO;
1067 keyboardYawOverride = !keyboardRollOverride;
1068 }
1069 else
1070 {
1071 [UNIVERSE addMessage:DESC(@"mouse-off") forCount:3.0];
1072 #if OOLITE_GNUSTEP
1073 [gameView grabMouseInsideGameWindow:NO];
1074 #endif
1075 }
1076 }
1077 if (OOMouseInteractionModeIsFlightMode([gameController mouseInteractionMode]))
1078 {
1079 [gameController setMouseInteractionModeForFlight];
1080 }
1081 m_key_pressed = YES;
1082 }
1083 else
1084 {
1085 m_key_pressed = NO;
1086 }
1087 }
1088 else
1089 {
1090 if (mouse_control_on)
1091 {
1092 mouse_control_on = NO;
1093 [UNIVERSE addMessage:DESC(@"mouse-off") forCount:3.0];
1094 #if OOLITE_GNUSTEP
1095 [gameView grabMouseInsideGameWindow:NO];
1096 #endif
1097
1098 if (OOMouseInteractionModeIsFlightMode([gameController mouseInteractionMode]))
1099 {
1100 [gameController setMouseInteractionModeForFlight];
1101 }
1102 }
1103 }
1104
1105 // HUD toggle
1106 if (([self checkKeyPress:n_key_hud_toggle] || joyButtonState[BUTTON_TOGGLEHUD]) && [gameController isGamePaused] && !onTextEntryScreen) // 'o' key while paused
1107 {
1108 exceptionContext = @"toggle HUD";
1109 if (!hide_hud_pressed)
1110 {
1111 HeadUpDisplay *theHUD = [self hud];
1112 [theHUD setHidden:![theHUD isHidden]];
1113 if (gui_screen == GUI_SCREEN_STATUS)
1114 {
1115 // ensure refresh of status page screen if looking at it
1116 [self setGuiToStatusScreen];
1117 }
1118 }
1119 hide_hud_pressed = YES;
1120 }
1121 else
1122 {
1123 hide_hud_pressed = NO;
1124 }
1125 }
1126 @catch (NSException *exception)
1127 {
1128 OOLog(kOOLogException, @"***** Exception in pollApplicationControls [%@]: %@ : %@", exceptionContext, [exception name], [exception reason]);
1129 }
1130}
@ gvStringInputAlpha
@ BUTTON_SNAPSHOT
@ BUTTON_TOGGLEHUD
NSString *const kOOLogException
Definition OOLogging.m:651
#define OOLog(class, format,...)
Definition OOLogging.h:88
BOOL OOMouseInteractionModeIsFlightMode(OOMouseInteractionMode mode)
static BOOL taking_snapshot
static BOOL m_key_pressed
static BOOL f_key_pressed
static BOOL hide_hud_pressed
static BOOL f9_key_pressed
static double saved_script_time
static BOOL mouse_x_axis_map_to_yaw
void setGamePaused:(BOOL value)
void exitAppWithContext:(NSString *context)
void setMouseInteractionModeForFlight()
void pauseFullScreenModeToPerform:onTarget:(SEL selector,[onTarget] id target)
void setHidden:(BOOL newValue)
void grabMouseInsideGameWindow:(BOOL value)
void allowStringInput:(BOOL value)
BOOL snapShot:(NSString *filename)
const BOOL * getAllButtonStates()

◆ pollAutopilotControls:

- (void) pollAutopilotControls: (double)  delta_t

Definition at line 4739 of file PlayerEntityControls.m.

4741 :(double)delta_t
4742{
4743 // don't do anything if we're configuring the keyboard
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;
4745
4746 const BOOL *joyButtonState = [[OOJoystickManager sharedStickHandler] getAllButtonStates];
4747
4748 // controls polled while the autopilot is active
4749 if (![[UNIVERSE gameController] isGamePaused])
4750 {
4751 // view keys
4752 [self pollViewControls];
4753
4754 // text displays
4755 [self pollGuiScreenControls];
4756
4757 if ([UNIVERSE displayGUI])
4758 [self pollGuiArrowKeyControls:delta_t];
4759
4760 if ([self checkKeyPress:n_key_autopilot] || joyButtonState[BUTTON_DOCKCPU]
4761 || [self checkKeyPress:n_key_autodock] || joyButtonState[BUTTON_DOCKCPUFAST]) // look for the 'c' and 'C' key
4762 {
4763 if ([self hasDockingComputer] && !autopilot_key_pressed && !fast_autopilot_key_pressed)
4764 {
4765 [self disengageAutopilot];
4766 [UNIVERSE addMessage:DESC(@"autopilot-off") forCount:4.5];
4767 }
4769 if ([self checkKeyPress:n_key_autodock] || joyButtonState[BUTTON_DOCKCPUFAST])
4770 {
4772 }
4773 }
4774 else
4775 {
4778 }
4779
4780 if (([self checkKeyPress:n_key_docking_music] || joyButtonState[BUTTON_DOCKINGMUSIC])) // look for the 's' key
4781 {
4782 if (!toggling_music)
4783 {
4785 }
4786 toggling_music = YES;
4787 }
4788 else
4789 {
4790 toggling_music = NO;
4791 }
4792 // look for the pause game, 'p' key
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)
4794 {
4795 if (!autopilot_pause)
4796 {
4799 // normal flight controls can handle the rest.
4800 pause_pressed = NO; // pause button flag must be NO for pollflightControls to react!
4801 [self pollFlightControls:delta_t];
4802 }
4803 autopilot_pause = YES;
4804 }
4805 else
4806 {
4807 autopilot_pause = NO;
4808 }
4809 }
4810 else
4811 {
4812 // paused
4813 if ([self checkKeyPress:n_key_pausebutton] || joyButtonState[BUTTON_PAUSE])
4814 {
4815 if (!autopilot_pause)
4816 {
4818 }
4819 autopilot_pause = YES;
4820 }
4821 else
4822 {
4823 autopilot_pause = NO;
4824 }
4825 // let the normal flight controls handle paused commands.
4826 [self pollFlightControls:delta_t];
4827 }
4828}
@ BUTTON_DOCKINGMUSIC
@ BUTTON_DOCKCPU
@ BUTTON_DOCKCPUFAST
@ BUTTON_PAUSE
static BOOL autopilot_pause
static BOOL fast_autopilot_key_pressed
static BOOL pause_pressed
static BOOL toggling_music
static BOOL playing_music
static BOOL autopilot_key_pressed

◆ pollCustomViewControls

- (void) pollCustomViewControls

Definition at line 164 of file PlayerEntityControls.m.

4013{
4014 static Quaternion viewQuaternion;
4015 static Vector viewOffset;
4016 static Vector rotationCenter;
4017 static Vector up;
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;
4024 MyOpenGLView *gameView = [UNIVERSE gameView];
4025 const BOOL *joyButtonState = [[OOJoystickManager sharedStickHandler] getAllButtonStates];
4026
4027 if ([self checkKeyPress:n_key_custom_view] || joyButtonState[BUTTON_EXTVIEWCYCLE])
4028 {
4029 if (!customView_pressed && [_customViews count] != 0 && gui_screen != GUI_SCREEN_LONG_RANGE_CHART && ![gameView allowingStringInput])
4030 {
4031 if ([UNIVERSE viewDirection] == VIEW_CUSTOM) // already in custom view mode
4032 {
4033 // rotate the custom views
4034 _customViewIndex = (_customViewIndex + 1) % [_customViews count];
4035 }
4036
4037 [self setCustomViewDataFromDictionary:[_customViews oo_dictionaryAtIndex:_customViewIndex] withScaling:YES];
4038
4039 [self switchToThisView:VIEW_CUSTOM andProcessWeaponFacing:NO]; // weapon facing must not change, we just want an external view
4040 }
4041 customView_pressed = YES;
4042 }
4043 else
4044 customView_pressed = NO;
4045 NSTimeInterval this_time = [NSDate timeIntervalSinceReferenceDate];
4046 if ([UNIVERSE viewDirection] > VIEW_STARBOARD && [gameView isCapsLockOn])
4047 {
4048 BOOL ctrl_down = [gameView isCtrlDown];
4049 float customViewZoomSpeed = ctrl_down ? CUSTOM_VIEW_ZOOM_SPEED * CUSTOM_VIEW_SPEED_REDUCTION_FACTOR: CUSTOM_VIEW_ZOOM_SPEED;
4051
4052 if (!caps_on) caps_on = YES;
4053
4054 OOTimeDelta delta_t = this_time - last_time;
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)
4056 {
4057 [self customViewZoomOut: pow(customViewZoomSpeed, delta_t)];
4058 }
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)
4060 {
4061 [self customViewZoomIn: pow(customViewZoomSpeed, delta_t)];
4062 }
4063 if ([self checkKeyPress:n_key_custom_view_roll_left ignore_ctrl:YES] && ![self checkKeyPress:n_key_custom_view_roll_right ignore_ctrl:YES])
4064 {
4065 [self customViewRollLeft:customViewRotateSpeed * delta_t];
4066 }
4067 if ([self checkKeyPress:n_key_custom_view_pan_left ignore_ctrl:YES] && ![self checkKeyPress:n_key_custom_view_pan_right ignore_ctrl:YES])
4068 {
4069 [self customViewPanLeft:customViewRotateSpeed * delta_t];
4070 }
4071 if ([self checkKeyPress:n_key_custom_view_roll_right ignore_ctrl:YES] && ![self checkKeyPress:n_key_custom_view_roll_left ignore_ctrl:YES])
4072 {
4073 [self customViewRollRight:customViewRotateSpeed * delta_t];
4074 }
4075 if ([self checkKeyPress:n_key_custom_view_pan_right ignore_ctrl:YES] && ![self checkKeyPress:n_key_custom_view_pan_left ignore_ctrl:YES])
4076 {
4077 [self customViewPanRight:customViewRotateSpeed * delta_t];
4078 }
4079 if ([self checkKeyPress:n_key_custom_view_rotate_up ignore_ctrl:YES] && ![self checkKeyPress:n_key_custom_view_rotate_down ignore_ctrl:YES])
4080 {
4081 [self customViewRotateUp:customViewRotateSpeed * delta_t];
4082 }
4083 if ([self checkKeyPress:n_key_custom_view_pan_down ignore_ctrl:YES] && ![self checkKeyPress:n_key_custom_view_pan_up ignore_ctrl:YES])
4084 {
4085 [self customViewPanDown:customViewRotateSpeed * delta_t];
4086 }
4087 if ([self checkKeyPress:n_key_custom_view_rotate_down ignore_ctrl:YES] && ![self checkKeyPress:n_key_custom_view_rotate_up ignore_ctrl:YES])
4088 {
4089 [self customViewRotateDown:customViewRotateSpeed * delta_t];
4090 }
4091 if ([self checkKeyPress:n_key_custom_view_pan_up ignore_ctrl:YES] && ![self checkKeyPress:n_key_custom_view_pan_down ignore_ctrl:YES])
4092 {
4093 [self customViewPanUp:customViewRotateSpeed * delta_t];
4094 }
4095 if ([self checkKeyPress:n_key_custom_view_rotate_left ignore_ctrl:YES] && ![self checkKeyPress:n_key_custom_view_rotate_right ignore_ctrl:YES])
4096 {
4097 [self customViewRotateLeft:customViewRotateSpeed * delta_t];
4098 }
4099 if ([self checkKeyPress:n_key_custom_view_rotate_right ignore_ctrl:YES] && ![self checkKeyPress:n_key_custom_view_rotate_left ignore_ctrl:YES])
4100 {
4101 [self customViewRotateRight:customViewRotateSpeed * delta_t];
4102 }
4103 if ([gameView isDown:gvMouseLeftButton])
4104 {
4105 if(!mouse_clicked || shift_down != [gameView isShiftDown])
4106 {
4107 mouse_clicked = YES;
4108 viewQuaternion = [PLAYER customViewQuaternion];
4109 viewOffset = [PLAYER customViewOffset];
4110 rotationCenter = [PLAYER customViewRotationCenter];
4111 up = [PLAYER customViewUpVector];
4112 right = [PLAYER customViewRightVector];
4113 mouse_clicked_position = [gameView virtualJoystickPosition];
4114 shift_down = [gameView isShiftDown];
4115 }
4116 NSPoint mouse_position = [gameView virtualJoystickPosition];
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])
4123 {
4124 quaternion_rotate_about_axis(&newViewQuaternion, axis, angle);
4125 [PLAYER setCustomViewQuaternion: newViewQuaternion];
4126 [PLAYER setCustomViewRotationCenter: vector_subtract(viewOffset,
4127 vector_multiply_scalar([PLAYER customViewForwardVector],
4128 dot_product([PLAYER customViewForwardVector], viewOffset)))];
4129 }
4130 else
4131 {
4132 quaternion_rotate_about_axis(&newViewQuaternion, axis, -angle);
4133 OOScalar m = magnitude(vector_subtract(viewOffset, rotationCenter));
4134 [PLAYER setCustomViewQuaternion: newViewQuaternion];
4135 Vector offset = vector_flip([PLAYER customViewForwardVector]);
4136 scale_vector(&offset, m / magnitude(offset));
4137 [PLAYER setCustomViewOffset:vector_add(offset, rotationCenter)];
4138 }
4139 }
4140 else
4141 {
4142 mouse_clicked = NO;
4143 }
4144 }
4145 else
4146 {
4147 mouse_clicked = NO;
4148 if (caps_on)
4149 {
4150 caps_on = NO;
4151 if ([self isMouseControlOn]) [gameView resetMouse];
4152 }
4153 }
4154 last_time = this_time;
4155}
@ gvMouseWheelDown
@ gvMouseWheelUp
@ gvMouseLeftButton
@ BUTTON_EXTVIEWCYCLE
GLfloat OOScalar
Definition OOMaths.h:64
void quaternion_rotate_about_axis(Quaternion *quat, Vector axis, OOScalar angle)
double OOTimeDelta
Definition OOTypes.h:224
#define CUSTOM_VIEW_SPEED_REDUCTION_FACTOR
#define CUSTOM_VIEW_ZOOM_SPEED
#define CUSTOM_VIEW_ROTATE_SPEED
static BOOL customView_pressed
#define PLAYER
NSPoint virtualJoystickPosition
voidpf uLong offset
Definition ioapi.h:140

◆ pollDemoControls:

- (void) pollDemoControls: (double)  delta_t

Definition at line 4739 of file PlayerEntityControls.m.

4931 :(double)delta_t
4932{
4933 MyOpenGLView *gameView = [UNIVERSE gameView];
4934 GuiDisplayGen *gui = [UNIVERSE gui];
4935 NSUInteger end_row = 21;
4936 OOOXZManager *oxzmanager = [OOOXZManager sharedManager];
4937
4938 switch (gui_screen)
4939 {
4940 case GUI_SCREEN_INTRO1:
4941 [self handleGUIUpDownArrowKeys];
4942
4943 int row_zero = 21;
4944 if (!selectPressed)
4945 {
4947 {
4948 if (([gameView isDown:gvMouseDoubleClick] || [self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 2+row_zero)
4949 {
4951 [UNIVERSE removeDemoShips];
4952 [gui clearBackground];
4953 if (![self loadPlayer])
4954 {
4955 [self setGuiToIntroFirstGo:YES];
4956 }
4957 break;
4958 }
4959 }
4960 if (([gameView isDown:gvMouseDoubleClick] || [self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 1+row_zero)
4961 {
4962 missionTextRow = 0;
4963 [self setGuiToScenarioScreen:0];
4964 }
4965 else if (([gameView isDown:gvMouseDoubleClick] || [self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 3+row_zero)
4966 {
4967 [self setGuiToIntroFirstGo:NO];
4968 }
4969 else if (([gameView isDown:gvMouseDoubleClick] || [self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 4+row_zero)
4970 {
4971 [self setGuiToGameOptionsScreen];
4972 }
4973 else if (([gameView isDown:gvMouseDoubleClick] || [self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 5+row_zero)
4974 {
4975 [self setGuiToOXZManager];
4976 }
4977 else if (([gameView isDown:gvMouseDoubleClick] || [self checkKeyPress:n_key_gui_select]) && [gui selectedRow] == 6+row_zero)
4978 {
4979 [[UNIVERSE gameController] exitAppWithContext:@"Exit Game selected on start screen"];
4980 }
4981 else
4982 {
4984 }
4985 }
4986 selectPressed = [self checkKeyPress:n_key_gui_select];
4987 if ([gameView isDown:gvMouseDoubleClick])
4988 {
4989 [gameView clearMouse];
4990 }
4991 break;
4992
4993 case GUI_SCREEN_GAMEOPTIONS:
4994 [self handleGameOptionsScreenKeys];
4995 break;
4996
4997 case GUI_SCREEN_KEYBOARD:
4998 //if ([gameView isDown:' ']) // '<space>'
4999 //{
5000 // [self setGuiToIntroFirstGo:YES];
5001 //}
5002 [self handleKeyMapperScreenKeys];
5003 break;
5004
5005 case GUI_SCREEN_KEYBOARD_CONFIRMCLEAR:
5006 [self handleKeyMapperConfirmClearKeys:gui view:gameView];
5007 break;
5008
5009 case GUI_SCREEN_KEYBOARD_CONFIG:
5010 [self handleKeyConfigKeys:gui view:gameView];
5011 break;
5012
5013 case GUI_SCREEN_KEYBOARD_ENTRY:
5014 [self handleKeyConfigEntryKeys:gui view:gameView];
5015 break;
5016
5017 case GUI_SCREEN_KEYBOARD_LAYOUT:
5018 [self handleKeyboardLayoutKeys];
5019 break;
5020
5021 case GUI_SCREEN_STICKMAPPER:
5022 [self handleStickMapperScreenKeys];
5023 break;
5024
5025 case GUI_SCREEN_STICKPROFILE:
5026 [self stickProfileInputHandler:gui view:gameView];
5027 break;
5028
5029 case GUI_SCREEN_SHIPLIBRARY:
5030 if ([gameView isDown:' ']) // '<space>'
5031 {
5032 // viewed from start screen, return to it
5033 [self setGuiToIntroFirstGo:YES];
5034 }
5035 if ([self checkKeyPress:n_key_gui_arrow_up]) // '<--'
5036 {
5037 if (!upDownKeyPressed)
5038 [UNIVERSE selectIntro2Previous];
5039 }
5040 if ([self checkKeyPress:n_key_gui_arrow_down]) // '-->'
5041 {
5042 if (!upDownKeyPressed)
5043 [UNIVERSE selectIntro2Next];
5044 }
5045 upDownKeyPressed = (([self checkKeyPress:n_key_gui_arrow_up])||([self checkKeyPress:n_key_gui_arrow_down]));
5046
5047 if ([self checkKeyPress:n_key_gui_arrow_left]) // '<--'
5048 {
5050 [UNIVERSE selectIntro2PreviousCategory];
5051 }
5052 if ([self checkKeyPress:n_key_gui_arrow_right]) // '-->'
5053 {
5055 [UNIVERSE selectIntro2NextCategory];
5056 }
5057 leftRightKeyPressed = (([self checkKeyPress:n_key_gui_arrow_left])||([self checkKeyPress:n_key_gui_arrow_right]));
5058
5059
5060 break;
5061
5062 case GUI_SCREEN_NEWGAME:
5063 if ([self handleGUIUpDownArrowKeys])
5064 {
5065 [self showScenarioDetails];
5066 }
5067
5069 {
5070 if ([self checkKeyPress:n_key_gui_page_up])
5071 {
5072 // find the Back <<< line, select it and press it
5073 if ([[gui keyForRow:GUI_ROW_SCENARIOS_START - 1] hasPrefix:@"__page"])
5074 {
5075 if ([gui setSelectedRow:GUI_ROW_SCENARIOS_START - 1])
5076 {
5077 [self startScenario];
5078 }
5079 }
5080
5081 }
5082 else if ([self checkKeyPress:n_key_gui_page_down])
5083 {
5084 // find the Next >>> line, select it and press it
5085 if ([[gui keyForRow:GUI_ROW_SCENARIOS_START + GUI_MAX_ROWS_SCENARIOS] hasPrefix:@"__page"])
5086 {
5087 if ([gui setSelectedRow:GUI_ROW_SCENARIOS_START + GUI_MAX_ROWS_SCENARIOS])
5088 {
5089 [self startScenario];
5090 }
5091 }
5092 }
5093 }
5094 pageUpDownKeyPressed = [self checkKeyPress:n_key_gui_page_down]|[self checkKeyPress:n_key_gui_page_up];
5095
5096 if (!selectPressed)
5097 {
5098 if ([self checkKeyPress:n_key_gui_select] || [gameView isDown:gvMouseDoubleClick]) // enter
5099 {
5100 if (![self startScenario])
5101 {
5102 [UNIVERSE removeDemoShips];
5103 [self setGuiToIntroFirstGo:YES];
5104 }
5105 }
5106 }
5107 selectPressed = [self checkKeyPress:n_key_gui_select];
5108 if ([gameView isDown:gvMouseDoubleClick] || [gameView isDown:gvMouseLeftButton])
5109 {
5110 [gameView clearMouse];
5111 }
5112 break;
5113
5114 case GUI_SCREEN_OXZMANAGER:
5115 // release locks on music on this screen
5117 if (EXPECT(![oxzmanager isRestarting]))
5118 {
5119 if ([oxzmanager isAcceptingGUIInput])
5120 {
5121 if ([oxzmanager isAcceptingTextInput])
5122 {
5123 [gameView setStringInput: gvStringInputAll];
5124 [oxzmanager refreshTextInput:[gameView typedString]];
5125 }
5126 else
5127 {
5128 [gameView allowStringInput: NO];
5129 }
5130 if ([self handleGUIUpDownArrowKeys])
5131 {
5132 // only has an effect on install/remove selection screens
5133 [oxzmanager showOptionsUpdate];
5134 }
5135 if ([self checkKeyPress:n_key_gui_arrow_left] || [self checkKeyPress:n_key_gui_page_up])
5136 {
5137 if ((!leftRightKeyPressed))
5138 {
5139 [oxzmanager processOptionsPrev];
5140 }
5141 }
5142 else if ([self checkKeyPress:n_key_gui_arrow_right] || [self checkKeyPress:n_key_gui_page_down])
5143 {
5144 if ((!leftRightKeyPressed))
5145 {
5146 [oxzmanager processOptionsNext];
5147 }
5148 }
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];
5150
5151 if (!selectPressed)
5152 {
5153 if ([self checkKeyPress:n_key_gui_select] || [gameView isDown:gvMouseDoubleClick]) // enter
5154 {
5155 if ([oxzmanager isAcceptingTextInput])
5156 {
5157 [oxzmanager processTextInput:[gameView typedString]];
5158 }
5159 else
5160 {
5161 [oxzmanager processSelection];
5162 }
5163 }
5164 }
5165 selectPressed = [self checkKeyPress:n_key_gui_select];
5166 if ([gameView isDown:gvMouseDoubleClick] || [gameView isDown:gvMouseLeftButton])
5167 {
5168 [gameView clearMouse];
5169 }
5170 } // endif isAcceptingGUIInput
5171 if ([self checkKeyPress:n_key_oxzmanager_setfilter] ||
5172 [self checkKeyPress:n_key_oxzmanager_showinfo] ||
5173 [self checkKeyPress:n_key_oxzmanager_extract])
5174 {
5176 {
5177 oxz_manager_pressed = YES;
5178 if ([self checkKeyPress:n_key_oxzmanager_setfilter])
5179 {
5180 [oxzmanager processFilterKey];
5181 }
5182 else if ([self checkKeyPress:n_key_oxzmanager_showinfo])
5183 {
5184 [oxzmanager processShowInfoKey];
5185 }
5186 else if ([self checkKeyPress:n_key_oxzmanager_extract])
5187 {
5188 [oxzmanager processExtractKey];
5189 }
5190
5191 }
5192 }
5193 else
5194 {
5196 }
5197 }
5198 break;
5199
5200
5201
5202 case GUI_SCREEN_MISSION:
5203 if ([[self hud] allowBigGui])
5204 {
5205 end_row = 27;
5206 }
5207 if (_missionTextEntry)
5208 {
5209 [self refreshMissionScreenTextEntry];
5210 if ([self checkKeyPress:n_key_gui_select] || [gameView isDown:gvMouseDoubleClick]) // '<enter/return>' or double click
5211 {
5212 [self setMissionChoice:[gameView typedString] keyPress:@"enter"];
5214 [self playDismissedMissionScreen];
5215
5216 [self handleMissionCallback];
5217
5218 [self checkScript];
5219 selectPressed = YES;
5220 pollControls = YES;
5221 }
5222 else
5223 {
5224 pollControls = NO;
5225 selectPressed = NO;
5226 [self pollMissionInterruptControls];
5227 }
5228 }
5229 else if ([[gui keyForRow:end_row] isEqual:@"spacebar"])
5230 {
5231 if ([gameView isDown:32]) // '<space>'
5232 {
5233 if (!spacePressed)
5234 {
5236 [self handleMissionCallback];
5237
5238 }
5239 spacePressed = YES;
5240 }
5241 else
5242 {
5243 spacePressed = NO;
5244 [self pollMissionInterruptControls];
5245 }
5246 }
5247 else
5248 {
5249 [self handleGUIUpDownArrowKeys];
5250 NSString *extraKey = @"";
5251 if (extraMissionKeys)
5252 {
5253 NSString *key = nil;
5254 foreach (key, [extraMissionKeys allKeys])
5255 {
5256 if ([self checkKeyPress:[extraMissionKeys oo_arrayForKey:key]]) {
5257 if (!extra_key_pressed)
5258 {
5259 extraKey = [key copy];
5260 }
5261 extra_key_pressed = YES;
5262 }
5263 else
5264 extra_key_pressed = NO;
5265 }
5266 }
5267 if ([self checkKeyPress:n_key_gui_select] || [gameView isDown:gvMouseDoubleClick] || [extraKey length] > 0) // '<enter/return>' or double click
5268 {
5269 if ([gameView isDown:gvMouseDoubleClick])
5270 {
5271 selectPressed = NO;
5272 [gameView clearMouse];
5273 }
5274 if (!selectPressed)
5275 {
5276 if ([extraKey length] == 0) extraKey = @"enter";
5277 [self setMissionChoice:[gui selectedRowKey] keyPress:extraKey];
5279 [self playDismissedMissionScreen];
5280
5281 [self handleMissionCallback];
5282
5283 [self checkScript];
5284 }
5285 selectPressed = YES;
5286 }
5287 else
5288 {
5289 selectPressed = NO;
5290 [self pollMissionInterruptControls];
5291 }
5292 [extraKey release];
5293 }
5294 break;
5295
5296#if OO_USE_CUSTOM_LOAD_SAVE
5297 // DJS: Farm off load/save screen options to LoadSave.m
5298 case GUI_SCREEN_LOAD:
5299 {
5300 NSString *commanderFile = [self commanderSelector];
5301 if(commanderFile)
5302 {
5303 // also release the demo ship here (see showShipyardModel and noteGUIDidChangeFrom)
5304 [demoShip release];
5305 demoShip = nil;
5306
5307 [self loadPlayerFromFile:commanderFile asNew:NO];
5308 }
5309 break;
5310 }
5311#endif
5312
5313 default:
5314 break;
5315 }
5316}
#define EXPECT(x)
static BOOL selectPressed
static BOOL pageUpDownKeyPressed
static BOOL upDownKeyPressed
static BOOL spacePressed
static BOOL extra_key_pressed
static BOOL disc_operation_in_progress
static BOOL oxz_manager_pressed
@ GUI_ROW_SCENARIOS_START
@ GUI_MAX_ROWS_SCENARIOS
NSString * selectedRowKey()
NSMutableString * typedString
void setStringInput:(enum StringInput value)
void processOptionsNext()
void processFilterKey()
void processSelection()
void showOptionsUpdate()
void processTextInput:(NSString *input)
void processOptionsPrev()
void processExtractKey()
OOOXZManager * sharedManager()
void refreshTextInput:(NSString *input)
void processShowInfoKey()

◆ pollDockedControls:

- (void) pollDockedControls: (double)  delta_t

Definition at line 4739 of file PlayerEntityControls.m.

4831 :(double)delta_t
4832{
4833 MyOpenGLView *gameView = [UNIVERSE gameView];
4834 GameController *gameController = [UNIVERSE gameController];
4835 const BOOL *joyButtonState = [[OOJoystickManager sharedStickHandler] getAllButtonStates];
4836 NSString *exceptionContext = @"setup";
4837
4838 @try
4839 {
4840 // Pause game, 'p' key
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) )
4845 {
4846 BOOL isMissionScreenWithTextEntry = gui_screen == GUI_SCREEN_MISSION && _missionTextEntry;
4847 if (!pause_pressed)
4848 {
4849 if ([gameController isGamePaused])
4850 {
4851 script_time = saved_script_time;
4852 [gameView allowStringInput:NO];
4853 if ([UNIVERSE pauseMessageVisible])
4854 {
4855 [UNIVERSE clearPreviousMessage]; // remove the 'paused' message.
4856 }
4857 [[UNIVERSE gui] setForegroundTextureKey:@"docked_overlay"];
4858 [gameController setGamePaused:NO];
4859 }
4860 else
4861 {
4862 if (!isMissionScreenWithTextEntry)
4863 {
4864 saved_script_time = script_time;
4865 [[UNIVERSE messageGUI] clear];
4866
4867 [UNIVERSE pauseGame]; // 'paused' handler
4868 }
4869 }
4870 }
4871 if (!isMissionScreenWithTextEntry)
4872 {
4873 pause_pressed = YES;
4874 }
4875 }
4876 else
4877 {
4878 pause_pressed = NO;
4879 }
4880
4881 if ([gameController isGamePaused]) return;
4882
4883 if(pollControls)
4884 {
4885 exceptionContext = @"undock";
4886 if ([self checkKeyPress:n_key_launch_ship])
4887 {
4888 if (EXPECT((gui_screen != GUI_SCREEN_MISSION || _missionAllowInterrupt) && gui_screen != GUI_SCREEN_KEYBOARD_ENTRY))
4889 {
4890 [self handleUndockControl];
4891 }
4892 }
4893 }
4894
4895 // text displays
4896 // mission screens
4897 exceptionContext = @"GUI keys";
4898 if (gui_screen == GUI_SCREEN_MISSION || gui_screen == GUI_SCREEN_KEYBOARD_ENTRY)
4899 {
4900 [self pollDemoControls: delta_t]; // don't switch away from mission screens
4901 }
4902 else
4903 {
4904 if (gui_screen != GUI_SCREEN_REPORT)[self pollGuiScreenControls]; // don't switch away from report screens
4905 }
4906
4907 [self pollGuiArrowKeyControls:delta_t];
4908 }
4909 @catch (NSException *exception)
4910 {
4911 OOLog(kOOLogException, @"***** Exception in pollDockedControls [%@]: %@ : %@", exceptionContext, [exception name], [exception reason]);
4912 }
4913}

◆ pollFlightArrowKeyControls:

- (void) pollFlightArrowKeyControls: (double)  delta_t

Definition at line 164 of file PlayerEntityControls.m.

4315 :(double)delta_t
4316{
4317 MyOpenGLView *gameView = [UNIVERSE gameView];
4319 NSUInteger numSticks = [stickHandler joystickCount];
4320 NSPoint virtualStick = NSZeroPoint;
4321 double reqYaw = 0.0;
4322
4323 /* DJS: Handle inputs on the joy roll/pitch axis.
4324 Mouse control on takes precedence over joysticks.
4325 We have to assume the player has a reason for switching mouse
4326 control on if they have a joystick - let them do it. */
4327 if (mouse_control_on)
4328 {
4329 virtualStick=[gameView virtualJoystickPosition];
4330 double sensitivity = 2.0;
4331 virtualStick.x *= sensitivity;
4332 virtualStick.y *= sensitivity;
4333 reqYaw = virtualStick.x;
4334 }
4335 else if (numSticks > 0)
4336 {
4337 virtualStick = [stickHandler rollPitchAxis];
4338 // handle roll separately (fix for BUG #17490)
4339 if(virtualStick.x == STICK_AXISUNASSIGNED)
4340 {
4341 // Not assigned - set to zero.
4342 virtualStick.x=0;
4343 }
4344 else if(virtualStick.x != 0)
4345 {
4346 // cancel keyboard override, stick has been waggled
4347 keyboardRollOverride=NO;
4348 }
4349 // handle pitch separately (fix for BUG #17490)
4350 if(virtualStick.y == STICK_AXISUNASSIGNED)
4351 {
4352 // Not assigned - set to zero.
4353 virtualStick.y=0;
4354 }
4355 else if(virtualStick.y != 0)
4356 {
4357 // cancel keyboard override, stick has been waggled
4358 keyboardPitchOverride=NO;
4359 }
4360 // handle yaw separately from pitch/roll
4361 reqYaw = [stickHandler getAxisState: AXIS_YAW];
4362 if(reqYaw == STICK_AXISUNASSIGNED)
4363 {
4364 // Not assigned or deadzoned - set to zero.
4365 reqYaw=0;
4366 }
4367 else if(reqYaw != 0)
4368 {
4369 // cancel keyboard override, stick has been waggled
4370 keyboardYawOverride=NO;
4371 }
4372 }
4373
4374 double roll_dampner = ROLL_DAMPING_FACTOR * delta_t;
4375 double pitch_dampner = PITCH_DAMPING_FACTOR * delta_t;
4376 double yaw_dampner = YAW_DAMPING_FACTOR * delta_t;
4377 BOOL capsLockCustomView = [UNIVERSE viewDirection] == VIEW_CUSTOM && [gameView isCapsLockOn];
4378
4379 BOOL isCtrlDown = [gameView isCtrlDown];
4380
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;
4384
4385 rolling = NO;
4386 // if we have yaw on the mouse x-axis, then allow using the keyboard roll keys
4387 if (!mouse_control_on || (mouse_control_on && mouse_x_axis_map_to_yaw))
4388 {
4389 if ([self checkNavKeyPress:n_key_roll_left] && [self checkNavKeyPress:n_key_roll_right])
4390 {
4391 keyboardRollOverride = YES;
4392 flightRoll = 0.0;
4393 }
4394 else if ([self checkNavKeyPress:n_key_roll_left] && !capsLockCustomView)
4395 {
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];
4399 rolling = YES;
4400 }
4401 else if ([self checkNavKeyPress:n_key_roll_right] && !capsLockCustomView)
4402 {
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];
4406 rolling = YES;
4407 }
4408 }
4409 if(((mouse_control_on && !mouse_x_axis_map_to_yaw) || numSticks) && !keyboardRollOverride && !capsLockCustomView)
4410 {
4411 stick_roll = max_flight_roll * virtualStick.x;
4412 if (flightRoll < stick_roll)
4413 {
4414 [self increase_flight_roll:delta_t*roll_delta];
4415 if (flightRoll > stick_roll)
4416 flightRoll = stick_roll;
4417 }
4418 if (flightRoll > stick_roll)
4419 {
4420 [self decrease_flight_roll:delta_t*roll_delta];
4421 if (flightRoll < stick_roll)
4422 flightRoll = stick_roll;
4423 }
4424 rolling = (fabs(virtualStick.x) > 0.0);
4425 }
4426 if (!rolling)
4427 {
4428 if (flightRoll > 0.0)
4429 {
4430 if (flightRoll > roll_dampner) [self decrease_flight_roll:roll_dampner];
4431 else flightRoll = 0.0;
4432 }
4433 if (flightRoll < 0.0)
4434 {
4435 if (flightRoll < -roll_dampner) [self increase_flight_roll:roll_dampner];
4436 else flightRoll = 0.0;
4437 }
4438 }
4439
4440 pitching = NO;
4441 // we don't care about pitch keyboard overrides when mouse control is on, only when using joystick
4442 if (!mouse_control_on)
4443 {
4444 if ([self checkNavKeyPress:n_key_pitch_back] && [self checkNavKeyPress:n_key_pitch_forward])
4445 {
4446 keyboardPitchOverride=YES;
4447 flightPitch = 0.0;
4448 }
4449 else if ([self checkNavKeyPress:n_key_pitch_back] && !capsLockCustomView)
4450 {
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];
4454 pitching = YES;
4455 }
4456 else if ([self checkNavKeyPress:n_key_pitch_forward] && !capsLockCustomView)
4457 {
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];
4461 pitching = YES;
4462 }
4463 }
4464 if((mouse_control_on || (numSticks && !keyboardPitchOverride)) && !capsLockCustomView)
4465 {
4466 stick_pitch = max_flight_pitch * virtualStick.y;
4467 if (flightPitch < stick_pitch)
4468 {
4469 [self increase_flight_pitch:delta_t*pitch_delta];
4470 if (flightPitch > stick_pitch)
4471 flightPitch = stick_pitch;
4472 }
4473 if (flightPitch > stick_pitch)
4474 {
4475 [self decrease_flight_pitch:delta_t*pitch_delta];
4476 if (flightPitch < stick_pitch)
4477 flightPitch = stick_pitch;
4478 }
4479 pitching = (fabs(virtualStick.y) > 0.0);
4480 }
4481 if (!pitching)
4482 {
4483 if (flightPitch > 0.0)
4484 {
4485 if (flightPitch > pitch_dampner) [self decrease_flight_pitch:pitch_dampner];
4486 else flightPitch = 0.0;
4487 }
4488 if (flightPitch < 0.0)
4489 {
4490 if (flightPitch < -pitch_dampner) [self increase_flight_pitch:pitch_dampner];
4491 else flightPitch = 0.0;
4492 }
4493 }
4494
4495 yawing = NO;
4496 // if we have roll on the mouse x-axis, then allow using the keyboard yaw keys
4497 if (!mouse_control_on || (mouse_control_on && !mouse_x_axis_map_to_yaw))
4498 {
4499 if ([self checkNavKeyPress:n_key_yaw_left] && [self checkNavKeyPress:n_key_yaw_right])
4500 {
4501 keyboardYawOverride=YES;
4502 flightYaw = 0.0;
4503 }
4504 else if ([self checkNavKeyPress:n_key_yaw_left] && !capsLockCustomView)
4505 {
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];
4509 yawing = YES;
4510 }
4511 else if ([self checkNavKeyPress:n_key_yaw_right] && !capsLockCustomView)
4512 {
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];
4516 yawing = YES;
4517 }
4518 }
4519 if(((mouse_control_on && mouse_x_axis_map_to_yaw) || numSticks) && !keyboardYawOverride && !capsLockCustomView)
4520 {
4521 // I think yaw is handled backwards in the code,
4522 // which is why the negative sign is here.
4523 stick_yaw = max_flight_yaw * (-reqYaw);
4524 if (flightYaw < stick_yaw)
4525 {
4526 [self increase_flight_yaw:delta_t*yaw_delta];
4527 if (flightYaw > stick_yaw)
4528 flightYaw = stick_yaw;
4529 }
4530 if (flightYaw > stick_yaw)
4531 {
4532 [self decrease_flight_yaw:delta_t*yaw_delta];
4533 if (flightYaw < stick_yaw)
4534 flightYaw = stick_yaw;
4535 }
4536 yawing = (fabs(reqYaw) > 0.0);
4537 }
4538 if (!yawing)
4539 {
4540 if (flightYaw > 0.0)
4541 {
4542 if (flightYaw > yaw_dampner) [self decrease_flight_yaw:yaw_dampner];
4543 else flightYaw = 0.0;
4544 }
4545 if (flightYaw < 0.0)
4546 {
4547 if (flightYaw < -yaw_dampner) [self increase_flight_yaw:yaw_dampner];
4548 else flightYaw = 0.0;
4549 }
4550 }
4551
4552}
#define STICK_AXISUNASSIGNED
#define YAW_DAMPING_FACTOR
#define ROLL_DAMPING_FACTOR
#define PITCH_DAMPING_FACTOR

◆ pollFlightControls:

- (void) pollFlightControls: (double)  delta_t

Definition at line 164 of file PlayerEntityControls.m.

1133 :(double)delta_t
1134{
1135 MyOpenGLView *gameView = [UNIVERSE gameView];
1137 NSString *exceptionContext = @"setup";
1138
1139 @try
1140 {
1141 exceptionContext = @"joystick handling";
1142 const BOOL *joyButtonState = [[OOJoystickManager sharedStickHandler] getAllButtonStates];
1143
1144 BOOL paused = [[UNIVERSE gameController] isGamePaused];
1145 double speed_delta = SHIP_THRUST_FACTOR * thrust;
1146
1147 if (!paused && gui_screen == GUI_SCREEN_MISSION)
1148 {
1149 exceptionContext = @"mission screen";
1150 OOViewID view = VIEW_NONE;
1151
1152 NSPoint virtualView = NSZeroPoint;
1153 double view_threshold = 0.5;
1154
1155 if ([stickHandler joystickCount])
1156 {
1157 virtualView = [stickHandler viewAxis];
1158 if (virtualView.y == STICK_AXISUNASSIGNED)
1159 virtualView.y = 0.0;
1160 if (virtualView.x == STICK_AXISUNASSIGNED)
1161 virtualView.x = 0.0;
1162 if (fabs(virtualView.y) >= fabs(virtualView.x))
1163 virtualView.x = 0.0; // forward/aft takes precedence
1164 else
1165 virtualView.y = 0.0;
1166 }
1167
1168 if ([self checkKeyPress:n_key_view_forward] || (virtualView.y < -view_threshold) || joyButtonState[BUTTON_VIEWFORWARD])
1169 {
1170 view = VIEW_FORWARD;
1171 }
1172 if ([self checkKeyPress:n_key_view_aft]|(virtualView.y > view_threshold)||joyButtonState[BUTTON_VIEWAFT])
1173 {
1174 view = VIEW_AFT;
1175 }
1176 if ([self checkKeyPress:n_key_view_port]||(virtualView.x < -view_threshold)||joyButtonState[BUTTON_VIEWPORT])
1177 {
1178 view = VIEW_PORT;
1179 }
1180 if ([self checkKeyPress:n_key_view_starboard]||(virtualView.x > view_threshold)||joyButtonState[BUTTON_VIEWSTARBOARD])
1181 {
1182 view = VIEW_STARBOARD;
1183 }
1184 if (view == VIEW_NONE)
1185 {
1186 // still in mission screen, process the input.
1187 [self pollDemoControls: delta_t];
1188 }
1189 else
1190 {
1191 [[UNIVERSE gui] clearBackground];
1192 [self switchToThisView:view];
1193 if (_missionWithCallback)
1194 {
1195 [self doMissionCallback];
1196 }
1197 // notify older scripts, but do not trigger missionScreenOpportunity.
1198 [self doWorldEventUntilMissionScreen:OOJSID("missionScreenEnded")];
1199 }
1200 }
1201 else if (!paused)
1202 {
1203 exceptionContext = @"arrow keys";
1204 // arrow keys
1205 if ([UNIVERSE displayGUI])
1206 [self pollGuiArrowKeyControls:delta_t];
1207 else
1208 [self pollFlightArrowKeyControls:delta_t];
1209
1210 // view keys
1211 [self pollViewControls];
1212
1213 if (OOMouseInteractionModeIsFlightMode([[UNIVERSE gameController] mouseInteractionMode]))
1214 {
1215 exceptionContext = @"afterburner";
1216 if ((joyButtonState[BUTTON_FUELINJECT] || [self checkKeyPress:n_key_inject_fuel]) &&
1217 [self hasFuelInjection] &&
1218 !hyperspeed_engaged)
1219 {
1220 if (fuel > 0 && !afterburner_engaged)
1221 {
1222 [UNIVERSE addMessage:DESC(@"fuel-inject-on") forCount:1.5];
1223 afterburner_engaged = YES;
1224 [self startAfterburnerSound];
1225 }
1226 else
1227 {
1228 if (fuel <= 0.0)
1229 [UNIVERSE addMessage:DESC(@"fuel-out") forCount:1.5];
1230 }
1231 afterburner_engaged = (fuel > 0);
1232 }
1233 else
1234 afterburner_engaged = NO;
1235
1236 if ((!afterburner_engaged)&&(afterburnerSoundLooping))
1237 [self stopAfterburnerSound];
1238
1239 exceptionContext = @"thrust";
1240 // DJS: Thrust can be an axis or a button. Axis takes precidence.
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;
1244 // Updated DJS original code to fix BUG #17482 - (Getafix 2010/09/13)
1245 if (([self checkKeyPress:n_key_increase_speed] ||
1246 joyButtonState[BUTTON_INCTHRUST] ||
1247 ((mouse_control_on)&&([gameView mouseWheelState] == gvMouseWheelUp) && ([UNIVERSE viewDirection] <= VIEW_STARBOARD || ![gameView isCapsLockOn])))
1248 && (flightSpeed < maxFlightSpeed) && (!afterburner_engaged))
1249 {
1250 flightSpeed += speed_delta * delta_t * mouseWheelDeltaFactor;
1251 }
1252
1253 if (([self checkKeyPress:n_key_decrease_speed] ||
1254 joyButtonState[BUTTON_DECTHRUST] ||
1255 ((mouse_control_on)&&([gameView mouseWheelState] == gvMouseWheelDown) && ([UNIVERSE viewDirection] <= VIEW_STARBOARD || ![gameView isCapsLockOn])))
1256 && (!afterburner_engaged))
1257 {
1258 flightSpeed -= speed_delta * delta_t * mouseWheelDeltaFactor;
1259 // ** tgape ** - decrease obviously means no hyperspeed
1260 hyperspeed_engaged = NO;
1261 }
1262
1263 NSDictionary *functionForThrustAxis = [[stickHandler axisFunctions] oo_dictionaryForKey:[[NSNumber numberWithInt:AXIS_THRUST] stringValue]];
1264 if([stickHandler joystickCount] != 0 && functionForThrustAxis != nil)
1265 {
1266 if (flightSpeed < maxFlightSpeed * reqSpeed)
1267 {
1268 flightSpeed += speed_delta * delta_t;
1269 }
1270 if (flightSpeed > maxFlightSpeed * reqSpeed)
1271 {
1272 flightSpeed -= speed_delta * delta_t;
1273 }
1274 } // DJS: end joystick thrust axis (Getafix - End code update for fixing BUG #17482)
1275
1276 if (!afterburner_engaged && ![self atHyperspeed] && !hyperspeed_engaged)
1277 {
1278 flightSpeed = OOClamp_0_max_f(flightSpeed, maxFlightSpeed);
1279 }
1280
1281 exceptionContext = @"hyperspeed";
1282 // hyperspeed controls
1283 if ([self checkKeyPress:n_key_jumpdrive] || joyButtonState[BUTTON_HYPERSPEED]) // 'j'
1284 {
1285 if (!jump_pressed)
1286 {
1287 if (!hyperspeed_engaged)
1288 {
1289 hyperspeed_locked = [self massLocked];
1290 hyperspeed_engaged = !hyperspeed_locked;
1291 if (hyperspeed_locked)
1292 {
1293 [self playJumpMassLocked];
1294 [UNIVERSE addMessage:DESC(@"jump-mass-locked") forCount:1.5];
1295 }
1296 }
1297 else
1298 {
1299 hyperspeed_engaged = NO;
1300 }
1301 }
1302 jump_pressed = YES;
1303 }
1304 else
1305 {
1306 jump_pressed = NO;
1307 }
1308
1309 exceptionContext = @"shoot";
1310 // shoot 'a'
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))
1312 {
1313 if ([self fireMainWeapon])
1314 {
1315 [self playLaserHit:([self shipHitByLaser] != nil) offset:[[self currentLaserOffset] oo_vectorAtIndex:0] weaponIdentifier:[[self currentWeapon] identifier]];
1316 }
1317 }
1318
1319 exceptionContext = @"weapons online toggle";
1320 // weapons online / offline toggle '_'
1321 if (([self checkKeyPress:n_key_weapons_online_toggle] || joyButtonState[BUTTON_WEAPONSONLINETOGGLE]))
1322 {
1324 {
1325 NSString* weaponsOnlineToggleMsg;
1326
1327 [self setWeaponsOnline:![self weaponsOnline]];
1328 weaponsOnlineToggleMsg = [self weaponsOnline] ? DESC(@"weapons-systems-online") : DESC(@"weapons-systems-offline");
1329 if ([self weaponsOnline])
1330 {
1331 [self playWeaponsOnline];
1332 }
1333 else
1334 {
1335 [self playWeaponsOffline];
1336 }
1337 [UNIVERSE addMessage:weaponsOnlineToggleMsg forCount:2.0];
1338 [self doScriptEvent:OOJSID("weaponsSystemsToggled") withArgument:[NSNumber numberWithBool:[self weaponsOnline]]];
1340 }
1341 }
1343
1344 exceptionContext = @"missile fire";
1345 // shoot 'm' // launch missile
1346 if ([self checkKeyPress:n_key_launch_missile] || joyButtonState[BUTTON_LAUNCHMISSILE])
1347 {
1348 // launch here
1350 {
1351 [self fireMissile];
1353 }
1354 }
1355 else fire_missile_pressed = NO;
1356
1357 exceptionContext = @"next missile";
1358 // shoot 'y' // next missile
1359 if ([self checkKeyPress:n_key_next_missile] || joyButtonState[BUTTON_CYCLEMISSILE])
1360 {
1361 if (!ident_engaged && !next_missile_pressed && [self weaponsOnline])
1362 {
1363 [self playNextMissileSelected];
1364 [self selectNextMissile];
1365 }
1367 }
1368 else next_missile_pressed = NO;
1369
1370 exceptionContext = @"next target";
1371 // '+' // next target
1372 if ([self checkKeyPress:n_key_next_target] || joyButtonState[BUTTON_NEXTTARGET])
1373 {
1374 if ((!next_target_pressed)&&([self hasEquipmentItemProviding:@"EQ_TARGET_MEMORY"]))
1375 {
1376 [self moveTargetMemoryBy:+1];
1377 }
1378 next_target_pressed = YES;
1379 }
1380 else next_target_pressed = NO;
1381
1382 exceptionContext = @"previous target";
1383 // '-' // previous target
1384 if ([self checkKeyPress:n_key_previous_target] || joyButtonState[BUTTON_PREVTARGET])
1385 {
1386 if ((!previous_target_pressed)&&([self hasEquipmentItemProviding:@"EQ_TARGET_MEMORY"]))
1387 {
1388 [self moveTargetMemoryBy:-1];
1389 }
1391 }
1392 else previous_target_pressed = NO;
1393
1394 exceptionContext = @"ident R";
1395 // shoot 'r' // switch on ident system
1396 if ([self checkKeyPress:n_key_ident_system] || joyButtonState[BUTTON_ID])
1397 {
1398 // ident 'on' here
1399 if (!ident_pressed)
1400 {
1401 [self handleButtonIdent];
1402 }
1403 ident_pressed = YES;
1404 }
1405 else ident_pressed = NO;
1406
1407 exceptionContext = @"prime equipment";
1408 // prime equipment 'N' - selects equipment to use with keypress
1409 if ([self checkKeyPress:n_key_prime_next_equipment] || [self checkKeyPress:n_key_prime_previous_equipment] || joyButtonState[BUTTON_PRIMEEQUIPMENT] || joyButtonState[BUTTON_PRIMEEQUIPMENT_PREV])
1410 {
1411
1413 {
1414
1415 // cycle through all the relevant equipment.
1416 NSUInteger c = [eqScripts count];
1417
1418 // if Ctrl is held down at the same time as the prime equipment key,
1419 // cycle relevant equipment in reverse
1420 //if (![gameView isCtrlDown])
1421 if (![self checkKeyPress:n_key_prime_previous_equipment] || joyButtonState[BUTTON_PRIMEEQUIPMENT_PREV])
1422 {
1423 primedEquipment++;
1424 if (primedEquipment > c) primedEquipment = 0;
1425 }
1426 else
1427 {
1428 if (primedEquipment > 0) primedEquipment--;
1429 else primedEquipment = c;
1430 }
1431
1432 NSString *eqKey = @"";
1433
1434 if (primedEquipment == c)
1435 {
1436 if (c > 0)
1437 {
1438 [self playNextEquipmentSelected];
1439 [UNIVERSE addMessage:DESC(@"equipment-primed-none") forCount:2.0];
1440 }
1441 else [UNIVERSE addMessage:DESC(@"equipment-primed-none-available") forCount:2.0];
1442 }
1443 else
1444 {
1445 [self playNextEquipmentSelected];
1446 NSString *equipmentName = [[OOEquipmentType equipmentTypeWithIdentifier:[[eqScripts oo_arrayAtIndex:primedEquipment] oo_stringAtIndex:0]] name];
1447 eqKey = [[eqScripts oo_arrayAtIndex:primedEquipment] oo_stringAtIndex:0];
1448 [UNIVERSE addMessage:OOExpandKey(@"equipment-primed", equipmentName) forCount:2.0];
1449 }
1450 [self doScriptEvent:OOJSID("playerChangedPrimedEquipment") withArgument:eqKey];
1451 }
1453
1454 }
1455 else prime_equipment_pressed = NO;
1456
1457 exceptionContext = @"activate equipment";
1458 // activate equipment 'n' - runs the activated() function inside the equipment's script.
1459 if ([self checkKeyPress:n_key_activate_equipment] || joyButtonState[BUTTON_ACTIVATEEQUIPMENT])
1460 {
1462 {
1463 [self activatePrimableEquipment:primedEquipment withMode:OOPRIMEDEQUIP_ACTIVATED];
1464 }
1466 }
1468
1469 exceptionContext = @"mode equipment";
1470 // mode equipment 'b' - runs the mode() function inside the equipment's script.
1471 if ([self checkKeyPress:n_key_mode_equipment] || joyButtonState[BUTTON_MODEEQUIPMENT])
1472 {
1474 {
1475 [self activatePrimableEquipment:primedEquipment withMode:OOPRIMEDEQUIP_MODE];
1476 }
1478 }
1479 else mode_equipment_pressed = NO;
1480
1481 exceptionContext = @"fast equipment A";
1482 if ([self checkKeyPress:n_key_fastactivate_equipment_a] || joyButtonState[BUTTON_CLOAK])
1483 {
1485 {
1486 [self activatePrimableEquipment:[self eqScriptIndexForKey:[self fastEquipmentA]] withMode:OOPRIMEDEQUIP_ACTIVATED];
1487 }
1489 }
1490 else fastactivate_a_pressed = NO;
1491
1492 exceptionContext = @"fast equipment B";
1493 if ([self checkKeyPress:n_key_fastactivate_equipment_b] || joyButtonState[BUTTON_ENERGYBOMB])
1494 {
1496 {
1497 [self activatePrimableEquipment:[self eqScriptIndexForKey:[self fastEquipmentB]] withMode:OOPRIMEDEQUIP_ACTIVATED];
1498 }
1500 }
1501 else fastactivate_b_pressed = NO;
1502
1503 exceptionContext = @"custom equipment";
1504 // loop through all the objects in the customEquipActivation array
1505 NSDictionary *item;
1506 NSUInteger i;
1507 for (i = 0; i < [customEquipActivation count]; i++)
1508 {
1509 item = [customEquipActivation objectAtIndex:i];
1510 // check if the player has the equip item installed
1511 if ([self hasOneEquipmentItem:[item oo_stringForKey:CUSTOMEQUIP_EQUIPKEY] includeWeapons:NO whileLoading:NO])
1512 {
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];
1517 // if so,
1518 // check to see if the key or button was pressed for activate
1519 if ((key_act && [self checkKeyPress:key_act]) || (but_act && [[OOJoystickManager sharedStickHandler] isButtonDown:[but_act oo_intForKey:STICK_AXBUT] stick:[but_act oo_intForKey:STICK_NUMBER]]))
1520 {
1521 if (![[customActivatePressed objectAtIndex:i] boolValue])
1522 {
1523 // initate the activate JS code
1524 [self activatePrimableEquipment:[self eqScriptIndexForKey:[item oo_stringForKey:CUSTOMEQUIP_EQUIPKEY]] withMode:OOPRIMEDEQUIP_ACTIVATED];
1525 }
1526 [customActivatePressed replaceObjectAtIndex:i withObject:[NSNumber numberWithBool:YES]];
1527 }
1528 else [customActivatePressed replaceObjectAtIndex:i withObject:[NSNumber numberWithBool:NO]];
1529
1530 // check to see if the key or button was pressed for mode
1531 if ((key_mod && [self checkKeyPress:key_mod]) || (but_mod && [[OOJoystickManager sharedStickHandler] isButtonDown:[but_mod oo_intForKey:STICK_AXBUT] stick:[but_mod oo_intForKey:STICK_NUMBER]]))
1532 {
1533 if (![[customModePressed objectAtIndex:i] boolValue])
1534 {
1535 // initiate the activate JS code
1536 [self activatePrimableEquipment:[self eqScriptIndexForKey:[item oo_stringForKey:CUSTOMEQUIP_EQUIPKEY]] withMode:OOPRIMEDEQUIP_MODE];
1537 }
1538 [customModePressed replaceObjectAtIndex:i withObject:[NSNumber numberWithBool:YES]];
1539 }
1540 else [customModePressed replaceObjectAtIndex:i withObject:[NSNumber numberWithBool:NO]];
1541 }
1542 }
1543
1544 exceptionContext = @"incoming missile T";
1545 // target nearest incoming missile 'T' - useful for quickly giving a missile target to turrets
1546 if ([self checkKeyPress:n_key_target_incoming_missile] || joyButtonState[BUTTON_TARGETINCOMINGMISSILE])
1547 {
1549 {
1550 [self targetNearestIncomingMissile];
1551 }
1553 }
1555
1556 exceptionContext = @"missile T";
1557 // shoot 't' // switch on missile targeting
1558 if (([self checkKeyPress:n_key_target_missile] || joyButtonState[BUTTON_ARMMISSILE])&&(missile_entity[activeMissile]))
1559 {
1560 // targeting 'on' here
1562 {
1563 [self handleButtonTargetMissile];
1564 }
1566 }
1567 else target_missile_pressed = NO;
1568
1569 exceptionContext = @"missile U";
1570 // shoot 'u' // disarm missile targeting
1571 if ([self checkKeyPress:n_key_untarget_missile] || joyButtonState[BUTTON_UNARM])
1572 {
1573 if (!safety_pressed)
1574 {
1575 //targeting off in both cases!
1576 if ([self primaryTarget] != nil) [self noteLostTarget];
1577 DESTROY(_primaryTarget);
1578 [self safeAllMissiles];
1579 if (!ident_engaged && [self weaponsOnline])
1580 {
1581 [UNIVERSE addMessage:DESC(@"missile-safe") forCount:2.0];
1582 [self playMissileSafe];
1583 }
1584 else
1585 {
1586 [UNIVERSE addMessage:DESC(@"ident-off") forCount:2.0];
1587 [self playIdentOff];
1588 }
1589 ident_engaged = NO;
1590 }
1591 safety_pressed = YES;
1592 }
1593 else safety_pressed = NO;
1594
1595 exceptionContext = @"ECM";
1596 // shoot 'e' // ECM
1597 if (([self checkKeyPress:n_key_ecm] || joyButtonState[BUTTON_ECM]) && [self hasECM])
1598 {
1599 if (!ecm_in_operation)
1600 {
1601 if ([self weaponsOnline] && [self fireECM])
1602 {
1603 [self playFiredECMSound];
1604 [UNIVERSE addMessage:DESC(@"ecm-on") forCount:3.0];
1605 }
1606 }
1607 }
1608
1609
1610 exceptionContext = @"escape pod";
1611 // shoot 'escape' // Escape pod launch - NOTE: Allowed at all times, but requires double press within a specific time interval.
1612 // Double press not available in strict mode or when the "escape-pod-activation-immediate" override is in the
1613 // user defaults file.
1614 if (([self checkKeyPress:n_key_launch_escapepod] || joyButtonState[BUTTON_ESCAPE]) && [self hasEscapePod])
1615 {
1616 BOOL goodToLaunch = [[NSUserDefaults standardUserDefaults] boolForKey:@"escape-pod-activation-immediate"];
1617 static OOTimeDelta escapePodKeyResetTime;
1618
1619 if (!goodToLaunch)
1620 {
1622 {
1624 // first keypress will unregister in KEY_REPEAT_INTERVAL seconds
1625 escapePodKeyResetTime = [NSDate timeIntervalSinceReferenceDate] + KEY_REPEAT_INTERVAL;
1626 //[gameView clearKey:key_launch_escapepod];
1627 [gameView clearKey:[self getFirstKeyCode:n_key_launch_escapepod]];
1628 if ([stickHandler joystickCount])
1629 {
1630 [stickHandler clearStickButtonState:BUTTON_ESCAPE];
1631 }
1632 }
1633 else
1634 {
1635 OOTimeDelta timeNow = [NSDate timeIntervalSinceReferenceDate];
1637 if (timeNow < escapePodKeyResetTime) goodToLaunch = YES;
1638 }
1639 }
1640 if (goodToLaunch)
1641 {
1642 [self launchEscapeCapsule];
1643 }
1644 }
1645
1646 exceptionContext = @"dump cargo";
1647 // shoot 'd' // Dump Cargo
1648 if (([self checkKeyPress:n_key_dump_cargo] || joyButtonState[BUTTON_JETTISON]) && [cargo count] > 0)
1649 {
1650 [self dumpCargo];
1651 }
1652
1653 exceptionContext = @"rotate cargo";
1654 // shoot 'R' // Rotate Cargo
1655 if ([self checkKeyPress:n_key_rotate_cargo] || joyButtonState[BUTTON_ROTATECARGO])
1656 {
1657 if ((!rotateCargo_pressed)&&([cargo count] > 0))
1658 [self rotateCargo];
1659 rotateCargo_pressed = YES;
1660 }
1661 else
1663
1664 exceptionContext = @"autopilot C";
1665 // autopilot 'c'
1666 if ([self checkKeyPress:n_key_autopilot] || joyButtonState[BUTTON_DOCKCPU]) // look for the 'c' key
1667 {
1668 if ([self hasDockingComputer] && (!autopilot_key_pressed))
1669 {
1670 [self handleAutopilotOn:false];
1671 }
1673 }
1674 else
1676
1677 exceptionContext = @"autopilot shift-C";
1678 // autopilot 'C' - fast-autopilot
1679 if ([self checkKeyPress:n_key_autodock] || joyButtonState[BUTTON_DOCKCPUFAST]) // look for the 'C' key
1680 {
1681 if ([self hasDockingComputer] && (!fast_autopilot_key_pressed))
1682 {
1683 [self handleAutopilotOn:true];
1684 }
1686 }
1687 else
1688 {
1690 }
1691
1692 exceptionContext = @"docking clearance request";
1693
1694 if ([self checkKeyPress:n_key_docking_clearance_request] || joyButtonState[BUTTON_DOCKINGCLEARANCE])
1695 {
1697 {
1698 Entity *primeTarget = [self primaryTarget];
1699 [self performDockingRequest:(StationEntity*)primeTarget];
1700 }
1702 }
1703 else
1704 {
1706 }
1707
1708 exceptionContext = @"hyperspace";
1709 // hyperspace 'h'
1710 if ( ([self checkKeyPress:n_key_hyperspace] || joyButtonState[BUTTON_HYPERDRIVE]) &&
1711 [self hasHyperspaceMotor] ) // look for the 'h' key
1712 {
1713 if (!hyperspace_pressed)
1714 {
1715 if ([self status] == STATUS_WITCHSPACE_COUNTDOWN)
1716 {
1717 [self cancelWitchspaceCountdown];
1718 if (galactic_witchjump)
1719 {
1720 galactic_witchjump = NO;
1721 [UNIVERSE addMessage:DESC(@"witch-user-galactic-abort") forCount:3.0];
1722 }
1723 else
1724 {
1725 [UNIVERSE addMessage:DESC(@"witch-user-abort") forCount:3.0];
1726 }
1727 }
1728 else if ([self witchJumpChecklist:false])
1729 {
1730 [self beginWitchspaceCountdown:hyperspaceMotorSpinTime];
1731 }
1732 }
1733 hyperspace_pressed = YES;
1734 }
1735 else
1736 hyperspace_pressed = NO;
1737
1738 exceptionContext = @"galactic hyperspace";
1739 // Galactic hyperspace 'g'
1740 if (([self checkKeyPress:n_key_galactic_hyperspace] || joyButtonState[BUTTON_GALACTICDRIVE]) &&
1741 ([self hasEquipmentItemProviding:@"EQ_GAL_DRIVE"]))// look for the 'g' key
1742 {
1744 {
1745 if ([self status] == STATUS_WITCHSPACE_COUNTDOWN)
1746 {
1747 [self cancelWitchspaceCountdown];
1748 if (galactic_witchjump)
1749 {
1750 galactic_witchjump = NO;
1751 [UNIVERSE addMessage:DESC(@"witch-user-galactic-abort") forCount:3.0];
1752 }
1753 else
1754 {
1755 [UNIVERSE addMessage:DESC(@"witch-user-abort") forCount:3.0];
1756 }
1757 }
1758 else
1759 {
1760 galactic_witchjump = YES;
1761
1762 // even if we don't have a witchspace motor, we can still do a default galactic jump (!)
1763 if(EXPECT([self hasHyperspaceMotor])) witchspaceCountdown = hyperspaceMotorSpinTime;
1764 else witchspaceCountdown = DEFAULT_HYPERSPACE_SPIN_TIME;
1765
1766 [self setStatus:STATUS_WITCHSPACE_COUNTDOWN];
1767 [self playGalacticHyperspace];
1768 // say it!
1769 [UNIVERSE addMessage:[NSString stringWithFormat:DESC(@"witch-galactic-in-f-seconds"), witchspaceCountdown] forCount:1.0];
1770 // FIXME: how to preload target system for hyperspace jump?
1771
1772 [self doScriptEvent:OOJSID("playerStartedJumpCountdown")
1773 withArguments:[NSArray arrayWithObjects:@"galactic", [NSNumber numberWithFloat:witchspaceCountdown], nil]];
1774 }
1775 }
1777 }
1778 else
1780
1781 }
1782
1783#if OO_FOV_INFLIGHT_CONTROL_ENABLED
1784 // Field of view controls
1785 if (![UNIVERSE displayGUI])
1786 {
1787 if (([self checkKeyPress:n_key_inc_field_of_view] || joyButtonState[BUTTON_INC_FIELD_OF_VIEW]) && (fieldOfView < MAX_FOV))
1788 {
1789 fieldOfView *= pow(fov_delta, delta_t);
1790 if (fieldOfView > MAX_FOV) fieldOfView = MAX_FOV;
1791 }
1792
1793 if (([self checkKeyPress:n_key_dec_field_of_view] || joyButtonState[BUTTON_DEC_FIELD_OF_VIEW]) && (fieldOfView > MIN_FOV))
1794 {
1795 fieldOfView /= pow(fov_delta, delta_t);
1796 if (fieldOfView < MIN_FOV) fieldOfView = MIN_FOV;
1797 }
1798
1799 NSDictionary *functionForFovAxis = [[stickHandler axisFunctions] oo_dictionaryForKey:[[NSNumber numberWithInt:AXIS_FIELD_OF_VIEW] stringValue]];
1800 if ([stickHandler joystickCount] != 0 && functionForFovAxis != nil)
1801 {
1802 // TODO think reqFov through
1803 double reqFov = [stickHandler getAxisState: AXIS_FIELD_OF_VIEW];
1804 if (fieldOfView < maxFieldOfView * reqFov)
1805 {
1806 fieldOfView *= pow(fov_delta, delta_t);
1807 if (fieldOfView > MAX_FOV) fieldOfView = MAX_FOV;
1808 }
1809 if (fieldOfView > maxFieldOfView * reqFov)
1810 {
1811 fieldOfView /= pow(fov_delta, delta_t);
1812 if (fieldOfView < MIN_FOV) fieldOfView = MIN_FOV;
1813 }
1814 }
1815 }
1816#endif
1817
1818 #ifndef NDEBUG
1819 exceptionContext = @"dump target state";
1820 if ([self checkKeyPress:n_key_dump_target_state])
1821 {
1823 {
1825 id target = [self primaryTarget];
1826 if (target == nil) target = self;
1827 [target dumpState];
1828 }
1829 }
1830 else dump_target_state_pressed = NO;
1831 #endif
1832
1833 // text displays
1834 exceptionContext = @"pollGuiScreenControls";
1835 [self pollGuiScreenControls];
1836 }
1837 else
1838 {
1839 // game is paused
1840 // check options menu request
1841 exceptionContext = @"options menu";
1842 if (([self checkKeyPress:n_key_gui_screen_options]) && (gui_screen != GUI_SCREEN_OPTIONS) && ![gameView allowingStringInput])
1843 {
1844 [gameView clearKeys];
1845 [self setGuiToLoadSaveScreen];
1846 }
1847
1848 #if (ALLOW_CUSTOM_VIEWS_WHILE_PAUSED)
1849 [self pollCustomViewControls]; // allow custom views during pause
1850 #endif
1851
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)
1855 {
1856 if ([UNIVERSE pauseMessageVisible]) [[UNIVERSE messageGUI] leaveLastLine];
1857 else [[UNIVERSE messageGUI] clear];
1858 NSTimeInterval time_this_frame = [NSDate timeIntervalSinceReferenceDate];
1859 OOTimeDelta time_delta;
1860 if (![[GameController sharedController] isGamePaused])
1861 {
1862 time_delta = time_this_frame - time_last_frame;
1863 time_last_frame = time_this_frame;
1864 time_delta = OOClamp_0_max_d(time_delta, MINIMUM_GAME_TICK);
1865 }
1866 else
1867 {
1868 time_delta = 0.0;
1869 }
1870
1871 script_time += time_delta;
1872 [self pollGuiArrowKeyControls:time_delta];
1873 }
1874
1875 exceptionContext = @"debug keys";
1876 #ifndef NDEBUG
1877 // look for debugging keys
1878 if ([self checkKeyPress:n_key_dump_entity_list] && ![gameView allowingStringInput])// look for the '0' key
1879 {
1881 {
1882 [UNIVERSE debugDumpEntities];
1883 gDebugFlags = 0;
1884 [UNIVERSE addMessage:@"Entity List dumped. Debugging OFF" forCount:3];
1885 }
1887 }
1888 else
1890
1891 // look for debugging keys
1892 if ([self checkKeyPress:n_key_debug_full] && ![gameView allowingStringInput])// look for the 'd' key
1893 {
1895 [UNIVERSE addMessage:@"Full debug ON" forCount:3];
1896 }
1897
1898 if ([self checkKeyPress:n_key_debug_collision] && ![gameView allowingStringInput])// look for the 'b' key
1899 {
1901 [UNIVERSE addMessage:@"Collision debug ON" forCount:3];
1902 }
1903
1904 if ([self checkKeyPress:n_key_debug_console_connect] && ![[OODebugMonitor sharedDebugMonitor] usingPlugInController] && ![gameView allowingStringInput]) // look for the 'c' key
1905 {
1906 // This code is executed only if we're not using the integrated plugin controller
1908 {
1909 if (![[OODebugMonitor sharedDebugMonitor] debuggerConnected])
1910 {
1912 if ([[OODebugMonitor sharedDebugMonitor] debuggerConnected])
1913 [UNIVERSE addMessage:@"Connected to debug console." forCount:3];
1914 }
1915 else
1916 {
1918 [UNIVERSE addMessage:@"Disconnected from debug console." forCount:3];
1919 }
1920 }
1922 }
1923 else
1925
1926 if ([self checkKeyPress:n_key_debug_bounding_boxes] && ![gameView allowingStringInput])// look for the 'x' key
1927 {
1929 [UNIVERSE addMessage:@"Bounding box debug ON" forCount:3];
1930 }
1931
1932 if ([self checkKeyPress:n_key_debug_shaders] && ![gameView allowingStringInput])// look for the 's' key
1933 {
1934 OOLogSetDisplayMessagesInClass(@"$shaderDebugOn", YES);
1935 [UNIVERSE addMessage:@"Shader debug ON" forCount:3];
1936 }
1937
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])
1939 {
1941 {
1942 float newTimeAccelerationFactor = [self checkKeyPress:n_key_gui_arrow_left] ?
1943 fmax([UNIVERSE timeAccelerationFactor] / 2.0f, TIME_ACCELERATION_FACTOR_MIN) :
1944 fmin([UNIVERSE timeAccelerationFactor] * 2.0f, TIME_ACCELERATION_FACTOR_MAX);
1945 [UNIVERSE setTimeAccelerationFactor:newTimeAccelerationFactor];
1946 }
1947 leftRightKeyPressed = YES;
1948 }
1949 else
1951
1952
1953 if ([self checkKeyPress:n_key_debug_off] && ![gameView allowingStringInput])// look for the 'n' key
1954 {
1955 gDebugFlags = 0;
1956 [UNIVERSE addMessage:@"All debug flags OFF" forCount:3];
1957 OOLogSetDisplayMessagesInClass(@"$shaderDebugOn", NO);
1958 }
1959 #endif
1960 }
1961
1962 exceptionContext = @"pause";
1963 // Pause game 'p'
1964 if (([self checkKeyPress:n_key_pausebutton] || joyButtonState[BUTTON_PAUSE]) && gui_screen != GUI_SCREEN_LONG_RANGE_CHART && gui_screen != GUI_SCREEN_MISSION && ![gameView allowingStringInput])// look for the 'p' key
1965 {
1966 if (!pause_pressed)
1967 {
1968 if (paused)
1969 {
1970 script_time = saved_script_time;
1971 // Reset to correct GUI screen, if we are unpausing from one.
1972 // Don't set gui_screen here, use setGuis - they also switch backgrounds.
1973 // No gui switching events will be triggered while still paused.
1974 switch (saved_gui_screen)
1975 {
1976 case GUI_SCREEN_STATUS:
1977 [self setGuiToStatusScreen];
1978 break;
1979 case GUI_SCREEN_LONG_RANGE_CHART:
1980 [self setGuiToLongRangeChartScreen];
1981 break;
1982 case GUI_SCREEN_SHORT_RANGE_CHART:
1983 [self setGuiToShortRangeChartScreen];
1984 break;
1985 case GUI_SCREEN_MANIFEST:
1986 [self setGuiToManifestScreen];
1987 break;
1988 case GUI_SCREEN_MARKET:
1989 [self setGuiToMarketScreen];
1990 break;
1991 case GUI_SCREEN_MARKETINFO:
1992 [self setGuiToMarketInfoScreen];
1993 break;
1994 case GUI_SCREEN_SYSTEM_DATA:
1995 // Do not reset planet rotation if we are already in the system info screen!
1996 if (gui_screen != GUI_SCREEN_SYSTEM_DATA)
1997 [self setGuiToSystemDataScreen];
1998 break;
1999 default:
2000 gui_screen = saved_gui_screen; // make sure we're back to the right screen
2001 break;
2002 }
2003 [gameView allowStringInput:NO];
2004 [UNIVERSE clearPreviousMessage];
2005 [UNIVERSE setViewDirection:saved_view_direction];
2006 currentWeaponFacing = saved_weapon_facing;
2007 // make sure the light comes from the right direction after resuming from pause!
2008 if (saved_gui_screen == GUI_SCREEN_SYSTEM_DATA) [UNIVERSE setMainLightPosition:_sysInfoLight];
2009 [[UNIVERSE gui] setForegroundTextureKey:@"overlay"];
2010 [[UNIVERSE gameController] setGamePaused:NO];
2011 }
2012 else
2013 {
2014 saved_view_direction = [UNIVERSE viewDirection];
2015 saved_script_time = script_time;
2016 saved_gui_screen = gui_screen;
2017 saved_weapon_facing = currentWeaponFacing;
2018 [UNIVERSE pauseGame]; // pause handler
2019 }
2020 }
2021 pause_pressed = YES;
2022 }
2023 else
2024 {
2025 pause_pressed = NO;
2026 }
2027 }
2028 @catch (NSException *exception)
2029 {
2030 OOLog(kOOLogException, @"***** Exception in pollFlightControls [%@]: %@ : %@", exceptionContext, [exception name], [exception reason]);
2031 }
2032}
#define MAX_FOV
#define MIN_FOV
NSUInteger gDebugFlags
Definition main.m:7
#define MINIMUM_GAME_TICK
#define DESTROY(x)
Definition OOCocoa.h:75
#define DEBUG_ALL
@ DEBUG_COLLISIONS
Definition OODebugFlags.h:7
@ DEBUG_BOUNDING_BOXES
void OOInitDebugSupport(void)
@ BUTTON_DOCKINGCLEARANCE
@ BUTTON_LAUNCHMISSILE
@ BUTTON_FUELINJECT
@ BUTTON_ENERGYBOMB
@ BUTTON_TARGETINCOMINGMISSILE
@ BUTTON_PRIMEEQUIPMENT
@ BUTTON_ROTATECARGO
@ BUTTON_VIEWSTARBOARD
@ BUTTON_VIEWAFT
@ BUTTON_GALACTICDRIVE
@ BUTTON_ARMMISSILE
@ BUTTON_HYPERDRIVE
@ BUTTON_ACTIVATEEQUIPMENT
@ BUTTON_CLOAK
@ BUTTON_NEXTTARGET
@ BUTTON_FIRE
@ BUTTON_UNARM
@ BUTTON_CYCLEMISSILE
@ BUTTON_VIEWPORT
@ BUTTON_HYPERSPEED
@ BUTTON_ESCAPE
@ BUTTON_JETTISON
@ BUTTON_MODEEQUIPMENT
@ BUTTON_VIEWFORWARD
@ BUTTON_WEAPONSONLINETOGGLE
@ BUTTON_INCTHRUST
@ BUTTON_ID
@ BUTTON_ECM
@ BUTTON_PREVTARGET
@ BUTTON_DECTHRUST
@ BUTTON_PRIMEEQUIPMENT_PREV
#define STICK_NUMBER
#define STICK_AXBUT
void OOLogSetDisplayMessagesInClass(NSString *inClass, BOOL inFlag)
Definition OOLogging.m:182
float y
float x
OOViewID
Definition OOTypes.h:43
static BOOL prime_equipment_pressed
static BOOL ident_pressed
static BOOL dump_target_state_pressed
static BOOL next_target_pressed
static BOOL rotateCargo_pressed
static BOOL previous_target_pressed
static NSTimeInterval time_last_frame
static OOWeaponFacing saved_weapon_facing
static BOOL mode_equipment_pressed
static BOOL jump_pressed
static BOOL fire_missile_pressed
static BOOL safety_pressed
static BOOL target_incoming_missile_pressed
static BOOL galhyperspace_pressed
static int saved_gui_screen
static BOOL next_missile_pressed
static BOOL weaponsOnlineToggle_pressed
static BOOL hyperspace_pressed
static BOOL fastactivate_a_pressed
static int saved_view_direction
static BOOL escapePodKey_pressed
static BOOL activate_equipment_pressed
static BOOL dump_entity_list_pressed
static BOOL fastactivate_b_pressed
static BOOL target_missile_pressed
static BOOL docking_clearance_request_key_pressed
#define CUSTOMEQUIP_EQUIPKEY
#define DEFAULT_HYPERSPACE_SPIN_TIME
Definition ShipEntity.h:70
#define SHIP_THRUST_FACTOR
Definition ShipEntity.h:44
#define TIME_ACCELERATION_FACTOR_MAX
Definition Universe.h:167
#define TIME_ACCELERATION_FACTOR_MIN
Definition Universe.h:165
void clearKey:(int theKey)
BOOL setDebugger:(id< OODebuggerInterface > debugger)
OODebugMonitor * sharedDebugMonitor()
OOEquipmentType * equipmentTypeWithIdentifier:(NSString *identifier)
NSDictionary * axisFunctions()
double getAxisState:(int function)
void clearStickButtonState:(int stickButton)

◆ pollGameOverControls:

- (void) pollGameOverControls: (double)  delta_t

Definition at line 164 of file PlayerEntityControls.m.

4720 :(double)delta_t
4721{
4722 MyOpenGLView *gameView = [UNIVERSE gameView];
4723 if ([gameView isDown:32]) // look for the spacebar
4724 {
4725 if (!spacePressed)
4726 {
4727 [UNIVERSE displayMessage:@"" forCount:1.0];
4728 shot_time = INITIAL_SHOT_TIME; // forces immediate restart
4729 }
4730 spacePressed = YES;
4731 }
4732 else
4733 spacePressed = NO;
4734}
#define INITIAL_SHOT_TIME
Definition ShipEntity.h:100

◆ pollGuiArrowKeyControls:

- (void) pollGuiArrowKeyControls: (double)  delta_t

Definition at line 164 of file PlayerEntityControls.m.

2035 :(double) delta_t
2036{
2037 MyOpenGLView *gameView = [UNIVERSE gameView];
2038 BOOL moving = NO;
2039 BOOL dragging = NO;
2040 double cursor_speed = ([gameView isCtrlDown] ? 20.0 : 10.0)* chart_zoom;
2041 GameController *controller = [UNIVERSE gameController];
2042 GuiDisplayGen *gui = [UNIVERSE gui];
2043 GUI_ROW_INIT(gui);
2044
2045 // deal with string inputs as necessary
2046 if (gui_screen == GUI_SCREEN_LONG_RANGE_CHART)
2047 {
2048 [gameView setStringInput: gvStringInputAlpha];
2049 }
2050 else if (gui_screen == GUI_SCREEN_SAVE)
2051 {
2052 [gameView setStringInput: gvStringInputLoadSave];
2053 }
2054 else if (gui_screen == GUI_SCREEN_MISSION && _missionTextEntry)
2055 {
2056 [gameView setStringInput: gvStringInputAll];
2057 }
2058 else if (gui_screen == GUI_SCREEN_KEYBOARD_ENTRY)
2059 {
2060 [gameView setStringInput: gvStringInputAll];
2061 }
2062#if 0
2063 // at the moment this function is never called for GUI_SCREEN_OXZMANAGER
2064 // but putting this here in case we do later
2065 else if (gui_screen == GUI_SCREEN_OXZMANAGER && [[OOOXZManager sharedManager] isAcceptingTextInput])
2066 {
2067 [gameView setStringInput: gvStringInputAll];
2068 }
2069#endif
2070 else
2071 {
2072 [gameView allowStringInput: NO];
2073 // If we have entered this screen with the injectors key pressed, make sure
2074 // that injectors switch off when we release it - Nikos.
2075 if (afterburner_engaged && ![self checkKeyPress:n_key_inject_fuel])
2076 {
2077 afterburner_engaged = NO;
2078 }
2079
2080 }
2081
2082 switch (gui_screen)
2083 {
2084 case GUI_SCREEN_LONG_RANGE_CHART:
2085
2086 if ([self status] != STATUS_WITCHSPACE_COUNTDOWN)
2087 {
2088 if ([[gameView typedString] length] > 0)
2089 {
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))
2093 {
2094 // always reset the found system index at the beginning of a new search
2095 if ([planetSearchString length] == 1) [[UNIVERSE gui] targetNextFoundSystem:0];
2096
2097 // Always select the right one out of 2 overlapping systems.
2098 [self targetNewSystem:0 whileTyping:YES];
2099 }
2100 else
2101 {
2102 found_system_id = -1;
2103 [self clearPlanetSearchString];
2104 }
2105 }
2106 else
2107 {
2108 if ([gameView isDown:gvDeleteKey]) // did we just delete the string ?
2109 {
2110 found_system_id = -1;
2111 [UNIVERSE findSystemCoordinatesWithPrefix:@""];
2112 }
2113 if (planetSearchString) [planetSearchString release];
2114 planetSearchString = nil;
2115 }
2116
2117 moving |= (searchStringLength != [[gameView typedString] length]);
2118 searchStringLength = [[gameView typedString] length];
2119 }
2120
2121 case GUI_SCREEN_SHORT_RANGE_CHART:
2122
2123 if ([self checkKeyPress:n_key_chart_highlight])
2124 {
2125 if (!queryPressed)
2126 {
2127 OOLongRangeChartMode mode = [self longRangeChartMode];
2128 if (mode != OOLRC_MODE_TECHLEVEL)
2129 {
2130 [self setLongRangeChartMode:mode+1];
2131 }
2132 else
2133 {
2134 [self setLongRangeChartMode:OOLRC_MODE_SUNCOLOR];
2135 }
2136 [self doScriptEvent:OOJSID("chartHighlightModeChanged") withArgument:OOStringFromLongRangeChartMode([self longRangeChartMode])];
2137 }
2138 queryPressed = YES;
2139 }
2140 else
2141 {
2142 queryPressed = NO;
2143 }
2144
2145 if ([self checkKeyPress:n_key_map_info] && chart_zoom <= CHART_ZOOM_SHOW_LABELS)
2146 {
2147 if (!chartInfoPressed)
2148 {
2149 show_info_flag = !show_info_flag;
2150 chartInfoPressed = YES;
2151 }
2152 }
2153 else
2154 {
2155 chartInfoPressed = NO;
2156 }
2157
2158 if ([self status] != STATUS_WITCHSPACE_COUNTDOWN)
2159 {
2160 if ([self hasEquipmentItemProviding:@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
2161 {
2162 if ([self checkKeyPress:n_key_advanced_nav_array_next] || [self checkKeyPress:n_key_advanced_nav_array_previous])
2163 {
2164 if (!pling_pressed)
2165 {
2166 if ([self checkKeyPress:n_key_advanced_nav_array_previous])
2167 {
2168 switch (ANA_mode)
2169 {
2170 case OPTIMIZED_BY_NONE: ANA_mode = OPTIMIZED_BY_TIME; break;
2171 case OPTIMIZED_BY_TIME: ANA_mode = OPTIMIZED_BY_JUMPS; break;
2172 default: ANA_mode = OPTIMIZED_BY_NONE; break;
2173 }
2174 }
2175 else
2176 {
2177 switch (ANA_mode)
2178 {
2179 case OPTIMIZED_BY_NONE: ANA_mode = OPTIMIZED_BY_JUMPS; break;
2180 case OPTIMIZED_BY_JUMPS:ANA_mode = OPTIMIZED_BY_TIME; break;
2181 default: ANA_mode = OPTIMIZED_BY_NONE; break;
2182 }
2183 }
2184 if (ANA_mode == OPTIMIZED_BY_NONE || ![self infoSystemOnRoute])
2185 {
2186 [self setInfoSystemID: target_system_id moveChart: NO];
2187 }
2188 }
2189 pling_pressed = YES;
2190 }
2191 else
2192 {
2193 pling_pressed = NO;
2194 }
2195 }
2196 else
2197 {
2198 ANA_mode = OPTIMIZED_BY_NONE;
2199 }
2200
2201 if ([gameView isDown:gvMouseDoubleClick])
2202 {
2203 [gameView clearMouse];
2204 mouse_left_down = NO;
2205 [self noteGUIWillChangeTo:GUI_SCREEN_SYSTEM_DATA];
2206 showingLongRangeChart = (gui_screen == GUI_SCREEN_LONG_RANGE_CHART);
2207 [self setGuiToSystemDataScreen];
2208 break;
2209 }
2210 if ([gameView isDown:gvMouseLeftButton])
2211 {
2212 NSPoint maus = [gameView virtualJoystickPosition];
2214 double hscale = MAIN_GUI_PIXEL_WIDTH / (64.0 * chart_zoom);
2215 double vscale = MAIN_GUI_PIXEL_HEIGHT / (128.0 * chart_zoom);
2216 if (mouse_left_down == NO)
2217 {
2218 NSPoint centre = [self adjusted_chart_centre];
2219 centre_at_mouse_click = chart_centre_coordinates;
2220 mouse_click_position = maus;
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;
2224 }
2225 if (fabs(maus.x - mouse_click_position.x)*MAIN_GUI_PIXEL_WIDTH > 2 ||
2226 fabs(maus.y - mouse_click_position.y)*MAIN_GUI_PIXEL_HEIGHT > 2)
2227 {
2228 chart_centre_coordinates.x = OOClamp_0_max_f(centre_at_mouse_click.x - (maus.x - mouse_click_position.x)*MAIN_GUI_PIXEL_WIDTH/hscale, 256.0);
2229 chart_centre_coordinates.y = OOClamp_0_max_f(centre_at_mouse_click.y - (maus.y - mouse_click_position.y)*MAIN_GUI_PIXEL_HEIGHT/vscale, 256.0);
2230 target_chart_centre = chart_centre_coordinates;
2231 dragging = YES;
2232 }
2233 if (gui_screen == GUI_SCREEN_LONG_RANGE_CHART)
2234 [gameView resetTypedString];
2235 mouse_left_down = YES;
2236 }
2237 else if (mouse_left_down == YES)
2238 {
2239 NSPoint maus = [gameView virtualJoystickPosition];
2240 if (fabs(maus.x - mouse_click_position.x)*MAIN_GUI_PIXEL_WIDTH <= 2 &&
2241 fabs(maus.y - mouse_click_position.y)*MAIN_GUI_PIXEL_HEIGHT <= 2)
2242 {
2243 cursor_coordinates = chart_focus_coordinates;
2244 moving = YES;
2245 }
2246 else
2247 {
2248 dragging = YES;
2249 }
2250 mouse_left_down = NO;
2251 }
2252 if ([self checkKeyPress:n_key_map_home])
2253 {
2254 if ([gameView isOptDown])
2255 {
2256 [self homeInfoSystem];
2257 target_chart_focus = galaxy_coordinates;
2258 }
2259 else
2260 {
2261 [gameView resetTypedString];
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:@""];
2267 moving = YES;
2268 }
2269 }
2270 if ([self checkKeyPress:n_key_map_end])
2271 {
2272 [self targetInfoSystem];
2273 target_chart_focus = cursor_coordinates;
2274 }
2275 if ([self checkKeyPress:n_key_map_zoom_in] || [gameView mouseWheelState] == gvMouseWheelDown)
2276 {
2277 target_chart_zoom *= CHART_ZOOM_SPEED_FACTOR;
2278 if (target_chart_zoom > CHART_MAX_ZOOM) target_chart_zoom = CHART_MAX_ZOOM;
2279 saved_chart_zoom = target_chart_zoom;
2280 }
2281 if ([self checkKeyPress:n_key_map_zoom_out] || [gameView mouseWheelState] == gvMouseWheelUp)
2282 {
2283 if (gui_screen == GUI_SCREEN_LONG_RANGE_CHART)
2284 {
2285 target_chart_zoom = CHART_MAX_ZOOM;
2286 [self setGuiToShortRangeChartScreen];
2287 }
2288 target_chart_zoom /= CHART_ZOOM_SPEED_FACTOR;
2289 if (target_chart_zoom < 1.0) target_chart_zoom = 1.0;
2290 saved_chart_zoom = target_chart_zoom;
2291 //target_chart_centre = cursor_coordinates;
2292 target_chart_focus = target_chart_centre;
2293 }
2294
2295 BOOL nextSystem = [gameView isShiftDown];
2296 BOOL nextSystemOnRoute = [gameView isOptDown];
2297
2298 if ([self checkNavKeyPress:n_key_gui_arrow_left])
2299 {
2300 if ((nextSystem || nextSystemOnRoute) && pressedArrow != 1)
2301 {
2302 if (nextSystem)
2303 {
2304 [self targetNewSystem:-1];
2305 target_chart_focus = cursor_coordinates;
2306 }
2307 else
2308 {
2309 [self clearPlanetSearchString];
2310 [self previousInfoSystem];
2311 target_chart_focus = [[UNIVERSE systemManager] getCoordinatesForSystem:info_system_id inGalaxy:galaxy_number];
2312 }
2313 pressedArrow = 1;
2314 }
2315 else if (!nextSystem && !nextSystemOnRoute)
2316 {
2317 [gameView resetTypedString];
2318 cursor_coordinates.x -= cursor_speed*delta_t;
2319 if (cursor_coordinates.x < 0.0) cursor_coordinates.x = 0.0;
2320 moving = YES;
2321 target_chart_focus = cursor_coordinates;
2322 }
2323 }
2324 else
2326
2327 if ([self checkNavKeyPress:n_key_gui_arrow_right])
2328 {
2329 if ((nextSystem || nextSystemOnRoute) && pressedArrow != 2)
2330 {
2331 if (nextSystem)
2332 {
2333 [self targetNewSystem:+1];
2334 target_chart_focus = cursor_coordinates;
2335 }
2336 else
2337 {
2338 [self clearPlanetSearchString];
2339 [self nextInfoSystem];
2340 target_chart_focus = [[UNIVERSE systemManager] getCoordinatesForSystem:info_system_id inGalaxy:galaxy_number];
2341 }
2342 pressedArrow = 2;
2343 }
2344 else if (!nextSystem && !nextSystemOnRoute)
2345 {
2346 [gameView resetTypedString];
2347 cursor_coordinates.x += cursor_speed*delta_t;
2348 if (cursor_coordinates.x > 256.0) cursor_coordinates.x = 256.0;
2349 moving = YES;
2350 target_chart_focus = cursor_coordinates;
2351 }
2352 }
2353 else
2355
2356 if ([self checkNavKeyPress:n_key_gui_arrow_down])
2357 {
2358 if (nextSystem && pressedArrow != 3)
2359 {
2360 [self targetNewSystem:+1];
2361 pressedArrow = 3;
2362 }
2363 else if (!nextSystem)
2364 {
2365 [gameView resetTypedString];
2366 cursor_coordinates.y += cursor_speed*delta_t*2.0;
2367 if (cursor_coordinates.y > 256.0) cursor_coordinates.y = 256.0;
2368 moving = YES;
2369 }
2370 target_chart_focus = cursor_coordinates;
2371 }
2372 else
2374
2375 if ([self checkNavKeyPress:n_key_gui_arrow_up])
2376 {
2377 if (nextSystem && pressedArrow != 4)
2378 {
2379 [self targetNewSystem:-1];
2380 pressedArrow = 4;
2381 }
2382 else if (!nextSystem)
2383 {
2384 [gameView resetTypedString];
2385 cursor_coordinates.y -= cursor_speed*delta_t*2.0;
2386 if (cursor_coordinates.y < 0.0) cursor_coordinates.y = 0.0;
2387 moving = YES;
2388 }
2389 target_chart_focus = cursor_coordinates;
2390 }
2391 else
2393 if ((cursor_moving)&&(!moving))
2394 {
2395 if (found_system_id == -1)
2396 {
2397 target_system_id = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxy:galaxy_number includingHidden:NO];
2398 [self setInfoSystemID: target_system_id moveChart: YES];
2399 }
2400 else
2401 {
2402 // if found with a search string, don't recalculate! Required for overlapping systems, like Divees & Tezabi in galaxy 5
2403 NSPoint fpos = [[UNIVERSE systemManager] getCoordinatesForSystem:found_system_id inGalaxy:galaxy_number];
2404 if (fpos.x != cursor_coordinates.x && fpos.y != cursor_coordinates.y)
2405 {
2406 target_system_id = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxy:galaxy_number includingHidden:NO];
2407 [self setInfoSystemID: target_system_id moveChart: YES];
2408 }
2409 }
2410 cursor_coordinates = [[UNIVERSE systemManager] getCoordinatesForSystem:target_system_id inGalaxy:galaxy_number];
2411 }
2412 if (chart_focus_coordinates.x - target_chart_centre.x <= -CHART_SCROLL_AT_X*chart_zoom)
2413 {
2414 target_chart_centre.x = chart_focus_coordinates.x + CHART_SCROLL_AT_X*chart_zoom;
2415 }
2416 else if (chart_focus_coordinates.x - target_chart_centre.x >= CHART_SCROLL_AT_X*chart_zoom)
2417 {
2418 target_chart_centre.x = chart_focus_coordinates.x - CHART_SCROLL_AT_X*chart_zoom;
2419 }
2420 if (chart_focus_coordinates.y - target_chart_centre.y <= -CHART_SCROLL_AT_Y*chart_zoom)
2421 {
2422 target_chart_centre.y = chart_focus_coordinates.y + CHART_SCROLL_AT_Y*chart_zoom;
2423 }
2424 else if (chart_focus_coordinates.y - target_chart_centre.y >= CHART_SCROLL_AT_Y*chart_zoom)
2425 {
2426 target_chart_centre.y = chart_focus_coordinates.y - CHART_SCROLL_AT_Y*chart_zoom;
2427 }
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]; // update graphics
2434 cursor_moving = moving;
2435 }
2436 break;
2437
2438 case GUI_SCREEN_SYSTEM_DATA:
2439 if ([self checkKeyPress:n_key_system_next_system])
2440 {
2442 {
2443 [self nextInfoSystem];
2445 }
2446 }
2447 else
2448 {
2450 }
2451 if ([self checkKeyPress:n_key_system_previous_system])
2452 {
2454 {
2455 [self previousInfoSystem];
2457 }
2458 }
2459 else
2460 {
2462 }
2463 if ([self checkKeyPress:n_key_system_home])
2464 {
2465 if (!home_info_pressed)
2466 {
2467 [self homeInfoSystem];
2468 home_info_pressed = YES;
2469 }
2470 }
2471 else
2472 {
2473 home_info_pressed = NO;
2474 }
2475 if ([self checkKeyPress:n_key_system_end])
2476 {
2478 {
2479 [self targetInfoSystem];
2480 target_info_pressed = YES;
2481 }
2482 }
2483 else
2484 {
2486 }
2487 break;
2488
2489#if OO_USE_CUSTOM_LOAD_SAVE
2490 // DJS: Farm off load/save screen options to LoadSave.m
2491 case GUI_SCREEN_LOAD:
2492 {
2493 NSString *commanderFile = [self commanderSelector];
2494 if(commanderFile)
2495 {
2496 // also release the demo ship here (see showShipyardModel and noteGUIDidChangeFrom)
2497 [demoShip release];
2498 demoShip = nil;
2499
2500 [self loadPlayerFromFile:commanderFile asNew:NO];
2501 }
2502 break;
2503 }
2504
2505 case GUI_SCREEN_SAVE:
2506 [self pollGuiScreenControlsWithFKeyAlias:NO];
2507 /* Only F1 works for launch on this screen, not '1' or
2508 * whatever it has been bound to */
2509 if ([self checkKeyPress:n_key_launch_ship fKey_only:YES]) [self handleUndockControl];
2510 if (gui_screen == GUI_SCREEN_SAVE)
2511 {
2512 [self saveCommanderInputHandler];
2513 }
2514 else pollControls = YES;
2515 break;
2516
2517 case GUI_SCREEN_SAVE_OVERWRITE:
2518 [self overwriteCommanderInputHandler];
2519 break;
2520#endif
2521
2522 case GUI_SCREEN_STICKMAPPER:
2523 [self handleStickMapperScreenKeys];
2524 break;
2525
2526 case GUI_SCREEN_STICKPROFILE:
2527 [self stickProfileInputHandler: gui view: gameView];
2528 break;
2529
2530 case GUI_SCREEN_GAMEOPTIONS:
2531 [self handleGameOptionsScreenKeys];
2532 break;
2533
2534 case GUI_SCREEN_KEYBOARD:
2535 [self handleKeyMapperScreenKeys];
2536 //if ([gameView isDown:' '])
2537 //{
2538 // [self setGuiToGameOptionsScreen];
2539 //}
2540 break;
2541
2542 case GUI_SCREEN_KEYBOARD_CONFIRMCLEAR:
2543 [self handleKeyMapperConfirmClearKeys:gui view:gameView];
2544 break;
2545
2546 case GUI_SCREEN_KEYBOARD_CONFIG:
2547 [self handleKeyConfigKeys:gui view:gameView];
2548 break;
2549
2550 case GUI_SCREEN_KEYBOARD_ENTRY:
2551 [self handleKeyConfigEntryKeys:gui view:gameView];
2552 break;
2553
2554 case GUI_SCREEN_KEYBOARD_LAYOUT:
2555 [self handleKeyboardLayoutKeys];
2556 break;
2557
2558 case GUI_SCREEN_SHIPLIBRARY:
2559 if ([gameView isDown:' ']) // '<space>'
2560 {
2561 // viewed in game, return to interfaces as that's where it's accessed from
2562 [self setGuiToInterfacesScreen:0];
2563 }
2564 if ([self checkKeyPress:n_key_gui_arrow_up]) // '<--'
2565 {
2566 if (!upDownKeyPressed)
2567 [UNIVERSE selectIntro2Previous];
2568 }
2569 if ([self checkKeyPress:n_key_gui_arrow_down]) // '-->'
2570 {
2571 if (!upDownKeyPressed)
2572 [UNIVERSE selectIntro2Next];
2573 }
2574 upDownKeyPressed = (([self checkKeyPress:n_key_gui_arrow_up])||([self checkKeyPress:n_key_gui_arrow_down]));
2575
2576 if ([self checkKeyPress:n_key_gui_arrow_left]) // '<--'
2577 {
2579 [UNIVERSE selectIntro2PreviousCategory];
2580 }
2581 if ([self checkKeyPress:n_key_gui_arrow_right]) // '-->'
2582 {
2584 [UNIVERSE selectIntro2NextCategory];
2585 }
2586 leftRightKeyPressed = (([self checkKeyPress:n_key_gui_arrow_left])||([self checkKeyPress:n_key_gui_arrow_right]));
2587
2588 break;
2589 case GUI_SCREEN_OPTIONS:
2590 [self handleGUIUpDownArrowKeys];
2591 OOGUIRow guiSelectedRow = [gui selectedRow];
2592 BOOL selectKeyPress = ([self checkKeyPress:n_key_gui_select]||[gameView isDown:gvMouseDoubleClick]);
2593
2594 if (selectKeyPress) // 'enter'
2595 {
2596 if ((guiSelectedRow == GUI_ROW(,QUICKSAVE))&&(!disc_operation_in_progress))
2597 {
2598 @try
2599 {
2601 [self quicksavePlayer];
2602 }
2603 @catch (NSException *exception)
2604 {
2605 OOLog(kOOLogException, @"\n\n***** Handling exception: %@ : %@ *****\n\n",[exception name], [exception reason]);
2606 if ([[exception name] isEqual:@"GameNotSavedException"]) // try saving game instead
2607 {
2608 OOLog(kOOLogException, @"%@", @"\n\n***** Trying a normal save instead *****\n\n");
2609 if ([controller inFullScreenMode])
2610 [controller pauseFullScreenModeToPerform:@selector(savePlayer) onTarget:self];
2611 else
2612 [self savePlayer];
2613 }
2614 else
2615 {
2616 @throw exception;
2617 }
2618 }
2619 }
2620 if ((guiSelectedRow == GUI_ROW(,SAVE))&&(!disc_operation_in_progress))
2621 {
2623 [self savePlayer];
2624 }
2625 if ((guiSelectedRow == GUI_ROW(,LOAD))&&(!disc_operation_in_progress))
2626 {
2628 if (![self loadPlayer])
2629 {
2631 [self setGuiToStatusScreen];
2632 }
2633 }
2634
2635
2636 if ((guiSelectedRow == GUI_ROW(,BEGIN_NEW))&&(!disc_operation_in_progress))
2637 {
2639 [UNIVERSE setUseAddOns:SCENARIO_OXP_DEFINITION_ALL fromSaveGame:NO forceReinit:YES]; // calls reinitAndShowDemo
2640 }
2641
2642 if ([gameView isDown:gvMouseDoubleClick])
2643 [gameView clearMouse];
2644 }
2645 else
2646 {
2648 }
2649
2650#if OOLITE_SDL
2651 // quit only appears in GNUstep as users aren't
2652 // used to Cmd-Q equivs. Same goes for window
2653 // vs fullscreen.
2654 if ((guiSelectedRow == GUI_ROW(,QUIT)) && selectKeyPress)
2655 {
2656 [[UNIVERSE gameController] exitAppWithContext:@"Exit Game selected on options screen"];
2657 }
2658#endif
2659
2660 if ((guiSelectedRow == GUI_ROW(,GAMEOPTIONS)) && selectKeyPress)
2661 {
2662 [gameView clearKeys];
2663 [self setGuiToGameOptionsScreen];
2664 }
2665
2666 break;
2667
2668 case GUI_SCREEN_EQUIP_SHIP:
2669 if ([self handleGUIUpDownArrowKeys])
2670 {
2671 NSString *itemText = [gui selectedRowText];
2672 OOWeaponType weaponType = nil;
2673
2674 if ([itemText isEqual:FORWARD_FACING_STRING]) weaponType = forward_weapon_type;
2675 if ([itemText isEqual:AFT_FACING_STRING]) weaponType = aft_weapon_type;
2676 if ([itemText isEqual:PORT_FACING_STRING]) weaponType = port_weapon_type;
2677 if ([itemText isEqual:STARBOARD_FACING_STRING]) weaponType = starboard_weapon_type;
2678
2679 if (weaponType != nil)
2680 {
2681 BOOL sameAs = OOWeaponTypeFromEquipmentIdentifierSloppy([gui selectedRowKey]) == weaponType;
2682 // override showInformation _completely_ with itemText
2683 if ([[weaponType identifier] isEqualToString:@"EQ_WEAPON_NONE"]) itemText = DESC(@"no-weapon-enter-to-install");
2684 else
2685 {
2686 NSString *weaponName = [[OOEquipmentType equipmentTypeWithIdentifier:OOEquipmentIdentifierFromWeaponType(weaponType)] name];
2687 if (sameAs) itemText = [NSString stringWithFormat:DESC(@"weapon-installed-@"), weaponName];
2688 else itemText = [NSString stringWithFormat:DESC(@"weapon-@-enter-to-replace"), weaponName];
2689 }
2690
2691 [self showInformationForSelectedUpgradeWithFormatString:itemText];
2692 }
2693 else
2694 [self showInformationForSelectedUpgrade];
2695 }
2696
2697 if ([self checkKeyPress:n_key_gui_arrow_left] || [self checkKeyPress:n_key_gui_page_up])
2698 {
2700 {
2701 if ([[gui keyForRow:GUI_ROW_EQUIPMENT_START] hasPrefix:@"More:"])
2702 {
2703 [self playMenuPagePrevious];
2704 [gui setSelectedRow:GUI_ROW_EQUIPMENT_START];
2705 [self buySelectedItem];
2706 }
2707 timeLastKeyPress = script_time;
2708 }
2709 }
2710 if ([self checkKeyPress:n_key_gui_arrow_right] || [self checkKeyPress:n_key_gui_page_down])
2711 {
2713 {
2714 if ([[gui keyForRow:GUI_ROW_EQUIPMENT_START + GUI_MAX_ROWS_EQUIPMENT - 1] hasPrefix:@"More:"])
2715 {
2716 [self playMenuPageNext];
2717 [gui setSelectedRow:GUI_ROW_EQUIPMENT_START + GUI_MAX_ROWS_EQUIPMENT - 1];
2718 [self buySelectedItem];
2719 }
2720 timeLastKeyPress = script_time;
2721 }
2722 }
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];
2724
2725 if ([self checkKeyPress:n_key_gui_select] || [gameView isDown:gvMouseDoubleClick])
2726 {
2727 if ([gameView isDown:gvMouseDoubleClick])
2728 {
2729 selectPressed = NO;
2730 [gameView clearMouse];
2731 }
2732 if ((!selectPressed)&&([gui selectedRow] > -1))
2733 {
2734 [self buySelectedItem];
2735 selectPressed = YES;
2736 }
2737 }
2738 else
2739 {
2740 selectPressed = NO;
2741 }
2742 break;
2743
2744 case GUI_SCREEN_INTERFACES:
2745 if ([self handleGUIUpDownArrowKeys])
2746 {
2747 [self showInformationForSelectedInterface];
2748 }
2749 if ([self checkKeyPress:n_key_gui_arrow_left] || [self checkKeyPress:n_key_gui_page_up])
2750 {
2752 {
2753 if ([[gui keyForRow:GUI_ROW_INTERFACES_START] hasPrefix:@"More:"])
2754 {
2755 [self playMenuPagePrevious];
2756 [gui setSelectedRow:GUI_ROW_INTERFACES_START];
2757 [self activateSelectedInterface];
2758 }
2759 timeLastKeyPress = script_time;
2760 }
2761 }
2762 if ([self checkKeyPress:n_key_gui_arrow_right] || [self checkKeyPress:n_key_gui_page_down])
2763 {
2765 {
2766 if ([[gui keyForRow:GUI_ROW_INTERFACES_START + GUI_MAX_ROWS_INTERFACES - 1] hasPrefix:@"More:"])
2767 {
2768 [self playMenuPageNext];
2769 [gui setSelectedRow:GUI_ROW_INTERFACES_START + GUI_MAX_ROWS_INTERFACES - 1];
2770 [self activateSelectedInterface];
2771 }
2772 timeLastKeyPress = script_time;
2773 }
2774 }
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];
2776 if ([self checkKeyPress:n_key_gui_select] || [gameView isDown:gvMouseDoubleClick]) // 'enter'
2777 {
2778 if ([gameView isDown:gvMouseDoubleClick])
2779 {
2780 selectPressed = NO;
2781 [gameView clearMouse];
2782 }
2783 if ((!selectPressed)&&([gui selectedRow] > -1))
2784 {
2785 [self activateSelectedInterface];
2786 selectPressed = YES;
2787 }
2788 }
2789 else
2790 {
2791 selectPressed = NO;
2792 }
2793 break;
2794
2795
2796 case GUI_SCREEN_MARKETINFO:
2797 [self pollMarketScreenControls];
2798 break;
2799
2800 case GUI_SCREEN_MARKET:
2801 [self pollMarketScreenControls];
2802
2803 if ([self checkKeyPress:n_key_market_filter_cycle] || [self checkKeyPress:n_key_market_sorter_cycle])
2804 {
2805 if (!queryPressed)
2806 {
2807 queryPressed = YES;
2808 if ([self checkKeyPress:n_key_market_filter_cycle])
2809 {
2810 if (marketFilterMode >= MARKET_FILTER_MODE_MAX)
2811 {
2812 marketFilterMode = MARKET_FILTER_MODE_OFF;
2813 }
2814 else
2815 {
2816 marketFilterMode++;
2817 }
2818 }
2819 else
2820 {
2821 if (marketSorterMode >= MARKET_SORTER_MODE_MAX)
2822 {
2823 marketSorterMode = MARKET_SORTER_MODE_OFF;
2824 }
2825 else
2826 {
2827 marketSorterMode++;
2828 }
2829 }
2830 [self playChangedOption];
2831 [self setGuiToMarketScreen];
2832 }
2833 }
2834 else
2835 {
2836 queryPressed = NO;
2837 }
2838
2839 break;
2840
2841 case GUI_SCREEN_REPORT:
2842 if ([gameView isDown:32]) // spacebar
2843 {
2844 if (!spacePressed)
2845 {
2846 BOOL reportEnded = ([dockingReport length] == 0);
2847 [self playDismissedReportScreen];
2848 if(reportEnded)
2849 {
2850 [self setGuiToStatusScreen];
2851 [self doScriptEvent:OOJSID("reportScreenEnded")]; // last report given. Screen is now free for missionscreens.
2852 [self doWorldEventUntilMissionScreen:OOJSID("missionScreenOpportunity")];
2853 }
2854 else
2855 {
2856 [self setGuiToDockingReportScreen];
2857 }
2858
2859 }
2860 spacePressed = YES;
2861 }
2862 else
2863 spacePressed = NO;
2864 break;
2865 case GUI_SCREEN_STATUS:
2866 [self handleGUIUpDownArrowKeys];
2867 if ([self checkKeyPress:n_key_gui_arrow_left] || [self checkKeyPress:n_key_gui_page_up])
2868 {
2869
2871 {
2872 if ([[gui keyForRow:STATUS_EQUIPMENT_FIRST_ROW] isEqual:GUI_KEY_OK])
2873 {
2874 [gui setSelectedRow:STATUS_EQUIPMENT_FIRST_ROW];
2875 [self playMenuPagePrevious];
2876 [gui setStatusPage:-1];
2877 [self setGuiToStatusScreen];
2878 }
2879 timeLastKeyPress = script_time;
2880 }
2881 }
2882 if ([self checkKeyPress:n_key_gui_arrow_right] || [self checkKeyPress:n_key_gui_page_down])
2883 {
2884
2886 {
2887 NSUInteger maxRows = [[self hud] allowBigGui] ? STATUS_EQUIPMENT_MAX_ROWS + STATUS_EQUIPMENT_BIGGUI_EXTRA_ROWS : STATUS_EQUIPMENT_MAX_ROWS;
2888 if ([[gui keyForRow:STATUS_EQUIPMENT_FIRST_ROW + maxRows] isEqual:GUI_KEY_OK])
2889 {
2890 [gui setSelectedRow:STATUS_EQUIPMENT_FIRST_ROW + maxRows];
2891 [self playMenuPageNext];
2892 [gui setStatusPage:+1];
2893 [self setGuiToStatusScreen];
2894 }
2895 timeLastKeyPress = script_time;
2896 }
2897 }
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];
2899
2900 if ([self checkKeyPress:n_key_gui_select] || [gameView isDown:gvMouseDoubleClick])
2901 {
2902 if ([gameView isDown:gvMouseDoubleClick])
2903 {
2904 selectPressed = NO;
2905 [gameView clearMouse];
2906 }
2907 if ((!selectPressed)&&([gui selectedRow] > -1))
2908 {
2909 [gui setStatusPage:([gui selectedRow] == STATUS_EQUIPMENT_FIRST_ROW ? -1 : +1)];
2910 [self setGuiToStatusScreen];
2911
2912 selectPressed = YES;
2913 }
2914 }
2915 else
2916 {
2917 selectPressed = NO;
2918 }
2919
2920 break;
2921 case GUI_SCREEN_MANIFEST:
2922 [self handleGUIUpDownArrowKeys];
2923 if ([self checkKeyPress:n_key_gui_arrow_left] || [self checkKeyPress:n_key_gui_page_up])
2924 {
2925
2927 {
2928 if ([[gui keyForRow:MANIFEST_SCREEN_ROW_BACK] isEqual:GUI_KEY_OK])
2929 {
2930 [gui setSelectedRow:MANIFEST_SCREEN_ROW_BACK];
2931 [self playMenuPagePrevious];
2932 [gui setStatusPage:-1];
2933 [self setGuiToManifestScreen];
2934 }
2935 timeLastKeyPress = script_time;
2936 }
2937 }
2938 if ([self checkKeyPress:n_key_gui_arrow_right] || [self checkKeyPress:n_key_gui_page_down])
2939 {
2941 if ([[self hud] isHidden] || [[self hud] allowBigGui])
2942 {
2943 nextRow += 7;
2944 }
2946 {
2947 if ([[gui keyForRow:nextRow] isEqual:GUI_KEY_OK])
2948 {
2949 [gui setSelectedRow:nextRow];
2950 [self playMenuPageNext];
2951 [gui setStatusPage:+1];
2952 [self setGuiToManifestScreen];
2953 }
2954 timeLastKeyPress = script_time;
2955 }
2956 }
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];
2958
2959 if ([self checkKeyPress:n_key_gui_select] || [gameView isDown:gvMouseDoubleClick])
2960 {
2961 if ([gameView isDown:gvMouseDoubleClick])
2962 {
2963 selectPressed = NO;
2964 [gameView clearMouse];
2965 }
2966 if ((!selectPressed)&&([gui selectedRow] > -1))
2967 {
2968 [gui setStatusPage:([gui selectedRow] == MANIFEST_SCREEN_ROW_BACK ? -1 : +1)];
2969 [self setGuiToManifestScreen];
2970
2971 selectPressed = YES;
2972 }
2973 }
2974 else
2975 {
2976 selectPressed = NO;
2977 }
2978
2979 break;
2980
2981 case GUI_SCREEN_SHIPYARD:
2982 if ([self handleGUIUpDownArrowKeys])
2983 {
2984 [self showShipyardInfoForSelection];
2985 }
2986
2987 if ([self checkKeyPress:n_key_gui_arrow_left] || [self checkKeyPress:n_key_gui_page_up])
2988 {
2990 {
2991 if ([[gui keyForRow:GUI_ROW_SHIPYARD_START] hasPrefix:@"More:"])
2992 {
2993 [self playMenuPagePrevious];
2994 [gui setSelectedRow:GUI_ROW_SHIPYARD_START];
2995 [self buySelectedShip];
2996 }
2997 timeLastKeyPress = script_time;
2998 }
2999 }
3000 if ([self checkKeyPress:n_key_gui_arrow_right] || [self checkKeyPress:n_key_gui_page_down])
3001 {
3003 {
3004 if ([[gui keyForRow:GUI_ROW_SHIPYARD_START + MAX_ROWS_SHIPS_FOR_SALE - 1] hasPrefix:@"More:"])
3005 {
3006 [self playMenuPageNext];
3007 [gui setSelectedRow:GUI_ROW_SHIPYARD_START + MAX_ROWS_SHIPS_FOR_SALE - 1];
3008 [self buySelectedShip];
3009 }
3010 timeLastKeyPress = script_time;
3011 }
3012 }
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];
3014
3015 if ([self checkKeyPress:n_key_gui_select]) // 'enter' NOT double-click
3016 {
3017 if (!selectPressed)
3018 {
3019 // try to buy the ship!
3020 NSString *key = [gui keyForRow:[gui selectedRow]];
3021 OOCreditsQuantity shipprice = 0;
3022 if (![key hasPrefix:@"More:"])
3023 {
3024 shipprice = [self priceForShipKey:key];
3025 }
3026
3027 if ([self buySelectedShip])
3028 {
3029 if (![key hasPrefix:@"More:"]) // don't do anything if we clicked/selected a "More:" line
3030 {
3031 [UNIVERSE removeDemoShips];
3032 [self setGuiToStatusScreen];
3033 [self playBuyShip];
3034 [self doScriptEvent:OOJSID("playerBoughtNewShip") withArgument:self andArgument:[NSNumber numberWithUnsignedLongLong:shipprice]]; // some equipment.oxp might want to know everything has changed.
3035 }
3036 }
3037 else
3038 {
3039 [self playCantBuyShip];
3040 }
3041 }
3042 selectPressed = YES;
3043 }
3044 else
3045 {
3046 selectPressed = NO;
3047 }
3048 if ([gameView isDown:gvMouseDoubleClick])
3049 {
3050 if (([gui selectedRow] == GUI_ROW_SHIPYARD_START + MAX_ROWS_SHIPS_FOR_SALE - 1) && [[gui keyForRow:GUI_ROW_SHIPYARD_START + MAX_ROWS_SHIPS_FOR_SALE - 1] hasPrefix:@"More:"])
3051 {
3052 [self playMenuPageNext];
3053 [gui setSelectedRow:GUI_ROW_SHIPYARD_START + MAX_ROWS_SHIPS_FOR_SALE - 1];
3054 [self buySelectedShip];
3055 }
3056 else if (([gui selectedRow] == GUI_ROW_SHIPYARD_START) && [[gui keyForRow:GUI_ROW_SHIPYARD_START] hasPrefix:@"More:"])
3057 {
3058 [self playMenuPagePrevious];
3059 [gui setSelectedRow:GUI_ROW_SHIPYARD_START];
3060 [self buySelectedShip];
3061 }
3062 [gameView clearMouse];
3063 }
3064
3065 break;
3066
3067 default:
3068 break;
3069 }
3070
3071 // check for any extra keys added by scripting
3072 NSArray *keys = [extraGuiScreenKeys objectForKey:[NSString stringWithFormat:@"%d", gui_screen]];
3073 if (keys) {
3074 NSInteger kc = [keys count];
3075 OOJSGuiScreenKeyDefinition *definition = nil;
3076 NSDictionary *keydefs = nil;
3077 NSString *key = nil;
3078 while (kc--) {
3079 definition = [keys objectAtIndex:kc];
3080 keydefs = [definition registerKeys];
3081 foreach (key, [keydefs allKeys])
3082 {
3083 if ([self checkKeyPress:[keydefs objectForKey:key]])
3084 {
3086 {
3087 // do callback
3088 if (definition)
3089 {
3090 [[UNIVERSE gameView] clearKeys];
3091 [definition runCallback:key];
3092 }
3093 else
3094 {
3095 OOLog(@"interface.missingCallback", @"Unable to find callback definition for %@ using key %@", [definition name], key);
3096 }
3097 }
3099 }
3100 else
3102 }
3103 }
3104 }
3105
3106 // damp any rotations we entered with
3107 if (flightRoll > 0.0)
3108 {
3109 if (flightRoll > delta_t) [self decrease_flight_roll:delta_t];
3110 else flightRoll = 0.0;
3111 }
3112 if (flightRoll < 0.0)
3113 {
3114 if (flightRoll < -delta_t) [self increase_flight_roll:delta_t];
3115 else flightRoll = 0.0;
3116 }
3117 if (flightPitch > 0.0)
3118 {
3119 if (flightPitch > delta_t) [self decrease_flight_pitch:delta_t];
3120 else flightPitch = 0.0;
3121 }
3122 if (flightPitch < 0.0)
3123 {
3124 if (flightPitch < -delta_t) [self increase_flight_pitch:delta_t];
3125 else flightPitch = 0.0;
3126 }
3127 if (flightYaw > 0.0)
3128 {
3129 if (flightYaw > delta_t) [self decrease_flight_yaw:delta_t];
3130 else flightYaw = 0.0;
3131 }
3132 if (flightYaw < 0.0)
3133 {
3134 if (flightYaw < -delta_t) [self increase_flight_yaw:delta_t];
3135 else flightYaw = 0.0;
3136 }
3137}
@ gvDeleteKey
#define GUI_KEY_OK
#define MAIN_GUI_PIXEL_WIDTH
#define MAIN_GUI_PIXEL_HEIGHT
OOLongRangeChartMode
Definition OOTypes.h:50
@ OPTIMIZED_BY_NONE
Definition OOTypes.h:34
@ OPTIMIZED_BY_JUMPS
Definition OOTypes.h:35
@ OPTIMIZED_BY_TIME
Definition OOTypes.h:36
uint64_t OOCreditsQuantity
Definition OOTypes.h:182
#define MAX_ROWS_SHIPS_FOR_SALE
#define GUI_ROW_SHIPYARD_START
static BOOL extra_gui_key_pressed
static NSPoint centre_at_mouse_click
static BOOL chartInfoPressed
static BOOL next_planet_info_pressed
static int pressedArrow
static BOOL target_info_pressed
static BOOL home_info_pressed
static BOOL previous_planet_info_pressed
static BOOL mouse_left_down
static BOOL queryPressed
static BOOL pling_pressed
static NSUInteger searchStringLength
static NSPoint mouse_click_position
static BOOL cursor_moving
#define CHART_SCREEN_VERTICAL_CENTRE
@ STATUS_EQUIPMENT_FIRST_ROW
@ STATUS_EQUIPMENT_MAX_ROWS
@ GUI_MAX_ROWS_EQUIPMENT
@ GUI_ROW_EQUIPMENT_START
@ STATUS_EQUIPMENT_BIGGUI_EXTRA_ROWS
@ GUI_ROW_INTERFACES_START
@ GUI_MAX_ROWS_INTERFACES
#define PORT_FACING_STRING
@ MARKET_FILTER_MODE_MAX
@ MARKET_FILTER_MODE_OFF
#define CHART_ZOOM_SHOW_LABELS
#define CHART_MAX_ZOOM
#define MANIFEST_SCREEN_ROW_BACK
#define FORWARD_FACING_STRING
#define AFT_FACING_STRING
#define CHART_ZOOM_SPEED_FACTOR
#define MANIFEST_SCREEN_ROW_NEXT
#define STARBOARD_FACING_STRING
#define CHART_SCROLL_AT_Y
#define CHART_SCROLL_AT_X
@ MARKET_SORTER_MODE_OFF
@ MARKET_SORTER_MODE_MAX
OOWeaponType OOWeaponTypeFromEquipmentIdentifierSloppy(NSString *string) PURE_FUNC
void setStatusPage:(NSInteger pageNum)
NSString * selectedRowText()
void resetTypedString()

◆ pollGuiScreenControls

- (void) pollGuiScreenControls

Definition at line 164 of file PlayerEntityControls.m.

4556{
4557 [self pollGuiScreenControlsWithFKeyAlias:YES];
4558}

◆ pollGuiScreenControlsWithFKeyAlias:

- (void) pollGuiScreenControlsWithFKeyAlias: (BOOL)  fKeyAlias

Definition at line 164 of file PlayerEntityControls.m.

4561 :(BOOL)fKeyAlias
4562{
4563 if(!pollControls && fKeyAlias) // Still OK to run, if we don't use number keys.
4564 return;
4565
4566 GuiDisplayGen *gui = [UNIVERSE gui];
4567 MyOpenGLView *gameView = [UNIVERSE gameView];
4568 BOOL docked_okay = ([self status] == STATUS_DOCKED);
4569
4570 // text displays
4571 if ([self checkKeyPress:n_key_gui_screen_status fKey_only:!fKeyAlias])
4572 {
4574 {
4576 if (gui_screen == GUI_SCREEN_STATUS)
4577 {
4578 [self noteGUIWillChangeTo:GUI_SCREEN_MANIFEST];
4579 [self setGuiToManifestScreen];
4580 }
4581 else
4582 [self setGuiToStatusScreen];
4583 [self checkScript];
4584 }
4585 }
4586 else
4587 {
4589 }
4590
4591 if ([self checkKeyPress:n_key_gui_chart_screens fKey_only:!fKeyAlias])
4592 {
4593 mouse_left_down = NO;
4594 [gameView clearMouse];
4596 {
4598 // handles http://aegidian.org/bb/viewtopic.php?p=233189#p233189
4599 if (EXPECT_NOT([self status] == STATUS_WITCHSPACE_COUNTDOWN && gui_screen == GUI_SCREEN_SHORT_RANGE_CHART))
4600 {
4601 // don't switch to LRC if countdown in progress
4603 }
4604 else if (gui_screen == GUI_SCREEN_SHORT_RANGE_CHART || (gui_screen == GUI_SCREEN_SYSTEM_DATA && showingLongRangeChart))
4605 {
4606 if (target_chart_zoom != CHART_MAX_ZOOM)
4607 {
4608 saved_chart_zoom = target_chart_zoom;
4609 }
4610 target_chart_zoom = CHART_MAX_ZOOM;
4611 [self noteGUIWillChangeTo:GUI_SCREEN_LONG_RANGE_CHART];
4612 [self setGuiToLongRangeChartScreen];
4613 }
4614 else
4615 {
4616 if (target_chart_zoom == CHART_MAX_ZOOM)
4617 {
4618 target_chart_zoom = saved_chart_zoom;
4619 }
4620 //target_chart_centre = cursor_coordinates = [[UNIVERSE systemManager] getCoordinatesForSystem:target_system_id inGalaxy:galaxy_number];
4621 [self noteGUIWillChangeTo:GUI_SCREEN_SHORT_RANGE_CHART];
4622 [self setGuiToShortRangeChartScreen];
4623 }
4624 }
4625 }
4626 else
4627 {
4629 }
4630
4631 if ([self checkKeyPress:n_key_gui_system_data fKey_only:!fKeyAlias])
4632 {
4633 if (gui_screen != GUI_SCREEN_SYSTEM_DATA)
4634 {
4635 showingLongRangeChart = (gui_screen == GUI_SCREEN_LONG_RANGE_CHART);
4636 [self noteGUIWillChangeTo:GUI_SCREEN_SYSTEM_DATA];
4637 [self setGuiToSystemDataScreen];
4638 }
4639 }
4640
4641 if ([self checkKeyPress:n_key_gui_market fKey_only:!fKeyAlias])
4642 {
4643 if (gui_screen != GUI_SCREEN_MARKET)
4644 {
4645 [gameView clearKeys];
4646 [gui setNoSelectedRow];
4647 [self noteGUIWillChangeTo:GUI_SCREEN_MARKET];
4648 [self setGuiToMarketScreen];
4649 }
4650 else
4651 {
4652 [gameView clearKeys];
4653 [gui setNoSelectedRow];
4654 [self noteGUIWillChangeTo:GUI_SCREEN_MARKETINFO];
4655 [self setGuiToMarketInfoScreen];
4656 }
4657 }
4658
4659
4660 if (docked_okay)
4661 {
4662 if (([self checkKeyPress:n_key_gui_screen_options fKey_only:!fKeyAlias]) && (gui_screen != GUI_SCREEN_OPTIONS))
4663 {
4664 [gameView clearKeys];
4665 [self setGuiToLoadSaveScreen];
4666 }
4667
4668 if ([self checkKeyPress:n_key_gui_screen_equipship fKey_only:!fKeyAlias])
4669 {
4671 {
4672 if ([self dockedStation] == nil) [self setDockedAtMainStation];
4673 OOGUIScreenID oldScreen = gui_screen;
4674
4675 if ((gui_screen == GUI_SCREEN_EQUIP_SHIP) && [[self dockedStation] hasShipyard])
4676 {
4677 [gameView clearKeys];
4678 [self noteGUIWillChangeTo:GUI_SCREEN_SHIPYARD];
4679 [gui setNoSelectedRow];
4680 [self setGuiToShipyardScreen:0];
4681 [gui setSelectedRow:GUI_ROW_SHIPYARD_START];
4682 [self showShipyardInfoForSelection];
4683 }
4684 else
4685 {
4686 [gameView clearKeys];
4687 [self noteGUIWillChangeTo:GUI_SCREEN_EQUIP_SHIP];
4688 [gui setNoSelectedRow];
4689 [self setGuiToEquipShipScreen:0];
4690 [gui setSelectedRow:GUI_ROW_EQUIPMENT_START];
4691 }
4692
4693 [self noteGUIDidChangeFrom:oldScreen to:gui_screen];
4694 }
4696 }
4697 else
4698 {
4700 }
4701
4702 if ([self checkKeyPress:n_key_gui_screen_interfaces fKey_only:!fKeyAlias])
4703 {
4705 [gui setNoSelectedRow];
4706 [self setGuiToInterfacesScreen:0];
4707 [gui setSelectedRow:GUI_ROW_INTERFACES_START];
4708 }
4710 }
4711 else
4712 {
4714 }
4715
4716 }
4717}
#define EXPECT_NOT(x)
static BOOL switching_interface_screens
static BOOL switching_chart_screens
static BOOL switching_equipship_screens
static BOOL switching_status_screens
OOGUIScreenID

◆ pollMarketScreenControls

- (void) pollMarketScreenControls

Definition at line 164 of file PlayerEntityControls.m.

3141{
3142 MyOpenGLView *gameView = [UNIVERSE gameView];
3143 GuiDisplayGen *gui = [UNIVERSE gui];
3144
3145 if (gui_screen == GUI_SCREEN_MARKET)
3146 {
3147 [self handleGUIUpDownArrowKeys];
3148 DESTROY(marketSelectedCommodity);
3149 marketSelectedCommodity = [[gui selectedRowKey] retain];
3150
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)
3154 {
3155 if ((!pageUpDownKeyPressed) || (script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
3156 {
3157 OOCommodityMarket *localMarket = [self localMarket];
3158 NSArray *goods = [self applyMarketSorter:[self applyMarketFilter:[localMarket goods] onMarket:localMarket] onMarket:localMarket];
3159 if ([goods count] > 0)
3160 {
3161 NSInteger goodsIndex = [goods indexOfObject:marketSelectedCommodity];
3162 NSInteger offset1 = 0;
3163 NSInteger offset2 = 0;
3164 if ([[gui keyForRow:GUI_ROW_MARKET_START] isEqualToString:@"<<<"] == true) offset1 += 1;
3165 if ([[gui keyForRow:GUI_ROW_MARKET_LAST] isEqualToString:@">>>"] == true) offset2 += 1;
3166 if (page_up)
3167 {
3168 [self playMenuPagePrevious];
3169 // some edge cases
3170 if (goodsIndex - 16 <= 0)
3171 {
3172 offset1 = 0;
3173 offset2 = 0;
3174 }
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;
3179 }
3180 if (page_down)
3181 {
3182 [self playMenuPageNext];
3183 // some edge cases
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;
3188 }
3189 DESTROY(marketSelectedCommodity);
3190 marketSelectedCommodity = [[goods oo_stringAtIndex:goodsIndex] retain];
3191 [self setGuiToMarketScreen];
3192 }
3193 }
3195 timeLastKeyPress = script_time;
3196 }
3197 else {
3199 }
3200 }
3201 else
3202 {
3203 // handle up and down slightly differently
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)
3207 {
3208 if ((!upDownKeyPressed) || (script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
3209 {
3210 OOCommodityMarket *localMarket = [self localMarket];
3211 NSArray *goods = [self applyMarketSorter:[self applyMarketFilter:[localMarket goods] onMarket:localMarket] onMarket:localMarket];
3212 if ([goods count] > 0)
3213 {
3214 NSInteger goodsIndex = [goods indexOfObject:marketSelectedCommodity];
3215 if (arrow_down)
3216 {
3217 ++goodsIndex;
3218 }
3219 else
3220 {
3221 --goodsIndex;
3222 }
3223 if (goodsIndex < 0)
3224 {
3225 goodsIndex = [goods count]-1;
3226 }
3227 else if (goodsIndex >= (NSInteger)[goods count])
3228 {
3229 goodsIndex = 0;
3230 }
3231 DESTROY(marketSelectedCommodity);
3232 marketSelectedCommodity = [[goods oo_stringAtIndex:goodsIndex] retain];
3233 [self setGuiToMarketInfoScreen];
3234 }
3235 }
3236 upDownKeyPressed = YES;
3237 timeLastKeyPress = script_time;
3238 }
3239 else
3240 {
3241 upDownKeyPressed = NO;
3242 }
3243 }
3244
3245 BOOL isdocked = [self isDocked];
3246
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]))
3248 {
3249 if ([self checkNavKeyPress:n_key_gui_arrow_right]) // -->
3250 {
3251 if (!wait_for_key_up)
3252 {
3253 if (isdocked && [self tryBuyingCommodity:marketSelectedCommodity all:[gameView isShiftDown]])
3254 {
3255 [self playBuyCommodity];
3256 if (gui_screen == GUI_SCREEN_MARKET)
3257 {
3258 [self setGuiToMarketScreen];
3259 }
3260 else
3261 {
3262 [self setGuiToMarketInfoScreen];
3263 }
3264 }
3265 else
3266 {
3267 if ([[gui selectedRowKey] isEqualToString:@">>>"])
3268 {
3269 [self playMenuNavigationDown];
3270 [self setGuiToMarketScreen];
3271 }
3272 else if ([[gui selectedRowKey] isEqualToString:@"<<<"])
3273 {
3274 [self playMenuNavigationUp];
3275 [self setGuiToMarketScreen];
3276 }
3277 else
3278 {
3279 [self playCantBuyCommodity];
3280 }
3281 }
3282 wait_for_key_up = YES;
3283 }
3284 }
3285 if ([self checkNavKeyPress:n_key_gui_arrow_left]) // <--
3286 {
3287 if (!wait_for_key_up)
3288 {
3289 if (isdocked && [self trySellingCommodity:marketSelectedCommodity all:[gameView isShiftDown]])
3290 {
3291 [self playSellCommodity];
3292 if (gui_screen == GUI_SCREEN_MARKET)
3293 {
3294 [self setGuiToMarketScreen];
3295 }
3296 else
3297 {
3298 [self setGuiToMarketInfoScreen];
3299 }
3300 }
3301 else
3302 {
3303 if ([[gui selectedRowKey] isEqualToString:@">>>"])
3304 {
3305 [self playMenuNavigationDown];
3306 [self setGuiToMarketScreen];
3307 }
3308 else if ([[gui selectedRowKey] isEqualToString:@"<<<"])
3309 {
3310 [self playMenuNavigationUp];
3311 [self setGuiToMarketScreen];
3312 }
3313 else
3314 {
3315 [self playCantSellCommodity];
3316 }
3317
3318 }
3319 wait_for_key_up = YES;
3320 }
3321 }
3322 if ((gui_screen == GUI_SCREEN_MARKET && [gameView isDown:gvMouseDoubleClick]) || [self checkKeyPress:n_key_gui_select]) // 'enter'
3323 {
3324 if ([gameView isDown:gvMouseDoubleClick])
3325 {
3326 wait_for_key_up = NO;
3327 [gameView clearMouse];
3328 }
3329 if (!wait_for_key_up)
3330 {
3331 OOCommodityType item = marketSelectedCommodity;
3332 OOCargoQuantity yours = [shipCommodityData quantityForGood:item];
3333 if ([item isEqualToString:@">>>"])
3334 {
3335 [self tryBuyingCommodity:item all:YES];
3336 [self setGuiToMarketScreen];
3337 }
3338 else if ([item isEqualToString:@"<<<"])
3339 {
3340 [self trySellingCommodity:item all:YES];
3341 [self setGuiToMarketScreen];
3342 }
3343 else if (isdocked && [gameView isShiftDown] && [self tryBuyingCommodity:item all:YES]) // buy as much as possible (with Shift)
3344 {
3345 [self playBuyCommodity];
3346 if (gui_screen == GUI_SCREEN_MARKET)
3347 {
3348 [self setGuiToMarketScreen];
3349 }
3350 else
3351 {
3352 [self setGuiToMarketInfoScreen];
3353 }
3354 }
3355 else if (isdocked && (yours > 0) && [self trySellingCommodity:item all:YES]) // sell all you can
3356 {
3357 [self playSellCommodity];
3358 if (gui_screen == GUI_SCREEN_MARKET)
3359 {
3360 [self setGuiToMarketScreen];
3361 }
3362 else
3363 {
3364 [self setGuiToMarketInfoScreen];
3365 }
3366 }
3367 else if (isdocked && [self tryBuyingCommodity:item all:YES]) // buy as much as possible
3368 {
3369 [self playBuyCommodity];
3370 if (gui_screen == GUI_SCREEN_MARKET)
3371 {
3372 [self setGuiToMarketScreen];
3373 }
3374 else
3375 {
3376 [self setGuiToMarketInfoScreen];
3377 }
3378 }
3379 else if (isdocked)
3380 {
3381 [self playCantBuyCommodity];
3382 }
3383 wait_for_key_up = YES;
3384 }
3385 }
3386 }
3387 else
3388 {
3389 wait_for_key_up = NO;
3390 }
3391
3392
3393
3394
3395}
NSString * OOCommodityType
Definition OOTypes.h:106
uint32_t OOCargoQuantity
Definition OOTypes.h:176
static BOOL wait_for_key_up
@ GUI_ROW_MARKET_START
@ GUI_ROW_MARKET_LAST

◆ pollMissionInterruptControls

- (void) pollMissionInterruptControls

Definition at line 4739 of file PlayerEntityControls.m.

5320{
5321 if (_missionAllowInterrupt)
5322 {
5323 if (gui_screen == GUI_SCREEN_MISSION && _missionTextEntry)
5324 {
5325 [self pollGuiScreenControlsWithFKeyAlias:NO];
5326 }
5327 else {
5328 [self pollGuiScreenControls];
5329 }
5330 if (gui_screen != GUI_SCREEN_MISSION)
5331 {
5332 if (gui_screen != GUI_SCREEN_SYSTEM_DATA)
5333 {
5334 [UNIVERSE removeDemoShips];
5335 }
5336 [self endMissionScreenAndNoteOpportunity];
5337 }
5338 }
5339}

◆ pollViewControls

- (void) pollViewControls

Definition at line 164 of file PlayerEntityControls.m.

4159{
4160 if(!pollControls)
4161 return;
4162
4163 MyOpenGLView *gameView = [UNIVERSE gameView];
4165
4166 NSPoint virtualView = NSZeroPoint;
4167 double view_threshold = 0.5;
4168
4169 if ([stickHandler joystickCount])
4170 {
4171 virtualView = [stickHandler viewAxis];
4172 if (virtualView.y == STICK_AXISUNASSIGNED)
4173 virtualView.y = 0.0;
4174 if (virtualView.x == STICK_AXISUNASSIGNED)
4175 virtualView.x = 0.0;
4176 if (fabs(virtualView.y) >= fabs(virtualView.x))
4177 virtualView.x = 0.0; // forward/aft takes precedence
4178 else
4179 virtualView.y = 0.0;
4180 }
4181
4182 const BOOL *joyButtonState = [stickHandler getAllButtonStates];
4183
4184 // view keys
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]))
4186 {
4187 [self switchToThisView:VIEW_FORWARD];
4188 }
4189 if (([self checkKeyPress:n_key_view_aft])||(virtualView.y > view_threshold)||joyButtonState[BUTTON_VIEWAFT])
4190 {
4191 [self switchToThisView:VIEW_AFT];
4192 }
4193 if (([self checkKeyPress:n_key_view_port])||(virtualView.x < -view_threshold)||joyButtonState[BUTTON_VIEWPORT])
4194 {
4195 [self switchToThisView:VIEW_PORT];
4196 }
4197 if (([self checkKeyPress:n_key_view_starboard])||(virtualView.x > view_threshold)||joyButtonState[BUTTON_VIEWSTARBOARD])
4198 {
4199 [self switchToThisView:VIEW_STARBOARD];
4200 }
4201
4202 [self pollCustomViewControls];
4203
4204 // Zoom scanner 'z'
4205 if (([self checkKeyPress:n_key_scanner_zoom] && ([gameView allowingStringInput] == gvStringInputNo)) || joyButtonState[BUTTON_SCANNERZOOM]) // look for the 'z' key
4206 {
4207 if (!scanner_zoom_rate)
4208 {
4209 if ([hud scannerZoom] < 5.0)
4210 {
4211 if (([hud scannerZoom] > 1.0)||(!zoom_pressed))
4212 scanner_zoom_rate = SCANNER_ZOOM_RATE_UP;
4213 }
4214 else
4215 {
4216 if (!zoom_pressed) // must release and re-press zoom to zoom back down..
4217 scanner_zoom_rate = SCANNER_ZOOM_RATE_DOWN;
4218 }
4219 }
4220 zoom_pressed = YES;
4221 }
4222 else
4223 zoom_pressed = NO;
4224
4225 // Unzoom scanner 'Z'
4226 if (([self checkKeyPress:n_key_scanner_unzoom] && ([gameView allowingStringInput] == gvStringInputNo)) || joyButtonState[BUTTON_SCANNERUNZOOM]) // look for the 'Z' key
4227 {
4228 if ((!scanner_zoom_rate)&&([hud scannerZoom] > 1.0))
4229 scanner_zoom_rate = SCANNER_ZOOM_RATE_DOWN;
4230 }
4231
4232 if (EXPECT([[self hud] isCompassActive])) // only switch compass modes if there is a compass
4233 {
4234 // Compass mode '|'
4235 if ([self checkKeyPress:n_key_prev_compass_mode] || joyButtonState[BUTTON_COMPASSMODE_PREV]) // look for the '|' key
4236 {
4237 if ((!prev_compass_mode_pressed)&&(compassMode != COMPASS_MODE_BASIC))
4238 [self setPrevCompassMode];
4240 }
4241 else
4242 {
4244 }
4245 // Compass mode '\'
4246 if ([self checkKeyPress:n_key_next_compass_mode] || joyButtonState[BUTTON_COMPASSMODE]) // look for the '\' key
4247 {
4248 if ((!next_compass_mode_pressed)&&(compassMode != COMPASS_MODE_BASIC))
4249 [self setNextCompassMode];
4251 }
4252 else
4253 {
4255 }
4256 }
4257
4258 // ';' // Cycle active MFD
4259 if ([self checkKeyPress:n_key_cycle_next_mfd] || [self checkKeyPress:n_key_cycle_previous_mfd] || joyButtonState[BUTTON_MFDCYCLENEXT] || joyButtonState[BUTTON_MFDCYCLEPREV])
4260 {
4261 if (!cycleMFD_pressed)
4262 {
4263 //if (![gameView isCtrlDown])
4264 if (![self checkKeyPress:n_key_cycle_previous_mfd] || joyButtonState[BUTTON_MFDCYCLEPREV])
4265 {
4266 [self cycleNextMultiFunctionDisplay:activeMFD];
4267 }
4268 else
4269 {
4270 [self cyclePreviousMultiFunctionDisplay:activeMFD];
4271 }
4272 }
4273 cycleMFD_pressed = YES;
4274 }
4275 else
4276 {
4277 cycleMFD_pressed = NO;
4278 }
4279
4280 // ':' // Select next MFD
4281 if ([self checkKeyPress:n_key_switch_next_mfd] || [self checkKeyPress:n_key_switch_previous_mfd] || joyButtonState[BUTTON_MFDSELECTNEXT] || joyButtonState[BUTTON_MFDSELECTPREV])
4282 {
4283 if ([[self hud] mfdCount] > 1)
4284 {
4285 if (!switchMFD_pressed)
4286 {
4287 //if (![gameView isCtrlDown])
4288 if (![self checkKeyPress:n_key_switch_previous_mfd] || joyButtonState[BUTTON_MFDSELECTPREV])
4289 {
4290 [self selectNextMultiFunctionDisplay];
4291 }
4292 else
4293 {
4294 [self selectPreviousMultiFunctionDisplay];
4295 }
4296 }
4297 }
4298 switchMFD_pressed = YES;
4299 }
4300 else
4301 {
4302 switchMFD_pressed = NO;
4303 }
4304
4305
4306 // show comms log '`'
4307 if ([self checkKeyPress:n_key_comms_log])
4308 {
4309 [UNIVERSE showCommsLog: 1.5];
4310 [hud refreshLastTransmitter];
4311 }
4312}
@ gvStringInputNo
@ BUTTON_MFDSELECTNEXT
@ BUTTON_COMPASSMODE
@ BUTTON_MFDCYCLENEXT
@ BUTTON_MFDCYCLEPREV
@ BUTTON_SCANNERUNZOOM
@ BUTTON_SCANNERZOOM
@ BUTTON_COMPASSMODE_PREV
@ BUTTON_MFDSELECTPREV
static BOOL cycleMFD_pressed
static BOOL zoom_pressed
static BOOL switchMFD_pressed
static BOOL next_compass_mode_pressed
static BOOL prev_compass_mode_pressed
#define SCANNER_ZOOM_RATE_DOWN
#define SCANNER_ZOOM_RATE_UP

◆ setGuiToMissionEndScreen

- (void) setGuiToMissionEndScreen

Definition at line 4739 of file PlayerEntityControls.m.

5374{
5375 MyOpenGLView *gameView = [UNIVERSE gameView];
5376 [gameView clearKeys];
5377 if ([self status] != STATUS_DOCKED)
5378 {
5379 // this setting is only applied when not docked
5380 [self setGuiToStatusScreen];
5381 return;
5382 }
5383 switch (_missionExitScreen)
5384 {
5385 case GUI_SCREEN_MANIFEST:
5386 [self noteGUIWillChangeTo:GUI_SCREEN_MANIFEST];
5387 [self setGuiToManifestScreen];
5388 break;
5389 case GUI_SCREEN_EQUIP_SHIP:
5390 [self noteGUIWillChangeTo:GUI_SCREEN_EQUIP_SHIP];
5391 [self setGuiToEquipShipScreen:0];
5392 break;
5393 case GUI_SCREEN_SHIPYARD:
5394 if ([[self dockedStation] hasShipyard])
5395 {
5396 [self noteGUIWillChangeTo:GUI_SCREEN_SHIPYARD];
5397 [self setGuiToShipyardScreen:0];
5398 [[UNIVERSE gui] setSelectedRow:GUI_ROW_SHIPYARD_START];
5399 [self showShipyardInfoForSelection];
5400 }
5401 else
5402 {
5403 // that doesn't work here
5404 [self setGuiToStatusScreen];
5405 }
5406 break;
5407 case GUI_SCREEN_LONG_RANGE_CHART:
5408 [self setGuiToLongRangeChartScreen];
5409 break;
5410 case GUI_SCREEN_SHORT_RANGE_CHART:
5411 [self setGuiToShortRangeChartScreen];
5412 break;
5413 case GUI_SCREEN_SYSTEM_DATA:
5414 [self noteGUIWillChangeTo:GUI_SCREEN_SYSTEM_DATA];
5415 [self setGuiToSystemDataScreen];
5416 break;
5417 case GUI_SCREEN_MARKET:
5418 [self noteGUIWillChangeTo:GUI_SCREEN_MARKET];
5419 [self setGuiToMarketScreen];
5420 break;
5421 case GUI_SCREEN_MARKETINFO:
5422 [self noteGUIWillChangeTo:GUI_SCREEN_MARKETINFO];
5423 [self setGuiToMarketInfoScreen];
5424 break;
5425 case GUI_SCREEN_INTERFACES:
5426 [self setGuiToInterfacesScreen:0];
5427 break;
5428 case GUI_SCREEN_STATUS:
5429 default: // invalid screen specifications
5430 [self setGuiToStatusScreen];
5431 }
5432}

◆ switchToThisView:

- (void) switchToThisView: (OOViewID viewDirection

Definition at line 4739 of file PlayerEntityControls.m.

5435 :(OOViewID)viewDirection
5436{
5437 [self switchToThisView:viewDirection andProcessWeaponFacing:YES];
5438}

◆ switchToThisView:andProcessWeaponFacing:

- (void) switchToThisView: (OOViewID viewDirection
andProcessWeaponFacing: (BOOL)  processWeaponFacing 

Definition at line 4739 of file PlayerEntityControls.m.

5441 :(OOViewID)viewDirection andProcessWeaponFacing:(BOOL)processWeaponFacing
5442{
5443 [self switchToThisView:viewDirection fromView:[UNIVERSE viewDirection] andProcessWeaponFacing:processWeaponFacing justNotify:NO];
5444}

◆ switchToThisView:fromView:andProcessWeaponFacing:justNotify:

- (void) switchToThisView: (OOViewID viewDirection
fromView: (OOViewID oldViewDirection
andProcessWeaponFacing: (BOOL)  processWeaponFacing
justNotify: (BOOL)  justNotify 

Definition at line 4739 of file PlayerEntityControls.m.

5447 :(OOViewID)viewDirection fromView:(OOViewID)oldViewDirection andProcessWeaponFacing:(BOOL)processWeaponFacing justNotify:(BOOL)justNotify
5448{
5449 if (!justNotify)
5450 {
5451 if ([UNIVERSE displayGUI]) [self switchToMainView];
5452 [UNIVERSE setViewDirection:viewDirection];
5453 }
5454 if (processWeaponFacing)
5455 {
5457 switch (viewDirection)
5458 {
5459 case VIEW_FORWARD:
5460 facing = WEAPON_FACING_FORWARD;
5461 break;
5462
5463 case VIEW_AFT:
5464 facing = WEAPON_FACING_AFT;
5465 break;
5466
5467 case VIEW_PORT:
5468 facing = WEAPON_FACING_PORT;
5469 break;
5470
5471 case VIEW_STARBOARD:
5472 facing = WEAPON_FACING_STARBOARD;
5473 break;
5474
5475 default:
5476 break;
5477 }
5478
5479 if (facing != WEAPON_FACING_NONE)
5480 {
5481 currentWeaponFacing = facing;
5482 [self currentWeaponStats];
5483 }
5484 else
5485 {
5486 OOLogERR(kOOLogParameterError, @"%s called with processWeaponFacing=YES for non-main view %i.", __FUNCTION__, viewDirection);
5487 }
5488 }
5489 if ((oldViewDirection != viewDirection || viewDirection == VIEW_CUSTOM) && ![[UNIVERSE gameController] isGamePaused])
5490 {
5491 JSContext *context = OOJSAcquireContext();
5492 ShipScriptEvent(context, self, "viewDirectionChanged", OOJSValueFromViewID(context, viewDirection), OOJSValueFromViewID(context, oldViewDirection));
5493 OOJSRelinquishContext(context);
5494 }
5495}
OOINLINE jsval OOJSValueFromViewID(JSContext *context, OOViewID value)
OOINLINE JSContext * OOJSAcquireContext(void)
OOINLINE void OOJSRelinquishContext(JSContext *context)
#define OOLogERR(class, format,...)
Definition OOLogging.h:112
NSString *const kOOLogParameterError
Definition OOLogging.m:647
OOWeaponFacing
Definition OOTypes.h:228
@ WEAPON_FACING_FORWARD
Definition OOTypes.h:229
@ WEAPON_FACING_NONE
Definition OOTypes.h:234
@ WEAPON_FACING_AFT
Definition OOTypes.h:230
@ WEAPON_FACING_PORT
Definition OOTypes.h:231
@ WEAPON_FACING_STARBOARD
Definition OOTypes.h:232
#define ShipScriptEvent(context, ship, event,...)

The documentation for this category was generated from the following file: