Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions Orbiter/Orbitersdk/samples/SR71R/APU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,47 @@ void APU::Step(double simt, double simdt, double mjd)

gaugeHydrPress_.SetState((fuelDraw == actualDraw) ? 1.0 : 0.0);
}

SetSound();
}

void APU::SetSound()
{
double status = gaugeHydrPress_.GetState();
// TODO: NOTE: Startup and shutdown sound aren't 'true', since the status is just 0 and 1.
// However, the code supports shutdown and start. When the status shows the actual status, it will work.

if (HasPower() && swPower_.IsOn() && propulsionControl_) {
// If it's starting (See note above)
if (status < 1.0 && status > 0.0) {
if(!GetBaseVessel()->IsSoundRunning(APU_START_ID)) GetBaseVessel()->PlaySound(APU_START_ID, true, false);
}
// If it's running
else if (status == 1.0) {
if (!GetBaseVessel()->IsSoundRunning(APU_RUNNING_ID)) {
StopAllSounds();
GetBaseVessel()->PlaySound(APU_RUNNING_ID, true, false);
}
}
if(isSoundStopped) isSoundStopped = false;
}
else {
// If it's shutting down (See note above)
if (status < 1.0 && status > 0.0) {
if (!GetBaseVessel()->IsSoundRunning(APU_SHUTDOWN_ID)) {
StopAllSounds();
GetBaseVessel()->PlaySound(APU_SHUTDOWN_ID, true, false);
}
}
else {
if (!isSoundStopped) { StopAllSounds(); isSoundStopped = true; }
}
}
}

void APU::StopAllSounds()
{
for (int i = APU_START_ID; i <= APU_SHUTDOWN_ID; i++) GetBaseVessel()->StopSound(i);
}

double APU::CurrentDraw()
Expand Down
9 changes: 8 additions & 1 deletion Orbiter/Orbitersdk/samples/SR71R/APU.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,21 @@ class APU :

const char* ConfigKey = "APU";

bool isSoundStopped = false;

bco::VCGauge gaugeHydrPress_{ {bt_mesh::SR71rVC::gaHydPress_id },
bt_mesh::SR71rVC::gaHydPress_location, bt_mesh::SR71rVC::axisHydPress_location,
(300 * RAD),
0.2
};

bco::VCToggleSwitch swPower_ { bt_mesh::SR71rVC::SwAPUPower_id,
bco::VCToggleSwitch swPower_ { bt_mesh::SR71rVC::SwAPUPower_id,
GetBaseVessel(),
bt_mesh::SR71rVC::SwAPUPower_location,
bt_mesh::SR71rVC::LeftPanelTopRightAxis_location
};

virtual void SetSound();

virtual void StopAllSounds();
};
19 changes: 18 additions & 1 deletion Orbiter/Orbitersdk/samples/SR71R/AirBrake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ double AirBrake::GetAirBrakeState()
return animAirBrake_.GetState();
}

void AirBrake::SetSound()
{
if (animAirBrake_.GetState() > 0.0 && animAirBrake_.GetState() < 0.33) {
if (!GetBaseVessel()->IsSoundRunning(AIRBRAKE_ID)) GetBaseVessel()->PlaySound(AIRBRAKE_ID, true, false);
}
else if (animAirBrake_.GetState() > 0.33 && animAirBrake_.GetState() < 0.66) {
if (!GetBaseVessel()->IsSoundRunning(AIRBRAKE_ID)) GetBaseVessel()->PlaySound(AIRBRAKE_ID, true, false);
}
else if (animAirBrake_.GetState() > 0.66 && animAirBrake_.GetState() < 1.0) {
if (!GetBaseVessel()->IsSoundRunning(AIRBRAKE_ID)) GetBaseVessel()->PlaySound(AIRBRAKE_ID, true, false);
}
else {
if (GetBaseVessel()->IsSoundRunning(AIRBRAKE_ID)) GetBaseVessel()->StopSound(AIRBRAKE_ID);
}
}

void AirBrake::Step(double simt, double simdt, double mjd)
{
// Note: The animAirBrake can only move if there is hydraulic power, that
Expand All @@ -61,7 +77,8 @@ void AirBrake::Step(double simt, double simdt, double mjd)

// Update drag.
dragFactor_ = animAirBrake_.GetState();
// sprintf(oapiDebugString(), "air brake: %+4.2f", dragFactor_);

SetSound();
}

bool AirBrake::LoadConfiguration(char* key, FILEHANDLE scn, const char* configLine)
Expand Down
4 changes: 3 additions & 1 deletion Orbiter/Orbitersdk/samples/SR71R/AirBrake.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ class AirBrake :
double AirBrake::GetAirBrakeState();

