16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 12:49:18 +02:00

pantograph switch functionality swapped for the rear cab

This commit is contained in:
tmj-fstate
2017-07-27 18:24:58 +02:00
parent bb58156513
commit 9b4dc83a2d
3 changed files with 264 additions and 133 deletions

View File

@@ -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;
} }

393
Train.cpp
View File

@@ -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,60 +1376,99 @@ 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->ggPantFrontButton.SubModel ) if( Train->mvControlled->ActiveCab < 0 ) {
Train->ggPantFrontButton.UpdateValue( 1.0, Train->dsbSwitch ); if( Train->ggPantRearButton.SubModel )
// NOTE: currently we animate the selectable pantograph control based on standard key presses Train->ggPantRearButton.UpdateValue( 1.0, Train->dsbSwitch );
// TODO: implement actual selection control, and refactor handling this control setup in a separate method // NOTE: currently we animate the selectable pantograph control based on standard key presses
if( Train->ggPantSelectedButton.SubModel ) // TODO: implement actual selection control, and refactor handling this control setup in a separate method
Train->ggPantSelectedButton.UpdateValue( 1.0, Train->dsbSwitch ); if( Train->ggPantSelectedButton.SubModel )
// pantograph control can have two-button setup Train->ggPantSelectedButton.UpdateValue( 1.0, Train->dsbSwitch );
if( Train->ggPantFrontButtonOff.SubModel ) // pantograph control can have two-button setup
Train->ggPantFrontButtonOff.UpdateValue( 0.0, Train->dsbSwitch ); if( Train->ggPantRearButtonOff.SubModel )
// NOTE: currently we animate the selectable pantograph control based on standard key presses Train->ggPantRearButtonOff.UpdateValue( 0.0, Train->dsbSwitch );
// TODO: implement actual selection control, and refactor handling this control setup in a separate method // NOTE: currently we animate the selectable pantograph control based on standard key presses
if( Train->ggPantSelectedDownButton.SubModel ) // TODO: implement actual selection control, and refactor handling this control setup in a separate method
Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch ); if( Train->ggPantSelectedDownButton.SubModel )
Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch );
}
else {
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 { else {
// ...or turn off // ...or turn off
if( Train->mvOccupied->PantSwitchType == "impulse" ) { if( Train->mvOccupied->PantSwitchType == "impulse" ) {
if( ( Train->ggPantFrontButtonOff.SubModel == nullptr ) if( Train->mvControlled->ActiveCab < 0 ) {
&& ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) { if( ( Train->ggPantRearButtonOff.SubModel == nullptr )
// with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it && ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) {
// then another control has to be used (like pantographlowerall) // with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it
// TODO: we should have a way to define presense of cab controls without having to bind these to 3d submodels // then another control has to be used (like pantographlowerall)
return; // 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 )
&& ( 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;
}
} }
} }
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->ggPantFrontButton.SubModel ) if( Train->mvControlled->ActiveCab < 0 ) {
Train->ggPantFrontButton.UpdateValue( 0.0, Train->dsbSwitch ); // in rear cab switch functions are swapped
// NOTE: currently we animate the selectable pantograph control based on standard key presses if( Train->ggPantRearButton.SubModel )
// TODO: implement actual selection control, and refactor handling this control setup in a separate method Train->ggPantRearButton.UpdateValue( 0.0, Train->dsbSwitch );
if( Train->ggPantSelectedButton.SubModel ) // NOTE: currently we animate the selectable pantograph control based on standard key presses
Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch ); // TODO: implement actual selection control, and refactor handling this control setup in a separate method
// pantograph control can have two-button setup if( Train->ggPantSelectedButton.SubModel )
if( Train->ggPantFrontButtonOff.SubModel ) Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch );
Train->ggPantFrontButtonOff.UpdateValue( 1.0, Train->dsbSwitch ); // pantograph control can have two-button setup
// NOTE: currently we animate the selectable pantograph control based on standard key presses if( Train->ggPantRearButtonOff.SubModel )
// TODO: implement actual selection control, and refactor handling this control setup in a separate method Train->ggPantRearButtonOff.UpdateValue( 1.0, Train->dsbSwitch );
if( Train->ggPantSelectedDownButton.SubModel ) // NOTE: currently we animate the selectable pantograph control based on standard key presses
Train->ggPantSelectedDownButton.UpdateValue( 1.0, Train->dsbSwitch ); // 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 )
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 );
}
} }
} }
} }
@@ -1429,29 +1476,37 @@ 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 );
}
#endif
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
#ifdef EU07_USE_OLD_CONTROLSOUNDS
if( Train->ggPantFrontButtonOff.GetValue() > 0.35 ) {
Train->play_sound( Train->dsbSwitch );
}
#endif
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 // 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 // TODO: implement actual selection control, and refactor handling this control setup in a separate method
Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch ); 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 );
}
}
else {
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 );
}
} }
} }
} }
@@ -1459,6 +1514,14 @@ 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,60 +1529,100 @@ 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->ggPantRearButton.SubModel ) if( Train->mvControlled->ActiveCab < 0 ) {
Train->ggPantRearButton.UpdateValue( 1.0, Train->dsbSwitch ); // in rear cab switch functions are swapped
// NOTE: currently we animate the selectable pantograph control based on standard key presses if( Train->ggPantFrontButton.SubModel )
// TODO: implement actual selection control, and refactor handling this control setup in a separate method Train->ggPantFrontButton.UpdateValue( 1.0, Train->dsbSwitch );
if( Train->ggPantSelectedButton.SubModel ) // NOTE: currently we animate the selectable pantograph control based on standard key presses
Train->ggPantSelectedButton.UpdateValue( 1.0, Train->dsbSwitch ); // TODO: implement actual selection control, and refactor handling this control setup in a separate method
// pantograph control can have two-button setup if( Train->ggPantSelectedButton.SubModel )
if( Train->ggPantRearButtonOff.SubModel ) Train->ggPantSelectedButton.UpdateValue( 1.0, Train->dsbSwitch );
Train->ggPantRearButtonOff.UpdateValue( 0.0, Train->dsbSwitch ); // pantograph control can have two-button setup
// NOTE: currently we animate the selectable pantograph control based on standard key presses if( Train->ggPantFrontButtonOff.SubModel )
// TODO: implement actual selection control, and refactor handling this control setup in a separate method Train->ggPantFrontButtonOff.UpdateValue( 0.0, Train->dsbSwitch );
if( Train->ggPantSelectedDownButton.SubModel ) // NOTE: currently we animate the selectable pantograph control based on standard key presses
Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch ); // 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 )
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 { else {
// ...or turn off // ...or turn off
if( Train->mvOccupied->PantSwitchType == "impulse" ) { if( Train->mvOccupied->PantSwitchType == "impulse" ) {
if( ( Train->ggPantRearButtonOff.SubModel == nullptr ) if( Train->mvControlled->ActiveCab < 0 ) {
&& ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) { // in rear cab switch functions are swapped
// with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it if( ( Train->ggPantFrontButtonOff.SubModel == nullptr )
// then another control has to be used (like pantographlowerall) && ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) {
// TODO: we should have a way to define presense of cab controls without having to bind these to 3d submodels // with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it
return; // 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 )
&& ( 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;
}
} }
} }
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->ggPantRearButton.SubModel ) if( Train->mvControlled->ActiveCab < 0 ) {
Train->ggPantRearButton.UpdateValue( 0.0, Train->dsbSwitch ); // in rear cab switch functions are swapped
// NOTE: currently we animate the selectable pantograph control based on standard key presses if( Train->ggPantFrontButton.SubModel )
// TODO: implement actual selection control, and refactor handling this control setup in a separate method Train->ggPantFrontButton.UpdateValue( 0.0, Train->dsbSwitch );
if( Train->ggPantSelectedButton.SubModel ) // NOTE: currently we animate the selectable pantograph control based on standard key presses
Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch ); // TODO: implement actual selection control, and refactor handling this control setup in a separate method
// pantograph control can have two-button setup if( Train->ggPantSelectedButton.SubModel )
if( Train->ggPantRearButtonOff.SubModel ) Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch );
Train->ggPantRearButtonOff.UpdateValue( 1.0, Train->dsbSwitch ); // pantograph control can have two-button setup
// NOTE: currently we animate the selectable pantograph control based on standard key presses if( Train->ggPantFrontButtonOff.SubModel )
// TODO: implement actual selection control, and refactor handling this control setup in a separate method Train->ggPantFrontButtonOff.UpdateValue( 1.0, Train->dsbSwitch );
if( Train->ggPantSelectedDownButton.SubModel ) // NOTE: currently we animate the selectable pantograph control based on standard key presses
Train->ggPantSelectedDownButton.UpdateValue( 1.0, Train->dsbSwitch ); // 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 )
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 );
}
} }
} }
} }
@@ -1527,29 +1630,38 @@ 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 );
#endif
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 );
// 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 )
Train->ggPantRearButtonOff.UpdateValue( 0.0, Train->dsbSwitch );
if( Train->ggPantSelectedDownButton.SubModel ) {
// 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
// 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
Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch ); 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 );
}
}
else {
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 );
// 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 );
}
} }
} }
} }
@@ -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 ) );
} }

View File

@@ -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 );