mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
Reverser buttons
This commit is contained in:
73
Train.cpp
73
Train.cpp
@@ -1963,15 +1963,6 @@ void TTrain::OnCommand_reverserdecrease( TTrain *Train, command_data const &Comm
|
||||
|
||||
void TTrain::OnCommand_reverserforwardhigh( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
|
||||
OnCommand_reverserforward( Train, Command );
|
||||
OnCommand_reverserincrease( Train, Command );
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_reverserforward( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
|
||||
// HACK: master controller position isn't set in occupied vehicle in E(D)MUs
|
||||
@@ -1994,9 +1985,44 @@ void TTrain::OnCommand_reverserforward( TTrain *Train, command_data const &Comma
|
||||
Train->DynamicObject->Mechanik->DirectionChange();
|
||||
}
|
||||
}
|
||||
OnCommand_reverserincrease( Train, Command );
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_reverserforward( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
|
||||
// HACK: master controller position isn't set in occupied vehicle in E(D)MUs
|
||||
// so we do a manual check in relevant vehicle here
|
||||
if( false == Train->mvControlled->EIMDirectionChangeAllow() ) { return; }
|
||||
|
||||
// HACK: try to move the reverser one position back, in case it's set to "high forward"
|
||||
//OnCommand_reverserdecrease( Train, Command );
|
||||
// visual feedback
|
||||
Train->ggDirForwardButton.UpdateValue(1.0, Train->dsbSwitch);
|
||||
|
||||
if( Train->mvOccupied->DirActive == 0 ) {
|
||||
|
||||
while( ( Train->mvOccupied->DirActive < 1 )
|
||||
&& ( true == Train->mvOccupied->DirectionForward() ) ) {
|
||||
// all work is done in the header
|
||||
}
|
||||
// aktualizacja skrajnych pojazdów w składzie
|
||||
if( ( Train->mvOccupied->DirActive == 1 )
|
||||
&& ( Train->DynamicObject->Mechanik ) ) {
|
||||
|
||||
Train->DynamicObject->Mechanik->DirectionChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Command.action == GLFW_RELEASE) {
|
||||
// release
|
||||
// visual feedback
|
||||
Train->ggDirForwardButton.UpdateValue(0.0, Train->dsbSwitch);
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_reverserneutral( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
@@ -2004,7 +2030,8 @@ void TTrain::OnCommand_reverserneutral( TTrain *Train, command_data const &Comma
|
||||
// HACK: master controller position isn't set in occupied vehicle in E(D)MUs
|
||||
// so we do a manual check in relevant vehicle here
|
||||
if( false == Train->mvControlled->EIMDirectionChangeAllow() ) { return; }
|
||||
|
||||
// visual feedback
|
||||
Train->ggDirNeutralButton.UpdateValue(1.0, Train->dsbSwitch);
|
||||
while( ( Train->mvOccupied->DirActive < 0 )
|
||||
&& ( true == Train->mvOccupied->DirectionForward() ) ) {
|
||||
// all work is done in the header
|
||||
@@ -2014,6 +2041,11 @@ void TTrain::OnCommand_reverserneutral( TTrain *Train, command_data const &Comma
|
||||
// all work is done in the header
|
||||
}
|
||||
}
|
||||
else if (Command.action == GLFW_RELEASE) {
|
||||
// release
|
||||
// visual feedback
|
||||
Train->ggDirNeutralButton.UpdateValue(0.0, Train->dsbSwitch);
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_reverserbackward( TTrain *Train, command_data const &Command ) {
|
||||
@@ -2023,8 +2055,8 @@ void TTrain::OnCommand_reverserbackward( TTrain *Train, command_data const &Comm
|
||||
// HACK: master controller position isn't set in occupied vehicle in E(D)MUs
|
||||
// so we do a manual check in relevant vehicle here
|
||||
if( false == Train->mvControlled->EIMDirectionChangeAllow() ) { return; }
|
||||
|
||||
if( Train->mvOccupied->DirActive > -1 ) {
|
||||
Train->ggDirBackwardButton.UpdateValue(1.0, Train->dsbSwitch);
|
||||
if( Train->mvOccupied->DirActive == 0 ) {
|
||||
|
||||
while( ( Train->mvOccupied->DirActive > -1 )
|
||||
&& ( true == Train->mvOccupied->DirectionBackward() ) ) {
|
||||
@@ -2038,6 +2070,11 @@ void TTrain::OnCommand_reverserbackward( TTrain *Train, command_data const &Comm
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Command.action == GLFW_RELEASE) {
|
||||
// release
|
||||
// visual feedback
|
||||
Train->ggDirBackwardButton.UpdateValue(0.0, Train->dsbSwitch);
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_alerteracknowledge( TTrain *Train, command_data const &Command ) {
|
||||
@@ -5942,6 +5979,9 @@ bool TTrain::Update( double const Deltatime )
|
||||
}
|
||||
// helper variables
|
||||
m_doors = ( DynamicObject->Mechanik->IsAnyDoorOpen[ side::right ] || DynamicObject->Mechanik->IsAnyDoorOpen[ side::left ] );
|
||||
m_dirforward = ( mvControlled->DirActive > 0 );
|
||||
m_dirneutral = ( mvControlled->DirActive == 0 );
|
||||
m_dirbackward = ( mvControlled->DirActive <0 );
|
||||
|
||||
// check for received user commands
|
||||
// NOTE: this is a temporary arrangement, for the transition period from old command setup to the new one
|
||||
@@ -6901,6 +6941,9 @@ bool TTrain::Update( double const Deltatime )
|
||||
}
|
||||
ggLocalBrake.Update();
|
||||
}
|
||||
ggDirForwardButton.Update();
|
||||
ggDirNeutralButton.Update();
|
||||
ggDirBackwardButton.Update();
|
||||
ggAlarmChain.Update();
|
||||
ggBrakeProfileCtrl.Update();
|
||||
ggBrakeProfileG.Update();
|
||||
@@ -8269,6 +8312,9 @@ void TTrain::clear_cab_controls()
|
||||
ggScndCtrlButton.Clear();
|
||||
ggDistanceCounterButton.Clear();
|
||||
ggDirKey.Clear();
|
||||
ggDirForwardButton.Clear();
|
||||
ggDirNeutralButton.Clear();
|
||||
ggDirBackwardButton.Clear();
|
||||
ggBrakeCtrl.Clear();
|
||||
ggLocalBrake.Clear();
|
||||
ggAlarmChain.Clear();
|
||||
@@ -9120,6 +9166,9 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
{ "doorleftpermit_sw:", { ggDoorLeftPermitButton, &mvOccupied->Doors.instances[ ( cab_to_end() == end::front ? side::left : side::right ) ].open_permit } },
|
||||
{ "doorrightpermit_sw:", { ggDoorRightPermitButton, &mvOccupied->Doors.instances[ ( cab_to_end() == end::front ? side::right : side::left ) ].open_permit } },
|
||||
{ "dooralloff_sw:", { ggDoorAllOffButton, &m_doors } },
|
||||
{ "dirforward_bt:", { ggDirForwardButton, &m_dirforward } },
|
||||
{ "dirneutral_bt:", { ggDirNeutralButton, &m_dirneutral } },
|
||||
{ "dirbackward_bt:", { ggDirBackwardButton, &m_dirbackward } },
|
||||
};
|
||||
{
|
||||
auto const lookup { stategauges.find( Label ) };
|
||||
|
||||
6
Train.h
6
Train.h
@@ -465,6 +465,9 @@ public: // reszta może by?publiczna
|
||||
TGauge ggScndCtrl;
|
||||
TGauge ggScndCtrlButton;
|
||||
TGauge ggDirKey;
|
||||
TGauge ggDirForwardButton;
|
||||
TGauge ggDirNeutralButton;
|
||||
TGauge ggDirBackwardButton;
|
||||
TGauge ggBrakeCtrl;
|
||||
TGauge ggLocalBrake;
|
||||
TGauge ggAlarmChain;
|
||||
@@ -789,6 +792,9 @@ private:
|
||||
double m_brakehandlecp{ 0.0 };
|
||||
int m_pantselection{ 0 };
|
||||
bool m_doors{ false }; // helper, true if any door is open
|
||||
bool m_dirforward{ false }; // helper, true if direction set to forward
|
||||
bool m_dirneutral{ false }; // helper, true if direction set to neutral
|
||||
bool m_dirbackward{ false }; // helper, true if direction set to backward
|
||||
// ld substitute
|
||||
bool m_couplingdisconnect { false };
|
||||
|
||||
|
||||
@@ -530,6 +530,15 @@ drivermouse_input::default_bindings() {
|
||||
{ "dirkey:", {
|
||||
user_command::reverserincrease,
|
||||
user_command::reverserdecrease } },
|
||||
{ "dirforward_bt:", {
|
||||
user_command::reverserforward,
|
||||
user_command::none } },
|
||||
{ "dirneutral_bt:", {
|
||||
user_command::reverserneutral,
|
||||
user_command::none } },
|
||||
{ "dirbackward_bt:", {
|
||||
user_command::reverserbackward,
|
||||
user_command::none } },
|
||||
{ "brakectrl:", {
|
||||
user_command::trainbrakeset,
|
||||
user_command::none } },
|
||||
|
||||
@@ -101,6 +101,9 @@ init() {
|
||||
"tempomat (speed)",
|
||||
"distance counter",
|
||||
"reverser",
|
||||
"reverser forward",
|
||||
"reverser neutral",
|
||||
"reverser backward",
|
||||
"train brake",
|
||||
"independent brake",
|
||||
"manual brake",
|
||||
@@ -303,6 +306,9 @@ init() {
|
||||
"tempomat (predkosc)",
|
||||
"miernik odleglosci",
|
||||
"nastawnik kierunku",
|
||||
"kierunek naprzod",
|
||||
"kierunek neutralny",
|
||||
"kierunek wstecz",
|
||||
"hamulec zespolony",
|
||||
"hamulec pomocniczy",
|
||||
"hamulec reczny",
|
||||
@@ -458,6 +464,9 @@ init() {
|
||||
"speedbutton9:",
|
||||
"distancecounter_sw:",
|
||||
"dirkey:",
|
||||
"dirforward_bt:",
|
||||
"dirneutral_bt:",
|
||||
"dirbackward_bt:",
|
||||
"brakectrl:",
|
||||
"localbrake:",
|
||||
"manualbrake:",
|
||||
|
||||
Reference in New Issue
Block a user