Allow mission screens (while docked) to choose their exit screen.

Update parcels script to exit to the interface screen.


git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@5433 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Chris Morris 2012-10-18 18:26:37 +00:00
parent ecb5a1ada6
commit dae5fa6466
6 changed files with 107 additions and 4 deletions

View File

@ -259,7 +259,8 @@ this._parcelContractsDisplay = function(summary) {
{ {
mission.runScreen({titleKey: "oolite-contracts-parcels-none-available-title", mission.runScreen({titleKey: "oolite-contracts-parcels-none-available-title",
messageKey: "oolite-contracts-parcels-none-available-message", messageKey: "oolite-contracts-parcels-none-available-message",
allowInterrupt: true }); allowInterrupt: true,
exitScreen: "GUI_SCREEN_INTERFACES"});
// no callback, just exits contracts system // no callback, just exits contracts system
return; return;
} }
@ -362,6 +363,7 @@ this._parcelContractSummaryPage = function()
var missionConfig = {titleKey: "oolite-contracts-parcels-title-summary", var missionConfig = {titleKey: "oolite-contracts-parcels-title-summary",
message: headline, message: headline,
allowInterrupt: true, allowInterrupt: true,
exitScreen: "GUI_SCREEN_INTERFACES",
choices: options, choices: options,
initialChoicesKey: initialChoice}; initialChoicesKey: initialChoice};
if (this.$parcelSummaryPageBackground != "") { if (this.$parcelSummaryPageBackground != "") {
@ -474,6 +476,7 @@ this._parcelContractSinglePage = function()
title: title, title: title,
message: message, message: message,
allowInterrupt: true, allowInterrupt: true,
exitScreen: "GUI_SCREEN_INTERFACES",
backgroundSpecial: backgroundSpecial, backgroundSpecial: backgroundSpecial,
choices: options, choices: options,
initialChoicesKey: this.$lastChoice initialChoicesKey: this.$lastChoice

View File

@ -269,6 +269,7 @@ typedef enum
NSString *missionChoice; NSString *missionChoice;
BOOL _missionWithCallback; BOOL _missionWithCallback;
BOOL _missionAllowInterrupt; BOOL _missionAllowInterrupt;
OOGUIScreenID _missionExitScreen;
NSString *specialCargo; NSString *specialCargo;
@ -829,7 +830,7 @@ typedef enum
- (void) setMissionBackgroundDescriptor:(NSDictionary *)descriptor; - (void) setMissionBackgroundDescriptor:(NSDictionary *)descriptor;
- (OOGUIBackgroundSpecial) missionBackgroundSpecial; - (OOGUIBackgroundSpecial) missionBackgroundSpecial;
- (void) setMissionBackgroundSpecial:(NSString *)special; - (void) setMissionBackgroundSpecial:(NSString *)special;
- (void) setMissionExitScreen:(OOGUIScreenID)screen;
// Nasty hack to keep background textures around while on equip screens. // Nasty hack to keep background textures around while on equip screens.
- (NSDictionary *) equipScreenBackgroundDescriptor; - (NSDictionary *) equipScreenBackgroundDescriptor;

View File

@ -9102,6 +9102,12 @@ static NSString *last_outfitting_key=nil;
} }
- (void) setMissionExitScreen:(OOGUIScreenID)screen
{
_missionExitScreen = screen;
}
- (NSDictionary *) equipScreenBackgroundDescriptor - (NSDictionary *) equipScreenBackgroundDescriptor
{ {
return _equipScreenBackgroundDescriptor; return _equipScreenBackgroundDescriptor;

View File

@ -144,6 +144,7 @@ static NSTimeInterval time_last_frame;
- (void) pollDockedControls:(double) delta_t; - (void) pollDockedControls:(double) delta_t;
- (void) pollDemoControls:(double) delta_t; - (void) pollDemoControls:(double) delta_t;
- (void) handleMissionCallback; - (void) handleMissionCallback;
- (void) setGuiToMissionEndScreen;
- (void) switchToThisView:(OOViewID)viewDirection; - (void) switchToThisView:(OOViewID)viewDirection;
- (void) switchToThisView:(OOViewID)viewDirection andProcessWeaponFacing:(BOOL)processWeaponFacing; - (void) switchToThisView:(OOViewID)viewDirection andProcessWeaponFacing:(BOOL)processWeaponFacing;
- (void) switchToThisView:(OOViewID)viewDirection fromView:(OOViewID)oldViewDirection andProcessWeaponFacing:(BOOL)processWeaponFacing justNotify:(BOOL)justNotify; - (void) switchToThisView:(OOViewID)viewDirection fromView:(OOViewID)oldViewDirection andProcessWeaponFacing:(BOOL)processWeaponFacing justNotify:(BOOL)justNotify;
@ -3518,7 +3519,18 @@ static BOOL autopilot_pause;
spacePressed = YES; spacePressed = YES;
} }
else else
{
spacePressed = NO; spacePressed = NO;
if (_missionAllowInterrupt)
{
[self pollGuiScreenControls];
if (gui_screen != GUI_SCREEN_MISSION)
{
[UNIVERSE removeDemoShips];
[self endMissionScreenAndNoteOpportunity];
}
}
}
} }
else else
{ {
@ -3565,7 +3577,7 @@ static BOOL autopilot_pause;
[UNIVERSE removeDemoShips]; [UNIVERSE removeDemoShips];
[[UNIVERSE gui] clearBackground]; [[UNIVERSE gui] clearBackground];
[self setGuiToStatusScreen]; // need this to find out if we call a new mission screen inside callback. [self setGuiToMissionEndScreen]; // need this to find out if we call a new mission screen inside callback.
if ([self status] != STATUS_DOCKED) [self switchToThisView:VIEW_FORWARD]; if ([self status] != STATUS_DOCKED) [self switchToThisView:VIEW_FORWARD];
@ -3583,13 +3595,82 @@ static BOOL autopilot_pause;
{ {
if (gui_screen != GUI_SCREEN_MISSION) // did we call a new mission screen inside callback? if (gui_screen != GUI_SCREEN_MISSION) // did we call a new mission screen inside callback?
{ {
[self setGuiToStatusScreen]; // if not, update status screen with callback changes, if any. [self setGuiToMissionEndScreen]; // if not, update status screen with callback changes, if any.
[self endMissionScreenAndNoteOpportunity]; // missionScreenEnded, plus opportunity events. [self endMissionScreenAndNoteOpportunity]; // missionScreenEnded, plus opportunity events.
} }
} }
} }
- (void) setGuiToMissionEndScreen
{
if ([self status] != STATUS_DOCKED)
{
// this setting is only applied when not docked
[self setGuiToStatusScreen];
return;
}
switch (_missionExitScreen)
{
case GUI_SCREEN_MANIFEST:
[self noteGUIWillChangeTo:GUI_SCREEN_MANIFEST];
[self setGuiToManifestScreen];
break;
case GUI_SCREEN_EQUIP_SHIP:
[self noteGUIWillChangeTo:GUI_SCREEN_EQUIP_SHIP];
[self setGuiToEquipShipScreen:0];
break;
case GUI_SCREEN_SHIPYARD:
if ([dockedStation hasShipyard])
{
[self noteGUIWillChangeTo:GUI_SCREEN_SHIPYARD];
[self setGuiToShipyardScreen:0];
[[UNIVERSE gui] setSelectedRow:GUI_ROW_SHIPYARD_START];
[self showShipyardInfoForSelection];
}
else
{
// that doesn't work here
[self setGuiToStatusScreen];
}
break;
case GUI_SCREEN_SHORT_RANGE_CHART:
[self setGuiToShortRangeChartScreen];
break;
case GUI_SCREEN_LONG_RANGE_CHART:
[self setGuiToLongRangeChartScreen];
break;
case GUI_SCREEN_SYSTEM_DATA:
[self noteGUIWillChangeTo:GUI_SCREEN_SYSTEM_DATA];
[self setGuiToSystemDataScreen];
break;
case GUI_SCREEN_MARKET:
[self noteGUIWillChangeTo:GUI_SCREEN_MARKET];
[self setGuiToMarketScreen];
[[UNIVERSE gui] setSelectedRow:GUI_ROW_MARKET_START];
break;
case GUI_SCREEN_CONTRACTS:
if (dockedStation == [UNIVERSE station] && [self hasHyperspaceMotor])
{
[self setGuiToContractsScreen];
[[UNIVERSE gui] setSelectedRow:GUI_ROW_PASSENGERS_START];
}
else
{
// can't get to contracts screen from here
[self setGuiToStatusScreen];
}
break;
case GUI_SCREEN_INTERFACES:
[self setGuiToInterfacesScreen:0];
break;
case GUI_SCREEN_STATUS:
default: // invalid screen specifications
[self setGuiToStatusScreen];
}
}
- (void) switchToThisView:(OOViewID)viewDirection - (void) switchToThisView:(OOViewID)viewDirection
{ {
[self switchToThisView:viewDirection andProcessWeaponFacing:YES]; [self switchToThisView:viewDirection andProcessWeaponFacing:YES];

View File

@ -2345,6 +2345,8 @@ static int scriptRandomSeed = -1; // ensure proper random function
// reset special background as legacy scripts can't use it, and this // reset special background as legacy scripts can't use it, and this
// is only called by legacy scripts // is only called by legacy scripts
[self setMissionBackgroundSpecial:nil]; [self setMissionBackgroundSpecial:nil];
// likewise exit screen target
[self setMissionExitScreen:GUI_SCREEN_STATUS];
[self setGuiToMissionScreenWithCallback:NO]; [self setGuiToMissionScreenWithCallback:NO];
} }