private:
bco::RotarySwitch airBrakeSwitch_;
void SetSound();

bco::RotarySwitch airBrakeSwitch_ { _V(0.0, 0.0, 0.0), 0.0, GetBaseVessel() };
bco::EventTarget eventIncreaseBrake_ { bt_mesh::SR71rVC::ABTargetIncrease_location, 0.01 };
bco::EventTarget eventDecreaseBrake_ { bt_mesh::SR71rVC::ABTargetDecrease_location, 0.01 };

Expand Down
5 changes: 4 additions & 1 deletion Orbiter/Orbitersdk/samples/SR71R/Avionics.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Avionics :

bool IsOverSpeed() const;

bco::DialSwitch& HeadingSetDial();
bco::DialSwitch& HeadingSetDial();
bco::OnOffSwitch& PowerSwitch();

private:
Expand Down Expand Up @@ -431,17 +431,20 @@ class Avionics :
bco::TextureVisual txSpeedVel_ { bt_mesh::SR71rVC::SpeedVelocityFlag_verts, bt_mesh::SR71rVC::SpeedVelocityFlag_id};

bco::VCToggleSwitch swPower_ { bt_mesh::SR71rVC::SwAvionics_id,
GetBaseVessel(),
bt_mesh::SR71rVC::SwAvionics_location,
bt_mesh::SR71rVC::PowerTopRightAxis_location
};

bco::VCRotorSwitch swSelectRadio_ { bt_mesh::SR71rVC::SwNavSelect_id,
GetBaseVessel(),
bt_mesh::SR71rVC::SwNavSelect_location,
bt_mesh::SR71rVC::SwNavSelectAxis_location,
(117*RAD)
};

bco::VCRotorSwitch swAvionMode_ { bt_mesh::SR71rVC::SwExoSelect_id,
GetBaseVessel(),
bt_mesh::SR71rVC::SwExoSelect_location,
bt_mesh::SR71rVC::SwExoSelectAxis_location,
(117*RAD)
Expand Down
12 changes: 12 additions & 0 deletions Orbiter/Orbitersdk/samples/SR71R/Canopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ bool Canopy::CanopyHasPower()
return HasPower() && swCanopyPower_.IsOn();
}

void Canopy::SetSound()
{
if (animCanopy_.GetState() > 0.0 && animCanopy_.GetState() < 1.0) {
if(!GetBaseVessel()->IsSoundRunning(CANOPY_ID)) GetBaseVessel()->PlaySound(CANOPY_ID, true, false);
}
else {
if (GetBaseVessel()->IsSoundRunning(CANOPY_ID)) GetBaseVessel()->StopSound(CANOPY_ID);
}
}

Canopy::Canopy(bco::BaseVessel* vessel, double amps) :
PoweredComponent(vessel, amps, 26.0)
{
Expand All @@ -51,6 +61,8 @@ void Canopy::Step(double simt, double simdt, double mjd)
{
animCanopy_.Step(swCanopyOpen_.GetState(), simdt);
}

SetSound();
}

bool Canopy::LoadConfiguration(char* key, FILEHANDLE scn, const char* configLine)
Expand Down
4 changes: 4 additions & 0 deletions Orbiter/Orbitersdk/samples/SR71R/Canopy.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,21 @@ class Canopy : public bco::PoweredComponent
private:
bool CanopyHasPower();

void SetSound();

const char* ConfigKeyCanopy = "CANOPY";

bco::Animation animCanopy_ { &swCanopyOpen_, 0.2};
UINT idAnim_ { 0 };

bco::VCToggleSwitch swCanopyPower_ { bt_mesh::SR71rVC::SwCanopyPower_id,
GetBaseVessel(),
bt_mesh::SR71rVC::SwCanopyPower_location,
bt_mesh::SR71rVC::PowerTopRightAxis_location
};

bco::VCToggleSwitch swCanopyOpen_ { bt_mesh::SR71rVC::SwCanopyOpen_id,
GetBaseVessel(),
bt_mesh::SR71rVC::SwCanopyOpen_location,
bt_mesh::SR71rVC::DoorsRightAxis_location
};
Expand Down
12 changes: 12 additions & 0 deletions Orbiter/Orbitersdk/samples/SR71R/CargoBayController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ bool CargoBayController::CargoBayHasPower()
return HasPower() && swCargoPower_.IsOn();
}

