Ahruman's dazzling distraction attack strikes again. All beep, boop and click sounds now go through customsounds.plist. Setting the player's target through JS now works more or less as expected (locks on ident, with UI feedback, unless a missile is selected in which case current missile is locked on to the new target). Custom sound tags can now expand to other custom sound tags (with recursion checking), and final results are cached. No actual progress on the nova script I thought I was working on.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1477 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Jens Ayton 2008-03-11 19:49:46 +00:00
parent 627e5a9b57
commit f67b87aa0d
17 changed files with 677 additions and 389 deletions

View File

@ -1,4 +1,60 @@
{
/* Sound keys starting with @ are (by convention) only used within
customsounds.plist, not directly by the game.
*/
// Interface sounds
"[@beep]" = "beep.ogg"; // positive beep
"[@boop]" = "boop.ogg"; // negative beep
"[@click]" = "guiclick.ogg";
"[@switch-on]" = "[@beep]";
"[@switch-off]" = "[@boop]";
"[ident-on]" = "[@switch-on]"; // Turned on ident
"[ident-off]" = "[@switch-off]"; // Turned off ident
"[ident-locked-on]" = "[@beep]"; // Ident targeted ship
"[missile-locked-on]" = "[@beep]";
"[missile-armed]" = "[@beep]";
"[mine-armed]" = "[@beep]";
"[missile-safe]" = "[@boop]";
"[next-missile-selected]" = "[@click]";
"[save-overwrite-yes]" = "[@beep]"; // Player selects Overwrite on "are you sure you want to overwrite?" alert on save screen
"[save-overwrite-no]" = "[@boop]"; // Player selects Cancel on "are you sure you want to overwrite?" alert on save screen
"[buy-commodity]" = "buy.ogg";
"[buy-ship]" = "[buy-commodity]";
"[sell-commodity]" = "sell.ogg";
"[could-not-buy-any]" = "[@boop]";
"[could-not-buy-ship]" = "[could-not-buy-any]";
"[cargo-jettisoned]" = "[@beep]";
"[autopilot-on]" = "[@switch-on]";
"[autopilot-off]" = "[@switch-off]";
"[autopilot-out-of-range]" = "[@switch-off]";
"[autopilot-cannot-dock-with-target]" = "[@boop]";
"[hold-full]" = "[@boop]";
"[target-lost]" = "[@boop]";
"[no-target-in-memory]" = "[@boop]";
"[jump-mass-locked]" = "[@boop]"; // Target memory expansion could not be used
"[target-switched]" = "[@click]"; // Target memory expansion used successfully
"[cloaking-device-on]" = "[@switch-on]";
"[cloaking-device-off]" = "[@switch-off]";
"[cloaking-device-insufficent-energy]" = "[@boop]";
"[menu-navigation-up]" = "[@click]";
"[menu-navigation-down]" = "[@click]";
// "[menu-navigation-not]" = ""; // Attempt to go past end of a menu; no sound by default
"[menu-next-page]" = "[@click]";
"[menu-previous-page]" = "[@click]";
"[dismissed-report-screen]" = "[@click]";
"[dismissed-mission-screen]" = "[@click]"; // No way to differentiate between mission options
"[changed-option]" = "[@click]"; // Player made a change on options screen
// Hyperspace
"[hyperspace-countdown-begun]" = "[@beep]";
"[galactic-hyperspace-countdown-begun]" = "[@beep]";
"[hyperspace-countdown-aborted]" = "[@boop]";
"[witch-no-target]" = "[@boop]";
"[witch-no-fuel]" = "[@boop]";
"[witch-blocked-by-@]" = "[@boop]";
// Damage
"[player-hit-by-weapon]" = "hit.ogg"; // Hit by weapon
"[player-direct-hit]" = "hullbang.ogg"; // Hit by weapon while shield down ([player-hit-by-weapon] and [player-direct-hit] play at once)
@ -10,19 +66,21 @@
"[energy-bomb-fired]" = "bigbang.ogg";
// Warnings
"[hostile-warning]" = "warning.ogg";
"[alert-condition-red]" = "warning.ogg";
"[incoming-missile]" = "warning.ogg"; // Help, help, they're shooting at us
"[@warning]" = "warning.ogg"; // Not used directly by game, only by references below.
"[hostile-warning]" = "[@warning]";
"[alert-condition-red]" = "[@warning]";
"[incoming-missile]" = "[@warning]"; // Help, help, they're shooting at us
// "[energy-low]" = ""; // Energy below 25% - may occur repeatedly
"[autopilot-denied]" = "warning.ogg"; // Station refuses docking clearance
"[autopilot-denied]" = "[@warning]"; // Station refuses docking clearance
"[witchdrive-malfunction]" = "ecm.ogg"; // Misjump (3/4 witchjump malfunctions)
"[witchdrive-failure]" = "warning.ogg"; // Jump failed, internal damage (1/8 witchjump malfunctions; other 1/8 is fuel leak, see [fuel-leak])
"[fuel-leak]" = "warning.ogg";
"[witchdrive-failure]" = "[@warning]"; // Jump failed, internal damage (1/8 witchjump malfunctions; other 1/8 is fuel leak, see [fuel-leak])
"[fuel-leak]" = "[@warning]";
// Tunnel effects
"[player-launch-from-station]" = "breakpattern.ogg";
"[player-dock-with-station]" = "breakpattern.ogg";
"[player-exit-witchspace]" = "breakpattern.ogg";
"[@breakpattern]" = "breakpattern.ogg"; // Not used directly by game, only by references below.
"[player-launch-from-station]" = "[@breakpattern]";
"[player-dock-with-station]" = "[@breakpattern]";
"[player-exit-witchspace]" = "[@breakpattern]";
// ECM
"[player-fired-ecm]" = "ecm.ogg";
@ -37,28 +95,16 @@
"[autopilot-off]" = "";
"[autopilot-on]" = "";
"[autopilot-out-of-range]" = "";
"[cargo-jettisoned]" = "";
"[cloaking-device-off]" = "";
"[cloaking-device-on]" = "";
"[escape-pod-scooped]" = "";
"[galactic-hyperspace-countdown-begun]" = "";
"[game-over]" = "";
"[hold-full]" = "";
"[hyperspace-countdown-aborted]" = "";
"[hyperspace-countdown-begun]" = "";
"[ident-locked-on]" = "";
"[ident-off]" = "";
"[ident-on]" = "";
"[incoming-missile]" = "";
"[jump-mass-locked]" = "";
"[mine-armed]" = "";
"[mine-launched]" = "";
"[missile-armed]" = "";
"[missile-launched]" = "";
"[missile-locked-on]" = "";
"[missile-safe]" = "";
"[no-target-in-memory]" = "";
"[target-lost]" = "";
"[weapon-overheat]" = "";
"[witch-blocked-by-@]" = "";
"[witch-no-fuel]" = "";

View File

@ -550,14 +550,14 @@
);
"station-hold-position" =
(
"Please be patient - you are being held in a docking queue.",
"Please be patient you are being held in a docking queue.",
"Docking sequence will recommence shortly. Thank you for your patience.",
"Traffic is heavy, please continue to hold until we can clear an approach for you.",
"You are being queued for docking. Thank you for your patience."
);
"station-acknowledges-hold-position" =
(
"Please be patient - we are preparing to accommodate your vessel.",
"Please be patient we are preparing to accommodate your vessel.",
"Docking sequence will recommence shortly. Thank you for waiting.",
"We are preparing an approach for you. Please wait.",
"Preparing approach for docking. Thank you for your patience.",
@ -746,7 +746,7 @@
"press-space-commander" = "Press Space Commander";
// Intro1 screen
"game-copyright" = "by Giles Williams and contributors © 2003-2008";
"game-copyright" = "by Giles Williams and contributors © 20032008";
"theme-music-credit" = "Oolite Theme Music by NoSleep © 2004";
"load-previous-commander" = "Load Previous Commander (Y/N)?";
"load-previous-commander-yes" = "y"; // Defines the key that corresponds to the yes answer to load-previous-commnader.
@ -940,9 +940,9 @@
"savescreen-commander-name-@" = "Commander name: %@";
"savescreen-commander-name" = "Commander name: ";
"overwrite-save-commander-@" = "Save Commander %@";
"overwritescreen-commander-@-already-exists-overwrite-query" = "Commander %@ already exists - overwrite this saved game?";
"overwritescreen-yes" = " YES ";
"overwritescreen-no" = " NO ";
"overwritescreen-commander-@-already-exists-overwrite-query" = "A file named %@ already exists. Do you wish to overwrite it?";
"overwritescreen-yes" = " Overwrite ";
"overwritescreen-no" = " Cancel ";
// Mission screen
"mission-information" = "Mission Information";
@ -957,7 +957,7 @@
"adjusting-word" = " (adjusting)";
"strict-play-enabled" = "Strict Play Enabled";
"unrestricted-play-enabled" = "Unrestricted Play Enabled";
"human-word" = "human"; // Important - only lower case characters here!
"human-word" = "human"; // Important only lower case characters here!
"human-colonial-description" = "Human Colonial";
"human-colonial-description-plural" = "Human Colonials";
"clock-format" = "%07d:%02d:%02d:%02d";

View File

@ -295,6 +295,9 @@
sky.setup = no;
sounds.customSounds.recursion = $error; // Circular dependency in customsounds.plist, e.g. [foo] = [bar], [bar] = [foo].
strings.conversion = $scriptError; // Conversion of text to values (vectors, quaternions etc)
strings.conversion.vector = inherit;
strings.conversion.quaternion = inherit;

View File

@ -45,6 +45,7 @@ this.missionOffers = function ()
if (missionVariables.nova == "TWO_HRS_TO_ZERO")
{
mission.runMissionScreen("nova_1", "solar.png", "nova_yesno");
log("nova.missionOffers", "Setting this.novaOffer to \"NOVA_CHOICE\"");
this.novaOffer = "NOVA_CHOICE"; // use a temporary variable for the offering.
this.novaMissionTimer.stop();
}
@ -76,14 +77,19 @@ this.missionOffers = function ()
this.choiceEvaluation = function()
{
if (!this.novaOffer) return;
if (!this.novaOffer)
{
log("nova.choicesEvaluation", "Exiting early because !this.novaOffer.");
return;
}
if (this.novaOffer == "NOVA_CHOICE")
{
log("nova.choicesEvaluation", "Evaluating this.novaOffer == \"NOVA_CHOICE\"");
if (mission.choice == "YES")
{
log("nova.choicesEvaluation", "mission.choice == YES, player loaded refugees.");
mission.choice = null;
this.novaOffer = null;
player.useSpecialCargo(expandDescription("[oolite-nova-refugees]"));
mission.setInstructionsKey("nova_missiondesc");
missionVariables.nova = "NOVA_ESCAPE_HERO";
@ -94,17 +100,21 @@ this.choiceEvaluation = function()
}
else
{
log("nova.choicesEvaluation", "mission.choice == " + mission.choice + ", player refused to help.");
// mission.choice = "NO", or null when player launched without a choice.
mission.choice = null;
this.novaOffer = null;
missionVariables.nova = "NOVA_ESCAPE_COWARD";
player.commsMessage(expandDescription("[oolite-nova-coward]"), 4.5);
system.setSunNova(3);
missionVariables.novacount = null;
}
delete this.novaOffer;
log("nova.choicesEvaluation", "deleted this.novaOffer, this.novaOffer is now " + this.novaOffer);
}
}
// general, used when player enters nova system after mission.
this.sendShipsAway = function()
{
@ -157,6 +167,7 @@ this.missionScreenEnded = this.missionChoiceWasReset = function ()
if (player.docked) this.missionOffers();
}
this.shipWillExitWitchspace = function () // call this as soon as possible so other scripts can see it will go nova.
{
if (galaxyNumber == 3)

View File

@ -36,6 +36,15 @@ SOFTWARE.
#import "OOJavaScriptEngine.h"
#import "OOJSScript.h"
#import "OOJSVector.h"
#import "OOJSEntity.h"
@interface Entity (OODebugInspector)
// Method added by inspector in Debug OXP under OS X only.
- (void) inspect;
@end
static JSObject *sConsolePrototype = NULL;
@ -48,6 +57,7 @@ static void ConsoleFinalize(JSContext *context, JSObject *this);
static JSBool ConsoleConsoleMessage(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
static JSBool ConsoleClearConsole(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
static JSBool ConsoleScriptStack(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
static JSBool ConsoleInspectEntity(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
static JSBool ConsoleSettingsDeleteProperty(JSContext *context, JSObject *this, jsval name, jsval *outValue);
static JSBool ConsoleSettingsGetProperty(JSContext *context, JSObject *this, jsval name, jsval *outValue);
@ -77,6 +87,7 @@ static JSFunctionSpec sConsoleMethods[] =
{ "consoleMessage", ConsoleConsoleMessage, 2 },
{ "clearConsole", ConsoleClearConsole, 0 },
{ "scriptStack", ConsoleScriptStack, 0 },
{ "inspectEntity", ConsoleInspectEntity, 1 },
{ 0 }
};
@ -320,4 +331,20 @@ static JSBool ConsoleScriptStack(JSContext *context, JSObject *this, uintN argc,
return YES;
}
static JSBool ConsoleInspectEntity(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult)
{
Entity *entity = nil;
if (JSValueToEntity(context, argv[0], &entity))
{
if ([entity respondsToSelector:@selector(inspect)])
{
[entity inspect];
}
}
return YES;
}
#endif /* OO_EXCLUDE_DEBUG_SUPPORT */

View File

@ -278,20 +278,13 @@ typedef enum
double ecm_start_time;
OOSound *beepSound;
OOSound *boopSound;
OOSound *missileSound;
OOSound *buySound;
OOSound *sellSound;
OOSound *afterburner1Sound;
OOSound *afterburner2Sound;
OOSound *witchAbortSound;
OOSound *fuelScoopSound;
OOSoundReferencePoint *refPoint;
OOSoundSource *interfaceBeepSource;
OOSoundSource *ecmSource;
OOSoundSource *breakPatternSource;
OOGUIScreenID gui_screen;
OOAlertFlags alertFlags;
@ -654,8 +647,7 @@ waitingForStickCallback: 1;
- (void) setScoopsActive;
- (void) clearTargetMemory;
- (BOOL) selectNextTargetFromMemory;
- (BOOL) selectPreviousTargetFromMemory;
- (BOOL) moveTargetMemoryBy:(int)delta;
- (void) printIdentLockedOnForMissile:(BOOL)missile;

View File

@ -1587,8 +1587,7 @@ double scoopSoundPlayTime = 0.0;
if (!suppressTargetLost)
{
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[target-lost]") forCount:3.0];
if (![UNIVERSE playCustomSound:@"[target-lost]"])
[self boop];
[self playTargetLost];
}
else
{
@ -1615,8 +1614,7 @@ double scoopSoundPlayTime = 0.0;
if ((!target_ship)||(target_ship->zero_distance > SCANNER_MAX_RANGE2))
{
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[target-lost]") forCount:3.0];
if (![UNIVERSE playCustomSound:@"[target-lost]"])
[self boop];
[self playTargetLost];
[missile_entity[i] removeTarget:nil];
if ((i == activeMissile)&&(!ident_engaged))
{
@ -1627,31 +1625,12 @@ double scoopSoundPlayTime = 0.0;
}
}
if ((missile_status == MISSILE_STATUS_ARMED)&&(ident_engaged||[missile_entity[activeMissile] isMissile])&&((status == STATUS_IN_FLIGHT)||(status == STATUS_WITCHSPACE_COUNTDOWN)))
if (missile_status == MISSILE_STATUS_ARMED &&
(ident_engaged || [missile_entity[activeMissile] isMissile]) &&
(status == STATUS_IN_FLIGHT || status == STATUS_WITCHSPACE_COUNTDOWN))
{
int first_target_id = [UNIVERSE getFirstEntityTargettedByPlayer:self];
if (first_target_id != NO_TARGET)
{
Entity *first_target = [UNIVERSE entityForUniversalID:first_target_id];
if ([first_target isShip])
{
[self addTarget: first_target];
missile_status = MISSILE_STATUS_TARGET_LOCKED;
if ((missile_entity[activeMissile])&&(!ident_engaged))
[missile_entity[activeMissile] addTarget:first_target];
[self printIdentLockedOnForMissile:!ident_engaged];
if (ident_engaged)
{
if (![UNIVERSE playCustomSound:@"[ident-locked-on]"])
[self beep];
}
else
{
if (![UNIVERSE playCustomSound:@"[missile-locked-on]"])
[self beep];
}
}
}
ShipEntity *target = [UNIVERSE getFirstEntityTargettedByPlayer];
if (target != nil) [self addTarget:target];
}
}
@ -1669,38 +1648,19 @@ double scoopSoundPlayTime = 0.0;
air_friction = 0.5 * [UNIVERSE airResistanceFactor];
// cool all weapons
if (forward_weapon_temp > 0.0)
{
forward_weapon_temp -= WEAPON_COOLING_FACTOR * delta_t;
if (forward_weapon_temp < 0.0)
forward_weapon_temp = 0.0;
}
if (aft_weapon_temp > 0.0)
{
aft_weapon_temp -= WEAPON_COOLING_FACTOR * delta_t;
if (aft_weapon_temp < 0.0)
aft_weapon_temp = 0.0;
}
if (port_weapon_temp > 0.0)
{
port_weapon_temp -= WEAPON_COOLING_FACTOR * delta_t;
if (port_weapon_temp < 0.0)
port_weapon_temp = 0.0;
}
if (starboard_weapon_temp > 0.0)
{
starboard_weapon_temp -= WEAPON_COOLING_FACTOR * delta_t;
if (starboard_weapon_temp < 0.0)
starboard_weapon_temp = 0.0;
}
// copy new temp to main temp
forward_weapon_temp = fmaxf(forward_weapon_temp - WEAPON_COOLING_FACTOR * delta_t, 0.0);
aft_weapon_temp = fmaxf(aft_weapon_temp - WEAPON_COOLING_FACTOR * delta_t, 0.0);
port_weapon_temp = fmaxf(port_weapon_temp - WEAPON_COOLING_FACTOR * delta_t, 0.0);
starboard_weapon_temp = fmaxf(starboard_weapon_temp - WEAPON_COOLING_FACTOR * delta_t, 0.0);
// copy new temp to main temp
switch (currentWeaponFacing)
{
case VIEW_GUI_DISPLAY:
case VIEW_NONE:
case VIEW_BREAK_PATTERN:
case VIEW_FORWARD:
case VIEW_CUSTOM:
weapon_temp = forward_weapon_temp;
break;
case VIEW_AFT:
@ -1712,8 +1672,6 @@ double scoopSoundPlayTime = 0.0;
case VIEW_STARBOARD:
weapon_temp = starboard_weapon_temp;
break;
case VIEW_CUSTOM:
break;
}
// cloaking device
@ -1877,8 +1835,7 @@ double scoopSoundPlayTime = 0.0;
if (hyperspeed_locked)
{
if (![UNIVERSE playCustomSound:@"[jump-mass-locked]"])
[self boop];
[self playJumpMassLocked];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[jump-mass-locked]") forCount:4.5];
hyperspeed_engaged = NO;
}
@ -2640,8 +2597,7 @@ double scoopSoundPlayTime = 0.0;
{
if ([ms isEqual:@"HOLD_FULL"])
{
if (![UNIVERSE playCustomSound:@"[hold-full]"])
[self beep];
[self playHoldFull];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[hold-full]") forCount:4.5];
}
@ -3267,6 +3223,7 @@ double scoopSoundPlayTime = 0.0;
if (result != CARGO_NOT_CARGO)
{
[UNIVERSE addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[@-ejected]") ,[UNIVERSE displayNameForCommodity:result]] forCount:3.0];
[self playCargoJettisioned];
}
return result;
}
@ -5118,6 +5075,8 @@ static int last_outfitting_index;
int item = [key intValue];
NSString *item_text = [gui selectedRowText];
// FIXME: this is nuts, should be associating lines with keys in sone sensible way. --Ahruman 20080311
if ([item_text isEqual:FORWARD_FACING_STRING])
chosen_weapon_facing = WEAPON_FACING_FORWARD;
if ([item_text isEqual:AFT_FACING_STRING])
@ -5132,14 +5091,13 @@ static int last_outfitting_index;
{
if (credits == old_credits)
{
[[UNIVERSE gui] click];
[self playCantBuyBuyCommodity];
}
else
{
[self playInterfaceBeep:kInterfaceBeep_Buy];
[self playBuyCommodity];
// wind the clock forward by 10 minutes plus 10 minutes for every 60 credits spent
double time_adjust = (old_credits > credits) ? (old_credits - credits) : 0.0;
ship_clock_adjust += time_adjust + 600.0;
}
@ -5147,7 +5105,7 @@ static int last_outfitting_index;
}
else
{
[self boop];
[self playCantBuyBuyCommodity];
}
}
@ -6198,17 +6156,28 @@ OOSound* burnersound;
// override shipentity addTarget to implement target_memory
- (void) addTarget:(Entity *) targetEntity
{
if (status != STATUS_IN_FLIGHT && status != STATUS_WITCHSPACE_COUNTDOWN) return;
if (missile_status == MISSILE_STATUS_SAFE)
{
missile_status = MISSILE_STATUS_ARMED;
ident_engaged = YES;
}
[super addTarget:targetEntity];
missile_status = MISSILE_STATUS_TARGET_LOCKED;
if ([self hasExtraEquipment:@"EQ_TARGET_MEMORY"])
{
int i = 0;
BOOL foundSlot = NO;
// if targetted previously use that memory space
for (i = 0; i < PLAYER_TARGET_MEMORY_SIZE; i++)
{
if (primaryTarget == target_memory[i])
{
target_memory_index = i;
return;
foundSlot = YES;
break;
}
}
// find and use a blank space in memory
@ -6217,14 +6186,31 @@ OOSound* burnersound;
if (target_memory[target_memory_index] == NO_TARGET)
{
target_memory[target_memory_index] = primaryTarget;
return;
foundSlot = YES;
break;
}
target_memory_index = (target_memory_index + 1) % PLAYER_TARGET_MEMORY_SIZE;
}
if (!foundSlot)
{
// use the next memory space
target_memory_index = (target_memory_index + 1) % PLAYER_TARGET_MEMORY_SIZE;
target_memory[target_memory_index] = primaryTarget;
return;
}
}
if (missile_entity[activeMissile] == nil && ident_engaged) ident_engaged = YES;
if (ident_engaged)
{
[self playIdentLockedOn];
[self printIdentLockedOnForMissile:NO];
}
else
{
[missile_entity[activeMissile] addTarget:targetEntity];
[self playMissileLockedOn];
[self printIdentLockedOnForMissile:YES];
}
}
@ -6257,28 +6243,19 @@ OOSound* burnersound;
[super addTarget:potential_target];
missile_status = MISSILE_STATUS_TARGET_LOCKED;
[self printIdentLockedOnForMissile:!ident_engaged];
[self playTargetSwitched];
return YES;
}
}
else
target_memory[target_memory_index] = NO_TARGET; // tidy up
}
[self playNoTargetInMemory];
return NO;
}
- (BOOL) selectNextTargetFromMemory
{
return [self moveTargetMemoryBy:+1];
}
- (BOOL) selectPreviousTargetFromMemory
{
return [self moveTargetMemoryBy:-1];
}
- (void) printIdentLockedOnForMissile:(BOOL)missile
{
NSString *fmt = nil;

View File

@ -305,9 +305,13 @@ static NSTimeInterval time_last_frame;
{
if ([gui setNextRow: +1])
{
[gui click];
[self playMenuNavigationDown];
result = YES;
}
else
{
[self playMenuNavigationNot];
}
timeLastKeyPress = script_time;
}
}
@ -318,9 +322,13 @@ static NSTimeInterval time_last_frame;
{
if ([gui setNextRow: -1])
{
[gui click];
[self playMenuNavigationUp];
result = YES;
}
else
{
[self playMenuNavigationNot];
}
timeLastKeyPress = script_time;
}
}
@ -570,8 +578,7 @@ static NSTimeInterval time_last_frame;
hyperspeed_engaged = !hyperspeed_locked;
if (hyperspeed_locked)
{
if (![UNIVERSE playCustomSound:@"[jump-mass-locked]"])
[self boop];
[self playJumpMassLocked];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[jump-mass-locked]") forCount:1.5];
}
}
@ -619,7 +626,7 @@ static NSTimeInterval time_last_frame;
{
if ((!ident_engaged)&&(!next_missile_pressed)&&([self hasExtraEquipment:@"EQ_MULTI_TARGET"]))
{
[[UNIVERSE gui] click];
[self playNextMissileSelected];
[self selectNextMissile];
}
next_missile_pressed = YES;
@ -632,13 +639,7 @@ static NSTimeInterval time_last_frame;
{
if ((!next_target_pressed)&&([self hasExtraEquipment:@"EQ_TARGET_MEMORY"]))
{
if ([self selectNextTargetFromMemory])
[[UNIVERSE gui] click];
else
{
if (![UNIVERSE playCustomSound:@"[no-target-in-memory]"])
[self boop];
}
[self moveTargetMemoryBy:+1];
}
next_target_pressed = YES;
}
@ -650,13 +651,7 @@ static NSTimeInterval time_last_frame;
{
if ((!previous_target_pressed)&&([self hasExtraEquipment:@"EQ_TARGET_MEMORY"]))
{
if ([self selectPreviousTargetFromMemory])
[[UNIVERSE gui] click];
else
{
if (![UNIVERSE playCustomSound:@"[no-target-in-memory]"])
[self boop];
}
[self moveTargetMemoryBy:-1];
}
previous_target_pressed = YES;
}
@ -672,8 +667,7 @@ static NSTimeInterval time_last_frame;
missile_status = MISSILE_STATUS_ARMED;
primaryTarget = NO_TARGET;
ident_engaged = YES;
if (![UNIVERSE playCustomSound:@"[ident-on]"])
[self beep];
[self playIdentOn];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[ident-on]") forCount:2.0];
}
ident_pressed = YES;
@ -695,8 +689,7 @@ static NSTimeInterval time_last_frame;
missile_status = MISSILE_STATUS_TARGET_LOCKED;
[missile_entity[activeMissile] addTarget:[self primaryTarget]];
[self printIdentLockedOnForMissile:YES];
if (![UNIVERSE playCustomSound:@"[missile-locked-on]"])
[self beep];
[self playMissileLockedOn];
}
}
else
@ -707,15 +700,13 @@ static NSTimeInterval time_last_frame;
if (missile_entity[activeMissile])
[missile_entity[activeMissile] removeTarget:nil];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[missile-armed]") forCount:2.0];
if (![UNIVERSE playCustomSound:@"[missile-armed]"])
[self beep];
[self playMissileArmed];
}
}
if ([missile_entity[activeMissile] isMine])
{
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[mine-armed]") forCount:4.5];
if (![UNIVERSE playCustomSound:@"[mine-armed]"])
[self beep];
[self playMineArmed];
}
ident_engaged = NO;
}
@ -735,8 +726,7 @@ static NSTimeInterval time_last_frame;
missile_status = MISSILE_STATUS_SAFE;
primaryTarget = NO_TARGET;
[self safeAllMissiles];
if (![UNIVERSE playCustomSound:@"[missile-safe]"])
[self boop];
[self playMissileSafe];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[missile-safe]") forCount:2.0];
}
else
@ -744,8 +734,7 @@ static NSTimeInterval time_last_frame;
// targetting 'back on' here
primaryTarget = [missile_entity[activeMissile] primaryTargetID];
missile_status = (primaryTarget != NO_TARGET)? MISSILE_STATUS_TARGET_LOCKED : MISSILE_STATUS_SAFE;
if (![UNIVERSE playCustomSound:@"[ident-off]"])
[self boop];
[self playIdentOff];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[ident-off]") forCount:2.0];
}
ident_engaged = NO;
@ -786,11 +775,7 @@ static NSTimeInterval time_last_frame;
// shoot 'd' // Dump Cargo
if (([gameView isDown:key_dump_cargo] || joyButtonState[BUTTON_JETTISON])&&([cargo count] > 0))
{
if ([self dumpCargo] != CARGO_NOT_CARGO)
{
if (![UNIVERSE playCustomSound:@"[cargo-jettisoned]"])
[self beep];
}
[self dumpCargo];
}
// shoot 'R' // Rotate Cargo
@ -816,8 +801,7 @@ static NSTimeInterval time_last_frame;
if ([self checkForAegis] != AEGIS_IN_DOCKING_RANGE)
{
isOkayToUseAutopilot = NO;
if (![UNIVERSE playCustomSound:@"[autopilot-out-of-range]"])
[self boop];
[self playAutopilotOutOfRange];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[autopilot-out-of-range]") forCount:4.5];
}
}
@ -832,8 +816,7 @@ static NSTimeInterval time_last_frame;
velocity = kZeroVector;
status = STATUS_AUTOPILOT_ENGAGED;
[shipAI setState:@"GLOBAL"]; // reboot the AI
if (![UNIVERSE playCustomSound:@"[autopilot-on]"])
[self beep];
[self playAutopilotOn];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[autopilot-on]") forCount:4.5];
[self doScriptEvent:@"playerStartedAutoPilot"];
@ -868,8 +851,7 @@ static NSTimeInterval time_last_frame;
velocity = kZeroVector;
status = STATUS_AUTOPILOT_ENGAGED;
[shipAI setState:@"GLOBAL"]; // restart the AI
if (![UNIVERSE playCustomSound:@"[autopilot-on]"])
[self beep];
[self playAutopilotOn];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[autopilot-on]") forCount:4.5];
[self doScriptEvent:@"playerStartedAutoPilot"];
@ -884,8 +866,7 @@ static NSTimeInterval time_last_frame;
}
else
{
if (![UNIVERSE playCustomSound:@"[autopilot-cannot-dock-with-target]"])
[self boop];
[self playAutopilotCannotDockWithTarget];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"Target is not capable of autopilot-docking") forCount:4.5];
}
}
@ -915,7 +896,7 @@ static NSTimeInterval time_last_frame;
{
// there's a slight chance you'll be fined for your past offences when autodocking
int fine_chance = ranrot_rand() & 0x03ff; // 0..1023
int government = 1 + [(NSNumber *)[[UNIVERSE currentSystemData] objectForKey:KEY_GOVERNMENT] intValue]; // 1..8
int government = 1 + [[UNIVERSE currentSystemData] intForKey:KEY_GOVERNMENT]; // 1..8
fine_chance /= government;
if (fine_chance < legalStatus)
[self markForFines];
@ -930,8 +911,7 @@ static NSTimeInterval time_last_frame;
}
else
{
if (![UNIVERSE playCustomSound:@"[autopilot-out-of-range]"])
[self boop];
[self playAutopilotOutOfRange];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[autopilot-out-of-range]") forCount:4.5];
}
}
@ -952,8 +932,7 @@ static NSTimeInterval time_last_frame;
if ((dx == 0) && (dy == 0) && equal_seeds(target_system_seed, system_seed))
{
if (![UNIVERSE playCustomSound:@"[witch-no-target]"])
[self boop];
[self playHyperspaceNoTarget];
[UNIVERSE clearPreviousMessage];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[witch-no-target]") forCount:3.0];
jumpOK = NO;
@ -961,8 +940,7 @@ static NSTimeInterval time_last_frame;
if ((10.0 * distance > fuel)||(fuel == 0))
{
if (![UNIVERSE playCustomSound:@"[witch-no-fuel]"])
[self boop];
[self playHyperspaceNoFuel];
[UNIVERSE clearPreviousMessage];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[witch-no-fuel]") forCount:3.0];
jumpOK = NO;
@ -971,18 +949,10 @@ static NSTimeInterval time_last_frame;
if (status == STATUS_WITCHSPACE_COUNTDOWN)
{
// abort!
#if 0
// FIXME: should use an OOSoundSource.
if (galactic_witchjump)
[UNIVERSE stopCustomSound:@"[galactic-hyperspace-countdown-begun]"];
else
[UNIVERSE stopCustomSound:@"[hyperspace-countdown-begun]"];
#endif
jumpOK = NO;
galactic_witchjump = NO;
status = STATUS_IN_FLIGHT;
if (![UNIVERSE playCustomSound:@"[hyperspace-countdown-aborted]"])
[self boop];
[self playHyperspaceAborted];
// say it!
[UNIVERSE clearPreviousMessage];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[witch-user-abort]") forCount:3.0];
@ -995,8 +965,7 @@ static NSTimeInterval time_last_frame;
galactic_witchjump = NO;
witchspaceCountdown = 15.0;
status = STATUS_WITCHSPACE_COUNTDOWN;
if (![UNIVERSE playCustomSound:@"[hyperspace-countdown-begun]"])
[self beep];
[self playStandardHyperspace];
// say it!
[UNIVERSE clearPreviousMessage];
[UNIVERSE addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[witch-to-@-in-f-seconds]"), [UNIVERSE getSystemName:target_system_seed], witchspaceCountdown] forCount:1.0];
@ -1019,18 +988,10 @@ static NSTimeInterval time_last_frame;
if (status == STATUS_WITCHSPACE_COUNTDOWN)
{
// abort!
#if 0
// FIXME: should use an OOSoundSource.
if (galactic_witchjump)
[UNIVERSE stopCustomSound:@"[galactic-hyperspace-countdown-begun]"];
else
[UNIVERSE stopCustomSound:@"[hyperspace-countdown-begun]"];
#endif
jumpOK = NO;
galactic_witchjump = NO;
status = STATUS_IN_FLIGHT;
if (![UNIVERSE playCustomSound:@"[hyperspace-countdown-aborted]"])
[self boop];
[self playHyperspaceAborted];
// say it!
[UNIVERSE clearPreviousMessage];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[witch-user-abort]") forCount:3.0];
@ -1043,9 +1004,7 @@ static NSTimeInterval time_last_frame;
galactic_witchjump = YES;
witchspaceCountdown = 15.0;
status = STATUS_WITCHSPACE_COUNTDOWN;
if (![UNIVERSE playCustomSound:@"[galactic-hyperspace-countdown-begun]"])
if (![UNIVERSE playCustomSound:@"[hyperspace-countdown-begun]"])
[self beep];
[self playGalacticHyperspace];
// say it!
[UNIVERSE addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[witch-galactic-in-f-seconds]"), witchspaceCountdown] forCount:1.0];
@ -1065,25 +1024,21 @@ static NSTimeInterval time_last_frame;
if (!cloaking_device_active)
{
if ([self activateCloakingDevice])
{
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[cloak-on]") forCount:2];
[self playCloakingDeviceOn];
}
else
{
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[cloak-low-juice]") forCount:3];
[self playCloakingDeviceInsufficientEnergy];
}
}
else
{
[self deactivateCloakingDevice];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[cloak-off]") forCount:2];
}
if (cloaking_device_active)
{
if (![UNIVERSE playCustomSound:@"[cloaking-device-on]"])
[self beep];
}
else
{
if (![UNIVERSE playCustomSound:@"[cloaking-device-off]"])
[self boop];
[self playCloakingDeviceOff];
}
}
cloak_pressed = YES;
@ -1560,7 +1515,7 @@ static NSTimeInterval time_last_frame;
{
if ([[gui keyForRow:GUI_ROW_EQUIPMENT_START] hasPrefix:@"More:"])
{
[gui click];
[self playMenuPagePrevious];
[gui setSelectedRow:GUI_ROW_EQUIPMENT_START];
[self buySelectedItem];
}
@ -1573,7 +1528,7 @@ static NSTimeInterval time_last_frame;
{
if ([[gui keyForRow:GUI_ROW_EQUIPMENT_START + GUI_MAX_ROWS_EQUIPMENT - 1] hasPrefix:@"More:"])
{
[gui click];
[self playMenuPageNext];
[gui setSelectedRow:GUI_ROW_EQUIPMENT_START + GUI_MAX_ROWS_EQUIPMENT - 1];
[self buySelectedItem];
}
@ -1614,9 +1569,13 @@ static NSTimeInterval time_last_frame;
{
int item = [(NSString *)[gui selectedRowKey] intValue];
if ([self tryBuyingCommodity:item])
{
[self setGuiToMarketScreen];
}
else
[self boop];
{
[self playCantBuyBuyCommodity];
}
wait_for_key_up = YES;
}
}
@ -1626,9 +1585,13 @@ static NSTimeInterval time_last_frame;
{
int item = [(NSString *)[gui selectedRowKey] intValue];
if ([self trySellingCommodity:item])
{
[self setGuiToMarketScreen];
}
else
[self boop];
{
[self playCantBuyBuyCommodity];
}
wait_for_key_up = YES;
}
}
@ -1642,13 +1605,13 @@ static NSTimeInterval time_last_frame;
if (!wait_for_key_up)
{
int item = [(NSString *)[gui selectedRowKey] intValue];
int yours = [(NSNumber *)[(NSArray *)[shipCommodityData objectAtIndex:item] objectAtIndex:1] intValue];
int yours = [[shipCommodityData arrayAtIndex:item] intAtIndex:1];
if ((yours > 0)&&(![self marketFlooded:item])) // sell all you can
{
int i;
for (i = 0; i < yours; i++)
[self trySellingCommodity:item];
[self playInterfaceBeep:kInterfaceBeep_Sell];
[self playSellCommodity];
[self setGuiToMarketScreen];
}
else // buy as much as possible
@ -1659,11 +1622,11 @@ static NSTimeInterval time_last_frame;
[self setGuiToMarketScreen];
if (amount_bought == 0)
{
[self boop];
[self playCantBuyBuyCommodity];
}
else
{
[self playInterfaceBeep:kInterfaceBeep_Buy];
[self playBuyCommodity];
}
}
wait_for_key_up = YES;
@ -1691,12 +1654,12 @@ static NSTimeInterval time_last_frame;
{
if ([self pickFromGuiContractsScreen])
{
[self playInterfaceBeep:kInterfaceBeep_Buy];
[self playBuyCommodity];
[self setGuiToContractsScreen];
}
else
{
[self boop];
[self playCantBuyBuyCommodity];
}
}
selectPressed = YES;
@ -1724,7 +1687,7 @@ static NSTimeInterval time_last_frame;
{
if (!spacePressed)
{
[gui click];
[self playDismissedReportScreen];
[self setGuiToStatusScreen];
}
spacePressed = YES;
@ -1745,7 +1708,7 @@ static NSTimeInterval time_last_frame;
{
if ([[gui keyForRow:GUI_ROW_SHIPYARD_START] hasPrefix:@"More:"])
{
[gui click];
[self playMenuPagePrevious];
[gui setSelectedRow:GUI_ROW_SHIPYARD_START];
[self buySelectedShip];
}
@ -1758,7 +1721,7 @@ static NSTimeInterval time_last_frame;
{
if ([[gui keyForRow:GUI_ROW_SHIPYARD_START + MAX_ROWS_SHIPS_FOR_SALE - 1] hasPrefix:@"More:"])
{
[gui click];
[self playMenuPageNext];
[gui setSelectedRow:GUI_ROW_SHIPYARD_START + MAX_ROWS_SHIPS_FOR_SALE - 1];
[self buySelectedShip];
}
@ -1777,18 +1740,18 @@ static NSTimeInterval time_last_frame;
{
if (money == credits) // we just skipped to another page
{
[gui click];
[self playCantBuyBuyShip];
}
else
{
[UNIVERSE removeDemoShips];
[self setGuiToStatusScreen];
[self playInterfaceBeep: kInterfaceBeep_Buy];
[self playBuyShip];
}
}
else
{
[self boop];
[self playCantBuyBuyCommodity];
}
}
selectPressed = YES;
@ -1881,7 +1844,7 @@ static NSTimeInterval time_last_frame;
#endif
NSString *displayModeString = [self screenModeStringForWidth:modeWidth height:modeHeight refreshRate:modeRefresh];
[gui click];
[self playChangedOption];
[gui setText:displayModeString forRow:GUI_ROW_GAMEOPTIONS_DISPLAY align:GUI_ALIGN_CENTER];
switching_resolution = YES;
}
@ -1895,7 +1858,7 @@ static NSTimeInterval time_last_frame;
{
GuiDisplayGen* gui = [UNIVERSE gui];
if ([gameView isDown:gvArrowKeyRight] != isSpeechOn)
[gui click];
[self playChangedOption];
isSpeechOn = [gameView isDown:gvArrowKeyRight];
if (isSpeechOn)
[gui setText:DESC(@"gameoptions-spoken-messages-yes") forRow:GUI_ROW_GAMEOPTIONS_SPEECH align:GUI_ALIGN_CENTER];
@ -1909,7 +1872,7 @@ static NSTimeInterval time_last_frame;
// FIXME: Music mode UI
/*GuiDisplayGen* gui = [UNIVERSE gui];
if ([gameView isDown:gvArrowKeyRight] != ootunes_on)
[gui click];
[self playChangedOption];
ootunes_on = [gameView isDown:gvArrowKeyRight];
if (ootunes_on)
[gui setText:DESC(@"gameoptions-itunes-yes") forRow:GUI_ROW_GAMEOPTIONS_OOTUNES align:GUI_ALIGN_CENTER];
@ -1921,7 +1884,7 @@ static NSTimeInterval time_last_frame;
{
GuiDisplayGen* gui = [UNIVERSE gui];
if ([gameView isDown:gvArrowKeyRight] != [UNIVERSE autoSave])
[gui click];
[self playChangedOption];
[UNIVERSE setAutoSave:[gameView isDown:gvArrowKeyRight]];
if ([UNIVERSE autoSave])
[gui setText:DESC(@"gameoptions-autosave-yes") forRow:GUI_ROW_GAMEOPTIONS_AUTOSAVE align:GUI_ALIGN_CENTER];
@ -1943,7 +1906,7 @@ static NSTimeInterval time_last_frame;
if (volume > 100) volume = 100;
if (volume < 0) volume = 0;
[OOSound setMasterVolume: 0.01 * volume];
[gui click];
[self playChangedOption];
if (volume > 0)
{
NSString* soundVolumeWordDesc = DESC(@"gameoptions-sound-volume");
@ -1989,7 +1952,7 @@ static NSTimeInterval time_last_frame;
NSString* growl_priority_desc = [Groolite priorityDescription:growl_min_priority];
[gui setText:[NSString stringWithFormat:DESC(@"gameoptions-show-growl-messages-@"), growl_priority_desc]
forRow:GUI_ROW_GAMEOPTIONS_GROWL align:GUI_ALIGN_CENTER];
[gui click];
[self playChangedOption];
[prefs setInteger:growl_min_priority forKey:@"groolite-min-priority"];
}
timeLastKeyPress = script_time;
@ -2004,7 +1967,7 @@ static NSTimeInterval time_last_frame;
{
GuiDisplayGen* gui = [UNIVERSE gui];
if ([gameView isDown:gvArrowKeyRight] != [UNIVERSE wireframeGraphics])
[gui click];
[self playChangedOption];
[UNIVERSE setWireframeGraphics:[gameView isDown:gvArrowKeyRight]];
if ([UNIVERSE wireframeGraphics])
[gui setText:DESC(@"gameoptions-wireframe-graphics-yes") forRow:GUI_ROW_GAMEOPTIONS_WIREFRAMEGRAPHICS align:GUI_ALIGN_CENTER];
@ -2016,7 +1979,7 @@ static NSTimeInterval time_last_frame;
{
GuiDisplayGen* gui = [UNIVERSE gui];
if ([gameView isDown:gvArrowKeyRight] != [UNIVERSE reducedDetail])
[gui click];
[self playChangedOption];
[UNIVERSE setReducedDetail:[gameView isDown:gvArrowKeyRight]];
if ([UNIVERSE reducedDetail])
[gui setText:DESC(@"gameoptions-reduced-detail-yes") forRow:GUI_ROW_GAMEOPTIONS_DETAIL align:GUI_ALIGN_CENTER];
@ -2536,8 +2499,7 @@ static BOOL toggling_music;
autopilot_engaged = NO;
primaryTarget = NO_TARGET;
status = STATUS_IN_FLIGHT;
if (![UNIVERSE playCustomSound:@"[autopilot-off]"])
[self beep];
[self playAutopilotOff];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[autopilot-off]") forCount:4.5];
[self doScriptEvent:@"playerCancelledAutoPilot"];
@ -2690,7 +2652,11 @@ static BOOL toggling_music;
{
if ([gui setSelectedRow:guiSelectedRow + 1])
{
[gui click];
[self playMenuNavigationDown];
}
else
{
[self playMenuNavigationNot];
}
timeLastKeyPress = script_time;
}
@ -2701,7 +2667,11 @@ static BOOL toggling_music;
{
if ([gui setSelectedRow:guiSelectedRow - 1])
{
[gui click];
[self playMenuNavigationUp];
}
else
{
[self playMenuNavigationNot];
}
timeLastKeyPress = script_time;
}
@ -2718,6 +2688,7 @@ static BOOL toggling_music;
[gui clearBackground];
[self setGuiToStatusScreen];
[[OOMusicController sharedController] stopMissionMusic];
[self playDismissedMissionScreen];
[self doScriptEvent:@"missionScreenEnded"];
[self checkScript];

View File

@ -25,6 +25,7 @@
#import "PlayerEntityLoadSave.h"
#import "PlayerEntityContracts.h"
#import "PlayerEntityControls.h"
#import "PlayerEntitySound.h"
#import "NSFileManagerOOExtensions.h"
#import "GameController.h"
@ -357,16 +358,17 @@
[self nativeSavePlayer: commanderNameString];
[self setGuiToStatusScreen];
[beepSound play];
[self playSaveOverwriteYes];
}
if (([gameView isDown: 13] && ([gui selectedRow] == SAVE_OVERWRITE_NO_ROW))||[gameView isDown: 27]||[gameView isDown: 110]||[gameView isDown: 78])
{
// esc or NO was pressed - get out of here
// FIXME: should return to save screen instead.
pollControls=YES;
[self setGuiToStatusScreen];
[boopSound play];
[self playSaveOverwriteNo];
}
}

View File

@ -25,25 +25,66 @@ MA 02110-1301, USA.
#import "PlayerEntity.h"
enum
{
kInterfaceBeep_Beep = 1UL,
kInterfaceBeep_Boop,
kInterfaceBeep_Buy,
kInterfaceBeep_Sell
};
@interface PlayerEntity (Sound)
- (void) setUpSound;
- (void) destroySound;
- (void) beep;
- (void) boop;
- (void) playInterfaceBeep:(unsigned)inInterfaceBeep;
// Interface sounds; only one at a time
- (BOOL) isBeeping;
- (void) playIdentOn;
- (void) playIdentOff;
- (void) playIdentLockedOn;
- (void) playMissileArmed;
- (void) playMineArmed;
- (void) playMissileSafe;
- (void) playMissileLockedOn;
- (void) playNextMissileSelected;
- (void) playBuyCommodity;
- (void) playBuyShip;
- (void) playSellCommodity;
- (void) playCantBuyBuyCommodity;
- (void) playCantBuyBuyShip;
- (void) playCargoJettisioned;
- (void) playAutopilotOn;
- (void) playAutopilotOff;
- (void) playAutopilotOutOfRange;
- (void) playAutopilotCannotDockWithTarget;
- (void) playSaveOverwriteYes;
- (void) playSaveOverwriteNo;
- (void) playHoldFull;
- (void) playJumpMassLocked;
- (void) playTargetLost;
- (void) playNoTargetInMemory;
- (void) playTargetSwitched;
- (void) playCloakingDeviceOn;
- (void) playCloakingDeviceOff;
- (void) playCloakingDeviceInsufficientEnergy;
- (void) playMenuNavigationUp;
- (void) playMenuNavigationDown;
- (void) playMenuNavigationNot;
- (void) playMenuPagePrevious;
- (void) playMenuPageNext;
- (void) playDismissedReportScreen;
- (void) playDismissedMissionScreen;
- (void) playChangedOption;
// Hyperspace alert sounds; logically hyperspace sounds, but played on the interface sound source.
- (void) playHyperspaceNoTarget;
- (void) playHyperspaceNoFuel;
- (void) playHyperspaceBlocked;
/* Hyperspace sounds; only one at a time. These get their own pool since
people might want something longer than beeps and boops (e.g. the existing
hyperspace countdown one). Hyperspace-related alert sounds are with the
normal interface sounds.
*/
- (void) playStandardHyperspace;
- (void) playGalacticHyperspace;
- (void) playHyperspaceAborted;
// ECM; only one at a time
- (void) playHitByECMSound;
- (void) playFiredECMSound;

View File

@ -29,15 +29,6 @@ MA 02110-1301, USA.
#import "OOSoundSourcePool.h"
/*
If BEEP_MODE is 0, playing two identical beeps (i.e. beep twice, or boop twice) will result in
that beep being played twice in a row. If it is 1, the playing beep will be interrupted. If it
is 2, two beeps will play at once with the CA implementation (and interfaceBeepSource will be
unused).
*/
#define BEEP_MODE 1
// Sizes of sound source pools
enum
{
@ -50,6 +41,10 @@ enum
static OOSoundSourcePool *sWarningSoundPool;
static OOSoundSourcePool *sWeaponSoundPool;
static OOSoundSourcePool *sDamageSoundPool;
static OOSoundSource *sHyperspaceSoundSource;
static OOSoundSource *sInterfaceBeepSource;
static OOSoundSource *sEcmSource;
static OOSoundSource *sBreakPatternSource;
@implementation PlayerEntity (Sound)
@ -58,12 +53,8 @@ static OOSoundSourcePool *sDamageSoundPool;
{
[self destroySound];
beepSound = [[ResourceManager ooSoundNamed:@"beep.ogg" inFolder:@"Sounds"] retain];
boopSound = [[ResourceManager ooSoundNamed:@"boop.ogg" inFolder:@"Sounds"] retain];
missileSound = [[ResourceManager ooSoundNamed:@"missile.ogg" inFolder:@"Sounds"] retain];
buySound = [[ResourceManager ooSoundNamed:@"buy.ogg" inFolder:@"Sounds"] retain];
sellSound = [[ResourceManager ooSoundNamed:@"sell.ogg" inFolder:@"Sounds"] retain];
afterburner1Sound = [[ResourceManager ooSoundNamed:@"afterburner1.ogg" inFolder:@"Sounds"] retain];
afterburner2Sound = [[ResourceManager ooSoundNamed:@"afterburner2.ogg" inFolder:@"Sounds"] retain];
@ -72,9 +63,11 @@ static OOSoundSourcePool *sDamageSoundPool;
fuelScoopSound = [[ResourceManager ooSoundNamed:@"scoop.ogg" inFolder:@"Sounds"] retain];
refPoint = [[OOSoundReferencePoint alloc] init];
interfaceBeepSource = [[OOSoundSource alloc] init];
breakPatternSource = [[OOSoundSource alloc] init];
ecmSource = [[OOSoundSource alloc] init];
sInterfaceBeepSource = [[OOSoundSource alloc] init];
sBreakPatternSource = [[OOSoundSource alloc] init];
sEcmSource = [[OOSoundSource alloc] init];
sHyperspaceSoundSource = [[OOSoundSource alloc] init];
sWarningSoundPool = [[OOSoundSourcePool alloc] initWithCount:kWarningPoolSize minRepeatTime:0];
sWeaponSoundPool = [[OOSoundSourcePool alloc] initWithCount:kWeaponPoolSize minRepeatTime:0];
@ -84,14 +77,9 @@ static OOSoundSourcePool *sDamageSoundPool;
- (void) destroySound
{
[beepSound release];
beepSound = nil;
[boopSound release];
boopSound = nil;
[buySound release];
buySound = nil;
[sellSound release];
sellSound = nil;
[missileSound release];
missileSound = nil;
[afterburner1Sound release];
afterburner1Sound = nil;
[afterburner2Sound release];
@ -105,12 +93,15 @@ static OOSoundSourcePool *sDamageSoundPool;
[refPoint release];
refPoint = nil;
[interfaceBeepSource release];
interfaceBeepSource = nil;
[ecmSource release];
ecmSource = nil;
[breakPatternSource release];
breakPatternSource = nil;
[sInterfaceBeepSource release];
sInterfaceBeepSource = nil;
[sBreakPatternSource release];
sBreakPatternSource = nil;
[sEcmSource release];
sEcmSource = nil;
[sHyperspaceSoundSource release];
sHyperspaceSoundSource = nil;
[sWarningSoundPool release];
sWarningSoundPool = nil;
@ -121,89 +112,303 @@ static OOSoundSourcePool *sDamageSoundPool;
}
- (void) beep
- (void) playInterfaceBeep:(NSString *)beepKey
{
[self playInterfaceBeep:kInterfaceBeep_Beep];
}
- (void) boop
{
[self playInterfaceBeep:kInterfaceBeep_Boop];
}
- (void) playInterfaceBeep:(unsigned)inInterfaceBeep
{
OOSound *sound = nil;
switch (inInterfaceBeep)
{
case kInterfaceBeep_Beep:
sound = beepSound;
break;
case kInterfaceBeep_Boop:
sound = boopSound;
break;
case kInterfaceBeep_Buy:
sound = buySound;
break;
case kInterfaceBeep_Sell:
sound = sellSound;
break;
default:
OOLog(@"sound.invalidBeep", @"Invalid beep selector: %u", inInterfaceBeep);
}
#if BEEP_MODE == 0
[interfaceBeepSource playOrRepeatSound:sound];
#elif BEEP_MODE == 1
[interfaceBeepSource playSound:sound];
#elif BEEP_MODE == 2
[sound play];
#else
#error Unknown BEEP_MODE
#endif
[sInterfaceBeepSource playSound:[OOSound soundWithCustomSoundKey:beepKey]];
}
- (BOOL) isBeeping
{
return [interfaceBeepSource isPlaying];
return [sInterfaceBeepSource isPlaying];
}
- (void) boop
{
[self playInterfaceBeep:@"[general-boop]"];
}
- (void) playIdentOn
{
[self playInterfaceBeep:@"[ident-on]"];
}
- (void) playIdentOff
{
[self playInterfaceBeep:@"[ident-off]"];
}
- (void) playIdentLockedOn
{
[self playInterfaceBeep:@"[ident-locked-on]"];
}
- (void) playMissileArmed
{
[self playInterfaceBeep:@"[missile-armed]"];
}
- (void) playMineArmed
{
[self playInterfaceBeep:@"[mine-armed]"];
}
- (void) playMissileSafe
{
[self playInterfaceBeep:@"[missile-safe]"];
}
- (void) playMissileLockedOn
{
[self playInterfaceBeep:@"[missile-locked-on]"];
}
- (void) playNextMissileSelected
{
[self playInterfaceBeep:@"[next-missile-selected]"];
}
- (void) playBuyCommodity
{
[self playInterfaceBeep:@"[buy-commodity]"];
}
- (void) playBuyShip
{
[self playInterfaceBeep:@"[buy-ship]"];
}
- (void) playSellCommodity
{
[self playInterfaceBeep:@"[sell-commodity]"];
}
- (void) playCantBuyBuyCommodity
{
[self playInterfaceBeep:@"[could-not-buy-any]"];
}
- (void) playCantBuyBuyShip
{
[self playInterfaceBeep:@"[could-not-buy-ship]"];
}
- (void) playCargoJettisioned
{
[self playInterfaceBeep:@"[cargo-jettisoned]"];
}
- (void) playAutopilotOn
{
[self playInterfaceBeep:@"[autopilot-on]"];
}
- (void) playAutopilotOff
{
[self playInterfaceBeep:@"[autopilot-off]"];
}
- (void) playAutopilotOutOfRange
{
[self playInterfaceBeep:@"[autopilot-out-of-range]"];
}
- (void) playAutopilotCannotDockWithTarget
{
[self playInterfaceBeep:@"[autopilot-cannot-dock-with-target]"];
}
- (void) playSaveOverwriteYes
{
[self playInterfaceBeep:@"[save-overwrite-yes]"];
}
- (void) playSaveOverwriteNo
{
[self playInterfaceBeep:@"[save-overwrite-no]"];
}
- (void) playHoldFull
{
[self playInterfaceBeep:@"[hold-full]"];
}
- (void) playJumpMassLocked
{
[self playInterfaceBeep:@"[jump-mass-locked]"];
}
- (void) playTargetLost
{
[self playInterfaceBeep:@"[target-lost]"];
}
- (void) playNoTargetInMemory
{
[self playInterfaceBeep:@"[no-target-in-memory]"];
}
- (void) playTargetSwitched
{
[self playInterfaceBeep:@"[target-switched]"];
}
- (void) playHyperspaceNoTarget
{
[self playInterfaceBeep:@"[witch-no-target]"];
}
- (void) playHyperspaceNoFuel
{
[self playInterfaceBeep:@"[witch-no-fuel]"];
}
- (void) playHyperspaceBlocked
{
[self playInterfaceBeep:@"[witch-blocked-by-@]"];
}
- (void) playCloakingDeviceOn
{
[self playInterfaceBeep:@"[cloaking-device-on]"];
}
- (void) playCloakingDeviceOff
{
[self playInterfaceBeep:@"[cloaking-device-off]"];
}
- (void) playMenuNavigationUp
{
[self playInterfaceBeep:@"[menu-navigation-up]"];
}
- (void) playMenuNavigationDown
{
[self playInterfaceBeep:@"[menu-navigation-down]"];
}
- (void) playMenuNavigationNot
{
[self playInterfaceBeep:@"[menu-navigation-not]"];
}
- (void) playMenuPagePrevious
{
[self playInterfaceBeep:@"[menu-next-page]"];
}
- (void) playMenuPageNext
{
[self playInterfaceBeep:@"[menu-previous-page]"];
}
- (void) playDismissedReportScreen
{
[self playInterfaceBeep:@"[dismissed-report-screen]"];
}
- (void) playDismissedMissionScreen
{
[self playInterfaceBeep:@"[dismissed-mission-screen]"];
}
- (void) playChangedOption
{
[self playInterfaceBeep:@"[changed-option]"];
}
- (void) playCloakingDeviceInsufficientEnergy
{
[self playInterfaceBeep:@"[cloaking-device-insufficent-energy]"];
}
- (void) playStandardHyperspace
{
[sHyperspaceSoundSource playCustomSoundWithKey:@"[hyperspace-countdown-begun]"];
}
- (void) playGalacticHyperspace
{
[sHyperspaceSoundSource playCustomSoundWithKey:@"[galactic-hyperspace-countdown-begun]"];
}
- (void) playHyperspaceAborted
{
[sHyperspaceSoundSource playCustomSoundWithKey:@"[hyperspace-countdown-begun]"];
}
- (void) playHitByECMSound
{
if (![ecmSource isPlaying]) [ecmSource playCustomSoundWithKey:@"[player-hit-by-ecm]"];
if (![sEcmSource isPlaying]) [sEcmSource playCustomSoundWithKey:@"[player-hit-by-ecm]"];
}
- (void) playFiredECMSound
{
if (![ecmSource isPlaying]) [ecmSource playCustomSoundWithKey:@"[player-fired-ecm]"];
if (![sEcmSource isPlaying]) [sEcmSource playCustomSoundWithKey:@"[player-fired-ecm]"];
}
- (void) playLaunchFromStation
{
[breakPatternSource playCustomSoundWithKey:@"[player-launch-from-station]"];
[sBreakPatternSource playCustomSoundWithKey:@"[player-launch-from-station]"];
}
- (void) playDockWithStation
{
[breakPatternSource playCustomSoundWithKey:@"[player-dock-with-station]"];
[sBreakPatternSource playCustomSoundWithKey:@"[player-dock-with-station]"];
}
- (void) playExitWitchspace
{
[breakPatternSource playCustomSoundWithKey:@"[player-exit-witchspace]"];
[sBreakPatternSource playCustomSoundWithKey:@"[player-exit-witchspace]"];
}

View File

@ -72,8 +72,6 @@ typedef OOGUITabStop OOGUITabSettings[GUI_MAX_COLUMNS];
NSSize pixel_title_size;
OOSound *guiclick;
OOColor *backgroundColor;
OOColor *textColor;
@ -149,8 +147,6 @@ typedef OOGUITabStop OOGUITabSettings[GUI_MAX_COLUMNS];
- (void) setCharacterSize:(NSSize) character_size;
- (void) click;
- (void)setShowAdvancedNavArray:(BOOL)inFlag;
- (void) setColor:(OOColor *)color forRow:(OOGUIRow)row;

View File

@ -80,9 +80,7 @@ OOINLINE BOOL RowInRange(OOGUIRow row, NSRange range)
tabStops[i] = stops[i];
}
title = @"Test Page";
guiclick = [[ResourceManager ooSoundNamed:@"guiclick.ogg" inFolder:@"Sounds"] retain];
title = @"";
textColor = [[OOColor yellowColor] retain];
@ -132,8 +130,6 @@ OOINLINE BOOL RowInRange(OOGUIRow row, NSRange range)
title = [gui_title retain];
guiclick = [[ResourceManager ooSoundNamed:@"guiclick.ogg" inFolder:@"Sounds"] retain];
textColor = [[OOColor yellowColor] retain];
return self;
@ -328,12 +324,6 @@ OOINLINE BOOL RowInRange(OOGUIRow row, NSRange range)
}
- (void) click
{
[guiclick play];
}
- (void)setShowAdvancedNavArray:(BOOL)inFlag
{
showAdvancedNavArray = inFlag;

View File

@ -708,47 +708,51 @@ static BOOL hostiles;
&&(the_sun)
&&(the_planet)) // and be in a system
{
Vector relativePosition;
Entity *reference = nil;
switch ([player compassMode])
{
case COMPASS_MODE_BASIC:
relativePosition = the_planet->position;
if (([player checkForAegis] != AEGIS_NONE)&&(the_station))
relativePosition = the_station->position;
if ([player checkForAegis] != AEGIS_NONE && the_station)
{
reference = the_station;
}
else
{
reference = the_planet;
}
break;
case COMPASS_MODE_PLANET:
relativePosition = the_planet->position;
reference = the_planet;
break;
case COMPASS_MODE_STATION:
relativePosition = the_station->position;
reference = the_station;
break;
case COMPASS_MODE_SUN:
relativePosition = the_sun->position;
reference = the_sun;
break;
case COMPASS_MODE_TARGET:
if (the_target)
relativePosition = the_target->position;
else
{
[player setCompassMode:COMPASS_MODE_PLANET];
relativePosition = the_planet->position;
}
break;
reference = the_target;
case COMPASS_MODE_BEACONS:
if (the_next_beacon)
relativePosition = the_next_beacon->position;
else
{
[player setCompassMode:COMPASS_MODE_PLANET];
relativePosition = the_planet->position;
}
reference = the_next_beacon;
break;
}
if (reference == nil)
{
[player setCompassMode:COMPASS_MODE_PLANET];
reference = the_planet;
}
// translate and rotate the view
relativePosition = OOVectorMultiplyMatrix(vector_subtract(relativePosition, position), rotMatrix);
Vector relativePosition = vector_subtract([reference position], position);
relativePosition = OOVectorMultiplyMatrix(relativePosition, rotMatrix);
relativePosition = vector_normal_or_fallback(relativePosition, kBasisZVector);
relativePosition.x *= siz.width * 0.4;

View File

@ -64,7 +64,7 @@ static NSString * const kCacheKeyCaches = @"_caches";
enum
{
kEndianTagValue = 0x12345678UL,
kFormatVersionValue = 9
kFormatVersionValue = 10
};

View File

@ -367,7 +367,7 @@ enum
- (Vector) getSafeVectorFromEntity:(Entity *) e1 toDistance:(double)dist fromPoint:(Vector) p2;
- (OOUniversalID) getFirstEntityHitByLaserFromEntity:(ShipEntity *)srcEntity inView:(OOViewID)viewdir offset:(Vector)offset rangeFound:(GLfloat*)range_ptr;
- (OOUniversalID) getFirstEntityTargettedByPlayer:(PlayerEntity *)player;
- (ShipEntity *) getFirstEntityTargettedByPlayer;
- (NSArray *) getEntitiesWithinRange:(double)range ofEntity:(Entity *)entity;
- (unsigned) countShipsWithRole:(NSString *)role inRange:(double)range ofEntity:(Entity *)entity;

View File

@ -4547,20 +4547,16 @@ static BOOL MaintainLinkedLists(Universe* uni)
}
- (OOUniversalID) getFirstEntityTargettedByPlayer:(PlayerEntity*) player
- (ShipEntity *)getFirstEntityTargettedByPlayer
{
if ((!player)||(!player->isPlayer))
return NO_TARGET;
PlayerEntity *player = [PlayerEntity sharedPlayer];
ShipEntity *hit_entity = nil;
int result = NO_TARGET;
double nearest = SCANNER_MAX_RANGE - 10; // 10m shorter than range at which target is lost
int i;
int ent_count = n_entities;
int ship_count = 0;
Entity *my_entities[ent_count];
for (i = 0; i < ent_count; i++)
if ((sortedEntities[i]->isShip)&&(sortedEntities[i] != player))
my_entities[ship_count++] = [sortedEntities[i] retain]; // retained
@ -4617,16 +4613,13 @@ static BOOL MaintainLinkedLists(Universe* uni)
}
}
// check for MASC'M
if ((hit_entity) && [hit_entity isJammingScanning] && (![player hasMilitaryScannerFilter]))
if ((hit_entity) && [hit_entity isJammingScanning] && ![player hasMilitaryScannerFilter])
hit_entity = nil;
if (hit_entity)
result = [hit_entity universalID];
for (i = 0; i < ship_count; i++)
[my_entities[i] release]; // released
return result;
return hit_entity;
}
@ -4923,16 +4916,18 @@ OOINLINE BOOL EntityInRange(Vector p1, Entity *e2, float range)
mouseDelta = NO;
break;
}
#ifdef GNUSTEP
#if OOLITE_SDL
[gameView setMouseInDeltaMode: mouseDelta];
#endif
if ((viewDirection != vd)|(viewDirection = VIEW_CUSTOM))
{
viewDirection = vd;
if (ms)
{
[self addMessage:ms forCount:3];
}
}
}
- (OOViewID) viewDirection
@ -4943,7 +4938,35 @@ OOINLINE BOOL EntityInRange(Vector p1, Entity *e2, float range)
- (NSString *) soundNameForCustomSoundKey:(NSString *)key;
{
return [customsounds stringForKey:key];
NSString *result = nil;
NSMutableSet *seen = nil;
result = [[OOCacheManager sharedCache] objectForKey:key inCache:@"resolved custom sounds"];
if (result == nil)
{
// Resolve sound, allowing indirection within customsounds.plist
seen = [NSMutableSet set];
result = key;
for (;;)
{
[seen addObject:result];
result = [customsounds objectForKey:result];
if (result == nil || ![result hasPrefix:@"["] || ![result hasSuffix:@"]"]) break;
if ([seen containsObject:result])
{
OOLog(@"sounds.customSounds.recursion", @"***** ERROR: recursion in customsounds.plist for %@ (at %@), no sound will be played.", key, result);
result = nil;
break;
}
}
if (result == nil) result = @"__oolite-no-sound";
[[OOCacheManager sharedCache] setObject:result forKey:key inCache:@"resolved custom sounds"];
}
if ([result isEqualToString:@"__oolite-no-sound"]) result = nil;
return result;
}