- manifest['foo'] is now case insensitive:manifest['food'] = manifest['Food'] = manifest['FOOD']

- corrected a last-minute snafu with mission screen callbacks & status screen. Should stop doing this when sleepy!

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@2761 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Marc 2009-11-19 00:53:07 +00:00
parent 116d83f955
commit 9ee6b481c4
2 changed files with 569 additions and 518 deletions

View File

@ -3084,14 +3084,22 @@ static BOOL toggling_music;
[UNIVERSE removeDemoShips]; [UNIVERSE removeDemoShips];
[gui clearBackground]; [gui clearBackground];
[[OOMusicController sharedController] stopMissionMusic]; [[OOMusicController sharedController] stopMissionMusic];
[self setGuiToStatusScreen]; // some js actions require this to be set first.
if (_missionWithCallback) if (_missionWithCallback)
{ {
[self doMissionCallback]; [self doMissionCallback];
} }
[self setGuiToStatusScreen]; // we need to provide feedback when something changes inside the callback. // fix for launching from inside the callback.
if ([self status] == STATUS_DOCKED)
{
[self setGuiToStatusScreen]; // enable feedback
[self endMissionScreenAndNoteOpportunity]; [self endMissionScreenAndNoteOpportunity];
} }
else
{
[self doWorldEventUntilMissionScreen:@"missionScreenEnded"];
}
}
spacePressed = YES; spacePressed = YES;
} }
else else
@ -3142,13 +3150,20 @@ static BOOL toggling_music;
[gui clearBackground]; [gui clearBackground];
[[OOMusicController sharedController] stopMissionMusic]; [[OOMusicController sharedController] stopMissionMusic];
[self playDismissedMissionScreen]; [self playDismissedMissionScreen];
[self setGuiToStatusScreen]; // enable some js commands
if (_missionWithCallback) if (_missionWithCallback)
{ {
[self doMissionCallback]; [self doMissionCallback];
} }
// fix for launching from inside the callback
if ([self status] == STATUS_DOCKED)
{
[self setGuiToStatusScreen]; // enable feedback [self setGuiToStatusScreen]; // enable feedback
[self endMissionScreenAndNoteOpportunity]; [self endMissionScreenAndNoteOpportunity];
}
else
{
[self doWorldEventUntilMissionScreen:@"missionScreenEnded"];
}
[self checkScript]; [self checkScript];
} }
selectPressed = YES; selectPressed = YES;

View File

@ -95,6 +95,9 @@ enum
kManifest_alien_items, // standardised identifier commodity quantity, integer, read/write kManifest_alien_items, // standardised identifier commodity quantity, integer, read/write
kManifest_alienItems, // js style alias to previous commodity quantity, integer, read/write kManifest_alienItems, // js style alias to previous commodity quantity, integer, read/write
kManifest_alienitems // alias to previous commodity quantity, integer, read/write kManifest_alienitems // alias to previous commodity quantity, integer, read/write
// FIXME: using kManifest_alienitems as the length of the array below, to help iterate through the elements.
// there must be a better way of doing this.
}; };
@ -205,6 +208,23 @@ static JSBool ManifestGetProperty(JSContext *context, JSObject *this, jsval name
id result = nil; id result = nil;
PlayerEntity *entity = OOPlayerForScripting(); PlayerEntity *entity = OOPlayerForScripting();
if (JSVAL_IS_STRING(name)) // let's convert it to a lowercase property
{
const char *str = [[[NSString stringWithJavaScriptValue:name inContext:context] lowercaseString] cString];
int i,len;
//FIXME: there must be a better way of doing this.
len = kManifest_alienitems + 1; // FIXME: waiting for proper solution.
for (i=0; i<len; i++)
{
if (strcmp(sManifestProperties[i].name, str) == 0)
{
name = INT_TO_JSVAL(sManifestProperties[i].tinyid);
break;
}
}
}
if (!JSVAL_IS_INT(name)) return YES; if (!JSVAL_IS_INT(name)) return YES;
//if (EXPECT_NOT(!JSShipGetShipEntity(context, this, &entity))) return NO; // NOTE: to be added if we get NPCs with manifests. //if (EXPECT_NOT(!JSShipGetShipEntity(context, this, &entity))) return NO; // NOTE: to be added if we get NPCs with manifests.
@ -322,6 +342,22 @@ static JSBool ManifestSetProperty(JSContext *context, JSObject *this, jsval name
PlayerEntity *entity = OOPlayerForScripting(); PlayerEntity *entity = OOPlayerForScripting();
int32 iValue; int32 iValue;
if (JSVAL_IS_STRING(name)) // let's convert it to a lowercase property
{
int i,len;
//FIXME: there must be a better way of doing this.
const char *str = [[[NSString stringWithJavaScriptValue:name inContext:context] lowercaseString] cString];
len = kManifest_alienitems + 1; // FIXME: waiting for proper solution.
for (i=0; i<len; i++) {
if (strcmp(sManifestProperties[i].name, str) == 0)
{
name = INT_TO_JSVAL(sManifestProperties[i].tinyid);
break;
}
}
}
if (!JSVAL_IS_INT(name)) return YES; if (!JSVAL_IS_INT(name)) return YES;
//if (EXPECT_NOT(!JSShipGetShipEntity(context, this, &entity))) return NO; //if (EXPECT_NOT(!JSShipGetShipEntity(context, this, &entity))) return NO;
if ([entity specialCargo]) if ([entity specialCargo])