void CargoBayController::SetSound()
{
if (animCargoBayDoors_.GetState() > 0.0 && animCargoBayDoors_.GetState() < 1.0) {
if (!GetBaseVessel()->IsSoundRunning(CARGO_ID)) GetBaseVessel()->PlaySound(CARGO_ID, true, false);
}
else {
if (GetBaseVessel()->IsSoundRunning(CARGO_ID)) GetBaseVessel()->StopSound(CARGO_ID);
}
}

CargoBayController::CargoBayController(bco::BaseVessel* vessel, double amps) :
PoweredComponent(vessel, amps, 26.0)
{
Expand All @@ -52,6 +62,8 @@ void CargoBayController::Step(double simt, double simdt, double mjd)
{
animCargoBayDoors_.Step(swCargoOpen_.GetState(), simdt);
}

SetSound();
}

bool CargoBayController::LoadConfiguration(char* key, FILEHANDLE scn, const char* configLine)
Expand Down
4 changes: 4 additions & 0 deletions Orbiter/Orbitersdk/samples/SR71R/CargoBayController.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,22 @@ class CargoBayController : public bco::PoweredComponent
private:
bool CargoBayHasPower();

void SetSound();

const char* ConfigKeyCargo = "CARGOBAY";

bco::Animation animCargoBayDoors_{ &swCargoOpen_, 0.01 };

UINT idCargoAnim_{ 0 };

bco::VCToggleSwitch swCargoPower_ { bt_mesh::SR71rVC::SwCargoPower_id,
GetBaseVessel(),
bt_mesh::SR71rVC::SwCargoPower_location,
bt_mesh::SR71rVC::PowerTopRightAxis_location
};

bco::VCToggleSwitch swCargoOpen_ { bt_mesh::SR71rVC::SwCargoOpen_id,
GetBaseVessel(),
bt_mesh::SR71rVC::SwCargoOpen_location,
bt_mesh::SR71rVC::DoorsRightAxis_location
};
Expand Down
4 changes: 2 additions & 2 deletions Orbiter/Orbitersdk/samples/SR71R/Clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class Clock : public bco::Component

const char* ConfigKey = "CLOCK";

bco::PushButtonSwitch switchResetElapsed_ { bt_mesh::SR71rVC::ClockElapsedReset_location, 0.01 };
bco::PushButtonSwitch switchStopWatch_ { bt_mesh::SR71rVC::ClockTimerReset_location, 0.01 };
bco::PushButtonSwitch switchResetElapsed_ { bt_mesh::SR71rVC::ClockElapsedReset_location, 0.01, GetBaseVessel() };
bco::PushButtonSwitch switchStopWatch_ { bt_mesh::SR71rVC::ClockTimerReset_location, 0.01, GetBaseVessel() };

double startElapsedTime_;
double startTimerTime_;
Expand Down
10 changes: 5 additions & 5 deletions Orbiter/Orbitersdk/samples/SR71R/FlightComputer.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,19 +361,19 @@ namespace FC

// Auto pilot panel
bco::TextureVisual visAPMainOn_;
bco::PushButtonSwitch swAPMain_{ bt_mesh::SR71rVC::SwAPMain_location, 0.01 };
bco::PushButtonSwitch swAPMain_{ bt_mesh::SR71rVC::SwAPMain_location, 0.01, GetBaseVessel() };

bco::TextureVisual visAPHeadingOn_;
bco::PushButtonSwitch swAPHeading_{ bt_mesh::SR71rVC::SwAPHeading_location, 0.01 };
bco::PushButtonSwitch swAPHeading_{ bt_mesh::SR71rVC::SwAPHeading_location, 0.01, GetBaseVessel() };

bco::TextureVisual visAPAltitudeOn_;
bco::PushButtonSwitch swAPHAltitude_{ bt_mesh::SR71rVC::SwAPAltitude_location, 0.01 };
bco::PushButtonSwitch swAPHAltitude_{ bt_mesh::SR71rVC::SwAPAltitude_location, 0.01, GetBaseVessel() };

bco::TextureVisual visAPKEASOn_;
bco::PushButtonSwitch swAPKEAS_{ bt_mesh::SR71rVC::SwAPKEAS_location, 0.01 };
bco::PushButtonSwitch swAPKEAS_{ bt_mesh::SR71rVC::SwAPKEAS_location, 0.01, GetBaseVessel() };

bco::TextureVisual visAPMACHOn_;
bco::PushButtonSwitch swAPMACH_{ bt_mesh::SR71rVC::SwAPMACH_location, 0.01 };
bco::PushButtonSwitch swAPMACH_{ bt_mesh::SR71rVC::SwAPMACH_location, 0.01, GetBaseVessel() };


};
Expand Down
3 changes: 2 additions & 1 deletion Orbiter/Orbitersdk/samples/SR71R/FuelCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class FuelCell :

