- Pause now works when docked. If paused when docked, no options are available. Added new translation string "game-paused-docked".

- Added 3 javascript properties to ships: isCargo, isDerelict and isRock (the last one identifies both asteroids and rock hermits)
- Tidying up!

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@2906 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Marc 2009-12-23 23:00:53 +00:00
parent f158db818f
commit c010a69056
5 changed files with 132 additions and 75 deletions

View File

@ -413,63 +413,64 @@
// *** Misc. messages ***
// Messages used when awarding bounties
"bounty-@-total-@" = "Bounty: %@\nTotal: %@";
"bounty-@-total-@" = "Bounty: %@\nTotal: %@";
"right-on-commander" = "Right On, Commander!";
// Assorted messages used by the onboard computer
"autopilot-on" = ( "Autopilot engaged." );
"autopilot-off" = ( "Autopilot disengaged." );
"autopilot-out-of-range" = ( "Could not contact station for docking instructions." );
"autopilot-cannot-dock-with-target" = ( "Target is not capable of autopilot-docking." );
"autopilot-target-docking-instructions-denied" = ( "Target has denied broadcast of docking instructions." );
"autopilot-denied" = ( "Station refuses to issue docking instructions." );
"witch-to-@-in-f-seconds" = ( "Witchspace to %@ in %.0f s." );
"witch-blocked-by-@" = ( "Witchspace jump aborted (too close to %@.)" );
"witch-user-abort" = ( "Witchspace jump aborted." );
"witch-no-target" = ( "No target system set." );
"witch-no-fuel" = ( "Insufficient fuel for witchspace jump." );
"witch-too-far" = ( "Engines incapable of witchspace jump to that target." );
"witch-engine-malfunction" = ( "Witchspace engine malfunction!" );
"witch-galactic-in-f-seconds" = ( "Intergalactic jump in %.0f s." );
"game-paused" = ( "Game paused.\nPress F2 for options, P to resume." );
"game-saved" = ( "Game saved." );
"mouse-on" = ( "Mouse control on." );
"mouse-off" = ( "Mouse control off." );
"target-lost" = ( "Target lost." );
"unknown-target" = ( "Unknown Target" );
"ecm-on" = ( "ECM system activated." );
"ecm-out-of-juice" = ( "ECM system deactivated (no energy left)." );
"jump-mass-locked" = ( "Hyperspeed mass-locked." );
"fuel-inject-on" = ( "Fuel injection engaged." );
"fuel-out" = ( "Witchdrive fuel exhausted." );
"ident-on" = ( "Ident system active." );
"ident-off" = ( "Ident system deactivated." );
"missile-locked-onto-@" = ( "Missile locked onto %@." );
"ident-locked-onto-@" = ( "Ident system locked onto %@." );
"missile-armed" = ( "Missile armed." );
"mine-armed" = ( "Mine armed." );
"@-armed" = ( "%@ armed." );
"missile-safe" = ( "Missiles on safety." );
"incoming-missile" = ( "Incoming missile." );
"energy-low" = ( "Energy low." );
"energy-bomb-activated" = ( "Energy bomb triggered." );
"weapon-overheat" = ( "Weapon system overheated." );
"weapon-out-of-juice" = ( "Weapon system inactive (no energy left)." );
"escape-sequence" = ( "Escape sequence active." );
"@-ejected" = ( "%@ ejected." );
"@-ready-to-eject" = ( "Ready to eject %@." );
"ready-to-eject-@" = ( "Ready to eject %@." );
"@-scooped" = ( "%@ scooped." );
"scoop-captured-@" = ( "You captured %@." );
"scoop-rescued-@" = ( "You rescued %@." );
"scoop-got-slave" = ( "You captured a slave." );
"fuel-scoop-active" = ( "Fuel scoop active." );
"hold-locked" = ( "Cargo ejection system offline (speed too high)." );
"hold-full" = ( "Cargo hold full." );
"autopilot-on" = "Autopilot engaged.";
"autopilot-off" = "Autopilot disengaged.";
"autopilot-out-of-range" = "Could not contact station for docking instructions.";
"autopilot-cannot-dock-with-target" = "Target is not capable of autopilot-docking.";
"autopilot-target-docking-instructions-denied" = "Target has denied broadcast of docking instructions.";
"autopilot-denied" = "Station refuses to issue docking instructions.";
"witch-to-@-in-f-seconds" = "Witchspace to %@ in %.0f s.";
"witch-blocked-by-@" = "Witchspace jump aborted (too close to %@.)";
"witch-user-abort" = "Witchspace jump aborted.";
"witch-no-target" = "No target system set.";
"witch-no-fuel" = "Insufficient fuel for witchspace jump.";
"witch-too-far" = "Engines incapable of witchspace jump to that target.";
"witch-engine-malfunction" = "Witchspace engine malfunction!";
"witch-galactic-in-f-seconds" = "Intergalactic jump in %.0f s.";
"game-paused" = "Game paused.\nPress F2 for options, P to resume.";
"game-paused-docked" = "Game paused. Press P to resume.";
"game-saved" = "Game saved.";
"mouse-on" = "Mouse control on.";
"mouse-off" = "Mouse control off.";
"target-lost" = "Target lost.";
"unknown-target" = "Unknown Target";
"ecm-on" = "ECM system activated.";
"ecm-out-of-juice" = "ECM system deactivated (no energy left).";
"jump-mass-locked" = "Hyperspeed mass-locked.";
"fuel-inject-on" = "Fuel injection engaged.";
"fuel-out" = "Witchdrive fuel exhausted.";
"ident-on" = "Ident system active.";
"ident-off" = "Ident system deactivated.";
"missile-locked-onto-@" = "Missile locked onto %@.";
"ident-locked-onto-@" = "Ident system locked onto %@.";
"missile-armed" = "Missile armed.";
"mine-armed" = "Mine armed.";
"@-armed" = "%@ armed.";
"missile-safe" = "Missiles on safety.";
"incoming-missile" = "Incoming missile.";
"energy-low" = "Energy low.";
"energy-bomb-activated" = "Energy bomb triggered.";
"weapon-overheat" = "Weapon system overheated.";
"weapon-out-of-juice" = "Weapon system inactive (no energy left).";
"escape-sequence" = "Escape sequence active.";
"@-ejected" = "%@ ejected.";
"@-ready-to-eject" = "Ready to eject %@.";
"ready-to-eject-@" = "Ready to eject %@.";
"@-scooped" = "%@ scooped.";
"scoop-captured-@" = "You captured %@.";
"scoop-rescued-@" = "You rescued %@.";
"scoop-got-slave" = "You captured a slave.";
"fuel-scoop-active" = "Fuel scoop active.";
"hold-locked" = "Cargo ejection system offline (speed too high).";
"hold-full" = "Cargo hold full.";
// cloaking device ..
"cloak-on" = ( "Cloaking device activated." );
"cloak-off" = ( "Cloaking device deactivated." );
"cloak-low-juice" = ( "Not enough energy to activate cloaking device." );
"cloak-on" = "Cloaking device activated.";
"cloak-off" = "Cloaking device deactivated.";
"cloak-low-juice" = "Not enough energy to activate cloaking device.";
// Assorted messages sent out by ships etc..
/* %H - homeworld
@ -712,15 +713,15 @@
(
"The %I sun has gone nova, destroying the planet and all life here. Beware of navigational and radiological hazards in this system."
);
"nova-system-government" = "Uninhabited system - no government";
"nova-system-economy" = "Uninhabited system - no economy";
"nova-system-inhabitants" = "Uninhabited system";
"nova-system-government" = "Uninhabited system - no government";
"nova-system-economy" = "Uninhabited system - no economy";
"nova-system-inhabitants" = "Uninhabited system";
// trumbles
"trumbles-eat-@" = ( "Trumbles have eaten a cargopod of %@." );
"trumbles-eat-@" = "Trumbles have eaten a cargopod of %@.";
// internal damage
"@-damaged" = ( "%@ damaged." );
"@-destroyed" = ( "%@ destroyed." );
"@-damaged" = "%@ damaged.";
"@-destroyed" = "%@ destroyed.";
// icons for the hud
"EQ_HARDENED_MISSILE" =

View File

@ -1352,9 +1352,6 @@ static NSTimeInterval time_last_frame;
case GUI_SCREEN_SHORT_RANGE_CHART:
[self setGuiToShortRangeChartScreen];
break;
case GUI_SCREEN_LONG_RANGE_CHART:
[self setGuiToLongRangeChartScreen];
break;
case GUI_SCREEN_MANIFEST:
[self setGuiToManifestScreen];
break;
@ -3019,12 +3016,45 @@ static BOOL toggling_music;
- (void) pollDockedControls:(double)delta_t
{
StationEntity *station = nil;
MyOpenGLView *gameView = nil;
MyOpenGLView *gameView = [UNIVERSE gameView];
GameController *gameController = [gameView gameController];
// Pause game, 'p' key
if ([gameView isDown:key_pausebutton] && (gui_screen != GUI_SCREEN_LONG_RANGE_CHART &&
gui_screen != GUI_SCREEN_MISSION && gui_screen != GUI_SCREEN_REPORT &&
gui_screen != GUI_SCREEN_SAVE) )
{
if (!pause_pressed)
{
if ([gameController gameIsPaused])
{
script_time = saved_script_time;
[gameView allowStringInput:NO];
[UNIVERSE setDisplayCursor:NO];
[UNIVERSE clearPreviousMessage];
[gameController unpause_game];
}
else
{
saved_script_time = script_time;
[UNIVERSE addMessage:DESC(@"game-paused-docked") forCount:1.0];
[[UNIVERSE message_gui] leaveLastLine]; // remove other messages.
[gameController pause_game];
}
}
pause_pressed = YES;
}
else
{
pause_pressed = NO;
}
if ([gameController gameIsPaused]) return;
if(pollControls)
{
gameView = [UNIVERSE gameView];
if (([gameView isDown:gvFunctionKey1])||([gameView isDown:gvNumberKey1])) // look for the f1 key
if ([gameView isDown:gvFunctionKey1] || [gameView isDown:gvNumberKey1]) // look for the f1 key
{
// FIXME: should this not be in leaveDock:? (Note: leaveDock: is also called from script method launchFromStation and -[StationEntity becomeExplosion]) -- Ahruman 20080308
[UNIVERSE setUpUniverseFromStation]; // player pre-launch

View File

@ -143,14 +143,17 @@ enum
kShip_desiredSpeed, // AI desired flight speed, double, read/write
kShip_maxSpeed, // maximum flight speed, double, read-only
kShip_script, // script, Script, read-only
kShip_isCargo, // contains cargo, boolean, read-only
kShip_isDerelict, // is an abandoned ship, boolean, read-only
kShip_isPirate, // is pirate, boolean, read-only
kShip_isPirateVictim, // is pirate victim, boolean, read-only
kShip_isPlayer, // is player, boolean, read-only
kShip_isPolice, // is police, boolean, read-only
kShip_isThargoid, // is thargoid, boolean, read-only
kShip_isTrader, // is trader, boolean, read-only
kShip_isPirateVictim, // is pirate victim, boolean, read-only
kShip_isMissile, // is missile, boolean, read-only
kShip_isMine, // is mine, boolean, read-only
kShip_isRock, // is a rock (hermits included), boolean, read-only
kShip_isThargoid, // is thargoid, boolean, read-only
kShip_isTrader, // is trader, boolean, read-only
kShip_isWeapon, // is missile or mine, boolean, read-only
kShip_scriptInfo, // arbitrary data for scripts, dictionary, read-only
kShip_trackCloseContacts, // generate close contact events, boolean, read/write
@ -190,16 +193,19 @@ static JSPropertySpec sShipProperties[] =
{ "heatInsulation", kShip_heatInsulation, JSPROP_PERMANENT | JSPROP_ENUMERATE },
{ "isBeacon", kShip_isBeacon, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "isCloaked", kShip_isCloaked, JSPROP_PERMANENT | JSPROP_ENUMERATE },
{ "isCargo", kShip_isCargo, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "isDerelict", kShip_isDerelict, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "isFrangible", kShip_isFrangible, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "isJamming", kShip_isJamming, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "isMine", kShip_isMine, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "isMissile", kShip_isMissile, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "isPirate", kShip_isPirate, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "isPirateVictim", kShip_isPirateVictim, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "isPlayer", kShip_isPlayer, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "isPolice", kShip_isPolice, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "isRock", kShip_isRock, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "isThargoid", kShip_isThargoid, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "isTrader", kShip_isTrader, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "isMissile", kShip_isMissile, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "isMine", kShip_isMine, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "isWeapon", kShip_isWeapon, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "cargoSpaceUsed", kShip_cargoSpaceUsed, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "cargoSpaceCapacity", kShip_cargoCapacity, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
@ -520,6 +526,21 @@ static JSBool ShipGetProperty(JSContext *context, JSObject *this, jsval name, js
OK = YES;
break;
case kShip_isRock:
*outValue = BOOLToJSVal([entity scanClass] == CLASS_ROCK); // hermits and asteroids!
OK = YES;
break;
case kShip_isCargo:
*outValue = BOOLToJSVal([entity scanClass] == CLASS_CARGO && [entity commodityAmount] > 0);
OK = YES;
break;
case kShip_isDerelict:
*outValue = BOOLToJSVal([entity isHulk]);
OK = YES;
break;
case kShip_scriptInfo:
result = [entity scriptInfo];
if (result == nil) result = [NSDictionary dictionary]; // empty rather than NULL

View File

@ -288,7 +288,6 @@ enum
- (void) reinitAndShowDemo:(BOOL)showDemo;
- (int) obj_count;
#ifndef NDEBUG
- (void) obj_dump;

View File

@ -526,11 +526,17 @@ OOINLINE size_t class_getInstanceSize(Class cls)
{
// deal with the machine going to sleep
PlayerEntity *player = [PlayerEntity sharedPlayer];
if ((player)&&([player status] == STATUS_IN_FLIGHT))
if (!player) return;
if ([player status] == STATUS_DOCKED)
{
[self displayMessage:@" Paused (press 'p') " forCount:1.0];
[[gameView gameController] pause_game];
[self addMessage:DESC(@"game-paused-docked") forCount:1.0];
[message_gui leaveLastLine]; // remove other messages.
}
else
[self addMessage:DESC(@"game-paused") forCount:1.0];
[[gameView gameController] pause_game];
}
@ -1017,7 +1023,7 @@ OOINLINE size_t class_getInstanceSize(Class cls)
[a_station setPosition: stationPos];
[a_station setPitch: 0.0];
[a_station setScanClass: CLASS_STATION];
[a_station setPlanet:[self planet]];
//[a_station setPlanet:[self planet]]; // done inside addEntity.
[a_station setEquivalentTechLevel:techlevel];
[self addEntity:a_station]; // STATUS_IN_FLIGHT, AI state GLOBAL
[a_station setStatus:STATUS_ACTIVE]; // For backward compatibility. Might not be needed.