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

Separate buttons for openning and closing pant valve

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

View File

@@ -2848,23 +2848,43 @@ void TTrain::change_pantograph_selection( int const Change ) {
void TTrain::OnCommand_pantographvalvesupdate( TTrain *Train, command_data const &Command ) { 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_REPEAT ) { return; }
if( Command.action == GLFW_PRESS ) { if( Command.action == GLFW_PRESS ) {
// implement action if (hasSeparateSwitches)
Train->update_pantograph_valves(); {
// visual feedback // implement action
Train->ggPantValvesButton.UpdateValue( 1.0, Train->dsbSwitch ); 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 ) { else if( Command.action == GLFW_RELEASE ) {
// visual feedback // visual feedback
// NOTE: pantvalves_sw: is a specialized button, with no toggle behavior support // 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 ) { 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_REPEAT ) { return; }
if( Command.action == GLFW_PRESS ) { if( Command.action == GLFW_PRESS ) {
@@ -2872,12 +2892,18 @@ void TTrain::OnCommand_pantographvalvesoff( TTrain *Train, command_data const &C
Train->mvOccupied->OperatePantographValve( end::front, operation_t::disable ); Train->mvOccupied->OperatePantographValve( end::front, operation_t::disable );
Train->mvOccupied->OperatePantographValve( end::rear, operation_t::disable ); Train->mvOccupied->OperatePantographValve( end::rear, operation_t::disable );
// visual feedback // 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 ) { else if( Command.action == GLFW_RELEASE ) {
// visual feedback // visual feedback
// NOTE: pantvalves_sw: is a specialized button, with no toggle behavior support // 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 );
} }
} }
@@ -8086,6 +8112,9 @@ bool TTrain::Update( double const Deltatime )
ggPantCompressorButton.Update(); ggPantCompressorButton.Update();
ggPantCompressorValve.Update(); ggPantCompressorValve.Update();
ggPantValvesOff.Update();
ggPantValvesUpdate.Update();
ggLightsButton.Update(); ggLightsButton.Update();
ggUpperLightButton.Update(); ggUpperLightButton.Update();
ggLeftLightButton.Update(); ggLeftLightButton.Update();
@@ -9579,6 +9608,10 @@ void TTrain::clear_cab_controls()
ggPantValvesButton.Clear(); ggPantValvesButton.Clear();
ggPantCompressorButton.Clear(); ggPantCompressorButton.Clear();
ggPantCompressorValve.Clear(); ggPantCompressorValve.Clear();
ggPantValvesOff.Clear();
ggPantValvesUpdate.Clear();
ggI1B.Clear(); ggI1B.Clear();
ggI2B.Clear(); ggI2B.Clear();
ggI3B.Clear(); ggI3B.Clear();
@@ -9730,6 +9763,16 @@ void TTrain::set_cab_controls( int const Cab ) {
ggModernLightDimSw.PutValue(mvOccupied->modernDimmerState - 1); 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 // motor connectors
ggStLinOffButton.PutValue( ggStLinOffButton.PutValue(
( mvControlled->StLinSwitchOff ? ( mvControlled->StLinSwitchOff ?
@@ -9788,6 +9831,7 @@ void TTrain::set_cab_controls( int const Cab ) {
0.f ) ); 0.f ) );
} }
ggPantValvesButton.PutValue( 0.5f ); ggPantValvesButton.PutValue( 0.5f );
// auxiliary compressor // auxiliary compressor
ggPantCompressorValve.PutValue( ggPantCompressorValve.PutValue(
mvControlled->bPantKurek3 ? mvControlled->bPantKurek3 ?
@@ -10172,7 +10216,7 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co
{ "i-cabactived:", btCabActived }, { "i-cabactived:", btCabActived },
{"i-aklvents:", btAKLVents}, {"i-aklvents:", btAKLVents},
{"i-compressorany:", btCompressors }, {"i-compressorany:", btCompressors },
{"i-edenabled", btEDenabled } {"i-edenabled", btEDenabled },
}; };
{ {
auto lookup = lights.find( Label ); auto lookup = lights.find( Label );
@@ -10404,6 +10448,8 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
{ "invertertoggle10_bt:", ggInverterToggleButtons[9] }, { "invertertoggle10_bt:", ggInverterToggleButtons[9] },
{ "invertertoggle11_bt:", ggInverterToggleButtons[10] }, { "invertertoggle11_bt:", ggInverterToggleButtons[10] },
{ "invertertoggle12_bt:", ggInverterToggleButtons[11] }, { "invertertoggle12_bt:", ggInverterToggleButtons[11] },
{"pantvalvesupdate_bt:", ggPantValvesUpdate},
{"pantvalvesoff_bt:", ggPantValvesOff}
}; };
{ {
auto const lookup { gauges.find( Label ) }; auto const lookup { gauges.find( Label ) };

View File

@@ -663,6 +663,8 @@ public: // reszta może by?publiczna
TGauge ggPantValvesButton; TGauge ggPantValvesButton;
TGauge ggPantCompressorButton; TGauge ggPantCompressorButton;
TGauge ggPantCompressorValve; TGauge ggPantCompressorValve;
TGauge ggPantValvesUpdate;
TGauge ggPantValvesOff;
// Winger 020304 - wlacznik ogrzewania // Winger 020304 - wlacznik ogrzewania
TGauge ggTrainHeatingButton; TGauge ggTrainHeatingButton;
TGauge ggSignallingButton; TGauge ggSignallingButton;

View File

@@ -854,6 +854,12 @@ drivermouse_input::default_bindings() {
{ "pantvalves_sw:", { { "pantvalves_sw:", {
user_command::pantographvalvesupdate, user_command::pantographvalvesupdate,
user_command::pantographvalvesoff } }, user_command::pantographvalvesoff } },
{ "pantvalvesupdate_bt:", {
user_command::pantographvalvesupdate,
user_command::none}},
{ "pantvalvesoff_bt:", {
user_command::pantographvalvesoff,
user_command::none}},
{ "pantcompressor_sw:", { { "pantcompressor_sw:", {
user_command::pantographcompressoractivate, user_command::pantographcompressoractivate,
user_command::none } }, user_command::none } },

View File

@@ -283,6 +283,8 @@ std::string locale::label_cab_control(std::string const &Label)
{ "pantselectedoff_sw:", STRN("selected pantograph") }, { "pantselectedoff_sw:", STRN("selected pantograph") },
{ "pantselect_sw:", STRN("selected pantograph") }, { "pantselect_sw:", STRN("selected pantograph") },
{ "pantvalves_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") }, { "pantcompressor_sw:", STRN("pantograph compressor") },
{ "pantcompressorvalve_sw:", STRN("pantograph 3 way valve") }, { "pantcompressorvalve_sw:", STRN("pantograph 3 way valve") },
{ "trainheating_sw:", STRN("heating") }, { "trainheating_sw:", STRN("heating") },