- mission.setInstructionsKey fix (the global prefix implementation would not be able to tell which oxp it was called from)
- yet another windows DEP fix. There's something inside OOJSScript that windows doesn't like. git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@2770 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
f8cba46d16
commit
bf23119d18
@ -51,6 +51,7 @@ this.global = (function () { return this; } ).call();
|
||||
|
||||
/**** Utilities, not intended to be retired ****/
|
||||
|
||||
|
||||
// Ship.spawnOne(): like spawn(role, 1), but returns the ship rather than an array.
|
||||
Ship.__proto__.spawnOne = function (role)
|
||||
{
|
||||
@ -59,14 +60,6 @@ Ship.__proto__.spawnOne = function (role)
|
||||
};
|
||||
|
||||
|
||||
|
||||
// mission.setInstructionsKey(): load mission text from mission.plist and use it as mission instructions.
|
||||
mission.setInstructionsKey = function(textKey, missionKey)
|
||||
{
|
||||
mission.setInstructions((textKey ? expandMissionText(textKey) : null), missionKey);
|
||||
}
|
||||
|
||||
|
||||
// mission.addMessageTextKey(): load mission text from mission.plist and append to mission screen or info screen.
|
||||
mission.addMessageTextKey = function(textKey)
|
||||
{
|
||||
|
@ -45,6 +45,7 @@ static JSBool MissionSetBackgroundImage(JSContext *context, JSObject *this, uint
|
||||
static JSBool MissionSetMusic(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
static JSBool MissionSetChoicesKey(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
static JSBool MissionSetInstructions(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
static JSBool MissionSetInstructionsKey(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
static JSBool MissionClearMissionScreen(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
static JSBool MissionRunScreen(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
|
||||
@ -99,6 +100,7 @@ static JSFunctionSpec sMissionMethods[] =
|
||||
{ "setMusic", MissionSetMusic, 1 },
|
||||
{ "setChoicesKey", MissionSetChoicesKey, 1 },
|
||||
{ "setInstructions", MissionSetInstructions, 1 },
|
||||
{ "setInstructionsKey", MissionSetInstructionsKey, 1 },
|
||||
{ "clearMissionScreen", MissionClearMissionScreen, 0 },
|
||||
{ "runScreen", MissionRunScreen, 2 },
|
||||
{ 0 }
|
||||
@ -131,13 +133,14 @@ void MissionRunCallback()
|
||||
// now reset the mission choice silently, before calling the callback script.
|
||||
[player setMissionChoice:nil withEvent:NO];
|
||||
|
||||
[OOJSScript pushScript:callbackScript];
|
||||
// windows DEP fix: use the underlying object!
|
||||
[OOJSScript pushScript:[callbackScript weakRefUnderlyingObject]];
|
||||
[engine callJSFunction:function
|
||||
forObject:JSVAL_TO_OBJECT([callbackScript javaScriptValueInContext:context])
|
||||
forObject:JSVAL_TO_OBJECT([[callbackScript weakRefUnderlyingObject] javaScriptValueInContext:context])
|
||||
argc:1
|
||||
argv:&argval
|
||||
result:&rval];
|
||||
[OOJSScript popScript:callbackScript];
|
||||
[OOJSScript popScript:[callbackScript weakRefUnderlyingObject]];
|
||||
[engine releaseContext:context];
|
||||
}
|
||||
|
||||
@ -326,7 +329,13 @@ static JSBool MissionSetChoicesKey(JSContext *context, JSObject *this, uintN arg
|
||||
}
|
||||
|
||||
|
||||
// setInstructionsKey is now a convenience alias inside oolite-global-prefix.js
|
||||
static JSBool MissionSetInstructionsKey(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult)
|
||||
{
|
||||
*outResult = [@"textKey" javaScriptValueInContext:context];
|
||||
MissionSetInstructions(context, this, argc, argv, outResult);
|
||||
}
|
||||
|
||||
|
||||
// setInstructions(instructions: String [, missionKey : String])
|
||||
static JSBool MissionSetInstructions(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult)
|
||||
{
|
||||
@ -348,13 +357,17 @@ static JSBool MissionSetInstructions(JSContext *context, JSObject *this, uintN a
|
||||
|
||||
if (text != nil)
|
||||
{
|
||||
[player setMissionInstructions:text forMission:missionKey];
|
||||
if ([@"textKey" isEqualTo:JSValToNSString(context,*outResult)])
|
||||
[player setMissionDescription:text forMission:missionKey];
|
||||
else
|
||||
[player setMissionInstructions:text forMission:missionKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
[player clearMissionDescriptionForMission:missionKey];
|
||||
}
|
||||
|
||||
*outResult = JSVAL_VOID;
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user