Separate buttons for openning and closing pant valve

This commit is contained in:
2025-02-15 03:03:31 +01:00
parent f9d81b8afe
commit dd62a1529e
4 changed files with 64 additions and 8 deletions

View File

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

View File

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

View File

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

View File

@@ -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") },