mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 22:09:19 +02:00
pantograph switch functionality swapped for the rear cab
This commit is contained in:
@@ -180,7 +180,7 @@ void TGauge::DecValue(double fNewDesired)
|
|||||||
void
|
void
|
||||||
TGauge::UpdateValue( double fNewDesired, PSound Fallbacksound ) {
|
TGauge::UpdateValue( double fNewDesired, PSound Fallbacksound ) {
|
||||||
|
|
||||||
auto const desiredtimes100 = static_cast<int>( 100.0 * fNewDesired );
|
auto const desiredtimes100 = static_cast<int>( std::round( 100.0 * fNewDesired ) );
|
||||||
if( static_cast<int>( std::round( 100.0 * ( fDesiredValue - fOffset ) / fScale ) ) == desiredtimes100 ) {
|
if( static_cast<int>( std::round( 100.0 * ( fDesiredValue - fOffset ) / fScale ) ) == desiredtimes100 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
217
Train.cpp
217
Train.cpp
@@ -1361,6 +1361,14 @@ void TTrain::OnCommand_batterytoggle( TTrain *Train, command_data const &Command
|
|||||||
|
|
||||||
void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const &Command ) {
|
void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const &Command ) {
|
||||||
|
|
||||||
|
return (
|
||||||
|
Train->mvControlled->ActiveCab < 0 ?
|
||||||
|
pantographtogglerear( Train, Command ) :
|
||||||
|
pantographtogglefront( Train, Command ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void TTrain::pantographtogglefront( TTrain *Train, command_data const &Command ) {
|
||||||
|
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
||||||
if( false == Train->mvControlled->PantFrontUp ) {
|
if( false == Train->mvControlled->PantFrontUp ) {
|
||||||
@@ -1368,11 +1376,23 @@ void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const
|
|||||||
Train->mvControlled->PantFrontSP = false;
|
Train->mvControlled->PantFrontSP = false;
|
||||||
if( Train->mvControlled->PantFront( true ) ) {
|
if( Train->mvControlled->PantFront( true ) ) {
|
||||||
if( Train->mvControlled->PantFrontStart != 1 ) {
|
if( Train->mvControlled->PantFrontStart != 1 ) {
|
||||||
#ifdef EU07_USE_OLD_CONTROLSOUNDS
|
|
||||||
// sound feedback
|
|
||||||
Train->play_sound( Train->dsbSwitch );
|
|
||||||
#endif
|
|
||||||
// visual feedback
|
// visual feedback
|
||||||
|
if( Train->mvControlled->ActiveCab < 0 ) {
|
||||||
|
if( Train->ggPantRearButton.SubModel )
|
||||||
|
Train->ggPantRearButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||||
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
|
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
||||||
|
if( Train->ggPantSelectedButton.SubModel )
|
||||||
|
Train->ggPantSelectedButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||||
|
// pantograph control can have two-button setup
|
||||||
|
if( Train->ggPantRearButtonOff.SubModel )
|
||||||
|
Train->ggPantRearButtonOff.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
|
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
||||||
|
if( Train->ggPantSelectedDownButton.SubModel )
|
||||||
|
Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
|
}
|
||||||
|
else {
|
||||||
if( Train->ggPantFrontButton.SubModel )
|
if( Train->ggPantFrontButton.SubModel )
|
||||||
Train->ggPantFrontButton.UpdateValue( 1.0, Train->dsbSwitch );
|
Train->ggPantFrontButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
@@ -1389,9 +1409,20 @@ void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// ...or turn off
|
// ...or turn off
|
||||||
if( Train->mvOccupied->PantSwitchType == "impulse" ) {
|
if( Train->mvOccupied->PantSwitchType == "impulse" ) {
|
||||||
|
if( Train->mvControlled->ActiveCab < 0 ) {
|
||||||
|
if( ( Train->ggPantRearButtonOff.SubModel == nullptr )
|
||||||
|
&& ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) {
|
||||||
|
// with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it
|
||||||
|
// then another control has to be used (like pantographlowerall)
|
||||||
|
// TODO: we should have a way to define presense of cab controls without having to bind these to 3d submodels
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
if( ( Train->ggPantFrontButtonOff.SubModel == nullptr )
|
if( ( Train->ggPantFrontButtonOff.SubModel == nullptr )
|
||||||
&& ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) {
|
&& ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) {
|
||||||
// with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it
|
// with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it
|
||||||
@@ -1400,15 +1431,30 @@ void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Train->mvControlled->PantFrontSP = false;
|
Train->mvControlled->PantFrontSP = false;
|
||||||
if( false == Train->mvControlled->PantFront( false ) ) {
|
if( false == Train->mvControlled->PantFront( false ) ) {
|
||||||
if( Train->mvControlled->PantFrontStart != 0 ) {
|
if( Train->mvControlled->PantFrontStart != 0 ) {
|
||||||
#ifdef EU07_USE_OLD_CONTROLSOUNDS
|
|
||||||
// sound feedback
|
|
||||||
Train->play_sound( Train->dsbSwitch );
|
|
||||||
#endif
|
|
||||||
// visual feedback
|
// visual feedback
|
||||||
|
if( Train->mvControlled->ActiveCab < 0 ) {
|
||||||
|
// in rear cab switch functions are swapped
|
||||||
|
if( Train->ggPantRearButton.SubModel )
|
||||||
|
Train->ggPantRearButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
|
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
||||||
|
if( Train->ggPantSelectedButton.SubModel )
|
||||||
|
Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
|
// pantograph control can have two-button setup
|
||||||
|
if( Train->ggPantRearButtonOff.SubModel )
|
||||||
|
Train->ggPantRearButtonOff.UpdateValue( 1.0, Train->dsbSwitch );
|
||||||
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
|
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
||||||
|
if( Train->ggPantSelectedDownButton.SubModel )
|
||||||
|
Train->ggPantSelectedDownButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// in front cab switches map normally
|
||||||
if( Train->ggPantFrontButton.SubModel )
|
if( Train->ggPantFrontButton.SubModel )
|
||||||
Train->ggPantFrontButton.UpdateValue( 0.0, Train->dsbSwitch );
|
Train->ggPantFrontButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
@@ -1426,14 +1472,27 @@ void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if( Command.action == GLFW_RELEASE ) {
|
else if( Command.action == GLFW_RELEASE ) {
|
||||||
// impulse switches return automatically to neutral position
|
// impulse switches return automatically to neutral position
|
||||||
if( Train->mvOccupied->PantSwitchType == "impulse" ) {
|
if( Train->mvOccupied->PantSwitchType == "impulse" ) {
|
||||||
#ifdef EU07_USE_OLD_CONTROLSOUNDS
|
if( Train->mvControlled->ActiveCab < 0 ) {
|
||||||
if( Train->ggPantFrontButton.GetValue() > 0.35 ) {
|
if( Train->ggPantRearButton.SubModel )
|
||||||
Train->play_sound( Train->dsbSwitch );
|
Train->ggPantRearButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
|
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
||||||
|
if( Train->ggPantSelectedButton.SubModel )
|
||||||
|
Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
|
// also the switch off button, in cabs which have it
|
||||||
|
if( Train->ggPantRearButtonOff.SubModel )
|
||||||
|
Train->ggPantRearButtonOff.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
|
if( Train->ggPantSelectedDownButton.SubModel ) {
|
||||||
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
|
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
||||||
|
Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
else {
|
||||||
if( Train->ggPantFrontButton.SubModel )
|
if( Train->ggPantFrontButton.SubModel )
|
||||||
Train->ggPantFrontButton.UpdateValue( 0.0, Train->dsbSwitch );
|
Train->ggPantFrontButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
@@ -1441,11 +1500,6 @@ void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const
|
|||||||
if( Train->ggPantSelectedButton.SubModel )
|
if( Train->ggPantSelectedButton.SubModel )
|
||||||
Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch );
|
Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
// also the switch off button, in cabs which have it
|
// also the switch off button, in cabs which have it
|
||||||
#ifdef EU07_USE_OLD_CONTROLSOUNDS
|
|
||||||
if( Train->ggPantFrontButtonOff.GetValue() > 0.35 ) {
|
|
||||||
Train->play_sound( Train->dsbSwitch );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if( Train->ggPantFrontButtonOff.SubModel )
|
if( Train->ggPantFrontButtonOff.SubModel )
|
||||||
Train->ggPantFrontButtonOff.UpdateValue( 0.0, Train->dsbSwitch );
|
Train->ggPantFrontButtonOff.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
if( Train->ggPantSelectedDownButton.SubModel ) {
|
if( Train->ggPantSelectedDownButton.SubModel ) {
|
||||||
@@ -1455,10 +1509,19 @@ void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const &Command ) {
|
void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const &Command ) {
|
||||||
|
|
||||||
|
return (
|
||||||
|
Train->mvControlled->ActiveCab < 0 ?
|
||||||
|
pantographtogglefront( Train, Command ) :
|
||||||
|
pantographtogglerear( Train, Command ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void TTrain::pantographtogglerear( TTrain *Train, command_data const &Command ) {
|
||||||
|
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
||||||
if( false == Train->mvControlled->PantRearUp ) {
|
if( false == Train->mvControlled->PantRearUp ) {
|
||||||
@@ -1466,11 +1529,24 @@ void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const &
|
|||||||
Train->mvControlled->PantRearSP = false;
|
Train->mvControlled->PantRearSP = false;
|
||||||
if( Train->mvControlled->PantRear( true ) ) {
|
if( Train->mvControlled->PantRear( true ) ) {
|
||||||
if( Train->mvControlled->PantRearStart != 1 ) {
|
if( Train->mvControlled->PantRearStart != 1 ) {
|
||||||
#ifdef EU07_USE_OLD_CONTROLSOUNDS
|
|
||||||
// sound feedback
|
|
||||||
Train->play_sound( Train->dsbSwitch );
|
|
||||||
#endif
|
|
||||||
// visual feedback
|
// visual feedback
|
||||||
|
if( Train->mvControlled->ActiveCab < 0 ) {
|
||||||
|
// in rear cab switch functions are swapped
|
||||||
|
if( Train->ggPantFrontButton.SubModel )
|
||||||
|
Train->ggPantFrontButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||||
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
|
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
||||||
|
if( Train->ggPantSelectedButton.SubModel )
|
||||||
|
Train->ggPantSelectedButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||||
|
// pantograph control can have two-button setup
|
||||||
|
if( Train->ggPantFrontButtonOff.SubModel )
|
||||||
|
Train->ggPantFrontButtonOff.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
|
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
||||||
|
if( Train->ggPantSelectedDownButton.SubModel )
|
||||||
|
Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
|
}
|
||||||
|
else {
|
||||||
if( Train->ggPantRearButton.SubModel )
|
if( Train->ggPantRearButton.SubModel )
|
||||||
Train->ggPantRearButton.UpdateValue( 1.0, Train->dsbSwitch );
|
Train->ggPantRearButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
@@ -1487,9 +1563,21 @@ void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// ...or turn off
|
// ...or turn off
|
||||||
if( Train->mvOccupied->PantSwitchType == "impulse" ) {
|
if( Train->mvOccupied->PantSwitchType == "impulse" ) {
|
||||||
|
if( Train->mvControlled->ActiveCab < 0 ) {
|
||||||
|
// in rear cab switch functions are swapped
|
||||||
|
if( ( Train->ggPantFrontButtonOff.SubModel == nullptr )
|
||||||
|
&& ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) {
|
||||||
|
// with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it
|
||||||
|
// then another control has to be used (like pantographlowerall)
|
||||||
|
// TODO: we should have a way to define presense of cab controls without having to bind these to 3d submodels
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
if( ( Train->ggPantRearButtonOff.SubModel == nullptr )
|
if( ( Train->ggPantRearButtonOff.SubModel == nullptr )
|
||||||
&& ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) {
|
&& ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) {
|
||||||
// with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it
|
// with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it
|
||||||
@@ -1498,15 +1586,29 @@ void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const &
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Train->mvControlled->PantRearSP = false;
|
Train->mvControlled->PantRearSP = false;
|
||||||
if( false == Train->mvControlled->PantRear( false ) ) {
|
if( false == Train->mvControlled->PantRear( false ) ) {
|
||||||
if( Train->mvControlled->PantRearStart != 0 ) {
|
if( Train->mvControlled->PantRearStart != 0 ) {
|
||||||
#ifdef EU07_USE_OLD_CONTROLSOUNDS
|
|
||||||
// sound feedback
|
|
||||||
Train->play_sound( Train->dsbSwitch );
|
|
||||||
#endif
|
|
||||||
// visual feedback
|
// visual feedback
|
||||||
|
if( Train->mvControlled->ActiveCab < 0 ) {
|
||||||
|
// in rear cab switch functions are swapped
|
||||||
|
if( Train->ggPantFrontButton.SubModel )
|
||||||
|
Train->ggPantFrontButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
|
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
||||||
|
if( Train->ggPantSelectedButton.SubModel )
|
||||||
|
Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
|
// pantograph control can have two-button setup
|
||||||
|
if( Train->ggPantFrontButtonOff.SubModel )
|
||||||
|
Train->ggPantFrontButtonOff.UpdateValue( 1.0, Train->dsbSwitch );
|
||||||
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
|
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
||||||
|
if( Train->ggPantSelectedDownButton.SubModel )
|
||||||
|
Train->ggPantSelectedDownButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||||
|
}
|
||||||
|
else {
|
||||||
if( Train->ggPantRearButton.SubModel )
|
if( Train->ggPantRearButton.SubModel )
|
||||||
Train->ggPantRearButton.UpdateValue( 0.0, Train->dsbSwitch );
|
Train->ggPantRearButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
@@ -1524,14 +1626,28 @@ void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if( Command.action == GLFW_RELEASE ) {
|
else if( Command.action == GLFW_RELEASE ) {
|
||||||
// impulse switches return automatically to neutral position
|
// impulse switches return automatically to neutral position
|
||||||
if( Train->mvOccupied->PantSwitchType == "impulse" ) {
|
if( Train->mvOccupied->PantSwitchType == "impulse" ) {
|
||||||
#ifdef EU07_USE_OLD_CONTROLSOUNDS
|
if( Train->mvControlled->ActiveCab < 0 ) {
|
||||||
if( Train->ggPantRearButton.GetValue() > 0.35 ) {
|
// in rear cab switch functions are swapped
|
||||||
Train->play_sound( Train->dsbSwitch );
|
if( Train->ggPantFrontButton.SubModel )
|
||||||
|
Train->ggPantFrontButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
|
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
||||||
|
if( Train->ggPantSelectedButton.SubModel )
|
||||||
|
Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
|
// also the switch off button, in cabs which have it
|
||||||
|
if( Train->ggPantFrontButtonOff.SubModel )
|
||||||
|
Train->ggPantFrontButtonOff.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
|
if( Train->ggPantSelectedDownButton.SubModel ) {
|
||||||
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
|
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
||||||
|
Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
else {
|
||||||
if( Train->ggPantRearButton.SubModel )
|
if( Train->ggPantRearButton.SubModel )
|
||||||
Train->ggPantRearButton.UpdateValue( 0.0, Train->dsbSwitch );
|
Train->ggPantRearButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
@@ -1539,11 +1655,6 @@ void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const &
|
|||||||
if( Train->ggPantSelectedButton.SubModel )
|
if( Train->ggPantSelectedButton.SubModel )
|
||||||
Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch );
|
Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
// also the switch off button, in cabs which have it
|
// also the switch off button, in cabs which have it
|
||||||
#ifdef EU07_USE_OLD_CONTROLSOUNDS
|
|
||||||
if( Train->ggPantRearButtonOff.GetValue() > 0.35 ) {
|
|
||||||
Train->play_sound( Train->dsbSwitch );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if( Train->ggPantRearButtonOff.SubModel )
|
if( Train->ggPantRearButtonOff.SubModel )
|
||||||
Train->ggPantRearButtonOff.UpdateValue( 0.0, Train->dsbSwitch );
|
Train->ggPantRearButtonOff.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
if( Train->ggPantSelectedDownButton.SubModel ) {
|
if( Train->ggPantSelectedDownButton.SubModel ) {
|
||||||
@@ -1553,6 +1664,7 @@ void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTrain::OnCommand_pantographcompressorvalvetoggle( TTrain *Train, command_data const &Command ) {
|
void TTrain::OnCommand_pantographcompressorvalvetoggle( TTrain *Train, command_data const &Command ) {
|
||||||
@@ -6329,12 +6441,21 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
|| ( mvControlled->ConverterFlag ) ) {
|
|| ( mvControlled->ConverterFlag ) ) {
|
||||||
if( ggPantAllDownButton.GetValue() == 0.0 ) {
|
if( ggPantAllDownButton.GetValue() == 0.0 ) {
|
||||||
// the 'lower all' button overrides state of switches, while active itself
|
// the 'lower all' button overrides state of switches, while active itself
|
||||||
|
// when in rear cab we treat switches as reversed, i.e. front controls physical rear
|
||||||
|
auto const frontpantographswitch = (
|
||||||
|
mvControlled->ActiveCab < 0 ?
|
||||||
|
ggPantRearButton.GetValue() >= 1.0 :
|
||||||
|
ggPantFrontButton.GetValue() >= 1.0 );
|
||||||
|
auto const rearpantographswitch = (
|
||||||
|
mvControlled->ActiveCab < 0 ?
|
||||||
|
ggPantFrontButton.GetValue() >= 1.0 :
|
||||||
|
ggPantRearButton.GetValue() >= 1.0 );
|
||||||
if( ( false == mvControlled->PantFrontUp )
|
if( ( false == mvControlled->PantFrontUp )
|
||||||
&& ( ggPantFrontButton.GetValue() >= 1.0 ) ) {
|
&& ( frontpantographswitch ) ) {
|
||||||
mvControlled->PantFront( true );
|
mvControlled->PantFront( true );
|
||||||
}
|
}
|
||||||
if( ( false == mvControlled->PantRearUp )
|
if( ( false == mvControlled->PantRearUp )
|
||||||
&& ( ggPantRearButton.GetValue() >= 1.0 ) ) {
|
&& ( rearpantographswitch ) ) {
|
||||||
mvControlled->PantRear( true );
|
mvControlled->PantRear( true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7205,42 +7326,50 @@ void TTrain::set_cab_controls() {
|
|||||||
}
|
}
|
||||||
// pantographs
|
// pantographs
|
||||||
if( mvOccupied->PantSwitchType != "impulse" ) {
|
if( mvOccupied->PantSwitchType != "impulse" ) {
|
||||||
|
auto const pantograph = (
|
||||||
|
mvControlled->ActiveCab < 0 ?
|
||||||
|
mvControlled->PantRearUp :
|
||||||
|
mvControlled->PantFrontUp );
|
||||||
ggPantFrontButton.PutValue(
|
ggPantFrontButton.PutValue(
|
||||||
( mvControlled->PantFrontUp ?
|
( pantograph ?
|
||||||
1.0 :
|
1.0 :
|
||||||
0.0 ) );
|
0.0 ) );
|
||||||
ggPantFrontButtonOff.PutValue(
|
ggPantFrontButtonOff.PutValue(
|
||||||
( mvControlled->PantFrontUp ?
|
( pantograph ?
|
||||||
0.0 :
|
0.0 :
|
||||||
1.0 ) );
|
1.0 ) );
|
||||||
// NOTE: currently we animate the selectable pantograph control for both pantographs
|
// NOTE: currently we animate the selectable pantograph control for both pantographs
|
||||||
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
||||||
ggPantSelectedButton.PutValue(
|
ggPantSelectedButton.PutValue(
|
||||||
( mvControlled->PantFrontUp ?
|
( pantograph ?
|
||||||
1.0 :
|
1.0 :
|
||||||
0.0 ) );
|
0.0 ) );
|
||||||
ggPantSelectedDownButton.PutValue(
|
ggPantSelectedDownButton.PutValue(
|
||||||
( mvControlled->PantFrontUp ?
|
( pantograph ?
|
||||||
0.0 :
|
0.0 :
|
||||||
1.0 ) );
|
1.0 ) );
|
||||||
}
|
}
|
||||||
if( mvOccupied->PantSwitchType != "impulse" ) {
|
if( mvOccupied->PantSwitchType != "impulse" ) {
|
||||||
|
auto const pantograph = (
|
||||||
|
mvControlled->ActiveCab < 0 ?
|
||||||
|
mvControlled->PantFrontUp :
|
||||||
|
mvControlled->PantRearUp );
|
||||||
ggPantRearButton.PutValue(
|
ggPantRearButton.PutValue(
|
||||||
( mvControlled->PantRearUp ?
|
( pantograph ?
|
||||||
1.0 :
|
1.0 :
|
||||||
0.0 ) );
|
0.0 ) );
|
||||||
ggPantRearButtonOff.PutValue(
|
ggPantRearButtonOff.PutValue(
|
||||||
( mvControlled->PantRearUp ?
|
( pantograph ?
|
||||||
0.0 :
|
0.0 :
|
||||||
1.0 ) );
|
1.0 ) );
|
||||||
// NOTE: currently we animate the selectable pantograph control for both pantographs
|
// NOTE: currently we animate the selectable pantograph control for both pantographs
|
||||||
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
||||||
ggPantSelectedButton.PutValue(
|
ggPantSelectedButton.PutValue(
|
||||||
( mvControlled->PantRearUp ?
|
( pantograph ?
|
||||||
1.0 :
|
1.0 :
|
||||||
0.0 ) );
|
0.0 ) );
|
||||||
ggPantSelectedDownButton.PutValue(
|
ggPantSelectedDownButton.PutValue(
|
||||||
( mvControlled->PantRearUp ?
|
( pantograph ?
|
||||||
0.0 :
|
0.0 :
|
||||||
1.0 ) );
|
1.0 ) );
|
||||||
}
|
}
|
||||||
|
|||||||
2
Train.h
2
Train.h
@@ -155,7 +155,9 @@ class TTrain
|
|||||||
static void OnCommand_pantographcompressorvalvetoggle( TTrain *Train, command_data const &Command );
|
static void OnCommand_pantographcompressorvalvetoggle( TTrain *Train, command_data const &Command );
|
||||||
static void OnCommand_pantographcompressoractivate( TTrain *Train, command_data const &Command );
|
static void OnCommand_pantographcompressoractivate( TTrain *Train, command_data const &Command );
|
||||||
static void OnCommand_pantographtogglefront( TTrain *Train, command_data const &Command );
|
static void OnCommand_pantographtogglefront( TTrain *Train, command_data const &Command );
|
||||||
|
static void pantographtogglefront( TTrain *Train, command_data const &Command );
|
||||||
static void OnCommand_pantographtogglerear( TTrain *Train, command_data const &Command );
|
static void OnCommand_pantographtogglerear( TTrain *Train, command_data const &Command );
|
||||||
|
static void pantographtogglerear( TTrain *Train, command_data const &Command );
|
||||||
static void OnCommand_pantographlowerall( TTrain *Train, command_data const &Command );
|
static void OnCommand_pantographlowerall( TTrain *Train, command_data const &Command );
|
||||||
static void OnCommand_linebreakertoggle( TTrain *Train, command_data const &Command );
|
static void OnCommand_linebreakertoggle( TTrain *Train, command_data const &Command );
|
||||||
static void OnCommand_convertertoggle( TTrain *Train, command_data const &Command );
|
static void OnCommand_convertertoggle( TTrain *Train, command_data const &Command );
|
||||||
|
|||||||
Reference in New Issue
Block a user