Pause & autopilot fixes:

- Unless explicitly in normal flight or docked, the game actively unpauses itself. This fixes 'frozen' pause mode when in witchspace tunnels.
 - Pause buttons weren't working when using the autopilot. Fixed.
 - Regression fix: pressing 'fast dock' while on autopilot stops the autopilot, as before.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@4663 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Marc 2011-11-23 11:56:15 +00:00
parent ca2205ff57
commit f44dede98e
2 changed files with 103 additions and 25 deletions

View File

@ -8325,7 +8325,7 @@ static NSString *last_outfitting_key=nil;
#if 0
// post-NMSR fuelPrices - the state of repair to affect the rate?
// state of repair never lower than 75, but added the check just in case. -- Kaks 20110429
if (ship_trade_in_factor <= 90 && ship_trade_in_factor >= 75)
if (EXPECT(ship_trade_in_factor <= 90 && ship_trade_in_factor >= 75))
{
rate *= 2.0 - (ship_trade_in_factor / 100); // between 1.1x and 1.25x
OOLog(@"fuelPrices", @"\"%@\" - repair status: %d%%, adjusted rate to:%.2f)", [self shipDataKey], ship_trade_in_factor, rate);

View File

@ -312,6 +312,7 @@ static NSTimeInterval time_last_frame;
break;
default:
// don't poll extra controls at any other times.
break;
}
}
@ -488,6 +489,35 @@ static NSTimeInterval time_last_frame;
}
}
if ([[gameView gameController] isGamePaused])
{
// What's the status?
switch ([self status])
{
case STATUS_WITCHSPACE_COUNTDOWN:
case STATUS_IN_FLIGHT:
case STATUS_AUTOPILOT_ENGAGED:
case STATUS_DOCKED:
// Pause is handled inside their pollControls, no need to unpause.
break;
default:
{
// In all other cases we can't handle pause. Unpause immediately.
script_time = saved_script_time;
[gameView allowStringInput:NO];
[UNIVERSE setDisplayCursor:NO];
if ([UNIVERSE pauseMessageVisible])
{
[UNIVERSE clearPreviousMessage]; // remove the 'paused' message.
}
[[gameView gameController] unpauseGame];
}
break;
}
}
// snapshot
const BOOL *joyButtonState = [[OOJoystickManager sharedStickHandler] getAllButtonStates];
if ([gameView isDown:key_snapshot] || joyButtonState[BUTTON_SNAPSHOT]) // '*' key
@ -3033,6 +3063,8 @@ static NSTimeInterval time_last_frame;
static BOOL toggling_music;
static BOOL playing_music;
static BOOL autopilot_pause;
- (void) pollAutopilotControls:(double)delta_t
{
@ -3040,38 +3072,84 @@ static BOOL toggling_music;
MyOpenGLView *gameView = [UNIVERSE gameView];
// view keys
[self pollViewControls];
// text displays
[self pollGuiScreenControls];
if ([UNIVERSE displayGUI])
[self pollGuiArrowKeyControls:delta_t];
if ([gameView isDown:key_autopilot]) // look for the 'c' key
if (![[gameView gameController] isGamePaused])
{
if ([self hasDockingComputer] && !autopilot_key_pressed) // look for the 'c' key
// view keys
[self pollViewControls];
// text displays
[self pollGuiScreenControls];
if ([UNIVERSE displayGUI])
[self pollGuiArrowKeyControls:delta_t];
const BOOL *joyButtonState = [[OOJoystickManager sharedStickHandler] getAllButtonStates];
if ([gameView isDown:key_autopilot] || joyButtonState[BUTTON_DOCKCPU]
|| [gameView isDown:key_autodock] || joyButtonState[BUTTON_DOCKCPUFAST]) // look for the 'c' and 'C' key
{
[self disengageAutopilot];
[UNIVERSE addMessage:DESC(@"autopilot-off") forCount:4.5];
if ([self hasDockingComputer] && !autopilot_key_pressed)
{
[self disengageAutopilot];
[UNIVERSE addMessage:DESC(@"autopilot-off") forCount:4.5];
}
autopilot_key_pressed = YES;
if ([gameView isDown:key_autodock] || joyButtonState[BUTTON_DOCKCPUFAST])
{
fast_autopilot_key_pressed = YES;
}
}
autopilot_key_pressed = YES;
}
else
autopilot_key_pressed = NO;
if (([gameView isDown:key_docking_music])) // look for the 's' key
{
if (!toggling_music)
else
{
[[OOMusicController sharedController] toggleDockingMusic];
autopilot_key_pressed = NO;
}
if (([gameView isDown:key_docking_music])) // look for the 's' key
{
if (!toggling_music)
{
[[OOMusicController sharedController] toggleDockingMusic];
}
toggling_music = YES;
}
else
{
toggling_music = NO;
}
// look for the pause game, 'p' key
if ([gameView isDown:key_pausebutton] && gui_screen != GUI_SCREEN_LONG_RANGE_CHART)
{
if (!autopilot_pause)
{
playing_music = [[OOMusicController sharedController] isPlaying];
if (playing_music) [[OOMusicController sharedController] toggleDockingMusic];
// normal flight controls can handle the rest.
pause_pressed = NO; // pause button flag must be NO for pollflightControls to react!
[self pollFlightControls:delta_t];
}
autopilot_pause = YES;
}
else
{
autopilot_pause = NO;
}
toggling_music = YES;
}
else
{
toggling_music = NO;
// paused
if ([gameView isDown:key_pausebutton])
{
if (!autopilot_pause)
{
if (playing_music) [[OOMusicController sharedController] toggleDockingMusic];
}
autopilot_pause = YES;
}
else
{
autopilot_pause = NO;
}
// let the normal flight controls handle paused commands.
[self pollFlightControls:delta_t];
}
}