View File

@ -26,6 +26,7 @@ MA 02110-1301, USA.
#import "OOJSMission.h" #import "OOJSMission.h"
#import "OOJavaScriptEngine.h" #import "OOJavaScriptEngine.h"
#import "OOJSScript.h" #import "OOJSScript.h"
#import "OOConstToJSString.h"
#import "OOJSPlayer.h" #import "OOJSPlayer.h"
#import "PlayerEntityScriptMethods.h" #import "PlayerEntityScriptMethods.h"
@ -543,6 +544,15 @@ static JSBool MissionRunScreen(JSContext *context, uintN argc, jsval *vp)
JS_ValueToBoolean(context, value, &allowInterrupt); JS_ValueToBoolean(context, value, &allowInterrupt);
} }
if (JS_GetProperty(context, params, "exitScreen", &value) && !JSVAL_IS_VOID(value))
{
[player setMissionExitScreen:OOGUIScreenIDFromJSValue(context, value)];
}
else
{
[player setMissionExitScreen:GUI_SCREEN_STATUS];
}
// Start the mission screen. // Start the mission screen.
sCallbackFunction = function; sCallbackFunction = function;
[player setGuiToMissionScreenWithCallback:!JSVAL_IS_NULL(sCallbackFunction)]; [player setGuiToMissionScreenWithCallback:!JSVAL_IS_NULL(sCallbackFunction)];