diff --git a/Train.cpp b/Train.cpp index e5bbb9f0..6dc6beb0 100644 --- a/Train.cpp +++ b/Train.cpp @@ -2818,23 +2818,43 @@ void TTrain::change_pantograph_selection( int const Change ) { void TTrain::OnCommand_pantographvalvesupdate( TTrain *Train, command_data const &Command ) { + bool hasSeparateSwitches = Train->m_controlmapper.contains("pantvalvesupdate_bt:") && + Train->m_controlmapper.contains("pantvalvesoff_bt:"); + if( Command.action == GLFW_REPEAT ) { return; } if( Command.action == GLFW_PRESS ) { - // implement action - Train->update_pantograph_valves(); - // visual feedback - Train->ggPantValvesButton.UpdateValue( 1.0, Train->dsbSwitch ); + if (hasSeparateSwitches) + { + // implement action + Train->update_pantograph_valves(); + // visual feedback + Train->ggPantValvesUpdate.UpdateValue(1.0, Train->dsbSwitch); + } + + // Old logic to maintain compatibility + else + { + Train->update_pantograph_valves(); + Train->ggPantValvesButton.UpdateValue(1.0, Train->dsbSwitch); + } } else if( Command.action == GLFW_RELEASE ) { // visual feedback // NOTE: pantvalves_sw: is a specialized button, with no toggle behavior support - Train->ggPantValvesButton.UpdateValue( 0.5, Train->dsbSwitch ); + if (hasSeparateSwitches) + Train->ggPantValvesUpdate.UpdateValue(0.5, Train->dsbSwitch); + + // Old logic to maintain compatibility + else + Train->ggPantValvesButton.UpdateValue(0.5, Train->dsbSwitch); } } void TTrain::OnCommand_pantographvalvesoff( TTrain *Train, command_data const &Command ) { + bool hasSeparateSwitches = Train->m_controlmapper.contains("pantvalvesupdate_bt:") && Train->m_controlmapper.contains("pantvalvesoff_bt:"); + if( Command.action == GLFW_REPEAT ) { return; } if( Command.action == GLFW_PRESS ) { @@ -2842,12 +2862,18 @@ void TTrain::OnCommand_pantographvalvesoff( TTrain *Train, command_data const &C Train->mvOccupied->OperatePantographValve( end::front, operation_t::disable ); Train->mvOccupied->OperatePantographValve( end::rear, operation_t::disable ); // visual feedback - Train->ggPantValvesButton.UpdateValue( 0.0, Train->dsbSwitch ); + if (hasSeparateSwitches) + Train->ggPantValvesOff.UpdateValue(1.0, Train->dsbSwitch); + else + Train->ggPantValvesButton.UpdateValue( 0.0, Train->dsbSwitch ); } else if( Command.action == GLFW_RELEASE ) { // visual feedback // NOTE: pantvalves_sw: is a specialized button, with no toggle behavior support - Train->ggPantValvesButton.UpdateValue( 0.5, Train->dsbSwitch ); + if (hasSeparateSwitches) + Train->ggPantValvesOff.UpdateValue(0.f, Train->dsbSwitch); + else + Train->ggPantValvesButton.UpdateValue( 0.5, Train->dsbSwitch ); } } @@ -8062,6 +8088,9 @@ bool TTrain::Update( double const Deltatime ) ggPantCompressorButton.Update(); ggPantCompressorValve.Update(); + ggPantValvesOff.Update(); + ggPantValvesUpdate.Update(); + ggLightsButton.Update(); ggUpperLightButton.Update(); ggLeftLightButton.Update(); @@ -9544,6 +9573,10 @@ void TTrain::clear_cab_controls() ggPantValvesButton.Clear(); ggPantCompressorButton.Clear(); ggPantCompressorValve.Clear(); + + ggPantValvesOff.Clear(); + ggPantValvesUpdate.Clear(); + ggI1B.Clear(); ggI2B.Clear(); ggI3B.Clear(); @@ -9695,6 +9728,16 @@ void TTrain::set_cab_controls( int const Cab ) { ggModernLightDimSw.PutValue(mvOccupied->modernDimmerState - 1); } + // Init separate buttons + if (ggPantValvesUpdate.SubModel != nullptr) + { + ggPantValvesUpdate.PutValue(0.f); + } + if (ggPantValvesOff.SubModel != nullptr) + { + ggPantValvesOff.PutValue(0.f); + } + // motor connectors ggStLinOffButton.PutValue( ( mvControlled->StLinSwitchOff ? @@ -9753,6 +9796,7 @@ void TTrain::set_cab_controls( int const Cab ) { 0.f ) ); } ggPantValvesButton.PutValue( 0.5f ); + // auxiliary compressor ggPantCompressorValve.PutValue( mvControlled->bPantKurek3 ? @@ -10137,7 +10181,7 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co { "i-cabactived:", btCabActived }, {"i-aklvents:", btAKLVents}, {"i-compressorany:", btCompressors }, - {"i-edenabled", btEDenabled } + {"i-edenabled", btEDenabled }, }; { auto lookup = lights.find( Label ); @@ -10369,6 +10413,8 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con { "invertertoggle10_bt:", ggInverterToggleButtons[9] }, { "invertertoggle11_bt:", ggInverterToggleButtons[10] }, { "invertertoggle12_bt:", ggInverterToggleButtons[11] }, + {"pantvalvesupdate_bt:", ggPantValvesUpdate}, + {"pantvalvesoff_bt:", ggPantValvesOff} }; { auto const lookup { gauges.find( Label ) }; diff --git a/Train.h b/Train.h index 60eccb0b..8a27584b 100644 --- a/Train.h +++ b/Train.h @@ -661,6 +661,8 @@ public: // reszta może by?publiczna TGauge ggPantValvesButton; TGauge ggPantCompressorButton; TGauge ggPantCompressorValve; + TGauge ggPantValvesUpdate; + TGauge ggPantValvesOff; // Winger 020304 - wlacznik ogrzewania TGauge ggTrainHeatingButton; TGauge ggSignallingButton; diff --git a/drivermouseinput.cpp b/drivermouseinput.cpp index 4d6ae28d..a2f0f278 100644 --- a/drivermouseinput.cpp +++ b/drivermouseinput.cpp @@ -848,6 +848,12 @@ drivermouse_input::default_bindings() { { "pantvalves_sw:", { user_command::pantographvalvesupdate, user_command::pantographvalvesoff } }, + { "pantvalvesupdate_bt:", { + user_command::pantographvalvesupdate, + user_command::none}}, + { "pantvalvesoff_bt:", { + user_command::pantographvalvesoff, + user_command::none}}, { "pantcompressor_sw:", { user_command::pantographcompressoractivate, user_command::none } }, diff --git a/translation.cpp b/translation.cpp index 74a4e35a..65638988 100644 --- a/translation.cpp +++ b/translation.cpp @@ -283,6 +283,8 @@ std::string locale::label_cab_control(std::string const &Label) { "pantselectedoff_sw:", STRN("selected pantograph") }, { "pantselect_sw:", STRN("selected pantograph") }, { "pantvalves_sw:", STRN("selected pantograph") }, + { "pantvalvesoff_bt:", STRN("all pantographs down") }, + { "pantvalvesupdate_bt:", STRN("selected pantographs up") }, { "pantcompressor_sw:", STRN("pantograph compressor") }, { "pantcompressorvalve_sw:", STRN("pantograph 3 way valve") }, { "trainheating_sw:", STRN("heating") },