// Config members:

bco::VCToggleSwitch swPower_ { bt_mesh::SR71rVC::swFuelCellPower_id,
bco::VCToggleSwitch swPower_ { bt_mesh::SR71rVC::swFuelCellPower_id,
GetBaseVessel(),
bt_mesh::SR71rVC::swFuelCellPower_location,
bt_mesh::SR71rVC::PowerTopRightAxis_location
};
Expand Down
1 change: 1 addition & 0 deletions Orbiter/Orbitersdk/samples/SR71R/HUD.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class HUD : public bco::PoweredComponent
bool isInternalTrigger_{ false };

bco::VCRotorSwitch swSelectMode_{ bt_mesh::SR71rVC::SwHUDMode_id,
GetBaseVessel(),
bt_mesh::SR71rVC::SwHUDMode_location,
bt_mesh::SR71rVC::SwHUDSelectAxis_location,
(120 * RAD)
Expand Down
12 changes: 12 additions & 0 deletions Orbiter/Orbitersdk/samples/SR71R/HoverEngines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ void HoverEngines::Step(double simt, double simdt, double mjd)
{
animHoverDoors_.Step(swOpen_.GetState(), simdt);
}

SetSound();
}

double HoverEngines::CurrentDraw()
Expand Down Expand Up @@ -154,6 +156,16 @@ void HoverEngines::EnableHover(bool isEnabled)
}
}

void HoverEngines::SetSound()
{
if (animHoverDoors_.GetState() > 0.0 && animHoverDoors_.GetState() < 1.0) {
if (!GetBaseVessel()->IsSoundRunning(HOVER_DOOR_ID)) GetBaseVessel()->PlaySound(HOVER_DOOR_ID, true, false);
}
else {
if (GetBaseVessel()->IsSoundRunning(HOVER_DOOR_ID)) GetBaseVessel()->StopSound(HOVER_DOOR_ID);
}
}

bool HoverEngines::DrawHUD(int mode, const HUDPAINTSPEC* hps, oapi::Sketchpad* skp)
{
if (oapiCockpitMode() != COCKPIT_VIRTUAL) return false;
Expand Down
4 changes: 3 additions & 1 deletion Orbiter/Orbitersdk/samples/SR71R/HoverEngines.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class HoverEngines : public bco::PoweredComponent
private:

void EnableHover(bool isEnabled);
void SetSound();


THRUSTER_HANDLE hoverThrustHandles_[3];
Expand All @@ -54,7 +55,8 @@ class HoverEngines : public bco::PoweredComponent
int hoverMouseId_;


bco::VCToggleSwitch swOpen_ { bt_mesh::SR71rVC::swHoverDoor_id,
bco::VCToggleSwitch swOpen_ { bt_mesh::SR71rVC::swHoverDoor_id,
GetBaseVessel(),
bt_mesh::SR71rVC::swHoverDoor_location,
bt_mesh::SR71rVC::DoorsRightAxis_location
};
Expand Down
3 changes: 2 additions & 1 deletion Orbiter/Orbitersdk/samples/SR71R/HydrogenSupply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ void HydrogenSupply::Step(double simt, double simdt, double mjd)
if (IsFilling())
{
FillTank(HYDROGEN_FILL_RATE * simdt);
}
GetBaseVessel()->PlaySound(LH2_SUPPLY_ID, true, false);
} else if(GetBaseVessel()->IsSoundRunning(LH2_SUPPLY_ID)) GetBaseVessel()->StopSound(LH2_SUPPLY_ID);
}

bool HydrogenSupply::VCRedrawEvent(int id, int event, SURFHANDLE surf)
Expand Down
2 changes: 1 addition & 1 deletion Orbiter/Orbitersdk/samples/SR71R/HydrogenSupply.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class HydrogenSupply :

bco::TextureVisual lightSupplyAvailable_;
bco::TextureVisual lightValveOpen_;
bco::PushButtonSwitch switchValveOpen_ { bt_mesh::SR71rVC::LH2ValveOpenSwitch_location, 0.01 };
bco::PushButtonSwitch switchValveOpen_ { bt_mesh::SR71rVC::LH2ValveOpenSwitch_location, 0.01, GetBaseVessel() };

bco::VCGauge gaugeHydro_{ {bt_mesh::SR71rVC::gaHydrogenLevel_id },
bt_mesh::SR71rVC::gaHydrogenLevel_location,
Expand Down
Loading